problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02726
s722509289
Wrong Answer
N, X, Y = list(map(int,input().split())) X -= 1 Y -= 1 out = [0]*N for i in range(N-1): for j in range(i+1,N): out[min(j-i, abs(i-X)+1+abs(j-Y))] += 1 for i in range(N-1): print(out[i])
p03944
s710022967
Wrong Answer
import sys input = sys.stdin.readline W,H,N = list(map(int,input().split())) x0 = 0 y0 = 0 x1 = W y1 = H X = [x0,x1,y0,y1] for i in range(N): x,y,a = list(map(int,input().split())) if a == 1: x0 = x elif a == 2: x1 = x elif a == 3: y0 = y elif a == 4: y1 = y print(max(0,(x1-x0)*(y1-y0)))
p04030
s430824522
Accepted
s = input() a = "" for i in s: if i == "0": a+="0" elif i == "1": a+="1" else: if a!="": a=a[:-1] print(a)
p03592
s240903517
Wrong Answer
n, m, k = map(int, input().split()) for i in range(n): for j in range(m): if i * (m - j) + j * (n - i) == k: print("Yes") exit() print("No")
p02576
s450005425
Wrong Answer
def main(): N, X, T = map(int, input().split()) print(T * (N//X+1)) if __name__ == "__main__": main()
p02866
s254925243
Accepted
import collections n=int(input()) a=list(map(int,input().split())) if a[0]==0 and a.count(0)==1: ans=1 else: ans=0 a=collections.Counter(a) for i in range(max(a)): ans*=a[i]**a[i+1] ans%=998244353 print(ans)
p03555
s169418031
Accepted
a=ina=input() b=input() if a[0]==b[2] and a[1]==b[1] and a[2]==b[0]: print("YES") else: print("NO")
p02953
s636561024
Accepted
N = int(input()) H = list(map(int, input().split())) for i in range(N-1): if H[i+1] > H[i]: H[i+1] -= 1 if H[i+1] < H[i]: print("No") break else: print("Yes")
p02612
s050425314
Accepted
N=int(input()) R=(1000-N%1000)%1000 print(R)
p03565
s571077027
Accepted
S=list(input()) T=list(input()) p=-1; i=0; e=0 for i in range(len(S)-len(T)+1): for j in range(len(T)): if S[j+i]==T[j] or S[j+i]=="?": e=e+1 #print(i,p,e) else: e=0 break if e==len(T): p=i e=0 #print(i,p,e) if p==-1: print("UNRESTORABLE") else: S[p:p+len(T)]=T for i in range(len(S)): if S[i]=="?": S[i]="a" print("".join(S))
p03543
s603598929
Accepted
N = input() if N[0] == N[1] == N[2] or N[1] == N[2] == N[3]: print('Yes') else: print('No')
p02958
s961176760
Accepted
n = int(input()) p = list(map(int,input().rstrip().split())) pp = sorted(p) cnt = 0 for i in range(n): if p[i]!=pp[i]: cnt+=1 if cnt>2: print("NO") else: print("YES")
p03145
s496948129
Wrong Answer
ab,bc,ca = map(int,input().split()) print(ab*bc/2)
p02785
s319253219
Wrong Answer
a,b=input().split() a=int(a) b=int(b) c=list(map(int,input().split())) c.sort() d=sum(c) e=0 if a<=b: print(0) else: for i in range(b): e=e+c[-b] print(d-e)
p04030
s604959261
Accepted
s = list(input()) ans = "" for c in s: if c == "0": ans += "0" if c == "1": ans += "1" if c == "B": if ans != "": ans = ans[:len(ans)-1] print(ans)
p02879
s438737378
Accepted
A, B = map(int, input().split()) if A <= 9 and B <= 9: print(A * B) else: print(-1)
p03659
s483517757
Accepted
from itertools import accumulate N = int(input()) an = list(map(int, input().split())) res = [0] + an res = list(accumulate(res)) ans = 10e+9 for i in range(1, N): ans = min(ans, abs(res[i] - (res[-1]-res[i]))) print(ans)
p03719
s610832985
Accepted
a, b, c = map(int, input().split()) print('Yes' if a <= c <= b else 'No')
p02924
s453267603
Wrong Answer
def main(): ''' N = aq + r (0 <= r <= a-1)よりΣrを最大にするのはr = a-1のとき ''' N = int(input()) N -= 1 print(N * N // 2) if __name__ == '__main__': main()
p03086
s733058624
Accepted
S=input() res=0 for i in range(len(S)+1): for j in range(i): t=True s=S[j:i] for k in range(len(s)): if(s[k]!='A' and s[k]!='C' and s[k]!='G' and s[k]!='T'): t=0 break if(t): res=max(res,len(s)) print(res)
p03219
s421872805
Accepted
x,y=map(int,input().split()) print(x+y//2)
p04045
s328330624
Accepted
N, K = [int(x) for x in input().split()] D = input().split() for payment in range(N, 10*N+1): if all(char not in D for char in str(payment)): print(payment) break
p03711
s869485232
Accepted
x,y=map(int,input().split()) A=[2] B=[4,6,9,11] C=[1,3,5,7,8,10,12] if x in B and y in B: print("Yes") elif x in C and y in C: print("Yes") else: print("No")
p03417
s312070794
Accepted
N,M = map(int,input().split()) if N == 1 and M == 1: ans = 1 elif N == 1: ans = (M-2) elif M == 1: ans = (N-2) else: ans = (M-2) * (N-2) print(ans)
p02784
s263210149
Wrong Answer
a,b=map(int,input().split()) attack=[int(i) for i in input().split()] sum=0 for j in attack: sum+=j if sum>a: print("YES") else: print("NO")
p03761
s719022020
Accepted
N = int(input()) Ss = [] d = 97 for i in range(N): Ss.append(input()) from collections import Counter counter = [float('inf') for i in range(26)] for S in Ss: D = Counter(S) for key in range(d,d+26): counter[key-d] = min(D[chr(key)],counter[key-d]) ans = '' for i,e in enumerate(counter): if e == float('inf'): continue for j in range(e): ans += chr(i+d) print(ans)
p02924
s447048794
Wrong Answer
def main(): n = int(input()) print(n * (n - 1) / 2) main()
p02628
s897843333
Wrong Answer
N,K = map(int,input().split()) p = [int(m) for m in input().split()] p.sort() ans = 0 if K == 1: print(*p) elif K == 2: print(p[0]+p[1]) else: for i in range(K): ans += p[i] print(ans)
p03012
s298847243
Wrong Answer
n = int(input()) w = list(map(int,input().split())) l = [] for i in range(n-1): a = abs(sum(w[0:i+1]) - sum(w[i+1:n+1])) l.append(a) print(l.index(min(l))+1)
p02971
s042363376
Accepted
N=int(input()) A=[int(input()) for i in range(N)] B=sorted(A) for i in A: if i==B[-1]: print(B[-2]) else: print(B[-1])
p02732
s002840600
Accepted
from collections import Counter N = int(input()) A = list(map(int, input().split())) cnt = Counter(A) cmb = 0 for a, c in cnt.items(): if c >= 2: cmb += c * (c - 1) // 2 for a in A: minus = 0 if cnt[a] < 2 else cnt[a] * (cnt[a]-1) // 2 c = cnt[a] - 1 plus = 0 if c < 2 else c * (c-1) // 2 ans = cmb - minus + plus print(ans)
p03625
s882612159
Wrong Answer
N = int(input()) A = map(int, input().split()) import collections A_count = collections.Counter(A) keys = sorted(list(A_count.keys()), reverse=True) hen_list = [] flag = 0 for key in keys: if A_count[key] >= 4: hen_list.append(key) hen_list.append(key) if A_count[key] >= 2: hen_list.append(key) if len(hen_list) == 2: flag = 1 break if flag == 1: print(hen_list[0] * hen_list[1]) else: print(0)
p02848
s538283320
Accepted
n = int(input()) s = input() ans = [] for i in range(len(s)): ans.append( chr((ord(s[i]) + n - 65) % 26 + 65) ) for i in range(len(s)): print(ans[i], end='') print()
p02923
s534308130
Accepted
n=int(input()) H=list(map(int, input().split())) ans = 0 p = 0 for i in range(n-1): if H[i] >= H[i+1]: p += 1 else: ans = max(ans, p) p = 0 ans = max(ans, p) print(ans)
p02622
s700691435
Wrong Answer
S=list(input()) T=list(input()) b=0 print(S) print(T) for i in range(0,len(S)): if S[i]!= T[i]: b+=1 print(b)
p02553
s231611748
Accepted
def main(): a, b, c, d = tuple([int(_x) for _x in input().split()]) print(max(a*c, a*d, b*c, b*d)) main()
p02952
s849953493
Accepted
n = int(input()) cnt = 0 for i in range(1, n+1): if len(str(i)) % 2 == 1: cnt += 1 print(cnt)
p03797
s139737603
Accepted
N, M = map(int, input().split()) real = M - 2*N if real < 0: ans = M // 2 elif real == 0: ans = real else: a = real // 4 ans = a + N print(ans)
p03146
s777953128
Accepted
s =int(input()) sl =[s] for i in range(10**6): if sl[-1]%2 ==0: new_sl =sl[-1] //2 else: new_sl =3*sl[-1]+1 if new_sl in sl: print(i+2) break sl.append(new_sl)
p04012
s463973961
Accepted
w = input() for i in range(len(w)): if w.count(w[i]) % 2 == 1: print('No') exit() print('Yes')
p02659
s128652523
Accepted
import math from decimal import Decimal a, b = map(float, input().split()) print(math.floor(Decimal(str(a))*Decimal(str(b))))
p03997
s663979155
Accepted
print((int(input()) + int(input())) * int(input()) // 2)
p02786
s599159898
Accepted
import math H = int(input()) ans = 1 atk = 1 while H > 1: H = math.floor(H/2) atk *= 2 ans += atk print(ans)
p03338
s366197781
Wrong Answer
n = int(input()) s = input() a = [] ans = 0 for i in s: a.append(i) for i in range(n): b = set(a[:i + 1]) & set(a[i:]) ans = max(ans, len(b)) print(ans)
p02678
s318196894
Wrong Answer
print('No')
p03457
s192286878
Accepted
N = int(input()) T, X, Y = 0, 0, 0 count = 0 for i in range(N): t, x, y = map(int, input().split()) dt = t - T dist = abs(x - X) + abs(y - Y) if dist <= dt and t%2 == (x+y)%2: count += 1 T, X, Y = t, x, y print('Yes' if count == N else 'No')
p02831
s730717200
Accepted
import math as mp a,b=map(int,input().split()) print(a*b//mp.gcd(a,b))
p02786
s983587088
Accepted
import sys def I(): return int(sys.stdin.readline()) def LI(): return [int(x) for x in sys.stdin.readline().split()] def main(): H = I() count = 0 while(H>0): H = H // 2 count += 1 print(pow(2,count)-1) if __name__ == "__main__": main()
p03681
s264738064
Accepted
mod = 10**9+7 n, m = map(int, input().split()) if abs(n-m) >= 2: print(0) exit() x, y = 1, 1 for i in range(1, n+1): x *= i x %= mod for i in range(1, m+1): y *= i y %= mod if n == m: print((2*x*y)%mod) else: print((x*y)%mod)
p03994
s250306526
Accepted
S = input() K = int(input()) oz = ord("z") ans = "" for s in S[:-1]: if s != "a" and oz+1-ord(s) <= K: K -= oz+1-ord(s) ans += "a" else: ans += s ans += chr(((ord(S[-1])-ord("a")+K)%26)+ord("a")) print(ans)
p03944
s484619836
Accepted
W,H,N = map(int,input().split()) Xu,Xd,Yu,Yd=W,0,H,0 for i in range(N): x,y,a = map(int,input().split()) if a==1: Xd=max(Xd,x) elif a==2: Xu=min(Xu,x) elif a==3: Yd=max(Yd,y) elif a==4: Yu=min(Yu,y) X = max(0,Xu-Xd) Y = max(0,Yu-Yd) print(X*Y)
p02790
s631296424
Accepted
a,b = map(int,input().split()) ans = "" if a > b: for i in range(a): ans += str(b) else: for i in range(b): ans += str(a) print(ans)
p02664
s336187791
Wrong Answer
T = list(input()) N = len(T) for i in range(N): if i < N-1: if T[i] == '?': if T[i+1] == '?': T[i] = 'P' T[i+1] = 'D' elif T[i+1] == 'D': T[i] = 'P' else: T[i] = 'D' else: if T[i] == '?': T[i] = 'D' print(''.join(T))
p02777
s263779819
Accepted
s ,t= [x for x in input().split()] A , B = [int(x) for x in input().split()] U = input() if s != t: if U == t : B -=1 if U == s: A-= 1 print('{} {}'.format(A,B))
p02639
s014696490
Accepted
x = list(map(int, input().split())) # 0が何番目に有るか リストなので+1 print(x.index(0) + 1)
p03239
s586973021
Wrong Answer
def main(): N, T = map(int, input().split()) min_c = 1001 for _ in range(N): c, t = map(int, input().split()) if t <= T and c < min_c: min_c = c if min_c == 1001: print("LTE") else: print(min_c) if __name__ == '__main__': main()
p03285
s495660743
Wrong Answer
import math N = int(input()) a = math.ceil(N / 4) b = math.ceil(N / 7) ans = "No" for i in range(a): for j in range(b): if i * 4 + j * 7 == N: ans = "Yes" break else: continue break print(ans)
p02833
s325823509
Accepted
n=int(input()) ans=0 tmp=0 p=1 if n%2==0: k=n//2 while True: tmp =k//pow(5,p) ans+=tmp p+=1 if tmp==0: break print(ans)
p03377
s295233244
Accepted
import sys input = sys.stdin.readline # sys.setrecursionlimit(100000) def main(): A, B, X = [int(i) for i in input().strip().split()] for i in range(B+1): if A + i == X: return "YES" return "NO" if __name__ == "__main__": print(main())
p03486
s265322269
Accepted
s=sorted(input()) t=sorted(input(),reverse=True) if ''.join(t)>''.join(s): print('Yes') else: print('No')
p03543
s192715446
Accepted
n=input() print("Yes" if n[0]==n[1]==n[2]or n[1]==n[2]==n[3] else "No") #or and notを使う
p03673
s292125289
Wrong Answer
from collections import deque n = int(input()) a = list(map(int,input().split())) b = deque() for i in range(n): if i%2==0: b.append(a[i]) else: b.appendleft(a[i]) print(*b)
p03495
s895944767
Wrong Answer
ma = lambda :map(int,input().split()) n,k = ma() A = list(ma()) import collections co = collections.Counter(A) print(max(0,len(co.items()) -k))
p03767
s469305685
Accepted
#-*-coding:utf-8-*- import sys input=sys.stdin.readline import numpy as np def main(): numbers=[] dp=[] n = int(input()) numbers=np.array(list(map(int,input().split())),dtype=int) numbers.sort() print(numbers[n::2].sum()) if __name__=="__main__": main()
p02787
s716165663
Accepted
import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x+"\n") h,n = map(int, input().split()) a = [None]*n b = [None]*n for i in range(n): a[i], b[i] = map(int, input().split()) dp = [float("inf")]*(h+1) dp[0] = 0 for i in range(n): for j in range(1,h+1): dp[j] = min(dp[j], dp[max(0, j-a[i])] + b[i]) print(dp[h])
p03011
s887136959
Wrong Answer
num_list = list(map(int, input().split())) s_List = sorted(num_list) print(num_list[0] + num_list[1])
p02602
s478802415
Accepted
m, n = map(int, input().split()) l = list(map(int, input().split())) for i in range(m-n): if l[i] < l[i+n]: print('Yes') else: print('No')
p02761
s291194760
Accepted
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) n, m = map(int, readline().split()) sc = [list(map(int, readline().split())) for _ in range(m)] max_dig = 10 ** n min_dig = 10 ** (n - 1) if n == 1: min_dig -= 1 for dig in range(min_dig, max_dig): dig = str(dig) for s, c in sc: if dig[s - 1] != str(c): break else: print(dig) exit() print(-1)
p02789
s533315789
Accepted
a,b=map(int,input().split()) if a==b: print('Yes') else: print('No')
p03524
s315690111
Wrong Answer
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) from collections import Counter s = read().rstrip().decode() size = len(s) flag = True for v in Counter(list(s)).values(): if v > size // 2: print('NO') exit() if size % 2 == 1: if v % 2 == 1: flag = False if size % 2 == 1 and flag: print('NO') else: print('YES')
p03252
s073220366
Wrong Answer
S = str(input()) T = str(input()) alp = "abcdefghijklmnopqrstuvwxyz" for i in range(0,min(len(S),len(alp))): if S[i] != T[i]: S = S.translate(str.maketrans({S[i]:T[i], T[i]:S[i]})) else: pass if S == T: print("Yes") exit() print("No")
p02848
s398201555
Accepted
N = int(input()) S = input() for i in range(len(S)): if (ord(S[i]) + N) > 90: print(chr(ord(S[i]) + N - 90 + 64), end="") else: print(chr(ord(S[i]) + N ), end="")
p04011
s182860373
Wrong Answer
n = input('N:') k = input('K:') x = input('X:') y = input('Y:') n = int(n) k = int(k) x = int(x) y = int(y) if n >= k: total = k * x + (n - k) * y else: total = n * x print(total)
p02755
s027353480
Accepted
from math import floor A, B = map(int, input().split()) ans = 10**9 for i in range(1, 100000): a = floor(i * 0.08) b = floor(i * 0.1) if a == A and b == B: ans = min(ans, i) if ans == 10**9: print(-1) else: print(ans)
p03136
s966851863
Accepted
N = int(input()) L = list(map(int, input().split())) sortL = sorted(L) print('Yes' if sortL[-1] < sum(sortL[:-1]) else 'No')
p04044
s742903685
Accepted
n, l=map(int, input().split()) s=[input() for _ in range(n)] s.sort() print(''.join(s[i] for i in range(n)))
p03379
s609029995
Wrong Answer
N = input() problemList = input().split() currentList = [] for i in range(int(N)): for n in range(int(N)): currentList.append(problemList[n]) del currentList[i] sortedList = sorted(currentList, reverse = True) CentralNumber = int(int(N) / 2) - 1 print(sortedList[CentralNumber]) currentList = []
p02744
s985959042
Wrong Answer
N = int(input()) def dfs(x): if len(x) == N: s = "".join(chr(v + ord("a")) for v in x) print(s) return val = x[-1] if x else 0 for i in range(val + 2): x.append(i) dfs(x) x.pop() dfs([0])
p03665
s061542856
Accepted
n , p = map(int, input().split()) a = list(map(int,input().split())) b = [0]*n for i in range(n): b[i]=a[i]%2 ans=2**(n-1) if p==1 and sum(b)==0: ans = 0 if p==0 and sum(b)==0: ans *= 2 print(ans)
p02753
s445733799
Accepted
s = input() if s == "AAA" or s == "BBB": print("No") else: print("Yes")
p02691
s666709190
Accepted
n=int(input()) l=list(map(int,input().split())) an=0;d={} for i in range(n): d[l[i]+i]=d.get(l[i]+i,0)+1 an+=d.get(i-l[i],0) print(an)
p02779
s096481876
Accepted
n=int(input()) l=input().split() l.sort() flag=1 for i in range(n-1): if l[i]==l[i+1]:flag=0 if flag==1:print("YES") else:print("NO")
p03371
s667622066
Accepted
a,b,c,x,y=map(int,input().split()) if (a+b)>2*c: if x>y: if a>2*c: print(y*2*c+(x-y)*c*2) else: print(y*2*c+(x-y)*a) else: if b>2*c: print(x*2*c+(y-x)*c*2) else: print(x*2*c+(y-x)*b) else: print(x*a+y*b)
p02548
s957449798
Accepted
def main(): n = int(input()) ans = 0 for i in range(2,n): ans += (n - 1) // i ans += n - 1 print(ans) return if __name__ == "__main__": main()
p03250
s600160016
Wrong Answer
a,b,c=map(int,input().split()) print(max(a,b,c)+a+b+c)
p02627
s008143342
Wrong Answer
x=input() y='x'.isupper() if y=='true': print('A') else: print('a')
p03773
s282974174
Wrong Answer
A, B = map(int,input().split()) print(A + B % 24)
p02681
s572948402
Accepted
def Int(): return int(input()) def Ints(): return map(int,input().split()) def IntList(): return list(Ints()) def IntMat(N): return [IntList() for i in range(N)] import sys sys.setrecursionlimit(4100000) rl = sys.stdin.readline s = input() t = input() flag = 1 l = len(s) for i in range(l): if s[i]!=t[i]: flag = 0 break if flag == 1: print('Yes') else: print('No')
p02631
s562093063
Accepted
from functools import reduce from operator import xor n = int(input()) list_a = list(map(int, input().split())) xorsum = reduce(xor, list_a) list_n = [xor(xorsum, a) for a in list_a] print(' '.join(map(str, list_n)))
p03524
s249231769
Accepted
from collections import Counter s = list(input()) count = Counter(s) if len(s) <= 3: if len(s) == 1: print("YES") elif len(count.keys()) == len(s): print("YES") else: print("NO") else: if len(count.keys()) <= 2: print("NO") elif max(count.values()) - min(count.values()) <= 1: print("YES") else: print("NO")
p03719
s925818327
Accepted
A,B,C = map(int,input().split()) print("Yes") if A<=C<=B else print("No")
p03774
s679282001
Wrong Answer
N,M=map(int,input().split()) A=[list(map(int,input().split())) for i in range(N)] C=[list(map(int,input().split())) for i in range(M)] for i in range(N): z=10**10 ans=0 for t in range(M): if (abs(A[i][0]-C[t][0])+abs(A[i][1]-C[t][1]))<z: z=(abs(A[i][0]-C[t][0])+abs(A[i][0]-C[t][1])) ans=t+1 else: continue print(ans)
p03000
s254793345
Accepted
n, x = map(int, input().split()) l = list(map(int, input().split())) d = [0] for i in range(1, n+1): d.append(d[i-1]+l[i-1]) cnt = 0 for j in d: if j <= x: cnt += 1 print(cnt)
p03286
s404475910
Accepted
import sys,math,collections,itertools input = sys.stdin.readline N=int(input()) s = [] if N ==0: print(0) exit() while N: r = N%(-2) if r<0: r+=2 N = (N-r)//(-2) s.append(str(r)) print(''.join(s)[::-1])
p02818
s251533447
Accepted
a, b, k = map(int, input().split()) if k <= a: print(a-k, b) else: print(0, max(a+b-k, 0))
p03627
s913603390
Accepted
N = int(input()) A = sorted(list(map(int, input().split())), reverse=True) s = set() U = [] ans = 0 for a in A: if a in s: U.append(a) if len(U) >= 2: ans = U[0]*U[1] break s.remove(a) else: s.add(a) print(ans)
p03486
s008957791
Accepted
s = sorted(input()) t = sorted(input())[::-1] if s < t: print('Yes') else: print('No')
p02791
s088678811
Wrong Answer
n=int(input()) lists=list(map(int,input().split())) mn=2*10^5+1 cnt=0 for li in lists: if mn>li: mn=li cnt+=1 print(cnt)
p02847
s071304900
Accepted
s = input() if s=="SAT": print(1) elif s=="FRI": print(2) elif s=="THU": print(3) elif s=="WED": print(4) elif s=="TUE": print(5) elif s=="MON": print(6) else: print(7)
p03438
s150231053
Accepted
N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) score = 0 for a, b in zip(A, B): diff = b - a if diff > 0: score += diff // 2 else: score += diff print("Yes") if score >= 0 else print("No")