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
s501014598
p03943
u578501242
2,000
262,144
Wrong Answer
17
2,940
104
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.
x=list(map(int, input().split())) x.sort() print(x) if x[0]+x[1]==x[2]: print('yes') else: print('no')
s237237214
Accepted
17
2,940
95
x=list(map(int, input().split())) x.sort() if x[0]+x[1]==x[2]: print('Yes') else: print('No')
s277288052
p02866
u327310087
2,000
1,048,576
Wrong Answer
40
14,396
92
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.
n = int(input()) d = list(map(int, input().split())) if d[0] != 0: print(0) quit()
s439182710
Accepted
199
21,888
598
n = int(input()) d = list(map(int, input().split())) # bucket lst = [[] for i in range(n)] ans = 1 sum = 1 P = 998244353 if d[0] != 0: print(0) quit() else: for i in range(n): if d[i] == 0 and i != 0: print(0) quit() lst[d[i]].append(i + 1) tmp = len(lst[1]) for i in range(1, n): if len(lst[i]) == 0: if sum != n: print(0) quit() sum += len(lst[i]) if i == 1: continue ans = (ans * tmp ** len(lst[i])) % P tmp = len(lst[i]) print(ans)
s834085633
p03730
u398182947
2,000
262,144
Wrong Answer
26
9,080
239
We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
A,B,C = map(int,input().split()) startR = A % B i = 1 while True: R = A*i % B if R == C: print("Yes") break if i != 1: if R == startR: print("No") break i += 1
s256535169
Accepted
27
9,124
224
A,B,C = map(int,input().split()) startR = A % B i = 1 while True: R = A*i % B if R == C: print("YES") break if i != 1: if R == startR: print("NO") break i += 1
s568509552
p03469
u533713111
2,000
262,144
Wrong Answer
17
2,940
38
On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in `yyyy/mm/dd` format. For example, January 23, 2018 should be written as `2018/01/23`. After finishing the document, she noticed that she had mistakenly wrote `2017` at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to `2018` and prints it.
S = input() print(S.replace(S[3],'8'))
s869726667
Accepted
17
2,940
36
S = input() print(S[:3] +'8'+ S[4:])
s222706112
p03494
u403875332
2,000
262,144
Wrong Answer
19
2,940
159
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())) while all([e % 2 == 0 for e in a]) == True: for i in range(N): a[i] = a[i]/2 print(a)
s468927885
Accepted
18
2,940
185
N = int(input()) a = list(map(int,input().split())) count=0 while all([e % 2 == 0 for e in a]) == True: count = count + 1 for i in range(N): a[i] = a[i]/2 print(count)
s372125198
p03455
u468430765
2,000
262,144
Wrong Answer
17
2,940
70
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()) print("Odd" if a*b%2 == 1 else "Odd")
s042179337
Accepted
17
2,940
71
a, b = map(int, input().split()) print("Odd" if a*b%2 == 1 else "Even")
s474412171
p03813
u601393594
2,000
262,144
Wrong Answer
21
9,072
4
Smeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200, and participate in AtCoder Regular Contest (ARC) otherwise. You are given Smeke's current rating, x. Print `ABC` if Smeke will participate in ABC, and print `ARC` otherwise.
2000
s944870154
Accepted
25
9,148
141
# AtCoder abc053 a x = int(input()) if x < 1200: print("ABC") else: print("ARC")
s240169390
p03140
u305452255
2,000
1,048,576
Wrong Answer
18
3,064
476
You are given three strings A, B and C. Each of these is a string of length N consisting of lowercase English letters. Our objective is to make all these three strings equal. For that, you can repeatedly perform the following operation: * Operation: Choose one of the strings A, B and C, and specify an integer i between 1 and N (inclusive). Change the i-th character from the beginning of the chosen string to some other lowercase English letter. What is the minimum number of operations required to achieve the objective?
n, a, b, c = [input() for i in range(4)] n = int(n) ret = 0 for i in range(n): if (a[i] == b[i]) and (a[i] == c[i]): pass elif (a[i] == b[i]) and (a[i] != c[i]): c = c[:i] + a[i] + c[i + 1:] ret += 1 elif a[i] == c[i] and a[i] != b[i]: b = b[:i] + a[i] + b[i + 1:] ret += 1 elif a[i] != b[i] and a[i] != c[i]: b = b[:i] + a[i] + b[i + 1:] c = c[:i] + a[i] + c[i + 1:] ret += 2 print(ret)
s132428479
Accepted
17
3,064
569
n, a, b, c = [input() for i in range(4)] n = int(n) ret = 0 for i in range(n): if (a[i] == b[i]) and (a[i] == c[i]): pass elif (a[i] == b[i]) and (a[i] != c[i]): c = c[:i] + a[i] + c[i + 1:] ret += 1 elif a[i] == c[i] and a[i] != b[i]: b = b[:i] + a[i] + b[i + 1:] ret += 1 elif a[i] != c[i] and b[i] == c[i]: a = a[:i] + b[i] + a[i + 1:] ret += 1 elif a[i] != b[i] and a[i] != c[i]: b = b[:i] + a[i] + b[i + 1:] c = c[:i] + a[i] + c[i + 1:] ret += 2 print(ret)
s281169038
p03730
u000349418
2,000
262,144
Wrong Answer
2,103
2,940
149
We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
a,b,c = map(int,input().split(' ')) x = a%b ans = 'No' i = 1 while i*x <= c: if i*x == c: ans = 'Yes' break i += 1 print(ans)
s664478787
Accepted
17
3,060
142
a,b,c = map(int,input().split(' ')) i = 1 ans = 'NO' while i < b: if (i*a)%b == c: ans = 'YES' break i += 1 print(ans)
s327340002
p00019
u116501200
1,000
131,072
Wrong Answer
30
8,204
84
Write a program which reads an integer n and prints the factorial of n. You can assume that n ≤ 20\.
(lambda n:__import__("functools").reduce(lambda a,b:a*b,range(1,n+1)))(int(input()))
s067137847
Accepted
30
8,192
91
print((lambda n:__import__("functools").reduce(lambda a,b:a*b,range(1,n+1)))(int(input())))
s959887641
p03371
u547167033
2,000
262,144
Wrong Answer
19
3,060
135
"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=map(int,input().split()) ans=[] ans.append(a*x+b*y) ans.append(c*x+b*max(0,y-x)) ans.append(c*y+a*max(0,x-y)) print(min(ans))
s587318088
Accepted
17
2,940
139
a,b,c,x,y=map(int,input().split()) ans=[] ans.append(a*x+b*y) ans.append(c*2*x+b*max(0,y-x)) ans.append(c*2*y+a*max(0,x-y)) print(min(ans))
s293080854
p03469
u198035503
2,000
262,144
Wrong Answer
17
2,940
33
On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in `yyyy/mm/dd` format. For example, January 23, 2018 should be written as `2018/01/23`. After finishing the document, she noticed that she had mistakenly wrote `2017` at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to `2018` and prints it.
s = input() print("2018" + s[3:])
s275129027
Accepted
17
2,940
34
s = input() print("2018" + s[4:])
s502326059
p03472
u785578220
2,000
262,144
Wrong Answer
19
3,064
602
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?
def get_input(inp): li = inp.split("\n") def inner(): return li.pop(0) return inner INPUT = """4 1000000000 1 1 1 10000000 1 30000000 1 99999999 """ input = get_input(INPUT) from heapq import heappush, heappop from operator import itemgetter N, K = map(int, input().split()) a = [] aa = [] for i in range(N): ta,tb = map(int, input().split()) a.append(ta) aa.append(tb) aa.append(0) aa.sort() b = max(a) n = K//b+1 res = 0 while K>0: t = aa.pop() if t > b: K -= t res+=1 else: res +=-(-K//b) K = 0 break print(res)
s348925053
Accepted
397
12,236
419
from heapq import heappush, heappop from operator import itemgetter N, K = map(int, input().split()) a = [] aa = [] for i in range(N): ta,tb = map(int, input().split()) a.append(ta) aa.append(tb) a = sorted(a) aa.append(0) aa.sort() b = max(a) n = K//b+1 res = 0 while K>0: t = aa.pop() if t > b: K -= t res+=1 else: res +=-(-K//b) K = 0 break print(res)
s142214535
p03471
u383551754
2,000
262,144
Wrong Answer
20
3,064
347
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these. According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.
n, y = map(int, input().split()) ichi = y // 10000 for i in reversed(range(ichi + 1)): gos = (y - 10000 * ichi) // 5000 for j in reversed(range(gos+1)): rest = y - 10000 * i - 5000 * j k = rest // 1000 if rest % 1000 == 0 and i + j + k == n: print(i, j, k) break else: print(-1, -1, -1)
s983474500
Accepted
716
2,940
253
n, y = map(int, input().split()) for i in reversed(range(n + 1)): for j in reversed(range(n - i + 1)): k = n - i - j if 10000 * i + 5000 * j + 1000 * k == y: print(i, j, k) exit() else: print(-1, -1, -1)
s359065847
p00028
u650459696
1,000
131,072
Wrong Answer
20
7,708
355
Your task is to write a program which reads a sequence of integers and prints mode values of the sequence. The mode value is the element which occurs most frequently.
a, md = [], [] c, mx = 1, 1 while True: try: a.append(int(input())) except EOFError: break a = sorted(a) print(a) for i in range(0, len(a) - 1): if a[i] == a[i + 1]: c += 1 else: c = 1 if mx < c: mx = c md = [a[i]] elif mx == c: md.append(a[i]) print('\n'.join(map(str, md)))
s613321483
Accepted
20
7,504
203
a = [] ary = [0] * 101 while True: try: c = int(input()) except EOFError: break a.append(c) ary[c] += 1 for i in range(1, 101): if ary[i] == max(ary): print(i)
s824689704
p02407
u731896389
1,000
131,072
Wrong Answer
20
7,508
88
Write a program which reads a sequence and prints it in the reverse order.
n = list(map(int,input().split())) for i in range(len(n)): print(n[len(n)-i-1])
s642686834
Accepted
20
7,656
154
n =int(input()) a = list(map(int,input().split())) a.reverse() for i in range(n): if i!=n-1: print(a[i],end=" ") else: print(a[i])
s397861005
p03007
u227082700
2,000
1,048,576
Wrong Answer
212
14,264
156
There are N integers, A_1, A_2, ..., A_N, written on a blackboard. We will repeat the following operation N-1 times so that we have only one integer on the blackboard. * Choose two integers x and y on the blackboard and erase these two integers. Then, write a new integer x-y. Find the maximum possible value of the final integer on the blackboard and a sequence of operations that maximizes the final integer.
n=int(input()) a=list(map(int,input().split())) a.sort() mi,ma=a[0],a[-1] for i in a[1:-1]: if i<0:print(ma,i);ma-=i else:print(mi,i);mi-=i print(ma,mi)
s790922216
Accepted
229
14,264
232
n=int(input()) a=list(map(int,input().split())) a.sort() mi,ma=a[0],a[-1] for i in a[1:-1]: if i<0:ma-=i else:mi-=i print(ma-mi) mi,ma=a[0],a[-1] for i in a[1:-1]: if i<0:print(ma,i);ma-=i else:print(mi,i);mi-=i print(ma,mi)
s133358500
p04035
u766684188
2,000
262,144
Wrong Answer
67
14,060
175
We have N pieces of ropes, numbered 1 through N. The length of piece i is a_i. At first, for each i (1≤i≤N-1), piece i and piece i+1 are tied at the ends, forming one long rope with N-1 knots. Snuke will try to untie all of the knots by performing the following operation repeatedly: * Choose a (connected) rope with a total length of at least L, then untie one of its knots. Is it possible to untie all of the N-1 knots by properly applying this operation? If the answer is positive, find one possible order to untie the knots.
n,l=map(int,input().split()) A=list(map(int,input().split())) for i in range(n-1): if A[i]+A[i+1]>=l: print('Possible') break else: print('Impossible')
s938674905
Accepted
120
14,052
282
n,l=map(int,input().split()) A=list(map(int,input().split())) for i in range(n-1): if A[i]+A[i+1]>=l: print('Possible') t=i+1 break else: print('Impossible') exit() for i in range(1,t): print(i) for i in range(n-1,t,-1): print(i) print(t)
s421801359
p03448
u194894739
2,000
262,144
Wrong Answer
47
2,940
220
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, b, c, x = map(int,[input() for i in range(4)]) ans = 0 for i in range(0, a): for j in range(0, b): for k in range(0, c): if i * 500 + j * 100 + k * 50 == x: ans += 1 print(ans)
s237178418
Accepted
50
2,940
223
a, b, c, x = map(int,[input() for i in range(4)]) ans = 0 for i in range(a + 1): for j in range(b + 1): for k in range(c + 1): if i * 500 + j * 100 + k * 50 == x: ans += 1 print(ans)
s542968455
p03479
u724687935
2,000
262,144
Wrong Answer
19
3,060
77
As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below: * A consists of integers between X and Y (inclusive). * For each 1\leq i \leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i. Find the maximum possible length of the sequence.
import math X, Y = map(int, input().split()) print(int(math.log2(Y / X)))
s037148563
Accepted
17
2,940
102
X, Y = map(int, input().split()) cnt = 1 k = X while k * 2 <= Y: cnt += 1 k *= 2 print(cnt)
s145315502
p03957
u386131832
1,000
262,144
Wrong Answer
23
3,064
263
This contest is `CODEFESTIVAL`, which can be shortened to the string `CF` by deleting some characters. Mr. Takahashi, full of curiosity, wondered if he could obtain `CF` from other strings in the same way. You are given a string s consisting of uppercase English letters. Determine whether the string `CF` can be obtained from the string s by deleting some characters.
import sys s=input() for i in range(len(s)): if s[i]=="C": for j in range(i+1,len(s)): if s[j]=="F": print("YES") sys.exit() if j==len(s)-1: print("NO") sys.exit()
s381140390
Accepted
22
3,064
322
import sys s=input() for i in range(len(s)): if i==len(s)-1: print("No") sys.exit() if s[i]=="C": for j in range(i+1,len(s)): if s[j]=="F": print("Yes") sys.exit() if j==len(s)-1: print("No") sys.exit()
s399354817
p03565
u744920373
2,000
262,144
Wrong Answer
52
3,188
313
E869120 found a chest which is likely to contain treasure. However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters. He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with `?`. One more thing he found is a sheet of paper with the following facts written on it: * Condition 1: The string S contains a string T as a contiguous substring. * Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1. Print the string S. If such a string does not exist, print `UNRESTORABLE`.
S = input() T = input() l = len(T) ind = 51 for i in range(len(S)-l+1): flag = 0 for j in range(l): if S[i+j]!='?' and S[i+j]!=T[j]: flag = 1 if flag==0: ind = i if ind == 51: print('UNRESTORABLE') exit() print(S[:i].replace('?','a')+T+S[i+j:].replace('?','a'))
s595760459
Accepted
17
3,064
317
S = input() T = input() l = len(T) ind = 51 for i in range(len(S)-l+1): flag = 0 for j in range(l): if S[i+j]!='?' and S[i+j]!=T[j]: flag = 1 if flag==0: ind = i if ind == 51: print('UNRESTORABLE') exit() print(S[:ind].replace('?','a')+T+S[ind+l:].replace('?','a'))
s660976154
p00282
u847467233
1,000
131,072
Wrong Answer
20
5,596
411
大きな数を表そうとすると、文字数も多くなるし、位取りがわからなくなってしまうので、なかなか面倒です。大きな数をわかりやすく表すために、人々は数の単位を使ってきました。江戸時代に書かれた「塵劫記」という本の中では、数の単位が次のように書かれています。 たとえば、2の100乗のようなとても大きな数は、126穣7650(じょ)6002垓2822京9401兆4967億320万5376と表せます。それでは、正の整数 m と n が与えられたとき、m の n 乗を塵劫記の単位を使って上のように表すプログラムを作成してください。
# Python3 2018.6.26 bal4u unit = ("", "Man", "Oku", "Cho", "Kei", "Gai", "Jo", "Jou", "Ko", "Kan", \ "Sei", "Sai", "Gok", "Ggs", "Asg", "Nyt", "Fks", "Mts") while True: m, n = map(int, input().split()) if m == 0: break s = str(m ** n)[::-1] ans, j = [], 0 for i in range(0, len(s), 4): t = s[i:i+4][::-1] if t != "0000": ans += [unit[j], t] j += 1 print(*ans[::-1], sep='')
s012461429
Accepted
20
5,604
403
# Python3 2018.6.26 bal4u unit = ("", "Man", "Oku", "Cho", "Kei", "Gai", "Jo", "Jou", "Ko", "Kan", \ "Sei", "Sai", "Gok", "Ggs", "Asg", "Nyt", "Fks", "Mts") while True: m, n = map(int, input().split()) if m == 0: break s = str(m ** n)[::-1] ans = [] for i in range(0, len(s), 4): t = str(int(s[i:i+4][::-1])) if t != "0": ans += [unit[i>>2], t] print(*ans[::-1], sep='')
s088221910
p03494
u260036763
2,000
262,144
Wrong Answer
17
2,940
229
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.
ans = 0 N = input() A = list(map(int, input().split())) for i in A : p = 0 if i % 2 != 0 : print(0) break else : while i % 2 != 0 : i //= 2 p += 1 if ans < p : ans = p print(ans)
s694968109
Accepted
19
3,064
522
import sys def main(): N = int(sys.stdin.readline().rstrip()) A = list(map(int, sys.stdin.readline().rstrip().split())) cnt = 0 exist_odd = False while True: for i in range(N): if A[i] % 2 != 0: exist_odd = True if exist_odd == True: break for i in range(N): A[i] /= 2 cnt += 1 print(cnt) if __name__ == '__main__': main()
s582993899
p03131
u902973687
2,000
1,048,576
Wrong Answer
17
2,940
298
Snuke has one biscuit and zero Japanese yen (the currency) in his pocket. He will perform the following operations exactly K times in total, in the order he likes: * Hit his pocket, which magically increases the number of biscuits by one. * Exchange A biscuits to 1 yen. * Exchange 1 yen to B biscuits. Find the maximum possible number of biscuits in Snuke's pocket after K operations.
K, A, B = map(int, input().split()) if not B - A <= 2: if not (A == K or A == K + 1): if (K - A) // 2 == 0: print(B + (B - A) * ((K - A - 1) // 2) + 1) else: print(B + (B - A) * ((K - A - 1) // 2)) else: print(K + 1) else: print(K + 1)
s948458068
Accepted
17
2,940
120
K, A, B = map(int, input().split()) if (B - A) <= 2: print(K + 1) else: res = K-A+1 print(A+(B-A)*(res//2)+res%2)
s781533154
p02413
u340503368
1,000
131,072
Wrong Answer
20
5,588
283
Your task is to perform a simple table calculation. Write a program which reads the number of rows r, columns c and a table of r × c elements, and prints a new table, which includes the total sum for each row and column.
r,c = map(int, input().split()) for i in range(r): a = list(map(int, input().split())) sum = 0 for j in range(c): sum += a[j] a.append(sum) for k in range(c+1): print(a[k], end = "") if k != c: print(" ") print()
s760605315
Accepted
50
5,740
481
r,c = map(int, input().split()) matrix = [] for i in range(r): a = list(map(int, input().split())) sum = 0 for j in range(c): sum += a[j] a.append(sum) matrix.append(a) for k in range(c+1): print(a[k], end = "") if k != c: print(" ", end = "") print() for l in range(c+1): sum2 = 0 for m in range(r): sum2 += matrix[m][l] print(sum2, end = "") if l != c: print(" ", end = "") print()
s797216979
p03473
u114920558
2,000
262,144
Wrong Answer
17
2,940
28
How many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?
M = int(input()) print(24-M)
s319763249
Accepted
17
2,940
29
M = int(input()) print(48-M)
s564611448
p03943
u223663729
2,000
262,144
Wrong Answer
17
2,940
180
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.
# -*- coding: utf-8 -*- a, b, c = map(int, input().split()) if a+b == c or a == b+c: print('Yes') else: print('No')
s577310171
Accepted
19
2,940
234
# -*- coding: utf-8 -*- a, b, c = map(int, input().split()) if a == (b+c): print('Yes') elif (a+b) == c: print('Yes') elif (a+c) == b: print('Yes') else: print('No')
s702946703
p03457
u357949405
2,000
262,144
Wrong Answer
984
6,132
485
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
N = int(input()) t0, x0, y0 = map(int, input().split()) if t0 < x0 + y0 or t0 % 2 != (x0 + y0) % 2: print("No") exit() for i in range(1, N): t1, x1, y1 = map(int, input().split()) dist_t, dist_x, dist_y = abs(t1-t0), abs(x1-x0), abs(y1-y0) print("dist_t: {}, dist_x: {}, dist_y: {}".format(dist_t, dist_x, dist_y)) if dist_t < dist_x + dist_y or dist_t % 2 != (dist_x + dist_y) % 2: print("No") exit() t0, x0, y0 = t1, x1, y1 print("Yes")
s233647766
Accepted
385
3,064
487
N = int(input()) t0, x0, y0 = map(int, input().split()) if t0 < x0 + y0 or t0 % 2 != (x0 + y0) % 2: print("No") exit() for i in range(1, N): t1, x1, y1 = map(int, input().split()) dist_t, dist_x, dist_y = abs(t1-t0), abs(x1-x0), abs(y1-y0) # print("dist_t: {}, dist_x: {}, dist_y: {}".format(dist_t, dist_x, dist_y)) if dist_t < dist_x + dist_y or dist_t % 2 != (dist_x + dist_y) % 2: print("No") exit() t0, x0, y0 = t1, x1, y1 print("Yes")
s407894977
p02613
u684556734
2,000
1,048,576
Wrong Answer
144
16,276
377
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()) n = [input() for i in range(N)] count_AC = 0 count_WA = 0 count_TLE = 0 count_RE = 0 for i in n: if i == 'AC': count_AC += 1 elif i == 'WA': count_WA += 1 elif i == 'TLE': count_WA += 1 elif i == 'RE': count_WA += 1 print('AC x {0}\nWA x {1}\nTLE x {2}\nRE x {3}'.format(count_AC, count_WA, count_TLE, count_RE))
s384090465
Accepted
151
16,200
378
N = int(input()) n = [input() for i in range(N)] count_AC = 0 count_WA = 0 count_TLE = 0 count_RE = 0 for i in n: if i == 'AC': count_AC += 1 elif i == 'WA': count_WA += 1 elif i == 'TLE': count_TLE += 1 elif i == 'RE': count_RE += 1 print('AC x {0}\nWA x {1}\nTLE x {2}\nRE x {3}'.format(count_AC, count_WA, count_TLE, count_RE))
s096590877
p02694
u398203017
2,000
1,048,576
Wrong Answer
23
9,164
78
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
X=int(input()) A=int(100) B=int(0) while A<=X: A=A*101//100 B=B+1 print(B)
s696287909
Accepted
22
9,152
78
X=int(input()) A=int(100) B=int(0) while A<X: A=A*101//100 B=B+1 print(B)
s054355142
p02694
u423812170
2,000
1,048,576
Wrong Answer
37
9,184
199
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
import math X = int(input()) deposit = 100 y_later = 0 while deposit < X: y_later += 1 deposit = math.floor(deposit) * 1.01 print(deposit) print(y_later)
s242209492
Accepted
28
9,160
126
X = int(input()) deposit = 100 y_later = 0 while deposit < X: y_later += 1 deposit += deposit // 100 print(y_later)
s356131406
p02608
u438946728
2,000
1,048,576
Wrong Answer
38
9,204
324
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
n = int(input()) a = [0 for _ in range(n+1)] for i in range(1,n+1): if i*i>n: break for j in range(1,n+1): if i*i + j*j +i*j > n: break for k in range(1,n+1): tmp = i*i + j*j + k*k + i*j + j*k + k*i if tmp==n: a[tmp]+=1 else: break for i in range(1,n+1): print(a[i])
s105588222
Accepted
151
9,196
324
n = int(input()) a = [0 for _ in range(n+1)] for i in range(1,n+1): if i*i>n: break for j in range(1,n+1): if i*i + j*j +i*j > n: break for k in range(1,n+1): tmp = i*i + j*j + k*k + i*j + j*k + k*i if tmp<=n: a[tmp]+=1 else: break for i in range(1,n+1): print(a[i])
s272133049
p02646
u017415492
2,000
1,048,576
Wrong Answer
25
9,120
209
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
a,v=map(int,input().split()) b,w=map(int,input().split()) t=int(input()) if a==b: print("Yes") else: if w>v: print("No") else: if (v-w)*t<abs(b-a): print("No") else: print("Yes")
s281261096
Accepted
21
9,180
209
a,v=map(int,input().split()) b,w=map(int,input().split()) t=int(input()) if a==b: print("YES") else: if w>v: print("NO") else: if (v-w)*t<abs(b-a): print("NO") else: print("YES")
s015983339
p03567
u486773779
2,000
262,144
Wrong Answer
29
8,968
64
Snuke built an online judge to hold a programming contest. When a program is submitted to the judge, the judge returns a verdict, which is a two-character string that appears in the string S as a contiguous substring. (The judge can return any two-character substring of S.) Determine whether the judge can return the string `AC` as the verdict to a program.
s=input() if s in 'AC': print('Yes') else: print('No')
s737722245
Accepted
28
9,076
64
s=input() if 'AC' in s: print('Yes') else: print('No')
s554414601
p03473
u960513073
2,000
262,144
Wrong Answer
17
2,940
29
How many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?
print(24 - int(input()) + 12)
s521779194
Accepted
18
2,940
29
print(24 - int(input()) + 24)
s215832954
p03110
u902266190
2,000
1,048,576
Wrong Answer
18
2,940
201
Takahashi received _otoshidama_ (New Year's money gifts) from N of his relatives. You are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either `JPY` or `BTC`, and x_i and u_i represent the content of the otoshidama from the i-th relative. For example, if x_1 = `10000` and u_1 = `JPY`, the otoshidama from the first relative is 10000 Japanese yen; if x_2 = `0.10000000` and u_2 = `BTC`, the otoshidama from the second relative is 0.1 bitcoins. If we convert the bitcoins into yen at the rate of 380000.0 JPY per 1.0 BTC, how much are the gifts worth in total?
N = int(input()) money = 0 for i in range(N): x, u = list(input().split(' ')) if(u == 'JPY'): rate = 1.0 else: rate = 380000.0 money += int(float(x) * rate) print(money)
s057243210
Accepted
17
2,940
230
N = int(input()) money = 0 for i in range(N): x, u = list(input().split(' ')) if(u == 'JPY'): rate = 1.0 x = int(x) else: rate = 380000.0 x = float(x) money += x * rate print(money)
s320959537
p03386
u252964975
2,000
262,144
Wrong Answer
17
3,060
161
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()) if B-A<2*K: for i in range(A,B+1): print(i) else: for i in range(K): print(A+i) for i in range(K): print(B-K+i)
s515084190
Accepted
17
3,060
167
A,B,K=map(int, input().split()) if B-A+1-2*K<1: for i in range(A,B+1): print(i) else: for i in range(K): print(A+i) for i in range(K): print(B-K+i+1)
s034300642
p03693
u318165580
2,000
262,144
Wrong Answer
17
2,940
84
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?
a,b,c=list(map(int,input().split())) d=100*a+10*b+c print("Yes" if d%4==0 else "No")
s833352178
Accepted
17
2,940
84
a,b,c=list(map(int,input().split())) d=100*a+10*b+c print("YES" if d%4==0 else "NO")
s848278443
p03672
u589381719
2,000
262,144
Wrong Answer
17
2,940
74
We will call a string that can be obtained by concatenating two equal strings an _even_ string. For example, `xyzxyz` and `aaaaaa` are even, while `ababab` and `xyzxy` are not. You are given an even string S consisting of lowercase English letters. Find the length of the longest even string that can be obtained by deleting one or more characters from the end of S. It is guaranteed that such a non-empty string exists for a given input.
S=input() for i in range(len(S),0,-1): if S[:i]==S[i:]: break
s673378459
Accepted
17
2,940
160
S=input() for i in range(len(S)-1,0,-1): if i%2: continue else: t=i//2 if S[:t]==S[t:i]: print(i) break
s033721449
p03493
u179958942
2,000
262,144
Wrong Answer
27
9,052
115
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.
num = int(input()) a = num // 100 b = num // 10 - (a * 10) c = num - (a * 100) - (b * 10) print(num) print(a, b, c)
s543664657
Accepted
25
9,084
106
num = int(input()) a = num // 100 b = num // 10 - (a * 10) c = num - (a * 100) - (b * 10) print(a + b + c)
s443731105
p02841
u489762173
2,000
1,048,576
Wrong Answer
20
3,188
405
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.
import sys def main(): M1, D1 = map(int, input().split()) M2, D2 = map(int, input().split()) if(M1==2 and D1!=28): print('0') sys.exit() if(M1==4 or M1==6 or M1==9 or M1==11 and D1==30): print('0') sys.exit() if(M1==1 or M1==3 or M1==5 or M1==7 or M1==8 or M1==10 or M1==12 and D1!=31): print('0') sys.exit() print('1') main()
s831406888
Accepted
17
3,064
556
import sys def main(): M1, D1 = map(int, input().split()) M2, D2 = map(int, input().split()) if(M1==2 and D1==28): if(M2==M1+1 and D2==1): print('1') sys.exit() if(M1==4 or M1==6 or M1==9 or M1==11 and D1==30): if(M2==M1+1 and D2==1): print('1') sys.exit() if(M1==1 or M1==3 or M1==5 or M1==7 or M1==8 or M1==10 or M1==12 and D1==31): if(M2==M1+1 and D2==1) or (M1==12 and M2==1 and D2==1): print('1') sys.exit() print('0') main()
s478401728
p03599
u143492911
3,000
262,144
Wrong Answer
371
14,572
633
Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations. * Operation 1: Pour 100A grams of water into the beaker. * Operation 2: Pour 100B grams of water into the beaker. * Operation 3: Put C grams of sugar into the beaker. * Operation 4: Put D grams of sugar into the beaker. In our experimental environment, E grams of sugar can dissolve into 100 grams of water. Snuke will make sugar water with the highest possible density. The beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker. Find the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it. If there is more than one candidate, any of them will be accepted. We remind you that the sugar water that contains a grams of water and b grams of sugar is \frac{100b}{a + b} percent. Also, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water.
a,b,c,d,e,f=map(int,input().split()) w=s=[] from fractions import Fraction import math for i in range(math.ceil(f/a)): for j in range(math.ceil(f/b)): x=100*a*i+100*b*j if 0<x and x<=f: w.append(x) w=list(set(w)) print(w) for i in range(math.ceil(f/c)): for j in range(math.ceil(f/d)): y=i*c+j*d if 0<y and y<=f: s.append(y) s=list(set(s)) s.sort() print(s) ans=ans_2=0 con=1 for i in w: for j in s: if i+j<=f and j<=e*(i//100): max_con=(100*j)/(i+j) if con<=max_con: ans=i+j ans_2=j print(ans,ans_2)
s562077681
Accepted
1,976
12,440
664
a,b,c,d,e,f=map(int,input().split()) water=[] suguar=[] temp_3=0 temp_2=0 ans=0 temp=0 for i in range((f+1)//100): for j in range((f+1)//100): x=100*i*a+100*j*b if 1<=x<=f: water.append(x) for i in range(f+1): for j in range(f+1): y=c*i+d*j if y<=f: suguar.append(y) for i in water: for j in suguar: total=i+j if total<=f: if j<=i//100*e: ans=100*j/(i+j) if temp<=ans: temp=ans temp_2=total temp_3=j print(temp_2,temp_3)
s156773248
p02646
u922449550
2,000
1,048,576
Wrong Answer
25
9,012
145
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
A, V = map(int, input().split()) B, W = map(int, input().split()) T = int(input()) if abs(A - B) <= (W - V)*T: print('YES') else: print('NO')
s881478227
Accepted
24
9,104
145
A, V = map(int, input().split()) B, W = map(int, input().split()) T = int(input()) if abs(A - B) <= (V - W)*T: print('YES') else: print('NO')
s744281703
p03657
u903005414
2,000
262,144
Wrong Answer
19
2,940
122
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.
a, b = map(int, input().split()) print('Possible' if not (a // 3) or not (b // 3) or not ((a + b) // 3) else 'Impossible')
s669620126
Accepted
18
2,940
141
a, b = map(int, input().split()) if (a % 3 == 0) or (b % 3 == 0) or ((a + b) % 3 == 0): print('Possible') else: print('Impossible')
s342907285
p02678
u255943004
2,000
1,048,576
Wrong Answer
809
43,748
576
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()) A = [] B = [] for m in range(M): a,b = map(int,input().split()) A.append(a) B.append(b) from collections import defaultdict as ddict route = ddict(list) for i in range(M): route[A[i]].append(B[i]) route[B[i]].append(A[i]) for i in range(1,N+1): if route[i] == []: print("No") exit() ans = [0 for i in range(N+1)] from collections import deque Q = deque([1]) while Q: q = Q.popleft() for r in route[q]: if ans[r] == 0: ans[r] = q Q.append(r) print(*ans[2:],sep="\n")
s972551911
Accepted
931
43,700
589
N,M = map(int,input().split()) A = [] B = [] for m in range(M): a,b = map(int,input().split()) A.append(a) B.append(b) from collections import defaultdict as ddict route = ddict(list) for i in range(M): route[A[i]].append(B[i]) route[B[i]].append(A[i]) for i in range(1,N+1): if route[i] == []: print("No") exit() ans = [0 for i in range(N+1)] from collections import deque Q = deque([1]) while Q: q = Q.popleft() for r in route[q]: if ans[r] == 0: ans[r] = q Q.append(r) print("Yes") print(*ans[2:],sep="\n")
s365575382
p03997
u740047492
2,000
262,144
Wrong Answer
17
2,940
63
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, b, h, = [int(input()) for i in range(3)] print((a+b)*h/2)
s125240764
Accepted
18
3,060
64
a, b, h = [int(input()) for i in range(3)] print(int((a+b)*h/2))
s621843245
p00003
u560214129
1,000
131,072
Wrong Answer
40
8,096
414
Write a program which judges wheather given length of three side form a right triangle. Print "YES" if the given sides (integers) form a right triangle, "NO" if not so.
n=int(input()) a=[] c=[] for i in range(n): a.append([]) for j in range(3): a[i].append([]) print (a) for i in range(n): #for j in range(3): a[i][0], a[i][1], a[i][2]=map(int, input().split()) a[i].sort() if(((a[i][0]*a[i][0])+(a[i][1]*a[i][1]))==(a[i][2]*a[i][2])): k="YES" c.append(k) else: k="NO" c.append(k) for i in range(n): print(c[i])
s671080158
Accepted
30
7,940
404
n=int(input()) a=[] c=[] for i in range(n): a.append([]) for j in range(3): a[i].append([]) for i in range(n): #for j in range(3): a[i][0], a[i][1], a[i][2]=map(int, input().split()) a[i].sort() if(((a[i][0]*a[i][0])+(a[i][1]*a[i][1]))==(a[i][2]*a[i][2])): k="YES" c.append(k) else: k="NO" c.append(k) for i in range(n): print(c[i])
s093219114
p02833
u245870380
2,000
1,048,576
Wrong Answer
17
2,940
160
For an integer n not less than 0, let us define f(n) as follows: * f(n) = 1 (if n < 2) * f(n) = n f(n-2) (if n \geq 2) Given is an integer N. Find the number of trailing zeros in the decimal notation of f(N).
N = int(input()) if N < 12: print(0) else: cnt = 0 for i in range(1, 19): cnt += ((N-2) // 10**i)*i print(cnt, i) print(cnt+1)
s337673221
Accepted
17
2,940
211
N = int(input()) if N % 2 != 0: print(0) else: ans = 0 cnt = 10 while True: if N >= cnt: ans += N // (cnt) cnt *= 5 else: break print(ans)
s618968762
p02536
u491296898
2,000
1,048,576
Wrong Answer
634
48,304
535
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 sys sys.setrecursionlimit(10**9) n,m = list(map(int,input().split())) d = {} for i in range(m): fr, to = list(map(int,input().split())) d[fr] = d.get(fr, []) + [to] d[to] = d.get(to, []) + [fr] visited = [0 for i in range(n+1)] def connect(node, i): visited[node] = i if node in d: for neig in d[node]: if visited[neig] == 0: connect(neig, i) ans = 1 for key in range(1,n+1): if visited[key] == 0: connect(key, ans) ans += 1 print(ans-1)
s123550723
Accepted
519
48,340
544
import sys sys.setrecursionlimit(10**9) n,m = list(map(int,input().split())) d = {} for i in range(m): fr, to = list(map(int,input().split())) d[fr] = d.get(fr, []) + [to] d[to] = d.get(to, []) + [fr] visited = [0 for i in range(n+1)] def connect(node, i): visited[node] = i if node in d: for neig in d[node]: if visited[neig] == 0: connect(neig, i) ans = 1 for key in range(1,n+1): if visited[key] == 0: connect(key, ans) ans += 1 print(max(visited)-1)
s240156962
p04030
u767797498
2,000
262,144
Wrong Answer
26
8,988
175
Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string: * The `0` key: a letter `0` will be inserted to the right of the string. * The `1` key: a letter `1` will be inserted to the right of the string. * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted. Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now?
def bs(s): if s == "": return s else: return s[:-1] s = input() ans = "" for c in s: if c == "b": ans = bs(ans) else: ans += c print(ans)
s544362076
Accepted
24
8,968
83
s=input() ss="" for c in s: if c=="B": ss=ss[:-1] else: ss+=c print(ss)
s172686649
p03400
u459283268
2,000
262,144
Wrong Answer
22
2,940
207
Some number of chocolate pieces were prepared for a training camp. The camp had N participants and lasted for D days. The i-th participant (1 \leq i \leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on. As a result, there were X chocolate pieces remaining at the end of the camp. During the camp, nobody except the participants ate chocolate pieces. Find the number of chocolate pieces prepared at the beginning of the camp.
n = int(input()) D, X = list(map(int, input().split())) a = [int(input()) for _ in range(n)] r = 0 for i in range(n): k = 0 for j in a: r += 1 if k*j + 1 <= D else r k += 1 print(r)
s981098232
Accepted
19
2,940
199
n = int(input()) D, X = list(map(int, input().split())) a = [int(input()) for _ in range(n)] r = 0 for i in range(n): k = 0 while(k*a[i]+1 <= D): r += 1 k += 1 print(r + X)
s590095514
p03378
u980492406
2,000
262,144
Wrong Answer
17
3,060
175
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to right. Initially, you are in Square X. You can freely travel between adjacent squares. Your goal is to reach Square 0 or Square N. However, for each i = 1, 2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0, Square X and Square N. Find the minimum cost incurred before reaching the goal.
n,m,x = map(int,input().split()) li = list(map(int,input().split())) if x < li[0] or x > li[m-1] : print(0) else : for i in range(m-1) : print(min(i+1,m-i-1))
s403277382
Accepted
17
2,940
218
n,m,x = map(int,input().split()) li = list(map(int,input().split())) if x < li[0] or x > li[m-1] : print(0) else : for i in range(m-1) : if x > li[i] and x < li[i+1] : print(min(i+1,m-i-1))
s688005720
p03455
u057079894
2,000
262,144
Wrong Answer
17
2,940
77
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*b%2: print('Even') else: print('Odd')
s871351731
Accepted
17
2,940
83
a, b= map(int,input().split()) if a*b%2 == 0: print('Even') else: print('Odd')
s800423233
p03563
u403984573
2,000
262,144
Wrong Answer
17
2,940
34
Takahashi is a user of a site that hosts programming contests. When a user competes in a contest, the _rating_ of the user (not necessarily an integer) changes according to the _performance_ of the user, as follows: * Let the current rating of the user be a. * Suppose that the performance of the user in the contest is b. * Then, the new rating of the user will be the avarage of a and b. For example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000. Takahashi's current rating is R, and he wants his rating to be exactly G after the next contest. Find the performance required to achieve it.
print(2*int(input())-int(input()))
s807500304
Accepted
17
2,940
42
A=int(input()) B=int(input()) print(2*B-A)
s758432689
p03455
u604846694
2,000
262,144
Wrong Answer
17
2,940
93
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 * b % 2 == 0: print("odd") else : print("even")
s945614745
Accepted
17
2,940
93
a, b = map(int, input().split()) if a * b % 2 == 0: print("Even") else : print("Odd")
s409321487
p03470
u982762220
2,000
262,144
Wrong Answer
17
2,940
174
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?
N = int(input()) mochis = sorted([int(input()) for _ in range(N)], reverse=True) res = 0 for idx in range(1, N): if mochis[idx] > mochis[idx - 1]: res += 1 print(res)
s852649530
Accepted
17
2,940
174
N = int(input()) mochis = sorted([int(input()) for _ in range(N)], reverse=True) res = 1 for idx in range(1, N): if mochis[idx] < mochis[idx - 1]: res += 1 print(res)
s017604038
p03494
u067632118
2,000
262,144
Time Limit Exceeded
2,104
3,188
175
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 = [int(x) for x in input().split()] DA = [] for v in A: d = 0 while v & 1 == 0: v = v << 2 d += 1 DA.append(d) print(min(DA))
s835822013
Accepted
18
2,940
176
N = int(input()) A = [int(x) for x in input().split()] DA = [] for v in A: d = 0 while v & 1 == 0: v = v >> 1 d += 1 DA.append(d) print(min(DA))
s361150965
p04012
u483151310
2,000
262,144
Wrong Answer
17
2,940
225
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() dct_str = dict.fromkeys(w, 0) for alp in w: dct_str[alp] += 1 flag = True for alp in dct_str.keys(): if dct_str[alp] % 2 != 0: flag = False if flag == True: print("YES") else: print("NO")
s317421221
Accepted
18
2,940
227
w = input() dct_str = dict.fromkeys(w, 0) for alp in w: dct_str[alp] += 1 flag = True for alp in dct_str.keys(): if dct_str[alp] % 2 != 0: flag = False if flag == True: print("Yes") else: print("No")
s507377505
p03399
u694422786
2,000
262,144
Wrong Answer
17
2,940
126
You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
a = [] for i in range(4): a.append(int(input())) print(a) train = min(a[0],a[1]) bus = min(a[2],a[3]) print(train + bus)
s095347184
Accepted
17
3,060
118
a = [] for i in range(4): a.append(int(input())) train = min(a[0],a[1]) bus = min(a[2],a[3]) print(train + bus)
s216770480
p03578
u089142196
2,000
262,144
Wrong Answer
319
57,136
300
Rng is preparing a problem set for a qualification round of CODEFESTIVAL. He has N candidates of problems. The difficulty of the i-th candidate is D_i. There must be M problems in the problem set, and the difficulty of the i-th problem must be T_i. Here, one candidate of a problem cannot be used as multiple problems. Determine whether Rng can complete the problem set without creating new candidates of problems.
N=int(input()) D=list(map(int,input().split())) M=int(input()) T=list(map(int,input().split())) from collections import Counter a=Counter(D) b=Counter(T) for keys in b: if keys not in a: print("No") break else: if b[keys]>a[keys]: print("No") break else: print("Yes")
s896998853
Accepted
324
56,800
300
N=int(input()) D=list(map(int,input().split())) M=int(input()) T=list(map(int,input().split())) from collections import Counter a=Counter(D) b=Counter(T) for keys in b: if keys not in a: print("NO") break else: if b[keys]>a[keys]: print("NO") break else: print("YES")
s158773763
p02690
u927373043
2,000
1,048,576
Wrong Answer
2,205
9,152
262
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.
X = int(input()) b = 0 flag = True while(flag): for i in range(1,X+1): if(X % i == 0): print(i) if(pow(b+i,5)-pow(b,5) == X): print("%d %d"%(b+i,b)) flag = False break b -= 1 if(-pow(b,5) > X): b = int(X**(1/5))
s613213974
Accepted
23
9,152
308
X = int(input()) a = [] b = 0 flag = True num = 120 if(X <= 120): num = X for i in range(1,num+1): if(X%i== 0): a.append(i) while(flag): for i in range(len(a)): if(pow(b+a[i],5)-pow(b,5) == X): print("%d %d"%(b+a[i],b)) flag = False break b -= 1 if(b < -119): b = 119
s333648048
p02407
u105694406
1,000
131,072
Wrong Answer
30
7,636
110
Write a program which reads a sequence and prints it in the reverse order.
a = list(map(int, input().split())) a.reverse() sum = "" for i in a: sum = sum + str(i) + " " print(sum[:-1])
s367817310
Accepted
30
7,588
118
input() a = list(map(int, input().split())) a.reverse() sum = "" for i in a: sum = sum + str(i) + " " print(sum[:-1])
s691754988
p03386
u210817970
2,000
262,144
Wrong Answer
17
3,064
348
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.
s = input().split() s = list(map(int,s)) ans = [] i = 0 while i<s[2]: if (i+s[0])>s[1]: i += 1 elif (i+s[0])<=s[1]: ans.append(int(i + s[0])) i += 1 i = 0 while i<s[2]: if (s[1]-i)>=s[0]: ans.append(int(s[1]-i)) i += 1 elif (s[1]-i)<s[0]: i += 1 ans = list(set(ans)) for a in ans: print(a)
s609373125
Accepted
17
3,064
359
s = input().split() s = list(map(int,s)) ans = [] i = 0 while i<s[2]: if (i+s[0])>s[1]: i += 1 elif (i+s[0])<=s[1]: ans.append(int(i + s[0])) i += 1 i = 0 while i<s[2]: if (s[1]-i)>=s[0]: ans.append(int(s[1]-i)) i += 1 elif (s[1]-i)<s[0]: i += 1 ans = list(set(ans)) ans.sort() for a in ans: print(a)
s066611922
p03909
u506127000
2,000
262,144
Wrong Answer
140
4,024
245
There is a grid with H rows and W columns. The square at the i-th row and j-th column contains a string S_{i,j} of length 5. The rows are labeled with the numbers from 1 through H, and the columns are labeled with the uppercase English letters from `A` through the W-th letter of the alphabet. Exactly one of the squares in the grid contains the string `snuke`. Find this square and report its location. For example, the square at the 6-th row and 8-th column should be reported as `H6`.
from string import ascii_uppercase H, W = [int(i) for i in input().split()] S = [input().split() for _ in range(H)] for h in range(H): for w in range(W): if S[h][w] == "snuke": print("{}{}".format(ascii_uppercase[w], h))
s323055567
Accepted
62
4,024
247
from string import ascii_uppercase H, W = [int(i) for i in input().split()] S = [input().split() for _ in range(H)] for h in range(H): for w in range(W): if S[h][w] == "snuke": print("{}{}".format(ascii_uppercase[w], h+1))
s454492445
p03471
u999503965
2,000
262,144
Wrong Answer
341
8,944
226
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these. According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.
n,y=map(int,input().split()) a,b,c=-1,-1,-1 for i in range(n+1): for j in range(n+1): if i+j>0: continue h=n-i-j if 10000*i+5000*j+1000*h==y: a,b,c=i,j,h break print("{} {} {}".format(a,b,c))
s693138229
Accepted
1,108
9,108
206
n,y=map(int,input().split()) a,b,c=-1,-1,-1 for i in range(n+1): for j in range(n+1): h=n-i-j if 10000*i+5000*j+1000*h==y and h>=0: a,b,c=i,j,h break print("{} {} {}".format(a,b,c))
s715336720
p02396
u498462680
1,000
131,072
Wrong Answer
20
5,540
17
In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets. Write a program which reads an integer x and print it as is. Note that multiple datasets are given for this problem.
Indata = input()
s933660597
Accepted
140
5,604
152
i=0 while True: Indata = int(input()) if Indata == 0: break else: i=i+1 print("Case " +str(i) + ": " + str(Indata))
s071039525
p02612
u131411061
2,000
1,048,576
Wrong Answer
29
9,168
48
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()) tmp = N//1000 print(N-tmp*1000)
s082824767
Accepted
31
9,152
105
N = int(input()) if N%1000==0: print(0) else: tmp = N//1000 res = tmp+1 print(res*1000-N)
s322624083
p03448
u038027079
2,000
262,144
Wrong Answer
148
4,080
272
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()) for _ in range(4)] count = 0 for i in range(A[0] + 1): for j in range(A[1] + 1): for k in range(A[2] + 1): sum = i * 500 + j * 100 + k * 50 if sum == A[3]: count += 1 print(sum) print(count)
s103471025
Accepted
55
3,060
249
A = [int(input()) for _ in range(4)] count = 0 for i in range(A[0] + 1): for j in range(A[1] + 1): for k in range(A[2] + 1): sum = i * 500 + j * 100 + k * 50 if sum == A[3]: count += 1 print(count)
s176079997
p02795
u417589709
2,000
1,048,576
Wrong Answer
18
2,940
73
We have a grid with H rows and W columns, where all the squares are initially white. You will perform some number of painting operations on the grid. In one operation, you can do one of the following two actions: * Choose one row, then paint all the squares in that row black. * Choose one column, then paint all the squares in that column black. At least how many operations do you need in order to have N or more black squares in the grid? It is guaranteed that, under the conditions in Constraints, having N or more black squares is always possible by performing some number of operations.
h = int(input()) w = int(input()) n = int(input()) t = 0 print(max(h,w))
s971866381
Accepted
17
2,940
83
h = int(input()) w = int(input()) n = int(input()) print(int((n-1) / max(h,w))+1)
s330798692
p03598
u543954314
2,000
262,144
Wrong Answer
18
2,940
134
There are N balls in the xy-plane. The coordinates of the i-th of them is (x_i, i). Thus, we have one ball on each of the N lines y = 1, y = 2, ..., y = N. In order to collect these balls, Snuke prepared 2N robots, N of type A and N of type B. Then, he placed the i-th type-A robot at coordinates (0, i), and the i-th type-B robot at coordinates (K, i). Thus, now we have one type-A robot and one type-B robot on each of the N lines y = 1, y = 2, ..., y = N. When activated, each type of robot will operate as follows. * When a type-A robot is activated at coordinates (0, a), it will move to the position of the ball on the line y = a, collect the ball, move back to its original position (0, a) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything. * When a type-B robot is activated at coordinates (K, b), it will move to the position of the ball on the line y = b, collect the ball, move back to its original position (K, b) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything. Snuke will activate some of the 2N robots to collect all of the balls. Find the minimum possible total distance covered by robots.
n = int(input()) k = int(input()) x = list(map(int, input().split())) ans = 0 for i in range(n): ans += min(x[i], k-x[i]) print(ans)
s733230763
Accepted
18
2,940
136
n = int(input()) k = int(input()) x = list(map(int, input().split())) ans = 0 for i in range(n): ans += min(x[i], k-x[i]) print(ans*2)
s929609686
p03409
u404710939
2,000
262,144
Wrong Answer
19
3,064
390
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.
N = int(input()) ab = [[int(i) for i in input().split(" ")] for _ in range(N)] cd = [[int(i) for i in input().split(" ")] for _ in range(N)] ab_sort = sorted(ab, key=lambda x:(-x[0], -x[1])) cd_sort = sorted(cd, key=lambda x:(-x[0], -x[1])) cnt = 0 for c, d in cd_sort: for a, b in ab_sort: if a < c and b < d: ab_sort.remove([a, b]) cnt += 1 print(cnt)
s907436121
Accepted
18
3,064
390
N = int(input()) ab = [[int(i) for i in input().split(" ")] for _ in range(N)] cd = [[int(i) for i in input().split(" ")] for _ in range(N)] ab_sort = sorted(ab, key=lambda x:-x[1]) cd_sort = sorted(cd, key=lambda x:x[0]) cnt = 0 for c, d in cd_sort: for a, b in ab_sort: if a < c and b < d: ab_sort.remove([a, b]) cnt += 1 break print(cnt)
s771540514
p03970
u396391104
2,000
262,144
Wrong Answer
17
2,940
111
CODE FESTIVAL 2016 is going to be held. For the occasion, Mr. Takahashi decided to make a signboard. He intended to write `CODEFESTIVAL2016` on it, but he mistakenly wrote a different string S. Fortunately, the string he wrote was the correct length. So Mr. Takahashi decided to perform an operation that replaces a certain character with another in the minimum number of iterations, changing the string to `CODEFESTIVAL2016`. Find the minimum number of iterations for the rewrite operation.
S = input() T = "CODEFESTIVAL2016" ans = 0 for i in range(len(S)): if S[i] == T[i]: ans += 1 print(ans)
s798073754
Accepted
17
2,940
111
S = input() T = "CODEFESTIVAL2016" ans = 0 for i in range(len(S)): if S[i] != T[i]: ans += 1 print(ans)
s254967090
p03658
u419963262
2,000
262,144
Wrong Answer
17
2,940
126
Snuke has N sticks. The length of the i-th stick is l_i. Snuke is making a snake toy by joining K of the sticks together. The length of the toy is represented by the sum of the individual sticks that compose it. Find the maximum possible length of the toy.
n,k=map(int,input().split()) a=list(map(int,input().split())) b=sorted(a) ans=0 for i in range(k): ans+=a[(-1)*i] print(ans)
s256327395
Accepted
19
2,940
131
n,k=map(int,input().split()) a=list(map(int,input().split())) b=sorted(a) ans=0 for i in range(1,k+1): ans+=b[(-1)*i] print(ans)
s660197813
p03386
u562016607
2,000
262,144
Wrong Answer
2,151
797,592
166
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()) S=[] for i in range(A,max([A+K,B+1])): S.append(i) for i in range(min([B-K+1,A]),B+1): S.append(i) S.sort() for i in S: print(i)
s205772618
Accepted
17
3,060
173
A,B,K=map(int,input().split()) S=set() for i in range(A,min([A+K,B+1])): S.add(i) for i in range(max([B-K+1,A]),B+1): S.add(i) T=list(S) T.sort() for i in T: print(i)
s703690049
p03555
u898967808
2,000
262,144
Wrong Answer
17
2,940
94
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
c1=input() c2=input() if c1==c2[::-1] and c2==c1[::-1]: print('Yes') else: print('No')
s313158266
Accepted
17
2,940
113
c1=input() c2=input() if c1[0]==c2[2] and c1[1] == c2[1] and c1[2] == c2[0]: print('YES') else: print('NO')
s940282698
p03544
u131625544
2,000
262,144
Wrong Answer
17
2,940
166
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers. You are given an integer N. Find the N-th Lucas number. Here, the i-th Lucas number L_i is defined as follows: * L_0=2 * L_1=1 * L_i=L_{i-1}+L_{i-2} (i≥2)
n = int(input()) luc = [2, 1] if n < 3: print(luc[n - 1]) else: for _ in range(n - 3): tmp = sum(luc) luc = luc[1:] + [tmp] print(luc[1])
s359446200
Accepted
17
3,064
162
n = int(input()) luc = [2, 1] if n < 2: print(luc[n]) else: for _ in range(n - 1): tmp = sum(luc) luc = luc[1:] + [tmp] print(luc[1])
s190754776
p03160
u364061715
2,000
1,048,576
Wrong Answer
155
13,924
337
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()) costlist = list(map(int,input().split())) DP = [0 for i in range(N)] DP[1]=abs(costlist[1]-costlist[0]) for i in range(N-2): probmin1 = abs(costlist[i+2]-costlist[i+1]) + costlist[i+1] probmin2 = abs(costlist[i+2]-costlist[i]) + costlist[i] plusmin = min(probmin1,probmin2) DP[i+2]=plusmin print(DP[-1])
s790281660
Accepted
141
13,924
325
N = int(input()) costlist = list(map(int,input().split())) DP = [0 for i in range(N)] DP[1]=abs(costlist[1]-costlist[0]) for i in range(N-2): probmin1 = abs(costlist[i+2]-costlist[i+1]) + DP[i+1] probmin2 = abs(costlist[i+2]-costlist[i]) + DP[i] plusmin = min(probmin1,probmin2) DP[i+2]=plusmin print(DP[-1])
s149415827
p03408
u622570247
2,000
262,144
Wrong Answer
31
9,412
285
Takahashi has N blue cards and M red cards. A string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i. Takahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen. Here, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces `atcoder`, he will not earn money even if there are blue cards with `atcoderr`, `atcode`, `btcoder`, and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.) At most how much can he earn on balance? Note that the same string may be written on multiple cards.
from collections import Counter n = int(input()) s = [None] * n for i in range(n): s[i] = input().rstrip() m = int(input()) t = [None] * m for i in range(m): t[i] = input().rstrip() ctr = Counter(s) - Counter(t) if ctr: print(ctr.most_common(1)[0][0]) else: print(0)
s663848275
Accepted
32
9,408
285
from collections import Counter n = int(input()) s = [None] * n for i in range(n): s[i] = input().rstrip() m = int(input()) t = [None] * m for i in range(m): t[i] = input().rstrip() ctr = Counter(s) - Counter(t) if ctr: print(ctr.most_common(1)[0][1]) else: print(0)
s698967176
p02419
u324811972
1,000
131,072
Wrong Answer
20
5,556
181
Write a program which reads a word W and a text T, and prints the number of word W which appears in text T T consists of string Ti separated by space characters and newlines. Count the number of Ti which equals to W. The word and text are case insensitive.
target = input() text = input() text2 = text.replace('\n',' ') sentenceList = text2.split() count = 0 for word in sentenceList: if(word.lower() == target): count+=1 print(count)
s922396626
Accepted
20
5,552
285
target = input() total_text = "" while True: text = input() if(text=="END_OF_TEXT"): break total_text+=" " total_text+=text #text2 = text.replace('\n',' ') sentenceList = total_text.split() count = 0 for word in sentenceList: if(word.lower() == target): count+=1 print(count)
s681956776
p02410
u757827098
1,000
131,072
Wrong Answer
30
7,668
309
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 =[int(r) for r in input().split()] matrix = [] for ni in range(n): matrix.append([int(a)for a in input().split()]) vector = [] for mi in range(m): vector.append(int(input())) for i in range(len(matrix)): sum = 0 for j in range(len(matrix[i])): sum += matrix[i][j] * vector[j]
s515347797
Accepted
30
7,988
306
n,m =[int(r) for r in input().split()] matrix = [] for ni in range(n): matrix.append([int(a)for a in input().split()]) vector = [] for mi in range(m): vector.append(int(input())) for ni in range(n): sum = 0 for mi in range(m): sum += matrix[ni][mi] * vector[mi] print(sum)
s070563010
p03068
u250102437
2,000
1,048,576
Wrong Answer
17
3,060
425
You are given a string S of length N consisting of lowercase English letters, and an integer K. Print the string obtained by replacing every character in S that differs from the K-th character of S, with `*`.
# -*- coding: utf-8 -*- from sys import stdin ############################################ # read data for n sequences. n = stdin.readline() N = int(n) n = stdin.readline() S = str(n) n = stdin.readline() K = int(n) #data = [int(stdin.readline().rstrip()) for _ in range(n)] key = S[K] out=[] for i,l in enumerate(S): if l != key: out.append("*") else: out.append(l) out1='' for o in out: out1+=o print(out1)
s055559991
Accepted
17
3,064
467
# -*- coding: utf-8 -*- from sys import stdin ############################################ # read data for n sequences. n = stdin.readline() N = int(n) n = stdin.readline() S = str(n) n = stdin.readline() K = int(n) #data = [int(stdin.readline().rstrip()) for _ in range(n)] key = S[K-1] out=[] for i,l in enumerate(S): if i < N: if l != key: out.append("*") elif l =="\n": x=1 else: out.append(l) out1='' for o in out: out1+=o print(out1)
s655324624
p03079
u114648678
2,000
1,048,576
Wrong Answer
17
2,940
105
You are given three integers A, B and C. Determine if there exists an equilateral triangle whose sides have lengths A, B and C.
A,B,C=map(int,input().split()) if A+B>=C and B+C>=A and C+A>=B: print('YES') else : print('NO')
s633917944
Accepted
18
2,940
91
A,B,C=map(int,input().split()) if A==B and B==C: print('Yes') else : print('No')
s121524113
p02690
u735891571
2,000
1,048,576
Wrong Answer
32
9,184
281
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.
X = int(input()) lis = [] for i in range(-200, 201): lis.append(i**5) flag = 0 for a, i in enumerate(lis): for b, j in enumerate(lis): if (i + j == X) or (j - i == X): flag = 1 break if flag == 1: break print(a-200, b-200)
s644411459
Accepted
37
9,196
293
X = int(input()) lis = [] for i in range(-200, 201): lis.append(i**5) flag = 0 for a, i in enumerate(lis): for b, j in enumerate(lis): if (i + j == X) or (j - i == X): flag = 1 break if flag == 1: break print((a-200)*(-1), (b-200)*(-1))
s188458620
p02865
u541475502
2,000
1,048,576
Wrong Answer
20
3,316
27
How many ways are there to choose two distinct positive integers totaling N, disregarding the order?
a = int(input()) print(a-1)
s384327586
Accepted
17
2,940
72
a = int(input()) if a % 2 == 0: print(a//2-1) else: print(a//2)
s108576715
p03846
u941753895
2,000
262,144
Wrong Answer
101
13,812
752
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
a=1000000007 n=int(input()) if n==5: exit() l=list(map(int,input().split())) l.sort() if n%2==1: if l[0]!=0: print(0) exit() else: l.remove(0) sh=2 f=0 for i in l: if f==0: if i!=sh: print(0) exit() else: f=1 else: if i!=sh: print(0) exit() else: sh+=2 f=0 sh=(n-1)//2 b=1 for i in range(sh): b*=2 b%=a print(b) else: sh=1 f=0 for i in l: if f==0: if i!=sh: print(0) exit() else: f=1 else: if i!=sh: print(0) exit() else: sh+=2 f=0 sh=n//2 b=1 for i in range(sh): b*=2 b%=a print(b)
s786978794
Accepted
104
16,300
549
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time sys.setrecursionlimit(10**7) inf=10**20 mod=10**9+7 def LI(): return list(map(int,input().split())) def I(): return int(input()) def LS(): return input().split() def S(): return input() def main(): n=I() l=LI() l.sort() if n%2==0: for i in range(n//2): if l[i]!=i//2*2+1: return 0 else: if l[0]!=0: return 0 for i in range(1,n): if -(-i//2)*2!=l[i]: return 0 return pow(2,n//2)%mod print(main())
s024013374
p03386
u606033239
2,000
262,144
Wrong Answer
2,104
2,940
112
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()) s = list(i for i in range(a,b+1) if i<=a+k-1 or i>=b+1-k) s.sort() print(s)
s579568070
Accepted
19
3,060
99
a,b,k=map(int,input().split()) s=range(a,b+1) for i in sorted(set(s[:k])|set(s[-k:])): print(i)
s377844458
p03369
u496744988
2,000
262,144
Wrong Answer
17
2,940
131
In "Takahashi-ya", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions). A customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is three characters long, and if the first character in S is `o`, it means the ramen should be topped with boiled egg; if that character is `x`, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen. Write a program that, when S is given, prints the price of the corresponding bowl of ramen.
s=input() price=0 if s[0] == 'o': price += 700 if s[1] == 'o': price += 100 if s[2] == 'o': price += 100 print(price)
s645034901
Accepted
17
2,940
133
s=input() price=700 if s[0] == 'o': price += 100 if s[1] == 'o': price += 100 if s[2] == 'o': price += 100 print(price)
s031530029
p03493
u221888299
2,000
262,144
Wrong Answer
18
3,060
229
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.
print('数字を連続で入力') s1,s2,s3 = map(int, input()) while s1<0 or s1>1 or s2<0 or s2>1 or s3<0 or s3>1: print('数字を連続で再入力') s1,s2,s3 = map(int, input()) ans = s1+s2+s3 print("{}".format(ans))
s722553288
Accepted
17
2,940
31
n = input() print(n.count('1'))
s001594685
p03795
u982591663
2,000
262,144
Wrong Answer
17
2,940
45
Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
N = int(input()) print(800*N + 200*(N//15))
s566036847
Accepted
17
2,940
45
N = int(input()) print(800*N - 200*(N//15))
s899331886
p03698
u445404615
2,000
262,144
Wrong Answer
17
2,940
110
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.
s = input() for i in range(len(s)): if s.count(s[i]) != 1: print('No') exit() print('Yes')
s048115512
Accepted
17
2,940
110
s = input() for i in range(len(s)): if s.count(s[i]) != 1: print('no') exit() print('yes')
s214162820
p03605
u844789719
2,000
262,144
Wrong Answer
17
2,940
77
It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
N = input() if N[0] == 9 or N[1] == 9: print('Yes') else: print('No')
s771563712
Accepted
17
2,940
81
N = input() if N[0] == '9' or N[1] == '9': print('Yes') else: print('No')
s608645557
p02409
u682153677
1,000
131,072
Wrong Answer
20
5,628
1,047
You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room. For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth floor at building b. If v is negative, it means that −v persons left. Assume that initially no person lives in the building.
# -*- coding: utf-8 -*- a = {} b = {} c = {} d = {} for i in range(1, 30): a[i] = 0 b[i] = 0 c[i] = 0 d[i] = 0 n = int(input()) for j in range(n): m = list(map(int, input().split())) if m[0] == 1: a[m[2] + 10 * (m[1] - 1)] = a[m[2] + 10 * (m[1] - 1)] + m[3] elif m[0] == 2: b[m[2] + 10 * (m[1] - 1)] = b[m[2] + 10 * (m[1] - 1)] + m[3] elif m[0] == 3: c[m[2] + 10 * (m[1] - 1)] = b[m[2] + 10 * (m[1] - 1)] + m[3] elif m[0] == 4: d[m[2] + 10 * (m[1] - 1)] = d[m[2] + 10 * (m[1] - 1)] + m[3] for i in range(1, 3): for j in range(1, 10): print(' {0}'.format(a[i * j]), end='') print('####################') for i in range(1, 3): for j in range(1, 10): print(' {0}'.format(b[i * j]), end='') print('####################') for i in range(1, 3): for j in range(1, 10): print(' {0}'.format(c[i * j]), end='') print('####################') for i in range(1, 3): for j in range(1, 10): print(' {0}'.format(d[i * j]), end='')
s503111558
Accepted
20
5,640
1,139
# -*- coding: utf-8 -*- a = {} b = {} c = {} d = {} for i in range(1, 31): a[i] = 0 b[i] = 0 c[i] = 0 d[i] = 0 n = int(input()) for j in range(n): m = list(map(int, input().split())) if m[0] == 1: a[m[2] + 10 * (m[1] - 1)] = a[m[2] + 10 * (m[1] - 1)] + m[3] elif m[0] == 2: b[m[2] + 10 * (m[1] - 1)] = b[m[2] + 10 * (m[1] - 1)] + m[3] elif m[0] == 3: c[m[2] + 10 * (m[1] - 1)] = c[m[2] + 10 * (m[1] - 1)] + m[3] elif m[0] == 4: d[m[2] + 10 * (m[1] - 1)] = d[m[2] + 10 * (m[1] - 1)] + m[3] for i in range(1, 4): for j in range(1, 11): print(' {0}'.format(a[j + 10 * (i - 1)]), end='') print() print('####################') for i in range(1, 4): for j in range(1, 11): print(' {0}'.format(b[j + 10 * (i - 1)]), end='') print() print('####################') for i in range(1, 4): for j in range(1, 11): print(' {0}'.format(c[j + 10 * (i - 1)]), end='') print() print('####################') for i in range(1, 4): for j in range(1, 11): print(' {0}'.format(d[j + 10 * (i - 1)]), end='') print()
s451866700
p02694
u861471387
2,000
1,048,576
Wrong Answer
23
9,260
118
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
import math X = int(input()) m = 100 ans = 0 while m<X: m=math.floor(m*1.01) ans+=1 print(m) print(ans)
s682066078
Accepted
20
9,168
105
import math X = int(input()) m = 100 ans = 0 while m<X: m=math.floor(m*1.01) ans+=1 print(ans)
s194864077
p02694
u706908631
2,000
1,048,576
Wrong Answer
23
9,156
127
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
N = int(input()) X = 100 count = 0 while True: if X >= N: print(count) break else: X = X + (X * 0.01)
s013048766
Accepted
23
9,168
142
N = int(input()) X = 100 count = 0 while True: if X >= N: print(count) break else: X = int(X + (X * 0.01)) count += 1
s173439186
p03711
u706828591
2,000
262,144
Wrong Answer
17
2,940
243
Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below. Given two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.
x, y = map(int,input().split()) #ls = list(map(int,input().split())) #r = int(input()) #s = input() ls = [4,6,9,11] if (ls.count(x) == 1 and ls.count(y) == 1) or (x == 2 and y == 2): print("Yes") else: print("No")
s892766986
Accepted
17
3,060
308
x, y = map(int,input().split()) #ls = list(map(int,input().split())) #r = int(input()) #s = input() ls = [4,6,9,11] if (ls.count(x) == 1 and ls.count(y) == 1) or (x == 2 and y == 2) or (ls.count(x) != 1 and x != 2 and y != 2 and ls.count(y) != 1): print("Yes") else: print("No")
s380998996
p03681
u622045059
2,000
262,144
Wrong Answer
2,107
83,316
289
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.
import sys sys.setrecursionlimit(1000000) N,M = map(int, input().split()) print(sys.getrecursionlimit()) if abs(N-M) > 1: print(0) exit() def frac(n): if n == 1: return 1 return n * frac(n-1) if N-M == 0: print(frac(N)*frac(M)*2) else: print(frac(N)*frac(M))
s732989693
Accepted
491
5,184
306
from math import factorial N,M = map(int, input().split()) mod = 10 ** 9 + 7 if abs(N-M) > 1: print(0) exit() n_frac = factorial(N) m_frac = n_frac if N-M == 0: print((n_frac*m_frac)*2%mod) else: if N > M: m_frac //= N else: m_frac *= M print(n_frac*m_frac%mod)
s476664930
p03433
u951980350
2,000
262,144
Wrong Answer
18
2,940
161
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 A >= N: print("yes") else: n = N % 500 if n != 0 and A >= n: print("yes") else: print("no")
s503200843
Accepted
18
2,940
173
N = int(input()) A = int(input()) if A >= N: print("Yes") else: n = N % 500 if n == 0 or (n != 0 and A >= n): print("Yes") else: print("No")
s216508789
p03400
u280512618
2,000
262,144
Wrong Answer
18
2,940
107
Some number of chocolate pieces were prepared for a training camp. The camp had N participants and lasted for D days. The i-th participant (1 \leq i \leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on. As a result, there were X chocolate pieces remaining at the end of the camp. During the camp, nobody except the participants ate chocolate pieces. Find the number of chocolate pieces prepared at the beginning of the camp.
n=int(input()) d,x=map(int,input().split()) s=d*(1+d)//2 print(x+n*d+sum(int(input()) for _ in range(n))*s)
s470955275
Accepted
20
2,940
97
n=int(input()) d,x=map(int,input().split()) print(x+n+sum((d-1)//int(input()) for _ in range(n)))
s201415269
p03699
u488178971
2,000
262,144
Wrong Answer
17
2,940
247
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well. However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
N = int(input()) S = [] for i in range(N): S.append(int(input())) sorted(S) if sum(S)%10!=0: print(sum(S)) else: while len(S)>0: S.pop(0) if sum(S)%10!=0 or len(S)==0: print(sum(S)) exit()
s958115346
Accepted
18
3,064
261
N = int(input()) S = [] for i in range(N): S.append(int(input())) nb10 = ([s for s in S if s%10 != 0]) b10 = ([s for s in S if s%10 == 0]) if sum(S)%10!=0: print(sum(S)) elif sum(S) ==sum(b10): print(0) else: print(sum(S)-sorted(nb10)[0])