problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03479
s843436314
Accepted
x,y = map(int,input().split()) d = y//x ans = 0 while 0 < d: ans += 1 d //= 2 print(ans)
p02791
s106268754
Accepted
N = int(input()) P = list(map(int, input().split())) m = N+1 c = 0 for i in range(N): if m > P[i]: m = P[i] c = c + 1 print(c)
p02595
s969982157
Wrong Answer
import math n, d = map(int, input().split()) count = 0 for i in range(n): x, y = map(int, input().split()) if math.sqrt((x)**2 + (y)**2) <= d: count += 1 else: break print(count)
p03645
s707797754
Accepted
N,M=map(int,input().split()) scan=[] gcan=[] flag=0 for i in range(M): a,b=map(int,input().split()) if a==1: scan.append(b) if b==N: gcan.append(a) if set(scan)&set(gcan): flag=1 if flag==1: print("POSSIBLE") else: print("IMPOSSIBLE")
p03417
s598408091
Accepted
N, M = map(int, input().split()) if N >= 3 and M >= 3: print((M-2)*(N-2)) elif N ==1 and M == 1: print(1) elif N == 1 and M >= 3: print(M-2) elif M ==1 and N >= 3: print(N-2) else: print(0)
p02768
s410220496
Accepted
n,a,b=map(int,input().split()) c=10**9+7 nca=1 ncb=1 for i in range(a): nca*=(n-i)*pow(i+1,c-2,c) nca%=c for i in range(b): ncb*=(n-i)*pow(i+1,c-2,c) ncb%=c ans=pow(2,n,c)-1-(nca+ncb) ans%=c print(ans)
p03760
s740126440
Accepted
O = input() E = input() ans = [] for i in range(len(E)): ans.append(O[i]) ans.append(E[i]) if len(E)==len(O): print("".join(ans)) else: ans.append(O[-1]) print("".join(ans))
p03339
s837112201
Wrong Answer
n = int(input()) s = input() # full search cnt = s.count('E') ans = cnt for i in range(n-1): if s[i] == 'E': cnt -= 1 if ans > cnt: ans = cnt else: cnt += 1 print(ans)
p03835
s799128807
Wrong Answer
K,S=map(int,input().split()) count=0 for X in range(K+1): for Y in range(X,K+1): for Z in range(Y,K+1): com=X+Y+Z if(com==S): count+=1 else: pass print(count)
p02628
s051261468
Accepted
n,k=map(int,input().split()) L=list(map(int,input().split())) L.sort() ans=0 for i in range(k): ans+=L[i] print(ans)
p02681
s981766526
Accepted
s = input() t = input() l = len(s) if s == t[:l]: print('Yes') else: print('No')
p03086
s466968443
Wrong Answer
ans = [] cnt = 0 for s in input(): if not s in "ACGT": ans.append(cnt) continue cnt += 1 ans.append(cnt) print(max(ans) )
p02697
s625444134
Accepted
import sys readline = sys.stdin.readline n,m = map(int,readline().split()) l=1 r=n used = set() while len(used) < m * 2: diff = r - l rdiff = n - diff if diff == rdiff: r -= 1 continue if diff in used: r -= 1 continue print(l,r) used.add(diff) used.add(rdiff) l += 1 r -= 1
p02946
s603382002
Wrong Answer
K,X =map(int,input().split()) l = [] for i in range(X-K+1,X+K): l.append(str(i)) ##print(l) print("".join(l))
p02701
s857058593
Accepted
n = int(input()) l = list() c = 0 for i in range(n): x = input() l.append(x) l = set(l) print(len(l))
p03545
s066921649
Accepted
from itertools import product s = list(input()) n = len(s)-1 for x in list(product(["+", "-"], repeat=n)): x = list(x) x.append("") strs = [i+j for i, j in zip(s, x)] if eval("".join(strs)) == 7: print("".join(strs) + "=7") break
p02615
s557185625
Accepted
n = int(input()) a = sorted(list(map(int, input().split())), reverse=True) ans = 0 i = 0 for j in range(n - 1): ans += a[i] if j % 2 == 0: i += 1 print(ans)
p02801
s781701345
Wrong Answer
# -*- coding: utf-8 -*- import sys def main(): alist = [ "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", ] for s in sys.stdin: i = 0 for a in alist: if s == a: print(alist[i+1], end="") i += 1 if __name__ == '__main__': main()
p02548
s485253720
Accepted
import math N = int(input()) #sqrtN = math.floor(math.sqrt(N)) #count = 1 #for i in range(sqrtN): # count += 2 *((N-1) // (i+2)) count = 0 for i in range(N): count += (N-1) // (i+1) print(count)
p02683
s166011074
Accepted
import itertools import numpy as np n, m, x = map(int, input().split()) c = [] a = [] for i in range(n): cu, *au = list(map(int, input().split())) c.append(cu) a.append(au) c = np.array(c) a = np.array(a) pmin = 10000000 for e in itertools.product([0, 1], repeat=n): e = np.array(e) results = np.dot(e, a) if results.min()>=x: p = np.dot(e, c) if p < pmin: pmin = p pmin = -1 if pmin==10000000 else pmin print(pmin)
p03250
s726962680
Wrong Answer
num=[int(i) for i in input().split()] num.sort() print(num[1]+num[2])
p03474
s793159140
Accepted
#!/usr/bin/env python # coding: utf-8 # In[8]: A, B = map(int, input().split()) S = input() # In[11]: flag = True for x in S[:A]: if x == "-": flag = False break if flag: for x in S[A+1:]: if x == "-": flag = False break if flag: if S[A] != "-": flag = False if flag: print("Yes") else: print("No") # In[ ]:
p03338
s938780544
Accepted
n = int(input()) s = input() m = 0 for i in range(1, n-1): if m < len(list(set(s[:i]) & set(s[i:]))): m = len(list(set(s[:i]) & set(s[i:]))) print(m)
p03001
s855506125
Accepted
W,H,x,y = map(int,input().split()) print(H*W/2, int(W/2 == x and H/2 == y))
p03545
s166288182
Accepted
nums = input() n = 4 def calc(i, f, sum): if i == n-1: if sum == 7: print(f+'=7') exit() else: calc(i+1, f + '-' + nums[i+1], sum - int(nums[i+1])) calc(i+1, f + '+' + nums[i+1], sum + int(nums[i+1])) calc(0, nums[0], int(nums[0]))
p02789
s438087255
Wrong Answer
a,b=map(int,input().split()) if a<=b: for i in range(b): print(a,end="") else: for i in range(a): print(b,end="")
p02797
s772032515
Wrong Answer
n, k , s = map(int, input().split()) ans = [] for i in range(k): ans.append(str(s)) for i in range(n-k): ans.append(str(s+1)) print(" ".join(ans))
p04043
s531634749
Accepted
#ABC042A x = list(input().split()) print("YES" if x.count("5")==2 and x.count("7")==1 else "NO")
p02771
s415807333
Wrong Answer
A,B,C = [int(x) for x in input().split()] if A != B and B != C and C!= A: print("No") else: print('Yes')
p03438
s145679427
Accepted
N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) cnta, cntb = 0, 0 for i in range(N): a, b = A[i], B[i] if a > b : cntb += a-b continue if (b-a)%2 > 0: cntb += 1 b += 1 cnta += (b-a) // 2 #print(cnta, cntb) print('Yes' if cnta >= cntb else 'No')
p02946
s436599143
Accepted
K,X = map(int, input().split()) ans = list() i = -(K-1) while i<K: ans.append(X+i) i+=1 print(*ans)
p02882
s103049032
Accepted
a,b,x=list(map(int,input().split())) import math x=x/a if a*b/2<x: print(math.degrees(math.atan(2*(a*b-x)/a**2))) else: print(math.degrees(math.atan(b**2/(2*x))))
p02677
s820937088
Accepted
A,B,H,M = map(int, input().split()) import math Hrad = H*math.pi*2/12 + M*math.pi*2/(60*12) Mrad = M*math.pi*2/60 theta = abs(Hrad - Mrad) print(math.sqrt(A**2 + B**2 -2*A*B*math.cos(theta)))
p03262
s070437983
Wrong Answer
from fractions import gcd N, X = map(int, input().split()) x = list(map(int, input().split())) if (N == 1): print(x[0]) exit(0) ans = abs(X - x[0]) for i in range(1, len(x)): ans = gcd(abs(x[i] - x[i - 1]), ans) print(ans)
p03262
s709920964
Accepted
import fractions from functools import reduce def gcd_list(numbers): return reduce(fractions.gcd, numbers) n,x=map(int,input().split()) print(gcd_list([abs(int(i)-x) for i in input().split()]))
p03220
s796819678
Accepted
n = int(input()) t, a = map(int, input().split()) h = list(map(int, input().split())) tmp = float('inf') ans = 0 for i in range(n): if tmp > abs(a - (t-h[i]*0.006)): tmp = abs(a- (t-h[i]*0.006)) ans = i print(ans+1)
p03637
s614760334
Accepted
N=int(input()) A=list(map(int,input().split())) div_1,div_2,div_4=0,0,0 for a in A: if a%4==0: div_4+=1 elif a%2==0: div_2+=1 elif a%2!=0: div_1+=1 if div_2==0 and div_1<=div_4+1: print('Yes') elif div_2>0 and div_1<=div_4: print('Yes') else: print('No')
p02675
s670303197
Accepted
N = int(input()) mod = N%10 if mod == 3: print("bon") elif mod in {0, 1, 6, 8}: print("pon") else: print("hon")
p04031
s530611187
Accepted
N=int(input()) a=list(map(int,input().split())) avg=0 for j in range(N): avg+=a[j] avg=avg/N t=int(avg) if abs(t-avg)>abs(t+1-avg): t=t+1 cost=0 for j in range(N): cost+=(a[j]-t)**2 print(cost)
p02556
s169504517
Accepted
m,*p=[], for i in [*open(0)][1:]:x,y=map(int,i.split());m+=x-y,;p+=x+y, a=max;print(a(a(m)-min(m),a(p)-min(p)))
p03013
s639108730
Accepted
n, m = [int(i) for i in input().split()] a = [1 for i in range(n+1)] for i in range(m): a[int(input())] = 0 dp = [0 for i in range(n + 1)] dp[0] = 1 if a[1]: dp[1] = 1 for i in range(2, n + 1): dp[i] = a[i] * (dp[i-2] * a[i-2] + dp[i-1] * a[i-1]) print(dp[-1] % 1000000007)
p03796
s861575383
Accepted
ans=1 md=10**9+7 for i in range(1,int(input())+1): ans=(ans*i)%md print(ans)
p02630
s641069934
Accepted
N=int(input()) A=list(map(int,input().split())) Q=int(input()) s=sum(A) import collections a= collections.Counter(A) for i in range(Q): B,C=map(int,input().split()) n=a[B] s+=(C-B)*n print(s) a[B]=0 a[C]=a[C]+n
p03645
s394392995
Accepted
N, M = map(int,input().split()) AB = [] for _ in range(M): a,b = map(int,input().split()) if a == 1 or b== N: AB.append((a,b)) set1 = set() set2 = set() for ab in AB: if ab[0] == 1: set1.add(ab[1]) if ab[1] == N: set2.add(ab[0]) if set1 & set2: print("POSSIBLE") else: print("IMPOSSIBLE")
p02601
s105468857
Accepted
a, b, c = list(map(int, input().split(" "))) k = int(input()) for i in range(k): if b <= a: b *= 2 else: c *= 2 if b > a and c > b: print("Yes") else: print("No")
p02594
s169635685
Accepted
X = int(input()) if X >= 30: print("Yes") else: print("No")
p03994
s154876572
Accepted
s = input() K = int(input()) s = list(s) # print(diff) for i in range(len(s)): if s[i] != 'a': dist = ord('z') - ord(s[i]) + 1 if dist <= K: K -= dist s[i] = 'a' # print(s) temp = K % 26 s[-1] = chr(ord(s[-1]) + temp) # print(s) print(''.join(s))
p02795
s976480505
Wrong Answer
h = int(input()) w = int(input()) k = int(input()) a = (k // (max(h, w) - 1)) print(a + 1)
p03030
s827348944
Accepted
n=int(input()) a=[] for i in range(n): b,c=map(str,input().split()) d=[str(i+1),b,int(c)*(-1)] a.append(d) a.sort(key=lambda x:x[1]) r={} ans=[] q=[] for f in a: e=f[1] t=[f[0],f[2]] if e not in r: q.sort(key=lambda x:x[1]) ans.append(q) q=[] q.append(t) r[e]=0 else: q.append(t) q.sort(key=lambda x:x[1]) ans.append(q) for y in ans: for w in y: print(w[0])
p03557
s229545173
Accepted
from bisect import bisect_right, bisect_left def main(): n = int(input()) A = sorted(list(map(int, input().split()))) B = list(map(int, input().split())) C = sorted(list(map(int, input().split()))) ans = 0 for b in B: ans += bisect_left(A, b) * (n - bisect_right(C, b)) print(ans) if __name__ == '__main__': main()
p03779
s977222555
Accepted
X = int(input()) a = 0 i = 0 while a < X: i += 1 a += i print(i)
p03469
s292149229
Accepted
s=input() print('2018'+s[4:])
p02657
s460937147
Accepted
a,b=map(int,input().split()) print(a*b)
p02546
s450906732
Accepted
s = input() if s[len(s)-1] == "s": print(s+"es") else: print(s+"s")
p04033
s383390012
Accepted
a,b = map(int,input().split()) if a > 0 and b > 0: print("Positive") elif a == 0 or b == 0: print("Zero") elif a < 0 and b > 0: print("Zero") elif a < 0 and b < 0: tmp = abs(a-b) if tmp % 2 == 0: print("Negative") else: print("Positive")
p03815
s349955009
Accepted
X = int(input()) r = 0 if (X % 11) % 6 == 0 else 1 print((X // 11) * 2 + (X % 11) // 6 + r)
p02744
s091804284
Accepted
chars = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'] n = int(input()) seq = [97 for i in range(n)] i = n - 1 print('a' * n) while i > 0: if seq[i] <= max(seq[:i]): seq[i] += 1 i = n - 1 print(''.join(map(chr, seq))) else: seq[i] = 97 i -= 1
p03860
s829839365
Accepted
A, s, C = input().split() print('A{}C'.format(s[0]))
p02726
s395003863
Accepted
def solve(n, x, y): res_list = [0] * n for i in range(n - 1): for j in range(i + 1, n): d = min(j - i, abs(i - x+1) + abs(j - y+1) + 1) res_list[d] += 1 return res_list[1:] n, x, y = map(int, input().split()) res_list = solve(n, x, y) for res in res_list: print(res)
p02829
s673265079
Wrong Answer
a = int(input()) b = int(input()) A = [1, 2, 3] A.pop(a-1) A.pop(b-2) print(A[0])
p02795
s033405632
Accepted
def main(h: int, w: int, n: int): m = max(h, w) if n % m == 0: print(n // m) else: print((n // m) + 1) if __name__ == "__main__": h = int(input()) w = int(input()) n = int(input()) main(h, w, n)
p03221
s285379143
Wrong Answer
n,m = map(int,input().split()) pre = [[] for _ in range(n)] num=[] for i in range(m): p,y = map(int,input().split()) pre[p-1].append([i,y]) for i in range(n): pre[i].sort(key=lambda x:x[1]) for j in range(len(pre[i])): num.append([pre[i][j][0],('0'*5+str(i+1))[:6]+('0'*5+str(j+1))[:6]]) num.sort(key=lambda x:x[0]) for k in num: print(k[1])
p03469
s193631754
Wrong Answer
S = input() print("2018"+S[5:])
p02753
s570324175
Accepted
s = input() if s[0] != s[1]: print("Yes") elif s[1] != s[2]: print("Yes") else: print("No")
p02631
s009169650
Accepted
N = int(input()) A = list(map(int,input().split())) cumsum = [0] for a in A: cumsum.append(cumsum[-1]^a) res = [] for i in range(N): res.append(cumsum[-1]^A[i]) print(" ".join(map(str, res)))
p03719
s819145576
Accepted
a,b,c=map(int,input().split()) if c>=a and c<=b: print("Yes") else: print("No")
p02866
s531556948
Accepted
import collections N=int(input()) D=list(map(int,input().split())) mod=998244353 data=collections.Counter(D) if D[0]==0 and data[0]==1: count=1 for i in range(1,len(data)): count*=data[i-1]**data[i] count%=mod print(count) else: print(0)
p02766
s980994706
Wrong Answer
import math x, y = [int(x) for x in input("").split()] a = math.log(x,y) b=x%y c=x/y if(c==0): print ("1") elif(b==0): print (math.ceil(a)+1) else: print (math.ceil(a))
p03327
s950441041
Wrong Answer
a=int(input()) if a >= 1000: print("ABD",a%1000+1) else: print("ABC",a)
p03761
s060628425
Accepted
from collections import Counter N = int(input()) S = [input() for _ in range(N)] a = [] s = S[0] for i in range(1,N): s += S[i] s = ''.join([key*(min(val//2,s.count(key)-S[i].count(key))) for key,val in Counter(s).items() if val > 1]) s = sorted(s) print(''.join(s))
p02873
s997467484
Wrong Answer
s = str(input()) num = [0 for _ in range(len(s)+1)] for i in range(len(s)): if (s[i] == "<"): num[i+1] = num[i]+1 for i in range(len(s),1,-1): if (s[i-1] == ">"): num[i-1] == max(num[i-1],num[i]+1) print(sum(num))
p04033
s320336596
Accepted
import numpy a,b = map(int,input().split()) if numpy.sign(a*b)==-1: print('Zero') elif (numpy.sign(a)==1) or (numpy.sign(b)==1): print('Positive') elif (a-b)%2==0: print('Negative') else: print('Positive')
p02797
s131696061
Accepted
n ,k ,s = map(int, input().split()) a = [s] * n for i in range(k,len(a)): if s != 1: a[i] -= 1 else: a[i] += 1 print(" ".join(map(str, a)))
p03644
s442023654
Wrong Answer
#!/usr/bin/env python3 def main(): n = int(input()) cnt = 0 while n % 2 == 0: n /= 2 cnt += 1 print(cnt) if __name__ == "__main__": main()
p03761
s504462078
Accepted
N = int(input()) let = [0]*26 S = input() for a in range(len(S)): let[ord(S[a])-ord("a")] += 1 for i in range(N-1): S = input() let_S = [0]*26 for j in range(len(S)): let_S[ord(S[j])-ord("a")] += 1 for k in range(26): if let[k] > let_S[k]: let[k] = let_S[k] ans = "" for l in range(26): ans += chr(ord("a")+l)*let[l] print(ans)
p02787
s238126589
Accepted
HP,n = map(int,input().split()) s = [tuple(map(int,input().split())) for i in range(n)] #dp[damage] := モンスターにdamageを与える最小コスト dp = [float('inf')]*(HP+1) #0~HP dp[0] = 0 for damage, cost in s: for hp in range(HP): next_idx = min(hp+damage, HP) dp[next_idx] = min(dp[next_idx], dp[hp]+cost) print(dp[-1])
p02783
s273091706
Accepted
def main(): h,a = map(int, input().split()) if h <= a: print(1) elif h%a== 0: print(h//a) else: print(h//a+1) if __name__ == '__main__': main()
p02947
s090240986
Accepted
from collections import Counter n = int(input()) s = [list(input()) for _ in range(n)] for i in range(n): s[i].sort() s[i] = ''.join(s[i]) counter = Counter(s) ans = 0 for val in counter.values(): ans += val * (val - 1) // 2 print(ans)
p02615
s878606988
Accepted
n = int(input()) a = list(map(int, input().split())) a.sort(reverse=True) ans = 0 for i in range(n-1): num = i // 2 num += 1 if i == 0: ans += a[i] else: ans += a[i-num+1] print(ans)
p03000
s509929656
Wrong Answer
n,x=map(int,input().split()) l=list(map(int,input().split())) k=0 cnt=0 for i in range(n): k += l[i] cnt += 1 if k>x: print(cnt+1) exit() else: continue print(cnt+1)
p03721
s582623222
Wrong Answer
n, k = map(int, input().split()) for _ in range(n): a, b = map(int, input().split()) k -= b if k <= 0: ans = a break print(ans)
p02957
s453389302
Wrong Answer
a=list(map(int,input().split())) if (a[0]+a[1])%2==0: print((a[0]+a[1])/2) else: print("IMPOSSIBLE")
p03385
s125423427
Wrong Answer
S=input() t=[a for a in S] number=0 for a in range(2): if 'a' in t: number+=1 elif 'b' in t: number+=1 elif 'c' in t: number+=1 if number==3: print('Yes') else: print('No')
p03543
s985667561
Accepted
def main(): N = input() if N[0] == N[1] == N[2] or N[1] == N[2] == N[3]: print("Yes") else: print("No") main()
p03838
s753016985
Wrong Answer
x,y = map(int,input().split()) if x <= y: print(y - x) else: print(abs(-x-y)+ 1)
p03095
s615914820
Accepted
N = int(input()) S = input() MOD = 10**9 + 7 from collections import Counter Scnt = Counter(list(S)) ans = 1 for cnt in Scnt.values(): ans = (ans * (cnt + 1)) % MOD ans -= 1 print(ans % MOD)
p02924
s109832461
Wrong Answer
N=int(input()) Q=(1+N)*N/2-N print(int(Q))
p02777
s620438523
Accepted
S,T = map(str,input().split()) X,Y = map(int,input().split()) Z = input() if S==Z: print(X-1,Y) elif T==Z: print(X,Y-1) else: print(X,Y)
p04012
s888252407
Accepted
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) from collections import Counter for check in list(Counter(read().rstrip().decode()).values()): if check % 2 == 1: print('No') exit() print('Yes')
p02939
s550851378
Accepted
S = input() now = "aa" tmp = "" ans = 0 for s in S: tmp += s if tmp != now: ans += 1 now = tmp tmp = "" print(ans)
p03408
s707050200
Wrong Answer
n = int(input()) blue = [input() for i in range(n)] m = int(input()) red = [input() for i in range(m)] a = set(blue) ans = [] for i in a: b = 0 for j in range(n): if blue[j] == i: b += 1 for j in range(m): if red[j] == i: b -= 1 ans.append(b) print(max(ans))
p03474
s761981596
Accepted
a,b = map(int, input().split()) s = input() ok = True ok = ok and s[0:a].isdecimal() ok = ok and s[a] == '-' ok = ok and s[a+1:].isdecimal() if ok: print("Yes") else: print("No")
p02842
s799801320
Accepted
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10**8) INF = float('inf') MOD = 10**9+7 def main(): N = int(readline()) for i in range(50000): a = int(i*1.08) if a == N: print(i) break else: continue else: print(':(') if __name__ == '__main__': main()
p02947
s763220976
Wrong Answer
n=int(input()) dict={} count=0 for i in range(0,n): temp=str(input()) temp=sorted(list(temp)) temp="".join(temp) if temp in dict: dict[temp]=dict[temp]+1 count=count+dict[temp] else: dict[temp]=1 print(count)
p03109
s213414101
Accepted
a=list(map(int,input().split('/'))) #print(a) if a[0]==2019: if a[1]==4: if 30>=a[2]: print("Heisei") else: print("TBD") elif 5>a[1]: print("Heisei") else: print("TBD") elif 2019>=a[0]: print("Heisei") else: print("TBD")
p02971
s274807313
Accepted
import bisect n = int(input()) A = [int(input()) for i in range(n)] A_sd = sorted(A) for a in A: if bisect.bisect_left(A_sd, a) == n - 1: print(A_sd[-2]) else: print(A_sd[-1])
p02756
s106088268
Wrong Answer
from collections import deque S = deque([s for s in input()]) Q = int(input()) for i in range(Q): query = input().split() t = int(query[0]) if t == 1: S[0], S[-1] = S[-1], S[0] else: f = int(query[1]) c = query[2] if f == 1: S.appendleft(c) else: S.append(c) print(''.join(S))
p02879
s146045210
Wrong Answer
A,B=map(int,input().split()) if A and B <=9: print(A*B) else: print("-1")
p02900
s644305449
Accepted
A,B=map(int,input().split()) import fractions import collections GCD=fractions.gcd(A,B) a=[] while GCD % 2 ==0: a.append(2) GCD //= 2 f = 3 while f * f <= GCD: if GCD % f == 0: a.append(f) GCD //= f else: f += 2 if GCD != 1: a.append(GCD) #print(a) c = collections.Counter(a) #print(c) #print(sum(c.values())+1) print(len(c)+1)
p03211
s249780298
Accepted
S = input() i=0 ans = 1000 while i < len(S)-2: tmp = abs(753-int(S[i:i+3])) ans = min([ans, tmp]) i+=1 print(ans)