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
s663491223
p03712
u945181840
2,000
262,144
Wrong Answer
17
3,060
157
You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}. Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1.
import sys s = sys.stdin.readlines() H, W = map(int, s[0].split()) a0 = '#' * (W + 2) print(a0) for i in range(H): print('#' + s[i + 1] + '#') print(a0)
s021149972
Accepted
18
3,060
121
H, W = map(int, input().split()) a0 = '#' * (W + 2) print(a0) for i in range(H): print('#' + input() + '#') print(a0)
s647828046
p03860
u093500767
2,000
262,144
Wrong Answer
18
2,940
51
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppercase English letter at the beginning of s. Given the name of the contest, print the abbreviation of the name.
x = str(input().split()[1]) print("A{}C".format(x))
s819160152
Accepted
17
2,940
60
x = str(input().split()[1]) x = x[0] print("A{}C".format(x))
s702358461
p02694
u659712937
2,000
1,048,576
Wrong Answer
25
9,096
145
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=100 for i in range(3800): if a>X: print(i) break else: a=(a*1.01)//1 if a>10**6: a/(10**6) X/(10**6)
s804941938
Accepted
26
9,248
146
X=int(input()) a=100 for i in range(3800): if a>=X: print(i) break else: a=(a*1.01)//1 if a>10**6: a/(10**6) X/(10**6)
s058840357
p03470
u291914812
2,000
262,144
Wrong Answer
17
2,940
77
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()) nums = set(list(map(int, input().split()))) print(len(nums))
s000250001
Accepted
19
2,940
74
N = int(input()) nums = [input() for i in range(N)] print(len(set(nums)))
s991101455
p02833
u189188797
2,000
1,048,576
Wrong Answer
17
2,940
203
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()) ans=0 cnt=5 if n%2==0: while True: tmp=n//cnt if tmp==0: break else: ans+=tmp cnt=cnt*5 print(tmp) print(ans//2)
s771858226
Accepted
17
2,940
99
n=int(input()) ans=0 if n%2==0: n=n//2 while n>0: n=n//5 ans+=n print(ans)
s520955172
p03545
u677440371
2,000
262,144
Wrong Answer
17
3,064
568
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.
abcd = str(input()) abcd_list = list(abcd) a = int(abcd_list[0]) b = int(abcd_list[1]) c = int(abcd_list[2]) d = int(abcd_list[3]) ans2='+' ans3='+' ans4='+' for i in [a]: for j in [b,-b]: for k in [c,-c]: for l in [d,-d]: ans = i + j + k + l if ans == 7: if j < 0: ans2 = '-' elif k < 0: ans3 = '-' elif l < 0: ans4 = '-' print(str(a)+ans2+str(b)+ans3+str(c)+ans4+str(d))
s708624622
Accepted
18
3,064
405
s = str(input()) for bits in range(1 << 3): op1 = '+' op2 = '+' op3 = '+' for i in range(3): if (bits >> i & 1) == 1: if i == 0: op1 = '-' if i == 1: op2 = '-' if i == 2: op3 = '-' if eval(s[0]+op1+s[1]+op2+s[2]+op3+s[3]) == 7: print(s[0]+op1+s[1]+op2+s[2]+op3+s[3]+'=7') break
s774006847
p03380
u253952966
2,000
262,144
Wrong Answer
75
14,684
201
Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted.
n = int(input()) an = list(map(int, input().split())) maxi = max(an) v = maxi for a in an: if a == maxi: continue if abs(a-maxi) < abs(v-maxi): v = a print(' '.join( map(str, [maxi, v]) ))
s816919789
Accepted
87
14,052
275
n = int(input()) an = list(map(int, input().split())) if n == 2: print(' '.join( map(str, [max(an), min(an)]) )) exit() maxi = max(an) v = maxi for a in an: if a == maxi: continue if abs(a-maxi/2) < abs(v-maxi/2): v = a print(' '.join( map(str, [maxi, v]) ))
s816432046
p02678
u968404618
2,000
1,048,576
Wrong Answer
575
36,808
1,032
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.
import heapq import sys input = sys.stdin.readline def Dijkstra_heap(s, edge): d = [10**6] * n used = [False] * n d[s] = 0 used[s] = True edgelist = [] for i in edge[s]: heapq.heappush(edgelist, i) while len(edgelist): minedge = heapq.heappop(edgelist) v = minedge % (10**6) if used[v]: continue d[v] = minedge // (10**6) used[v] = True for e in edge[v]: if not used[e]: heapq.heappush(edgelist, e+d[v]*(10**6)) return d n, m = map(int, input().split()) edge = [[] for _ in range(n)] for _ in range(m): a, b = map(int, input().split()) a -= 1 b -= 1 edge[a].append(b) edge[b].append(a) dist = Dijkstra_heap(0, edge) if 10**6 in dist: print("No") exit() for i in dist[1:]: print(i)
s829486384
Accepted
531
34,904
621
from collections import deque import sys input = sys.stdin.readline f_inf = float("inf") n, m = map(int, input().split()) to = [[] for _ in range(n)] for _ in range(m): a, b = map(int, input().split()) a -= 1 b -= 1 to[a].append(b) to[b].append(a) que = deque([]) que.append(0) dist = [f_inf for _ in range(n)] dist[0] = 0 guide = [-1 for _ in range(n)] while que: v = que.popleft() for u in to[v]: if dist[u] != f_inf: continue dist[u] = dist[v]+1 guide[u] = v que.append(u) print("Yes") for i in range(1, n): ans = guide[i] + 1 print(ans)
s261548770
p03455
u243312682
2,000
262,144
Wrong Answer
17
2,940
173
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
def main(): n, m = map(int, input().split()) if n % 2 == 0 or n % 2 == 0: print('Even') else: print('Odd') if __name__ == '__main__': main()
s198847438
Accepted
17
2,940
172
def main(): n, m = map(int, input().split()) if n % 2 == 0 or m % 2 == 0: print('Even') else: print('Odd') if __name__ == '__main__': main()
s519879158
p03456
u106118504
2,000
262,144
Wrong Answer
25
9,100
53
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
a, b = map(str,input().split()) c = int(a+b) print(c)
s592759182
Accepted
26
9,372
114
a, b = map(str,input().split()) c = int(a+b) d = c ** (1/2) if d.is_integer(): print("Yes") else: print("No")
s848144229
p03151
u062621835
2,000
1,048,576
Wrong Answer
143
19,188
658
A university student, Takahashi, has to take N examinations and pass all of them. Currently, his _readiness_ for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i-th examination. Takahashi thinks that he may not be able to pass all the examinations, and he has decided to ask a magician, Aoki, to change the readiness for as few examinations as possible so that he can pass all of them, while not changing the total readiness. For Takahashi, find the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the following conditions: * The sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal. * For every i, B_i \leq C_i holds. If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) df = list([0 for i in range(n)]) ans = -1 if sum(a) < sum(b): ans = -1 else: for i in range(n): df[i] = a[i] - b[i] minus = list(filter(lambda x: x < 0, df)) plus = list(filter(lambda x: x > 0, df)) m_count = len(minus) m_sum = sum(minus) plus.sort(reverse=True) if m_count == 0: ans = 0 else: print(minus) print(plus) for i in range(len(plus)): m_sum += plus[i] if m_sum >= 0: break if m_sum>=0: ans = m_count + i + 1 print(ans)
s937602813
Accepted
138
19,188
714
n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) df = list([0 for i in range(n)]) ans = -1 if sum(a) < sum(b): ans = -1 else: for i in range(n): df[i] = a[i] - b[i] minus = list(filter(lambda x: x < 0, df)) plus = list(filter(lambda x: x > 0, df)) m_count = len(minus) m_sum = sum(minus) #print("m_count=%d"%(m_count)) #print("m_sum=%d"%(m_sum)) plus.sort(reverse=True) #print(df) if m_count == 0: ans = 0 else: for i in range(len(plus)): m_sum += plus[i] if m_sum >= 0: break if m_sum>=0: ans = m_count + i + 1 print(ans)
s638701006
p03730
u104922648
2,000
262,144
Wrong Answer
20
3,064
128
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 = list(map(int, input().split())) for i in range(a, a*(b+1), a): if i%b == c: print('Yes') exit() print('No')
s164046294
Accepted
17
2,940
122
a, b, c = list(map(int, input().split())) for i in range(a*b): if (a*i)%b == c: print('YES') exit() print('NO')
s800922477
p03477
u545411641
2,000
262,144
Wrong Answer
17
3,060
135
A balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L<R. Takahashi placed a mass of weight A and a mass of weight B on the left pan of a balance scale, and placed a mass of weight C and a mass of weight D on the right pan. Print `Left` if the balance scale tips to the left; print `Balanced` if it balances; print `Right` if it tips to the right.
A, B, C, D = map(int, input().split()) L = A + B R = C + D if L < R: print('Left') elif L==R: print('Balanced') else: print('Right')
s333808210
Accepted
17
3,060
135
A, B, C, D = map(int, input().split()) L = A + B R = C + D if L > R: print('Left') elif L==R: print('Balanced') else: print('Right')
s391825246
p03945
u556589653
2,000
262,144
Wrong Answer
49
3,188
79
Two foxes Jiro and Saburo are playing a game called _1D Reversi_. This game is played on a board, using black and white stones. On the board, stones are placed in a row, and each player places a new stone to either end of the row. Similarly to the original game of Reversi, when a white stone is placed, all black stones between the new white stone and another white stone, turn into white stones, and vice versa. In the middle of a game, something came up and Saburo has to leave the game. The state of the board at this point is described by a string S. There are |S| (the length of S) stones on the board, and each character in S represents the color of the i-th (1 ≦ i ≦ |S|) stone from the left. If the i-th character in S is `B`, it means that the color of the corresponding stone on the board is black. Similarly, if the i-th character in S is `W`, it means that the color of the corresponding stone is white. Jiro wants all stones on the board to be of the same color. For this purpose, he will place new stones on the board according to the rules. Find the minimum number of new stones that he needs to place.
S = input() ans = 0 for i in range(1,len(S)): if S[i-1] != S[i]: ans += 1
s674695215
Accepted
46
9,204
90
S = input() ans = 0 for i in range(1,len(S)): if S[i] != S[i-1]: ans += 1 print(ans)
s088288817
p03999
u610143410
2,000
262,144
Wrong Answer
23
3,192
2,004
You are given a string S consisting of digits between `1` and `9`, inclusive. You can insert the letter `+` into some of the positions (possibly none) between two letters in this string. Here, `+` must not occur consecutively after insertion. All strings that can be obtained in this way can be evaluated as formulas. Evaluate all possible formulas, and print the sum of the results.
class NumExpression: def __init__(self, input_value, rank): self.raw_value = input_value self.rank = rank @property def value(self): list = self.expression.split("+") sum = 0 for num in list: sum += int(num) return sum @property def expression(self): #print("rank = {0}".format(self.rank)) points = self.gen_points(self.rank, len(self.raw_value) - 1) #print("gen_points = {0}".format(points)) expression = self.insert_plus(points) #print("expression = {0}".format(expression)) return expression def gen_points(self, num, width): points = [0] * width temp = num i = 1 while True: p = temp % 2 if p == 1: points[width - i] = 1 temp = temp >> 1 if temp == 0: break i += 1 return points def insert_plus(self, points): i = 0 #points[0] new_value = self.raw_value[0:i] for point in points: new_value += self.raw_value[i:i+1] if point == 1: new_value += "+" i += 1 new_value += self.raw_value[i:] return new_value class Calculator: def __init__(self, input_value): self.input_value = input_value self.expressions = self.make_expressions() def len(self): return len(self.input_value) def make_expressions(self): expressions = [] for i in range(0, pow(2, self.len()-1)): expression = NumExpression(self.input_value, i) expressions.append(expression) return expressions def compute_sum(self): sum = 0 for expression in self.expressions: sum += expression.value return sum
s507289146
Accepted
28
3,192
2,101
class NumExpression: def __init__(self, input_value, rank): self.raw_value = input_value self.rank = rank @property def value(self): list = self.expression.split("+") sum = 0 for num in list: sum += int(num) return sum @property def expression(self): #print("rank = {0}".format(self.rank)) points = self.gen_points(self.rank, len(self.raw_value) - 1) #print("gen_points = {0}".format(points)) expression = self.insert_plus(points) #print("expression = {0}".format(expression)) return expression def gen_points(self, num, width): points = [0] * width temp = num i = 1 while True: p = temp % 2 if p == 1: points[width - i] = 1 temp = temp >> 1 if temp == 0: break i += 1 return points def insert_plus(self, points): i = 0 #points[0] new_value = self.raw_value[0:i] for point in points: new_value += self.raw_value[i:i+1] if point == 1: new_value += "+" i += 1 new_value += self.raw_value[i:] return new_value class Calculator: def __init__(self, input_value): self.input_value = input_value self.expressions = self.make_expressions() def len(self): return len(self.input_value) def make_expressions(self): expressions = [] for i in range(0, pow(2, self.len()-1)): expression = NumExpression(self.input_value, i) expressions.append(expression) return expressions def compute_sum(self): sum = 0 for expression in self.expressions: sum += expression.value return sum if __name__ == "__main__": num = input() c = Calculator(num) print(c.compute_sum())
s786571173
p03797
u589969467
2,000
262,144
Wrong Answer
29
9,048
198
Snuke loves puzzles. Today, he is working on a puzzle using `S`\- and `c`-shaped pieces. In this puzzle, you can combine two `c`-shaped pieces into one `S`-shaped piece, as shown in the figure below: Snuke decided to create as many `Scc` groups as possible by putting together one `S`-shaped piece and two `c`-shaped pieces. Find the maximum number of `Scc` groups that can be created when Snuke has N `S`-shaped pieces and M `c`-shaped pieces.
s,c = map(int,input().split()) ans = 0 if s*2 <= c: c = c - s*2 ans += s s = 0 else: tmp = c//2 s = s - tmp c = c%2 ans += tmp #print(s,c,ans) ans += c//4 #print(s,c,ans)
s000782290
Accepted
25
9,092
136
n,m = map(int,input().split()) ans = 0 if m-n*2>0: ans += n tmp = m-n*2 ans += tmp//4 else: ans += m//2 print(ans)
s517659746
p03657
u006425112
2,000
262,144
Wrong Answer
17
2,940
157
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.
import sys a, b = map(int, sys.stdin.readline().split()) if a % 3 == 0 or b % 3 == 0 or a + b % 3 == 0: print("Possible") else: print("Impossible")
s796304918
Accepted
18
2,940
159
import sys a, b = map(int, sys.stdin.readline().split()) if a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0: print("Possible") else: print("Impossible")
s072688919
p03636
u653485478
2,000
262,144
Wrong Answer
17
2,940
52
The word `internationalization` is sometimes abbreviated to `i18n`. This comes from the fact that there are 18 letters between the first `i` and the last `n`. You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way.
s = input() print(s[0] + str(len(s[1:-2])) + s[-1])
s977936620
Accepted
17
2,940
52
s = input() print(s[0] + str(len(s[1:-1])) + s[-1])
s838681031
p02613
u105659451
2,000
1,048,576
Wrong Answer
167
16,176
299
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()) L = [0,0,0,0] S = N*[0] for i in range(N): S[i] = input() if S[i]=="AC": L[0]+=1 elif S[i]=="WA": L[1]+=1 elif S[i]=="TLE": L[2]+=1 else: L[3]+=1 print(f"AC×{L[0]}") print(f"WA×{L[1]}") print(f"TLE×{L[2]}") print(f"RE×{L[3]}")
s970351787
Accepted
167
16,184
303
N = int(input()) L = [0,0,0,0] S = N*[0] for i in range(N): S[i] = input() if S[i]=="AC": L[0]+=1 elif S[i]=="WA": L[1]+=1 elif S[i]=="TLE": L[2]+=1 else: L[3]+=1 print(f"AC x {L[0]}") print(f"WA x {L[1]}") print(f"TLE x {L[2]}") print(f"RE x {L[3]}")
s800445715
p03610
u076363290
2,000
262,144
Wrong Answer
27
9,144
38
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 = str(input().split()) print(S[::2])
s736480387
Accepted
25
9,100
30
S = str(input()) print(S[::2])
s038744538
p02742
u036914910
2,000
1,048,576
Wrong Answer
17
2,940
126
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds: * r_1 + c_1 = r_2 + c_2 * r_1 - c_1 = r_2 - c_2 For example, in the following figure, the bishop can move to any of the red squares in one move:
H, W = map(int,input().split()) if H % 2 == 0 : print(H * W / 2 ) else : print(int(int(H / 2) * W + int(W / 2) + 1))
s882956291
Accepted
17
2,940
114
H, W = map(int,input().split()) if H>1 and W>1 : print(int(H/2)*W + (int(W/2)+W%2)*(H%2)) else : print(1)
s770550098
p02612
u956433805
2,000
1,048,576
Wrong Answer
33
9,152
61
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()) i = N // 1000 ans = N - i * 1000 print(ans)
s946195019
Accepted
25
9,152
90
N = int(input()) i = N // 1000 if N % 1000 != 0: i += 1 ans = i * 1000 - N print(ans)
s596901037
p03680
u103902792
2,000
262,144
Wrong Answer
204
13,216
213
Takahashi wants to gain muscle, and decides to work out at AtCoder Gym. The exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up. These buttons are numbered 1 through N. When Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i. When Button i is not lighten up, nothing will happen by pressing it. Initially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up. Determine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.
n = int(input()) A = [int(input())-1 for _ in range(n)] push = set([]) ans = 0 b = 0 while 1: if b in push: print(-1) exit() push.add(b) b = A[b] ans += 1 if b== 2: print(ans) break
s753409257
Accepted
210
13,220
215
n = int(input()) A = [int(input())-1 for _ in range(n)] push = set([]) ans = 0 b = 0 while 1: if b in push: print(-1) exit() push.add(b) b = A[b] ans += 1 if b== 1: print(ans) break
s067121668
p03377
u222634810
2,000
262,144
Wrong Answer
17
2,940
98
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
A, B, X = map(int, input().split()) if X > A + B or X < A: print('No') else: print('Yes')
s998593626
Accepted
17
2,940
98
A, B, X = map(int, input().split()) if X > A + B or X < A: print('NO') else: print('YES')
s448982870
p02398
u944658202
1,000
131,072
Time Limit Exceeded
9,990
5,572
97
Write a program which reads three integers a, b and c, and prints the number of divisors of c between a and b.
a,b,c=map(int,input().split()) count=0 while a<=b: if c%a==0: count+=1 print(count)
s666968852
Accepted
20
5,592
105
a,b,c=map(int,input().split()) count=0 while a<=b: if c%a==0: count+=1 a+=1 print(count)
s004227416
p02615
u271853076
2,000
1,048,576
Wrong Answer
111
31,620
133
Quickly after finishing the tutorial of the online game _ATChat_ , you have decided to visit a particular place with N-1 players who happen to be there. These N players, including you, are numbered 1 through N, and the **friendliness** of Player i is A_i. The N players will arrive at the place one by one in some order. To make sure nobody gets lost, you have set the following rule: players who have already arrived there should form a circle, and a player who has just arrived there should cut into the circle somewhere. When each player, except the first one to arrive, arrives at the place, the player gets **comfort** equal to the smaller of the friendliness of the clockwise adjacent player and that of the counter-clockwise adjacent player. The first player to arrive there gets the comfort of 0. What is the maximum total comfort the N players can get by optimally choosing the order of arrivals and the positions in the circle to cut into?
n = int(input()) comforts = list(map(int,input().split())) newcomforts = sorted(comforts, reverse=True) print(newcomforts[1] * (n-1))
s680224310
Accepted
121
31,596
334
n = int(input()) comforts = list(map(int,input().split())) newcomforts = sorted(comforts, reverse=True) x = 0 if n%2 == 0: for i in range(1, int(n/2)): x += newcomforts[i] print(x * 2 + newcomforts[0]) else: for i in range(1, int((n-1)/2)): x += newcomforts[i] print(x*2 + newcomforts[0] + newcomforts[int((n+1)/2-1)])
s487468257
p02540
u467736898
2,000
1,048,576
Wrong Answer
2,207
74,872
15,482
There are N cities on a 2D plane. The coordinate of the i-th city is (x_i, y_i). Here (x_1, x_2, \dots, x_N) and (y_1, y_2, \dots, y_N) are both permuations of (1, 2, \dots, N). For each k = 1,2,\dots,N, find the answer to the following question: Rng is in City k. Rng can perform the following move arbitrarily many times: * move to another city that has a smaller x-coordinate and a smaller y-coordinate, or a larger x-coordinate and a larger y-coordinate, than the city he is currently in. How many cities (including City k) are reachable from City k?
code_segtree = r code_setup = r""" from distutils.core import setup, Extension module = Extension( "atcoder", sources=["atcoder_library_wrapper.cpp"], extra_compile_args=["-O3", "-march=native", "-std=c++14"] ) setup( name="atcoder-library", version="0.0.1", description="wrapper for atcoder library", ext_modules=[module] ) """ import os import sys if sys.argv[-1] == "ONLINE_JUDGE" or os.getcwd() != "/imojudge/sandbox": with open("atcoder_library_wrapper.cpp", "w") as f: f.write(code_segtree) with open("setup.py", "w") as f: f.write(code_setup) os.system(f"{sys.executable} setup.py build_ext --inplace") from atcoder import SegTree from operator import itemgetter class UnionFind: def __init__(self, N): self.p = list(range(N)) self.rank = [0] * N self.size = [1] * N def root(self, x): if self.p[x] != x: self.p[x] = self.root(self.p[x]) return self.p[x] def same(self, x, y): return self.root(x) == self.root(y) def unite(self, x, y): u = self.root(x) v = self.root(y) if u == v: return if self.rank[u] < self.rank[v]: self.p[u] = v self.size[v] += self.size[u] self.size[u] = 0 else: self.p[v] = u self.size[u] += self.size[v] self.size[v] = 0 if self.rank[u] == self.rank[v]: self.rank[u] += 1 def count(self, x): return self.size[self.root(x)] import sys input = sys.stdin.buffer.readline N = int(input()) IXY = [] for i in range(N): x, y = map(int, input().split()) x -= 1 y -= 1 IXY.append((i, x, y)) IXY.sort(key=itemgetter(1)) op = lambda a, b: a if a > b else b e = 0 seg = SegTree(op, e, N) f = lambda x: x == 0 uf = UnionFind(N) for _, _, y in IXY: l = seg.min_left(y, f) - 1 if l >= 0: uf.unite(l, y) seg.set(y, 1) #print() seg = SegTree(op, e, N) for _, _, y in IXY[::-1]: r = seg.max_right(y, f) if r < N: uf.unite(r, y) seg.set(y, 1) Ans = [-100] * N for i, x, y in IXY: Ans[i] = uf.count(y) print("\n".join(map(str, Ans)))
s900535714
Accepted
1,027
70,752
1,400
class UnionFind: def __init__(self, N): self.p = list(range(N)) self.rank = [0] * N self.size = [1] * N def root(self, x): if self.p[x] != x: self.p[x] = self.root(self.p[x]) return self.p[x] def same(self, x, y): return self.root(x) == self.root(y) def unite(self, x, y): u = self.root(x) v = self.root(y) if u == v: return if self.rank[u] < self.rank[v]: self.p[u] = v self.size[v] += self.size[u] self.size[u] = 0 else: self.p[v] = u self.size[u] += self.size[v] self.size[v] = 0 if self.rank[u] == self.rank[v]: self.rank[u] += 1 def count(self, x): return self.size[self.root(x)] from operator import itemgetter import sys input = sys.stdin.buffer.readline N = int(input()) IXY = [] for i in range(N): x, y = map(int, input().split()) x -= 1 y -= 1 IXY.append((i, x, y)) IXY.sort(key=itemgetter(1)) B = [IXY[0][2]] uf = UnionFind(N) for i, _, y in IXY[1:]: if B[-1] < y: bl = B.pop() uf.unite(bl, y) while B and B[-1] < y: uf.unite(bl, B.pop()) B.append(bl) else: B.append(y) Ans = [-100] * N for i, _, y in IXY: Ans[i] = uf.count(y) print("\n".join(map(str, Ans)))
s415683107
p03478
u013408661
2,000
262,144
Wrong Answer
25
3,060
178
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()) def num(x): ans=0 while x>0: ans+=x%10 x=x//10 return ans count=0 for i in range(1,n+1): if a<=num(i)<=b: count+=1 print(count)
s476951249
Accepted
26
2,940
178
n,a,b=map(int,input().split()) def num(x): ans=0 while x>0: ans+=x%10 x=x//10 return ans count=0 for i in range(1,n+1): if a<=num(i)<=b: count+=i print(count)
s705436403
p02612
u313890617
2,000
1,048,576
Wrong Answer
31
9,136
29
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
n=int(input()) print(n%1000)
s650399444
Accepted
31
9,144
76
n=int(input()) if n%1000==0: ans=0 else: ans=1000-n%1000 print(ans)
s722291383
p02242
u519227872
1,000
131,072
Wrong Answer
60
8,008
673
For a given weighted graph $G = (V, E)$, find the shortest path from a source to each vertex. For each vertex $u$, print the total weight of edges on the shortest path from vertex $0$ to $u$.
n = int(input()) from collections import defaultdict G = defaultdict(list) for i in range(n): i = [int(i) for i in input().split()] k = i[1] G[i[0]] = list(zip(i[2::2],i[3::2])) def mind(Q, d): c = float('inf') ret = 0 for i, j in enumerate(d): if c > j and i in Q: c = j ret = i return ret def dijkstra(G): d = [0] + [float('inf')] * (n - 1) Q = set(range(n)) while len(Q) != 0: u = mind(Q, d) print(u) Q = Q - set([u]) for v, c in G[u]: if d[v] > d[u] + c: d[v] = d[u] + c return d for i,j in enumerate(dijkstra(G)): print(i, j)
s426318391
Accepted
30
8,616
656
n = int(input()) from collections import defaultdict G = defaultdict(list) for i in range(n): i = [int(i) for i in input().split()] k = i[1] G[i[0]] = list(zip(i[2::2],i[3::2])) def mind(Q, d): c = float('inf') ret = 0 for i, j in enumerate(d): if c > j and i in Q: c = j ret = i return ret def dijkstra(G): d = [0] + [float('inf')] * (n - 1) Q = set(range(n)) while len(Q) != 0: u = mind(Q, d) Q = Q - set([u]) for v, c in G[u]: if d[v] > d[u] + c: d[v] = d[u] + c return d for i,j in enumerate(dijkstra(G)): print(i, j)
s969550600
p03456
u933214067
2,000
262,144
Wrong Answer
161
13,612
947
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
from statistics import mean, median,variance,stdev import numpy as np import sys import math import fractions def j(q): if q==1: print("Yes") else:print("No") exit(0) def ct(x,y): if (x>y):print("") elif (x<y): print("") else: print("") def ip(): return int(input()) a = input().split() b = ''.join([a[0],a[1]]) print(b) c = int(b) j(pow(int(np.sqrt(c)),2) == c)
s326230700
Accepted
160
13,560
938
from statistics import mean, median,variance,stdev import numpy as np import sys import math import fractions def j(q): if q==1: print("Yes") else:print("No") exit(0) def ct(x,y): if (x>y):print("") elif (x<y): print("") else: print("") def ip(): return int(input()) a = input().split() b = ''.join([a[0],a[1]]) c = int(b) j(pow(int(np.sqrt(c)),2) == c)
s816417196
p04043
u581603131
2,000
262,144
Wrong Answer
17
2,940
119
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
list = list(map(int, input().split())) if list.count(5)==2 and list.count(7)==1: print('Yes') else: print('No')
s512873194
Accepted
17
2,940
119
list = list(map(int, input().split())) if list.count(5)==2 and list.count(7)==1: print('YES') else: print('NO')
s580369993
p03068
u620755587
2,000
1,048,576
Wrong Answer
19
3,188
65
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 `*`.
import re n,s,k=open(0) print(re.sub("[^"+s[int(k)-1]+"]","*",s))
s434423227
Accepted
19
3,188
76
import re n,s,k=open(0) print(re.sub("[^" + s[int(k)-1] + "]", "*", s[:-1]))
s019843498
p04029
u721970149
2,000
262,144
Wrong Answer
17
2,940
98
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?
a = int(input()) sum = a * (a+1) / 2 print(sum)
s972849839
Accepted
17
2,940
103
a = int(input()) sum = a * (a+1) / 2 print(int(sum))
s312331546
p02844
u268554510
2,000
1,048,576
Wrong Answer
118
48,136
409
AtCoder Inc. has decided to lock the door of its office with a 3-digit PIN code. The company has an N-digit lucky number, S. Takahashi, the president, will erase N-3 digits from S and concatenate the remaining 3 digits without changing the order to set the PIN code. How many different PIN codes can he set this way? Both the lucky number and the PIN code may begin with a 0.
N = int(input()) S = list(map(int,list(input()))) S_riv=S[::-1] l_lis=[0]*N r_lis=[0]*N mat=([0 for j in range(10)]) l_set=set([]) r_set=set([]) for i,s in enumerate(S): l_lis[i]=l_set.copy() l_set.add(s) for i,s in enumerate(S_riv): r_lis[i]=r_set.copy() r_set.add(s) r_lis.reverse() ans=0 for i,s in enumerate(S): length=len(l_lis[i]) ans+=(length-mat[s])*len(r_lis[i]) mat[s]=length
s768376237
Accepted
121
48,136
402
N = int(input()) S = list(map(int,list(input()))) S_riv=S[::-1] l_lis=[0]*N r_lis=[0]*N mat=([0 for j in range(10)]) l_set=set([]) r_set=set([]) for i,(r,l) in enumerate(zip(S_riv,S)): l_lis[i]=l_set.copy() r_lis[i]=r_set.copy() l_set.add(l) r_set.add(r) r_lis.reverse() ans=0 for i,s in enumerate(S): length=len(l_lis[i]) ans+=(length-mat[s])*len(r_lis[i]) mat[s]=length print(ans)
s214142990
p03478
u692311686
2,000
262,144
Wrong Answer
40
3,060
191
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()) counter=0 for i in range(N): n=str(i+1) s=len(n) n_total=0 for t in range(s): n_total+=int(n[t]) if A<= n_total <=B: counter+=1 print(counter)
s219142933
Accepted
39
3,060
198
N,A,B=map(int,input().split()) counter=0 for i in range(N): n=str(i+1) s=len(n) n_total=0 for t in range(s): n_total+=int(n[t]) if A<= n_total <=B: counter+=int(i+1) print(counter)
s325519776
p04043
u044378346
2,000
262,144
Wrong Answer
26
9,080
155
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
a,b,c = map(int, input().split()) if(a==5 and b==5): print("Yes") elif(b==5 and c==5): print("Yes") elif(a==5 and c==5): print("Yes") else: print("No")
s219089628
Accepted
21
9,012
155
a,b,c = map(int, input().split()) if(a==5 and b==5): print("YES") elif(b==5 and c==5): print("YES") elif(a==5 and c==5): print("YES") else: print("NO")
s565388972
p03090
u543954314
2,000
1,048,576
Wrong Answer
24
3,612
146
You are given an integer N. Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions: * The graph is simple and connected. * There exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is S. It can be proved that at least one such graph exists under the constraints of this problem.
n = int(input()) print(n*(n-1)//2-n//2) for i in range(1,n): for j in range(i+1,n+1): if i == j or i+j == n+1: continue print(i,j)
s310203576
Accepted
23
3,612
166
n = int(input()) print(n*(n-1)//2-n//2) if n%2: m = n else: m = n+1 for i in range(1,n): for j in range(i+1,n+1): if i+j == m: continue print(i,j)
s758505842
p03555
u731028462
2,000
262,144
Wrong Answer
17
2,940
62
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.
a = input() b = input() print("Yes" if a[::-1] == b else "No")
s005654251
Accepted
17
3,064
62
a = input() b = input() print("YES" if a[::-1] == b else "NO")
s261766621
p03814
u759412327
2,000
262,144
Wrong Answer
18
3,500
44
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`.
s = input() print(s.rfind("Z")-s.find("A"))
s501743915
Accepted
25
9,256
45
S = input() print(1+S.rfind("Z")-S.find("A"))
s188881053
p02972
u716270596
2,000
1,048,576
Wrong Answer
2,104
6,484
533
There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N). For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it. We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied: * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2. Does there exist a good set of choices? If the answer is yes, find one good set of choices.
def main(n, a): box = [0 for _ in range(n)] for i in range(n, 0, -1): if i > n // 2: factors = [] else: factors = [x for x in range(i + 1, n + 1) if x % i == 0] if a[i - 1] == 0: if sum([a[i - 1]] + factors) % 2 == 1: box[i - 1] = 1 else: if sum([a[i - 1]] + factors) % 2 == 0: box[i - 1] = 1 print(sum(box)) print(' '.join(map(str, box))) n = int(input()) a = list(map(int, input().split())) main(n, a)
s890791464
Accepted
236
14,132
309
def main(n, a): box = [0] * n for i in range(n, 0, -1): if a[i - 1] != sum(box[i - 1 :: i]) % 2: box[i - 1] = 1 box_indices = [i + 1 for i in range(n) if box[i] == 1] print(sum(box)) print(*box_indices) n = int(input()) a = list(map(int, input().split())) main(n, a)
s709568393
p03479
u862282448
2,000
262,144
Wrong Answer
17
2,940
102
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.
X, Y = map(int, input().split()) ans = 0 while X <= Y: Y /= 2 print(Y) ans += 1 print(ans)
s180300780
Accepted
17
2,940
89
X, Y = map(int, input().split()) ans = 0 while X <= Y: X *= 2 ans += 1 print(ans)
s933693229
p04029
u785205215
2,000
262,144
Wrong Answer
17
2,940
63
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()) ans=0 for i in range(n): ans+=i print(ans)
s447619128
Accepted
17
2,940
67
n = int(input()) ans=0 for i in range(1,n+1): ans+=i print(ans)
s620460185
p02975
u204415375
2,000
1,048,576
Wrong Answer
47
14,116
176
Snuke has N hats. The i-th hat has an integer a_i written on it. There are N camels standing in a circle. Snuke will put one of his hats on each of these camels. If there exists a way to distribute the hats to the camels such that the following condition is satisfied for every camel, print `Yes`; otherwise, print `No`. * The bitwise XOR of the numbers written on the hats on both adjacent camels is equal to the number on the hat on itself. What is XOR? The bitwise XOR x_1 \oplus x_2 \oplus \ldots \oplus x_n of n non- negative integers x_1, x_2, \ldots, x_n is defined as follows: - When x_1 \oplus x_2 \oplus \ldots \oplus x_n is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if the number of integers among x_1, x_2, \ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even. For example, 3 \oplus 5 = 6.
n = int(input()) c = list(map(int, input().split())) c_set = set(c) ans = 'no' if n % 2 == 1 and len(c_set) == 3: if c[0] ^ c[1] == c[2]: ans = 'yes' print(ans)
s553369990
Accepted
73
14,708
575
n = int(input()) c = list(map(int, input().split())) c.sort() c_set = set(c) set_list = list(c_set) ans = 'No' if c.count(0) == n: ans = 'Yes' elif c[0] == 0: if n % 3 == 0 and len(c_set) == 2 and c.count(0) == int(n / 3): ans = 'Yes' elif n == 3: if c[0] ^ c[1] == c[2]: ans = 'Yes' else: if n % 3 == 0 and len(c_set) == 3: ank = int(n / 3) if c.count(c[0]) == ank and c.count(c[ank]) == ank and set_list[0] ^ set_list[1] == set_list[2]: ans = 'Yes' print(ans)
s129818695
p03583
u288430479
2,000
262,144
Wrong Answer
1,457
9,140
172
You are given an integer N. Find a triple of positive integers h, n and w such that 4/N = 1/h + 1/n + 1/w. If there are multiple solutions, any of them will be accepted.
n = int(input()) for a in range(1,3501): for b in range(1,3501): s = n*a*b t = 4*a*b-n*b-n*a if t!=0 and s%t==0: c = s/t print(a,b,s) exit()
s007537933
Accepted
1,997
9,212
513
n = int(input()) if n<=3000: for a in range(1,3501): for b in range(1,3501): s = n*a*b #s=4 t = 4*a*b-n*b-n*a #t=8-4-2 if s<=t*3500: if t!=0 and s%t==0 and t>0: c = s//t print(a,b,c) exit() else: for a in range(3501,1,-1): for b in range(3501,1,-1): s = n*a*b #s=4 t = 4*a*b-n*b-n*a #t=8-4-2 if s<=t*3500: if t!=0 and s%t==0 and t>0: c = s//t print(a,b,c) exit()
s555998143
p03644
u740284863
2,000
262,144
Wrong Answer
21
3,060
61
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()) if N % 2 == 0: print(N) else: print(N-1)
s980280761
Accepted
18
2,940
132
N = int(input()) count = 0 while True: c = 2**count if c > N: print(c//2) break else: count +=1
s955693148
p03854
u652737716
2,000
262,144
Wrong Answer
17
3,188
428
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
import sys S = input() while S: prefix = S[0:5] if prefix == 'dream': if S[5:7] == 'er': if S[7] == 'a': S = S[5:] else: S = S[7:] else: S = S[5:] elif prefix == 'erase': if S[5] == 'r': S = S[6:] else: S = S[5] else: print('NO') sys.exit(0) # print(S) print('YES')
s850034564
Accepted
69
3,188
461
import sys S = input() while S: prefix = S[0:5] if prefix == 'dream': if S[5:7] == 'er': if len(S) >= 8 and S[7] == 'a': S = S[5:] else: S = S[7:] else: S = S[5:] elif prefix == 'erase': if len(S) >= 6 and S[5] == 'r': S = S[6:] else: S = S[5:] else: print('NO') sys.exit(0) # print(S) print('YES')
s902831177
p03502
u764000168
2,000
262,144
Wrong Answer
17
2,940
194
An integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10. Given an integer N, determine whether it is a Harshad number.
def sum_digit(num): sums = 0 while num != 0: sums += num % 10 num //= 10 return sums n = int(input()) if sum_digit(n)%n == 0: print('Yes') else: print('No')
s478656945
Accepted
17
2,940
195
def sum_digit(num): sums = 0 while num != 0: sums += num % 10 num //= 10 return sums n = int(input()) if n % sum_digit(n) == 0: print('Yes') else: print('No')
s356903749
p03644
u733132703
2,000
262,144
Wrong Answer
17
2,940
325
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()) for i in range(N+1,-1,-1): if i == 64: print(i) break elif i == 32: print(i) break elif i == 16: print(i) break elif i == 8: print(i) break elif i == 4: print(i) break elif i == 2: print(i) break elif i == 1: print(1)
s530153793
Accepted
17
3,060
323
N = int(input()) for i in range(N,-1,-1): if i == 64: print(i) break elif i == 32: print(i) break elif i == 16: print(i) break elif i == 8: print(i) break elif i == 4: print(i) break elif i == 2: print(i) break elif i == 1: print(1)
s502113395
p03228
u556589653
2,000
1,048,576
Wrong Answer
17
3,060
290
In the beginning, Takahashi has A cookies, and Aoki has B cookies. They will perform the following operation alternately, starting from Takahashi: * If the number of cookies in his hand is odd, eat one of those cookies; if the number is even, do nothing. Then, give one-half of the cookies in his hand to the other person. Find the numbers of cookies Takahashi and Aoki respectively have after performing K operations in total.
A,B,K = map(int,input().split()) count = 0 for i in range(100): if count ==K: break else: if A%2 == 1: A = A-1 B = B + A/2 A = A/2 count += 1 if count == K: break else: if B%2 == 1: B = B-1 A = A+ B/2 B = B/2 count += 1 print(A,B)
s451395233
Accepted
17
3,064
300
A,B,K = map(int,input().split()) count = 0 for i in range(100): if count ==K: break else: if A%2 == 1: A = A-1 B = B + A/2 A = A/2 count += 1 if count == K: break else: if B%2 == 1: B = B-1 A = A+ B/2 B = B/2 count += 1 print(int(A),int(B))
s381540885
p03360
u279461856
2,000
262,144
Wrong Answer
17
2,940
88
There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times: * Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n. What is the largest possible sum of the integers written on the blackboard after K operations?
a = list(map(int, input().split())) k = int(input()) m = max(a) print(m**k + sum(a) - m)
s600650287
Accepted
17
2,940
92
a = list(map(int, input().split())) k = int(input()) m = max(a) print(m * 2**k + sum(a) - m)
s470996708
p02390
u364762182
1,000
131,072
Wrong Answer
30
6,732
142
Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
a = input() a = int(a) s = a%60 m = (a-a%60)/60%60 h = (a-s-m*60)/3600 m = int(m) h = int(h) s=str(s) m=str(m) h=str(h) print(s + ':'+m+':'+h)
s668669107
Accepted
30
6,736
142
a = input() a = int(a) s = a%60 m = (a-a%60)/60%60 h = (a-s-m*60)/3600 m = int(m) h = int(h) s=str(s) m=str(m) h=str(h) print(h + ':'+m+':'+s)
s427250967
p03067
u041382530
2,000
1,048,576
Wrong Answer
17
2,940
79
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.
a,b,c=map(int,input().split()) if (a<b)&(b<c): print('Yes') else: print('No')
s513449125
Accepted
19
3,316
95
a=list(map(int,input().split())) if (max(a)!=a[2])&(min(a)!=a[2]):print('Yes') else:print('No')
s049352914
p03228
u967835038
2,000
1,048,576
Wrong Answer
18
3,188
269
In the beginning, Takahashi has A cookies, and Aoki has B cookies. They will perform the following operation alternately, starting from Takahashi: * If the number of cookies in his hand is odd, eat one of those cookies; if the number is even, do nothing. Then, give one-half of the cookies in his hand to the other person. Find the numbers of cookies Takahashi and Aoki respectively have after performing K operations in total.
a,b,k=map(int,input().split()) flag=0 if k==(k//2)*2+1: flag=1 for i in range(k//2): if a==(a//2)*2+1: a=a-1 b+=(a/2) a=a/2 if b==(b//2)*2+1: b=b-1 a+=(b/2) b=b/2 if flag==1: a=a-1 b+=(a/2) a=a/2 print(a) print(b)
s923274115
Accepted
17
3,064
270
a,b,k=map(int,input().split()) flag=0 if k%2==1: flag=1 for i in range(k//2): if a%2==1: a=a-1 b+=(a/2) a=a/2 if b%2==1: b=b-1 a+=(b/2) b=b/2 if flag==1: if a%2==1: a=a-1 b+=(a/2) a=a/2 print(int(a),int(b))
s030890289
p03599
u481250941
3,000
262,144
Wrong Answer
77
16,128
1,265
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.
# # abc074 c # import sys from io import StringIO import unittest class TestClass(unittest.TestCase): def assertIO(self, input, output): stdout, stdin = sys.stdout, sys.stdin sys.stdout, sys.stdin = StringIO(), StringIO(input) resolve() sys.stdout.seek(0) out = sys.stdout.read()[:-1] sys.stdout, sys.stdin = stdout, stdin self.assertEqual(out, output) def test_入力例_1(self): input = """1 2 10 20 15 200""" output = """110 10""" self.assertIO(input, output) def test_入力例_2(self): input = """1 2 1 2 100 1000""" output = """200 100""" self.assertIO(input, output) def test_入力例_3(self): input = """17 19 22 26 55 2802""" output = """2634 934""" self.assertIO(input, output) def resolve(): A, B, C, D, E, F = map(int, input().split()) w = 0 s = 0 while w + B <= F//100: w += B while w + A <= F//100: w += A while 100*w + s <= F and s + D <= E*w: s += D while 100*w + s <= F and s + C <= E*w: s += C print(f"{100*w+s} {s}") if __name__ == "__main__": # unittest.main() resolve()
s375696643
Accepted
169
16,232
1,466
# # abc074 c # import sys from io import StringIO import unittest class TestClass(unittest.TestCase): def assertIO(self, input, output): stdout, stdin = sys.stdout, sys.stdin sys.stdout, sys.stdin = StringIO(), StringIO(input) resolve() sys.stdout.seek(0) out = sys.stdout.read()[:-1] sys.stdout, sys.stdin = stdout, stdin self.assertEqual(out, output) def test_入力例_1(self): input = """1 2 10 20 15 200""" output = """110 10""" self.assertIO(input, output) def test_入力例_2(self): input = """1 2 1 2 100 1000""" output = """200 100""" self.assertIO(input, output) def test_入力例_3(self): input = """17 19 22 26 55 2802""" output = """2634 934""" self.assertIO(input, output) def resolve(): A, B, C, D, E, F = map(int, input().split()) N = 0 W = 100*A S = 0 for i in range(31): for j in range(31): for k in range(101): for l in range(101): w = A*i+B*j s = C*k+D*l if w == 0 or 100*w+s > F or s > w*E: break n = 100*s / (100*w+s) if n > N: N = n W = 100*w+s S = s print(f"{W} {S}") if __name__ == "__main__": # unittest.main() resolve()
s833096507
p03493
u106297876
2,000
262,144
Wrong Answer
17
2,940
69
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 = map(int, list(input())) print(sum(s)) print(sum(s)) print(sum(s))
s286116086
Accepted
17
2,940
42
s = map(int, list(input())) print(sum(s))
s440227472
p04029
u152638361
2,000
262,144
Wrong Answer
17
2,940
31
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)
s922949879
Accepted
17
2,940
34
N = int(input()) print(N*(N+1)//2)
s559926174
p02678
u874333466
2,000
1,048,576
Wrong Answer
878
44,016
864
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 i in range(M): a, b = map(int,input().split()) A.append(a) B.append(b) link_dic = {} for i in range(M): if A[i] not in link_dic.keys(): link_dic[A[i]] = [B[i]] else: link_dic[A[i]].append(B[i]) if B[i] not in link_dic.keys(): link_dic[B[i]] = [A[i]] else: link_dic[B[i]].append(A[i]) sign = [0] * N j = 1 current_room = [1] def search_room(l): global current_room did = 0 next_cr = [] for i in l: li = link_dic[i] for k in range(len(li)): if sign[li[k]-1] == 0: sign[li[k]-1] = i next_cr.append(li[k]) did += 1 current_room = list(next_cr) if did == 0: return 1 else: return 0 while j > 0: result = search_room(current_room) if result: break sign_ans = sign[1:N] for i in sign_ans: print(i)
s106232400
Accepted
860
44,152
927
N, M = map(int,input().split()) A = [] B = [] for i in range(M): a, b = map(int,input().split()) A.append(a) B.append(b) link_dic = {} for i in range(M): if A[i] not in link_dic.keys(): link_dic[A[i]] = [B[i]] else: link_dic[A[i]].append(B[i]) if B[i] not in link_dic.keys(): link_dic[B[i]] = [A[i]] else: link_dic[B[i]].append(A[i]) sign = [0] * N j = 1 current_room = [1] def search_room(l): global current_room did = 0 next_cr = [] for i in l: li = link_dic[i] for k in range(len(li)): if sign[li[k]-1] == 0: sign[li[k]-1] = i next_cr.append(li[k]) did += 1 current_room = list(next_cr) if did == 0: return 1 else: return 0 while j > 0: result = search_room(current_room) if result: break sign_ans = sign[1:N] if min(sign_ans) == 0: print('No') else: print('Yes') for i in sign_ans: print(i)
s105837412
p03486
u465246274
2,000
262,144
Wrong Answer
17
2,940
103
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.
s = input() t = input() if ''.join(sorted(s)) < ''.join(sorted(t)): print('Yes') else: print('No')
s049511398
Accepted
17
2,940
117
s = input() t = input() if ''.join(sorted(s)) < ''.join(sorted(t, reverse=True)): print('Yes') else: print('No')
s619977453
p04043
u221842690
2,000
262,144
Wrong Answer
17
2,940
144
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
abc_list = list(map(int, input().split())) if abc_list.count("5") ==2 and abc_list.count("7") == 1: print("YES") else: print("NO")
s927746534
Accepted
17
2,940
140
abc_list = list(map(int, input().split())) if abc_list.count(5) ==2 and abc_list.count(7) == 1: print("YES") else: print("NO")
s605969643
p02821
u606045429
2,000
1,048,576
Wrong Answer
185
14,300
400
Takahashi has come to a party as a special guest. There are N ordinary guests at the party. The i-th ordinary guest has a _power_ of A_i. Takahashi has decided to perform M _handshakes_ to increase the _happiness_ of the party (let the current happiness be 0). A handshake will be performed as follows: * Takahashi chooses one (ordinary) guest x for his left hand and another guest y for his right hand (x and y can be the same). * Then, he shakes the left hand of Guest x and the right hand of Guest y simultaneously to increase the happiness by A_x+A_y. However, Takahashi should not perform the same handshake more than once. Formally, the following condition must hold: * Assume that, in the k-th handshake, Takahashi shakes the left hand of Guest x_k and the right hand of Guest y_k. Then, there is no pair p, q (1 \leq p < q \leq M) such that (x_p,y_p)=(x_q,y_q). What is the maximum possible happiness after M handshakes?
N, M, *A = map(int, open(0).read().split()) A.sort(reverse=True) K = int(M ** 0.5) while not (K * (K + 1) // 2 <= M < (K + 1) * (K + 2) // 2): K += 1 A = A[:K + 1] Q = [] for i in range(len(A) // 2 + 1): Q.append(A[i] + A[-i - 1]) Q.sort(reverse=True) ans = 0 for i, a in enumerate(A): ans += a * (2 * i + 2 * max(0, K - i - 2)) print(ans + sum(Q[:M - ((K + 1) * (K + 2) // 2)]))
s483177102
Accepted
668
23,880
489
from itertools import accumulate MAX = 2 * 10 ** 5 + 5 N, M, *A = map(int, open(0).read().split()) B = [0] * MAX for a in A: B[a] += 1 C = list(accumulate(reversed(B)))[::-1] ng, ok = 1, MAX while abs(ok - ng) > 1: m = (ok + ng) // 2 if sum(C[max(0, m - a)] for a in A) >= M: ng = m else: ok = m D = list(accumulate(reversed(list(i * b for i, b in enumerate(B)))))[::-1] print(sum(D[max(0, ng - a)] - (ng - a) * C[max(0, ng - a)] for a in A) + ng * M)
s356116641
p03645
u228232845
2,000
262,144
Wrong Answer
2,206
24,932
647
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N. There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i. Cat Snuke is on Island 1 now, and wants to go to Island N. However, it turned out that there is no boat service from Island 1 to Island N, so he wants to know whether it is possible to go to Island N by using two boat services. Help him.
import sys def input(): return sys.stdin.readline().strip() def I(): return int(input()) def LI(): return list(map(int, input().split())) def IR(n): return [I() for i in range(n)] def LIR(n): return [LI() for i in range(n)] def SR(n): return [S() for i in range(n)] def S(): return input() def LS(): return input().split() n, m = LI() a = [] b = [] for _ in range(m): ai, bi = LI() a.append(ai) b.append(bi) b1 = [bi for ai, bi in zip(a, b) if ai == 1] an = [ai for ai, bi in zip(a, b) if bi == n] ans = 'IMPOSSIBLE' for v1 in b1: for v2 in an: if v1 == v2: ans = 'POSSIBILE' break print(ans)
s177304534
Accepted
299
32,380
594
import sys def input(): return sys.stdin.readline().strip() def I(): return int(input()) def LI(): return list(map(int, input().split())) def IR(n): return [I() for i in range(n)] def LIR(n): return [LI() for i in range(n)] def SR(n): return [S() for i in range(n)] def S(): return input() def LS(): return input().split() n, m = LI() a = [] b = [] for _ in range(m): ai, bi = LI() a.append(ai) b.append(bi) b1 = set(bi for ai, bi in zip(a, b) if ai == 1) an = set(ai for ai, bi in zip(a, b) if bi == n) s = b1 & an ans = 'POSSIBLE' if len(s) > 0 else 'IMPOSSIBLE' print(ans)
s531061076
p03997
u103341055
2,000
262,144
Wrong Answer
17
2,940
68
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
a = int(input()) b = int(input()) h = int(input()) print((a+b)*h/2)
s945911938
Accepted
17
2,940
73
a = int(input()) b = int(input()) h = int(input()) print(int((a+b)*h/2))
s202145814
p03369
u485566817
2,000
262,144
Wrong Answer
17
2,940
97
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 = str(input()) S = 0 for i in range(1, 3): if a[i] == 'o': S ++ S print(700+S*100)
s908526153
Accepted
17
2,940
97
a = str(input()) S = 0 for i in range(0, 3): if a[i] == 'o': S += 1 print(700+S*100)
s375643832
p03494
u244118793
2,000
262,144
Wrong Answer
19
3,060
311
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 = [] a = list(map(int, input().split())) product = 1 for i in range(n): product *= a[i] while product % 2 == 0: for i in range(n): a[i] = a[i]/2 for i in range(n): product = 1 product *= a[i] print(a)
s369076628
Accepted
20
3,060
331
n = int(input()) a = [] a = list(map(int, input().split())) counter = 0 check = 0 for i in range(n): if a[i] % 2 == 0: check += 1 while check == n: check = 0 for i in range(n): a[i] = a[i]/2 for i in range(n): if a[i] % 2 == 0: check += 1 counter += 1 print(counter)
s968033432
p02927
u089121621
2,000
1,048,576
Wrong Answer
22
3,064
263
Today is August 24, one of the five Product Days in a year. A date m-d (m is the month, d is the date) is called a Product Day when d is a two-digit number, and all of the following conditions are satisfied (here d_{10} is the tens digit of the day and d_1 is the ones digit of the day): * d_1 \geq 2 * d_{10} \geq 2 * d_1 \times d_{10} = m Takahashi wants more Product Days, and he made a new calendar called Takahashi Calendar where a year consists of M month from Month 1 to Month M, and each month consists of D days from Day 1 to Day D. In Takahashi Calendar, how many Product Days does a year have?
m,d = list(map(int, input().split())) cnt = 0 for j in range(1,m+1): for i in range(1, d+1, 1): d1 = i % 10 d2 = int(i / 10) if((d1 >= 2) & (d2 >= 2) & (d1 * d2 == j) ): cnt+=1 print(str(j)+'月'+str(i)+'日')
s072163428
Accepted
22
3,064
242
m,d = list(map(int, input().split())) cnt = 0 for j in range(1,m+1): for i in range(1, d+1, 1): d1 = i % 10 d2 = int(i / 10) if((d1 >= 2) & (d2 >= 2) & (d1 * d2 == j) ): cnt+=1 print(cnt)
s051840046
p03624
u247465867
2,000
262,144
Wrong Answer
19
3,188
359
You are given a string S consisting of lowercase English letters. Find the lexicographically (alphabetically) smallest lowercase English letter that does not occur in S. If every lowercase English letter occurs in S, print `None` instead.
#2019/10/22 S = open(0).read() # print(S) set_S=list(set(S)) set_S.sort() # print(set_S) alpha = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] # print(alpha) for i in range(len(alpha)): if set_S[i] != alpha[i]: print(alpha[i]) break if i==len(alpha)-1: print("None")
s319559503
Accepted
19
3,188
247
#2019/10/22 #S = open(0).read() S = input() # print(S) set_S=set(S) # print(set_S) alpha = "abcdefghijklmnopqrstuvwxyz" # print(alpha) productSet = sorted(set_S^set(alpha)) #print(productSet) print("None" if len(productSet)==0 else productSet[0])
s926084121
p03644
u864667985
2,000
262,144
Wrong Answer
18
2,940
107
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()) cand = [2**x for x in range(7)] for i in range(n,0,-1): if i in cand: print(i)
s302500610
Accepted
20
2,940
121
n = int(input()) cand = [2**x for x in range(7)] for i in range(n,0,-1): if i in cand: print(i) break
s566872104
p02603
u033566567
2,000
1,048,576
Wrong Answer
32
9,196
558
To become a millionaire, M-kun has decided to make money by trading in the next N days. Currently, he has 1000 yen and no stocks - only one kind of stock is issued in the country where he lives. He is famous across the country for his ability to foresee the future. He already knows that the price of one stock in the next N days will be as follows: * A_1 yen on the 1-st day, A_2 yen on the 2-nd day, ..., A_N yen on the N-th day. In the i-th day, M-kun can make the following trade **any number of times** (possibly zero), **within the amount of money and stocks that he has at the time**. * Buy stock: Pay A_i yen and receive one stock. * Sell stock: Sell one stock for A_i yen. What is the maximum possible amount of money that M-kun can have in the end by trading optimally?
n = int(input()) a = list(map(int, input().split())) money = 1000 stack = 0 up = [] last_high = 0 high = 0 low = a[0] for i in range(n): if i == 0: up.append(-1) elif a[i] > a[i - 1]: up.append(1) elif a[i] < a[i - 1]: up.append(-1) else: up.append(0) print(up) for i in range(n): if up[i] == 1: high = a[i] for j in range(last_high, i): if up[j] == -1: low = a[j] stack = money // low money %= low money += stack * high print(money)
s233968504
Accepted
37
9,228
631
n = int(input()) a = list(map(int, input().split())) money = 1000 stack = 0 up = [] last_high = 0 high = 0 low = a[0] for i in range(n): if i == 0: up.append(-1) elif a[i] < a[i-1]: up.append(-1) elif a[i] >= a[i-1]: if i == n-1: up.append(1) elif a[i] > a[i+1]: up.append(1) else: up.append(0) for i in range(n): if up[i] == 1: high = a[i] for j in range(last_high, i): if up[j] == -1: low = a[j] stack = money // low money %= low money += stack * high print(money)
s694949078
p03050
u500944229
2,000
1,048,576
Wrong Answer
2,104
2,940
155
Snuke received a positive integer N from Takahashi. A positive integer m is called a _favorite number_ when the following condition is satisfied: * The quotient and remainder of N divided by m are equal, that is, \lfloor \frac{N}{m} \rfloor = N \bmod m holds. Find all favorite numbers and print the sum of those.
n = int(input()) result = 0 for x in range(1,n): if n%x == 0: m = (n/x-1) if m<=1: break result += m print(result)
s928041670
Accepted
118
3,272
389
n = int(input()) def make_divisors(n): divisors = [] for i in range(1, int(n**0.5)+1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n//i) return divisors fav = make_divisors(n) result = 0 for x in fav: if x == n: continue m = int(n/x)-1 if int(n/m)==n%m: result += m print(result)
s114940519
p03007
u405256066
2,000
1,048,576
Wrong Answer
1,852
14,144
441
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.
from sys import stdin N = int(stdin.readline().rstrip()) data = [int(x) for x in stdin.readline().rstrip().split()] data = sorted(data) ans = [0] * (N-1) for i in range(1,N): if i % 2 == 0: val = data[-1] - data[0] ans[i-1] = (data[-1],data[0]) else: val = data[0] - data[-1] ans[i-1] = (data[0],data[-1]) data = sorted(data[i:N-i] + [val]) for j,k in ans: print(j,k) print(sum(data))
s640729667
Accepted
265
20,544
333
from sys import stdin N = int(stdin.readline().rstrip()) A = [int(x) for x in stdin.readline().rstrip().split()] A.sort() ans = [] p = A[0] q = A[-1] for i in A[1:-1]: if i < 0: ans.append((q,i)) q -= i else: ans.append((p,i)) p -= i ans.append((q,p)) print(q-p) for i,j in ans: print(i,j)
s434241087
p03360
u693933222
2,000
262,144
Wrong Answer
19
2,940
104
There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times: * Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n. What is the largest possible sum of the integers written on the blackboard after K operations?
num = list(map(int,input().split())) k = int(input()) for i in range(k): max(num)*2 print(sum(num))
s982457321
Accepted
17
2,940
114
num = list(map(int,input().split())) k = int(input()) num.sort() for i in range(k): num[-1]*=2 print(sum(num))
s548058262
p02269
u253463900
2,000
131,072
Wrong Answer
30
7,720
1,098
Your task is to write a program of a simple _dictionary_ which implements the following instructions: * **insert _str_** : insert a string _str_ in to the dictionary * **find _str_** : if the distionary contains _str_ , then print 'yes', otherwise print 'no'
def hash1(m,key): return key % m def hash2(m,key): return 1 + key % ( m -1 ) def hash(m,key,i): return (hash1(m,key) + i * hash2(m,key) ) % m def insert(T,key): i = 0 l = len(T) while True: h = hash(l,key,i) if (T[h] is None ): T[h] = key return h else: i += 1 def search(T,key): l = len(T) i = 0 while True: h = hash(l,key,i) if(T[h] == key): return h elif(T[h] is None or h >= l): return -1 else: i += 1 def find(T,key): a = search(T,key) if(a == -1): print('no') else: print('yes') dict = {'A' : '1', 'C' : '2', 'G' : '3', 'T' : '4'} data = [] T = [None]*4444 n = int(input()) while n > 0: st = input() d = list(st.split()) ### convert key to num(1~4) tmp_key = '' for x in list(d[1]): tmp_key += dict[x] data.append([d[0],int(tmp_key)]) n -= 1 print(data) for com in data: if(com[0] == 'insert'): insert(T,com[1]) else: find(T,com[1])
s130562430
Accepted
8,840
207,444
1,157
def hash1(m, key): return key % m def hash2(m, key): return 1 + key % (m - 1) def hash(m, key, i): return (hash1(m, key) + i * hash2(m, key) ) % m def insert(T, key): i = 0 l = len(T) while True: h = hash(1046527,key,i) if (T[h] == None ): T[h] = key return h elif (T[h] == key): return h else: i += 1 def search(T,key): l = len(T) i = 0 while True: h = hash(1046527,key,i) if(T[h] == key): return h elif(T[h] is None or h >= l): return -1 else: i += 1 def find(T, key): a = search(T,key) if(a == -1): print('no') else: print('yes') dict = {'A' : '1', 'C' : '2', 'G' : '3', 'T' : '4'} data = [] T = [None]*1046527 n = int(input()) while n > 0: st = input() d = list(st.split()) ### convert key to num(1~4) tmp_key = '' for x in list(d[1]): tmp_key += dict[x] data.append([d[0],int(tmp_key)]) n -= 1 for com in data: if(com[0] == 'insert'): insert(T,com[1]) else: find(T,com[1])
s816820843
p02406
u546968095
1,000
131,072
Wrong Answer
20
5,592
272
In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops. Note that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto. Write a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements. void call(int n){ int i = 1; CHECK_NUM: int x = i; if ( x % 3 == 0 ){ cout << " " << i; goto END_CHECK_NUM; } INCLUDE3: if ( x % 10 == 3 ){ cout << " " << i; goto END_CHECK_NUM; } x /= 10; if ( x ) goto INCLUDE3; END_CHECK_NUM: if ( ++i <= n ) goto CHECK_NUM; cout << endl; }
def call(n): ret = "" for i in range(int(n)): if 0 == i % 3: ret += " " + str(i) elif -1 != str(i).find("3"): ret += " " + str(i) return ret if __name__ == "__main__": n = input() ret = call(n) print (ret)
s702759123
Accepted
20
5,628
277
def call(n): ret = "" for i in range(1, int(n)+1): if 0 == i % 3: ret += " " + str(i) elif -1 != str(i).find("3"): ret += " " + str(i) return ret if __name__ == "__main__": n = input() ret = call(n) print (ret)
s897294648
p03545
u360085167
2,000
262,144
Wrong Answer
18
3,064
749
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.
ABCD = int(input()) a = int(ABCD//10e2) b = int((ABCD-a*10e2)//10e1) c = int((ABCD-a*10e2-b*10e1)//10) d = int(ABCD-a*10e2-b*10e1-c*10) print(a,b,c,d) if a+b+c+d == 7: print(str(a)+"+"+str(b)+"+"+str(c)+"+"+str(d)+"=7") elif a-b+c+d == 7: print(str(a)+"-"+str(b)+"+"+str(c)+"+"+str(d)+"=7") elif a+b-c+d == 7: print(str(a)+"+"+str(b)+"-"+str(c)+"+"+str(d)+"=7") elif a+b+c-d == 7: print(str(a)+"+"+str(b)+"+"+str(c)+"-"+str(d)+"=7") elif a-b-c+d == 7: print(str(a)+"-"+str(b)+"-"+str(c)+"+"+str(d)+"=7") elif a-b+c-d == 7: print(str(a)+"-"+str(b)+"+"+str(c)+"-"+str(d)+"=7") elif a+b-c-d == 7: print(str(a)+"+"+str(b)+"-"+str(c)+"-"+str(d)+"=7") elif a-b-c-d == 7: print(str(a)+"-"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
s594319721
Accepted
17
3,064
734
ABCD = int(input()) a = int(ABCD//10e2) b = int((ABCD-a*10e2)//10e1) c = int((ABCD-a*10e2-b*10e1)//10) d = int(ABCD-a*10e2-b*10e1-c*10) if a+b+c+d == 7: print(str(a)+"+"+str(b)+"+"+str(c)+"+"+str(d)+"=7") elif a-b+c+d == 7: print(str(a)+"-"+str(b)+"+"+str(c)+"+"+str(d)+"=7") elif a+b-c+d == 7: print(str(a)+"+"+str(b)+"-"+str(c)+"+"+str(d)+"=7") elif a+b+c-d == 7: print(str(a)+"+"+str(b)+"+"+str(c)+"-"+str(d)+"=7") elif a-b-c+d == 7: print(str(a)+"-"+str(b)+"-"+str(c)+"+"+str(d)+"=7") elif a-b+c-d == 7: print(str(a)+"-"+str(b)+"+"+str(c)+"-"+str(d)+"=7") elif a+b-c-d == 7: print(str(a)+"+"+str(b)+"-"+str(c)+"-"+str(d)+"=7") elif a-b-c-d == 7: print(str(a)+"-"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
s181218963
p03370
u646989285
2,000
262,144
Wrong Answer
479
3,868
233
Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
N, X = [int(i) for i in input().split()] donut_type = [int(input()) for i in range(N)] X = X - sum(donut_type) result = N while X >= sorted(donut_type)[0]: X = X - sorted(donut_type)[0] print(X) result += 1 print(result)
s050629478
Accepted
19
3,060
159
N, X = [int(i) for i in input().split()] donut_type = [int(input()) for i in range(N)] X = X - sum(donut_type) result = N + X // min(donut_type) print(result)
s500824912
p02612
u202560873
2,000
1,048,576
Wrong Answer
27
8,768
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()) print(min(0, 1000 - N % 1000))
s556896225
Accepted
31
9,032
49
N = int(input()) print((1000 - N % 1000) % 1000)
s286625345
p04043
u981206782
2,000
262,144
Wrong Answer
17
2,940
105
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
a=list(input().split()) if a==[5,5,7] or a==[5,7,5] or a==[7,5,5]: print("YES") else: print("NO")
s387317721
Accepted
17
2,940
115
a=list(map(int,input().split())) if a==[5,5,7] or a==[5,7,5] or a==[7,5,5]: print("YES") else: print("NO")
s134289306
p03625
u452015170
2,000
262,144
Wrong Answer
94
14,252
246
We have N sticks with negligible thickness. The length of the i-th stick is A_i. Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.
n = int(input()) a = list(map(int, input().split())) a.sort(reverse = True) for i in range(3, n - 3) : if a[i] == a[i + 1] and a[i + 2] == a[i + 3] : print(a[i] * a[i + 2]) break else : continue else : print(0)
s714686609
Accepted
90
14,244
309
n = int(input()) a = list(map(int, input().split())) a.sort(reverse = True) condition = True for i in range(0, n - 3) : if a[i] == a[i + 1] : for j in range(i + 2, n - 1) : if a[j] == a[j + 1] : print(a[i] * a[j]) break break else : print(0)
s914486794
p03827
u590647174
2,000
262,144
Wrong Answer
17
3,064
251
You have an integer variable x. Initially, x=0. Some person gave you a string S of length N, and using the string you performed the following operation N times. In the i-th operation, you incremented the value of x by 1 if S_i=`I`, and decremented the value of x by 1 if S_i=`D`. Find the maximum value taken by x during the operations (including before the first operation, and after the last operation).
def judge(N,S): x = 0 maxi = 0 lst = list(S) for i in range(N): if lst[i]=="I": x += 1 else: x -= 1 if maxi<x: maxi = x print(max) N = int(input()) S = input() judge(N,S)
s406314108
Accepted
17
3,060
252
def judge(N,S): x = 0 maxi = 0 lst = list(S) for i in range(N): if lst[i]=="I": x += 1 else: x -= 1 if maxi<x: maxi = x print(maxi) N = int(input()) S = input() judge(N,S)
s759859103
p02396
u780025254
1,000
131,072
Wrong Answer
140
7,600
154
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.
while True: x = int(input()) i = 1 if x != 0: print('Case {}: {}'.format(i, x)) i += 1 elif x == 0: break
s725157664
Accepted
140
5,560
132
i = 1 while True: x = input() if x == "0": break else: print("Case {}: {}".format(i, x)) i += 1
s373672666
p02975
u079022693
2,000
1,048,576
Wrong Answer
130
15,396
743
Snuke has N hats. The i-th hat has an integer a_i written on it. There are N camels standing in a circle. Snuke will put one of his hats on each of these camels. If there exists a way to distribute the hats to the camels such that the following condition is satisfied for every camel, print `Yes`; otherwise, print `No`. * The bitwise XOR of the numbers written on the hats on both adjacent camels is equal to the number on the hat on itself. What is XOR? The bitwise XOR x_1 \oplus x_2 \oplus \ldots \oplus x_n of n non- negative integers x_1, x_2, \ldots, x_n is defined as follows: - When x_1 \oplus x_2 \oplus \ldots \oplus x_n is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if the number of integers among x_1, x_2, \ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even. For example, 3 \oplus 5 = 6.
from sys import stdin from collections import Counter def main(): readline=stdin.readline N=int(readline()) a=list(map(int,readline().split())) c=Counter(a) c=sorted(c.items()) if N%3!=0: if len(c)==1 and c[0][0]=="0": print("Yes") else: print("No") elif N%3==0: if len(c)==1 and c[0][0]==0: print("Yes") elif len(c)==2 and c[0][0]==0 and c[0][1]==N//3: print("Yes") elif len(c)==3 and c[0][1]==2 and c[1][1]==2 and c[2][1]==2 and c[0][0]^c[1][0]^c[2][0]==0: print("Yes") else: print("No") if __name__=="__main__": main()
s495301611
Accepted
125
15,400
750
from sys import stdin from collections import Counter def main(): readline=stdin.readline N=int(readline()) a=list(map(int,readline().split())) c=Counter(a) c=sorted(c.items()) if N%3!=0: if len(c)==1 and c[0][0]==0: print("Yes") else: print("No") elif N%3==0: if len(c)==1 and c[0][0]==0: print("Yes") elif len(c)==2 and c[0][0]==0 and c[0][1]==N//3: print("Yes") elif len(c)==3 and c[0][1]==N//3 and c[1][1]==N//3 and c[2][1]==N//3 and c[0][0]^c[1][0]^c[2][0]==0: print("Yes") else: print("No") if __name__=="__main__": main()
s479438438
p03416
u329865314
2,000
262,144
Wrong Answer
88
3,060
182
Find the number of _palindromic numbers_ among the integers between A and B (inclusive). Here, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward.
a,b = map(int,input().split()) ans = 0 def kai(s): for j in range(len(s)): if s[j] != s[len(s)-j-1]: return(0) return(1) for i in range(a,b+1): ans += kai(str(i)) print(ans)
s994813193
Accepted
94
3,060
181
a,b = map(int,input().split()) ans = 0 def kai(s): for j in range(len(s)): if s[j] != s[len(s)-j-1]: return(0) return(1) for i in range(a,b+1): ans += kai(str(i)) print(ans)
s609134784
p03795
u662449766
2,000
262,144
Wrong Answer
17
2,940
149
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.
import sys input = sys.stdin.readline def main(): n = int(input()) print(n * 800 + n // 15 * 200) if __name__ == "__main__": main()
s180969304
Accepted
17
2,940
149
import sys input = sys.stdin.readline def main(): n = int(input()) print(n * 800 - n // 15 * 200) if __name__ == "__main__": main()
s071114074
p03380
u948524308
2,000
262,144
Wrong Answer
2,104
15,392
308
Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted.
from math import factorial n=int(input()) a=list(map(int,input().split())) a.sort() ai=a[n-1] a0=0 for i in range(n-1): j=a[i] temp=factorial(ai)//(factorial(ai-j)*factorial(j)) if a0>=temp: print(str(a[i-1])+" "+str(ai)) exit() a0=temp print(str(a[n-2])+" "+str(ai))
s804012609
Accepted
110
14,060
185
n=int(input()) a=list(map(int,input().split())) a.sort(reverse=True) ans1=a[0] b=ans1//2 ans2=0 for i in range(n): if abs(a[i]-b)<abs(ans2-b): ans2=a[i] print(ans1,ans2)
s896538586
p03719
u379559362
2,000
262,144
Wrong Answer
17
2,940
92
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
a, b, c = map(int, input().split()) if a <= c <= b: print("YES") else: print("NO")
s098564260
Accepted
17
2,940
92
a, b, c = map(int, input().split()) if a <= c <= b: print("Yes") else: print("No")
s836893638
p03472
u557494880
2,000
262,144
Wrong Answer
537
16,900
485
You are going out for a walk, when you suddenly encounter a monster. Fortunately, you have N katana (swords), Katana 1, Katana 2, …, Katana N, and can perform the following two kinds of attacks in any order: * Wield one of the katana you have. When you wield Katana i (1 ≤ i ≤ N), the monster receives a_i points of damage. The same katana can be wielded any number of times. * Throw one of the katana you have. When you throw Katana i (1 ≤ i ≤ N) at the monster, it receives b_i points of damage, and you lose the katana. That is, you can no longer wield or throw that katana. The monster will vanish when the total damage it has received is H points or more. At least how many attacks do you need in order to vanish it in total?
N,H = map(int,input().split()) ken = [] for i in range(N): a,b = map(int,input().split()) ken.append((a,b)) ken.sort() A,B = ken.pop() ans = 0 for i in range(N-1): a,b = ken[i] ken[i] = (b,a) ken.sort() for i in range(N-1): b,a = ken[i] if b >= A: if b >= B: ans += 1 H -= b else: ans += 1 H -= B else: ans += (H-1)//A + 1 H = 0 if H <= 0: print(ans) quit()
s382215473
Accepted
549
16,920
648
N,H = map(int,input().split()) ken = [] for i in range(N): a,b = map(int,input().split()) ken.append((a,b)) ken.sort() A,B = ken.pop() ans = 0 for i in range(N-1): a,b = ken[i] ken[i] = (b,a) ken.sort() for i in range(N-1): b,a = ken[-i-1] if b >= A: if b >= B: ans += 1 H -= b else: ans += 1 H -= B B = 0 if H > 0: ans += 1 H -= b if H <= 0: print(ans) quit() if B != 0: H -= B ans += 1 if H <= 0: print(ans) quit() ans += H//A if H % A >= 1: ans += 1 print(ans)
s091699486
p03080
u350697094
2,000
1,048,576
Wrong Answer
18
2,940
167
There are N people numbered 1 to N. Each person wears a red hat or a blue hat. You are given a string s representing the colors of the people. Person i wears a red hat if s_i is `R`, and a blue hat if s_i is `B`. Determine if there are more people wearing a red hat than people wearing a blue hat.
N = input(int) L = input() R_list = [s for s in L if 'R' in s] B_list = [s for s in L if 'B' in s] if len(R_list) >len(B_list): print('Yes') else: print('No')
s728650202
Accepted
18
2,940
163
N = input() L = input() R_list = [s for s in L if 'R' in s] B_list = [s for s in L if 'B' in s] if len(R_list) >len(B_list): print('Yes') else: print('No')
s938023600
p03698
u450956662
2,000
262,144
Wrong Answer
26
3,060
215
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.
# -*- coding: utf-8 -*- S = input() list(S) boolean = True for i in range(len(S)): for j in range(i+1, len(S)): if i == j: boolean = False [print('no') if boolean == True else print('yes')]
s790239158
Accepted
29
8,984
153
S = input() char = [chr(ord('a') + i) for i in range(26)] for c in char: if S.count(c) > 1: print('no') break else: print('yes')
s111458509
p02972
u625554679
2,000
1,048,576
Wrong Answer
660
21,912
376
There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N). For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it. We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied: * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2. Does there exist a good set of choices? If the answer is yes, find one good set of choices.
from functools import reduce add = lambda a, b: a+b N = int(input()) a = [0] + [int(x) for x in input().split()] balls = [0]*(N+1) for i in range(N, 0, -1): summ = reduce(add, [balls[j] for j in range(i, N+1, i)]) if summ % 2 == a[i]: pass else: balls[i] += 1 summ = reduce(add, balls) print(summ) if summ != 0: print(" ".join([str(x) for x in balls[1:]]))
s470596295
Accepted
456
20,384
384
from functools import reduce add = lambda a, b: a+b N = int(input()) a = [0] + [int(x) for x in input().split()] balls = [0]*(N+1) for i in range(N, 0, -1): if sum([balls[j] for j in range(i, N+1, i)]) % 2 != a[i]: balls[i] += 1 ans = [] for i, b in enumerate(balls): if b == 1: ans.append(i) print(len(ans)) if len(ans) != 0: print(" ".join([str(a) for a in ans]))
s683104994
p03827
u941753895
2,000
262,144
Wrong Answer
17
2,940
115
You have an integer variable x. Initially, x=0. Some person gave you a string S of length N, and using the string you performed the following operation N times. In the i-th operation, you incremented the value of x by 1 if S_i=`I`, and decremented the value of x by 1 if S_i=`D`. Find the maximum value taken by x during the operations (including before the first operation, and after the last operation).
N=int(input()) S=input() c=0 for x in S: if x=='I': c+=1 elif x=='D': c-=1 print(c)
s223607099
Accepted
17
2,940
161
N=int(input()) S=input() c=0 mx=0 for x in S: if x=='I': c+=1 elif x=='D': c-=1 mx=max(mx,c) print(mx)
s611226451
p02393
u782850499
1,000
131,072
Wrong Answer
20
7,488
159
Write a program which reads three integers, and prints them in ascending order.
a= [int(x) for x in input().split()] if a[0]>a[1]: a[0],a[1]=a[1],a[0] if a[1]>a[2]: a[1],a[2]=a[2],a[1] if a[0]>a[1]: a[0],a[1]=a[1],a[0] print(a)
s156300593
Accepted
20
7,680
194
a= [int(x) for x in input().split()] if a[0]>a[1]: a[0],a[1]=a[1],a[0] if a[1]>a[2]: a[1],a[2]=a[2],a[1] if a[0]>a[1]: a[0],a[1]=a[1],a[0] print("{0} {1} {2}".format(a[0],a[1],a[2]))
s977074580
p03567
u871334392
2,000
262,144
Wrong Answer
17
2,940
151
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() a = '' for i in range(len(s)-1): if s[i] + s[i+1] =='AC': a = 'yes' else: pass if a == 'yes': print(a) else: print('no')
s602954933
Accepted
18
2,940
151
s = input() a = '' for i in range(len(s)-1): if s[i] + s[i+1] =='AC': a = 'Yes' else: pass if a == 'Yes': print(a) else: print('No')
s877153394
p02843
u441246928
2,000
1,048,576
Wrong Answer
17
2,940
87
AtCoder Mart sells 1000000 of each of the six items below: * Riceballs, priced at 100 yen (the currency of Japan) each * Sandwiches, priced at 101 yen each * Cookies, priced at 102 yen each * Cakes, priced at 103 yen each * Candies, priced at 104 yen each * Computers, priced at 105 yen each Takahashi wants to buy some of them that cost exactly X yen in total. Determine whether this is possible. (Ignore consumption tax.)
X = int(input()) x = X//100 if X > x*105 : print('1') if X < x*105 : print('0')
s928291490
Accepted
17
2,940
90
X = int(input()) x = X//100 if X > x*105 : print('0') elif X <= x*105 : print('1')
s752083178
p02612
u773058758
2,000
1,048,576
Wrong Answer
27
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.
i = int(input()) print(i % 1000)
s224707997
Accepted
27
9,088
102
i = int(input().strip()) if i % 1000 == 0: print('0') else: print((i // 1000 + 1) * 1000 - i)
s384541182
p03679
u305965165
2,000
262,144
Wrong Answer
17
2,940
106
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 = (int(i) for i in input().split()) if b-a > x: print("dangerous") else: print("delicious")
s084442005
Accepted
17
2,940
140
x,a,b = (int(i) for i in input().split()) if b-a <= 0: print("delicious") elif b-a <= x: print("safe") else: print("dangerous")
s110542120
p03738
u725133562
2,000
262,144
Wrong Answer
17
3,064
400
You are given two positive integers A and B. Compare the magnitudes of these numbers.
a = input() b = input() al = len(a) bl = len(b) if al>bl: print('GREATER') elif al<bl: print('LESS') else: i = 0 check = 0 for i in range(al): if a[i] == b[i]: pass else: check += int(a[i]) - int(b[i]) break if check > 0: print('GRAETER') elif check < 0: print('LESS') else: print('EQUAL')
s864431808
Accepted
17
3,060
401
a = input() b = input() al = len(a) bl = len(b) if al>bl: print('GREATER') elif al<bl: print('LESS') else: i = 0 check = 0 for i in range(al): if a[i] == b[i]: pass else: check += int(a[i]) - int(b[i]) break if check > 0: print('GREATER') elif check < 0: print('LESS') else: print('EQUAL')
s344059230
p03852
u595289165
2,000
262,144
Wrong Answer
17
2,940
78
Given a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`.
if input() in "aiueo".split(): print("vowel") else: print("consonant")
s982752606
Accepted
17
2,940
76
if input() in list("aiueo"): print("vowel") else: print("consonant")
s800452327
p03386
u107091170
2,000
262,144
Wrong Answer
17
3,060
96
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()) for i in range(K): print(A+i) for i in range(K): print(B-i)
s916870834
Accepted
17
3,060
189
A,B,K=map(int, input().split()) L = [] for i in range(min(K,(B-A+2)//2)): L.append(A+i) for i in range(min(K,(B-A+2)//2)): L.append(B-i) L = sorted(list(set(L))) for i in L: print(i)
s075077531
p03352
u857070771
2,000
1,048,576
Wrong Answer
17
2,940
137
You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
x=int(input()) cnt=0 a=[] for i in range(1,11): for j in range(1,32): a.append(j**i) a=[l for l in a if l <= x] print(max(a))
s873240285
Accepted
17
2,940
131
x=int(input()) a=[] for i in range(2,11): for j in range(1,32): a.append(j**i) a=[l for l in a if l <= x] print(max(a))