wrong_submission_id
stringlengths 10
10
| problem_id
stringlengths 6
6
| user_id
stringlengths 10
10
| time_limit
float64 1k
8k
| memory_limit
float64 131k
1.05M
| wrong_status
stringclasses 2
values | wrong_cpu_time
float64 10
40k
| wrong_memory
float64 2.94k
3.37M
| wrong_code_size
int64 1
15.5k
| problem_description
stringlengths 1
4.75k
| wrong_code
stringlengths 1
6.92k
| acc_submission_id
stringlengths 10
10
| acc_status
stringclasses 1
value | acc_cpu_time
float64 10
27.8k
| acc_memory
float64 2.94k
960k
| acc_code_size
int64 19
14.9k
| acc_code
stringlengths 19
14.9k
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s398558795
|
p04043
|
u326775883
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 168 |
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
A = 5
B = 5
C = 7
if A==5 and B==5 and C==7:
print('Yes')
elif A==5 and B==7 and C==5:
print('Yes')
elif A==7 and B==5 and C==5:
print('Yes')
else:
print('No')
|
s606286407
|
Accepted
| 17 | 2,940 | 111 |
n = list(map(int, input().split()))
if n.count(5) == 2 and n.count(7) == 1:
print("YES")
else:
print("NO")
|
s828131832
|
p03067
|
u243963816
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 124 |
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.
|
#!/usr/bin/python
# coding: UTF-8
a, b, c = map(int,input().split())
if a < c < b:
print("yes")
else:
print("no")
|
s504478849
|
Accepted
| 17 | 2,940 | 157 |
#!/usr/bin/python
a, b, c = map(int,input().split())
if a <= c and c <= b:
print("Yes")
elif b <= c and c <= a:
print("Yes")
else:
print("No")
|
s068124191
|
p03416
|
u634046173
| 2,000 | 262,144 |
Wrong Answer
| 93 | 9,176 | 154 |
Find the number of _palindromic numbers_ among the integers between A and B (inclusive). Here, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward.
|
A,B = map(int,input().split())
c = 0
for i in range(A,B+1):
s = str(i)
for j in range(len(s)//2):
if s[j] == s[(j+1)*-1]:
c+=1
print(c)
|
s057435450
|
Accepted
| 87 | 9,040 | 202 |
A,B = map(int,input().split())
c = 0
for i in range(A,B+1):
s = str(i)
k = True
for j in range(len(s)//2):
if s[j] != s[(j+1)*-1]:
k = False
break
if k:
c+=1
print(c)
|
s539260602
|
p00710
|
u659034691
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,600 | 237 |
There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. There is a deck of _n_ cards. Starting from the _p_ -th card from the top of the deck, _c_ cards are pulled out and put on the top of the deck, as shown in Figure 1. This operation, called a cutting operation, is repeated. Write a program that simulates Hanafuda shuffling and answers which card will be finally placed on the top of the deck. --- Figure 1: Cutting operation
|
#hanafuda
N,r=(int(i) for i in input().split())
H=[int(i) for i in range(N)]
for i in range(N):
p,c=(int(i) for i in input().split())
T=[]
for j in range(p,p+c-1):
T.append(H[p])
H.pop(p)
H=T+H
print(H[0])
|
s447003674
|
Accepted
| 90 | 7,616 | 385 |
#hanafuda
N,r=(int(i) for i in input().split())
while N!=0 or r!=0:
H=[int(N-i) for i in range(N)]
for i in range(r):
p,c=(int(i) for i in input().split())
T=[]
# print(H)
for j in range(p-1,p+c-1):
# print("T")
T.append(H[p-1])
H.pop(p-1)
H=T+H
print(H[0])
N,r=(int(i) for i in input().split())
|
s236639094
|
p03067
|
u820052258
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 95 |
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.
|
m = list(map(int,input().split()))
if m[0]<=m[2]<=m[1]:
print('yes')
else:
print('No')
|
s467628320
|
Accepted
| 17 | 3,060 | 131 |
m = list(map(int,input().split()))
if m[0]<m[2]<m[1]:
print('Yes')
elif m[1]<m[2]<m[0]:
print('Yes')
else:
print('No')
|
s857311025
|
p02276
|
u269568674
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,600 | 269 |
Quick sort is based on the Divide-and-conquer approach. In QuickSort(A, p, r), first, a procedure Partition(A, p, r) divides an array A[p..r] into two subarrays A[p..q-1] and A[q+1..r] such that each element of A[p..q-1] is less than or equal to A[q], which is, inturn, less than or equal to each element of A[q+1..r]. It also computes the index q. In the conquer processes, the two subarrays A[p..q-1] and A[q+1..r] are sorted by recursive calls of QuickSort(A, p, q-1) and QuickSort(A, q+1, r). Your task is to read a sequence A and perform the Partition based on the following pseudocode: Partition(A, p, r) 1 x = A[r] 2 i = p-1 3 for j = p to r-1 4 do if A[j] <= x 5 then i = i+1 6 exchange A[i] and A[j] 7 exchange A[i+1] and A[r] 8 return i+1 Note that, in this algorithm, Partition always selects an element A[r] as a pivot element around which to partition the array A[p..r].
|
n = int(input())
l = list(map(int,input().split()))
last = l[-1]
half1 = []
half2 = []
j = 0
for i in range(n-1):
if l[j] > last:
half2.append(l[j])
else:
half1.append(l[j])
l.pop(j)
print(*half1,end = ' ')
print(l,end = ' ')
print(*half2)
|
s062336864
|
Accepted
| 80 | 16,388 | 322 |
def partition(a, p, r):
x = a[r]
i = p - 1
for j in range(p, r):
if a[j] <= x:
i = i + 1
a[i], a[j] = a[j], a[i]
a[i + 1], a[r] = a[r], a[i + 1]
return(i + 1)
n = int(input())
l = list(map(int, input().split()))
i = partition(l, 0, n - 1)
l[i] = "[%d]"%l[i]
print(*l)
|
s124952831
|
p02928
|
u261260430
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 3,188 | 197 |
We have a sequence of N integers A~=~A_0,~A_1,~...,~A_{N - 1}. Let B be a sequence of K \times N integers obtained by concatenating K copies of A. For example, if A~=~1,~3,~2 and K~=~2, B~=~1,~3,~2,~1,~3,~2. Find the inversion number of B, modulo 10^9 + 7. Here the inversion number of B is defined as the number of ordered pairs of integers (i,~j)~(0 \leq i < j \leq K \times N - 1) such that B_i > B_j.
|
n,k = map(int, input().split())
*a, = map(int, input().split())
ans = 0
for i in range(n-1):
if a[i] > a[i+1]:
ans += 1
ans *= k
if a[-1] > a[0]:
ans += k-1
ans %= 10**9 + 7
print(ans)
|
s716315526
|
Accepted
| 1,065 | 3,188 | 308 |
n,k = map(int, input().split())
*a, = map(int, input().split())
ans = 0
wer = 0
for i in range(n-1):
for j in range(i+1, n):
if a[i] > a[j]:
ans += 1
ans *= k
for i in range(n):
for j in range(n):
if a[i] > a[j]:
wer += 1
wer *= k*(k-1)//2
ans += wer
ans %= 10**9 + 7
print(ans)
|
s760569184
|
p03371
|
u706159977
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 308 |
"Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.
|
a,b,c,x,y = [int(i) for i in input().split()]
if a>2*c and b>2*c:
m = max(x,y)*2*c
elif a>2*c:
if x>=y:
m = x*2*c
else:
m=x*2*c+(y-x)*b
elif b>2*c:
if y>=x:
m=y*2*c
else:
m=y*2*c +(x-y)*a
else:
m = x*a + y*b
print(m)
|
s875775001
|
Accepted
| 17 | 3,064 | 412 |
a,b,c,x,y = [int(i) for i in input().split()]
if a>2*c and b>2*c:
m = max(x,y)*2*c
elif a>2*c:
if x>=y:
m = x*2*c
else:
m=x*2*c+(y-x)*b
elif b>2*c:
if y>=x:
m=y*2*c
else:
m=y*2*c +(x-y)*a
elif a+b>2*c:
if x>=y:
d=a
else:
d=b
m = min(x,y)*2*c+(max(x,y)-min(x,y))*d
else:
m = x*a + y*b
print(m)
|
s912646413
|
p03470
|
u197300260
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 699 |
An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
|
# Python 2nd Try
import sys
# from collections import defaultdict
# import heapq,copy
# from collections import deque
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def solver(riceCakesList):
result = 0
print("LIST={}".format(riceCakesList))
# algorithm
result = len(set(riceCakesList))
return result
if __name__ == "__main__":
N = II()
DI = list()
for _ in range(N):
DI.append(II())
print("{}".format(solver(DI)))
|
s862627354
|
Accepted
| 21 | 3,316 | 691 |
# Python 3rd Try
import sys
from collections import Counter,deque
# import heapq,copy
# from collections import deque
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def solver(riseSetQue):
result = 0
riseCounter = Counter(riseSetQue)
result = len(riseCounter)
return result
if __name__ == "__main__":
N = II()
riceSet = deque()
for j in range(0, N, +1):
riceSet.append(II())
print("{}".format(solver(riceSet)))
|
s524727359
|
p03388
|
u881557500
| 2,000 | 262,144 |
Time Limit Exceeded
| 2,104 | 3,064 | 457 |
10^{10^{10}} participants, including Takahashi, competed in two programming contests. In each contest, all participants had distinct ranks from first through 10^{10^{10}}-th. The _score_ of a participant is the product of his/her ranks in the two contests. Process the following Q queries: * In the i-th query, you are given two positive integers A_i and B_i. Assuming that Takahashi was ranked A_i-th in the first contest and B_i-th in the second contest, find the maximum possible number of participants whose scores are smaller than Takahashi's.
|
q = int(input())
a = []
b = []
for i in range(q):
c = [int(i) for i in input().split()]
a += [c[0]]
b += [c[1]]
for i in range(q):
prod = a[i] * b[i]
cnt = 0
used = prod
for j in range(1, prod):
if j == a[i]:
continue
upper_limit = prod // j
for k in range(min(used - 1, upper_limit), 0, -1):
if k == b[i] or j * k >= prod:
continue
else:
used = k
cnt += 1
break
print(cnt)
|
s744329912
|
Accepted
| 18 | 3,064 | 459 |
import math
q = int(input())
a = []
b = []
for i in range(q):
c = [int(i) for i in input().split()]
a += [c[0]]
b += [c[1]]
for i in range(q):
prod = a[i] * b[i]
sqrt = int(math.sqrt(prod))
cnt = 2 * sqrt
if a[i] == b[i]:
cnt -= 2
else:
if sqrt * sqrt == prod:
cnt -= 2
elif prod // sqrt == sqrt:
cnt -= 1
elif prod // sqrt == sqrt + 1 and prod // sqrt * sqrt == prod:
cnt -= 1
cnt -= 1
print(cnt)
|
s079872878
|
p03910
|
u445624660
| 2,000 | 262,144 |
Wrong Answer
| 2,104 | 3,444 | 693 |
The problem set at _CODE FESTIVAL 20XX Finals_ consists of N problems. The score allocated to the i-th (1≦i≦N) problem is i points. Takahashi, a contestant, is trying to score exactly N points. For that, he is deciding which problems to solve. As problems with higher scores are harder, he wants to minimize the highest score of a problem among the ones solved by him. Determine the set of problems that should be solved.
|
n = int(input())
ans = []
cur = 0
while cur != n:
tmp = 0
for i in range(1, n + 1 - cur):
if i + tmp >= n + 1 - cur:
tmp = i
break
tmp += i
ans.append(tmp)
cur += tmp
# print(ans)
for a in ans:
print(a)
|
s439960031
|
Accepted
| 22 | 3,444 | 439 |
n = int(input())
cur = 0
target = 0
for i in range(1, n + 1):
if i + cur >= n:
target = i
break
cur += i
remove_num = sum([i for i in range(1, target + 1)]) - n
for i in range(1, target + 1):
if i != remove_num:
print(i)
|
s177336330
|
p02536
|
u401810884
| 2,000 | 1,048,576 |
Wrong Answer
| 2,206 | 11,192 | 347 |
There are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i. Snuke can perform the following operation zero or more times: * Choose two distinct cities that are not directly connected by a road, and build a new road between the two cities. After he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times). What is the minimum number of roads he must build to achieve the goal?
|
import math
N, M= map(int,input().split())
#AB=[]
#N = int(input())
#C = input()
C = []
for i in range(M):
A, B = map(int,input().split())
c = 0
for p in C:
if A in p:
c = 1
p.add(B)
elif B in p:
c = 1
p.add(A)
if c != 1:
C.append(set([A,B]))
print(len(C)-1)
|
s250861597
|
Accepted
| 286 | 12,928 | 1,173 |
import math
n, M= map(int,input().split())
#AB=[]
#N = int(input())
#C = input()
parents = [-1] * n
def find( x):
if parents[x] < 0:
return x
else:
parents[x] = find(parents[x])
return parents[x]
def union(x, y):
x = find(x)
y = find(y)
if x == y:
return
if parents[x] > parents[y]:
x, y = y, x
parents[x] += parents[y]
parents[y] = x
def size( x):
return -parents[find(x)]
def same( x, y):
return find(x) == find(y)
def members( x):
root = find(x)
return [i for i in range(n) if find(i) == root]
def roots():
return [i for i, x in enumerate(parents) if x < 0]
def group_count():
return len(roots())
def all_group_members():
return {r: members(r) for r in roots()}
def __str__():
return '\n'.join('{}: {}'.format(r, members(r)) for r in roots())
C = []
for i in range(M):
A, B = map(int,input().split())
union(A-1,B-1)
'''
c = 0
for p in C:
if A in p:
c = 1
p.add(B)
elif B in p:
c = 1
p.add(A)
if c != 1:
C.append(set([A,B]))
'''
print(group_count()-1)
|
s920690571
|
p02619
|
u912208257
| 2,000 | 1,048,576 |
Wrong Answer
| 60 | 9,296 | 492 |
Let's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.
|
D = int(input())
c = list(map(int,input().split()))
s = []
for i in range(D):
s.append(list(map(int,input().split())))
t = [int(input()) for _ in range(D)]
def my_index(l, x, default=False):
if x in l:
return l.index(x)
else:
return -1
def last(d,i):
a= t[:d]
reversed(a)
day = my_index(a,i)+1
return day
score = 0
for d in range(1,D+1):
score += s[d-1][t[d-1]-1]
for i in range(1,27):
score -= c[i-1]*(d-last(d,i))
print(score)
|
s646778562
|
Accepted
| 64 | 9,264 | 498 |
D = int(input())
c = list(map(int,input().split()))
s = []
for i in range(D):
s.append(list(map(int,input().split())))
t = [int(input()) for _ in range(D)]
def my_index(l,x,d,default=False):
if x in l:
return l.index(x)
else:
return d
def last(d,i):
a= t[:d]
a.reverse()
day = -1*(my_index(a,i,d))+d
return day
score = 0
for d in range(1,D+1):
score += s[d-1][t[d-1]-1]
for i in range(1,27):
score -= c[i-1]*(d-last(d,i))
print(score)
|
s353219612
|
p02678
|
u268210555
| 2,000 | 1,048,576 |
Wrong Answer
| 25 | 9,156 | 11 |
There is a cave. The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside. It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage. Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1. * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible. Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
|
print('No')
|
s219484958
|
Accepted
| 691 | 40,868 | 325 |
n, m = map(int, input().split())
g = [[] for _ in range(n+1)]
for _ in range(m):
a, b = map(int, input().split())
g[a].append(b)
g[b].append(a)
d = {1:0}
q = [1]
for i in q:
for j in g[i]:
if j not in d:
d[j] = i
q.append(j)
print('Yes')
for i in range(2, n+1):
print(d[i])
|
s633059640
|
p02742
|
u414050834
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 81 |
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds: * r_1 + c_1 = r_2 + c_2 * r_1 - c_1 = r_2 - c_2 For example, in the following figure, the bishop can move to any of the red squares in one move:
|
h,w=map(int,input().split())
if (h*w)%2==0:
print(h*w/2)
else:
print(h*w/2+1)
|
s283460095
|
Accepted
| 17 | 2,940 | 120 |
h,w=map(int,input().split())
if h==1 or w==1:
print(1)
elif (h*w)%2==0:
print(round(h*w/2))
else:
print(h*w//2+1)
|
s138865555
|
p03997
|
u185331085
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 68 |
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
|
a = int(input())
b = int(input())
h = int(input())
print((a+b)*h/2)
|
s632008944
|
Accepted
| 17 | 2,940 | 74 |
a = int(input())
b = int(input())
h = int(input())
print(int((a+b)*h/2))
|
s215587837
|
p02390
|
u500257793
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,600 | 70 |
Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
|
S=int(input())
h=S/3600
m=S%3600/60
s=S%3600%60
print(f"{m}:{h}:{s}")
|
s534994720
|
Accepted
| 20 | 5,592 | 72 |
S=int(input())
h=S//3600
m=S%3600//60
s=S%3600%60
print(f"{h}:{m}:{s}")
|
s047787899
|
p04012
|
u771405286
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 124 |
Let w be a string consisting of lowercase letters. We will call w _beautiful_ if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful.
|
w = input()
retw = "YES"
for i in range(len(w)):
if w.count(w[i])%2 != 0:
retw = "NO"
break
print(retw)
|
s487123461
|
Accepted
| 18 | 2,940 | 124 |
w = input()
retw = "Yes"
for i in range(len(w)):
if w.count(w[i])%2 != 0:
retw = "No"
break
print(retw)
|
s248690838
|
p03502
|
u943004959
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 201 |
An integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10. Given an integer N, determine whether it is a Harshad number.
|
def solve():
S = input()
N = list(S)
N = [int(x) for x in N]
summation = sum(N)
if summation % int(S) == 0:
print("Yes")
else:
print("No")
solve()
|
s269526395
|
Accepted
| 17 | 2,940 | 202 |
def solve():
S = input()
N = list(S)
N = [int(x) for x in N]
summation = sum(N)
if int(S) % summation == 0:
print("Yes")
else:
print("No")
solve()
|
s175771983
|
p04043
|
u506085195
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 110 |
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
A, B, C = map(int, input().split())
if (A == 5) & (B == 7) & (C == 5):
print('YES')
else:
print('NO')
|
s942972471
|
Accepted
| 17 | 2,940 | 200 |
A, B, C = map(int, input().split())
if (A == 5 or A == 7) & (B == 5 or B == 7) & (C == 5 or C == 7):
if (A + B + C) == 17:
print('YES')
else:
print('NO')
else:
print('NO')
|
s864110963
|
p03545
|
u978510477
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 282 |
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
|
a, b, c, d = map(int, input())
pm = [1, -1]
op = ["+", "-"]
for i in range(2):
for j in range(2):
for k in range(2):
if a + pm[i]*b + pm[j]*c + pm[k]*d == 7:
ans = [op[i], op[j], op[k]]
break
print("".join(map(str, [a, ans[0], b, ans[1], c, ans[2], d])))
|
s557733794
|
Accepted
| 18 | 3,064 | 290 |
a, b, c, d = map(int, input())
pm = [1, -1]
op = ["+", "-"]
for i in range(2):
for j in range(2):
for k in range(2):
if a + pm[i]*b + pm[j]*c + pm[k]*d == 7:
ans = [op[i], op[j], op[k]]
break
print("".join(map(str, [a, ans[0], b, ans[1], c, ans[2], d, "=", 7])))
|
s189838559
|
p03352
|
u749770850
| 2,000 | 1,048,576 |
Wrong Answer
| 22 | 3,060 | 167 |
You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
|
x = int(input())
pre = 0
arr = []
for b in range(331,):
print(b)
for p in range(2,33):
if b ** p <= x:
arr.append(b**p)
print(max(arr))
|
s203901446
|
Accepted
| 17 | 2,940 | 174 |
x = int(input())
ans = 0
for i in range(1,33):
for j in range(2,10):
t = i**j
if t <= x:
ans = max(t,ans)
print(ans)
|
s925509496
|
p03624
|
u728120584
| 2,000 | 262,144 |
Wrong Answer
| 19 | 3,188 | 177 |
You are given a string S consisting of lowercase English letters. Find the lexicographically (alphabetically) smallest lowercase English letter that does not occur in S. If every lowercase English letter occurs in S, print `None` instead.
|
def check(S):
for i in range(97, 123):
if chr(i) not in S:
return chr(i)
return 'None'
if __name__ == "__main__":
S = set(input())
print(S)
print(check(S))
|
s234970553
|
Accepted
| 19 | 3,188 | 166 |
def check(S):
for i in range(97, 123):
if chr(i) not in S:
return chr(i)
return 'None'
if __name__ == "__main__":
S = set(input())
print(check(S))
|
s784240276
|
p04031
|
u731028462
| 2,000 | 262,144 |
Wrong Answer
| 277 | 17,800 | 82 |
Evi has N integers a_1,a_2,..,a_N. His objective is to have N equal **integers** by transforming some of them. He may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transforming each of them (See Sample 2). Find the minimum total cost to achieve his objective.
|
import numpy as np
n = int(input())
a = [int(input()) for i in range(n)]
print(n)
|
s986994133
|
Accepted
| 29 | 3,684 | 188 |
from functools import reduce
n = int(input())
arr = list(map(int, input().split()))
s = reduce(lambda sum,x: sum+x, arr)
h = round(s/n)
m = 0
for a in arr:
m += (a-h)**2
print(int(m))
|
s345860866
|
p03719
|
u958506960
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 90 |
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
|
a, b, c = map(int, input().split())
if a <= c <= b:
print('YES')
else:
print('NO')
|
s760548979
|
Accepted
| 17 | 2,940 | 90 |
a, b, c = map(int, input().split())
if a <= c <= b:
print('Yes')
else:
print('No')
|
s386528380
|
p02422
|
u921541953
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,616 | 445 |
Write a program which performs a sequence of commands to a given string $str$. The command is one of: * print a b: print from the a-th character to the b-th character of $str$ * reverse a b: reverse from the a-th character to the b-th character of $str$ * replace a b p: replace from the a-th character to the b-th character of $str$ with p Note that the indices of $str$ start with 0.
|
str, q = input(), int(input())
for i in range(q):
com = input().strip().split()
if com[0] == 'print':
print(str[int(com[1]):int(com[2])+1])
elif com[0] == 'reverse':
str = list(str)
str[int(com[1]):int(com[2])+1] = str[int(com[2]):int(com[1])-6:-1]
str = ''.join(str)
print(str)
elif com[0] == 'replace':
str = str.replace(str[int(com[1]):int(com[2])+1], com[3])
print(str)
|
s902881358
|
Accepted
| 20 | 7,708 | 449 |
str, q = input(), int(input())
for i in range(q):
com = input().strip().split()
if com[0] == 'print':
print(str[int(com[1]):int(com[2])+1])
elif com[0] == 'reverse':
str = list(str)
str[int(com[1]):int(com[2])+1] = str[int(com[2]):int(com[1])-len(str)-1:-1]
str = ''.join(str)
elif com[0] == 'replace':
str = list(str)
str[int(com[1]):int(com[2])+1] = com[3]
str = ''.join(str)
|
s891725634
|
p04044
|
u866124363
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 140 |
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds: * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i. * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m.
|
N, L = map(int, input().split())
S = []
for s in open(0).read().split():
S.append(s)
S.sort()
for s in S:
print(s, end='')
print()
|
s449187679
|
Accepted
| 17 | 3,060 | 132 |
N, L = map(int, input().split())
S = []
for i in range(N):
S.append(input())
S.sort()
for s in S:
print(s, end='')
print()
|
s735288186
|
p03861
|
u070423038
| 2,000 | 262,144 |
Wrong Answer
| 31 | 9,040 | 59 |
You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x?
|
a, b, x = map(int, input().split())
print(b//x-(a-1)//x, 0)
|
s076287891
|
Accepted
| 26 | 9,060 | 58 |
a,b,x=map(int,input().split())
print(max(b//x-(a-1)//x,0))
|
s278659251
|
p03433
|
u584459098
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 85 |
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
|
N=int(input())
A=int(input())
if N % 500 > A:
print("Yes")
else:
print("No")
|
s053511399
|
Accepted
| 17 | 2,940 | 86 |
N=int(input())
A=int(input())
if N % 500 <= A:
print("Yes")
else:
print("No")
|
s742947915
|
p03494
|
u842949311
| 2,000 | 262,144 |
Wrong Answer
| 26 | 9,148 | 187 |
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
|
l = list(map(int,input().split()))
cnt = 0
while True:
if len([i for i in l if i%2 == 1]) == 0:
cnt += 1
l = [int(s/2) for s in l]
else:
break
print(cnt)
|
s175847806
|
Accepted
| 30 | 9,116 | 199 |
n = input()
l = list(map(int,input().split()))
cnt = 0
while True:
if len([i for i in l if i%2 == 1]) == 0:
cnt += 1
l = [int(s/2) for s in l]
else:
break
print(cnt)
|
s831946673
|
p02678
|
u771210206
| 2,000 | 1,048,576 |
Wrong Answer
| 617 | 36,560 | 481 |
There is a cave. The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside. It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage. Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1. * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible. Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
|
from collections import deque
n,m = map(int, input().split())
graph = [[] for _ in range(n+1)]
for i in range (m):
a, b = map(int, input().split())
graph[a].append(b)
graph[b].append(a)
#print(graph)
dist = [-1] * (n+1)
dist[0] = 0
dist[1] = 0
d = deque()
d.append(1)
#print(d)
while d:
v = d.popleft()
for i in graph[v]:
if dist[i] != -1:
continue
dist[i] = dist[v] +1
d.append(i)
ans = dist[1:]
print(*ans, sep="\n")
|
s130161402
|
Accepted
| 633 | 36,300 | 522 |
from collections import deque
n,m = map(int, input().split())
graph = [[] for _ in range(n+1)]
for i in range (m):
a, b = map(int, input().split())
graph[a].append(b)
graph[b].append(a)
#print(graph)
dist = [-1]*2 + [0 for i in range (n-1)]
dist[1] = 0
d = deque([1])
#print(d)
while d:
v = d.popleft()
for i in graph[v]:
if dist[i] == 0:
dist[i] = v
d.append(i)
#print(i ," " ,dist[i], d)
print("Yes")
ans = dist[2:]
print(*ans, sep="\n")
|
s672040858
|
p03695
|
u668503853
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 640 |
In AtCoder, a person who has participated in a contest receives a _color_ , which corresponds to the person's rating as follows: * Rating 1-399 : gray * Rating 400-799 : brown * Rating 800-1199 : green * Rating 1200-1599 : cyan * Rating 1600-1999 : blue * Rating 2000-2399 : yellow * Rating 2400-2799 : orange * Rating 2800-3199 : red Other than the above, a person whose rating is 3200 or higher can freely pick his/her color, which can be one of the eight colors above or not. Currently, there are N users who have participated in a contest in AtCoder, and the i-th user has a rating of a_i. Find the minimum and maximum possible numbers of different colors of the users.
|
N=int(input())
A=list(map(int,input().split()))
gray=0
brown=0
green=0
light=0
blue=0
yellow=0
orange=0
red=0
god=0
for a in A:
if 1<=a and a<=399 and gray==0:
gray=1
elif 400<=a and a<=799 and brown==0:
brown=1
elif 800<=a and a<=1199 and green==0:
green=1
elif 1200<=a and a<=1599 and light==0:
light=1
elif 1600<=a and a<=1999 and blue==0:
blue=1
elif 2000<=a and a<=2399 and yellow==0:
yellow=1
elif 2400<=a and a<=2799 and orange==0:
orange=1
elif 2800<=a and a<=3199 and red==0:
red=1
elif a<=3200:
god+=1
mi=gray+brown+green+light+blue+yellow+orange+red
ma=mi+god
print(mi,ma)
|
s960770091
|
Accepted
| 18 | 2,940 | 144 |
N=int(input())
A=map(int,input().split())
c=0
s=set()
for a in A:
if a>=3200:
c+=1
else:
s.add(a//400)
print(max(1,len(s)),len(s)+c)
|
s974258568
|
p03160
|
u255673886
| 2,000 | 1,048,576 |
Wrong Answer
| 147 | 14,708 | 236 |
There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N.
|
n = int(input())
h = list(map(int,input().split()))
dp = [0]*n
dp[0] = 0
dp[1] = abs(h[1]-h[0])
for i in range(2,n):
a = dp[i-1] + abs(h[i]-h[i-1])
b = dp[i-2] + abs(h[i]-h[i-2])
dp[i] = min(a,b)
print(dp)
print(dp[n-1])
|
s749504715
|
Accepted
| 140 | 13,980 | 238 |
n = int(input())
h = list(map(int,input().split()))
dp = [0]*n
dp[0] = 0
dp[1] = abs(h[1]-h[0])
for i in range(2,n):
a = dp[i-1] + abs(h[i]-h[i-1])
b = dp[i-2] + abs(h[i]-h[i-2])
dp[i] = min(a,b)
# print(dp)
print(dp[n-1])
|
s184654153
|
p02406
|
u954630472
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,596 | 351 |
In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops. Note that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto. Write a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements. void call(int n){ int i = 1; CHECK_NUM: int x = i; if ( x % 3 == 0 ){ cout << " " << i; goto END_CHECK_NUM; } INCLUDE3: if ( x % 10 == 3 ){ cout << " " << i; goto END_CHECK_NUM; } x /= 10; if ( x ) goto INCLUDE3; END_CHECK_NUM: if ( ++i <= n ) goto CHECK_NUM; cout << endl; }
|
def call(n):
ans = []
for x in range(n + 1):
if x % 3 == 0:
ans.append(x)
continue
while x % 10 == 3:
ans.append(x)
x //= 10
print(" ".join(map(str, ans)))
if __name__ == '__main__':
from sys import stdin
n = int(stdin.readline().rstrip())
print(call(n))
|
s402521232
|
Accepted
| 20 | 6,104 | 414 |
def call(n):
ans = []
for i, x in enumerate(range(1, n + 1), 1):
if x % 3 == 0:
ans.append(i)
continue
while x:
if x % 10 == 3:
ans.append(i)
break
x //= 10
print(" " + " ".join(map(str, ans)))
if __name__ == '__main__':
from sys import stdin
n = int(stdin.readline().rstrip())
call(n)
|
s250596115
|
p03370
|
u775623741
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 113 |
Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
|
(N,X)=[int(i) for i in input().split()]
m=[0]*N
for i in range(N):
m[i]=int(input())
print(N+(X-sum(m))/min(m))
|
s670742928
|
Accepted
| 17 | 2,940 | 118 |
(N,X)=[int(i) for i in input().split()]
m=[0]*N
for i in range(N):
m[i]=int(input())
print(int(N+(X-sum(m))/min(m)))
|
s668508600
|
p03610
|
u311669106
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,192 | 20 |
You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
|
print(input()[1::2])
|
s381592707
|
Accepted
| 17 | 3,192 | 20 |
print(input()[0::2])
|
s540865245
|
p03409
|
u285443936
| 2,000 | 262,144 |
Wrong Answer
| 45 | 3,572 | 550 |
On a two-dimensional plane, there are N red points and N blue points. The coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i). A red point and a blue point can form a _friendly pair_ when, the x-coordinate of the red point is smaller than that of the blue point, and the y-coordinate of the red point is also smaller than that of the blue point. At most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs.
|
import sys
input = sys.stdin.readline
N = int(input())
R = []
B = []
ans = 0
for i in range(N):
a,b = map(int,input().split())
R.append((a,b))
for i in range(N):
c,d = map(int,input().split())
B.append((c,d))
R.sort(key=lambda x:x[0])
B.sort(key=lambda x:x[0])
H = []
l = 0
for i in range(N):
for j in range(l,N):
if R[j][0] > B[i][0]:
l = j
break
H.append(R[j])
H.sort(key=lambda x:x[1], reverse=True)
print(H)
for k in range(len(H)):
if H[k][1] < B[i][1]:
H.pop(k)
ans += 1
break
print(ans)
|
s834637361
|
Accepted
| 19 | 3,064 | 440 |
N = int(input())
red = []
blue = []
memo = [0]*N
ans = 0
for i in range(N):
a,b = map(int, input().split())
red.append((a,b))
for i in range(N):
c,d = map(int, input().split())
blue.append((c,d))
blue.sort()
red.sort(key=lambda x:x[1],reverse=True)
for i in range(N):
bx,by = blue[i]
for j in range(N):
rx,ry = red[j]
if memo[j] == 0 and rx<=bx and ry<=by:
memo[j] = 1
ans += 1
break
print(ans)
|
s910342482
|
p02613
|
u231954178
| 2,000 | 1,048,576 |
Wrong Answer
| 145 | 9,200 | 274 |
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
|
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
s = input()
if s == "AC":
ac += 1
elif s == "WA":
wa += 1
elif s == "TLE":
tle += 1
else:
re += 1
print(f"AC × {ac}\nWA × {wa}\nTLE × {tle}\nRE × {re}")
|
s539353188
|
Accepted
| 147 | 9,200 | 277 |
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
s = ""
for i in range(n):
s = input()
if s == "AC":
ac += 1
elif s == "WA":
wa += 1
elif s == "TLE":
tle += 1
else:
re += 1
print(f"AC x {ac}\nWA x {wa}\nTLE x {tle}\nRE x {re}")
|
s368371530
|
p03573
|
u338225045
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 66 |
You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
|
A, B, C = map( int, input().split() )
print( C if A == B else A )
|
s305806762
|
Accepted
| 18 | 2,940 | 108 |
A, B, C = map( int, input().split() )
if A == B: print( C )
elif B == C: print( A )
elif A == C: print( B )
|
s827286407
|
p03485
|
u689258494
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 68 |
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
|
import math
a,b = map(int,input().split())
print(math.ceil((a+b)%2))
|
s601171564
|
Accepted
| 17 | 2,940 | 68 |
import math
a,b = map(int,input().split())
print(math.ceil((a+b)/2))
|
s098826236
|
p03545
|
u239981649
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 391 |
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
|
a, b, c, d = map(int, list(input()))
Lis = ["+", "-"]
for k in range(8):
bi = list(map(int, bin(k).replace('b', '0')))
bi.reverse()
res = a+b if not bi[0] else a-b
res += c if not bi[1] else -c
res += d if not bi[2] else -d
if res == 7:
print(''.join([str(a), Lis[bi[0]], str(b), Lis[bi[1]],
str(c), Lis[bi[2]], str(d)]))
break
|
s640487452
|
Accepted
| 18 | 3,064 | 372 |
a, b, c, d = map(int, list(input()))
Lis = ["+", "-"]
for k in range(8):
bi = list(map(int, bin(k).replace('b', '0')))
bi.reverse()
res = a+b if not bi[0] else a-b
res += c if not bi[1] else -c
res += d if not bi[2] else -d
if res == 7:
print(str(a)+Lis[bi[0]]+str(b)+Lis[bi[1]] +
str(c)+Lis[bi[2]]+str(d)+"=7")
break
|
s842464180
|
p02678
|
u366886346
| 2,000 | 1,048,576 |
Wrong Answer
| 1,391 | 33,832 | 634 |
There is a cave. The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside. It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage. Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1. * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible. Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
|
n,m=map(int,input().split())
ans=[0]*n
num1=[[] for _ in range(n)]
def ap(num01,num02):
num1[num01-1].append(num02)
num1[num02-1].append(num01)
for i in range(m):
a,b=map(int,input().split())
ap(a,b)
queue=[1]
def apq(num01):
queue.append(num01)
def qp():
return queue.pop(0)
for i in range(n):
if len(queue)==0:
break
num=qp()
print(num)
for j in range(len(num1[num-1])):
if ans[num1[num-1][j]-1]==0:
apq(num1[num-1][j])
ans[num1[num-1][j]-1]=num
if ans.count(0)!=0:
print("No")
else:
print("Yes")
for i in range(1,n):
print(ans[i])
|
s040833065
|
Accepted
| 1,354 | 33,856 | 619 |
n,m=map(int,input().split())
ans=[0]*n
num1=[[] for _ in range(n)]
def ap(num01,num02):
num1[num01-1].append(num02)
num1[num02-1].append(num01)
for i in range(m):
a,b=map(int,input().split())
ap(a,b)
queue=[1]
def apq(num01):
queue.append(num01)
def qp():
return queue.pop(0)
for i in range(n):
if len(queue)==0:
break
num=qp()
for j in range(len(num1[num-1])):
if ans[num1[num-1][j]-1]==0:
apq(num1[num-1][j])
ans[num1[num-1][j]-1]=num
if ans.count(0)!=0:
print("No")
else:
print("Yes")
for i in range(1,n):
print(ans[i])
|
s144715047
|
p02410
|
u853619096
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,592 | 178 |
Write a program which reads a $ n \times m$ matrix $A$ and a $m \times 1$ vector $b$, and prints their product $Ab$. A column vector with m elements is represented by the following equation. \\[ b = \left( \begin{array}{c} b_1 \\\ b_2 \\\ : \\\ b_m \\\ \end{array} \right) \\] A $n \times m$ matrix with $m$ column vectors, each of which consists of $n$ elements, is represented by the following equation. \\[ A = \left( \begin{array}{cccc} a_{11} & a_{12} & ... & a_{1m} \\\ a_{21} & a_{22} & ... & a_{2m} \\\ : & : & : & : \\\ a_{n1} & a_{n2} & ... & a_{nm} \\\ \end{array} \right) \\] $i$-th element of a $m \times 1$ column vector $b$ is represented by $b_i$ ($i = 1, 2, ..., m$), and the element in $i$-th row and $j$-th column of a matrix $A$ is represented by $a_{ij}$ ($i = 1, 2, ..., n,$ $j = 1, 2, ..., m$). The product of a $n \times m$ matrix $A$ and a $m \times 1$ column vector $b$ is a $n \times 1$ column vector $c$, and $c_i$ is obtained by the following formula: \\[ c_i = \sum_{j=1}^m a_{ij}b_j = a_{i1}b_1 + a_{i2}b_2 + ... + a_{im}b_m \\]
|
n,m=map(int,input().split())
b=[list(map(int,input().split())) for i in range(n)]
c =[int(input()) for j in range(m)]
[print([sum(d*e for d,e in zip(b[i],c))]) for i in range(n)]
|
s792430659
|
Accepted
| 30 | 8,060 | 303 |
n,m=map(int,input().split())
a=[]
b=[]
z=[]
x=[]
for i in range(n):
a+=[[int(i) for i in input().split()]]
for i in range(m):
b+=[[int(i) for i in input().split()]]
for i in range(n):
for j in range(m):
z+=[a[i][j]*b[j][0]]
x+=[sum(z)]
z=[]
for i in range(n):
print(x[i])
|
s164513445
|
p03738
|
u371132735
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 129 |
You are given two positive integers A and B. Compare the magnitudes of these numbers.
|
# abc059_b.py
A = int(input())
B = int(input())
if A>B:
print('GRETER')
elif A==B:
print('EQUAL')
else:
print('LESS')
|
s963142255
|
Accepted
| 18 | 2,940 | 130 |
# abc059_b.py
A = int(input())
B = int(input())
if A>B:
print('GREATER')
elif A==B:
print('EQUAL')
else:
print('LESS')
|
s533327589
|
p03992
|
u373047809
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 38 |
This contest is `CODE FESTIVAL`. However, Mr. Takahashi always writes it `CODEFESTIVAL`, omitting the single space between `CODE` and `FESTIVAL`. So he has decided to make a program that puts the single space he omitted. You are given a string s with 12 letters. Output the string putting a single space between the first 4 letters and last 8 letters in the string s.
|
s = input()
print(s[:5] + " " + s[5:])
|
s780938064
|
Accepted
| 25 | 9,028 | 30 |
s = input()
print(s[:4],s[4:])
|
s309271957
|
p03024
|
u103146596
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 96 |
Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament. The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S consisting of `o` and `x`. If the i-th character in S is `o`, it means that Takahashi won the match on the i-th day; if that character is `x`, it means that Takahashi lost the match on the i-th day. Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` if there is no such possibility.
|
l = list(map(str, input().split()))
if(l.count("x") > 7):
print("YES")
else:
print("NO")
|
s981900650
|
Accepted
| 17 | 2,940 | 158 |
lll = str(input())
l = list(lll)
if(l.count("o")>7):
print("YES")
elif(l.count("x") <= 7 and l.count("o") <= 8 ):
print("YES")
else:
print("NO")
|
s800889899
|
p03963
|
u936985471
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 49 |
There are N balls placed in a row. AtCoDeer the deer is painting each of these in one of the K colors of his paint cans. For aesthetic reasons, any two adjacent balls must be painted in different colors. Find the number of the possible ways to paint the balls.
|
n,k=map(int,input().split())
print((k-1)**(n-1))
|
s198084072
|
Accepted
| 17 | 2,940 | 53 |
N,K=map(int,input().split())
print(K*((K-1)**(N-1)))
|
s828318407
|
p02613
|
u524534026
| 2,000 | 1,048,576 |
Wrong Answer
| 150 | 9,212 | 353 |
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
|
import sys
n=int(input())
AC=0
WA=0
TLE=0
RE=0
for i in range(n):
moji=input()
if moji =='AC':
AC+=1
elif moji =='WA':
WA+=1
elif moji =='TLE':
TLE+=1
else:
RE+=1
A=[AC,WA,TLE,RE]
B=['AC','WA','TLE','RE']
for i in range(4):
q=A[i]
print(B[i],end='')
print(' × ',end='')
print(q)
|
s032557720
|
Accepted
| 155 | 9,212 | 352 |
import sys
n=int(input())
AC=0
WA=0
TLE=0
RE=0
for i in range(n):
moji=input()
if moji =='AC':
AC+=1
elif moji =='WA':
WA+=1
elif moji =='TLE':
TLE+=1
else:
RE+=1
A=[AC,WA,TLE,RE]
B=['AC','WA','TLE','RE']
for i in range(4):
q=A[i]
print(B[i],end='')
print(' x ',end='')
print(q)
|
s017733383
|
p02742
|
u496966444
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 106 |
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds: * r_1 + c_1 = r_2 + c_2 * r_1 - c_1 = r_2 - c_2 For example, in the following figure, the bishop can move to any of the red squares in one move:
|
h, w = map(int, input().split())
if h * w % 2 == 0:
print(h * w / 2)
else:
print((h * w)//2 + 1)
|
s155418348
|
Accepted
| 17 | 2,940 | 104 |
h, w = map(int, input().split())
if h == 1 or w == 1:
print(1)
exit()
print((h * w + 1) // 2)
|
s604727345
|
p03161
|
u561992253
| 2,000 | 1,048,576 |
Wrong Answer
| 2,104 | 14,776 | 408 |
There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to one of the following: Stone i + 1, i + 2, \ldots, i + K. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N.
|
n,k = map(int,input().split())
h = list(map(int,input().split()))
dp = [0] * (n)
dp[0] = 0
dp[1] = abs(h[1] - h[0])
for i in range(2,n):
minp = dp[i-1] + abs(h[i]-h[i-1])
for j in range(1,k+1):
if i - j < 0:
break;
#print(i,j,minp,dp[i-j] + abs(h[i]-h[i-j]))
minp = min(minp,
dp[i-j] + abs(h[i]-h[i-j]))
dp[i] = minp
print(dp)
print(dp[n-1])
|
s487097343
|
Accepted
| 1,786 | 22,804 | 331 |
import sys
import numpy as np
n,k = map(int,input().split())
h = np.array(list(map(int,sys.stdin.readline().split())))
dp = np.zeros(n, dtype=int)
dp[0] = 0
for i in range(1,n):
x = max(i-k, 0)
dp[i] = (dp[x:i] + abs(h[i] - h[x:i])).min()
print(dp[-1])
|
s748870108
|
p03556
|
u074220993
| 2,000 | 262,144 |
Wrong Answer
| 30 | 9,052 | 79 |
Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer.
|
N = int(input())
from math import floor, sqrt
ans = floor(sqrt(N))
print(ans)
|
s589322555
|
Accepted
| 38 | 9,164 | 122 |
N = int(input())
from math import sqrt, floor
for i in range(1,floor(sqrt(N))+2):
if i**2 > N:
print((i-1)**2)
|
s527306907
|
p02853
|
u654240084
| 2,000 | 1,048,576 |
Wrong Answer
| 29 | 9,200 | 203 |
We held two competitions: Coding Contest and Robot Maneuver. In each competition, the contestants taking the 3-rd, 2-nd, and 1-st places receive 100000, 200000, and 300000 yen (the currency of Japan), respectively. Furthermore, a contestant taking the first place in both competitions receives an additional 400000 yen. DISCO-Kun took the X-th place in Coding Contest and the Y-th place in Robot Maneuver. Find the total amount of money he earned.
|
x, y = map(int, input().split())
ans = 0
if x == 3 or y == 3:
ans += 100000
if x == 2 or y == 2:
ans += 200000
if x == 1 or y == 1:
ans += 300000
if x == y == 1:
ans += 400000
print(ans)
|
s108832132
|
Accepted
| 26 | 9,116 | 258 |
def p(n):
if n == 1:
return 300000
elif n == 2:
return 200000
elif n == 3:
return 100000
else:
return 0
x, y = map(int, input().split())
ans = 0
if x == y == 1:
ans += 400000
ans += p(x) + p(y)
print(ans)
|
s379897076
|
p02690
|
u548765110
| 2,000 | 1,048,576 |
Wrong Answer
| 27 | 9,168 | 153 |
Give a pair of integers (A, B) such that A^5-B^5 = X. It is guaranteed that there exists such a pair for the given integer X.
|
N=int(input())
for i in range(-40,40):
for j in range(-40,40):
if pow(i,5)-pow(j,5)==N:
print(i,j)
break
else:
continue
break
|
s385971552
|
Accepted
| 798 | 9,164 | 160 |
N=int(input())
for i in range(800,-800,-1):
for j in range(-800,800):
if pow(i,5)-pow(j,5)==N:
print(i,j)
break
else:
continue
break
|
s333731849
|
p04043
|
u018597853
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 114 |
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
haiku = list(map(int,input().split()))
haiku.sort()
if haiku ==[5,5,7]:
print("Yes")
else:
print("No")
|
s419772773
|
Accepted
| 17 | 2,940 | 107 |
value = input()
if value.count("5") == 2 and value.count("7") == 1:
print("YES")
else:
print("NO")
|
s567740644
|
p04044
|
u061104093
| 2,000 | 262,144 |
Wrong Answer
| 19 | 3,060 | 106 |
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds: * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i. * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m.
|
n, l = map(int, input().split())
s = list()
for i in range(n):
s.append(input())
s = sorted(s)
print(s)
|
s237413652
|
Accepted
| 17 | 3,060 | 115 |
n, l = map(int, input().split())
s = list()
for i in range(n):
s.append(input())
s = sorted(s)
print(''.join(s))
|
s443601974
|
p03351
|
u775623741
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 127 |
Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either directly or indirectly. Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.
|
[a,b,c,d]=[int(i) for i in input().split()]
if abs(a-c)<d or abs(a-b)<d and abs(b-c)<d:
print("Yes")
else:
print("No")
|
s354789569
|
Accepted
| 17 | 2,940 | 130 |
[a,b,c,d]=[int(i) for i in input().split()]
if abs(a-c)<=d or abs(a-b)<=d and abs(b-c)<=d:
print("Yes")
else:
print("No")
|
s516636088
|
p03693
|
u924308178
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 78 |
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
|
r,g,b = map(str, input().split())
print(["Yes","No","No","No"][int(r+g+b)%4])
|
s779088104
|
Accepted
| 17 | 2,940 | 78 |
r,g,b = map(str, input().split())
print(["YES","NO","NO","NO"][int(r+g+b)%4])
|
s569547136
|
p03386
|
u207799478
| 2,000 | 262,144 |
Wrong Answer
| 27 | 3,832 | 721 |
Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.
|
import math
import string
def readints():
return list(map(int, input().split()))
def nCr(n, r):
return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))
def has_duplicates2(seq):
seen = []
for item in seq:
if not(item in seen):
seen.append(item)
return len(seq) != len(seen)
def divisor(n):
divisor = []
for i in range(1, n+1):
if n % i == 0:
divisor.append(i)
return divisor
# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
a, b, k = map(int, input().split())
l = []
for i in range(k):
if a+i <= b:
l.append(a+i)
if b-i >= a:
l.append(b-i)
# print(l)
print(sorted(set(l)))
|
s419933848
|
Accepted
| 25 | 3,832 | 761 |
import math
import string
def readints():
return list(map(int, input().split()))
def nCr(n, r):
return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))
def has_duplicates2(seq):
seen = []
for item in seq:
if not(item in seen):
seen.append(item)
return len(seq) != len(seen)
def divisor(n):
divisor = []
for i in range(1, n+1):
if n % i == 0:
divisor.append(i)
return divisor
# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
a, b, k = map(int, input().split())
l = []
for i in range(k):
if a+i <= b:
l.append(a+i)
if b-i >= a:
l.append(b-i)
# print(l)
ll = sorted(set(l))
for i in range(len(ll)):
print(ll[i])
|
s200292167
|
p03737
|
u164261323
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 53 |
You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words.
|
a,b,c = input().split()
print(a[0]+b[0]+c[0].upper())
|
s800094204
|
Accepted
| 17 | 2,940 | 55 |
a,b,c = input().split()
print((a[0]+b[0]+c[0]).upper())
|
s739057949
|
p03637
|
u065099501
| 2,000 | 262,144 |
Wrong Answer
| 63 | 20,040 | 283 |
We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective.
|
_=int(input())
a=list(map(int,input().split()))
r1=a.count(2)
r2=a.count(6)
r=r1+r2
for _ in range(r1):
a.remove(2)
for _ in range(r2):
a.remove(6)
cnt=0
if r%2!=0:
cnt-=1
for i in a:
if i%4==0:
cnt+=1
if cnt>=len(a)//2:
print('YES')
else:
print('NO')
|
s628887918
|
Accepted
| 62 | 20,000 | 303 |
_=int(input())
a=list(map(int,input().split()))
x,y,z=0,0,0
for i in a:
if i%4 == 0:
z+=1
elif i%2 == 0:
y+=1
else:
x+=1
if y:
if x <= z:
print('Yes')
else:
print('No')
else:
if x <= z+1:
print('Yes')
else:
print('No')
|
s211842405
|
p02612
|
u164957173
| 2,000 | 1,048,576 |
Wrong Answer
| 25 | 9,144 | 30 |
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
N = int(input())
print(N%1000)
|
s456146190
|
Accepted
| 29 | 9,160 | 105 |
N = int(input())
ans = 0
if N % 1000 == 0:
ans = 0
else:
ans = 1000 - (N % 1000)
print(ans)
|
s124748485
|
p02390
|
u435300817
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,572 | 138 |
Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
|
import time
t = int(input())
h = 0
m = 0
s = 0
t_str = time.gmtime(t)
h, m, s = t_str.tm_hour, t_str.tm_min, t_str.tm_sec
print(h, m, s)
|
s787829603
|
Accepted
| 30 | 7,692 | 160 |
import time
t = int(input())
h = 0
m = 0
s = 0
t_str = time.gmtime(t)
h, m, s = t_str.tm_hour, t_str.tm_min, t_str.tm_sec
print('{0}:{1}:{2}'.format(h, m, s))
|
s031728612
|
p03671
|
u636290142
| 2,000 | 262,144 |
Wrong Answer
| 152 | 12,488 | 175 |
Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
|
import numpy as np
bell_li = list(map(int, input().split()))
bell_np = np.array(bell_li)
bell_np_sorted = bell_np.argsort()[::-1]
print(bell_np_sorted[0] + bell_np_sorted[1])
|
s792941484
|
Accepted
| 153 | 12,492 | 187 |
import numpy as np
bell_li = list(map(int, input().split()))
bell_np = np.array(bell_li)
bell_np_sorted = bell_np.argsort()
print(bell_li[bell_np_sorted[0]] + bell_li[bell_np_sorted[1]])
|
s696698449
|
p03693
|
u629560745
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 92 |
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
|
r, g, b = map(int,input().split())
if r+g+b % 4 == 0:
print('YES')
else:
print('NO')
|
s473256073
|
Accepted
| 17 | 2,940 | 108 |
r, g, b = map(str,input().split())
num = int(r+g+b)
if num % 4 == 0:
print('YES')
else:
print('NO')
|
s780451936
|
p03729
|
u731368968
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 83 |
You are given three strings A, B and C. Check whether they form a _word chain_. More formally, determine whether both of the following are true: * The last character in A and the initial character in B are the same. * The last character in B and the initial character in C are the same. If both are true, print `YES`. Otherwise, print `NO`.
|
a, b, c = input().split()
print('Yes' if a[-1] == b[0] and b[-1] == c[0] else 'No')
|
s453715272
|
Accepted
| 17 | 2,940 | 83 |
a, b, c = input().split()
print('YES' if a[-1] == b[0] and b[-1] == c[0] else 'NO')
|
s297169751
|
p02741
|
u260068288
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 121 |
Print the K-th element of the following sequence of length 32: 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
|
list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(list[0])
|
s685266684
|
Accepted
| 17 | 3,060 | 136 |
list=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
n=int(input())
print(list[n-1])
|
s347039949
|
p03487
|
u222841610
| 2,000 | 262,144 |
Wrong Answer
| 109 | 18,676 | 224 |
You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a **good sequence**. Here, an sequence b is a **good sequence** when the following condition holds true: * For each element x in b, the value x occurs exactly x times in b. For example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not. Find the minimum number of elements that needs to be removed so that a will be a good sequence.
|
import collections
n = int(input())
a = list(map(int,input().split()))
count_delete = 0
count_dict = collections.Counter(a)
for k, v in count_dict.items():
if k != v:
count_delete += min(abs(k-v), v)
count_delete
|
s384290815
|
Accepted
| 86 | 18,676 | 292 |
import collections
n = int(input())
a = list(map(int,input().split()))
count_delete = 0
count_dict = collections.Counter(a)
for k, v in count_dict.items():
if k != v:
if k > v:
count_delete += v
else:
count_delete += min(v-k, v)
print(count_delete)
|
s390957921
|
p03456
|
u789417951
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 132 |
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
|
import math
a,b=map(str,input().split())
c=a+b
c=int(c)
print(c)
d=math.sqrt(c)
if d==int(d):
print('Yes')
else:
print('No')
|
s795146547
|
Accepted
| 17 | 2,940 | 123 |
import math
a,b=map(str,input().split())
c=a+b
c=int(c)
d=math.sqrt(c)
if d==int(d):
print('Yes')
else:
print('No')
|
s330053103
|
p03433
|
u393512980
| 2,000 | 262,144 |
Wrong Answer
| 21 | 2,940 | 137 |
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
|
n = int(input())
a = int(input())
ans = 0
for i in range(21):
for j in range(a + 1):
if 500 * i + j == n:
ans += 1
print(ans)
|
s685015789
|
Accepted
| 22 | 2,940 | 187 |
n = int(input())
a = int(input())
ans, flag = 0, False
for i in range(21):
for j in range(a + 1):
if 500 * i + j == n:
flag = True
if flag:
print("Yes")
else:
print("No")
|
s023054698
|
p03681
|
u175590965
| 2,000 | 262,144 |
Wrong Answer
| 134 | 4,136 | 263 |
Snuke has N dogs and M monkeys. He wants them to line up in a row. As a Japanese saying goes, these dogs and monkeys are on bad terms. _("ken'en no naka", literally "the relationship of dogs and monkeys", means a relationship of mutual hatred.)_ Snuke is trying to reconsile them, by arranging the animals so that there are neither two adjacent dogs nor two adjacent monkeys. How many such arrangements there are? Find the count modulo 10^9+7 (since animals cannot understand numbers larger than that). Here, dogs and monkeys are both distinguishable. Also, two arrangements that result from reversing each other are distinguished.
|
n,m = map(int,input().split())
if abs(n-m)>=2:
print(0)
elif abs(n-m) ==1:
x =max(n,m)
for i in range(1,min(n,m)+1):
x = x*i**2%(10**9+7)
print(x)
else:
x =2
for i in range(1,n+1):
x = x*i**2%(10**9+7)
print(x)
|
s836104995
|
Accepted
| 60 | 3,064 | 255 |
n,m = map(int,input().split())
if abs(n-m)>=2:
print(0)
elif abs(n-m) ==1:
x =max(n,m)
for i in range(1,min(n,m)+1):
x = x*i**2%(10**9+7)
print(x)
else:
x =2
for i in range(1,n+1):
x = x*i**2%(10**9+7)
print(x)
|
s125062399
|
p02659
|
u008022357
| 2,000 | 1,048,576 |
Wrong Answer
| 24 | 9,036 | 93 |
Compute A \times B, truncate its fractional part, and print the result as an integer.
|
import math
a, b = map(float,input().split())
ans = a * b
print(ans)
print(math.floor(ans))
|
s322526334
|
Accepted
| 21 | 9,000 | 105 |
import math
a, b = map(float,input().split())
a = int(a)
b = int(b*1000)
print(math.floor((a*b)//1000))
|
s352307190
|
p04043
|
u609773122
| 2,000 | 262,144 |
Wrong Answer
| 28 | 9,088 | 207 |
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
a,b,c = map(int,input().split())
if (a == 5 or a== 7):
if(b == 5 or b == 7):
if(c == 5 or c == 7):
if(a + b + c == 17):
print("YES")
print("NO")
|
s319325128
|
Accepted
| 29 | 9,036 | 331 |
a,b,c = map(int,input().split())
if (a == 5 or a== 7):
if(b == 5 or b == 7):
if(c == 5 or c == 7):
if(a + b + c == 17):
print("YES")
else:
print("NO")
else:
print("NO")
else:
print("NO")
else:
print("NO")
|
s206373386
|
p04043
|
u312482829
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 111 |
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
s = list(map(int, input().split()))
if s.count(5) == 2 and s.count(7) == 1:
print('Yes')
else:
print('No')
|
s259336416
|
Accepted
| 17 | 2,940 | 111 |
s = list(map(int, input().split()))
if s.count(5) == 2 and s.count(7) == 1:
print('YES')
else:
print('NO')
|
s932439505
|
p03671
|
u518556834
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 107 |
Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
|
s = input()
n = len(s)
while True:
s = s[:-2]
n -= 2
if s[:n//2] == s[n//2:]:
print(n)
break
|
s782047143
|
Accepted
| 17 | 2,940 | 60 |
a = list(map(int,input().split()))
a.sort()
print(a[0]+a[1])
|
s440709154
|
p02255
|
u923973323
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,672 | 450 |
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key A[j+1] = A[j] j-- A[j+1] = key Note that, indices for array elements are based on 0-origin. To illustrate the algorithms, your program should trace intermediate result for each step.
|
n = input()
data = [int(i) for i in input().split(' ')]
def insertion_sort(raw_list):
for i, v in enumerate(raw_list):
if i == 0:
continue
j = i - 1
while j >= 0 and v < raw_list[j]:
raw_list[j+1] = v
raw_list[j+1] = raw_list[j]
j -= 1
raw_list[j+1] = v
return raw_list
print(' '.join([str(i) for i in data]))
print(' '.join([str(i) for i in insertion_sort(data)]))
|
s392417038
|
Accepted
| 30 | 7,704 | 532 |
n = input()
data = [int(i) for i in input().split(' ')]
def insertion_sort(raw_list):
for i, v in enumerate(raw_list):
if i == 0:
continue
j = i - 1
while j >= 0 and v < raw_list[j]:
raw_list[j+1] = v
raw_list[j+1] = raw_list[j]
j -= 1
raw_list[j+1] = v
print(' '.join([str(i) for i in raw_list]))
return raw_list
print(' '.join([str(i) for i in data]))
insertion_sort(data)
|
s521953407
|
p03998
|
u113255362
| 2,000 | 262,144 |
Wrong Answer
| 30 | 9,140 | 400 |
Alice, Bob and Charlie are playing _Card Game for Three_ , as below: * At first, each of the three players has a deck consisting of some number of cards. Each card has a letter `a`, `b` or `c` written on it. The orders of the cards in the decks cannot be rearranged. * The players take turns. Alice goes first. * If the current player's deck contains at least one card, discard the top card in the deck. Then, the player whose name begins with the letter on the discarded card, takes the next turn. (For example, if the card says `a`, Alice takes the next turn.) * If the current player's deck is empty, the game ends and the current player wins the game. You are given the initial decks of the players. More specifically, you are given three strings S_A, S_B and S_C. The i-th (1≦i≦|S_A|) letter in S_A is the letter on the i-th card in Alice's initial deck. S_B and S_C describes Bob's and Charlie's initial decks in the same way. Determine the winner of the game.
|
A=input()
B=input()
C=input()
ListA=list(A)
ListB=list(B)
ListC=list(C)
pile = "a"
res = ""
for i in range(100):
if pile == "a":
pile = ListA.pop(0)
elif pile == "b":
pile = ListB.pop(0)
else:
pile = ListC.pop(0)
if len(ListA) == 0:
res = "A"
break
elif len(ListB) == 0:
res = "B"
break
elif len(ListC) == 0:
res = "C"
break
else:
pass
print(res)
|
s903299941
|
Accepted
| 29 | 9,052 | 448 |
A=input()
B=input()
C=input()
ListA=list(A)
ListB=list(B)
ListC=list(C)
pile = "a"
res = ""
for i in range(400):
if pile == "a":
pile = ListA.pop(0)
elif pile == "b":
pile = ListB.pop(0)
else:
pile = ListC.pop(0)
if len(ListA) == 0 and pile == "a":
res = "A"
break
elif len(ListB) == 0 and pile == "b":
res = "B"
break
elif len(ListC) == 0 and pile == "c":
res = "C"
break
else:
pass
print(res)
|
s403798790
|
p02866
|
u334928930
| 2,000 | 1,048,576 |
Wrong Answer
| 2,104 | 19,936 | 402 |
Given is an integer sequence D_1,...,D_N of N elements. Find the number, modulo 998244353, of trees with N vertices numbered 1 to N that satisfy the following condition: * For every integer i from 1 to N, the distance between Vertex 1 and Vertex i is D_i.
|
import collections
N=int(input())
D_list=[int(thing) for thing in input().split(" ")]
maxx=max(D_list)
if D_list[0] !=0:
print(0)
exit()
C=collections.Counter(D_list)
if C[0] != 1:
print(0)
exit()
ret=1
for i in range(0,maxx):
if maxx-i not in C:
print(0)
exit()
if maxx-i==0:
pass
else:
ret=ret*C[maxx-i-1]**C[maxx-i]
print(ret//998244353)
|
s835534263
|
Accepted
| 330 | 19,936 | 401 |
import collections
N=int(input())
D_list=[int(thing) for thing in input().split(" ")]
maxx=max(D_list)
if D_list[0] !=0:
print(0)
exit()
C=collections.Counter(D_list)
if C[0] != 1:
print(0)
exit()
ret=1
for i in range(0,maxx):
if maxx-i not in C:
print(0)
exit()
if maxx-i==0:
pass
else:
ret=ret*C[maxx-i-1]**C[maxx-i]
print(ret%998244353)
|
s571690818
|
p03997
|
u222138979
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 77 |
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
|
#045 a
a = int(input())
b = int(input())
h = int(input())
print(0.5*(a+b)*h)
|
s519932065
|
Accepted
| 17 | 2,940 | 82 |
#045 a
a = int(input())
b = int(input())
h = int(input())
print(int(0.5*(a+b)*h))
|
s714890921
|
p03387
|
u769870836
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 119 |
You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.
|
a,b,c=sorted(list(map(int,input().split())))
ans=c-b
if (c-a)%2==0:
print(ans+(c-a)//2)
else:
print(ans+(c-a)//2+2)
|
s302906997
|
Accepted
| 18 | 3,060 | 119 |
a,b,c=sorted(list(map(int,input().split())))
ans=c-b
if (b-a)%2==0:
print(ans+(b-a)//2)
else:
print(ans+(b-a)//2+2)
|
s005211888
|
p03386
|
u886112691
| 2,000 | 262,144 |
Wrong Answer
| 19 | 3,060 | 242 |
Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.
|
a,b,k=map(int,input().split())
atmp=a; btmp=b;
ans=set()
for i in range(1,k+1):
ans.add(atmp)
atmp+=1
if atmp>b:
break
for i in range(1,k+1):
ans.add(btmp)
btmp-=1
if btmp<a:
break
print(sorted(ans))
|
s586654675
|
Accepted
| 17 | 3,064 | 283 |
a,b,k=map(int,input().split())
atmp=a; btmp=b;
ans=set()
for i in range(1,k+1):
ans.add(atmp)
atmp+=1
if atmp>b:
break
for i in range(1,k+1):
ans.add(btmp)
btmp-=1
if btmp<a:
break
ans=sorted(ans)
for i in range(len(ans)):
print(ans[i])
|
s275975511
|
p03455
|
u298376876
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 100 |
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
a, b = map(int, input().split())
if a % 2 == 1 and b % 2 == 0:
print('odd')
else:
print('even')
|
s983285363
|
Accepted
| 17 | 2,940 | 101 |
a, b = map(int, input().split())
if a % 2 == 1 and b % 2 == 1:
print('Odd')
else:
print('Even')
|
s906060816
|
p03494
|
u292810930
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 246 |
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
|
N=int(input())
A=list(map(int, input().split()))
B=A[:]
i=0
while i < N:
if A[i] % 2 == 0:
A[i] = A[i]//2
print(A[i])
if i == N-1:
B = A[:]
i = -1
i =+ 1
else:
break
print(B)
|
s677035078
|
Accepted
| 20 | 3,060 | 224 |
N=int(input())
A=list(map(int, input().split()))
t=0
i=0
while i < N:
if A[i] % 2 == 0:
A[i] = A[i]//2
if i == N - 1:
t += 1
i = -1
i += 1
else:
break
print(t)
|
s397479587
|
p02283
|
u007270338
| 2,000 | 131,072 |
Wrong Answer
| 20 | 5,608 | 1,131 |
Search trees are data structures that support dynamic set operations including insert, search, delete and so on. Thus a search tree can be used both as a dictionary and as a priority queue. Binary search tree is one of fundamental search trees. The keys in a binary search tree are always stored in such a way as to satisfy the following binary search tree property: * Let $x$ be a node in a binary search tree. If $y$ is a node in the left subtree of $x$, then $y.key \leq x.key$. If $y$ is a node in the right subtree of $x$, then $x.key \leq y.key$. The following figure shows an example of the binary search tree. For example, keys of nodes which belong to the left sub-tree of the node containing 80 are less than or equal to 80, and keys of nodes which belong to the right sub-tree are more than or equal to 80. The binary search tree property allows us to print out all the keys in the tree in sorted order by an inorder tree walk. A binary search tree should be implemented in such a way that the binary search tree property continues to hold after modifications by insertions and deletions. A binary search tree can be represented by a linked data structure in which each node is an object. In addition to a key field and satellite data, each node contains fields _left_ , _right_ , and _p_ that point to the nodes corresponding to its left child, its right child, and its parent, respectively. To insert a new value $v$ into a binary search tree $T$, we can use the procedure insert as shown in the following pseudo code. The insert procedure is passed a node $z$ for which $z.key = v$, $z.left = NIL$, and $z.right = NIL$. The procedure modifies $T$ and some of the fields of $z$ in such a way that $z$ is inserted into an appropriate position in the tree. 1 insert(T, z) 2 y = NIL // parent of x 3 x = 'the root of T' 4 while x ≠ NIL 5 y = x // set the parent 6 if z.key < x.key 7 x = x.left // move to the left child 8 else 9 x = x.right // move to the right child 10 z.p = y 11 12 if y == NIL // T is empty 13 'the root of T' = z 14 else if z.key < y.key 15 y.left = z // z is the left child of y 16 else 17 y.right = z // z is the right child of y Write a program which performs the following operations to a binary search tree $T$. * insert $k$: Insert a node containing $k$ as key into $T$. * print: Print the keys of the binary search tree by inorder tree walk and preorder tree walk respectively. You should use the above pseudo code to implement the insert operation. $T$ is empty at the initial state.
|
#coding:utf-8
N = int(input())
trees = [list(input().split()) for i in range(N)]
class BinaryTree:
def __init__(self,key,p=None,l=None,r=None):
self.key = key
self.p = p
self.l = l
self.r = r
def Insert(root,z):
y = None
x = root
while x != None:
y = x
if z.key < x.key:
x = x.l
else:
x = x.r
z.p = y
if y == None:
root = z
elif z.key < y.key:
y.l = z
else:
y.r = z
return root
preList = []
def preOrder(root):
x = root
if x == None:
return
global preList
preList.append(x.key)
preOrder(x.l)
preOrder(x.r)
inList = []
def inOrder(root):
x = root
if x == None:
return
inOrder(x.l)
global inList
inList.append(x.key)
inOrder(x.r)
root = None
for data in trees:
if data[0] == "insert":
z = BinaryTree(data[1])
root = Insert(root,z)
inOrder(root)
inList = " ".join([str(num) for num in inList])
print(inList)
preOrder(root)
preList = " ".join([str(num) for num in preList])
print(preList)
|
s549163799
|
Accepted
| 7,440 | 147,952 | 1,196 |
#coding:utf-8
class MakeTree():
def __init__(self, key, p=None, l=None, r=None):
self.key = key
self.p = p
self.l = l
self.r = r
def Insert(root,value):
y = None
x = root
z = MakeTree(value)
while x != None:
y = x
if x.key > z.key:
x = x.l
else:
x = x.r
z.p = y
if y == None:
root = z
elif z.key < y.key:
y.l = z
else:
y.r = z
return root
def inParse(u):
if u == None:
return
inParse(u.l)
global inParseList
inParseList.append(u.key)
inParse(u.r)
def preParse(u):
if u == None:
return
global preParseList
preParseList.append(u.key)
preParse(u.l)
preParse(u.r)
root = None
n = int(input())
inParseList = []
preParseList = []
for i in range(n):
order = list(input().split())
if order[0] == "insert":
root = Insert(root, int(order[1]))
else:
inParse(root)
preParse(root)
print(" " + " ".join([str(i) for i in inParseList]))
print(" " + " ".join([str(i) for i in preParseList]))
preParseList = []
inParseList = []
|
s813088517
|
p03547
|
u018679195
| 2,000 | 262,144 |
Wrong Answer
| 20 | 3,188 | 486 |
In programming, hexadecimal notation is often used. In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters `A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12, 13, 14 and 15, respectively. In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`, `C`, `D`, `E` or `F`. When X and Y are seen as hexadecimal numbers, which is larger?
|
def main():
inputList = input().split()
firstChar = inputList[0]
secondChar = inputList[1]
firstNum = ord(firstChar)
secondNum = ord(secondChar)
if(firstNum > secondNum):
print(">")
print("%d>%d." % (firstNum-55, secondNum-55))
elif(firstNum < secondNum):
print("<")
print("%d<%d." % (firstNum-55, secondNum-55))
elif(firstNum == secondNum):
print("=")
print("%d=%d." % (firstNum-55, secondNum-55))
main()
|
s049136620
|
Accepted
| 18 | 3,060 | 474 |
def main():
while True:
try:
inputList = input().split()
firstChar = inputList[0]
secondChar = inputList[1]
firstNum = ord(firstChar)
secondNum = ord(secondChar)
if(firstNum > secondNum):
print(">")
elif(firstNum < secondNum):
print("<")
elif(firstNum == secondNum):
print("=")
except:
break
main()
|
s017164249
|
p03731
|
u616117610
| 2,000 | 262,144 |
Wrong Answer
| 136 | 25,200 | 145 |
In a public bath, there is a shower which emits water for T seconds when the switch is pushed. If the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds. Note that it does not mean that the shower emits water for T additional seconds. N people will push the switch while passing by the shower. The i-th person will push the switch t_i seconds after the first person pushes it. How long will the shower emit water in total?
|
n,k = map(int, input().split())
t = list(map(int, input().split()))
ans = 0
i_ = t[0]
for i in t[1:]:
ans += min(i-i_,k)
i_ = i
print(ans+i_)
|
s973140487
|
Accepted
| 136 | 25,200 | 145 |
n,k = map(int, input().split())
t = list(map(int, input().split()))
ans = 0
i_ = t[0]
for i in t[1:]:
ans += min(i-i_,k)
i_ = i
print(ans+k)
|
s426092412
|
p04043
|
u951289777
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 142 |
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
num_list = list(map(int, input().split()))
if (num_list.count(5) == 2) and (num_list.count(7) == 1):
print("Yes")
else:
print("No")
|
s861691466
|
Accepted
| 17 | 2,940 | 137 |
num_list = list(map(int, input().split()))
if num_list.count(5) == 2 and num_list.count(7) == 1:
print("YES")
else:
print("NO")
|
s268919425
|
p02743
|
u154473588
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 3,060 | 211 |
Does \sqrt{a} + \sqrt{b} < \sqrt{c} hold?
|
import math
inputs = list(map(int, (input().split())))
a = inputs[0]
b = inputs[1]
c = inputs[2]
aa = math.sqrt(a)
bb = math.sqrt(b)
cc = math.sqrt(c)
if (a + b < c):
print("Yes")
else:
print("No")
|
s553177007
|
Accepted
| 17 | 3,060 | 274 |
import math
inputs = list(map(int, (input().split())))
a = inputs[0]
b = inputs[1]
c = inputs[2]
# bb = math.sqrt(b)
# cc = math.sqrt(c)
if a + b >= c:
print("No")
exit(0)
if ((c - a - b)**2 > 4*a*b):
print("Yes")
else:
print("No")
|
s723819425
|
p03449
|
u354527070
| 2,000 | 262,144 |
Wrong Answer
| 29 | 9,208 | 420 |
We have a 2 \times N grid. We will denote the square at the i-th row and j-th column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j). You are initially in the top-left square, (1, 1). You will travel to the bottom-right square, (2, N), by repeatedly moving right or down. The square (i, j) contains A_{i, j} candies. You will collect all the candies you visit during the travel. The top-left and bottom-right squares also contain candies, and you will also collect them. At most how many candies can you collect when you choose the best way to travel?
|
n = int(input())
a = []
for i in range(2):
a.append(list(map(int, input().split(" "))))
print(a)
ans_l = []
for i in range(n):
ans = 0
f = False
for j in range(n):
if j == 0:
ans += a[0][0]
elif f:
ans += a[1][j]
else:
ans += a[0][j]
if i == j:
ans += a[1][j]
f = True
ans_l.append(ans)
print(max(ans_l))
|
s580224760
|
Accepted
| 32 | 9,208 | 411 |
n = int(input())
a = []
for i in range(2):
a.append(list(map(int, input().split(" "))))
ans_l = []
for i in range(n):
ans = 0
f = False
for j in range(n):
if j == 0:
ans += a[0][0]
elif f:
ans += a[1][j]
else:
ans += a[0][j]
if i == j:
ans += a[1][j]
f = True
ans_l.append(ans)
print(max(ans_l))
|
s649439940
|
p03609
|
u723583932
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 57 |
We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
|
#abc072 a
x,t=map(int,input().split())
print(max(t-x,0))
|
s798673883
|
Accepted
| 17 | 2,940 | 57 |
#abc072 a
x,t=map(int,input().split())
print(max(x-t,0))
|
s034038807
|
p03943
|
u217627525
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 92 |
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
|
a=list(map(int,input().split()))
if max(a)*2==sum(a):
print("YES")
else:
print("NO")
|
s823314573
|
Accepted
| 17 | 2,940 | 92 |
a=list(map(int,input().split()))
if max(a)*2==sum(a):
print("Yes")
else:
print("No")
|
s598196175
|
p03493
|
u339922532
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 54 |
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.
|
s = list(map(int, input().split()))
print(s.count(1))
|
s884944272
|
Accepted
| 17 | 2,940 | 31 |
s = input()
print(s.count("1"))
|
s282269048
|
p02261
|
u672822075
| 1,000 | 131,072 |
Wrong Answer
| 30 | 6,748 | 551 |
Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1. Your task is to write a program which sorts a given set of cards in ascending order by their values using the Bubble Sort algorithms and the Selection Sort algorithm respectively. These algorithms should be based on the following pseudocode: BubbleSort(C) 1 for i = 0 to C.length-1 2 for j = C.length-1 downto i+1 3 if C[j].value < C[j-1].value 4 swap C[j] and C[j-1] SelectionSort(C) 1 for i = 0 to C.length-1 2 mini = i 3 for j = i to C.length-1 4 if C[j].value < C[mini].value 5 mini = j 6 swap C[i] and C[mini] Note that, indices for array elements are based on 0-origin. For each algorithm, report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).
|
def bubble(c):
for i in range(len(c)):
for j in range(len(c)-1,i,-1):
if int(c[j][-1]) < int(c[j-1][-1]):
c[j],c[j-1] = c[j-1],c[j]
return c
def selection(c):
for i in range(len(c)):
mini = i
for j in range(i,len(c)):
if int(c[j][-1])<int(c[mini][-1]):
mini = j
c[i],c[mini]=c[mini],c[i]
return c
n = int(input())
card = list(map(str,input().split()))
card1 = card
bubble(card)
selection(card1)
print(" ".join(map(str,card)))
print("Stable")
print(" ".join(map(str,card1)))
print("Stable") if card==card1 else ("Not stable")
|
s964241830
|
Accepted
| 30 | 6,756 | 560 |
def bubble(c):
for i in range(len(c)):
for j in range(len(c)-1,i,-1):
if int(c[j][-1]) < int(c[j-1][-1]):
c[j],c[j-1] = c[j-1],c[j]
return c
def selection(c):
for i in range(len(c)):
mini = i
for j in range(i,len(c)):
if int(c[j][-1])<int(c[mini][-1]):
mini = j
c[i],c[mini]=c[mini],c[i]
return c
n = int(input())
card = list(map(str,input().split()))
card1 = card[:]
bubble(card)
selection(card1)
print(" ".join(map(str,card)))
print("Stable")
print(" ".join(map(str,card1)))
print("Stable") if card==card1 else print("Not stable")
|
s393314580
|
p02255
|
u408444038
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,596 | 243 |
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key A[j+1] = A[j] j-- A[j+1] = key Note that, indices for array elements are based on 0-origin. To illustrate the algorithms, your program should trace intermediate result for each step.
|
def Isort(a,n):
for i in range(1,n):
v = a[i]
j = i-1
while(j>=0 and a[j]>v):
a[j+1] = a[j]
j-=1
a[j+1] = v
print(*a)
n = int(input("n:"))
a = input().split()
Isort(a,n)
|
s327738564
|
Accepted
| 20 | 5,980 | 273 |
def Isort(a,n):
for i in range(1,n):
v = a[i]
j = i-1
while j>=0 and a[j]>v:
a[j+1] = a[j]
j-=1
a[j+1] = v
print(*a)
n = int(input())
a = list(map(int, input().split()))
print(*a)
Isort(a,n)
|
s869518593
|
p03160
|
u893270619
| 2,000 | 1,048,576 |
Wrong Answer
| 790 | 22,712 | 253 |
There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N.
|
import numpy as np
N = int(input())
h = list(map(int, input().split()))
dp = np.full(N, np.inf)
dp[0] = 0
for i in range(1,N):
dp[i] = min(dp[i],dp[i-1]+np.abs(h[i] - h[i-1]))
if i > 1: dp[i] = min(dp[i],dp[i-2]+np.abs(h[i] - h[i-2]))
print(dp[-1])
|
s857944685
|
Accepted
| 779 | 22,688 | 258 |
import numpy as np
N = int(input())
h = list(map(int, input().split()))
dp = np.full(N, np.inf)
dp[0] = 0
for i in range(1,N):
dp[i] = min(dp[i],dp[i-1]+np.abs(h[i] - h[i-1]))
if i > 1: dp[i] = min(dp[i],dp[i-2]+np.abs(h[i] - h[i-2]))
print(int(dp[-1]))
|
s664110656
|
p03962
|
u403986473
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 39 |
AtCoDeer the deer recently bought three paint cans. The color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c. Here, the color of each paint can is represented by an integer between 1 and 100, inclusive. Since he is forgetful, he might have bought more than one paint can in the same color. Count the number of different kinds of colors of these paint cans and tell him.
|
color = input().split()
len(set(color))
|
s564169136
|
Accepted
| 17 | 2,940 | 46 |
color = input().split()
print(len(set(color)))
|
s837091771
|
p03478
|
u548308904
| 2,000 | 262,144 |
Wrong Answer
| 47 | 3,628 | 400 |
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
|
inp = input().split()
max = int(inp[0])
mink = int(inp[1])
maxk = int(inp[2])
result = 0
print(max,maxk,mink)
for i in range(1,max+1):
sen = i // 1000
hyaku = i %1000 // 100
ju = i % 100 // 10
ichi = i % 10
keta = sen + hyaku + ju + ichi
print(keta)
if mink <= keta:
print('mink')
if maxk >= keta:
print('in',i)
result += i
print(result)
|
s028176270
|
Accepted
| 25 | 3,060 | 353 |
inp = input().split()
max = int(inp[0])
mink = int(inp[1])
maxk = int(inp[2])
result = 0
for i in range(1,max+1):
man = i // 10000
sen = i % 10000 // 1000
hyaku = i %1000 // 100
ju = i % 100 // 10
ichi = i % 10
keta = man + sen + hyaku + ju + ichi
if mink <= keta:
if maxk >= keta:
result += i
print(result)
|
s363948503
|
p03448
|
u125308199
| 2,000 | 262,144 |
Wrong Answer
| 53 | 3,060 | 353 |
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
|
A = int(input("A ="))
B = int(input("B ="))
C = int(input("C ="))
X = int(input("50の倍数X = "))
count = 0
for A in range(0,A+1):
for B in range(0,B+1):
for C in range(0,C+1):
price = A * 500 + B * 100 + C * 50
if price == X:
count += 1
else:
continue
print(count)
|
s148254243
|
Accepted
| 53 | 3,060 | 321 |
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for A in range(0,A+1):
for B in range(0,B+1):
for C in range(0,C+1):
price = A * 500 + B * 100 + C * 50
if price == X:
count += 1
else:
continue
print(count)
|
s455983192
|
p02841
|
u077291787
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 142 |
In this problem, a date is written as Y-M-D. For example, 2019-11-30 means November 30, 2019. Integers M_1, D_1, M_2, and D_2 will be given as input. It is known that the date 2019-M_2-D_2 follows 2019-M_1-D_1. Determine whether the date 2019-M_1-D_1 is the last day of a month.
|
# A - November 30
def main():
M1, _, M2, _ = map(int, open(0).read().split())
print(M1 != M2)
if __name__ == "__main__":
main()
|
s127846157
|
Accepted
| 18 | 2,940 | 147 |
# A - November 30
def main():
M1, _, M2, _ = map(int, open(0).read().split())
print(int(M1 != M2))
if __name__ == "__main__":
main()
|
s395503968
|
p03407
|
u616217092
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 196 |
An elementary school student Takahashi has come to a variety store. He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it? Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.
|
import sys
def main():
A, B, C = [int(x) for x in sys.stdin.readline().split()]
if A + B <= C:
print('Yes')
else:
print('No')
if __name__ == '__main__':
main()
|
s241212855
|
Accepted
| 17 | 2,940 | 196 |
import sys
def main():
A, B, C = [int(x) for x in sys.stdin.readline().split()]
if C <= A + B:
print('Yes')
else:
print('No')
if __name__ == '__main__':
main()
|
s330060476
|
p03472
|
u788703383
| 2,000 | 262,144 |
Wrong Answer
| 300 | 27,812 | 476 |
You are going out for a walk, when you suddenly encounter a monster. Fortunately, you have N katana (swords), Katana 1, Katana 2, …, Katana N, and can perform the following two kinds of attacks in any order: * Wield one of the katana you have. When you wield Katana i (1 ≤ i ≤ N), the monster receives a_i points of damage. The same katana can be wielded any number of times. * Throw one of the katana you have. When you throw Katana i (1 ≤ i ≤ N) at the monster, it receives b_i points of damage, and you lose the katana. That is, you can no longer wield or throw that katana. The monster will vanish when the total damage it has received is H points or more. At least how many attacks do you need in order to vanish it in total?
|
n,h = map(int,input().split())
l = []
x,y = 0,0
for _ in range(n):
a,b = map(int,input().split())
if a > x or a == x and b < y:
x,y = a,b
if b < x:continue
l.append((a,b))
l.remove((x,y))
l = sorted(l,key=lambda x:-x[1])
ans = 0
for a,b in l:
if a == x and b == y:continue
if x < b < y and y >= h:
print(ans+1);exit()
h -= max(b,x)
ans += 1
if h <= 0:
print(ans);exit()
r = (max(0,h - y)) // x
print(ans + r + 1)
|
s615282241
|
Accepted
| 255 | 18,188 | 275 |
import math
n,h = map(int,input().split())
A = 0; b = []; ans = 0
for _ in range(n):
u,v = map(int,input().split())
A = max(A,u); b.append(v)
for B in sorted(b,key=lambda x:-x):
if h <= 0 or B <= A:break
h -= B
ans += 1
print(max(0,math.ceil(h/A)) + ans)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.