problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03131
s470909433
Wrong Answer
K,A,B=map(int,input().split(' ')) if K<A+1: print(K) else: print(max(K+1,B+(B-A)*max(0,(K-(A+1))//2)+max(0,(K-(A+1)))%2))
p03017
s292150222
Accepted
N, A, B, C, D = map(int, input().split()) S = input() if C < D: if '##' in S[A-1:C] or '##' in S[B-1:D]: print('No') else: print('Yes') else: if '...' in S[B-2:D+1] and '##' not in S[A-1:C]: print('Yes') else: print('No')
p02708
s422252472
Wrong Answer
n,k = map(int,input().split()) cnt = 0 for i in range(k,n+2): cnt += n * (n + 1) / 2 - (n - i) * (n - i + 1) / 2 - i * (i - 1) / 2 + 1 print(cnt % (10 ** 9 + 7))
p03352
s492873164
Accepted
x = int(input()) beki_li = [] for i in range(2, 1001): for j in range(2, 10): if i ** j < 1001 and i**j <= x: beki_li.append(i**j) else: break beki_li.append(1) print(max(beki_li))
p03695
s178505755
Wrong Answer
import sys from collections import deque from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値) from heapq import heapify, heappop, heappush sys.setrecursionlimit(10**6) INF = 10**20 def mint(): return map(int,input().split()) def lint(): return map(int,input().split()) def judge(x, l=['Yes', 'No']): print(l[0] if x else l[1]) N = int(input()) A = lint() S = set() pro = 0 for a in A: if a//400<8: S.add(a//400) else: pro += 1 print(max(1,len(S)),min(8,len(S)+pro))
p04034
s255382187
Accepted
N,M = map(int,input().split()) ans = [0]*N ans[0] = 1 ball = [1]*N for _ in range(M): x,y = map(int,input().split()) x -= 1 y -= 1 if ans[x]: ans[y] = 1 ball[x] -= 1 ball[y] += 1 if not ball[x]: ans[x] = 0 print(sum([i*(j>0) for i,j in zip(ans,ball)]))
p03543
s661388239
Accepted
a,b,c,d=input() print("Yes" if a==b==c or b==c==d else "No")
p02789
s748902192
Wrong Answer
inout=input() if(inout[0]==inout[1]): print("Yes") else: print("No")
p02854
s489417644
Wrong Answer
n = int(input()) a = list(map(int, input().split())) for i in range(1, n): a[i] += a[i - 1] ans = n for x in a[:n-1]: ans = min(ans, abs(a[n-1] - 2 * x)) print(ans)
p02777
s311126601
Wrong Answer
s,t = input().split() a,b = list(map(int, input().split())) u = input() if u == s: print(a, b) else: print(a, b-1)
p03479
s006890947
Accepted
#!/usr/bin/env python3 import sys input = sys.stdin.readline def IS(cb): return cb(input().strip()) def IL(cb): return [cb(s) for s in input().strip().split()] def IR(cb, rows): return [IS(cb) for _ in range(rows)] def ILL(cb, rows): return [IL(cb) for _ in range(rows)] def solve(): X, Y = IL(int) ans = 1 while Y // 2 >= X: ans += 1 Y //= 2 print(ans) solve()
p02708
s237412334
Accepted
N,K = map(int,input().split()) number = N+1-K+1 W = 0 for i in range(number): min = (K+i)*(K+i-1)/2 max = (K+i)*(2*N-K-i+1)/2 W += (max-min+1) w = W % (1000000007) print(int(w))
p03359
s438589915
Wrong Answer
a,b = map(int,input().split()) if a>b: a -1 else: a
p03106
s075073427
Accepted
a,b,k = map(int,input().split()) abmin = min(a,b) nums = [] for i in range(abmin): if a % (i + 1) == 0 and b % (i+1) == 0: nums.append(i+1) list.sort(nums,reverse=True) print(nums[k-1])
p03105
s911212920
Accepted
import sys sys.setrecursionlimit(10 ** 5 + 10) def input(): return sys.stdin.readline().strip() def resolve(): a,b,c=map(int,input().split()) if b>=a*c: print(c) else: print(b//a) resolve()
p03345
s449390469
Accepted
A, B, C, K = map(int, input().split()) if K % 2 == 1: print(B-A) elif K % 2 == 0: print(A-B)
p02756
s746719929
Accepted
# coding: utf-8 import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) S = sr() Q = ir() rev = 0 top = '' tail = '' # xor for _ in range(Q): x = sr().split() if x[0] == '1': rev ^= 1 else: _, f, c = x if (int(f)^rev) & 1: top += c else: tail += c answer = top[::-1] + S + tail if rev&1: answer = answer[::-1] print(answer) # 40
p02729
s609704714
Wrong Answer
a,b=map(int,input().split()) c=0 while a>1 or b>1: a=a-2 b=b-2 c=c+1 print(c)
p04012
s454970562
Wrong Answer
s = input() d = {} for letter in s: if letter in d: d[letter] += 1 else: d[letter] = 1 for i in d.values(): if i % 2 != 0: print("No") print("Yes")
p03127
s044034983
Accepted
import sys from math import gcd input = sys.stdin.readline N = int(input()) res = 0 a = list(map(int, input().split())) for x in a: res = gcd(res, x) print(res)
p02547
s649906186
Accepted
def main(): N = int(input()) zorome_count = 0 for i in range(N): d1, d2 = map(int, input().split()) if d1 == d2: zorome_count += 1 else: zorome_count = 0 if zorome_count == 3: print('Yes') return print('No') if __name__ == '__main__': main()
p03494
s909119437
Wrong Answer
import numpy as np A = list(map(int,input().split())) count = 0 while all(a % 2 == 0 for a in A): A = [a/2 for a in A] count += 1 print(count)
p02546
s915727395
Accepted
s = input() if s[-1] == "s": print(s+"es") else: print(s+"s")
p02947
s691883216
Wrong Answer
from collections import Counter N = int(input()) S =[] for i in range(N): S.append(str(input())) B =[] for i in S: S1 =list(Counter(i).items()) #S1 =sorted(S1, reverse = False) B.append(S1) cnt = 0 for i in range(N-1): for j in range(i+1,N): if B[i] == B[j]: cnt += 1 print(cnt)
p03262
s171233382
Wrong Answer
N, X = [int(i) for i in input().split()] x = [int(i) for i in input().split()] ans = 10e9 for i in range(N): ans = min(ans, abs(X - x[i])) print(ans)
p02618
s622188543
Accepted
import sys input=sys.stdin.readline d=int(input()) C=list(map(int,input().split())) S=[list(map(int,input().split())) for _ in range(d)] A=[sorted([[j,S[i][j]] for j in range(26)],key=lambda x:x[1],reverse=True) for i in range(d)] DP=[0]*26 for i in range(d): num,index=0,0 for j in range(26): if A[i][j][1]-(C[j]*(i-DP[j]))>num: num=A[i][j][1]-C[j]*(i-DP[j]) index=j DP[index]=i print(index+1)
p02953
s274995191
Wrong Answer
N = int(input()) H = list(map(int,input().split())) if N>1: for i in range(N-1,0,-1): if H[i] < H[i-1] : H[i-1] -= 1 if sorted(H) != H: print('NO') else: print('YES')
p03721
s088880092
Wrong Answer
L=[0 for _ in range(10**5)] n,k=map(int,input().split()) for i in range(n): a,b=map(int,input().split()) L[a-1]+=b tmp=0 for j in range(n): tmp+=L[j] if tmp>=k: print(j+1) break
p03761
s159533809
Accepted
N = int(input()) ordA = ord("a") mozilist = [0] * 26 for k in range(26): mozilist[k] = [0]*N for i in range(N): S = input() for j in range(len(S)): mozilist[ord(S[j]) - ordA][i] += 1 ans = "" for p in range(26): numofthealphabet = min(mozilist[p]) ans += chr(ordA + p) * numofthealphabet print(ans)
p02659
s651944225
Accepted
import decimal A,B = input().split() A = decimal.Decimal(A) B = decimal.Decimal(B) print(int(A*B))
p02918
s162655204
Accepted
n,k=map(int,input().split()) s=input() a=[] cnt=0 flag=s[0] for i in range(1,n): if flag==s[i]:cnt+=1 else: flag=s[i] a+=[cnt] cnt=0 a+=[cnt] print(min(sum(a)+2*k,n-1))
p03433
s740191394
Accepted
n=int(input()) a=int(input()) if n%500<=a: print("Yes") else: print("No")
p03943
s691347367
Accepted
x = list(map(int, input().split())) if max(x) == sum(x) - max(x): print("Yes") else: print("No")
p02988
s422615925
Wrong Answer
n=int(input()) l=list(map(int,input().split())) cnt=0 for i in range(n-2): if l[i]<l[i+1]<l[i+2]: cnt+=1 print(cnt)
p04019
s186696184
Accepted
S = list(input()) ans = True if ("N" in S) and not("S" in S): ans = False if ("S" in S) and not("N" in S): ans = False if ("W" in S) and not("E" in S): ans = False if ("E" in S) and not("W" in S): ans = False if ans: print("Yes") else: print("No")
p03814
s682365112
Accepted
s=input() a=s.find("A") z=s.rfind("Z") print(z-a+1)
p03803
s762864739
Wrong Answer
a,b=map(int,input().split()) if a==1 and b!=1 : print('Alice') elif a>b: print('Alice') elif a<b: print('Bob') elif a!=1 and b==1: print('Bob') else: print('Draw')
p03041
s349937807
Accepted
# coding: utf-8 N, K = map(int, input().split()) # print(N, K) S = input() # print(S) # print(chr(ord(S[K -1]) + 32)) s = "" for i in range(N): if i == K - 1: s += chr(ord(S[K -1]) + 32) else: s += S[i] print(s)
p03360
s800939738
Wrong Answer
s=list(map(int,input().split())) k=int(input()) s.sort() m=1 m *= s[2]*(k+1) print(m+s[0]+s[1])
p02553
s907873151
Accepted
a, b, c, d = map(int, input().split()) print(max(a*c, a*d, b*c, b*d))
p03126
s255027159
Accepted
n, m = map(int, input().split()) a = [] for i in range(n): a += (list(map(int, input().split()))[1:]) ans = 0 for i in range(1, m + 1): if a.count(i) == n: ans += 1 print(ans)
p03767
s708514125
Accepted
n=int(input()) a=sorted(list(map(int,input().split())),reverse=True) ans=sum(a[1::2][:n]) print(ans)
p04031
s767650529
Accepted
n = int(input()) a = list(map(int,input().split())) ans = 100000000 for i in range(-100, 101): s = 0 for j in a: s += (j - i) **2 ans = min(ans , s) print(ans)
p02897
s053140199
Accepted
a=int(input()) odd = 0 for i in range(1, a+1): if i%2==1: odd += 1 print('{:.10f}'.format(odd/a))
p03657
s965395196
Accepted
# AtCoder abc067 a # ストレッチ課題 # 入力 a, b = map(int, input().split()) # 判定 if (a % 3 == 0) or (b % 3 == 0) or ((a + b) % 3 == 0): print("Possible") else: print("Impossible")
p03067
s825678611
Accepted
a,b,c = map(int,input().split()) x = sorted([a,b,c]) ans = "No" if x[1] == c: ans = "Yes" print(ans)
p03448
s439491150
Accepted
a=int(input()) b=int(input()) c=int(input()) x=int(input()) ans=0 for i in range(a+1): for j in range(b+1): for k in range(c+1): if i*500+j*100+k*50==x: ans+=1 print(ans)
p02747
s634634887
Wrong Answer
S=input() h="hi" for i in range(5): if h*i==S: print("Yes") break else: print("No")
p02778
s277403880
Accepted
s = str(input()) n = len(s) ans = "" for i in range(n): ans += "x" print(ans)
p02773
s704648446
Accepted
# coding: utf-8 # Your code here! import collections a = int(input()) li1 = [] for i in range(a): li1.append(str(input())) c = collections.Counter(li1) sorted_items = sorted( c.most_common(), key = lambda x:(x[1],x[0]), reverse=True) key, value = zip(*sorted_items) li2 = [] li2.append(key[0]) for i in range(1,len(key)): if(value[0] == value[i]): li2.append(key[i]) else: break; list.sort(li2) for i in range(len(li2)): print(li2[i])
p02923
s475082141
Accepted
N = int(input()) H = tuple(map(int, input().split())) n_max = 0 n = 0 last = H[-1] for x in H[-2::-1]: if x >= last: n += 1 else: n_max = max(n, n_max) n = 0 last = x n_max = max(n, n_max) print(n_max)
p03471
s713188811
Accepted
def main(): N,Y=map(int,input().split()) for i in range(Y//10000+1): tY=Y-10000*i for j in range(tY//5000+1): k=(tY-5000*j)//1000 if i+j+k==N: print(i,j,k) return print("-1 -1 -1") main()
p02595
s486705075
Accepted
import math n, d = map(int, input().split()) ans = 0 for i in range(0, n): x, y = map(int, input().split()) r = math.sqrt(x ** 2 + y ** 2) if r <= d: ans += 1 print(ans)
p02622
s143667796
Accepted
S = input() T = input() n = 0 for s, t in zip(S, T): if s != t: n += 1 print(n) exit()
p02723
s877746697
Wrong Answer
s = input() s_list = list(s) def has_duplicates(seq): return len(seq) != len(set(seq)) if has_duplicates(s_list): print("Yes") else: print("No")
p03657
s585781820
Accepted
a,b=input().split() a=int(a) b=int(b) if ((a+b)%3)==0: print("Possible") else: if (a%3)==0: print("Possible") else: if (b%3)==0: print("Possible") else: print("Impossible")
p02756
s350585962
Accepted
from collections import * from itertools import * from bisect import * from heapq import * import copy import math from fractions import gcd mod=10**9+7 #N=int(input()) S=input() Q=int(input()) Query=[list(input().split()) for i in range(Q)] lst=deque(S) flag=0 for query in Query: if len(query)==1: flag+=1 flag%=2 else: _,F,C=query if (int(F)+flag)%2: lst.appendleft(C) else: lst.append(C) if flag: lst.reverse() print("".join(lst))
p02951
s679721870
Accepted
import sys def main(): A, B, C = map(int, input().split()) ans = max(0, C - (A-B)) print(ans) return if __name__ == '__main__': main() sys.exit(0)
p02973
s890271886
Wrong Answer
import bisect N = int(input()) LIS = [-1 * int(input())] for _ in range(N-1): A = -1 * int(input()) if A >= LIS[-1]: LIS.append(A) else: LIS[bisect.bisect_left(LIS, A)] = A print(len(LIS))
p02576
s707775369
Wrong Answer
n, x, t = map(int, input().split()) print(((n//x)+1)*t)
p03371
s407361798
Wrong Answer
A, B, C, X, Y = map(int, input().split()) ans = float('inf') if A + B >= 2 * C: p = (2 * max(X, Y)) * C ans = min(ans, p) else: for x in range(X + 1): for y in range(Y + 1): c = max(X - x, Y - y) p = x * A + y * B + (2 * c) * C ans = min(ans, p) print(ans)
p03759
s828675122
Accepted
a,b,c=map(int,input().split()) print("YES" if b-a==c-b else "NO")
p02784
s885366677
Accepted
h,n = map(int, input().split()) a = list(map(int, input().split())) if sum(a) >= h: print('Yes') else: print('No')
p03220
s774037104
Wrong Answer
url = "https://atcoder.jp//contests/abc113/tasks/abc113_b" def main(): input() t, a = list(map(int, input().split())) syuto = list(map(int, input().split())) tempture = [] for s in syuto: tempture.append((a - (t - s * 0.006))) print(tempture.index(min(tempture))+1) if __name__ == '__main__': main()
p04030
s822143591
Accepted
s = list(input()) ans = [] for i in s: if i == "B": if ans == []: pass else: del ans[-1] else: ans.append(i) print("".join(ans))
p03011
s181635703
Wrong Answer
P, Q, R = map(int ,input().split()) print(max(P+Q, Q+R, R+P))
p02681
s600261327
Accepted
s = input() t = input() if s == t[:len(s)]: print('Yes') else: print('No')
p03730
s500815257
Accepted
A, B, C = map(int, input().split()) flag = 0 for i in range(B): if A* i % B == C: flag = 1 break if(flag == 1): print("YES") else: print("NO")
p03479
s023178730
Accepted
def main(): X, Y = map(int, input().split()) ans = 0 while X <= Y: ans += 1 X *= 2 print(ans) if __name__ == "__main__": main()
p03719
s406287631
Accepted
a,b,c = map(int,input().split()) if c >= a and c <= b: print("Yes") else: print("No")
p02765
s314317873
Accepted
n,r = list(map(int,(input().split()))) if n<=10: naibu =(100*(10-n)) print(r+naibu) else: print(r)
p03109
s857814063
Accepted
S=input() print("Heisei" if S<="2019/04/30" else "TBD")
p03471
s069174862
Accepted
n,y = [int(e) for e in input().split()] for i in range(0,n+1): for j in range(0,n-i+1): if 10000*i + 5000*j + 1000*(n-i-j) == y: print(str(i)+" " +str(j) + " " + str(n-i-j)) break else: continue break else: print("-1 -1 -1")
p03087
s234887605
Accepted
N,Q = map(int, input().split()) S = input() Query = [] for _ in range(Q): l,r = map(int, input().split()) Query.append([l,r]) A = [0]*N for i in range(N-2+1): if S[i]=="A" and S[i+1]=="C": A[i] = 1 s = [0]*(N+1) for i in range(0,N,1): s[i+1] = A[i] + s[i] for i in range(Q): l,r = Query[i] print(s[r-1]-s[l-1])
p02577
s061045242
Accepted
n = input() s = str(n) l = len(s) ans = 0 for i in range(l+1): ans += int(s[-i]) p = ans-(int(s[-l])) if p%9 == 0: print("Yes") exit() print("No")
p02725
s372814156
Wrong Answer
k,n = map(int,input().split()) num_list = list(map(int, input().split())) min_num = num_list[0]+num_list[-1] for i in range(0,len(num_list)): res = num_list[-1]-k #print(num_list) num_list.pop(-1) #print(num_list) num_list.insert(0, res) #print(num_list) sum_num = abs(num_list[0])+abs(num_list[-1]) #print("sum_num") #print(sum_num) if sum_num < min_num: min_num = sum_num print(min_num)
p02660
s100478822
Accepted
n=int(input()) d={2:0} while n%2<1: n//=2; d[2]+=1 for i in range(3,int(n**0.5)+1,2): while n%i<1: n//=i; d[i]=d.get(i,0)+1 if n<2: break if n>1: d[n]=1 a=0 for i in d.values(): t=c=0 while t+c<i: c+=1; t+=c a+=c print(a)
p02657
s517889498
Wrong Answer
# 169A # 1.入力をちゃんと受け取る。図解をする # ex: [2 5] a=2 b=5 的な a, b = map(int, input().split()) print(a) print(b) # 2.計算 answer=a*b # 3出力 print(answer)
p03659
s209572091
Accepted
n = int(input()) arr = list(map(int, input().split())) sum1 = 0 sum2 = sum(arr) min_ = 1<<60 for i in range(n-1): sum1 += arr[i] sum2 -= arr[i] min_ = min(min_, abs(sum1 - sum2)) print(min_)
p03545
s251896732
Accepted
A=input() for i in range(2**3): tmp=['-','-','-'] for j in range(3): if ((i>>j)&1): tmp[j]='+' if eval(A[0]+tmp[0]+A[1]+tmp[1]+A[2]+tmp[2]+A[3])==7: print(A[0]+tmp[0]+A[1]+tmp[1]+A[2]+tmp[2]+A[3]+"=7") exit()
p03487
s439434456
Wrong Answer
n = int(input()) al = list(map(int, input().split())) import collections c = collections.Counter(al) res = 0 for i in range(1,n+1): if c[i] ==0: pass elif c[i] ==i: pass else: if c[i] >i: res += c[i]-i else : res +=c[i] print(res)
p02600
s689409778
Accepted
x = int(input()) res = 10 - x // 200 print(res)
p02639
s005950643
Wrong Answer
A, B, C, D, E = map(int, input().split()) result = 15 - (A+B+C+D+E)
p03037
s487711918
Accepted
def resolve(): N, M = map(int, input().split()) start_index = 1 last_index = N for _ in range(M): pp, ss = map(int, input().split()) start_index = max(start_index, pp) last_index = min(last_index, ss) print(max(0, last_index - start_index + 1)) resolve()
p02555
s381434023
Wrong Answer
S = int(input()) M = 0 div = S//3 res = S%3 ans = 0 while div - M > 0: ans_tmp = ((div - M)**(res+3*M))%(10**9+7) ans += ans_tmp M += 1 print(ans%(10**9+7))
p03693
s447082803
Accepted
r, g, b = map(int, input().split()) if (100 * r + 10 * g + b) % 4: print("NO") else: print("YES")
p03624
s214792623
Accepted
S = input() t = list(sorted(list(set(chr(i) for i in range(ord('a'), ord('z') + 1)) - set(S)))) if len(t) == 0: print('None') else: print(t[0])
p02630
s466471051
Accepted
N = int(input()) A = input().split() num_list = [0] * 10**5 ans = 0 for i in range(N): num_list[int(A[i])-1] += 1 for i in range(10**5): ans += (i+1) * num_list[i] Q = int(input()) for i in range(Q): B, C = map(int, input().split()) ans = ans + C * num_list[B-1] - B * num_list[B-1] num_list[C-1] += num_list[B-1] num_list[B-1] = 0 print(ans)
p03624
s664172677
Accepted
import string import sys s = str(input()) low = string.ascii_lowercase fin = '' for i in range(len(low)): if low[i] not in s: print(low[i]) sys.exit() print('None')
p03696
s429502508
Accepted
n=int(input()) s=input() l=[] counter=0 for i in range(n): if s[i]=="(": counter+=1 else: counter-=1 l.append(counter) suml=l[-1] for i in range(n): if l[i]<0: s="("+s for j in range(n): l[j]+=1 suml+=1 if suml>0: s+=")"*suml print(s)
p03377
s530868906
Wrong Answer
a,b,x=map(int,input().split()) if x>=a and a+b>=x: print('YEs') else: print('NO')
p02688
s264903915
Accepted
N, K = map(int, input().split()) A = [] for i in range(K): d = int(input()) A.append(list(map(int, input().split()))) s = set() for i in range(K): for a in A[i]: s.add(a) # print(s) print(N - len(s))
p02627
s710108577
Accepted
str = input() if str.isupper(): print("A") elif str.islower(): print("a")
p03796
s309732665
Wrong Answer
a = 1 for i in range(int(input()),1): a = a * i % 1000000007 print(a)
p03472
s389969764
Wrong Answer
from math import ceil n,h=map(int,input().split()) a=[] b=[] ans=0 for i in range(n): aa,bb=map(int,input().split()) a.append(aa) b.append(bb) b.sort() b.reverse() pin=max(a) for i in range(n): p=b[i] if p<=pin: break ans+=1 h-=p ans+=ceil((h-0.5)/pin) print(ans)
p02817
s403639215
Accepted
S, T = input().split() print(T + S)
p03556
s060832894
Accepted
N=int(input()) print(int(N**(1/2))**2)
p02723
s565297032
Accepted
s = input() if s[2] == s[3] and s[4] == s[5]: print('Yes') else: print('No')
p04020
s943972252
Wrong Answer
N = int(input()) A = [int(input()) for _ in range(N)] res = 0 b = 0 for a in A: res += a//2 a %= 2 if a+b == 2: res += 1 b = 0 else: b = a print(res)
p02775
s397596181
Accepted
n = str(input())[::-1] n = n + "0" l = len(n) ans = 0 flg = 0 check = 0 for i in range(l): check = int(n[i]) check += flg if check == 5: if int(n[i + 1]) >= 5: ans += 5 flg = 1 else: ans += 5 flg = 0 elif check > 5: ans += 10 - check flg = 1 else: ans += check flg = 0 print(ans + flg)