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
s241227386
p03854
u761471989
2,000
262,144
Wrong Answer
20
5,172
890
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() f = 0 while(1): print(S) if len(S) <= 4: break if S[:5] == "dream": if len(S) == 5: f = 1 break elif len(S) == 6: break if S[:7] == "dreamer": if len(S) == 7: f = 1 break ...
s446785808
Accepted
75
3,188
890
S = input() f = 0 while(1): #print(S) if len(S) <= 4: break if S[:5] == "dream": if len(S) == 5: f = 1 break elif len(S) == 6: break if S[:7] == "dreamer": if len(S) == 7: f = 1 break ...
s486078638
p03712
u593567568
2,000
262,144
Wrong Answer
28
9,180
284
You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}. Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1.
H,W = map(int,input().split()) A = [list(input()) for _ in range(H)] ANS = [] for i in range(H+1): t = [] for j in range(W+1): if i == 0 or j == 0 or i == H or j == W: t.append("#") else: t.append(A[i-1][j-1]) ANS.append("".join(t)) print("\n".join(ANS))
s250529498
Accepted
28
8,960
289
H,W = map(int,input().split()) A = [list(input()) for _ in range(H)] ANS = [] for i in range(H+2): t = [] for j in range(W+2): if i == 0 or j == 0 or i == H+1 or j == W+1: t.append("#") else: t.append(A[i-1][j-1]) ANS.append("".join(t)) print("\n".join(ANS))
s813470426
p03827
u105124953
2,000
262,144
Wrong Answer
17
3,060
175
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...
n = int(input()) s = input() tmp_list = [0] x = 0 for _ in s: if _ == 'I': x += 1 else: x -= 1 tmp_list.append(x) print(x) print(max(tmp_list))
s599667538
Accepted
17
2,940
162
n = int(input()) s = input() tmp_list = [0] x = 0 for _ in s: if _ == 'I': x += 1 else: x -= 1 tmp_list.append(x) print(max(tmp_list))
s521847013
p03957
u582243208
1,000
262,144
Wrong Answer
22
3,064
155
This contest is `CODEFESTIVAL`, which can be shortened to the string `CF` by deleting some characters. Mr. Takahashi, full of curiosity, wondered if he could obtain `CF` from other strings in the same way. You are given a string s consisting of uppercase English letters. Determine whether the string `CF` can be obtai...
s=input() a="" for i in range(len(s)): if s[i]=='C': a+="c" if s[i]=='F': a+="f" if a=="cf": print("YES") else: print("NO")
s420412027
Accepted
23
3,064
157
s=input() a="" for i in range(len(s)): if s[i]=='C': a+="c" if s[i]=='F': a+="f" if "cf" in a: print("Yes") else: print("No")
s988428383
p03545
u870518235
2,000
262,144
Wrong Answer
18
3,064
405
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 = list(input()) ops = [] lst = [] for i in range(8): ops.append(bin(i)) ops[i] = ops[i][2:].zfill(3) print(ops[i]) for i in range(8): res = S[0] for j in range(3): if ops[i][j] == "0": res = res + "+" + S[j+1] else: res = res + "-" + S[j+1] if eval(res...
s601833921
Accepted
18
3,064
387
S = list(input()) ops = [] lst = [] for i in range(8): ops.append(bin(i)) ops[i] = ops[i][2:].zfill(3) for i in range(8): res = S[0] for j in range(3): if ops[i][j] == "0": res = res + "+" + S[j+1] else: res = res + "-" + S[j+1] if eval(res) == 7: re...
s209373607
p03693
u219369949
2,000
262,144
Wrong Answer
17
2,940
99
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 g * 10 + b % 4 == 0: print('YES') else: print('NO')
s031219517
Accepted
17
2,940
101
r, g, b = map(int, input().split()) if (g * 10 + b) % 4 == 0: print('YES') else: print('NO')
s105620214
p03644
u375616706
2,000
262,144
Wrong Answer
21
3,188
241
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...
from math import log2 # python template for atcoder1 import sys sys.setrecursionlimit(10**9) input = sys.stdin.readline def ceil(n): return int(-n//1)*(-1) N = int(input()) ans = ceil(log2(N)) if ans > N: ans -= 1 print(2**ans)
s985189273
Accepted
18
3,060
244
from math import log2 # python template for atcoder1 import sys sys.setrecursionlimit(10**9) input = sys.stdin.readline def ceil(n): return int(-n//1)*(-1) N = int(input()) ans = ceil(log2(N)) if 2**ans > N: ans -= 1 print(2**ans)
s306079158
p03503
u379340657
2,000
262,144
Wrong Answer
141
3,064
527
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()) f = [list(map(int, input().split())) for _ in range(n)] p = [list(map(int, input().split())) for _ in range(n)] benefits = [] for t in range(1,1024): bits = list(bin(t)) a = [0 for _ in range(n)] jk = 0 while jk < 10: b = bits.pop() if b == "b": break elif b == "0": jk ...
s928100932
Accepted
139
3,064
554
n = int(input()) f = [list(map(int, input().split())) for _ in range(n)] p = [list(map(int, input().split())) for _ in range(n)] benefits = -1000000000 for t in range(1,1024): bits = list(bin(t)) a = [0 for _ in range(n)] jk = 0 while jk < 10: b = bits.pop() if b == "b": break elif b == "0":...
s374883143
p03556
u618373524
2,000
262,144
Wrong Answer
18
2,940
35
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 = int(input()) print(int(n**0.5))
s774532985
Accepted
19
3,060
49
n = int(input()) m = int(n**0.5) print(int(m**2))
s673232453
p03470
u306060982
2,000
262,144
Wrong Answer
18
3,064
229
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()) l = 0 count = 0 dlist = [] for i in range(N): dlist.append(int(input())) for i in range(N): m = max(dlist) if(l != m): count += 1 dlist[dlist.index(m)] = 0 l = m print(count)
s786009456
Accepted
18
2,940
122
N = int(input()) dlist = [] for i in range(N): dlist.append(int(input())) dlistt = list(set(dlist)) print(len(dlistt))
s690858001
p03149
u334712262
2,000
1,048,576
Wrong Answer
362
7,996
1,275
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".
# -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, product, permut...
s875535667
Accepted
258
7,868
1,275
# -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, product, permut...
s828270975
p03672
u316386814
2,000
262,144
Wrong Answer
18
2,940
134
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() for n in range(len(s) // 2 - 1, -1, -1): if s[:n] == s[n: 2 * n]: ans = s[: 2 * n] break print(ans)
s436162812
Accepted
18
2,940
129
s = input() for n in range(len(s) // 2 - 1, -1, -1): if s[:n] == s[n: 2 * n]: ans = 2 * n break print(ans)
s601084601
p02409
u554198876
1,000
131,072
Wrong Answer
30
7,708
414
You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room. For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth fl...
N = int(input()) A = [[[0] * 10, [0] * 10, [0] * 10], [[0] * 10, [0] * 10, [0] * 10], [[0] * 10, [0] * 10, [0] * 10], [[0] * 10, [0] * 10, [0] * 10]] print(len(A)) for i in range(N): b, f, r, v = [int(j) for j in input().split()] A[b-1][f-1][r-1] += v for a, b in enumerate(A): for f in b: print(' ...
s036267522
Accepted
40
7,756
406
N = int(input()) A = [[[0] * 10, [0] * 10, [0] * 10], [[0] * 10, [0] * 10, [0] * 10], [[0] * 10, [0] * 10, [0] * 10], [[0] * 10, [0] * 10, [0] * 10]] for i in range(N): b, f, r, v = [int(j) for j in input().split()] A[b-1][f-1][r-1] += v for a, b in enumerate(A): for f in b: print(' ' + ' '.join([...
s429810190
p03378
u125505541
2,000
262,144
Wrong Answer
17
3,064
171
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to right. Initially, you are in Square X. You can freely travel between adjacent squares. Your goal is to reach Square 0 or Square N. However, for each i = 1, 2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i incurs a c...
n, m, x = input().split() n = int(n) m = int(m) x = int(x) c = [0 for _ in range(n+1)] a = input().split() for i in range(m): c[int(a[i])]=1 min(sum(c[:x]),sum(c[x:]))
s091020967
Accepted
17
3,064
178
n, m, x = input().split() n = int(n) m = int(m) x = int(x) c = [0 for _ in range(n+1)] a = input().split() for i in range(m): c[int(a[i])]=1 print(min(sum(c[:x]),sum(c[x:])))
s697302095
p04044
u058850663
2,000
262,144
Wrong Answer
17
3,060
173
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...
# -*- coding: utf-8 -*- n, l = map(int, input().split()) a = [] b = '' for i in range(n): a.append(input()) sorted(a) for i in range(len(a)): b += a[i] print(b)
s758341386
Accepted
18
3,060
168
# -*- coding: utf-8 -*- n, l = map(int, input().split()) a = [] b = '' for i in range(n): a.append(input()) a.sort() for i in range(len(a)): b += a[i] print(b)
s052039123
p02609
u724687935
2,000
1,048,576
Wrong Answer
567
12,752
997
Let \mathrm{popcount}(n) be the number of `1`s in the binary representation of n. For example, \mathrm{popcount}(3) = 2, \mathrm{popcount}(7) = 3, and \mathrm{popcount}(0) = 0. Let f(n) be the number of times the following operation will be done when we repeat it until n becomes 0: "replace n with the remainder when n...
from collections import Counter import sys sys.setrecursionlimit(10 ** 6) def dfs(n): if memo[n] >= 0: rst = memo[n] else: tmp = n one = 0 while tmp > 0: one += tmp & 1 tmp >>= 1 m = n % one rst = 1 if m == 0 else 1 + dfs(m) memo[...
s069504706
Accepted
588
12,720
1,001
from collections import Counter import sys sys.setrecursionlimit(10 ** 6) def dfs(n): if memo[n] >= 0: rst = memo[n] else: tmp = n one = 0 while tmp > 0: one += tmp & 1 tmp >>= 1 m = n % one rst = 1 if m == 0 else 1 + dfs(m) memo[...
s558297469
p02866
u997322530
2,000
1,048,576
Wrong Answer
74
14,396
211
Given is an integer sequence D_1,...,D_N of N elements. Find the number, modulo 998244353, of trees with N vertices numbered 1 to N that satisfy the following condition: * For every integer i from 1 to N, the distance between Vertex 1 and Vertex i is D_i.
n = int(input()) a = [int(s) for s in input().split(' ')] counts = [0] * n for i in a: counts[i] += 1 ans = 1 if a[0] == 0 else 0 for u, v in zip(counts, counts[1:]): ans = ans * u * v % 998244353 print(ans)
s697395531
Accepted
95
14,396
249
n = int(input()) a = [int(s) for s in input().split(' ')] counts = [0] * n for i in a: counts[i] += 1 ans = 1 if a[0] == 0 and counts[0] == 1 else 0 for u, v in zip(counts, counts[1:]): for _ in range(v): ans = ans * u % 998244353 print(ans)
s453480579
p04043
u698197687
2,000
262,144
Wrong Answer
17
2,940
397
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 ...
def haiku(sentence_length_list): length_five_cnt=0 length_seven_cnt=0 for s in sentence_length_list: if s==5: length_five_cnt=length_five_cnt+1 if s==7: length_seven_cnt=length_seven_cnt+1 if length_five_cnt==2 and length_seven_cnt==1: return 'YES' e...
s009494866
Accepted
17
2,940
438
def haiku(sentence_length_list): length_five_cnt=0 length_seven_cnt=0 for s in sentence_length_list: if s=='5': length_five_cnt=length_five_cnt+1 if s=='7': length_seven_cnt=length_seven_cnt+1 if length_five_cnt==2 and length_seven_cnt==1: return 'YES' ...
s090653576
p04045
u063073794
2,000
262,144
Wrong Answer
103
3,060
257
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 = list(map(str,input().split())) ans=0 for i in range (n,100000): s=str(i) pay=True for j in range(len(s)): if s[j] in d: pay = False break if pay: ans = i break print(ans)
s788240765
Accepted
83
3,060
371
n, k = map(int,input().split()) d = list(map(str,input().split())) ans=0 for i in range (n,100000): s= str(i) pay=True for j in range (len(s)): if s[j] in d: pay = False break if pay: ans = i break print(ans)
s064590984
p03814
u527993431
2,000
262,144
Wrong Answer
39
3,516
179
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() ans=0 tmp=0 end=0 for i in range(len(S)): if S[i]=="A": tmp=i break for i in range(1,len(S)): if S[-i]=="Z": end=len(S)-i break print(tmp,end) print(end-tmp+1)
s583570747
Accepted
41
3,512
164
S=input() ans=0 tmp=0 end=0 for i in range(len(S)): if S[i]=="A": tmp=i break for i in range(1,len(S)): if S[-i]=="Z": end=len(S)-i break print(end-tmp+1)
s120500898
p03067
u514299323
2,000
1,048,576
Wrong Answer
17
2,940
121
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.
A, B, C = map(int,input().split(" ")) if A<C<B: print('YES') elif B<C<A: print('YES') else: print('No')
s201998737
Accepted
17
2,940
121
A, B, C = map(int,input().split(" ")) if A<C<B: print('Yes') elif B<C<A: print('Yes') else: print('No')
s681157343
p03645
u072717685
2,000
262,144
Wrong Answer
375
15,572
395
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N. There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i. Cat Snuk...
def main(): n, m = input().split() g1 = [] g2 = [] for _ in range(int(m)): x, y = input().split() if x == 1: g1.append(y) elif y == n: g2.append(x) sx = set(g1) sy = set(g2) sxy = sx.intersection(sy) if len(sxy): print('POSSIBLE') ...
s731895365
Accepted
379
26,540
397
def main(): n, m = input().split() g1 = [] g2 = [] for _ in range(int(m)): x, y = input().split() if x == '1': g1.append(y) elif y == n: g2.append(x) sx = set(g1) sy = set(g2) sxy = sx.intersection(sy) if len(sxy): print('POSSIBLE')...
s509299503
p03971
u761989513
2,000
262,144
Wrong Answer
104
4,588
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 = list(input()) p = 0 ab = 0 for i in s: if i == "c": print("No") elif i == "a": if p < a + b: p += 1 print("Yes") else: if p < a + b and ab < b: p += 1 ab += 1 print("Yes")
s739757509
Accepted
109
4,712
316
n, a, b = map(int, input().split()) s = list(input()) p = 0 ab = 0 for i in s: if i == "c": print("No") elif i == "a": if p < a + b: p += 1 print("Yes") else: print("No") else: if p < a + b and ab < b: p += 1 ab += 1 print("Yes") else: print("No")
s677588279
p03860
u582243208
2,000
262,144
Wrong Answer
21
3,064
38
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppe...
a,b,c=input().split() print("A"+b+"C")
s600208753
Accepted
23
3,064
41
a,b,c=input().split() print("A"+b[0]+"C")
s403972085
p04045
u207241407
2,000
262,144
Wrong Answer
17
3,064
350
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 = set(map(int,input().split())) num = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} usable = num - d ans = [] n_list = [int(x) for x in list(str(n))] for i in n_list: if i in usable: ans.append(i) else: for j in usable: if i < j: ans.append(j) for ...
s952365356
Accepted
19
3,064
735
import itertools N, K = map(int, input().split()) D = set(input().split()) n = [x for x in str(N)] num = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"} - D judge = "no" ans = N for i in n: if i in D: judge = "yes" break if judge == "yes": if ans < int(sorted(list(num))[-1] * len(n)): ...
s288997092
p03386
u410118019
2,000
262,144
Wrong Answer
18
3,064
150
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()) c = [0] * (2*k) for i in range(k): c[i] = a + i for i in range(k): c[2*k-1-i] = b - i for i in set(c): print(i)
s338893584
Accepted
17
3,060
157
a,b,k = map(int,input().split()) s1 = set(range(a,min(a+k,b+1))) s2 = set(range(b,max(b-k,a-1),-1)) s0 = sorted(s1|s2) [print(s0[i]) for i in range(len(s0))]
s880100041
p00007
u915343634
1,000
131,072
Wrong Answer
20
7,648
109
Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week. Write a program which computes the amount of the debt in n weeks.
from math import ceil n = int(input()) x = 100 for i in range(n): x = ceil(x * 1.05) print(x * 1000)
s877836732
Accepted
20
7,696
113
from math import ceil yen = 100000 for i in range(int(input())): yen = ceil((yen*1.05)/1000)*1000 print(yen)
s800430474
p03693
u834301346
2,000
262,144
Wrong Answer
25
9,020
116
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 = list(map(int, input().split(' '))) num = r*100 + g*10 + b if num//4==0: print('YES') else: print('NO')
s368894743
Accepted
25
9,068
115
r, g, b = list(map(int, input().split(' '))) num = r*100 + g*10 + b if num%4==0: print('YES') else: print('NO')
s717532820
p03471
u706159977
2,000
262,144
Wrong Answer
19
3,064
481
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()) if n*1000>y: print("-1 -1 -1") else: x=n*1000 n10 = 0 n5 = 0 while y-x>=9000: x = x+9000 n10 = n10+1 if n<n10: print("-1 -1 -1") break print(x) while y-x>=4000: x = x+4000 n5 = n5+1 if n10+...
s978085400
Accepted
553
3,188
360
n,y = map(int,input().split()) s=[-1,-1,-1] if n*10000<y: pass elif n*10000==y: s=[n,0,0] else: m=1 x_0=n*10000 while m<=n: for i in range(m+1): x= x_0-9000*(m-i)-5000*i if x == y: s=[n-m,i,m-i] break if x==y: break ...
s772341647
p02578
u205042576
2,000
1,048,576
Wrong Answer
333
32,052
396
N persons are standing in a row. The height of the i-th person from the front is A_i. We want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person: Condition: Nobody in front of the person is taller than the person. Here, the height of a ...
# coding: utf-8 N = input() N = int(N) An = list(map(int, input().split())) cnt = 0 step = [] step_sum = 0 for i in range(0, N): if i == 0: step.append(0) continue diff = (An[i - 1] + step[i - 1]) - An[i] print('i ', i, 'diff ', diff) if diff <= 0: step.append(0) else: ...
s411273609
Accepted
164
32,216
347
N = input() N = int(N) An = list(map(int, input().split())) cnt = 0 step = [] step_sum = 0 for i in range(0, N): if i == 0: step.append(0) continue diff = (An[i - 1] + step[i - 1]) - An[i] if diff <= 0: step.append(0) else: step.append(diff) for num in step: step_s...
s478892837
p03544
u021916304
2,000
262,144
Wrong Answer
18
2,940
87
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)
n = int(input()) l = [2,1] for i in range(n): l.append(l[-1]+l[-2]) print(l[n-1])
s817287286
Accepted
17
2,940
85
n = int(input()) l = [2,1] for i in range(n): l.append(l[-1]+l[-2]) print(l[n])
s806980486
p02613
u656801456
2,000
1,048,576
Wrong Answer
152
16,288
476
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`,...
import math import sys def main(): n = int(input()) s = [input() for i in range(n)] c0,c1,c2,c3 = 0,0,0,0 for i in range(n): if "AC" in s[i]: c0 += 1 if s[i] in 'WA': c1 += 1 if s[i] in 'TLE': c2 += 1 if s[i] in 'RE': ...
s694379848
Accepted
151
16,316
476
import math import sys def main(): n = int(input()) s = [input() for i in range(n)] c0,c1,c2,c3 = 0,0,0,0 for i in range(n): if "AC" in s[i]: c0 += 1 if s[i] in 'WA': c1 += 1 if s[i] in 'TLE': c2 += 1 if s[i] in 'RE': ...
s707136127
p02399
u641357568
1,000
131,072
Wrong Answer
20
5,604
78
Write a program which reads two integers a and b, and calculates the following values: * a ÷ b: d (in integer) * remainder of a ÷ b: r (in integer) * a ÷ b: f (in real number)
i,j= map(int, input().split()) print("{0:d} {1:d} {0:.5f}".format(i//j,i%j))
s499529355
Accepted
20
5,600
82
i,j= map(int, input().split()) print("{0:d} {1:d} {2:.5f}".format(i//j,i%j,i/j))
s453149915
p03711
u243572357
2,000
262,144
Wrong Answer
17
2,940
110
Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below. Given two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.
x, y = map(int, input().split()) print('YES' if x==y or (x in [4, 6, 9, 11] and y in [4, 6, 9, 11]) else 'NO')
s605678607
Accepted
17
2,940
219
a, b = map(int, input().split()) lst = [4, 6, 9, 11] lst2 = [1, 3, 5, 7, 8, 10, 12] if a==b==2: print('Yes') elif a in lst and b in lst: print('Yes') elif a in lst2 and b in lst2: print('Yes') else: print('No')
s601675759
p02413
u130834228
1,000
131,072
Wrong Answer
20
7,600
318
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 = map(int, input().split()) sheet = [[0 for i in range (r)] for j in range(c)] for i in range(r): sheet[i] = input().split() k = 0 for j in range(c): k += int(sheet[i][j]) sheet[i].append(k) for i in range(r): for j in range(c+1): if j != c: print(sheet[i][j], end=' ') else: print(sheet[i][j])
s974780493
Accepted
40
8,628
476
r, c = map(int, input().split()) sheet = [[0 for i in range (c)] for j in range(r)] for i in range(r): sheet[i] = input().split() k = 0 for j in range(c): k += int(sheet[i][j]) sheet[i].append(k) l=[0 for i in range (c+1)] for j in range(c+1): for i in range(r): l[j] += int(sheet[i][j]) #print(sheet[i][j]...
s615831866
p00020
u548155360
1,000
131,072
Wrong Answer
20
5,540
72
Write a program which replace all the lower-case letters of a given text with the corresponding captital letters.
# coding=utf-8 sentence = input() sentence.capitalize() print(sentence)
s238271441
Accepted
20
5,544
78
# coding=utf-8 sentence = input() sentence = sentence.upper() print(sentence)
s986431696
p02744
u424768586
2,000
1,048,576
Wrong Answer
123
18,284
416
In this problem, we only consider strings consisting of lowercase English letters. Strings s and t are said to be **isomorphic** when the following conditions are satisfied: * |s| = |t| holds. * For every pair i, j, one of the following holds: * s_i = s_j and t_i = t_j. * s_i \neq s_j and t_i \neq t_j. F...
# -*- coding: utf-8 -*- N=int(input()) l0=['a'] l1=[] li=[0] li1=[] alp=[chr(i) for i in range(97, 97+26)] for i in range(1,N): for j, l in enumerate(l0): ind=0 while ind<=li[j]+1: l1.append(l+alp[ind]) if ind==li[j]+1: li1.append(li[j]+1) else: li1.append(li[j]...
s479094460
Accepted
165
15,308
432
# -*- coding: utf-8 -*- N=int(input()) l0=['a'] l1=[] li=[0] li1=[] alp=[chr(i) for i in range(97, 97+26)] for i in range(1,N): for j, l in enumerate(l0): ind=0 while ind<=li[j]+1: l1.append(l+alp[ind]) if ind==li[j]+1: li1.append(li[j]+1) else: li1.append(li[j]...
s695132624
p02613
u102218630
2,000
1,048,576
Wrong Answer
144
9,200
305
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): result=input() if result=="AC": AC+=1 elif result == "WA": WA+=1 elif result == "TLE": TLE += 1 else: RE+=1 print("AC x"+str(AC)) print("WA x"+str(WA)) print("TLE x"+str(TLE)) print("RE x"+str(RE))
s085988560
Accepted
147
9,200
310
N=int(input()) AC=0 WA=0 TLE=0 RE=0 for i in range(N): result=input() if result=="AC": AC+=1 elif result == "WA": WA+=1 elif result == "TLE": TLE += 1 else: RE+=1 print("AC x "+str(AC)) print("WA x "+str(WA)) print("TLE x "+str(TLE)) print("RE x "+str(RE))
s766199279
p03992
u970308980
2,000
262,144
Wrong Answer
17
2,940
34
This contest is `CODE FESTIVAL`. However, Mr. Takahashi always writes it `CODEFESTIVAL`, omitting the single space between `CODE` and `FESTIVAL`. So he has decided to make a program that puts the single space he omitted. You are given a string s with 12 letters. Output the string putting a single space between the fi...
s = input() print(s[:4+1], s[4:])
s078369787
Accepted
17
2,940
32
s = input() print(s[:4], s[4:])
s908960907
p03501
u737508101
2,000
262,144
Wrong Answer
17
2,940
84
You are parking at a parking lot. You can choose from the following two fee plans: * Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours. * Plan 2: The fee will be B yen, regardless of the duration. Find the minimum fee when you park for N hours.
N, A, B = map(int, input().split()) if A*N > B: print(A*N) if A*N <= B: print(B)
s862590996
Accepted
17
2,940
85
N, A, B = map(int, input().split()) if A*N > B: print(B) if A*N <= B: print(A*N)
s657469842
p03485
u179750651
2,000
262,144
Wrong Answer
17
2,940
92
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()) if 0 == ((a+b)%2): print((a+b)/2) else: print(((a+b)//2)+1)
s783550140
Accepted
17
2,940
44
print(-(-sum(map(int,input().split()))//2))
s005354678
p02927
u717626627
2,000
1,048,576
Wrong Answer
32
3,064
280
Today is August 24, one of the five Product Days in a year. A date m-d (m is the month, d is the date) is called a Product Day when d is a two-digit number, and all of the following conditions are satisfied (here d_{10} is the tens digit of the day and d_1 is the ones digit of the day): * d_1 \geq 2 * d_{10} \geq...
a,b = map(int, input().split()) ans = 0 for i in range(a+1): for j in range(b+1): if len(str(j)) == 2 and i >= 2 and int(str(j)[1]) >= 2 and int(str(j)[0]) >= 2: if i == int(str(j)[0]) * int(str(j)[1]): print(str(i) +' '+ str(j)) ans += 1 print(ans)
s356029671
Accepted
32
3,064
246
a,b = map(int, input().split()) ans = 0 for i in range(a+1): for j in range(b+1): if len(str(j)) == 2 and i >= 2 and int(str(j)[1]) >= 2 and int(str(j)[0]) >= 2: if i == int(str(j)[0]) * int(str(j)[1]): ans += 1 print(ans)
s118241999
p03470
u460129720
2,000
262,144
Wrong Answer
30
9,160
63
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 = list(map(int,input().split())) S = set(N[1:]) print(len(S))
s259457436
Accepted
25
8,948
81
n = int(input()) mochi = set([int(input()) for i in range(n)]) print(len(mochi))
s576316802
p02747
u746849814
2,000
1,048,576
Wrong Answer
17
2,940
112
A Hitachi string is a concatenation of one or more copies of the string `hi`. For example, `hi` and `hihi` are Hitachi strings, while `ha` and `hii` are not. Given a string S, determine whether S is a Hitachi string.
s = input() ans = 0 for i in range(1, len(s)): if s[i-1] == 'h' and s[i] == 'i': ans += 1 print(ans)
s178637565
Accepted
17
3,060
150
s = list(input()) if s[::2].count('h') == len(s[::2]) and s[1::2].count('i') == len(s[1::2]) and len(s)%2 == 0: print('Yes') else: print('No')
s993929465
p03730
u763249708
2,000
262,144
Wrong Answer
17
2,940
128
We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objecti...
a, b, c = map(int, input().split()) for i in range(a, a*b, a): if i%b == c: print("Yes") exit() print("No")
s627724779
Accepted
18
2,940
128
a, b, c = map(int, input().split()) for i in range(a, a*b, a): if i%b == c: print("YES") exit() print("NO")
s783413082
p03973
u794173881
2,000
262,144
Wrong Answer
243
7,848
345
N people are waiting in a single line in front of the Takahashi Store. The cash on hand of the i-th person from the front of the line is a positive integer A_i. Mr. Takahashi, the shop owner, has decided on the following scheme: He picks a product, sets a positive integer P indicating its price, and shows this product...
n = int(input()) a = [int(input()) for i in range(n)] a = a[::-1] ans = 0 num = 1 while a: if a[-1] == num: num += 1 elif a[-1] > num: if a[-1] % num == 0: a[-1] = a[-1] - (num + 1) ans += 1 ans += a[-1] // num else: ans += a[-1] // num ...
s154262823
Accepted
251
7,848
359
n = int(input()) a = [int(input()) for i in range(n)] a = a[::-1] ans = 0 num = 1 while a: if a[-1] < num: del a[-1] elif a[-1] == num: num += 1 elif a[-1] > num: if a[-1] % num == 0: ans += a[-1] // num - 1 a[-1] = 1 else: ans += a[-1] /...
s589014754
p03549
u001024152
2,000
262,144
Wrong Answer
32
3,700
330
Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of th...
from math import factorial, ceil def combination(n, r): return factorial(n) // (factorial(n - r) * factorial(r)) n, m = map(int, input().split()) t = 100*(n-m) + m*1900 rs = [0.5**m * ( 1- 0.5**m)**i for i in range(int(1e4))] ans = 0.0 for i,r in enumerate(rs): ans += ((i+1)*t)*r print(ceil(ans))
s611704896
Accepted
17
2,940
72
N,M = map(int, input().split()) p = 1/2 print((1900*M+100*(N-M))*2**M)
s584312783
p02742
u595893956
2,000
1,048,576
Wrong Answer
17
2,940
59
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...
n,m=map(int,input().split()) print(n*(m//2)+(n%2)*(n//2+1))
s732566375
Accepted
18
2,940
122
n,m=map(int,input().split()) if m==1 or n==1: print(1) elif m%2+n%2<2: print(n*m//2) else: print(n*(m//2)+(n//2+1))
s816517596
p02957
u769633956
2,000
1,048,576
Wrong Answer
31
3,964
250
We have two distinct integers A and B. Print the integer K such that |A - K| = |B - K|. If such an integer does not exist, print `IMPOSSIBLE` instead.
import string while True: try: a,b=map(int,input().split()) if a!=b: if str((a+b)/2.0).isdecimal(): print(int((a+b)/2)) else:print("IMPOSSIBLE") else:print(int(a+b)) except:break
s156762094
Accepted
32
3,956
238
import string while True: try: a,b=map(int,input().split()) if a!=b: if ((a+b)%2)==0.0: print(int((a+b)/2)) else:print("IMPOSSIBLE") else:print(int(a+b)) except:break
s479444569
p02401
u483716678
1,000
131,072
Wrong Answer
20
5,600
290
Write a program which reads two integers a, b and an operator op, and then prints the value of a op b. The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part.
while True: a,op,b = input().split() if(op == '+'): print(int(a)+int(b)) elif(op == '-'): print(int(a)-int(b)) elif(op == '*'): print(int(a)*int(b)) elif(op == '/'): print(int(a)/int(b)) elif(op == '?'): break;
s880517745
Accepted
20
5,596
299
while True: a,op,b = input().split() if(op == '+'): print(int(a)+int(b)) elif(op == '-'): print(int(a)-int(b)) elif(op == '*'): print((int(a)*int(b))) elif(op == '/'): print('%d'%(int(a)/int(b))) elif(op == '?'): break;
s928751744
p04012
u637175065
2,000
262,144
Wrong Answer
52
5,400
355
Let w be a string consisting of lowercase letters. We will call w _beautiful_ if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful.
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time sys.setrecursionlimit(10**7) inf = 10**20 mod = 10**9 + 7 def main(): s = input() d = collections.defaultdict(int) for c in s: d[c] += 1 for c in d.values(): if c % 2 == 1: return 'No'...
s059216307
Accepted
49
5,404
355
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time sys.setrecursionlimit(10**7) inf = 10**20 mod = 10**9 + 7 def main(): s = input() d = collections.defaultdict(int) for c in s: d[c] += 1 for c in d.values(): if c % 2 == 1: return 'No'...
s416765790
p03711
u785066634
2,000
262,144
Wrong Answer
17
2,940
175
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] C=[2] x,y=map(int,input().split()) if x in A and y in A: print('YES') elif x in B and y in B: print('YES') else: print('NO')
s193960885
Accepted
17
2,940
175
A=[1,3,5,7,8,10,12] B=[4,6,9,11] C=[2] x,y=map(int,input().split()) if x in A and y in A: print('Yes') elif x in B and y in B: print('Yes') else: print('No')
s713664978
p04043
u580316619
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 = input('') if a.count('5') == 2 and a.count('7') ==1: print('yes') else: print('no')
s531811700
Accepted
17
2,940
89
a = input('') if a.count('5') == 2 and a.count('7') ==1: print('YES') else: print('NO')
s496507051
p02795
u329785342
2,000
1,048,576
Wrong Answer
17
3,064
282
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...
input_list = [] for i in range(0, 3): input_list.append(int(input())) h = input_list[0] w = input_list[1] n = input_list[2] temp_num = 0 if w <= h: temp_num = h else: temp_num = w answer = 0 if n % temp_num == 0: answer = n / temp_num else: answer = (n // temp_num) + 1
s138381047
Accepted
17
3,064
301
input_list = [] for i in range(0, 3): input_list.append(int(input())) h = input_list[0] w = input_list[1] n = input_list[2] temp_num = 0 if w <= h: temp_num = h else: temp_num = w answer = 0 if n % temp_num == 0: answer = int(n / temp_num) else: answer = (n // temp_num) + 1 print(answer)
s770900523
p03693
u771167374
2,000
262,144
Wrong Answer
17
2,940
66
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...
s = int(''.join(input().split())) print('Yes' if s%4==0 else 'No')
s679924608
Accepted
17
2,940
66
s = int(''.join(input().split())) print('YES' if s%4==0 else 'NO')
s449335912
p04043
u652569315
2,000
262,144
Wrong Answer
17
2,940
105
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each ...
l=sorted(list(map(int,input().split()))) if l[0]==7 and l[1]==l[2]==5: print('YES') else: print('NO')
s945231568
Accepted
17
2,940
105
l=sorted(list(map(int,input().split()))) if l[2]==7 and l[1]==l[0]==5: print('YES') else: print('NO')
s314680188
p03050
u564902833
2,000
1,048,576
Wrong Answer
122
3,064
339
Snuke received a positive integer N from Takahashi. A positive integer m is called a _favorite number_ when the following condition is satisfied: * The quotient and remainder of N divided by m are equal, that is, \lfloor \frac{N}{m} \rfloor = N \bmod m holds. Find all favorite numbers and print the sum of those.
N = int(input()) ans = sum( N // d - 1 for d in range(1, int(N**0.5)) if N % d == 0 and (N // (N // d - 1)) == (N % (N // d - 1)) ) print(ans)
s349713149
Accepted
123
3,060
358
N = int(input()) ans = sum( N // d - 1 for d in range(1, int(N**0.5) + 1) if N % d == 0 and N // d > 1 and (N // (N // d - 1)) == (N % (N // d - 1)) ) print(ans)
s019288730
p02268
u852745524
1,000
131,072
Wrong Answer
20
7,676
367
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.
n=int(input()) S=list(map(int,input().split())) q=int(input()) T=list(map(int,input().split())) def search(s,T): left = 0 ; right = len(T)-1 while left < right: mid = (left + right)//2 if T[mid]==s: return True elif T[mid]>s: right = mid else: left = mid+1 count = 0 for s in...
s412051378
Accepted
50
21,384
120
n=int(input()) s=map(int,input().split()) q=int(input()) t=map(int,input().split()) ans=len(set(s)&set(t)) print(ans)
s364597940
p04029
u894440853
2,000
262,144
Wrong Answer
17
2,940
39
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 + 1) * N / 2)
s089128805
Accepted
17
2,940
44
N = int(input()) print(int((N + 1) * N / 2))
s965549205
p02612
u376324032
2,000
1,048,576
Wrong Answer
29
9,144
72
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()) a = N - 1000 while a >= 1000: a = a - 1000 print(a)
s486770161
Accepted
27
9,160
140
N = int(input()) a = 0 if N >= 1000: a = N - 1000 else: a = N while a >= 1000: a = a - 1000 if a != 0: a = 1000 - a print(a)
s581418356
p03150
u865413330
2,000
1,048,576
Wrong Answer
18
2,940
188
A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
S = input() key = "keyence" ans = "No" for i in range(len(S)): for j in range(i,len(S)): if S[:i] + S[j:] == key: ans = "Yes" print(ans)
s646414989
Accepted
18
3,060
188
S = input() key = "keyence" ans = "NO" for i in range(len(S)): for j in range(i,len(S)): if S[:i] + S[j:] == key: ans = "YES" print(ans)
s494595158
p03698
u344813796
2,000
262,144
Wrong Answer
29
8,964
79
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.
s=list(str(input())) len(s) print('Yes' if len(list(set(s)))==len(s) else 'No')
s401895158
Accepted
28
8,848
74
s=list(str(input())) print('yes' if len(list(set(s)))==len(s) else 'no')
s061531884
p02612
u833436666
2,000
1,048,576
Wrong Answer
119
27,140
139
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 sys import math import numpy as np import functools import operator import collections import itertools N=int(input()) print(N%1000)
s297852942
Accepted
113
27,048
227
import sys import math import numpy as np import functools import operator import collections import itertools N=int(input()) count=0 for i in range(N): count+=1000 if count>=N: print(count-N) sys.exit()
s578639329
p03447
u278670845
2,000
262,144
Wrong Answer
17
2,940
70
You went shopping to buy cakes and donuts with X yen (the currency of Japan). First, you bought one cake for A yen at a cake shop. Then, you bought as many donuts as possible for B yen each, at a donut shop. How much do you have left after shopping?
x = int(input()) a = int(input()) b = int(input()) print(x-a-b*(x//b))
s540066089
Accepted
18
2,940
74
x = int(input()) a = int(input()) b = int(input()) print(x-a-b*((x-a)//b))
s134737198
p03575
u893063840
2,000
262,144
Wrong Answer
22
3,064
951
You are given an undirected connected graph with N vertices and M edges that does not contain self-loops and double edges. The i-th edge (1 \leq i \leq M) connects Vertex a_i and Vertex b_i. An edge whose removal disconnects the graph is called a _bridge_. Find the number of the edges that are bridges among the M ...
WHITE = 0 GRAY = 1 BLACK = 2 def dfs(s, n, m): color = [WHITE] * n stack = [s] color[s] = GRAY while stack: u = stack[-1] for v, flg in enumerate(m[u]): if flg: if color[v] == WHITE: color[v] = GRAY stack.append(v) ...
s852167067
Accepted
121
3,572
981
from copy import deepcopy WHITE = 0 GRAY = 1 BLACK = 2 def dfs(s, n, m): color = [WHITE] * n stack = [s] color[s] = GRAY while stack: u = stack[-1] for v, flg in enumerate(m[u]): if flg: if color[v] == WHITE: color[v] = GRAY ...
s282244532
p03693
u559367141
2,000
262,144
Wrong Answer
27
9,148
119
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 = input().split() is_four_multiple = g+b if int(is_four_multiple) % 4 == 0: print("Yes") else: print("No")
s410726043
Accepted
26
9,100
96
r,g,b = map(int,input().split()) if((10*g + b) % 4 == 0): print('YES') else: print('NO')
s384990948
p00015
u957840591
1,000
131,072
Wrong Answer
30
7,612
302
A country has a budget of more than 81 trillion yen. We want to process such data, but conventional integer type which uses signed 32 bit can represent up to 2,147,483,647. Your task is to write a program which reads two integers (more than or equal to zero), and prints a sum of these integers. If given integers or t...
N=int(input()) A=[] B=[] for i in range(N): a = int(input()) b = int(input()) A.append(a) B.append(b) for i in range(N): if A[i] >= 10 ** 79 or B[i] >= 10 ** 79: print("overflow") elif A[i] + B[i]>= 10 ** 79: print("overflow") else: print(A[i]+B[i])
s121335692
Accepted
20
7,532
316
N = int(input()) A = [] B = [] for i in range(N): a = int(input()) b = int(input()) A.append(a) B.append(b) for i in range(N): if A[i] >= 10 ** 80 or B[i] >= 10 ** 80: print("overflow") elif A[i] + B[i] >= 10 ** 80: print("overflow") else: print(str(A[i] + B[i]))
s396144331
p02258
u311299757
1,000
131,072
Wrong Answer
30
7,564
293
You can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen. Write a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2,...
v = [] v = str(input()).splitlines() dif_max = -200000 dif_max = -200000 for i in range(len(v) ): v[i] = int(v[i]) for i in range(len(v) - 1): for j in range(i + 1, len(v), 1): dif = v[j] - v[i] dif_max = dif if dif_max < dif else dif_max print("{}".format(dif_max))
s290884790
Accepted
500
7,664
243
cnt = int(input()) dif_max = -1000000000 v_min = 1000000000 for i in range(cnt): buf = int(input()) if i > 0: dif_max = dif_max if buf - v_min < dif_max else buf - v_min v_min = buf if buf < v_min else v_min print(dif_max)
s547213029
p03155
u102461423
2,000
1,048,576
Wrong Answer
17
2,940
91
It has been decided that a programming contest sponsored by company A will be held, so we will post the notice on a bulletin board. The bulletin board is in the form of a grid with N rows and N columns, and the notice will occupy a rectangular region with H rows and W columns. How many ways are there to choose where ...
N = int(input()) H = int(input()) W = int(input()) answer = (N-H+1) * (H-W+1) print(answer)
s641028955
Accepted
17
2,940
91
N = int(input()) H = int(input()) W = int(input()) answer = (N-H+1) * (N-W+1) print(answer)
s588555507
p03501
u971811058
2,000
262,144
Wrong Answer
17
2,940
98
You are parking at a parking lot. You can choose from the following two fee plans: * Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours. * Plan 2: The fee will be B yen, regardless of the duration. Find the minimum fee when you park for N hours.
n, a, b = map(int, input().split()) print(n, a, b) if n*a < b : print(n*a) else : print(b)
s023338858
Accepted
17
2,940
83
n, a, b = map(int, input().split()) if n*a < b : print(n*a) else : print(b)
s177648780
p03827
u717001163
2,000
262,144
Wrong Answer
17
2,940
112
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...
n=int(input()) s=input() x=0 ans=0 for i in range(n): x=x+1 if s[i]=='i' else x-1 ans=max(ans,x) print(ans)
s755656993
Accepted
18
2,940
112
n=int(input()) s=input() x=0 ans=0 for i in range(n): x=x+1 if s[i]=='I' else x-1 ans=max(ans,x) print(ans)
s047651993
p02854
u328364772
2,000
1,048,576
Wrong Answer
72
26,764
201
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()) A = list(map(int, input().split())) l, r = sum(A[:n//2]), sum(A[n//2:]) if n % 2 == 0: print(abs(l-r)) else: m = A[n//2] s, b = min(l, r-m), max(l, r-m) print(b-s-m)
s487266563
Accepted
179
26,024
187
n = int(input()) A = list(map(int, input().split())) s = sum(A) cnt = 0 res = sum(A) for a in A: cnt += a res = min(res, abs(s-cnt*2)) if res == 0: break print(res)
s640008206
p02259
u626266743
1,000
131,072
Wrong Answer
30
7,576
269
Write a program of the Bubble Sort algorithm which sorts a sequence _A_ in ascending order. The algorithm should be based on the following pseudocode: BubbleSort(A) 1 for i = 0 to A.length-1 2 for j = A.length-1 downto i+1 3 if A[j] < A[j-1] 4 swap A[j] and A[j-1] Note that, in...
N = int(input()) A = list(map(int, input().split())) count = 0 for i in range(N): for j in range(i, N): if(A[j] < A[j-1]): temp = A[j-1] A[j-1] = A[j] A[j] = temp count += 1 print(*A) print(count)
s366365336
Accepted
20
7,716
285
N = int(input()) A = list(map(int, input().split())) count = 0 flag = True while flag: flag = False for i in range(N-1, 0, -1): if(A[i] < A[i-1]): A[i], A[i-1] = A[i-1], A[i] flag = True count += 1 print(*A) print(count)
s148838478
p03044
u667469290
2,000
1,048,576
Wrong Answer
2,109
15,940
451
We have a tree with N vertices numbered 1 to N. The i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i. Your objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied: * For any two vertices...
# -*- coding: utf-8 -*- import numpy as np def solve(): N = int(input()) L = np.vstack((np.arange(N+1), np.zeros(N+1, dtype=int))) for _ in range(N-1): u, v, w = map(int, input().split()) u, v = sorted([u,v]) I = np.where(L == L[0, u])[1] L[0, I] = L[0, v] L[1, I] =...
s295747228
Accepted
596
46,124
616
# -*- coding: utf-8 -*- from heapq import heappop, heappush def solve(): N = int(input()) edges = [[] for _ in range(N+1)] for _ in range(N-1): u, v, w = map(int, input().split()) edges[u].append((v, w&1)) edges[v].append((u, w&1)) D = [-1]*(N+1) hq = [(0,1)] checked = ...
s679538832
p03644
u361826811
2,000
262,144
Wrong Answer
17
3,060
272
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 import itertools # import numpy as np read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N = int(readline()) ans=1 while N>ans: ans*=2 print(ans)
s290816652
Accepted
20
3,188
272
import sys import itertools # import numpy as np read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N = int(readline()) ans=1 while N>=ans: ans*=2 print(ans//2)
s734852446
p03457
u474423089
2,000
262,144
Wrong Answer
356
27,324
181
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1...
N=int(input()) TXY=[list(map(int,input().split(' '))) for i in range(N)] t,x,y=0,0,0 for i,j,k in TXY: if i-t!=abs(x-j)+abs(y+k): print('No') exit() print('Yes')
s654443569
Accepted
390
27,324
210
N=int(input()) TXY=[list(map(int,input().split(' '))) for i in range(N)] t,x,y=0,0,0 for i,j,k in TXY: chk=(i-t-(abs(x-j)+abs(y+k))) if chk<0 or chk%2!=0: print('No') exit() print('Yes')
s567062983
p03359
u685244071
2,000
262,144
Wrong Answer
17
2,940
75
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year. For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year. In this country, a date is called _Takahashi_ when the month and the day are equal as numbers. For ...
a, b = map(int, input().split()) if a>= b: print(a - 1) else: print(a)
s166320416
Accepted
17
2,940
76
a, b = map(int, input().split()) if a > b: print(a - 1) else: print(a)
s863546711
p03338
u703890795
2,000
1,048,576
Wrong Answer
18
2,940
163
You are given a string S of length N consisting of lowercase English letters. We will cut this string at one position into two strings X and Y. Here, we would like to maximize the number of different letters contained in both X and Y. Find the largest possible number of different letters contained in both X and Y when ...
N = int(input()) S = input() c = 0 m = 0 for i in range(N): S1 = S[:i] S2 = S[i:] c = 0 for s1 in S1: if s1 in S2: c += 1 m = max(c,m) print(m)
s804166502
Accepted
22
3,316
259
N = int(input()) S = input() import collections c = 0 m = 0 for i in range(N): S1 = S[:i] S2 = S[i:] C1 = collections.Counter(S1) C2 = collections.Counter(S2) c = 0 for c1 in C1.keys(): if c1 in C2.keys(): c += 1 m = max(m,c) print(m)
s818502565
p02268
u354053070
1,000
131,072
Wrong Answer
20
7,648
409
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.
n = int(input()) S = list(map(int, input().split())) q = int(input()) T = list(map(int, input().split())) count = 0 m, M = S[0], S[n - 1] for x in T: if x < m or M < x: continue l, r = 0, n - 1 while l < r: m = (l + r) // 2 if S[m] == x: count += 1 break ...
s857029679
Accepted
590
18,668
414
n = int(input()) S = list(map(int, input().split())) q = int(input()) T = list(map(int, input().split())) count = 0 Sm, SM = S[0], S[n - 1] for x in T: if x < Sm or SM < x: continue l, r = 0, n - 1 while l <= r: m = (l + r) // 2 if S[m] == x: count += 1 break...
s638785813
p03695
u422272120
2,000
262,144
Wrong Answer
27
9,240
787
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())) d = {'gry':0,'brw':0,'grn':0,'miz':0,'blu':0,'yel':0,'dai':0,'red':0,'any':0} for i in a: if 1 <= i <= 399: d['gry'] += 1 elif 400 <= i <= 799: d['brw'] += 1 elif 800 <= i <= 1199: d['grn'] += 1 elif 1200 <= i <= 1599: ...
s732114775
Accepted
28
9,044
726
n = int(input()) a = list(map(int,input().split())) d = {'gry':0,'brw':0,'grn':0,'miz':0,'blu':0,'yel':0,'dai':0,'red':0,'any':0} for i in a: if 1 <= i <= 399: d['gry'] += 1 elif 400 <= i <= 799: d['brw'] += 1 elif 800 <= i <= 1199: d['grn'] += 1 elif 1200 <= i <= 1599: ...
s877722176
p02663
u442850625
2,000
1,048,576
Wrong Answer
24
9,304
352
In this problem, we use the 24-hour clock. Takahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the time H_2 : M_2. (See Sample Inputs below for clarity.) He has decided to study for K consecutive minutes while he is up. What is the length of the period in which he can start studying?
import datetime h1, m1, h2, m2, k = map(int, input().split()) one = datetime.timedelta(hours=h1, minutes=m1) two = datetime.timedelta(hours=h2, minutes=m2) study = datetime.timedelta(minutes=k) diff_one_two_seconds = (two.total_seconds() - one.total_seconds()) / 60 study_seconds = study.total_seconds()/60 print(diff_...
s251007652
Accepted
24
9,320
357
import datetime h1, m1, h2, m2, k = map(int, input().split()) one = datetime.timedelta(hours=h1, minutes=m1) two = datetime.timedelta(hours=h2, minutes=m2) study = datetime.timedelta(minutes=k) diff_one_two_seconds = (two.total_seconds() - one.total_seconds()) / 60 study_seconds = study.total_seconds()/60 print(int(d...
s982927981
p03606
u366959492
2,000
262,144
Wrong Answer
20
2,940
110
Joisino is working as a receptionist at a theater. The theater has 100000 seats, numbered from 1 to 100000. According to her memo, N groups of audiences have come so far, and the i-th group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive). How many people are sitting at the theater now?
N=int(input()) l=0 for i in range(N): r,l=(int(x) for x in input().split()) l+=(r-l) print(100000-l)
s950567620
Accepted
20
2,940
105
N=int(input()) m=0 for i in range(N): l,r=(int(x) for x in input().split()) m+=(r-l+1) print(m)
s729104298
p03992
u760961723
2,000
262,144
Wrong Answer
17
2,940
39
This contest is `CODE FESTIVAL`. However, Mr. Takahashi always writes it `CODEFESTIVAL`, omitting the single space between `CODE` and `FESTIVAL`. So he has decided to make a program that puts the single space he omitted. You are given a string s with 12 letters. Output the string putting a single space between the fi...
s = input() print(s[:4] + " " + s[5:])
s331943727
Accepted
17
2,940
40
s = input() print(s[:4] + " " + s[4:])
s902462338
p03047
u702582248
2,000
1,048,576
Wrong Answer
17
2,940
40
Snuke has N integers: 1,2,\ldots,N. He will choose K of them and give those to Takahashi. How many ways are there to choose K consecutive integers?
n,k=map(int, input().split()) print(n-k)
s180936530
Accepted
17
2,940
43
n,k=map(int, input().split()) print(n-k+1)
s776645004
p00767
u571918510
8,000
131,072
Wrong Answer
1,010
7,788
659
Let us consider rectangles whose height, _h_ , and width, _w_ , are both integers. We call such rectangles _integral rectangles_. In this problem, we consider only wide integral rectangles, i.e., those with _w_ > _h_. We define the following ordering of wide integral rectangles. Given two wide integral rectangles, ...
import sys import math def is_square(n): for i in range(n): if i*i == n: return True return False def f(h,w): r = h**2 + w**2 for hh in range(h+1,w): if is_square(r-hh**2): return (hh, int(math.sqrt(r-hh**2))) t1 = h**2+(w+1)**2 t2 = (h+1)**2+w**2 ...
s216242180
Accepted
1,290
11,548
911
import sys import math def f(h,w): r = h**2 + w**2 ary = [] for hi in range(1,150+1): for wi in range(hi+1,150+1): ss = hi**2+wi**2 if ss == r and hi>h: ary.append({ "ss": ss ,"h": hi ,"w": wi ...
s153634625
p03388
u547167033
2,000
262,144
Wrong Answer
19
3,064
245
10^{10^{10}} participants, including Takahashi, competed in two programming contests. In each contest, all participants had distinct ranks from first through 10^{10^{10}}-th. The _score_ of a participant is the product of his/her ranks in the two contests. Process the following Q queries: * In the i-th query, you ...
q=int(input()) for _ in range(q): a,b=map(int,input().split()) if a>b: a,b=b,a if a==b: print(2*a-1) elif a==b+1: print(2*a-2) else: c=int((a*b)**0.5) if c*(c+1)>=a*b: print(2*c-2) else: print(2*c-1)
s185167188
Accepted
19
3,064
285
q=int(input()) for _ in range(q): a,b=map(int,input().split()) if a>b: a,b=b,a if a==b: print(2*a-2) elif b==a+1: print(2*a-2) else: c=int((a*b)**0.5)-1 while (c+1)*(c+1)<a*b: c+=1 if c*(c+1)>=a*b: print(2*c-2) else: print(2*c-1)
s007293514
p03067
u661576386
2,000
1,048,576
Wrong Answer
17
2,940
159
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.
A,B,C =map(int,input().split()) if A < B: if A < C < B: print("OK") else: print("NO") else: if B < C < A: print("OK") else: print("NO")
s450513424
Accepted
18
2,940
162
A,B,C =map(int,input().split()) if A < B: if A < C < B: print("Yes") else: print("No") else: if B < C < A: print("Yes") else: print("No")
s598616587
p03359
u440904221
2,000
262,144
Wrong Answer
17
2,940
94
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year. For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year. In this country, a date is called _Takahashi_ when the month and the day are equal as numbers. For ...
a,b = map(int,input().split()) count = 0 count = a-1 if(a < b): count=count+1 print(count)
s829117170
Accepted
17
2,940
95
a,b = map(int,input().split()) count = 0 count = a-1 if(a <= b): count=count+1 print(count)
s305768287
p03457
u558242240
2,000
262,144
Wrong Answer
247
3,064
421
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1...
import sys sys.setrecursionlimit(10**6) input = sys.stdin.readline n = int(input()) #n = 2 prev = [0,0,0] for i in range(n): txy = list(map(int, input().split())) #txy = list(map(int, ["5 1 1", "100 1 1"][i].split())) t = txy[0] - prev[0] x = abs(txy[1] - prev[1]) y = abs(txy[2] - prev[2]) d =...
s172294203
Accepted
248
3,064
429
import sys sys.setrecursionlimit(10**6) input = sys.stdin.readline n = int(input()) #n = 2 prev = [0,0,0] for i in range(n): txy = list(map(int, input().split())) #txy = list(map(int, ["3 1 2", "6 1 1"][i].split())) t = txy[0] - prev[0] x = abs(txy[1] - prev[1]) y = abs(txy[2] - prev[2]) d = x...
s713276301
p04031
u598229387
2,000
262,144
Wrong Answer
25
3,064
218
Evi has N integers a_1,a_2,..,a_N. His objective is to have N equal **integers** by transforming some of them. He may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transforming each of them (...
n=int(input()) a=[int(i) for i in input().split()] check=float('inf') for i in range(-100,101): check2=0 for j in a: check2+=(i-j)**2 if check>check2: check=check2 ans=i print(ans)
s271446619
Accepted
24
3,060
194
n=int(input()) a=[int(i) for i in input().split()] check=float('inf') for i in range(-100,101): ans=0 for j in a: ans+=(i-j)**2 if check>ans: check=ans print(check)
s091920404
p03457
u962803758
2,000
262,144
Wrong Answer
1,308
38,584
574
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1...
t = [] N = input() for i in range(int(N)): t.append(list(map(int, input().split()))) t.sort() co, co_ = [0, 0, 0], [0, 0, 0] flag = 1 for i in range(len(t)): co_[0] = t[i][0] - co[0] print(co,co_) co_[1] = t[i][1] - co[1] print(co,co_) co_[2] = t[i][2] - co[2] print(co,co_) dis ...
s751825713
Accepted
464
27,312
502
t = [] N = input() for i in range(int(N)): t.append(list(map(int, input().split()))) t.sort() co, co_ = [0, 0, 0], [0, 0, 0] flag = 1 for i in range(len(t)): co_[0] = t[i][0] - co[0] co_[1] = t[i][1] - co[1] co_[2] = t[i][2] - co[2] dis = abs(co_[1]) + abs(co_[2]) if dis % 2 != (t[i...
s123555184
p03556
u633548583
2,000
262,144
Wrong Answer
56
2,940
91
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=int(input()) m=1 for i in range(100000): if i**2<=n: m=max(i,m) print(m)
s804458395
Accepted
60
2,940
95
n=int(input()) m=1 for i in range(100000): if i**2<=n: m=max(i,m) print(m**2)
s361726841
p03150
u903460784
2,000
1,048,576
Wrong Answer
19
3,064
412
A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
s=input() ans='keyence' index=0 isCut=0 isKeyence=0 for si in s: if isCut==1: if si!=ans[index]: isKeyence=0 break elif isCut==-1: if si==ans[index]: isCut=1 else: if si==ans[index]: isKeyence=1 else: isCut=-1 i...
s521754785
Accepted
17
3,064
1,202
s=input() ans='keyence' i=0 # index of s index=0 # index of ans isCut=0 canRestart=0 restart=0 lenS=len(s) while i<lenS: # print(i,index,end='=>') if isCut==1: if index>6: # 7=len(ans) if canRestart: canRestart=0 isCut=-1 i=restartI ...
s658743080
p03494
u840958781
2,000
262,144
Time Limit Exceeded
2,104
2,940
145
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
n=int(input()) a=list(map(int,input().split())) s=[] cnt=0 for i in range(n): while a[i]%2==0: cnt+=1 s.append(cnt) print(min(s))
s186708828
Accepted
18
3,060
223
n=int(input()) a=list(map(int,input().split())) cnt=-1 while True: cnt+=1 for i in range(n): if a[i]%2==0: a[i]//=2 else: break else: continue break print(cnt)
s620591086
p03351
u374802266
2,000
1,048,576
Wrong Answer
17
2,940
106
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 ...
a,b,c,x=map(int,input().split()) d=sorted([a,b,c]) if d[2]-d[0]<=x: print('Yes') else: print('No')
s875187115
Accepted
18
2,940
101
a,b,c,x=map(int,input().split()) print('Yes' if abs(c-a)<=x or abs(b-a)<=x and abs(c-b)<=x else 'No')
s815781516
p03605
u992910889
2,000
262,144
Wrong Answer
17
2,940
78
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=list(input()) if N[0]==9 or N[1]==9: print('Yes') else: print('No')
s536674424
Accepted
17
3,068
82
N=list(input()) if N[0]=='9' or N[1]=='9': print('Yes') else: print('No')
s747017940
p00007
u424041287
1,000
131,072
Wrong Answer
20
7,672
87
Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week. Write a program which computes the amount of the debt in n weeks.
import math a = 100000 for n in range(int(input())): a = math.ceil(a*105/100) print(a)
s292319759
Accepted
20
7,580
100
import math a = 100000 for n in range(int(input())): a = math.ceil(a*105/100000)*1000 print(int(a))
s312735291
p03713
u106297876
2,000
262,144
Wrong Answer
82
3,064
381
There is a bar of chocolate with a height of H blocks and a width of W blocks. Snuke is dividing this bar into exactly three pieces. He can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle. Snuke is trying to divide the bar as evenly as possible. More specifically, he is trying...
H, W = map(int,input().split( )) ans = 0 if H % 3 == 0 or W % 3 == 0: ans = 0 if H % 2 == 0 or W % 2 == 0: ans = H * W if W % 2 == 0: H, W = W, H for i in range(W): aaa = abs(((H//2) * (i + 1)) - (W - (i + 1)) * H) ans = min(ans, aaa) if H % 2 == 1 and W % 2 == 1: ans = min((H // 2) * W - (H // 2 + 1) * ...
s502082813
Accepted
495
3,188
507
H, W = map(int,input().split( )) ans = H * W for i in range(H): l_1 = [(i+1) * W, (H - i - 1) * (W//2), (H - i - 1) * (W-(W//2))] l_2 = [(i+1) * W, ((H - i - 1)//2) * W, (H-i-1 -((H - i - 1)//2)) * W] ans = min(ans, max(l_1) - min(l_1), max(l_2) - min(l_2)) H, W = W, H for i in range(H): l_1 = [(i+1) * W, (H - i...
s514135406
p00028
u184989919
1,000
131,072
Wrong Answer
20
7,632
278
Your task is to write a program which reads a sequence of integers and prints mode values of the sequence. The mode value is the element which occurs most frequently.
import sys def ModeValue(): mode=[0 for i in range(0,101)] try: for n in sys.stdin: mode[int(n)]+=1 except EOFError: a=1 maxN=max(mode) for i in mode: if mode[i]>maxN: print(i) ModeValue()
s716987253
Accepted
30
7,632
237
import sys def ModeValue(): mode=[0 for i in range(0,101)] for n in sys.stdin: mode[int(n)]+=1 maxN=max(mode) for i in range(0,101): if mode[i]==maxN: print(i) ModeValue()
s085479317
p03719
u467307100
2,000
262,144
Wrong Answer
18
2,940
79
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()) print("YES" if a <= c and c <= b else "NO" )
s966507338
Accepted
17
2,940
69
a, b, c = map(int,input().split()) print("Yes" if a<=c<=b else "No" )