problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03076
s379627264
Accepted
#cited by maspy A = [int(input()) for _ in range(5)] ceiled = [(x+9)//10*10 for x in A] can_save = [y - x for x,y in zip(A,ceiled)] answer = sum(ceiled) - max(can_save) print(answer)
p02645
s428885561
Wrong Answer
S=input() print("S[0]"+"S[1]"+"S[2]")
p03804
s293045928
Wrong Answer
n,m = map(int,input().split()) a = [input() for i in range(n)] b = [input() for i in range(m)] ans = "No" for i in range(n-m+1): for j in range(n-m+1): flag = True for k in range(m): if a[k][:m]!=b[k]: flag = False break if flag: ans = "Yes" break print(ans)
p03208
s063553324
Wrong Answer
import sys input = sys.stdin.readline def main(): N, K = map(int, input().split()) h = [int(input()) for i in range(N)] H = sorted(h) ans = H[N-1] - H[N-K] print(ans) if __name__ == '__main__': main()
p02860
s720431246
Accepted
# input N = int(input()) S = input() # check if N < 2 or N % 2 != 0: print("No") else: if N == 2: right = S[0] left = S[1] else: c = N // 2 right = S[0:c] left = S[c:] if right == left: print("Yes") else: print("No")
p03486
s242126248
Wrong Answer
s=input() t=input() s=sorted(s) t=sorted(t) if s<t: print('Yes') else: print('No')
p03605
s403492588
Accepted
N = input() if "9" in N: print("Yes") else: print("No")
p02602
s298827870
Accepted
n, k = map(int, input().split()) a = list(map(int, input().split())) for i in range(n - k): if a[i] < a[i + k]: print("Yes") else: print("No")
p02854
s649852599
Wrong Answer
N = int(input()) a = list(map(int, input().split())) num0 = 0 num1 = sum(a) ans = 10**10 for i in range(0, N): num0 += a[i] num1 -= a[i] if ans > abs(num1-num0): ans = abs(num1-num0) else: break print(ans)
p02608
s518960045
Accepted
N = int(input()) A = [0]*N for x in range(1,100): for y in range(1,100): for z in range(1,100): a = x**2+y**2+z**2+x*y+z*x+y*z if a <= N: A[a-1]+= 1 for a in A: print(a)
p02705
s283056844
Accepted
import math n = int(input()) print(n *2 * math.pi)
p02771
s247743237
Wrong Answer
n = list(map(int,input().split())) if n[0] == n[1] == n[2]: print('No') else: print('Yes')
p03611
s274041416
Accepted
# -*- coding: utf-8 -*- N = int(input()) a = list(map(int, input().split())) count = [0] * (10**5+1) for i in range(N): count[a[i]] += 1 if a[i]-1 >=0: count[a[i]-1] += 1 if a[i]+1 <=10**5: count[a[i]+1] += 1 max_value = max(count) #max_index = count.index(max_value) print(max_value)
p03281
s663651025
Accepted
N=int(input()) count = 0 def make_divisors(n): divisors = [] for i in range(1, int(n**0.5)+1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n//i) # divisors.sort() #小さい順位欲しいとき return divisors for i in range(1,N+1): if len(make_divisors(i))==8 and i%2==1: count += 1 print(count)
p03041
s766318367
Accepted
N, K = map(int, input().split()) line = input() S = list(i for i in line) S[K - 1] = S[K - 1].lower() print("".join(S))
p02982
s612813178
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-1): for j in range(i+1, n): ans = 0 for k in range(d): ans += (x[i][k] - x[j][k])**2 if math.sqrt(ans).is_integer(): count += 1 print(count)
p02880
s962419870
Wrong Answer
n = int(input()) num = [1, 2, 3, 4, 5, 6, 7, 8, 9] ans = 0 for i in range(len(num)): if n%(num[i]) == 0 and n//(num[i]) <= 9: ans = 1 if ans == 1: print("Yes") else: print("NO")
p03494
s971031240
Accepted
N = int(input()) A = list(map(int,input().split())) ans = 0 y = [] x = 0 z = 1 while x == 0: for i in range(N): a = str(A[i] % (2 ** z)) y.append(a) if y.count('0') == N: ans += 1 y = [] z += 1 else: x =+ 3 print(ans)
p02664
s293224296
Accepted
s=input() print(s.replace("?", "D"))
p03632
s312927211
Accepted
a,b,c,d = map(int,input().split()) print(max(min(b,d)-max(a,c),0))
p03943
s949916942
Wrong Answer
l = input ().split () list.sort (l, reverse=True) a = l[0] b = l[1] c = l[2] if a+b == c: print ('Yes') else: print ('No')
p02793
s199930978
Accepted
def gcd(a,b): if b==0: return a else: return gcd(b,a%b) mod=1000000007 n=input(); arr = list(map(int, raw_input().split())) l=arr[0]; for i in arr: x=gcd(l,i) l=(l*i)/x ans=0 #print l for i in arr: b=l/i ans+=b ans=(ans%mod +mod)%mod print ans
p03254
s706813622
Accepted
n,x = list(map(int, input().split())) a = sorted(list(map(int, input().split()))) cnt=0 for i,X in enumerate(a): if x>=X: cnt+=1 x-=X else: break if cnt==n and x>0: cnt-=1 print(cnt)
p02848
s222991557
Accepted
alph = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'] N = int(input()) S = input() new = "" for s in S: idx = alph.index(s) new += alph[N - (len(alph) - idx)] print(new)
p03379
s352599318
Wrong Answer
import copy n = int(input()) l = list(map(int,input().split())) p1 = n//2 p2 = n//2-1 ans = copy.copy(l) ans.sort() for i in l: if i >= l[p1]: print(ans[p2]) else: print(ans[p1])
p03012
s304562200
Accepted
# -*- coding: utf-8 -*- from sys import stdin input = stdin.readline import numpy as np N = int(input()) W = list(map(int,input().split())) temp = 1e+9 for i in range(N): res = np.array(W[:i]).sum() pos = np.array(W[i:]).sum() if(abs(res - pos) < temp): temp = abs(res - pos) print(temp)
p03329
s461535286
Wrong Answer
N = int(input()) n6 = 1 n9 = 1 li = [] while 9**n9 < N: li.append(9**n9) n9 += 1 while 6**n6 < N: li.append(6**n6) n6 += 1 li.sort() INF = 10**10 # 1円の場合はね dp = [[i for i in range(N+1)] for i in range(len(li) + 1)] dp = [i for i in range(N+1)] for i,l in enumerate(li): for j in range(N+1): if j+l > N : continue dp[j+l] = min(dp[j+l], dp[j]+1) # print(dp) print(dp[N])
p03211
s511803016
Accepted
s = input() n = len(s) ans = 10000 for i in range(n-2): x = int(s[i:i+3]) ans = min(ans, abs(753-x)) print(ans)
p03252
s945977058
Wrong Answer
S = list(input()) T = list(input()) s_len = len(set(S)) t_len = len(set(T)) if s_len == t_len: print('Yes') else: print('No')
p03161
s742686935
Accepted
n,k=map(int,input().split()) l=list(map(int,input().split())) dp=[0]*n for i in range(1,n): start=max(0,i-k) dp[i]=min(dp[j]+abs(l[i]-l[j]) for j in range(start,i)) print(dp[-1])
p02743
s808999258
Accepted
from decimal import Decimal a, b, c = map(Decimal, input().split()) if a.sqrt() + b.sqrt() < c.sqrt(): print('Yes') else: print('No')
p02594
s992569458
Wrong Answer
a = int(input()) if a > 30: print('Yes') else: print('No')
p03239
s065783065
Wrong Answer
n, t = map(int, input().split()) c = 10000 for i in range(n): tmp = input().split() if t >= int(tmp[1]): if int(tmp[0]) < c: c = int(tmp[0]) if c == 999: print('TLE') exit() else: print(c)
p03419
s040898170
Accepted
N, M = map(int, input().split()) if N == 2 or M == 2: print(0) else: print(abs((N - 2) * (M - 2)))
p03612
s841389320
Accepted
N = int(input()) P = list(map(int, input().split())) cnt = 0 ans = 0 t = 'o' if P[0] == 1 else 'x' for i, p in enumerate(P): s = 'o' if p == (i + 1) else 'x' if s == t: cnt += 1 else: if t == 'o': ans += (cnt + 2 - 1) // 2 cnt = 1 t = s else: if t == 'o': ans += (cnt + 2 - 1) // 2 print(ans)
p02629
s847934014
Accepted
n=int(input()) ans='' check='abcdefghijklmnopqrstuvwxyz' #c(a)-1=0,c(b)-1=1,…,c(z)-1=25を対応づける文字列 while n!=0: n-=1 ans+=check[n%26] #(n-1)%26がc(Sk)-1を表すので、上記の文字列を用いてc(Sk)-1からSkを求める n//=26 print(ans[::-1])
p03625
s908350438
Wrong Answer
M = int(input()) A = list(map(int,input().split())) B = [0]*(M+1) C = [0]*2 D = [0]*2
p03419
s265734801
Accepted
n,m=map(int,input().split()) print(abs(m-2)*abs(n-2))
p03379
s565215895
Accepted
N = int(input()) Xlist = list(map(int, input().split())) X_sort = sorted(Xlist) left_med = X_sort[N//2-1] right_med = X_sort[N//2] for i in range(N): if Xlist[i] <= left_med: print(right_med) else: print(left_med)
p03721
s782655501
Wrong Answer
n, k = map(int, input().split()) nums = [list(map(int, input().split())) for _ in range(n)] cnt = 0 for a, b in nums: cnt += b if cnt >= k: print(a) break
p03611
s619741865
Accepted
n = int(input()) a = list(map(int, input().split())) l = [0] * 100002 for i in a: l[i+1] += 1 l[i+2] += 1 l[i] += 1 print(max(l))
p03720
s077525734
Wrong Answer
n,m=map(int,input().split()) al=[] bl=[] for i in range(m): a,b=map(int,input().split()) al.append(a) bl.append(b) for i in range(m+1): print(al.count(i)+bl.count(i))
p03456
s181313975
Wrong Answer
a, b = map(str, input().split()) num = int(a+b) flag = False for i in range(1, 101): if i*i > num: break elif i*i == num: print("Yes") flag = True break if not flag: print("No")
p03076
s583077482
Accepted
a,b=5,10 for i in range(5): i=int(input()) a+=(i-1)//10 if 0<i%10<b: b=i%10 print(a*10-(10-b))
p03760
s019058923
Accepted
o=input() e=input() moji="" for i in range(0,len(o)): moji+=o[i] try: moji+=e[i] except IndexError: pass print(moji)
p02818
s660818219
Accepted
A, B, K = map(int, input().split()) if A >= K: print(A - K, B) elif A + B >= K: print(0, B - (K - A)) else: print(0, 0)
p02711
s873232080
Accepted
n = input() if "7" in n: print("Yes") else: print("No")
p02847
s686136742
Wrong Answer
S=input() D=['MON','TUE','WED','THU','FRI','SAT','SUN'] for i in range(len(D)): if D[i]==S: print(i+1)
p03478
s114931996
Accepted
N, A, B = map(int, input().split(" ")) result = 0 for i in range(N+1): if A <= sum(map(int, list(str(i)))) <= B: result += i print(result)
p02570
s673546492
Accepted
import sys import itertools tokens = itertools.chain.from_iterable(map(str.split, sys.stdin)) yesno = ['No', 'Yes'] d = int(next(tokens)) t = int(next(tokens)) s = int(next(tokens)) ans = yesno[d / s <= t] print(ans)
p03633
s079344514
Accepted
import fractions from functools import reduce def lcm(x, y): return (x * y) // fractions.gcd(x, y) def lcm_ls(num): return reduce(lcm, num, 1) n = int(input()) ls = [int(input()) for _ in range(n)] print(lcm_ls(ls))
p02947
s977330737
Wrong Answer
n = int(input()) res = dict() for i in range(n): m = input() m = sorted(m) m = ''.join(m) if m in res: res[m] += res[m] else: res[m] = 1 print(sum(res.values())-len(res))
p03206
s192128237
Accepted
D = int(input()) if D == 25: print("Christmas") elif D == 24: print("Christmas Eve") elif D == 23: print("Christmas"+" Eve"*2) else: print("Christmas"+" Eve"*3)
p02621
s579158394
Wrong Answer
x = int(input()) print(x+x^2+x^3)
p03910
s335736311
Accepted
import math N = int(input()) x = math.ceil((math.sqrt(8 * N + 1) - 1) / 2) S = x * (x + 1) // 2 ex = S - N for i in range(1, x + 1): if i != ex: print(i)
p03632
s359223752
Accepted
a,b,c,d=map(int,input().split()) if b<=c or d<=a: print(0) else: time=[] time.append(a) time.append(b) time.append(c) time.append(d) time.sort() print(time[2]-time[1])
p02939
s589213125
Accepted
S = list(input()) N = len(S) old = S[0] T = '' ans = 1 for i in range(1, N): if T == '': T = S[i] if T != old: ans += 1 old = T T = '' else: T += S[i] old = T ans += 1 T = '' print(ans)
p04012
s669059210
Accepted
def resolve(): w = str(input()) ls = set(w) for l in ls: if w.count(l) % 2 == 1: print('No') return print('Yes') return resolve()
p02823
s452645142
Wrong Answer
N,A,B=map(int,input().split()) if (B+A)%2==0: ans=int((B-A)/2) else: ans=min(A-1,N-B)+1+int((B-A-1)/2) print(ans)
p03262
s845737191
Wrong Answer
import numpy as np n,x=map(int,input().split()) p=list(map(int,input().split())) p.append(x) p.sort() p=np.array(p) p=p-x p1=np.array(p[1:]-p[:-1]) print(min(p1))
p04031
s286377604
Accepted
N = int(input()) a = list(map(int,input().split())) def minimize(list): min = 1000000 for i in range(-100,101): num = 0 for j in range(len(list)): num = num + (int(list[j]) - i)**2 if min >= num: min = num return min print(minimize(a))
p03001
s610114531
Accepted
w, h, x, y = map(int, input().split()) s_max = (w * h) / 2 if x == w / 2 and y == h / 2: print(s_max, 1) else: print(s_max, 0)
p02765
s681405417
Wrong Answer
n,r=map(int,input().split()) if n>=10: print(r) else: R=r-100*(10-n) print(R)
p02658
s888193413
Accepted
n = int(input()) a = list(map(int, input().split())) a.sort() tmp = a[0] f = True for i in range(1, n): tmp *= a[i] if tmp > 10 ** 18: f = False break if f: print(tmp) else: print(-1)
p03779
s847962199
Wrong Answer
import math x = int(input()) n = math.ceil(math.sqrt(x*2)) s = [list(map(int,bin(x)[2:].zfill(n))) for x in range(2**n)] t = 0 c = 0 min = x for i in range(2**n): for j in range(len(s[i])): t+=s[i][j]*(j+1) if s[i][j]==1: c =j+1 if t==x and c<min: min =c print(c)
p02880
s990687856
Accepted
r=range(10) print(['No','Yes'][int(input()) in {i*j for i in r for j in r}])
p02951
s377931438
Accepted
a,b,c = map(int,input().split()) d = a-b if c-d>0: print(c-d) else: print(0)
p02761
s869214250
Accepted
N, M = map(int, input().split()) sc = [list(map(int, input().split())) for _ in range(M)] if N == 1: ans = 0 else: ans = 10 ** (N - 1) limit = 10 ** N while ans < limit: l = str(ans) for s, c in sc: if not int(l[s-1]) == c: break else: print(ans) exit() ans += 1 print(-1)
p03986
s477155717
Accepted
x=input() s,a=0,0 for i in x: if i=="S": s+=1 elif s==0: a+=1 else: s-=1 print(a+s)
p03469
s600069922
Wrong Answer
S=input() print("2018"+S[5:])
p02690
s372798814
Accepted
X = int(input()) A, B = 0, 0 for i in range(-200, 200): for j in range(-200, 200): if X == i**5 - j**5: A = i B = j print(A, B)
p03644
s355816379
Accepted
n = int(input()) for i in range(6,0,-1): if n >= 2**i: print(2**i) exit() print(1)
p03449
s469515763
Wrong Answer
n = int(input()) a1 = list(map(int,input().split())) a2 = list(map(int,input().split())) s1 = [a1[0]] s2 = [a2[-1]] for i in range(n-1): s1 += [s1[i]+a1[i+1]] s2 += [s2[i]+a2[n-i-2]] ans = 0 for i in range(n): ans += max(ans, s1[i] + s2[n-1-i]) print(ans)
p02963
s310121349
Accepted
def main(): s = int(input()) p, q = divmod(-s, 10 ** 9) print(0, 0, 1, 10 ** 9, abs(p), q) if __name__ == '__main__': main()
p04033
s028894703
Accepted
i = input().split() a = int(i[0]) b = int(i[1]) if a < 0 and b > 0: print("Zero") elif a < 0 and b < 0: tmp = (a*-1) - (b*-1) + 1 if tmp % 2 == 0: print("Positive") else: print("Negative") else: print("Positive")
p03150
s652183925
Accepted
s=input();ans='NO' if s == 'keyence': ans = 'YES' l = len(s) if len(s) >= 8: i = 0 while i < 8: s0 = s[:i]+s[i+(len(s)-7):] if s0 == 'keyence': ans = 'YES' break i += 1 print(ans)
p04019
s544454972
Accepted
S = input() direct = set() for s in S: direct.add(s) if len(direct) == 4: print("Yes") elif (len(direct) == 2) and ('N' in direct) and ('S' in direct): print("Yes") elif (len(direct) == 2) and ('E' in direct) and ('W' in direct): print("Yes") else: print("No")
p03962
s586419013
Accepted
import sys sys.setrecursionlimit(10 ** 7) input = sys.stdin.readline f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): ABC = list(map(int, input().split())) print(len(set(ABC))) if __name__ == '__main__': resolve()
p02647
s071515798
Wrong Answer
N, K = map(int, input().split()) A_ = list(map(int, input().split())) count = [0] * N for _ in range(0, K): count = [0] * N for i in range(0, N): a_min = int(i - A_[i] - 0.5 + 1) a_max = int(i + A_[i] + 0.5) if(a_min < 0): a_min = 0 if(a_max > N - 1): a_max = N -1 for j in range(a_min, a_max + 1): count[j] += 1 A_ = count print(A_)
p02989
s503868114
Accepted
N = int(input()) d = list(map(int,input().split())) k = 0 d.sort() if len(d) % 2 == 1: k = 0 elif d[int(len(d) / 2)] == d[int((len(d) / 2) - 1)]: k = 0 else: k = d[int(len(d) / 2)] - d[int((len(d) / 2) - 1)] print(k)
p03239
s682507166
Accepted
MOD = 10 ** 9 + 7 INF = 10 ** 10 import sys sys.setrecursionlimit(100000000) dy = (-1,0,1,0) dx = (0,1,0,-1) def main(): n,T = map(int,input().split()) ans = INF for _ in range(n): c,t = map(int,input().split()) if t <= T: ans = min(ans,c) if ans == INF: print('TLE') else: print(ans) if __name__ =='__main__': main()
p03371
s593648448
Wrong Answer
A,B,C,X,Y = map(int, input().split()) ans = 0 if A >= C: ans += 2*C*X Y -= X if Y > 0: if B >= C: ans += 2*C*Y else: ans += B*Y else: if B >= C: ans += 2*C*Y X -= Y else: ans += B*Y if X > 0: ans += A*X print(ans)
p03817
s332794550
Wrong Answer
def solve(): x = int(input()) n = x // 11 if x == n * 11: return 2 * n elif n * 11 < x <= n * 11 + 5: return 2 * n + 1 elif n * 11 + 5 < x <= n * 11 + 11: return 2 * n + 2 print(solve())
p03103
s890993984
Accepted
import sys sys.setrecursionlimit(10**7) input = sys.stdin.readline n,m = map(int, input().split()) li = [list(map(int, input().split())) for _ in range(n)] s = 0 for i in sorted(li): if i[1] <= m: m -= i[1] s += i[0] * i[1] else: s += i[0] * m break print(s)
p02953
s170622255
Wrong Answer
def ok(hs): m = 0 for h in hs: if h > m + 1: return False m = max(m, h) return True n = int(input()) print('Yes' if ok(map(int, input().split())) else 'No')
p03043
s631639519
Accepted
import numpy as np n, k = map(int, input().split()) dice = np.arange(1, n+1) m = np.ceil(np.log2(k) - np.log2(dice)) for i in range(n): if m[i] <= 0: m[i:] = 0 break p = (0.5**m) print(sum(p)/n)
p02608
s589250954
Accepted
import math import sys n = int(input()) l = [0] * n if n < 6: for i in range(n): print(0) sys.exit() y = int(math.sqrt(n-3)) if n <= 5: for i in range(n): print(0) for i in range(1,y): for j in range(1, y): for k in range(1, y): x = i ** 2 + j ** 2 + k ** 2 + i*j + i*k + j*k if x % 1 == 0 and x <= n: l[x-1] += 1 for i in l: print(i)
p03804
s260232301
Accepted
def mtx2vec(mtx): tmp = '' for s in mtx: tmp += s return tmp N, M = map(int, input().split()) A = [] B = [] for _ in range(N): A.append(input()) for _ in range(M): B.append(input()) b = '' for s in B: b += s ans = 'No' for i in range(N-M+1): for j in range(N-M+1): tmp = '' for k in range(M): tmp += A[i+k][j:j+M] if tmp == b: ans = 'Yes' break print(ans)
p02796
s866508540
Accepted
n = int(input()) lines = [] for i in range(n): x,l = map(int,input().split()) lines.append([x-l,x+l]) lines = sorted(lines,key=lambda x:x[1]) count = 0 kari = -9999999999999 for i in range(n): if lines[i][0] >= kari: count += 1 kari = lines[i][1] print(count)
p02615
s453630196
Accepted
n = int(input()) li_a = list(map(int,input().split())) li_a.sort(reverse=True) ans = li_a[0] if n % 2 == 0: for i in range(1,n//2): ans += 2*li_a[i] else: for i in range(1,n//2): ans += 2*li_a[i] ans += li_a[n//2] print(ans)
p02888
s165675557
Accepted
import bisect N=int(input()) L=list(map(int,input().split())) L=sorted(L) ans=0 for i in range(N-1): for k in range(i+1,N-1): a=L[i]+L[k] b=bisect.bisect_left(L,a) ans=ans+(b-k-1) print(ans)
p02983
s407197552
Wrong Answer
l,r=map(int,input().split()) lmod673=l%673 rmod673=r%673 lmod2019=l%2019 rmod2019=r%2019 if lmod2019==0 or lmod2019>rmod2019: print(0) elif rmod2019-lmod2019>=673: print(0) elif lmod673>rmod673 or lmod673==0: if r-l>=2: print(0) elif (lmod2019*rmod2019)%3==0: print(0) else: print(lmod2019*(lmod2019+1)) else: print(lmod2019*(lmod2019+1))
p02663
s938781507
Accepted
h1, m1, h2, m2, k = map(int, input().split()) t = (m2 - m1) + (h2 - h1) * 60 ans = t - k print(ans)
p02918
s983892677
Accepted
n , k = map(int,input().split()) s = input() cou = 0 for i in range(1,n): if s[i-1] != s[i]: cou += 1 print(n-1-max(0,cou-2*k))
p02755
s834118375
Wrong Answer
a,b=map(int,input().split()) k=[] o=[] p=[] for i in range(1,101): if int(i*0.08)==a: k.append(i) for j in range(1,101): if int(j*0.1)==b: o.append(j) for t in range(len(k)): for u in range(len(o)): if k[t]==o[u]: p.append(k[t]) if p==[]: print(-1) else: print(min(p))
p03069
s521164986
Accepted
n = int(input()) s = input() w = s.count('.') b = n - w ans = min(w, b) r = 0 l = w for si in s: if si == '#': r += 1 else: l -= 1 if ans > r + l: ans = r + l print(ans)
p02900
s846982871
Accepted
import fractions def div(n): l =[] for i in range(1,n+1): if n%i ==0: l.append(i) return l def prime_decomposition(n): i = 2 table = [] while i * i <= n: while n % i == 0: n /= i if i not in table: table.append(i) i += 1 if n > 1: table.append(n) return table A,B = list(map(int,input().split())) maxy = fractions.gcd(A,B) l2 = prime_decomposition(maxy) print(len(l2) + 1)
p02584
s956664052
Accepted
X, K, D = map(int, input().split()) num = abs(X)//D if num >= K: X = abs(X) - K*D else: if num%2 == K%2: X = abs(X) - D*num else: X = abs(X) - D*(num+1) print(abs(X))
p04044
s593661510
Wrong Answer
n,l=map(int,input().split()) s=[input() for _ in range(n)] t=[] t.append(s[0]) for i in range(1,n): t.append(s[i]) for j in reversed(range(len(t)-1)): for k in range(l): if not t[j][:k+1]==t[j+1][:k+1]: if ord(t[j][k])>ord(t[j+1][k]): t[j],t[j+1]=t[j+1],t[j] else: break print("".join(t))
p02793
s366115707
Accepted
MOD = 1000000007 def gcd(a, b): if b == 0: return a else: return gcd(b, a%b) def lcm(a, b): return a//gcd(a,b)*b n = int(input()) a = list(map(int,input().split())) all_lcm = 1 for i in range(n): all_lcm = lcm(all_lcm, a[i]) ans = 0 for i in range(n): ans += all_lcm//a[i] print(ans%MOD)