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
s385073231
p04043
u132344815
2,000
262,144
Wrong Answer
17
2,940
211
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each ...
a, b, c = map(int,input().split()) if a == 5 and b == 5 and c == 7: print('Yes') elif a == 5 and b == 7 and c == 5: print('Yes') elif a == 7 and b == 5 and c == 5: print('Yes') else: print('No')
s706894660
Accepted
17
2,940
211
a, b, c = map(int,input().split()) if a == 5 and b == 5 and c == 7: print('YES') elif a == 5 and b == 7 and c == 5: print('YES') elif a == 7 and b == 5 and c == 5: print('YES') else: print('NO')
s031686379
p03637
u820047642
2,000
262,144
Wrong Answer
63
14,224
206
We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective.
N=int(input()) A=list(map(int,input().split())) Odd,Four=0,0 for a in A: if a%2==1:Odd+=1 elif a%4==0:Four+=1 if Odd+Four==N and Odd-Four==1:print("Yes") elif Odd<=Four:print("Yse") else:print("No")
s773837949
Accepted
64
14,252
206
N=int(input()) A=list(map(int,input().split())) Odd,Four=0,0 for a in A: if a%2==1:Odd+=1 elif a%4==0:Four+=1 if Odd+Four==N and Odd-Four==1:print("Yes") elif Odd<=Four:print("Yes") else:print("No")
s633840703
p02401
u505411588
1,000
131,072
Wrong Answer
20
7,592
314
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.
x = [] while True: x = input().split() if x[1] == "?": break elif x[1] == "+": print(int(x[0]) + int(x[2])) elif x[1] == "-": print(int(x[0]) - int(x[2])) elif x[1] == "*": print(int(x[0]) * int(x[2])) elif x[1] == "/": print(int(x[0]) / int(x[2]))
s391758310
Accepted
30
7,732
315
x = [] while True: x = input().split() if x[1] == "?": break elif x[1] == "+": print(int(x[0]) + int(x[2])) elif x[1] == "-": print(int(x[0]) - int(x[2])) elif x[1] == "*": print(int(x[0]) * int(x[2])) elif x[1] == "/": print(int(x[0]) // int(x[2]))
s779957925
p03079
u625811641
2,000
1,048,576
Wrong Answer
17
2,940
82
You are given three integers A, B and C. Determine if there exists an equilateral triangle whose sides have lengths A, B and C.
a,b,c = map(int,input().split()) ans = "No" if a==b==c: ans = "yes" print(ans)
s756635248
Accepted
18
2,940
82
a,b,c = map(int,input().split()) ans = "No" if a==b==c: ans = "Yes" print(ans)
s169044484
p04011
u580362735
2,000
262,144
Wrong Answer
17
2,940
114
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 = int(input()) K = int(input()) X = int(input()) Y = int(input()) print(X*N) if K < N else print(X*K + Y*(N-K))
s270850416
Accepted
17
2,940
114
N = int(input()) K = int(input()) X = int(input()) Y = int(input()) print(X*N) if K > N else print(X*K + Y*(N-K))
s369690826
p03720
u016323272
2,000
262,144
Wrong Answer
18
3,060
178
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?
#ABC061.B N,M = map(int,input().split()) L = [] for i in range(M): a,b = map(int,input().split()) L.append([a,b]) for m in range(N+1): ans = L.count(m) print(ans)
s996876490
Accepted
17
3,060
184
N , M = map(int,input().split()) L = [] for i in range(M): a,b = map(int,input().split()) L.append(a) L.append(b) for j in range(1,N+1): ans = L.count(j) print(ans)
s425245191
p03574
u982896977
2,000
262,144
Wrong Answer
21
3,444
960
You are given an H × W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square con...
h,w = map(int,input().split()) a = ["." for i in range(w+2)] dot_map = [a] for _ in range(h): l = list(input()) l.insert(0, ".") l.append(".") dot_map.append(l) dot_map.append(a) for i in range(1, h+1): for j in range(1,w+1): if dot_map[i][j] == ".": counter = 0 if d...
s919844144
Accepted
21
3,188
973
h,w = map(int,input().split()) a = ["." for i in range(w+2)] dot_map = [a] for _ in range(h): l = list(input()) l.insert(0, ".") l.append(".") dot_map.append(l) dot_map.append(a) for i in range(1, h+1): for j in range(1,w+1): if dot_map[i][j] == ".": counter = 0 if d...
s162993539
p03861
u933214067
2,000
262,144
Wrong Answer
38
5,104
747
You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x?
from statistics import mean, median,variance,stdev import sys import math import fractions def j(a): if a==1: print("YES") else :print("NO") def ct(x,y): if (x>y):print("") elif (x<y): print("") else: print("") def ip(): return int(input()) x,y,z = (int(i) for i in input().split()) ...
s337756198
Accepted
164
13,644
1,078
from statistics import mean, median,variance,stdev import numpy as np import sys import math import fractions import itertools import copy from operator import itemgetter def j(q): if q==1: print("Yes") else:print("No") exit(0) def ct(x,y): if (x>y):print("+") elif (x<y): print("-") else: pri...
s910995777
p03997
u841623074
2,000
262,144
Time Limit Exceeded
2,104
3,064
501
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.
sa = input() sb = input() sc = input() turn = sa[0] sa = sa[1:] while True: if turn == 'a': if not sa: win = 'A' break else: turn = sa[0] sa = sa[1:] if turn == 'b': if not sb: win = 'B' break else: ...
s416672839
Accepted
17
2,940
74
a=int(input()) b=int(input()) h=int(input()) ans=(a+b)*h/2 print(int(ans))
s237271097
p03574
u742729271
2,000
262,144
Wrong Answer
30
3,064
424
You are given an H × W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square con...
H, W = map(int, input().split()) S = [[""]]*H for i in range(H): S[i] = input() print(S) dh = [-1,-1,-1,0,0,1,1,1] dw = [-1,0,1,-1,1,-1,0,1] for i in range(H): for j in range(W): count=0 if S[i][j]==".": for l in range(8): if H>i+dh[l]>-1 and W>j+dw[l]>-1: if S[i+dh[l]][j+dw[l]]=="...
s024069534
Accepted
31
3,064
415
H, W = map(int, input().split()) S = [[""]]*H for i in range(H): S[i] = input() dh = [-1,-1,-1,0,0,1,1,1] dw = [-1,0,1,-1,1,-1,0,1] for i in range(H): for j in range(W): count=0 if S[i][j]==".": for l in range(8): if H>i+dh[l]>-1 and W>j+dw[l]>-1: if S[i+dh[l]][j+dw[l]]=="#": ...
s328778273
p03353
u497046426
2,000
1,048,576
Wrong Answer
2,379
917,248
381
You are given a string s. Among the **different** substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` are substrings of s, while `ac`, `z` and an empty string are not. A...
from collections import defaultdict S = input() K = int(input()) alphabet = defaultdict(list) for i, s in enumerate(S): alphabet[s].append(i) alpha_list = sorted(alphabet.keys()) cand = [] i = 0 while len(cand) < K: for j in alphabet[alpha_list[i]]: for l in range(1, len(S)-j+1): cand.app...
s096524078
Accepted
35
5,068
190
# ABC 097 C S = input() K = int(input()) cand = [] for l in range(1, K+1): for i in range(len(S) - l + 1): cand.append(S[i:i+l]) cand = sorted(list(set(cand))) print(cand[K-1])
s739302864
p00002
u116501200
1,000
131,072
Wrong Answer
20
7,576
87
Write a program which computes the digit number of sum of two integers a and b.
[print(i//10)for i in[sum(int(e)for e in ln.split())for ln in __import__("sys").stdin]]
s239607100
Accepted
30
7,628
93
[print(len(str(i)))for i in[sum(int(e)for e in ln.split())for ln in __import__("sys").stdin]]
s734741022
p03693
u257018224
2,000
262,144
Wrong Answer
17
2,940
97
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()) A=100*r+10*g+b if A%4==0: print("Yes") else : print("No")
s780748164
Accepted
17
2,940
98
r,g ,b=map(int,input().split()) A=100*r+10*g+b if A%4==0 : print("YES") else : print("NO")
s580940604
p03478
u095021077
2,000
262,144
Wrong Answer
41
9,176
154
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
N, A, B=map(int, input().split()) ans=0 for i in range(1, N+1): s=str(i) x=0 for j in s: x+=int(j) if A<=x<=B: ans+=1 print(ans)
s895918829
Accepted
41
9,052
154
N, A, B=map(int, input().split()) ans=0 for i in range(1, N+1): s=str(i) x=0 for j in s: x+=int(j) if A<=x<=B: ans+=i print(ans)
s705896459
p02261
u482227082
1,000
131,072
Wrong Answer
20
5,600
734
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...
def bubblesort(n, a): r = a[:] for i in range(n): for j in range(n-1, i, -1): if int(r[j][1]) < int(r[j-1][1]): r[j], r[j-1] = r[j-1], r[j] print(*r) print("Stable") def selectionsort(n, a): r = a[:] ret = "Stable" for i in range(n): tmp = i ...
s290254634
Accepted
220
5,612
892
def bubblesort(n, a): r = a[:] for i in range(n): for j in range(n-1, i, -1): if int(r[j][1]) < int(r[j-1][1]): r[j], r[j-1] = r[j-1], r[j] print(*r) print("Stable") def selectionsort(n, a): r = a[:] ret = "Stable" for i in range(n): tmp = i ...
s851576217
p02612
u036065030
2,000
1,048,576
Wrong Answer
29
9,140
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.
a = int(input()) print(a % 1000)
s342430840
Accepted
32
9,148
83
a = int(input()) if a % 1000 == 0: print(0) else: print(1000 - (a % 1000))
s353359937
p04045
u650245944
2,000
262,144
Wrong Answer
20
3,188
397
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(int, input().split())) L = [i for i in range(10) if i not in D] A = [i for i in L] for i in L: for j in L: A.append(10*i+j) for i in L: for j in L: for k in L: A.append(100*i+10*j+k) for i in L: for j in L: for k in L: for l in L: A...
s649714775
Accepted
43
5,732
539
N, K = map(int, input().split()) D = list(map(int, input().split())) L = [i for i in range(10) if i not in D] A = [] for i in L: A.append(i) for i in L: for j in L: A.append(10*i+j) for i in L: for j in L: for k in L: A.append(100*i+10*j+k) for i in L: for j in L: for k in L: for l in L...
s572314399
p02392
u655518263
1,000
131,072
Wrong Answer
20
7,568
128
Write a program which reads three integers a, b and c, and prints "Yes" if a < b < c, otherwise "No".
lin = input() l = lin.split(" ") a = int(l[0]) b = int(l[1]) c = int(l[2]) if a < b < c: print('YES') else: print('NO')
s674305619
Accepted
30
7,688
128
lin = input() l = lin.split(" ") a = int(l[0]) b = int(l[1]) c = int(l[2]) if a < b < c: print('Yes') else: print('No')
s375018332
p02613
u307622233
2,000
1,048,576
Wrong Answer
149
16,616
310
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`,...
from collections import Counter def main(): N = int(input()) lst = [] for _ in range(N): lst.extend(input().split()) c = dict(Counter(lst)) for i in ["AC", "WA", "TLE", "RE"]: c.setdefault(i, 0) print(f"{i} × {c[i]}") if __name__ == '__main__': main()
s955514099
Accepted
155
16,648
308
from collections import Counter def main(): N = int(input()) lst = [] for _ in range(N): lst.extend(input().split()) c = dict(Counter(lst)) for i in ["AC", "WA", "TLE", "RE"]: c.setdefault(i, 0) print(f"{i} x {c[i]}") if __name__ == '__main__': main()
s315192113
p04043
u234631479
2,000
262,144
Wrong Answer
17
3,060
173
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 = list(map(int, input().split())) L.sort() print(L) for i in range(2): if not L[i] == 5: print("NO") exit() if not L[2] == 7: print("NO") exit() print("YES")
s820910607
Accepted
17
2,940
164
L = list(map(int, input().split())) L.sort() for i in range(2): if not L[i] == 5: print("NO") exit() if not L[2] == 7: print("NO") exit() print("YES")
s155223385
p03853
u863442865
2,000
262,144
Wrong Answer
23
3,572
193
There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, p...
import copy h, w = list(map(int, input().split())) p = [input().split() for _ in range(h)] ans = copy.deepcopy(p) for i in range(h): ans.insert(i*2, p[i]) for i in range(h*2): print(ans[i])
s793285840
Accepted
23
3,572
196
import copy h, w = list(map(int, input().split())) p = [input().split() for _ in range(h)] ans = copy.deepcopy(p) for i in range(h): ans.insert(i*2, p[i]) for i in range(h*2): print(ans[i][0])
s979724175
p03555
u203211107
2,000
262,144
Wrong Answer
17
2,940
111
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
Ca=input() Cb=input() if Ca[0]==Cb[2] and Ca[1]==Cb[1] and Ca[2]==Cb[0]: print("Yes") else: print("No")
s928822697
Accepted
17
2,940
111
Ca=input() Cb=input() if Ca[0]==Cb[2] and Ca[1]==Cb[1] and Ca[2]==Cb[0]: print("YES") else: print("NO")
s072172272
p02646
u750651325
2,000
1,048,576
Wrong Answer
2,206
9,200
515
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch ...
# -*- coding: utf-8 -*- """ Created on Sat Jun 13 20:58:10 2020 @author: sd18016 """ import sys A, V = map(int, input().split()) B, W = map(int, input().split()) T = int(input()) kyori = abs(B-A) if V <= W: print("No") sys.exit() else: miji = V - W for i in range(T): if kyori == miji*i: ...
s016519718
Accepted
36
10,136
679
import sys import math import itertools import bisect from copy import copy from collections import deque,Counter from decimal import Decimal import functools def s(): return input() def k(): return int(input()) def S(): return input().split() def I(): return map(int,input().split()) def X(): return list(input()) def L...
s861724780
p03477
u397953026
2,000
262,144
Wrong Answer
17
2,940
124
A balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L<R. Takahashi placed a mass of weight A and a mass of weight B on the left pan of a balance scale, and pl...
a,b,c,d=map(int,input().split()) if a+b>c+d: print("Right") elif a+b==c+d: print("Balanced") else: print("Left")
s319673833
Accepted
17
2,940
124
a,b,c,d=map(int,input().split()) if a+b<c+d: print("Right") elif a+b==c+d: print("Balanced") else: print("Left")
s120634927
p03504
u521389909
2,000
262,144
Wrong Answer
2,111
121,440
1,023
Joisino is planning to record N TV programs with recorders. The TV can receive C channels numbered 1 through C. The i-th program that she wants to record will be broadcast from time s_i to time t_i (including time s_i but not t_i) on Channel c_i. Here, there will never be more than one program that are broadcast on ...
import sys from itertools import accumulate # functions used r = lambda: sys.stdin.readline().strip() #single: int(r()), line: map(int, r().split()) R = lambda: list(map(int, r().split())) # line: R(), lines: [R() for _ in range(n)] Rmap = lambda: map(int, r().split()) N, C = R() STC = [R() for _ in range(N)] # 0.5...
s875705636
Accepted
1,569
122,992
860
import sys from itertools import accumulate # functions used r = lambda: sys.stdin.readline().strip() #single: int(r()), line: map(int, r().split()) R = lambda: list(map(int, r().split())) # line: R(), lines: [R() for _ in range(n)] Rmap = lambda: map(int, r().split()) N, C = R() STC = [R() for _ in range(N)] # 0.5s...
s259748971
p03448
u284363684
2,000
262,144
Wrong Answer
44
9,168
355
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that co...
# input A = int(input()) B = int(input()) C = int(input()) X = int(input()) if X % 100 == 50 and C == 0: print(0) else: all_case = len( [ 1 for a in range(A) for b in range(B) for c in range(C) if 500 * a + 100 * b + 50 * c == X ] ...
s508353088
Accepted
53
9,152
362
# input A = int(input()) B = int(input()) C = int(input()) X = int(input()) if X % 100 == 50 and C == 0: print(0) else: all_case = len( [ 1 for a in range(A + 1) for b in range(B + 1) for c in range(C + 1) if 500 * a + 100 * b + 50 * c == X ...
s942713408
p02856
u899645116
2,000
1,048,576
Wrong Answer
694
3,060
144
N programmers are going to participate in the preliminary stage of DDCC 20XX. Due to the size of the venue, however, at most 9 contestants can participate in the finals. The preliminary stage consists of several rounds, which will take place as follows: * All the N contestants will participate in the first round. ...
m = int(input()) csum = 0 dsum = 0 for i in range(m): d,c = (int(x) for x in input().split()) csum += c dsum += d*c print(c-1 + dsum // 9)
s872659859
Accepted
281
3,060
181
import sys input = sys.stdin.readline m = int(input()) csum = 0 dsum = 0 for i in range(m): d,c = map(int,input().split()) csum += c dsum += d*c print(csum-1 + (dsum-1) // 9)
s281714625
p02613
u370852395
2,000
1,048,576
Wrong Answer
140
16,612
203
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 collections N=int(input()) l=[input() for _ in range(N)] tmp = collections.Counter(l) print('AC','×',tmp["AC"]) print('WA','×',tmp["WA"]) print('TLE','×',tmp["TLE"]) print('RE','×',tmp["RE"])
s546874784
Accepted
146
16,616
199
import collections N=int(input()) l=[input() for _ in range(N)] tmp = collections.Counter(l) print('AC','x',tmp["AC"]) print('WA','x',tmp["WA"]) print('TLE','x',tmp["TLE"]) print('RE','x',tmp["RE"])
s089935525
p03302
u538523244
2,000
1,048,576
Wrong Answer
17
2,940
127
You are given two integers a and b. Determine if a+b=15 or a\times b=15 or neither holds. Note that a+b=15 and a\times b=15 do not hold at the same time.
a, b = map(int, input().split()) if a+b == 15: print("+") if a*b == 15: print("*") else: print("x")
s986111606
Accepted
17
2,940
113
a, b = map(int, input().split()) if a+b == 15: print("+") elif a*b == 15: print("*") else: print("x")
s846863741
p03486
u996665352
2,000
262,144
Wrong Answer
18
2,940
65
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.
s=sorted(input()) t=sorted(input()) print("Yes" if s<t else "No")
s018205131
Accepted
19
3,060
71
s=sorted(input()) t=sorted(input())[::-1] print("Yes" if s<t else "No")
s445172189
p02831
u779170803
2,000
1,048,576
Wrong Answer
17
3,064
493
Takahashi is organizing a party. At the party, each guest will receive one or more snack pieces. Takahashi predicts that the number of guests at this party will be A or B. Find the minimum number of pieces that can be evenly distributed to the guests in both of the cases predicted. We assume that a piece cannot be ...
INT = lambda: int(input()) INTM = lambda: map(int,input().split()) STRM = lambda: map(str,input().split()) STR = lambda: str(input()) LIST = lambda: list(map(int,input().split())) LISTS = lambda: list(map(str,input().split())) def do(): a,b = INTM() c =min(a,b) d=max(a,b) if d%c ==0: print(int(d...
s676881895
Accepted
17
3,064
494
INT = lambda: int(input()) INTM = lambda: map(int,input().split()) STRM = lambda: map(str,input().split()) STR = lambda: str(input()) LIST = lambda: list(map(int,input().split())) LISTS = lambda: list(map(str,input().split())) def do(): a,b = INTM() c =min(a,b) d=max(a,b) if d%c ==0: print(int(d...
s031161023
p04043
u753803401
2,000
262,144
Wrong Answer
17
2,940
143
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, b, c = map(int, input().split()) print("Yes" if (a == b == 5 and c == 7) or (b == c == 5 and a == 7) or (a == c == 5 and b == 7) else "No")
s127217804
Accepted
21
3,316
197
import collections a = collections.Counter(list(map(int, input().split()))).items() for k, v in a: if (k != 5 or v != 2) and (k != 7 or v != 1): print("NO") exit() print("YES")
s850765581
p03110
u793633137
2,000
1,048,576
Wrong Answer
17
3,060
190
Takahashi received _otoshidama_ (New Year's money gifts) from N of his relatives. You are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either `JPY` or `BTC`, and x_i and u_i represent the content of the otoshidama from the i-th relative. For example, if x_1 = `10000`...
N=int(input()) s=[input().split() for i in range(N)] M=0 print(s) for i in range(N): p=int(i) if s[p][1]=="JPY": M=M+float(s[p][0]) else: M=M+float(s[p][0])*380000.0 print(M)
s324053743
Accepted
17
2,940
181
N=int(input()) s=[input().split() for i in range(N)] M=0 for i in range(N): p=int(i) if s[p][1]=="JPY": M=M+float(s[p][0]) else: M=M+float(s[p][0])*380000.0 print(M)
s967288133
p02390
u467070262
1,000
131,072
Wrong Answer
20
7,644
112
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.
x = int(input()) s = x % 60 x -= s x /= 60 m = x % 60 x -= m x /= 60 print(str(x) + ":" + str(m) + ":" + str(s))
s791737903
Accepted
20
7,640
127
x = int(input()) s = x % 60 x -= s x /= 60 m = x % 60 x -= m x /= 60 print(str(int(x)) + ":" + str(int(m)) + ":" + str(int(s)))
s336456865
p02612
u298445293
2,000
1,048,576
Wrong Answer
29
9,064
38
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 = 1000 - N print(A)
s482559886
Accepted
28
9,072
86
N = int(input()) A = int(N/1000) if A != N/1000: print(1000*(A+1)-N) else: print(0)
s845303606
p03475
u993622994
3,000
262,144
Wrong Answer
40
5,212
572
A railroad running from west to east in Atcoder Kingdom is now complete. There are N stations on the railroad, numbered 1 through N from west to east. Tomorrow, the opening ceremony of the railroad will take place. On this railroad, for each integer i such that 1≤i≤N-1, there will be trains that run from Station i t...
from fractions import gcd def lcm(a, b): return a * b // gcd(a, b) N = int(input()) c = [] s = [] f = [] t = [] t_c = [] for i in range(N-1): C, S, F = map(int, input().split()) c.append(C) s.append(S) f.append(F) T = lcm(S, F) t.append(T) t_c.append(T+C) c.reverse() s.reverse() f.rev...
s620063318
Accepted
96
3,188
408
N = int(input()) csf = [list(map(int, input().split())) for _ in range(N-1)] ans = [] for i in range(N): t = 0 for j in range(i, N-1): C = csf[j][0] S = csf[j][1] F = csf[j][2] if S <= t: if t % F == 0: t += C else: t += F ...
s581872858
p03385
u342801789
2,000
262,144
Wrong Answer
17
2,940
65
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.
s = input() if s == 'abc': print('Yes') else: print('No')
s726958385
Accepted
17
3,060
180
s = input() s_list = list(s) s_sort_list = sorted(s_list) s_sort = ','.join(s_sort_list) s_sort = s_sort.replace(',', '') if s_sort == 'abc': print('Yes') else: print('No')
s422958476
p03377
u411858517
2,000
262,144
Wrong Answer
17
2,940
89
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
A, B, X = map(int, input().split()) if X - A <= B: print("Yes") else: print("No")
s236127902
Accepted
17
2,940
94
A, B, X = map(int, input().split()) if 0 <= X - A <= B: print("YES") else: print("NO")
s491768671
p03149
u853185302
2,000
1,048,576
Wrong Answer
18
3,060
412
You are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits "1974".
s = input() target = 'keyence' s_len = len(s) flg = 0 target1_len = 0 for i in range(8): target1_ind = -1 target1 = target[0:i] target2 = target[i:7] if target1 in s: target1_ind = s.index(target1) print(target1_ind) target1_len = len(target1) if target2 in s[target1_ind+...
s216668940
Accepted
17
2,940
204
N_list = input().split() flg = 0 if '1' in N_list: if '9' in N_list: if '7' in N_list: if '4' in N_list: flg = 1 if flg == 1: print('YES') else: print('NO')
s114689632
p02396
u095590628
1,000
131,072
Wrong Answer
140
5,608
97
In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets. Write a program which reads an integer x and print it as is. Note that multiple datasets are give...
a = int(input()) i = 1 while(a != 0): print("Case ",i,": ",a) i = 1 a = int(input())
s854537339
Accepted
140
5,604
109
a = int(input()) i = 1 while(a != 0): print("Case {0}: {1}".format(i,a)) i += 1 a = int(input())
s113138591
p03796
u004025573
2,000
262,144
Wrong Answer
17
2,940
131
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.
mod=1000000007 def P(x): ans=1 for i in range(x): ans=ans*(i+1)%mod return(ans) n=int(input()) print(n)
s088356266
Accepted
35
2,940
134
mod=1000000007 def P(x): ans=1 for i in range(x): ans=ans*(i+1)%mod return(ans) n=int(input()) print(P(n))
s081304554
p02694
u115877451
2,000
1,048,576
Wrong Answer
25
9,168
86
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...
a=int(input()) count=0 b=100 while b<=a: b=b*1.01 b=int(b) count+=1 print(count)
s283355954
Accepted
23
9,172
85
a=int(input()) count=0 b=100 while b<a: b=b*1.01 b=int(b) count+=1 print(count)
s933085732
p03399
u144980750
2,000
262,144
Wrong Answer
17
2,940
92
You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimu...
a=[int(input(i)) for i in range(2)] b=[int(input(i)) for i in range(2)] print(min(a)+min(b))
s497939491
Accepted
17
2,940
90
a=[int(input()) for i in range(2)] b=[int(input()) for i in range(2)] print(min(a)+min(b))
s390699258
p03351
u290187182
2,000
1,048,576
Wrong Answer
26
3,828
421
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 ...
import sys import copy import math import bisect import pprint import bisect from functools import reduce from copy import deepcopy from collections import deque def lcm(x, y): return (x * y) // math.gcd(x, y) if __name__ == '__main__': a = [int(i) for i in input().split()] if abs(a[0]-a[2]) <a[3] or...
s867226880
Accepted
25
3,828
420
import sys import copy import math import bisect import pprint import bisect from functools import reduce from copy import deepcopy from collections import deque def lcm(x, y): return (x * y) // math.gcd(x, y) if __name__ == '__main__': a = [int(i) for i in input().split()] if abs(a[0]-a[2]) <=a[3] or (a...
s176468964
p02606
u477837488
2,000
1,048,576
Wrong Answer
30
9,124
108
How many multiples of d are there among the integers between L and R (inclusive)?
L, R, d = map(int, input().split()) if L % d == 0: print((R - L) // d + 1) else: print((R - L) // d)
s133574590
Accepted
25
9,032
58
l, r, d = map(int, input().split()) print(r//d - (l-1)//d)
s730842820
p03251
u625741705
2,000
1,048,576
Wrong Answer
17
3,064
170
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 = list(map(int,input().split())) y = list(map(int,input().split())) if(max(x) < min(y)-1): print("No War") else: print("War")
s083240119
Accepted
17
3,060
192
N,M,X,Y = map(int,input().split()) x = list(map(int,input().split())) y = list(map(int,input().split())) x.append(X) y.append(Y) if(max(x) < min(y)): print("No War") else: print("War")
s260626902
p03433
u678875535
2,000
262,144
Wrong Answer
17
3,060
322
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()) def hantei(N, A): if (N - A) <= 0: print("No") else: if ((N - A) % 100) != 0: print("No") elif ((N-A) % 100) == 0 and ((N-A) % 500) == 0: print("Yes") else: print("No") if __name__ == "__main__": hantei(N, ...
s483442914
Accepted
18
2,940
172
N=int(input()) A=int(input()) def hantei(N, A): if (N % 500) - A <= 0: print("Yes") else: print("No") if __name__ == "__main__": hantei(N, A)
s399989957
p03163
u841623074
2,000
1,048,576
Wrong Answer
215
15,508
250
There are N items, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), Item i has a weight of w_i and a value of v_i. Taro has decided to choose some of the N items and carry them home in a knapsack. The capacity of the knapsack is W, which means that the sum of the weights of items taken must be at most W. Find ...
import numpy as np N,W=map(int,input().split()) w,v=[],[] for i in range(N): a,b=map(int,input().split()) w+=[a] v+=[b] DP=np.zeros(W+1,dtype=int) print(DP) for i in range(N): DP[w[i]:]=np.maximum(DP[:-w[i]]+v[i],DP[w[i]:]) print(DP)
s783315942
Accepted
221
15,476
245
import numpy as np N,W=map(int,input().split()) w,v=[],[] for i in range(N): a,b=map(int,input().split()) w+=[a] v+=[b] DP=np.zeros(W+1,dtype=int) for i in range(N): DP[w[i]:]=np.maximum(DP[:-w[i]]+v[i],DP[w[i]:]) print(max(DP))
s651221979
p03597
u268285577
2,000
262,144
Wrong Answer
17
2,940
65
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()) brack = N ** N - A print(brack)
s834050845
Accepted
17
2,940
65
n = int(input()) a = int(input()) brack = n ** 2 - a print(brack)
s166547193
p02613
u882564128
2,000
1,048,576
Wrong Answer
149
9,160
298
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()) C = [0]*4 for i in range(N): S = input() if S == 'AC': C[0] += 1 elif S == 'WA': C[1] += 1 elif S == 'TLE': C[2] += 1 elif S == 'RE': C[3] += 1 print('AC ×', C[0]) print('WA ×', C[1]) print('TLE ×', C[2]) print('RE ×', C[3])
s621901416
Accepted
149
9,160
314
N = int(input()) C = [0]*4 for i in range(N): S = input() if S == 'AC': C[0] += 1 elif S == 'WA': C[1] += 1 elif S == 'TLE': C[2] += 1 elif S == 'RE': C[3] += 1 print('AC x '+str(C[0])) print('WA x '+str(C[1])) print('TLE x '+str(C[2])) print('RE x '+str(C[3]))
s267018983
p02612
u690781906
2,000
1,048,576
Wrong Answer
28
9,024
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)
s905198132
Accepted
25
9,116
81
N = int(input()) if N % 1000 == 0: print(0) else: print(1000 - N % 1000)
s297480767
p02850
u595905528
2,000
1,048,576
Wrong Answer
548
47,768
824
Given is a tree G with N vertices. The vertices are numbered 1 through N, and the i-th edge connects Vertex a_i and Vertex b_i. Consider painting the edges in G with some number of colors. We want to paint them so that, for each vertex, the colors of the edges incident to that vertex are all different. Among the colo...
from collections import deque N = int(input()) node_branch = [[] for _ in range(N+1)] branch = [0] * (N) link = [0] * (N+1) checked = [False] * (N+1) for num in range(N - 1): a, b = map(int, input().split()) node_branch[a].append((b, num+1)) node_branch[b].append((a, num+1)) maxlen = 0 for i, node in enum...
s805100454
Accepted
518
47,628
839
from collections import deque N = int(input()) node_branch = [[] for _ in range(N+1)] branch = [0] * (N) link = [0] * (N+1) checked = [False] * (N+1) for num in range(N - 1): a, b = map(int, input().split()) node_branch[a].append((b, num+1)) node_branch[b].append((a, num+1)) maxlen = 0 for i, node in enum...
s406186228
p03503
u665038048
2,000
262,144
Wrong Answer
19
3,064
456
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 = [] P = [] for i in range(N): F.append(list(map(int, input().split()))) for j in range(N): P.append(list(map(int, input().split()))) even_list = [] odd_list = [] for i in range(N): even_sum = 0 odd_sum = 0 for j in range(5): even_sum += F[i][0::2][j]*P[i][2*j] odd...
s897839653
Accepted
40
3,064
404
max_time = 10 n = int(input()) f = [sum(v << max_time - k - 1 for k, v in enumerate(map(int, input().split()))) for i in range(n)] p = [[int(j) for j in input().split()] for i in range(n)] pattern = [sum(i >> j & 1 for j in range(max_time)) for i in range(2 ** max_time)] print(max(sum( p[j]...
s176860355
p02678
u449473917
2,000
1,048,576
Wrong Answer
694
35,940
476
There is a cave. The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside. It is dark in th...
from collections import deque n,m=map(int,input().split()) graph=[[] for i in range(n)] sirusi=[0]*n for i in range(m): a,b=map(int,input().split()) a-=1;b-=1 graph[a].append(b) graph[b].append(a) D=deque([0]) visited=[False]*n visited[0]=True while D: v=D.popleft() for i in graph[v]: if...
s701487068
Accepted
671
34,844
462
from collections import deque n,m=map(int,input().split()) graph=[[] for i in range(n)] sirusi=[0]*n for i in range(m): a,b=map(int,input().split()) a-=1;b-=1 graph[a].append(b) graph[b].append(a) D=deque([0]) visited=[False]*n visited[0]=True while D: v=D.popleft() for i in graph[v]: if...
s419136361
p02255
u217703215
1,000
131,072
Wrong Answer
20
5,596
255
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(A) return A N=int(input()) A=input().split() insertionSort(A,N)
s126442210
Accepted
30
5,984
333
N=int(input()) A=[0 for i in range(N)] A=input().split() for i in range(N): A[i]=(int)(A[i]) for i in range(N): v=A[i] j=i-1 while j>=0 and A[j]>v: A[j+1]=A[j] j=j-1 A[j+1]=v for i in range(N): if i!=N-1: print(A[i],end=" ") if i==N-1: ...
s676270142
p03433
u304209389
2,000
262,144
Wrong Answer
17
2,940
131
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
Nyen = int(input()) Amai = int(input()) while Nyen > 500: Nyen = Nyen - 500 if Nyen < Amai: print('YES') else: print('NO')
s229381704
Accepted
17
2,940
98
Nyen = int(input()) Amai = int(input()) if Nyen % 500 <= Amai: print('Yes') else: print('No')
s698804585
p03416
u999503965
2,000
262,144
Wrong Answer
30
9,100
212
Find the number of _palindromic numbers_ among the integers between A and B (inclusive). Here, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward.
a,b=map(int,input().split()) cnt=0 for i in range(1,10): for j in range(1,10): for k in range(1,10): num=int(str(i)+str(j)+str(k)+str(j)+str(i)) if a<=num<=b: cnt+=1 print(cnt)
s083148665
Accepted
30
9,112
212
a,b=map(int,input().split()) cnt=0 for i in range(1,10): for j in range(0,10): for k in range(0,10): num=int(str(i)+str(j)+str(k)+str(j)+str(i)) if a<=num<=b: cnt+=1 print(cnt)
s537748299
p03228
u067986021
2,000
1,048,576
Wrong Answer
18
3,064
218
In the beginning, Takahashi has A cookies, and Aoki has B cookies. They will perform the following operation alternately, starting from Takahashi: * If the number of cookies in his hand is odd, eat one of those cookies; if the number is even, do nothing. Then, give one-half of the cookies in his hand to the other pe...
a, b, k = [int(i) for i in input().split(" ")] for i in range(k): if a % 2 == 1: a -= 1 b += (a / 2) a = a / 2 if b % 2 == 1: b -= 1 a += (b / 2) b = b / 2 print("{} {}".format(int(a), int(b)))
s318692610
Accepted
18
3,064
309
a, b, k = [int(i) for i in input().split(" ")] for i in range(int(k / 2)): if a % 2 == 1: a -= 1 b += (a / 2) a = a / 2 if b % 2 == 1: b -= 1 a += (b / 2) b = b / 2 if k % 2 == 1: if a % 2 == 1: a -= 1 b += (a / 2) a = a / 2 print("{} {}".format(int(a), int(b)))
s979706714
p03674
u203900263
2,000
262,144
Wrong Answer
2,104
13,812
500
You are given an integer sequence of length n+1, a_1,a_2,...,a_{n+1}, which consists of the n integers 1,...,n. It is known that each of the n integers 1,...,n appears at least once in this sequence. For each integer k=1,...,n+1, find the number of the different subsequences (not necessarily contiguous) of the given s...
import math def nCm(n, m): return math.factorial(n) // (math.factorial(m) * (math.factorial(n - m))) n = int(input()) a = list(map(int, input().split())) saw = [-1] * n left = 0 right = 0 for i in range(n): if saw[a[i] - 1] == -1: saw[a[i] - 1] = i else: left, right = saw[a[i] -1 ], n -...
s384815117
Accepted
1,375
20,420
914
def power(x, n): y = 1 while n > 0: if n % 2 == 0: x = (x * x) % (10 ** 9 + 7) n = n // 2 else: y = (y * x) % (10 ** 9 + 7) n = n - 1 return y MOD = 10 ** 9 + 7 n = int(input()) a = list(map(int, input().split())) fact = [1] * (n + 2) inv =...
s072068674
p03457
u086624329
2,000
262,144
Wrong Answer
911
3,316
276
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()) start=[0,0,0] ans=0 for i in range(n): cont=list(map(int,input().split())) if abs(start[0]-cont[0])!=abs(start[1]-cont[1])+abs(start[2]-cont[2]): print('No') ans=1 start=cont if ans==0: print('Yes')
s027400850
Accepted
415
3,064
490
n=int(input()) start=[0,0,0] ans=0 for i in range(n): cont=list(map(int,input().split())) x=abs(start[0]-cont[0]) y=abs(start[1]-cont[1])+abs(start[2]-cont[2]) if x<y: ans=1 else: if x%2==0: if y%2!=0: ans=1 ...
s455944086
p03730
u731368968
2,000
262,144
Wrong Answer
17
2,940
122
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()) f=False for i in range(b): if a*i%b==c: f=True print('Yes' if f else 'No')
s994719726
Accepted
17
2,940
122
a, b, c = map(int, input().split()) f=False for i in range(b): if a*i%b==c: f=True print('YES' if f else 'NO')
s226989492
p03658
u744898490
2,000
262,144
Wrong Answer
18
3,064
212
Snuke has N sticks. The length of the i-th stick is l_i. Snuke is making a snake toy by joining K of the sticks together. The length of the toy is represented by the sum of the individual sticks that compose it. Find the maximum possible length of the toy.
ab = input().split(' ') st = input().split(' ') st = [int(x) for x in st] k = int(ab[1]) max1 =0 for i in range( int(ab[0])-k): if sum(st[i:i+k+1] ) > max1: max1= sum(st[i:i+k] ) print(max1)
s091613529
Accepted
20
3,064
210
ab = input().split(' ') st = input().split(' ') st = [int(x) for x in st] k = int(ab[1]) max1 =0 pl = sum(st) for i in range(int(ab[0])-k): pl -= min(st) del st[st.index(min(st))] print(pl)
s032697963
p03565
u131634965
2,000
262,144
Wrong Answer
17
3,064
525
E869120 found a chest which is likely to contain treasure. However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters. He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with `?`. One mo...
ss=input()[::-1] t=input()[::-1] match_len=0 for i in range(len(ss)-len(t)): for j in range(len(t)): if ss[i+j]=="?" or ss[i+j]==t[j]: match_len+=1 print("match") else: match_len=0 break if match_len==len(t): ss=ss[:...
s049424677
Accepted
17
3,060
467
ss=input()[::-1] t=input()[::-1] for i in range(len(ss)-len(t)+1): match_len=0 for j in range(len(t)): if ss[i+j]=="?" or ss[i+j]==t[j]: match_len+=1 else: break if match_len==len(t): ss=ss[:i]+t+ss[i+len(t):] ss=ss.replace("?","a") ...
s894395659
p03973
u139112865
2,000
262,144
Wrong Answer
244
7,080
268
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 _ in range(n)] ans = 0 tmp = 1 for i in range(n): if a[i] <= tmp: tmp = max(tmp, a[i] + 1) continue ans += -(-(a[i] - tmp) // tmp) a[i] = a[i] + (-(a[i] - tmp) // tmp) * tmp a[i] = 1 print(ans)
s533045349
Accepted
246
7,080
201
n = int(input()) a = [int(input()) for _ in range(n)] ans = 0 tmp = 1 for i in range(n): if a[i] > tmp: ans += (a[i] - 1) // tmp a[i] = 1 tmp = max(tmp, a[i] + 1) print(ans)
s575634072
p02390
u800408401
1,000
131,072
Wrong Answer
20
5,580
94
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=int(S//360) m=int((S-(h*360))/60) s=int(S-(h*360+m*60)) print(h,':',m,':',s)
s742194265
Accepted
20
5,588
104
S=int(input()) h=int(S//3600) m=int((S-(h*3600))/60) s=int(S-(h*3600+m*60)) print(h,':',m,':',s,sep='')
s466698329
p03407
u094565093
2,000
262,144
Wrong Answer
17
2,940
86
An elementary school student Takahashi has come to a variety store. He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it? Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.
A, B, C = map(int, input().split()) if A+B<=C: print("Yes") else: print("No")
s646577328
Accepted
17
2,940
86
A, B, C = map(int, input().split()) if A+B>=C: print("Yes") else: print("No")
s747152923
p03635
u475966842
2,000
262,144
Wrong Answer
18
2,940
39
In _K-city_ , there are n streets running east-west, and m streets running north-south. Each street running east-west and each street running north-south cross each other. We will call the smallest area that is surrounded by four streets a block. How many blocks there are in K-city?
n,m=map(int,input().split()) print(n*m)
s364057194
Accepted
17
2,940
47
n,m=map(int,input().split()) print((n-1)*(m-1))
s718183989
p02565
u315078622
5,000
1,048,576
Wrong Answer
233
10,752
3,419
Consider placing N flags on a line. Flags are numbered through 1 to N. Flag i can be placed on the coordinate X_i or Y_i. For any two different flags, the distance between them should be at least D. Decide whether it is possible to place all N flags. If it is possible, print such a configulation.
from itertools import product import sys input = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 6 + 100) class StronglyConnectedComponets: def __init__(self, n: int) -> None: self.n = n self.edges = [[] for _ in range(n)] self.rev_edeges = [[] for _ in range(n)] self.vs = [...
s410279633
Accepted
206
9,940
3,007
import sys input = sys.stdin.buffer.readline class StronglyConnectedComponets: def __init__(self, n: int) -> None: self.n = n self.edges = [[] for _ in range(n)] self.rev_edeges = [[] for _ in range(n)] self.vs = [] self.order = [0] * n self.used = [False] * n ...
s580238823
p03155
u438383815
2,000
1,048,576
Wrong Answer
17
2,940
79
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 ...
a = int(input()) b = int(input()) c = int(input()) d = a-b c = a-c print(d*c)
s188058226
Accepted
17
2,940
83
a = int(input()) b = int(input()) c = int(input()) d = a-b+1 c = a-c+1 print(d*c)
s855794325
p03455
u221393935
2,000
262,144
Wrong Answer
17
2,940
83
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
a,b=map(int,input().split()) if a*b%2==0: print("even") else: print("odd")
s207237835
Accepted
18
2,940
83
a,b=map(int,input().split()) if a*b%2==0: print("Even") else: print("Odd")
s111105004
p03385
u272377260
2,000
262,144
Wrong Answer
18
2,940
96
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.
s = input() for i in "abc": if i not in s: break else: print('Yes') print('No')
s442214399
Accepted
18
2,940
98
s = input() for i in "abc": if i not in s: print('No') break else:print('Yes')
s914320426
p03399
u084357428
2,000
262,144
Wrong Answer
17
3,060
186
You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimu...
a = [int(_) for _ in input().split()] if len(a) == 4 and all(1 <= item <= 1000 for item in a): print(min(a[0] + a[2], a[0] + a[3], a[1] + a[2], a[1] + a[3])) else: print('hoge!')
s133728246
Accepted
18
3,064
271
a = [] b = int(input()) a.append(b) c = int(input()) a.append(c) d = int(input()) a.append(d) e = int(input()) a.append(e) if len(a) == 4 and all(1 <= item <= 1000 for item in a): print(min(a[0] + a[2], a[0] + a[3], a[1] + a[2], a[1] + a[3])) else: print('hoge!')
s613647860
p02669
u989345508
2,000
1,048,576
Wrong Answer
2,206
10,984
2,240
You start with the number 0 and you want to reach the number N. You can change the number, paying a certain amount of coins, with the following operations: * Multiply the number by 2, paying A coins. * Multiply the number by 3, paying B coins. * Multiply the number by 5, paying C coins. * Increase or decrease...
import sys check=dict() N,a,b,c,d=0,0,0,0,0 def dfs_sub(n,ttf,cha): global check,d if n%ttf<=(ttf//2): if n//ttf==0: if n//ttf in check: if check[n//ttf]>check[n]+(n%ttf)*d: check[n//ttf]=check[n]+(n%ttf)*d dfs(n//ttf,check[n]+(n%ttf)...
s971337432
Accepted
399
11,216
207
def f(n): if (m:=s.get(n,-1))<0:s[n]=m=min([d*n]+[abs(p*k-n)*d+c+f(k)for p,c in zip((2,3,5),b)for k in(n//p,0--n//p)]) return m exec("n,*b,d=map(int,input().split());s={0:0,1:d};print(f(n));"*int(input()))
s950136893
p03720
u027622859
2,000
262,144
Wrong Answer
17
3,064
176
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?
n, m = map(int, input().split()) ab = [input().split() for _ in range(m)] ab = [item for ab in ab for item in ab] print(ab) for x in range(1, n+1): print(ab.count(str(x)))
s062697906
Accepted
18
3,064
166
n, m = map(int, input().split()) ab = [input().split() for _ in range(m)] ab = [item for ab in ab for item in ab] for x in range(1, n+1): print(ab.count(str(x)))
s804927295
p03359
u740047492
2,000
262,144
Wrong Answer
17
2,940
57
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()) print(a if a<b else a-1)
s291387152
Accepted
17
2,940
58
a, b = map(int, input().split()) print(a if a<=b else a-1)
s983308818
p03555
u846155148
2,000
262,144
Wrong Answer
25
8,952
164
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
c = input('') d = input('') if c == d[::-1]: print('Yes') else: print('No')
s627634593
Accepted
27
8,928
164
c = input('') d = input('') if c == d[::-1]: print('YES') else: print('NO')
s642382838
p03054
u562935282
2,000
1,048,576
Wrong Answer
113
4,004
886
We have a rectangular grid of squares with H horizontal rows and W vertical columns. Let (i,j) denote the square at the i-th row from the top and the j-th column from the left. On this grid, there is a piece, which is initially placed at square (s_r,s_c). Takahashi and Aoki will play a game, where each player has a st...
import sys input = sys.stdin.readline def main(): h, w, n = map(int, input().split()) y, x = map(int, input().split()) y -= 1 x -= 1 s, t = input(), input() u, d, l, r = 0, h - 1, 0, w - 1 for ss, tt in zip(s[::-1], t[::-1]): if tt == 'U': d = min(d + 1, h - 1) ...
s030204054
Accepted
110
4,024
807
def main(): h, w, n = map(int, input().split()) y, x = map(int, input().split()) s, t = input(), input() u, d, l, r = 1, h, 1, w for ss, tt in zip(s[::-1], t[::-1]): if tt == 'U': d = min(d + 1, h) elif tt == 'D': u = max(u - 1, 1) elif tt == 'L': ...
s971953638
p03624
u840958781
2,000
262,144
Wrong Answer
18
3,188
131
You are given a string S consisting of lowercase English letters. Find the lexicographically (alphabetically) smallest lowercase English letter that does not occur in S. If every lowercase English letter occurs in S, print `None` instead.
s=input() all="abcdefghijklmnopqrstuvwxyz" for i in all: if i not in s: print(i) elif i=="z": print("None")
s737896170
Accepted
17
3,188
155
s=input() ans=1 all="abcdefghijklmnopqrstuvwxyz" for i in all: if i not in s: print(i) ans=0 break if ans==1: print("None")
s043375876
p03361
u637551956
2,000
262,144
Wrong Answer
20
3,064
1,118
We have a canvas divided into a grid with H rows and W columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Initially, all the squares are white. square1001 wants to draw a picture with black paint. His specific objective is to make Square (i, j) black when s_{i...
H,W=map(int,input().split()) S = [list(str(input())) for i in range(H)] judge=True for i in range(H): for j in range(W): if S[i][j]=='#': judge1=True judge2=True judge3=True judge4=True try:S[i][j-1] except IndexError:judge...
s448673474
Accepted
20
3,064
1,144
H,W=map(int,input().split()) S = [list(str(input())) for i in range(H)] judge=True for i in range(H): for j in range(W): if S[i][j]=='#': judge1=True judge2=True judge3=True judge4=True try:S[i][j-1] except IndexError:judge...
s165230773
p03486
u168778320
2,000
262,144
Wrong Answer
19
3,064
727
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.
class Judge(): @classmethod def judge1(cls,s,t): if len(s) == len(t): return False judge = True n = min(len(s),len(t)) for i in range(n): judge = judge and s[i]==t[i] return judge @classmethod def judge2(cls,s,t): n = min(len(s),le...
s894951742
Accepted
17
2,940
149
s = list(input()) s.sort() s = ''.join(s) t= list(input()) t.sort() t = ''.join(reversed(list(t))) if s < t: print('Yes') else: print('No')
s885481601
p03337
u444856278
2,000
1,048,576
Wrong Answer
17
2,940
63
You are given two integers A and B. Find the largest value among A+B, A-B and A \times B.
a,b = [int() for i in input().split()] print(max(a+b,a-b,a*b))
s939722402
Accepted
17
2,940
64
a,b = [int(i) for i in input().split()] print(max(a+b,a-b,a*b))
s991696119
p02669
u225388820
2,000
1,048,576
Wrong Answer
276
10,984
378
You start with the number 0 and you want to reach the number N. You can change the number, paying a certain amount of coins, with the following operations: * Multiply the number by 2, paying A coins. * Multiply the number by 3, paying B coins. * Multiply the number by 5, paying C coins. * Increase or decrease...
t=int(input()) INF=10**19 def dfs(k): if k==1:return d if k==0:return 0 if k in dic:return dic[k] ans=INF ans=min(ans,dfs(k//2)+a+k%2*d,dfs((k+1)//2)+a+-k%2*d,dfs(k//3)+b+k%3*d,dfs((k+2)//3)+b+-k%3*d,dfs(k//5)+c+k%5*d,dfs((k+4)//5)+c+-k%5*d) dic[k]=ans return ans for _ in range(t): dic={...
s218673512
Accepted
284
10,888
321
def f(k): if k==1:return d if k==0:return 0 if k in m:return m[k] s=min(k*d,f(k//2)+a+k%2*d,f(-(-k//2))+a+-k%2*d,f(k//3)+b+k%3*d,f(-(-k//3))+b+-k%3*d,f(k//5)+c+k%5*d,f(-(-k//5))+c+-k%5*d) m[k]=s return s for _ in range(int(input())): m={} n,a,b,c,d=map(int,input().split()) print(f(n)...
s388664059
p03693
u062484507
2,000
262,144
Wrong Answer
17
2,940
85
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 (r*100+g*10+b) % 4 == 0 else 'No')
s730567887
Accepted
17
2,940
85
r, g, b = map(int, input().split()) print('YES' if (r*100+g*10+b) % 4 == 0 else 'NO')
s912085386
p02411
u104931506
1,000
131,072
Wrong Answer
20
7,512
347
Write a program which reads a list of student test scores and evaluates the performance for each student. The test scores for a student include scores of the midterm examination m (out of 50), the final examination f (out of 50) and the makeup examination r (out of 100). If the student does not take the examination, t...
while True: m, f, r = map(int, input().split()) A = m + f + r if m == f == r == -1: break elif m == 0 or f == 0: print('F') elif A >= 80: print('A') elif 65 <= A < 80: print('B') elif 50 <= A < 65: print('C') elif 30 <= A < 50: print('D') ...
s330111671
Accepted
40
7,668
406
while True: m, f, r = map(int, input().split()) A = m + f if m == f == r == -1: break elif m == -1 or f == -1: print('F') elif A >= 80: print('A') elif 65 <= A < 80: print('B') elif 50 <= A < 65: print('C') elif 30 <= A < 50: if 50 <= r: ...
s868652503
p03044
u761989513
2,000
1,048,576
Wrong Answer
631
32,276
691
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...
n = int(input()) a = sorted([list(map(int, input().split())) for i in range(n - 1)]) color = [-1 for i in range(n)] color[0] = 1 for i in a: u, v, w = i u -= 1 v -= 1 if w % 2 == 0: if color[u] == 0: color[v] = 0 if color[u] == 1: color[v] = 1 if color[v] ...
s531845399
Accepted
809
45,132
791
import heapq def dijkstra(graph, node, start): dist = [float("inf") for _ in range(node)] dist[start] = 0 q = [] heapq.heappush(q, (0, start)) while q: cost, cur_node = heapq.heappop(q) if dist[cur_node] < cost: continue for nex_cost, nex_node in graph[cur_no...
s992897349
p03577
u133038626
2,000
262,144
Wrong Answer
16
2,940
19
Rng is going to a festival. The name of the festival is given to you as a string S, which ends with `FESTIVAL`, from input. Answer the question: "Rng is going to a festival of what?" Output the answer. Here, assume that the name of "a festival of s" is a string obtained by appending `FESTIVAL` to the end of s. For ex...
print(input()[:-9])
s524183775
Accepted
17
2,940
19
print(input()[:-8])
s113275029
p02928
u708255304
2,000
1,048,576
Wrong Answer
1,854
3,188
472
We have a sequence of N integers A~=~A_0,~A_1,~...,~A_{N - 1}. Let B be a sequence of K \times N integers obtained by concatenating K copies of A. For example, if A~=~1,~3,~2 and K~=~2, B~=~1,~3,~2,~1,~3,~2. Find the inversion number of B, modulo 10^9 + 7. Here the inversion number of B is defined as the number of o...
N, K = map(int, input().split()) A = list(map(int, input().split())) mod = 1000000007 B = A * 2 syokiti_A = 0 syokiti_B = 0 for i in range(N): for j in range(i, N): if A[i] > A[j]: syokiti_A += 1 for i in range(N*2): for j in range(i, N*2): if B[i] > B[j]: syokiti_B ...
s903779753
Accepted
1,061
3,188
393
N, K = map(int, input().split()) A = list(map(int, input().split())) mod = 10**9+7 ans = 0 normal = 0 for i in range(N): for j in range(i+1, N): if A[i] > A[j]: normal += 1 un_normal = 0 for i in range(N): for j in range(N): if A[i] > A[j]: un_normal += 1 print((normal ...
s057930637
p02620
u729133443
2,000
1,048,576
Wrong Answer
29
9,124
1
"Local search" is a powerful method for finding a high-quality solution. In this method, instead of constructing a solution from scratch, we try to find a better solution by slightly modifying the already found solution. If the solution gets better, update it, and if it gets worse, restore it. By repeating this process...
0
s205948609
Accepted
1,391
122,188
491
from numba import njit from numpy import int64,zeros @njit('i8(i8[:],i8[:])',cache=True) def func(s,x): last=zeros(26,int64) score=0 for i,v in enumerate(x,1): last[v]=i c=0 for j in range(26): c+=s[j]*(i-last[j]) score+=s[i*26+v]-c return score def main(): ...
s101255448
p03557
u111497285
2,000
262,144
Wrong Answer
857
24,012
884
The season for Snuke Festival has come again this year. First of all, Ringo will perform a ritual to summon Snuke. For the ritual, he needs an altar, which consists of three parts, one in each of the three categories: upper, middle and lower. He has N parts for each of the three categories. The size of the i-th upper ...
n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) a = sorted(a) b = sorted(b) c = sorted(c) def bs(li, num): """return boundary index""" l = 0 r = len(li) - 1 if li[l] >= num: return -1 elif li[r] < num: ret...
s395035776
Accepted
1,549
22,720
911
n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) cnt = [0] * len(b) a = sorted(a) c = sorted(c) for i in range(len(b)): target = b[i] l = 0 r = len(a) - 1 if a[l] >= target: cnt[i] += 0 elif a[r] < target: ...
s072188544
p03623
u926678805
2,000
262,144
Wrong Answer
17
2,940
87
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and...
# coding: utf-8 x,a,b=map(int,input().split()) print('A' if abs(x-a)>abs(x-b) else 'B')
s962482137
Accepted
17
2,940
87
# coding: utf-8 x,a,b=map(int,input().split()) print('A' if abs(x-a)<abs(x-b) else 'B')
s750501107
p02608
u209275335
2,000
1,048,576
Wrong Answer
46
9,400
258
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
n = int(input()) li = [0]*n for i in range(1,32): for j in range(1,32): for k in range(1,32): if i*2 + j*2 + k*2 + i*j + j*k + k*i <= n: li[i*2 + j*2 + k*2 + i*j + j*k + k*i-1] += 1 for i in range(n): print(li[i])
s223845729
Accepted
1,026
9,368
268
n = int(input()) li = [0]*n for i in range(1,100): for j in range(1,100): for k in range(1,100): if i**2 + j**2 + k**2 + i*j + j*k + k*i <= n: li[i**2 + j**2 + k**2 + i*j + j*k + k*i -1] += 1 for i in range(n): print(li[i])
s040420628
p03997
u483640741
2,000
262,144
Wrong Answer
17
2,940
64
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*1/2)
s095323845
Accepted
17
2,940
88
a=int(input()) b=int(input()) h=int(input()) answer=(a+b)*h*1/2 print(round(answer))
s250402186
p03400
u220345792
2,000
262,144
Wrong Answer
17
2,940
138
Some number of chocolate pieces were prepared for a training camp. The camp had N participants and lasted for D days. The i-th participant (1 \leq i \leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on. As a result, there were X ...
n = int(input()) D, X = map(int, input().split()) cnt = 0 D = D -1 for i in range(n): tmp = int(input()) cnt += D//tmp print(X+cnt)
s900360221
Accepted
17
2,940
142
n = int(input()) D, X = map(int, input().split()) cnt = 0 D = D -1 for i in range(n): tmp = int(input()) cnt += D//tmp print(X+cnt+n)
s586255364
p03494
u840974625
2,000
262,144
Time Limit Exceeded
2,107
2,940
202
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()) list = list(map(int, input().split())) b = 0 while True: for i in range(n): if(list[i] % 2 == 0): list[i] = list[i] / 2 else: break b += 1 print(b)
s859541603
Accepted
19
2,940
222
n = int(input()) list = list(map(int, input().split())) b = -1 cont = True while cont: b += 1 for i in range(n): if(list[i] % 2 == 0): list[i] = list[i] / 2 else: cont = False print(b)
s908528014
p03680
u668726177
2,000
262,144
Wrong Answer
194
7,084
162
Takahashi wants to gain muscle, and decides to work out at AtCoder Gym. The exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up. These buttons are numbered 1 through N. When Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It ...
n = int(input()) a = [int(input())-1 for _ in range(n)] now = 0 checked = set() for i in range(1, n+1): now = a[now] if now==1: print(i) else: print(-1)
s218792889
Accepted
187
7,084
172
n = int(input()) a = [int(input())-1 for _ in range(n)] now = 0 checked = set() for i in range(1, n+1): now = a[now] if now==1: print(i) break else: print(-1)
s154475030
p02612
u668503853
2,000
1,048,576
Wrong Answer
28
9,144
28
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)
s845907557
Accepted
32
9,148
71
N=int(input()) if N%1000!=0: print(1000-N%1000) else: print(N%1000)
s340031347
p03067
u404057606
2,000
1,048,576
Wrong Answer
17
2,940
119
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.
abc=list(map(int,input().split())) a=abc[0] b=abc[1] c=abc[2] if (b-c)*(a-c)<0: print("YES") else: print("NO")
s722039793
Accepted
17
2,940
103
h = list(map(int,input().split())) if (h[2]-h[1])*(h[2]-h[0])<0: print("Yes") else: print("No")
s241563283
p02842
u821712904
2,000
1,048,576
Wrong Answer
17
3,064
148
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)....
n=int(input()) if 100*n/108//1==100*(n+1)/108//1: print(':(') elif 100*(n+1)/108%1!=0: print(100*(n+1)/108//1) else: print(100*(n+1)/108//1-1)
s288792138
Accepted
18
2,940
128
n=int(input()) for i in range(int(100*n/108//1),int(100*(n+1)/108//1)+1): if i*1.08//1==n: print(i) exit() print(':(')
s081872830
p00037
u150984829
1,000
131,072
Wrong Answer
20
5,612
389
上から見ると図 1 のような形の格子状の広場があります。この格子の各辺に「壁」があるかないかを 0 と 1 の並びで表します。点 A に立って壁に右手をつき、壁に右手をついたまま、矢印の方向に歩き続けて再び点 A に戻ってくるまでの経路を出力するプログラムを作成してください。 --- 図1 ---
g=[[0]*5 for _ in[0]*5] for i in range(9): e=input() for j in range(4+i%2): if int(e[j]): if i%2:g[i//2][j]+=4;g[i//2+1][j]+=1 else:r=g[i//2];r[j]+=2;r[j+1]+=8 y,x=0,1 k=1 a='1' while 1: k=k%4+3 for i in range(4): k=k+i if g[y][x]&int(2**(k%4)):a+=str(k%4);break if k%2:x+=[1,-1][(k%4)>1] else:y+=[-1,1...
s997694967
Accepted
20
5,612
368
g=[[0]*5 for _ in[0]*5] for i in range(9): e=input() for j in range(4+i%2): if int(e[j]): if i%2:g[i//2][j]+=4;g[i//2+1][j]+=1 else:r=g[i//2];r[j]+=2;r[j+1]+=8 y,x=0,1 k=1 a=[1] while 1: k+=2 for _ in[0]*4: k+=1 if g[y][x]&int(2**(k%4)):a+=[k%4];break if k%2:x+=1-2*((k%4)>1) else:y+=2*((k%4)>0)-1 if ...
s694408966
p03545
u994784668
2,000
262,144
Wrong Answer
17
3,060
230
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given in...
import itertools num = str(input()) sign = ("+", "-") for s1, s2, s3 in itertools.product(sign, repeat=3): result = num[0] + s1 + num[1] + s2 + num[2] + s3 + num[3] if eval(result) == 7: print(result) break
s629892754
Accepted
17
3,060
235
import itertools num = str(input()) sign = ("+", "-") for s1, s2, s3 in itertools.product(sign, repeat=3): result = num[0] + s1 + num[1] + s2 + num[2] + s3 + num[3] if eval(result) == 7: print(result+"=7") break