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
s341233018
p03545
u378157957
2,000
262,144
Wrong Answer
28
9,332
634
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.
import operator vals = input() nums = list(map(int, tuple(vals))) def dump(a,b,c): if a == operator.add: a = '+' else: a = '-' if b == operator.add: b = '+' else: b = '-' if c == operator.add: c = '+' else: c = '-' print(vals[0] + a + vals[1] + b + vals[2] + c + vals[3] + '=7') for a in (operator.add, operator.sub): for b in (operator.add, operator.sub): for c in (operator.add, operator.sub): if c(b(a(nums[0], nums[1]), nums[2]), nums[3]) == 7: print(a, b, c) dump(a, b, c) break
s487971709
Accepted
27
9,032
234
a, b, c, d = input() for i in range(2**3): op = bin(i)[2:].zfill(3).replace("0", "-").replace("1", "+") equation = a + op[0] + b + op[1] + c + op[2] + d if eval(equation) == 7: print(equation + '=7') break
s698763617
p03555
u037221289
2,000
262,144
Wrong Answer
17
2,940
118
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
C1 = input() C2 = input() if C1[0] == C2[2] and C1[1] == C2[2] and C1[2] == C2[0]: print('YES') else: print('NO')
s296938138
Accepted
17
2,940
119
C1 = input() C2 = input() if C1[0] == C2[2] and C1[1] == C2[1] and C1[2] == C2[0]: print('YES') else: print('NO')
s514023224
p02612
u153094838
2,000
1,048,576
Wrong Answer
34
9,144
123
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.
# -*- coding: utf-8 -*- """ Created on Sun Jul 5 21:00:39 2020 @author: NEC-PCuser """ N = int(input()) print(N % 1000)
s870624073
Accepted
31
9,104
173
# -*- coding: utf-8 -*- """ Created on Sun Jul 5 21:00:39 2020 @author: NEC-PCuser """ N = int(input()) if N % 1000 == 0: print(0) else: print(1000 - (N % 1000))
s802792987
p03816
u620480037
2,000
262,144
Wrong Answer
46
14,564
61
Snuke has decided to play a game using cards. He has a deck consisting of N cards. On the i-th card from the top, an integer A_i is written. He will perform the operation described below zero or more times, so that the values written on the remaining cards will be pairwise distinct. Find the maximum possible number of remaining cards. Here, N is odd, which guarantees that at least one card can be kept. Operation: Take out three arbitrary cards from the deck. Among those three cards, eat two: one with the largest value, and another with the smallest value. Then, return the remaining one card to the deck.
N=input() A=list(map(int,input().split())) print(len(set(A)))
s534674228
Accepted
49
14,388
122
N=input() A=list(map(int,input().split())) if len(set(A))%2==0: ans=len(set(A))-1 else: ans=len(set(A)) print(ans)
s199613678
p03455
u400143507
2,000
262,144
Wrong Answer
17
2,940
384
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
enter = input().split() def map_num(enter): input_list = [] for num in enter: if num != ' ': input_list.append(int(num)) return input_list[0], input_list[1] a, b = map_num(enter) result = a * b print(result) if result % 2 == 0: print('Even') elif result % 2 != 0: print('Odd')
s958111268
Accepted
17
2,940
370
enter = input().split() def map_num(enter): input_list = [] for num in enter: if num != ' ': input_list.append(int(num)) return input_list[0], input_list[1] a, b = map_num(enter) result = a * b if result % 2 == 0: print('Even') elif result % 2 != 0: print('Odd')
s476795605
p03944
u409542115
2,000
262,144
Wrong Answer
17
3,064
492
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white. Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i). Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows: * If a_i = 1, he painted the region satisfying x < x_i within the rectangle. * If a_i = 2, he painted the region satisfying x > x_i within the rectangle. * If a_i = 3, he painted the region satisfying y < y_i within the rectangle. * If a_i = 4, he painted the region satisfying y > y_i within the rectangle. Find the area of the white region within the rectangle after he finished painting.
W, H, N = map(int, input().split()) x = [0] * N y = [0] * N a = [0] * N for i in range(N): x[i], y[i], a[i] = map(int, input().split()) X1 = 0 X2 = W Y1 = 0 Y2 = H entire = W * H for i in range(N): if a[i] == 1: X1 = max(X1, x[i]) if a[i] == 2: X2 = min(X2, x[i]) if a[i] == 3: Y1 = max(Y1, y[i]) if a[i] == 4: Y2 = min(Y2, y[i]) if X1 >= X2 or Y1 >= Y2: print('0') else: entire = entire - (Y2-Y1) * (X2-X1) print(entire)
s873511853
Accepted
17
3,064
468
W, H, N = map(int, input().split()) x = [0] * N y = [0] * N a = [0] * N for i in range(N): x[i], y[i], a[i] = map(int, input().split()) X1 = 0 X2 = W Y1 = 0 Y2 = H for i in range(N): if a[i] == 1: X1 = max(X1, x[i]) if a[i] == 2: X2 = min(X2, x[i]) if a[i] == 3: Y1 = max(Y1, y[i]) if a[i] == 4: Y2 = min(Y2, y[i]) if X1 >= X2 or Y1 >= Y2: print('0') else: entire = (Y2-Y1) * (X2-X1) print(entire)
s013441745
p02697
u289162337
2,000
1,048,576
Wrong Answer
76
9,156
73
You are going to hold a competition of one-to-one game called AtCoder Janken. _(Janken is the Japanese name for Rock-paper-scissors.)_ N players will participate in this competition, and they are given distinct integers from 1 through N. The arena has M playing fields for two players. You need to assign each playing field two distinct integers between 1 and N (inclusive). You cannot assign the same integer to multiple playing fields. The competition consists of N rounds, each of which proceeds as follows: * For each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there. * Then, each player adds 1 to its integer. If it becomes N+1, change it to 1. You want to ensure that no player fights the same opponent more than once during the N rounds. Print an assignment of integers to the playing fields satisfying this condition. It can be proved that such an assignment always exists under the constraints given.
n, m = map(int, input().split()) for i in range(m): print(i+1, 2*m+1-i)
s280167696
Accepted
80
9,288
187
n, m = map(int, input().split()) if m%2 == 0: x = m//2 y = m//2 else: x = m//2 y = m//2+1 for i in range(x): print(i+1, 2*x+1-i) for i in range(y): print(i+2*x+2, 2*y+2*x+1-i)
s410159776
p03150
u638795007
2,000
1,048,576
Wrong Answer
40
4,804
1,096
A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
def examA(): N = LI() N.sort() if N==[1,4,7,9]: print("YES") else: print("NO") return def examB(): S = SI() K = "keyence" for i in range(8): if S[:i]+S[-7+i:0]==K: print("YES") return print("NO") return def examC(): ans = 0 print(ans) return def examD(): ans = 0 print(ans) return def examE(): ans = 0 print(ans) return def examF(): ans = 0 print(ans) return import sys,copy,bisect,itertools,heapq,math,random from heapq import heappop,heappush,heapify from collections import Counter,defaultdict,deque def I(): return int(sys.stdin.readline()) def LI(): return list(map(int,sys.stdin.readline().split())) def LSI(): return list(map(str,sys.stdin.readline().split())) def LS(): return sys.stdin.readline().split() def SI(): return sys.stdin.readline().strip() global mod,mod2,inf,alphabet,_ep mod = 10**9 + 7 mod2 = 998244353 inf = 10**18 _ep = 10**(-12) alphabet = [chr(ord('a') + i) for i in range(26)] if __name__ == '__main__': examB() """ """
s760841546
Accepted
41
4,804
1,148
def examA(): N = LI() N.sort() if N==[1,4,7,9]: print("YES") else: print("NO") return def examB(): S = SI() K = "keyence" for i in range(7): if S[:i]+S[-7+i:]==K: print("YES") return if S[:7]==K: print("YES") return print("NO") return def examC(): ans = 0 print(ans) return def examD(): ans = 0 print(ans) return def examE(): ans = 0 print(ans) return def examF(): ans = 0 print(ans) return import sys,copy,bisect,itertools,heapq,math,random from heapq import heappop,heappush,heapify from collections import Counter,defaultdict,deque def I(): return int(sys.stdin.readline()) def LI(): return list(map(int,sys.stdin.readline().split())) def LSI(): return list(map(str,sys.stdin.readline().split())) def LS(): return sys.stdin.readline().split() def SI(): return sys.stdin.readline().strip() global mod,mod2,inf,alphabet,_ep mod = 10**9 + 7 mod2 = 998244353 inf = 10**18 _ep = 10**(-12) alphabet = [chr(ord('a') + i) for i in range(26)] if __name__ == '__main__': examB() """ """
s392353301
p03477
u973108807
2,000
262,144
Wrong Answer
18
3,060
153
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()) left = a+b right = c+d if left > right: print('left') elif right > left: print('right') else: print('balanced')
s063698852
Accepted
17
3,060
132
a,b,c,d = map(int, input().split()) L = a+b R = c+d if L > R: print('Left') elif R > L: print('Right') else: print('Balanced')
s980421415
p03399
u611047648
2,000
262,144
Wrong Answer
17
2,940
73
You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
a = input() b = input() c = input() d = input() print(min(a, b)+min(c,d))
s866997460
Accepted
17
2,940
93
a = int(input()) b = int(input()) c = int(input()) d = int(input()) print(min(a, b)+min(c,d))
s137537135
p03957
u940102677
1,000
262,144
Time Limit Exceeded
1,056
2,940
147
This contest is `CODEFESTIVAL`, which can be shortened to the string `CF` by deleting some characters. Mr. Takahashi, full of curiosity, wondered if he could obtain `CF` from other strings in the same way. You are given a string s consisting of uppercase English letters. Determine whether the string `CF` can be obtained from the string s by deleting some characters.
s = input() n = len(s) i = 0 while i < n: if s[i] == "C": break i += 1 while i < n: if s[i] == "F": print("Yes") exit() print("No")
s846389356
Accepted
17
2,940
158
s = input() n = len(s) i = 0 while i < n: if s[i] == "C": break i += 1 while i < n: if s[i] == "F": print("Yes") exit() i += 1 print("No")
s744511556
p02697
u669173971
2,000
1,048,576
Wrong Answer
74
9,260
71
You are going to hold a competition of one-to-one game called AtCoder Janken. _(Janken is the Japanese name for Rock-paper-scissors.)_ N players will participate in this competition, and they are given distinct integers from 1 through N. The arena has M playing fields for two players. You need to assign each playing field two distinct integers between 1 and N (inclusive). You cannot assign the same integer to multiple playing fields. The competition consists of N rounds, each of which proceeds as follows: * For each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there. * Then, each player adds 1 to its integer. If it becomes N+1, change it to 1. You want to ensure that no player fights the same opponent more than once during the N rounds. Print an assignment of integers to the playing fields satisfying this condition. It can be proved that such an assignment always exists under the constraints given.
n,m=map(int, input().split()) for i in range(1,m+1): print(i,n+1-i)
s219375029
Accepted
79
9,224
258
n,m=map(int, input().split()) if m%2==1: for i in range(m//2): print(i+1,m-i) for i in range(m//2+1): print(m+i+1,2*m+1-i) else: for i in range(m//2): print(i+1,m+1-i) for i in range(m//2): print(m+i+2,2*m+1-i)
s946738458
p02865
u991269553
2,000
1,048,576
Wrong Answer
21
2,940
61
How many ways are there to choose two distinct positive integers totaling N, disregarding the order?
n = int(input()) if n%2 != 0: print(n/2) else: print(n/4)
s057564070
Accepted
17
2,940
58
import math n = int(input()) a = n/2 print(math.ceil(a)-1)
s418410384
p03730
u740284863
2,000
262,144
Wrong Answer
18
2,940
121
We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
a,b,c=map(int,input().split()) for i in range(b): if (i*a) % b == c: print("Yes") exit() print("No")
s233783229
Accepted
18
2,940
121
a,b,c=map(int,input().split()) for i in range(b): if (i*a) % b == c: print("YES") exit() print("NO")
s744606092
p03836
u758411830
2,000
262,144
Wrong Answer
26
9,268
259
Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement must be integers. He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy). Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty). Under this condition, find a shortest path for him.
sx, sy, tx, ty = list(map(int, input().split())) dx = tx - sx dy = ty - sy d1 = ['L'] + ['U']*(dy+1) + ['R']*(dx+1) + ['D']*1 d2 = ['L']*dx + ['D']*dy d3 = ['D']*1 + ['R']*(dx+1) + ['U']*(dy+1) + ['L']*1 d4 = ['U']*dy + ['R']*dx print(''.join(d1+d2+d3+d4))
s158533043
Accepted
33
9,192
253
sx, sy, tx, ty = list(map(int, input().split())) dx = tx - sx dy = ty - sy d1 = ['U']*dy + ['R']*dx d2 = ['D']*dy + ['L']*dx d3 = ['L'] + ['U']*(dy+1) + ['R']*(dx+1) + ['D'] d4 = ['R'] + ['D']*(dy+1) + ['L']*(dx+1) + ['U'] print(''.join(d1+d2+d3+d4))
s423421089
p03605
u131405882
2,000
262,144
Wrong Answer
17
2,940
72
It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
N = input() if N[0] == 9 or N[1] == 9: print('Yes') else: print('No')
s694114163
Accepted
17
2,940
77
N = input() if N[0] == '9' or N[1] == '9': print('Yes') else: print('No')
s509997606
p03485
u717501752
2,000
262,144
Wrong Answer
17
2,940
89
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
a,b=map(float,input().split()) if (a+b)%2==1: print((a+b)/2+0.5) else: print((a+b)/2)
s975260752
Accepted
17
2,940
99
a,b=map(float,input().split()) if (a+b)%2==1: print(int((a+b)/2+0.5)) else: print(int((a+b)/2))
s679200722
p03369
u284854859
2,000
262,144
Wrong Answer
17
2,940
50
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.
li = input().split() print(700+100*li.count('o'))
s919944948
Accepted
17
2,940
47
s=list(input()) print(700+100*(s.count('o')))
s420072978
p03606
u413165887
2,000
262,144
Wrong Answer
20
2,940
102
Joisino is working as a receptionist at a theater. The theater has 100000 seats, numbered from 1 to 100000. According to her memo, N groups of audiences have come so far, and the i-th group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive). How many people are sitting at the theater now?
n = int(input()) r = 0 for _ in range(n): l, r = map(int, input().split()) r += l-r+1 print(r)
s166339497
Accepted
20
2,940
117
n = int(input()) result = 0 for _ in range(n): l, r = map(int, input().split()) result += r-l+1 print(result)
s254833215
p03377
u408375121
2,000
262,144
Wrong Answer
17
2,940
111
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 A > X: print('No') elif X <= A + B: print('Yes') else: print('No')
s359288946
Accepted
17
2,940
94
A, B, X = map(int, input().split()) if A > X or X > A + B: print('NO') else: print('YES')
s542811361
p03543
u716660050
2,000
262,144
Wrong Answer
17
2,940
100
We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**. You are given a 4-digit integer N. Answer the question: Is N **good**?
N=list(input()) ans=False for i in N: if N.count(i)>2: ans=True break print(ans)
s005018003
Accepted
17
3,060
171
N=input() l=['000','111','222','333','444','555','666','777','888','999'] for i in l: if i == N[0:3] or i==N[1:len(N)]: print('Yes') exit() print('No')
s886883449
p03456
u963009166
2,000
262,144
Wrong Answer
17
2,940
115
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
import math a, b = map(int, input().split()) if math.sqrt(a * b) % 1 == 0: print('Yes') else: print('No')
s191001763
Accepted
17
2,940
110
import math a, b = input().split() if math.sqrt(int(a + b)) % 1 == 0: print('Yes') else: print('No')
s975763343
p03433
u272557899
2,000
262,144
Wrong Answer
18
2,940
97
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
n = int(input()) a = int(input()) t = n % 500 - a if a <= 0: print("Yes") else: print("No")
s869411699
Accepted
18
2,940
98
n = int(input()) a = int(input()) t = n % 500 - a if t <= 0: print("Yes") else: print("No")
s324389268
p02612
u826138795
2,000
1,048,576
Wrong Answer
31
9,008
83
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=input() i=(int(N[0])+1)*1000 j=i-int(N) if j==1000: print(0) else: print(j-i)
s861665483
Accepted
28
9,112
117
N=input() if len(N)>3: i=(int(N[:-3])+1)*1000 else: i=1000 j=i-int(N) if j>999: print(0) else: print(j)
s085913643
p03495
u547167033
2,000
262,144
Wrong Answer
151
39,344
197
Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them.
from collections import Counter n,k=map(int,input().split()) a=list(map(int,input().split())) c=Counter(a).most_common() ans=0 idx=1 while k>0: k-=c[-idx][1] ans+=c[-idx][1] idx+=1 print(ans)
s299737884
Accepted
237
39,344
197
from collections import Counter n,k=map(int,input().split()) a=list(map(int,input().split())) c=Counter(a).most_common() ans=0 idx=1 m=len(c) while m>k: m-=1 ans+=c[-idx][1] idx+=1 print(ans)
s324363307
p03543
u013756322
2,000
262,144
Wrong Answer
18
2,940
115
We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**. You are given a 4-digit integer N. Answer the question: Is N **good**?
n = input() s = set(n) print(s) if (len(s) <= 2 and n.count(s.pop()) % 2 == 1): print('Yes') else: print('No')
s106697684
Accepted
17
2,940
85
n = input() if (n[0] * 3 in n or n[-1] * 3 in n): print('Yes') else: print('No')
s898771741
p03400
u102960641
2,000
262,144
Wrong Answer
18
2,940
105
Some number of chocolate pieces were prepared for a training camp. The camp had N participants and lasted for D days. The i-th participant (1 \leq i \leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on. As a result, there were X chocolate pieces remaining at the end of the camp. During the camp, nobody except the participants ate chocolate pieces. Find the number of chocolate pieces prepared at the beginning of the camp.
n = int(input()) d,x = map(int, input().split()) for i in range(n): x += (d-1) // int(input()) print(x)
s615780924
Accepted
18
2,940
117
n = int(input()) d,x = map(int, input().split()) for i in range(n): a = (d-1) // int(input()) +1 x += a print(x)
s741447110
p03997
u772649753
2,000
262,144
Wrong Answer
17
2,940
67
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)
s312110251
Accepted
17
2,940
72
a = int(input()) b = int(input()) h = int(input()) print(int((a+b)*h/2))
s191247881
p03971
u735335967
2,000
262,144
Wrong Answer
112
3,988
337
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these. Only Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy the conditions listed below, from the top rank down. Participants who are not students cannot pass the Qualification contests. * A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B. * An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students. A string S is assigned indicating attributes of all participants. If the i-th character of string S is `a`, this means the participant ranked i-th in the Qualification contests is a Japanese student; `b` means the participant ranked i-th is an overseas student; and `c` means the participant ranked i-th is neither of these. Write a program that outputs for all the participants in descending rank either `Yes` if they passed the Qualification contests or `No` if they did not pass.
n, a, b = map(int, input().split()) s = input() print(len(s)) b_cnt = 0 a_cnt = 0 for i in range(n): if s[i] == "a" and (a_cnt+b_cnt) < a+b: a_cnt += 1 print("Yes") elif s[i] == "b" and (a_cnt+b_cnt) < a+b and b_cnt < b: #print(b_cnt) b_cnt += 1 print("Yes") else: print("No")
s918082265
Accepted
142
4,784
404
n, a, b = map(int, input().split()) s = input() total_cnt = 0 b_cnt = 0 ans = ["No"]*n for i in range(n): if total_cnt >= a+b: break if s[i] == "c": continue if s[i] == "a": total_cnt += 1 ans[i] = "Yes" if s[i] == "b": b_cnt += 1 if b_cnt <= b: total_cnt += 1 ans[i] = "Yes" for i in range(n): print(ans[i])
s538471344
p03400
u075303794
2,000
262,144
Wrong Answer
28
9,160
191
Some number of chocolate pieces were prepared for a training camp. The camp had N participants and lasted for D days. The i-th participant (1 \leq i \leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on. As a result, there were X chocolate pieces remaining at the end of the camp. During the camp, nobody except the participants ate chocolate pieces. Find the number of chocolate pieces prepared at the beginning of the camp.
N=int(input()) D,X=map(int,input().split()) A=[int(input()) for _ in range(N)] ans=0 for i in range(N): for j in range(N): if 30>=A[i]*j: ans+=1 else: break print(ans+X)
s371302432
Accepted
27
9,112
189
N=int(input()) D,X=map(int,input().split()) A=[int(input()) for _ in range(N)] ans=0 for i in range(N): for j in range(D): if D>A[i]*j: ans+=1 else: break print(ans+X)
s204755160
p02663
u897633035
2,000
1,048,576
Wrong Answer
26
9,168
123
In this problem, we use the 24-hour clock. Takahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the time H_2 : M_2. (See Sample Inputs below for clarity.) He has decided to study for K consecutive minutes while he is up. What is the length of the period in which he can start studying?
h1, m1, h2, m2, k = map(int, input().split()) a = (h2*60+m2)-(h1*60+m1) if(a>=k): print((h2*60+m2)-k) else : print(0)
s658084693
Accepted
23
9,164
113
h1, m1, h2, m2, k = map(int, input().split()) a = (h2*60+m2)-(h1*60+m1) if(a>k): print(a-k) else : print(0)
s600563969
p03645
u001024152
2,000
262,144
Wrong Answer
654
21,192
347
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.
N, M = map(int, input().split()) starts = set([]) ends = set([]) for _ in range(M): a, b = map(int, input().split()) if a == 1 or b == 1: starts.add(a if b == 1 else b) if a == N or b == N: ends.add(a if b == N else b) print(starts, ends) ans = "POSSIBLE" if len(starts&ends)>=1 else "IMPOSSIBLE" print(ans)
s833699167
Accepted
607
19,024
318
N, M = map(int, input().split()) starts = set([]) ends = set([]) for _ in range(M): a, b = map(int, input().split()) if a == 1 or b == 1: starts.add(a if b == 1 else b) if a == N or b == N: ends.add(a if b == N else b) ans = "POSSIBLE" if len(starts&ends)>=1 else "IMPOSSIBLE" print(ans)
s900761872
p03921
u163320134
2,000
262,144
Wrong Answer
464
9,532
1,083
On a planet far, far away, M languages are spoken. They are conveniently numbered 1 through M. For _CODE FESTIVAL 20XX_ held on this planet, N participants gathered from all over the planet. The i-th (1≦i≦N) participant can speak K_i languages numbered L_{i,1}, L_{i,2}, ..., L_{i,{}K_i}. Two participants A and B can _communicate_ with each other if and only if one of the following conditions is satisfied: * There exists a language that both A and B can speak. * There exists a participant X that both A and B can communicate with. Determine whether all N participants can communicate with all other participants.
class UnionFind(): def __init__(self,n): self.n=n self.root=[-1]*(n+1) self.rank=[0]*(n+1) def FindRoot(self,x): if self.root[x]<0: return x else: self.root[x]=self.FindRoot(self.root[x]) return self.root[x] def Unite(self,x,y): x=self.FindRoot(x) y=self.FindRoot(y) if x==y: return else: if self.rank[x]>self.rank[y]: self.root[x]+=self.root[y] self.root[y]=x elif self.rank[x]<=self.rank[y]: self.root[y]+=self.root[x] self.root[x]=y if self.rank[x]==self.rank[y]: self.rank[y]+=1 def isSameGroup(self,x,y): return self.FindRoot(x)==self.FindRoot(y) def Count(self,x): return -self.root[self.FindRoot(x)] n,m=map(int,input().split()) t=UnionFind(m) for _ in range(n): l=list(map(int,input().split())) if l[0]==1: t.Unite(0,l[1]) else: for i in range(l[0]-1): t.Unite(l[1],l[2+i]) s=set() for i in range(m): r=t.FindRoot(i) if r==i: continue else: s.add(r) if len(s)==1: print('Yes') else: print('No')
s688641045
Accepted
684
11,452
1,006
class UnionFind(): def __init__(self,n): self.n=n self.root=[-1]*(n+1) self.rank=[0]*(n+1) def FindRoot(self,x): if self.root[x]<0: return x else: self.root[x]=self.FindRoot(self.root[x]) return self.root[x] def Unite(self,x,y): x=self.FindRoot(x) y=self.FindRoot(y) if x==y: return else: if self.rank[x]>self.rank[y]: self.root[x]+=self.root[y] self.root[y]=x elif self.rank[x]<=self.rank[y]: self.root[y]+=self.root[x] self.root[x]=y if self.rank[x]==self.rank[y]: self.rank[y]+=1 def isSameGroup(self,x,y): return self.FindRoot(x)==self.FindRoot(y) def Count(self,x): return -self.root[self.FindRoot(x)] n,m=map(int,input().split()) t=UnionFind(n+m) for i in range(n): l=list(map(int,input().split())) for j in range(l[0]): t.Unite(i+1,n+l[1+j]) s=set() for i in range(n): r=t.FindRoot(i+1) s.add(r) if len(s)==1: print('YES') else: print('NO')
s652258421
p03643
u319612498
2,000
262,144
Wrong Answer
17
3,064
28
This contest, _AtCoder Beginner Contest_ , is abbreviated as _ABC_. When we refer to a specific round of ABC, a three-digit number is appended after ABC. For example, ABC680 is the 680th round of ABC. What is the abbreviation for the N-th round of ABC? Write a program to output the answer.
n=input() print("ABC"+n[1:])
s516085600
Accepted
17
2,940
29
n=input() print("ABC"+n[0:])
s770405599
p03943
u045939752
2,000
262,144
Wrong Answer
23
3,064
90
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
x = map(int, input().split()) if 2 * max(x) == sum(x): print("Yes") else: print("No")
s757926583
Accepted
24
3,064
98
x = [ int(i) for i in input().split()] if 2 * max(x) == sum(x): print("Yes") else: print("No")
s110126828
p02741
u896451538
2,000
1,048,576
Wrong Answer
17
2,940
97
Print the K-th element of the following sequence of length 32: 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
s826655587
Accepted
17
3,060
135
s = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51] k = int(input()) print(s[k-1])
s739370397
p03080
u688055251
2,000
1,048,576
Wrong Answer
17
3,064
150
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=int(input()) s=input().split() y=0 v=0 for i in s: if i=='R': y+=1 else: v+=1 if y>v: print('Yes') else: print('No')
s803347098
Accepted
18
2,940
154
N=int(input()) s=input() y=0 v=0 for i in s: if i=='R': y+=1 elif i=='B': v+=1 if y>v: print('Yes') elif v>=y: print('No')
s149007095
p04029
u036492525
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?
a=int(input()) print((1+a)*a/2)
s383842157
Accepted
17
2,940
36
a=int(input()) print(int((1+a)*a/2))
s675786380
p03853
u757030836
2,000
262,144
Wrong Answer
19
3,060
179
There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
h,w =map(int,input().split()) c =[[str(i) for i in input()] for _ in range(h)] for i in range(2*h): if i <h: print("".join(c[i])) elif i >= h: print("".join(c[i-h]))
s196511590
Accepted
18
3,060
93
h,w = map(int,input().split()) for i in range(h): c = input() print(c) print(c)
s194965297
p03448
u897328029
2,000
262,144
Wrong Answer
55
3,064
355
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
a_500 = int(input().split()[0]) b_100 = int(input().split()[0]) c_50 = int(input().split()[0]) x = int(input().split()[0]) all_coins = [] count = 0 for a_n in range(a_500+1): for b_n in range(b_100+1): for c_n in range(c_50+1): hoge = 500*a_n + 100*b_n + 50*c_50 if hoge == x: count += 1 print(count)
s395927815
Accepted
54
3,064
356
a_500 = int(input().split()[0]) b_100 = int(input().split()[0]) c_50 = int(input().split()[0]) x = int(input().split()[0]) all_coins = [] count = 0 for a_n in range(a_500+1): for b_n in range(b_100+1): for c_n in range(c_50+1): total = 500*a_n + 100*b_n + 50*c_n if total == x: count += 1 print(count)
s742678445
p02665
u515740713
2,000
1,048,576
Wrong Answer
2,232
710,472
569
Given is an integer sequence of length N+1: A_0, A_1, A_2, \ldots, A_N. Is there a binary tree of depth N such that, for each d = 0, 1, \ldots, N, there are exactly A_d leaves at depth d? If such a tree exists, print the maximum possible number of vertices in such a tree; otherwise, print -1.
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N, *A=map(int,read().split()) bound = [0]*(N+1) bound[0] = 1 if N == 0: if A[0] == 1: print(1) else: print(-1) sys.exit() for i in range(1,N+1): bound[i] = (bound[i-1]-A[i-1]) *2 if bound[i] <= 0: print(-1) sys.exit() print(bound) cum_sum = 0 for i in range(N,-1,-1): cum_sum += A[i] bound[i] = min(bound[i],cum_sum) print(sum(bound))
s460042104
Accepted
803
674,396
567
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N, *A=map(int,read().split()) bound = [0]*(N+1) bound[0] = 1 if N == 0: if A[0] == 1: print(1) else: print(-1) sys.exit() for i in range(1,N+1): bound[i] = (bound[i-1]-A[i-1]) *2 if bound[i] < A[i]: print(-1) sys.exit() cum_sum = 0 for i in range(N,-1,-1): cum_sum += A[i] bound[i] = min(bound[i],cum_sum) print(sum(bound))
s338370570
p03448
u670180528
2,000
262,144
Wrong Answer
49
2,940
108
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
a,b,c,x=map(int,open(0)) print(sum(500*i+100*j+50*k==x for i in range(a)for j in range(b)for k in range(c)))
s886095012
Accepted
50
2,940
114
a,b,c,x=map(int,open(0)) print(sum(500*i+100*j+50*k==x for i in range(a+1)for j in range(b+1)for k in range(c+1)))
s238381245
p03495
u059210959
2,000
262,144
Wrong Answer
601
51,596
654
Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them.
# encoding:utf-8 import copy import numpy as np import random n,k = map(int,input().split()) a = [int(i) for i in input().split()] count_dic = {} for i in range(len(a)): if a[i] in count_dic.keys(): count_dic[a[i]] += 1 else: count_dic[a[i]] = 1 # print(type(count_dic[1])) print(count_dic) count_list = sorted(count_dic.items(),key=lambda x: x[0]) ans = 0 # print(len(count_list)) while len(count_list)>k: # print(count_list) delte_tuple = count_list[-1] add_tuple = count_list[0] count_list[0] = tuple([add_tuple[0],add_tuple[1]+delte_tuple[1]]) ans += delte_tuple[1] del count_list[-1] print(ans)
s674108123
Accepted
554
48,776
670
# encoding:utf-8 import copy import numpy as np import random n,k = map(int,input().split()) a = [int(i) for i in input().split()] count_dic = {} for i in range(len(a)): if a[i] in count_dic.keys(): count_dic[a[i]] += 1 else: count_dic[a[i]] = 1 # print(type(count_dic[1])) # print(count_dic) count_list = sorted(count_dic.items(),key=lambda x: x[1],reverse=True) ans = 0 # print(len(count_list)) while len(count_list)>k: # print(count_list) delte_tuple = count_list[-1] add_tuple = count_list[0] count_list[0] = tuple([add_tuple[0],add_tuple[1]+delte_tuple[1]]) ans += delte_tuple[1] del count_list[-1] print(ans)
s267678081
p02613
u127157764
2,000
1,048,576
Wrong Answer
146
16,188
210
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.
s = [] n = int(input()) for i in range(n): s.append(input()) print("AC x " + str(s.count("AC"))) print("WA x " + str(s.count("WA"))) print("TlE x " + str(s.count("TLE"))) print("RE x " + str(s.count("RE")))
s112245346
Accepted
147
16,272
210
s = [] n = int(input()) for i in range(n): s.append(input()) print("AC x " + str(s.count("AC"))) print("WA x " + str(s.count("WA"))) print("TLE x " + str(s.count("TLE"))) print("RE x " + str(s.count("RE")))
s771696222
p02261
u840247626
1,000
131,072
Wrong Answer
20
5,592
355
Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1. Your task is to write a program which sorts a given set of cards in ascending order by their values using the Bubble Sort algorithms and the Selection Sort algorithm respectively. These algorithms should be based on the following pseudocode: BubbleSort(C) 1 for i = 0 to C.length-1 2 for j = C.length-1 downto i+1 3 if C[j].value < C[j-1].value 4 swap C[j] and C[j-1] SelectionSort(C) 1 for i = 0 to C.length-1 2 mini = i 3 for j = i to C.length-1 4 if C[j].value < C[mini].value 5 mini = j 6 swap C[i] and C[mini] Note that, indices for array elements are based on 0-origin. For each algorithm, report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).
n = int(input()) c = input().split() cb = c[:] for i in range(n): for j in range(n-1,i,-1): if cb[j][1] < cb[j-1][1]: cb[j-1],cb[j] = cb[j],cb[j-1] print(*cb) print('Stable') cs = c[:] for i in range(n): m = min(range(i,n), key=lambda j: cs[j][1]) if i != m: cs[i],cs[m] = cs[m],cs[i] print(*cs) print(('' if cb == cs else 'Not ') + 'Stable')
s768696650
Accepted
20
5,608
354
n = int(input()) c = input().split() cb = c[:] for i in range(n): for j in range(n-1,i,-1): if cb[j][1] < cb[j-1][1]: cb[j-1],cb[j] = cb[j],cb[j-1] print(*cb) print('Stable') cs = c[:] for i in range(n): m = min(range(i,n), key=lambda j: cs[j][1]) if i != m: cs[i],cs[m] = cs[m],cs[i] print(*cs) print('Stable' if cb == cs else 'Not stable')
s677365425
p04043
u714300041
2,000
262,144
Wrong Answer
17
2,940
89
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*B*C == 5*5*7: print("Yes") else: print("No")
s976201489
Accepted
17
2,940
122
A, B, C = map(int, input().split()) if A*B*C == 5*5*7 and A >= 5 and B >= 5 and C >= 5: print("YES") else: print("NO")
s893577182
p02603
u503111914
2,000
1,048,576
Wrong Answer
29
9,184
178
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())) ans = 1000 a = A[0] for i in range(N): if A[i] - a > 0: ans += (ans // a) * (A[i] - a) a = A[i] print(ans)
s557199397
Accepted
27
9,156
208
N = int(input()) A = list(map(int,input().split())) ans = 1000 m = A[0] M = A[0] for i in range(N): if A[i] < m: m = A[i] else: ans += (ans//m) * (A[i] - m) m = A[i] print(ans)
s584689073
p03711
u530383736
2,000
262,144
Wrong Answer
18
3,060
219
Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below. Given two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.
# -*- coding: utf-8 -*- x,y=[int(i) for i in input().rstrip().split()] g1={1,3,5,7,8,10,12} g2={4,6,9,11} g3={2} for G in [g1,g2,g3] : if all( n in G for n in [x,y] ): print("YES") break else: print("NO")
s371388822
Accepted
17
3,064
219
# -*- coding: utf-8 -*- x,y=[int(i) for i in input().rstrip().split()] g1={1,3,5,7,8,10,12} g2={4,6,9,11} g3={2} for G in [g1,g2,g3] : if all( n in G for n in [x,y] ): print("Yes") break else: print("No")
s672966951
p03044
u098012509
2,000
1,048,576
Wrong Answer
234
31,780
998
We have a tree with N vertices numbered 1 to N. The i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i. Your objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied: * For any two vertices painted in the same color, the distance between them is an even number. Find a coloring of the vertices that satisfies the condition and print it. It can be proved that at least one such coloring exists under the constraints of this problem.
import sys input = sys.stdin.readline def main(): N = int(input()) A = [] for _ in range(N - 1): A.append([int(x) for x in input().split()]) answer = [-1] * N for a in A: if a[2] % 2 == 0: if answer[a[0] - 1] != -1: answer[a[1] - 1] = answer[a[0] - 1] elif answer[a[1] - 1] != -1: answer[a[0] - 1] = answer[a[1] - 1] else: answer[a[0] - 1] = 1 answer[a[1] - 1] = 1 else: if answer[a[0] - 1] == 1: answer[a[1] - 1] = 0 elif answer[a[0] - 1] == 0: answer[a[1] - 1] = 1 elif answer[a[1] - 1] != 1: answer[a[0] - 1] = 0 elif answer[a[1] - 1] != 0: answer[a[0] - 1] = 1 else: answer[a[0] - 1] = 1 answer[a[1] - 1] = 0 print('\n'.join(map(str, answer))) if __name__ == '__main__': main()
s824644218
Accepted
901
63,556
575
import collections N = int(input()) UVW = [[int(x) for x in input().split()] for _ in range(N - 1)] ans = [-1] * N A = [[] for _ in range(N)] for u, v, w in UVW: A[u - 1].append([v - 1, w % 2]) A[v - 1].append([u - 1, w % 2]) q = collections.deque() q.append(0) ans[0] = 0 while q: c = q.popleft() for ni, nd in A[c]: if ans[ni] != -1: continue if nd == 0: ans[ni] = ans[c] else: ans[ni] = ans[c] ^ 1 q.append(ni) if sum(ans) == 0: ans[0] = 1 for a in ans: print(a)
s676951730
p03997
u460129720
2,000
262,144
Wrong Answer
19
3,060
70
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)
s398354220
Accepted
17
2,940
75
a = int(input()) b = int(input()) h = int(input()) print(int((a + b)*h /2))
s158221033
p02694
u951985579
2,000
1,048,576
Wrong Answer
28
9,000
108
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()) total = 100 count = 0 while total <= X: total += total//100 count += 1 print(count)
s440554512
Accepted
31
9,152
108
X = int(input()) total = 100 count = 0 while total < X: total += total//100 count += 1 print(count)
s522971982
p03555
u727787724
2,000
262,144
Wrong Answer
17
3,060
111
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=list(input()) b=list(input()) if a[0]==b[2] and a[1]==b[1] and a[2]==b[2]: print('YES') else: print('NO')
s463032941
Accepted
17
2,940
112
a=list(input()) b=list(input()) if a[0]==b[2] and a[1]==b[1] and a[2]==b[0]: print('YES') else: print('NO')
s819468653
p03929
u761320129
1,000
262,144
Wrong Answer
23
3,316
300
Snuke has a very long calendar. It has a grid with $n$ rows and $7$ columns. One day, he noticed that calendar has a following regularity. * The cell at the $i$-th row and $j$-th column contains the integer $7i+j-7$. A good sub-grid is a $3 \times 3$ sub-grid and the sum of integers in this sub-grid mod $11$ is $k$. How many good sub-grid are there? Write a program and help him.
N,K = map(int,input().split()) if N < 3: print(0) exit() mem = [0] * 11 for i in range(11): for j in range(2,7): n = i*7 + j if (9*n)%11 == K: mem[i] += 1 ans = sum(mem) * (N//11) ans -= mem[0] if N%11 == 0: ans -= mem[-1] else: ans += sum(mem[:N%11]) print(ans)
s531095523
Accepted
17
3,064
315
N,K = map(int,input().split()) if N<3: print(0) exit() table = [[0]*5 for i in range(11)] for i in range(11): for j in range(5): t = 9*(j+2 + 7*(i+1)) table[i][j] = t%11 c = [0] for row in table: c.append(c[-1] + row.count(K)) d,m = divmod(N-2, 11) ans = c[m] + c[-1]*d print(ans)
s915706311
p03779
u652892331
2,000
262,144
Wrong Answer
27
2,940
108
There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X.
x = int(input()) for t in range(1000000000): if 2 * x < t * (t + 1): print(t + 1) break
s656663518
Accepted
26
2,940
105
x = int(input()) for t in range(1000000000): if 2 * x <= t * (t + 1): print(t) break
s080211508
p03435
u057993957
2,000
262,144
Wrong Answer
151
12,480
387
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left. According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) is equal to a_i + b_j. Determine if he is correct.
import numpy as np c = np.array([list(map(int, input().split())) for i in range(3)]) flag = True for a1 in range(c.max()+1): b1, b2, b3 = c[0, :] - a1 if (c[1, 0] - b1 != c[1, 1] - b2) or (c[1, 2] - b3 == c[1, 0] - b1): flag = False break if (c[2, 0] - b1 != c[2, 1] - b2) or (c[2, 2] - b3 == c[2, 0] - b1): flag = False break print("Yes" if flag else "No")
s461108508
Accepted
150
14,524
389
import numpy as np c = np.array([list(map(int, input().split())) for i in range(3)]) flag = True for a1 in range(c.max()+1): b1, b2, b3 = c[0, :] - a1 if (c[1, 0] - b1 != c[1, 1] - b2) or (c[1, 2] - b3 != c[1, 0] - b1): flag = False break if (c[2, 0] - b1 != c[2, 1] - b2) or (c[2, 2] - b3 != c[2, 0] - b1): flag = False break print("Yes" if flag else "No")
s958932692
p02392
u365686736
1,000
131,072
Wrong Answer
20
5,580
76
Write a program which reads three integers a, b and c, and prints "Yes" if a < b < c, otherwise "No".
a,b,c = map(int, input().split()) if a < b < c: print("Yes") print("No")
s954853915
Accepted
20
7,648
76
a,b,c = map(int, input().split()) if a < b < c:print("Yes") else:print("No")
s591328649
p03386
u818283165
2,000
262,144
Wrong Answer
18
3,060
234
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()) ans = [] for i in range(k): if a+i > b: break ans.append(a+i) for i in range(k): if b-i < a: break ans.append(b-i) ans.sort() ans = set(ans) for i in ans: print(i)
s288834631
Accepted
19
3,060
240
a,b,k = map(int,input().split()) ans = [] for i in range(k): if a+i > b: break ans.append(a+i) for i in range(k): if b-i < a: break ans.append(b-i) ans = set(ans) ans =sorted(ans) for i in ans: print(i)
s309587527
p03048
u050708958
2,000
1,048,576
Wrong Answer
2,104
2,940
222
Snuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes: * Red boxes, each containing R red balls * Green boxes, each containing G green balls * Blue boxes, each containing B blue balls Snuke wants to get a total of exactly N balls by buying r red boxes, g green boxes and b blue boxes. How many triples of non-negative integers (r,g,b) achieve this?
r,g,b,n = [int(i) for i in input().split()] ans = 0 for i in range(n): for j in range(n): s = i * r + j * g if s > n: continue if (n - s) % b == 0: ans += 1 print(ans)
s944677491
Accepted
1,927
2,940
223
r,g,b,n = [int(i) for i in input().split()] ans = 0 for i in range(n+1): for j in range(n+1): s = i * r + j * g if s > n: break if (n - s) % b == 0: ans += 1 print(ans)
s946529074
p03024
u516272298
2,000
1,048,576
Wrong Answer
17
2,940
77
Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament. The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S consisting of `o` and `x`. If the i-th character in S is `o`, it means that Takahashi won the match on the i-th day; if that character is `x`, it means that Takahashi lost the match on the i-th day. Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` if there is no such possibility.
s = str(input()) if s.count("o") >= 8: print("YES") else: print("NO")
s544569841
Accepted
17
2,940
87
s = str(input()) if 15-len(s)+s.count("o") >= 8: print("YES") else: print("NO")
s234894929
p02615
u221272125
2,000
1,048,576
Wrong Answer
149
31,532
233
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()) A = list(map(int,input().split())) A.sort() if N == 2: print(A[1]) quit() a = A.pop() b = A.pop() c = A.pop() B = [c,b,a] ans = b + c i = 0 while A: a = A.pop() ans += b b = c c = a print(ans)
s899651674
Accepted
143
31,436
197
N = int(input()) A = list(map(int,input().split())) A.sort() k = N - 2 a = A.pop() ans = a n = k // 2 for i in range(n): a = A.pop() ans += 2*a if k - 2*n == 1: ans += A[-1] print(ans)
s719133337
p02742
u430336181
2,000
1,048,576
Wrong Answer
28
9,156
276
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()) H_ = H % 2 W_ = W % 2 if H_ == 0: print(H/2*W//1) else: h = H // 2 + 1 h_ = H // 2 if W_ == 0: print((h + h_)*W/2//1) elif W_ == 1: w = W // 2+1 w_ = W // 2 print((h * w + h_ * w_)//1)
s594654942
Accepted
28
9,188
351
H, W = map(int, input().split()) H_ = H % 2 W_ = W % 2 if H == 1 or W == 1: print(1) elif H_ == 0: print(str(round(H/2*W//1))) elif H_ == 1: h = H // 2 + 1 h_ = H // 2 if W_ == 0: print(str(round((h + h_)*W/2))) elif W_ == 1: w = W // 2+1 w_ = W // 2 print(str(round(h * w + h_ * w_)))
s594247974
p03433
u292810930
2,000
262,144
Wrong Answer
18
2,940
90
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
N = int(input()) A = int(input()) if N % 500 <= A: print('YES') else: print('NO')
s185070067
Accepted
17
2,940
90
N = int(input()) A = int(input()) if N % 500 <= A: print('Yes') else: print('No')
s485426260
p03997
u847033024
2,000
262,144
Wrong Answer
27
9,100
73
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()) c = int(input()) print((a + b) / 2 * c)
s203740251
Accepted
25
9,056
78
a = int(input()) b = int(input()) c = int(input()) print(int((a + b) / 2 * c))
s797948278
p03761
u117348081
2,000
262,144
Wrong Answer
22
3,316
499
Snuke loves "paper cutting": he cuts out characters from a newspaper headline and rearranges them to form another string. He will receive a headline which contains one of the strings S_1,...,S_n tomorrow. He is excited and already thinking of what string he will create. Since he does not know the string on the headline yet, he is interested in strings that can be created regardless of which string the headline contains. Find the longest string that can be created regardless of which string among S_1,...,S_n the headline contains. If there are multiple such strings, find the lexicographically smallest one among them.
from collections import defaultdict n = int(input()) s = [] t = [] a = defaultdict(int) for i in range(n): d = defaultdict(int) st = list(input()) st.sort() for j in range(len(st)): d[st[j]]+=1 if i==0: t = set(st) for j in t: a[j] = d[j] else: u = set(st) t = t & u for j in t: a[j] = min(a[j],d[j]) s.append(st) ans = "" for i in t: for j in range(a[i]): ans = ans + i print(ans)
s667199753
Accepted
22
3,316
503
from collections import defaultdict n = int(input()) s = [] t = [] a = defaultdict(int) for i in range(n): d = defaultdict(int) st = list(input()) st.sort() for j in range(len(st)): d[st[j]]+=1 if i==0: t = set(st) for j in t: a[j] = d[j] else: u = set(st) t = t & u for j in t: a[j] = min(a[j],d[j]) ans = "" t = list(t) t.sort() for i in t: for j in range(a[i]): ans = ans + i print(ans)
s733651099
p03455
u474464800
2,000
262,144
Wrong Answer
17
2,940
89
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
a, b = map(int, input().split()) if (a*b) % 2 == 0: print("Odd") else: print("Even")
s470284348
Accepted
18
2,940
89
a, b = map(int, input().split()) if (a*b) % 2 == 0: print("Even") else: print("Odd")
s605110788
p03544
u941753895
2,000
262,144
Wrong Answer
17
2,940
122
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers. You are given an integer N. Find the N-th Lucas number. Here, the i-th Lucas number L_i is defined as follows: * L_0=2 * L_1=1 * L_i=L_{i-1}+L_{i-2} (i≥2)
l=[] l.append(2) l.append(1) for i in range(84): l.append(l[i]+l[i+1]) N=int(input()) print(l[N-1])
s507053935
Accepted
17
2,940
120
l=[] l.append(2) l.append(1) for i in range(85): l.append(l[i]+l[i+1]) N=int(input()) print(l[N])
s330591840
p02614
u935642171
1,000
1,048,576
Wrong Answer
30
9,188
525
We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is `.`, and black if c_{i,j} is `#`. Consider doing the following operation: * Choose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns. You are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.
H,W,K = map(int,input().split()) s = [] black = 0 row = [0]*(H+1) col = [0]*(W+1) for i in range(H): s.append(list(input())) black += s[i].count('#') row[i+1] += s[i].count('#') for i in range(W): for j in range(H): if s[j][i]=='#': col[i+1] += 1 count = 0 for y,i in enumerate(row): if black - i == K: count += 1 for z,j in enumerate(col): if z==0 and y>=1: continue if black - (i+j) == K: if i+j!=0: count += 1 if K in col[1:]: count += col[1:].count(K) print(count)
s539973515
Accepted
68
9,124
316
H,W,K = map(int,input().split()) s = [list(input()) for i in range(H)] ans = 0 for i in range(1<<H): for j in range(1<<W): cnt = 0 for h in range(H): for w in range(W): if (i>>h)&1 == 1 and (j>>w)&1==1: if s[h][w]=='#': cnt += 1 if cnt==K: ans += 1 print(ans)
s620920062
p03759
u791664126
2,000
262,144
Wrong Answer
18
2,940
58
Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
a,b,c=map(int,input().split());print('YNeos'[b-a!=c-b::2])
s342417886
Accepted
17
2,940
59
a,b,c=map(int,input().split());print('YNEOS'[b-a!=c-b::2])
s492358339
p00008
u776559258
1,000
131,072
Wrong Answer
140
7,544
218
Write a program which reads an integer n and identifies the number of combinations of a, b, c and d (0 ≤ a, b, c, d ≤ 9) which meet the following equality: a + b + c + d = n For example, for n = 35, we have 4 different combinations of (a, b, c, d): (8, 9, 9, 9), (9, 8, 9, 9), (9, 9, 8, 9), and (9, 9, 9, 8).
import itertools def combination(n): c=0 for i in itertools.product(range(10),repeat=4): (a,b,c,d)=i if a+b+c+d==n: c+=1 return c while True: try: n=int(input()) combination(n) except EOFError: break
s137984907
Accepted
140
7,580
225
import itertools def combination(n): m=0 for i in itertools.product(range(10),repeat=4): (a,b,c,d)=i if a+b+c+d==n: m+=1 return m while True: try: n=int(input()) print(combination(n)) except EOFError: break
s100877310
p02646
u345778634
2,000
1,048,576
Wrong Answer
22
9,180
215
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
A, V = map(int, input().split()) B, W = map(int, input().split()) T = int(input()) if W >= V: print("No") else: L = abs(B - A) if T * (V - W) >= L : print("Yes") else: print("No")
s479722991
Accepted
25
9,180
215
A, V = map(int, input().split()) B, W = map(int, input().split()) T = int(input()) if W >= V: print("NO") else: L = abs(B - A) if T * (V - W) >= L : print("YES") else: print("NO")
s260536498
p02854
u189487046
2,000
1,048,576
Wrong Answer
244
32,712
213
Takahashi, who works at DISCO, is standing before an iron bar. The bar has N-1 notches, which divide the bar into N sections. The i-th section from the left has a length of A_i millimeters. Takahashi wanted to choose a notch and cut the bar at that point into two parts with the same length. However, this may not be possible as is, so he will do the following operations some number of times **before** he does the cut: * Choose one section and expand it, increasing its length by 1 millimeter. Doing this operation once costs 1 yen (the currency of Japan). * Choose one section of length at least 2 millimeters and shrink it, decreasing its length by 1 millimeter. Doing this operation once costs 1 yen. Find the minimum amount of money needed before cutting the bar into two parts with the same length.
n = int(input()) A = list(map(int, input().split())) ca = [0] for i in range(n): ca.append(A[i]+ca[i]) print(ca) ans = 2020202020 for i in range(n): ans = min(ans, abs(ca[i]-(ca[-1]-ca[i]))) print(ans)
s703265257
Accepted
216
26,764
203
n = int(input()) A = list(map(int, input().split())) ca = [0] for i in range(n): ca.append(A[i]+ca[i]) ans = 2020202020 for i in range(n): ans = min(ans, abs(ca[i]-(ca[-1]-ca[i]))) print(ans)
s118253056
p03836
u557235596
2,000
262,144
Wrong Answer
17
3,060
426
Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement must be integers. He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy). Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty). Under this condition, find a shortest path for him.
def main(): sx, sy, tx, ty = map(int, input().split()) result = "U" * (ty - sy) result += "R" * (tx - sx) result += "D" * (ty - sy) result += "L" * (tx - sx) result += "L" result += "U" * (ty - sy + 1) result += "R" * (tx - sx + 1) result += "D" result += "U" result += "D" * (ty - sy + 1) result += "L" * (tx - sx + 1) result += "R" if __name__ == "__main__": main()
s844321642
Accepted
17
3,060
444
def main(): sx, sy, tx, ty = map(int, input().split()) result = "U" * (ty - sy) result += "R" * (tx - sx) result += "D" * (ty - sy) result += "L" * (tx - sx) result += "L" result += "U" * (ty - sy + 1) result += "R" * (tx - sx + 1) result += "D" result += "R" result += "D" * (ty - sy + 1) result += "L" * (tx - sx + 1) result += "U" print(result) if __name__ == "__main__": main()
s570232104
p03379
u223904637
2,000
262,144
Wrong Answer
152
25,228
249
When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N.
import bisect n=int(input()) l=list(map(int,input().split())) l.sort() if n==2: print(l[1],l[0]) exit() m=max(l) k=m//2 if m%2==1: k+=1 i=bisect.bisect_left(l,k) if abs(l[i]-k)<=abs(l[i+1]-k): print(m,l[i]) else: print(m,l[i+1])
s087542558
Accepted
323
25,220
178
n=int(input()) li = list(map(int,input().split())) s=sorted(li) a=s[round(n/2)-1] b=s[round(n/2)] for i in range(n): if li[i]<a+1: print(b) else: print(a)
s382987765
p03565
u896741788
2,000
262,144
Wrong Answer
17
3,064
279
E869120 found a chest which is likely to contain treasure. However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters. He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with `?`. One more thing he found is a sheet of paper with the following facts written on it: * Condition 1: The string S contains a string T as a contiguous substring. * Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1. Print the string S. If such a string does not exist, print `UNRESTORABLE`.
s,y=(input() for i in range(2)) ans="{"*len(s);pa=ans for i in range(len(s)-len(y)): for j in range(len(y)): if s[i+j]!='?' and s[i+j]!=y[j]:break else:ans=min(ans,s[:i].replace("?","a")+y+s[i+len(y):].replace("?","a")) if pa==ans:print("UNRESTORABLE") else:print(ans)
s711355304
Accepted
27
9,084
319
s,t=input(),input() ans='z'*len(s) for i in range(len(s)-len(t)+1): pre=s[:i].replace("?",'a') for x,y in zip(list(s[i:]),list(t)): if x!="?"and x!=y:break pre+=y else: pre+=s[i+len(t):].replace("?",'a') ans=min(ans,pre) print(ans if ans!='z'*len(s) else 'UNRESTORABLE')
s864275080
p03131
u593567568
2,000
1,048,576
Wrong Answer
17
2,940
118
Snuke has one biscuit and zero Japanese yen (the currency) in his pocket. He will perform the following operations exactly K times in total, in the order he likes: * Hit his pocket, which magically increases the number of biscuits by one. * Exchange A biscuits to 1 yen. * Exchange 1 yen to B biscuits. Find the maximum possible number of biscuits in Snuke's pocket after K operations.
K,A,B = map(int,input().split()) ans = K + 1 t = ((K+1) // (A+1)) * B t += (K+1) % (A+1) ans = max(ans,t) print(ans)
s096134804
Accepted
17
2,940
153
K,A,B = map(int,input().split()) if K < A+1 or B <= A+2: print(K+1) exit(0) K -= A - 1 ans = A p,q = divmod(K,2) ans += (B-A) * p + q print(ans)
s826495728
p03852
u116348130
2,000
262,144
Wrong Answer
17
2,940
139
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`.
S = input() sc = ["eraser", "erase", "dreamer", "dream"] for i in sc: S = S.replace(i, "") if S: print("NO") else: print("YES")
s273722360
Accepted
17
2,940
82
c = input() p = "aeiou" if c in p: print("vowel") else: print("consonant")
s181103346
p02401
u078042885
1,000
131,072
Wrong Answer
30
7,412
63
Write a program which reads two integers a, b and an operator op, and then prints the value of a op b. The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part.
while 1: s=input() if '?' in s:break print(eval(s))
s842937176
Accepted
20
7,404
68
while 1: s=input() if '?' in s:break print(int(eval(s)))
s146198442
p03760
u319690708
2,000
262,144
Wrong Answer
18
3,060
664
Snuke signed up for a new website which holds programming competitions. He worried that he might forget his password, and he took notes of it. Since directly recording his password would cause him trouble if stolen, he took two notes: one contains the characters at the odd-numbered positions, and the other contains the characters at the even-numbered positions. You are given two strings O and E. O contains the characters at the odd- numbered positions retaining their relative order, and E contains the characters at the even-numbered positions retaining their relative order. Restore the original password.
from sys import stdin # import itertools as itr A = str(input()) B = str(input()) A = list(A) B = list(B) AL = len(A) BL = len(B) print(AL) b = [] for i in range(BL): b.append(A[i] + B[i]) if AL -BL == 1: b.append(A[-1]) print(",".join(b).replace(",", "")) # print(C)
s904150179
Accepted
17
3,060
227
A = str(input()) B = str(input()) A = list(A) B = list(B) AL = len(A) BL = len(B) b = [] for i in range(BL): b.append(A[i] + B[i]) if AL -BL == 1: # b.append(A[-1]) b.append(A[-1]) print(",".join(b).replace(",", ""))
s399068425
p03814
u637824361
2,000
262,144
Wrong Answer
17
3,500
58
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() A = s.find('a') Z = s.rfind('z') print(Z-A+1)
s455441033
Accepted
17
3,512
57
s = input() A = s.find('A') Z = s.rfind('Z') print(Z-A+1)
s491707959
p02880
u544587633
2,000
1,048,576
Wrong Answer
19
2,940
230
Having learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together. Given an integer N, determine whether N can be represented as the product of two integers between 1 and 9. If it can, print `Yes`; if it cannot, print `No`.
import sys for line in sys.stdin: N = int(line) found=False for i in range(1, 10, 1): if N % i == 0: found = True break if found: print('Yes') else: print('No')
s380899194
Accepted
19
3,060
217
import sys import math l = [] for i in range(1, 10, 1): for j in range(1,10,1): l.append(i*j) for line in sys.stdin: N = int(line) if N in l: print('Yes') else: print('No')
s314545038
p03485
u197300260
2,000
262,144
Wrong Answer
17
2,940
95
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
a,b=map(int,input().split(" ")) print(a) print(b) c=a+b d=c%2 e=c//2 if d==1: e=e+1 print(e)
s626218542
Accepted
17
2,940
331
# Python 3rd Try from math import ceil def ceil2number(a, b): result = 0 c = (a + b) / 2 result = ceil(c) return result if __name__ == "__main__": answer = 0 a, b = map(int, input().split(' ')) answer = ceil2number(a, b) print(answer)
s971800756
p03611
u361826811
2,000
262,144
Wrong Answer
177
21,420
329
You are given an integer sequence of length N, a_1,a_2,...,a_N. For each 1≤i≤N, you have three choices: add 1 to a_i, subtract 1 from a_i or do nothing. After these operations, you select an integer X and count the number of i such that a_i=X. Maximize this count by making optimal choices.
import sys import itertools import numpy as np read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N, *a = map(int, read().split()) A = np.array(a) counter = np.bincount(A) print(type(counter)) B = counter.copy() B[1:] += counter[:-1] B[:-1] += counter[1:] print(B.max())
s860743441
Accepted
177
21,408
308
import sys import itertools import numpy as np read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N, *a = map(int, read().split()) A = np.array(a) counter = np.bincount(A) B = counter.copy() B[1:] += counter[:-1] B[:-1] += counter[1:] print(B.max())
s449233279
p03624
u397563544
2,000
262,144
Wrong Answer
48
4,664
288
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.
from collections import Counter s = sorted(str(input())) l = list(Counter(s)) print(l) a = ['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'] for i in range(0,len(l)): if l[i]!=a[i]: print(a[i]) break
s047546465
Accepted
33
3,960
181
import string x = input() def func(x): diff = set(string.ascii_lowercase)- set(x) if diff: print(sorted(diff)[0]) else: print('None') func(x)
s710008664
p02853
u254634413
2,000
1,048,576
Wrong Answer
17
3,060
195
We held two competitions: Coding Contest and Robot Maneuver. In each competition, the contestants taking the 3-rd, 2-nd, and 1-st places receive 100000, 200000, and 300000 yen (the currency of Japan), respectively. Furthermore, a contestant taking the first place in both competitions receives an additional 400000 yen. DISCO-Kun took the X-th place in Coding Contest and the Y-th place in Robot Maneuver. Find the total amount of money he earned.
X, Y = map(int, input().split()) prices = {1: 3e5, 2: 2e5, 3: 1e5} ans = 0 if X < 4: ans += prices[X] if Y < 4: ans += prices[Y] if Y == 1 and X == 1: ans += 4e5 print(ans)
s349793146
Accepted
18
2,940
207
X, Y = map(int, input().split()) prices = {1: 300000, 2: 200000, 3: 100000} ans = 0 if X < 4: ans += prices[X] if Y < 4: ans += prices[Y] if Y == 1 and X == 1: ans += 400000 print(ans)
s821547343
p03455
u826785572
2,000
262,144
Wrong Answer
23
3,316
102
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
a, b = map(int, input().split()) x = a * b if x // 2 == 0: print('Even') else: print('Odd')
s174507113
Accepted
17
2,940
101
a, b = map(int, input().split()) x = a * b if x % 2 == 0: print('Even') else: print('Odd')
s639796048
p02613
u656330453
2,000
1,048,576
Wrong Answer
144
16,220
279
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()) a = [input() for i in range(n)] ac = 0 wa = 0 tle = 0 re = 0 for s in a: if a=='AC': ac+=1 if a=='WA': wa+=1 if a=='TLE': tle+=1 if a=='RE': re+=1 print(f'AC × {ac}') print(f'WA × {wa}') print(f'TLE × {tle}') print(f'RE × {re}')
s789100058
Accepted
142
16,540
194
from collections import Counter n = int(input()) s = [input() for _ in range(n)] counter = Counter(s) output = ['AC', 'WA', 'TLE', 'RE'] for key in output: print(f'{key} x {counter[key]}')
s346676735
p02255
u908651435
1,000
131,072
Wrong Answer
20
5,532
48
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key A[j+1] = A[j] j-- A[j+1] = key Note that, indices for array elements are based on 0-origin. To illustrate the algorithms, your program should trace intermediate result for each step.
a=input() n=input().split() s=n.sort() print(s)
s389559883
Accepted
30
5,976
363
def show (nums): for i in range(len(nums)): if i!=len(nums)-1: print(nums[i],end=' ') else : print(nums[i]) n=int(input()) nums=list(map(int,input().split())) show(nums) for i in range(1,n): v=nums[i] j=i-1 while (j>=0 and nums[j]>v): nums[j+1]=nums[j] j-=1 nums[j+1]=v show(nums)
s257173331
p03946
u007550226
2,000
262,144
Wrong Answer
456
15,060
604
There are N towns located in a line, conveniently numbered 1 through N. Takahashi the merchant is going on a travel from town 1 to town N, buying and selling apples. Takahashi will begin the travel at town 1, with no apple in his possession. The actions that can be performed during the travel are as follows: * _Move_ : When at town i (i < N), move to town i + 1. * _Merchandise_ : Buy or sell an arbitrary number of apples at the current town. Here, it is assumed that one apple can always be bought and sold for A_i yen (the currency of Japan) at town i (1 ≦ i ≦ N), where A_i are distinct integers. Also, you can assume that he has an infinite supply of money. For some reason, there is a constraint on merchandising apple during the travel: the sum of the number of apples bought and the number of apples sold during the whole travel, must be at most T. (Note that a single apple can be counted in both.) During the travel, Takahashi will perform actions so that the _profit_ of the travel is maximized. Here, the profit of the travel is the amount of money that is gained by selling apples, minus the amount of money that is spent on buying apples. Note that we are not interested in apples in his possession at the end of the travel. Aoki, a business rival of Takahashi, wants to trouble Takahashi by manipulating the market price of apples. Prior to the beginning of Takahashi's travel, Aoki can change A_i into another arbitrary non-negative integer A_i' for any town i, any number of times. The cost of performing this operation is |A_i - A_i'|. After performing this operation, different towns may have equal values of A_i. Aoki's objective is to decrease Takahashi's expected profit by at least 1 yen. Find the minimum total cost to achieve it. You may assume that Takahashi's expected profit is initially at least 1 yen.
n,t= map(int,input().split()) a= list(map(int,input().split())) mp,mprof = 999999999,0 bid = [] bsus = [] sid = [] nc=0 for i in range(n): cp = a[i]-mp if cp<0: nc += min(len(bid),len(sid)) mp = a[i] sid=[] bid=[] bsus=[i] elif cp>0: if mprof <= cp: bid += bsus bsus = [] if mprof < cp: mprof,sid,nc = cp,[i],0 else:sid.append(i) else:bsus.append(i) print(a[i],nc,mprof,bid,sid,bsus) else: if len(bid)!=0 and len(sid)!=0: nc += min(len(bid),len(sid)) print(nc)
s653341232
Accepted
122
15,060
566
n,t= map(int,input().split()) a= list(map(int,input().split())) mp,mprof = 999999999,0 bid = [] bsus = [] sid = [] nc=0 for i in range(n): cp = a[i]-mp if cp<0: nc += min(len(bid),len(sid)) mp = a[i] sid=[] bid=[] bsus=[i] elif cp>0: if mprof <= cp: bid += bsus bsus = [] if mprof < cp: mprof,sid,nc = cp,[i],0 else:sid.append(i) else:bsus.append(i) else: if len(bid)!=0 and len(sid)!=0: nc += min(len(bid),len(sid)) print(nc)
s753020397
p03964
u540290227
2,000
262,144
Wrong Answer
27
3,060
154
AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time. Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases.
N=int(input()) t=a=1 for i in range(N): T,A=map(int,input().split()) num=max(-(-t//T),-(-a//A)) t,a=num*T,num*A print(t, a) print(t + a)
s940000070
Accepted
20
3,064
138
N=int(input()) t=a=1 for i in range(N): T,A=map(int,input().split()) num=max(-(-t//T),-(-a//A)) t,a=num*T,num*A print(t + a)
s809850191
p04029
u546132222
2,000
262,144
Wrong Answer
25
9,068
158
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?
# 043A n =int(input()) ansewr = (n + 1) * n / 2 print(ansewr)
s049694016
Accepted
24
9,148
159
# 043A n = int(input()) answer = (n + 1) * n // 2 print(answer)
s344803021
p02385
u126478680
1,000
131,072
Wrong Answer
30
5,604
1,487
Write a program which reads the two dices constructed in the same way as [Dice I](description.jsp?id=ITP1_11_A), and determines whether these two dices are identical. You can roll a dice in the same way as [Dice I](description.jsp?id=ITP1_11_A), and if all integers observed from the six directions are the same as that of another dice, these dices can be considered as identical.
#! python3 class dice(): def __init__(self, arr): self.top = arr[0] self.south = arr[1] self.east = arr[2] self.west = arr[3] self.north = arr[4] self.bottom = arr[5] def rotate(self, ope): if ope == 'S': self.top, self.north, self.bottom, self.south = self.north, self.bottom, self.south, self.top elif ope == 'N': self.top, self.south, self.bottom, self.north = self.south, self.bottom, self.north, self.top elif ope == 'E': self.top, self.west, self.bottom, self.east = self.west, self.bottom, self.east, self.top elif ope == 'W': self.top, self.east, self.bottom, self.west = self.east, self.bottom, self.west, self.top def get_surfaces(self): return [self.top, self.south, self.east, self.north, self.west, self.bottom] dc1 = dice([int(x) for x in input().split(' ')]) dc2 = dice([int(x) for x in input().split(' ')]) judged = False if len((dc1.get_surfaces() and dc2.get_surfaces())) == 6: if dc2.top != dc1.top: opes = ['S', 'E', 'S', 'E', 'S'] for op in opes: dc2.rotate(op) if dc2.top == dc1.top: break for i in range(4): if dc2.south == dc1.south: break dc2.rotate('R') if (dc1.east == dc2.east) and (dc1.north == dc2.north) and (dc1.bottom == dc2.bottom): judged = True if judged: print('Yes') else: print('No')
s755200495
Accepted
20
5,612
1,709
#! python3 class dice(): def __init__(self, arr): self.top = arr[0] self.south = arr[1] self.east = arr[2] self.west = arr[3] self.north = arr[4] self.bottom = arr[5] def rotate(self, ope): if ope == 'S': self.top, self.north, self.bottom, self.south = self.north, self.bottom, self.south, self.top elif ope == 'N': self.top, self.south, self.bottom, self.north = self.south, self.bottom, self.north, self.top elif ope == 'E': self.top, self.west, self.bottom, self.east = self.west, self.bottom, self.east, self.top elif ope == 'W': self.top, self.east, self.bottom, self.west = self.east, self.bottom, self.west, self.top elif ope == 'R': # clockwise self.south, self.east, self.north, self.west = self.east, self.north, self.west, self.south elif ope == 'L': # reversed clockwise self.south, self.east, self.north, self.west = self.west, self.north, self.east, self.south else: pass def get_surfaces(self): return [self.top, self.south, self.east, self.north, self.west, self.bottom] dc1 = dice([int(x) for x in input().split(' ')]) dc2 = dice([int(x) for x in input().split(' ')]) judged = False if len((dc1.get_surfaces() and dc2.get_surfaces())) == 6: opes = ['', 'S', 'E', 'S', 'E', 'S'] for op in opes: dc2.rotate(op) for i in range(4): if dc1.get_surfaces() == dc2.get_surfaces(): judged = True break dc2.rotate('R') if judged: break if judged: print('Yes') else: print('No')
s784598308
p03729
u853586331
2,000
262,144
Wrong Answer
17
2,940
97
You are given three strings A, B and C. Check whether they form a _word chain_. More formally, determine whether both of the following are true: * The last character in A and the initial character in B are the same. * The last character in B and the initial character in C are the same. If both are true, print `YES`. Otherwise, print `NO`.
a,b,c=map(str, input().split()) if a[-1]==b[0] and b[-1]==c[0]: print ('Yes') else: print('No')
s303253259
Accepted
17
2,940
97
a,b,c=map(str, input().split()) if a[-1]==b[0] and b[-1]==c[0]: print ('YES') else: print('NO')
s415721456
p03048
u677393869
2,000
1,048,576
Wrong Answer
2,104
3,472
208
Snuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes: * Red boxes, each containing R red balls * Green boxes, each containing G green balls * Blue boxes, each containing B blue balls Snuke wants to get a total of exactly N balls by buying r red boxes, g green boxes and b blue boxes. How many triples of non-negative integers (r,g,b) achieve this?
A,B,C,N=map(int, input().split()) count=0 for x in range(A+1): for y in range(B+1): for z in range(C+1): if N==x+y+z: count+=1 print(x,y,z) print(count)
s412195330
Accepted
1,871
3,060
176
A,B,C,N=map(int, input().split()) count=0 for x in range(N+1): for y in range(N-x*A+1): b=(N-x*A-y*B) if b>=0 and b%C==0: count+=1 print(count)
s518222585
p03171
u858742833
2,000
1,048,576
Wrong Answer
2,115
117,116
490
Taro and Jiro will play the following game against each other. Initially, they are given a sequence a = (a_1, a_2, \ldots, a_N). Until a becomes empty, the two players perform the following operation alternately, starting from Taro: * Remove the element at the beginning or the end of a. The player earns x points, where x is the removed element. Let X and Y be Taro's and Jiro's total score at the end of the game, respectively. Taro tries to maximize X - Y, while Jiro tries to minimize X - Y. Assuming that the two players play optimally, find the resulting value of X - Y.
import sys sys.setrecursionlimit(10 ** 6) def main(): N = int(input()) A = list(map(int, input().split())) print(A) c = [[None] * (N + 1) for _ in range(N + 1)] def dp(r, l, A, c): if r == l: return A[r] if c[r][l] != None: return c[r][l] print(r, l) t = max(-dp(r + 1, l, A, c) + A[r], -dp(r, l - 1, A, c) + A[l]) c[r][l] = t return t print(dp(0, N - 1, A, c)) main()
s056976821
Accepted
1,544
3,444
275
def main(): N = int(input()) A = list(map(int, input().split())) c = [0] * N for r in reversed(range(N)): ar = A[r] c[r] = t = ar for l in range(r + 1, N): c[l] = t = max(ar - c[l], A[l] - t) print(c[-1]) main()
s352881429
p03486
u503476415
2,000
262,144
Wrong Answer
31
3,824
505
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.
import random s_given = list(input()) t_given = list(input()) s_len = len(s_given) t_len = len(t_given) s_random = random.sample(s_given, s_len) t_random = random.sample(t_given, t_len) print(s_random, t_random) for i in range(t_len): if s_random[i] < t_random[i]: print('Yes') break elif s_random[i] > t_random[i]: print('No') break if i == t_len - 1: print('No') break elif i == s_len - 1 : print('Yes') break
s822649054
Accepted
17
3,060
546
s_given = list(input()) t_given = list(input()) s_len = len(s_given) t_len = len(t_given) s_sorted = sorted(s_given) t_sorted = sorted(t_given, reverse=True) for i in range(t_len): if s_sorted[i] < t_sorted[i]: print('Yes') break elif s_sorted[i] > t_sorted[i]: print('No') break if i == t_len - 1: print('No') break elif i == s_len - 1 : print('Yes') break
s158883634
p02744
u445916016
2,000
1,048,576
Wrong Answer
988
440,040
336
In this problem, we only consider strings consisting of lowercase English letters. Strings s and t are said to be **isomorphic** when the following conditions are satisfied: * |s| = |t| holds. * For every pair i, j, one of the following holds: * s_i = s_j and t_i = t_j. * s_i \neq s_j and t_i \neq t_j. For example, `abcac` and `zyxzx` are isomorphic, while `abcac` and `ppppp` are not. A string s is said to be in **normal form** when the following condition is satisfied: * For every string t that is isomorphic to s, s \leq t holds. Here \leq denotes lexicographic comparison. For example, `abcac` is in normal form, but `zyxzx` is not since it is isomorphic to `abcac`, which is lexicographically smaller than `zyxzx`. You are given an integer N. Print all strings of length N that are in normal form, in lexicographically ascending order.
def main(): N = int(input()) li = 'abcdefghijklmnopqrstuvwxyz' def f(k): nonlocal li if k == 1: return ['a'] else: temp = f(k-1) return [t+char for t in temp for char in li[:k]] result = f(N) print(sorted(result)) if __name__ == '__main__': main()
s674350982
Accepted
455
13,892
546
def main(): N = int(input()) li = 'abcdefghijklmnopqrstuvwxyz' def condition(t,char): nonlocal li if li.index(sorted(t)[-1]) + 1 >= li.index(char): return True else: return False def f(k): nonlocal li if k == 1: return ['a'] else: temp = f(k-1) return [t+char for t in temp for char in li[:k] if condition(t, char)] result = f(N) for t in sorted(result): print(t) if __name__ == '__main__': main()
s750108676
p03623
u732870425
2,000
262,144
Wrong Answer
18
2,940
78
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and t on a number line is represented by |s-t|.
x, a, b = map(int, input().split()) print("A" if abs(x-a) > abs(x-b) else "B")
s509233195
Accepted
17
2,940
78
x, a, b = map(int, input().split()) print("A" if abs(x-a) < abs(x-b) else "B")
s492863045
p03469
u435281580
2,000
262,144
Wrong Answer
17
2,940
335
On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in `yyyy/mm/dd` format. For example, January 23, 2018 should be written as `2018/01/23`. After finishing the document, she noticed that she had mistakenly wrote `2017` at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to `2018` and prints it.
def bills(count, value): max10000 = value // 10000 for i in range(max10000 + 1): max5000 = min(count - i, (value - i * 10000) // 5000) for j in range(max5000 + 1): k = (value - i * 10000 - j * 5000) // 1000 if i + j + k == count: return i, j, k return -1, -1, -1
s692753374
Accepted
17
2,940
38
print(input().replace("2017", "2018"))
s010118934
p03079
u514299323
2,000
1,048,576
Wrong Answer
17
2,940
100
You are given three integers A, B and C. Determine if there exists an equilateral triangle whose sides have lengths A, B and C.
A, B, C = map(int,input("test").split(" ")) if A == B == C: print('Yes') else: print('No')
s672524152
Accepted
17
2,940
94
A, B, C = map(int,input("").split(" ")) if A == B == C: print('Yes') else: print('No')
s424975643
p02842
u540761833
2,000
1,048,576
Wrong Answer
17
2,940
131
Takahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it. The consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \times 1.08 yen (rounded down to the nearest integer). Takahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer. If there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.
N = int(input()) if N%1.08 == 0: print(N//1.08) elif int(N/1.08) != int((N+1)/1.08): print(int((N+1)/1.08)) else: print(':(')
s568224057
Accepted
18
2,940
125
N = int(input()) x = int(N//1.08) if int(x*1.08) == N: print(x) elif int((x+1)*1.08) == N: print(x+1) else: print(':(')