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
s657764582
p03625
u711539583
2,000
262,144
Wrong Answer
108
23,568
321
We have N sticks with negligible thickness. The length of the i-th stick is A_i. Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.
n = int(input()) d = {} for ai in input().split(): ai = int(ai) if ai not in d: d[ai] = 0 d[ai] += 1 n2 = [d[k] for k in d if d[k] > 1] n4 = [d[k] for k in d if d[k] > 3] n2.sort(reverse = True) n4.sort(reverse = True) ans = 0 if n4: ans = n4[0] ** 2 if len(n2) > 1: max(ans, n2[0] * n2[1]) print(ans...
s258912865
Accepted
115
23,848
322
n = int(input()) d = {} for ai in input().split(): ai = int(ai) if ai not in d: d[ai] = 0 d[ai] += 1 n2 = [k for k in d if d[k] > 1] n4 = [k for k in d if d[k] > 3] n2.sort(reverse = True) n4.sort(reverse = True) ans = 0 if n4: ans = n4[0] ** 2 if len(n2) > 1: ans = max(ans, n2[0] * n2[1]) print(ans...
s700065151
p04043
u163449343
2,000
262,144
Wrong Answer
16
2,940
78
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 ...
n = input().split() print(["NO","YES"][n.count("7") ==2 and n.count("5") ==1])
s543216119
Accepted
17
2,940
76
n = input().split() print(["NO","YES"][n.count("7")==1 and n.count("5")==2])
s175073507
p03470
u702208001
2,000
262,144
Wrong Answer
17
3,064
55
An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you h...
n = int(input()) print(len(set([a for a in range(n)])))
s419744334
Accepted
18
2,940
66
n = int(input()) print(len(set([int(input()) for _ in range(n)])))
s049294801
p03192
u181215519
2,000
1,048,576
Wrong Answer
17
2,940
72
You are given an integer N that has exactly four digits in base ten. How many times does `2` occur in the base-ten representation of N?
N = list( input() ) istwo = [ x == 2 for x in N ] print( sum( istwo ) )
s936461241
Accepted
17
2,940
73
N = list( input() ) istwo = [ x == "2" for x in N ] print( sum( istwo ) )
s887360317
p02608
u673101577
2,000
1,048,576
Wrong Answer
2,210
148,972
580
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
# from pprint import pprint # import math # import collections from numba import jit N = int(input()) # a = list(map(int, input().split(' '))) @jit(cache=True) def calc(x, y, z): return x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x p = [] for x in range(1, 100): for y in range(1, 100): for z i...
s245660212
Accepted
977
117,676
483
# from pprint import pprint # import math # import collections from numba import jit N = int(input()) # a = list(map(int, input().split(' '))) @jit(cache=True) def calc(x, y, z): return x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x res = [0] * 1000009 for x in range(1, 100): for y in range(1, 100): ...
s411637309
p03759
u690037900
2,000
262,144
Wrong Answer
17
2,940
67
Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
a,b,c = map(int,input().split()) print("Yes" if b-a==c-b else "No")
s584239983
Accepted
17
2,940
67
a,b,c = map(int,input().split()) print("YES" if b-a==c-b else "NO")
s786785565
p02927
u261260430
2,000
1,048,576
Wrong Answer
23
3,060
225
Today is August 24, one of the five Product Days in a year. A date m-d (m is the month, d is the date) is called a Product Day when d is a two-digit number, and all of the following conditions are satisfied (here d_{10} is the tens digit of the day and d_1 is the ones digit of the day): * d_1 \geq 2 * d_{10} \geq...
m,d = map(int, input().split()) ans = 0 for month in range(4, m): for day in range(22, d): sday = str(day) if int(sday[1]) < 2: continue if int(sday[0]) * int(sday[1]) == month: ans += 1 print(ans)
s266003916
Accepted
23
3,060
229
m,d = map(int, input().split()) ans = 0 for month in range(4, m+1): for day in range(22, d+1): sday = str(day) if int(sday[1]) < 2: continue if int(sday[0]) * int(sday[1]) == month: ans += 1 print(ans)
s841514303
p03826
u117629640
2,000
262,144
Wrong Answer
22
3,068
19
There are two rectangles. The lengths of the vertical sides of the first rectangle are A, and the lengths of the horizontal sides of the first rectangle are B. The lengths of the vertical sides of the second rectangle are C, and the lengths of the horizontal sides of the second rectangle are D. Print the area of the r...
print(1000000000+7)
s297552860
Accepted
23
3,192
172
# -*- coding: utf-8 -*- def main(): a, b, c, d = map(int, input().split()) print(a * b) if a * b > c * d else print(c * d) if __name__ == '__main__': main()
s545709554
p02612
u202641516
2,000
1,048,576
Wrong Answer
26
9,000
65
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.
x=int(input()) from math import ceil x=ceil(x/1000)*1000 print(x)
s876844234
Accepted
29
9,108
64
from math import ceil x=int(input()) print(ceil(x/1000)*1000-x)
s279826155
p03470
u363836311
2,000
262,144
Wrong Answer
17
2,940
79
An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you h...
n=int(input()) T=[0]*n for i in range(n): T[i]=int(input()) t=set(T) print(t)
s832329483
Accepted
19
2,940
84
n=int(input()) T=[0]*n for i in range(n): T[i]=int(input()) t=len(set(T)) print(t)
s303054489
p03854
u693953100
2,000
262,144
Wrong Answer
19
3,188
163
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.replace('erase','') s = s.replace('eraser','') s = s.replace('dream','') s = s.replace('dreamer','') if s: print('YES') else: print('NO')
s002559752
Accepted
18
3,188
140
s = input().replace('eraser','').replace('erase','').replace('dreamer','').replace('dream','') if s: print('NO') else: print('YES')
s992759778
p03759
u399721252
2,000
262,144
Wrong Answer
17
2,940
105
Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
a, b, c = [ int(v) for v in input().split() ] if c-b == b-a: ans = "yes" else: ans = "NO" print(ans)
s065737277
Accepted
17
2,940
101
a, b, c = [ int(v) for v in input().split() ] if (a-b) == (b-c): print("YES") else: print("NO")
s088528551
p03448
u838296343
2,000
262,144
Wrong Answer
58
9,140
326
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that co...
a = int(input()) b= int(input()) c = int(input()) x = int(input()) pattern = 0 for i in range(a+1): if x-500*i==0: pattern+=1 for j in range(b+1): if x-500*i-100*j==0: pattern+=1 for k in range(c+1): if x-500*i-100*j-50*k==0: pattern+=1 print(pa...
s654796106
Accepted
59
8,984
249
a = int(input()) b= int(input()) c = int(input()) x = int(input()) pattern = 0 for i in range(a+1): for j in range(b+1): for k in range(c+1): if x-500*i-100*j-50*k==0: pattern+=1 print(pattern)
s399430675
p02255
u182913399
1,000
131,072
Wrong Answer
30
7,500
228
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key ...
n = int(input()) a = list(map(int, input().split())) 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(list(map(str, a))))
s398943414
Accepted
20
7,668
264
n = int(input()) a = list(map(int, input().split())) for i in range(1, n): print(' '.join(list(map(str, 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(' '.join(list(map(str, a))))
s117727184
p03163
u451206510
2,000
1,048,576
Wrong Answer
201
14,600
213
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()) dp = np.zeros(W + 1, int) for i in range(N): w, v = map(int, input().split()) np.maximum(dp[:-w] + v, dp[w:], out=dp[w:]) print(dp) print(dp[-1])
s066904028
Accepted
173
14,612
199
import numpy as np N, W = map(int, input().split()) dp = np.zeros(W + 1, int) for i in range(N): w, v = map(int, input().split()) np.maximum(dp[:-w] + v, dp[w:], out=dp[w:]) print(dp[-1])
s208372158
p03860
u728566015
2,000
262,144
Wrong Answer
17
2,940
50
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppe...
a, b, c = input().split() print(a[0], b[0], c[0])
s459691933
Accepted
17
2,940
54
[print(i[0], end="") for i in input().split()] print()
s989499964
p02853
u014139588
2,000
1,048,576
Wrong Answer
31
9,096
239
We held two competitions: Coding Contest and Robot Maneuver. In each competition, the contestants taking the 3-rd, 2-nd, and 1-st places receive 100000, 200000, and 300000 yen (the currency of Japan), respectively. Furthermore, a contestant taking the first place in both competitions receives an additional 400000 yen....
x,y = map(int,input().split()) ans = 0 if x == 1 and y == 1: print(1000000) elif x < 4 and y > 3: ans += 100000*(4-x) elif x > 3 and y < 4: ans += 100000*(4-y) elif x < 4 and y < 4: ans += 100000*(8-x-y) else: print(0) print(ans)
s992351628
Accepted
25
9,140
220
x,y = map(int,input().split()) if x == 1 and y == 1: print(1000000) elif x < 4 and y > 3: print(100000*(4-x)) elif x > 3 and y < 4: print(100000*(4-y)) elif x < 4 and y < 4: print(100000*(8-x-y)) else: print(0)
s740640824
p03643
u371467115
2,000
262,144
Wrong Answer
18
2,940
36
This contest, _AtCoder Beginner Contest_ , is abbreviated as _ABC_. When we refer to a specific round of ABC, a three-digit number is appended after ABC. For example, ABC680 is the 680th round of ABC. What is the abbreviation for the N-th round of ABC? Write a program to output the answer.
print(2**(len(bin(int(input())))-3))
s381661646
Accepted
18
2,940
20
print("ABC"+input())
s815281736
p00007
u506705885
1,000
131,072
Wrong Answer
20
7,700
144
Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week. Write a program which computes the amount of the debt in n weeks.
week=int(input()) money=100000 for i in range(week): money=money*1.05 if money%1000!=0: money=1000*(money//1000+1) print(money)
s280001900
Accepted
20
7,564
149
week=int(input()) money=100000 for i in range(week): money=money*1.05 if money%1000!=0: money=1000*(money//1000+1) print(int(money))
s217651006
p02833
u798557584
2,000
1,048,576
Wrong Answer
2,104
3,652
291
For an integer n not less than 0, let us define f(n) as follows: * f(n) = 1 (if n < 2) * f(n) = n f(n-2) (if n \geq 2) Given is an integer N. Find the number of trailing zeros in the decimal notation of f(N).
# abc148_e.py from sys import stdin def f(n): sum = 1 while n >= 2: sum = sum * n n = n - 2 return sum N = int(stdin.readline().rstrip()) sum = f(N) print(sum) l = [int(x) for x in list(str(sum))] l.reverse(); cnt = 0 for i in l: if i == 0: cnt = cnt + 1 else: break print(cnt)
s528066951
Accepted
17
2,940
116
n = int(input()) if n % 2 == 1: print(0) else: i = 10 ans = 0 while i <= n: ans += n // i i *= 5 print(ans)
s259524918
p03795
u202570162
2,000
262,144
Wrong Answer
18
2,940
40
Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant ...
n = int(input()) print(n*800-(n%15)*200)
s589484395
Accepted
17
2,940
53
n = int(input()) x = n*800 y = 200*(n//15) print(x-y)
s555757237
p02744
u171077406
2,000
1,048,576
Wrong Answer
18
2,940
101
In this problem, we only consider strings consisting of lowercase English letters. Strings s and t are said to be **isomorphic** when the following conditions are satisfied: * |s| = |t| holds. * For every pair i, j, one of the following holds: * s_i = s_j and t_i = t_j. * s_i \neq s_j and t_i \neq t_j. F...
N = 3 alpha = ["a","b","c","d","e","f","g","h","i","j"] s = "".join(alpha[:N]) print("a"*N) print(s)
s402654655
Accepted
231
4,412
241
N = int(input()) def DFS(s, mx): if len(s) == N: print(s) return c = 'a' while c <= chr(ord(mx)+1): t = s + c DFS(t, chr(max(ord(c), ord(mx)))) c = chr(ord(c) + 1) DFS("", chr(ord('a')-1))
s661856591
p02831
u434609232
2,000
1,048,576
Wrong Answer
17
2,940
137
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 ...
a, b = map(int, input().split()) def gcd(x, y): while x%y != 0: x, y = y, x%y return y ans = a * b / gcd(a, b) print(ans)
s903216945
Accepted
17
3,064
142
a, b = map(int, input().split()) def gcd(x, y): while x%y != 0: x, y = y, x%y return y ans = a * b / gcd(a, b) print(int(ans))
s612483921
p02396
u800408401
1,000
131,072
Wrong Answer
140
5,604
105
In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets. Write a program which reads an integer x and print it as is. Note that multiple datasets are give...
i=1 while True: x = int(input()) print("Case %d: %d" % (i,x)) i+=1 if x== 0 : break
s382907652
Accepted
140
5,604
101
i=0 while True: i+=1 x = int(input()) if x== 0 : break print("Case %d: %d" % (i,x))
s353490650
p02603
u612496929
2,000
1,048,576
Wrong Answer
29
9,188
182
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 n...
n = int(input()) a = list(map(int,input().split())) dp = [0] * n dp[0] = 1000 for i in range(1, n): dp[i] = max(dp[i-1], dp[i-1] // a[i-1] * a[i] + dp[i-1] % a[i-1]) print(dp[i-1])
s251277195
Accepted
31
9,128
181
n = int(input()) a = list(map(int,input().split())) dp = [0] * n dp[0] = 1000 for i in range(1, n): dp[i] = max(dp[i-1], dp[i-1] // a[i-1] * a[i] + dp[i-1] % a[i-1]) print(dp[-1])
s220876599
p02601
u654240084
2,000
1,048,576
Wrong Answer
29
9,072
145
M-kun has the following three cards: * A red card with the integer A. * A green card with the integer B. * A blue card with the integer C. He is a genius magician who can do the following operation at most K times: * Choose one of the three cards and multiply the written integer by 2. His magic is successfu...
a, b, c = map(int, input().split()) k = int(input()) if a * 2 < b < c or a < b * 2 < c or a < b < c * 2: print("Yes") else: print("No")
s637261330
Accepted
31
9,116
161
a, b, c = map(int, input().split()) k = int(input()) while a >= b: k -= 1 b *= 2 while b >= c: k -= 1 c *= 2 print("Yes" if k >= 0 else "No")
s781988018
p03456
u175034939
2,000
262,144
Wrong Answer
18
2,940
133
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
a,b = input().split() ab = a+b for i in range(320): if int(ab) == i**2: print('yes') break else: print('No')
s565811566
Accepted
18
2,940
136
a,b = input().split() ab = a+b for i in range(4,320): if int(ab) == i**2: print('Yes') exit() else: print('No')
s349646615
p03378
u756988562
2,000
262,144
Wrong Answer
151
12,484
407
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to right. Initially, you are in Square X. You can freely travel between adjacent squares. Your goal is to reach Square 0 or Square N. However, for each i = 1, 2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i incurs a c...
import numpy as np import sys N,M,X = map(int,input().split(" ")) A = list(map(int,input().split(" "))) A = np.array(A) # print(A) test = (N+1)/2 count1 = np.where(A >= test) count2 = np.where(A <= test) # print(count1) # print(len(count2)) # print("test") if count1[0][0] == 0 and len(count1[0]) == 1: print(0) ...
s419014443
Accepted
148
12,748
437
import numpy as np import sys N,M,X = map(int,input().split(" ")) A = list(map(int,input().split(" "))) temp = [] ans1 = 0 ans2 = 0 for i in range(N+1): if (i == 0) or (i==N): temp.append(0) elif i in A: temp.append(1) # elif (i == 0) or (i==N): # temp.append(0) else: tem...
s971947825
p02694
u262481526
2,000
1,048,576
Wrong Answer
21
9,104
112
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or abo...
X = int(input()) year = 0 money = 100 while money > X: year += 1 money = int(money*1.01) print(int(year))
s305329008
Accepted
23
9,172
112
X = int(input()) year = 0 money = 100 while money < X: year += 1 money = int(money*1.01) print(int(year))
s372046069
p02406
u839008951
1,000
131,072
Wrong Answer
20
5,588
320
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 ...
a = int(input()) i = 1 while True: x = i if x % 3 == 0: print(" {i}".format(i=i)) else: while True: if x % 10 == 3: print(" {i}".format(i=i)) x = x // 10 if x == 0: break i += 1 if i > a: break print('')
s900840945
Accepted
20
5,628
340
a = int(input()) res = '' i = 1 while True: x = i if x % 3 == 0: res += " " + str(i) else: while True: if x % 10 == 3: res += " " + str(i) break x = x // 10 if x == 0: break i += 1 if i > a: ...
s275644221
p03150
u110619679
2,000
1,048,576
Wrong Answer
17
3,064
777
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.
""" B - KEYENCE String """ def simple_input(): temp_input = input().rstrip().split(' ') if len(temp_input) > 1: return temp_input return temp_input[0] if __name__ == '__main__': s = input() keyence = "keyence" result = "NO" matchcount = 0 for i in range(7): ...
s321096547
Accepted
17
3,064
754
""" B - KEYENCE String """ def simple_input(): temp_input = input().rstrip().split(' ') if len(temp_input) > 1: return temp_input return temp_input[0] if __name__ == '__main__': s = input() keyence = "keyence" result = "NO" matchcount = 0 for i in range(7): ...
s173276502
p03964
u698176039
2,000
262,144
Wrong Answer
2,104
3,572
318
AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he c...
N = int(input()) TA = [list(map(int,input().split())) for _ in range(N)] lcms = TA[0] for t,a in TA[1:]: print(t,a,lcms) tmp = [t,a] while tmp[0] < lcms[0]: tmp[0] += t tmp[1] += a while tmp[1] < lcms[1]: tmp[0] += t tmp[1] += a lcms = tmp print(sum(lcms))
s715506429
Accepted
21
3,188
314
N = int(input()) TA = [list(map(int,input().split())) for _ in range(N)] lcms = TA[0] for t,a in TA[1:]: tmp = [t,a] m1 = (lcms[0]+tmp[0]-1)//tmp[0] m2 = (lcms[1]+tmp[1]-1)//tmp[1] m = max(m1,m2) if m != 0: tmp[0] *= m tmp[1] *= m lcms = tmp print(sum(lcms))
s963387348
p03719
u763963344
2,000
262,144
Wrong Answer
29
9,068
91
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
a,b,c = map(int, input().split()) if c>=a and c<=b: print("YES") else: print("NO")
s657940688
Accepted
25
9,152
91
a,b,c = map(int, input().split()) if c>=a and c<=b: print("Yes") else: print("No")
s119827763
p02396
u726978687
1,000
131,072
Wrong Answer
70
6,244
317
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...
def solve(test): for i in range(len(test)): print("Case {0}: {1}".format(i,test[i])) def answer(): test =[] while True : n = input() if n=='0': break else: test.append(n) solve(test) if __name__ =='__main__': answer()
s876114125
Accepted
70
6,248
319
def solve(test): for i in range(len(test)): print("Case {0}: {1}".format(i+1,test[i])) def answer(): test =[] while True : n = input() if n=='0': break else: test.append(n) solve(test) if __name__ =='__main__': answer()
s069068452
p02646
u989074104
2,000
1,048,576
Wrong Answer
23
9,120
158
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 ...
A,V = map(int,input().split()) B,W = map(int,input().split()) T=int(input()) if V<=W: print("NO") elif abs(A-B)/(V-W)<=T: print("Yes") else: print("NO")
s900334360
Accepted
20
9,180
161
A,V = map(int,input().split()) B,W = map(int,input().split()) T=int(input()) if V<=W: print("NO") elif abs(A-B)/abs(V-W)<=T: print("YES") else: print("NO")
s126241936
p02850
u029000441
2,000
1,048,576
Wrong Answer
688
86,584
921
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...
import sys sys.setrecursionlimit(500000) N = int(input()) E = [[] for _ in range(N+1)] for i in range(N-1): a, b = map(int, input().split()) E[a].append((b, i)) E[b].append((a, i)) K = max(len(e) for e in E) print(K) Ans = [-1] * (N-1) def dfs(v=1, p=0, p_col=-1): col = 1 for u, idx in E[v]: ...
s665536298
Accepted
562
85,652
497
import sys sys.setrecursionlimit(500000) N = int(input()) E = [[] for _ in range(N+1)] for i in range(N-1): a, b = map(int, input().split()) E[a].append((b, i)) E[b].append((a, i)) K = max(len(e) for e in E) print(K) Ans = [-1] * (N-1) def dfs(v=1, p=0, p_col=-1): col = 1 for u, idx in E[v]: ...
s339747374
p03624
u220345792
2,000
262,144
Wrong Answer
18
3,188
171
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.
alpha = "abcdefghijklmnopqrstuvwxyz" S = input() flag = True for i in alpha: if i in S: pass else: print(i) flag = False if flag: print("None")
s114986841
Accepted
17
3,188
183
alpha = "abcdefghijklmnopqrstuvwxyz" S = input() flag = True for i in alpha: if i in S: pass else: print(i) flag = False break if flag: print("None")
s845892735
p04043
u814986259
2,000
262,144
Wrong Answer
17
2,940
129
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 ...
s=list(input()) s.sort(key=lambda x:len(x)) if len(s[0])==7 and len(s[1])==5 and len(s[2])==5: print("YES") else: print("NO")
s641521127
Accepted
17
2,940
112
s=list(map(int,input().split())) s.sort() if s[0]==5 and s[1]==5 and s[2]==7: print("YES") else: print("NO")
s499879755
p03731
u791838908
2,000
262,144
Wrong Answer
95
25,196
122
In a public bath, there is a shower which emits water for T seconds when the switch is pushed. If the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds. Note that it does not mean that the shower emits water for T additional seconds. N people will pus...
n, T = map(int, input().split()) t = list(map(int, input().split())) total = T for i in t: total += T - i print(total)
s949375160
Accepted
113
25,200
229
n, T = map(int, input().split()) t = list(map(int, input().split())) total = T lastnum = 0 for i in t: time = i - lastnum if T < time: total += T else: total += time lastnum = i print(total)
s509639087
p03945
u189326411
2,000
262,144
Wrong Answer
17
3,188
239
Two foxes Jiro and Saburo are playing a game called _1D Reversi_. This game is played on a board, using black and white stones. On the board, stones are placed in a row, and each player places a new stone to either end of the row. Similarly to the original game of Reversi, when a white stone is placed, all black stones...
s = input() while s!="": if s[-5:]=="dream" or s[-5:]=="erase": s = s[:-5] elif s[-6:]=="eraser": s = s[:-6] elif s[-7:]=="dreamer": s = s[:-7] else: print("NO") exit() print("YES")
s937287337
Accepted
34
3,188
102
s = input() t = "" count = -1 for i in s: if i!=t: t = i count += 1 print(count)
s523196915
p03433
u167908302
2,000
262,144
Wrong Answer
17
2,940
144
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
#coding:utf-8 n = int(input()) a = int(input()) need = n % 500 if a <= need: print("yes") else: print("no")
s466493531
Accepted
19
2,940
144
#coding:utf-8 n = int(input()) a = int(input()) need = n % 500 if a >= need: print("Yes") else: print("No")
s329987244
p03730
u357949405
2,000
262,144
Time Limit Exceeded
2,108
2,940
129
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()) count = 1 while B > count: if A * count % B == C: print("YES") exit(0) print("NO")
s052479562
Accepted
17
2,940
142
A, B, C = map(int, input().split()) count = 1 while B > count: if A * count % B == C: print("YES") exit(0) count += 1 print("NO")
s604504878
p03386
u880277518
2,000
262,144
Wrong Answer
2,154
820,888
282
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=list(map(int,input().split())) l=[] v=[] for i in range(a,b+1): l.append(i) for i in range(k): if i>=len(l): break v.append(l[i]) l.reverse() for i in range(k-1,-1,-1): if i>=len(l): continue v.append(l[i]) s=set(v) for i in s: print(i)
s772066163
Accepted
17
3,064
254
A,B,K=list(map(int,input().split())) L=[] k=0 for i in range(A,B+1): L.append(i) k+=1 if(k>=K): break k=0 for i in range(B,A-1,-1): L.append(i) k+=1 if(k>=K): break S=set(L) for s in sorted(list(S)): print(s)
s640019345
p03828
u218843509
2,000
262,144
Wrong Answer
39
3,064
469
You are given an integer N. Find the number of the positive divisors of N!, modulo 10^9+7.
n = int(input()) prime = [] for i in range(2, n): j = 2 while j ** 2 <= i: if i % j == 0: break j += 1 if j ** 2 > i: prime.append(i) ans = 1 for p in prime: soinsu = 1 for i in range(2, n + 1): while True: if i % p == 0: ...
s026138647
Accepted
39
3,064
473
n = int(input()) prime = [] for i in range(2, n + 1): j = 2 while j ** 2 <= i: if i % j == 0: break j += 1 if j ** 2 > i: prime.append(i) ans = 1 for p in prime: soinsu = 1 for i in range(2, n + 1): while True: if i % p == 0: ...
s371784262
p03434
u359787029
2,000
262,144
Wrong Answer
18
3,064
534
We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the c...
def ret_max(n, list): i = 0 tmp = 0 max = 0 for i in range(n): if(max < list[i]): tmp = i max = list[i] return tmp N = int(input()) lis = [int(i) for i in input().split()] j = 0 k = 0 alice = 0 bob = 0 max = 0 lis_elem = len(lis) for j in range(N): lis_elem = l...
s250182414
Accepted
18
3,064
552
def ret_max_index(n, list): i = 0 tmp = 0 max = 0 for i in range(n): if(max < list[i]): tmp = i max = list[i] return tmp N = int(input()) lis = [int(i) for i in input().split()] j = 0 k = 0 alice = 0 bob = 0 max = 0 lis_elem = len(lis) for j in range(N): lis_el...
s408881252
p03998
u442877951
2,000
262,144
Wrong Answer
20
3,316
457
Alice, Bob and Charlie are playing _Card Game for Three_ , as below: * At first, each of the three players has a deck consisting of some number of cards. Each card has a letter `a`, `b` or `c` written on it. The orders of the cards in the decks cannot be rearranged. * The players take turns. Alice goes first. * ...
from collections import deque S = [list(input()) for _ in range(3)] SA = deque(S[0]) SB = deque(S[1]) SC = deque(S[2]) i = 'a' ans = 'now playing' while ans == 'now playing': if i == 'a': if SA == deque([]): ans = 'A' else: i = SA.popleft() elif i == 'b': if SB == deque([]): ans = '...
s569196503
Accepted
21
3,316
448
from collections import deque S = [list(input()) for _ in range(3)] SA = deque(S[0]) SB = deque(S[1]) SC = deque(S[2]) i = 'a' ans = 'now playing' while ans == 'now playing': if i == 'a': if SA == deque([]): ans = 'A' else: i = SA.popleft() elif i == 'b': if SB == deque([]): ans = '...
s160354631
p03679
u140251125
2,000
262,144
Wrong Answer
17
3,060
145
Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though. Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Ot...
# input X, A, B = map(int, input().split()) if A - B < 0: print('dangerous') elif A - B == 0: print('safe') else: print('delicious')
s817255849
Accepted
17
2,940
143
# input X, A, B = map(int, input().split()) if A >= B: print('delicious') elif B - A <= X: print('safe') else: print('dangerous')
s146767986
p02613
u972474792
2,000
1,048,576
Wrong Answer
166
16,224
317
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()) I=[] for i in range(N): I.append(input()) a=0 b=0 c=0 d=0 for i in range(N): if I[i]=='AC': a+=1 if I[i]=='WA': b+=1 if I[i]=='TLE': c+=1 if I[i]=='RE': d+=1 print('AC × '+str(a)) print('WA × '+str(b)) print('TLE × '+str(c)) print('RE × '+str(d))
s084343653
Accepted
166
16,272
313
N=int(input()) I=[] for i in range(N): I.append(input()) a=0 b=0 c=0 d=0 for i in range(N): if I[i]=='AC': a+=1 if I[i]=='WA': b+=1 if I[i]=='TLE': c+=1 if I[i]=='RE': d+=1 print('AC x '+str(a)) print('WA x '+str(b)) print('TLE x '+str(c)) print('RE x '+str(d))
s243850162
p03854
u708019102
2,000
262,144
Wrong Answer
19
3,316
246
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() a = s.count("dream") b = s.count("dreamer") c = s.count("erase") d = s.count("eraser") e = s.count("dreamera") f = s.count("erasera") b = b-e d = d-f a = a-b c = c-e if (a+c)*5 + b*7 + d*6 == len(s): print("Yes") else: print("No")
s993284055
Accepted
36
4,084
917
l = list(input()) n = len(l) cursor = n-1 while True: if cursor >= 5 and l[cursor] == "r" and l[cursor-1] == "e" and l[cursor-2] == "s" and l[cursor-3] == "a" and l[cursor-4] == "r" and l[cursor-5] == "e": cursor = cursor - 6 continue if cursor >= 4 and l[cursor] == "e" and l[cursor-1] == "s" an...
s144279698
p00718
u078042885
1,000
131,072
Wrong Answer
100
7,568
305
Prof. Hachioji has devised a new numeral system of integral numbers with four lowercase letters "m", "c", "x", "i" and with eight digits "2", "3", "4", "5", "6", "7", "8", "9". He doesn't use digit "0" nor digit "1" in this system. The letters "m", "c", "x" and "i" correspond to 1000, 100, 10 and 1, respectively, and ...
a={'m':1000,'c':100,'x':10,'i':1} for _ in range(int(input())): b,s,t=input(),0,1 for x in b: if x==' ':continue if x in a:s+=a[x]*t;t=1 else:t=int(x) ans='' for k in ['m','c','x','i']: c,s=divmod(s,a[k]) if c:ans+=['',str(c)][c!=0]+k print(ans)
s527405047
Accepted
80
7,648
288
a={'m':1000,'c':100,'x':10,'i':1} for _ in range(int(input())): b,s,t=input().replace(' ',''),0,1 for x in b: if x in a:s+=a[x]*t;t=1 else:t=int(x) d='' for k in ['m','c','x','i']: c,s=divmod(s,a[k]) if c:d+=['',str(c)][c!=1]+k print(d)
s269831237
p02646
u842797390
2,000
1,048,576
Wrong Answer
22
9,164
197
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 ...
A, V = [int(x) for x in input().split()] B, W = [int(x) for x in input().split()] T = int(input()) if W >= V: print('No') elif abs(A - B) <= (V - W) * T: print('Yes') else: print('No')
s468069371
Accepted
25
9,172
197
A, V = [int(x) for x in input().split()] B, W = [int(x) for x in input().split()] T = int(input()) if W >= V: print('NO') elif abs(A - B) <= (V - W) * T: print('YES') else: print('NO')
s058351294
p02277
u253463900
1,000
131,072
Wrong Answer
20
7,712
1,375
Let's arrange a deck of cards. Your task is to sort totally n cards. A card consists of a part of a suit (S, H, C or D) and an number. Write a program which sorts such cards based on the following pseudocode: Partition(A, p, r) 1 x = A[r] 2 i = p-1 3 for j = p to r-1 4 do if A[j] <= x 5 then ...
def Partition(A,p,r): x = A[r] i = p-1 for j in range(p,r): if (A[j] <= x): i += 1 A[i],A[j] = A[j],A[i] A[i+1],A[r] = A[r],A[i+1] return i+1 def qsort(A,p,r): if p < r: q = Partition(A,p,r) qsort(A,p,q-1) qsort(A,q+1,r) class card(object...
s021530687
Accepted
3,830
29,800
2,409
def Partition(A,p,r): x = A[r] i = p-1 for j in range(p,r): if (A[j] <= x): i += 1 A[i],A[j] = A[j],A[i] A[i+1],A[r] = A[r],A[i+1] return i+1 def qsort(A,p,r): if p < r: q = Partition(A,p,r) qsort(A,p,q-1) qsort(A,q+1,r) def marge(A,left,...
s024318321
p03380
u047197186
2,000
262,144
Wrong Answer
2,104
14,864
398
Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted.
import math def combinations_count(n, r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) n = int(input()) a_lst = list(map(int, input().split())) max_ = 0 for i, a1 in enumerate(a_lst): for a2 in a_lst[i+1:]: if a1 > a2: cand = combinations_count(a1, a2) else: cand =...
s395812139
Accepted
120
14,052
238
n = int(input()) a = list(map(int, input().split())) a.sort() large = max(a) a.remove(large) min_list = [0, large/2] for i in a: if abs(i - large/2) < min_list[1]: min_list = [i, abs(i - large/2)] print(large, min_list[0])
s517673969
p00002
u298999032
1,000
131,072
Wrong Answer
20
5,584
49
Write a program which computes the digit number of sum of two integers a and b.
a,b=map(int,input().split()) print(len(str(a+b)))
s009855334
Accepted
20
5,584
109
while 1: try: a,b=map(int,input().split()) print(len(str(a+b))) except: break
s891569392
p03593
u102126195
2,000
262,144
Wrong Answer
23
3,444
1,335
We have an H-by-W matrix. Let a_{ij} be the element at the i-th row from the top and j-th column from the left. In this matrix, each a_{ij} is a lowercase English letter. Snuke is creating another H-by-W matrix, A', by freely rearranging the elements in A. Here, he wants to satisfy the following condition: * Every ...
H, W = map(int, input().split()) A = [] for i in range(H): A.extend(list(input())) A.sort() print(A) a = [0, 0, 0] if H % 2 != 0 and W % 2 != 0: a[0] = 1 a[1] = int(H / 2) + int(W / 2) a[2] = int((H * W - a[0] - a[1]) / 4) elif H % 2 != 0: a[0] = 0 a[1] = int(W / 2) a[2] = int((H * W - a[0] ...
s441181719
Accepted
22
3,316
1,657
H, W = map(int, input().split()) A = [] for i in range(H): A.extend(list(input())) A.sort() a = [0, 0, 0] if H % 2 != 0 and W % 2 != 0: a[0] = 1 a[1] = int(H / 2) + int(W / 2) a[2] = int((H * W - a[0] - a[1] * 2) / 4) elif H % 2 != 0: a[0] = 0 a[1] = int(W / 2) a[2] = int((H * W - a[0] - a[1...
s211341275
p03673
u023229441
2,000
262,144
Wrong Answer
2,105
22,120
112
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b. The i-th operation is as follows: 1. Append a_i to the end of b. 2. Reverse the order of the elements in b. Find the sequence b obtained after these n operations.
n=int(input()) A=list(map(str,input().split())) ans="" for i in range(n): ans+=A[i] ans=ans[::-1] print(ans)
s605619872
Accepted
151
24,868
134
n=int(input()) A=list(map(str,input().split())) ans=A[1::2][::-1]+A[::2] if n%2==1: print(*[ans[::-1]][0]) else: print(*[ans][0])
s883440554
p03214
u735906430
2,525
1,048,576
Wrong Answer
1,608
21,680
163
Niwango-kun is an employee of Dwango Co., Ltd. One day, he is asked to generate a thumbnail from a video a user submitted. To generate a thumbnail, he needs to select a frame of the video according to the following procedure: * Get an integer N and N integers a_0, a_1, ..., a_{N-1} as inputs. N denotes the numbe...
import numpy as np N = int(input()) a = np.array([int(x) for x in input().split(" ")]) indices = np.abs(np.subtract.outer(a, a.mean())).argmin(0) print(a[indices])
s726159581
Accepted
1,583
22,048
160
import numpy as np N = int(input()) a = np.array([int(x) for x in input().split(" ")]) indices = np.abs(np.subtract.outer(a, a.mean())).argmin(0) print(indices)
s850822725
p03485
u643840641
2,000
262,144
Wrong Answer
17
2,940
50
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
a, b = map(int, input().split()) print((a+b)//2+1)
s745099148
Accepted
18
2,940
96
a, b = map(int, input().split()) if (a+b) %2 == 0: print ((a+b)//2) else: print ((a+b)//2+1)
s424542534
p03563
u385244248
2,000
262,144
Wrong Answer
18
2,940
53
Takahashi is a user of a site that hosts programming contests. When a user competes in a contest, the _rating_ of the user (not necessarily an integer) changes according to the _performance_ of the user, as follows: * Let the current rating of the user be a. * Suppose that the performance of the user in the cont...
R,G = map(int,open(0).read().split()) print(3*R-2*G)
s924402264
Accepted
17
2,940
48
R = int(input()) G = int(input()) print(2*G -R)
s716499894
p03827
u607741489
2,000
262,144
Wrong Answer
17
2,940
166
You have an integer variable x. Initially, x=0. Some person gave you a string S of length N, and using the string you performed the following operation N times. In the i-th operation, you incremented the value of x by 1 if S_i=`I`, and decremented the value of x by 1 if S_i=`D`. Find the maximum value taken by x duri...
n = int(input()) s = list(input()) ans=0 tmp = 0 for i in range(n): if s[i] == 'D': tmp += 1 else: tmp -= 1 ans = max(ans,tmp) print(ans)
s403426290
Accepted
17
2,940
166
n = int(input()) s = list(input()) ans=0 tmp = 0 for i in range(n): if s[i] == 'I': tmp += 1 else: tmp -= 1 ans = max(ans,tmp) print(ans)
s937510155
p02659
u906501980
2,000
1,048,576
Wrong Answer
26
9,888
138
Compute A \times B, truncate its fractional part, and print the result as an integer.
from decimal import Decimal as dec def main(): a, b = map(dec, input().split()) print(a*b) if __name__ == "__main__": main()
s995891177
Accepted
27
10,036
143
from decimal import Decimal as dec def main(): a, b = map(dec, input().split()) print(int(a*b)) if __name__ == "__main__": main()
s717418990
p03351
u859897687
2,000
1,048,576
Wrong Answer
17
2,940
90
Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either ...
a,b,c,d=map(int,input().split()) print('No'if max(abs(a-b),abs(b-c),abs(c-a))>d else'Yes')
s282411303
Accepted
17
2,940
111
a,b,c,d=map(int,input().split()) if abs(a-c)>d and max(abs(a-b),abs(c-b))>d: print('No') else: print('Yes')
s696689234
p02612
u092061507
2,000
1,048,576
Wrong Answer
29
9,136
31
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)
s401361957
Accepted
26
9,152
77
N = int(input()) if N%1000 == 0: print(0) else: print(1000 - N%1000)
s165195215
p03228
u905582793
2,000
1,048,576
Wrong Answer
17
2,940
118
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=map(int,input().split()) for i in range(k): if k%2: a,b=a+b//2,b//2 else: a,b=a//2,a//2+b print(a,b)
s005671169
Accepted
17
2,940
118
a,b,k=map(int,input().split()) for i in range(k): if i%2: a,b=a+b//2,b//2 else: a,b=a//2,a//2+b print(a,b)
s589150483
p03854
u496975476
2,000
262,144
Wrong Answer
19
3,272
296
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`.
#!/usr/bin/env python3 s = input() words = ['maerd', 'remaerd', 'resare', 'esare'] for word in words: if s[::-1].find(word) != -1: s = s.replace(word[::-1], '') print(s) if s == '': print('YES') else: print('NO')
s678824339
Accepted
45
3,316
320
#!/usr/bin/env python3 s = input()[::-1] collector = '' t = '' words = ['remaerd', 'maerd', 'resare', 'esare'] for c in s: collector += c if collector in words: t += collector collector = '' if s == t: print('YES') else: print('NO')
s822646530
p02389
u965112171
1,000
131,072
Wrong Answer
20
5,592
163
Write a program which calculates the area and perimeter of a given rectangle.
def rect(a,b): return a * b, b+2 s = input() x = s.split() a = int(x[0]) b = int(x[1]) area,perimeter = rect(a,b) print(area,perimeter)
s281584604
Accepted
20
5,588
73
s = input() x = s.split() a = int(x[0]) b = int(x[1]) print(a*b,a+b+a+b)
s362861084
p03611
u498575211
2,000
262,144
Wrong Answer
163
19,676
657
You are given an integer sequence of length N, a_1,a_2,...,a_N. For each 1≤i≤N, you have three choices: add 1 to a_i, subtract 1 from a_i or do nothing. After these operations, you select an integer X and count the number of i such that a_i=X. Maximize this count by making optimal choices.
N = int(input()) a = list(map(int, input().split())) Memory = {} for i in a: p = i + 1 q = i r = -1 if i >= 0: r = i-1 if p in Memory: Memory[p] += 1 else: Memory[p] = 1 if q in Memory: Memory[q] += 1 else: Memory[q] = 1 if r != -1: if r in Memory: Memory[r] +=...
s632012864
Accepted
162
18,800
654
N = int(input()) a = list(map(int, input().split())) Memory = {} for i in a: p = i + 1 q = i r = -1 if i >= 0: r = i-1 if p in Memory: Memory[p] += 1 else: Memory[p] = 1 if q in Memory: Memory[q] += 1 else: Memory[q] = 1 if r != -1: if r in Memory: Memory[r] +=...
s875375339
p02396
u967268722
1,000
131,072
Wrong Answer
140
5,564
94
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...
s=1 while True: i=input() if i=='0': break print('case '+str(s)+':', i) s+=1
s078194921
Accepted
140
5,568
94
s=1 while True: i=input() if i=='0': break print('Case '+str(s)+':', i) s+=1
s685123652
p04044
u187737912
2,000
262,144
Wrong Answer
27
9,096
158
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is _lexicographically sm...
val = input() splited_val = val.split() val_list=[] for x in range(int(splited_val[0])): val = input() val_list.append(val) print(sorted(val_list))
s814240185
Accepted
26
9,168
167
val = input() splited_val = val.split() val_list=[] for x in range(int(splited_val[0])): val = input() val_list.append(val) print("".join(sorted(val_list)))
s218662672
p03943
u982591663
2,000
262,144
Wrong Answer
17
3,060
134
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Not...
A, B, C = map(int, input().split()) AB = A+B BC = B+C CA = C+A if AB==BC or BC==CA or CA==AB: print("Yes") else: print("No")
s245585357
Accepted
17
2,940
132
A, B, C = map(int, input().split()) AB = A+B BC = B+C CA = C+A if AB==C or BC==A or CA==B: print("Yes") else: print("No")
s745818849
p02314
u011621222
1,000
131,072
Wrong Answer
20
5,596
372
Find the minimum number of coins to make change for n cents using coins of denominations d1, d2,.., dm. The coins can be used any number of times.
n,m = map(int, input().split()) cs = list(map(int, input().split())) dp = [True]*(n+1) dp[0] = 0 while 1: if dp[n]: break for d in range(n+1): if (dp[d]): continue for c in cs: if (dp[d+c]): dp[d+c] = dp[d]+1 elif d+c < n+1: ...
s163035965
Accepted
710
7,384
233
n,m = map(int, input().split()) mo = list(map(int,input().split())) dp = [float("inf") for i in range(n+2)] dp[0] = 0 for i in range(n+1): for j in mo: if i+j <= n: dp[i+j] = min(dp[i+j],dp[i]+1) print(dp[n])
s224673973
p03387
u057079894
2,000
262,144
Wrong Answer
17
3,064
292
You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be ...
da = list(map(int, input().split())) da = sorted(da) ans = 0 ans += (da[2] - da[0]) // 2 da[0] += (da[2] - da[0]) // 2 * 2 ans += (da[2] - da[1]) // 2 da[1] += (da[2] - da[1]) // 2 * 2 da = sorted(da) if da[0] == da[2]: pass elif da[1] == da[2]: ans += 1 else: ans += 2 print(ans)
s453913087
Accepted
17
3,064
293
da = list(map(int, input().split())) da = sorted(da) ans = 0 ans += (da[2] - da[0]) // 2 da[0] += (da[2] - da[0]) // 2 * 2 ans += (da[2] - da[1]) // 2 da[1] += (da[2] - da[1]) // 2 * 2 da = sorted(da) if da[0] == da[2]: pass elif da[0] == da[1]: ans += 1 else: ans += 2 print(ans)
s528879864
p03352
u650700749
2,000
1,048,576
Wrong Answer
17
2,940
74
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.
import math x = int(input()) print(math.pow(math.floor(math.sqrt(x)), 2))
s892225047
Accepted
17
3,060
227
import math x = int(input()) def func(num, n): root = num ** (1/n) return round(root) if num == round(root) ** n else root slv = lambda b, p: math.floor(func(b, p)) ** p print(max([slv(x, p) for p in range(2, 10)]))
s204212221
p03943
u635339675
2,000
262,144
Wrong Answer
17
2,940
105
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Not...
x,y,z=map(int,input().split()) if x+y==z or y+z==z or y+z==x: print("Yes") else: print("No")
s101204489
Accepted
17
2,940
101
x,y,z=map(int,input().split()) if x+y==z or y+z==x or z+x==y: print("Yes") else: print("No")
s269160102
p04044
u248670337
2,000
262,144
Wrong Answer
18
3,060
83
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is _lexicographically sm...
N,L=map(int,input().split()) S=sorted([input() for i in range(N)]) print(*S,end="")
s309396395
Accepted
17
3,060
83
N,L=map(int,input().split()) S=sorted([input() for i in range(N)]) print(*S,sep="")
s277361113
p03854
u843318925
2,000
262,144
Wrong Answer
19
3,188
143
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().replace('eraser', '').replace('erace', '').replace('dreamer', '').replace('dream', '') if s: print('no') else: print('yes')
s766632645
Accepted
19
3,188
143
s = input().replace('eraser', '').replace('erase', '').replace('dreamer', '').replace('dream', '') if s: print('NO') else: print('YES')
s909261058
p00767
u506554532
8,000
131,072
Wrong Answer
170
5,592
434
Let us consider rectangles whose height, _h_ , and width, _w_ , are both integers. We call such rectangles _integral rectangles_. In this problem, we consider only wide integral rectangles, i.e., those with _w_ > _h_. We define the following ordering of wide integral rectangles. Given two wide integral rectangles, ...
while True: H,W = map(int,input().split()) if H == 0: break d0 = H*H + W*W ans_d = ans_h = ans_w = 10**9 for w in range(2,151): for h in range(1,w): d = h*h + w*w if d <= d0: continue if d <= ans_d: ans_h = h ans_w = w ...
s097529959
Accepted
220
5,596
350
while True: H,W = map(int,input().split()) if H == 0: break d0 = H*H + W*W ans = (10**9,H,W) for w in range(2,151): for h in range(1,w): d = h*h + w*w if (d,h,w) < (d0,H,W) or (h,w) == (H,W): continue ans = min(ans, (d,h,w)) break print('{0...
s912715253
p02618
u384793271
2,000
1,048,576
Wrong Answer
110
9,460
477
AtCoder currently hosts three types of contests: ABC, ARC, and AGC. As the number of users has grown, in order to meet the needs of more users, AtCoder has decided to increase the number of contests to 26 types, from AAC to AZC. For convenience, we number these 26 types as type 1 through type 26. AtCoder wants to sched...
D = int(input()) C = [0] + list(map(int, input().split())) S = [0] + [[0] + list(map(int, input().split())) for _ in range(D)] last = [0] + [0 for _ in range(26)] for d in range(1, D+1): vmax = -float('inf') for i in range(1, 27): v = 0 last_ = [s for s in last] v += S[d][i] la...
s980264075
Accepted
104
9,400
473
D = int(input()) C = [0] + list(map(int, input().split())) S = [0] + [[0] + list(map(int, input().split())) for _ in range(D)] last = [0] + [0 for _ in range(26)] for d in range(1, D+1): vmax = -float('inf') for i in range(1, 27): v = 0 last_ = [s for s in last] v += S[d][i] la...
s469415215
p03068
u095756391
2,000
1,048,576
Wrong Answer
17
2,940
114
You are given a string S of length N consisting of lowercase English letters, and an integer K. Print the string obtained by replacing every character in S that differs from the K-th character of S, with `*`.
N = int(input()) S = input() K = int(input()) for i in range(N): if S[K-1] != S[i]: S[i] == '*' print(S)
s545814590
Accepted
18
2,940
149
N = int(input()) S = input() K = int(input()) ans = '' for i in range(N): if S[K-1] != S[i]: ans += '*' else: ans += S[i] print(ans)
s960328583
p03447
u329049771
2,000
262,144
Wrong Answer
17
2,940
73
You went shopping to buy cakes and donuts with X yen (the currency of Japan). First, you bought one cake for A yen at a cake shop. Then, you bought as many donuts as possible for B yen each, at a donut shop. How much do you have left after shopping?
x, a, b = [int(input()) for _ in range(3)] x -= a while x > 0: x -= b
s254435484
Accepted
20
3,060
83
x, a, b = [int(input()) for _ in range(3)] x -= a while x >= b: x -= b print(x)
s287074234
p02853
u663861584
2,000
1,048,576
Wrong Answer
17
3,060
321
We held two competitions: Coding Contest and Robot Maneuver. In each competition, the contestants taking the 3-rd, 2-nd, and 1-st places receive 100000, 200000, and 300000 yen (the currency of Japan), respectively. Furthermore, a contestant taking the first place in both competitions receives an additional 400000 yen....
x,y = map(int, input().split()) point = 0 if x == 1 and y == 1: point = 40000 if x == 1: point += 30000 elif x == 2: point += 20000 elif x == 3: point += 10000 else: pass if y == 1: point += 30000 elif y == 2: point += 20000 elif y == 3: point += 10000 else: pass print(point) ...
s892130608
Accepted
18
3,060
328
x,y = map(int, input().split()) point = 0 if x == 1 and y == 1: point = 400000 if x == 1: point += 300000 elif x == 2: point += 200000 elif x == 3: point += 100000 else: pass if y == 1: point += 300000 elif y == 2: point += 200000 elif y == 3: point += 100000 else: pass print(...
s557077205
p03543
u583276018
2,000
262,144
Wrong Answer
27
9,156
64
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**?
if(int(input()) % 1111 == 0): print("Yes") else: print("No")
s080112723
Accepted
34
8,988
115
t = input() if((t[0:1] == t[1:2] == t[2:3]) or (t[1:2] == t[2:3] == t[3:4])): print("Yes") else: print("No")
s748841493
p03139
u428341537
2,000
1,048,576
Wrong Answer
28
9,004
68
We conducted a survey on newspaper subscriptions. More specifically, we asked each of the N respondents the following two questions: * Question 1: Are you subscribing to Newspaper X? * Question 2: Are you subscribing to Newspaper Y? As the result, A respondents answered "yes" to Question 1, and B respondents answ...
n,a,b = map(int, input().split()) q=min(a, b) w=a+b-n print(q,w)
s637394497
Accepted
25
9,068
75
n,a,b = map(int, input().split()) q=min(a, b) w=max(0,a+b-n) print(q,w)
s262573638
p02422
u362104929
1,000
131,072
Wrong Answer
20
7,740
1,012
Write a program which performs a sequence of commands to a given string $str$. The command is one of: * print a b: print from the a-th character to the b-th character of $str$ * reverse a b: reverse from the a-th character to the b-th character of $str$ * replace a b p: replace from the a-th character to the b-t...
def main(): class MyClass: def __init__(self): self.strings = "" def rpl(self, int1, int2, str1): self.strings = self.strings.replace(self.strings[int1:int2+1], str1) print(self.strings) def rvr(self, int1, int2): if int1 >= 1: ...
s173160521
Accepted
20
7,748
945
def main(): class MyClass: def __init__(self): self.strings = "" def rpl(self, int1, int2, str1): self.strings = self.strings[:int1] + str1 + self.strings[int2+1:] def rvr(self, int1, int2): if int1 >= 1: revstr = self.strings[int2:int1-1...
s089282074
p02401
u436634575
1,000
131,072
Wrong Answer
30
6,744
95
Write a program which reads two integers a, b and an operator op, and then prints the value of a op b. The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part.
while True: s = input() a, op, b = s.split() if op == '?': break print(eval(s))
s710572482
Accepted
40
6,732
100
while True: s = input() a, op, b = s.split() if op == '?': break print(int(eval(s)))
s674038420
p03155
u225388820
2,000
1,048,576
Wrong Answer
31
9,120
63
It has been decided that a programming contest sponsored by company A will be held, so we will post the notice on a bulletin board. The bulletin board is in the form of a grid with N rows and N columns, and the notice will occupy a rectangular region with H rows and W columns. How many ways are there to choose where ...
n = int(input()) print((n - int(input())) * (n - int(input())))
s876365269
Accepted
29
9,152
71
n = int(input()) print((n - int(input()) + 1) * (n - int(input()) + 1))
s783341500
p03555
u951601135
2,000
262,144
Wrong Answer
18
2,940
176
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.
list_1=list(input()) list_2=list(input()) print(list_1[0],list_2[2]) if(list_1[0]==list_2[2] and list_1[1]==list_2[1] and list_1[2]==list_2[0]): print('YES') else:print('NO')
s794922632
Accepted
18
2,940
43
print(["NO","YES"][input()==input()[::-1]])
s306508982
p03470
u658113376
2,000
262,144
Wrong Answer
17
2,940
186
An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you h...
import sys def main(lines): print(len(set(lines[1:-1]))) if __name__ == '__main__': lines = [] for l in sys.stdin: lines.append(l.rstrip('\r\n')) main(lines)
s205149417
Accepted
17
2,940
184
import sys def main(lines): print(len(set(lines[1:]))) if __name__ == '__main__': lines = [] for l in sys.stdin: lines.append(l.rstrip('\r\n')) main(lines)
s302542042
p04044
u074161135
2,000
262,144
Wrong Answer
33
9,172
117
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is _lexicographically sm...
info = input().split() lst = [] for i in range(int(info[0])): lst.append(str(input())) lst = sorted(lst) print(lst)
s653077647
Accepted
28
9,044
128
info = input().split() lst = [] for i in range(int(info[0])): lst.append(str(input())) lst = "".join(sorted(lst)) print((lst))
s371658630
p03593
u925364229
2,000
262,144
Wrong Answer
25
3,320
1,650
We have an H-by-W matrix. Let a_{ij} be the element at the i-th row from the top and j-th column from the left. In this matrix, each a_{ij} is a lowercase English letter. Snuke is creating another H-by-W matrix, A', by freely rearranging the elements in A. Here, he wants to satisfy the following condition: * Every ...
def fourcount(List): num = 0 tmp = 1 l = len(List) for i in range(1,l): if (List[i-1] == List[i]) and (tmp < 4): tmp += 1 else: if tmp == 4: num += 1 tmp = 1 return num def twocount(List): num = 0 tmp = 1 l = len(List) for i in range(1,l): if (List[i-1] == List[i]) and (tmp ...
s777378138
Accepted
25
3,316
1,839
def fourcount(List): num = 0 tmp = 1 l = len(List) for i in range(1,l): if (List[i-1] == List[i]) and (tmp < 4): tmp += 1 elif tmp == 4: num += 1 tmp = 1 else: tmp = 1 if tmp == 4: num += 1 return num def twocount(List): num = 0 tmp = 1 l = len(List) for i in range(1,l): ...
s663529475
p03448
u729217226
2,000
262,144
Wrong Answer
17
3,060
220
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that co...
A = input() B = input() C = input() X = input() ans = 0 for a in A: for b in B: for c in C: total = (500 * a) + (100 * b) + (50 * c) if total == X: ans += 1 print(ans)
s701906852
Accepted
54
3,188
267
A = int(input()) B = int(input()) C = int(input()) X = int(input()) ans = 0 for a in range(A+1): for b in range(B+1): for c in range(C+1): total = (500 * a) + (100 * b) + (50 * c) if total == X: ans += 1 print(ans)
s828703862
p02608
u437990671
2,000
1,048,576
Wrong Answer
556
9,432
272
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()) dp = [0 for i in range(n+1)] maxn = 101 for x in range(1,maxn): for y in range(1,maxn): for z in range(1,maxn): p = (x+y+z)**2 p-=(x*y + y*z + z*x) if p<=n: dp[p]+=1 for i in dp: print(i)
s095440887
Accepted
474
9,396
288
n = int(input()) dp = [0 for i in range(n+1)] maxn = n**0.5 maxn = int(maxn)+1 for x in range(1,maxn): for y in range(1,maxn): for z in range(1,maxn): p = x*x + y*y + z*z + x*y + y*z +z*x if p<=n: dp[p]+=1 for i in dp[1::]: print(i)
s443631760
p03548
u495415554
2,000
262,144
Wrong Answer
18
2,940
89
We have a long seat of width X centimeters. There are many people who wants to sit here. A person sitting on the seat will always occupy an interval of length Y centimeters. We would like to seat as many people as possible, but they are all very shy, and there must be a gap of length at least Z centimeters between two...
a, b, c = map(int, input().split()) max = int((a + c) / (b + 2*c)) print(max)
s600718063
Accepted
18
3,064
277
import sys import math a, b, c = map(int, input().split()) if a < (b + 2*c): print("a >= b + 2*cとなるようにしてください") sys.exit() elif a == (b + 2*c): print("1") else: max = math.floor((a - c) / (b + c)) print(max)
s614152396
p03795
u319612498
2,000
262,144
Wrong Answer
17
2,940
38
Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant ...
n=int(input()) print(n*800-(n%15)*200)
s794665352
Accepted
17
2,940
44
n=int(input()) print(n*800-(int(n/15))*200)
s063050057
p02972
u748241164
2,000
1,048,576
Wrong Answer
849
7,220
286
There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N). For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it. We say a set of choices to put a ball or not in the boxes is good when the following con...
n = int(input()) a = list(map(int, input().split())) a = [0] + a c = [0] * (n+1) for i in range(n, 0, -1): c[i] = a[i] tmp = i * 2 while tmp <= n: c[i] -= c[tmp] tmp += i c[i] = c[i] % 2 for i in range(1, n+1): if c[i] == 1: print(i)
s225577870
Accepted
780
7,220
300
n = int(input()) a = list(map(int, input().split())) a = [0] + a c = [0] * (n+1) for i in range(n, 0, -1): c[i] = a[i] tmp = i * 2 while tmp <= n: c[i] -= c[tmp] tmp += i c[i] = c[i] % 2 print(sum(c)) for i in range(1, n+1): if c[i] == 1: print(i)
s462418882
p00007
u617990214
1,000
131,072
Wrong Answer
20
7,576
105
Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week. Write a program which computes the amount of the debt in n weeks.
a=int(input()) for i in range(5): a*=1.05 if a%1000==0: pass else: a=(a+1000)-a%1000 print(int(a))
s859674330
Accepted
20
7,492
114
a=100000 j=int(input()) for i in range(j): a*=1.05 if a%1000==0: pass else: a=(a+1000)-a%1000 print(int(a))
s027730990
p02748
u052821962
2,000
1,048,576
Wrong Answer
628
33,540
383
You are visiting a large electronics store to buy a refrigerator and a microwave. The store sells A kinds of refrigerators and B kinds of microwaves. The i-th refrigerator ( 1 \le i \le A ) is sold at a_i yen (the currency of Japan), and the j-th microwave ( 1 \le j \le B ) is sold at b_j yen. You have M discount tic...
na,nb,M=map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) C = [[0 for i in range(3)] for j in range(M)] #C = [[0]*3]*M s=min(A)+min(B) t=0 #print(A) for i in range(M): C[i][0],C[i][1],C[i][2] = map(int, input().split()) #print(C) for j in range(M): print(j) t=A[C[...
s186775341
Accepted
514
32,556
384
na,nb,M=map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) C = [[0 for i in range(3)] for j in range(M)] #C = [[0]*3]*M s=min(A)+min(B) t=0 #print(A) for i in range(M): C[i][0],C[i][1],C[i][2] = map(int, input().split()) #print(C) for j in range(M): #print(j) t=A[C...
s706130577
p02612
u695079172
2,000
1,048,576
Wrong Answer
35
9,136
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.
def main(): n = int(input()) print(n % 1000) if __name__ == '__main__': main()
s907696849
Accepted
28
9,144
157
def main(): n = int(input()) n = n % 1000 if n == 0: print(0) else: print(1000 - n) if __name__ == '__main__': main()
s390215517
p03353
u059210959
2,000
1,048,576
Wrong Answer
2,109
60,992
414
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...
#encoding utf-8 import copy import numpy as np import random s = list(str(input())) k = int(input()) substrings = [] for length in range(1,len(s)+1): for i in range(len(s)-length+1): word = "".join(s[i:i+length]) print(word) if word in substrings: pass else: ...
s393202068
Accepted
1,682
13,672
449
#encoding utf-8 import copy import numpy as np import random s = list(str(input())) k = int(input()) substrings = [] for length in range(1,len(s)+1): if length > 5: break for i in range(len(s)-length+1): word = "".join(s[i:i+length]) # print(word) if word in substrings: ...
s011587580
p03545
u174181999
2,000
262,144
Wrong Answer
17
3,064
398
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...
x = str(input()) l = [x[0], x[1], x[2], x[3]] m = [int(s) for s in l] N = 2 ** 3 for i in range(N): n = [m[0], 0, 0, 0] o = [] for j in range(3): if (i >> j) & 1: n[-j-1] = -m[-j-1] o.append('-') else: n[-j-1] = m[-j-1] o.append('+') if sum(n) == 7: print(str(m[0]) + o[0] + ...
s804561969
Accepted
18
3,064
405
x = str(input()) l = [x[0], x[1], x[2], x[3]] m = [int(s) for s in l] N = 2 ** 3 for i in range(N): n = [m[0], 0, 0, 0] o = [] for j in range(3): if (i >> j) & 1: n[-j-1] = -m[-j-1] o.append('-') else: n[-j-1] = m[-j-1] o.append('+') if sum(n) == 7: print(str(m[0]) + o[2] + ...