problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02664
s575778680
Accepted
T = input() T_len = int(len(T)) S = "" for i in range(T_len): if T[i] == '?': S = "D" else: S = T[i] print(S, end = "")
p02553
s765094590
Accepted
a,b,c,d = map(int,input().split()) print(max(a*c,a*d,b*c,b*d))
p02796
s815156321
Wrong Answer
n = int(input()) ll = [] for i in range(n): x, l = map(int, input().split()) ll.append([x-l, x+l]) ll = sorted(ll) ans = n r = ll.pop(0)[1] while ll: while ll and ll[0][0] < r: ans -= 1 ll.pop(0) if ll: r = ll.pop(0)[1] print(ans)
p02939
s683241876
Accepted
s = input() ans = 1 num = 1 #ๆ–‡ๅญ—ๆ•ฐ if len(s) == 1: print(1) exit() for i in range(1, len(s)): if num == 1: if s[i - 1] != s[i]: ans += 1 else: if i != len(s) - 1: num = 2 ans += 1 elif num == 2: num = 1.5 elif num == 1.5: ans += 1 num = 1 print(ans)
p03281
s045940005
Accepted
N = int(input()) ans = 0 for i in range(1, N + 1): if i % 2 == 0: continue cnt = 2 for j in range(2, i): if i % j == 0: cnt += 1 if cnt == 8: ans += 1 print(ans)
p02717
s100260467
Accepted
A = list(map(int, input().split())) print(A[2], A[0], A[1])
p03862
s922521035
Accepted
n, x = map(int, input().split()) a = list(map(int, input().split())) ans = 0 for i in range(1, n): if a[i] + a[i-1] > x: ans += min(a[i], a[i] + a[i-1] - x) a[i] = max(0, x - a[i-1]) if a[i] + a[i-1] > x: ans += a[i-1] - x a[i-1] = x print(ans)
p03331
s480211659
Accepted
N = int(input()) a = list(str(N)) a = [int(s) for s in a] Z = 10 ** (len(a) - 1) Y = N - Z X = list(str(Y)) X = [int(s) for s in X] SUM = 0 for i in range(len(X)): SUM = SUM + X[i] if Y != 0: print(SUM + 1) else: print(10)
p02748
s471470311
Wrong Answer
if __name__ == "__main__": S = input() if len(S) % 2 == 0: for i in range(0, len(S), 2): if S[i] == "h" and S[i+1] == "i": ret = "Yes" else: ret = "No" break else: ret = "No" print(ret)
p02548
s709685759
Accepted
n = int(input()) cnt = 0 for i in range(1,n): b = n//i c = n%i if c: cnt += b else: cnt += b-1 print(cnt)
p02755
s762601730
Wrong Answer
A, B = list(map(int, input().split())) amax = (A + 1) / 8 * 100 amin = A / 8 * 100 bmax = (B + 1) / 10 * 100 bmin = B / 10 * 100 answer = amin if amin <= bmax and amin >= bmin else - 1 print(int(answer))
p02909
s107286370
Accepted
# ๅ…ฅๅŠ›ใฎๅ–ๅพ— S = input() # ๅ…ฅๅŠ›ๅ†…ๅฎนใ‹ใ‚‰ๆฌกใฎๅคฉๆฐ—ใ‚’ไบˆๆธฌ if S == "Sunny": print("Cloudy") elif S == "Cloudy": print("Rainy") elif S == "Rainy": print("Sunny") else: print("ๅ…ฅๅŠ›ๅ†…ๅฎนใŒ้–“้•ใฃใฆใ„ใพใ™ใ€‚")
p03474
s373998260
Wrong Answer
import sys a, b = map(int, input().split()) s = input() flag = True for i in range(a + b - 1): if(s[a] != '-' or s[not a] == '-'): flag = False print('Yes') if flag else print('No')
p02795
s995064824
Accepted
H = int(input()) W = int(input()) N = int(input()) result = N // max(H, W) if N % max(H, W) == 0: # ๅ‰ฒใ‚Šๅˆ‡ใ‚ŒใŸๅ ดๅˆ print(result) else: print(result + 1)
p03487
s490266209
Accepted
from collections import Counter n = int(input()) d = Counter(list(map(int, input().split()))) ans = 0 for k, v in d.items(): if k > v: ans += v elif k < v: ans += v-k print(ans)
p02747
s811322388
Accepted
S=input() flag=True if len(S)%2!=0: print("No") else: for i in range(len(S)//2): if S[2*i]+S[2*i+1]=="hi": pass else: flag=False break if flag: print("Yes") else: print("No")
p02918
s478494105
Accepted
def main(): n,k=map(int,input().split()) s=input() A=(('L','L'),('L','R'),('R','L'),('R','R')) B=[] cnt=0 for i in range(n-1): tmp=(s[i],s[i+1]) cnt+=1 if tmp==A[1]: B.append(cnt) cnt=0 elif tmp==A[2]: B.append(cnt) cnt=0 cnt+=1 B.append(cnt) if len(B)//2<=k: unhappy=1 else: unhappy=len(B)-2*k print(n-unhappy) if __name__=='__main__': main()
p03644
s576801477
Accepted
n = int(input()) a = 0 b = 0 for i in range(10): a = 2 ** i if a > n : print(b) break else: b = a
p02747
s216802604
Accepted
s = input() t =0 for s in s: if s == "h": t=1 elif s =="i": if t == 0: t = 0 print("No") quit() t = 0 else: print("No") quit() if t == 1: print("No") else: print("Yes")
p03061
s740213383
Accepted
import sys from fractions import gcd input = sys.stdin.readline N = int(input()) a = list(map(int, input().split())) l = [0] * (N + 1) r = [0] * (N + 1) for i in range(N): l[i + 1] = gcd(l[i], a[i]) a.reverse() for i in range(N): r[i + 1] = gcd(r[i], a[i]) res = 0 for i in range(N + 1): res = max(res, gcd(l[i], r[N - i - 1])) print(res)
p03274
s723615569
Accepted
N, K = map(int, input().split()) x = list(map(int, input().split())) ans = [] for i in range(N-K+1): l = x[i] r = x[i+K-1] ans.append(min(abs(l)+abs(l-r), abs(r)+abs(l-r))) print(min(ans))
p03037
s222089691
Wrong Answer
n, m = map(int, input().split()) a = [] flag = True for i in range(m): l, r = map(int, input().split()) if i == 0: l1 = l r1 = r else: if l1 < l: l1 = l elif r1 > r: r1 = r if flag: print(r1-l1+1) else: print(0)
p02823
s405543834
Accepted
N, A, B = map(int, input().split()) if (B - A) % 2 == 0: print((B - A) // 2) else: # N ใซๅ‘ใ‹ใ†ใ“ใจใ‚’่€ƒใˆใ‚‹ A_to_N_dis = N - B + 1 A_to_N = A + A_to_N_dis tmp_ans = (N - A_to_N) // 2 + A_to_N_dis # 1ใซๅ‘ใ‹ใ†ใ“ใจใ‚’่€ƒใˆใ‚‹ B_to_1_dis = A - 1 + 1 B_to_1 = B - B_to_1_dis ans = (B_to_1 - 1) // 2 + B_to_1_dis print(min(tmp_ans, ans))
p02995
s569156726
Accepted
import sys def input(): return sys.stdin.readline().strip() def mapint(): return map(int, input().split()) sys.setrecursionlimit(10**9) A, B, C, D = mapint() from math import gcd m = C*D//gcd(C, D) Ccnt = B//C-(A-1)//C Dcnt = B//D -(A-1)//D Mcnt = B//m - (A-1)//m print((B-A)-(Ccnt+Dcnt-Mcnt)+1)
p02711
s157731623
Accepted
inp=input() ok=0 for i in range(len(inp)): if(inp[i]=='7'): print("Yes") ok=1 break if(ok==0): print("No")
p02724
s676225999
Wrong Answer
b=int(input()) if b>=10: overall=b*2 print(overall) elif b<=9 and b>0: print(b) elif b<=0: print(0)
p03254
s467726581
Wrong Answer
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np def main(n, x, a): cnt = 0 for i in a: x -= i if x <= 0: break elif i == a[-1] and x > 0: break cnt += 1 return cnt n, x = map(int, readline().split()) a = np.sort(np.array(readline().split(), np.int64)) print(main(n, x, a))
p03474
s466116559
Accepted
A,B=map(int,input().split()) S=list(input()) if S[A]!='-': print("No") else: S.sort() #print(S) for i in range(1,len(S)): if S[i]=="-": print("No") break else: print("Yes")
p02973
s038841180
Accepted
from bisect import bisect_left N,A,c = int(input()),[],[] for i in range(N): A.append(int(input())) A.reverse() for x in A: p = bisect_left(c, x+1) if p == len(c): c.append(x) else: c[p] = x print(len(c))
p02677
s195735721
Accepted
import math a, b, h, m = map(int,input().split()) ms = m//60 ma = m%60 h = h + ms ha =h%12 + ma/60 rh = ha*math.pi/6 rm = ma*math.pi/30 x = math.cos(rh - rm) ans = math.sqrt(a**2 + b**2 - 2*a*b*x) print(ans)
p03565
s267929026
Accepted
s=list(input()) t=input() n,m=len(s),len(t) def match(a,b): for i in range(len(a)): if a[i]!=b[i] and a[i]!="?": return False return True flag=True for i in range(n-m,-1,-1): if match(s[i:i+m],t): for j in range(m): s[j+i]=t[j] flag=False break if flag: print("UNRESTORABLE") exit() for i in range(n): if s[i]=="?": s[i]="a" print(*s,sep="")
p03797
s501003995
Accepted
N,M=map(int,input().split()) #S=N,C=M print(min(((2*N)+M)//4,M//2))
p03324
s339619859
Accepted
def main(): d, n = map(int, input().split()) answer = 100 ** d if 0 < d: while 0 < n: if answer % (100 ** d) == 0 and answer % (100 ** (d + 1)) > 0: n -= 1 answer += 100 ** d answer -= 100 ** d else: answer = n if n < 100 else 101 print(answer) if __name__ == '__main__': main()
p03548
s789201169
Wrong Answer
x,y,z = map(int,input().split()) print(x//(y+z))
p02659
s664752864
Accepted
A, B = input().split() c = int(A) * round(float(B)*100) ans = c // 100 print(int(ans))
p03665
s881588758
Accepted
n,p = map(int,input().split()) a = [int(i) for i in input().split()] odd = 0 evil = 0 for i in a: if i % 2== 0: evil += 1 else: odd += 1 if p==1 and odd ==0: print(0) elif evil ==n: print(pow(2,n)) else: print(pow(2,n-1))
p02983
s883348529
Accepted
L, R = map(int, input().split()) R = min(R, L+4038) ans = 2018 for i in range(L, R): for j in range(i+1, R+1): ans = min((i*j)%2019, ans) print(ans)
p03548
s454423092
Accepted
x,y,z = (int(x) for x in input().split()) cnt = 0 while x >= y*cnt+z*(cnt+1): if x == y*cnt+z*(cnt+1): print(str(cnt)) break cnt+=1 else: print(str(cnt-1))
p03672
s735155202
Accepted
s = input() while len(s) > 2: s = s[:-2] x = len(s) // 2 if s[:x] == s[x:]: print(len(s)) break
p03803
s752767945
Accepted
A,B = map(int,input().split()) if A == 1: A += 13 if B == 1: B += 13 if A == B: print("Draw") elif A < B: print("Bob") else: print("Alice")
p02754
s605725711
Accepted
N,A,B = map(int,input().split()) c = 0 if A == 0: print(0) exit() if B == 0: print(N) exit() x = N // (A+B) y = N % (A+B) c = x * A if A <= y: c += A else: c += y print(c)
p03001
s528299800
Wrong Answer
W,H,x,y=map(int,input().split()) xx = min(W-x,x) yy = min(H-y,y) A1 = H*xx A2 = W*yy res = max(A1,A2) if A1 == A2: print(res,1) else: print(res,0)
p03339
s039114291
Wrong Answer
#C - Attention N = int(input()) S = input() DP_w= [] DP_e = [] tmp = 0 tmpw = 0 tmpe = 0 ans = 0 # for i in range(N): # if S[i] == "W": # tmpw += 1 # DP_w.append(tmpw) # DP_e.append(tmpe) # else: # tmpe += 1 # DP_w.append(tmpw) # DP_e.append(tmpe) for i in range(N): tmpw = S[:i].count('W') tmpe = S[i:].count('E') ans = max(ans,tmpw+tmpe) print(ans)
p03329
s376092765
Wrong Answer
N=int(input()) ans=0 while N: if 12<=N<=14: N-=6 ans+=1 if 1458<=N<=1511: N-=729 ans+=1 if 13122<=N<=14336: N-=6561 ans+=1 i=0 while 9**i<=N: i+=1 i-=1 j=0 while 6**j<=N: j+=1 j-=1 N-=max(9**i,6**j) ans+=1 print(ans)
p02753
s033261968
Accepted
S = input() if S[0]==S[1] and S[0]==S[2]: ans = 'No' else: ans = 'Yes' print(ans)
p02661
s915076456
Accepted
import statistics import math N = int(input()) a = [] b = [] for i in range(N): A, B = map(int,input().split()) a.append(A) b.append(B) if N%2 == 1: ans = statistics.median(b) - statistics.median(a) + 1 else: ans = (statistics.median(b) - statistics.median(a))*2 + 1 print(int(ans))
p02702
s997176100
Accepted
import sys readline = sys.stdin.readline from collections import Counter MOD = 2019 def main(): S = list(map(int, list(readline().rstrip()))) N = len(S) T = [0] * (N+1) e = 1 for i in range(N-1, -1, -1): T[i] = (T[i+1] + int(S[i]) * e) % MOD e = e * 10 % MOD T = [t % MOD for t in T] c = Counter(T) ans = 0 for k, v in c.items(): ans += (v * (v-1)) // 2 print(ans) if __name__ == '__main__': main()
p02859
s562296684
Wrong Answer
r=int(input()) print(int((3.14*r*r)/3))
p02924
s817304991
Wrong Answer
import sys stdin=sys.stdin ns = lambda:stdin.readline().rstrip() ni = lambda:int(stdin.readline().rstrip()) nm = lambda:map(int,stdin.readline().split()) nl = lambda:list(map(int,stdin.readline().split())) N=int(input()) print(N*(N-1)/2)
p02641
s371273877
Accepted
from collections import defaultdict if __name__ == "__main__": x,n = map(int,input().split()) l = list(map(int,input().split())) if n == 0 : print(x) else : l.sort() count = 0 dist = 999 ans = -100 for i in range(-100,201) : if i in l : continue if dist > abs(x - i) : dist = abs(x - i) ans = i print(ans)
p02660
s522074585
Accepted
n = int(input()) nn = n nnn = n e = [] while n % 2 == 0: e.append(2) n = n // 2 p = 3 while p * p <= n: if n % p == 0: e.append(p) n = n // p else: p = p + 2 if n != 1: e.append(n) ue = set(e) cnt = 0 for f in ue: tmpf = f while nn % f == 0: cnt = cnt + 1 nn = nn // f f = f*tmpf if nnn == 1: print(0) else: print(cnt)
p03434
s350553885
Wrong Answer
n=int(input()) a = list(map(int, input().split())) al=0 bo=0 for i in range(n): if i%2==0: al+=a[i] else: bo+=a[i] print(al-bo)
p03013
s954941121
Wrong Answer
N, M = map(int, input().split()) A = [True] * (N + 1) for _ in range(M): a = int(input()) - 1 A[a] = False dp = [0] * (N + 1) dp[0] = 1 for i in range(N): for j in range(i + 1, min(N, i + 2) + 1): if A[j] is True: dp[j] += dp[i] dp[j] %= 10 ** 9 + 7 print(dp[N])
p03417
s559998059
Wrong Answer
n, m = map(int, input().split()) ans = (n-2)*(m-2) if ans < 0: ans = 0 print(ans)
p02645
s397247529
Accepted
S = input() print(S[0],S[1],S[2],sep="")
p03038
s804440946
Accepted
n,m = map(int,input().split()) a_array = [int(x) for x in input().split()] d = dict() for a in a_array: d.setdefault(a, 0) d[a] += 1 for _ in range(m): b,c = map(int, input().split()) d.setdefault(c, 0) d[c] += b key = sorted(d.keys(),reverse=True) ans = 0 index = 0 while n > 0: num = key[index] if d[num] >= n: ans += num * n break ans += num * d[num] n -= d[num] index += 1 print(ans)
p02615
s662954771
Accepted
from collections import deque n = int(input()) a = list(map(int,input().split())) a.sort() fir = a[n-1] sco = 0 sit = deque([fir]) for i in range(n-1): sco += sit.popleft() sit.append(a[n-i-2]) sit.append(a[n-i-2]) print(sco)
p03043
s129941709
Accepted
import math N, K = map(int, input().split(' ')) ans=0 # 1ใ‹ใ‚‰Nใพใงใฎใฉใ‚Œใ‹ใŒใงใ‚‹ใ€ใใฃใ‹ใ‚‰ๅ€ใ€…ใซใ—ใฆKใซ for i in range(1,N+1): t=max(0,math.ceil(math.log2(K/i))) ans+=(0.5**t)/N print(ans)
p02775
s179468735
Wrong Answer
N= int(input()) n = N ans = 0 i = 0 while n: j = i i = n%10 if i > 11-i: ans += 10-i else: ans += i n//= 10 if (j > 5 and i <= 5) or (j <= 5 and i > 5): ans += 1 print(ans)
p03485
s953621462
Accepted
a, b = map(int, input().split()) import math print(math.ceil((a + b) / 2))
p03474
s687072749
Accepted
a,b = map(int, input().split()) s = input() if len(s) == a+b+1 and s.count("-") == 1 and s[a] == "-": print("Yes") else: print("No")
p02678
s560041929
Wrong Answer
from collections import deque n,m = map(int, input().split()) graph = [[] for i in range(n+1)] dist = [-1] * (n+1) dist[0] = 0 dist[1] = 0 for _ in range(m): a,b = map(int, input().split()) graph[a].append(b) graph[b].append(a) d = deque() d.append(1) while d: v = d.popleft() for i in graph[v]: if dist[i] != -1: continue dist[i] = dist[v]+1 d.append(i) print('Yes') for i in range(2,n+1): print(dist[i])
p04045
s250198887
Accepted
N, K = list(map(int, input().split())) D = set(input().split()) num = {str(i) for i in range(10)} - D while True: if set(str(N)) <= num: ans = N break else: N += 1 print(ans)
p02996
s698699755
Wrong Answer
n = int(input()) a = [0] * n b = [0] * n sa = [0] * n for i in range(n): a[i], b[i] = map(int, input().split()) c = b.copy() c.sort() wa = 0 for i in c: wa += a[b.index(i)] if wa > b[b.index(i)]: print("No") exit() print("Yes")
p03419
s256071548
Accepted
# https://atcoder.jp/contests/arc091/tasks/arc091_a n, m = map(int, input().split()) peremeter = 0 if n == 1 and m == 1: pass elif n == 1 or m == 1: peremeter += 2 else: peremeter += (n - 1) * 2 peremeter += (m - 1) * 2 ans = n * m - peremeter print(ans)
p03680
s162545568
Wrong Answer
import sys import itertools sys.setrecursionlimit(1000000000) from heapq import heapify,heappop,heappush,heappushpop import math import collections n = int(input()) A = [int(input()) for i in range(n)] flag = [False for i in range(n)] flag[0] = True cnt = 0 for i in range(n): if flag[i] == False: continue flag[A[i]-1] = True cnt += 1 if flag[1] == True: break if flag[1] == False: print(-1) else: print(cnt)
p02720
s152112321
Accepted
# -*- coding: utf-8 -*- import queue K = int(input()) q = queue.Queue() count = 0 for i in range(1, 10): q.put(i) a = 0 while count < K: a = q.get() fp = int(str(a)[-1]) if fp == 0: q.put(a*10) q.put(a*10 + 1) elif fp == 9: q.put(a*10 + 8) q.put(a*10 + 9) else: q.put(a*10 + fp - 1) q.put(a*10 + fp) q.put(a*10 + fp + 1) count += 1 print(a)
p02792
s052424033
Accepted
n=int(input()) ans=0 Dic={} for i in range(1,n+1): s=str(i) d=(s[0],s[-1]) if d in Dic.keys(): Dic[d]+=1 else: Dic[d]=1 for a in Dic.keys(): b=(a[1],a[0]) if b in Dic.keys(): ans+=Dic[a]*Dic[b] print(ans)
p02953
s058645900
Accepted
def resolve(): n=int(input()) H=list(map(int,input().split())) def main(): if n == 1: return 'Yes' maxval=0 for i in range(n): if maxval-2>=H[i]: return 'No' else: maxval=max(maxval,H[i]) return 'Yes' print(main()) resolve()
p03821
s092262935
Wrong Answer
import math n = int(input()) mat = [list(map(int, input().split())) for _ in range(n)] ans = 0 for idx in range(n-1, -1, -1): a,b = mat[idx] a += ans if a <= b: score = b - a else: score = b*math.ceil(a/b) - a ans += score print(ans)
p03281
s805368253
Accepted
from math import sqrt N=int(input()) ans=0 for i in range(1,N+1,2): d=[] for j in range(1,int(sqrt(i))+1): if i%j==0: d.append(j) d.append(N//j) d=list(set(d)) if len(d)==8: ans+=1 print(ans)
p02696
s585496806
Accepted
import sys import math from pprint import pprint A, B, N = map(int, sys.stdin.readline().strip().split()) def func(x): # return math.floor(A*x/B) - A*math.floor(x/B) return A*x//B - A*(x//B) print(func(min(B-1, N)))
p02900
s031555757
Wrong Answer
A,B = map(int,input().split()) c = 1 for i in range(2,int(max(A,B)**0.5)+2): k = 0 while(A % i == 0 and B % i == 0): k = 1 A = A//i B = B//i c += k for i in range(2,int(A**0.5)+2): while(A % i == 0): A = A//i for i in range(2,int(B**0.5)+2): while(B % i == 0): B = B//i if A == B: c += 1 print(c)
p02958
s422381604
Accepted
import sys def solve(): input = sys.stdin.readline N = int(input()) P = [int(p) for p in input().split()] diff = 0 for i in range(N): if P[i] != i + 1: diff += 1 if diff <= 2: print("YES") else: print("NO") return 0 if __name__ == "__main__": solve()
p03000
s747012921
Accepted
n, X = map(int, input().split()) l = list(map(int, input().split())) sumList = [0] for i in range(n): s = sumList[i]+l[i] if s > X: break sumList.append(s) print(len(sumList))
p02705
s462759761
Accepted
import math, sys from bisect import bisect_left, bisect_right from collections import Counter, defaultdict, deque from copy import deepcopy from functools import lru_cache from heapq import heapify, heappop, heappush from itertools import accumulate, combinations, permutations input = sys.stdin.readline p = 10**9 + 7 ns = lambda: input().strip() ni = lambda: int(input().strip()) nm = lambda: map(int, input().split()) nl = lambda: list(map(int, input().split())) def main(): r = ni() print(2 * math.pi * r) if __name__ == '__main__': main()
p02946
s805378437
Accepted
K,X=map(int,input().split()) print(*[x for x in range(X-K+1,X+K)])
p03944
s813287307
Accepted
w,h,n = map(int,input().split()) p = [0,w,0,h] for i in range(n): x,y,a = map(int,input().split()) if a == 1: p[0] = max(x,p[0]) if a == 2: p[1] = min(x,p[1]) if a == 3: p[2] = max(y,p[2]) if a == 4: p[3] = min(y,p[3]) print(max(0,p[1]-p[0])*max(0,p[3]-p[2]))
p03433
s997052892
Accepted
n = int(input()) a = int(input()) coin = n%500 if a >= coin: print("Yes") else: print("No")
p04044
s029295758
Accepted
#!/usr/bin/env python3 def main(): n, l = map(int, input().split()) s = [] for i in range(n): s.append(input()) s.sort() print("".join(s)) if __name__ == "__main__": main()
p03665
s187180606
Accepted
n, p = map(int, input().split()) a = list(map(int, input().split())) even_cnt = 1 odd_cnt = 0 for i in range(n): if a[i] % 2 == 0: even_cnt *= 2 odd_cnt *= 2 else: k = even_cnt l = odd_cnt even_cnt = k + l odd_cnt = k + l if p == 0: print(even_cnt) else: print(odd_cnt)
p02695
s938980535
Accepted
from itertools import combinations_with_replacement n,m,q = map(int,input().split()) L = [i+1 for i in range(m)] li = [input().split() for i in range(q)] for i in range(q): li[i] = [int(x) for x in li[i]] ans = 0 for v in combinations_with_replacement(L,n): sum1 = 0 for i in li: if v[i[1]-1] - v[i[0]-1] == i[2]: sum1 +=i[3] ans = max(ans,sum1) print(ans)
p03061
s199137990
Accepted
from math import gcd N = int(input()) A = [0]+list(map(int, input().split()))+[0] L = [0]*(N+1) R = [0]*(N+1) for i in range(1, N+1): L[i] = gcd(L[i-1], A[i]) R[N-i] = gcd(R[N+1-i], A[N+1-i]) # print(L) # print(R) ans = 0 for i in range(1, N+1): ans = max(ans, gcd(L[i-1], R[i])) print(ans)
p03672
s211581992
Accepted
S = input() N = len(S) for d in range(1,N-1): if (N-d)&1: continue m = (N-d)//2 for i in range(m): if S[i] != S[m+i]: break else: print(N-d) exit()
p02696
s387346269
Wrong Answer
A,B,N=map(int,input().split()) import math M = 0 for x in range(max(N-100,0),N+1): Z = math.floor(A * x / B) - A * math.floor(x / B) if M < Z: M = Z print(M)
p02786
s839631688
Accepted
h = int(input()) import numpy as np def solve(num): if num==1: return 1 return 1+2 * solve(np.floor(num/2)) print(solve(h))
p02706
s552477159
Accepted
N,M = map(int, input().split()) A = list(map(int, input().split())) hw = sum(A) if N>=hw: print(N-hw) else: print(-1)
p03067
s213671252
Accepted
a,b,c=map(int,input().split()) if a>b: a,b=b,a print("Yes" if a<c<b else "No")
p03795
s212109454
Wrong Answer
n=int(input()) gohan=800*n if n>=15: cnt=n//15 total=gohan-200*cnt print(total)
p02946
s699076382
Accepted
k, x = map(int, input().split()) print(*[i for i in range(x-k+1, x+k)])
p02726
s706182830
Wrong Answer
#ใ”ใ‚ŠๆŠผใ— from scipy.sparse import csr_matrix from scipy.sparse.csgraph import dijkstra import numpy as np from collections import Counter N, X, Y = map(int, input().split()) start = list(range(0, N-1)) + list(range(1, N)) + [X, Y] end = list(range(1, N)) + list(range(0, N-1)) + [Y, X] cost = [1] * len(start) graph = csr_matrix((cost, (start, end))) lengths = dijkstra(graph, directed = False) c = Counter(lengths.astype(np.int64).reshape(-1)) for k in range(1, N): print(c[k])
p03380
s281844836
Wrong Answer
n=int(input()) l=list(map(int,input().split())) m=max(l) if m%2!=0: med=(m+1)//2 else: med=m//2 mi=m for ll in l: mi=min(mi,abs(ll-med)) if med+mi in l: print(m,med+mi) else: print(m,med-mi)
p02756
s909944939
Accepted
from collections import deque S = deque(input()) Q = int(input()) rev = False for _ in range(Q): T, F, C, *_ = input().split() + [None, None] if int(T) == 1: rev = not rev else: F = int(F) if rev: F = F % 2 + 1 if F == 1: S.appendleft(C) else: S.append(C) if rev: S.reverse() print(*[x for x in S if x], sep='')
p02761
s330338397
Wrong Answer
n,m=list(map(int,input().split())) if m==0: print('1'+'0'*(n-1)) exit(0) d=[-1]*4 for _ in range(m): s,c=list(map(int,input().split())) if d[s]!=-1 and d[s]!=c: print(-1) exit(0) d[s]=c ans=0 for i in range(1,n+1): if d[i]==-1: if ans==0:d[i]=1 else:d[i]=0 ans=10*ans+d[i] if len(str(ans))==n: print(ans) else: print(-1)
p02584
s992049953
Accepted
X,K,D=(int(x) for x in input().split()) x=abs(X) a=x//D b=x-a*D B=abs(x-(a+1)*D) if b>B: a=a+1 if a>=K: print(abs(x-K*D)) else: c=K-a if c%2 == 0: print(abs(x-a*D)) else: d=abs(x-(a-1)*D) e=abs(x-(a+1)*D) print(min(d,e))
p02861
s264042436
Accepted
import numpy as np import math N = int(input()) X=[] for i in range(N): X.append(list(map(int, input().split()))) X = np.array(X) gokei = 0 for i in range(N): for j in range(i+1, N): gokei += np.linalg.norm(X[i]-X[j]) print(gokei*math.factorial(N-1)*2/math.factorial(N))
p03721
s228979302
Accepted
n, k = map(int,input().split()) q = [] for i in range(n): q.append(list(map(int, input().split()))) q = sorted(q, key=lambda x:x[0]) cnt = 0 i = 0 while cnt < k: a, b = q[i] cnt += b i += 1 print(a)
p02597
s590039984
Wrong Answer
n = int(input()) s = list(input()) cnt = 0 for i in s: if i == "R": cnt += 1 else: break print(s.count("R")-cnt)
p02951
s619391033
Accepted
A,B,C = map(int,input().split()) X = C - A + B if X < 0: X = 0 print(X)
p03282
s955868989
Accepted
S = list(map(int, input())) K = int(input()) count = 0 for a in S: if a == 1: count += 1 if count == K: print(1) exit() else: print(a) exit()