problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02948
s563805088
Accepted
N,M = map(int,input().split()) t = [[0] for _ in range(M+1)] for _ in range(N): a,b = map(int,input().split()) if a<=M: t[a].append(b) import heapq A=[-i for i in t[1]] heapq.heapify(A) ans = 0 for i in range(1,M+1): maxi = heapq.heappop(A) ans -= maxi if i+1<=M: for k in t[i+1]: heapq.heappush(A,-k) print(ans)
p02719
s600973830
Wrong Answer
N, K = map(int, input().split()) if 0 <= N <= 10^18 and 1 <= K <= 10^18: if N>K: N = abs(N-K) N = abs(N-K) print(N) else: print(N) else: print("0")
p03478
s531924231
Accepted
N, A, B = list(map(int, input().split())) ans = 0 for n in range(1, N+1): s = str(n) acc = 0 for c in s: acc += int(c) if A <= acc <= B: ans += n print(ans)
p02747
s446586626
Accepted
S=input() S = set(S.replace("hi","*")) if S == set("*"): print("Yes") else: print("No")
p02982
s922438899
Accepted
import math n, d = map(int, input().split()) x = [] for _ in range(n): x.append(list(map(int, input().split()))) count = 0 for i in range(n): for j in range(i+1, n): s = 0 for k in range(d): diff = x[i][k]-x[j][k] s += diff * diff sq = math.sqrt(s) if sq == int(sq): count += 1 print(count)
p02596
s906466579
Accepted
K = int(input()) if K % 2 == 0 or K % 5 == 0: print(-1) exit() m = 7 % K cnt = 1 d = 10 % K while True: if m == 0: break cnt += 1 m = (m+7*d)%K d = d*10%K print(cnt)
p03472
s250680144
Wrong Answer
n, h = map(int, input().split()) a, b = [], [] for _ in range(n): s, t = map(int, input().split()) a.append(s) b.append(t) m = max(a) b.sort() ans, c = 0, 0 while b: l = b.pop() if l >= m and c <= h: ans += 1 c += l else: break if len(b) == 0 or l < m: ans += max(h - c, 0) // m if max(h - c, 0) % m != 0: ans += 1 print(ans)
p03455
s097574974
Accepted
a, b = map(int, input().split()) ans = "Odd" if(a*b%2==0): ans = "Even" print(ans)
p03910
s335634005
Wrong Answer
n,ans = int(input()),0 for i in range(n): if ans+i<=n: ans+=i else: break if ans==n: for j in range(i-1): print(j+1) else: for j in range(i-2): print(j+1) print(n-ans+i-1)
p02665
s342840792
Wrong Answer
n = int(input()) arr = list(map(int , input().split())) if arr[0] > 0 or arr[-1] == 0: print("-1") else: f = 1 possible = 2 ans = 1 for i in range(1,n+1): #print(possible, ans) if arr[i] > possible: print(-1) f = 0 break ans+=possible #if i == n: # break possible-=arr[i] possible = 2*possible if f: print(ans)
p03469
s324883620
Accepted
s = input() S="2018" S+=s[4:] print(S)
p02639
s955004293
Accepted
x = list(map(int, input().split())) print(x.index(0) + 1)
p02555
s321084928
Accepted
def main(): n = int(input()) dp = [0]*(n+1) dp[0] = 1 mod = pow(10, 9) + 7 for i in range(3, n+1): dp[i] = dp[i-1] + dp[i-3] dp[i] %= mod print(dp[n]) if __name__ == "__main__": main()
p02687
s944458066
Accepted
S = input() if(S == "ABC"): print("ARC") else: print("ABC")
p03639
s887951826
Accepted
n = int(input()) A = list(map(int, input().split())) wari = [0]*3 for a in A: if a % 4 == 0: wari[2] += 1 elif a % 2 == 0: wari[1] += 1 elif a % 2 == 1: wari[0] += 1 if wari[1] == 0: if wari[2] + 1 >= wari[0]: print("Yes") else: print("No") else: if wari[2] >= wari[0]: print("Yes") else: print("No")
p02833
s883478355
Accepted
N = int(input()) x = N if(N%2==1): print(0) else: ans = 0 num = 1 while( x//(5**num) > 1 ): #print(ans,(x//(5**num)//2) ) ans += ( (x//(5**num)) // 2) num += 1 print(ans)
p02785
s106909303
Accepted
N,K = map(int,input().split()) H = sorted(list(map(int,input().split())),reverse = True) print(sum(H[K:]))
p03835
s308740171
Accepted
K,S = map(int,input().split()) ans = 0 for i in range(K+1): for j in range(K+1): z = S - i - j if 0 <= z <= K: ans += 1 print(ans)
p02946
s322584658
Wrong Answer
k,x=map(int,input().split()) for i in range(x-k+1,x+k): print("i",end=" ") print()
p03545
s633869317
Accepted
a,b,c,d=input() for i in range(2**3): ls=['+','+','+'] for j in range(len(ls)): if (i>>j)&1: ls[j]='-' if eval(a+ls[0]+b+ls[1]+c+ls[2]+d) == 7: print(a+ls[0]+b+ls[1]+c+ls[2]+d+"=7") break
p03693
s530996215
Accepted
l=input().split() s=''.join(l) s=int(s) print('YES' if s%4==0 else 'NO')
p03543
s101088119
Accepted
a,b,c,d = input() if a==b==c or b==c==d: print("Yes") else: print("No")
p02952
s683619032
Accepted
N = int(input()) sumans = 0 for count in range(1,N+1): if len(str(count))%2 == 1: sumans +=1 print(sumans)
p02742
s022609424
Wrong Answer
h,w = map(int,input().split()) if (h*w)%2 == 0: print((h*w)//2) else: print(((h*w)//2)+1)
p03815
s179322833
Accepted
n = int(input()) ans = 0 ans += 2*(n // 11) n %= 11 if n >= 7: print(ans+2) elif n >= 1: print(ans+1) else: print(ans)
p03797
s701239734
Accepted
n,m=map(int,input().split()) if 2*n>=m: print(m//2) else: k1 = (m-n*2)//4 k2 = k1+1 k3 = max(k1-1,0) r1 = min(n+k1,(m-k1*2)//2) r2 = min(n+k2,(m-k2*2)//2) r3 = min(n+k3,(m-k3*2)//2) print(max(r1,r2,r3))
p02556
s791513687
Accepted
n = int(input()) a = [0] * n b = [0] * n for i in range(n): p, q = [int(j) for j in input().split(' ')] a[i] = p+q b[i] = p-q a.sort() b.sort() print(max(a[-1] - a[0], b[-1] - b[0]))
p03607
s039313507
Accepted
from collections import Counter N = int(input()) C = Counter([int(input()) for _ in range(N)]) print(len(list(filter(lambda x: x % 2 == 1, list(C.values())))))
p04030
s545611417
Wrong Answer
S = list(input()) print(S) S_after = [] for i in S: if i == '1': S_after.append('1') elif i == '0': S_after.append('0') elif i == 'B': if S_after == []: pass else: S_after.pop() print(''.join(S_after))
p03633
s607752628
Accepted
N = int(input()) T = [] for i in range(N): T.append(int(input())) # print('T:',T) if N==1: f2 = T[0] elif N==2: import math a,b = T[0], T[1] f=math.gcd(a,b) f2=a*b//f else: import math a,b = T[0], T[1] f=math.gcd(a,b) f2=a*b//f for i in range(2,N): a,b=f2, T[i] f=math.gcd(a,b) f2=a*b//f print(f2)
p02641
s780383823
Accepted
x,n=map(int,input().split()) l=list(map(int,input().split())) a=0 for i in range(100): if x-i not in l: ans=x-i a=i+1 break for i in range(100): if x+i not in l: ansb=x+i ab=i+1 break if a>ab: print(ansb) else: print(ans)
p03815
s880476126
Accepted
x = int(input()) ans = 0 if x % 11 == 0: print(2 * (x // 11)) else: if x % 11 <= 6: print(2 * (x // 11) + 1) else: print(2 * (x // 11) + 2)
p03645
s615721414
Accepted
n, m = [int(x) for x in input().split()] f_set = set() t_set = set() for _ in range(m): a, b = [int(x) for x in input().split()] if a == 1: f_set.add(b) elif b == n: t_set.add(a) print("POSSIBLE" if len(f_set & t_set) >= 1 else "IMPOSSIBLE")
p03095
s213650524
Accepted
n=int(input()) s=list(input()) mod=10**9+7 from collections import Counter c=Counter(s) ans=1 for k in c.keys(): ans*=(c[k]+1)%mod ans%=mod print((ans+mod-1)%mod)
p03250
s609881213
Wrong Answer
def main(): n = list(map(int,input().split())) print(max(n[0] + n[1] * 10 + n[2], n[0] * 10 + n[1] + n[2])) main()
p02681
s474470121
Accepted
S = str(input()) T = str(input()) if T.startswith(S) ==True: print("Yes") else: print("No")
p03680
s180504303
Wrong Answer
import sys N = list(map(int, sys.stdin)) bot = N[1] for i in range(N[0]): if bot == 2: print(i) break bot == N[bot] else: print(-1)
p03161
s607265329
Accepted
n,k = map(int,input().split()) h = list(map(int,input().split())) dp = [10**10]*n dp[0] = 0 for i in range(n-1): for j in range(i+1,min(i+k,n-1)+1): dp[j] = min(dp[j],dp[i]+abs(h[j]-h[i])) # print(dp) print(dp[n-1])
p03000
s265515040
Wrong Answer
import sys def input(): return sys.stdin.readline().rstrip() def main(): n, x = map(int, input().split()) l = tuple(map(int, input().split())) d = 0 for i in range(1, n): d += l[i-1] if d >= x: print(i) quit() else: print(n) if __name__ == '__main__': main()
p02690
s090070024
Accepted
x=int(input()) [i**5-x-j**5or print(i,j)+exit()for i in range(200)for j in range(-i,i)]
p02759
s090942311
Accepted
N = int(input()) if N%2 == 0: print(int(N/2)) else: print(int(N//2) + 1)
p03042
s739468472
Accepted
import sys def LI2(): return list(map(int,sys.stdin.readline().rstrip())) #็ฉบ็™ฝใชใ— S = LI2() a = 10*S[0]+S[1] b = 10*S[2]+S[3] if 1 <= a <= 12 and 1 <= b <= 12: print('AMBIGUOUS') elif not 1 <= a <= 12: if 1 <= b <= 12: print('YYMM') else: print('NA') else: print('MMYY')
p02682
s857678234
Accepted
a, b, c, k = list(map(int, input().split())) if a>=k: print(k) elif a<k<=(a+b): print(a) else: print(a-(k-a-b))
p03625
s154662115
Accepted
n = int(input()) a = list(map(int, input().split())) l = [] d = dict() for v in a: if v not in d: d[v] = 1 else: d[v] += 1 if d[v] == 2 or d[v] == 4: l.append(v) if len(l) < 2: print(0) else: l.sort() print(l[-1] * l[-2])
p02923
s115489145
Accepted
n=int(input()) H=list(map(int,input().split())) c=0 C=[] for i in range(n-1): if H[i]>=H[i+1]: c+=1 else: C.append(c) c=0 if i==n-2: C.append(c) if len(H)!=1: ans=max(C) else: ans=0 print(ans)
p04029
s037536139
Accepted
import sys input = sys.stdin.readline def I(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) def main(): mod=10**9+7 N=I() print((N*(N+1))//2) main()
p02939
s836115037
Wrong Answer
from collections import defaultdict def readInt(): return int(input()) def readInts(): return list(map(int, input().split())) def readChar(): return input() def readChars(): return input().split() s = readChar() b="-1" ans=0 while len(s)>1: if b!=s[:1]: b=s[:1] s=s[1:] ans+=1 else: b=s[:2] s=s[2:] ans+=1 if b!=s: ans+=1 print(ans)
p03387
s875823337
Accepted
A, B, C = map(int, input().split()) num = [A, B, C] cnt =0 for i in range(2): multi = (max(num)-min(num))//2 num[num.index(min(num))] += 2*multi cnt += multi if len([i for i in num if i==max(num)]) ==1: cnt += 1 elif len([i for i in num if i==max(num)]) ==2: cnt += 2 print(cnt)
p02785
s021450705
Accepted
N, K = map(int, input().split()) H = sorted(list(map(int, input().split()))) print(sum([0] + H[:-K]) if K > 0 else sum(H))
p03103
s853544700
Wrong Answer
n,m = map(int,input().split()) li = [list(map(int,input().split()))for i in range(n)] li.sort() n = 0 ans = 0 for i in range(n): a = min(m,li[i][1]) m-=a ans += li[i][0]*a if a ==0: break print(ans)
p02912
s257784441
Accepted
import heapq n, m = map(int, input().split()) *a, = map(lambda x: -x, map(int, input().split())) heapq.heapify(a) for i in range(m): _a = int(heapq.heappop(a)/2) heapq.heappush(a, _a) print(sum(a)*-1)
p03778
s391254159
Accepted
w, a, b = map(int, input().split()) if a <= b: print(max(0, b-(a+w))) else: print(max(0, a-(b+w)))
p03760
s029753072
Wrong Answer
O=input() E=input() print(*[O+E for O,E in zip(O,E)],sep="")
p03208
s429154646
Wrong Answer
n,k=map(int,input().split()) h=[] ma=10**9 for i in range(n): a=int(input()) h.append(a) h.sort() for i in range(n-k+1): sa=h[n-k+1]-h[i] if sa<ma: ma=sa print(ma)
p02659
s601211551
Wrong Answer
s=input().split() a=int(s[0]) b=float(s[1]) print(a*int(b*100)//100)
p03419
s952605085
Accepted
#!/usr/bin/env python3 n, m = map(int, input().split()) a = max(n, m) b = min(n, m) if b == 1: print((a - 2) if a > 1 else 1) elif b == 2: print(0) else: print((a - 2) * (b - 2))
p03645
s405260111
Accepted
N,M=list(map(int,input().split())) s=set();t=set(); for i in range(M): a,b=list(map(int,input().split())) if(a==1): s.add(b) if(b==N): t.add(a) print("POSSIBLE"if s&t else"IMPOSSIBLE")
p02953
s631627213
Wrong Answer
n=int(input()) a=list(map(int,input().split())) frag=1 frag2=1 for i in range(n-1): if a[i]-a[i+1]==1: if frag2==1 and frag==1: frag2=0 elif frag2==0: frag=0 break elif frag==2: frag=0 break elif a[i]-a[i+1]>1: frag=0 break elif a[i]==a[i+1]: frag=2 elif frag==2: frag=1 if frag!=0: print('Yes') else: print('No')
p04019
s580860277
Accepted
s = input() s = set(s) if s==set('WE') or s==set('SN') or s==set('SNWE'): print('Yes') else: print('No')
p03061
s231249980
Accepted
from fractions import gcd n = int(input()) a = list(map(int,input().split())) l = [0] r = [0] ans = 0 for i in range(n-1): l.append(gcd(l[i],a[i])) for i in range(n-1): r.append(gcd(r[i],a[n-1-i])) for i in range(n): ans = max(ans,gcd(l[i],r[-i-1])) print(ans)
p02696
s652919986
Accepted
a,b,n = map(int, input().split()) if n >= b-1: print( (a*(b-1)) // b - a * ((b-1)//b)) else: print( (a*n) // b - a * (n//b))
p03962
s034828215
Accepted
a=set(map(int,input().split())) print(len(a))
p02897
s071780739
Wrong Answer
a = int(input()) print(1 / 2 if a % 2 == 0 else (a + 1) / 2)
p02760
s551368606
Accepted
a1_list = list(map(int, input().split())) a2_list = list(map(int, input().split())) a3_list = list(map(int, input().split())) a1_list.extend(a2_list) a1_list.extend(a3_list) n = int(input()) nums = [] for _ in range(n): x = int(input()) nums.append(x) result = "No" patterns = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6]] for p in patterns: if a1_list[p[0]] in nums and a1_list[p[1]] in nums and a1_list[p[2]] in nums: result = "Yes" break print(result)
p02818
s224353308
Wrong Answer
a, b, k = map(int , input().split()) #ใ‚‚ใ—้ซ˜ๆฉ‹ๅ›ใŒใ‚ฏใƒƒใ‚ญใƒผใ‚’ 1 ๆžšไปฅไธŠๆŒใฃใฆใ„ใ‚‹ใชใ‚‰ใ€้ซ˜ๆฉ‹ๅ›ใฎใ‚ฏใƒƒใ‚ญใƒผใ‚’ 1 ๆžš้ฃŸในใ‚‹ใ€‚ #ใใ†ใงใชใใ€ใ‚‚ใ—้’ๆœจๅ›ใŒใ‚ฏใƒƒใ‚ญใƒผใ‚’ 1 ๆžšไปฅไธŠๆŒใฃใฆใ„ใ‚‹ใชใ‚‰ใ€้’ๆœจๅ›ใฎใ‚ฏใƒƒใ‚ญใƒผใ‚’ 1 ๆžš้ฃŸในใ‚‹ใ€‚ #้ซ˜ๆฉ‹ๅ›ใ‚‚้’ๆœจๅ›ใ‚‚ใ‚ฏใƒƒใ‚ญใƒผใ‚’ๆŒใฃใฆใ„ใชใ„ใชใ‚‰ใ€ไฝ•ใ‚‚ใ—ใชใ„ใ€‚ if k >= a: k = k - a a = 0 else: a = a - k k = 0 if k >= b: b = k - b else: b = b - k print(a, b)
p02866
s009149554
Wrong Answer
N = int( input() ) D = list ( int(x) for x in input().split() ) Ds = [ 0 for i in range( max(D) + 1 ) ] for i in range( N ): Ds[ D[i] ] += 1 ans = 1 if Ds[ 0 ] != 1: ans = 0 else: for i in range( 1 , max(D) + 1 ): ans *= Ds[ i-1 ] ** Ds[i] if ans == 0: break print( ans )
p03371
s702382898
Accepted
import sys stdin = sys.stdin mod = 10**9 + 7 ns = lambda: stdin.readline().rstrip() ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) A, B, C, X, Y = na() ans = 10**10 for ab in range((10**5+1)*2): cost = ab * C cost += max(0, X - ab//2) * A cost += max(0, Y - ab//2) * B ans = min(ans, cost) print(ans)
p02793
s332624868
Wrong Answer
import sys input = sys.stdin.readline n=int(input()) A=list(map(int,input().split())) mod=10**9+7 from fractions import gcd if n==1: print(1) else: g=A[0] l=A[0] for i in range(n-1): g=gcd(l,A[i+1]) l*=A[i+1] l//=g ans=n*l for i in range(n): ans//=A[i] print(ans%mod)
p04030
s179046504
Accepted
s = input() t = "" for i in s: if i == "B": if t: t = t[:-1] else: t += i print(t)
p03632
s390376733
Accepted
## coding: UTF-8 s = input().split() t = [int(p) for p in s] #print(t) #print(max(t)) count = 0 for i in range(1, max(t)+1): if(t[0] < i and i <= t[1] and t[2] < i and i <= t[3]): count += 1 print(count)
p03095
s469179901
Accepted
import collections TEISUU = 1000000007 S = input() N = input() c = collections.Counter(N) lis = list(c.values()) ans = 1 for count in lis: ans *= int(count + 1) ans -= 1 print(ans % TEISUU)
p02957
s903644399
Accepted
# input A, B = map(int, input().split()) # check if abs(A - B) % 2 == 1: print("IMPOSSIBLE") else: K = (A + B) // 2 print(K)
p03059
s433937100
Accepted
a, b, t = map(int, raw_input().split()) print t/a*b
p03434
s053156662
Accepted
n = int(input()) card_list = list(map(int,input().split())) alice_score = 0 bob_score = 0 card_list.sort(reverse = True) for i in range(0,n): if i % 2 == 0: alice_score += card_list[i] else: bob_score += card_list[i] print(alice_score - bob_score)
p03073
s683662900
Accepted
S = list(input()) import numpy as np S = np.array(S) zeroichi = ["0","1"]*(len(S)//2)+["0"]*(len(S)%2) ichizero = ["1","0"]*(len(S)//2)+["1"]*(len(S)%2) zeroichi = np.array(zeroichi) ichizero = np.array(ichizero) print(min(list(S == ichizero).count(False),list(S == zeroichi).count(False)))
p03815
s884607269
Accepted
x=int(input()) a=x%11 if a==0: res=0 elif a<7: res=1 else: res=2 print((x//11)*2 + res)
p02797
s410570175
Wrong Answer
n,k,s = list(map(int, input().split())) ret = [s for i in range(k)] + [s+1 for i in range(n-k)] print(*ret)
p03309
s640927168
Wrong Answer
N =int(input()) A =[int(_) for _ in input().split()] a =0 for i in range(N): a += abs(A[i] - (i+1)) print(a)
p02768
s901071784
Wrong Answer
import math #้šŽไน—ใ‚’่จˆ็ฎ—ใ™ใ‚‹ใŸใ‚ใซๅฟ…่ฆ def combinations_count(n, r): return math.factorial(n)//math.factorial(n-r)*math.factorial(r) #intใ‚’่ฟ”ใ™ใ‚ˆใ†ใซ//ใงๆผ”็ฎ— n, a, b=map(int, input().split()) com_sum=0 for i in range(1, n+1): #range(start, stop)ใง start โ‰ฆ i < stopใฎ้€ฃ็•ชใŒ็”Ÿๆˆ com_sum+=combinations_count(n, i) com_sum-=combinations_count(n, a)+combinations_count(n, b) print(com_sum%((10**9)+7))
p03796
s472068588
Accepted
n=int(input()) ans=1 for i in range(1,n+1): ans *= i ans %= (10**9+7) print(ans)
p03778
s196507370
Accepted
W, a, b = map(int, input().split()) A = a + W if b > a: if b - A <= 0: print(0) else: print(b - A) else: B = b + W if a - B <= 0: print(0) else: print(a-B)
p03252
s708888030
Accepted
s = input() t = input() start = [-1 for _ in range(26)] goal = [-1 for _ in range(26)] for i in range(len(s)): a = ord(s[i]) - ord('a') b = ord(t[i]) - ord('a') if start[a] != -1 or goal[b] != -1: if start[a] != b or goal[b] != a: print('No') exit() else: start[a] = b goal[b] = a print('Yes')
p02970
s197008652
Accepted
n,d = map(int,input().split()) range = 2*d+1 if n%range == 0: print(n//range) else: print(n//range+1)
p02606
s639346418
Accepted
import sys #DEBUG=True DEBUG=False if DEBUG: f=open("202007_2nd/A_input.txt") else: f=sys.stdin l,h,d=map(int,f.readline().split()) ans=0 for _ in range(l,h+1): ans=ans+1 if _%d==0 else ans print(ans)
p03838
s039897031
Accepted
x,y = map(int,input().split()) if x==0 and y>0: print(y) elif x==0 and y<0: print(abs(y)+1) elif y==0 and x>0: print(abs(x)+1) elif y==0 and x<0: print(abs(x)) elif x>0 and y>0: if x>y: print(2+(x-y)) else: print(y-x) elif x>=0 and y<0: a = abs(x+y) print(1+a) elif x<=0 and y>0: a = abs(y+x) print(a+1) else: if x>y: print(2+(x-y)) else: print(y-x)
p02707
s199472388
Accepted
import collections def main(): N = int(input()) A = list(map(int, input().split())) A = collections.Counter(A) for i in range(1,N+1): print(A[i] if A[i] is not None else 0) if __name__ == '__main__': main()
p02697
s349593743
Wrong Answer
def resolve(): N,M = map(int,input().split()) for i in range(M): print(str(N//2 - i) + " " + str(N//2+1 + i)) resolve()
p02910
s547699253
Accepted
s=input() count=0 for i in range(len(s)): if i%2==0: if s[i]=="R" or s[i]=="U" or s[i]=="D": count+=1 else: if s[i]=="L" or s[i]=="U" or s[i]=="D": count+=1 if count==len(s): print("Yes") else: print("No")
p02647
s943974583
Accepted
def main(): n,k=map(int,input().split()) a=list(map(int,input().split())) for i in range(k): b=[0]*(n+1) for j in range(n): b[max(j-a[j],0)]+=1 b[min(j+a[j]+1,n)]-=1 for j in range(n): b[j+1]+=b[j] a=b[:n] if min(a)==n: break print(*a) if __name__ == '__main__': main()
p02711
s985800421
Accepted
s = input() if "7" in s: print("Yes") else: print("No")
p03106
s385734242
Accepted
A,B,K =map(int,input().split()) cnt = 0 for i in range(101,0,-1): if A % i == 0 and B % i == 0: cnt += 1 if cnt == K: print(i)
p03126
s969158889
Wrong Answer
N,M=map(int,input().split()) A=list(map(int,input().split())) A.pop(0) for _ in range(N-1): B=list(map(int,input().split())) for num in A: if num not in B[1:]: A.remove(num) print(len(A))
p02756
s386710527
Accepted
import sys #input=sys.stdin.readline from collections import deque r=False d=deque(list(input())) for i in range(int(input())): Q=input().split() if Q[0]=='1': r=not r else: if (Q[1]=='1' and not r) or (Q[1]=='2' and r): d.appendleft(Q[2]) else: d.append(Q[2]) if r: d.reverse() print("".join(list(d)))
p02600
s503364188
Wrong Answer
X = int(input()) if X <= 400 and X <= 599: print('8') elif 600 <= X and X <= 799: print('7') elif 800 <= X and X <= 999: print('6') elif 1000 <= X and X <= 1199: print('5') elif 1200 <= X and X <= 1399: print('4') elif 1400 <= X and X <= 1599: print('3') elif 1600 <= X and X <= 1799: print('2') elif 1800 <= X and X <= 1999: print('1')
p02813
s140321865
Accepted
import math import itertools n = int(input()) P = list(map(int, input().split())) Q = list(map(int, input().split())) cnt_p, cnt_q = 1, 1 p = tuple(P) q = tuple(Q) for a in sorted(itertools.permutations(P)): if a != p: cnt_p += 1 else: break for b in sorted(itertools.permutations(Q)): if b != q: cnt_q += 1 else: break print(abs(cnt_p-cnt_q))
p02787
s061350715
Wrong Answer
h, n = map(int, input().split()) l = [] for i in range(n): a, b = map(int, input().split()) l.append([a, b]) dp = [10 ** 8 + 1 for i in range(h + 10**4 + 1)] dp[0] = 0 for i in range(h+1): for j in range(n): if dp[i] == 10 ** 8 + 1: continue x = dp[i] + l[j][1] if dp[i + l[j][0]] > x: dp[i + l[j][0]] = x print(dp[h])
p03001
s740799566
Accepted
W,H,x,y = map(int,input().split()) print(W*H/2) if(x == W/2 and y == H/2): print("1") else: print("0")
p02677
s649909583
Accepted
import math A,B,H,M=map(int,input().split()) kaku=abs(30*H-5.5*M) rad=math.radians(kaku) #print(rad) sq=A**2+B**2-2*A*B*math.cos(rad) print(math.sqrt(sq))
p02814
s862519551
Accepted
from functools import reduce def gcd(v1,v2): v=v1%v2 if v==0: return v2 else : return gcd(v2,v) n,m=map(int,input().split()) a=list(map(int,input().split())) a=[i//2 for i in a] #print(a) lc=reduce(lambda x,y: (x*y)//gcd(x,y) , a) #print(lc) flag=True for i in a: if (lc//i)%2==0: flag=False break if flag==False: print(0) else: x=m//lc print(x//2) if (x%2)==0 else print((x//2)+1)
p02724
s568880299
Accepted
a=int(input()) b=int(a/500) c=int((a%500)/5) print(b*1000+c*5)