problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02705
s812692121
Accepted
import math R = int(input()) L = math.pi*2*R print(L)
p03475
s899455292
Accepted
n = int(input()) table = [] for i in range(n-1): c , s , f = map(int,input().split()) table.append([c,s,f]) for i in range(n): time = 0 for j in range(i,n-1): if time < table[j][1]: time = table[j][1] elif time > table[j][1]: if time % table[j][2] != 0: time += table[j][2] -(time%table[j][2]) time += table[j][0] print(time)
p03624
s128698958
Accepted
import sys readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines read = sys.stdin.buffer.read sys.setrecursionlimit(10 ** 7) INF = float('inf') S = input() set_ = set(S) for c in [chr(i) for i in range(97, 97+26)]: if c not in set_: print(c) quit() print('None')
p02777
s569091718
Wrong Answer
n, m = map(str, input().split()) a, b = map(int, input().split()) u = str(input()) if n==u: a=a-1 if m==u: b=b-1 print(n,m) print(a,b) print(u)
p03284
s615027619
Accepted
N, K = map(int, input().split()) if N % K == 0: print(0) else: print(1)
p02717
s476712270
Accepted
x, y, z = map(int, input().split()) print(z, x, y)
p03785
s209166668
Accepted
N, C, K = [int(x) for x in input().split()] T = [int(input()) for _ in range(N)] T.sort() depart = T[0] + K # 出発時刻 passenger = 0 # 乗客数 bus = 1 for i in range(N): if passenger >= C or depart < T[i]: # すでに満員または待ち時間オーバー bus += 1 passenger = 1 depart = T[i] + K else: passenger += 1 print(bus)
p03862
s432438156
Accepted
n, x = map(int, input().split()) a = list(map(int, input().split()))+[0] ans = 0 for i in range(n): if a[i+1] + a[i] <= x: continue else: ans += (a[i+1] + a[i] - x) a[i+1] = max(0, x - a[i]) # print(ans) # print(a) print(ans)
p02759
s960590150
Accepted
N = int(input()) ans = (N + 1) // 2 print(ans)
p03086
s043610813
Accepted
S = str(input()) chrs = ('A', 'C', 'G', 'T') max_len = 0 this_len = 0 for s in S: if s in chrs: this_len += 1 else: this_len = 0 max_len = max(this_len, max_len) print(max_len)
p03017
s260927224
Accepted
import sys #input = sys.stdin.buffer.readline def main(): N,A,B,C,D = map(int,input().split()) s = str(input()) if "##" in s[A:max(C,D)]: print("No") elif (C > D and "..." not in s[B-2:D+1]): print("No") else: print("Yes") if __name__ == "__main__": main()
p02702
s658323208
Wrong Answer
S = input() S = S[::-1] leng = len(S) S = int(S) count = [0] * 2019 count[0] = 1 for i in range(leng): remainder = (S // (10**i)) % 2019 print(S//(10**i), remainder) count[remainder] += 1 res = 0 for cnt in count: res += cnt * (cnt - 1) // 2 print(res)
p03543
s346887421
Accepted
n = input() if n[0] == n[1] == n[2] or n[1]==n[2]==n[3]: print("Yes") else: print("No")
p02595
s883025496
Wrong Answer
from math import sqrt def main(): n, d = map(int, input().split()) xy = [list(map(int, input().split())) for _ in range(n)] print(n, d) print(xy) cnt = 0 for x, y in xy: xy_d = sqrt(x**2 + y**2) if xy_d <= d: cnt +=1 print(cnt) if __name__ == '__main__': main()
p04012
s005036129
Accepted
import collections w = list(input()) w = collections.Counter(w).values() ans = all(x%2 == 0 for x in w) print("Yes" if ans else "No")
p02994
s281155297
Wrong Answer
N, L = map(int, input().split()) # 元々の味: s s = (N-1)*(2*L+N-1) // 2 l = [abs(L+i) for i in range(N)] print(s - (L+l.index(min(l))))
p03319
s431463263
Accepted
n, k = map(int, input().split()) a = list(map(int, input().split())) print(-(-(n-1)//(k-1)))
p02631
s049961832
Accepted
n=int(input()) a=list(map(int,input().split())) ans=[] p=0 for i in range(n): p=p^a[i] for i in range(n): k=p^a[i] ans.append(k) print(*ans)
p02675
s607072005
Wrong Answer
##A N = str(input()) if N[-1] == '3': print('bon') elif N[-1] == '0' or '1' or '6' or '8': print('pon') else: print('hon')
p03796
s219101509
Accepted
import math N = int(input()) print(math.factorial(N)%(10**9+7))
p02646
s190983489
Wrong Answer
a, v = map(int,input().split()) b, w = map(int,input().split()) t = int(input()) if a + v*t >= b + w*t : print("YES") else: print("NO")
p04043
s252795119
Accepted
def main(): x = sorted(list(map(int, input().split()))) print('YES' if x == [5, 5, 7] else 'NO') if __name__ == '__main__': main()
p03011
s253423909
Accepted
import sys *t, = map(int, sys.stdin.readline().split()) def main(): ans = sum(t) - max(t) print(ans) if __name__ == '__main__': main()
p02633
s363923353
Accepted
a = int(input()) x = a k = 1 while a != 360: a = a + x if a > 360 : a = a - 360 k = k + 1 print(k)
p02860
s807064336
Accepted
N = int(input()) S = input() A = S[:N//2] B = S[N//2:] if A==B: print("Yes") else: print("No")
p02951
s529557577
Accepted
import sys def input(): return sys.stdin.readline().rstrip() def main(): A,B,C =map(int,input().split()) print(max(0,C-A+B)) if __name__ == "__main__": main()
p03760
s524083743
Wrong Answer
O = input() E = input() ans = "" for i in range(len(E)): ans+=O[i] ans+=E[i] if len(O)%2==1: ans+=O[len(O)-1] print(ans)
p03475
s700305714
Accepted
n = int(input()) li = [list(map(int,input().split())) for i in range(n-1)] #csf for i in range(n-1): t = li[i][1] + li[i][0] for j in range(i+1,n-1): while True: if t >= li[j][1] and t%li[j][2] == 0: break else: t += 1 t += li[j][0] print(t) print(0)
p02699
s787633506
Accepted
s, w = map(int, input().split()) print("unsafe" if w >= s else "safe")
p02987
s079714864
Accepted
print ("YNeos"[len(''.join(set(sorted(input()))))!=2::2])
p03854
s007978704
Accepted
import re s = input() flag = re.match('^(dream|dreamer|erase|eraser)+$',s) if flag: print('YES') else: print('NO')
p04033
s157446919
Wrong Answer
a,b= list(map(int,input().split())) if 0 < a: print("Positive") elif b < 0: if abs(b-a) % 2 == 0: print("Negative") else: print("Positive") else: print("zero")
p03000
s740563906
Wrong Answer
n, x = map(int, input().split()) l = list(map(int, input().split())) d = 0 count = 0 i = 1 while d <= x and i <= n: d = d + l[i - 1] count += 1 i += 1 print(count)
p03037
s426443769
Wrong Answer
n, m = (int(x) for x in input().split()) l, r = (int(x) for x in input().split()) sss = set(range(l, r + 1)) for i in range(m-1): l, r = (int(x) for x in input().split()) sss &= set(range(l, r)) print(len(sss))
p03633
s365718218
Accepted
import fractions #昔はfractions n = int(input()) a = int(input()) for i in range(n-1): b = int(input()) f=fractions.gcd(a,b) a=a*b//f print(a)
p02836
s820905599
Accepted
#147_B s = input() ans = 0 for i in range(0, len(s)//2): if s[i] != s[-i-1]: ans += 1 print(ans)
p03067
s120748124
Wrong Answer
A, B, C = map(int, input().split()) if A < C < B: print('Yes') else: print('No')
p03997
s888877992
Wrong Answer
a = int(input()) b = int(input()) h = int(input()) S = (a+b)*h/2
p02663
s039723148
Accepted
h1, m1, h2, m2, k = map(int, input().split()) a = (h2 - h1) * 60 + (m2 - m1) print(a - k)
p02860
s237155298
Accepted
def main(): import sys readline = sys.stdin.buffer.readline n = int(readline()) s = readline().rstrip().decode('utf-8') print('Yes' if s[:n//2] == s[n//2:] else 'No') if __name__ == '__main__': main()
p03795
s823195998
Accepted
n = int(input()) print(n*800 - (n//15)*200)
p02873
s273663010
Accepted
S = input() ans = [0] * (len(S) + 1) for i in range(len(S)): if S[i] == '<': ans[i + 1] = ans[i] + 1 for i in range(len(S) - 1, -1, -1): if S[i] == '>': ans[i] = max(ans[i], ans[i + 1] + 1) print(sum(ans))
p04011
s748569843
Accepted
N = int(input()) K = int(input()) X = int(input()) Y = int(input()) print(min(K, N) * X + max(N-K, 0) * Y)
p03013
s523859958
Wrong Answer
from math import factorial
p04019
s272768840
Accepted
S = input() n = 0 w = 0 s = 0 e = 0 for si in S: if si == 'N': n += 1 elif si == 'W': w += 1 elif si == 'S': s += 1 else: e += 1 ans = False if (n and s) or (not n and not s): if (w and e) or (not w and not e): ans = True if ans: print('Yes') else: print('No')
p03319
s794491446
Accepted
N, K = map(int, input().split()) print((N - 1) // (K - 1) + int((N - 1) % (K - 1) != 0))
p03645
s003557440
Accepted
import sys n, m = map(int, input().split()) p = [list(map(int, input().split())) for _ in range(m)] ln1 = [] ln2 = [] for i in p: if i[0] == 1: ln1.append(i[1]) for j in p: if j[1] == n: ln2.append(j[0]) if len(set(ln1) & set(ln2)) == 0: print('IMPOSSIBLE') else: print('POSSIBLE')
p02836
s370342255
Accepted
s = input() ans = 0 rs = s[::-1] for i in range(len(s)): if s[i] != rs[i]: ans += 1 print(ans//2)
p04044
s899859092
Accepted
N,L=map(int,input().split()) S=[] for i in range(N): S.append(str(input())) print("".join(sorted(S)))
p03416
s568539105
Accepted
a, b=map(int, input().split()) ans=0 for num in range(a, b+1): num=str(num) if num[0]==num[-1] and num[1]==num[-2]: ans+=1 print(ans)
p03328
s196115038
Accepted
import bisect import cmath import heapq import itertools import math import operator import os import random import re import string import sys from collections import Counter, deque, defaultdict from copy import deepcopy from decimal import Decimal from fractions import gcd from functools import lru_cache, reduce from operator import itemgetter, mul, add, xor import numpy as np if os.getenv("LOCAL"): sys.stdin = open("_in.txt", "r") sys.setrecursionlimit(10 ** 9) INF = float("inf") IINF = 10 ** 18 MOD = 10 ** 9 + 7 # MOD = 998244353 a, b = list(map(int, sys.stdin.buffer.readline().split())) s = 0 for i in range(b - a): s += i ans = s - a print(ans)
p04012
s360110785
Accepted
import collections def main(): w = list(input()) ans = "Yes" for c, freq in collections.Counter(w).items(): if freq % 2 == 1: ans = "No" break print(ans) if __name__ == '__main__': main()
p03487
s958736315
Accepted
import sys from collections import Counter input = lambda: sys.stdin.readline().rstrip() def main(): n = int(input()) a = Counter(list(map(int, input().split()))) ans = 0; for k, v in a.items(): if k < v: ans += v - k elif k > v: ans += v print(ans) if __name__ == '__main__': main()
p03693
s654987972
Accepted
import sys readline = sys.stdin.readline MOD = 10 ** 9 + 7 INF = float('INF') sys.setrecursionlimit(10 ** 5) def main(): a, b, c = input().split() x = int(a + b + c) if x % 4 == 0: print("YES") else: print("NO") if __name__ == '__main__': main()
p03309
s405803612
Accepted
n = int(input()) a = list(map(int , input().split())) b = [a[i] - (i+1) for i in range(n)] b.sort() idx= n//2 bi = b[idx] ans = 0 for i in range(n): ans += abs(a[i] - (i + 1 + bi)) print(ans)
p03962
s623436006
Accepted
inp=list(map(int,input().split())) l = [0] * 100 for i in inp: l[i-1]+=1 if 2 in l: print(2) elif 3 in l: print(1) else: print(3)
p03745
s857211320
Wrong Answer
#!/usr/bin/env python3 n = int(input()) a = list(map(int, input().split())) d = [0 for _ in range(n-1)] for i in range(n-1): d[i] = a[i+1]-a[i] ans = 0 flg = False for i in range(n-1): if i == 0 or flg == True: flg = False continue else: if d[i]*d[i-1] < 0: ans += 1 flg = True print(ans+1)
p04044
s585434102
Accepted
N = list(map(int, input().split())) string = [input() for s in range(N[0])] string.sort() print(''.join(string))
p02771
s723782831
Accepted
x = list(map(int,input().split(" "))) a = x[0] b = x[1] c = x[2] if a == b and a == c: print("No") elif a == b or b == c or a == c: print("Yes") else: print("No")
p02773
s230298169
Wrong Answer
import collections n=int(input()) l=[] for _ in range(n): l.append(input()) c=collections.Counter(l) cc=sorted(c.most_common(max(c.values()))) for i in cc: print(i[0])
p02882
s779427482
Wrong Answer
import sys def input(): return sys.stdin.readline().rstrip() import math def main(): a,b,x=map(int,input().split()) if x==a**2*b: print(90) sys.exit() if x<=a**2*b/2: print(90.0-math.degrees(math.atan((2*x)/(a*b**2)))) else: z=2*x/a**2-b print(90.0-math.degrees(math.atan(a/(b-z)))) if __name__=='__main__': main()
p02714
s575258256
Accepted
def main(): N = int(input()) S = input() cnt = 0 for i in range(N): for j in range(i + 1, N): k = 2 * j - i if k >= N: continue if S[j] != S[i] and S[i] != S[k] and S[k] != S[j]: cnt += 1 print(S.count("R") * S.count("B") * S.count("G") - cnt) if __name__ == "__main__": main()
p02717
s417773805
Wrong Answer
X, Y, Z = input().split() print(Z,Y,X)
p03059
s525122929
Accepted
# ABC125A a, b, t = map(int, input().split()) print(b * (t // a))
p03379
s651301446
Wrong Answer
import copy N = int(input()) X = list(map(int,input().split())) length = len(X) X.sort() bef = int(length/2)-1 aft = bef for i in range(N): if(i<=bef-1): print(X[bef]) else: print(X[aft])
p03633
s176267293
Wrong Answer
import fractions n=int(input()) a=1 for i in range(n): b=int(input()) a=a/fractions.gcd(a,b)*b print(a)
p02729
s986337305
Accepted
N, M = [int(i) for i in input().split()] print(N*(N-1)//2 + M*(M-1)//2)
p02744
s617503040
Wrong Answer
n = int(input()) alp = [chr(ord("a") + x) for x in range(26)] def dfs(S): if len(S) == n: print(S) else: for i in range(len(S) + 1): dfs(S + alp[i]) dfs("a")
p03103
s605457038
Accepted
import numpy as np N, M = map(int, input().split()) store = {} for i in range(N): a, b = map(int, input().split()) if a in store: store[a] += b else: store[a] = b key = list(store.keys()) key.sort() bins = 0 total = 0 for k in key: if bins + store[k] < M: bins += store[k] total += k * store[k] else: total += k * (M-bins) break print(total)
p02596
s797416096
Accepted
K = int(input()) if K % 7 == 0: L = 9 * K // 7 else: L = 9 * K ans = -1 n = 10 for i in range(1, L): surplus = n % L if surplus == 1: ans = i break n = 10 * surplus print(ans)
p03438
s286144698
Accepted
N = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) cnt1 = 0 cnt2 = 0 for i in range(N): if a[i] > b[i]: cnt2 += a[i] - b[i] else: cnt1 += (b[i] - a[i] + 1) // 2 cnt2 += (b[i] - a[i]) % 2 # print(cnt1, cnt2) if cnt1 >= cnt2: print("Yes") else: print("No")
p03627
s159186255
Wrong Answer
N = int(input()) A = list(map(int,input().split())) from collections import Counter AA = Counter(A) B = [] for k,v in AA.items(): if v>=2: B.append(k) B.sort(reverse=True) if len(B)<2: print(0) else: print(B[0]*B[1])
p02970
s702322665
Accepted
N, D = list(map(int, input().split())) if N % (D*2+1) == 0: print(N//(D*2+1)) else: print((N//(D*2+1))+1)
p04045
s488929274
Accepted
n, k = map(int, input().split()) d = set(input().split()) while True: flag = True for i in str(n): if i in d: flag = False if flag: print(n) exit() n += 1
p03799
s166723259
Wrong Answer
N,M = map(int, input().split()) ans = 0 if True: ans = ans + N M = M - 2*N N = N - N ans = ans + M//4 print(ans) else: print(0)
p03059
s288805773
Accepted
A,B,T=map(int,input().split()) print(int((T+0.5)//A *B))
p02714
s896677619
Accepted
N = int(input()) S = input() r,g,b = 0,0,0 for i in S: if i == 'R': r += 1 elif i == 'G': g += 1 else: b += 1 minus = 0 for i in range(N - 2): for j in range(i + 1, N - 1): k = 2 * j - i if k >= N: continue if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]: minus += 1 print(r*g*b - minus)
p02933
s644574139
Wrong Answer
a = int(input()) s = input() if a >= 3200: print("s") elif a < 3200: print("red")
p03041
s953998163
Accepted
n, k = map(int, input().split()) s = input() s_new = '' for i in range(n): if i == k - 1: s_new += s[i].lower() else: s_new += s[i] print(s_new)
p02952
s499640751
Accepted
n = input() a = len(n) c = 0 for i in range(a - 1): if i % 2 == 0: c += 9 * 10 ** i n = int(n) if a % 2: c += n - 10 ** (a - 1 ) + 1 print(c)
p02772
s708471893
Accepted
import sys read = sys.stdin.read readlines = sys.stdin.readlines import numpy as np def main(): a = np.fromstring(read(), np.int64, sep=' ')[1:] a = a[a % 2 == 0] if np.all((a % 3 == 0) | (a % 5 == 0)): print('APPROVED') else: print('DENIED') if __name__ == '__main__': main()
p02946
s927441194
Accepted
K, X = map(int, input().split()) ans = [i for i in range(X-K+1, X+K)] for i in ans: print(i)
p03211
s452383888
Accepted
S=input();print(min(abs(753-int(S[i:i+3]))for i in range(len(S)-2)))
p02657
s621185740
Accepted
a,b=map(int,input().split()) print(a*b)
p03146
s857977070
Accepted
s = int(input()) i = 1 if s == 1 or s == 2: print(4) exit() while True: if s == 4: print(i+3) exit() if s%2 == 0: s=s//2 else: s=3*s+1 i += 1
p03219
s690492287
Accepted
x, y = map(int,input().split()) print(x + y // 2)
p02547
s830004504
Accepted
import sys def I(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def main(): n = I() ans = 0 temp = 0 for _ in range(n): d1, d2 = MI() if d1 == d2: temp += 1 else: temp = 0 ans = max(ans, temp) if ans >= 3: print('Yes') else: print('No') if __name__ == '__main__': main()
p03997
s543740160
Wrong Answer
import sys sys.setrecursionlimit(10 ** 7) f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): a = int(input()) b = int(input()) h = int(input()) res = (a + b) * 2 // h print(res) if __name__ == '__main__': resolve()
p02963
s694170200
Accepted
import math S = int(input()) X1 = 0 Y1 = 0 X2 = 10 ** 9 X3 = 1 Y3 = math.ceil(S / (10 ** 9)) Y2 = X2 * Y3 - S print(X1, Y1, X2, Y2, X3, Y3)
p04045
s570788491
Accepted
N, K = map(int, input().split()) num = list(map(int, input().split())) kirai = [0]*10 for i in num: kirai[i] = 1 MAXX = 100000 for n in range(N, MAXX): tmp = n good = True while tmp > 0: d = tmp % 10 tmp = tmp//10 if kirai[d]: good = False break if good: break print(n)
p03827
s926482889
Accepted
N = int(input()) S = input() ans = 0 x = 0 for s in S: if s == "I": x += 1 else: x -= 1 ans = max(ans, x) print(ans)
p02765
s253205198
Accepted
a,b=input().split() a=int(a) b=int(b) if a>=10: print(b) else: c=b-100*a+1000 print(c)
p03289
s726795308
Accepted
s = list(input()) if s[0] == "A" and s[2:-1].count("C") == 1: s.remove("A") s.remove("C") if "".join(s).lower() == "".join(s): print("AC") else: print('WA') else: print("WA")
p03814
s043134422
Accepted
S = input() A = int(S.find("A")) Z = int(S.rfind("Z")) print(Z-A+1)
p03472
s858794673
Accepted
from bisect import bisect n,h=map(int,input().split()) b=[] a_max=0 for i in range(n): x,y=map(int,input().split()) b.append(y) a_max=max(a_max,x) b=sorted(b) lim_inx=bisect(b,a_max) cnt=0 total=0 inx=n-1 while total<h: if inx>=lim_inx: total+=b[inx] cnt+=1 inx-=1 else: if (h-total)%a_max==0: cnt+=(h-total)//a_max else: cnt+=(h-total)//a_max+1 print(cnt) exit() print(cnt)
p03545
s582672407
Accepted
s = list(input()) op = ['+', '-'] for op1 in op: for op2 in op: for op3 in op: ans = s[0]+op1+s[1]+op2+s[2]+op3+s[3] if eval(ans) ==7: print(ans + '=7') exit()
p02675
s531216797
Accepted
N = int(input()) if N % 10 == 3: print("bon") elif N % 10 == 0: print("pon") elif N % 10 == 1: print("pon") elif N % 10 == 6: print("pon") elif N % 10 == 8: print("pon") else: print("hon")
p02691
s668991389
Wrong Answer
N=int(input()) L=list(map(int,input().split())) L_i=[i+1 for i in range(len(L))] cnt=0 for i in range(N): P_L= [m+L[i] for m in L[i:]] P_L_i = [x for x in range(N-i)] print(P_L) print(P_L_i) cnt = cnt + sum([w==z for (w, z) in zip(P_L,P_L_i)]) print(cnt)
p02576
s949556416
Wrong Answer
n, x, t = map(int, input().split()) answer = (n//x)*t print(answer)
p02982
s961467281
Wrong Answer
N, D = map(int, input().split()) X = [list(map(int, input().split())) for i in range(N)] sq = set() for i in range(1, 100): sq.add(i**2) def foo(x,y): t = 0 for i, j in zip(X[x], X[y]): t += (i - j) * (i - j) if t in sq: return 1 else: return 0 ans = 0 for i in range(N): for j in range(i+1, N): ans += foo(i, j) print(ans)