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
s641351127
p03455
u375681664
2,000
262,144
Wrong Answer
17
2,940
269
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
S = input() if S in "1234567890": print ("number") elif S in "abcdefghijklmnopqrstuvwxyz": print ("alphabet") else: print ("other")
s830931134
Accepted
17
2,940
127
a,b = input().split() a = int(a) b = int(b) c = a % 2 d = b % 2 if c == 0 or d == 0: print ("Even") else: print ("Odd")
s744391986
p03090
u189575640
2,000
1,048,576
Wrong Answer
295
21,212
1,037
You are given an integer N. Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions: * The graph is simple and connected. * There exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is S. It can be proved that at least one such graph exists under the constraints of this problem.
from sys import exit from numpy.random import rand # A,B,C = [int(n) for n in input().split()] # N = int(input()) # a = [int(input()) for _ in range(N)] # S = str(input()) # L = len(S) # T = str(input()) N = int(input()) # dic = {} ansgroup = [] if N%2 == 0: for i in range(1,N//2+1): ansgroup.append([i, N-i+1]) else: for i in range(1,N//2+1): ansgroup.append([i, N-i]) ansgroup.append([N]) # print(ansgroup) for i in range(len(ansgroup)): for j in range(i+1,len(ansgroup)): for e1 in ansgroup[i]: for e2 in ansgroup[j]: print(e1,e2) # tmpset = set() # if ans[i-1][0] == ans[i][0]: # else: # exit()
s004161132
Accepted
158
14,512
1,124
from sys import exit from numpy.random import rand # A,B,C = [int(n) for n in input().split()] # N = int(input()) # a = [int(input()) for _ in range(N)] # S = str(input()) # L = len(S) # T = str(input()) N = int(input()) # dic = {} ansgroup = [] if N%2 == 0: for i in range(1,N//2+1): ansgroup.append([i, N-i+1]) else: for i in range(1,N//2+1): ansgroup.append([i, N-i]) ansgroup.append([N]) nodesum = 0 ans = [] for i in range(len(ansgroup)): for j in range(i+1,len(ansgroup)): for e1 in ansgroup[i]: for e2 in ansgroup[j]: nodesum+=1 ans.append([e1,e2]) print(nodesum) for a in ans: print(a[0],a[1]) # tmpset = set() # if ans[i-1][0] == ans[i][0]: # else: # exit()
s753094690
p02394
u446066125
1,000
131,072
Wrong Answer
30
6,724
149
Write a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$ and radius $r$ of the circle are given.
(W, H, x, y, r) = [int(i) for i in input().split()] if 0 >= x - r and 0 >= y - r and W <= x + r and H <= y + r : print('Yes') else : print('No')
s763373627
Accepted
40
6,724
149
(W,H,x,y,r) = [int(i) for i in input().split()] if x - r >= 0 and y - r >= 0 and x + r <= W and y + r <= H : print('Yes') else : print('No')
s393217804
p03478
u350997995
2,000
262,144
Wrong Answer
34
3,060
155
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
N,A,B = map(int,input().split()) ans = 0 for i in range(1,N+1): S = str(i) a = 0 for s in S: a+=int(s) if A<=a<=B:ans+=1 print(ans)
s716467833
Accepted
34
3,060
155
N,A,B = map(int,input().split()) ans = 0 for i in range(1,N+1): S = str(i) a = 0 for s in S: a+=int(s) if A<=a<=B:ans+=i print(ans)
s712044895
p03680
u722535636
2,000
262,144
Wrong Answer
175
7,852
193
Takahashi wants to gain muscle, and decides to work out at AtCoder Gym. The exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up. These buttons are numbered 1 through N. When Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i. When Button i is not lighten up, nothing will happen by pressing it. Initially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up. Determine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.
n = int(input()) l = [0] + [int(input()) for i in range(n)] cnt = 0 a = 1 while a != 2: if a==0: print(-1) break a = l[a] l[a] = 0 cnt += 1 else: print(cnt)
s881281843
Accepted
205
7,852
201
n = int(input()) l = [0] + [int(input()) for i in range(n)] cnt = 0 a = 1 while a != 2: if a==0: print(-1) break tmp=l[a] l[a]=0 a=tmp cnt += 1 else: print(cnt)
s663231490
p03711
u746849814
2,000
262,144
Wrong Answer
17
3,060
221
Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below. Given two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.
x, y = map(int, input().split()) a = [1, 3, 5, 7, 8, 10, 12] b = [4, 6, 9, 11] c = [2] if x in a and y in b: print('Yes') elif x in b and y in b: print('Yes') elif x in c and y in c: print('Yes') else: print('No')
s058005879
Accepted
17
3,060
221
x, y = map(int, input().split()) a = [1, 3, 5, 7, 8, 10, 12] b = [4, 6, 9, 11] c = [2] if x in a and y in a: print('Yes') elif x in b and y in b: print('Yes') elif x in c and y in c: print('Yes') else: print('No')
s840821258
p02316
u947762778
1,000
131,072
Wrong Answer
20
7,636
277
You have N kinds of items that you want to put them into a knapsack. Item i has value vi and weight wi. You want to find a subset of items to put such that: * The total value of the items is as large as possible. * The items have combined weight at most W, that is capacity of the knapsack. * You can select as many items as possible into a knapsack for each kind. Find the maximum total value of items in the knapsack.
N, W = map(int, input().split()) value = [] weight = [] dp = [0 for _ in range(W + 1)] for i in range(N): v, w = map(int, input().split()) for j in range(w+1): if j >= w: dp[j] = max(dp[j], dp[j - w] + v) else: break print(dp[W])
s592927724
Accepted
680
8,024
245
N, W = map(int, input().split()) value = [] weight = [] dp = [0 for _ in range(W + 1)] for i in range(N): v, w = map(int, input().split()) for j in range(W+1): if j >= w: dp[j] = max(dp[j], dp[j - w] + v) print(dp[W])
s652689491
p03657
u089032001
2,000
262,144
Wrong Answer
18
2,940
102
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.
a, b = map(int, input().split()) print("Possible" if a+b%3 == 0 or a%3==0 or b%3==0 else "Impossible")
s576786709
Accepted
18
2,940
104
a, b = map(int, input().split()) print("Possible" if (a+b)%3 == 0 or a%3==0 or b%3==0 else "Impossible")
s165098219
p02399
u442346200
1,000
131,072
Wrong Answer
30
6,744
105
Write a program which reads two integers a and b, and calculates the following values: * a ÷ b: d (in integer) * remainder of a ÷ b: r (in integer) * a ÷ b: f (in real number)
(a, b) = [int(x) for x in input().split()] x = a // b y = a % b z = a / b print(x); print(y); print(z);
s944125979
Accepted
30
6,748
110
(a, b) = [int(i) for i in input().split()] d = int (a / b) r = a % b f = a / b print('%s %s %.5f' % (d, r, f))
s076732042
p03069
u101742684
2,000
1,048,576
Wrong Answer
957
23,844
390
There are N stones arranged in a row. Every stone is painted white or black. A string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is `.`, and the stone is black if the character is `#`. Takahashi wants to change the colors of some stones to black or white so that there will be no white stone immediately to the right of a black stone. Find the minimum number of stones that needs to be recolored.
import numpy as np N = int(input()) s = input() S = [] for c in s: S.append(c) A = np.zeros(N+1) if S[0] == "#": A[0] = 0 for i in range(1,N+1): if S[i-1] == "#": A[i] = A[i-1] + 1 else: A[i] = A[i-1] minimum = N for i in range(N+1): num = int(A[i] + (N-i-(A[N]-A[i]))) if minimum > num: minimum = num print(num)
s732171672
Accepted
949
18,132
393
import numpy as np N = int(input()) s = input() S = [] for c in s: S.append(c) A = np.zeros(N+1) if S[0] == "#": A[0] = 0 for i in range(1,N+1): if S[i-1] == "#": A[i] = A[i-1] + 1 else: A[i] = A[i-1] minimum = N for i in range(N+1): num = int(A[i] + (N-i-(A[N]-A[i]))) if minimum > num: minimum = num print(minimum)
s330932904
p02392
u801346721
1,000
131,072
Wrong Answer
30
7,496
110
Write a program which reads three integers a, b and c, and prints "Yes" if a < b < c, otherwise "No".
a, b, c = input().split(' ') a = int(a) b = int(b) c = int(c) if a > b > c: print('Yes') else: print('No')
s927771038
Accepted
60
7,648
110
a, b, c = input().split(' ') a = int(a) b = int(b) c = int(c) if a < b < c: print("Yes") else: print("No")
s575705185
p03476
u666964944
2,000
262,144
Wrong Answer
603
12,180
241
We say that a odd number N is _similar to 2017_ when both N and (N+1)/2 are prime. You are given Q queries. In the i-th query, given two odd numbers l_i and r_i, find the number of odd numbers x similar to 2017 such that l_i ≤ x ≤ r_i.
q = int(input()) n = 100001 limit = int(n**0.5) a = [i for i in range(3, n, 2)] e = [] for i in range(n): p = a[i] if limit <= p: break e = [j for j in a if j%p!=0 ] print(e) for i in range(q): l,r = map(int, input().split())
s936270358
Accepted
1,465
14,424
670
#import numpy #for loop #a = [1,2,3,4,5,6,7,8,9,10] #s = [0]*len(a) #s[0] = a[0] # s[i+1] = s[i] + a[i+1] #print(s) #numpy.cumsum() #print(numpy.cumsum(a)) q = int(input()) n = 10**5+1 limit = int(n**0.5) a = [i for i in range(3, n, 2)] prime = [2] while True: p = a[0] if limit <= p: prime += a break prime.append(p) a = [j for j in a if j%p!=0] pi = [0]*n for i in range(len(prime)): ai = (prime[i]+1)//2 if ai in prime: pi[prime[i]-1] = 1 s = [0]*n s[0] = pi[0] for i in range(len(pi)-1): s[i+1] = s[i] + pi[i+1] s = [0,0] + s for i in range(q): l, r = map(int, input().split()) print(s[r+1]-s[l])
s502618961
p03339
u287775083
2,000
1,048,576
Wrong Answer
133
15,140
969
There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions.
import sys import re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd from itertools import accumulate, permutations, combinations, product from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_uppercase, digits from bisect import bisect, bisect_left from heapq import heappush, heappop from functools import reduce def input(): return sys.stdin.readline().strip() def INT(): return int(input()) def MAP(): return map(str, input().split()) def LIST(): return list(map(int, input().split())) sys.setrecursionlimit(10 ** 9) INF = float('inf') mod = 10 ** 9 + 7 N = INT() S = [_ for _ in input()] init_cnt = S[1:].count('E') min_c = init_cnt ans = 0 for i in range(1, N): tmp = min_c if S[i-1] == 'W': tmp = tmp + 1 if S[i] == 'E': tmp = tmp - 1 if tmp < min_c: min_c = tmp ans = i print(ans)
s488212969
Accepted
171
15,136
923
import sys import re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd from itertools import accumulate, permutations, combinations, product from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_uppercase, digits from bisect import bisect, bisect_left from heapq import heappush, heappop from functools import reduce def input(): return sys.stdin.readline().strip() def INT(): return int(input()) def MAP(): return map(str, input().split()) def LIST(): return list(map(int, input().split())) sys.setrecursionlimit(10 ** 9) INF = float('inf') mod = 10 ** 9 + 7 N = INT() S = [_ for _ in input()] left, right = 0, S[1:].count('E') ans = left + right for i in range(N-1): if S[i] == 'W': left += 1 if S[i+1] == 'E': right -= 1 ans = min(ans, left + right) print(ans)
s183741746
p03578
u692632484
2,000
262,144
Wrong Answer
390
35,556
299
Rng is preparing a problem set for a qualification round of CODEFESTIVAL. He has N candidates of problems. The difficulty of the i-th candidate is D_i. There must be M problems in the problem set, and the difficulty of the i-th problem must be T_i. Here, one candidate of a problem cannot be used as multiple problems. Determine whether Rng can complete the problem set without creating new candidates of problems.
N=int(input()) D=[int(i) for i in input().split()] M=int(input()) T=[int(i) for i in input().split()] D.sort() T.sort() indexD=0 indexT=0 while indexD<len(D) and indexT<len(T): if D[indexD]==T[indexT]: indexD+=1 indexT+=1 else: indexD+=1 if indexT==len(T): print("Yes") else: print("No")
s467225998
Accepted
426
35,556
299
N=int(input()) D=[int(i) for i in input().split()] M=int(input()) T=[int(i) for i in input().split()] D.sort() T.sort() indexD=0 indexT=0 while indexD<len(D) and indexT<len(T): if D[indexD]==T[indexT]: indexD+=1 indexT+=1 else: indexD+=1 if indexT==len(T): print("YES") else: print("NO")
s784381160
p00004
u811733736
1,000
131,072
Wrong Answer
30
7,732
531
Write a program which solve a simultaneous equation: ax + by = c dx + ey = f The program should print x and y for given a, b, c, d, e and f (-1,000 ≤ a, b, c, d, e, f ≤ 1,000). You can suppose that given equation has a unique solution.
import sys from math import fabs if __name__ == '__main__': epsilon = 1e-10 for line in sys.stdin: a, b, e, c, d, f = [int(x) for x in line.strip().split(' ')] x = 1/(a*d-b*c) * (d*e - b*f) y = 1/(a*d-b*c) * (-c*e + a*f) if fabs(x) < epsilon: x = 0.0 if fabs(y) < epsilon: y = 0.0 print('{0:.3f}, {1:.3f}'.format(x, y))
s683585649
Accepted
30
7,780
528
import sys from math import fabs if __name__ == '__main__': epsilon = 1e-9 for line in sys.stdin: a, b, e, c, d, f = [int(x) for x in line.strip().split(' ')] x = 1/(a*d-b*c) * (d*e - b*f) y = 1/(a*d-b*c) * (-c*e + a*f) if fabs(x) < epsilon: x = 0.0 if fabs(y) < epsilon: y = 0.0 print('{0:.3f} {1:.3f}'.format(x, y))
s798537636
p03494
u360258922
2,000
262,144
Wrong Answer
17
3,060
184
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
n = input() a = list(map(int, input().split(' '))) cnt = 0 while sum(x%2==0 for x in a) == n: a = list(map(lambda x: x / 2 if x % 2 == 0 else x, a)) cnt += 1 print(cnt)
s989110393
Accepted
20
3,060
181
n = int(input()) a = list(map(int, input().split(' '))) cnt = 0 while sum(x%2==0 for x in a) == n: a = list(map(lambda x: x / 2 if x % 2 == 0 else x, a)) cnt += 1 print(cnt)
s285644005
p02927
u629350026
2,000
1,048,576
Wrong Answer
28
9,020
147
Today is August 24, one of the five Product Days in a year. A date m-d (m is the month, d is the date) is called a Product Day when d is a two-digit number, and all of the following conditions are satisfied (here d_{10} is the tens digit of the day and d_1 is the ones digit of the day): * d_1 \geq 2 * d_{10} \geq 2 * d_1 \times d_{10} = m Takahashi wants more Product Days, and he made a new calendar called Takahashi Calendar where a year consists of M month from Month 1 to Month M, and each month consists of D days from Day 1 to Day D. In Takahashi Calendar, how many Product Days does a year have?
m,d=map(int,input().split()) ans=0 for i in range(1,m+1): for j in range(22,d+1): if j%10>=2 and (j/10)*(j%10)==i: ans=ans+1 print(ans)
s405207454
Accepted
26
9,084
148
m,d=map(int,input().split()) ans=0 for i in range(1,m+1): for j in range(22,d+1): if j%10>=2 and (j//10)*(j%10)==i: ans=ans+1 print(ans)
s726888085
p03494
u064408584
2,000
262,144
Wrong Answer
19
3,060
137
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
n=int(input()) a=list(map(int, input().split())) count=0 while sum(a)%2==0: a=[i/2 for i in a] count+=1 print(a) print(count)
s687924141
Accepted
19
3,060
136
n=int(input()) a=list(map(int, input().split())) count=0 while all(i%2==0 for i in a): a=[i//2 for i in a] count+=1 print(count)
s638959156
p02669
u162612857
2,000
1,048,576
Wrong Answer
408
11,016
1,802
You start with the number 0 and you want to reach the number N. You can change the number, paying a certain amount of coins, with the following operations: * Multiply the number by 2, paying A coins. * Multiply the number by 3, paying B coins. * Multiply the number by 5, paying C coins. * Increase or decrease the number by 1, paying D coins. You can perform these operations in arbitrary order and an arbitrary number of times. What is the minimum number of coins you need to reach N? **You have to solve T testcases.**
import math def calc_cost(n, ans_dict): min_cost = n * d inc_2 = int(math.ceil(n / 2)) if inc_2 not in ans_dict: ans_dict[inc_2] = calc_cost(inc_2, ans_dict) min_cost = min(min_cost, d * (inc_2 * 2 - n) + a + ans_dict[inc_2]) dec_2 = int(math.floor(n / 2)) if dec_2 not in ans_dict: ans_dict[dec_2] = calc_cost(dec_2, ans_dict) min_cost = min(min_cost, d * (- dec_2 * 2 + n) + a + ans_dict[dec_2]) inc_3 = int(math.ceil(n / 3)) if inc_3 not in ans_dict: ans_dict[inc_3] = calc_cost(inc_3, ans_dict) min_cost = min(min_cost, d * (inc_3 * 3 - n) + b + ans_dict[inc_3]) dec_3 = int(math.floor(n / 3)) if dec_3 not in ans_dict: ans_dict[dec_3] = calc_cost(dec_3, ans_dict) min_cost = min(min_cost, d * (- dec_3 * 3 + n) + b + ans_dict[dec_3]) inc_5 = int(math.ceil(n / 5)) if inc_5 not in ans_dict: ans_dict[inc_5] = calc_cost(inc_5, ans_dict) min_cost = min(min_cost, d * (inc_5 * 5 - n) + c + ans_dict[inc_5]) dec_5 = int(math.floor(n / 5)) if dec_5 not in ans_dict: ans_dict[dec_5] = calc_cost(dec_5, ans_dict) min_cost = min(min_cost, d * (- dec_5 * 5 + n) + c + ans_dict[dec_5]) ans_dict[n] = min_cost return min_cost n_testcase = int(input()) for i in range(n_testcase): n, a, b, c, d = list(map(int, input().split())) ans_dict = {} ans_dict[0] = 0 ans_dict[1] = d ans = calc_cost(n, ans_dict) print(ans) # print(ans_dict)
s475117787
Accepted
312
11,124
1,726
def calc_cost(n, ans_dict): min_cost = n * d inc_2 = (n + 2 - 1) // 2 if inc_2 not in ans_dict: ans_dict[inc_2] = calc_cost(inc_2, ans_dict) min_cost = min(min_cost, d * (inc_2 * 2 - n) + a + ans_dict[inc_2]) dec_2 = n // 2 if dec_2 not in ans_dict: ans_dict[dec_2] = calc_cost(dec_2, ans_dict) min_cost = min(min_cost, d * (- dec_2 * 2 + n) + a + ans_dict[dec_2]) inc_3 = (n + 3 - 1) // 3 if inc_3 not in ans_dict: ans_dict[inc_3] = calc_cost(inc_3, ans_dict) min_cost = min(min_cost, d * (inc_3 * 3 - n) + b + ans_dict[inc_3]) dec_3 = n // 3 if dec_3 not in ans_dict: ans_dict[dec_3] = calc_cost(dec_3, ans_dict) min_cost = min(min_cost, d * (- dec_3 * 3 + n) + b + ans_dict[dec_3]) inc_5 = (n + 5 - 1) // 5 if inc_5 not in ans_dict: ans_dict[inc_5] = calc_cost(inc_5, ans_dict) min_cost = min(min_cost, d * (inc_5 * 5 - n) + c + ans_dict[inc_5]) dec_5 = n // 5 if dec_5 not in ans_dict: ans_dict[dec_5] = calc_cost(dec_5, ans_dict) min_cost = min(min_cost, d * (- dec_5 * 5 + n) + c + ans_dict[dec_5]) ans_dict[n] = min_cost return min_cost n_testcase = int(input()) for i in range(n_testcase): n, a, b, c, d = list(map(int, input().split())) ans_dict = {} ans_dict[0] = 0 ans_dict[1] = d ans = calc_cost(n, ans_dict) print(ans) # print(ans_dict)
s341126813
p03478
u813569174
2,000
262,144
Wrong Answer
30
3,060
196
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
s = input().split() N = int(s[0]) A = int(s[1]) B = int(s[2]) k = 0 for i in range(1,N+1): S = 0 while i >= 1: p = i%10 i = i//10 S = S + p if A <= S <= B: k = k + i print(k)
s357607127
Accepted
30
3,060
204
s = input().split() N = int(s[0]) A = int(s[1]) B = int(s[2]) k = 0 for i in range(1,N+1): S = 0 l = i while l >= 1: p = l%10 l = l//10 S = S + p if A <= S <= B: k = k + i print(k)
s243262250
p03149
u849756457
2,000
1,048,576
Wrong Answer
27
9,068
137
You are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits "1974".
n = [int(i) for i in input().split()] n.sort() if n[0] == 1 and n[1] == 4 and n[2] == 7 and n[3] == 9: print("Yes") else: print("No")
s689845398
Accepted
30
9,024
138
n = [int(i) for i in input().split()] n.sort() if n[0] == 1 and n[1] == 4 and n[2] == 7 and n[3] == 9: print("YES") else: print("NO")
s005846152
p02255
u567380442
1,000
131,072
Wrong Answer
30
6,720
205
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key A[j+1] = A[j] j-- A[j+1] = key Note that, indices for array elements are based on 0-origin. To illustrate the algorithms, your program should trace intermediate result for each step.
n = input() A = list(map(int, input().split())) for i in range(1, len(A)): key = A[i] j = i - 1 while j >= 0 and A[j] > key: A[j+1] = A[j] j -= 1 A[j+1] = key print(*A)
s222528180
Accepted
40
6,756
214
n = input() A = list(map(int, input().split())) print(*A) for i in range(1, len(A)): key = A[i] j = i - 1 while j >= 0 and A[j] > key: A[j+1] = A[j] j -= 1 A[j+1] = key print(*A)
s835235700
p02842
u256027816
2,000
1,048,576
Wrong Answer
17
3,064
255
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.
import math n = int(input()) print(math.floor(math.floor(n/1.08)*1.08)) if math.floor(math.floor(n/1.08)*1.08) == n: print(math.floor(n/1.08)) elif math.floor((math.floor(n/1.08)+1) *1.08) == n: print(math.floor(n/1.08)+1) else: print(':(')
s467511933
Accepted
18
3,060
212
import math n = int(input()) if math.floor(math.floor(n/1.08)*1.08) == n: print(math.floor(n/1.08)) elif math.floor((math.floor(n/1.08)+1) *1.08) == n: print(math.floor(n/1.08)+1) else: print(':(')
s326344805
p03435
u811176339
2,000
262,144
Wrong Answer
35
9,228
643
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.
lc = [[int(w) for w in input().split()] for i in range(3)] def ch1(la, lb, aindex): return la[aindex] + lb[0] == lc[aindex][0]\ and la[aindex] + lb[1] == lc[aindex][1]\ and la[aindex] + lb[2] == lc[aindex][2] cond = False for i in range(100): if cond: break for j in range(100): la = [i//100, (i % 100)//10, i % 10] lb = [j//100, (j % 100)//10, j % 10] if ch1(la, lb, 0): if ch1(la, lb, 1): if ch1(la, lb, 2): cond = True else: j += 9 else: j += 99 print("Yes" if cond else "No")
s136881350
Accepted
30
9,132
293
lc = [[int(w) for w in input().split()] for i in range(3)] cond = True lb = lc[0] a2 = lc[1][0]-lb[0] a3 = lc[2][0]-lb[0] la = [0, a2, a3] for i in range(3): for j in range(3): if lc[i][j] != la[i]+lb[j]: cond = False break print("Yes" if cond else "No")
s717736507
p03477
u778700306
2,000
262,144
Wrong Answer
18
2,940
149
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()) if a + b < c + d: print("Left") if a + b > c + d: print("Right") if a + b == c + d: print("Balance")
s672260808
Accepted
18
2,940
150
a,b,c,d = map(int, input().split()) if a + b > c + d: print("Left") if a + b < c + d: print("Right") if a + b == c + d: print("Balanced")
s221307427
p03471
u937642029
2,000
262,144
Wrong Answer
2,104
3,064
715
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these. According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.
y,n1 = map(int,input().split()) k10=-1 k5=-1 k1=-1 n=n1 for i in range(n//10000+1): n=n1 if(n//10000==y and n%10000==0): k10=n//10000 k5=0 k1=0 break else: i=n//10000-i n-=i*10000 for j in range(n//5000+1): n=n1 if(n//5000==(y-i) and n%5000==0): k10=i k5=n//5000 k1=0 break else: j=n//5000-j n-=j*5000 if(n//1000==(y-i-j) and n%1000==0): k10=i k5=j k1=n//1000 break if(k1!=-1): break print(k10,k5,k1)
s314860723
Accepted
56
3,064
839
y,n1 = map(int,input().split()) k10=-1 k5=-1 k1=-1 n=n1 for i in range(n//10000+1): n=n1 if(n//10000==y and n%10000==0): k10=n//10000 k5=0 k1=0 break elif(n//10000>y): break else: i=n//10000-i n-=i*10000 for j in range(n//5000+1): n=n1-i*10000 if(n//5000==(y-i) and n%5000==0): k10=i k5=n//5000 k1=0 break elif(n//5000>y-i): break else: n=n1-i*10000 j=n//5000-j n-=j*5000 if(n//1000==(y-i-j) and n%1000==0): k10=i k5=j k1=n//1000 break if(k1!=-1): break print(k10,k5,k1)
s556904942
p04043
u077291787
2,000
262,144
Wrong Answer
17
2,940
185
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 = input().rstrip().split() print("YES" if len(a) == 5 and len(b) == 7 and len(c) == 5 else "NO")
s361678818
Accepted
17
2,940
233
def main(): A = sorted(map(int, input().split())) flg = A == [5, 5, 7] print("YES" if flg else "NO") if __name__ == "__main__": main()
s740672605
p02841
u138781768
2,000
1,048,576
Wrong Answer
17
2,940
110
In this problem, a date is written as Y-M-D. For example, 2019-11-30 means November 30, 2019. Integers M_1, D_1, M_2, and D_2 will be given as input. It is known that the date 2019-M_2-D_2 follows 2019-M_1-D_1. Determine whether the date 2019-M_1-D_1 is the last day of a month.
m1, d1 = map(int, input().split()) m2, d2 = map(int, input().split()) if m1 != m2: print(0) else: print(1)
s616323421
Accepted
17
2,940
110
m1, d1 = map(int, input().split()) m2, d2 = map(int, input().split()) if m1 != m2: print(1) else: print(0)
s620718092
p02612
u405733072
2,000
1,048,576
Wrong Answer
29
9,092
71
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
N = int(input()) pay = 0 while N <= pay: pay += 1000 print(pay -N)
s155316629
Accepted
28
9,152
66
N = int(input()) pay = 0 while N > pay: pay += 1000 print(pay-N)
s790109427
p03997
u597017430
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)
s160892964
Accepted
17
2,940
69
a = int(input()) b = int(input()) h = int(input()) print((a+b)*h//2)
s419872463
p03673
u190405389
2,000
262,144
Wrong Answer
100
28,956
162
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b. The i-th operation is as follows: 1. Append a_i to the end of b. 2. Reverse the order of the elements in b. Find the sequence b obtained after these n operations.
n = int(input()) a = input().split() b = [0]*n for i in range(n//2): b[i] = a[-1-2*i] b[n-i-1] = a[-2-2*i] if n % 2 == 1: b[n//2] = a[0] print(b)
s295435301
Accepted
81
25,540
172
n = int(input()) a = input().split() b = [0]*n for i in range(n//2): b[i] = a[-1-2*i] b[n-i-1] = a[-2-2*i] if n % 2 == 1: b[n//2] = a[0] print(' '.join(b))
s525763278
p02936
u712719923
2,000
1,048,576
Wrong Answer
2,207
58,908
622
Given is a rooted tree with N vertices numbered 1 to N. The root is Vertex 1, and the i-th edge (1 \leq i \leq N - 1) connects Vertex a_i and b_i. Each of the vertices has a counter installed. Initially, the counters on all the vertices have the value 0. Now, the following Q operations will be performed: * Operation j (1 \leq j \leq Q): Increment by x_j the counter on every vertex contained in the subtree rooted at Vertex p_j. Find the value of the counter on each vertex after all operations.
from collections import deque def main(): n, q = list(map(int, input().split(" "))) v_dict = {i: [] for i in range(n)} for _ in range(n-1): a, b = list(map(int, input().split(" "))) v_dict[a-1].append(b-1) point_list = [0]*n for _ in range(q): p, x = list(map(int, input().split(" "))) stack = deque([p-1]) while stack: cur = stack.pop() point_list[cur]+=x for next_i in v_dict[cur]: stack.append(next_i) for i in range(n): print(point_list[i], end=" ") if __name__=="__main__": main()
s399241466
Accepted
1,151
62,864
811
from collections import deque def main(): n, q = list(map(int, input().split(" "))) v_list = [[] for i in range(n)] for _ in range(n-1): a, b = list(map(int, input().split(" "))) v_list[a-1].append(b-1) v_list[b-1].append(a-1) p_x_list = [0]*n for _ in range(q): p, x = list(map(int, input().split(" "))) p_x_list[p-1]+=x point_list = [0]*n checked_list = [0]*n stack = deque([0]) while stack: cur = stack.pop() checked_list[cur] = 1 point_list[cur]+=p_x_list[cur] for next_i in v_list[cur]: if checked_list[next_i]: continue stack.append(next_i) point_list[next_i]+=point_list[cur] print(*point_list) if __name__=="__main__": main()
s611203138
p03943
u123273712
2,000
262,144
Wrong Answer
22
3,444
227
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.
import copy a = list(map(int,input().split())) nokori = copy.copy(a) count = max(a) nokori.remove(count) if a[0] == a[1] == a[2]: print("NO") if int(nokori[0] + nokori[1]) == count: print("YES") else: print("NO")
s124525551
Accepted
22
3,444
235
import copy a = list(map(int,input().split())) nokori = copy.copy(a) count = max(a) nokori.remove(count) """ if a[0] == a[1] == a[2]: print("No") """ if int(nokori[0] + nokori[1]) == count: print("Yes") else: print("No")
s618424707
p03815
u787562674
2,000
262,144
Wrong Answer
17
2,940
153
Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7. Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation: * Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward. For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back. Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.
x = int(input()) if x <= 6: print(1) else: div = x % 11 if div <= 6: print(2 * x // 11 + 1) else: print(2 * x // 11 + 2)
s743594609
Accepted
17
3,060
241
x = int(input()) if x <= 6: print(1) elif 7 <= x <= 10: print(2) else: div = x % 11 shou = x // 11 if div == 0: print(2 * shou) elif div <= 6: print(2 * shou + 1) else: print(2 * shou + 2)
s726922442
p01101
u843517396
8,000
262,144
Wrong Answer
1,570
5,636
452
Mammy decided to give Taro his first shopping experience. Mammy tells him to choose any two items he wants from those listed in the shopping catalogue, but Taro cannot decide which two, as all the items look attractive. Thus he plans to buy the pair of two items with the highest price sum, not exceeding the amount Mammy allows. As getting two of the same item is boring, he wants two different items. You are asked to help Taro select the two items. The price list for all of the items is given. Among pairs of two items in the list, find the pair with the highest price sum not exceeding the allowed amount, and report the sum. Taro is buying two items, not one, nor three, nor more. Note that, two or more items in the list may be priced equally.
while 1: str=input().split() n=int(str[0]) m=int(str[1]) if n==0 and m==0: break str=input().split() a=[0]*n for i in range(n): a[i]=int(str[i]) a.sort() a.reverse() print(a) flag=0 max=0 for i in range(n): if flag!=0: break for j in range(i+1,n): v=a[i]+a[j] if m>=v: if max<v: max=v if max==0: print("NONE") else: print(max)
s698146496
Accepted
1,570
5,624
439
while 1: str=input().split() n=int(str[0]) m=int(str[1]) if n==0 and m==0: break str=input().split() a=[0]*n for i in range(n): a[i]=int(str[i]) a.sort() a.reverse() flag=0 max=0 for i in range(n): if flag!=0: break for j in range(i+1,n): v=a[i]+a[j] if m>=v: if max<v: max=v if max==0: print("NONE") else: print(max)
s242953809
p02613
u853728588
2,000
1,048,576
Wrong Answer
138
16,152
286
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
N = int(input()) s = [input() for i in range(N)] ac = s.count("AC") wa = s.count("wa") tle = s.count("TLE") re = s.count("RE") print("AC x "+str(ac)) print("WA x "+str(wa)) print("TLE x "+str(tle)) print("RE x "+str(re))
s485336000
Accepted
139
16,276
286
N = int(input()) s = [input() for i in range(N)] ac = s.count("AC") wa = s.count("WA") tle = s.count("TLE") re = s.count("RE") print("AC x "+str(ac)) print("WA x "+str(wa)) print("TLE x "+str(tle)) print("RE x "+str(re))
s942285147
p04035
u543954314
2,000
262,144
Wrong Answer
65
14,052
254
We have N pieces of ropes, numbered 1 through N. The length of piece i is a_i. At first, for each i (1≤i≤N-1), piece i and piece i+1 are tied at the ends, forming one long rope with N-1 knots. Snuke will try to untie all of the knots by performing the following operation repeatedly: * Choose a (connected) rope with a total length of at least L, then untie one of its knots. Is it possible to untie all of the N-1 knots by properly applying this operation? If the answer is positive, find one possible order to untie the knots.
n,l = map(int,input().split()) a = list(map(int,input().split())) for i in range(n-1): if a[i] + a[i+1] >= l: print("Possible") break else: print("Impossible") exit() li = [range(1,i+1)]+[range(n,i+1,-1)]+[i+1] print(" ".join(map(str, li)))
s822411211
Accepted
120
14,052
258
n,l = map(int,input().split()) a = list(map(int,input().split())) for i in range(n-1): if a[i] + a[i+1] >= l: print("Possible") break else: print("Impossible") exit() li = list(range(1,i+1))+list(range(n-1,i+1,-1))+[i+1] for x in li: print(x)
s984681157
p03494
u792671636
2,000
262,144
Wrong Answer
19
2,940
180
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
import sys n = input() l = list(map(int, input().split())) loop = 0 while (1): for i in l: if (i % (2 ** loop) != 0): print(loop) sys.exit(0) loop = loop + 1
s376960301
Accepted
19
2,940
185
import sys n = input() l = list(map(int, input().split())) loop = 0 while (1): for i in l: if i % (2 ** (loop + 1)) != 0: print(loop) sys.exit(0) loop = loop + 1
s896726969
p03795
u247781603
2,000
262,144
Wrong Answer
17
2,940
87
Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
price = 800 i_ate = int(input()) ans = price * i_ate - (200 * (i_ate % 15)) print(ans)
s391432968
Accepted
17
2,940
90
price = 800 i_ate = int(input()) ans = (price * i_ate) - (200 * (i_ate // 15)) print(ans)
s234346572
p02600
u894521144
2,000
1,048,576
Wrong Answer
35
9,172
240
M-kun is a competitor in AtCoder, whose highest rating is X. In this site, a competitor is given a _kyu_ (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given: * From 400 through 599: 8-kyu * From 600 through 799: 7-kyu * From 800 through 999: 6-kyu * From 1000 through 1199: 5-kyu * From 1200 through 1399: 4-kyu * From 1400 through 1599: 3-kyu * From 1600 through 1799: 2-kyu * From 1800 through 1999: 1-kyu What kyu does M-kun have?
def main(): X = int(input()) lst = [i * 200 + 400 for i in range(8)] lst.reverse() print(lst) for i, l in enumerate(lst): if X >= l: print(i+1) break if __name__ == '__main__': main()
s667599814
Accepted
29
9,160
225
def main(): X = int(input()) lst = [i * 200 + 400 for i in range(8)] lst.reverse() for i, l in enumerate(lst): if X >= l: print(i+1) break if __name__ == '__main__': main()
s101166783
p03470
u721425712
2,000
262,144
Wrong Answer
17
3,064
74
An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
N = int(input()) mochi = set(map(int, input().split())) print(len(mochi))
s909923229
Accepted
17
3,060
246
n = int(input()) d = [int(input()) for i in range(n)] num = [0]*101 for i in range(n): num[d[i]] += 1 ans = 0 for i in range(101): if num[i] > 0: ans += 1 print(ans)
s697257611
p03609
u365156087
2,000
262,144
Wrong Answer
26
9,088
25
We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
S = input() print(S[::2])
s337936577
Accepted
29
9,008
61
x,t = map(int, input().split()) print(x-t if x-t >= 0 else 0)
s593524852
p03386
u057993957
2,000
262,144
Wrong Answer
2,223
2,007,064
130
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 = list(map(int, input().split())) x = [i for i in range(a, b+1)] xx = list(set(x[:k] + x[-2:])) for xi in xx: print(xi)
s460835684
Accepted
18
3,060
107
a,b,k=map(int,input().split()) l=range(a,b+1) ans=sorted(set(l[:k])|set(l[-k:])) for i in ans: print(i)
s866326813
p02534
u761087127
2,000
1,048,576
Wrong Answer
29
9,076
22
You are given an integer K. Print the string obtained by repeating the string `ACL` K times and concatenating them. For example, if K = 3, print `ACLACLACL`.
S = input() print(S*3)
s051745586
Accepted
28
9,132
32
K = int(input()) print('ACL'*K)
s239598970
p03598
u923712635
2,000
262,144
Wrong Answer
17
2,940
125
There are N balls in the xy-plane. The coordinates of the i-th of them is (x_i, i). Thus, we have one ball on each of the N lines y = 1, y = 2, ..., y = N. In order to collect these balls, Snuke prepared 2N robots, N of type A and N of type B. Then, he placed the i-th type-A robot at coordinates (0, i), and the i-th type-B robot at coordinates (K, i). Thus, now we have one type-A robot and one type-B robot on each of the N lines y = 1, y = 2, ..., y = N. When activated, each type of robot will operate as follows. * When a type-A robot is activated at coordinates (0, a), it will move to the position of the ball on the line y = a, collect the ball, move back to its original position (0, a) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything. * When a type-B robot is activated at coordinates (K, b), it will move to the position of the ball on the line y = b, collect the ball, move back to its original position (K, b) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything. Snuke will activate some of the 2N robots to collect all of the balls. Find the minimum possible total distance covered by robots.
N = int(input()) K = int(input()) x = [int(x) for x in input().split()] ans = 0 for i in x: ans+=min(abs(K-i),i) print(ans)
s055955288
Accepted
17
2,940
128
N = int(input()) K = int(input()) x = [int(x) for x in input().split()] ans = 0 for i in x: ans+=2*min(abs(K-i),i) print(ans)
s070782220
p03469
u260036763
2,000
262,144
Wrong Answer
17
2,940
43
On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in `yyyy/mm/dd` format. For example, January 23, 2018 should be written as `2018/01/23`. After finishing the document, she noticed that she had mistakenly wrote `2017` at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to `2018` and prints it.
s = input() s.replace('7', '8', 1) print(s)
s223705789
Accepted
17
2,940
33
s = input() print('2018' + s[4:])
s593986765
p03759
u271176141
2,000
262,144
Wrong Answer
29
9,112
242
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()) if b - a == c - b: print("Yes") else: print("No")
s166381392
Accepted
28
9,052
242
a,b,c = map(int,input().split()) if b - a == c - b: print("YES") else: print("NO")
s394529369
p02612
u624455250
2,000
1,048,576
Wrong Answer
27
9,136
24
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.
print(int(input())%1000)
s799772144
Accepted
29
9,092
65
a=int(input()) r=a%1000 if r==0: print(r) else: print(1000-r)
s852834781
p03545
u608088992
2,000
262,144
Wrong Answer
17
3,064
390
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.
def Cal(A, B, op): if op == "+": return A + B else: return A - B Num = input() OP = ["---", "--+", "-+-", "-++", "+--", "+-+", "++-", "+++"] for o in OP: Sum = Cal(int(Num[0]), int(Num[1]), o[0]) Sum = Cal(Sum, int(Num[2]), o[1]) Sum = Cal(Sum, int(Num[3]), o[2]) if Sum == 7: print(Num[0]+o[0]+Num[1]+o[1]+Num[2]+o[2]+Num[3]) break
s316208119
Accepted
17
3,064
616
import sys def solve(): input = sys.stdin.readline Num = list(map(int, list(input().strip("\n")))) for i in range(8): #0: +; 1: - ans = Num[0] d = i toPrint = str(Num[0]) for k in range(3): if d % 2 == 0: ans += Num[k + 1] toPrint += "+" + str(Num[k + 1]) else: ans -= Num[k + 1] toPrint += "-" + str(Num[k + 1]) d //= 2 if ans == 7: toPrint += "=7" print(toPrint) break return 0 if __name__ == "__main__": solve()
s164641345
p03548
u853900545
2,000
262,144
Wrong Answer
17
2,940
51
We have a long seat of width X centimeters. There are many people who wants to sit here. A person sitting on the seat will always occupy an interval of length Y centimeters. We would like to seat as many people as possible, but they are all very shy, and there must be a gap of length at least Z centimeters between two people, and between the end of the seat and a person. At most how many people can sit on the seat?
x,y,z = map(int,input().split()) print(x-z//(y+1))
s021751309
Accepted
17
2,940
53
x,y,z = map(int,input().split()) print((x-z)//(y+z))
s632497453
p02972
u410118019
2,000
1,048,576
Wrong Answer
672
19,200
248
There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N). For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it. We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied: * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2. Does there exist a good set of choices? If the answer is yes, find one good set of choices.
import sys input = sys.stdin.readline n = int(input()) a = tuple(map(int,input().split())) b = [0] * n for i in range(n,0,-1): c = 0 for j in range(2,n//i): c += b[j*i-1] b[i-1] = (a[i-1] - c) % 2 print(sum(b)) print(' '.join(map(str,b)))
s461028957
Accepted
641
19,868
344
import sys input = sys.stdin.readline n = int(input()) a = tuple(map(int,input().split())) b = [0] * n for i in range(n,0,-1): c = 0 for j in range(i,(n//i+1)*i,i): c += b[j-1] if c % 2 == a[i-1]: continue else: b[i-1] = 1 d = [] for i in range(n): if b[i] == 1: d.append(i+1) print(len(d)) print(' '.join(map(str,d)))
s813419515
p02262
u418996726
6,000
131,072
Wrong Answer
20
5,460
1
Shell Sort is a generalization of [Insertion Sort](http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A) to arrange a list of $n$ elements $A$. 1 insertionSort(A, n, g) 2 for i = g to n-1 3 v = A[i] 4 j = i - g 5 while j >= 0 && A[j] > v 6 A[j+g] = A[j] 7 j = j - g 8 cnt++ 9 A[j+g] = v 10 11 shellSort(A, n) 12 cnt = 0 13 m = ? 14 G[] = {?, ?,..., ?} 15 for i = 0 to m-1 16 insertionSort(A, n, G[i]) A function shellSort(A, n) performs a function insertionSort(A, n, g), which considers every $g$-th elements. Beginning with large values of $g$, it repeats the insertion sort with smaller $g$. Your task is to complete the above program by filling ?. Write a program which reads an integer $n$ and a sequence $A$, and prints $m$, $G_i (i = 0, 1, ..., m − 1)$ in the pseudo code and the sequence $A$ in ascending order. The output of your program must meet the following requirements: * $1 \leq m \leq 100$ * $0 \leq G_i \leq n$ * cnt does not exceed $\lceil n^{1.5}\rceil$
s192692976
Accepted
13,640
45,508
778
def insertionSort(arr,step): count = 0 for i in range(step, len(arr)): j = i while j >= step and arr[j] < arr[j-step]: count += 1 t = arr[j] arr[j] = arr[j-step] arr[j-step] = t j -= step return count def shellSort(arr): gaps = [776591, 345152, 153401, 68178, 30301, 13467, 5985, 2660, 1182, 525, 233, 103, 46, 20, 9, 4, 1] m = 0 count = 0 for step in gaps: if step > len(arr): continue m += 1 count += insertionSort(arr, step) print(m) print(" ".join(map(str, gaps[len(gaps)-m:]))) print(count) for num in arr: print(num) arr = list() for _ in range(int(input())): arr.append(int(input())) shellSort(arr)
s033739151
p02534
u601508807
2,000
1,048,576
Wrong Answer
24
9,136
23
You are given an integer K. Print the string obtained by repeating the string `ACL` K times and concatenating them. For example, if K = 3, print `ACLACLACL`.
k=int(input()) print(k)
s833187701
Accepted
28
9,152
101
k=int(input()) list=[str("ACL")]*k ans = str() for i in range(k): ans = ans+str(list[i]) print(ans)
s406515558
p03973
u045939752
2,000
262,144
Wrong Answer
202
7,080
160
N people are waiting in a single line in front of the Takahashi Store. The cash on hand of the i-th person from the front of the line is a positive integer A_i. Mr. Takahashi, the shop owner, has decided on the following scheme: He picks a product, sets a positive integer P indicating its price, and shows this product to customers in order, starting from the front of the line. This step is repeated as described below. At each step, when a product is shown to a customer, if price P is equal to or less than the cash held by that customer at the time, the customer buys the product and Mr. Takahashi ends the current step. That is, the cash held by the first customer in line with cash equal to or greater than P decreases by P, and the next step begins. Mr. Takahashi can set the value of positive integer P independently at each step. He would like to sell as many products as possible. However, if a customer were to end up with 0 cash on hand after a purchase, that person would not have the fare to go home. Customers not being able to go home would be a problem for Mr. Takahashi, so he does not want anyone to end up with 0 cash. Help out Mr. Takahashi by writing a program that determines the maximum number of products he can sell, when the initial cash in possession of each customer is given.
N = int(input()) A = [ int(input()) for _ in range(N) ] ans = 0 m = 0 for a in A: if a == m+1: m = m + 1 else: ans += (a - 1) // (m+1) print(ans)
s108219939
Accepted
213
7,080
213
N = int(input()) A = [ int(input()) for _ in range(N) ] ans = 0 m = 1 for i,a in enumerate(A): if i == 0: ans += a-1 m = 1 elif a == m+1: m = m + 1 else: ans += (a - 1) // (m+1) print(ans)
s165446955
p02690
u594803920
2,000
1,048,576
Wrong Answer
142
21,208
139
Give a pair of integers (A, B) such that A^5-B^5 = X. It is guaranteed that there exists such a pair for the given integer X.
x = int(input()) d = {} for a in range(-200, 200): for b in range(-200, 200): k = a**5 - b**5 d[k] = (a, b) print(d[x])
s589382531
Accepted
162
22,476
140
x = int(input()) d = {} for a in range(-200, 200): for b in range(-200, 200): k = a**5 - b**5 d[k] = [a, b] print(*d[x])
s100360744
p02390
u445380745
1,000
131,072
Wrong Answer
30
7,520
111
Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
S = int(input()) h = S / 3600 m = S % 3600 / 60 s = S % 3600 % 60 print(str(h) + ':' + str(m) + ':' + str(s))
s640405575
Accepted
20
7,592
113
S = int(input()) h = S // 3600 m = S % 3600 // 60 s = S % 3600 % 60 print(str(h) + ':' + str(m) + ':' + str(s))
s783174607
p02602
u933650305
2,000
1,048,576
Wrong Answer
76
31,492
222
M-kun is a student in Aoki High School, where a year is divided into N terms. There is an exam at the end of each term. According to the scores in those exams, a student is given a grade for each term, as follows: * For the first through (K-1)-th terms: not given. * For each of the K-th through N-th terms: the multiplication of the scores in the last K exams, including the exam in the graded term. M-kun scored A_i in the exam at the end of the i-th term. For each i such that K+1 \leq i \leq N, determine whether his grade for the i-th term is **strictly** greater than the grade for the (i-1)-th term.
a = list(map(int,input().split())) b = list(map(int,input().split())) for v in range(a[1]-a[0]): c=list(map(numpy.prod.b[0+v:a[0]+v])) for m in range(a[1]-a[0]): if c[m+1]>c[m]: print("Yes") else: print("No")
s186350454
Accepted
140
31,604
143
N,K=map(int,input().split()) a=list(map(int,input().split())) for v in range(N-K): if a[v]>=a[K+v]: print("No") else: print("Yes")
s327620883
p02612
u169678167
2,000
1,048,576
Wrong Answer
33
9,148
76
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.
from sys import stdin input = stdin.readline N = int(input()) print(N%1000)
s362062921
Accepted
31
9,152
132
from sys import stdin input = stdin.readline N = int(input()) if (1000- N%1000) != 1000: print(1000- N%1000) else: print(0)
s820542224
p02612
u401086905
2,000
1,048,576
Wrong Answer
32
9,128
33
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
N = int(input()) print( N%100 )
s186459092
Accepted
32
9,152
92
N = int(input()) for i in range(0, 10001, 1000): if N <= i: break print( i-N )
s364057064
p03836
u077291787
2,000
262,144
Wrong Answer
17
3,064
366
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.
# ABC051C - Back and Forth def main(): sx, sy, tx, ty = list(map(int, input().rstrip().split())) X, Y = abs(sx - tx), abs(sy - ty) move = "" move += "U" * X + "R" * Y + "D" * X + "L" * Y move += "L" + "U" * (X + 1) + "R" * (Y + 1) + "D" move += "R" + "D" * (Y + 1) + "L" * (X + 1) + "U" print(move) if __name__ == "__main__": main()
s735710849
Accepted
17
3,064
366
# ABC051C - Back and Forth def main(): sx, sy, tx, ty = list(map(int, input().rstrip().split())) X, Y = abs(sx - tx), abs(sy - ty) move = "" move += "U" * Y + "R" * X + "D" * Y + "L" * X move += "L" + "U" * (Y + 1) + "R" * (X + 1) + "D" move += "R" + "D" * (Y + 1) + "L" * (X + 1) + "U" print(move) if __name__ == "__main__": main()
s787698260
p03090
u902576227
2,000
1,048,576
Wrong Answer
23
3,336
389
You are given an integer N. Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions: * The graph is simple and connected. * There exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is S. It can be proved that at least one such graph exists under the constraints of this problem.
n = int(input()) if n % 2 == 0: # 1 <-> n, 2 <-> n-1... is Pair for i in range(1, n + 1): for j in range(i + 1, n + 1): if i + j != n + 1: print(str(i) + " " + str(j)) else: # Each edge has (sum - N) for i in range(1, n + 1): for j in range(i + 1, n + 1): if i + j != n: print(str(i) + " " + str(j))
s147716175
Accepted
23
3,336
453
n = int(input()) if n % 2 == 0: # 1 <-> n, 2 <-> n-1... is Pair print(int(n*(n-1)/2-n/2)) for i in range(1, n + 1): for j in range(i + 1, n + 1): if i + j != n + 1: print(str(i) + " " + str(j)) else: # Each edge has (sum - N) print(int(n*(n-1)/2-(n-1)/2)) for i in range(1, n + 1): for j in range(i + 1, n + 1): if i + j != n: print(str(i) + " " + str(j))
s864611495
p03131
u278260569
2,000
1,048,576
Wrong Answer
17
3,060
277
Snuke has one biscuit and zero Japanese yen (the currency) in his pocket. He will perform the following operations exactly K times in total, in the order he likes: * Hit his pocket, which magically increases the number of biscuits by one. * Exchange A biscuits to 1 yen. * Exchange 1 yen to B biscuits. Find the maximum possible number of biscuits in Snuke's pocket after K operations.
K,A,B = map(int,input().split()) if A+2 >= B: print(1+K) elif K <= A: print(1+K) else: new_K = K-A print(new_K) if new_K % 2 == 1: temp_K = int((new_K+1)/2) print(temp_K) print(int(temp_K*B - (temp_K-1)*A)) else: print(int((new_K/2)*B - ((new_K/2)-1)*A + 1))
s387928778
Accepted
17
3,060
264
K,A,B = map(int,input().split()) if A+2 >= B: print(1+K) elif K <= A: print(1+K) else: new_K = K-A if new_K % 2 == 1: temp_K = int((new_K+1)/2) print((temp_K*B - (temp_K-1)*A)) else: temp_K = int(new_K/2) print((int(temp_K*B - (temp_K-1)*A + 1)))
s458805053
p03548
u428397309
2,000
262,144
Wrong Answer
18
2,940
92
We have a long seat of width X centimeters. There are many people who wants to sit here. A person sitting on the seat will always occupy an interval of length Y centimeters. We would like to seat as many people as possible, but they are all very shy, and there must be a gap of length at least Z centimeters between two people, and between the end of the seat and a person. At most how many people can sit on the seat?
# -*- coding: utf-8 -*- X, Y, Z = map(int, input().split()) ans = (X + Z) // Y print(ans)
s468772038
Accepted
18
3,064
98
# -*- coding: utf-8 -*- X, Y, Z = map(int, input().split()) ans = (X - Z) // (Y + Z) print(ans)
s306082336
p03474
u652737716
2,000
262,144
Wrong Answer
21
3,188
105
The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`. You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.
import re match = re.match('^[0-9]{3}-[0-9]{4}$', input()) if match: print('Yes') else: print('No')
s979554081
Accepted
23
3,188
129
import re A, B = [x for x in input().split()] print('Yes' if re.match('^[0-9]{' + A + '}-[0-9]{' + B + '}$', input()) else 'No')
s776604930
p03399
u129801138
2,000
262,144
Wrong Answer
17
2,940
69
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 = [int(input()) for i in range(4)] print(min(a[0:1]) + min(a[2:3]))
s237509603
Accepted
20
3,316
69
a = [int(input()) for i in range(4)] print(min(a[0:2]) + min(a[2:4]))
s919346850
p00031
u197615397
1,000
131,072
Wrong Answer
20
5,612
126
祖母が天秤を使っています。天秤は、二つの皿の両方に同じ目方のものを載せると釣合い、そうでない場合には、重い方に傾きます。10 個の分銅の重さは、軽い順に 1g, 2g, 4g, 8g, 16g, 32g, 64g, 128g, 256g, 512g です。 祖母は、「1kg くらいまでグラム単位で量れるのよ。」と言います。「じゃあ、試しに、ここにあるジュースの重さを量ってよ」と言ってみると、祖母は左の皿にジュースを、右の皿に 8g と64g と128g の分銅を載せて釣合わせてから、「分銅の目方の合計は 200g だから、ジュースの目方は 200g ね。どう、正しいでしょう?」と答えました。 左の皿に載せる品物の重さを与えるので、天秤で与えられた重みの品物と釣合わせるときに、右の皿に載せる分銅を軽い順に出力するプログラムを作成して下さい。ただし、量るべき品物の重さは、すべての分銅の重さの合計 (=1023g) 以下とします。
import sys print("\n".join((" ".join(str(2**i)for i, n in enumerate(bin(int(s))[:1:-1])if n)for s in sys.stdin.readlines())))
s822904141
Accepted
20
5,608
131
import sys print("\n".join((" ".join(str(2**i)for i, n in enumerate(bin(int(s))[:1:-1])if n=="1")for s in sys.stdin.readlines())))
s437902092
p03853
u174603263
2,000
262,144
Wrong Answer
18
3,064
223
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).
import sys import math input = sys.stdin.readline h, w = map(int, input().rstrip().split()) pic = list(input().rstrip().split() for _ in range(h)) print(pic) for i in range(h): print(pic[i][0]) print(pic[i][0])
s731345127
Accepted
18
3,060
213
import sys import math input = sys.stdin.readline h, w = map(int, input().rstrip().split()) pic = list(input().rstrip().split() for _ in range(h)) for i in range(h): print(pic[i][0]) print(pic[i][0])
s022996922
p03415
u239301277
2,000
262,144
Wrong Answer
17
2,940
57
We have a 3×3 square grid, where each square contains a lowercase English letters. The letter in the square at the i-th row from the top and j-th column from the left is c_{ij}. Print the string of length 3 that can be obtained by concatenating the letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right.
a=input() b=input() c=input() print('a[0]'+'b[1]'+'c[2]')
s907083191
Accepted
17
2,940
51
a=input() b=input() c=input() print(a[0]+b[1]+c[2])
s976695838
p02678
u366963613
2,000
1,048,576
Wrong Answer
2,217
328,928
738
There is a cave. The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside. It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage. Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1. * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible. Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
# -*- coding: utf-8 -*- import numpy as np from collections import deque import collections import heapq n, m = list(map(int, input().split())) a = [0] * m b = [0] * m path = [[] for i in range(n+1)] for i in range(m): # a[i], b[i] = list(map(int, input().split())) a, b = list(map(int, input().split())) path[a].append(b) path[b].append(a) ans = [0]*(n+1) visited = [1] que = deque([[1, 1]]) now = 1 prev = 1 # BFS while len(visited) != n: for can_go in path[now]: que.append([can_go, now]) now, prev = que.popleft() if (now in visited): continue ans[now] = prev visited.append(now) for _ans in ans[2:]: print(_ans)
s739125411
Accepted
858
61,584
1,009
# -*- coding: utf-8 -*- import numpy as np from collections import deque import collections import heapq n, m = list(map(int, input().split())) a = [0] * m b = [0] * m path = [[] for i in range(n+1)] for i in range(m): # a[i], b[i] = list(map(int, input().split())) a, b = list(map(int, input().split())) path[a].append(b) path[b].append(a) # start = time.time() ans = [0]*(n+1) visited = [] que = deque([[1, 1]]) que_items = set([1]) # BFS while len(que) > 0: now, prev = que.popleft() # print('pop', now) for can_go in path[now]: if(not (can_go in que_items)): # print('push', can_go) que.append([can_go, now]) que_items.add(can_go) ans[now] = prev visited.append(now) # print(visited) if (len(visited) != n): print('No') else: print('Yes') for _ans in ans[2:]: print(_ans) # print(time.time() - start)
s344002361
p03739
u212831449
2,000
262,144
Wrong Answer
123
14,464
697
You are given an integer sequence of length N. The i-th term in the sequence is a_i. In one operation, you can select a term and either increment or decrement it by one. At least how many operations are necessary to satisfy the following conditions? * For every i (1≤i≤n), the sum of the terms from the 1-st through i-th term is not zero. * For every i (1≤i≤n-1), the sign of the sum of the terms from the 1-st through i-th term, is different from the sign of the sum of the terms from the 1-st through (i+1)-th term.
n = int(input()) s = list(map(int,input().split())) temp = s[0] ans = 0 if temp > 0: for i in range(1,n): temp += s[i] if i%2 == 0: if temp <= 0: ans += abs(temp-1) temp = 1 else: if temp >= 0: ans += abs(temp+1) temp = -1 if temp < 0: for i in range(1,n): temp += s[i] if i%2 == 0: if temp >= 0: ans += abs(temp+1) temp = -1 else: if temp <= 0: ans += abs(temp-1) temp = 1 print(ans)
s641631903
Accepted
122
14,468
599
n = int(input()) s = list(map(int,input().split())) temp = 0 cand1 = 0 for i in range(n): temp += s[i] if i%2 == 0: if temp <= 0: cand1 += abs(temp-1) temp = 1 else: if temp >= 0: cand1 += abs(temp+1) temp = -1 temp = 0 cand2 = 0 for i in range(n): temp += s[i] if i%2 == 0: if temp >= 0: cand2 += abs(temp+1) temp = -1 else: if temp <= 0: cand2 += abs(temp-1) temp = 1 print(min(cand2,cand1))
s885304864
p02392
u534156032
1,000
131,072
Wrong Answer
30
7,600
116
Write a program which reads three integers a, b and c, and prints "Yes" if a < b < c, otherwise "No".
# coding: utf-8 a,b,c = [int(i) for i in input().split()] if a < b and b < c: print("YES") else: print("NO")
s941871911
Accepted
20
7,732
116
# coding: utf-8 a,b,c = [int(i) for i in input().split()] if a < b and b < c: print("Yes") else: print("No")
s357116021
p03623
u694370915
2,000
262,144
Wrong Answer
20
2,940
153
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|.
def main(): x, a, b = map(int, input().split()) if abs(a-x) > abs(b-x): print('A') return print('B') if __name__ == '__main__': main()
s660320327
Accepted
17
2,940
153
def main(): x, a, b = map(int, input().split()) if abs(a-x) > abs(b-x): print('B') return print('A') if __name__ == '__main__': main()
s449709195
p03470
u367130284
2,000
262,144
Wrong Answer
18
2,940
42
An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
print(len(set(open(0).readlines()[1:-1])))
s431320965
Accepted
17
2,940
40
print(len(set(open(0).readlines()[1:])))
s365477467
p03997
u630027862
2,000
262,144
Time Limit Exceeded
2,104
3,064
472
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.
S_A, S_B, S_C = [list(input()) for i in range(3)] S = S_A[0] while True: if S == 'a': if len(S_A) == 0: break else: S == S_A.pop(0) elif S == 'b': if len(S_B) == 0: break else: S = S_B.pop(0) elif S == 'c': if len(S_C) == 0: break else: S == S_C.pop(0) if S == 'a': print('A') elif S == 'b': print('B') elif S == 'c': print('C')
s343812548
Accepted
17
2,940
82
a, b, h = [int(input()) for i in range(3)] S = (a + b) * h / 2 S = int(S) print(S)
s304148190
p03377
u317785246
2,000
262,144
Wrong Answer
17
2,940
104
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 and a + b >= x: print("Yes") else: print("No")
s081282596
Accepted
17
2,940
104
a, b, x = map(int, input().split()) if a <= x and a + b >= x: print("YES") else: print("NO")
s920184326
p02614
u747703115
1,000
1,048,576
Wrong Answer
150
9,384
701
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.
from copy import deepcopy h, w, k = map(int, input().split()) C = [['']*w for _ in range(h)] for i in range(h): C[i] = list(input()) ans = 0 for i in range(2**h-1): for j in range(2**w-1): _C = deepcopy(C) H = bin(i)[2:].zfill(h) W = bin(j)[2:].zfill(w) for _k,_h in enumerate(H): if _h == '1': for _w in range(w): _C[_k][_w] = 'x' for _k,_w in enumerate(W): if _w == '1': for _h in range(h): _C[_h][_k] = 'x' tmp = [] _ = [tmp.extend(c) for c in _C] if tmp.count('#')==k: ans += 1 print(i,j,tmp,ans) print(ans)
s077864469
Accepted
136
9,348
674
from copy import deepcopy h, w, k = map(int, input().split()) C = [['']*w for _ in range(h)] for i in range(h): C[i] = list(input()) ans = 0 for i in range(2**h-1): for j in range(2**w-1): _C = deepcopy(C) H = bin(i)[2:].zfill(h) W = bin(j)[2:].zfill(w) for _k,_h in enumerate(H): if _h == '1': for _w in range(w): _C[_k][_w] = 'x' for _k,_w in enumerate(W): if _w == '1': for _h in range(h): _C[_h][_k] = 'x' tmp = [] _ = [tmp.extend(c) for c in _C] if tmp.count('#')==k: ans += 1 print(ans)
s180311469
p02694
u161857931
2,000
1,048,576
Wrong Answer
24
9,152
89
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()) c = 100 y = 0 while c <= X : c = int(c * 1.01) y += 1 print(y)
s872937768
Accepted
22
9,160
88
X = int(input()) c = 100 y = 0 while c < X : c = int(c * 1.01) y += 1 print(y)
s773417488
p03720
u146575240
2,000
262,144
Wrong Answer
18
3,064
420
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?
# B - Counting Roads N, M = map(int,input().split()) city = [list(map(int, input().split())) for i in range(M)] road = [0]*N for i in range(N): count = 0 for j in range(M): if i+1 == city[j][0]: count += 1 else: pass if i+1 == city[j][1]: count += 1 else: pass road[i] = count print(road) for k in range(N): print(road[k])
s412041819
Accepted
18
3,060
408
# B - Counting Roads N, M = map(int,input().split()) city = [list(map(int, input().split())) for i in range(M)] road = [0]*N for i in range(N): count = 0 for j in range(M): if i+1 == city[j][0]: count += 1 else: pass if i+1 == city[j][1]: count += 1 else: pass road[i] = count for k in range(N): print(road[k])
s008397700
p03759
u716660050
2,000
262,144
Wrong Answer
17
2,940
67
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('YES' if b-c == c-b else 'NO')
s267789209
Accepted
18
2,940
67
a,b,c=map(int,input().split()) print('YES' if b-a == c-b else 'NO')
s736128569
p03548
u164261323
2,000
262,144
Wrong Answer
17
2,940
48
We have a long seat of width X centimeters. There are many people who wants to sit here. A person sitting on the seat will always occupy an interval of length Y centimeters. We would like to seat as many people as possible, but they are all very shy, and there must be a gap of length at least Z centimeters between two people, and between the end of the seat and a person. At most how many people can sit on the seat?
x,y,z = map(int,input().split()) print(x-z//y+z)
s504211327
Accepted
29
2,940
52
x,y,z = map(int,input().split()) print((x-z)//(y+z))
s264819308
p02265
u091533407
1,000
131,072
Wrong Answer
20
7,620
572
Your task is to implement a double linked list. Write a program which performs the following operations: * insert x: insert an element with key x into the front of the list. * delete x: delete the first element which has the key of x from the list. If there is not such element, you need not do anything. * deleteFirst: delete the first element from the list. * deleteLast: delete the last element from the list.
# -*- coding: utf-8 -*- """ Created on Wed Jun 21 08:50:28 2017 @author: syaga """ COMMAND = ["insert", "delete", "deleteFirst", "deleteLast"] if __name__ == "__main__": n = int(input()) com = [] for i in range(n): com.append(input().split()) print(com) ans = [] for i in com: if i[0] == COMMAND[0]: ans.insert(0, i[1]) elif i[0] == COMMAND[1]: ans.remove(i[1]) elif i[0] == COMMAND[2]: ans.pop(0) elif i[0] == COMMAND[3]: ans.pop() print(" ".join(ans))
s186000152
Accepted
1,930
214,316
601
# -*- coding: utf-8 -*- from collections import deque import sys COMMAND = ("insert", "delete", "deleteFirst", "deleteLast") if __name__ == "__main__": n = int(sys.stdin.readline()) ans = deque() inp = sys.stdin.readlines() for i in range(n): com = inp[i].split() if com[0] == COMMAND[0]: ans.appendleft(com[1]) elif com[0] == COMMAND[1]: if com[1] in ans: ans.remove(com[1]) elif com[0] == COMMAND[2]: ans.popleft() elif com[0] == COMMAND[3]: ans.pop() print(" ".join(ans))
s973852361
p03624
u996564551
2,000
262,144
Wrong Answer
40
9,108
182
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.
S = input() alp = list('abcdefghijklmnopqrstuvwxyz') print(alp) for i in range(len(S)): if S[i] in alp: alp.remove(S[i]) if len(alp) == 0: print('None') else: print(alp[0])
s636435845
Accepted
39
9,208
171
S = input() alp = list('abcdefghijklmnopqrstuvwxyz') for i in range(len(S)): if S[i] in alp: alp.remove(S[i]) if len(alp) == 0: print('None') else: print(alp[0])
s610634971
p03380
u867848444
2,000
262,144
Wrong Answer
104
14,060
240
Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted.
n = int(input()) a = list(map(int,input().split())) a = sorted(a, reverse = True) ai = a[0] // 2 aj = 0 comb = 10 ** 10 for i in range(n): temp = abs(a[i] - ai) if comb >= temp: comb = temp aj = a[i] print(a[0], aj)
s376258686
Accepted
114
14,428
239
n = int(input()) a = list(map(int,input().split())) a = sorted(a, reverse = True) ai = a[0] / 2 aj = 0 comb = 10 ** 10 for i in range(n): temp = abs(a[i] - ai) if comb >= temp: comb = temp aj = a[i] print(a[0], aj)
s100161667
p03457
u350179603
2,000
262,144
Wrong Answer
341
3,060
230
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
n = int(input()) cnt = 0 for i in range(n): t, x, y = map(int, input().split()) if t >= x+y and t%2 == (x+y)%2: cnt += 1 else: print("No") break
s188038465
Accepted
448
11,840
607
n = int(input()) cnt = 0 t = [] x = [] y = [] for i in range(n): ttmp, xtmp, ytmp = map(int, input().split()) t.append(ttmp) x.append(xtmp) y.append(ytmp) for i in range(n): if i == 0: if t[i] >= x[i]+y[i] and (t[i])%2 == (x[i]+y[i])%2: cnt += 1 else: print("No") break else: if t[i] >= x[i]+y[i] and (t[i])%2 == (x[i]+y[i])%2 and x[i]+y[i]-x[i-1]-y[i-1] <= t[i]-t[i-1] : cnt += 1 else: print("No") break if cnt == n: print("Yes")
s261624434
p02469
u837811962
1,000
131,072
Wrong Answer
30
7,660
238
Find the least common multiple (LCM) of given n integers.
def GCD(x,y): r = x%y if r == 0: return y else: return GCD(y,r) n = int(input()) list1 = list(map(int,input().split())) result = list1[0] for i in list1[1:]: result = result*i/GCD(i,result) print(result)
s974684925
Accepted
30
7,664
243
def GCD(x,y): r = x%y if r == 0: return y else: return GCD(y,r) n = int(input()) list1 = list(map(int,input().split())) result = list1[0] for i in list1[1:]: result = result*i/GCD(i,result) print(int(result))
s776944677
p02612
u697502900
2,000
1,048,576
Wrong Answer
29
9,140
24
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.
print(int(input())%1000)
s757069416
Accepted
28
9,144
78
n = int(input()) if n % 1000 == 0: print(0) else: print(1000-n%1000)
s196828121
p03623
u383450070
2,000
262,144
Wrong Answer
17
2,940
60
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(min(abs(x-a),abs(x-b)))
s757229870
Accepted
17
2,940
71
x,a,b=map(int,input().split()) print("A" if abs(x-a)<abs(x-b) else "B")
s587915764
p03577
u504715104
2,000
262,144
Wrong Answer
18
2,940
47
Rng is going to a festival. The name of the festival is given to you as a string S, which ends with `FESTIVAL`, from input. Answer the question: "Rng is going to a festival of what?" Output the answer. Here, assume that the name of "a festival of s" is a string obtained by appending `FESTIVAL` to the end of s. For example, `CODEFESTIVAL` is a festival of `CODE`.
x=input() y='FESTIVAL' print(x.rstrip(y))
s015261121
Accepted
19
2,940
41
x=input() y='FESTIVAL' print(x[:-8])
s914463378
p03524
u572373398
2,000
262,144
Wrong Answer
27
3,444
607
Snuke has a string S consisting of three kinds of letters: `a`, `b` and `c`. He has a phobia for palindromes, and wants to permute the characters in S so that S will not contain a palindrome of length 2 or more as a substring. Determine whether this is possible.
from collections import Counter s = input() c = Counter(s) if len(c) == 1: print('No') elif len(c) == 2: sort_ = sorted(c.items(), key=lambda x:x[1]) if sort_[0][1] == sort_[1][1]: print('Yes') else: print('No') else: sort_ = sorted(c.items(), key=lambda x: x[1], reverse = True) if sort_[0][1] - (sort_[1][1] + sort_[2][1]) > 1: print('No') else: print('Yes')
s195677637
Accepted
25
3,444
196
from collections import Counter s = input() c = Counter(s) x = abs(c['a'] - c['b']) y = abs(c['a'] - c['c']) z = abs(c['b'] - c['c']) if max(x, y, z) < 2: print('YES') else: print('NO')
s498061669
p03712
u778700306
2,000
262,144
Wrong Answer
18
2,940
125
You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}. Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1.
h,w=map(int,input().split()) print('*' * (w + 2)) for _ in range(h): print("*" + input() + "*") print('*' * (w + 2))
s434179331
Accepted
18
3,060
125
h,w=map(int,input().split()) print('#' * (w + 2)) for _ in range(h): print("#" + input() + "#") print('#' * (w + 2))
s071648548
p02743
u833070958
2,000
1,048,576
Wrong Answer
17
2,940
99
Does \sqrt{a} + \sqrt{b} < \sqrt{c} hold?
a, b, c = map(int, input().split()) if a * b < (c - a - b) ** 2: print("Yes") else: print("No")
s847265516
Accepted
18
2,940
118
a, b, c = map(int, input().split()) if c >= a + b and 4 * a * b < (c - a - b) ** 2: print("Yes") else: print("No")
s350954803
p03695
u202570162
2,000
262,144
Wrong Answer
17
3,064
236
In AtCoder, a person who has participated in a contest receives a _color_ , which corresponds to the person's rating as follows: * Rating 1-399 : gray * Rating 400-799 : brown * Rating 800-1199 : green * Rating 1200-1599 : cyan * Rating 1600-1999 : blue * Rating 2000-2399 : yellow * Rating 2400-2799 : orange * Rating 2800-3199 : red Other than the above, a person whose rating is 3200 or higher can freely pick his/her color, which can be one of the eight colors above or not. Currently, there are N users who have participated in a contest in AtCoder, and the i-th user has a rating of a_i. Find the minimum and maximum possible numbers of different colors of the users.
N=int(input()) A=[int(i) for i in input().split()] col=[0 for i in range(8)] fre=0 for a in A: if a<3200: col[a//400]+=1 else: fre+=1 ans=0 # print(col) for c in col: if c>0: ans+=1 ans+=fre print(ans if ans<=8 else 8)
s081540389
Accepted
17
3,064
264
N=int(input()) A=[int(i) for i in input().split()] col=[0 for i in range(9)] for a in A: if a<3200: col[a//400]+=1 else: col[-1]+=1 ans=0 # print(col) for i in range(8): if col[i]>0: ans+=1 MIN=1 if ans==0 else ans MAX=ans+col[-1] print(MIN,MAX)
s565227765
p04043
u966695411
2,000
262,144
Wrong Answer
36
3,064
90
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.
L = map(int, input().split()) print("YES" if 5 in L and 7 in L and sum(L) == 17 else "NO")
s765521258
Accepted
40
3,064
96
L = list(map(int, input().split())) print("YES" if 5 in L and 7 in L and sum(L) == 17 else "NO")
s616401503
p03369
u894694822
2,000
262,144
Wrong Answer
19
3,060
39
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.
l=list(input()) print(700+l.count("o"))
s501093959
Accepted
17
2,940
46
l=list(input()) print(700+(l.count("o"))*100)
s245454366
p03861
u851648783
2,000
262,144
Wrong Answer
17
3,064
95
You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x?
abx = input().split() a, b, x = int(abx[0]), int(abx[1]), int(abx[2]) print(int(b/x - (a-1)/x))
s748479455
Accepted
17
2,940
102
abx = input().split() a, b, x = int(abx[0]), int(abx[1]), int(abx[2]) print(int(b//x) - int((a-1)//x))
s802953525
p03069
u679759899
2,000
1,048,576
Wrong Answer
2,104
3,816
219
There are N stones arranged in a row. Every stone is painted white or black. A string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is `.`, and the stone is black if the character is `#`. Takahashi wants to change the colors of some stones to black or white so that there will be no white stone immediately to the right of a black stone. Find the minimum number of stones that needs to be recolored.
n = int(input()) s = input() _min = float('inf') for i in range(n+1): ss = '.'*i + '#' * (n-i) t = 0 for j in range(n): if (s[j]) != ss[j]: t+=1 if _min > t: _min = t print(t)
s974810751
Accepted
113
3,500
168
n = int(input()) s = input() b = 0 w = 0 for i in range(n): if s[i] == '.': b = min(b,w) + 1 else: b = min(b, w) w += 1 print(min(b, w))
s903060144
p02646
u106095117
2,000
1,048,576
Wrong Answer
24
9,112
207
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()) distance = abs(a - b) distance_t = (w * t) - (v * t) if distance + distance_t <= 0: print('Yes') else: print('No')
s965176047
Accepted
23
9,204
207
a, v = map(int, input().split()) b, w = map(int, input().split()) t = int(input()) distance = abs(a - b) distance_t = (v * t) - (w * t) if distance - distance_t <= 0: print('YES') else: print('NO')
s134974494
p04043
u088488125
2,000
262,144
Wrong Answer
23
9,024
181
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
a,b,c=map(int, input().split()) if a==5 and b==5 and c==7: print("Yes") elif a==5 and b==7 and c==5: print("Yes") elif a==7 and b==5 and c==5: print("Yes") else: print("No")
s835498311
Accepted
24
9,036
181
a,b,c=map(int, input().split()) if a==5 and b==5 and c==7: print("YES") elif a==5 and b==7 and c==5: print("YES") elif a==7 and b==5 and c==5: print("YES") else: print("NO")
s753249822
p03470
u033719192
2,000
262,144
Wrong Answer
19
2,940
53
An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
input() D = list(input().split()) print(len(set(D)))
s245797449
Accepted
17
3,060
68
N = int(input()) D = [input() for _ in range(N)] print(len(set(D)))
s631285887
p03693
u358360701
2,000
262,144
Wrong Answer
17
2,940
102
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
r,g,b = map(int, input().split()) if (g*10 + b) % 4 == 0: print("yes") else: print("no")
s647491894
Accepted
17
2,940
102
r,g,b = map(int, input().split()) if (g*10 + b) % 4 == 0: print("YES") else: print("NO")