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
s101352337
p03962
u767664985
2,000
262,144
Wrong Answer
17
2,940
30
AtCoDeer the deer recently bought three paint cans. The color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c. Here, the color of each paint can is represented by an integer between 1 and 100, inclusive. Since he is forgetful, he migh...
print(len(set(list(input()))))
s044069166
Accepted
17
2,940
48
print(len(set(list(map(int, input().split())))))
s823494839
p03380
u813387707
2,000
262,144
Wrong Answer
85
14,052
384
Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted.
from bisect import bisect_left n = int(input()) a_list = sorted([int(x) for x in input().split()]) base = a_list[-1] // 2 i = bisect_left(a_list, base) if i > 0: i -= 1 ans = [a_list[-1], a_list[i], abs(a_list[i] - base)] for i in range(i + 1, n): temp = abs(a_list[i] - base) if temp >= ans[2]: brea...
s764801706
Accepted
82
14,052
383
from bisect import bisect_left n = int(input()) a_list = sorted([int(x) for x in input().split()]) base = a_list[-1] / 2 i = bisect_left(a_list, base) if i > 0: i -= 1 ans = [a_list[-1], a_list[i], abs(a_list[i] - base)] for i in range(i + 1, n): temp = abs(a_list[i] - base) if temp >= ans[2]: break...
s759999270
p03474
u896791216
2,000
262,144
Wrong Answer
17
3,060
354
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.
nums = "1234567890" a, b = map(int, input().split()) s = input() ok_flg = True for i in range(a): if s[i] not in nums: ok_flg = False break print(s[a]) if s[a] != "-": ok_flg = False for j in range(b): if s[a + 1 + j] not in nums: ok_flg = False break if ok_flg == True: p...
s579524628
Accepted
18
3,060
342
nums = "1234567890" a, b = map(int, input().split()) s = input() ok_flg = True for i in range(a): if s[i] not in nums: ok_flg = False break if s[a] != "-": ok_flg = False for j in range(b): if s[a + 1 + j] not in nums: ok_flg = False break if ok_flg == True: print("Yes") ...
s698058803
p04000
u866746776
3,000
262,144
Wrong Answer
3,165
84,728
448
We have a grid with H rows and W columns. At first, all cells were painted white. Snuke painted N of these cells. The i-th ( 1 \leq i \leq N ) cell he painted is the cell at the a_i-th row and b_i-th column. Compute the following: * For each integer j ( 0 \leq j \leq 9 ), how many subrectangles of size 3×3 of the ...
from collections import Counter h, w, n = [int(i) for i in input().split()] cnt = Counter() vs = [] for i in range(-1, 2): for j in range(-1, 2): vs.append((i,j)) print(list(vs)) for _ in range(n): a, b = [int(i) for i in input().split()] for v in vs: aa = a + v[0] bb = b + v[1] if 2<=aa<=h-1 and 2<=bb<=w-...
s718299667
Accepted
2,986
119,920
469
from collections import Counter h, w, n = [int(i) for i in input().split()] vs = [] for i in range(-1, 2): for j in range(-1, 2): vs.append((i,j)) cnt = [] for _ in range(n): a, b = [int(i) for i in input().split()] for v in vs: aa = a + v[0] bb = b + v[1] if 2<=aa<=(h-1) and 2<=bb<=(w-1): cnt.append(aa*...
s487876692
p03379
u219607170
2,000
262,144
Wrong Answer
2,104
25,224
119
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, .....
N = int(input()) X = list(map(int, input().split())) X.sort() for i in range(N): print((X[:i] + X[i+1:])[(N-1)//2])
s676210749
Accepted
308
25,472
256
N = int(input()) X = list(map(int, input().split())) Y = sorted(X) l, r = Y[N//2-1], Y[N//2] A = [] for i in range(N): if X[i] <= l: print(r) # A.append(r) else: print(l) # A.append(l) # print('\n'.join(map(str, A)))
s084401583
p03485
u545503667
2,000
262,144
Wrong Answer
17
2,940
73
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 = tuple(map(int, input().split())) print(((a+b)//2) + (a % b > 0))
s038848816
Accepted
18
3,060
84
from math import ceil a, b = tuple(map(int, input().split())) print(ceil((a+b)/2))
s014598344
p03672
u697658632
2,000
262,144
Wrong Answer
17
2,940
103
We will call a string that can be obtained by concatenating two equal strings an _even_ string. For example, `xyzxyz` and `aaaaaa` are even, while `ababab` and `xyzxy` are not. You are given an even string S consisting of lowercase English letters. Find the length of the longest even string that can be obtained by del...
s = input() ans = 0 for i in range(1, len(s) // 2 - 1): if s[:i] == s[i:2*i]: ans = i print(ans)
s250737111
Accepted
17
2,940
103
s = input() ans = 0 for i in range(1, len(s) // 2): if s[:i] == s[i:2*i]: ans = 2 * i print(ans)
s620950649
p03471
u635273885
2,000
262,144
Wrong Answer
1,599
3,060
229
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 situat...
n, y = map(int, input().split()) x = -1 y = -1 z = -1 for i in range(n+1): for j in range(n+1): k = n-i-j if 10000*i + 5000*j + 1000*k == y: x = i y = j z = k print(x, y, z)
s005337463
Accepted
834
2,940
232
N, Y = map(int, input().split()) x = -1 y = -1 z = -1 for i in range(N+1): for j in range(N+1-i): k = N-i-j if 10000*i + 5000*j + 1000*k == Y: x = i y = j z = k print(x, y, z)
s195762027
p03943
u424967964
2,000
262,144
Wrong Answer
17
2,940
143
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. Not...
candy = [int(i) for i in input().split()] candy = sorted(candy) print(candy) if(candy[0]+candy[1]==candy[2]): print("Yes") else: print("No")
s174988816
Accepted
17
2,940
130
candy = [int(i) for i in input().split()] candy = sorted(candy) if(candy[0]+candy[1]==candy[2]): print("Yes") else: print("No")
s764537875
p03610
u448655578
2,000
262,144
Wrong Answer
36
4,268
112
You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
s = list(input()) ans = [s[0]] for i in range(len(s)): if i % 2 == 0: ans.append(s[i]) print(''.join(ans))
s808076647
Accepted
37
4,264
108
s = list(input()) ans = [] for i in range(len(s)): if i % 2 == 0: ans.append(s[i]) print(''.join(ans))
s626565663
p03695
u394731058
2,000
262,144
Wrong Answer
23
9,096
206
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 : or...
n = int(input()) a = list(map(int, input().split())) c = [False]*8 k = 0 ans = 0 for i in range(n): cn = a[i]//400 if cn < 8: if c[cn] == False: ans += 1 c[cn] = True else: k += 1
s507297352
Accepted
27
9,072
234
n = int(input()) a = list(map(int, input().split())) c = [False]*8 k = 0 ans = 0 for i in range(n): cn = a[i]//400 if cn < 8: if c[cn] == False: ans += 1 c[cn] = True else: k += 1 print(max(1, ans), ans + k)
s057111747
p03160
u608053762
2,000
1,048,576
Wrong Answer
533
23,088
330
There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of...
import numpy as np n = map(int, input()) h_list = [int(i) for i in input().split()] dp = np.zeros((len(h_list))) dp[1] = h_list[1]-h_list[0] for i in range(2,len(h_list)): temp1 = dp[i-1] + abs(h_list[i] - h_list[i-1]) temp2 = dp[i-2] + abs(h_list[i] - h_list[i-2]) dp[i] = min(temp1, temp2) pri...
s578756256
Accepted
806
23,092
375
import numpy as np n = map(int, input()) h_list = [int(i) for i in input().split()] h_list = np.array(h_list) dp = np.zeros((len(h_list))) dp[1] = np.abs(h_list[1]-h_list[0]) for i in range(2,len(h_list)): temp1 = dp[i-1] + np.abs(h_list[i] - h_list[i-1]) temp2 = dp[i-2] + np.abs(h_list[i] - h_list[i-2]) ...
s315685762
p03386
u437215432
2,000
262,144
Wrong Answer
17
3,060
178
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.
# ABC093B a, b, k = map(int, input().split()) ans = set() for i in range(a, min(a+k, b+1)): ans.add(i) for i in range(max(a, b-k+1), b+1): ans.add(i) print(sorted(ans))
s052533541
Accepted
17
3,060
192
a, b, k = map(int, input().split()) ans = set() for i in range(a, min(a+k, b+1)): ans.add(i) for i in range(max(a, b-k+1), b+1): ans.add(i) ans = sorted(ans) for i in ans: print(i)
s661766930
p03471
u728200259
2,000
262,144
Wrong Answer
590
8,944
274
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 situat...
N, Y = map(int, input().split()) result = [-1 , -1, -1] for m in range(N + 1): for f in range(N + 1 - m): s = N - m - f if 10000*m + 5000*f + 1000*s == Y: result = [m, f, s] break print(result)
s913879503
Accepted
564
9,100
328
N, Y = map(int, input().split()) result = [-1 , -1, -1] for m in range(N + 1): for f in range(N + 1 - m): s = N - m - f if 10000*m + 5000*f + 1000*s == Y: result = [m, f, s] break print(f'{result[0]} {result[1]} {result[2]}') ...
s723901997
p03386
u994521204
2,000
262,144
Wrong Answer
19
3,064
179
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()) A=[i for i in range(a, min((a+k),b+1))] B=[i for i in range(max((b-k),a)+1,b+1)] for i in range(len(list(set(A+B)))): print((list(set(A+B)))[i])
s032498766
Accepted
17
3,060
224
a,b,k=map(int,input().split()) A=[i for i in range(a, min((a+k),b))] B=[i for i in range(max((b-k),a)+1,b+1)] ans=list(set(A)|set(B)) ans.sort() if a==b: print(a) else: for i in range(len(ans)): print(ans[i])
s262973473
p03555
u010437136
2,000
262,144
Wrong Answer
17
2,940
162
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.
import sys C1 = sys.stdin.readline() C2 = sys.stdin.readline() c1 = C1.rstrip() c2 = C2.rstrip() c3 = c2[::-1] if c1 == c3: print("Yes") else: print("No")
s887356653
Accepted
17
3,060
162
import sys C1 = sys.stdin.readline() C2 = sys.stdin.readline() c1 = C1.rstrip() c2 = C2.rstrip() c3 = c2[::-1] if c1 == c3: print("YES") else: print("NO")
s072857398
p03433
u035445296
2,000
262,144
Wrong Answer
17
2,940
83
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')
s308537904
Accepted
17
2,940
83
N = int(input()) A = int(input()) if N%500 > A: print('No') else: print('Yes')
s455000360
p03729
u111365362
2,000
262,144
Wrong Answer
17
3,064
116
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 `Y...
#16:05 a,b,c = input().split() x = int(a[-1]==b[0]) * int(b[-1]==c[0]) if x == 1: print('Yes') else: print('No')
s644290709
Accepted
18
2,940
116
#16:05 a,b,c = input().split() x = int(a[-1]==b[0]) * int(b[-1]==c[0]) if x == 1: print('YES') else: print('NO')
s488628806
p03970
u859897687
2,000
262,144
Wrong Answer
20
2,940
87
CODE FESTIVAL 2016 is going to be held. For the occasion, Mr. Takahashi decided to make a signboard. He intended to write `CODEFESTIVAL2016` on it, but he mistakenly wrote a different string S. Fortunately, the string he wrote was the correct length. So Mr. Takahashi decided to perform an operation that replaces a ce...
a=input() b='CODEFESTIVAL2016' ans=0 for i in range(16): ans+=(a[i]==b[i]) print(ans)
s697620052
Accepted
17
2,940
87
a=input() b='CODEFESTIVAL2016' ans=0 for i in range(16): ans+=(a[i]!=b[i]) print(ans)
s706873723
p03090
u608850287
2,000
1,048,576
Wrong Answer
24
3,612
167
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...
n = int(input()) for i in range(1, n + 1): for j in range(i + 1, n + 1): if n % 2 == 1 and i + j != n \ or n % 2 == 0 and i + j != n + 1: print(i, j)
s933073635
Accepted
25
3,956
240
n = int(input()) edges = [] for i in range(1, n + 1): for j in range(i + 1, n + 1): if n % 2 == 1 and i + j != n \ or n % 2 == 0 and i + j != n + 1: edges.append((i, j)) print(len(edges)) for i, j in edges: print(i, j)
s250398949
p03067
u951598454
2,000
1,048,576
Wrong Answer
17
3,064
143
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.
A, B, C = map(int, input().split()) # normalize norm_A = 0 norm_B = B - A norm_C = C - A print('YES' if abs(norm_B) >= abs(norm_C) else 'No')
s648952807
Accepted
17
2,940
170
A, B, C = map(int, input().split()) # normalize norm_A = 0 norm_B = B - A norm_C = C - A print('Yes' if abs(norm_B) >= abs(norm_C) and (norm_B * norm_C) > 0 else 'No')
s550965215
p03943
u594956556
2,000
262,144
Wrong Answer
17
2,940
100
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. Not...
abc = list(map(int, input().split())) if abc[0]+abc[1] == abc[2]: print('Yes') else: print('No')
s704542315
Accepted
17
2,940
112
abc = list(map(int, input().split())) abc.sort() if abc[0]+abc[1] == abc[2]: print('Yes') else: print('No')
s929926972
p02665
u928784113
2,000
1,048,576
Wrong Answer
143
32,532
2,364
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 itertools from collections import deque,defaultdict,Counter from itertools import accumulate import bisect from heapq import heappop,heappush,heapify import math from copy import deepcopy import queue #import numpy as np Mod = 1000000007 fact = [1, 1] factinv = [1, 1] inv = [0, 1] for i in range(2, 10**5 + 1):...
s210912584
Accepted
190
32,708
2,495
import itertools from collections import deque,defaultdict,Counter from itertools import accumulate import bisect from heapq import heappop,heappush,heapify import math from copy import deepcopy import queue #import numpy as np Mod = 1000000007 fact = [1, 1] factinv = [1, 1] inv = [0, 1] for i in range(2, 10**5 + 1):...
s439590351
p02413
u067975558
1,000
131,072
Wrong Answer
30
6,724
226
Your task is to perform a simple table calculation. Write a program which reads the number of rows r, columns c and a table of r × c elements, and prints a new table, which includes the total sum for each row and column.
(r, c) = [int(i) for i in input().split()] a = [] for i in range(r): a.append([int(i) for i in input().split()]) for i in range(r): sum = 0 for j in a[i]: print(j, end=' ') sum += j print(sum)
s231738405
Accepted
60
6,828
347
(r, c) = [int(i) for i in input().split()] a = [] for i in range(r): a.append([int(i) for i in input().split()]) a.append([0 for i in range(c)]) for i in range(r + 1): sum = 0 count = 0 for j in a[i]: print(j, end=' ') sum += j if i != r: a[r][count] += j ...
s795874714
p03680
u823458368
2,000
262,144
Wrong Answer
209
7,084
310
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 ...
n = int(input()) a = [] for _ in range(n): a.append(int(input())) now = 1 nex = [now-1] ans = 0 flg = 0 while a[now-1] != 0: a[now-1], nex = 0, a[now-1] now = a[nex-1] ans += 1 if nex == 2: flg = 1 ans += 1 break if flg == 1: print(ans) else: print(-1)
s588535343
Accepted
223
7,084
289
n = int(input()) a = [] for _ in range(n): a.append(int(input())) now = 1 nex = a[now-1] ans = 0 flg = 0 while a[now-1] != 0: a[now-1], nex = 0, a[now-1] now = nex ans += 1 if nex == 2: flg = 1 break if flg == 1: print(ans) else: print(-1)
s627571249
p03610
u608088992
2,000
262,144
Wrong Answer
17
3,188
26
You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
s = input() print(s[1::2])
s231316702
Accepted
17
3,188
26
s = input() print(s[::2])
s450286582
p03448
u139112865
2,000
262,144
Wrong Answer
47
4,120
141
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 co...
#087_B a,b,c,x=[int(input()) for i in range(4)] print(sum([500*p+100*q+10*r==x for p in range(a+1) for q in range(b+1) for r in range(c+1)]))
s402844166
Accepted
49
4,120
141
#087_B a,b,c,x=[int(input()) for i in range(4)] print(sum([500*p+100*q+50*r==x for p in range(a+1) for q in range(b+1) for r in range(c+1)]))
s273420338
p02389
u489417537
1,000
131,072
Wrong Answer
20
5,572
47
Write a program which calculates the area and perimeter of a given rectangle.
a, b = map(int, input().split()) print(a * b)
s654616781
Accepted
20
5,572
62
a, b = map(int, input().split()) print(a * b, a * 2 + b * 2)
s576281903
p03672
u844005364
2,000
262,144
Wrong Answer
17
2,940
78
We will call a string that can be obtained by concatenating two equal strings an _even_ string. For example, `xyzxyz` and `aaaaaa` are even, while `ababab` and `xyzxy` are not. You are given an even string S consisting of lowercase English letters. Find the length of the longest even string that can be obtained by del...
n = input() while n[:len(n)//2] != n[len(n)//2:]: n = n[:-1] print(len(n))
s564434672
Accepted
17
2,940
91
n = input() n = n[:-1] while n[:len(n)//2] != n[len(n)//2:]: n = n[:-1] print(len(n))
s289283930
p03815
u116142267
2,000
262,144
Wrong Answer
17
2,940
96
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° t...
x = int(input()) cnt = int(x / 11) * 2 if x%11<6 and cnt!=0: print(cnt) else: print(cnt+1)
s614810398
Accepted
17
2,940
114
x = int(input()) cnt = int(x / 11)*2 if x%11==0: print(cnt) elif x%11<=6: print(cnt+1) else: print(cnt+2)
s306663057
p04039
u903596281
2,000
262,144
Wrong Answer
17
3,064
532
Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K. She is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change). However, as mentioned before, she is very ...
N,K=map(int,input().split()) D=[int(x) for x in input().split()] kazu=[9,8,7,6,5,4,3,2,1,0] for item in D: kazu.remove(item) p=[] m=len(str(N)) for i in range(m): p.append(kazu[0]*(10**i)) p.sort(reverse=True) print(p) j=0 while j<m: for i in range(1,len(kazu)): if sum(p)-p[j]+kazu[i]*(10**(m-j-1))>=N: ...
s455216406
Accepted
17
3,064
523
N,K=map(int,input().split()) D=[int(x) for x in input().split()] kazu=[9,8,7,6,5,4,3,2,1,0] for item in D: kazu.remove(item) p=[] m=len(str(N)) for i in range(m): p.append(kazu[0]*(10**i)) p.sort(reverse=True) j=0 while j<m: for i in range(1,len(kazu)): if sum(p)-p[j]+kazu[i]*(10**(m-j-1))>=N: p[j]=kazu...
s589777271
p04043
u172780602
2,000
262,144
Wrong Answer
17
2,940
116
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 ...
a=list(map(int,input().split())) if a.count(5)==2: if a.count(7)==1: print("Yes") else: print("No")
s973581102
Accepted
17
2,940
146
a=list(map(int,input().split())) if a.count(5)==2: if a.count(7)==1: print("YES") else: print("NO") else: print("NO")
s280640494
p02608
u748311048
2,000
1,048,576
Wrong Answer
60
9,604
328
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
from collections import Counter n = int(input()) l = list() for i in range(31): l.append((i, i**2)) # print(l) c = Counter() for X in l: for Y in l: for Z in l: x = X[0] y = Y[0] z = Z[0] c[X[1]+Y[1]+Z[1]+x*y+y*z+x*z] += 1 for i in range(1, n+1): prin...
s527677664
Accepted
753
11,848
331
from collections import Counter n = int(input()) l = list() for i in range(1,101): l.append((i, i**2)) # print(l) c = Counter() for X in l: for Y in l: for Z in l: x = X[0] y = Y[0] z = Z[0] c[X[1]+Y[1]+Z[1]+x*y+y*z+x*z] += 1 for i in range(1, n+1): p...
s613245636
p03545
u272336707
2,000
262,144
Wrong Answer
20
3,064
411
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 in...
s= input() n = len(s) - 1 import itertools li = list(itertools.product({0, 1}, repeat=n)) for i in range(len(li)): total = int(s[0]) shiki = s[0] for j in range(n): if li[i][j] == 0: total += int(s[j+1]) shiki += "+"+s[j+1] else: total -= int(s[j+1]) ...
s785889201
Accepted
17
3,064
454
s= input() n = len(s) - 1 import itertools li = list(itertools.product({0, 1}, repeat=n)) for i in range(len(li)): total = int(s[0]) shiki = s[0] for j in range(n): if li[i][j] == 0: total += int(s[j+1]) shiki += "+"+s[j+1] else: total -= int(s[j+1]) ...
s927640455
p03455
u313043608
2,000
262,144
Wrong Answer
27
9,028
78
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')
s963500995
Accepted
26
9,068
79
a,b=map(int,input().split()) if a*b%2==1: print('Odd') else: print('Even')
s229755450
p01132
u635391238
8,000
131,072
Wrong Answer
20
7,824
1,365
Mr. Bill は店で買い物をしている。 彼の財布にはいくらかの硬貨(10 円玉、50 円玉、100 円玉、500 円玉)が入っているが、彼は今この小銭をできるだけ消費しようとしている。 つまり、適切な枚数の硬貨によって品物の代金を払うことで、釣り銭を受け取った後における硬貨の合計枚数を最小にしようとしている。 幸いなことに、この店の店員はとても律儀かつ親切であるため、釣り銭は常に最適な方法で渡される。 したがって、例えば 1 枚の 500 円玉の代わりに 5 枚の 100 円玉が渡されるようなことはない。 また、例えば 10 円玉を 5 枚出して、50 円玉を釣り銭として受け取ることもできる。 ただし、出した硬貨と同じ種類の硬...
def back_oturigation(fee, coin_values, coin_nums): # 1. oturi = coin_values[0]*coin_nums[0]\ +coin_values[1]*coin_nums[1]\ +coin_values[2]*coin_nums[2]\ +coin_values[3]*coin_nums[3]\ -fee use_coins = [0] * len(coin_value) no_use_coins = [0]*len(coin_...
s564556848
Accepted
120
7,908
1,512
import math def back_oturigation(fee, coin_values, coin_nums): # 1. oturi = coin_values[0] * coin_nums[0] \ + coin_values[1] * coin_nums[1] \ + coin_values[2] * coin_nums[2] \ + coin_values[3] * coin_nums[3] \ - fee use_coins = [0] * len(coin_values) ...
s574740943
p03623
u404556828
2,000
262,144
Wrong Answer
17
3,060
178
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...
x, a, b = input().split() x = int(x) a = int(a) b = int(b) x_a = (x - a) ** 2 x_b = (x - b) ** 2 if x_a > x_b: print("b") # elif x_a == x_b: # print("A = B") else: print("A")
s275781292
Accepted
17
2,940
146
x, a, b = input().split() x = int(x) a = int(a) b = int(b) x_a = (x - a) ** 2 x_b = (x - b) ** 2 if x_a > x_b: print("B") else: print("A")
s314062944
p03449
u255280439
2,000
262,144
Wrong Answer
18
3,060
360
We have a 2 \times N grid. We will denote the square at the i-th row and j-th column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j). You are initially in the top-left square, (1, 1). You will travel to the bottom-right square, (2, N), by repeatedly moving right or down. The square (i, j) contains A_{i, j} candies. You ...
N = int(input()) Board = [] for i in range(2): Board.append(list(map(int, input().split()))) max_candies = -1 for gotodown_index in range(N): upper_candies = sum(Board[0][:gotodown_index+1]) lower_candies = sum(Board[1][gotodown_index:]) candies = upper_candies + lower_candies if candies > max_candies: ...
s120976492
Accepted
17
3,060
363
N = int(input()) Board = [] for i in range(2): Board.append(list(map(int, input().split()))) max_candies = 0 for gotodown_index in range(N): upper_candies = sum(Board[0][:gotodown_index+1]) lower_candies = sum(Board[1][gotodown_index:]) candies = upper_candies + lower_candies if candies > max_candies: ...
s412141678
p03470
u992875223
2,000
262,144
Wrong Answer
17
2,940
137
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 h...
N = int(input()) D = [int(input()) for i in range(N)] D.sort() ans = 0 for i in range(N - 1): if D[i] < D[i + 1]: ans += 1 print(ans)
s873220439
Accepted
17
3,060
137
N = int(input()) D = [int(input()) for i in range(N)] D.sort() ans = 1 for i in range(N - 1): if D[i] < D[i + 1]: ans += 1 print(ans)
s147598720
p03636
u063614215
2,000
262,144
Wrong Answer
18
3,064
41
The word `internationalization` is sometimes abbreviated to `i18n`. This comes from the fact that there are 18 letters between the first `i` and the last `n`. You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way.
s = input() print(s[0]+str(len(s))+s[-1])
s130502526
Accepted
17
2,940
58
s = input() ans = s[0] + str(len(s)-2) + s[-1] print(ans)
s445148754
p02694
u648192617
2,000
1,048,576
Wrong Answer
23
9,168
101
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 abo...
X = int(input()) Y = 100 year = 0 while Y <= X: Y = int(Y * 1.01) year = year + 1 print(year)
s500451213
Accepted
20
9,108
100
X = int(input()) Y = 100 year = 0 while Y < X: Y = int(Y * 1.01) year = year + 1 print(year)
s711388800
p04029
u779728630
2,000
262,144
Wrong Answer
18
2,940
34
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
N = int(input()) print( N*(N+1)/2)
s530103717
Accepted
17
2,940
40
N = int(input()) print( int(N*(N+1)/2))
s429376652
p03433
u153729035
2,000
262,144
Wrong Answer
17
2,940
56
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
print('YES' if int(input())%500<=int(input()) else 'NO')
s469628213
Accepted
17
2,940
56
print('Yes' if int(input())%500<=int(input()) else 'No')
s522029989
p03352
u977096988
2,000
1,048,576
Wrong Answer
17
3,064
403
You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
s=input() X=int(s) if(X==1): print(1) else: data=[] for b in range(1,35): for p in range(2,10): xt=b**p if(xt>1000): break data.append(xt) print(data) dist=2000 ans=-1 for i in range(len(data)): if(data[i]<X and abs(data[i]...
s292659784
Accepted
17
3,064
407
s=input() X=int(s) if(X==1): print(1) else: data=[] for b in range(1,35): for p in range(2,10): xt=b**p if(xt>1000): break data.append(xt) dist=abs(data[0]-X) ans=data[0] for i in range(1,len(data)): if(data[i]<=X and abs(data...
s370548713
p02854
u667024514
2,000
1,048,576
Wrong Answer
177
26,220
167
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 po...
n = int(input()) lis = list(map(int,input().split())) ans = 10 ** 10 num = sum(lis) nu = 0 for i in range(n): nu += lis[i] ans = min(ans,abs(nu-num//2)) print(ans)
s055235988
Accepted
203
26,024
176
n = int(input()) lis = list(map(int,input().split())) ans = 10 ** 10 num = sum(lis) nu = 0 for i in range(n): nu += lis[i] ans = min(ans,abs(nu-num/2)) print(int(ans//0.5))
s150828310
p03610
u316386814
2,000
262,144
Wrong Answer
19
3,188
27
You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
s = input() print(s[1::2])
s393827304
Accepted
17
3,188
26
s = input() print(s[::2])
s874383621
p03674
u442877951
2,000
262,144
Wrong Answer
2,206
20,700
549
You are given an integer sequence of length n+1, a_1,a_2,...,a_{n+1}, which consists of the n integers 1,...,n. It is known that each of the n integers 1,...,n appears at least once in this sequence. For each integer k=1,...,n+1, find the number of the different subsequences (not necessarily contiguous) of the given s...
N = int(input()) A = list(map(int,input().split())) MOD = 10**9 + 7 def cmb(n,r,mod): a=1 b=1 r = min(r,n-r) for i in range(r): a = a*(n-i)%mod b = b*(i+1)%mod return a*pow(b,mod-2,mod)%mod ans = 0 INF = 10**9 x,y = 0,0 l = [INF]*(N+1) for i in range(N+1): if l[A[i]-1] != INF: x = l[A[i]-1] y = i...
s014593625
Accepted
289
27,112
985
def cmb(n, k, mod, fac, ifac): k = min(k, n-k) return fac[n] * ifac[k] % mod * ifac[n-k] % mod if n >= k >= 0 else 0 def make_tables(mod, n): fac = [1, 1] ifac = [1, 1] inverse = [0, 1] for i in range(2, n+1): fac.append((fac[-1] * i) % mod) inverse.append((-inver...
s974026329
p03417
u527261492
2,000
262,144
Wrong Answer
17
3,064
436
There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following op...
n,m=map(int,input().split()) if n*m==1: print(1) if n*m==2: print(0) if n*m==3: print(1) if n==2 and m==2: print(0) elif n*m==4: print(2) if n*m==5: print(3) if n==2 and m==3: print(0) if n==3 and m==2: print(0) elif n*m==6: print(4) if n*m==7: print(5) if n==2 and m==4: print(0) if n==4 and m==2:...
s933222408
Accepted
18
2,940
126
n,m=map(int,input().split()) if n*m==1: print(1) elif n==1: print(m-2) elif m==1: print(n-2) else: print((n-2)*(m-2))
s175051057
p00002
u680933765
1,000
131,072
Wrong Answer
20
7,548
127
Write a program which computes the digit number of sum of two integers a and b.
# Compatible with Python3 # -*- coding: utf-8 -*- from math import log10 print(int(log10(eval(input().replace(" ", "+"))) + 1))
s870972910
Accepted
20
7,604
79
import sys [print(len(str(sum(list(map(int, i.split())))))) for i in sys.stdin]
s127698127
p03361
u118019047
2,000
262,144
Wrong Answer
18
3,064
326
We have a canvas divided into a grid with H rows and W columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Initially, all the squares are white. square1001 wants to draw a picture with black paint. His specific objective is to make Square (i, j) black when s_{i...
h, w = map(int, input().split()) ls = [[i for i in '.'+input()+'.'] for i in range(h)] print(ls) ls.insert(0, ['.' for i in range(w+2)]) print(ls) ls.append(['.' for i in range(w+2)]) print(ls) for i in range(len(ls)): print(ls[i])
s977586242
Accepted
24
3,064
628
h,w = list(map(int,input().split())) table = list() x = [0,1,0,-1] y =[1,0,-1,0] for i in range(h): table.append(list(input())) for i in range(h): j_check = False for j in range(w): if table[i][j] == "#": counter = 0 for a,b in zip(x,y): if i + b >= h or...
s923041965
p00014
u075836834
1,000
131,072
Wrong Answer
20
7,668
151
Write a program which computes the area of a shape represented by the following three lines: $y = x^2$ $y = 0$ $x = 600$ It is clear that the area is $72000000$, if you use an integral you learn in high school. On the other hand, we can obtain an approximative area of the shape by adding up areas of many...
def function(a): s=0 d=a for i in range(d,600-d+1,d): s+=a*(d**2) d+=a #print("%10d %10d"%(d,s)) return s n=int(input()) print(function(n))
s246640490
Accepted
30
7,564
198
def function(a): s=0 d=a for i in range(d,600-d+1,d): s+=a*(d**2) d+=a #print("%10d %10d"%(d,s)) return s while True: try: n=int(input()) print(function(n)) except EOFError: break
s309130846
p03229
u129019798
2,000
1,048,576
Wrong Answer
660
13,444
859
You are given N integers; the i-th of them is A_i. Find the maximum possible sum of the absolute differences between the adjacent elements after arranging these integers in a row in any order you like.
N=input() N=int(N) L=[] def diff(L): total=0 for i in range(len(L)-1): total+=abs(L[i+1]-L[i]) return total for i in range(N): A=input() L.append(int(A)) L.sort() if len(L)>3: length=len(L) SL=L[:int(length/2)] LL=L[int(length/2):] print(SL) print(LL) result=[] r...
s241962693
Accepted
637
9,060
902
N=input() N=int(N) L=[] def diff(L): total=0 for i in range(len(L)-1): total+=abs(L[i+1]-L[i]) return total for i in range(N): A=input() L.append(int(A)) L.sort() if len(L)>3: length=len(L) SL=L[:int(length/2)] LL=L[int(length/2):] result=[] result.append(SL[-1]) SL....
s784551686
p03943
u143189168
2,000
262,144
Wrong Answer
17
2,940
136
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. Not...
s1 = input().split() s2 = sorted(s1) a = int(s2[0]) b = int(s2[1]) c = int(s2[2]) if a + b == c: print("YES") else: print("NO")
s877193592
Accepted
17
2,940
123
a,b,c = map(int, input().split()) s = [a,b,c] t = sorted(s) if t[0] + t[1] == t[2]: print("Yes") else: print("No")
s731990344
p03636
u696197059
2,000
262,144
Wrong Answer
31
9,108
142
The word `internationalization` is sometimes abbreviated to `i18n`. This comes from the fact that there are 18 letters between the first `i` and the last `n`. You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way.
st_list = list(input()) print(st_list[0]) print(st_list[-1]) print(len(st_list[1:-1])) print(st_list[0]+str(len(st_list[1:-1]))+st_list[-1])
s677506272
Accepted
28
9,088
80
st_list = list(input()) print(st_list[0]+str(len(st_list[1:-1]))+st_list[-1])
s360760944
p03998
u292978925
2,000
262,144
Wrong Answer
17
3,064
552
Alice, Bob and Charlie are playing _Card Game for Three_ , as below: * At first, each of the three players has a deck consisting of some number of cards. Each card has a letter `a`, `b` or `c` written on it. The orders of the cards in the decks cannot be rearranged. * The players take turns. Alice goes first. * ...
sa = input() sb = input() sc = input() now = 'a' ca = 0 cb = 0 cc = 0 RC = '' while RC == '': if now == 'a': print('a') if ca == len(sa): break now = sa[ca] ca += 1 elif now == 'b': print('b') if cb == len(sb): break now = sb[cb]...
s673199278
Accepted
17
3,064
495
sa = input() sb = input() sc = input() now = 'a' ca = 0 cb = 0 cc = 0 RC = '' while RC == '': if now == 'a': if ca == len(sa): break now = sa[ca] ca += 1 elif now == 'b': if cb == len(sb): break now = sb[cb] cb += 1 else: if...
s288922953
p03436
u571445182
2,000
262,144
Wrong Answer
31
4,596
1,971
We have an H \times W grid whose squares are painted black or white. The square at the i-th row from the top and the j-th column from the left is denoted as (i, j). Snuke would like to play the following game on this grid. At the beginning of the game, there is a character called Kenus at square (1, 1). The player re...
from collections import deque nNM = [] nNM = input().rstrip().split(' ') nH = int(nNM[0]) nW = int(nNM[1]) nTmp = [0 for i in range(nW)] graph = {} kyori = {} checked = {} nWallCnt = 0 for i in range(nH): nTmp=input() # print(nTmp) for i2 in range(nW): nPoi=('%d-%d' %(i,i2)) ...
s945719376
Accepted
38
4,596
1,837
from collections import deque nNM = [] nNM = input().rstrip().split(' ') nH = int(nNM[0]) nW = int(nNM[1]) nTmp = [0 for i in range(nW)] graph = {} kyori = {} checked = {} nWallCnt = 0 for i in range(nH): nTmp=input() # print(nTmp) for i2 in range(nW): # print(nTmp[i2]) nPoi=('%d-%...
s613408413
p02665
u563838154
2,000
1,048,576
Wrong Answer
2,278
76,148
301
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.
n = int(input()) a = list(map(int,input().split())) su = sum(a) print(su) l = [su]*n for i in range(1,n): l[i]=l[i-1]-a[i-1] count=0 m=[1]*n for j in range(1,n): m[j] = m[j-1]*2 if m[j]>l[j]: m[j]=l[j] print(m[j]) count += m[j] m[j] -= a[j] count+=a[-1]+1 print(count)
s847992000
Accepted
141
20,840
520
n = int(input()) a = list(map(int,input().split())) if a[0] == 1 and n == 0: print(1) exit() su = sum(a) # print(su) l = [su]*(n+1) for i in range(1,n+1): l[i]=l[i-1]-a[i-1] # print(l) count=0 x = 0 m=[1]*(n+1) for j in range(1,n+1): m[j] = m[j-1]*2 if m[j]>l[j]: m[j]=l[j] if (m[j]<a[j])...
s637265801
p03997
u231122239
2,000
262,144
Wrong Answer
17
2,940
60
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
a, b, h = [int(input()) for _ in range(3)] print((a+b)*h/2)
s633647775
Accepted
17
2,940
61
a, b, h = [int(input()) for _ in range(3)] print((a+b)*h//2)
s710816540
p03944
u289162337
2,000
262,144
Wrong Answer
18
3,064
431
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) po...
x_max, y_max, N = map(int, input().split()) x_min, y_min = 0, 0 l = [input().split() for _ in range(N)] for i in range(N): if l[i][2] == 1: x_min = max(x_min, l[i][0]) elif l[i][2] == 2: x_max = min(x_max, l[i][0]) elif l[i][2] == 3: y_min = max(y_min, l[i][1]) elif l[i][2] == 4: y_max = min(y_m...
s757873109
Accepted
18
3,064
443
x_max, y_max, N = map(int, input().split()) x_min, y_min = 0, 0 l = [[int(i) for i in input().split()] for _ in range(N)] for i in range(N): if l[i][2] == 1: x_min = max(x_min, l[i][0]) elif l[i][2] == 2: x_max = min(x_max, l[i][0]) elif l[i][2] == 3: y_min = max(y_min, l[i][1]) elif l[i][2] == 4: ...
s706718720
p03759
u446711904
2,000
262,144
Wrong Answer
17
2,940
56
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'[a+c!=b::2])
s023668863
Accepted
17
2,940
58
a,b,c=map(int,input().split());print('YNEOS'[b-a!=c-b::2])
s274699755
p02850
u561992253
2,000
1,048,576
Wrong Answer
1,076
20,516
455
Given is a tree G with N vertices. The vertices are numbered 1 through N, and the i-th edge connects Vertex a_i and Vertex b_i. Consider painting the edges in G with some number of colors. We want to paint them so that, for each vertex, the colors of the edges incident to that vertex are all different. Among the colo...
words = lambda t : list(map(t, input().split())) n = int(input()) vs = [[] for i in range(n)] for i in range(n-1): s,e = words(int) vs[s-1].append(e-1) import queue q = queue.Queue() q.put(0) color = [0] * n color[0] = 1 while not q.empty(): v = q.get() cur_c = 1 for c in vs[v]: if color[v...
s289598686
Accepted
1,200
30,816
547
words = lambda t : list(map(t, input().split())) n = int(input()) vs = [[] for i in range(n)] for i in range(n-1): s,e = words(int) vs[s-1].append((e-1,i)) import queue q = queue.Queue() q.put(0) color = [0] * (n-1) color_par = [0] * (n) color_par[0] = -1 while not q.empty(): v = q.get() cur_c = 1 ...
s902605502
p03610
u835482198
2,000
262,144
Wrong Answer
18
3,188
29
You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
s = input() print(s[0:-1:2])
s517301840
Accepted
17
3,188
62
s = input() if len(s) % 2 == 1: s += '-' print(s[0:-1:2])
s306981410
p02357
u279605379
2,000
262,144
Wrong Answer
20
7,772
182
For a given array $a_1, a_2, a_3, ... , a_N$ of $N$ elements and an integer $L$, find the minimum of each possible sub-arrays with size $L$ and print them from the beginning. For example, for an array $\\{1, 7, 7, 4, 8, 1, 6\\}$ and $L = 3$, the possible sub-arrays with size $L = 3$ includes $\\{1, 7, 7\\}$, $\\{7, 7, ...
[N,L] = [int(x) for x in input().split()] A = [int(x) for x in input().split()] ans = "" for i in range(N-L+1): print(A[i*L:i*L+L]) ans += str(min(A[i:i+L])) + " " print(ans)
s805308984
Accepted
2,110
127,964
757
def ascend(a,b): mini = min(A[a:a+L]) ans[a] = mini for i in range(a+1,b): if A[i+L-1] <= mini : mini = A[i+L-1] elif A[i-1] == mini : mini = min(A[i:i+L]) ans[i] = mini def descend(a,b): mini = min(A[b-1:b+L-1]) ans[b-1] = mini for i in range(b-2,a-1,-1): if A[i...
s961204430
p03855
u012694084
2,000
262,144
Wrong Answer
2,110
137,460
660
There are N cities. There are also K roads and L railways, extending between the cities. The i-th road bidirectionally connects the p_i-th and q_i-th cities, and the i-th railway bidirectionally connects the r_i-th and s_i-th cities. No two roads connect the same pair of cities. Similarly, no two railways connect the s...
N, K, L = list(map(int, input().split(" "))) N += 1 n_rl = [[[], [], None] for _ in range(N)] for _ in range(K): p, q = list(map(int, input().split(" "))) for i in n_rl[p][0]: n_rl[i][0].append(q) n_rl[q][0].append(i) n_rl[p][0].append(q) n_rl[q][0].append(p) for _ in range(L): r,...
s303061135
Accepted
1,323
56,492
1,153
from collections import deque def create_group(N, n): city = [[] for _ in range(N + 1)] for _ in range(n): p, q = map(int, input().split(" ")) city[p].append(q) city[q].append(p) group_list = [0] * (N + 1) gid = 0 Q = deque() for i in range(1, N + 1): if group_...
s937706178
p03635
u251017754
2,000
262,144
Wrong Answer
17
2,940
43
In _K-city_ , there are n streets running east-west, and m streets running north-south. Each street running east-west and each street running north-south cross each other. We will call the smallest area that is surrounded by four streets a block. How many blocks there are in K-city?
n, m = map(int, input().split()) print(n*m)
s072109859
Accepted
17
2,940
51
n, m = map(int, input().split()) print((n-1)*(m-1))
s962201718
p03478
u314350544
2,000
262,144
Wrong Answer
43
9,112
148
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
n, a, b = map(int, input().split()) ans = 0 for i in range(n + 1): if a <= sum(list(map(int, list(str(i))))) >= b: ans += i print(ans)
s257037067
Accepted
39
9,164
144
n, a, b = map(int, input().split()) ans = 0 for i in range(n+1): if a <= sum(list(map(int, list(str(i))))) <= b: ans += i print(ans)
s384888074
p03592
u679325651
2,000
262,144
Wrong Answer
2,029
17,860
219
We have a grid with N rows and M columns of squares. Initially, all the squares are white. There is a button attached to each row and each column. When a button attached to a row is pressed, the colors of all the squares in that row are inverted; that is, white squares become black and vice versa. When a button attach...
N,M,K = [int(i) for i in input().split()] for i in range(0,N+1): for j in range(0,M+1): ans = i*M+j*N-i*j*2 print(i,j,ans) if ans==K: print("Yes") exit() print("No")
s031170731
Accepted
392
3,064
196
N,M,K = [int(i) for i in input().split()] for i in range(0,N+1): for j in range(0,M+1): ans = i*M+j*N-i*j*2 if ans==K: print("Yes") exit() print("No")
s050303831
p03149
u588633699
2,000
1,048,576
Wrong Answer
17
3,064
723
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".
S = str(input()) keyence = 'keyence' if len(S) == 7: if S==keyence: print('YES') else: print('NO') else : for i in range(0,7): if keyence[:i] in S and keyence[i:] in S[S.index(keyence[:i])+i:] : if i==0 and S.index(keyence[i:])==0 : print('YES') brea...
s213026224
Accepted
18
2,940
121
N = list(map( int, input().split() )) if 1 in N and 9 in N and 7 in N and 4 in N: print('YES') else: print('NO')
s165833142
p03545
u566787760
2,000
262,144
Wrong Answer
18
3,060
339
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 in...
n = input() cnt = len(n) -1 for i in range(2 ** cnt): op = ["-"] * cnt for j in range(cnt): if ((i >> j) & 1): op[cnt - 1 - j] = "+" formula = "" for p_n,p_o in zip(n,op+[""]): formula += (p_n + p_o) print(formula) if eval(formula) == 7: print(formula + "...
s349067439
Accepted
18
3,060
316
n = input() cnt = len(n) -1 for i in range(2 ** cnt): op = ["-"] * cnt for j in range(cnt): if ((i >> j) & 1): op[cnt - 1 - j] = "+" formula = "" for p_n,p_o in zip(n,op+[""]): formula += (p_n + p_o) if eval(formula) == 7: print(formula + "=7") break
s091276177
p03854
u156113867
2,000
262,144
Wrong Answer
18
3,188
157
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
S = input() result = S.replace("eraser", "").replace("erase", "").replace("dreamer", "").replace("dream", "") if result: print("No") else: print("Yes")
s790374119
Accepted
19
3,188
157
S = input() result = S.replace("eraser", "").replace("erase", "").replace("dreamer", "").replace("dream", "") if result: print("NO") else: print("YES")
s016100583
p03400
u368796742
2,000
262,144
Wrong Answer
17
2,940
144
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 ...
n = int(input()) d,x = map(int,input().split()) for i in range(n): a = int(input()) b = 1 while b > n: x += 1 b += a print(x)
s114199129
Accepted
17
2,940
146
n = int(input()) d,x = map(int,input().split()) for i in range(n): a = int(input()) b = 1 while b <= d: x += 1 b += a print(x)
s569114264
p02255
u935329231
1,000
131,072
Wrong Answer
30
7,584
489
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 ...
# -*- coding: utf-8 -*- def insertion_sort(seq, l): for i, v in enumerate(seq[1:], start=1): left = i - 1 while left >= 0 and seq[left] > v: seq[left], seq[left+1] = seq[left+1], seq[left] left -= 1 print(' '.join([str(n) for n in seq])) def to_int(v): return ...
s493399684
Accepted
20
7,748
532
# -*- coding: utf-8 -*- def insertion_sort(seq, l): print(' '.join([str(n) for n in seq])) for i, v in enumerate(seq[1:], start=1): left = i - 1 while left >= 0 and seq[left] > v: seq[left], seq[left+1] = seq[left+1], seq[left] left -= 1 print(' '.join([str(n) f...
s174177835
p02388
u655518263
1,000
131,072
Wrong Answer
30
7,604
34
Write a program which calculates the cube of a given integer x.
x = int(input("x = ")) print(x**3)
s588389409
Accepted
20
7,676
28
x = int(input()) print(x**3)
s715962418
p03814
u897328029
2,000
262,144
Wrong Answer
18
3,816
71
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 w...
s = input() l = s.find('A') r = s.rfind('Z') ans = s[l:r+1] print(ans)
s561923559
Accepted
17
3,628
76
s = input() l = s.find('A') r = s.rfind('Z') ans = len(s[l:r+1]) print(ans)
s393344767
p03386
u288948615
2,000
262,144
Wrong Answer
2,104
3,060
106
Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.
A, B, K = map(int, input().split()) for i in range(A, B+1): if i-A <= K or B-i <= K: print(i)
s252828895
Accepted
17
3,060
147
A, B, K = map(int, input().split()) m = min(A+K, B+1) for i in range(A, m): print(i) n = max(A+K, B-K+1) for j in range(n, B+1): print(j)
s702160989
p03449
u310678820
2,000
262,144
Wrong Answer
17
3,060
208
We have a 2 \times N grid. We will denote the square at the i-th row and j-th column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j). You are initially in the top-left square, (1, 1). You will travel to the bottom-right square, (2, N), by repeatedly moving right or down. The square (i, j) contains A_{i, j} candies. You ...
n=int(input()) u=[int(j) for j in input().split()] m=[int(j) for j in input().split()] ans=0 for i in range(n): t=0 t=sum(u[:i+1])+sum(m[i:]) print(t) if ans<t: ans=t print(ans)
s532493057
Accepted
19
2,940
197
n=int(input()) u=[int(j) for j in input().split()] m=[int(j) for j in input().split()] ans=0 for i in range(n): t=0 t=sum(u[:i+1])+sum(m[i:]) if ans<t: ans=t print(ans)
s448227607
p03090
u426764965
2,000
1,048,576
Wrong Answer
28
9,232
827
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...
def agc032_b(): n = int(input()) A = [[n], []] t = 1 for i in range(n-1, 0, -2): if i == 1: A[t] += [i] else: A[t] += [i, i-1] t = abs(t-1) odd = False if sum(A[0]) != sum(A[1]): odd = True if n % 2 == 1: if A[0][-1] == 1: A[1].append(1) ...
s535758886
Accepted
34
9,208
380
def agc032_b(): n = int(input()) g = [[1]*n for _ in range(n)] for i in range(n//2): j = 2*(n//2)-1-i g[i][j] = 0 g[j][i] = 0 cnt = (sum([sum(row) for row in g]) - n) // 2 print(cnt) for i in range(n): for j in range(i+1, n): if g[i][j]: print('{} {}'....
s574986774
p04043
u312913211
2,000
262,144
Wrong Answer
18
3,060
211
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 ...
inpstr = input() inp = inpstr.split(" ") inp = list(map(int,inp)) c5 = 0 c7 = 0 for i in inp: if inp==5: c5 += 1 elif inp==7: c7 += 1 if c5 == 2 and c7 == 1: print('YES') else: print('No')
s945346858
Accepted
18
3,060
202
inpstr = input() inp = inpstr.split(" ") inp = list(map(int,inp)) c5 = 0 c7 = 0 for i in inp: if i==5: c5 += 1 elif i==7: c7 += 1 if c5 == 2 and c7 == 1: print('YES') else: print('NO')
s571431902
p03862
u038353231
2,000
262,144
Wrong Answer
187
14,252
470
There are N boxes arranged in a row. Initially, the i-th box from the left contains a_i candies. Snuke can perform the following operation any number of times: * Choose a box containing at least one candy, and eat one of the candies in the chosen box. His objective is as follows: * Any two neighboring boxes con...
import sys Nx = input().split() an = input().split() anx = list() for item in an: anx.append(int(item)) x = int(Nx[1]) N = int(Nx[0]) i = 0 count = 0 while i < N - 1: sum = anx[i] + anx[i + 1] if sum > x: count+= sum - x num = sum - x anxi = anx[i] anxi -= num ...
s011559602
Accepted
151
14,276
469
import sys Nx = input().split() an = input().split() anx = list() for item in an: anx.append(int(item)) x = int(Nx[1]) N = int(Nx[0]) i = 0 count = 0 while i < N - 1: sum = anx[i] + anx[i + 1] if sum > x: count += sum - x num = sum - x anxi = anx[i+1] anxi -= num ...
s487573814
p03351
u787873596
2,000
1,048,576
Wrong Answer
17
3,060
202
Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either ...
line = input().split(' ') a, b, c, d = int(line[0]), int(line[1]), int(line[2]), int(line[3]) if abs(a-c) < d: print('Yes') else: if abs(a-b) < d and abs(b-c) < d: print('Yes') else: print('No')
s136545194
Accepted
17
2,940
207
line = input().split(' ') a, b, c, d = int(line[0]), int(line[1]), int(line[2]), int(line[3]) if abs(a-c) <= d: print('Yes') else: if abs(a-b) <= d and abs(b-c) <= d: print('Yes') else: print('No')
s888754158
p03251
u357751375
2,000
1,048,576
Wrong Answer
24
9,040
200
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes incli...
n,m,x,y = map(int,input().split()) a = list(map(int,input().split())) b = list(map(int,input().split())) a.sort(reverse = True) b.sort() if b[0] - a[0] < 2: print('War') else: print('No War')
s118737595
Accepted
30
9,112
215
n,m,x,y = map(int,input().split()) xl = list(map(int,input().split())) yl = list(map(int,input().split())) xl.append(x) yl.append(y) xl.sort() yl.sort() if xl[-1] < yl[0]: print('No War') else: print('War')
s922995368
p03545
u442581202
2,000
262,144
Wrong Answer
18
3,064
364
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 in...
import itertools s = input() x = ['+','-'] l = list(itertools.product(x,x,x)) res = int(s[0]) for sign in l: res = int(s[0]) for i in range(3): if sign[i] == '+': res += int(s[i+1]) else: res -= int(s[i+1]) if res == 7: print(s[0],end="") for i in range(3): print(sign[i],end=...
s152123532
Accepted
17
3,064
379
import itertools s = input() x = ['+','-'] l = list(itertools.product(x,x,x)) res = int(s[0]) for sign in l: res = int(s[0]) for i in range(3): if sign[i] == '+': res += int(s[i+1]) else: res -= int(s[i+1]) if res == 7: print(s[0],end="") for i in range(3): print(sign[i],end=...
s486594913
p02612
u070630744
2,000
1,048,576
Wrong Answer
39
10,436
200
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.
import math import collections import fractions import itertools import functools import operator def solve(): print(int(input()) - 1000) return 0 if __name__ == "__main__": solve() 1900
s402852391
Accepted
41
10,440
225
import math import collections import fractions import itertools import functools import operator def solve(): n = int(input()) print(math.ceil(n/1000)*1000 - n) return 0 if __name__ == "__main__": solve()
s336239176
p03719
u393971002
2,000
262,144
Wrong Answer
17
2,940
91
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
a, b, c = map(int, input().split()) if a <= c <= b: print("YES") else: print("NO")
s469563898
Accepted
17
2,940
91
a, b, c = map(int, input().split()) if a <= c <= b: print("Yes") else: print("No")
s144064895
p03623
u852790844
2,000
262,144
Wrong Answer
24
3,768
133
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...
import string s = set(input()) a = set(string.ascii_lowercase) b = sorted(list(a - s)) ans = b[0] if len(b) else "None" print(ans)
s878257952
Accepted
150
12,392
114
import numpy as np x, a, b = map(int, input().split()) ans = 'A' if np.abs(a-x) < np.abs(b-x) else 'B' print(ans)
s018213705
p02742
u579508806
2,000
1,048,576
Wrong Answer
17
2,940
57
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 to...
(a,b)=[int(x) for x in input().split()] print((a+b+1)//2)
s920298113
Accepted
17
2,940
93
(a,b)=[int(x) for x in input().split()] if a==1 or b==1: print(1) else: print((a*b+1)//2)
s148842826
p02854
u879478232
2,000
1,048,576
Wrong Answer
2,105
26,220
210
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 po...
import sys n = int(input()) a = list(map(int, input().split())) postCenter=dif=0 tmp = sys.maxsize for i in range(n): if tmp < abs(sum(a[:i])-sum(a[i:])): tmp = abs(sum(a[:i])-sum(a[i:])) print(tmp)
s069476453
Accepted
179
26,220
170
import sys n = int(input()) a = list(map(int, input().split())) tmp=sys.maxsize s = sum(a) t = 0 for i in range(n): t += a[i] tmp = min(tmp,abs(s-t*2)) print(tmp)
s701638875
p03448
u295043075
2,000
262,144
Wrong Answer
188
21,804
331
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 co...
import numpy A = int(input()) B = int(input()) C = int(input()) X = int(input()) vA=list(range(A+1))*(B+1)*(C+1) vB=list(range(B+1))*(A+1)*(C+1) vC=list(range(C+1))*(A+1)*(B+1) Com=len(vA) O = numpy.matrix([500,100,50]) P = numpy.matrix(vA+vB+vC).reshape(3,Com) Q = O*P ans=numpy.sum(Q==X) print(ans)
s839475885
Accepted
198
19,844
401
import numpy A = int(input()) B = int(input()) C = int(input()) X = int(input()) lisA=list(range(A+1)) lisB=list(range(B+1)) lisC=list(range(C+1)) vA=numpy.repeat(lisA, len(lisB)*len(lisC)) vB=numpy.repeat(len(lisA)*lisB, len(lisC)) vC=numpy.repeat(len(lisA)*len(lisB)*lisC,1) O = numpy.matrix([500,100,50]) P = nu...
s026486983
p03494
u360038884
2,000
262,144
Time Limit Exceeded
2,104
5,488
348
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() list = [int(i) for i in input().split()] count = 0 flg = False while True: for num in list: if num % 2 != 0: flg = True break if flg: break else: count += 1 list = map(lambda x: x / 2, list) print(count)
s141817241
Accepted
19
3,060
305
n = input() list = [int(i) for i in input().split()] min_count = 1000000000 tmp = 0 for num in list: tmp = 0 while True: if num % 2 != 0: break else: tmp += 1 num = num / 2 if min_count > tmp: min_count = tmp print(min_count)
s898370552
p02396
u108130680
1,000
131,072
Wrong Answer
50
5,596
96
In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets. Write a program which reads an integer x and print it as is. Note that multiple datasets are give...
i = 1 while True: x = int(input()) if x == 0: break print('Case i : x')
s604525328
Accepted
140
5,600
119
c = 1 while True: x = int(input()) if x == 0: break print("Case {}: {}".format(c, x)) c += 1
s395174597
p03455
u243699903
2,000
262,144
Wrong Answer
18
2,940
68
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
a,b=map(int,input().split()) print("Odd" if (a*b)%2==0 else "Even")
s538892606
Accepted
17
2,940
68
a,b=map(int,input().split()) print("Odd" if (a*b)%2==1 else "Even")
s284799149
p02613
u735542540
2,000
1,048,576
Wrong Answer
147
9,196
300
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`,...
n = int(input()) ac = 0 wa = 0 tle = 0 re = 0 for i in range(n): s = input() if s == "AC": ac += 1 elif s == "WA": wa += 1 elif s == "TLE": tle += 1 else: re += 1 print(f"AC × {ac}") print(f"WA × {wa}") print(f"TLE × {tle}") print(f"RE × {re}")
s566424046
Accepted
149
9,140
296
n = int(input()) ac = 0 wa = 0 tle = 0 re = 0 for i in range(n): s = input() if s == "AC": ac += 1 elif s == "WA": wa += 1 elif s == "TLE": tle += 1 else: re += 1 print(f"AC x {ac}") print(f"WA x {wa}") print(f"TLE x {tle}") print(f"RE x {re}")
s205284244
p02614
u571331348
1,000
1,048,576
Wrong Answer
68
9,084
566
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...
H, W, K = [int(x) for x in input().split()] init_map = [] for i in range(H): row = list(input()) init_map.append(row) #print(init_map) ans = 0 for paint_h in range(2 ** H): print("h: " + str(paint_h)) for paint_w in range(2 ** W): print("w: " + str(paint_w)) cnt = 0 for i in...
s563946404
Accepted
64
9,196
568
H, W, K = [int(x) for x in input().split()] init_map = [] for i in range(H): row = list(input()) init_map.append(row) #print(init_map) ans = 0 for paint_h in range(2 ** H): #print("h: " + str(paint_h)) for paint_w in range(2 ** W): #print("w: " + str(paint_w)) cnt = 0 f...
s572388574
p03644
u597047658
2,000
262,144
Wrong Answer
17
3,068
227
Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can...
# N = input() N = 100 tnum = 0 iter_num = 0 for i in range(N): res = 0 num = i+1 while num % 2 == 0: num /= 2 res += 1 if iter_num < res: iter_num = res tnum = i+1 print(tnum)
s477557965
Accepted
17
2,940
223
N = int(input()) tnum = 0 iter_num = 0 for i in range(N): res = 0 num = i+1 while num % 2 == 0: num /= 2 res += 1 if iter_num <= res: iter_num = res tnum = i+1 print(tnum)
s869212552
p03377
u765400831
2,000
262,144
Wrong Answer
19
2,940
115
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
A,B,X = map(int,input().split()) if (X < A): print("No") elif ((X-A)<=B): print("Yes") else: print("No")
s007049716
Accepted
17
2,940
114
A,B,X = map(int,input().split()) if (X<A): print("NO") elif ((X-A)<=B): print("YES") else: print("NO")
s814812822
p02694
u431225094
2,000
1,048,576
Wrong Answer
21
9,176
286
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 abo...
import sys try: sys.stdin = open(sys.path[0] + '\\input.txt', 'r') sys.stdout = open(sys.path[0] + '\\output.txt', 'w') except FileNotFoundError: pass x = int(input()) n = 100 t = 0 while n <= x: n += (0.01 * n) n = int(n) t += 1 # print(n, t) print(t)
s017541678
Accepted
23
9,180
285
import sys try: sys.stdin = open(sys.path[0] + '\\input.txt', 'r') sys.stdout = open(sys.path[0] + '\\output.txt', 'w') except FileNotFoundError: pass x = int(input()) n = 100 t = 0 while n < x: n += (0.01 * n) n = int(n) t += 1 # print(n, t) print(t)
s492046625
p03494
u902361509
2,000
262,144
Wrong Answer
17
3,060
247
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.
a = list(map(int, input().split())) ans = 0 while(True): t = True for i in a: if i%2: t = False if t == True: ans += 1 a = list(map(lambda j: j/2, a)) else: break print(str(ans))
s087607562
Accepted
18
2,940
246
n = input() a = list(map(int, input().split())) ans = 0 while(True): t = True for i in a: if i%2: t = False if t: ans += 1 a = [int(x/2) for x in a] else: break print(str(ans))
s077391260
p03433
u331672674
2,000
262,144
Wrong Answer
20
2,940
100
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
# -*- coding: utf-8 -*- n = int(input()) a = int(input()) print("YES" if (n % 500) <= a else "NO")
s764109043
Accepted
17
2,940
100
# -*- coding: utf-8 -*- n = int(input()) a = int(input()) print("Yes" if (n % 500) <= a else "No")
s863613226
p03679
u104888971
2,000
262,144
Wrong Answer
17
2,940
152
Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though. Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Ot...
X, A, B = map(int, input().split()) print(X, A, B) if A >= B: print('delicious') elif A + X >= B: print('safe') else: print('dangerous')
s953492471
Accepted
17
2,940
136
X, A, B = map(int, input().split()) if A >= B: print('delicious') elif A + X >= B: print('safe') else: print('dangerous')
s475870742
p03417
u736729525
2,000
262,144
Wrong Answer
17
2,940
225
There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following op...
def solve(N, M): # 1 2 # 3 4 # # (0) (1) # 1 2 1 2 3 # 3 4 4 5 6 # 5 6 7 8 9 return max(1, (N - 2)) * max(1, (M - 2)) N, M = [int(x) for x in input().split()] print(solve(N, M))
s805940227
Accepted
18
2,940
347
def solve(N, M): # 1 2 # 3 4 # 1 2 # 3 4 # # (0) (1) # 1 2 1 2 3 # 3 4 4 5 6 # 5 6 7 8 9 def cut(n): if n == 1: return 1 elif n == 2: return 0 return n - 2 return cut(N) * cut(M) N, M = [int(x) for x in input().s...