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
s431452434
p03163
u269235541
2,000
1,048,576
Wrong Answer
2,104
108,220
274
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 the maximum possible sum of the values of items that Taro takes home.
N,W = map(int,input().split()) V = sorted([[int(x) for x in input().split()] for _ in range(N)]) dp = [0]*(W+1) s = 0 for w,v in V: s += w for j in range(w-1,min(W,s)): if dp[j-w] + v > dp[j]: dp[j] = dp[j-w] + v print(dp) print(max(dp))
s198586929
Accepted
212
15,456
224
N, W = map(int, input().split()) import numpy as np dp = np.zeros(W + 1, dtype='int64') for i in range(1, N + 1): w, v = map(int, input().split()) dp[w:W+1] = np.maximum(dp[w:W+1], dp[:W-w+1] + v) print(dp[-1])
s565425487
p03501
u353855427
2,000
262,144
Wrong Answer
17
2,940
106
You are parking at a parking lot. You can choose from the following two fee plans: * Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours. * Plan 2: The fee will be B yen, regardless of the duration. Find the minimum fee when you park for N hours.
NAB = list(map(int,input().split())) if(NAB[0]*NAB[1]>=NAB[2]): print(NAB[0]*NAB[1]) else: print(NAB[2])
s161307769
Accepted
17
2,940
106
NAB = list(map(int,input().split())) if(NAB[0]*NAB[1]<=NAB[2]): print(NAB[0]*NAB[1]) else: print(NAB[2])
s185447855
p03471
u912650255
2,000
262,144
Wrong Answer
18
2,940
269
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these. According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.
N = 1000 Y = 1234000 ##N,Y = map(int,input().split()) ans = -1,-1,-1 for x in range(N+1): for y in range(N+1-x): z = N - x - y if 10000*x + 5000*y + 1000*z == Y: ans = x,y,z break else: break print(*ans)
s241789796
Accepted
774
3,060
241
N,Y = map(int,input().split()) ans = -1,-1,-1 for x in range(N+1): for y in range(N+1-x): z = N - x - y if 10000*x + 5000*y + 1000*z == Y: ans = x,y,z break else: continue print(*ans)
s606793469
p03455
u819135704
2,000
262,144
Wrong Answer
17
2,940
100
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
a, b = map(int, input().split()) c = a * b if c % 2 == 0: print('even') else: print('odd')
s986327033
Accepted
17
2,940
100
a, b = map(int, input().split()) c = a * b if c % 2 == 0: print('Even') else: print('Odd')
s998032863
p03079
u894258749
2,000
1,048,576
Wrong Answer
18
2,940
114
You are given three integers A, B and C. Determine if there exists an equilateral triangle whose sides have lengths A, B and C.
inpl = lambda: list(map(int,input().split())) A, B, C = inpl() if A==B==C: print('YES') else: print('NO')
s710331356
Accepted
17
2,940
114
inpl = lambda: list(map(int,input().split())) A, B, C = inpl() if A==B==C: print('Yes') else: print('No')
s821145541
p02742
u313317027
2,000
1,048,576
Wrong Answer
17
2,940
102
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds: * r_1 + c_1 = r_2 + c_2 * r_1 - c_1 = r_2 - c_2 For example, in the following figure, the bishop can move to any of the red squares in one move:
W, R = map(int,input().split()) seki = W*R if seki%2 == 0: print(seki/2) else: print((seki+1)/2)
s056943888
Accepted
17
3,060
168
import sys W, R = map(int,input().split()) seki = W*R if(W==1 or R==1): print(1) sys.exit() if seki%2 == 0: print(int(seki/2)) else: print(int((seki+1)/2))
s284013504
p03730
u276115223
2,000
262,144
Wrong Answer
17
2,940
195
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 objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
a, b, c = map(int, input().split()) canSelect = 'No' for i in range(1, b + 1): if (i * a) % b == c: canSelect = 'Yes' break print(canSelect)
s760479521
Accepted
19
2,940
195
a, b, c = map(int, input().split()) canSelect = 'NO' for i in range(1, b + 1): if (i * a) % b == c: canSelect = 'YES' break print(canSelect)
s967147431
p03597
u618373524
2,000
262,144
Wrong Answer
17
2,940
3
We have an N \times N square grid. We will paint each square in the grid either black or white. If we paint exactly A squares white, how many squares will be painted black?
3 4
s043838998
Accepted
17
2,940
47
N = int(input()) A = int(input()) print(N**2-A)
s911078563
p03129
u581040514
2,000
1,048,576
Wrong Answer
17
2,940
157
Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.
N, K = map(int, input().split()) if N == 1: print('No') elif N == 2: print('No') elif (int(N**2+N)/2)+1 <= K: print('Yes') else: print('No')
s692904299
Accepted
17
2,940
91
N, K = map(int, input().split()) if (K-1)*2+1 <= N: print('YES') else: print('NO')
s165490597
p02388
u656153606
1,000
131,072
Wrong Answer
20
7,512
75
Write a program which calculates the cube of a given integer x.
InputNunber = input('Input: ') x = int(InputNunber) ** 3 print('Output=',x)
s596363016
Accepted
20
7,632
58
InputNunber = input('') x = int(InputNunber) ** 3 print(x)
s566494853
p03738
u820351940
2,000
262,144
Wrong Answer
17
2,940
77
You are given two positive integers A and B. Compare the magnitudes of these numbers.
a = input() b = input() a > b and "GREATER" or (a == b and "EQUAL" or "LESS")
s093661703
Accepted
17
2,940
95
a = int(input()) b = int(input()) print(a > b and "GREATER" or (a == b and "EQUAL" or "LESS"))
s815263843
p03739
u882620594
2,000
262,144
Wrong Answer
2,104
112,768
301
You are given an integer sequence of length N. The i-th term in the sequence is a_i. In one operation, you can select a term and either increment or decrement it by one. At least how many operations are necessary to satisfy the following conditions? * For every i (1≤i≤n), the sum of the terms from the 1-st through i-th term is not zero. * For every i (1≤i≤n-1), the sign of the sum of the terms from the 1-st through i-th term, is different from the sign of the sum of the terms from the 1-st through (i+1)-th term.
n=int(input()) a=list(map(int,input().split())) sum=[0,]*n sum[0]=a[0] zoubun=0 cnt=0 for i in range(1,n): sum[i]=sum[i-1]+a[i] if(sum[i]*sum[i-1]>=0): cnt+=abs(sum[i])+1 if sum[i]>=0: sum[i]=-1 else: sum[i]=1 print(sum) print(str(cnt))
s525562311
Accepted
240
14,888
1,691
import copy import sys write = sys.stdout.write n = int(input()) A = list(map(int,input().split())) # +, -, +, ... B = copy.deepcopy(A) #-, +, -, ... sumA = [] sumB = [] cntA = 0 cntB = 0 if A[0] == 0: A[0] += 1 cntA += 1 B[0] -= 1 cntB += 1 elif A[0] > 0: cntB += (B[0]+1) B[0] = -1 else: cntA += abs(A[0])+1 A[0] = 1 sumA.append(A[0]) sumB.append(B[0]) for i in range(1, n): tempA = sumA[i-1] + A[i] tempB = sumB[i-1] + B[i] if i%2 == 1: if tempA == 0: #A[i] -= 1 cntA += 1 sumA.append(-1) elif tempA > 0: #A[i] -= abs(tempA) + 1 cntA += (abs(tempA) + 1) sumA.append(-1) else: sumA.append(tempA) if tempB == 0: #B[i] += 1 cntB += 1 sumB.append(1) elif tempB < 0: cntB += (abs(tempB) + 1) sumB.append(1) else: sumB.append(tempB) else: if tempA == 0: cntA += 1 sumA.append(1) elif tempA < 0: cntA += (abs(tempA) + 1) sumA.append(1) else: sumA.append(tempA) if tempB == 0: #B[i] -= 1 cntB += 1 sumB.append(-1) elif tempB > 0: cntB += (abs(tempB) + 1) sumB.append(-1) else: sumB.append(tempB) print(str(min(cntA, cntB)))
s390399732
p03359
u785205215
2,000
262,144
Wrong Answer
108
3,572
874
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?
import math import itertools from heapq import heapify, heappop, heappush from sys import stdin, stdout, setrecursionlimit from bisect import bisect, bisect_left, bisect_right from collections import defaultdict, deque # inf = float("inf") def LM(t, r): return list(map(t, r)) def R(): return stdin.readline() def RS(): return R().split() def I(): return int(R()) def F(): return float(R()) def LI(): return LM(int,RS()) def LF(): return LM(float,RS()) def ONE_SL(): return list(input()) def ONE_IL(): return LM(int, ONE_SL()) def ALL_IL(): return LM(int,stdin) ##### tools ##### def ap(f): return f.append def pll(li): print('\n'.join(LM(str,li))) def pljoin(li, s): print(s.join(li)) ##### main ##### def main(): m,d = LI() print(m-1 if m >= d else m) if __name__ == '__main__': main()
s539841071
Accepted
55
3,444
874
import math import itertools from heapq import heapify, heappop, heappush from sys import stdin, stdout, setrecursionlimit from bisect import bisect, bisect_left, bisect_right from collections import defaultdict, deque # inf = float("inf") def LM(t, r): return list(map(t, r)) def R(): return stdin.readline() def RS(): return R().split() def I(): return int(R()) def F(): return float(R()) def LI(): return LM(int,RS()) def LF(): return LM(float,RS()) def ONE_SL(): return list(input()) def ONE_IL(): return LM(int, ONE_SL()) def ALL_IL(): return LM(int,stdin) ##### tools ##### def ap(f): return f.append def pll(li): print('\n'.join(LM(str,li))) def pljoin(li, s): print(s.join(li)) ##### main ##### def main(): m,d = LI() print(m if m <= d else m-1) if __name__ == '__main__': main()
s579538878
p03565
u521020719
2,000
262,144
Wrong Answer
17
3,060
367
E869120 found a chest which is likely to contain treasure. However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters. He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with `?`. One more thing he found is a sheet of paper with the following facts written on it: * Condition 1: The string S contains a string T as a contiguous substring. * Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1. Print the string S. If such a string does not exist, print `UNRESTORABLE`.
sd = input() t = input() n = len(sd) m = len(t) s = [] for i in range(n - m, -1, -1): t_kamo = sd[i:i + m] for j in range(m + 1): if j == m: print((sd[:i] + t + sd[i + len(t):]).replace("?", "a")) exit() if t_kamo[j] == "?": continue elif t_kamo != t[j]: break print("UNRESTORABLE")
s627845164
Accepted
17
3,064
370
sd = input() t = input() n = len(sd) m = len(t) s = [] for i in range(n - m, -1, -1): t_kamo = sd[i:i + m] for j in range(m + 1): if j == m: print((sd[:i] + t + sd[i + len(t):]).replace("?", "a")) exit() if t_kamo[j] == "?": continue elif t_kamo[j] != t[j]: break print("UNRESTORABLE")
s002118204
p03543
u463775490
2,000
262,144
Wrong Answer
19
2,940
97
We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**. You are given a 4-digit integer N. Answer the question: Is N **good**?
n=str(input()) if n[0]==n[1]==n[2] or n[1]==n[2]==n[-1:]: print("YES") else: print("NO")
s319365192
Accepted
17
2,940
96
n=str(input()) if n[0]==n[1]==n[2] or n[1]==n[2]==n[-1:]: print("Yes") else: print("No")
s941473970
p03455
u472899240
2,000
262,144
Wrong Answer
17
2,940
100
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
a, b = map(int, input().split()) c = (a + b) % 2 if c == 1: print("Odd") else: print("Even")
s365191973
Accepted
17
2,940
100
a, b = map(int, input().split()) c = (a * b) % 2 if c == 1: print("Odd") else: print("Even")
s755566090
p02646
u933929042
2,000
1,048,576
Wrong Answer
24
9,112
162
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 her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
a, v = map(int, input().split()) b, w = map(int, input().split()) t = int(input()) if v-w != 0 and abs(a-b)/abs(v-w) > t: print("Yes") else: print("No")
s428178142
Accepted
22
9,172
159
a, v = map(int, input().split()) b, w = map(int, input().split()) t = int(input()) if v-w > 0 and abs(a-b) <= t*(v-w): print("YES") else: print("NO")
s365840646
p03360
u019584841
2,000
262,144
Wrong Answer
17
3,060
151
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()) if max(a,b,c) == a: print(a**k+b+c) elif max(a,b,c) == b: print(b**k+a+c) else: print(a+b+c**k)
s447212037
Accepted
19
3,316
165
a,b,c = map(int,input().split()) k = int(input()) if max(a,b,c) == a: print(a*(2**k)+b+c) elif max(a,b,c) == b: print(b*(2**k)+a+c) else: print(a+b+c*(2**k))
s970502816
p03044
u016128476
2,000
1,048,576
Wrong Answer
599
25,764
739
We have a tree with N vertices numbered 1 to N. The i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i. Your objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied: * For any two vertices painted in the same color, the distance between them is an even number. Find a coloring of the vertices that satisfies the condition and print it. It can be proved that at least one such coloring exists under the constraints of this problem.
N = int(input()) U, V, W = [], [], [] T = [[] for _ in range(N)] S = set() for _ in range(N-1): u, v, w = map(int, input().split()) if w % 2 == 1: T[u-1].append(v) T[v-1].append(u) S.add(u) S.add(v) # U.append(u) # V.append(v) # W.append(w) ans = [None for _ in range(N)] while len(S) > 0: s = S.pop() search = set() search.add(s) ans[s-1] = '0' while len(search) > 0: p = search.pop() if p in S: S.remove(p) for t in T[p-1]: if t in S: search.add(t) ans[t-1] = '0' if ans[p-1] == '1' else '1' for i in range(N): if ans[i] is None: ans[i] = '0' print(' '.join(ans))
s048975915
Accepted
807
66,736
1,255
N = int(input()) U, V, W = [], [], [] T = [[] for _ in range(N)] # tree class Tree(object): def __init__(self, us, vs, ws): self.con_table = [[] for _ in range(len(us) + 1)] self.weights = dict() for (u, v, w) in zip(us, vs, ws): self.con_table[u-1].append(v-1) self.con_table[v-1].append(u-1) self.weights[(u-1, v-1)] = w self.init_search() def init_search(self): self.visited = [False for _ in range(len(self.con_table))] dists = [None for _ in range(N)] from collections import deque def dfs(tree, s): tree.init_search() dists[s] = 0 while not all(tree.visited): search = deque() tree.visited[s] = True search.append(s) while len(search) > 0: v = search.pop() for u in tree.con_table[v]: if not tree.visited[u]: dists[u] = dists[v] + tree.weights[(min(u, v), max(u, v))] tree.visited[u] = True search.append(u) for _ in range(N-1): u, v, w = map(int, input().split()) U.append(u) V.append(v) W.append(w) tree = Tree(U, V, W) dfs(tree, 0) print('\n'.join(('0' if d % 2 == 0 else '1') for d in dists))
s163869109
p03720
u437215432
2,000
262,144
Wrong Answer
18
3,060
194
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?
n, m = map(int, input().split()) ab = [0] * m for i in range(m): ab[i] = list(map(int, input().split())) roads = [0] * n for a, b in ab: roads[a-1] += 1 roads[b-1] += 1 print(roads)
s958103615
Accepted
18
2,940
210
n, m = map(int, input().split()) ab = [0] * m for i in range(m): ab[i] = list(map(int, input().split())) roads = [0] * n for a, b in ab: roads[a-1] += 1 roads[b-1] += 1 for i in roads: print(i)
s360527463
p03860
u221888299
2,000
262,144
Wrong Answer
17
2,940
31
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')
s377956351
Accepted
17
2,940
31
s = input() print('A'+s[8]+'C')
s656053524
p03970
u333945892
2,000
262,144
Wrong Answer
17
2,940
110
CODE FESTIVAL 2016 is going to be held. For the occasion, Mr. Takahashi decided to make a signboard. He intended to write `CODEFESTIVAL2016` on it, but he mistakenly wrote a different string S. Fortunately, the string he wrote was the correct length. So Mr. Takahashi decided to perform an operation that replaces a certain character with another in the minimum number of iterations, changing the string to `CODEFESTIVAL2016`. Find the minimum number of iterations for the rewrite operation.
S1 = input() S2 = "CODEFESTIVAL2016" ans = 0 for i in range(16): if S1[i] == S2[i]: ans+=1 print(ans)
s697407903
Accepted
17
2,940
111
S1 = input() S2 = "CODEFESTIVAL2016" ans = 0 for i in range(16): if S1[i] != S2[i]: ans+=1 print(ans)
s764831024
p01225
u316584871
5,000
131,072
Wrong Answer
30
5,604
1,123
あなたの友達は最近 UT-Rummy というカードゲームを思いついた. このゲームで使うカードには赤・緑・青のいずれかの色と1から9までのいずれかの番号が つけられている. このゲームのプレイヤーはそれぞれ9枚の手札を持ち, 自分のターンに手札から1枚選んで捨てて, 代わりに山札から1枚引いてくるということを繰り返す. このように順番にターンを進めていき, 最初に手持ちのカードに3枚ずつ3つの「セット」を作ったプレイヤーが勝ちとなる. セットとは,同じ色の3枚のカードからなる組で,すべて同じ数を持っているか 連番をなしているもののことを言う. 連番に関しては,番号の巡回は認められない. 例えば,7, 8, 9は連番であるが 9, 1, 2は連番ではない. あなたの友達はこのゲームをコンピュータゲームとして売り出すという計画を立てて, その一環としてあなたに勝利条件の判定部分を作成して欲しいと頼んできた. あなたの仕事は,手札が勝利条件を満たしているかどうかを判定する プログラムを書くことである.
n = int(input()) def check(nl): for i in nl: if ((i+1 in nl) and (i+2 in nl)): for k in range(i,i+3): nl.remove(k) elif(nl.count(i)%3 == 0): for k in range(nl.count(i)): nl.remove(i) for i in range(n): num_list = list(map(int, input().split())) c_list = list(map(str, input().split())) r = c_list.count('R') g = c_list.count('G') b = c_list.count('B') if (r%3 == 0 and g % 3 == 0 and b % 3 == 0): rlist = [] glist = [] blist = [] for k in range(9): if(c_list[k] == 'R'): rlist.append(num_list[k]) elif(c_list[k] == 'G'): glist.append(num_list[k]) elif(c_list[k] == 'B'): blist.append(num_list[k]) rlist.sort() blist.sort() glist.sort() check(rlist) check(glist) check(blist) if(rlist == [] and glist == [] and blist == []): print(1) else: print(0) else: print(0)
s332321375
Accepted
20
5,604
1,246
n = int(input()) def check(nl): fl = list(nl) for w in range(len(nl)): if (fl[w] in nl): i = fl[w] if ((i+1 in nl) and (i+2 in nl)): for k in range(i,i+3): nl.remove(k) elif(nl.count(i)%3 == 0): for k in range(nl.count(i)): nl.remove(i) for i in range(n): num_list = list(map(int, input().split())) c_list = list(map(str, input().split())) r = c_list.count('R') g = c_list.count('G') b = c_list.count('B') if (r%3 == 0 and g % 3 == 0 and b % 3 == 0): rlist = [] glist = [] blist = [] for k in range(9): if(c_list[k] == 'R'): rlist.append(num_list[k]) elif(c_list[k] == 'G'): glist.append(num_list[k]) elif(c_list[k] == 'B'): blist.append(num_list[k]) rlist.sort() glist.sort() blist.sort() check(rlist) check(glist) check(blist) if(len(rlist) == 0 and len(glist) == 0 and len(blist) == 0): print(1) else: print(0) else: print(0)
s904902987
p02841
u094948011
2,000
1,048,576
Wrong Answer
18
2,940
117
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('1') else: print('0')
s454187623
Accepted
17
2,940
117
M1,D1 = map(int, input().split()) M2,D2 = map(int, input().split()) if M1 == M2: print('0') else: print('1')
s976755369
p03434
u247680229
2,000
262,144
Wrong Answer
18
3,064
270
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 cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.
N=int(input()) a=list(map(int, input().split())) a.sort(reverse=True) A=[] B=[] for i,k in enumerate(a): if i%2 == 0: A.append(a[i]) elif i%2 == 1: B.append(a[i]) print(i) print(sum(A)-sum(B))
s926681021
Accepted
17
3,060
260
N=int(input()) a=list(map(int, input().split())) a.sort(reverse=True) A=[] B=[] for i,k in enumerate(a): if i%2 == 0: A.append(a[i]) elif i%2 == 1: B.append(a[i]) print(sum(A)-sum(B))
s103551212
p02663
u282908818
2,000
1,048,576
Wrong Answer
22
9,072
289
In this problem, we use the 24-hour clock. Takahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the time H_2 : M_2. (See Sample Inputs below for clarity.) He has decided to study for K consecutive minutes while he is up. What is the length of the period in which he can start studying?
T = list(str(input())) for i in range(len(T)): if T[i] == '?': if T[i - 1] == 'P': T[i] = 'D' elif T[i + 1] == '?': T[i] = 'P' T[i + 1] = 'D' i= i+1 else: T[i] = 'D' TL=''.join(T) print(TL)
s169430962
Accepted
21
9,164
112
H,M,HH,MM,K=map(int,input().split()) hour = HH - H -1 minute=60+MM-M time = hour * 60 + minute - K print(time)
s451202415
p02600
u468972478
2,000
1,048,576
Wrong Answer
29
9,076
37
M-kun is a competitor in AtCoder, whose highest rating is X. In this site, a competitor is given a _kyu_ (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given: * From 400 through 599: 8-kyu * From 600 through 799: 7-kyu * From 800 through 999: 6-kyu * From 1000 through 1199: 5-kyu * From 1200 through 1399: 4-kyu * From 1400 through 1599: 3-kyu * From 1600 through 1799: 2-kyu * From 1800 through 1999: 1-kyu What kyu does M-kun have?
n = int(input()) print(10 - (n // 2))
s563500780
Accepted
27
9,156
39
n = int(input()) print(10 - (n // 200))
s242892629
p03597
u669057361
2,000
262,144
Wrong Answer
17
2,940
47
We have an N \times N square grid. We will paint each square in the grid either black or white. If we paint exactly A squares white, how many squares will be painted black?
N = int(input()) A = int(input()) print(N-A**2)
s442253301
Accepted
17
2,940
47
N = int(input()) A = int(input()) print(N**2-A)
s332176709
p02608
u733866054
2,000
1,048,576
Wrong Answer
459
9,464
236
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()) ans=[0]*(N+5) for i in range(100) : for j in range(100) : for k in range(100) : n=i*i+j*j+k*k+i*j+j*k+k*i if N>=n : ans[n]+=1 for i in range(1,N+1) : print(ans[i])
s319442260
Accepted
444
9,296
241
N=int(input()) ans=[0]*(N+5) for i in range(1,100) : for j in range(1,100) : for k in range(1,100) : n=i*i+j*j+k*k+i*j+j*k+k*i if N>=n : ans[n]+=1 for i in range(1,N+1) : print(ans[i])
s710140125
p03574
u734749411
2,000
262,144
Wrong Answer
53
3,924
592
You are given an H × W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square containing a bomb. Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square. (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.) He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square. Print the strings after the process.
H, W = map(int, input().split()) table = [] table.append(list("_" * (W + 2))) for _ in range(H): table.append(list("_" + input() + "_")) table.append(list("_" * (W + 2))) for h in range(1, H + 1): for w in range(1, W + 1): if table[h][w] == "#": continue count = 0 for _h in [-1, 0, +1]: for _w in [-1, 0, +1]: print(h + _h, w + _w) if table[h + _h][w + _w] == "#": count += 1 table[h][w] = str(count) for h in range(1, H + 1): print("".join(table[h]).replace("_", ""))
s133166994
Accepted
24
3,188
554
H, W = map(int, input().split()) table = [] table.append(list("_" * (W + 2))) for _ in range(H): table.append(list("_" + input() + "_")) table.append(list("_" * (W + 2))) for h in range(1, H + 1): for w in range(1, W + 1): if table[h][w] == "#": continue count = 0 for _h in [-1, 0, +1]: for _w in [-1, 0, +1]: if table[h + _h][w + _w] == "#": count += 1 table[h][w] = str(count) for h in range(1, H + 1): print("".join(table[h]).replace("_", ""))
s773660422
p02612
u268402865
2,000
1,048,576
Wrong Answer
26
9,140
71
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
import math a = int(input()) a_ceil = math.ceil(a/1000)*1000 a_ceil - a
s453383024
Accepted
26
9,108
83
N = int(input()) tmp = N%1000 if tmp == 0: print(0) else: print(1000 - tmp)
s307426514
p03636
u102242691
2,000
262,144
Wrong Answer
17
2,940
81
The word `internationalization` is sometimes abbreviated to `i18n`. This comes from the fact that there are 18 letters between the first `i` and the last `n`. You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way.
s = input() number = len(s) - 2 print(s[0]) print(s[0] + str(number) + s[-1])
s085919126
Accepted
17
2,940
112
s = list(input()) ans = [] ans.append(s[0]) ans.append(str((len(s)-2))) ans.append(s[-1]) print("".join(ans))
s034403581
p03478
u814986259
2,000
262,144
Wrong Answer
34
3,060
141
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
N,A,B=map(int,input().split()) ans=0 for i in range(1,N+1): s=list(map(int,str(i))) s=sum(s) if A<=s and s>=B: ans+=1 print(ans)
s190159758
Accepted
29
2,940
207
N, A, B = map(int, input().split()) ans = 0 for i in range(1, N+1): k = i tmp = 0 while k > 0: tmp += k % 10 k = k // 10 if tmp >= A and tmp <= B: ans += i print(ans)
s554939749
p03657
u496821919
2,000
262,144
Wrong Answer
17
2,940
244
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.
# -*- coding: utf-8 -*- """ Created on Thu May 14 12:29:30 2020 @author: shinba """ a,b = map(int,input().split()) if a % 3 == 0: print("Yes") elif b % 3 == 0: print("Yes") elif (a+b) % 3 == 0: print("Yes") else: print("No")
s758239516
Accepted
18
3,064
267
# -*- coding: utf-8 -*- """ Created on Thu May 14 12:29:30 2020 @author: shinba """ a,b = map(int,input().split()) if a % 3 == 0: print("Possible") elif b % 3 == 0: print("Possible") elif (a+b) % 3 == 0: print("Possible") else: print("Impossible")
s232771116
p03433
u631429391
2,000
262,144
Wrong Answer
17
2,940
90
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
N=int(input()) A=int(input()) if N%500 <= A: print("YES") elif N%500 > A: print("NO")
s470375197
Accepted
17
2,940
90
N=int(input()) A=int(input()) if N%500 <= A: print("Yes") elif N%500 > A: print("No")
s164420471
p02742
u933717615
2,000
1,048,576
Wrong Answer
17
2,940
100
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds: * r_1 + c_1 = r_2 + c_2 * r_1 - c_1 = r_2 - c_2 For example, in the following figure, the bishop can move to any of the red squares in one move:
H,W=map(int, input().split()) if W%2==0: ans = int(H*W/2) else: ans = int(H*W/2)+1 print(ans)
s840889734
Accepted
18
3,060
138
H,W=map(int, input().split()) if H==1 or W==1: ans=1 elif W%2!=0 and H%2!=0: ans = int(H*W/2)+1 else: ans = int(H*W/2) print(ans)
s113349700
p04044
u999331208
2,000
262,144
Wrong Answer
17
3,060
176
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()) print(n) print(l) input_str = [] for i in range(n): input_str.append(input()) input_str.sort() mojiretu = ''.join(input_str) print(mojiretu)
s863109977
Accepted
17
3,060
158
n,l=map(int,input().split()) input_str = [] for i in range(n): input_str.append(input()) input_str.sort() mojiretu = ''.join(input_str) print(mojiretu)
s578996227
p02972
u609061751
2,000
1,048,576
Wrong Answer
2,104
109,884
333
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 condition is satisfied: * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2. Does there exist a good set of choices? If the answer is yes, find one good set of choices.
N=int(input()) a=list(map(int,input().split())) M=0 b=[] M=0 for i in range(N): b.append(0) for j in range(N,0,-1): cnt=0 for k in range(j,N,j): cnt+=b[k-1] if cnt%2!=a[j-1]: b[j-1]=1 print(b) M+=1 c=[l+1 for l, x in enumerate(b) if x==1] c=list(map(str,c)) print(M) print(' '.join(c))
s272302167
Accepted
648
19,004
318
N=int(input()) a=list(map(int,input().split())) M=0 b=[] M=0 for i in range(N): b.append(0) for j in range(N,0,-1): cnt=0 for k in range(j,N+1,j): cnt+=b[k-1] if cnt%2!=a[j-1]: b[j-1]=1 M+=1 c=[l+1 for l, x in enumerate(b) if x==1] c=list(map(str,c)) print(M) print(' '.join(c))
s139727944
p03370
u806403461
2,000
262,144
Wrong Answer
325
4,536
219
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.
n, x = map(int, input().split()) m = list() for a in range(0, n): m.append(int(input())) sm = sum(m) ans = n while sm <= x: sm += min(m) ans += 1 print(sm, ans) if sm < x: ans -= 1 print(ans)
s670347878
Accepted
17
2,940
137
n, x = map(int, input().split()) m = list() for a in range(0, n): m.append(int(input())) s = sum(m) print(n + (x - s) // min(m))
s123806570
p03658
u396391104
2,000
262,144
Wrong Answer
17
2,940
137
Snuke has N sticks. The length of the i-th stick is l_i. Snuke is making a snake toy by joining K of the sticks together. The length of the toy is represented by the sum of the individual sticks that compose it. Find the maximum possible length of the toy.
n,k = map(int,input().split()) l = list(map(int,input().split())) l.sort(reverse=True) ans = 0 for i in range(k+1): ans += i print(ans)
s033371683
Accepted
17
2,940
139
n,k = map(int,input().split()) l = list(map(int,input().split())) l.sort(reverse=True) ans = 0 for i in range(k): ans += l[i] print(ans)
s239181736
p03457
u231189826
2,000
262,144
Wrong Answer
469
30,668
440
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
N = int(input()) T = [] Z = [] time = [] T.append([0,0,0]) for i in range(N): t = list(map(int, input().split())) T.append(t) goal = True for l in range(len(T)-1): Z.append(abs(T[l+1][1]-T[l][1]) + abs(T[l+1][2]-T[l][2])) time.append(T[l+1][0] - T[l][0]) for j in range(len(T)-1): if Z[j] > time[j] or Z[j]%2 != time[j]%2: goal = False break if goal == False: print('NO') else: print('YES')
s742840342
Accepted
100
26,632
109
_,*l=map(int,open(0).read().split());print("YNeos"[any((t+x+y)%2+(t<x+y)for t,x,y in zip(*[iter(l)]*3))::2])
s849469462
p02821
u967136506
2,000
1,048,576
Wrong Answer
989
14,340
712
Takahashi has come to a party as a special guest. There are N ordinary guests at the party. The i-th ordinary guest has a _power_ of A_i. Takahashi has decided to perform M _handshakes_ to increase the _happiness_ of the party (let the current happiness be 0). A handshake will be performed as follows: * Takahashi chooses one (ordinary) guest x for his left hand and another guest y for his right hand (x and y can be the same). * Then, he shakes the left hand of Guest x and the right hand of Guest y simultaneously to increase the happiness by A_x+A_y. However, Takahashi should not perform the same handshake more than once. Formally, the following condition must hold: * Assume that, in the k-th handshake, Takahashi shakes the left hand of Guest x_k and the right hand of Guest y_k. Then, there is no pair p, q (1 \leq p < q \leq M) such that (x_p,y_p)=(x_q,y_q). What is the maximum possible happiness after M handshakes?
def ints(): return [int(x) for x in input().split()] def ii(): return int(input()) N, M = ints() A = ints() A.sort() def combinations(x): s = 0 i = 0 j = N-1 while j>=0: while i<N and A[i]+A[j]<x: i += 1 s += N-i j -= 1 return s def koufukudo(x): s = 0 si = 0 j = 0 i = N-1 while j<N: while i>=0 and A[i]+A[j]>=x: si += A[i] i -= 1 s += si + A[j]*(N-1-i) j += 1 return s def bsearch(lower, upper): l = lower u = upper m = (l+u)//2 c = combinations(m) if c<M: return bsearch(l, m) else: if l==m: return (l, c-M) return bsearch(m, u) x, dm = bsearch(0, A[-1]*2+1) print(x) print(koufukudo(x)-dm*x)
s526223414
Accepted
1,263
13,972
560
def ints(): return [int(x) for x in input().split()] def ii(): return int(input()) N, M = ints() A = ints() A.sort() A.reverse() def combinations_and_kofukudo(x): c = 0 k = 0 si = 0 i = 0 for j in reversed(range(N)): while i<N and A[i]+A[j]>=x: si += A[i] i += 1 c += i k += si + A[j]*i return (c, k) def bsearch(l, u): m = (l+u)//2 c, k = combinations_and_kofukudo(m) if c<M: return bsearch(l, m) else: if l==m: print(k-(c-M)*l) exit() return bsearch(m, u) bsearch(0, A[0]*2+1)
s226022796
p04029
u667694979
2,000
262,144
Wrong Answer
17
2,940
50
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()) sum=0 for i in range(N): sum+=i+1
s358709753
Accepted
17
2,940
61
N=int(input()) sum=0 for i in range(N): sum+=i+1 print(sum)
s913709009
p03730
u663767599
2,000
262,144
Wrong Answer
17
3,060
314
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 objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
from itertools import count A, B, C = map(int, input().split()) reminders = [] for n in count(start=A // C): r = (n * A - C) % B if r == 0: print("Yes") break else: if r not in reminders: reminders.append(r) else: print("No") break
s966819323
Accepted
18
3,060
314
from itertools import count A, B, C = map(int, input().split()) reminders = [] for n in count(start=A // C): r = (n * A - C) % B if r == 0: print("YES") break else: if r not in reminders: reminders.append(r) else: print("NO") break
s570128704
p03067
u498202416
2,000
1,048,576
Wrong Answer
17
2,940
81
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.
A,B,C = map(int,input().split()) if A < B < C: print("YES") else: print("No")
s595588327
Accepted
17
2,940
94
A,B,C = map(int,input().split()) if A < C < B or B < C < A: print("Yes") else: print("No")
s188226376
p03597
u339922532
2,000
262,144
Wrong Answer
17
2,940
51
We have an N \times N square grid. We will paint each square in the grid either black or white. If we paint exactly A squares white, how many squares will be painted black?
n = int(input()) a = int(input()) print(n * 2 - a)
s214282167
Accepted
17
2,940
52
n = int(input()) a = int(input()) print(n ** 2 - a)
s829742262
p04029
u364027015
2,000
262,144
Wrong Answer
28
8,960
31
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
N=int(input()) print(N*(N+1)/2)
s877423570
Accepted
25
9,144
33
N=int(input()) print(N*(N+1)//2)
s220960085
p03657
u136647933
2,000
262,144
Wrong Answer
18
2,940
129
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: result='Possible' else: result='Impossible' print(result)
s748422394
Accepted
17
2,940
129
a,b= map(int,input().split()) if a%3==0 or b%3==0 or (a+b)%3==0: result='Possible' else: result='Impossible' print(result)
s156780901
p03417
u936985471
2,000
262,144
Wrong Answer
17
2,940
57
There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations.
N,M=map(int,input().split()) print(max(M-2,1)*max(N-2,1))
s733313944
Accepted
17
2,940
53
N,M=map(int,input().split()) print(abs((M-2)*(N-2)))
s160354784
p03501
u357751375
2,000
262,144
Wrong Answer
17
2,940
84
You are parking at a parking lot. You can choose from the following two fee plans: * Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours. * Plan 2: The fee will be B yen, regardless of the duration. Find the minimum fee when you park for N hours.
n,a,b = map(int,input().split()) if n * a >= b: print(n * a) else: print(b)
s934844818
Accepted
17
2,940
85
n,a,b = map(int,input().split()) if n * a <= b: print(n * a) else: print(b)
s247644431
p03693
u568711768
2,000
262,144
Wrong Answer
18
2,940
97
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
A,B,C = list(map(int,input().split())) if 10*B + C % 4 == 0: print("YES") else: print("NO")
s928822304
Accepted
17
2,940
99
A,B,C = list(map(int,input().split())) if (10*B + C) % 4 == 0: print("YES") else: print("NO")
s949163246
p03457
u743383679
2,000
262,144
Wrong Answer
245
9,200
294
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
# coding: utf-8 import math n = int(input()) t = 0 x = 0 y = 0 for i in range(n): ti, xi, yi = list(map(int, input().split())) if xi - x + yi - y > ti - t: print("NO") exit() elif (xi - x + yi - y - (ti - t)) % 2 != 0: print("NO") exit() print("YES")
s916899402
Accepted
252
9,128
486
# coding: utf-8 import math n = int(input()) t = 0 x = 0 y = 0 # txy = [] # ti, xi, yi = list(map(int, input().split())) # txy.append((ti, xi, yi)) for i in range(n): ti, xi, yi = map(int, input().split()) if abs(xi - x) + abs(yi - y) > abs(ti - t): print("No") exit() elif (abs(xi - x) + abs(yi - y) - abs(ti - t)) % 2 != 0: print("No") exit() else: t = ti x = xi y = yi print("Yes")
s530611218
p03469
u806855121
2,000
262,144
Wrong Answer
17
2,940
34
On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in `yyyy/mm/dd` format. For example, January 23, 2018 should be written as `2018/01/23`. After finishing the document, she noticed that she had mistakenly wrote `2017` at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to `2018` and prints it.
S = input() print('2017' + S[4:])
s736314620
Accepted
17
2,940
34
S = input() print('2018' + S[4:])
s850711508
p03644
u417835834
2,000
262,144
Wrong Answer
18
2,940
205
Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times.
n = int(input()) listn = list(range(1,n+1)) def n2(n): counter = 0 while n % 2 == 0: n = n / 2 counter += 1 return counter lists_n2 = list(map(n2, listn)) print(max(lists_n2))
s398385439
Accepted
17
3,060
288
n = int(input()) def n2(n): counter = 0 while n % 2 == 0: n = n / 2 counter += 1 return counter max_resistor = 0 max_n2 = 0 for i in range(1,n+1): i_n2 = n2(i) if max_n2 <= i_n2: max_n2 = i_n2 max_resistor = i print(max_resistor)
s928615015
p03577
u970308980
2,000
262,144
Wrong Answer
17
2,940
26
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`.
s = input() print(s[:-9])
s455411381
Accepted
17
2,940
25
s = input() print(s[:-8])
s655166374
p02613
u652034825
2,000
1,048,576
Wrong Answer
176
16,232
226
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()) s = [input() for i in range(N)] res = { 'AC' : 0, 'TLE' : 0, 'WA' : 0, 'RE' : 0 } for k in s: print(res[k]) res[k] = res[k] + 1 for k, v in res.items(): print(k + ' x ' + str(v))
s924091247
Accepted
146
16,276
208
N = int(input()) s = [input() for i in range(N)] res = { 'AC' : 0, 'WA' : 0, 'TLE' : 0, 'RE' : 0 } for k in s: res[k] = res[k] + 1 for k, v in res.items(): print(k + ' x ' + str(v))
s228846121
p02265
u387437217
1,000
131,072
Wrong Answer
30
7,732
523
Your task is to implement a double linked list. Write a program which performs the following operations: * insert x: insert an element with key x into the front of the list. * delete x: delete the first element which has the key of x from the list. If there is not such element, you need not do anything. * deleteFirst: delete the first element from the list. * deleteLast: delete the last element from the list.
n=int(input()) commands=[input().split() for i in range(n)] print(commands) List=[] def command(list_command): if 'insert' in list_command: List.insert(0,list_command[1]) elif 'delete' in list_command: try: t=List.index(list_command[1]) del List[t] except: pass elif 'deleteFirst' in list_command: del List[0] elif 'deleteLast' in list_command: del List[-1] return True for i in commands: command(i) print(*List)
s176083786
Accepted
4,650
557,404
470
from collections import deque n=int(input()) commands=[input().split() for i in range(n)] List=deque() for list_command in commands: if 'insert' in list_command: List.appendleft(list_command[1]) elif 'delete' in list_command: try: List.remove(list_command[1]) except: pass elif 'deleteFirst' in list_command: List.popleft() elif 'deleteLast' in list_command: List.pop() print(*List)
s004740842
p03944
u870518235
2,000
262,144
Wrong Answer
74
3,440
731
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white. Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i). Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows: * If a_i = 1, he painted the region satisfying x < x_i within the rectangle. * If a_i = 2, he painted the region satisfying x > x_i within the rectangle. * If a_i = 3, he painted the region satisfying y < y_i within the rectangle. * If a_i = 4, he painted the region satisfying y > y_i within the rectangle. Find the area of the white region within the rectangle after he finished painting.
#Beginner 047 B W, H, N = map(int, input().split()) s = [input() for i in range(N)] S = [] for i in range(N): S.append(list(map(int, s[i].split()))) lst = [[1 for i in range(W)] for j in range(H)] print(lst) for i in range(N): if S[i][2] == 1: for j in range(0,S[i][0]): for k in range(H): lst[k][j] = 0 if S[i][2] == 2: for j in range(S[i][0],W): for k in range(H): lst[k][j] = 0 if S[i][2] == 3: for j in range(0,S[i][1]): for k in range(W): lst[j][k] = 0 if S[i][2] == 4: for j in range(S[i][1],H): for k in range(W): lst[j][k] = 0 print(sum(lst,[]).count(1))
s068881798
Accepted
71
3,520
720
#Beginner 047 B W, H, N = map(int, input().split()) s = [input() for i in range(N)] S = [] for i in range(N): S.append(list(map(int, s[i].split()))) lst = [[1 for i in range(W)] for j in range(H)] for i in range(N): if S[i][2] == 1: for j in range(0,S[i][0]): for k in range(H): lst[k][j] = 0 if S[i][2] == 2: for j in range(S[i][0],W): for k in range(H): lst[k][j] = 0 if S[i][2] == 3: for j in range(0,S[i][1]): for k in range(W): lst[j][k] = 0 if S[i][2] == 4: for j in range(S[i][1],H): for k in range(W): lst[j][k] = 0 print(sum(lst,[]).count(1))
s893897059
p02833
u697690147
2,000
1,048,576
Wrong Answer
2,205
9,192
324
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).
n = int(input()) if n % 2 == 0: n5 = 1 y = 10 while n % y == 0: n5 += 1 y = 2*(5**n5) n5 -= 1 c = [n//(2*(5**i)) for i in range(1, n5+1)] cnt = 0 for i in range(n5): if i != n5-1: c[i] -= c[i+1] cnt += c[i]*(i+1) print(cnt) else: print(0)
s410735882
Accepted
28
9,064
274
n = int(input()) if n % 2 == 0: n5 = 1 y = 10 c = [] while y <= n: c.append(n//y) if len(c) > 1: c[-2] -= c[-1] y *= 5 cnt = 0 for i in range(len(c)): cnt += c[i]*(i+1) print(cnt) else: print(0)
s221824058
p03610
u905615376
2,000
262,144
Wrong Answer
29
3,188
143
You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
def getStrangeString(s): res = "" for i in range(len(s)): if i%2 != 0: res += s[i] print(getStrangeString(input()))
s288224374
Accepted
30
3,188
159
def getStrangeString(s): res = "" for i in range(len(s)): if i%2 == 0: res += s[i] return res print(getStrangeString(input()))
s045868642
p02388
u070117804
1,000
131,072
Wrong Answer
20
7,644
55
Write a program which calculates the cube of a given integer x.
x = input("input x: ") x = int(x) x = pow(x,3) print(x)
s822787285
Accepted
30
7,584
26
x=int(input()) print(x**3)
s973066340
p02409
u236295012
1,000
131,072
Wrong Answer
20
7,616
322
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.
house = [[[0 for i in range(10)] for i in range(3)] for i in range(4)] n = int(input()) input_4 = list(map(int,input().split())) for i in range(n): house[input_4[0]-1][input_4[1]-1][input_4[2]-1] = input_4[3] for i in range(4): for j in range(3): print('',''.join(map(str,house[i][j]))) print('#'*20)
s909117450
Accepted
50
7,764
345
house = [[[0 for i in range(10)] for i in range(3)] for i in range(4)] n = int(input()) for i in range(n): input_4 = list(map(int,input().split())) house[input_4[0]-1][input_4[1]-1][input_4[2]-1] += input_4[3] for i in range(4): for j in range(3): print('',' '.join(map(str,house[i][j]))) if i != 3: print('#'*20)
s680702533
p04029
u102930666
2,000
262,144
Wrong Answer
18
3,060
67
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()) i = 0 ans=0 for i in range(N+1): ans += i ans
s447970578
Accepted
18
2,940
74
N = int(input()) i = 0 ans=0 for i in range(N+1): ans += i print(ans)
s150794606
p03251
u224983328
2,000
1,048,576
Wrong Answer
21
3,064
470
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes inclined to put the cities at coordinates y_1, y_2, ..., y_M under its control. If there exists an integer Z that satisfies all of the following three conditions, they will come to an agreement, but otherwise war will break out. * X < Z \leq Y * x_1, x_2, ..., x_N < Z * y_1, y_2, ..., y_M \geq Z Determine if war will break out.
N,M,X,Y = map(int, input().split(" ")) xList = input().split(" ") yList = input().split(" ") for i in range(len(xList)): xList[i] = int(xList[i]) for j in range(len(yList)): yList[j] = int(yList[j]) xList.sort() yList.sort() if yList[0] - 1 >= xList[len(xList) - 1]: index = yList[0] - 1 while index > xList[len(xList) - 1]: if X < index and index <= Y: print("No War") break else: index -= 1 print("War") else: print("War")
s978843471
Accepted
17
3,064
354
N,M,X,Y = map(int, input().split(" ")) xList = input().split(" ") yList = input().split(" ") for i in range(len(xList)): xList[i] = int(xList[i]) for j in range(len(yList)): yList[j] = int(yList[j]) xList.sort() yList.sort() if yList[0] > xList[len(xList) - 1] and yList[0] > X and Y > xList[len(xList) - 1]: print("No War") else: print("War")
s360531200
p02972
u669173971
2,000
1,048,576
Wrong Answer
2,104
7,148
262
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 condition is satisfied: * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2. Does there exist a good set of choices? If the answer is yes, find one good set of choices.
n=int(input()) a=list(map(int, input().split())) b=[] for i in reversed(range(n)): count=0 for j in range(1,n+1): if j%(i+1)==0: count+=a[j-1] if count%2==1: b.append(1) for _ in range(len(b)): print("1")
s907236254
Accepted
626
14,132
296
n=int(input()) a=list(map(int, input().split())) b=[0]*n for i in range(n,0,-1): count=0 for j in range(i,n+1,i): count+=b[j-1] if (count%2)!=a[i-1]: b[i-1]=1 c=[i+1 for i in range(n) if b[i]==1] if len(c)==0: print("0") else: print(len(c)) print(*c)
s197669025
p03599
u198336369
3,000
262,144
Time Limit Exceeded
3,317
298,080
699
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()) con = list() s = list() for x in range(31): for y in range(31): for v in range(1501): if x == y == 0: continue else: w1 = (f-(100*a*x + 100*b*y + c*v))//d w2 = (100*a*x + 100*b*y -c*v)//d w3 = ((100*a*x + 100*b*y)*e -c*v*100)//(100*d) w = min(w1,w2,w3) con1 = 100*(c*v + d*w)/(100*a*x + 100*b*y +c*v +d*w) con.append(con1) s.append([x,y,v,w]) conm = max(con) conin =con.index(conm) t = s[conin] # print(t) ans1 = 100*a*t[0] + 100*b*t[1] + c*t[2] + d*t[3] ans2 = c*t[2] + d*t[3] print(ans1,ans2)
s197555597
Accepted
1,957
9,192
726
a,b,c,d,e,f = map(int, input().split()) s = [0,0,0,0] con1 = 0 for x in range(31): for y in range(31): for v in range(1501): if x == y == 0: continue else: w1 = (f-(100*a*x + 100*b*y + c*v))//d # w2 = (100*a*x + 100*b*y -c*v)//d w3 = ((100*a*x + 100*b*y)*e -c*v*100)//(100*d) w = min(w1,w3) con2 = 100*(c*v + d*w)/(100*a*x + 100*b*y +c*v +d*w) if con1 <= con2 and w >= 0: con1 = con2 s = [x,y,v,w] else: continue ans1 = 100*a*s[0] + 100*b*s[1] + c*s[2] + d*s[3] ans2 = c*s[2] + d*s[3] print(ans1,ans2)
s880624722
p03044
u187516587
2,000
1,048,576
Wrong Answer
485
64,644
479
We have a tree with N vertices numbered 1 to N. The i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i. Your objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied: * For any two vertices painted in the same color, the distance between them is an even number. Find a coloring of the vertices that satisfies the condition and print it. It can be proved that at least one such coloring exists under the constraints of this problem.
import sys def input(): return sys.stdin.readline()[:-1] sys.setrecursionlimit(200000) N=int(input()) s=[[]for i in range(N)] c=[None]*N for i in range(N-1): u,v,w=map(int,input().split()) s[v-1].append(u) s[u-1].append(v) def mu(n,l,co): for i in l: if c[i-1]==None: if co==1: c[i-1]=0 mu(i,s[i-1],0) else: c[i-1]=1 mu(i,s[i-1],1) mu(1,s[0],0) print(*c,sep="\n")
s288101065
Accepted
552
76,464
511
import sys def input(): return sys.stdin.readline()[:-1] sys.setrecursionlimit(200000) N=int(input()) s=[[]for i in range(N)] c=[None]*N for i in range(N-1): u,v,w=map(int,input().split()) s[v-1].append((u,w%2)) s[u-1].append((v,w%2)) def mu(n,l,co): for i in l: if c[i[0]-1]==None: if co==i[1]%2: c[i[0]-1]=0 mu(i,s[i[0]-1],0) else: c[i[0]-1]=1 mu(i,s[i[0]-1],1) mu(1,s[0],0) print(*c,sep="\n")
s893448170
p03494
u298297089
2,000
262,144
Time Limit Exceeded
2,104
3,060
271
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
N = int(input()) x = list([int(i) for i in input().split()]) cnt = 0 while True: flag = False for i in x: if i % 2: flag = True break else: i /= 2 else: cnt += 1 if flag: break print(cnt)
s474595588
Accepted
18
3,060
190
N = int(input()) x = list(map(int, input().split())) mn_lst = [] for i in x: cnt = 0 while i % 2 == 0: cnt += 1 i >>= 1 mn_lst.append(cnt) print(min(mn_lst))
s277483481
p03387
u089032001
2,000
262,144
Wrong Answer
17
3,060
276
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 proved that we can always make A, B and C all equal by repeatedly performing these operations.
A = list(map(int, input().split())) ans = 0 even = 0 odd = 0 for a in A: if(a%2==0): even += 1 for i in range(len(A)): if(A[i]%2==0 and even == 2): A[i] += 1 elif(A[i]%2==1 and even == 1): A[i] += 1 for a in A: ans += (max(A) - a) // 2 print(a)
s658969775
Accepted
18
3,064
322
A = list(map(int, input().split())) even = 0 odd = 0 for a in A: if(a%2==0): even += 1 for i in range(len(A)): if(A[i]%2==0 and even == 2): A[i] += 1 elif(A[i]%2==1 and even == 1): A[i] += 1 if(even == 2 or even == 1): ans = 1 else: ans = 0 for a in A: ans += (max(A) - a) // 2 print(ans)
s080134231
p02257
u909075105
1,000
131,072
Wrong Answer
20
5,592
254
A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. Write a program which reads a list of _N_ integers and prints the number of prime numbers in the list.
n=int(input()) A=[0]*n for m in range(n): A[m]=int(input()) k=0 for i in range(n): for j in range(1,A[n-1]): if j==1: continue if j==(A[n-1]-1): k+=1 if (A[i-1]%j)==0: break print(j)
s694812435
Accepted
2,620
5,996
298
import math as mh a=int(input()) A=[0]*a x=0 for i in range(a): A[i]=int(input()) for j in range(1,A[i]): if A[i]==2: x+=1 continue if j==1: continue elif (A[i]%j)==0: break elif j>=mh.sqrt(A[i]): x+=1 break print(x)
s495463446
p02744
u083960235
2,000
1,048,576
Wrong Answer
39
5,204
1,198
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. For example, `abcac` and `zyxzx` are isomorphic, while `abcac` and `ppppp` are not. A string s is said to be in **normal form** when the following condition is satisfied: * For every string t that is isomorphic to s, s \leq t holds. Here \leq denotes lexicographic comparison. For example, `abcac` is in normal form, but `zyxzx` is not since it is isomorphic to `abcac`, which is lexicographically smaller than `zyxzx`. You are given an integer N. Print all strings of length N that are in normal form, in lexicographically ascending order.
import sys, re, os from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import permutations, combinations, product, accumulate from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_uppercase, digits from fractions import gcd from bisect import bisect, bisect_left, bisect_right def input(): return sys.stdin.readline().strip() def INT(): return int(input()) def MAP(): return map(int, input().split()) def S_MAP(): return map(str, input().split()) def LIST(): return list(map(int, input().split())) def S_LIST(): return list(map(str, input().split())) sys.setrecursionlimit(10 ** 9) INF = float('inf') mod = 10 ** 9 + 7 l = 'abcdefghijklmnopqrstuvwxyz' N = INT() # ans = (N-1) * "a" + # p1 = "a" * N q = ["a"] # while q: a = "a" k = [n for n in l[:N]] # print(k) kazu = [] for i in range(1, N): y = k[:i] u = k[:i+1] B = list(product(y, u)) for b in B: # for c in b: kazu.append("".join(b)) kazu.sort() print(*kazu, sep="\n")
s265431192
Accepted
173
5,156
976
import sys, re, os from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import permutations, combinations, product, accumulate from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_uppercase, digits def input(): return sys.stdin.readline().strip() def INT(): return int(input()) def MAP(): return map(int, input().split()) def S_MAP(): return map(str, input().split()) def LIST(): return list(map(int, input().split())) def S_LIST(): return list(map(str, input().split())) sys.setrecursionlimit(10 ** 9) INF = float('inf') mod = 10 ** 9 + 7 N = INT() S = "abcdefghijk" ans = 0 def dfs(a, mx): # while q: if len(a) == N: print(a) return for c in range(len(S[:mx+2])): t = a t += S[:mx+2][c] dfs(t, max(c, mx)) dfs("", -1)
s655254860
p03251
u155236040
2,000
1,048,576
Wrong Answer
18
3,060
220
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes inclined to put the cities at coordinates y_1, y_2, ..., y_M under its control. If there exists an integer Z that satisfies all of the following three conditions, they will come to an agreement, but otherwise war will break out. * X < Z \leq Y * x_1, x_2, ..., x_N < Z * y_1, y_2, ..., y_M \geq Z Determine if war will break out.
n,m,x,y = map(int,input().split()) x_list = sorted(list(map(int,input().split()))) y_list = sorted(list(map(int,input().split()))) if x < y and x < y_list[0] and x_list[-1] < y: print('No war') else: print('War')
s095657223
Accepted
17
2,940
222
n,m,x,y = map(int,input().split()) x_list = list(map(int,input().split())) y_list = list(map(int,input().split())) x_list.append(x) y_list.append(y) if max(x_list) < min(y_list): print('No War') else: print('War')
s386477503
p03962
u733774002
2,000
262,144
Wrong Answer
18
2,940
150
AtCoDeer the deer recently bought three paint cans. The color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c. Here, the color of each paint can is represented by an integer between 1 and 100, inclusive. Since he is forgetful, he might have bought more than one paint can in the same color. Count the number of different kinds of colors of these paint cans and tell him.
a, b, c = map(int, input().split()) if a == b and b == c: print(1) elif (a != b and b == c) or (a == b or b != c): print(2) else: print(3)
s630843722
Accepted
17
3,060
174
a, b, c = map(int, input().split()) if a == b and b == c: print(1) elif (a != b and b == c) or (a == b and b != c) or (a == c and a != b): print(2) else: print(3)
s205903715
p03712
u079022116
2,000
262,144
Wrong Answer
17
3,060
138
You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}. Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1.
h,w = map(int,input().split()) a = [input() for i in range(h)] print(a) print('#'*(w+2)) for i in a: print('#'+i+'#') print('#'*(w+2))
s074230968
Accepted
17
3,060
129
h,w = map(int,input().split()) a = [input() for i in range(h)] print('#'*(w+2)) for i in a: print('#'+i+'#') print('#'*(w+2))
s260538281
p03713
u940102677
2,000
262,144
Wrong Answer
17
3,060
167
There is a bar of chocolate with a height of H blocks and a width of W blocks. Snuke is dividing this bar into exactly three pieces. He can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle. Snuke is trying to divide the bar as evenly as possible. More specifically, he is trying to minimize S_{max} \- S_{min}, where S_{max} is the area (the number of blocks contained) of the largest piece, and S_{min} is the area of the smallest piece. Find the minimum possible value of S_{max} - S_{min}.
h,w = map(int, input().split()) s = [h//2+w//3+1, h//1+w//2+1] if h%3 == 0 and w%3 == 0: s += [0] if h%2 == 0: s += [h//2] if w%2 == 0: s += [w//2] print(min(s))
s118707537
Accepted
17
3,064
172
h,w = map(int, input().split()) s = [h//2+w//3+1, h//3+w//2+1, h, w] if h%3 == 0 or w%3 == 0: s += [0] if h%2 == 0: s += [h//2] if w%2 == 0: s += [w//2] print(min(s))
s278486458
p02612
u440478998
2,000
1,048,576
Wrong Answer
31
9,152
55
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
import math n = int(input()) math.ceil(n/1000)*1000 - n
s240191319
Accepted
31
9,148
62
import math n = int(input()) print(math.ceil(n/1000)*1000 - n)
s830145981
p03380
u281303342
2,000
262,144
Wrong Answer
350
14,060
214
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.
N = int(input()) A = list(map(int,input().split())) maxA = max(A) half = maxA/2 t = 100000009 for i in range(N): print("i",i,"t",t,"Ai",A[i],) if abs(A[i]-half) < abs(t-half): t = A[i] print(maxA,t)
s471397781
Accepted
92
14,040
688
# Python3 (3.4.3) import sys input = sys.stdin.readline # ------------------------------------------------------------- # function # ------------------------------------------------------------- # ------------------------------------------------------------- # main # ------------------------------------------------------------- N = int(input()) A = list(map(int,input().split())) maxA = max(A) half = maxA/2 t = 10**10 for i in range(N): if A[i] != maxA and abs(A[i]-half) < abs(t-half): t = A[i] print(maxA,t)
s369222265
p04044
u679089074
2,000
262,144
Wrong Answer
23
9,168
144
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()) wordlist = [] for i in range(N): x = input() wordlist.append(x) print(sorted(wordlist))
s523473675
Accepted
22
9,076
169
N,L = map(int,input().split()) wordlist = [] for i in range(N): x = input() wordlist.append(x) answer = "".join(sorted(wordlist)) print(answer)
s374996003
p02612
u293326264
2,000
1,048,576
Wrong Answer
29
9,140
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%1000)
s962488845
Accepted
30
9,152
89
n = int(input()) if n % 1000 == 0: print(n % 1000) else: print(1000 - (n % 1000))
s973295245
p03730
u651803486
2,000
262,144
Wrong Answer
17
2,940
134
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 objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
a, b, c = map(int, input().split()) for i in range(a, a*b+1, a): if i % b == c: print('Yes') exit() print('No')
s935402124
Accepted
18
2,940
134
a, b, c = map(int, input().split()) for i in range(a, a*b+1, a): if i % b == c: print('YES') exit() print('NO')
s823291725
p03854
u344959886
2,000
262,144
Wrong Answer
17
2,940
150
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="dreamerer" s=s.replace('eraser','').replace('erase','').replace('dreamer','').replace('dream','') if len(s)==0:print("YES") else:print("NO")
s971670437
Accepted
19
3,188
168
s=input() s=s.replace('eraser','0').replace('erase','0').replace('dreamer','0').replace('dream','0') s=s.replace('0','') if len(s)==0:print("YES") else:print("NO")
s863451872
p02613
u569776981
2,000
1,048,576
Wrong Answer
147
9,212
307
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()) a = 0 w = 0 t = 0 r = 0 for i in range(N): i = input() if i == 'AC': a += 1 elif i == 'WA': w += 1 elif i == 'TLE': t += 1 else: r += 1 print('AC × ' + str(a)) print('WA × ' + str(w)) print('TLE × ' + str(t)) print('RE × ' + str(r))
s794050779
Accepted
142
9,168
301
N = int(input()) a, w, t, r = 0, 0, 0, 0 for _ in range(N): S = input() if S == 'AC': a += 1 elif S == 'WA': w += 1 elif S == 'TLE': t += 1 else: r += 1 print('AC x ' + str(a)) print('WA x ' + str(w)) print('TLE x ' + str(t)) print('RE x ' + str(r))
s418244296
p03155
u106181248
2,000
1,048,576
Wrong Answer
17
2,940
85
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 to put the notice so that it completely covers exactly HW squares?
n = int(input()) a = int(input()) b = int(input()) ans = (n-a+1)+(n-b+1) print(ans)
s269123860
Accepted
17
2,940
85
n = int(input()) a = int(input()) b = int(input()) ans = (n-a+1)*(n-b+1) print(ans)
s437806201
p02646
u537905693
2,000
1,048,576
Wrong Answer
20
9,124
352
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 her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
#!/usr/bin/env python # coding: utf-8 def ri(): return int(input()) def rl(): return list(input().split()) def rli(): return list(map(int, input().split())) def main(): a, v = rli() b, w = rli() t = ri() if t*(v-w) >= abs(a-b): print("Yes") else: print("No") if __name__ == '__main__': main()
s091382696
Accepted
23
9,180
352
#!/usr/bin/env python # coding: utf-8 def ri(): return int(input()) def rl(): return list(input().split()) def rli(): return list(map(int, input().split())) def main(): a, v = rli() b, w = rli() t = ri() if t*(v-w) >= abs(a-b): print("YES") else: print("NO") if __name__ == '__main__': main()
s048045066
p04029
u141419468
2,000
262,144
Wrong Answer
17
2,940
70
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()) P = 0 for i in range(1,n): P += i print(P)
s179605605
Accepted
17
2,940
72
n = int(input()) P = 0 for i in range(1,n+1): P += i print(P)
s522303271
p04043
u770035520
2,000
262,144
Wrong Answer
17
2,940
141
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.
def Haiku(check,syllables): check.sort() syllables.sort() if check==syllables: return "YES" else: return "NO"
s114783954
Accepted
17
2,940
152
syllables=[5,5,7] check=list(map(int,input().split())) check.sort() syllables.sort() if check==syllables: print("YES") else: print("NO")
s612969625
p03408
u386089355
2,000
262,144
Wrong Answer
20
3,064
382
Takahashi has N blue cards and M red cards. A string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i. Takahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen. Here, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces `atcoder`, he will not earn money even if there are blue cards with `atcoderr`, `atcode`, `btcoder`, and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.) At most how much can he earn on balance? Note that the same string may be written on multiple cards.
n = int(input()) ls_s = [input() for _ in range(n)] m = int(input()) ls_t = [input() for _ in range(m)] ls_u =ls_s + ls_t p = m + n ans = 0 for i in range(n): cnt = 0 for j in range(p): if ls_u[i] == ls_u[j] and j < n - 1: cnt += 1 elif ls_u[i] == ls_u[j] and n - 1 <= j: cnt += -1 if cnt >= ans: ans = cnt print(ans)
s028907843
Accepted
21
3,188
383
n = int(input()) ls_s = [input() for _ in range(n)] m = int(input()) ls_t = [input() for _ in range(m)] ls_u =ls_s + ls_t p = m + n ans = 0 for i in range(n): cnt = 0 for j in range(p): if ls_u[i] == ls_u[j] and j <= n - 1: cnt += 1 elif ls_u[i] == ls_u[j] and n - 1 < j: cnt += -1 if cnt >= ans: ans = cnt print(ans)
s047309008
p02612
u225463683
2,000
1,048,576
Wrong Answer
27
9,140
33
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
d = int(input()) print(d % 1000)
s692611149
Accepted
25
9,112
81
d = int(input()) if d % 1000 == 0: print(0) else: print(1000 - d % 1000)
s223062187
p03378
u687044304
2,000
262,144
Wrong Answer
17
2,940
215
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 cost of 1. It is guaranteed that there is no toll gate in Square 0, Square X and Square N. Find the minimum cost incurred before reaching the goal.
# -*- coding:utf-8 -*- if __name__ == "__main__": N, M, X = list(map(int, input().split())) As = list(map(int, input().split())) cost = 0 for A in As: if X > A: break cost += 1 print(max(cost, M-cost))
s728720585
Accepted
17
2,940
215
# -*- coding:utf-8 -*- if __name__ == "__main__": N, M, X = list(map(int, input().split())) As = list(map(int, input().split())) cost = 0 for A in As: if A > X: break cost += 1 print(min(cost, M-cost))
s223874815
p03455
u933622697
2,000
262,144
Wrong Answer
17
2,940
85
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
a, b = map(int, input().split()) if a*b % 2: print('Even') else: print('Odd')
s618940390
Accepted
17
2,940
174
a, b = map(int, input().split()) if (a*b) % 2: print('Odd') else: print('Even')
s147536993
p02694
u244737745
2,000
1,048,576
Wrong Answer
26
9,168
131
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?
#2020-05-02 import math a = int(input()) may = 100 ans = 0 while may <= a: may = math.floor(may * 1.01) ans += 1 print(ans)
s745275534
Accepted
21
9,168
118
import math may = 100 a = int(input()) ans = 0 while a > may: may = math.floor(may * 1.01) ans += 1 print(ans)
s432543346
p03081
u261646994
2,000
1,048,576
Wrong Answer
1,006
6,804
1,141
There are N squares numbered 1 to N from left to right. Each square has a character written on it, and Square i has a letter s_i. Besides, there is initially one golem on each square. Snuke cast Q spells to move the golems. The i-th spell consisted of two characters t_i and d_i, where d_i is `L` or `R`. When Snuke cast this spell, for each square with the character t_i, all golems on that square moved to the square adjacent to the left if d_i is `L`, and moved to the square adjacent to the right if d_i is `R`. However, when a golem tried to move left from Square 1 or move right from Square N, it disappeared. Find the number of golems remaining after Snuke cast the Q spells.
import re N, Q = [int(item) for item in re.split(r"\s", input())] s = input() t = [] d = [] for _ in range(Q): t_in, d_in = [item for item in re.split(r"\s", input())] t.append(t_in) d.append(d_in) l_most = -1 r_most = N for q in range(Q-1, -1, -1): # find last s[0], L if t[q] == s[0] and d[q] == "L": l_most = 0 for i in range(q-1, -1, -1): # look_l = l_most-1 look_r = l_most+1 # if look_l >= 0 and s[look_l] == t[i] and d[i] == "R": # l_most = look_l if look_r <= N-1 and s[look_r] == t[i] and d[i] == "L": l_most = look_r break for q in range(Q-1, -1, -1): # find last s[N-1], R if t[q] == s[N-1] and d[q] == "R": r_most = N-1 for i in range(q-1, -1, -1): look_l = r_most-1 # look_r = l_most+1 if look_l >= 0 and s[look_l] == t[i] and d[i] == "R": r_most = look_l # elif look_r <= N-1 and s[look_r] == t[i] and d[i] == "L": # r_most = look_r break print(l_most, r_most) print(r_most-l_most-1)
s792349691
Accepted
1,963
41,296
997
N, Q = map(int, input().split()) s = input() TD = [input().split() for i in range(Q)] def check(i): if i == -1: return -1 if i == N: return 1 for q in range(Q): t, d = TD[q] if t == s[i]: if d == "L": i -= 1 else: i += 1 if i == -1: return -1 if i == N: return 1 return 0 s_index = -1 # include e_index = N # include while s_index+1 < e_index: c_index = (s_index+e_index)//2 if check(c_index) == -1: s_index = c_index else: e_index = c_index left = s_index s_index = -1 # include e_index = N # include while s_index+1 < e_index: c_index = (s_index+e_index)//2 if check(c_index) == 1: e_index = c_index else: s_index = c_index right = e_index print(right-left-1)
s227930009
p03371
u761989513
2,000
262,144
Wrong Answer
17
3,064
271
"Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.
a, b, c, x, y = map(int, input().split()) ans = 0 if a > 2 * c and b > 2 * c: ans += max(x, y) * 2 * c else: if a + b > 2 * c: n = min(x, y) ans += n * 2 * c x -= n y -= n print(ans) ans += a * x ans += b * y print(ans)
s230604586
Accepted
17
2,940
189
a, b, c, x, y = map(int, input().split()) if x > y: print(min(a * x + b * y, a * (x - y) + 2 * c * y, 2 * c * x)) else: print(min(a * x + b * y, b * (y - x) + 2 * c * x, 2 * c * y))
s726698591
p02613
u161693347
2,000
1,048,576
Wrong Answer
80
17,264
1,093
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 sys, re, os from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import permutations, combinations, product, accumulate from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_uppercase, digits from functools import reduce from bisect import bisect_left, insort_left from heapq import heapify, heappush, heappop INPUT = lambda: sys.stdin.readline().rstrip() INT = lambda: int(INPUT()) MAP = lambda: map(int, INPUT().split()) S_MAP = lambda: map(str, INPUT().split()) LIST = lambda: list(map(int, INPUT().split())) S_LIST = lambda: list(map(str, INPUT().split())) ZIP = lambda: zip(*(MAP() for _ in range(n))) sys.setrecursionlimit(10 ** 9) INF = float('inf') mod = 10 ** 9 + 7 def main(): N = INT() S = [INPUT() for _ in range(N)] c = Counter(S) print(c) print("AC x " + str(c['AC'])) print("WA x " + str(c['WA'])) print("TLE x " + str(c['TLE'])) print("RE x " + str(c['RE'])) if __name__ == '__main__': main()
s275547664
Accepted
73
17,256
1,080
import sys, re, os from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import permutations, combinations, product, accumulate from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_uppercase, digits from functools import reduce from bisect import bisect_left, insort_left from heapq import heapify, heappush, heappop INPUT = lambda: sys.stdin.readline().rstrip() INT = lambda: int(INPUT()) MAP = lambda: map(int, INPUT().split()) S_MAP = lambda: map(str, INPUT().split()) LIST = lambda: list(map(int, INPUT().split())) S_LIST = lambda: list(map(str, INPUT().split())) ZIP = lambda: zip(*(MAP() for _ in range(n))) sys.setrecursionlimit(10 ** 9) INF = float('inf') mod = 10 ** 9 + 7 def main(): N = INT() S = [INPUT() for _ in range(N)] c = Counter(S) print("AC x " + str(c['AC'])) print("WA x " + str(c['WA'])) print("TLE x " + str(c['TLE'])) print("RE x " + str(c['RE'])) if __name__ == '__main__': main()
s777848483
p02402
u539789745
1,000
131,072
Wrong Answer
20
5,588
136
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.
def main(): nums = list(map(int, input().split())) print(min(nums), max(nums), sum(nums)) if __name__ == "__main__": main()
s159466830
Accepted
20
6,552
152
def main(): n = input() nums = list(map(int, input().split())) print(min(nums), max(nums), sum(nums)) if __name__ == "__main__": main()
s103156964
p02744
u952467214
2,000
1,048,576
Wrong Answer
19
2,940
262
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. For example, `abcac` and `zyxzx` are isomorphic, while `abcac` and `ppppp` are not. A string s is said to be in **normal form** when the following condition is satisfied: * For every string t that is isomorphic to s, s \leq t holds. Here \leq denotes lexicographic comparison. For example, `abcac` is in normal form, but `zyxzx` is not since it is isomorphic to `abcac`, which is lexicographically smaller than `zyxzx`. You are given an integer N. Print all strings of length N that are in normal form, in lexicographically ascending order.
import sys sys.setrecursionlimit(10 ** 7) n = int(input()) def rec(before, depth): if depth == n: return before+1 else: ret = 0 for i in range(before+1): ret += rec(i+1, depth+1) return ret print(rec(0,1))
s557129886
Accepted
241
22,904
468
import sys sys.setrecursionlimit(10 ** 7) from functools import lru_cache n = int(input()) ans = [] if n == 1: print('a') exit() @lru_cache(None) def rec(before, depth, MAX): for i in range(MAX-ord('a') +2): tmp = before + chr(ord('a') + i) if len(tmp) >= n: ans.append(tmp) else: MAX = max(MAX, ord(tmp[-1]) ) rec(tmp, depth+1, MAX) rec('a',1, ord('a')) ans.sort() print(*ans, sep ='\n')
s503000677
p03170
u703474183
2,000
1,048,576
Wrong Answer
1,851
9,924
243
There is a set A = \\{ a_1, a_2, \ldots, a_N \\} consisting of N positive integers. Taro and Jiro will play the following game against each other. Initially, we have a pile consisting of K stones. The two players perform the following operation alternately, starting from Taro: * Choose an element x in A, and remove exactly x stones from the pile. A player loses when he becomes unable to play. Assuming that both players play optimally, determine the winner.
N, K = map(int,input().split()) A = list(map(int,input().split())) dp = [None for _ in range(K+1)] dp[0] = 0 for k in range(1,K+1): for a in A: if k-a>=0: if dp[k-a]==0: dp[k]=1 if dp[K]==1: print('First') else: print('Second')
s790609151
Accepted
1,442
9,920
246
N, K = list(map(int,input().split())) A = list(map(int,input().split())) dp = [0 for _ in range(K+1)] dp[0] = 0 for k in range(1,K+1): for a in A: if k-a>=0: if dp[k-a]==0: dp[k]=1 if dp[K]==1: print('First') else: print('Second')
s737554710
p03711
u676264453
2,000
262,144
Wrong Answer
18
3,192
1,661
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.
import math import sys T = list(map(int, input().split())) S = T[0] * T[1] if ((T[0] % 3 == 0) or (T[1] % 3 == 0)): print(0) sys.exit() minS = 100000000000 for i in range(1, math.ceil(T[0]/2)): A = i * T[1] F = math.floor(T[1] / 2) * (T[0] - i) C = S - (A + F) if (F == C): minS = min(minS, abs(A - F)) continue else: if (A > C): minS = min(minS, abs(A - F)) elif(C >= A and A >= F): minS = min(minS, abs(C - F)) else: minS = min(minS, abs(C - A)) A = i * T[0] F = math.floor(T[0] / 2) * (T[1] - i) C = S - (A + F) if (F == C): minS = min(minS, abs(A - F)) continue else: if (A > C): minS = min(minS, abs(A - F)) elif(C >= A and A >= F): minS = min(minS, abs(C - F)) else: minS = min(minS, abs(C - A)) for i in range(1, math.ceil(T[1]/2)): A = i * T[1] F = math.floor(T[1] / 2) * (T[0] - i) C = S - (A + F) if (F == C): minS = min(minS, abs(A - F)) continue else: if (A > C): minS = min(minS, abs(A - F)) elif(C >= A and A >= F): minS = min(minS, abs(C - F)) else: minS = min(minS, abs(C - A)) A = i * T[0] F = math.floor(T[0] / 2) * (T[1] - i) C = S - (A + F) if (F == C): minS = min(minS, abs(A - F)) continue else: if (A > C): minS = min(minS, abs(A - F)) elif(C >= A and A >= F): minS = min(minS, abs(C - F)) else: minS = min(minS, abs(C - A)) print(minS)
s735467510
Accepted
19
3,188
211
x,y = list(map(int, input().split())) a = set([2]) b = set([4,6,9,11]) c = set([1,3,5,7,8,10,12]) if (x in a and y in a) or (x in b and y in b) or (x in c and y in c): print('Yes') else: print('No')
s967040949
p03377
u811967730
2,000
262,144
Wrong Answer
17
2,940
112
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
A, B, X = map(int, input().split()) if X >= A and X <= A + B: ans = "Yes" else: ans = "No" print(ans)
s904098849
Accepted
17
2,940
112
A, B, X = map(int, input().split()) if X >= A and X <= A + B: ans = "YES" else: ans = "NO" print(ans)
s592324941
p02842
u847165882
2,000
1,048,576
Wrong Answer
18
3,060
185
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()) Len=int(N-N*0.1) Ans=[] for i in range(Len,N): j=i*1.08 if int(j)==N: Ans.append(int(j)) if len(Ans)!=0: print(Ans[0]) else: print(":(")
s873302917
Accepted
32
2,940
161
N=int(input()) Ans=[] for i in range(N+1): j=i*1.08 if int(j)==N: Ans.append(i) if len(Ans)!=0: print(Ans[0]) else: print(":(")