problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03041
s002031209
Wrong Answer
N,K = list(map(int, input().split())) S = str(input()) s = (S[K-1].lower) print(s)
p03773
s391186097
Wrong Answer
a,b=map(int,input().split()) if (a>b): s=a+b s=s%24 if (b>=a): s=a-b if (s<=0): s=s*-1 print(s)
p04030
s253863586
Wrong Answer
given = [x for x in input()] rets = '' for i, v in enumerate(given): if v in ["1", "0"]: rets += v elif v == "B" and len(rets) > 0: rets = rets[:-1] else: rets += v print(rets)
p02759
s136515811
Accepted
def main(): n = int(input()) result = 0 while True: if n > 0: n = n - 2 result += 1 else: break print(result) if __name__ == "__main__": main()
p02621
s663554516
Accepted
a = int(input()) print(a + a**2 + a**3)
p03035
s631891186
Wrong Answer
A, B = map(int, input().split()) if A >= 13: print(B) else: print(B//2)
p03351
s176408652
Accepted
a,b,c,d = map(int,input().split()) if abs(a-c)<=d: print("Yes") elif abs(a-b)<=d and abs(b-c)<=d: print("Yes") else: print("No")
p02958
s330999032
Accepted
n=int(input()) l=list(map(int,input().split())) k=[] for i in range(1,n+1): k.append(i) c=0 for i in range(n): if k[i]!=l[i]: c+=1 if c==0 or c==2: print('YES') else: print('NO')
p02576
s937618272
Accepted
N,X,T = map(int,input().split()) if N%X == 0: print((N//X)*T) else: print((N//X+1)*T)
p03136
s147487973
Accepted
N=int(input()) L=list(map(int,input().split())) L=sorted(L) if sum(L[:-1])>L[-1]: print('Yes') else: print('No')
p03730
s479648270
Accepted
a, b, c = map(int, input().split()) for i in range(1, b + 1): if a * i % b == c: print("YES") break else: print("NO")
p02548
s902915928
Accepted
N = int(input()) res = 0 for i in range(1,N+1): if N%i ==0 and N//i>=2: res += N//i-1 elif N%i!=0: res += N//i print(res)
p02775
s779837133
Wrong Answer
#DPでしょ、DPなんでしょ!?お姉さん知ってるんだから!プリプリ
p02571
s912232516
Accepted
s = input() t = input() if len(s) <= len(t): a = s; s = t; t = a res = 0 for i in range(len(s)-len(t)+1): temp = 0 for j in range(len(t)): if s[j+i] == t[j]: temp+=1 res = max(temp, res) ans =len(t) - res print(ans)
p04043
s667777697
Accepted
a = input().split() if a.count('5') == 2 and a.count('7'): print('YES') else: print('NO')
p02743
s963526071
Accepted
a,b,c=map(int,input().split()) if a+b>=c: print('No') else: flg = 4*a*b < (c-a-b)**2 print('Yes' if flg else 'No')
p03061
s320035999
Wrong Answer
from fractions import gcd n=int(input()) A=list(map(int,input().split())) L=[0]*n R=[0]*n L[0]=A[0] R[n-1]=A[n-1] res=0 for i in range(1,n): L[i]=gcd(L[i-1],A[i]) for i in range(0,n-1): R[n-i-2]=gcd(R[n-i-1],A[n-i-2]) for i in range(1,n-1): res=max(res,gcd(L[i-1],R[i+1])) print(max(res,L[n-1],R[1]))
p02548
s363081378
Wrong Answer
N = int(input()) s = [0,1] for i in range(2,N): for j in range(2,int(i**0.5 + 1)+1): if i % j == 0: k = i//j s.append(2*s[k]) break if len(s) != i+1: s.append(1) print(sum(s))
p02582
s573480483
Accepted
S = list(input()) cnt = 0 for i, s in enumerate(S): if s == 'R' and cnt == 0: cnt += 1 elif s == 'R' and cnt >= 1 and S[i-1] == 'R': cnt += 1 print(cnt)
p03438
s705247044
Accepted
N = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) n = sum(b) - sum(a) c = 0 for i in range(N): if a[i] < b[i]: c += (b[i] - a[i] + 2 - 1) // 2 print('Yes' if c <= n else 'No')
p03617
s070246405
Accepted
# A Q,H,S,D = map(int,input().split()) N = int(input()) print((N//2) * min(8*Q,4*H,2*S,D) + (N % 2) * min(4*Q,2*H,S))
p02909
s599525766
Accepted
s = input() if s == "Sunny": print("Cloudy") elif s == "Cloudy": print("Rainy") else: print("Sunny")
p03545
s366040538
Accepted
n=input() for i in range(2**3): ans='' for j in range(4): ans+=n[j] if j==3: continue if (i>>j)&1: ans+='+' else: ans+='-' if eval(ans)==7: print(ans+'=7') break
p03219
s822536603
Accepted
x,y=map(int,input().split()) print(x+y//2)
p03077
s415229678
Accepted
from math import ceil n=int(input()) min_val=min(int(input()),int(input()),int(input()),int(input()),int(input())) m=ceil(n/min_val) print(5+m-1)
p02660
s054408422
Accepted
answer = 0 pf = {} m=int(input()) for i in range(2,int(m**0.5)+1): while m%i==0: pf[i]=pf.get(i,0)+1 m//=i if m>1: pf[m]=1 for i, j in pf.items(): temp = j for k in range(1, j+1): temp -= k if temp < 0: break else: answer += 1 print(answer)
p03817
s556894082
Wrong Answer
x = int(input()) ans = x // 11 * 2 nokori = x % 11 if nokori > 6: print(ans + 2) else: print(ans + 1)
p03693
s227772556
Wrong Answer
r, g, b = input().split() number = int(r+g+b) if number % 4 ==0: print('Yes') else: print('No')
p02862
s910841427
Wrong Answer
x,y=map(int,input().split()) if (2*y-x)%3!=0 or (2*x-y)%3!=0: ans=0 else: a=(2*y-x)//3 b=(2*x-y)//3 n=a+b ans=1 for i in range(min(a,b)): ans*=(n-i) ans%=(10**9+7) ans*=pow(i+1,10**9+5,10**9+7) print(ans%(10**9+7))
p02701
s622502823
Wrong Answer
import collections N=int(input()) a=[input() for i in range(N)] print(collections.Counter(a))
p03495
s732730358
Accepted
n,k=map(int,input().split()) a=list(map(int,input().split())) from collections import defaultdict d=defaultdict(int) for i in a: d[i]+=1 if len(d)<=k: print(0) else: print(sum(sorted(list(d.values()))[:len(d)-k]))
p02777
s167817197
Accepted
s,a,u=open(0);i=u in s;print(int(a[:2])-1+i,int(a[2:])-i)
p02860
s229284459
Accepted
N = int(input()) S = input() if N % 2 != 0: print('No') else: if S[:int(N/2)] == S[int(N/2):]: print('Yes') else: print('No')
p03419
s516935413
Accepted
n,m=map(int, input().split()) ans=0 if n==1 and m==1: ans=1 elif n==1: ans=m-2 elif m==1: ans=n-2 else: ans=(n-2)*(m-2) print(ans)
p04031
s340516051
Accepted
def main(): n = int(input()) a_lst = list(map(int, input().split())) minimum = min(a_lst) maximum = max(a_lst) cost = 10 ** 9 for i in range(maximum - minimum + 1): tmp_cost = 0 std = minimum + i for j in range(n): a = a_lst[j] tmp_cost += (a - st...
p03469
s635855064
Accepted
S=str(input()) T="2018"+S[4:] print(T)
p03852
s429543660
Accepted
c = set(input()) s = {"a","i","u","e","o"} w = c|s if len(w) == 5 : print("vowel") else: print("consonant")
p02761
s832975840
Accepted
#!/usr/bin/env python3 n,m = map(int,input().split()) digit = [-1]*3 for i in range(m): s,c =map(int,input().split()) if digit[s-1] == -1: digit[s-1] = c elif digit[s-1] != c: print(-1) exit() if digit[0] == 0 and n != 1: print(-1) exit() if (digit[0] == 0 and n == 1) or (n == 1 and...
p03778
s395939400
Wrong Answer
w,a,b=map(int,input().split()) print(b-a-w)
p02696
s990269980
Wrong Answer
a, b, n = map(int, input().split()) ans = int((a * n) / b) - a * int(n / b) for i in range(0, 100): n = n - 1 ans=max(ans, int((a * i) / b) - a * int(i / b)) print(ans)
p02953
s710726816
Wrong Answer
n=int(input()) h=list(map(int,input().split())) for i in range(n-1): if h[i]>h[i+1]: h[i]-=1 if max(h)-min(h)==1: print("Yes") quit() for i in range(n-1): if h[i]>h[i+1]: print("No") quit() print("Yes")
p02725
s750850879
Accepted
k, n = map(int, input().split()) L = list(map(int, input().split())) b = k - L[n-1] + L[0] for i in range(n-1): R = L[i+1] - L[i] if R > b: b = R print(k - b)
p02613
s109399958
Accepted
N = int(input()) S = [input() for i in range(N)] c0, c1, c2, c3 = 0, 0, 0, 0 for i in S: if i == 'AC': c0 += 1 if i == 'WA': c1 += 1 if i == 'TLE': c2 += 1 if i == 'RE': c3 += 1 print('AC','x',c0) print('WA','x',c1) print('TLE','x',c2) print('RE','x',c3)
p02684
s093083710
Accepted
N,K=map(int, input().split()) a_ls=list(map(int, input().split())) j=1 step=0 s=set([]) l=[] loop_s=-1 loop_g=-1 while True: s.add(j) l+=[j] j=a_ls[j-1] #update if j in s: loop_s=l.index(j) loop_g=len(l) break #print(l) #print(loop_s) #print(loop_g) if K<loop_s: print(l[K]) elif (K+1-loop_s)%(loop_g-loo...
p02633
s473999935
Accepted
from math import gcd X = int(input()) print(360 // gcd(X, 360))
p03351
s103959925
Accepted
a, b, c, d = map(int, input().split()) if abs(a-c) <= d: print('Yes') elif abs(a-b) <= d and abs(b-c) <= d: print('Yes') else: print('No')
p02683
s977280643
Wrong Answer
cin = open(0).read().strip().split('\n') n,m,x = map(int, cin[0].split(' ')) books = [] for i in cin[1:]: books.append(tuple(map(int, i.split(' ')))) for i in range(2**n): ret = [0] * m money = 0 for j in range(n): if i >> j & 1: for mi in range(m): ret[mi] += books[...
p03637
s439214048
Accepted
n = int(input()) a = list(map(int,input().strip().split())) t_4 = 0 t_2 = 0 for i in a: if i%4==0: t_4+=1 elif i%2==0: t_2+=1 other = len(a)-t_4-t_2 if other <= t_4: print("Yes") elif other == t_4 +1: if t_2 > 0: print("No") exit() else: print("Yes") exit() else: print("No")
p02947
s090075711
Accepted
n = int(input()) l = [] for i in range(n): tmp = list(input()) tmp.sort() tmp = ''.join(tmp) l.append(tmp) from collections import Counter c = Counter(l) num = list(c.values()) from math import factorial def combinations_count(n, r): return factorial(n) // (factorial(n - r) * factorial(r)) ans =...
p03329
s439198876
Accepted
N = int(input()) ans = [0] * 100001 for i in range(6): ans[i] = i s = 6 n = 9 for i in range(6,N+1): p = i%3 if p != 0: ans[i] = ans[i-p] + p else: if i == s*6: s *= 6 if i == n*9: n *= 9 ans[i] = min(ans[i-s]+1,ans[i-n]+1) print(ans[N])
p03103
s875188170
Accepted
from operator import itemgetter n,m= map(int,input().split()) ab = [list(map(int,input().split())) for i in range(n)] ab = sorted(ab) money = 0 drink = 0 for i in range(n): drink += ab[i][1] if drink > m: drink -= ab[i][1] break else: mon...
p02819
s606393086
Accepted
X = int(input()) ans = -1 x = X while(ans == -1): if all([x % i != 0 for i in range(2, x)]): ans = x else: x += 1 print(ans)
p02790
s127888572
Wrong Answer
a,b = map(int,input().split()) s1 = "" s2 = "" for i in range(b): s1 = s1 + str(a) for i in range(a): s2 = s2 + str(b) ans = min(s1,s2)
p02796
s287039446
Accepted
import sys input = sys.stdin.readline N = int(input()) R = [] for i in range(N): x,l = map(int, input().split()) R.append([max(x-l,0),x+l]) R.sort(key = lambda r : r[1]) ans = N lr = -1 for i in range(N): if(lr > R[i][0]): ans -=1 continue else: lr = R[i][1] print(ans)
p03457
s294923217
Wrong Answer
c = input() data = [] for s in range(0,int(c)): data.append(list(map(int, input().split())) ) nowtime = 0 nowx = 0 nowy = 0 nexttime = 0 nextx = 0 nexty = 0 costtime = 0 diffx = 0 diffy = 0 for s in range(0, len(data)): nexttime = data[s][0] nextx = data[s][1] nexty = data[s][2] costtime = nexttime - nowt...
p03698
s656805723
Accepted
# n, m, l = map(int, input().split()) # list_n = list(map(int, input().split())) # n = input() # list = [input() for i in range(N) # list = [[i for i in range(N)] for _ in range(M)] import sys input = sys.stdin.readline S = input() Sset = set(S) # print(Sset) if len(S) == len(Sset): print("yes") else: prin...
p02817
s840458264
Accepted
# -*- coding: utf-8 -*- def main(): S, T = input().split() ans = T + S print(ans) if __name__ == "__main__": main()
p02695
s378782263
Accepted
from itertools import combinations_with_replacement n,m,q =map(int,input().split()) summa=[] res=[] for i in range(q): a=[int(i) for i in input().split()] summa.append(a) for i in combinations_with_replacement(list(range(1,m+1)),n): cnt=0 for j in summa: if i[j[1]-1]-i[j[0]-1]==j[2]: ...
p03456
s518473385
Accepted
a,b=input().split() c=int(a+b) import math d=math.sqrt(c) if int(d)*int(d)==c: print("Yes") else: print("No")
p02690
s032216172
Accepted
X = int(input()) for a in range(-1000, 1000): A = a*a*a*a*a for b in range(-1000, 1000): if A - b*b*b*b*b == X: print(a, b) exit()
p03386
s374724841
Wrong Answer
[A,B,K] = list(map(int,input().split())) for i in range(K): dammy = A+i if dammy<B: print(dammy) for j in range(K): dammy = B-K+1+j if A+K-1<dammy and 0<dammy and dammy<=B: print(dammy)
p03835
s010109055
Wrong Answer
K,S=map(int,input().split()) ans=0 for i in range(K+1): for j in range(K+1): if (i+j)>S: break if (S-K)<=(i+j): break ans+=1 print(ans)
p02702
s287700755
Accepted
s = input() n = len(s) ans = 0 now = 0 mp = [0 for i in range(2019)] mp[0] += 1 tmp = [0 for i in range(2019)] id = [0 for i in range(2019)] for i in range(2019): id[i] = i * 10 % 2019 for c in s: now *= 10; now += ord(c) - ord("0") now %= 2019 ans += mp[now] mp[now] += 1 for i in range(2...
p03385
s938435224
Accepted
#pypyは内包表記使わない def main(): import sys #input = sys.stdin.readline sys.setrecursionlimit(10000000) from collections import Counter, deque #from collections import defaultdict from itertools import combinations, permutations #from itertools import accumulate, product from bisect import bis...
p02729
s316892258
Accepted
n,m = map(int,input().split()) an = n * (n-1)/2 am = m * (m-1)/2 answer = an + am print(int(answer))
p03555
s133201790
Accepted
a = input() b = input() if a == b [::-1]: print('YES') else: print('NO')
p04033
s737698484
Accepted
def main(): a, b = map(int, input().split()) if a < 0 and b > 0: print('Zero') elif a > 0 and b > 0: print('Positive') elif a == 0 or b == 0: print('Zero') else: if (abs(a) - abs(b) + 1) % 2 == 1: print('Negative') else: print('Positive...
p03250
s556233434
Accepted
a = list(map(int,input().split())) a = sorted(a) x = a[2] * 10 + a[1] y = a[0] print(x+y)
p02953
s969621370
Accepted
def main(): n = int(input()) h = list(map(int, input().split())) for i in reversed(range(1,n)): if h[i-1] <= h[i]: continue h[i-1] = h[i-1] - 1 if not h[i-1] <= h[i]: print('No') return else: continue print('Yes') if __name...
p04031
s722551021
Accepted
n = int(input()) a = [int(i) for i in input().split()] m = sum(a) / len(a) num = round(m) loss = 0 for n in a: loss += (n - num)**2 print(loss)
p02866
s827248679
Wrong Answer
from collections import Counter N = int(input()) *D, = map(int, input().split()) mod = 998244353 c = Counter(D) keys = sorted(c.keys()) if keys[0]!=0: print(0) else: size = len(keys) ans = 1 for i in range(1, size): a, b = keys[i-1], keys[i] ans *= (c[a]**c[b]) ans %= mod ...
p03042
s942774569
Wrong Answer
a=input() b=int(a[0]+a[1]) c=int(a[2]+a[3]) if b>12 or b==0: if c>12 or c==0: print("Na") else: print("YYMM") elif c>12 or c==0: if b>12 or b==0: print("Na") else: print("MMYY") else: print("AMBIGUOUS")
p02792
s295686243
Wrong Answer
n=int(input()) def f(x,y): ret=0 for i in range(1,n): s,e=int(str(i)[0]),int(str(i)[-1]) if x==s and y==e: ret+=1 return ret ans=0 for i in range(1,10): for j in range(1,10): ans+=f(i,j)*f(j,i) print(ans)
p02814
s877390842
Accepted
from fractions import gcd def lcm(p,q): return p*q//gcd(p,q) N, M = map(int, input().split()) a = [int(i)//2 for i in input().split()] x = 1 for i in range(N): x = lcm(x, a[i]) for i in range(N): if (x//a[i])%2==0: print(0) exit() num = M//x print(num//2 if num%2==0 else num//2+1)
p02600
s142575460
Wrong Answer
x=int(input()) if 400<=x<=599:print(8) elif 600<=x<799:print(7) elif 800<=x<999:print(6) elif 1000<=x<1199:print(5) elif 1200<=x<1399:print(4) elif 1400<=x<1599:print(3) elif 1600<=x<1799:print(2) elif 1800<=x<1999:print(1)
p02623
s516653344
Accepted
from bisect import bisect_right n,m,k=map(int,input().split()) a=list(map(int,input().split())) b=list(map(int,input().split())) a_ac=[0] for i in range(1,n+1): a_ac.append(a_ac[i-1]+a[i-1]) b_ac=[0] for i in range(1,m+1): b_ac.append(b_ac[i-1]+b[i-1]) #print(a_ac) #print(b_ac) ans=0 for i in range(n+1): rem...
p02948
s593973123
Accepted
import heapq from collections import defaultdict N, M = map(int, input().split()) salary = defaultdict(list) for i in range(N): a, b = map(int, input().split()) salary[a].append(-b) sv = [] heapq.heapify(sv) ans = 0 for i in range(1, M+1): for j in range(len(salary[i])): heapq.heappush(sv, salary[...
p03625
s036759277
Wrong Answer
import collections N = int(input()) A = list(map(int,input().split())) A.sort() ans = 0 items = list(set(A)) count = [0]*len(items) items.reverse() for i in range(N): count[items.index(A[i])] += 1 for i in range(len(count)): if ans == 0: if count[i] >= 4: ans = items[i]**2 brea...
p03360
s584054730
Accepted
def main(): a, b, c = map(int, input().split()) k = int(input()) p = pow(2, k) print(a + b + c - max(a,b,c) + max(a,b,c)*p) if __name__ == '__main__': main()
p02594
s978028082
Wrong Answer
n = int(input()) if n>=30: print('YES') else: print('NO')
p02702
s367423445
Wrong Answer
s=input() n=len(s) MOD=2019 l=[] for i in range(n-1,-1,-1): l.append(int(s[i:n])%MOD) print(l) from collections import Counter c=Counter(l) print(c) ans=0 for i in c.values(): ans+=i*(i-1)//2 print(ans)
p03679
s936393871
Wrong Answer
x,a,b = map(int,input().split()) if a > b: print('delicious') elif (b-a) <= x: print('safe') else: print('dangerous')
p03250
s224082849
Wrong Answer
A, B, C = sorted(map(int, input().split())) print(10*C + B + C)
p02717
s170624195
Wrong Answer
i = input() l = i.split() print(l) print(l[2] + ' ' + l[0] + ' ' + l[1])
p03605
s187185924
Accepted
print("Yes" if "9" in input() else "No")
p02641
s081985843
Accepted
x, n = map(int, input().split()) q = list(map(int, input().split())) p = [] for i in range(102): if not i in q: p.append(i) l = [] for i in p: l.append(abs(i - x)) print(p[l.index(min(l))])
p03607
s224779214
Accepted
N=int(input()) A=[int(input()) for x in range(N)] y=set() for i in A: if i in y: y.remove(i) else: y.add(i) print(len(y))
p03408
s414421780
Wrong Answer
from collections import defaultdict d = defaultdict(int) n = int(input()) for _ in range(n): d[input()] += 1 m = int(input()) for _ in range(m): d[input()] -= 1 print(max(d.values()))
p03795
s415167921
Accepted
# coding: utf-8 N = int(input()) ans = 800*N - N//15*200 print(ans)
p02695
s799782848
Wrong Answer
N, M, Q = map(int, input().split()) ABCD = [list(map(int, input().split())) for i in range(Q)] ABCD.sort(key=lambda x: x[3], reverse=True) A = [1 for _ in range(N)] for i in range(Q): if not(A[ABCD[i][0]-1] + ABCD[i][2] > M): A[ABCD[i][1]-1] = A[ABCD[i][0]-1] + ABCD[i][2] ans = 0 for i in range(Q): if ...
p02691
s778271459
Accepted
from collections import defaultdict dic = defaultdict(int) N = int(input()) A = list(map(int, input().split())) for i, a in enumerate(A): dic[i + a] += 1 counter = 0 for i, a in enumerate(A): counter += dic[i-a] print(counter)
p02924
s079956833
Accepted
n = int(input()) print(n*(n-1)//2)
p03136
s970215260
Accepted
inf = 10**9+7 mod = 10**9+7 n = int(input()) a = list(map(int, input().split())) maxa = max(a) a.remove(maxa) if maxa < sum(a): print('Yes') else: print('No')
p03485
s660835820
Accepted
a,b=map(int,input().split()) c=(a+b)/2 if c%1==0: print(int(c)) else: print(int((c//1)+1))
p03251
s685205108
Wrong Answer
def main(): N,M,X,Y = map(int,input().split()) x_s = list(map(int,input().split())) y_s = list(map(int,input().split())) x_max = max(x_s) y_min = min(y_s) ok = False for z in range(X+1,Y+1): if z <= x_max or z > y_min: ok = True break answer = "War" i...
p03323
s504501570
Wrong Answer
#!/use/bin/env python3 import math from collections import defaultdict (a, b) = [int(s) for s in input().split()] ans = 'Yay!' if a > 8 or b > 8: ans = ':)' print(ans)
p02982
s953122320
Wrong Answer
n,d=map(int,input().split()) l=[list(map(int,input().split())) for i in range(n)] ans=0 cnt=0 for i in range(n-1): for j in range(i+1,n): for k in range(d): siki=((l[i][k]-l[j][k])**2) ans+=siki flag=False for o in range(ans): if o*o==ans: ...
p02780
s030414186
Accepted
from sys import stdin import sys import math from functools import reduce import functools import itertools from collections import deque n,k = [int(x) for x in stdin.readline().rstrip().split()] p = [(int(x)+1)/2 for x in stdin.readline().rstrip().split()] m = sum(p[0:k]) maxm = m for i in range(1,n-k+1): m = m...
p02691
s479552496
Accepted
N = int(input()) A = [int(i) for i in input().split()] B = [A[i]-(i+1) for i in range(N)] C = sorted(B) from bisect import bisect from bisect import bisect_right from bisect import bisect_left ans=0 for i in range(N): target = -2*(i+1)-B[i] l=bisect_left(C, target) r=bisect_right(C, target) ans+=r-l p...
p03719
s238964700
Wrong Answer
A, B, C = input().split() if C >= A: if C <= B: print('Yes') else: print('No') else: print('No')