problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02597
s709431216
Accepted
n = int(input()) c = input() r = c.count('R') print(c[:r].count('W'))
p03760
s883819965
Wrong Answer
o, e = input(), input() ans = "" for q in range(min(len(o), len(e))): ans += o[q] + e[q] if len(o) != len(e): ans += e[-1] print(ans)
p02602
s819346305
Accepted
n, k = map(int, input().split()) arr = list(map(int, input().split())) i = k j = 0 nxt = 0 pre = sum(arr[:k]) while i < len(arr): nxt = (pre + arr[i]) - arr[j] if nxt > pre: print('Yes') else: print('No') j += 1 i += 1 pre = nxt
p02817
s520034665
Accepted
import os def main(): str_s,str_t = input().split() print(str_t + str_s) if __name__ == "__main__": main()
p03556
s435797357
Wrong Answer
n = int(input()) a=0 for i in range(n+1): if i*i <= n: a=i*i else: print(a) break
p03416
s717687686
Accepted
a,b = map(int,input().split()) cnt = 0 for i in range(a,b+1): tmp = str(i)[::-1] if str(i) == tmp: cnt += 1 print(cnt)
p03817
s187720891
Wrong Answer
N=int(input()) m=N%11 ans=-(-N//11)*2 if m<=6: print(ans-1) else: print(ans)
p02663
s517320345
Accepted
h1, m1, h2, m2, k = map(int, input().split()) time1 = h1*60+m1 time2 = h2*60+m2 print(time2-time1-k)
p03543
s057887425
Accepted
a,b,c,d=input() if b==c and(a==b or c==d): print('Yes') else: print('No')
p02647
s946873466
Wrong Answer
n,k=map(int,input().split()) a=list(map(int,input().split())) f=0 while f<k: b=[0]*n for i in range(n): for j in range(i-a[i],i+a[i]+1): if 0<=j<=n-1: b[j]+=1 a=b f+=1 print(a)
p04012
s212233188
Accepted
w = input() d = {} for i in w: d.setdefault(i, [0])[0] += 1 for i, in d.values(): if i % 2 != 0: print("No") break else: print("Yes")
p03943
s315303295
Wrong Answer
a, b, c = map(int, input().split()) print("Yes") if (a + b + c) // 2 == 0 else print("No")
p02688
s409711858
Wrong Answer
n,k = map(int,input().split()) z = 0 l = [0] for i in range(k): d=int(input()) s =list(map(int,input().split())) l.extend(s) print(l) for i in range(n+1): if l.count(i)==0: z = z + 1 print(z)
p03416
s994834853
Accepted
a,b=map(int,input().split()) ans=0 for i in range(a,b+1): if str(i)==str(i)[::-1]: ans+=1 print(ans)
p03035
s877058011
Accepted
a, b = map(int, input().split()) if a >= 13: print(b) elif a >= 6: print(b // 2) else: print(0)
p02860
s599246989
Wrong Answer
n = int(input()) s = input() if s.count(s[:n//2]) == 2 and n != 1: print("Yes") else: print("No")
p03487
s273806592
Accepted
import collections n = int(input()) a = list(map(int,input().split())) a_cnt = collections.Counter(a) #print(a_cnt) cnt = 0 for item in a_cnt.items(): if item[0]<item[1]: cnt += item[1]-item[0] elif item[0]>item[1]: cnt += item[1] print(cnt)
p02657
s890749405
Accepted
a, b = map(int, input().split()) print(a*b)
p03617
s313465560
Accepted
Q, H, S, D = map(int, input().split()) N = int(input()) cheap_l = min(4*Q, 2*H, S) print(min(N*cheap_l, (N//2)*D+(N%2)*cheap_l))
p02882
s593330898
Wrong Answer
from fractions import math a, b, x = map(int, input().split()) print(math.atan(a*(b**2)/2/x)/math.pi*180)
p02785
s584637763
Accepted
def main2(): n, k = list(map(int, input().split())) monsters = list(map(int, input().split())) monsters.sort(reverse=True) for i in range(k): if i >= len(monsters): break monsters[i] = 0 print(sum(monsters)) if __name__ == '__main__': main2()
p03086
s562749299
Wrong Answer
s = input() point = 0 for i in s: if i in "ACGT": point += 1 print(point)
p02623
s530071192
Wrong Answer
import numpy as np import sys input = sys.stdin.buffer.readline N, M, K = map(int, input().split()) cumA = np.zeros(N+1, dtype=np.int32) cumA[1:] = np.array(input().split(), dtype=np.int32).cumsum() cumB = np.zeros(M+1, dtype=np.int32) cumB[1:] = np.array(input().split(), dtype=np.int32).cumsum() # print(cumA) # print(cumB) ans = 0 for i in range(N, -1, -1): if cumA[i] > K: continue j = np.searchsorted(cumB, K-cumA[i], side='right') ans = max(ans, i+j-1) print(ans)
p02552
s836494848
Wrong Answer
x = int(input()) if x != 1: print(0) else: print(1)
p03657
s164819938
Accepted
A,B = map(int,input().split()) if A%3 == 0 or B%3 == 0 or (A+B)%3==0: print("Possible") else: print("Impossible")
p02631
s836933247
Accepted
N = int(input()) A = list(map(int, input().split())) x = 0 for a in A: x ^= a ans = [] for a in A: ans.append(x ^ a) print(" ".join(map(str, ans)))
p03633
s850445271
Accepted
N = int(input()) T = int(input()) ans = T import math for i in range(N - 1): T = int(input()) ans = T * ans // math.gcd(T, ans) print(ans)
p03086
s349710385
Wrong Answer
S = input() ans = 0 for i in range(len(S)): for j in range(i,len(S)): print(S[i:j+1]) flag = True for k in S[i:j+1]: if not (k=='A' or k=='C' or k=='G' or k=='T'): flag = False break if flag: ans = max(ans, len(S[i:j+1])) print(ans)
p02657
s791666044
Accepted
A,B = map(int,input().split()) print(A*B)
p03017
s037114422
Accepted
n,a,b,c,d = map(int,input().split()) S = list(input()) flg = 1 for i in range(a-1,c-2): if S[i:i+2] == ['#','#']: flg *= 0 for i in range(b-1,d-2): if S[i:i+2] == ['#','#']: flg *= 0 if c>d: flg2 = 0 for i in range(b-1,d): if S[i-1:i+2] == ['.','.','.']: flg2 = 1 flg *= flg2 if flg == 0: print('No') else: print('Yes')
p02935
s876583309
Accepted
N = int(input()) V = [_ for _ in map(int,input().split())] v = len(V) V.sort() if v == 2: print(sum(V)/2) else: i = 2 X = (V[0] + V[1])/2 while i != N: X = (X + V[i])/2 i += 1 print(X)
p03997
s097301360
Accepted
a=int(input()) b=int(input()) h=int(input()) print((a+b)*h//2)
p04011
s173135927
Accepted
n=int(input()) k=int(input()) x=int(input()) y=int(input()) if n <= k: print n * x else: print k * x + (n - k) * y
p02601
s231802617
Accepted
a,b,c = map(int,input().split()) k = int(input()) p = 0 while a >= b: b *= 2 p += 1 while b >= c: c *= 2 p += 1 if p <= k: print("Yes") else: print("No")
p03478
s962317836
Accepted
N, A, B = map(int, input().split()) count = 0 for i in range(1,N+1): n = list(k for k in str(i)) S_n = 0 for j in n: S_n += int(j) if A <= S_n <= B: count += i print(count)
p02596
s843327068
Accepted
K = int(input()) a = 7 % K cnt = 1 while a: a = (10*a+7) % K cnt += 1 if K < cnt: cnt = -1 break print(cnt)
p02594
s483723456
Wrong Answer
a=int(input()) print('Yes' if 30>=a else 'No')
p02725
s324498428
Accepted
K, N = map(int, input().split()) A = list(map(int, input().split())) D = list() D.append(A[0] + K - A[-1]) for i in range(N - 1): D.append(A[i + 1]- A[i]) print(K - max(D))
p02787
s200678532
Accepted
def main(): h,n,*t=map(int,open(0).read().split()) d=[0]+[10**18]*h for a,b in zip(*[iter(t)]*2): for j in range(h+1): k=j-a if k<0:k=0 c=d[k]+b if c<d[j]:d[j]=c print(d[h]) main()
p02688
s233406503
Accepted
n, k = map(int, input().split()) x = set() for i in range(k): d = int(input()) for j in input().split(): x.add(j) print(n - len(x))
p03997
s393195639
Accepted
import sys sys.setrecursionlimit(10 ** 6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def II(): 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 LLI(rows_number): return [LI() for _ in range(rows_number)] def SI(): return sys.stdin.readline()[:-1] print((II()+II())*II()//2)
p03038
s441920794
Wrong Answer
N, M = map(int, input().split()) A = list(map(int, input().split())) D = [] result_m = 0 for m in range(M): B, C = map(int, input().split()) D.extend([C]*B) A.sort() D.sort(reverse=True) result = 0 for i in range(min(len(A),len(D))): if D[i]-A[i]<=0: break result+=1 print(result) print(D[:result]+A[result:]) print(sum(D[:result])+sum(A[result:]))
p02951
s901130464
Accepted
a, b, c = map(int, input().split()) print(c - (a-b) if c >= (a-b) else "0")
p03998
s184861252
Wrong Answer
s = {'a': input(), 'b': input(), 'c': input()} now = 'a' while s[now] != '': now = s[now][0] s[now] = s[now][1:] print(now.upper())
p02707
s809827308
Wrong Answer
n = int(input()) A_list = list(map(int, input().split(" "))) print(A_list) for i in range(1, n+1): print(A_list.count(i))
p02842
s881857651
Accepted
import math N = int(input()) X_MAX = int(math.ceil(50000 / 1.08)) ans = ':(' for i in range(X_MAX + 1): if int(i * 1.08) == N: ans = i break print(ans)
p02613
s159633025
Accepted
n = int(input()) i = 0 ac = 0 wa = 0 tle = 0 re = 0 for i in range(n): s = input() if s == "AC": ac += 1 elif s == "TLE": tle += 1 elif s == "WA": wa += 1 else: re += 1 i += 1 print("AC x %s" %(ac)) print("WA x %s" %(wa)) print("TLE x %s" %(tle)) print("RE x %s" %(re))
p03971
s265034928
Wrong Answer
n, a, b = map(int, input().split()) s = input() cnt = 0 memo = 0 for i in range(n): if s[i] == 'c': print('No') else: if cnt < a + b: cnt += 1 if s[i] == 'b' and memo <= b: memo += 1 print('Yes') elif s[i] == 'a': print('Yes') else: print('No') else: print('No')
p02714
s865993005
Wrong Answer
import collections n=int(input()) s=input() c = collections.Counter(s) ans_count = c['R'] * c['G'] * c['B'] for i in range((n-1)//2): for j in range(n): if j+(2*i) >= n: break if s[j] != s[j+i] and s[j+i] != s[j+(2*i)] and s[j] != s[j+(2*i)]: ans_count -= 1 print(ans_count)
p02854
s043159209
Accepted
n = int(input()) a = list(map(int, input().split())) x = n//2 if sum(a)/2 == sum(a[:(n//2)]): print(0) elif sum(a)/2 >= sum(a[:(n//2)]): while sum(a)/2 >= sum(a[:x]): x += 1 print(min(abs(2*sum(a[:x])-sum(a)), abs(2*sum(a[:x-1])-sum(a)))) else: while sum(a)/2 <= sum(a[:x]): x -= 1 print(min(abs(2*sum(a[:x])-sum(a)), abs(2*sum(a[:x+1])-sum(a))))
p03556
s384270033
Accepted
N = int(input()) print(int(N**0.5)**2)
p02699
s627309055
Accepted
S, W = map(int, input().split()) if S <= W: print("unsafe") else: print("safe")
p02713
s487461977
Wrong Answer
#C def gcd(a, b): if b > a: a, b = b, a if b == 0: return a else: return gcd(b, a % b) K = int(input()) ans = 0 for a in range(1, K+1): for b in range(a+1, K+1): for c in range(b+1, K+1): tmp = gcd(a, b) ans += gcd(tmp, c) print(ans)
p02818
s957778723
Accepted
import sys a, b, k = map(int, sys.stdin.readline().split()) if a < k: if a + b - k >= 0: print(0, a + b - k) else: print(0, 0) else: print(a - k, b)
p02912
s728133723
Wrong Answer
N, M = map(int, input().split()) A = list(map(int, input().split())) for i in range(0,M): A[A.index(max(A))]=int(A[A.index(max(A))]) print(sum(A))
p03067
s317819915
Wrong Answer
a,b,c=map(int,input().split()) if c-a > 0 and b-a < 0: print('Yes') elif c-a < 0 and b-a > 0: print('Yes') else: print('No')
p03821
s249652156
Wrong Answer
from sys import stdin import fractions n = int(stdin.readline().rstrip()) li = [[0,0]]+[list(map(int,stdin.readline().rstrip().split())) for _ in range(n)] li = li[::-1] count = 0 for i in range(n): if li[i][0]%li[i][1] != 0: count += li[i][1]-li[i][0]%li[i][1] li[i+1][0] += count print(count)
p02657
s660406201
Accepted
a, b = (int(i) for i in input().split()) print(a * b)
p02661
s802911277
Accepted
n = int(input()) a = [0] * n b = [0] * n for i in range(n): a[i], b[i] = map(int, input().split()) def md(x): u = sorted(x) if len(u) % 2 == 0: return u[len(u) // 2] + u[len(u) // 2 - 1] else: return u[len(u) // 2] u, v = md(a), md(b) print(v - u + 1)
p03408
s729636378
Accepted
N = int(input()) s = [input() for i in range(N)] M = int(input()) t = [input() for i in range(M)] maxp = 0 for i in s: pre = s.count(i)-t.count(i) maxp = max(maxp,pre) print(maxp)
p03061
s435781266
Accepted
n = int(input()) a = list(map(int, input().split())) def gcd(a, b): return b if a == 0 else gcd(b % a, a) l = [0] r = [0] for i in range(n): l.append(gcd(l[-1], a[i])) r.append(gcd(r[-1], a[n - i - 1])) ret = 0 for i in range(n): ret = max(ret, gcd(l[i], r[n - i - 1])) print(ret)
p02797
s269238244
Accepted
n,k,s = map(int,input().split()) ans = [] for i in range(k): ans.append(str(s)) for j in range(n-k): if s != 1000000000: ans.append(str(s+1)) else: ans.append(str(s-1)) print(' '.join(ans))
p02963
s102675862
Wrong Answer
s = int(input()) print(0, 0, 0, 1, s, 0)
p03241
s122072725
Accepted
n,m = map(int,input().split()) def f(x): d = [] for i in range(1, int(x**0.5)+1): if x % i == 0: d.append(i) if i != x // i: d.append(x//i) d.sort(reverse = True) return d for i in f(m): if m // i >= n: print(i) quit()
p04019
s023742274
Wrong Answer
s = input() if 'N' in s and 'W' in s and 'S' in s and 'E' in s: print('Yes') else: print('No')
p02598
s282320622
Wrong Answer
N, K = map(int, input().split()) A = list(map(int, input().split())) if K == 0: print(max(A)) exit() def f(x): cnt = 0 for i in A: if i % x == 0: cnt += i//x - 1 else: cnt += i//x if cnt <= K: return True else: return False ok = 1 ng = 1e10 for i in range(60): mid = (ok + ng) // 2 if f(mid): ng = mid else: ok = mid print(ng)
p03705
s190366007
Accepted
n,a,b = map(int, input().split()) if a>b:print(0);exit() if n==1 and a!=b:print(0);exit() print((b-a)*(n-2)+1)
p02970
s225520331
Wrong Answer
n, d = map(int, input().split()) ans = (n+2*d)/(2*d+1) print(ans)
p03556
s475814087
Wrong Answer
N = int(input()) i = 1 while i < N: if((i * i) > N): print((i-1) * (i-1)) break i += 1
p02607
s343272877
Wrong Answer
N=int(input()) a=list(map(int,input().split())) count=0 for i in range(len(a)): if (i%2==1)&(a[i]%2==1): count+=1 print(count)
p02909
s448166152
Wrong Answer
""" abc141-b """ import sys S = input() if (len(S) == 1): print("No") sys.exit() else: for i in range(int(len(S))-1): if (i % 2 == 0): if (S[i] == "L"): print("No") sys.exit() else: if (S[i] == "R"): print("No") sys.exit() print("Yes")
p03673
s529844972
Wrong Answer
n = int(input()) a = [int(_) for _ in input().split()] left = [0] * (n//2) right = [0] * (n//2) if n % 2 == 0: left = a[n:0:-2] right = a[0:n:2] ans = left + right else: left = a[n:1:-2] right = a[1:n:2] ans = left + [a[0]] + right print(ans)
p03206
s873529646
Accepted
D=int(input()) if D==22: print("Christmas Eve Eve Eve") elif D==23: print("Christmas Eve Eve") elif D==24: print("Christmas Eve") elif D==25: print("Christmas")
p02756
s525199213
Accepted
S = input() Q = int(input()) r = False prefix = [] suffix = [] for _ in range(Q): query = input() if query == '1': r ^= True else: _, f, c = query.split() front = f == '1' if r ^ front: prefix.append(c) else: suffix.append(c) if r: S = ''.join(suffix[::-1]) + S[::-1] + ''.join(prefix) else: S = ''.join(prefix[::-1]) + S + ''.join(suffix) print(S)
p02996
s086111515
Wrong Answer
n = int(input()) ab = [list(map(int,input().split())) for _ in range(n)] sorted(ab, key = lambda x:x[1]) ans = 0 for i in ab: ans+=i[0] if ans > i[1]: print("No") exit() print("Yes")
p03286
s317868270
Accepted
from math import ceil, log def main(): n = int(input()) if n == 0: print(0) return k = 2 * int(log(3 * n, 4)) + 1 if n > 0 else 2 * ceil(log((2 - 3 * n) // 2, 4)) s = [0] * k while n: k = 2 * int(log(3 * n, 4)) if n > 0 else 2 * ceil(log((2 - 3 * n) // 2, 4)) - 1 s[k] = 1 n -= (-2)**k print(*s[::-1], sep="") if __name__ == '__main__': main()
p02777
s562505610
Accepted
s = list(input().split()) a = list(map(int, input().split())) t = input() a[s.index(t)] -= 1 print(*a)
p02713
s505407925
Wrong Answer
K = int(input()) print(K ** 3 + (1 / 2) *K ** 2 - (1 / 2) * K)
p02732
s631202113
Wrong Answer
n=int(input()) a=list(map(int,input().split())) d={} ua=list(set(a)) total=0 print('hoge') for x in ua: y=a.count(x) d[x]=y total+=(y-1)*y//2 for x in a: print(total-d[x]+1)
p03030
s748199218
Wrong Answer
from operator import itemgetter n = int(input()) # data = [input().split() for _ in range(n)] data = [] for i in range(n): city, point = input().split() data.append([city, point, i+1]) data = sorted(data, key=itemgetter(1), reverse=True) data = sorted(data, key=itemgetter(0), reverse=False) for i in range(n): print(data[i][2])
p03943
s222111523
Accepted
a, b, c = map(int, input().split()) if a == b + c or b == c + a or c == a + b: print('Yes') else: print('No')
p03681
s154455091
Accepted
import math f=math.factorial n,m=map(int,input().split()) print(f(n)*f(m)*(1+(n==m))%(10**9+7) if abs(n-m)<2 else 0)
p02859
s849526326
Wrong Answer
r = int(input()) int(r*r)
p02629
s022834162
Wrong Answer
def main(): N = int(input()) ANS = [] while N > 0: ANS.insert(0,chr(N%26+96)) N = N//26 print(''.join(ANS)) if __name__ == '__main__': main()
p03126
s432002407
Accepted
INT = lambda: int(input()) INTM = lambda: map(int,input().split()) STRM = lambda: map(str,input().split()) STR = lambda: str(input()) LIST = lambda: list(map(int,input().split())) LISTS = lambda: list(map(str,input().split())) def do(): n,m=INTM() alist=[] for i in range(n): ka=LIST() ka.pop(0) ka=set(ka) alist.append(ka) for i in range(n-1): alist[n-1]=alist[n-1]&alist[i] print(len(alist[n-1])) if __name__ == '__main__': do()
p02953
s967792481
Accepted
N = int(input()) H = list(map(int, input().split())) base = 0 for h in H: if(base > h): print("No") break base = max(base, h-1) else: print("Yes")
p03910
s421089939
Accepted
import sys stdin = sys.stdin ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) nn = lambda: list(stdin.readline().split()) ns = lambda: stdin.readline().rstrip() n = ni() m = 10**7 a = 1 i = 1 while a <= m: if a >= n: break i+=1 a+=i ans = [j for j in range(1,i+1) if j != a-n] print(*ans,sep="\n")
p02959
s292752030
Wrong Answer
N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) ans = 0 for i in range(N, 0, -1): ans += min(A[i], B[i - 1]) B[i - 1] -= min(A[i],B[i - 1]) ans += min(A[i - 1],B[i - 1]) B[i - 1] -= min(A[i - 1], B[i - 1]) print(ans)
p03835
s237937702
Accepted
k,s=map(int,input().split()) count=0 for x in range(k+1): for y in range(k+1): if k>=s-x-y>=0: count+=1 print(count)
p02659
s639753719
Accepted
import sys readline = sys.stdin.readline from fractions import Fraction A,B = readline().split() A = int(A) B = Fraction(B) print(int(A * B))
p02862
s646856452
Accepted
mod = 10 ** 9 + 7 x, y = [int(i) for i in input().split()] if (2*x - y) % 3 != 0 or (2*y - x) % 3 != 0: print(0) exit() a = (2*x - y) // 3 b = (2*y - x) // 3 if a < 0 or b < 0: print(0) exit() def mygcd(a_b, b, mod): b = min(a_b, b) cnt = 1 for i in range(b): cnt = cnt * (a_b - i) * pow(i+1, mod-2, mod) % mod return cnt print(mygcd(a+b, b, mod))
p02675
s095437046
Accepted
N = int(input()) def calculate(n): n = n % 10 s1 = [2,4,5,7,9] s2 = [0,1,6,8] if n in s1: print("hon") return if n in s2: print("pon") return print("bon") calculate(N)
p02702
s259208665
Wrong Answer
S=input() ans=0 a=0 b=3 if len(S)<4: print(0) else: while True: if int(S[a:b])%2019==0: ans+=1 b+=1 if b==len(S)+1: a+=1 b=a+3 if a==len(S)-3: break print(ans)
p03474
s273647208
Accepted
A,B=map(int,input().split()) S=input() if str.isdecimal(S[0:A]) and S[A]=="-" and str.isdecimal(S[A+1:]): #print(str.isdecimal(S[0:A])) #print(S[A]=="-") #print(str.isdecimal(S[A+1:])) #print(S[A+2:]) print("Yes") else: #print(str.isdecimal(S[0:A])) #print(S[A]) #print(str.isdecimal(S[A+1:])) #print(S[A+1:]) print("No")
p03037
s223819882
Accepted
n,m = map(int, input().split()) min_ = 1 max_ = 10**5 for i in range(m): l,r = map(int, input().split()) min_ = max(min_, l) max_ = min(max_, r) ans = max(0, max_ - min_ + 1) print(ans)
p02747
s207920604
Accepted
S = input() result = 'No' for i in range(1, 6): if S == 'hi' * i: result = 'Yes' break print(result)
p03644
s292300807
Accepted
N = int(input()) # 2で割れる最大数は2**x. 2**x がNを超えるかどうかで判定する for x in range(10): if N < 2**x: break print(2**(x-1))
p03986
s419050910
Accepted
X = list(input()) nt, ns = 0, 0 for x in X: if x == 'S': ns += 1 elif ns > 0: ns -= 1 else: nt += 1 print(nt+ns)
p03759
s271776621
Wrong Answer
def main(): a,b,c = map(int, input().split()) if b - a == c - b: print('Yes') else: print('No') main()
p03274
s939243994
Accepted
n,k=map(int,input().split()) X=list(map(int,input().split())) r=10**9 for i in range(n-k+1): a=X[i] b=X[i+k-1] if a*b>=0: t=max(abs(a),abs(b)) else: t=min((-a)*2+b,(-a)+2*b) r=min(r,t) print(r)