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
s689595127
p03048
u631019293
2,000
1,048,576
Wrong Answer
2,104
11,600
337
Snuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes: * Red boxes, each containing R red balls * Green boxes, each containing G green balls * Blue boxes, each containing B blue balls Snuke wants to get a total of exactly N balls by buying r red boxes, g...
r,g,b,n=list(map(int,input().split())) i,j,k=0,0,0 R,G,B=0,0,0 c=0 while R<n: R=r*i print(R) while G<=n-R: G=g*j print(G) B,k=0,0 while B<=n-R-G: B=b*k print(B) if n-R-G-B==0: c+=1 k+=1 j+=1 i+=1 ...
s122792185
Accepted
1,874
3,060
171
r,g,b,n=list(map(int,input().split())) i,j=0,0 R,G=0,0 c=0 while R<=n: while G<=n-R: if (n-R-G)%b==0: c+=1 G+=g G=0 R+=r print(c)
s170141948
p03587
u189762886
2,000
262,144
Wrong Answer
17
2,940
14
Snuke prepared 6 problems for a upcoming programming contest. For each of those problems, Rng judged whether it can be used in the contest or not. You are given a string S of length 6. If the i-th character of s is `1`, it means that the i-th problem prepared by Snuke is accepted to be used; `0` means that the problem...
print(input())
s966425222
Accepted
17
2,940
86
a = input() l = [] for i in str(a): if i == '1': l.append(i) print(len(l))
s847631410
p03578
u367130284
2,000
262,144
Wrong Answer
2,105
35,992
183
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....
n=int(input()) s=input().split() m=int(input()) for t in input().split(): if t in s: s.remove(t) continue else: print("No") exit() print("Yes")
s448027043
Accepted
342
67,680
223
from collections import* n=int(input()) d=Counter(map(int,input().split())) m=int(input()) t=Counter(map(int,input().split())) #print(d,t) for k,v in t.items(): if d[k]<v: print("NO") exit() print("YES")
s357664621
p03605
u102126195
2,000
262,144
Wrong Answer
17
2,940
73
It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
N = input() if N[0] == 9 or N[1] == 9: print("Yes") else: print("No")
s527859856
Accepted
17
2,940
78
N = input() if N[0] == "9" or N[1] == "9": print("Yes") else: print("No")
s098227762
p04044
u762540523
2,000
262,144
Wrong Answer
20
3,060
55
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is _lexicographically sm...
_=input();print("".join(sorted(list(input().split()))))
s083085584
Accepted
17
3,060
50
print("".join(sorted(open(0).read().split()[2:])))
s134358858
p03711
u293267652
2,000
262,144
Wrong Answer
18
3,060
253
Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below. Given two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.
a = [1,3,5,7,8,10,12] b = [4,6,9,11] x,y = map(int,(input().split())) cou1 = 0 cou2 = 0 for i in a: if i==x or i==y: cou1 += 1 for i in b: if i==x or i==y: cou2 += 1 if cou1>1 or cou2>1: print("YES") else: print("NO")
s619416470
Accepted
17
3,064
252
a = [1,3,5,7,8,10,12] b = [4,6,9,11] x,y = map(int,(input().split())) cou1 = 0 cou2 = 0 for i in a: if i==x or i==y: cou1 += 1 for i in b: if i==x or i==y: cou2 += 1 if cou1>1 or cou2>1: print("Yes") else: print("No")
s161574611
p02390
u911624488
1,000
131,072
Wrong Answer
30
7,576
102
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 = int((S % 3600) % 60) s = (S % 60) print("{}:{}:{}".format(h,m,s))
s703697404
Accepted
30
7,656
102
S = int(input()) h = (S // 3600) m = ((S % 3600) // 60) s = (S % 60) print("{}:{}:{}".format(h,m,s))
s879070474
p03434
u912652535
2,000
262,144
Wrong Answer
18
3,060
191
We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the c...
N = int(input()) l = list(map(int,input().split())) l_r = sorted(l,reverse=True) Alice = l_r[::2] Bob = l_r[1::2] m =0 n = 0 for i in Alice: m += i for j in Bob: n += j print({m-n})
s102104801
Accepted
17
3,060
1,147
# a = int(input()) # b,c = map(int, input().split()) # print('{} {}'.format(a+b+c,s)) # # a,b = map(int, input().split()) # if a*b%2 == 0: # print("Even") # else : # print("Odd") # l = list(input()) # l_new = [int(n) for n in l] # count = 0 # count += 1 # print(count) # ans = 10 **9 # N = int(input(...
s926624002
p03129
u428132025
2,000
1,048,576
Wrong Answer
17
2,940
86
Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.
n, k = map(int, input().split()) if n >= 2*k-1: print('Yes') else: print('No')
s034890307
Accepted
17
2,940
86
n, k = map(int, input().split()) if n >= 2*k-1: print('YES') else: print('NO')
s910946493
p03730
u134019875
2,000
262,144
Wrong Answer
17
2,940
243
We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objecti...
a, b, c = map(int, input().split()) L = [0] * b for i in range(1, b): s = (a * i) % b if L[s] == 1: print('No') break elif s == c: print('Yes') break else: L[s] = 1 else: print('No')
s188624752
Accepted
18
3,060
243
a, b, c = map(int, input().split()) L = [0] * b for i in range(1, b): s = (a * i) % b if L[s] == 1: print('NO') break elif s == c: print('YES') break else: L[s] = 1 else: print('NO')
s578549726
p03693
u768993705
2,000
262,144
Wrong Answer
17
2,940
56
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 i...
print('NO' if int(input().replace(' ',''))%4 else 'Yes')
s606069522
Accepted
17
2,940
56
print('NO' if int(input().replace(' ',''))%4 else 'YES')
s561391594
p03251
u713830790
2,000
1,048,576
Wrong Answer
20
3,316
440
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...
if __name__ == '__main__': N, M, X, Y = list(map(int, input().split())) x = list(map(int, input().split())) y = list(map(int, input().split())) mx = max(x) my = min(y) if mx >= my: print("War") else: m_list = [i for i in range(mx+1, my+1)] cap = [i for i in range(X+...
s927320309
Accepted
17
3,064
300
if __name__ == '__main__': N, M, X, Y = list(map(int, input().split())) x = list(map(int, input().split())) y = list(map(int, input().split())) mx = max(x) my = min(y) lx = max(mx, X) ly = min(my, Y) if lx < ly: print("No War") else: print("War")
s829692434
p03997
u340294296
2,000
262,144
Wrong Answer
17
2,940
74
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)
s269883482
Accepted
17
2,940
79
a = int(input()) b = int(input()) h = int(input()) print(int((a + b) * h / 2))
s372709839
p03438
u285891772
2,000
262,144
Wrong Answer
47
12,064
1,054
You are given two integer sequences of length N: a_1,a_2,..,a_N and b_1,b_2,..,b_N. Determine if we can repeat the following operation zero or more times so that the sequences a and b become equal. Operation: Choose two integers i and j (possibly the same) between 1 and N (inclusive), then perform the following two ac...
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2 from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby from operator import itemgetter, mul...
s458559572
Accepted
48
11,884
1,137
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby from operator import itemgetter...
s469751835
p03546
u523087093
2,000
262,144
Wrong Answer
61
9,568
443
Joisino the magical girl has decided to turn every single digit that exists on this world into 1. Rewriting a digit i with j (0≤i,j≤9) costs c_{i,j} MP (Magic Points). She is now standing before a wall. The wall is divided into HW squares in H rows and W columns, and at least one square contains a digit between 0 and...
H, W = map(int, input().split()) C = [list(map(int, input().split())) for _ in range(10)] A = [list(map(int, input().split())) for _ in range(H)] for k in range(10): for i in range(10): for j in range(10): C[i][j] = min(C[i][j], C[i][k] + C[k][j]) answer = 0 for i in range(H): for j in ran...
s381844694
Accepted
45
9,464
420
H, W = map(int, input().split()) C = [list(map(int, input().split())) for _ in range(10)] A = [list(map(int, input().split())) for _ in range(H)] for k in range(10): for i in range(10): for j in range(10): C[i][j] = min(C[i][j], C[i][k] + C[k][j]) answer = 0 for i in range(H): for j in ran...
s395321293
p02795
u357758400
2,000
1,048,576
Wrong Answer
17
3,060
229
We have a grid with H rows and W columns, where all the squares are initially white. You will perform some number of painting operations on the grid. In one operation, you can do one of the following two actions: * Choose one row, then paint all the squares in that row black. * Choose one column, then paint all t...
h = int(input()) w = int(input()) n = int(input()) if h >= w: cnt = int(n // h) if not isinstance(n // h, int): cnt += 1 else: cnt = int(n // w) if not isinstance(n // w, int): cnt += 1 print(cnt)
s109004589
Accepted
17
3,060
196
h = int(input()) w = int(input()) n = int(input()) if h >= w: cnt = int(n // h) if n % h != 0 : cnt += 1 else: cnt = int(n // w) if n % w != 0: cnt += 1 print(cnt)
s217755039
p03543
u296150111
2,000
262,144
Wrong Answer
17
2,940
80
We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**. You are given a 4-digit integer N. Answer the question: Is N **good**?
n=int(input()) if n/10%111==0 or n%1000%111==0: print("Yes") else: print("No")
s294196139
Accepted
17
2,940
83
n=int(input()) if n//10%111==0 or n%1000%111==0: print("Yes") else: print("No")
s305168624
p02742
u112317104
2,000
1,048,576
Wrong Answer
18
2,940
142
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...
def solve(): N, M = map(int, input().split()) if N*M % 2 == 0: return N*M/2 else: return (N*M//2)+1 print(solve())
s430209823
Accepted
17
3,060
311
def solve(): N, M = map(int, input().split()) if N == 1: return 1 if M == 1: return 1 if N % 2 == 0: return M * N // 2 else: a = N // 2 * M if M % 2 == 0: return a + M//2 else: return a + (M//2 + 1) print(solve())
s323537722
p03854
u939552576
2,000
262,144
Wrong Answer
136
4,240
510
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() q = [0] flag = False while len(s) > 0: if s[0:5] in ['dream','erase'] and flag == False: q.append(s[0:5]) s = s[5:] flag = False elif s[0:6] == 'eraser': q.append(s[0:6]) s = s[6:] flag = False elif s[0:7] == 'dreamer': q.append(s[0:7]) ...
s786417959
Accepted
130
4,248
510
s = input() q = [0] flag = False while len(s) > 0: if s[0:5] in ['dream','erase'] and flag == False: q.append(s[0:5]) s = s[5:] flag = False elif s[0:6] == 'eraser': q.append(s[0:6]) s = s[6:] flag = False elif s[0:7] == 'dreamer': q.append(s[0:7]) ...
s339186792
p02665
u822662438
2,000
1,048,576
Wrong Answer
121
20,008
418
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_li = list(map(int, input().split())) ans = 0 li = [0]*(n+1) for i,a in enumerate(a_li): ans += (i+1)*a for i,a in enumerate(a_li[::-1]): if i >= 1: li[i] = li[i-1]+a else: li[i] = a li = li[::-1] flag = True ne = 0.5 for i in range(n+1): if li[i] > 2*ne: ans -= li[i] -2*ne ...
s549115443
Accepted
922
20,136
487
n = int(input()) a_li = list(map(int, input().split())) ans = 0 li = [0]*(n+1) for i,a in enumerate(a_li): ans += (i+1)*a for i,a in enumerate(a_li[::-1]): if i >= 1: li[i] = li[i-1]+a else: li[i] = a li = li[::-1] flag = True ne = 0.5 for i in range(n+1): if li[i] > 2*ne: ans -= li[i] -int(2...
s552845964
p03448
u014724123
2,000
262,144
Wrong Answer
54
3,060
270
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...
a = int(input()) b = int(input()) c = int(input()) x = int(input()) counter = 0 for i in range(a): for j in range(b): for k in range(c): total = 500 * i + 100 * j + 50 * k if total == x: counter += 1 print(counter)
s938419001
Accepted
55
3,060
291
a = int(input()) b = int(input()) c = int(input()) x = int(input()) counter = 0 for i in range(0, a+1): for j in range(0, b+1): for k in range(0, c+1): total = (500 * i) + (100 * j) + (50 * k) if total == x: counter += 1 print(counter)
s611960098
p03693
u556657484
2,000
262,144
Wrong Answer
17
2,940
98
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 i...
r, g, b = map(int, input().split()) if ((10 * g + b) % 4): print("Yes") else: print("No")
s150049581
Accepted
17
2,940
103
r, g, b = map(int, input().split()) if ((10 * g + b) % 4 == 0): print("YES") else: print("NO")
s374388132
p04030
u729535891
2,000
262,144
Wrong Answer
18
2,940
274
Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this stri...
S = input() keybord = [s for s in S] editor = '' for i in range(len(S)): if keybord[i] == '0': editor += '0' elif keybord[i] == '1': editor += '1' else: if editor == '': continue else: editor = editor[:-1]
s945006810
Accepted
18
3,060
288
S = input() keybord = [s for s in S] editor = '' for i in range(len(S)): if keybord[i] == '0': editor += '0' elif keybord[i] == '1': editor += '1' else: if editor == '': continue else: editor = editor[:-1] print(editor)
s561780031
p03720
u846372029
2,000
262,144
Wrong Answer
17
3,064
221
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?
# Counting Roads n,m = list(map(int, input().split())) a = [] for i in range(m): a.append( list(map(int, input().split())) ) b = [] for s in a: b.extend(s) print(b) for i in range (n): print(b.count(i+1))
s173008094
Accepted
17
3,060
211
# Counting Roads n,m = list(map(int, input().split())) a = [] for i in range(m): a.append( list(map(int, input().split())) ) b = [] for s in a: b.extend(s) for i in range (n): print(b.count(i+1))
s618604190
p03548
u347640436
2,000
262,144
Wrong Answer
17
2,940
133
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...
X, Y, Z = map(int, input().split()) result = X // (Y + Z) - 1 while X < result * Y + (result + 1) * Z: result += 1 print(result)
s743159051
Accepted
17
2,940
63
X, Y, Z = map(int, input().split()) print((X - Z) // (Y + Z))
s823246681
p03737
u340947941
2,000
262,144
Wrong Answer
17
2,940
100
You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words.
s1,s2,s3=input().split(" ") print(s1[0].upper()+s1[0].upper()+s1[0].upper())
s873706333
Accepted
17
2,940
100
s1,s2,s3=input().split(" ") print(s1[0].upper()+s2[0].upper()+s3[0].upper())
s137831058
p02255
u362520072
1,000
131,072
Wrong Answer
20
5,600
265
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 ...
def insertionSort(A, N): for i in range(1, N): v = A[i] j = i - 1 while j >= 0 and A[j] > v: A[j + 1] = A[j] j -= 1 A[j + 1] = v print(' '.join(map(str, A))) N = int(input()) A = list(map(int, input().split())) insertionSort(A,N)
s009968662
Accepted
20
5,600
296
def insertionSort(A, N): print(' '.join(map(str, A))) for i in range(1, N): v = A[i] j = i - 1 while j >= 0 and A[j] > v: A[j + 1] = A[j] j -= 1 A[j + 1] = v print(' '.join(map(str, A))) N = int(input()) A = list(map(int, input().split())) insertionSort(A,N)
s544045447
p03696
u156815136
2,000
262,144
Wrong Answer
53
5,660
1,631
You are given a string S of length N consisting of `(` and `)`. Your task is to insert some number of `(` and `)` into S to obtain a _correct bracket sequence_. Here, a correct bracket sequence is defined as follows: * `()` is a correct bracket sequence. * If X is a correct bracket sequence, the concatenation of...
from statistics import median #import collections from fractions import gcd from itertools import combinations from collections import deque from collections import defaultdict import bisect # # d = m - k[i] - k[j] # # # # # import sys sys.setrecursionlimit(10000000) mod = 10**9 + 7 def readInts(): return li...
s039279625
Accepted
37
10,340
1,250
#from statistics import median #import collections from math import gcd from itertools import combinations,permutations,accumulate, product #from collections import deque from collections import deque,defaultdict,Counter import decimal import re import math import bisect import heapq # # # # # # my_round_int = lambd...
s231153563
p03048
u909991537
2,000
1,048,576
Wrong Answer
2,104
3,064
385
Snuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes: * Red boxes, each containing R red balls * Green boxes, each containing G green balls * Blue boxes, each containing B blue balls Snuke wants to get a total of exactly N balls by buying r red boxes, g...
r, g, b, n = (int(i) for i in input().split()) rmax = int(n/r) gmax = int(n/g) count = 0 i = 0 j = 0 k = 0 for i in range(0, rmax + 1): for j in range(0, gmax + 1): if ((n - r * i - g * j) % b == 0 and (n - r * i - g * j)>0): count += 1 for i in range(0, rmax + 1): for j in range(0, gmax + 1): i...
s118114397
Accepted
1,845
3,060
260
r, g, b, n = (int(i) for i in input().split()) rmax = int(n/r) count = 0 for i in range(0, rmax + 1): gmax = (n - r * i) // g for j in range(0, gmax + 1): tmp = n - r * i - g * j if (tmp % b == 0 and tmp >=0): count += 1 print(count)
s251087146
p03997
u596276291
2,000
262,144
Wrong Answer
23
3,064
142
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.
def main(): a = int(input()) b = int(input()) h = int(input()) print((a + b) * h / 2) if __name__ == '__main__': main()
s800272402
Accepted
37
4,200
781
from collections import defaultdict, Counter from itertools import product, groupby, count, permutations, combinations from math import pi, sqrt from collections import deque from bisect import bisect, bisect_left, bisect_right from string import ascii_lowercase from functools import lru_cache import sys sys.setrecursi...
s639238475
p03719
u255555420
2,000
262,144
Wrong Answer
17
2,940
93
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
abc = (input()) a,b,c = abc.split() if c>=a and c<=b: print("YES") else: print("NO")
s372378228
Accepted
17
2,940
84
A,B,C =map(int,input().split()) if A<=C<=B: print("Yes") else: print("No")
s877837978
p03449
u537034351
2,000
262,144
Wrong Answer
34
9,200
271
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()) candies_i = list(map(int, input().split())) candies_j = list(map(int, input().split())) l = [] for i in range(N): total_li = sum(candies_i[:i]) total_lj = sum(candies_j[i:]) total = ( total_li + total_lj ) l.append(total) print(max(l))
s988828540
Accepted
29
9,116
270
N = int(input()) candies_i = list(map(int, input().split())) candies_j = list(map(int, input().split())) l = [] for i in range(N): total_li = sum(candies_i[:i+1]) total_lj = sum(candies_j[i:]) total = total_li + total_lj l.append(total) print(max(l))
s642120510
p02261
u409571842
1,000
131,072
Wrong Answer
30
6,352
1,315
Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1. Your task is to write a program which sorts a given set of cards in ascending order by their values using the Bubbl...
#coding: UTF-8 import copy class Algo: @staticmethod def bubbleSort(r, c, n): print(r) print(c) tmp_r, tmp_c = r, c flag = 1 while flag: flag = 0 for j in range(n-1, 0, -1): if tmp_c[j] < tmp_c[j-1]: tmp_c[j], tmp_c[j-1] = tmp_c[j-1], tmp_c[j] tmp_r[j], t...
s667513051
Accepted
30
6,348
1,119
#coding: UTF-8 import copy class Algo: @staticmethod def bubbleSort(r, c, n): flag = 1 while flag: flag = 0 for j in range(n-1, 0, -1): if c[j] < c[j-1]: c[j], c[j-1] = c[j-1], c[j] r[j], r[j-1] = r[j-1], r[j] flag = 1 return r def selectionSort(r, c...
s643272828
p03503
u319612498
2,000
262,144
Wrong Answer
17
3,068
18
Joisino is planning to open a shop in a shopping street. Each of the five weekdays is divided into two periods, the morning and the evening. For each of those ten periods, a shop must be either open during the whole period, or closed during the whole period. Naturally, a shop must be open during at least one of those ...
N = int(input())
s142348699
Accepted
300
3,064
340
n=int(input()) f=[list(map(int,input().split())) for i in range(n)] p=[list(map(int,input().split())) for i in range(n)] ans=-float("inf") for i in range(1,1<<10): tot=0 for k in range(n): bit=0 for j in range(10): if i&(1<<j) and f[k][j]==1: bit+=1 tot+=p[k][bit] ans=max...
s427529678
p02267
u591467586
1,000
131,072
Wrong Answer
20
7,560
251
You are given a sequence of _n_ integers S and a sequence of different _q_ integers T. Write a program which outputs C, the number of integers in T which are also in the set S.
n1 = int(input()) s = (input()).split() n2 = int(input()) t = (input()).split() m = [] for i in range(0, n1): key = s[i] for j in range(0, n2): if t[j] == s[i]: m.append(t[j]) break print(len(m))
s602297686
Accepted
110
8,188
256
n1 = int(input()) s = (input()).split() n2 = int(input()) t = (input()).split() m = [] for i in range(0, n2): key = t[i] for j in range(0, n1): if s[j] == t[i]: m.append(s[j]) break print(len(m))
s660634939
p04043
u677393869
2,000
262,144
Wrong Answer
17
2,940
89
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each ...
A=[] A.append(map(int,input().split())) if A==[5,7,5]: print("YES") else: print("NO")
s699576747
Accepted
17
3,060
172
A,B,C=map(int,input().split()) five=0 seven=0 for i in [A,B,C]: if i==5: five+=1 elif i==7: seven+=1 if five==2 and seven==1: print("YES") else: print("NO")
s423974647
p03433
u665598835
2,000
262,144
Wrong Answer
17
2,940
87
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")
s078181867
Accepted
17
2,940
87
N = int(input()) A = int(input()) if N%500 <= A: print("Yes") else: print("No")
s752206474
p04044
u260036763
2,000
262,144
Wrong Answer
17
3,060
105
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is _lexicographically sm...
N, L = map(int, input().split()) S = [input() for i in range(N)] S.sort(reverse = True) print(''.join(S))
s324825849
Accepted
17
3,060
91
N, L = map(int, input().split()) S = [input() for i in range(N)] S.sort() print(''.join(S))
s486105119
p03644
u060537418
2,000
262,144
Wrong Answer
32
9,120
84
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=int(input()) ans=0 for i in range(10): if n>=(2**i): ans=i print(2**i)
s500841971
Accepted
30
9,176
103
n=int(input()) anslist=[1,2,4,8,16,32,64] ans=0 for i in anslist: if n>=i: ans=i print(ans)
s335182637
p02612
u193597115
2,000
1,048,576
Wrong Answer
31
9,092
107
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.
def payment(N): return N % 1000 if __name__ == '__main__': N = int(input()) print(payment(N))
s483973232
Accepted
25
9,136
167
def payment(N): if N % 1000 == 0: return 0 else: return 1000 - N % 1000 if __name__ == '__main__': N = int(input()) print(payment(N))
s982641132
p03455
u265118937
2,000
262,144
Wrong Answer
17
2,940
100
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 // 2 == 1 or b // 2 == 1: print("Odd") else: print("Even")
s084268500
Accepted
17
2,940
103
a, b = map(int, input().split()) if (a % 2 == 1) and (b % 2 == 1): print("Odd") else: print("Even")
s025324249
p02612
u734936991
2,000
1,048,576
Wrong Answer
32
9,028
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 % 1000)
s240026677
Accepted
29
9,156
77
n = int(input()) ans = 0 if n % 1000 == 0 else 1000 - (n % 1000) print(ans)
s735879725
p02841
u690536347
2,000
1,048,576
Wrong Answer
17
2,940
95
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()) print(1 if m1!=d1 else 0)
s760616322
Accepted
20
2,940
95
m1, d1 = map(int, input().split()) m2, d2 = map(int, input().split()) print(1 if m1!=m2 else 0)
s669851538
p02843
u204842730
2,000
1,048,576
Wrong Answer
1,588
3,064
324
AtCoder Mart sells 1000000 of each of the six items below: * Riceballs, priced at 100 yen (the currency of Japan) each * Sandwiches, priced at 101 yen each * Cookies, priced at 102 yen each * Cakes, priced at 103 yen each * Candies, priced at 104 yen each * Computers, priced at 105 yen each Takahashi want...
import sys x = int(input()) if x < 100: print(0) sys.exit() if x > 50000: print(1) sys.exit() for i in range(50): for j in range(50-i): for k in range(50-i-j): for l in range(50-i-j-k): for m in range(50-i-j-k-l): if x - (100*i+101*j+102*k+103*l+104*m) % 105 == 0: print(1) sys.exit() prin...
s495290568
Accepted
17
3,064
294
import sys x = int(input()) n = x % 100 maxbuy = x // 100 ans = 0 if maxbuy > 99: print(1) sys.exit() ans += n//5 n %= 5 ans += n//4 n %= 4 ans += n//3 n %= 3 ans += n//2 n %= 2 if n == 1: if ans+1 <= maxbuy: print(1) else: print(0) else: if ans <= maxbuy: print(1) else: print(0)
s962577760
p03494
u156931988
2,000
262,144
Time Limit Exceeded
2,107
2,940
221
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.
ignore = input() num = map(int,input().split()) count = 0 while True: if(sum([0 if i%2 == 0 else 1 for i in num]) == 0): num = [i/2 for i in num] count += 1 else: print(count) break
s058317400
Accepted
19
3,064
194
import math ignore = input() num = map(int,input().split()) score = [] for i in num: temp = i while i%2 == 0: i = i/2 score.append(temp/i) print(int(math.log(min(score),2)))
s102449186
p02647
u802234211
2,000
1,048,576
Wrong Answer
2,206
33,060
1,120
We have N bulbs arranged on a number line, numbered 1 to N from left to right. Bulb i is at coordinate i. Each bulb has a non-negative integer parameter called intensity. When there is a bulb of intensity d at coordinate x, the bulb illuminates the segment from coordinate x-d-0.5 to x+d+0.5. Initially, the intensity o...
import copy as cp n,k = map(int,input().split()) lamps = list(map(int,input().split())) # print(lamps) lamp_io = [0]*n # print(lamp_io) for j in range(k): for i in range(len(lamps)): if(i == 0): for k in range(1,lamps[i]+1): if(i+k <= n-1): lamp_io[k] += 1 ...
s506801628
Accepted
1,639
136,876
834
from numba import jit @jit def main(): n,k = map(int,input().split()) lamps = list(map(int,input().split())) for ki in range(k): lamplog = [0]*(n+1) for i in range(n): lamplog[max(0,i-lamps[i]) ] += 1 lamplog[min(i+lamps[i]+1,n)] -= 1 # print(lamplog) ...
s504220198
p03485
u728774856
2,000
262,144
Wrong Answer
17
2,940
94
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
a, b = map(int, input().split()) ave = (a + b) / 2 ave = int(ave) ave = ave + 1 print(ave)
s666321157
Accepted
18
3,060
88
import math a, b = map(float, input().split()) ave = (a + b)/ 2 print(math.ceil(ave))
s851489985
p03493
u359007262
2,000
262,144
Wrong Answer
27
8,984
68
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.
def resolve(): s = input() ans = s.count("1") print(ans)
s100784374
Accepted
28
8,936
78
def resolve(): s = input() ans = s.count("1") print(ans) resolve()
s938211676
p02393
u098047375
1,000
131,072
Wrong Answer
20
5,584
62
Write a program which reads three integers, and prints them in ascending order.
a, b, c = map(int, input().split()) print(sorted([a, b, c]))
s192554314
Accepted
20
5,588
94
a, b, c = map(int, input().split()) sort = sorted([a, b, c]) print(sort[0], sort[1], sort[2])
s299988495
p03089
u596505843
2,000
1,048,576
Wrong Answer
2,104
51,700
389
Snuke has an empty sequence a. He will perform N operations on this sequence. In the i-th operation, he chooses an integer j satisfying 1 \leq j \leq i, and insert j at position j in a (the beginning is position 1). You are given a sequence b of length N. Determine if it is possible that a is equal to b after N oper...
n = int(input()) a = list(map(int,input().split())) #n = 3 #a = [1,2,1] def f(a): print(a) if len(a) == 0: return [] for i in range(len(a)): if a[i] == i+1: b = a.copy() b.pop(i) ret = f(b) if ret == [-1]: continue ret.append(i+1) return ret else: cont...
s657465007
Accepted
18
3,064
367
n = int(input()) a = list(map(int,input().split())) acts = [] while True: for i in range(len(a)): idx = len(a)-i-1 if a[idx] == idx+1: a.pop(idx) acts.append(idx+1) break else: print('-1') break if len(a) == 0: acts.reverse() ...
s437904236
p03759
u288430479
2,000
262,144
Wrong Answer
17
2,940
89
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 2*B == A + C : print('Yes') else: print('No')
s570156789
Accepted
18
2,940
89
A,B,C = map(int,input().split()) if 2*B == A + C : print('YES') else: print('NO')
s020304538
p03730
u595375942
2,000
262,144
Wrong Answer
17
2,940
63
We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objecti...
a,b,c=map(int,input().split()) print('YES' if a%b==c else 'NO')
s665869727
Accepted
18
2,940
94
a,b,c=map(int,input().split()) print('YES' if any((a*i)%b==c for i in range(1,b+1) )else 'NO')
s869403597
p04043
u820461302
2,000
262,144
Wrong Answer
17
2,940
167
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 ...
# -*- coding: utf-8 -*- s = input().split(" ") print(s) if s.count('5') == 2 and s.count('7') == 1: print("YES") else: print("NO")
s963287858
Accepted
17
2,940
158
# -*- coding: utf-8 -*- s = input().split(" ") if s.count('5') == 2 and s.count('7') == 1: print("YES") else: print("NO")
s754588366
p03377
u864900001
2,000
262,144
Wrong Answer
17
2,940
99
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()) ans = "No" if A <= X and X <= A+B: ans = "Yes" print(ans)
s367037959
Accepted
17
2,940
103
A, B, X = map(int, input().split()) ans = "NO" if A <= X and X <= A+B: ans = "YES" print(ans)
s686549811
p00005
u500396695
1,000
131,072
Wrong Answer
20
7,672
265
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given a and b.
def GCD(x, y): while x > 0: z = x x = y % x y = z return y def LCM(x, y): X = x / GCD(x, y) Y = y / GCD(x, y) return X * Y * GCD(x, y) import sys L = sys.stdin.readlines() for line in L: x, y = list(map(int, line.split())) print(GCD(x, y), LCM(x, y))
s017432130
Accepted
30
7,624
259
def GCD(a, b): if b > a: return GCD(b, a) elif a % b == 0: return b return GCD(b, a % b) def LCM(a, b): return a * b // GCD(a, b) import sys L = sys.stdin.readlines() for line in L: x, y = list(map(int, line.split())) print(GCD(x, y), LCM(x, y))
s779751290
p02397
u962381052
1,000
131,072
Wrong Answer
20
7,624
149
Write a program which reads two integers x and y, and prints them in ascending order.
while True: x, y = [int(n) for n in input().split()] if x or y: break if x > y: print(x, y) else: print(y, x)
s658314016
Accepted
60
7,572
155
while True: x, y = [int(n) for n in input().split()] if not (x or y): break if x < y: print(x, y) else: print(y, x)
s951443494
p03827
u227082700
2,000
262,144
Wrong Answer
16
2,940
84
You have an integer variable x. Initially, x=0. Some person gave you a string S of length N, and using the string you performed the following operation N times. In the i-th operation, you incremented the value of x by 1 if S_i=`I`, and decremented the value of x by 1 if S_i=`D`. Find the maximum value taken by x duri...
ans=0 x=0 for i in input(): if i=="I":x+=1 else:x-=1 ans=max(x,ans) print(ans)
s496599049
Accepted
18
2,940
99
ans=0 x=0 n=int(input()) for i in input(): if i=="I":x+=1 else:x-=1 ans=max(x,ans) print(ans)
s988964227
p04043
u057993957
2,000
262,144
Wrong Answer
17
2,940
88
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 ...
sets = set(map(int, input().split())) print('Yes' if sets == set([5, 7, 5]) else 'no')
s055448522
Accepted
17
2,940
92
sets = sorted(list(map(int, input().split()))) print('YES' if sets == [5, 5, 7] else 'NO')
s728857022
p02255
u742797815
1,000
131,072
Wrong Answer
30
7,744
264
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 ...
n = int(input()) l = [int(x) for x in input().split()] for i in range(n): if i == 0: continue a = l[i] j = i - 1 while j >= 0 and l[j] > a: l[j+1] = l[j] j = j - 1 l[j+1] = a print(' '.join([str(x) for x in l]))
s953447950
Accepted
20
8,148
203
n = int(input()) l = [int(x) for x in input().split()] for i in range(n): a = l[i] j = i - 1 while j >= 0 and l[j] > a: l[j+1] = l[j] j = j - 1 l[j+1] = a print(*l)
s823238420
p03644
u609061751
2,000
262,144
Wrong Answer
17
2,940
192
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...
import sys input = sys.stdin.readline N = int(input()) ans = -1 for i in range(1, N + 1): cnt = 0 while i % 2 == 0: cnt += 1 i //= 2 ans = max(ans, cnt) print(ans)
s834973021
Accepted
17
3,060
230
import sys input = sys.stdin.readline N = int(input()) ans = [0, -1] for i in range(1, N + 1): cnt = 0 j = i while i % 2 == 0: cnt += 1 i //= 2 if cnt > ans[1]: ans = [j, cnt] print(ans[0])
s686333613
p03556
u347912669
2,000
262,144
Wrong Answer
23
2,940
110
Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer.
n = 81 ans = 0 for i in range(1, 40000)[::-1]: if i * i <= n: ans = i*i break print(ans)
s172845679
Accepted
24
2,940
120
n = int(input()) ans = 0 for i in range(1, 42500)[::-1]: if i * i <= n: ans = i*i break print(ans)
s255157116
p03479
u425762225
2,000
262,144
Wrong Answer
18
3,060
122
As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below: * A consists of integers between X and Y (inclusive). * For each 1\leq i \leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i. Find the maximum possibl...
from math import * def solve(x,y,ans=1): return 1 + ceil(log2(y/x)) X,Y = map(int,input().split()) print(solve(X,Y))
s939851610
Accepted
28
9,104
143
X,Y = map(int,input().split()) def solve(now,y,ans=0): ans = 0 while now <= y: ans += 1 now *= 2 return ans print(solve(X,Y))
s218390945
p03597
u287880059
2,000
262,144
Wrong Answer
18
2,940
49
We have an N \times N square grid. We will paint each square in the grid either black or white. If we paint exactly A squares white, how many squares will be painted black?
n = int(input()) a = int(input()) print(a**2-a)
s111709960
Accepted
17
2,940
46
N = int(input()) A = int(input()) print(N*N-A)
s924913318
p03251
u412563426
2,000
1,048,576
Wrong Answer
17
3,064
301
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...
import sys input = sys.stdin.readline n, m, X, Y = map(int, input().split()) x = map(int, input().split()) y = map(int, input().split()) x_max = max(x) y_min = min(y) for i in range(X + 1, Y + 1): if x_max < i and i <= y_min: print(i) print('No War') exit() print('War')
s149522884
Accepted
17
3,064
285
import sys input = sys.stdin.readline n, m, X, Y = map(int, input().split()) x = map(int, input().split()) y = map(int, input().split()) x_max = max(x) y_min = min(y) for i in range(X + 1, Y + 1): if x_max < i and i <= y_min: print('No War') exit() print('War')
s540466607
p03544
u735008991
2,000
262,144
Wrong Answer
17
2,940
71
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers. You are given an integer N. Find the N-th Lucas number. Here, the i-th Lucas number L_i is defined as follows: * L_0=2 * L_1=1 * L_i=L_{i-1}+L_{i-2} (i≥2)
a, b = 2, 1 for i in range(int(input())-1): a, b = b, a+b print(a)
s061454137
Accepted
17
2,940
71
a, b = 2, 1 for i in range(int(input())-1): a, b = b, a+b print(b)
s678442263
p03698
u244434589
2,000
262,144
Wrong Answer
26
8,868
123
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.
s = input() l = [] for i in s: if i in l: print('No') exit() else: l.append(i) print('Yes')
s729695775
Accepted
27
9,028
124
s = input() l = [] for i in s: if i in l: print('no') exit() else: l.append(i) print('yes')
s206316845
p03544
u857330600
2,000
262,144
Wrong Answer
19
3,060
83
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers. You are given an integer N. Find the N-th Lucas number. Here, the i-th Lucas number L_i is defined as follows: * L_0=2 * L_1=1 * L_i=L_{i-1}+L_{i-2} (i≥2)
l=[2,1] n=int(input()) i=0 while i!=n: l.append(l[i]+l[i+1]) i+=1 print(l[n-1])
s567657667
Accepted
17
2,940
81
l=[2,1] n=int(input()) i=0 while i!=n: l.append(l[i]+l[i+1]) i+=1 print(l[n])
s019087952
p03592
u952708174
2,000
262,144
Wrong Answer
263
2,940
165
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()] ans = 'No' for j in range(N+1): for k in range(M+1): if j * (M - 2) + k * (N - 2) == K: ans = 'Yes' print(ans)
s963836926
Accepted
312
3,060
165
N,M,K = [int(i) for i in input().split()] ans = 'No' for j in range(N+1): for k in range(M+1): if j * (M - k) + k * (N - j) == K: ans = 'Yes' print(ans)
s489557370
p03400
u578694888
2,000
262,144
Wrong Answer
18
3,060
158
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 ...
# -*- coding: utf-8 -*- n=int(input()) d,x=map(int,input().split()) a=[int(input()) for _ in range(n)] d-=1 for i in a: print(x) x+=d//i+1 print(x)
s443798470
Accepted
17
2,940
145
# -*- coding: utf-8 -*- n=int(input()) d,x=map(int,input().split()) a=[int(input()) for _ in range(n)] d-=1 for i in a: x+=d//i+1 print(x)
s430339915
p02842
u311636831
2,000
1,048,576
Wrong Answer
19
2,940
115
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)....
A=int(input()) B=(A*100)//108 print(((B+1)*1.08)//1) if((((B*1.08)//1)==A) or ((((B+1)*1.08)//1)==A)): print(B)
s780834762
Accepted
17
3,060
132
A=int(input()) B=(A*100)//108 if((((B*1.08)//1)==A)): print(B) elif((((B+1)*1.08)//1)==A): print(B+1) else: print(":(")
s336747016
p03971
u677523557
2,000
262,144
Wrong Answer
114
4,784
259
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these. Only Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy the conditions listed below, from t...
N, A, B = map(int, input().split()) S = input() C = A+B P = [0]*N for i in range(N): if S[i] == 'a' and C > 0: C -= 1 P[i] = 1 elif S[i] == 'b' and B > 0: C -= 1 B -= 1 P[i] = 1 for i in range(N): print('Yes' if P[i] else 'No')
s573939777
Accepted
109
4,784
287
N, A, B = map(int, input().split()) S = input() P = [0]*N for i in range(N): if S[i] == 'a': if A > 0: A -= 1 P[i] = 1 elif B >0: B -= 1 P[i] = 1 elif S[i] == 'b' and B > 0: B -= 1 P[i] = 1 for i in range(N): print('Yes' if P[i] else 'No')
s104490479
p03433
u920821326
2,000
262,144
Wrong Answer
17
2,940
91
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()) n=n-a if n//500==0: print("YES") else : print("NO")
s337337923
Accepted
17
2,940
172
n=int(input()) a=int(input()) if n<500: if n<=a: print("Yes") else: print("No") elif n>500 and (n%500)<=a: print("Yes") else : print("No")
s935209242
p03836
u767545760
2,000
262,144
Wrong Answer
17
3,064
276
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 ...
X = list(map(int, input().split())) sx = X[0] sy = X[1] tx = X[2] ty = X[3] x = tx - sx y = ty - sy print(x, y) l1 = "U" * y + "R" * x l2 = "D" * y + "L" * x l3 = "L" + "U" * (y + 1) + "R" * (x + 1) + "D" l4 = "R" + "D" * (y + 1) + "L" * (x + 1) + "U" print(l1 + l2 + l3 + l4)
s438940225
Accepted
17
3,064
264
X = list(map(int, input().split())) sx = X[0] sy = X[1] tx = X[2] ty = X[3] x = tx - sx y = ty - sy l1 = "U" * y + "R" * x l2 = "D" * y + "L" * x l3 = "L" + "U" * (y + 1) + "R" * (x + 1) + "D" l4 = "R" + "D" * (y + 1) + "L" * (x + 1) + "U" print(l1 + l2 + l3 + l4)
s381794017
p03162
u202727309
2,000
1,048,576
Wrong Answer
17
3,064
439
Taro's summer vacation starts tomorrow, and he has decided to make plans for it now. The vacation consists of N days. For each i (1 \leq i \leq N), Taro will choose one of the following activities and do it on the i-th day: * A: Swim in the sea. Gain a_i points of happiness. * B: Catch bugs in the mountains. Gain...
N = 3 A=[[10, 40, 70], [20, 50, 80], [30, 60, 90]] dp = [[0] * 3 for _ in range(N)] dp[0] = A[0] print(dp[0]) for i in range(N-1): for j in range(3): for k in range(3): if j == k: continue dp[i+1][k] = max(dp[i+1][k], dp[i][j] + A[i][k]) print(max(dp[...
s669213924
Accepted
573
34,616
457
N = int(input()) A = [0] * N B = [0] * N C = [0] * N for i in range(N): A[i], B[i], C[i] = map(int, input().split()) dp = [[0] * 3 for _ in range(N)] dp[0] = [A[0], B[0], C[0]] for i in range(N-1): dp[i+1][0] = max(dp[i][1]+A[i+1], dp[i][2]+A[i+1]) dp[i+1][1] = max(dp[i][0]+B[i+1], dp[i][2]+B[i+1]) d...
s592445005
p03361
u673101577
2,000
262,144
Wrong Answer
29
9,208
1,050
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...
# from pprint import pprint # import math # import collections # n = int(input()) h, w = map(int, input().split(' ')) # a = list(map(int, input().split(' '))) s = [] for i in range(h): s.append(list(input())) check = [[None] * w for i in range(h)] for i in range(h): for j in range(w): if s[i][j] == ...
s256349484
Accepted
31
9,248
930
# from pprint import pprint # import math # import collections # n = int(input()) h, w = map(int, input().split(' ')) # a = list(map(int, input().split(' '))) s = [] for i in range(h): s.append(list(input())) check = [[None] * w for i in range(h)] for i in range(h): for j in range(w): if s[i][j] == ...
s438551597
p03910
u006882546
2,000
262,144
Wrong Answer
1,927
86,892
209
The problem set at _CODE FESTIVAL 20XX Finals_ consists of N problems. The score allocated to the i-th (1≦i≦N) problem is i points. Takahashi, a contestant, is trying to score exactly N points. For that, he is deciding which problems to solve. As problems with higher scores are harder, he wants to minimize the highe...
N = int(input()) W = [0]*(N+1) W[1] = 1 for i in range(1, N+1): W[i] += W[i-1] if W[i] >= N: for j in range(1, i+1): if j != (W[i] - N): print(j) break
s457822325
Accepted
26
9,276
174
N = int(input()) W = 0 for i in range(1, N+1): W += i if W >= N: for j in range(1, i+1): if j != (W - N): print(j) break
s925968399
p02690
u630511239
2,000
1,048,576
Wrong Answer
25
9,224
150
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()) p = int(pow(X, 1/5)) for a in range(p): for b in range(-p, a): if a**5 - b**5 == X: print(a, b, sep = " ") break
s119567748
Accepted
50
9,328
209
X = int(input()) N = int(X**(1/5)) ans = [0,0] for i in range(-2*N-1, 2*N+2): for j in range(-2*N-1, 2*N+2): if i**5-j**5==X: ans = [i, j] ans = [str(i) for i in ans] ans = ' '.join(ans) print(ans)
s929064581
p03605
u395816772
2,000
262,144
Wrong Answer
29
8,944
73
It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
a = input() if a[0] == 9 or a[1] == 9: print('Yes') else: print('No')
s995764333
Accepted
24
9,044
82
a = input() if a[0] == '9' or a[1] == '9': print('Yes') else: print('No')
s901210884
p02645
u621215510
2,000
1,048,576
Wrong Answer
24
9,012
28
When you asked some guy in your class his name, he called himself S, where S is a string of length between 3 and 20 (inclusive) consisting of lowercase English letters. You have decided to choose some three consecutive characters from S and make it his nickname. Print a string that is a valid nickname for him.
s = input() nickname = s[:3]
s874837773
Accepted
27
8,860
25
s = input() print(s[:3])
s660781027
p02534
u466335531
2,000
1,048,576
Wrong Answer
31
9,076
25
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=input() print(k*len(k))
s684754077
Accepted
24
8,960
27
print("ACL" * int(input()))
s935195385
p02972
u328364772
2,000
1,048,576
Wrong Answer
57
6,836
166
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 con...
n = int(input()) A = list(map(int, input().split())) cnt = A.count(1) ans = ["1" for i in range(cnt)] if len(ans) == 0: print(0) else: print(" ".join(ans))
s042349311
Accepted
242
19,516
279
n = int(input()) A = list(map(int, input().split())) B = [0 for i in range(n)] for i in range(n-1, -1, -1): j = i + 1 ball = B[i::j] if sum(ball) % 2 != A[i]: B[i] = 1 print(sum(B)) B_ball = [str(i+1) for i in range(n) if B[i] == 1] print(" ".join(B_ball))
s146476428
p03795
u763963344
2,000
262,144
Wrong Answer
24
9,056
58
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 ...
N = int(input()) x = N * 800 y = N / 15 * 200 print(x - y)
s790384466
Accepted
32
8,828
46
N=int(input()) x=N*800 y=N//15*200 print(x-y)
s036307503
p04011
u074161135
2,000
262,144
Wrong Answer
25
9,032
158
There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.
def ston(): n = int(input()) k = int(input()) x = int(input()) y = int(input()) if n <= k: print(n*x) else: print(k*x + (n-k)*y)
s369067981
Accepted
27
9,092
87
n,k,x,y = [int(input()) for i in range(4)] cost = (min(n,k)*x+max(0,n-k)*y) print(cost)
s905327031
p03695
u143492911
2,000
262,144
Wrong Answer
17
3,064
661
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())) ash=0 brown=0 green=0 lightblue=0 blue=0 yellow=0 orange=0 red=0 anything=0 for i in range(n): if a[i]<=399: ash+=1 elif 400<=a[i]<=799: brown+=1 elif 800<=a[i]<=1199: green+=1 elif 1200<=a[i]<=1599: lightblue+=1 elif 16...
s600940553
Accepted
17
3,064
583
n=int(input()) a=list(map(int,input().split())) gray=brown=green=cyan=blue=yellow=orange=red=num=0 for i in range(n): if 1<=a[i]<=399: gray=1 if 400<=a[i]<=799: brown=1 if 800<=a[i]<=1199: green=1 if 1200<=a[i]<=1599: cyan=1 if 1600<=a[i]<=1999: blue=1 if ...
s189373490
p03251
u114920558
2,000
1,048,576
Wrong Answer
18
3,060
203
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()) x = [int(i) for i in input().split()] y = [int(j) for j in input().split()] if max(x) < min(y) and max(x) < Y and min(y) > X: print('No war') else: print('War')
s325962423
Accepted
18
3,060
206
N, M, X, Y = map(int, input().split()) x = [int(i) for i in input().split()] y = [int(j) for j in input().split()] if max(x) < min(y) and max(x) < Y and min(y) > X: print('No War') else: print('War')
s906512222
p03456
u367130284
2,000
262,144
Wrong Answer
18
2,940
75
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
print(sum(616**2**("B"in i)*float(i[:-4])for i in open(0).readlines()[1:]))
s427576267
Accepted
17
3,060
70
i=int(input().replace(" ",""));print("NYoe s"[int(i**0.5)==i**0.5::2])
s674370916
p02806
u945181840
2,525
1,048,576
Wrong Answer
17
3,060
285
Niwango created a playlist of N songs. The title and the duration of the i-th song are s_i and t_i seconds, respectively. It is guaranteed that s_1,\ldots,s_N are all distinct. Niwango was doing some work while playing this playlist. (That is, all the songs were played once, in the order they appear in the playlist, w...
import sys read = sys.stdin.read readline = sys.stdin.readline N = int(readline()) st = [tuple(readline().split()) for _ in range(N)] X = str(readline()) flag = False answer = 0 for s, t in st: if flag: answer += int(t) if s == X: flag = True print(answer)
s380859770
Accepted
17
2,940
226
import sys read = sys.stdin.read N, *st, X = read().split() flag = False answer = 0 for s, t in zip(*[iter(st)] * 2): if flag: answer += int(t) continue if s == X: flag = True print(answer)
s949637942
p03693
u045408189
2,000
262,144
Wrong Answer
17
2,940
68
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 i...
r,g,b=map(int,input().split()) print('YES' if 10*g+b%4==0 else 'NO')
s528075856
Accepted
17
2,940
71
r,g,b=map(int,input().split()) print('YES' if (10*g+b)%4==0 else 'NO')
s073903719
p03796
u161442663
2,000
262,144
Wrong Answer
2,104
4,224
68
Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
import math N=int(input()) P=(math.factorial(N))//(10**9+7) print(P)
s002668167
Accepted
230
3,968
68
import math N=int(input()) P=(math.factorial(N))%(10**9+7) print(P)
s816826710
p03448
u831081653
2,000
262,144
Wrong Answer
53
3,060
246
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...
a = int(input()) b = int(input()) c = int(input()) x = int(input()) cnt = 0 for i in range(a): for j in range(b): for k in range(c): ans = i*500 + j*100 + k*50 if ans == x: cnt += 1 print(cnt)
s595737837
Accepted
56
3,060
252
a = int(input()) b = int(input()) c = int(input()) x = int(input()) cnt = 0 for i in range(a+1): for j in range(b+1): for k in range(c+1): ans = i*500 + j*100 + k*50 if ans == x: cnt += 1 print(cnt)
s889952857
p01712
u301729341
2,000
131,072
Wrong Answer
30
7,500
351
Koto は言わずと知れた碁盤の目の街である. この街は東西方向に W メートル,南北方向に H メートルに伸びる長方形の領域によってできている. この街の西端から x メートル,南端から y メートルの点は (x, y) と記される. ここの街に住む人は古くから伝わる独自の文化を重んじており,その一つにKoto距離という変わった距離尺度がある. 2つの点 (x_1, y_1),(x_2, y_2) の Koto 距離は,min(|x_1 - x_2|, |y_1 - y_2|) によって定義される. 最近この街全体に Wifi を使えるようにする計画が立ち上がった. 現在の計画では,親機を N 個作ることになっている. i 番...
n,w,h = map(int,input().split()) Yoko = [0] * w Tate = [0] * h for i in range(n): x,y,r = map(int,input().split()) for j in range(x - 2,x + 2): if j < w: Yoko[j] += 1 if j < h: Tate[j] += 1 print(Yoko) print(Tate) if Yoko.count(0) > 0 or Tate.count(0) > 0: pri...
s299583356
Accepted
1,080
42,012
1,305
import sys n,w,h = map(int,input().split()) Yoko = [] Tate = [] for i in range(n): x,y,r = map(int,input().split()) Yoko.append([x - r,x + r]) Tate.append([y - r,y + r]) Yoko = sorted(Yoko) Tate = sorted(Tate) if Yoko[0][0] > 0 and Tate[0][0] > 0: print("No") sys.exit() Yoko_han = [Yoko[0][0],Yoko...
s469774558
p03797
u853900545
2,000
262,144
Wrong Answer
17
2,940
88
Snuke loves puzzles. Today, he is working on a puzzle using `S`\- and `c`-shaped pieces. In this puzzle, you can combine two `c`-shaped pieces into one `S`-shaped piece, as shown in the figure below: Snuke decided to create as many `Scc` groups as possible by putting together one `S`-shaped piece and two `c`-shaped...
s,c=map(int,input().split()) if c > 2*s: print(c//2) else: print(s + (c-2*s)//2)
s920436605
Accepted
17
2,940
98
s,c=map(int,input().split()) d = 0 if c < 2*s: d = c//2 else: d = s + (c-2*s)//4 print(d)
s636862900
p03469
u371467115
2,000
262,144
Wrong Answer
17
2,940
31
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 col...
s=list(input()) s[3]=8 print(s)
s428101448
Accepted
18
2,940
29
s=input() print("2018"+s[4:])
s844578166
p04011
u314008046
2,000
262,144
Wrong Answer
17
2,940
78
There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.
n,k,x,y=(int(input()) for i in range(4)) print(k*x if n<=k else (k*x+(n-k)*x))
s828492400
Accepted
18
2,940
78
n,k,x,y=(int(input()) for i in range(4)) print(n*x if n<=k else (k*x+(n-k)*y))
s569115420
p00070
u186082958
1,000
131,072
Wrong Answer
20
7,604
752
0 から 9 までの整数を使った n 個の数の並び k1, k2, ..., kn を考えます。正の整数 n と s を読み込んで、 k1 \+ 2 × k2 \+ 3 × k3 + ... \+ n × kn = s となっているような n 個の数の並びが何通りあるかを出力するプログラムを作成してください。ただし、1 つの「n 個の数の並び」には同じ数が 2 回以上現われないものとします。
def solve(used,rest,sum,memo): if rest==0: return sum==0 else: num=0 for i in range(10): num*=2 if used[i]:num+=1 if (num,rest,sum) in memo: return memo[(num,rest,sum)] if sum<0:return 0 if sum>maxs[rest]:return 0 ...
s933124832
Accepted
3,290
80,612
717
def solve(used,rest,sum,memo): if rest==0: return sum==0 else: num=0 for i in range(10): num*=2 if used[i]:num+=1 if (num,rest,sum) in memo: return memo[(num,rest,sum)] if sum<0:return 0 ans=0 for i in range(10): ...
s421428842
p03352
u296150111
2,000
1,048,576
Wrong Answer
19
3,060
123
You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
x=int(input()) a=[] for j in range(1,10): a.append(2**j) a.sort() import bisect k=bisect.bisect_right(a,x) print(a[k-1])
s163245875
Accepted
22
3,308
149
x=int(input()) a=[] for i in range(1,1000): for j in range(2,10): a.append(i**j) a.sort() import bisect k=bisect.bisect_right(a,x) print(a[k-1])
s838545679
p03006
u415905784
2,000
1,048,576
Wrong Answer
47
6,452
657
There are N balls in a two-dimensional plane. The i-th ball is at coordinates (x_i, y_i). We will collect all of these balls, by choosing two integers p and q such that p \neq 0 or q \neq 0 and then repeating the following operation: * Choose a ball remaining in the plane and collect it. Let (a, b) be the coordinat...
from fractions import gcd from collections import defaultdict N = int(input()) B = [[0, 0] for i in range(N)] D = [[[0, 0] for j in range(N)] for i in range(N)] G = defaultdict(lambda:defaultdict(int)) for i in range(N): B[i] = [int(x) for x in input().split()] B.sort() for i in range(N): for j in range(i): gra...
s361273397
Accepted
25
3,948
564
from collections import defaultdict N = int(input()) B = [[0, 0] for i in range(N)] D = [[[0, 0] for j in range(N)] for i in range(N)] G = defaultdict(int) for i in range(N): B[i] = [int(x) for x in input().split()] B.sort() for i in range(N): for j in range(i, N): if i == j: continue D[i][j] = [B[j][...
s150110412
p02694
u720124072
2,000
1,048,576
Wrong Answer
32
9,280
59
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 math x = float(input()) print(math.log(x/100, 1.01))
s073247939
Accepted
29
9,128
123
import math x = int(input()) num = 100 for i in range(10000): num += num//100 if num >= x: print(i+1) exit(0)
s428106252
p02401
u313600138
1,000
131,072
Wrong Answer
20
5,596
165
Write a program which reads two integers a, b and an operator op, and then prints the value of a op b. The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part.
a,op,b = input().split() a=int(a) b=int(b) if op=='+': print(a+b) if op=='-': print(a-b) if op=='*': print(a*b) if op=='/': print(a/b) if op=='?': pass
s239647222
Accepted
20
5,592
199
while True: a,op,b = input().split() a=int(a) b=int(b) if op=='?': break if op=='+': print(a+b) if op=='-': print(a-b) if op=='*': print(a*b) if op=='/': print(a//b)
s376289762
p03409
u518042385
2,000
262,144
Wrong Answer
22
3,064
598
On a two-dimensional plane, there are N red points and N blue points. The coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i). A red point and a blue point can form a _friendly pair_ when, the x-coordinate of the red point is smaller than that of the blue point, ...
n=int(input()) l=[] for i in range(n): l1=list(map(int,input().split())) l.append(l1+["a",0]) for i in range(n): l1=list(map(int,input().split())) l.append(l1+["b"]) count=0 for i in range(2*n): if l[i][2]=="a": pass else: num=l[i][1] min=100 index=-1 if i==0: pass else: ...
s553028717
Accepted
20
3,188
610
n=int(input()) l=[] for i in range(n): l1=list(map(int,input().split())) l.append(l1+["a",0]) for i in range(n): l1=list(map(int,input().split())) l.append(l1+["b"]) count=0 l=sorted(l) for i in range(2*n): if l[i][2]=="a": pass else: num=l[i][1] min=100 index=-1 if i==0: pass ...