problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02817
s873237025
Wrong Answer
print(*input().split(),sep='')
p02678
s867001403
Accepted
import queue n,m = map(int,input().split()) g = [[] for _ in range(n)] for i in range(m): a,b = map(int,input().split()) g[a-1].append(b-1) g[b-1].append(a-1) q = queue.Queue() q.put(0) d = [-1]*n d[0] = 0 while not q.empty(): v = q.get() for i in g[v]: if d[i] != -1: continue d[i] = v q.put(i) if -1 in d: print("No") else: print("Yes") for i in d[1:]: print(i+1)
p03986
s506254168
Accepted
x = input() n = len(x) stack=[] ans = 1 for i in range(n): if(len(stack) > 0 and x[i] == 'T' and stack[-1] == 'S'): ans += 1 stack.pop() else: stack.append(x[i]) print(len(stack))
p02829
s094812744
Accepted
A = int(input()) B = int(input()) if A + B == 3: print(3) elif A + B == 4: print(2) elif A + B == 5: print(1)
p03106
s185333252
Accepted
a,b,k = map(int,input().split()) l = [] for i in range(1,101)[::-1]: if(a % i == 0 and b % i == 0):l.append(i) print(l[k-1])
p02661
s812225869
Accepted
n = int(input()) a = [] b = [] for i in range(n): x = list(map(int, input().split())) a.append(x[0]) b.append(x[1]) a_sort = sorted(a) b_sort = sorted(b) flags = [False] * n s = 0 if n % 2 == 1: s = b_sort[n//2] - a_sort[n//2] + 1 else: p_min = a_sort[(n//2)-1] p_max = b_sort[(n//2)-1] q_min = a_sort[(n//2)] q_max = b_sort[(n//2)] s = ((p_max+q_max) - (p_min+q_min) ) + 1 print(s)
p03592
s624406830
Wrong Answer
n,m,k = map(int,input().split()) for x in range(1,n+1): for y in range(1,m+1): if (n-x)*y+(m-y)*x==k: print('Yes') exit() print('No')
p03778
s829309127
Wrong Answer
W,a,b = [int(i) for i in input().split()] if a <= b and b <= a + W: print(0) elif a + W < b: print(b-a-W) elif b + W < a: print(a-b-W)
p03644
s054882151
Wrong Answer
N = int(input()) result = [] for i in range(1, N + 1): count = 0 flag = True while flag: i = i / 2 if i % 2 == 0: count += 1 continue else: result.append(count) flag = False print(result.index(max(result))+1)
p03109
s711074553
Accepted
y,m,d=map(int,input().split("/")) if y<2019: print("Heisei") elif y==2019 and m<=4: print("Heisei") else: print("TBD")
p02724
s193572317
Accepted
x = int(input()) print(x // 500 * 1000 + x % 500 // 5 * 5)
p03474
s004518856
Accepted
#!/usr/bin/env python3 # -*- coding: utf-8 -*- def main(): A, B = map(int, input().split()) S = input() N = S[:A] + S[A + 1:] print("Yes" if S[A] == "-" and N.isdigit() else "No") if __name__ == "__main__": main()
p04031
s426034186
Wrong Answer
N = int(input()) l = list(map(int,input().split())) l_ans = [[] for _ in range(201)] for i in range(-100,101): sum = 0 for j in range(N): sum = sum + (i-l[j])**2 l_ans[i+100] = sum print(l_ans) print(min(l_ans))
p03427
s602781580
Accepted
s = input() n = len(s) ok = False ans = 9 if n == 1: print(s) exit() for i in range(n-1): if ok: ans += 9 continue if s[i+1] == '9': ans += ord(s[i]) - ord('0') continue x = ord(s[i]) - ord('0') ans += x-1 ok = True print(ans)
p02842
s495781310
Accepted
import math N = int(input()) X = math.ceil(N / 1.08) if math.floor(X * 1.08) == N: print(X) else: print(':(')
p03037
s392007411
Accepted
n,m=map(int,input().split()) hidari=-10**100 migi=10**100 keep=1 for i in range(m): l,r=map(int,input().split()) if l>migi or r<hidari: keep=0 break elif hidari<=l<=r<=migi: hidari=l migi=r elif l<=hidari<=migi<=r: pass elif l<=hidari<=r<=migi: migi=r elif hidari<=l<=migi<=r: hidari=l if keep==1: res=migi-hidari+1 print(min(res,n)) else: print(0)
p03285
s728384883
Accepted
N = int(input()) flag = 0 if N%4==0 or N%7==0: flag=1 print("Yes") else: for i in range(7,N,7): if (N-i)%4==0: flag=1 print("Yes") break if flag==0: print("No")
p03030
s440604798
Accepted
N = int(input()) city = [] for i in range(N): s, p = input().split() city.append([s, int(p), i+1]) city.sort(key=lambda city: (city[0], -city[1])) for i in city: print(i[2])
p03544
s581508358
Wrong Answer
n = int(input()) l = [2,1] if n>2: for i in range(n-1): l.append(l[i]+l[i+1]) print(l[-1])
p03061
s786669136
Wrong Answer
n=int(input()) a=list(map(int,input().split())) m=min(a) c=0 for i in reversed(range(1,m)): cnt=0 for j in range(n): if a[j]%i==0: cnt+=1 if cnt>=n-1: c=i break print(c)
p03633
s007017942
Accepted
from fractions import gcd def lcm(a, b): return a * b // gcd(a, b) n = int(input()) ans = 1 for i in range(n): ans = lcm(ans, int(input())) print(ans)
p02838
s085635640
Wrong Answer
import numpy as np n = int(input()) a = list(map(int,input().split())) m = len(bin(max(a)))-2 b = np.array([0]*m) ans = 0 for i in range(n): b += np.array([(a[i] >> j) & 1 for j in range(m)]) for i in range(m): ans += ((2**i)*b[i]*(n-b[i]))%(10**9+7) print(ans%(10**9+7))
p02677
s657054658
Accepted
import numpy as np a, b, h, m = [float(i) for i in input().split()] kakua = 2*np.pi/12*h+2*np.pi/12*m/60 kakub = 2*np.pi/60*m kaku = abs( kakua - kakub ) x = np.sqrt(a*a + b*b - 2*a*b*np.cos(kaku)) print(x)
p02900
s595628072
Accepted
A, B = map(int, input().split()) def prime_factor(n): res = set([1]) for i in range(2, n + 1): if i * i > n: break while n % i == 0: res.add(i) n //= i if n != 1: res.add(n) return res print(len(prime_factor(A) & prime_factor(B)))
p03760
s598744566
Accepted
def i(): return int(input()) def i2(): return map(int,input().split()) def s(): return str(input()) def l(): return list(input()) def intl(): return list(int(k) for k in input().split()) o = s() e = s() ans = "" for i in range( len(o)+len(e) ): if i%2 == 0: ans += o[i//2] else: ans += e[i//2] print(ans)
p03282
s765591527
Accepted
a = input() k = int(input()) count = 1 for i in a: if i != "1": break count += 1 if k >= count: print(a[count-1]) else: print("1")
p03360
s712778916
Accepted
l=sorted([int(x) for x in input().split()],reverse=True) k=int(input()) print((l[0]*2**k)+l[1]+l[2])
p03486
s335110754
Accepted
s = list(input()) t = list(input()) s.sort() t.sort(reverse = True) s1 = ''.join(s) t1 = ''.join(t) if s < t : print("Yes") else : print("No")
p03456
s877543091
Wrong Answer
import math a,b = map(int,input().split()) c = a*10+b if c == (math.sqrt(c))**2: print("Yes") else: print("No")
p03243
s576265877
Accepted
n = int(input()) for i in range(n,1000): a = str(i) if a[0] == a[1] and a[0] == a[2]: print(i) break
p03778
s158405262
Accepted
w,a,b = map(int,input().split()) m = b-a-w n = a-b-w if m>0: print(m) elif n>0: print(n) else: print(0)
p02727
s170838224
Accepted
# coding: utf-8 X, Y, A, B, C = map(int, input().split()) P = list(map(int, input().split())) Q = list(map(int, input().split())) R = list(map(int, input().split())) P.sort(reverse=True) Q.sort(reverse=True) R.sort(reverse=True) ans = 0 L = P[:X] + Q[:Y] Rt = [False for _ in range(C)] L.sort() idx = 0 for i in range(X+Y): if idx >= C: break if L[i] < R[idx]: L[i] = R[idx] idx += 1 print(sum(L))
p02678
s711034751
Wrong Answer
print('No')
p02756
s282386883
Accepted
from collections import deque S = input() dq = deque(S) Q = int(input()) inverse = False for _ in range(Q): query = list(input().split()) if query[0] == '1': inverse = not inverse else: tmp = (int(query[1]) - 1) ^ inverse if tmp: dq.append(query[2]) else: dq.appendleft(query[2]) if inverse: dq.reverse() for c in dq: print(c, end='') print('')
p03711
s033380184
Accepted
x, y =map(int, input().split()) if x in {1,3,5,7,8,10,12}: x= 1 elif x in {4,6,9,11}: x =2 else: x = 3 if y in {1,3,5,7,8,10,12}: y= 1 elif y in {4,6,9,11}: y =2 else: y = 3 print("Yes" if x == y else "No")
p04020
s301492010
Wrong Answer
N = int(input()) ans = 0 prev_A = -10 prev_card_num = 0 for i in range(1,N+1): A = int(input()) ans += (prev_card_num + A)//2 if prev_A == i-1 and (prev_card_num+A)%2 == 1: prev_card_num = 1 prev_A = i elif prev_A == i-1 and (prev_card_num+A)%2 == 0: prev_card_num = 0 else: prev_card_num = 1 prev_A = i print(ans)
p02639
s823621673
Wrong Answer
input_list = input().split(" ") [print(i+1) for i in range(len(input_list)) if input_list[i]!=i+1]
p02708
s488195956
Accepted
def conta_casos(n, k): s = 0 for i in range(k, n+2): s += i*(n-i+1)+1 print(s % (1000000000+7)) a, b = [int(x) for x in input().split()] conta_casos(a, b)
p02639
s833607932
Accepted
def main(): x = list(map(int, input().split())) r = x.index(0) + 1 print(r) if __name__ == '__main__': main()
p03485
s541430332
Accepted
a, b = map(int, input().split()) print(-(-(a + b) // 2))
p02948
s315488346
Accepted
N,M = map(int, input().split()) # tasks[i][j] # i: 開始日 # j: 価値 tasks = [[] for _ in range(M)] for _ in range(N): A,B = map(int, input().split()) if A <= M: tasks[M - A].append(B) from heapq import * que = [] for day in range(M): for task in tasks[day]: if len(que) < day + 1: heappush(que, task) elif len(que) == day + 1: heappushpop(que, task) print(sum(que))
p03605
s562938496
Wrong Answer
N = list(map(int, input().split())) if 9 in N: print("Yes") else: print("No")
p03910
s656505984
Wrong Answer
n = int(input()) if n<3: print(n) else: if n%2==1: print(n//2) print(n//2+1) else: print(n//2-1) print(n//2+1)
p02675
s261255804
Wrong Answer
N = str(input()) if N[-1]==3: print('bon') elif (N[-1]==0)or(N[-1]==1)or(N[-1]==6)or(N[-1]==8): print('pon') else: print('hon')
p02705
s656501131
Wrong Answer
import math r=int(input()) cir = 2 * r * r * math.pi print(cir)
p03220
s037518425
Accepted
n=int(input()) t,a=map(int,input().split()) H=[int(_) for _ in input().split()] Tx=[] for i in range(n): Tx.append([i+1,abs(a-t+H[i]*0.006)]) Tx.sort(key=lambda x:x[1]) print(Tx[0][0])
p04029
s095699559
Accepted
N = int(input()) ans = N*(N+1)/2 print(int(ans))
p02988
s761233763
Accepted
n = int(input()) p = list(map(int,input().split())) cnt = 0 for i in range(1, n-1): if p[i-1] < p[i] < p[i+1] or p[i-1] > p[i] > p[i+1]: cnt += 1 print(cnt)
p02836
s878766785
Wrong Answer
s = input() count = 0 for i in range(len(s)): if s[i] != s[len(s)-i-1]: count +=1 print(count/2)
p03860
s646708321
Wrong Answer
A,B,C = input().split() print("A""B[0]""C")
p02700
s554184222
Accepted
i = input() a, b, c, d= i.split() a = int(a) b = int(b) c = int(c) d = int(d) while (a > 0) or (c > 0): c = c - b if (a < 1) or (c < 1): break a = a - d if a < 1: print('No') else: print('Yes')
p02633
s089076051
Accepted
import math x = int(input()) def lcm(a): return (x*360)//math.gcd(x,360) if 360%x==0: print(int(360/x)) else: print(int(lcm(x)/x))
p02647
s257405148
Accepted
n,k=map(int,input().split()) a=list(map(int,input().split())) def imos(n,a): imos_l=[0]*n for i in range(n): l=max(i-a[i],0) r=min(i+a[i],n-1) imos_l[l]+=1 if (r+1)!=n: imos_l[r+1]-=1 b=[0] for i in range(1,n+1): b.append(imos_l[i-1]+b[i-1]) return b[1:] for i in range(k): na=imos(n,a) if na==a: break a=na print(*a)
p02725
s417143350
Accepted
a = [] a = input().split() K = int(a[0]) N = int(a[1]) #print('K=', K, 'N=', N) A = [] A = input().split() A = [int(i) for i in A] #print('A=', A) l = [] for i in range(len(A)-1): l.append(A[i+1] - A[i]) l.append(K - A[len(A)-1] + A[0]) #print('l=', l) M = max(l) #print('M=', M) print(K - M)
p02553
s922976670
Wrong Answer
inputs = [int(x) for x in input().split()] a = inputs[0] b = inputs[1] c = inputs[2] d = inputs[3] # Avoid using 0 if a == 0: a += 1 if b == 0: b -= 1 if c == 0: c += 1 if d == 0: d -= 1 if (a > 0 and b > 0 and c < 0 and d < 0) or (a < 0 and b < 0 and c > 0 and d > 0): # Return the max negative value print(-(min(abs(a), abs(b)) * min(abs(c), abs(d)))) else: # Return the max positive value print(max(a * c, b * d))
p03657
s964265055
Accepted
li = list(map(int,input().split())) li.append(li[0]+li[1]) for i in range(3): if li[i] % 3 == 0: print("Possible") exit() print("Impossible")
p03665
s488364788
Wrong Answer
n,p=map(int,input().split()) a=list(map(int,input().split())) print(2**(n-1))
p02833
s507114979
Accepted
# coding: utf-8 N = int(input()) if N % 2 != 0: print(0) exit() ans = N // 10 N //= 10 while N > 0: ans += N // 5 N //= 5 print(ans)
p03219
s969612354
Wrong Answer
X, Y = map(int, input().split()) print(X + Y/2)
p02829
s594351068
Accepted
data = [int(input()), int(input())] if not(1 in data): print(1) elif not(2 in data): print(2) elif not(3 in data): print(3)
p02645
s228483147
Accepted
s = input() print(s[0:3])
p02726
s048070720
Wrong Answer
N,X,Y=map(int,input().split()) def count(k): count=0 for i in range(1,N): for j in range(i+1,N+1): if min(abs(j-i),abs(X-i)+abs(Y-j)+1)==k: count+=1 if count >= 3: break return count for k in range(1,N): print(count(k))
p03759
s189152367
Wrong Answer
l=list(map(int,input().split())) if(l[1]-l[0]==l[2]-l[1]): print("Yes") else: print("No")
p03495
s085167381
Wrong Answer
N, K = map(int, input().split()) a = list(map(int,input().split())) a_dict = {} for i in range(N): if a[i] not in a_dict.keys(): a_dict[a[i]] = 1 else: a_dict[a[i]] += 1 ans = 0 if len(a_dict) <= K: print(ans) else: sort_a_dict_list = sorted(a_dict.items(), reverse=True) for j in range(len(a_dict) - K): ans += sort_a_dict_list[j][1] print(ans)
p02922
s083587735
Accepted
A, B = map(int, input().split()) print(-(-(B-A)//(A-1))+1)
p02631
s966808184
Accepted
n = int(input()) a = list(map(int, input().split())) s = a[0] for num in a[1:]: s ^= num res = [0] * n for i, num in enumerate(a): res[i] = s ^ num print(*res)
p02900
s454535243
Accepted
from fractions import gcd def factor(n): res = [] for i in range(2, int(n ** 0.5) + 1): while n % i == 0: res.append(i) n //= i if n > 1: res.append(n) return res A, B = map(int, input().split()) g = gcd(A, B) print(len(set(factor(g))) + 1)
p03145
s092741246
Wrong Answer
a, b, c = list(map(int, input().split())) print((a*b)/2)
p03107
s803041871
Accepted
s=input() stack=[2] n=len(s) cnt=0 for i in range(n): if s[i]=='0' and stack[-1]=='1': stack.pop() cnt+=2 elif s[i]=='1' and stack[-1]=='0': stack.pop() cnt+=2 else: stack.append(s[i]) print(cnt)
p02631
s031865903
Accepted
import sys N=int(sys.stdin.readline()) A=[int(i) for i in sys.stdin.readline().split()] ans=[0]*N total=0 for x in range(N): total^=A[x] for y in range(N): ans[y]=str(total^A[y]) print(" ".join(ans))
p03761
s604125487
Accepted
def main(): a = [input() for _ in range(int(input()))] common = "" for x in "abcdefghijklmnopqrstuvwxyz": common += x * min((i.count(x) for i in a)) print(common) if __name__ == "__main__": main()
p02690
s341436526
Wrong Answer
import sys X = int(input()) i, j = 0, 0 for b in range(1, 1000): for z in range(1, 1000): if b**4 + 10*b**3*z + 10*b**2*z**2 + 5*b*z**3 + z**4 == X//z: print(b+z, b) sys.exit()
p02615
s925118079
Wrong Answer
n = int(input()) alist = list(map(int,input().split())) alist = sorted(alist,reverse=True) ans = 0 for i in range(n-1): ans += alist[i] print(ans)
p02646
s710054201
Wrong Answer
A, V = map(int, input().split()) B, W = map(int, input().split()) T = int(input()) dis = abs(A-B) mob = W-V if B < A: print("No") elif A < B: if mob >= 0: print("No") else: if dis + mob*T <= 0: print("Yes") else: print("No")
p02546
s247758953
Accepted
s =input() if s[-1] == 's': print(s+'es') else: print(s+'s')
p02983
s183872798
Accepted
import bisect,copy,heapq,itertools,string from collections import * from math import * import sys def input() : return sys.stdin.readline().strip() def INT() : return int(input()) def MAP() : return map(int,input().split()) def LIST() : return list(MAP()) l,r = MAP() if(l%2019>=r%2019) or (r-l>=2018): print(0) exit() else: l %= 2019 r %= 2019 ans = inf for i in range(l,r): for j in range(i+1,r+1): ans = min(ans, i*j%2019) print(ans)
p03252
s977590093
Accepted
s,t = raw_input(), raw_input() def f(s,t): cc = {} cr = {} for u,v in zip(s,t): if u in cc: if cc[u] != v: return False if v in cr: if cr[v] != u: return False cc[u] = v cr[v] = u return True print 'Yes' if f(s,t) else 'No'
p02675
s387633246
Accepted
s = list(input()) if s[-1] == "0" or s[-1] == "1" or s[-1] == "6" or s[-1] =="8": print("pon") elif s[-1] == "3": print("bon") else: print("hon")
p03779
s529282517
Wrong Answer
def solve(): x = int(input()) l = [int(x) for x in range(1, int(x**0.5)+3)] for i in range(len(l)): if l[i]*(l[i]+1)//2 >= x: return i+1 print(solve())
p02767
s804793457
Accepted
N = int(input()) X = [int(x) for x in input().split()] y = sum(X)//N c1 = 0 c2 = 0 for x in X: c1 += (x-y)**2 c2 += (x-y-1)**2 print(min(c1, c2))
p02606
s251616941
Accepted
l,r,d=map(int,input().split()) ans=0 for i in range(l,r+1): if(i%d==0): ans+=1 print(ans)
p03030
s635020397
Accepted
import sys N = int(sys.stdin.readline().strip()) shops = [] for i in range(N): s, p = sys.stdin.readline().strip().split() shops.append((s, -1 * int(p), i+1)) for (s, p, i) in sorted(shops): print(i)
p02603
s773014379
Accepted
def main(): import sys N=int(sys.stdin.readline()) A=list(map(int,sys.stdin.readline().split())) B=[0]*N money=1000 kabu=0 for i in range(N-1): if A[i]<A[i+1]: kabu+=money//A[i] money%=A[i] elif A[i]>A[i+1]: money+=kabu*A[i] kabu=0 money+=kabu*A[-1] print(money) main()
p03131
s662193689
Accepted
import sys sys.setrecursionlimit(10 ** 7) f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): k, a, b = map(int, input().split()) if b - a < 2: print(k + 1) else: n = k - a + 1 res = a + n // 2 * (b - a) res += 1 if n % 2 != 0 else 0 print(res) if __name__ == '__main__': resolve()
p02572
s734804504
Accepted
import math N=int(input()) A=list(map(int,input().split())) ans=0 tmp=0 for i in range(N-1): tmp+=A[i] ans+=tmp*A[i+1] print(ans%((10**9)+7))
p04033
s707452853
Accepted
a, b = list(map(int, input().split())) if a <= 0 and b >= 0: print('Zero') elif a > 0: print('Positive') elif b < 0 and (b - a + 1) % 2 == 0: print('Positive') else: print('Negative')
p02732
s796166145
Accepted
import collections N = int(input()) A = input().split() c = collections.Counter(A) cou = list(c.values()) ans = 0 for j in range(len(cou)): m = cou[j] k = m*(m-1)/2 ans += int(k) for i in range(N): x = c[A[i]] print(ans - x + 1)
p02982
s512045384
Accepted
import math N, D = map(int, input().split()) X = [list(map(int, input().split())) for _ in range(N)] ans = 0 for i in range(N-1): for j in range(i+1, N): d = 0 for k in range(D): d += (X[i][k] - X[j][k]) ** 2 if int(math.sqrt(d)) ** 2 == d: ans += 1 print(ans)
p03387
s009068635
Accepted
lis=sorted(list(map(int,input().split()))) lis.sort(reverse=True) if (lis[1]-lis[2])%2==0:#偶数 print(((lis[0]-lis[1])+(lis[0]-lis[2]))//2) else:#奇数 print(((lis[0]-lis[1])+(lis[0]-lis[2])+3)//2)
p03637
s378563076
Accepted
# C - 4-adjacent n,a = int(input()),[int(x)%4 for x in input().split()] print("Yes" if n//2 <= a.count(0) + a.count(2)//2 else "No")
p02719
s916701609
Wrong Answer
n, k = map(int, input().split()) result = 0 while True: m = abs(n - k) if k == 1: break elif n == 0: result = m break elif n <= k: result = min(n, m) break else: n = n % k print(result)
p03951
s510367275
Accepted
n = int(input()) s= input() t = input() for i in range(n): if s[i:]==t[:n-i]: print(n+i) exit() print(n*2)
p03327
s654141918
Accepted
if int(input())<=999: print("ABC") else: print("ABD")
p03317
s558246017
Accepted
import math a,b = [int(i) for i in input().split()] l = [int(i) for i in input().split()] ans = 1 + int(math.ceil((a-b)/(b-1))) print(ans)
p03435
s796753794
Accepted
c1=list(map(int,input().split())) c2=list(map(int,input().split())) c3=list(map(int,input().split())) b1,b2,b3=c1[0],c1[1],c1[2] if c2[0]-b1==c2[1]-b2==c2[2]-b3 and c3[0]-b1==c3[1]-b2==c3[2]-b3: print('Yes') else: print('No')
p02951
s492007455
Accepted
a,b,c = map(int,input().split()) if b + c <= a: print(0) else: print(c-(a-b))
p03605
s412867422
Accepted
n=input() print("Yes" if (n[0]=="9" or n[1]=="9") else "No")
p02939
s793128300
Accepted
S = input() ans = 1 prev = S[0] i = 1 while i < len(S): tmp = S[i] while 1: if prev != tmp: break else: i += 1 tmp += S[i] if i == len(S) - 2 and tmp == S[-1]: tmp += S[-1] i += 1 ans += 1 i += 1 prev = tmp print(ans)
p02707
s024547104
Accepted
N = int(input()) A = list(map(int, input().split())) num = [0 for i in range(N)] for i in A: num[i-1] += 1 for l in num: print(l)
p02917
s176320196
Accepted
N = int(input()) L = list(map(int,input().split())) ans = L[0]+L[N-2] for i in range(N-2): ans += min([L[i],L[i+1]]) print(ans)