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
s789321218
p03494
u270057938
2,000
262,144
Time Limit Exceeded
2,108
14,180
616
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
import numpy import re import math def calc_max_num(int_list): count = 0 even_flag = False while True: for i in int_list: if i % 2 == 1: even_flag = True if even_flag is True: break else: for i in int_list: i /= 2 count += 1 return count def main(): line = input() int_num = int(line) line = input() line_list = re.split(" +", line) int_list = [int(s) for s in line_list] print(calc_max_num(int_list)) if __name__ == '__main__': main()
s462206574
Accepted
150
12,508
540
import numpy import re import math def main(): n = input() a = list(map(int, input().split())) ans = float("inf") for i in a: ans = min(ans, len(bin(i)) - bin(i).rfind("1") - 1) print(round(ans)) if __name__ == '__main__': main()
s954191352
p03160
u668785999
2,000
1,048,576
Wrong Answer
102
13,924
256
There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N.
def Frog1(): N = int(input()) Hs = list(map(int,input().split())) dp = [0 for i in range(N)] dp[0] = 0 dp[1] = abs(Hs[1]-Hs[0]) for i in range(2,N): dp[i] = min(abs(Hs[i-1]-Hs[i])+dp[i-1],abs(Hs[i-2]-Hs[i])+dp[i-2]) Frog1()
s767807129
Accepted
104
13,924
275
def Frog1(): N = int(input()) Hs = list(map(int,input().split())) dp = [0 for i in range(N)] dp[0] = 0 dp[1] = abs(Hs[1]-Hs[0]) for i in range(2,N): dp[i] = min(abs(Hs[i-1]-Hs[i])+dp[i-1],abs(Hs[i-2]-Hs[i])+dp[i-2]) print(dp[N-1]) Frog1()
s944074419
p03919
u102461423
2,000
262,144
Wrong Answer
18
2,940
190
There is a grid with H rows and W columns. The square at the i-th row and j-th column contains a string S_{i,j} of length 5. The rows are labeled with the numbers from 1 through H, and the columns are labeled with the uppercase English letters from `A` through the W-th letter of the alphabet. Exactly one of the squares in the grid contains the string `snuke`. Find this square and report its location. For example, the square at the 6-th row and 8-th column should be reported as `H6`.
H,W = map(int,input().split()) answer = '' for row in range(H): for col,s in enumerate(input().split()): if s == 'snuke': answer = chr(ord('A')+col) + str(row) print(answer)
s568845311
Accepted
17
2,940
192
H,W = map(int,input().split()) answer = '' for row in range(H): for col,s in enumerate(input().split()): if s == 'snuke': answer = chr(ord('A')+col) + str(row+1) print(answer)
s261547998
p02842
u336093806
2,000
1,048,576
Wrong Answer
38
5,016
142
Takahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it. The consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \times 1.08 yen (rounded down to the nearest integer). Takahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer. If there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.
N = int(input()) s = [] for i in range(50000): s.append(int((i+1)*1.08)) if N in s: print(int(1001/1.08+1/1.08)) else: print(":)")
s280220980
Accepted
38
5,144
144
N = int(input()) s = [] for i in range(50000): s.append(int((i+1)*1.08)) if N in s: print(int(N/1.08+1/1.08)) else: print(":(")
s626813581
p03599
u778700306
3,000
262,144
Wrong Answer
119
3,064
742
Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations. * Operation 1: Pour 100A grams of water into the beaker. * Operation 2: Pour 100B grams of water into the beaker. * Operation 3: Put C grams of sugar into the beaker. * Operation 4: Put D grams of sugar into the beaker. In our experimental environment, E grams of sugar can dissolve into 100 grams of water. Snuke will make sugar water with the highest possible density. The beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker. Find the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it. If there is more than one candidate, any of them will be accepted. We remind you that the sugar water that contains a grams of water and b grams of sugar is \frac{100b}{a + b} percent. Also, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water.
a,b,c,d,e,f = map(int, input().split()) waters = [] for i in range(f // (100 * a) + 1): for j in range(f // (100 * b) + 1): amount = 100 * (i * a + j * b) if amount <= e: waters.append(100 * i * a + 100 * j * b) sugers = [] for i in range(f // c + 1): for j in range(f // d + 1): amount = i * c + j * d if amount <= e: sugers.append(i * c + j * d) maxp = 0.0 res_w = 0 res_s = 0 for w in waters: for s in sugers: if w + s > f or w + s == 0: continue capa = w // 100 * e if s > capa: continue p = 100 * s / (w + s) if maxp < p: maxp, res_w, res_s = p, w + s, s print("%d %d" % (res_w, res_s))
s075393970
Accepted
180
12,440
760
a,b,c,d,e,f = map(int, input().split()) waters = [] for i in range(f // (100 * a) + 1): for j in range(f // (100 * b) + 1): amount = 100 * (i * a + j * b) if amount <= f: waters.append(amount) sugers = [] for i in range(f // c + 1): for j in range(f // d + 1): amount = i * c + j * d if amount <= f: sugers.append(amount) waters = set(waters) sugers = set(sugers) maxp = -1.0 res_w = 0 res_s = 0 for w in waters: for s in sugers: if w + s > f or w + s == 0: continue capa = w // 100 * e if s > capa: continue p = 100 * s / (w + s) if maxp < p: maxp, res_w, res_s = p, w + s, s print("%d %d" % (res_w, res_s))
s926616254
p03844
u089230684
2,000
262,144
Wrong Answer
17
2,940
77
Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
# Python user_input = input("Input in format A op B") print(eval(user_input))
s589105476
Accepted
18
2,940
98
n,x,m=input().split() if x=='+': print(int(n)+int(m)) if x=='-': print(int(n)-int(m))
s750371696
p03352
u845620905
2,000
1,048,576
Wrong Answer
17
2,940
76
You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
x = int(input()) ans = 1 while(ans**2 <= x): ans += 1 print(ans**2)
s333919969
Accepted
17
2,940
131
x = int(input()) ans = 1 for i in range(2, x+1): n = i*i while(n <= x): ans = max(ans, n) n *= i print(ans)
s176815104
p03556
u787679173
2,000
262,144
Wrong Answer
21
2,940
68
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()) i = 1 while i * i <= N: i = i + 1 print(i * i)
s285037306
Accepted
24
2,940
78
N = int(input()) i = 1 while (i + 1) * (i + 1) <= N: i = i + 1 print(i * i)
s171575284
p02612
u840958781
2,000
1,048,576
Wrong Answer
27
9,096
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)
s885621406
Accepted
28
9,012
64
n=int(input()) if n%1000==0: print(0) else: print(1000-n%1000)
s512314897
p02612
u474122160
2,000
1,048,576
Wrong Answer
33
9,076
30
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-n%1000)
s621226174
Accepted
29
9,088
69
n=int(input()) if(n%1000==0): print("0") else: print(1000-n%1000)
s795023056
p03698
u633450100
2,000
262,144
Wrong Answer
31
8,996
127
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.
s = input() list = [] for i in s: list.append(i) for j in list: if j in s: print('no') break print('yes')
s617562371
Accepted
33
8,988
212
import sys k = 'abcdefghijklmnopqrstuvwxyz' alp = {} for i in k: alp[i] = 0 s = input() for i in s: if alp[i] == 0: alp[i] = 1 else: print('no') sys.exit() print('yes')
s035024428
p02409
u539753516
1,000
131,072
Wrong Answer
20
5,600
289
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 floor at building b. If v is negative, it means that −v persons left. Assume that initially no person lives in the building.
n=int(input()) a=[[[0 for _ in range(10)]for _ in range(3)]for _ in range(4)] for i in range(n): b,f,r,v=map(int, input().split()) a[b-1][f-1][r-1]+=v for bb in range(b): for ff in range(f): print(*a[bb][ff]) if bb==2: break else: print("#"*20)
s352556503
Accepted
30
5,624
294
n=int(input()) a=[[[0 for _ in range(10)]for _ in range(3)]for _ in range(4)] for i in range(n): b,f,r,v=map(int, input().split()) a[b-1][f-1][r-1]+=v for bb in range(4): for ff in range(3): print(*[""]+a[bb][ff]) if bb==3: break else: print("#"*20)
s785786933
p03711
u616040357
2,000
262,144
Wrong Answer
17
3,060
236
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.
def solve(): x, y = map(int, input().split()) a = [0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1] if a[x] == a[y]: ans = "YES" else: ans = "NO" print(ans) if __name__ == '__main__': solve()
s432919607
Accepted
17
2,940
236
def solve(): x, y = map(int, input().split()) a = [0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1] if a[x] == a[y]: ans = "Yes" else: ans = "No" print(ans) if __name__ == '__main__': solve()
s100149927
p02741
u448650754
2,000
1,048,576
Wrong Answer
18
3,060
139
Print the K-th element of the following sequence of length 32: 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
K=int(input()) L=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51] L.sort() print(L[K-1])
s883389772
Accepted
17
2,940
132
k=int(input()) l=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51] print(l[k-1])
s295671597
p00004
u028347703
1,000
131,072
Wrong Answer
20
5,628
466
Write a program which solve a simultaneous equation: ax + by = c dx + ey = f The program should print x and y for given a, b, c, d, e and f (-1,000 ≤ a, b, c, d, e, f ≤ 1,000). You can suppose that given equation has a unique solution.
import sys def det(mat): t = 1 / (mat[0][0] * mat[1][1] - mat[0][1] * mat[1][0]) a = t * mat[1][1] b = t * -1 * mat[0][1] c = t * -1 * mat[1][0] d = t * mat[0][0] return [[a, b], [c, d]] for line in sys.stdin: try: a, b, c, d, e, f = [int(i) for i in line.split()] A = [[a, b], [d, e]] P = [c, f] detA = det(A) print("%lf %lf" % (detA[0][0] * P[0] + detA[0][1] * P[1], detA[1][0] * P[0] + detA[1][1] * P[1])) except: break
s694194888
Accepted
20
5,624
470
import sys def det(mat): t = 1 / (mat[0][0] * mat[1][1] - mat[0][1] * mat[1][0]) a = t * mat[1][1] b = t * -1 * mat[0][1] c = t * -1 * mat[1][0] d = t * mat[0][0] return [[a, b], [c, d]] for line in sys.stdin: try: a, b, c, d, e, f = [int(i) for i in line.split()] A = [[a, b], [d, e]] P = [c, f] detA = det(A) print("%.3lf %.3lf" % (detA[0][0] * P[0] + detA[0][1] * P[1], detA[1][0] * P[0] + detA[1][1] * P[1])) except: break
s523121821
p02692
u619819312
2,000
1,048,576
Wrong Answer
186
16,808
2,723
There is a game that involves three variables, denoted A, B, and C. As the game progresses, there will be N events where you are asked to make a choice. Each of these choices is represented by a string s_i. If s_i is `AB`, you must add 1 to A or B then subtract 1 from the other; if s_i is `AC`, you must add 1 to A or C then subtract 1 from the other; if s_i is `BC`, you must add 1 to B or C then subtract 1 from the other. After each choice, none of A, B, and C should be negative. Determine whether it is possible to make N choices under this condition. If it is possible, also give one such way to make the choices.
n,a,b,c=map(int,input().split()) if a+b+c==0: print("No") elif a+b+c==1: d=[] for i in range(n): s=input() if s=="AB": if a+b==0: print("No") exit() else: if a==0: d.append("A") else: d.append("B") a,b=b,a if s=="BC": if c+b==0: print("No") exit() else: if b==0: d.append("B") else: d.append("C") c,b=b,c if s=="AC": if a+c==0: print("No") exit() else: if a==0: d.append("A") else: d.append("C") a,c=c,a print("Yes") for i in d: print(i) else: d=[] s=[input()for i in range(n)]+["AB"] for i in range(n): if s[i]=="AB": if a+b==0: print("No") exit() if a+b+c==2 and a==b==1 and s[i+1]!=s[i]: if s[i]=="AC": d.append("A") a+=1 b-=1 else: d.append("B") b+=1 a-=1 elif a==0: d.append("A") a+=1 b-=1 else: d.append("B") b+=1 a-=1 if s=="BC": if c+b==0: print("No") exit() if a+b+c==2 and c==b==1 and s[i+1]!=s[i]: if s[i]=="AB": d.append("B") c-=1 b+=1 else: d.append("C") c+=1 b-=1 elif b==0: d.append("B") b+=1 c-=1 else: d.append("C") c+=1 b-=1 if s=="AC": if c+a==0: print("No") exit() if a+b+c==2 and c==a==1 and s[i+1]!=s[i]: if s[i]=="AB": d.append("A") a+=1 c-=1 else: d.append("C") c+=1 a-=1 elif a==0: d.append("A") a+=1 c-=1 else: d.append("C") c+=1 a-=1 print("Yes") for i in d: print(i)
s517107684
Accepted
210
17,048
2,754
n,a,b,c=map(int,input().split()) if a+b+c==0: print("No") elif a+b+c==1: d=[] for i in range(n): s=input() if s=="AB": if a+b==0: print("No") exit() else: if a==0: d.append("A") else: d.append("B") a,b=b,a if s=="BC": if c+b==0: print("No") exit() else: if b==0: d.append("B") else: d.append("C") c,b=b,c if s=="AC": if a+c==0: print("No") exit() else: if a==0: d.append("A") else: d.append("C") a,c=c,a print("Yes") for i in d: print(i) else: d=[] s=[input()for i in range(n)]+["AB"] for i in range(n): if s[i]=="AB": if a+b==0: print("No") exit() if a+b+c==2 and a==1 and b==1 and s[i+1]!=s[i]: if s[i+1]=="AC": d.append("A") a+=1 b-=1 else: d.append("B") b+=1 a-=1 elif a<b: d.append("A") a+=1 b-=1 else: d.append("B") b+=1 a-=1 elif s[i]=="BC": if c+b==0: print("No") exit() if a+b+c==2 and c==1 and b==1 and s[i+1]!=s[i]: if s[i+1]=="AB": d.append("B") c-=1 b+=1 else: d.append("C") c+=1 b-=1 elif b<c: d.append("B") b+=1 c-=1 else: d.append("C") c+=1 b-=1 elif s[i]=="AC": if c+a==0: print("No") exit() if a+b+c==2 and c==1and a==1 and s[i+1]!=s[i]: if s[i+1]=="AB": d.append("A") a+=1 c-=1 else: d.append("C") c+=1 a-=1 elif a<c: d.append("A") a+=1 c-=1 else: d.append("C") c+=1 a-=1 print("Yes") for i in d: print(i)
s643314282
p04000
u589969467
3,000
262,144
Wrong Answer
3,331
939,036
463
We have a grid with H rows and W columns. At first, all cells were painted white. Snuke painted N of these cells. The i-th ( 1 \leq i \leq N ) cell he painted is the cell at the a_i-th row and b_i-th column. Compute the following: * For each integer j ( 0 \leq j \leq 9 ), how many subrectangles of size 3×3 of the grid contains exactly j black cells, after Snuke painted N cells?
h,w,n = map(int,input().split()) s = [[0 for j in range(w+2)] for i in range(h+2)] #print(s) for i in range(0,n): x,y = map(int,input().split()) s[x-1][y-1] += 1 s[x-1][y] += 1 s[x-1][y+1] += 1 s[x][y-1] += 1 s[x][y] += 1 s[x][y+1] += 1 s[x+1][y-1] += 1 s[x+1][y] += 1 s[x+1][y+1] += 1 print(s) ans = [0] * 10 for i in range(2,h): for j in range(2,w): ans[s[i][j]] += 1 for i in range(0,10): print(ans[i])
s698643258
Accepted
2,679
135,604
840
def add_memo(tate,yoko): global memo if 2 <= tate <= h-1: if 2 <= yoko <= w-1: memo.append([tate,yoko]) h,w,n = map(int,input().split()) #print(s) memo = [] for i in range(0,n): x,y = map(int,input().split()) add_memo(x-1,y-1) add_memo(x-1,y) add_memo(x-1,y+1) add_memo(x,y-1) add_memo(x,y) add_memo(x,y+1) add_memo(x+1,y-1) add_memo(x+1,y) add_memo(x+1,y+1) memo.sort() ans = [0] * 10 ans[0] = (h-2)*(w-2) tmp_x = 0 tmp_y = 0 count = 0 for i in range(0,len(memo)): if tmp_x == memo[i][0] and tmp_y == memo[i][1]: ans[count] -= 1 count += 1 ans[count] += 1 else: ans[0] -= 1 count = 1 ans[count] += 1 tmp_x = memo[i][0] tmp_y = memo[i][1] # print(memo[i],count) for i in range(0,10): print(ans[i])
s658088014
p04029
u076363290
2,000
262,144
Wrong Answer
24
9,044
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 = input() print(int(N)*(int(N)+1)/2)
s882521334
Accepted
29
9,044
73
N = input() s = 0 i = 1 while i <= int(N): s = s + i i = i + 1 print(s)
s826453935
p03069
u510097799
2,000
1,048,576
Wrong Answer
120
12,512
175
There are N stones arranged in a row. Every stone is painted white or black. A string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is `.`, and the stone is black if the character is `#`. Takahashi wants to change the colors of some stones to black or white so that there will be no white stone immediately to the right of a black stone. Find the minimum number of stones that needs to be recolored.
n = int(input()) s = list(input()) b = s.count("*") b_l = 0 lst =[n - b] for i in range(len(s)): b_l += (s[i] == "*") lst.append(2 * b_l + (n - i - 1) - b) print(min(lst))
s099449698
Accepted
115
4,840
155
n = int(input()) s = list(input()) b = 0 w = s.count(".") m = w for i in range(n): if s[i] == "#": b += 1 else: w -= 1 m = min(m, b + w) print(m)
s929439965
p03407
u926678805
2,000
262,144
Wrong Answer
17
2,940
63
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()) print('Yes' if a+b==c else 'No')
s067198969
Accepted
17
2,940
63
a,b,c=map(int,input().split()) print('Yes' if a+b>=c else 'No')
s158395656
p03361
u369212307
2,000
262,144
Wrong Answer
22
3,064
604
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, j}= `#`, and to make Square (i, j) white when s_{i, j}= `.`. However, since he is not a good painter, he can only choose two squares that are horizontally or vertically adjacent and paint those squares black, for some number of times (possibly zero). He may choose squares that are already painted black, in which case the color of those squares remain black. Determine if square1001 can achieve his objective.
tate, yoko = map(int, input().split()) s = [input() for i in range(tate)] dxy = [(-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1)] for i in range(tate): for j in range(yoko): if s[i][j] == "#": save = [] for dx, dy in dxy: if i + dy < 0 or i + dy > tate - 1 or j + dx < 0 or j + dx > yoko - 1: continue if s[i + dy][j + dx] == "#": save.append("#") break if "#" in save: continue else: print("NO") exit() print("YES")
s365371941
Accepted
21
3,064
569
tate, yoko = map(int, input().split()) s = [input() for i in range(tate)] dxy = [(-1, 0), (0, -1), (0, 1), (1, 0),] for i in range(tate): for j in range(yoko): if s[i][j] == "#": save = [] for dx, dy in dxy: if i + dy < 0 or i + dy > tate - 1 or j + dx < 0 or j + dx > yoko - 1: continue if s[i + dy][j + dx] == "#": save.append("#") break if "#" in save: continue else: print("No") exit() print("Yes")
s000030547
p03377
u006425112
2,000
262,144
Wrong Answer
17
2,940
83
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.
s = input() sum = 700 for i in s: if i == "o": sum += 100 print(sum)
s646676230
Accepted
17
2,940
120
import sys a, b, x = map(int, sys.stdin.readline().split()) if a <= x <= a + b: print("YES") else: print("NO")
s289177716
p03557
u873904588
2,000
262,144
Wrong Answer
429
28,432
822
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 part is A_i, the size of the i-th middle part is B_i, and the size of the i-th lower part is C_i. To build an altar, the size of the middle part must be strictly greater than that of the upper part, and the size of the lower part must be strictly greater than that of the middle part. On the other hand, any three parts that satisfy these conditions can be combined to form an altar. How many different altars can Ringo build? Here, two altars are considered different when at least one of the three parts used is different.
import bisect if __name__ == "__main__": N = int(input()) A = sorted(list(map(int, input().split()))) B = sorted(list(map(int, input().split()))) C = sorted(list(map(int, input().split()))) BB = [] CC = [] print(A) print(B) print(C) print('-------') cnt = 0 for i in range(N): b = B[i] a_index = bisect.bisect_left(A, b) if i == 0: BB.append(a_index) else: BB.append(BB[i-1] + a_index) for i in range(N): c = C[i] b_index = bisect.bisect_left(B, c) if b_index == 0: CC.append(0) continue if i == 0: CC.append(BB[b_index - 1]) else: CC.append(CC[i-1] + BB[b_index - 1]) # print(CC) print(CC[-1])
s599384164
Accepted
411
26,312
830
import bisect if __name__ == "__main__": N = int(input()) A = sorted(list(map(int, input().split()))) B = sorted(list(map(int, input().split()))) C = sorted(list(map(int, input().split()))) BB = [] CC = [] # print(A) # print(C) # print('-------') cnt = 0 for i in range(N): b = B[i] a_index = bisect.bisect_left(A, b) if i == 0: BB.append(a_index) else: BB.append(BB[i-1] + a_index) for i in range(N): c = C[i] b_index = bisect.bisect_left(B, c) if b_index == 0: CC.append(0) continue if i == 0: CC.append(BB[b_index - 1]) else: CC.append(CC[i-1] + BB[b_index - 1]) # print(CC) print(CC[-1])
s053133271
p03623
u858136677
2,000
262,144
Wrong Answer
17
3,064
80
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and t on a number line is represented by |s-t|.
l = input().split() x = int(l[0]) t = int(l[1]) y = x - t print('{0}'.format(y))
s983367728
Accepted
18
3,060
172
def abs(x): if x >= 0: return x else: return -1 * x ls = list(map(int,input().split())) if abs(ls[0] - ls[1]) < abs(ls[0] - ls[2]): print ('A') else: print ('B')
s144825881
p03545
u708255304
2,000
262,144
Wrong Answer
18
3,060
239
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
ticket = list(str(input())) for state in range(1 << (len(ticket)-1)): fomula = ticket[0] + ''.join(('+' if state >> i & 1 else '-') + x for i, x in enumerate(ticket[1:])) if eval(fomula) == 7: print(fomula) exit()
s191572217
Accepted
17
3,060
467
numbers = list(input()) for i in range(1 << (len(numbers)-1)): tmp = numbers[0] for j in range(len(numbers)-1): if (i >> j) & 1: tmp += "+" else: tmp += "-" tmp += numbers[j+1] if eval(tmp) == 7: print(tmp+"=7") break
s593817061
p02402
u017435045
1,000
131,072
Wrong Answer
20
5,588
130
Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence.
ns=input().split() for i in range(len(ns)): ns[i]=int(ns[i]) asum=sum(ns) amin=min(ns) amax=max(ns) print(amin, amax,asum)
s860398078
Accepted
20
6,296
139
n=input() ns=input().split() for i in range(len(ns)): ns[i]=int(ns[i]) asum=sum(ns) amin=min(ns) amax=max(ns) print(amin, amax,asum)
s515456375
p03860
u683117905
2,000
262,144
Wrong Answer
26
8,828
33
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 uppercase English letter at the beginning of s. Given the name of the contest, print the abbreviation of the name.
s=input() print("A" + s[0] + "C")
s807008378
Accepted
31
8,972
30
s=input() print("A"+s[8]+"C")
s918941344
p04043
u241190800
2,000
262,144
Wrong Answer
17
2,940
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 of the phrases once, in some order.
data = [int(i) for i in input().split(" ")] print(data) total = 0 for i in data: if i==7 or i==5: total += i if total == 17: print("YES") else: print("NO")
s003626298
Accepted
17
2,940
117
tupni = [int(idx) for idx in input().split(" ")] tupni.sort() if tupni == [5,5,7]: print("YES") else: print("NO")
s158656415
p02396
u104171359
1,000
131,072
Wrong Answer
120
7,612
375
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 given for this problem.
#!usr/bin/env python3 def main(): count = 1 while True: x = int(input()) print('Case ' + str(count) + ': ' + str(x)) count += 1 if x == 0: break if __name__ == '__main__': main() # http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_3_B
s083503689
Accepted
130
7,676
227
#!usr/bin/env python3 def main(): count = 1 while True: x = int(input()) if x == 0: break print('Case %d: %d' % (count, x)) count += 1 if __name__ == '__main__': main()
s753073472
p03407
u776871252
2,000
262,144
Wrong Answer
19
2,940
90
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("No") else: print("Yes")
s989035182
Accepted
17
2,940
91
A, B, C = map(int, input().split()) if A + B >= C: print("Yes") else: print("No")
s916157824
p00008
u728901930
1,000
131,072
Wrong Answer
30
7,640
248
Write a program which reads an integer n and identifies the number of combinations of a, b, c and d (0 ≤ a, b, c, d ≤ 9) which meet the following equality: a + b + c + d = n For example, for n = 35, we have 4 different combinations of (a, b, c, d): (8, 9, 9, 9), (9, 8, 9, 9), (9, 9, 8, 9), and (9, 9, 9, 8).
import sys import math as mas n=int(input()) out=0 for i in range(10): for j in range(10): for k in range(10): for l in range(10): if(i+j+k+l==n):out+=1 print(out) # a,b=map(int,i.split()) # print(gcd(a,b),lcm(a,b))
s587318634
Accepted
30
7,640
234
import sys import math as mas x=[0]*60 for i in range(10): for j in range(10): for k in range(10): for l in range(10): x[i+j+k+l]+=1 for i in sys.stdin: print(x[int(i)]) # a,b=map(int,i.split()) # print(gcd(a,b),lcm(a,b))
s569797133
p03997
u912862653
2,000
262,144
Wrong Answer
17
2,940
68
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
a = int(input()) b = int(input()) h = int(input()) print((a+b)*h/2)
s742509987
Accepted
18
2,940
73
a = int(input()) b = int(input()) h = int(input()) print(int((a+b)*h/2))
s945183192
p03729
u534308356
2,000
262,144
Wrong Answer
25
9,016
97
You are given three strings A, B and C. Check whether they form a _word chain_. More formally, determine whether both of the following are true: * The last character in A and the initial character in B are the same. * The last character in B and the initial character in C are the same. If both are true, print `YES`. Otherwise, print `NO`.
a, b, c = map(str, input().split()) if a == b and b == c: print("YES") else: print("NO")
s745097500
Accepted
30
9,032
111
a, b, c = map(str, input().split()) if a[-1] == b[0] and b[-1] == c[0]: print("YES") else: print("NO")
s583196906
p02282
u805716376
1,000
131,072
Wrong Answer
20
5,596
282
Write a program which reads two sequences of nodes obtained by the preorder tree walk and the inorder tree walk on a binary tree respectively, and prints a sequence of the nodes obtained by the postorder tree walk on the binary tree.
n = int(input()) pre = list(map(int, input().split())) ino = list(map(int, input().split())) root = pre[1] pre = iter(pre).__next__ def dfs(l, r): if l >= r: return c = pre() m = ino.index(c) dfs(l, m) dfs(m+1, r) print(c) dfs(0, len(ino))
s668501857
Accepted
20
5,600
310
n = int(input()) pre = list(map(int, input().split())) ino = list(map(int, input().split())) d = [] root = pre[0] pre = iter(pre).__next__ def dfs(l, r): global d if l >= r: return c = pre() m = ino.index(c) dfs(l, m) dfs(m+1, r) d += [c] dfs(0, len(ino)) print(*d)
s766855782
p03836
u481333386
2,000
262,144
Wrong Answer
19
3,188
644
Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement must be integers. He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy). Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty). Under this condition, find a shortest path for him.
def main(sx, sy, tx, ty): answer = '' d_x = tx - sx d_y = ty - sy one_right = 'R' * d_x one_up = 'U' * d_y answer += one_right + one_up one_down = 'D' * d_y one_left = 'L' * (d_x + 1) answer += one_down + one_left + 'L' two_up = 'U' * (d_y + 1) two_right = 'R' * (d_x + 1) answer += two_up + two_right + 'DR' two_down = 'D' * (d_y + 1) two_left = 'L' * (d_x + 1) answer += two_down + two_left + 'U' return answer # print(main( # 0, 0, 1, 2 # )) if __name__ == '__main__': sx, sy, tx, ty = [int(e) for e in input().split()] print(main(sx, sy, tx, ty))
s804043975
Accepted
17
3,064
638
def main(sx, sy, tx, ty): answer = '' d_x = tx - sx d_y = ty - sy one_right = 'R' * d_x one_up = 'U' * d_y answer += one_up + one_right one_down = 'D' * d_y one_left = 'L' * (d_x + 1) answer += one_down + one_left two_up = 'U' * (d_y + 1) two_right = 'R' * (d_x + 1) answer += two_up + two_right + 'DR' two_down = 'D' * (d_y + 1) two_left = 'L' * (d_x + 1) answer += two_down + two_left + 'U' return answer # print(main( # 0, 0, 1, 2 # )) if __name__ == '__main__': sx, sy, tx, ty = [int(e) for e in input().split()] print(main(sx, sy, tx, ty))
s196465906
p03525
u747602774
2,000
262,144
Wrong Answer
36
9,592
1,396
In CODE FESTIVAL XXXX, there are N+1 participants from all over the world, including Takahashi. Takahashi checked and found that the _time gap_ (defined below) between the local times in his city and the i-th person's city was D_i hours. The time gap between two cities is defined as follows. For two cities A and B, if the local time in city B is d o'clock at the moment when the local time in city A is 0 o'clock, then the time gap between these two cities is defined to be min(d,24-d) hours. Here, we are using 24-hour notation. That is, the local time in the i-th person's city is either d o'clock or 24-d o'clock at the moment when the local time in Takahashi's city is 0 o'clock, for example. Then, for each pair of two people chosen from the N+1 people, he wrote out the time gap between their cities. Let the smallest time gap among them be s hours. Find the maximum possible value of s.
import sys readline = sys.stdin.readline sys.setrecursionlimit(10**8) mod = 10**9+7 #mod = 998244353 INF = 10**18 eps = 10**-7 N = int(readline()) D = list(map(int,readline().split())) c = [0]*13 c[0] = 1 for d in D: c[d] += 1 if c[0] >= 2 or c[12] >= 2: print(0) exit() for i in range(1,12): if c[i] >= 3: print(0) exit() bitsearchlist = [] notbitsearch = [False]*24 notbitsearch[0] = True if c[12]: notbitsearch[12] = True for i in range(1,12): if c[i] == 1: bitsearchlist.append(i) elif c[i] == 2: notbitsearch[i] = True notbitsearch[24-i] = True print(bitsearchlist) print(notbitsearch) def count(List): anss = INF ret = INF for b in notbitsearch: if b: anss = min(anss,ret) ret = 0 else: ret += 1 anss = min(anss,ret) anss += 1 return anss L = len(bitsearchlist) if L == 0: print(count(notbitsearch)) exit() ans = 0 for i in range(2**L): for j in range(L): if ((i >> j) & 1): notbitsearch[bitsearchlist[j]] = True else: notbitsearch[24-bitsearchlist[j]] = True ans = max(ans,count(notbitsearch)) for j in range(L): if ((i >> j) & 1): notbitsearch[bitsearchlist[j]] = False else: notbitsearch[24-bitsearchlist[j]] = False print(ans)
s125171958
Accepted
35
9,480
864
import sys readline = sys.stdin.readline sys.setrecursionlimit(10**8) mod = 10**9+7 #mod = 998244353 INF = 10**18 eps = 10**-7 N = int(readline()) D = list(map(int,readline().split())) cnt = [0]*13 for d in D: cnt[min(24-d,d)] += 1 cnt[0] += 1 for i in range(1,12): if cnt[i] >= 3: print(0) exit() if cnt[0] >= 2 or cnt[12] >= 2: print(0) exit() where = [0]*24 where[0] = 1 b = 0 if cnt[12]: where[12] = 1 for i in range(1,12): c = cnt[i] if c == 0: continue if c == 2: where[i] = 1 where[24-i] = 1 b = 0 else: if b: where[i] = 1 b = 0 else: where[24-i] = 1 b = 1 ans = INF a = 1 for i in range(1,24): if where[i]: ans = min(ans,a) a = 1 else: a += 1 ans = min(ans,a) print(ans)
s959356247
p00003
u058433718
1,000
131,072
Wrong Answer
30
7,568
273
Write a program which judges wheather given length of three side form a right triangle. Print "YES" if the given sides (integers) form a right triangle, "NO" if not so.
import sys num = int(sys.stdin.readline().strip()) for i in range(num): data = sys.stdin.readline().strip().split(' ') a = int(data[0]) b = int(data[1]) c = int(data[2]) if a == b and b == c: print('YES') else: print('NO')
s701001259
Accepted
30
7,776
409
import sys def is_right(edges): max_len = max(edges) edges.remove(max_len) return max_len ** 2 == edges[0] ** 2 + edges[1] ** 2 num = int(sys.stdin.readline().strip()) for i in range(num): data = sys.stdin.readline().strip().split(' ') a = int(data[0]) b = int(data[1]) c = int(data[2]) if is_right([a, b, c]): print('YES') else: print('NO')
s478614568
p03080
u896741788
2,000
1,048,576
Wrong Answer
17
2,940
69
There are N people numbered 1 to N. Each person wears a red hat or a blue hat. You are given a string s representing the colors of the people. Person i wears a red hat if s_i is `R`, and a blue hat if s_i is `B`. Determine if there are more people wearing a red hat than people wearing a blue hat.
s=input() r=s.count("R") b=s.count("B") print("Yes" if r>b else "No")
s707557395
Accepted
17
2,940
79
n=input() s=input() r=s.count("R") b=s.count("B") print("Yes" if r>b else "No")
s129947546
p02846
u363315718
2,000
1,048,576
Wrong Answer
18
3,064
753
Takahashi and Aoki are training for long-distance races in an infinitely long straight course running from west to east. They start simultaneously at the same point and moves as follows **towards the east** : * Takahashi runs A_1 meters per minute for the first T_1 minutes, then runs at A_2 meters per minute for the subsequent T_2 minutes, and alternates between these two modes forever. * Aoki runs B_1 meters per minute for the first T_1 minutes, then runs at B_2 meters per minute for the subsequent T_2 minutes, and alternates between these two modes forever. How many times will Takahashi and Aoki meet each other, that is, come to the same point? We do not count the start of the run. If they meet infinitely many times, report that fact.
import sys sys.setrecursionlimit(10**7) INF = 10 ** 18 MOD = 10 ** 9 + 7 def LI(): return list(map(int, sys.stdin.readline().split())) def II(): return int(sys.stdin.readline()) def LS(): return list(map(list, sys.stdin.readline().split())) def S(): return list(sys.stdin.readline())[:-1] def main(): t1, t2 = LI() a1, a2 = LI() b1, b2 = LI() if a1 < b1: tmp = b1 b1 = a1 a1 = tmp tmp = b2 b2 = a2 a2 = tmp l1 = (a1 - b1) * t1 l2 = (a2 - b2) * t2 l3 = l1 + l2 print(l1, l2) if l3 == 0: print("infinity") return if l3 > 0: print(0) return ans = 1 print(ans + 2 * (l1 // (-l3))) if __name__ == '__main__': main()
s231964325
Accepted
17
3,064
818
import sys sys.setrecursionlimit(10**7) INF = 10 ** 18 MOD = 10 ** 9 + 7 def LI(): return list(map(int, sys.stdin.readline().split())) def II(): return int(sys.stdin.readline()) def LS(): return list(map(list, sys.stdin.readline().split())) def S(): return list(sys.stdin.readline())[:-1] def main(): t1, t2 = LI() a1, a2 = LI() b1, b2 = LI() if a1 < b1: tmp = b1 b1 = a1 a1 = tmp tmp = b2 b2 = a2 a2 = tmp l1 = (a1 - b1) * t1 l2 = (a2 - b2) * t2 l3 = l1 + l2 if l3 == 0: print("infinity") return if l3 > 0: print(0) return ans = 1 if l1 % (-l3) == 0: print(ans + 2 * (l1 // (-l3)) - 1) return print(ans + 2 * (l1 // (-l3))) if __name__ == '__main__': main()
s302171126
p03303
u363407574
2,000
1,048,576
Wrong Answer
17
2,940
114
You are given a string S consisting of lowercase English letters. We will write down this string, starting a new line after every w letters. Print the string obtained by concatenating the letters at the beginnings of these lines from top to bottom.
S = input() w = int(input()) stack = [] for x in range(len(S)//w): stack.append(S[x*w]) print("".join(stack))
s300290006
Accepted
18
3,064
136
import math S = input() w = int(input()) stack = [] for x in range(math.ceil(len(S)/w)): stack.append(S[x*w]) print("".join(stack))
s575655644
p03660
u346812984
2,000
262,144
Wrong Answer
412
23,740
912
Fennec and Snuke are playing a board game. On the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the graph formed by the cells and the roads is a tree. Initially, Cell 1 is painted black, and Cell N is painted white. The other cells are not yet colored. Fennec (who goes first) and Snuke (who goes second) alternately paint an uncolored cell. More specifically, each player performs the following action in her/his turn: * Fennec: selects an uncolored cell that is adjacent to a **black** cell, and paints it **black**. * Snuke: selects an uncolored cell that is adjacent to a **white** cell, and paints it **white**. A player loses when she/he cannot paint a cell. Determine the winner of the game when Fennec and Snuke play optimally.
import sys from collections import deque sys.setrecursionlimit(10 ** 6) INF = float("inf") MOD = 10 ** 9 + 7 def input(): return sys.stdin.readline().strip() def bfs(edges, n_nodes): visited = [None] * n_nodes visited[0] = "B" visited[-1] = "W" q = deque([0, n_nodes - 1]) while q: i = q.popleft() for j in edges[i]: if visited[j] is None: print(i, j) visited[j] = visited[i] q.append(j) return visited def main(): N = int(input()) edges = [[] for _ in range(N)] for _ in range(N - 1): a, b = map(int, input().split()) a -= 1 b -= 1 edges[a].append(b) edges[b].append(a) visited = bfs(edges, N) if visited.count("B") > visited.count("W"): print("Fennec") else: print("Snuke") if __name__ == "__main__": main()
s695151865
Accepted
280
22,268
884
import sys from collections import deque sys.setrecursionlimit(10 ** 6) INF = float("inf") MOD = 10 ** 9 + 7 def input(): return sys.stdin.readline().strip() def bfs(edges, n_nodes): visited = [None] * n_nodes visited[0] = "B" visited[-1] = "W" q = deque([0, n_nodes - 1]) while q: i = q.popleft() for j in edges[i]: if visited[j] is None: visited[j] = visited[i] q.append(j) return visited def main(): N = int(input()) edges = [[] for _ in range(N)] for _ in range(N - 1): a, b = map(int, input().split()) a -= 1 b -= 1 edges[a].append(b) edges[b].append(a) visited = bfs(edges, N) if visited.count("B") > visited.count("W"): print("Fennec") else: print("Snuke") if __name__ == "__main__": main()
s398057391
p00001
u558004042
1,000
131,072
Wrong Answer
30
6,720
232
There is a data which provides heights (in meter) of mountains. The data is only for ten mountains. Write a program which prints heights of the top three mountains in descending order.
#!/usr/bin/env python3 #coding: utf-8 # Volume0 - 0001 (http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0001) li = [] for x in range(10): y = input() li.append(y) li.reverse() for y in range(3): print(li[y])
s459822627
Accepted
30
6,720
257
#!/usr/bin/env python3 #coding: utf-8 # Volume0 - 0001 (http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0001) li = [] for x in range(10): s = input() s = int(s) li.append(s) li.sort() li.reverse() for y in range(3): print(li[y])
s167446142
p03860
u920438243
2,000
262,144
Wrong Answer
17
2,940
46
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 uppercase English letter at the beginning of s. Given the name of the contest, print the abbreviation of the name.
line = input().split() print("A"+line[1]+"C")
s108860210
Accepted
18
2,940
49
line = input().split() print("A"+line[1][0]+"C")
s798389386
p03796
u723654028
2,000
262,144
Wrong Answer
29
2,940
87
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.
N=int(input()) p = 1 a = 10 ** 9 + 7 for i in range(1,N+1): p = p * i // a print(p)
s809993390
Accepted
36
2,940
86
N=int(input()) p = 1 a = 10 ** 9 + 7 for i in range(1,N+1): p = p * i % a print(p)
s117407186
p03577
u252828980
2,000
262,144
Wrong Answer
17
2,940
18
Rng is going to a festival. The name of the festival is given to you as a string S, which ends with `FESTIVAL`, from input. Answer the question: "Rng is going to a festival of what?" Output the answer. Here, assume that the name of "a festival of s" is a string obtained by appending `FESTIVAL` to the end of s. For example, `CODEFESTIVAL` is a festival of `CODE`.
print(input()[:8])
s951138342
Accepted
17
2,940
19
print(input()[:-8])
s253988158
p03543
u461636820
2,000
262,144
Wrong Answer
18
2,940
165
We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**. You are given a 4-digit integer N. Answer the question: Is N **good**?
# -*- coding: utf-8 -*- def main(): N = input() print('YES' if len(set(N[:3])) == 1 or len(set(N[1:])) == 1 else 'NO') if __name__ == '__main__': main()
s334633407
Accepted
17
2,940
165
# -*- coding: utf-8 -*- def main(): N = input() print('Yes' if len(set(N[:3])) == 1 or len(set(N[1:])) == 1 else 'No') if __name__ == '__main__': main()
s588273388
p03370
u925406312
2,000
262,144
Wrong Answer
169
4,468
303
Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
a,b = map(int,input().split()) c=[int(input()) for i in range(a)] minbox = min(c) flag = 0 for i in c: b = b - i flag += 1 while True: print(b) if b < minbox: break else: b = b - minbox flag += 1 print(flag) continue break print(flag)
s417471440
Accepted
35
3,060
270
a,b = map(int,input().split()) c=[int(input()) for i in range(a)] minbox = min(c) flag = 0 for i in c: b = b - i flag += 1 while True: if b < minbox: break else: b = b - minbox flag += 1 continue break print(flag)
s194441285
p02612
u952708174
2,000
1,048,576
Wrong Answer
27
9,144
26
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
print(int(input()) % 1000)
s484393189
Accepted
27
9,072
36
print((1000-int(input())%1000)%1000)
s595831901
p03494
u733738237
2,000
262,144
Wrong Answer
2,104
2,940
192
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
import sys input = sys.stdin.readline list_n = [int(i) for i in input().split()] x=0 while True: if [i for i in list_n if i % 2 == 1]: break nums = [i//2 for i in list_n] x += 1 print(x)
s487924731
Accepted
19
3,060
181
N = int(input()) a = list(map(int, input().split())) point = 0 while True: A =[x % 2 for x in a] if A.count(0) != len(a): break a = [x // 2 for x in a] point += 1 print(point)
s111533782
p02612
u215268883
2,000
1,048,576
Wrong Answer
28
9,004
34
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=input() a=int(a) print(a % 1000)
s075145147
Accepted
27
9,056
85
N = input() N = int(N) r = N % 1000 if r == 0: print(0) else: print(1000 - r)
s339156611
p03545
u169678167
2,000
262,144
Wrong Answer
17
3,060
364
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
s = input() for bit in range(1 << (3)): f = s[0] for i in range(3): if bit & (1 << i): f += '+' f += s[i + 1] if sum(list(map(int, f.split('+')))) == 7: print(f) exit()
s551576797
Accepted
18
3,060
394
s = input() for bit in range(1 << (3)): f = s[0] for i in range(3): if bit & (1 << i): f += '+' else: f += '-' f += s[i+1] if eval(f) == 7: f += "=7" print(f) exit()
s252539887
p03493
u256833330
2,000
262,144
Wrong Answer
17
2,940
38
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.
l=input().split() print(l.count('1'))
s932378475
Accepted
20
2,940
30
l=input() print(l.count('1'))
s628581866
p03377
u869519920
2,000
262,144
Wrong Answer
29
9,128
83
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()) s = "Yes" if A > X or A+B < X: s = "No" print(s)
s911002387
Accepted
29
9,152
83
A,B,X = map(int,input().split()) s = "YES" if A > X or A+B < X: s = "NO" print(s)
s498735050
p03360
u366644013
2,000
262,144
Wrong Answer
17
2,940
91
There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times: * Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n. What is the largest possible sum of the integers written on the blackboard after K operations?
a, b, c = map(int, input().split()) k = int(input()) d = max(a, b, c) print(a+b+c+(d**k-d))
s167759547
Accepted
17
2,940
90
a = list(map(int, input().split())) k = int(input()) d = max(a) print(d*2**k + sum(a) - d)
s128391513
p03141
u325227960
2,000
1,048,576
Wrong Answer
617
47,808
253
There are N dishes of cuisine placed in front of Takahashi and Aoki. For convenience, we call these dishes Dish 1, Dish 2, ..., Dish N. When Takahashi eats Dish i, he earns A_i points of _happiness_ ; when Aoki eats Dish i, she earns B_i points of happiness. Starting from Takahashi, they alternately choose one dish and eat it, until there is no more dish to eat. Here, both of them choose dishes so that the following value is maximized: "the sum of the happiness he/she will earn in the end" minus "the sum of the happiness the other person will earn in the end". Find the value: "the sum of the happiness Takahashi earns in the end" minus "the sum of the happiness Aoki earns in the end".
n=int(input()) A=[] for i in range(n): A.append(list(map(int,input().split()))) B=[] for i in range(n): B.append([i,A[i][0]-A[i][1]]) B.sort(key=lambda x:x[1]) print(B) S=[0,0] for i in range(n): S[i%2]+=A[B[i][0]][i%2] print(S[0]-S[1])
s756073788
Accepted
755
43,048
304
n=int(input()) A=[] for i in range(n): A.append(list(map(int,input().split()))) A.sort(reverse=1) B=[] for i in range(n): B.append([i,A[i][1]+A[i][0]]) B.sort(reverse=1,key=lambda x:x[1]) #print(C) S=[0,0] for i in range(n): S[i%2]+=A[B[i][0]][i%2] print(S[0]-S[1])
s746631090
p03693
u517774558
2,000
262,144
Wrong Answer
17
2,940
124
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
array = input().split() score = int(array[1]) * 10 + int(array[2]) if score % 4 == 0: print("Yes") else: print("No")
s513283377
Accepted
17
2,940
123
array = input().split() score = int(array[1]) * 10 + int(array[2]) if score % 4 == 0: print("YES") else: print("NO")
s759656396
p03605
u847033024
2,000
262,144
Wrong Answer
25
8,900
73
It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
a = input() if a[0] == 9 or a[1] == 9: print('Yes') else: print('No')
s206764285
Accepted
28
8,952
60
a = input() if '9' in a: print('Yes') else: print('No')
s144441840
p03433
u684084063
2,000
262,144
Wrong Answer
17
3,060
184
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
#-*-cording:utf-8-*- N = int(input()) A = input().split() A.sort() A.reverse() a=list(map(int,A)) Alice = a[1::2] Bob = a[0::2] allA=sum(Alice) allB=sum(Bob) Ans=allA-allB print(-Ans)
s373735029
Accepted
17
2,940
133
#-*-cording:utf-8-*- N = int(input()) A = int(input()) num=N//500 NUM=N-500*num if NUM <= A: print("Yes") else: print("No")
s905318904
p01223
u073685357
3,000
131,072
Wrong Answer
30
7,756
6,923
ある国で「サイゾウ」というテレビ番組が流行している. この番組は参加者がフィールドアスレチックに挑戦し, 見事攻略すれば賞金をもらえるというものである. フィールドアスレチックは高さが異なるブロックを一列に並べて作られていて, 攻略のためにはいかにして段差を登り降りするかが重要になる (図1). この番組に参加することになったあなたの友人は, フィールドアスレチックの構造が与えられたときに, 登らなければならない最大の段差と降りなければならない最大の段差を 計算するプログラムを書いてほしいと, 凄腕プログラマーであるあなたに依頼してきた. --- 図1: アスレチックの構造の例(入力例の最初のデータセット).
#coding:UTF-8 def Calculate(rows) : up, down = 0, 0 for x in range(0, len(rows) - 1) : tmp = rows[x + 1] - rows[x] if tmp < 0 : tmp = abs(tmp) if down < tmp : down = tmp elif tmp > 0 : if up < tmp : up = tmp else : pass print("{0} {1}".format(up, down)) return(up, down) def Main() : fields = int(input()) up, down = [], [] for x in range(fields) : blocks_q = int(input()) blocks = input().split(' ') blocks = [int(x) for x in blocks] if blocks_q != len(blocks) : pass tmp_up, tmp_down = Calculate(blocks) up.append(tmp_up) down.append(tmp_down) for x in range(len(up)) : print("{0} {1}".format(up[x], down[x])) if __name__ == "__main__" : Main()
s513575560
Accepted
30
7,660
6,711
#coding:UTF-8 def Calculate(rows) : up, down = 0, 0 for x in range(0, len(rows) - 1) : tmp = rows[x + 1] - rows[x] if tmp < 0 : tmp = abs(tmp) if down < tmp : down = tmp elif tmp > 0 : if up < tmp : up = tmp else : pass return(up, down) def Main() : fields = int(input()) up, down = [], [] for x in range(fields) : blocks_q = int(input()) blocks = input().split(' ') blocks = [int(x) for x in blocks] if blocks_q != len(blocks) : pass tmp_up, tmp_down = Calculate(blocks) up.append(tmp_up) down.append(tmp_down) for x in range(len(up)) : print("{0} {1}".format(up[x], down[x])) if __name__ == "__main__" : Main()
s300794018
p04029
u672898046
2,000
262,144
Wrong Answer
17
2,940
61
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()) c = 0 for i in range(n+1): c += i print(i)
s084485006
Accepted
18
2,940
61
n = int(input()) c = 0 for i in range(n+1): c += i print(c)
s120462591
p02603
u514969825
2,000
1,048,576
Wrong Answer
28
9,120
605
To become a millionaire, M-kun has decided to make money by trading in the next N days. Currently, he has 1000 yen and no stocks - only one kind of stock is issued in the country where he lives. He is famous across the country for his ability to foresee the future. He already knows that the price of one stock in the next N days will be as follows: * A_1 yen on the 1-st day, A_2 yen on the 2-nd day, ..., A_N yen on the N-th day. In the i-th day, M-kun can make the following trade **any number of times** (possibly zero), **within the amount of money and stocks that he has at the time**. * Buy stock: Pay A_i yen and receive one stock. * Sell stock: Sell one stock for A_i yen. What is the maximum possible amount of money that M-kun can have in the end by trading optimally?
N = int(input()) s_list = list(input().split()) money = 1000 stock = 0 for i in range(N): if (i == N-1): money += stock * int(s_list[i]) stock = 0 break # Stock price tomorrow is higher than today if (int(s_list[i+1]) > int(s_list[i])): stock = stock + int(money / int(s_list[i])) money = money - (int(s_list[i]) * int(money / int(s_list[i]))) continue # Stock price tomorrow is lower than or equal to today if (int(s_list[i+1]) <= int(s_list[i])): money = money + (int(s_list[i]) * stock) stock = 0 continue print("money: {}".format(money))
s357871406
Accepted
36
8,832
612
N = int(input()) s_list = list(input().split()) money = 1000 stock = 0 for i in range(N): #print("i:{}".format(i)) if (i == N-1): money += stock * int(s_list[i]) stock = 0 break # Stock price tomorrow is higher than today if (int(s_list[i+1]) > int(s_list[i])): stock = stock + int(money / int(s_list[i])) money = money - (int(s_list[i]) * int(money / int(s_list[i]))) continue # Stock price tomorrow is lower than or equal to today if (int(s_list[i+1]) <= int(s_list[i])): money = money + (int(s_list[i]) * stock) stock = 0 continue print(money)
s650304710
p03657
u301823349
2,000
262,144
Wrong Answer
17
2,940
115
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.
a,b=map(int,input().split()) if a%3==0 or b%3==0 or (a+b)%3==0: print("POSSIBLE") else: print("IMPOSSIBLE")
s824244963
Accepted
17
2,940
115
a,b=map(int,input().split()) if a%3==0 or b%3==0 or (a+b)%3==0: print("Possible") else: print("Impossible")
s658808140
p03798
u711539583
2,000
262,144
Wrong Answer
23
4,092
648
Snuke, who loves animals, built a zoo. There are N animals in this zoo. They are conveniently numbered 1 through N, and arranged in a circle. The animal numbered i (2≤i≤N-1) is adjacent to the animals numbered i-1 and i+1. Also, the animal numbered 1 is adjacent to the animals numbered 2 and N, and the animal numbered N is adjacent to the animals numbered N-1 and 1. There are two kinds of animals in this zoo: honest sheep that only speak the truth, and lying wolves that only tell lies. Snuke cannot tell the difference between these two species, and asked each animal the following question: "Are your neighbors of the same species?" The animal numbered i answered s_i. Here, if s_i is `o`, the animal said that the two neighboring animals are of the same species, and if s_i is `x`, the animal said that the two neighboring animals are of different species. More formally, a sheep answered `o` if the two neighboring animals are both sheep or both wolves, and answered `x` otherwise. Similarly, a wolf answered `x` if the two neighboring animals are both sheep or both wolves, and answered `o` otherwise. Snuke is wondering whether there is a valid assignment of species to the animals that is consistent with these responses. If there is such an assignment, show one such assignment. Otherwise, print `-1`.
n = int(input()) s = [c == 'o' for c in input()] def next_s(s, flag): d = {'S' : 'W', 'W' : 'S'} if flag: return s else: return d[s] def sim(s0): ans = ['.' for _ in range(n)] ans[0] = s0[0] ans[1] = s0[1] for i in range(2, n): if ans[i-1] == 'S': ans[i] = next_s(ans[i-2], s[i-1]) else: ans[i] = next_s(ans[i-2], not s[i-1]) res = ans[1] == ans[-1] if s0[0] == 'S': if res == s[0]: return ans else: if res != s[0]: return ans return False def solve(): for item in ["SS", "SW", "WS", "WW"]: ans = sim(item) if ans: return print(''.join(ans)) return print(-1)
s032067181
Accepted
228
5,516
716
n = int(input()) s = [c == 'o' for c in input()] def next_s(s, flag): d = {'S' : 'W', 'W' : 'S'} if flag: return s else: return d[s] def sim(s0): ans = ['.' for _ in range(n+1)] ans[0] = s0[0] ans[1] = s0[1] for i in range(2, n+1): if ans[i-1] == 'S': ans[i] = next_s(ans[i-2], s[i-1]) else: ans[i] = next_s(ans[i-2], not s[i-1]) res = ans[1] == ans[-2] if s0[0] == 'S': if res == s[0] and ans[-1] == ans[0]: return ans[:-1] else: if res != s[0] and ans[-1] == ans[0]: return ans[:-1] return False def solve(): for item in ["SS", "SW", "WS", "WW"]: ans = sim(item) if ans: return print(''.join(ans)) return print(-1) solve()
s731655966
p03110
u189950446
2,000
1,048,576
Wrong Answer
17
3,060
215
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` and u_1 = `JPY`, the otoshidama from the first relative is 10000 Japanese yen; if x_2 = `0.10000000` and u_2 = `BTC`, the otoshidama from the second relative is 0.1 bitcoins. If we convert the bitcoins into yen at the rate of 380000.0 JPY per 1.0 BTC, how much are the gifts worth in total?
N = int(input()) ans = 0 float(ans) for i in range(N): x,u = input().split() if str(u) == 'JPY': ans = float(ans) + float(x) if str(u) == 'BTC': ans = float(ans) + float(x) * 380000 print(u) print(ans)
s915536464
Accepted
17
3,060
204
N = int(input()) ans = 0 float(ans) for i in range(N): x,u = input().split() if str(u) == 'JPY': ans = float(ans) + float(x) if str(u) == 'BTC': ans = float(ans) + float(x) * 380000 print(ans)
s231465431
p02613
u516927307
2,000
1,048,576
Wrong Answer
141
16,428
196
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
import collections N = int(input()) S = [input() for i in range(N)] c = collections.Counter(S) print("AC","×",c['AC']) print("WA","×",c['WA']) print("TLE","×",c['TLE']) print("RE","×",c['RE'])
s060108113
Accepted
146
16,500
192
import collections N = int(input()) S = [input() for i in range(N)] c = collections.Counter(S) print("AC","x",c['AC']) print("WA","x",c['WA']) print("TLE","x",c['TLE']) print("RE","x",c['RE'])
s631975772
p03672
u551109821
2,000
262,144
Wrong Answer
17
2,940
147
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 deleting one or more characters from the end of S. It is guaranteed that such a non-empty string exists for a given input.
S = list(input()) n = len(S) for i in range(n,1,-1): if i%2==0: if S[:i//2] == S[i//2:]: print(i//2) exit()
s748010382
Accepted
18
2,940
147
S = list(input()) n = len(S) for i in range(n-1,1,-1): if i%2==0: if S[:i//2] == S[i//2:i]: print(i) exit()
s833578275
p03738
u474423089
2,000
262,144
Wrong Answer
18
2,940
105
You are given two positive integers A and B. Compare the magnitudes of these numbers.
a=int(input()) b=int(input()) if a<b: print('GREATER') elif a>b: print('LESS') else: print('EQUAL')
s084584567
Accepted
18
2,940
201
def main(): a = int(input()) b = int(input()) if a > b: print('GREATER') elif a < b: print('LESS') else: print('EQUAL') if __name__ == '__main__': main()
s764299574
p02613
u554850896
2,000
1,048,576
Wrong Answer
156
9,180
187
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
N = int(input()) d = {} for i in range(N): x = input() if x in d.keys(): d[x]+=1 else: d[x] = 1 for j in d.keys(): print(j + " " + "x" + " " + str(d[j])) print("\n")
s960774965
Accepted
158
9,220
381
N = int(input()) ac = 0 wa = 0 tle = 0 re = 0 while (N) : x = input() if x == 'AC': ac+=1 if x == 'WA': wa +=1 if x == 'TLE': tle += 1 if x == 'RE': re += 1 N-=1 print('AC' + " " + "x" + " " + str(ac)) print('WA' + " " + "x" + " " + str(wa)) print('TLE' + " " + "x" + " " + str(tle)) print('RE' + " " + "x" + " " + str(re))
s023222390
p03796
u210827208
2,000
262,144
Wrong Answer
26
2,940
76
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.
n=int(input()) ans=1 for i in range(n+1): ans*=1 print(ans%(10**9+7))
s877089430
Accepted
36
2,940
83
n=int(input()) ans=1 for i in range(1,n+1): ans=(ans*i)%(10**9+7) print(ans)
s619432209
p02612
u017624958
2,000
1,048,576
Wrong Answer
26
9,144
50
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()) answer = N / 1000 print(answer)
s863120929
Accepted
31
9,080
101
import math N = int(input()) answer = math.ceil(N / 1000) answer = answer * 1000 - N print(answer)
s158234892
p04044
u634873566
2,000
262,144
Wrong Answer
17
3,060
81
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 smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds: * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i. * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m.
n, l = map(int, input().split()) d = {input() for _ in range(n)} print(sorted(d))
s154147528
Accepted
17
3,060
90
n, l = map(int, input().split()) d = sorted([input() for _ in range(n)]) print(''.join(d))
s038121153
p03814
u607074939
2,000
262,144
Wrong Answer
43
3,516
198
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 with `Z`.
s = str(input()) Acount = 0 Zcount = 0 for i in range (len(s)): if s[i] == 'A': Acount = i break for j in range (len(s)): if s[j] == 'Z': Zcount = j print(j - i +1)
s007512944
Accepted
73
3,516
234
s = str(input()) Acount = 3000000 Zcount = 0 for i in range (len(s)): if (s[i] == 'A' and i < Acount): Acount = i for j in range (len(s)): if (s[j] == 'Z' and j > Zcount): Zcount = j print(Zcount - Acount +1)
s771173258
p02612
u974918235
2,000
1,048,576
Wrong Answer
28
9,120
91
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()) if a > 10000000: print(f"{a-10000000}") else: print(f"{a % 1000}")
s205137144
Accepted
28
9,144
38
N = int(input()) print(f"{-N % 1000}")
s456253133
p03455
u287097467
2,000
262,144
Wrong Answer
17
2,940
88
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()) c = a*b %2 if c: print('odd') else: print('even')
s956590725
Accepted
17
2,940
88
a, b = map(int, input().split()) c = a*b %2 if c: print('Odd') else: print('Even')
s125423427
p03385
u263824932
2,000
262,144
Wrong Answer
19
2,940
221
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() t=[a for a in S] number=0 for a in range(2): if 'a' in t: number+=1 elif 'b' in t: number+=1 elif 'c' in t: number+=1 if number==3: print('Yes') else: print('No')
s884497349
Accepted
18
2,940
124
S=input() t=[a for a in S] u=sorted(t) if u[0]=='a' and u[1]=='b' and u[2]=='c': print('Yes') else: print('No')
s745883323
p02406
u843169619
1,000
131,072
Wrong Answer
20
5,584
117
In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops. Note that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto. Write a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements. void call(int n){ int i = 1; CHECK_NUM: int x = i; if ( x % 3 == 0 ){ cout << " " << i; goto END_CHECK_NUM; } INCLUDE3: if ( x % 10 == 3 ){ cout << " " << i; goto END_CHECK_NUM; } x /= 10; if ( x ) goto INCLUDE3; END_CHECK_NUM: if ( ++i <= n ) goto CHECK_NUM; cout << endl; }
num = int(input().rstrip()) for i in range(1,num+1): if i % 3 == 0 or '3' in str(i): print(i)
s699590660
Accepted
20
6,124
123
n=int(input()) d=[] for i in range(3,n+1): if i%3==0 or "3" in str(i): d.append(i) print(' ',end="") print(*d)
s319894887
p02612
u261036477
2,000
1,048,576
Wrong Answer
32
9,136
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)
s298308029
Accepted
36
9,196
275
N = input() if len(N) >= 3: A = int(N[-3])*100 + int(N[-2])*10 + int(N[-1]) if A == 0: print(0) else: print(1000 - A) elif len(N) == 2: A = int(N[-2])*10 + int(N[-1]) print(1000 - A) elif len(N) == 1: A = int(N[-1]) print(1000 - A)
s493595106
p02255
u004192101
1,000
131,072
Wrong Answer
30
7,580
237
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key A[j+1] = A[j] j-- A[j+1] = key Note that, indices for array elements are based on 0-origin. To illustrate the algorithms, your program should trace intermediate result for each step.
n = input() A = [int(i) for i in input().split(' ')] for i in range(1, len(A)): 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(i, end=' ') for i in A] print()
s808644653
Accepted
40
8,452
636
n = input() A = [int(i) for i in input().split(' ')] def trace(A): for index, v in enumerate(A): print(v, end='') if index != len(A) - 1: print(' ', end='') print() trace(A) # algorithm # while j >= 0 and A[j] > v: # A[j+1] = A[j] # j -= 1 # A[j+1] = v # trace(A) for index, value in enumerate(A): if index == 0: continue prev_idx = index - 1 while prev_idx >= 0 and A[prev_idx] > value: A[prev_idx + 1] = A[prev_idx] prev_idx -= 1 A[prev_idx + 1] = value trace(A)
s554184494
p03149
u978167553
2,000
1,048,576
Wrong Answer
26
9,084
102
You are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits "1974".
n = input().split() print('Yes' if ('1' in n) and ('9' in n) and ('7' in n) and ('4' in n) else 'No')
s312433314
Accepted
35
8,940
102
n = input().split() print('YES' if ('1' in n) and ('9' in n) and ('7' in n) and ('4' in n) else 'NO')
s369860159
p03377
u399973890
2,000
262,144
Wrong Answer
18
3,064
100
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
A, B, X = map(int, input().split()) if A <= X and A+B >= X: print('Yes') else: print(('No'))
s914389269
Accepted
18
3,064
98
A, B, X = map(int, input().split()) if A <= X and A+B >= X: print('YES') else: print('NO')
s142338640
p03795
u434630332
2,000
262,144
Wrong Answer
30
9,112
157
Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
n = int(input()) if n >= n % 15 == 0: x = n * 800 y = 200 * n / 15 answer = x - y print(answer) else: answer = n * 800 print(answer)
s324942297
Accepted
27
9,020
93
n = int(input()) if n >= 15: print(800 * n - ( n // 15) * 200) else: print(800 * n )
s018192509
p03377
u381416158
2,000
262,144
Wrong Answer
17
2,940
103
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 = [int(i) for i in input().split()] if A <= X <= A + B: print("Yes") else: print("No")
s865298552
Accepted
17
2,940
103
A, B, X = [int(i) for i in input().split()] if A <= X <= A + B: print("YES") else: print("NO")
s166205077
p03623
u302292660
2,000
262,144
Wrong Answer
16
2,940
62
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and t on a number line is represented by |s-t|.
x,a,b = map(int,input().split()) print(min(abs(x-a),abs(x-b)))
s385144890
Accepted
17
2,940
73
x,a,b = map(int,input().split()) print("A" if abs(x-a)<abs(x-b) else "B")
s329636276
p02936
u738898077
2,000
1,048,576
Wrong Answer
1,876
59,120
410
Given is a rooted tree with N vertices numbered 1 to N. The root is Vertex 1, and the i-th edge (1 \leq i \leq N - 1) connects Vertex a_i and b_i. Each of the vertices has a counter installed. Initially, the counters on all the vertices have the value 0. Now, the following Q operations will be performed: * Operation j (1 \leq j \leq Q): Increment by x_j the counter on every vertex contained in the subtree rooted at Vertex p_j. Find the value of the counter on each vertex after all operations.
n,q = map(int,input().split()) v = [[0,0] for i in range(n+1)] for i in range(n-1): a,b = map(int,input().split()) v[a].append(b) for i in range(q): p,x = map(int,input().split()) v[p][1] += x q = [1] while q: now = q.pop() # print(now) for i in v[now][2:]: v[i][1] += v[now][1] q += v[now][2:] # print(q) print(v) s = [] for i in v: s.append(i[1]) print(*s[1:])
s836825357
Accepted
1,853
58,420
566
from collections import deque n,q = map(int,input().split()) v = [[0,0] for i in range(n+1)] # print(v) for i in range(n-1): a,b = map(int,input().split()) v[a].append(b) v[b].append(a) for i in range(q): p,x = map(int,input().split()) v[p][1] += x que = deque([1]) # print(v) v[1][0] = 1 while que: temp = que.popleft() for i in v[temp][2:]: if v[i][0] == 0: v[i][0] = 1 que.append(i) v[i][1] += v[temp][1] # print(v) ans = [] for i in v[1:]: ans.append(i[1]) # print(i[1]) print(*ans)
s740166077
p02694
u113255362
2,000
1,048,576
Wrong Answer
31
8,908
125
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
X = int(input()) k = 0 res = 100 for i in range (1, 4200): res = int(res * 1.01) if res > X: k = i break print(k)
s344182912
Accepted
26
9,096
122
X = int(input()) k = 0 res = 100 for i in range (1, 4200): res += res // 100 if res >= X: k = i break print(k)
s076422135
p03359
u026788530
2,000
262,144
Wrong Answer
17
2,940
100
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 example, 5-5 is Takahashi. How many days from 2018-1-1 through 2018-a-b are Takahashi?
a , b = input().split() a = int(a) b = int(b) print(a,b) if b > a: print(a+1) else: print(a)
s649996381
Accepted
17
2,940
90
a , b = input().split() a = int(a) b = int(b) if b >= a: print(a) else: print(a-1)
s535998564
p02806
u209627628
2,525
1,048,576
Wrong Answer
17
2,940
95
Niwango created a playlist of N songs. The title and the duration of the i-th song are s_i and t_i seconds, respectively. It is guaranteed that s_1,\ldots,s_N are all distinct. Niwango was doing some work while playing this playlist. (That is, all the songs were played once, in the order they appear in the playlist, without any pause in between.) However, he fell asleep during his work, and he woke up after all the songs were played. According to his record, it turned out that he fell asleep at the very end of the song titled X. Find the duration of time when some song was played while Niwango was asleep.
N = int(input()) i = 0 songs = [] while N-i: songs.append(input().split()) i+=1 X = input()
s789657073
Accepted
17
3,060
279
N = int(input()) songs = [] result = 0 for i in range(N): songs.append(input().split()) X = input() point = len(songs) for j in range(N): if songs[j][0] == X: point = j+1 break for i in range(point, N): result += int(songs[i][1]) print(result)
s798789804
p02612
u704157847
2,000
1,048,576
Wrong Answer
30
9,140
40
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(1000 - 1000 % N)
s079264429
Accepted
27
9,152
63
n = int(input()) print(1000 - n % 1000 if n % 1000 > 0 else 0)
s084112473
p03854
u873134970
2,000
262,144
Wrong Answer
37
3,188
302
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() S = S[::-1] _ = ["dream", "dreamer", "erase", "eraser"] _ = [_[i][::-1] for i in range(4)] i = 0 while i < len(S): can = False for k in _: if S[i:i + len(k)] == k: can = True i += len(k) if not can: print("No") exit() print("Yes")
s618881319
Accepted
38
3,188
302
S = input() S = S[::-1] _ = ["dream", "dreamer", "erase", "eraser"] _ = [_[i][::-1] for i in range(4)] i = 0 while i < len(S): can = False for k in _: if S[i:i + len(k)] == k: can = True i += len(k) if not can: print("NO") exit() print("YES")
s764880295
p03545
u341855122
2,000
262,144
Wrong Answer
17
3,188
794
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
a = input() c = map(int,list(a)) b = [] for i in c: b.append(i) if(b[0] + b[1] + b[2] + b[3]==7): print(a[0]+"+"+a[1]+"+"+a[2]+"+"+a[3]+"=7",end="") elif(b[0] + b[1] + b[2] - b[3]==7): print(a[0]+"+"+a[1]+"+"+a[2],"-"+a[3]+"=7",end="") elif(b[0] + b[1] - b[2] + b[3]==7): print(a[0]+"+"+a[1]+"-"+a[2],"+"+a[3]+"=7",end="") elif(b[0] + b[1] - b[2] - b[3]==7): print(a[0]+"+"+a[1]+"-"+a[2],"-"+a[3]+"=7",end="") elif(b[0] - b[1] + b[2] + b[3]==7): print(a[0]+"-"+a[1]+"+"+a[2],"+"+a[3]+"=7",end="") elif(b[0] - b[1] + b[2] - b[3]==7): print(a[0]+"-"+a[1]+"+"+a[2],"-"+a[3]+"=7",end="") elif(b[0] - b[1] - b[2] + b[3]==7): print(a[0]+"-"+a[1]+"-"+a[2],"+"+a[3]+"=7",end="") elif(b[0] - b[1] - b[2] - b[3]==7): print(a[0]+"-"+a[1]+"-"+a[2],"-"+a[3]+"=7",end="")
s576851972
Accepted
18
3,188
737
a = input() c = map(int,list(a)) b = [] for i in c: b.append(i) if(b[0] + b[1] + b[2] + b[3]==7): print(a[0]+"+"+a[1]+"+"+a[2]+"+"+a[3]+"=7") elif(b[0] + b[1] + b[2] - b[3]==7): print(a[0]+"+"+a[1]+"+"+a[2]+"-"+a[3]+"=7") elif(b[0] + b[1] - b[2] + b[3]==7): print(a[0]+"+"+a[1]+"-"+a[2]+"+"+a[3]+"=7") elif(b[0] + b[1] - b[2] - b[3]==7): print(a[0]+"+"+a[1]+"-"+a[2]+"-"+a[3]+"=7") elif(b[0] - b[1] + b[2] + b[3]==7): print(a[0]+"-"+a[1]+"+"+a[2]+"+"+a[3]+"=7") elif(b[0] - b[1] + b[2] - b[3]==7): print(a[0]+"-"+a[1]+"+"+a[2]+"-"+a[3]+"=7") elif(b[0] - b[1] - b[2] + b[3]==7): print(a[0]+"-"+a[1]+"-"+a[2]+"+"+a[3]+"=7") elif(b[0] - b[1] - b[2] - b[3]==7): print(a[0]+"-"+a[1]+"-"+a[2]+"-"+a[3]+"=7")
s501869964
p02255
u177808190
1,000
131,072
Wrong Answer
20
5,600
362
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key A[j+1] = A[j] j-- A[j+1] = key Note that, indices for array elements are based on 0-origin. To illustrate the algorithms, your program should trace intermediate result for each step.
def insertionSort(A, N): for i in range(1, N): v = A[i] j = i - 1 while j >= 0 and A[j] > v: A[j+1] = A[j] j -= 1 A[j+1] = v print (' '.join([str(x) for x in A])) if __name__ == '__main__': length = int(input()) hoge = [int(x) for x in input().split()] insertionSort(hoge, length)
s572070207
Accepted
20
5,612
407
def insertionSort(A, N): for i in range(1, N): v = A[i] j = i - 1 while j >= 0 and A[j] > v: A[j+1] = A[j] j -= 1 A[j+1] = v print (' '.join([str(x) for x in A])) if __name__ == '__main__': length = int(input()) hoge = [int(x) for x in input().split()] print (' '.join([str(x) for x in hoge])) insertionSort(hoge, length)
s092147216
p03502
u952708174
2,000
262,144
Wrong Answer
17
2,940
63
An integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10. Given an integer N, determine whether it is a Harshad number.
N = input() print('Yes' if int(N) % sum(map(int, N)) else 'No')
s879758671
Accepted
18
2,940
68
N = input() print('Yes' if int(N) % sum(map(int, N)) == 0 else 'No')
s450340679
p03852
u790812284
2,000
262,144
Wrong Answer
17
2,940
112
Given a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`.
list = ["a","b","c","d","e"] c =input() if c in list==True: print("vowel") else: print("consonant")
s709548635
Accepted
17
2,940
101
list = ["a","i","u","e","o"] c =input() if c in list: print("vowel") else: print("consonant")
s378881434
p03564
u966000628
2,000
262,144
Wrong Answer
17
2,940
112
Square1001 has seen an electric bulletin board displaying the integer 1. He can perform the following operations A and B to change this value: * Operation A: The displayed value is doubled. * Operation B: The displayed value increases by K. Square1001 needs to perform these operations N times in total. Find the minimum possible value displayed in the board after N operations.
N = int(input()) K = int(input()) i = 1 for num in range(N): if i < K: i *= 2 else: i += K print (K)
s467153827
Accepted
17
2,940
112
N = int(input()) K = int(input()) i = 1 for num in range(N): if i < K: i *= 2 else: i += K print (i)
s797126486
p02841
u031324264
2,000
1,048,576
Wrong Answer
17
2,940
111
In this problem, a date is written as Y-M-D. For example, 2019-11-30 means November 30, 2019. Integers M_1, D_1, M_2, and D_2 will be given as input. It is known that the date 2019-M_2-D_2 follows 2019-M_1-D_1. Determine whether the date 2019-M_1-D_1 is the last day of a month.
m1, d1 = map(int, input().split()) m2, d2 = map(int, input().split()) if m1 != m2: print(0) else: print(1)
s642105702
Accepted
17
2,940
111
m1, d1 = map(int, input().split()) m2, d2 = map(int, input().split()) if m1 != m2: print(1) else: print(0)
s380686184
p03455
u845937249
2,000
262,144
Wrong Answer
18
2,940
169
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()) moda = a % 2 modb = b % 2 if moda == 0: if modb == 0: print("Even") else: print("Odd") else: print("Odd")
s492344496
Accepted
17
2,940
198
a, b = map(int, input().split()) moda = a % 2 modb = b % 2 if moda == 0: print("Even") else: if modb == 0: print("Even") else: print("Odd")
s979068577
p03150
u212328220
2,000
1,048,576
Wrong Answer
31
9,068
240
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() if s == 'keyence': print('YES') exit() for i in range(0,len(s)-1): for j in range(i+1,len(s)): print(s[:i]+s[j:]) if s[:i]+s[j:] == 'keyence': print('YES') exit() print('NO')
s328290680
Accepted
31
9,060
213
s = input() if s == 'keyence': print('YES') exit() for i in range(0,len(s)-1): for j in range(i+1,len(s)): if s[:i]+s[j:] == 'keyence': print('YES') exit() print('NO')
s126348649
p03386
u492030100
2,000
262,144
Wrong Answer
19
3,060
262
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()) ans_array = [] for i in range(A, A + K if B > (A + K) else B): ans_array.append(i) for i in range(B, B - K if A < (B - K) else A, -1): ans_array.append(i) ans_array = sorted(list(set(ans_array))) print(ans_array)
s215446830
Accepted
17
3,060
285
A, B, K = map(int, input().split()) ans_array = [] for i in range(A, A + K if B > (A + K) else (B+1)): ans_array.append(i) for i in range(B, B - K if A < (B - K) else (A-1), -1): ans_array.append(i) ans_array = sorted(list(set(ans_array))) for i in ans_array: print(i)
s374414946
p03502
u969211566
2,000
262,144
Wrong Answer
17
2,940
172
An integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10. Given an integer N, determine whether it is a Harshad number.
n = int(input()) total = 0 flag = 1 nn = n while flag: total += nn % 10 nn = nn // 10 if nn <= 0: flag = 0 if total % n == 0: print("Yes") else: print("No")
s721538129
Accepted
18
2,940
172
n = int(input()) total = 0 flag = 1 nn = n while flag: total += nn % 10 nn = nn // 10 if nn <= 0: flag = 0 if n % total == 0: print("Yes") else: print("No")
s778024877
p03828
u934868410
2,000
262,144
Wrong Answer
76
3,436
239
You are given an integer N. Find the number of the positive divisors of N!, modulo 10^9+7.
from collections import defaultdict n = int(input()) f = defaultdict(int) for i in range(2, n+1): for j in range(2, i+1): if i % j == 0: f[j] += 1 ans = 1 mod = 10**9 + 7 for k,v in f.items(): ans = (ans * v) % mod print(ans)
s554964191
Accepted
22
3,316
403
from collections import defaultdict n = int(input()) f = defaultdict(int) def fact(n, d): div = 2 while n > 1 and div * div <= n: if n % div == 0: n //= div d[div] += 1 else: div += 1 if n > 1: d[n] += 1 for i in range(2, n+1): fact(i, f) ans = 1 mod = 10**9 + 7 for k,v in f.items(): ans = (ans * (v+1)) % mod print(ans)