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
s667144022
p03478
u429541300
2,000
262,144
Wrong Answer
1,234
3,060
185
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).
n, a, b = map(int, input().split()) ans = 0 for i in range(n+1): m = 0 while i != 0: m += int(n % 10) i = i / 10 if a <= m <= b: ans += m print(ans)
s851008662
Accepted
37
2,940
202
n, a, b = map(int, input().split()) ans = 0 for i in range(n+1): m = 0 i0 = i while i != 0: m += int(i % 10) i = int(i / 10) if a <= m <= b: ans += i0 print(ans)
s460943702
p03494
u811000506
2,000
262,144
Wrong Answer
17
3,060
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.
N = int(input()) A = list(map(int,input().split())) A.sort() count = 0 while(True): if A[0] % 2 == 0: A[0] = A[0] // 2 count += 1 else: break print(count)
s710393902
Accepted
19
3,064
280
N = int(input()) A = list(map(int,input().split())) i = 0 count = 0 flag = False while (True): for i in range(N): if A[i] % 2 != 0: flag = True break if flag == True: break for i in range(N): A[i] = A[i] // 2 count += 1 print(count)
s758116950
p03657
u050641473
2,000
262,144
Wrong Answer
18
2,940
128
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()) if A % 3 == 0 or B % 3 == 0 or A + B % 3 == 0: print("Possible") else: print("Impossible")
s603986549
Accepted
18
2,940
130
A, B = map(int, input().split()) if A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0: print("Possible") else: print("Impossible")
s995007841
p02396
u796301295
1,000
131,072
Wrong Answer
140
5,608
125
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.
a = 1 while True: n = int(input()) if n == 0: break print ("case " + str(a) + ": " + str(n)) a += 1
s332070304
Accepted
140
5,608
125
a = 1 while True: n = int(input()) if n == 0: break print ("Case " + str(a) + ": " + str(n)) a += 1
s359904804
p02396
u643542669
1,000
131,072
Wrong Answer
20
5,596
129
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.
inpu_list = list(map(int, input().split())) for i in range(len(inpu_list) - 1): print("Case %d: %d" % (i + 1, inpu_list[i]))
s110302093
Accepted
70
6,248
143
array = [] x = input() while x != "0": array.append(x) x = input() for i, x in enumerate(array): print("Case %d: %s" % (i + 1, x))
s451602910
p03574
u403355272
2,000
262,144
Wrong Answer
43
4,228
873
You are given an H × W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square containing a bomb. Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square. (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.) He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square. Print the strings after the process.
h,m = map(int,input().split()) s = [input() for i in range(h)] ans = [[] for i in range(h)] for i in range(h): for j in range(m): if s[i][j] == "#": ans[i].append("#") else: count = 0 s1=[[i-1,j],[i+1,j],[i,j-1],[i,j+1]] s2=[[i-1,j+1],[i+1,j+1],[i+1,j-1],[i-1,j-1]] for temp in s1 : i2=temp[0];j2=temp[1] print(i2,j2) if i2<0 or h-1<i2 or j2<0 or m-1<j2: continue if s[i2][j2]=="#": count+=1 for temp in s2 : i2=temp[0];j2=temp[1] if i2<0 or h-1<i2 or j2 <0 or m-1<j2 : continue if s[i2][j2]=="#": count+=1 ans[i].append(count) for i in range(h): print(*ans[i],sep="")
s365403365
Accepted
31
3,572
844
h,m = map(int,input().split()) s = [input() for i in range(h)] ans = [[] for i in range(h)] for i in range(h): for j in range(m): if s[i][j] == "#": ans[i].append("#") else: count = 0 s1=[[i-1,j],[i+1,j],[i,j-1],[i,j+1]] s2=[[i-1,j+1],[i+1,j+1],[i+1,j-1],[i-1,j-1]] for temp in s1 : i2=temp[0];j2=temp[1] if i2<0 or h-1<i2 or j2<0 or m-1<j2: continue if s[i2][j2]=="#": count+=1 for temp in s2 : i2=temp[0];j2=temp[1] if i2<0 or h-1<i2 or j2 <0 or m-1<j2 : continue if s[i2][j2]=="#": count+=1 ans[i].append(count) for i in range(h): print(*ans[i],sep="")
s677843757
p03434
u000349418
2,000
262,144
Wrong Answer
19
3,060
166
We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.
n=int(input()) A=list(map(int,input().split(' '))) A.sort() a=0 b=0 i=0 while i < n: if i%2==0: a+= A[i] else: b += A[i] i += 1 print(a-b)
s714942350
Accepted
17
3,060
171
n=int(input()) A=list(map(int,input().split(' '))) A.sort() a=0 b=0 i=0 while i < n: if i%2==0: a+= A[i] else: b += A[i] i += 1 print(abs(a-b))
s873635310
p03388
u046187684
2,000
262,144
Wrong Answer
19
3,060
378
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.
from math import sqrt, floor q = int(input()) for _ in range(q): a, b = map(int, input().split(" ")) if a == b: print(2 * a - 2) elif max(a, b) - min(a, b) == 1: print(2 * min(a, b) - 2) else: if sqrt(a * b) == floor(sqrt(a * b)): print(2 * floor(sqrt(a * b)) - 3) else: print(2 * floor(sqrt(a * b)) - 1)
s022197937
Accepted
18
3,064
530
from math import sqrt def solve(string): q, *ab = map(int, string.split()) ans = [] for a, b in zip(ab[::2], ab[1::2]): c = a * b d = int(sqrt(c)) answer = 2 * d - 2 if d * d == c: answer -= 1 if d * (d + 1) < c: answer += 1 if a == b: answer += 1 ans.append(str(answer)) return "\n".join(ans) if __name__ == '__main__': n = int(input()) print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(n)])))
s307441597
p03693
u573670713
2,000
262,144
Wrong Answer
17
2,940
109
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().strip().split())) if a*100 + b*10 +c %4 ==0: print("YES") else: print("NO")
s273610236
Accepted
17
2,940
113
a,b,c = list(map(int,input().strip().split())) if (a *100 +b*10 +c) % 4 == 0: print("YES") else: print("NO")
s706311183
p03475
u187205913
3,000
262,144
Wrong Answer
124
3,064
384
A railroad running from west to east in Atcoder Kingdom is now complete. There are N stations on the railroad, numbered 1 through N from west to east. Tomorrow, the opening ceremony of the railroad will take place. On this railroad, for each integer i such that 1≤i≤N-1, there will be trains that run from Station i to Station i+1 in C_i seconds. No other trains will be operated. The first train from Station i to Station i+1 will depart Station i S_i seconds after the ceremony begins. Thereafter, there will be a train that departs Station i every F_i seconds. Here, it is guaranteed that F_i divides S_i. That is, for each Time t satisfying S_i≤t and t%F_i=0, there will be a train that departs Station i t seconds after the ceremony begins and arrives at Station i+1 t+C_i seconds after the ceremony begins, where A%B denotes A modulo B, and there will be no other trains. For each i, find the earliest possible time we can reach Station N if we are at Station i when the ceremony begins, ignoring the time needed to change trains.
n = int(input()) l = [list(map(int,input().split())) for _ in range(n-1)] ans = [] for i in range(len(l)): m = l[i][1] for j in range(i,len(l)): if m<l[j][1]: m = l[j][1]+l[j][0] elif m==l[j][1] or (m-l[j][1])%l[j][2]==0: m += l[j][0] else: m += (m-l[j][1])%l[j][2]+l[j][0] ans.append(m) ans.append(0) print(ans)
s781292398
Accepted
127
3,188
422
n = int(input()) l = [list(map(int,input().split())) for _ in range(n-1)] ans = [] for i in range(len(l)): m = l[i][1] for j in range(i,len(l)): if m<l[j][1]: m = l[j][1]+l[j][0] elif m==l[j][1] or (m-l[j][1])%l[j][2]==0: m += l[j][0] else: next = l[j][2]-m%l[j][2] m += next+l[j][0] ans.append(m) ans.append(0) for i in ans: print(i)
s796064281
p03418
u692746605
2,000
262,144
Wrong Answer
87
2,940
142
Takahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten. He remembers that the remainder of a divided by b was greater than or equal to K. Find the number of possible pairs that he may have had.
N,K=map(int,input().split()) t=0 for b in range(K+1,N+1): t+=(N//b)*(b-K)+(N%b-K+(1 if K>0 else 0) if N%b>=K else 0)if N%b else 0 print(t)
s481324442
Accepted
84
2,940
121
N,K=map(int,input().split()) t=0 for b in range(K+1,N+1): t+=(-~N//b)*(b-K)+max(-~N%b-K,0) print(t-(0 if K else N-K))
s641276527
p03635
u618373524
2,000
262,144
Wrong Answer
17
2,940
43
In _K-city_ , there are n streets running east-west, and m streets running north-south. Each street running east-west and each street running north-south cross each other. We will call the smallest area that is surrounded by four streets a block. How many blocks there are in K-city?
s = input() print(s[0]+str(len(s)-2)+s[-1])
s579694488
Accepted
17
2,940
55
a,b = map(int,input().split()) c = (a-1)*(b-1) print(c)
s425279622
p03469
u428467389
2,000
262,144
Wrong Answer
17
2,940
129
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() count=0 if(S[0]=="o"): count+=1 if(S[1]=="o"): count+=1 if(S[2]=="o"): count+=1 print(700+100*count)
s449741183
Accepted
17
2,940
60
S = input() S = list(S) S[3]="8" S = "".join(S) print(S)
s774278114
p03643
u077291787
2,000
262,144
Wrong Answer
17
2,940
216
This contest, _AtCoder Beginner Contest_ , is abbreviated as _ABC_. When we refer to a specific round of ABC, a three-digit number is appended after ABC. For example, ABC680 is the 680th round of ABC. What is the abbreviation for the N-th round of ABC? Write a program to output the answer.
def main(): X = int(input()) ans, r = X // 11 * 2, X % 11 # r: remainder ans += 1 if 0 < r <= 6 else 2 print(ans) if __name__ == "__main__": main()
s887206440
Accepted
17
2,940
123
def main(): N = input().rstrip() print("ABC", N, sep="") if __name__ == "__main__": main()
s569448379
p03478
u829796346
2,000
262,144
Time Limit Exceeded
2,104
2,940
165
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).
N,A,B = map(int, input().split()) ret = 0 for i in range(N): c = 0 while i: c,mod = divmod(i,10) c += mod if A <= c and c <= B: ret += i print(ret)
s729857710
Accepted
33
2,940
146
N,A,B = map(int, input().split()) ret = 0 for i in range(N+1): s = sum([int(c) for c in str(i)]) if A <= s and s <= B: ret += i print(ret)
s269549112
p03610
u584870699
2,000
262,144
Wrong Answer
63
3,828
81
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.
s=input() for num,moji in enumerate(s): if((num+1)%2==0): print(moji)
s305316929
Accepted
17
3,188
23
s=input() print(s[::2])
s064265803
p03644
u697696097
2,000
262,144
Wrong Answer
17
2,940
197
Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times.
n=int(input()) maxx=0 maxn=0 for i in range(1,n+1): tmp=i cnt=0 while 1: if tmp%2==0: tmp=tmp//2 cnt+=1 else: break if cnt > maxx: maxn=tmp print(maxn)
s680366742
Accepted
17
3,060
202
n=int(input()) maxx=0 maxn=1 for i in range(1,n+1): tmp=i cnt=0 while 1: if tmp%2==0: tmp=tmp//2 cnt+=1 else: break if cnt > maxx: maxn=i maxx=cnt print(maxn)
s030593627
p04011
u785470389
2,000
262,144
Wrong Answer
18
2,940
127
There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.
n = int(input()) k = int(input()) x = int(input()) y = int(input()) price = k * x price = price + (n - k) * y print = (price)
s572422431
Accepted
17
2,940
169
n = int(input()) k = int(input()) x = int(input()) y = int(input()) if n > k: price = k * x price = price + (n - k) * y elif n <= k: price = n * x print(price)
s468729563
p02256
u227984374
1,000
131,072
Wrong Answer
20
5,592
134
Write a program which finds the greatest common divisor of two natural numbers _a_ and _b_
x, y = map(int, input().split()) if x > y : pass else : x, y = y, x while x % y != 0 : y = x % y x = y print(y)
s831188512
Accepted
30
5,596
144
x, y = map(int, input().split()) if x > y : pass else : x, y = y, x while x % y != 0 : d = x % y x = y y = d print(y)
s018301110
p03472
u169138653
2,000
262,144
Wrong Answer
852
42,404
391
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?
from math import ceil n,h=map(int,input().split()) g=[list(map(int,input().split())) for i in range(n)] l=[] ans=0 dm=0 for i in range(n): l.append([g[i][0],2]) l.append([g[i][1],1]) l.sort(reverse=True) for i in range(2*n): if l[i][1]==1: dm+=l[i][0] ans+=1 if dm>=h: print(ans) exit() else: h-=dm ans+=ceil(h//l[i][0]) print(ans) exit()
s528282858
Accepted
748
42,404
390
from math import ceil n,h=map(int,input().split()) g=[list(map(int,input().split())) for i in range(n)] l=[] ans=0 dm=0 for i in range(n): l.append([g[i][0],2]) l.append([g[i][1],1]) l.sort(reverse=True) for i in range(2*n): if l[i][1]==1: dm+=l[i][0] ans+=1 if dm>=h: print(ans) exit() else: h-=dm ans+=ceil(h/l[i][0]) print(ans) exit()
s586985377
p03556
u923659712
2,000
262,144
Wrong Answer
18
2,940
126
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()) for i in range(1,n): if i**i>n: print((i-1)**(i-1)) exit() elif i**i==n: print(i**i) exit()
s947504727
Accepted
26
2,940
124
n=int(input()) for i in range(1,n+1): if i*i>n: print((i-1)*(i-1)) exit() elif i*i==n: print(i*i) exit()
s411886406
p02388
u706217959
1,000
131,072
Wrong Answer
20
5,596
223
Write a program which calculates the cube of a given integer x.
def main(): n = int(input()) if n < 1 or n > 100: print("invalid answer.") return ans = n * 3 print("{0}".format(ans)) if __name__ == '__main__': main()
s862266567
Accepted
20
5,596
196
def main(): n = int(input()) if n <= 0 or n >= 101: print("invalid answer.") return ans = n * n * n print("{0}".format(ans)) if __name__ == '__main__': main()
s717222874
p03814
u161485415
2,000
262,144
Wrong Answer
39
9,340
192
Snuke has decided to construct a string that starts with `A` and ends with `Z`, by taking out a substring of a string s (that is, a consecutive part of s). Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with `A` and ends with `Z`.
a = input("") a_num = a.index("A") for i in range(len(a)-1,-1,-1): if a[i]=="Z": z_num = i+1 break print("num:" + str(len(a[a_num:z_num])) + \ "text:" + a[a_num:z_num])
s192489882
Accepted
38
9,244
145
a = input("") a_num = a.index("A") for i in range(len(a)-1,-1,-1): if a[i]=="Z": z_num = i+1 break print(len(a[a_num:z_num]))
s678595158
p03565
u371942102
2,000
262,144
Wrong Answer
21
3,188
383
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`.
from itertools import permutations import re def main(): s = input().replace('?', '.') t = input() for i in reversed(range(len(s) - len(t) + 1)): print(s[i:i + len(t)]) if re.search(s[i:i + len(t)], t): result = (s[:i] + t + s[i + len(t):]).replace('.', 'a') print(result) return print('UNRESTORABLE ') main()
s430221685
Accepted
21
3,188
384
from itertools import permutations import re def main(): s = input().replace('?', '.') t = input() for i in reversed(range(len(s) - len(t) + 1)): # print(s[i:i + len(t)]) if re.search(s[i:i + len(t)], t): result = (s[:i] + t + s[i + len(t):]).replace('.', 'a') print(result) return print('UNRESTORABLE') main()
s885564730
p03150
u197704813
2,000
1,048,576
Wrong Answer
18
3,064
636
A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
S = input() if S[0:7] == "keyence": print("YES") elif S[len(S)-8:len(S)-1] == "keyence": print("YES") else: if (S[0] == "k")and(S[len(S)-7:len(S)-1] == "eyence"): print("YES") elif (S[0] == "ke")and(S[len(S)-6:len(S)-1] == "yence"): print("YES") elif (S[0] == "key")and(S[len(S)-5:len(S)-1] == "ence"): print("YES") elif (S[0] == "keye")and(S[len(S)-4:len(S)-1] == "nce"): print("YES") elif (S[0] == "keyen")and(S[len(S)-3:len(S)-1] == "ce"): print("YES") elif (S[0] == "keyenc")and(S[len(S)-2:len(S)-1] == "e"): print("YES") else: print("NO")
s404767190
Accepted
17
3,064
634
S = input() if S[0:7] == "keyence": print("YES") elif S[len(S)-7:len(S)] == "keyence": print("YES") else: if (S[0:1] == "k")and(S[len(S)-6:len(S)] == "eyence"): print("YES") elif (S[0:2] == "ke")and(S[len(S)-5:len(S)] == "yence"): print("YES") elif (S[0:3] == "key")and(S[len(S)-4:len(S)] == "ence"): print("YES") elif (S[0:4] == "keye")and(S[len(S)-3:len(S)] == "nce"): print("YES") elif (S[0:5] == "keyen")and(S[len(S)-2:len(S)] == "ce"): print("YES") elif (S[0:6] == "keyenc")and(S[len(S)-1:len(S)] == "e"): print("YES") else: print("NO")
s224918716
p02748
u581320767
2,000
1,048,576
Wrong Answer
599
40,864
320
You are visiting a large electronics store to buy a refrigerator and a microwave. The store sells A kinds of refrigerators and B kinds of microwaves. The i-th refrigerator ( 1 \le i \le A ) is sold at a_i yen (the currency of Japan), and the j-th microwave ( 1 \le j \le B ) is sold at b_j yen. You have M discount tickets. With the i-th ticket ( 1 \le i \le M ), you can get a discount of c_i yen from the total price when buying the x_i-th refrigerator and the y_i-th microwave together. Only one ticket can be used at a time. You are planning to buy one refrigerator and one microwave. Find the minimum amount of money required.
A, B, M = map(int, input().split()) ref = list(map(int, input().split())) mic = list(map(int, input().split())) coupons = [ list(map(int, input().split())) for i in range(M)] ans = min(ref) + min(mic) for i in coupons: print(i) price = ref[i[0]-1] + mic[i[1]-1] - i[2] if price < ans: ans = price print(ans)
s072377276
Accepted
456
38,488
309
A, B, M = map(int, input().split()) ref = list(map(int, input().split())) mic = list(map(int, input().split())) coupons = [ list(map(int, input().split())) for i in range(M)] ans = min(ref) + min(mic) for i in coupons: price = ref[i[0]-1] + mic[i[1]-1] - i[2] if price < ans: ans = price print(ans)
s559569579
p02664
u607180061
2,000
1,048,576
Wrong Answer
88
10,824
221
For a string S consisting of the uppercase English letters `P` and `D`, let the _doctoral and postdoctoral quotient_ of S be the total number of occurrences of `D` and `PD` in S as contiguous substrings. For example, if S = `PPDDP`, it contains two occurrences of `D` and one occurrence of `PD` as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3. We have a string T consisting of `P`, `D`, and `?`. Among the strings that can be obtained by replacing each `?` in T with `P` or `D`, find one with the maximum possible doctoral and postdoctoral quotient.
t = list(input()) for i in range(len(t)): if t[i] == '?': if i == len(t) - 1: t[i] = 'D' elif t[i+1] == 'D': t[i] = 'P' else: t[i] = 'D' print(''.join(t))
s283121266
Accepted
82
10,800
342
t = list(input()) tl = len(t) for i in range(tl): if t[i] != '?': continue if tl == 1: t[i] = 'D' elif i == tl - 1: t[i] = 'D' elif t[i-1] == 'P': t[i] = 'D' elif t[i+1] == '?': t[i] = 'P' elif t[i+1] == 'D': t[i] = 'P' else: t[i] = 'D' print(''.join(t))
s032882210
p02613
u631579948
2,000
1,048,576
Wrong Answer
153
16,448
306
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.
a=int(input()) AC=[] WA=[] TLE=[] RE=[] for i in range(a): s=(input()) if s=='AC': AC.append(s) if s=='TLE': TLE.append(s) if s=='WA': WA.append(s) if s=='RE': RE.append(s) print('AC ×',len(AC)) print('WA ×',len(WA)) print('TLE ×',len(TLE)) print('RE ×',len(RE))
s805011114
Accepted
161
16,436
310
a=int(input()) AC=[] WA=[] TLE=[] RE=[] for i in range(a): s=(input()) if s=='AC': AC.append(s) if s=='TLE': TLE.append(s) if s=='WA': WA.append(s) if s=='RE': RE.append(s) print('AC','x',len(AC)) print('WA','x',len(WA)) print('TLE','x',len(TLE)) print('RE','x',len(RE))
s695357232
p03369
u969848070
2,000
262,144
Wrong Answer
17
2,940
41
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.
a = input() b = a.count('o') print(700+b)
s736514061
Accepted
17
2,940
46
a = input() b = a.count('o') print(700+b*100)
s217912442
p03449
u668726177
2,000
262,144
Wrong Answer
17
3,060
184
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()) upper = list(map(int, input().split())) lower = list(map(int, input().split())) ans = 0 for i in range(n): ans = max(ans, sum(upper[:i])+sum(lower[i:])) print(ans)
s841915197
Accepted
18
3,060
186
n = int(input()) upper = list(map(int, input().split())) lower = list(map(int, input().split())) ans = 0 for i in range(n): ans = max(ans, sum(upper[:i+1])+sum(lower[i:])) print(ans)
s077626551
p03457
u065578867
2,000
262,144
Wrong Answer
365
11,816
552
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()) t = [0] x = [0] y = [0] count = 0 for i in range(n): val_list = input().split() if val_list: t.append(int(val_list[0])) x.append(int(val_list[1])) y.append(int(val_list[2])) for i in range(n): distance = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]) if distance > t[i + 1] - t[i]: break elif distance == t[i + 1] - t[i]: count += 1 elif distance - (t[i + 1] - t[i]) % 2 == 0: count += 1 else: break if count == n: print('YES') else: print('NO')
s990864447
Accepted
357
11,816
552
n = int(input()) t = [0] x = [0] y = [0] count = 0 for i in range(n): val_list = input().split() if val_list: t.append(int(val_list[0])) x.append(int(val_list[1])) y.append(int(val_list[2])) for i in range(n): distance = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]) if distance > t[i + 1] - t[i]: break elif distance == t[i + 1] - t[i]: count += 1 elif distance - (t[i + 1] - t[i]) % 2 == 0: count += 1 else: break if count == n: print('Yes') else: print('No')
s734352756
p02399
u072053884
1,000
131,072
Wrong Answer
40
7,676
113
Write a program which reads two integers a and b, and calculates the following values: * a ÷ b: d (in integer) * remainder of a ÷ b: r (in integer) * a ÷ b: f (in real number)
a, b = [int(x) for x in input().split(' ')] d = a // b r = a % b f = a / b print("{0} {1} {2}".format(d, r, f))
s946029396
Accepted
20
7,692
117
a, b = [int(x) for x in input().split(' ')] d = a // b r = a % b f = a / b print("{0} {1} {2:.5f}".format(d, r, f))
s285382268
p03545
u610042046
2,000
262,144
Wrong Answer
29
9,156
363
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.
num = input() ls = [0] * 3 for i in range(2 ** 3): make7 = int(num[0]) for j in range(3): if (i >> j) & 1: make7 += int(num[j+1]) ls[j] = "+" else: make7 -= int(num[j+1]) ls[j] = "-" if make7 == 7: print(num[0] + ls[0] + num[1] + ls[1] + num[2] + ls[2] + num[3]) exit()
s664576696
Accepted
29
9,148
370
num = input() ls = [0] * 3 for i in range(2 ** 3): make7 = int(num[0]) for j in range(3): if (i >> j) & 1: make7 += int(num[j+1]) ls[j] = "+" else: make7 -= int(num[j+1]) ls[j] = "-" if make7 == 7: print(num[0] + ls[0] + num[1] + ls[1] + num[2] + ls[2] + num[3] + "=7") exit()
s823097345
p03471
u985949234
2,000
262,144
Wrong Answer
1,191
3,060
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()) f = False for i in range(N+1): for j in range(N+1-i): if (Y-(10000*i + 5000*j))//1000 <=N-(i+j) and Y-(10000*i + 5000*j) >= 0: f = True anls = [i,j,(Y-(10000*i + 5000*j))//1000] if f: print(anls[0],anls[1],anls[2]) else: print(-1,-1,-1)
s360555598
Accepted
738
3,060
326
N,Y = map(int, input().split()) f = False for i in range(N+1): for j in range(N+1-i): if (Y-(10000*i + 5000*j))//1000 ==N-(i+j) and (Y-(10000*i + 5000*j))>=0: f = True anls = [i,j,N-(i+j)] if f: print(anls[0],anls[1],anls[2]) else: print(-1,-1,-1)
s094766550
p03131
u211160392
2,000
1,048,576
Wrong Answer
17
3,060
183
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 = (int(i) for i in input().split()) if A+2>=B: print(1+K) else: Bis = A K-=A-1 print(K) Bis += int(K/2)*(B-A) if(K)%2==1: Bis+=1 print(Bis)
s864822833
Accepted
17
2,940
170
K,A,B = (int(i) for i in input().split()) if A+2>=B: print(1+K) else: Bis = A K-=A-1 Bis += int(K/2)*(B-A) if(K)%2==1: Bis+=1 print(Bis)
s977564221
p03730
u821588465
2,000
262,144
Wrong Answer
29
9,128
133
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()) if any((a * i) % b == c for i in range(1, b+1)): print('Yes') else: print('No')
s502458608
Accepted
29
9,136
129
a, b, c = map(int, input().split()) if any((a * i) % b == c for i in range(1, b+1)): print('YES') else: print('NO')
s922127524
p03495
u815797488
2,000
262,144
Time Limit Exceeded
2,104
26,132
207
Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them.
N,K = map(int, input().split()) A = [int(i) for i in input().split()] l=[] for i in range(N+1): l.append(A.count(i)) ls = sorted(l,reverse=True) j= K ans = 0 while ls[j] != 0: ans += ls[j] print(ans)
s491903719
Accepted
104
32,564
194
import collections as co N,K = map(int, input().split()) A = list(map(int, input().split())) ldic = co.Counter(A) l = list(ldic.values()) ls = sorted(l,reverse=True) print(sum(ls[K:]))
s674061442
p03563
u962718741
2,000
262,144
Wrong Answer
26
9,088
38
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()))
s169734813
Accepted
27
9,180
39
print(-int(input()) + 2 * int(input()))
s314547755
p03470
u050428930
2,000
262,144
Wrong Answer
17
3,060
159
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,ans,x=int(input()),0,0 s=sorted([int(input()) for i in range(N)]) print(s) for i in range(N): if s[i]>x: ans+=1 x=s[i] print(ans)
s083584223
Accepted
17
3,060
150
N,ans,x=int(input()),0,0 s=sorted([int(input()) for i in range(N)]) for i in range(N): if s[i]>x: ans+=1 x=s[i] print(ans)
s844892724
p03711
u408791346
2,000
262,144
Wrong Answer
17
3,060
198
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.
a = [1,3, 5,7,8,10,12] b = [4,6,9,11] c = [2] x, y = map(int,input().split()) for i in a,b: if x in i and y in i: print('yes') break else: print('no') break
s901055731
Accepted
17
3,060
254
a = [1,3, 5,7,8,10,12] b = [4,6,9,11] c = [2] x, y = map(int,input().split()) ans = [] for i in a,b: if x in i and y in i: ans.append('Yes') else: ans.append('No') if 'Yes' in ans: print('Yes') else: print('No')
s507409527
p03711
u701318346
2,000
262,144
Wrong Answer
17
2,940
133
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 = input().split() g = ['4', '6', '9', '11'] if (x == y == 2) or g.count(x) == g.count(y) == 1: print('Yes') else: print('No')
s175611027
Accepted
17
3,060
248
x, y = input().split() a = ['4', '6', '9', '11'] b = ['1', '3', '5', '7', '8', '10', '12'] if (x == y == '2'): print('Yes') elif (a.count(x) == a.count(y) == 1): print('Yes') elif (b.count(x) == b.count(y) == 1): print('Yes') else: print('No')
s432774667
p02694
u603253967
2,000
1,048,576
Wrong Answer
30
10,120
530
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?
from collections import deque, Counter, defaultdict from itertools import chain, combinations import json # import numpy as np import bisect import sys import math import bisect from functools import lru_cache sys.setrecursionlimit(10 ** 8) M = 10 ** 9 + 7 INF = 10 ** 17 def main(): N = int(input()) # A = [int(a) for a in input().split()] c = 1 d = 100 while True: d = int(d * 1.01) if d > N: print(c) return c += 1 if __name__ == "__main__": main()
s108865193
Accepted
29
10,120
531
from collections import deque, Counter, defaultdict from itertools import chain, combinations import json # import numpy as np import bisect import sys import math import bisect from functools import lru_cache sys.setrecursionlimit(10 ** 8) M = 10 ** 9 + 7 INF = 10 ** 17 def main(): N = int(input()) # A = [int(a) for a in input().split()] c = 1 d = 100 while True: d = int(d * 1.01) if d >= N: print(c) return c += 1 if __name__ == "__main__": main()
s122801027
p03493
u898058223
2,000
262,144
Wrong Answer
17
2,940
61
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=input() ans=0 for i in range(3): if s[i]=="1": ans+=1
s734063479
Accepted
17
2,940
72
s=input() ans=0 for i in range(3): if s[i]=="1": ans+=1 print(ans)
s890354000
p00017
u567380442
1,000
131,072
Wrong Answer
30
6,720
399
In cryptography, Caesar cipher is one of the simplest and most widely known encryption method. Caesar cipher is a type of substitution cipher in which each letter in the text is replaced by a letter some fixed number of positions down the alphabet. For example, with a shift of 1, 'a' would be replaced by 'b', 'b' would become 'c', 'y' would become 'z', 'z' would become 'a', and so on. In that case, a text: this is a pen is would become: uijt jt b qfo Write a program which reads a text encrypted by Caesar Chipher and prints the corresponding decoded text. The number of shift is secret and it depends on datasets, but you can assume that the decoded text includes any of the following words: "the", "this", or "that".
import sys import string f = sys.stdin sentence = ''.join([line for line in f]) ceasar1 = str.maketrans(string.ascii_lowercase, string.ascii_lowercase[1:] + string.ascii_lowercase[:1]) for i in range(len(string.ascii_lowercase)): sentence = sentence.translate(ceasar1) for word in ['the', 'this', 'that']: if sentence.find(word) != -1: print(sentence) break
s201085568
Accepted
30
6,724
388
import sys import string f = sys.stdin ceasar1 = str.maketrans(string.ascii_lowercase, string.ascii_lowercase[1:] + string.ascii_lowercase[:1]) for sentence in f: for i in range(len(string.ascii_lowercase)): sentence = sentence.translate(ceasar1) if 'the' in sentence or 'this' in sentence or 'that' in sentence: print(sentence, end='') break
s827675389
p03068
u840988663
2,000
1,048,576
Wrong Answer
17
2,940
166
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 `*`.
n=input() m=input() l=int(input()) kotae="" key=m[l-1] for i in range(len(m)): if m[i] != key: kotae=kotae+"*" else: kotae=kotae+key
s263169764
Accepted
17
3,060
175
n=input() m=input() l=int(input()) kotae="" key=m[l-1] for i in range(len(m)): if m[i] != key: kotae=kotae+"*" else: kotae=kotae+key print(kotae)
s456161235
p03816
u047816928
2,000
262,144
Wrong Answer
91
17,400
210
Snuke has decided to play a game using cards. He has a deck consisting of N cards. On the i-th card from the top, an integer A_i is written. He will perform the operation described below zero or more times, so that the values written on the remaining cards will be pairwise distinct. Find the maximum possible number of remaining cards. Here, N is odd, which guarantees that at least one card can be kept. Operation: Take out three arbitrary cards from the deck. Among those three cards, eat two: one with the largest value, and another with the smallest value. Then, return the remaining one card to the deck.
N = int(input()) A = list(map(int, input().split())) D = {} for a in A: if a not in D: D[a] = 0 D[a] += 1 n2 = 0 for k in D: D[k] = 2 if D[k]%2==0 else 1 if D[k]==2: n2+=1 print(len(D) + n2%2)
s857062802
Accepted
93
18,272
210
N = int(input()) A = list(map(int, input().split())) D = {} for a in A: if a not in D: D[a] = 0 D[a] += 1 n2 = 0 for k in D: D[k] = 2 if D[k]%2==0 else 1 if D[k]==2: n2+=1 print(len(D) - n2%2)
s077752644
p03679
u071061942
2,000
262,144
Wrong Answer
18
2,940
124
Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though. Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Otherwise, he does not find it delicious. Takahashi bought some food A days before the "best-by" date, and ate it B days after he bought it. Write a program that outputs `delicious` if he found it delicious, `safe` if he did not found it delicious but did not get a stomachache either, and `dangerous` if he got a stomachache.
X,A,B = map(int,input().split()) if B-A <= 0: print("delicious") elif B-A >= X: print("safe") else: print("dangerous")
s660336828
Accepted
17
3,060
124
X,A,B = map(int,input().split()) if B-A <= 0: print("delicious") elif B-A <= X: print("safe") else: print("dangerous")
s783945213
p02613
u268674745
2,000
1,048,576
Wrong Answer
154
16,316
357
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 = [] wa = [] tle = [] re = [] for _ in range(n): i = input() if i == "WA": wa.append(i) elif i == "AC": ac.append(i) elif i == "TLE": tle.append(i) else: re.append(i) print("AC ×", str(len(ac))) print("WA ×", str(len(wa))) print("TLE ×", str(len(tle))) print("RE ×", str(len(re)))
s670311216
Accepted
153
16,328
333
n = int(input()) ac = [] wa = [] tle = [] re = [] for _ in range(n): i = input() if i == "WA": wa.append(i) elif i == "AC": ac.append(i) elif i == "TLE": tle.append(i) else: re.append(i) print("AC x", len(ac)) print("WA x", len(wa)) print("TLE x", len(tle)) print("RE x", len(re))
s782807743
p03023
u252828980
2,000
1,048,576
Wrong Answer
17
2,940
27
Given an integer N not less than 3, find the sum of the interior angles of a regular polygon with N sides. Print the answer in degrees, but do not print units.
print((int(input())-3)*180)
s107413161
Accepted
18
2,940
27
print((int(input())-2)*180)
s255376550
p02612
u208512038
2,000
1,048,576
Wrong Answer
32
9,140
33
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.
x = int(input()) print(x % 1000)
s595269052
Accepted
29
9,156
81
x = int(input()) a = x % 1000 if a == 0: print("0") exit() print(1000 - a)
s643809168
p03493
u041075929
2,000
262,144
Wrong Answer
20
2,940
255
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.
import sys, os f = lambda:list(map(int,input().split())) if 'local' in os.environ : sys.stdin = open('./input.txt', 'r') def solve(): s = input() ans = 0 for i in s: if i == '0': ans += 1 print(ans) solve()
s886825699
Accepted
17
2,940
255
import sys, os f = lambda:list(map(int,input().split())) if 'local' in os.environ : sys.stdin = open('./input.txt', 'r') def solve(): s = input() ans = 0 for i in s: if i == '1': ans += 1 print(ans) solve()
s878720571
p02601
u337949146
2,000
1,048,576
Wrong Answer
26
9,208
237
M-kun has the following three cards: * A red card with the integer A. * A green card with the integer B. * A blue card with the integer C. He is a genius magician who can do the following operation at most K times: * Choose one of the three cards and multiply the written integer by 2. His magic is successful if both of the following conditions are satisfied after the operations: * The integer on the green card is **strictly** greater than the integer on the red card. * The integer on the blue card is **strictly** greater than the integer on the green card. Determine whether the magic can be successful.
import math A, B, C = list(map(int, input().split())) K = int(input()) #A, B, C = [7, 4, 2] #K = 3 i = math.floor(A/B) K -= i B = B * (2 ** i) j = math.floor(B/C) K -= j C = C * (2 ** j) if K >= 0: print("Yes") else: print("No")
s758466740
Accepted
30
9,184
281
import math A, B, C = list(map(int, input().split())) K = int(input()) #A, B, C = [7, 6, 100] #K = 3 i = max(math.ceil(math.log2((A+1)/B)),0) K -= i B = B * (2 ** i) j = max(math.ceil(math.log2((B+1)/C)),0) K -= j C = C * (2 ** j) if K >= 0: print("Yes") else: print("No")
s529575552
p03711
u290326033
2,000
262,144
Wrong Answer
17
3,060
179
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.
group = [[1, 3, 5, 7, 8, 10, 12],[4, 6, 9, 11],[2]] x, y = list(map(int, input().split())) for g in group: if x in g and y in g: print("Yes") break print("No")
s051952518
Accepted
17
3,060
199
import sys group = [[1, 3, 5, 7, 8, 10, 12],[4, 6, 9, 11],[2]] x, y = list(map(int, input().split())) for g in group: if (x in g) and (y in g): print("Yes") sys.exit() print("No")
s567191654
p00512
u221679506
8,000
131,072
Wrong Answer
20
7,644
148
ある工場では,各営業所から製品生産の注文を受けている. 前日の注文をまとめて,各製品の生産合計を求めたい. 入力ファイルの1行目には注文データの数 n が書いてあり, 続く n 行には製品名と注文数が空白で区切られて書いてある. 製品名は5文字以内の英大文字で書かれている. 注文データには同じ製品が含まれていることもあり,順序はバラバラである. この注文データの中に現れる同じ製品の注文数を合計し, 出力ファイルに製品名と合計を空白を区切り文字として出力しなさい. ただし,製品名に次の順序を付けて,その順で出力すること. 順序:文字の長さの小さい順に,同じ長さのときは,前から比べて 最初に異なる文字のアルファベット順とする. 入力データにおける製品数,注文数とその合計のどれも106以下である. 出力ファイルにおいては, 出力の最後の行にも改行コードを入れること.
data = {} for i in range(int(input())): p,n = input().split(); data[p] = data.get(p,0) + int(n) for i, j in sorted(data.items()): print (i, j)
s283679870
Accepted
30
7,692
175
data = {} for i in range(int(input())): p,n = input().split(); data[p] = data.get(p,0) + int(n) for i, j in sorted([[len(a),a] for a in data.keys()]): print (j, data[j])
s644507151
p02694
u090406054
2,000
1,048,576
Time Limit Exceeded
2,206
8,900
87
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()) times=0 money=100 while money<x: money*1.01 times+=1 print(times)
s534185034
Accepted
25
9,120
74
x=int(input()) t=100 cnt=0 while t<x: t=t+t//100 cnt+=1 print(cnt)
s378941049
p02422
u801346721
1,000
131,072
Wrong Answer
20
7,564
304
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.
s = input() n = int(input()) for i in range(n): a = list(input().split()) if a[0] == 'replace': temp = s[int(a[1]):int(a[2])+1] s.replace(temp, a[3]) elif a[0] == 'reverse': temp = s[int(a[1]):int(a[2])+1] s.replace(temp, temp[::-1]) elif a[0] == 'print': print(s[int(a[1]):int(a[2])+1])
s695139508
Accepted
30
7,696
381
s = input() n = int(input()) for i in range(n): a = list(input().split()) temp = s[int(a[1]):int(a[2])+1] if a[0] == 'replace': temp3 = a[3] s = list(s) seq = 0 for i in range(int(a[1]), int(a[2])+1): s[i] = temp3[seq] seq += 1 s = ''.join(s) elif a[0] == 'reverse': temp2 = temp[::-1] s = s.replace(temp, temp2, 1) elif a[0] == 'print': print(temp)
s363795601
p03563
u048945791
2,000
262,144
Wrong Answer
17
2,940
53
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.
r = int(input()) g = int(input()) print((r + g) / 2)
s888982426
Accepted
17
2,940
49
r = int(input()) g = int(input()) print(2*g - r)
s405291959
p04029
u068584789
2,000
262,144
Wrong Answer
17
2,940
39
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
n = int(input()) print(n * (n + 1) / 2)
s943332556
Accepted
20
3,060
75
n = int(input()) if n == 1: print(n) else: print(int(n * (n + 1) / 2))
s337204118
p03730
u407016024
2,000
262,144
Wrong Answer
17
3,060
142
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()) for i in range(A, A*B, A): print(i) if i % B == C: print('Yes') exit() print('No')
s230829642
Accepted
17
2,940
129
A, B, C = map(int, input().split()) for i in range(A, A*B, A): if i % B == C: print('YES') exit() print('NO')
s159147184
p00044
u024715419
1,000
131,072
Wrong Answer
120
5,908
483
素数というのは、1 よりも大きくそれ自身か 1 でしか割りきれない整数をいいます。例えば、2 は、2 と 1 でしか割り切れないので素数ですが、12 は、12 と 1 のほかに、2, 3, 4, 6 で割りきれる数なので素数ではありません。 整数 n を入力したとき、n より小さい素数のうち最も大きいものと、n より大きい素数のうち最も小さいものを出力するプログラムを作成してください。
n = 50000 c = [1 for i in range(n)] c[0] = 0 i = 2 while i**2 <= n: j = i*2 while j <= n: c[j - 1] = 0 j += i i += 1 while True: try: n = int(input()) i, a, b = 0, 0, 0 while a == 0 and b == 0: i += 1 if n - i >= 0 and a == 0 and c[n - i] == 1: a = n - i if n + i < 50000 and b == 0 and c[n + i] == 1: b = n + i print(a,b) except: break
s955989752
Accepted
120
5,908
498
n = 50021 c = [1 for i in range(n)] c[0] = 0 i = 2 while i**2 <= n: j = i*2 while j <= n: c[j - 1] = 0 j += i i += 1 while True: try: n = int(input()) i, a, b = 0, 0, 0 while a == 0 or b == 0: i += 1 if n - i - 1 >= 0 and a == 0 and c[n - i - 1] == 1: a = n - i if n + i - 1 < 50021 and b == 0 and c[n + i - 1] == 1: b = n + i print(a,b) except: break
s618370389
p00079
u032662562
1,000
131,072
Wrong Answer
30
7,528
583
凸 n 角形(すべての頂点の内角が 180 度未満である多角形、要するにへこんでいない多角形のこと)の頂点の座標を読んで、その面積を出力するプログラムを作成してください。頂点には辺のつながりの順序に従って頂点 1、頂点 2、頂点 3、‥‥頂点 n という名前がついています。 ただし、 n は 3 以上 20 以下とします。また、次の、三角形の 3 辺の長さ a, b, c から面積 S を求める公式を使ってもかまいません。
import math f = [] while True: try: st = input().strip().split(',') print("st=",st) x,y = list(map(float,st )) f.append(x + y*1j) except EOFError: break px = [p.real for p in f] ox = (max(px) + min(px)) / 2.0 py = [p.imag for p in f] oy = (max(py) + min(py)) / 2.0 fo = ox + oy * 1j ss = 0.0 for i in range(len(f)): if i == len(f)-1: j = 0 else: j = i + 1 a = abs(f[i]-fo) b = abs(f[j]-fo) c = abs(f[j]-f[i]) z = (a + b + c) / 2.0 s = math.sqrt(z*(z-a)*(z-b)*(z-c)) ss += s print(ss)
s886513006
Accepted
30
7,484
334
def op(u,v): return (complex.conjugate(u)*v).imag f = [] while True: try: st = input().strip().split(',') x,y = list(map(float,st )) f.append(x + y*1j) except EOFError: break s = 0.0 fo = f[0] for j in range(2,len(f)): i = j - 1 s += op(f[i]-fo,f[j]-fo)/2.0 print("%.6f" % abs(s))
s284718611
p03455
u947748301
2,000
262,144
Wrong Answer
17
2,940
113
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
num1,num2 = map(int,"3 4".split()) if ((num1 * num2) % 2) == 0: print("Odd") else: print("Even")
s234753157
Accepted
17
3,064
116
num1,num2 = map(int,input().split()) if ((num1 * num2) % 2) == 0: print("Even") else: print("Odd")
s808373506
p02393
u781194524
1,000
131,072
Wrong Answer
20
5,600
246
Write a program which reads three integers, and prints them in ascending order.
a,b,c=[int(x) for x in input().split()] if a > b: if a > c: if b < c: print(b,c,a,sep=" ") else: print(c,b,a,sep=" ") elif b < c: print(a,b,c,sep=" ") else: print(a,c,b,sep=" ")
s264999662
Accepted
20
5,604
224
a,b,c=[int(x) for x in input().split()] if a<=b<=c: print(a,b,c) elif a<=c<=b: print(a,c,b) elif b<=a<=c: print(b,a,c) elif b<=c<=a: print(b,c,a) elif c<=a<=b: print(c,a,b) elif c<=b<=a: print(c,b,a)
s621794027
p02613
u335599768
2,000
1,048,576
Wrong Answer
153
16,244
302
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()); s = [input() for i in range(n)] ac = wa = tle = re = 0 for s_kind in s: if s_kind == "AC": ac += 1 elif s_kind == "WA": wa += 1 elif s_kind == "TLE": tle += 1 elif s_kind == "RE": re += 1 print(ac) print(wa) print(tle) print(re)
s895919293
Accepted
146
16,328
331
n = int(input()); s = [input() for i in range(n)] ac = wa = tle = re = 0 for s_kind in s: if s_kind == "AC": ac += 1 elif s_kind == "WA": wa += 1 elif s_kind == "TLE": tle += 1 elif s_kind == "RE": re += 1 print("AC x",ac) print("WA x",wa) print("TLE x",tle) print("RE x",re)
s643323965
p02669
u469254913
2,000
1,048,576
Wrong Answer
440
11,300
1,008
You start with the number 0 and you want to reach the number N. You can change the number, paying a certain amount of coins, with the following operations: * Multiply the number by 2, paying A coins. * Multiply the number by 3, paying B coins. * Multiply the number by 5, paying C coins. * Increase or decrease the number by 1, paying D coins. You can perform these operations in arbitrary order and an arbitrary number of times. What is the minimum number of coins you need to reach N? **You have to solve T testcases.**
# import numpy as np # import math # import copy # from collections import deque import sys input = sys.stdin.readline sys.setrecursionlimit(10000000) memo = {} def solve(): N,A,B,C,D = map(int,input().split()) return process(N,N,A,B,C,D) def process(M,N,A,B,C,D): if M == 1: return D elif M == 0: return 0 elif M < 0: return D * N global memo if M in memo: return memo[M] res = process((M-M%2)//2,N,A,B,C,D) + A + (M%2) * D res = min(res,process((M+M%2)//2,N,A,B,C,D) + A + (M%2) * D) res = min(res,process((M-M%3)//3,N,A,B,C,D) + B + (M%3) * D) res = min(res,process((M+3-M%3)//3,N,A,B,C,D) + B + (3-M%3) * D) res = min(res,process((M-M%5)//5,N,A,B,C,D) + C + (M%5) * D) res = min(res,process((M+5-M%5)//5,N,A,B,C,D) + C + (5-M%5) * D) memo[M] = res return res def main(): T = int(input()) for i in range(T): global memo memo = {} res = solve() print(res) main()
s839963467
Accepted
402
11,204
970
# import numpy as np # import math # import copy # from collections import deque import sys input = sys.stdin.readline sys.setrecursionlimit(10000000) memo = {} def solve(): N,A,B,C,D = map(int,input().split()) global memo memo = {0:0,1:D} return process(N,N,A,B,C,D) def process(M,N,A,B,C,D): # if M < 0: # return D * N + 1 global memo if M in memo: return memo[M] res = process((M-M%2)//2,N,A,B,C,D) + A + (M%2) * D res = min(res,process((M+M%2)//2,N,A,B,C,D) + A + (M%2) * D) res = min(res,process((M-M%3)//3,N,A,B,C,D) + B + (M%3) * D) res = min(res,process((M+3-M%3)//3,N,A,B,C,D) + B + (3-M%3) * D) res = min(res,process((M-M%5)//5,N,A,B,C,D) + C + (M%5) * D) res = min(res,process((M+5-M%5)//5,N,A,B,C,D) + C + (5-M%5) * D) res = min(res,M*D) memo[M] = res return res def main(): T = int(input()) for i in range(T): res = solve() print(res) main()
s015700713
p03795
u314050667
2,000
262,144
Wrong Answer
17
2,940
87
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()) ans = 1 for i in range(1,n+1): ans = (ans*i)%1000000007 print(ans)
s005989659
Accepted
17
2,940
81
N = int(input()) div, mod = divmod(N, 15) x = N * 800 y = div * 200 print(x - y)
s058466919
p03229
u227082700
2,000
1,048,576
Wrong Answer
257
7,764
197
You are given N integers; the i-th of them is A_i. Find the maximum possible sum of the absolute differences between the adjacent elements after arranging these integers in a row in any order you like.
n=int(input()) a=[int(input())for _ in range(n)] a.sort() b=a[:0--n//2] c=a[0--n//2:] a=[] for i in range(n//2):a+=[b[i],c[i]] if n%2:a+=[b[-1]] x=0 for i in range(n-1):x+=abs(a[i+1]-a[i]) print(x)
s353883304
Accepted
316
9,912
350
n=int(input()) a=[int(input())for _ in range(n)] if n==2:print(abs(a[0]-a[1]));exit() f=[-1] for i in range(1,n-1-(n%2==0)): if i%2:f.append(2) else:f.append(-2) if n%2:f+=[-1] else:f+=[-2,1] b=[] c=[] for i in f: b.append(i) c.append(-i) b.sort() c.sort() sb=sc=0 a.sort() for i in range(n): sb+=a[i]*b[i] sc+=a[i]*c[i] print(max(sb,sc))