code1
stringlengths
16
427k
code2
stringlengths
16
427k
similar
int64
0
1
pair_id
int64
2
178,025B
question_pair_id
float64
27.1M
177,113B
code1_group
int64
1
297
code2_group
int64
1
297
def main(): N, K = map(int, input().split()) P = list(map(lambda x: int(x)-1, input().split())) C = list(map(int, input().split())) loop = [0] * N loopsum = [0] * N for i in range(N): if loop[i] > 0: continue cnt = 0 cur = i visited = set() score = 0 while cur not in visited: visited.add(cur) cnt += 1 cur = P[cur] score += C[cur] for v in visited: loop[v] = cnt loopsum[v] = score ans = max(C) for i in range(N): if loopsum[i] >= 0 and loop[i] <= K: score = loopsum[i] * (K // loop[i] - 1) limit = K % loop[i] + loop[i] else: score = 0 limit = min(loop[i], K) cur = i for _ in range(limit): cur = P[cur] score += C[cur] ans = max(ans, score) print(ans) if __name__ == "__main__": main()
n, k = map(int, input().split()) p = [0] + list(map(int, input().split())) c = [0] + list(map(int, input().split())) ans = - 10 ** 18 for i in range(1, n+1): base = i nxt = p[i] cnt = 0 score = 0 while True: cnt += 1 if cnt > k: break score += c[nxt] ans = max(ans, score) #print("i = ", i, "ans = ", ans, "score = ", score) if nxt == base: break nxt = p[nxt] if cnt >= k: continue extra = k - cnt score_tmp = score nxt = p[nxt] nxt_tmp = nxt for j in range(min(extra, cnt)): score += c[nxt] ans = max(ans, score) #print("ans = ", ans, "score = ", score, "nxt = ", nxt, "c[nxt] = ", c[nxt]) nxt = p[nxt] #print("score = ", score, "ans = ", ans) score = score_tmp nxt = nxt_tmp a = extra // cnt if extra % cnt == 0: a -= 1 score += score * max(a, 0) ans = max(ans, score) for j in range(extra - a * cnt): score += c[nxt] ans = max(ans, score) #print("ans = ", ans, "score = ", score, "nxt = ", nxt, "c[nxt] = ", c[nxt]) nxt = p[nxt] print(ans)
1
5,322,701,398,612
null
93
93
n, k = map(int, input().split()) enemy = list(map(int, input().split())) enemy.sort(reverse=True) if n <= k : print(0) else : for i in range(k) : enemy[i] = 0 print(sum(enemy))
n, k = map(int, input().split()) H = list(map(int, input().split())) H.sort(reverse=True) H = H[k:] print(sum(H))
1
79,136,806,148,960
null
227
227
l = list(map(int,input().split())) l.sort() if (l[0]==l[1] and l[1] != l[2]) or (l[0] != l[1] and l[1]==l[2]): print('Yes') else: print('No')
li=list(map(int,input().split())) for i in li: if li.count(i)==2: print("Yes") break else: print("No")
1
68,128,480,191,570
null
216
216
import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51] K = ir() print(A[K-1])
# coding: utf-8 num_array = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51] k = int(input()) print("{}".format(num_array[k-1]))
1
50,099,536,858,358
null
195
195
def solve(n): arr = [i for i in range(1, n+1) if i % 3 != 0 and i % 5 != 0] print(sum(arr)) if __name__ == "__main__": n = int(input()) solve(n)
n=int(input()) a=n//3 b=n//5 c=n//15 suma=(0+a*3)*(a+1)//2 sumb=(0+b*5)*(b+1)//2 sumc=(0+c*15)*(c+1)//2 print((n+1)*n//2-suma-sumb+sumc)
1
34,901,317,883,520
null
173
173
def solve(): n=int(input()) a=list(map(int,input().split())) cnt=[0]*(int(1e5)+9) s=0 for i in range(0,n) : s+=a[i] cnt[a[i]]+=1 q=int(input()) for q in range(0,q) : b,c=map(int,input().split()) ct=cnt[b] s+=ct*(c-b) cnt[b]=0 cnt[c]+=ct print(s) solve()
import sys def calc_cell(x, y): return '.' if (x + y) % 2 else '#' def print_chessboard(height, width): for y in range(height): l = [] for x in range(width): l.append(calc_cell(x, y)) print ''.join(l) if __name__ == '__main__': while True: h, w = map(int, sys.stdin.readline().split()) print_chessboard(h, w) if not h or not w: break print
0
null
6,524,978,992,518
122
51
import math N=int(input()) l=N*100/108 r=(N+1)*100/108 for i in range(math.ceil(l),math.ceil(r)): print(i);exit() print(":(")
import itertools n = int(input()) a = list(map(int,input().split())) q = int(input()) m = list(map(int,input().split())) data = [] for i in itertools.product(range(2),repeat=n): data.append(sum([i[j]*a[j] for j in range(n)])) for i in m: if i in data: print("yes") else: print("no")
0
null
62,627,941,045,952
265
25
n = int(input()) a = list(map(int, input().split())) ans = 0 tmp = a[0] for i in range(1,n): tmp = max(a[i], tmp) ans += tmp - a[i] print(ans)
n = int(input()) ans = [0 for x in range(10001)] for i in range(1, 100): for j in range(1, 100): for k in range(1, 100): v = i*i + j*j + k*k + i*j + i*k + j*k if v < 10001: ans[v] += 1 for i in range(n): print(ans[i+1])
0
null
6,287,911,038,460
88
106
n = int(input()) a = list(map(int,input().split())) mod = 10**9+7 ans = 0 for i in range(60): x = 1<< i l = len([1 for j in a if j & x]) ans += x * l * (n-l) % mod ans %= mod print(ans)
n = int(input()) arr = list(map(int, input().split())) MOD = 10**9 + 7 ans = 0 for i in range(60): mask = 1 << i cnt = sum([1 for x in arr if x & mask == mask]) ans += mask * cnt * (n - cnt) % MOD print(ans % MOD)
1
122,956,767,544,180
null
263
263
X, Y = list(map(int, input().split())) crane = 0 turtle = X while turtle >= 0: allLegs = crane * 2 + turtle * 4 if allLegs == Y: print("Yes") exit() crane += 1 turtle -= 1 print("No")
def main(): x,y = list(map(int,input().split())) ans=0 for i in range(0,x+1): if 2*i+4*(x-i)==y: ans=1 if ans==1: print("Yes") else: print("No") main()
1
13,766,796,225,910
null
127
127
a = int(input()) c=0 for i in range(a + 1): if bool(i%3!=0 and i % 5 != 0): c += i print(c)
A, B, C = map(int, input().split()) temp = B B = A A = temp temp = C C = A A = temp print(str(A) + " " + str(B) + " " + str(C))
0
null
36,303,303,260,808
173
178
while True: try: n,x = map(int,raw_input().split()) if n == x == 0: break except EOFError: break total = 0 for k in range(1,n+1): for j in range(1,n+1): for l in range(1,n+1): if k!=j!=l and k + j + l == x and k<j<l: total +=1 print total
while 1: n,x=map(int,input().split()) if n+x==0:break print(sum([1 for i in range(3,n+1)for j in range(2,x-i)if x-i-j<j<i]))
1
1,303,431,292,320
null
58
58
from collections import deque N,M=map(int,input().split()) haba=[[] for i in range(N+1)] for i in range(M): A,B=map(int,input().split()) haba[A].append(B) haba[B].append(A) kyori=[-1]*(N+1) kyori[0]=0 kyori[1]=0 que=deque() que.append(1) while que: kari=que.popleft() for i in haba[kari]: if kyori[i]!=-1: continue kyori[i]=kari que.append(i) ans=kyori[2:] print("Yes") for i in range(len(ans)): print(ans[i])
x,y = map(int, input().split()) ans = 'No' for i in range(x+1): for j in range(y+1): if i + j > x: continue if i*2 + j*4 == y and i+j == x: ans = 'Yes' print(ans)
0
null
17,068,637,758,836
145
127
N,D = map(int,input().split()) xy = [] for i in range(N): x,y = map(int,input().split()) xy.append([x,y]) ans = 0 for i in range(N): x = xy[i][0] y = xy[i][1] if(D*D >= (x*x + y*y)): ans+=1 print(ans)
num, max_num = map(int, input().split()) x = [] y = [] count = 0 for i in range(num): x1,y1 = map(int, input().split()) x.append(x1) y.append(y1) for i in range(len(x)): temp = (x[i]**2 +y[i]**2)**(1/2) if temp <= max_num: count += 1 print(count)
1
5,966,397,509,940
null
96
96
import sys for i in range(1,10): for j in range(1,10): print("{0}x{1}={2}".format(i,j,i*j))
for a in range(1,10): for b in range(1,10): ans=str(a*b) print(str(a)+'x'+str(b)+'='+ans)
1
3,791,620
null
1
1
a, b = map(int, input().split()) if a >= 10 or b >= 10: print(-1) else: print(a*b)
a, b = map(int,input().split()) print(a*b if a < 10 and b < 10 and a > 0 and b > 0 else -1)
1
158,404,982,278,620
null
286
286
# 169 B N = int(input()) A = list(map(int, input().split())) A.sort() ans = 1 for i in range(N): ans *= A[i] if ans > 10**18: print(-1) break else: print(ans)
n = int(input()) lst = list(map(int,input().split())) lst = sorted(lst) ans = 1 for i in range (n): ans = ans*lst[i] if (ans > 10**18): ans = -1 break print(ans)
1
16,173,979,744,208
null
134
134
import sys def solve(): input = sys.stdin.readline A = int(input()) B = int(input()) C = list(set([1, 2, 3]) - set([A, B])) print(C[0]) return 0 if __name__ == "__main__": solve()
# 解説を見て解き直し N, K = [int(x) for x in input().split()] ranges = [tuple(int(x) for x in input().split()) for _ in range(K)] ranges.sort() p = 998244353 dp = [0] * (N + 1) dpsum = [0] * (N + 1) dp[1] = 1 dpsum[1] = 1 for i in range(2, N + 1): for l, r in ranges: rj = i - l lj = max(1, i - r) # 1以上 if rj <= 0: continue dp[i] += dpsum[rj] - dpsum[lj - 1] dp[i] %= p dpsum[i] = dpsum[i - 1] + dp[i] dpsum[i] %= p print(dp[N])
0
null
56,979,810,649,988
254
74
a=input() if a==a.upper(): print("A") else: print("a")
#coding:utf-8 #1_1_D 2015.3.6 second = int(input()) hour = second // 3600 minutes = (second // 60) % 60 second %= 60 print("%s:%s:%s" %(hour,minutes,second))
0
null
5,811,292,187,104
119
37
import sys s = sys.stdin.read().lower() a = {chr(i): 0 for i in range(ord('a'), ord('z')+1)} for i in s: if ord(i) in range(ord('a'), ord('z')+1): a[i] += 1 [print(f'{k} : {v}') for k, v in a.items()]
N, K = map(int,input().split()) A = list(map(int,input().split())) B = [0];BB=[0] S = set([]);S.add(0) now = 0 Flag = False loop_start = -1 if K <= 2*pow(10,5)+10: for i in range(K): nxt = A[now]-1 BB.append(nxt) now = nxt #print(BB) print(BB[K]+1) exit() for i in range(N*2): nxt = A[now]-1 #print(now,nxt) if nxt in S: if Flag: if nxt == loop_start: #print(nxt,i) loop_cycle = i-loop_num break else: loop_start = nxt loop_num = i B.append(nxt) #print(loop_num,loop_start,B) Flag = True else: B.append(nxt);S.add(nxt) now = nxt loop_num += 1-loop_cycle #print(B,loop_start,loop_cycle,loop_num) loc = (K-loop_num)%loop_cycle+loop_num #print(loc) #print(len(B)) print(B[loc]+1)
0
null
12,281,211,890,048
63
150
k, x = list(map(int, input().split())) print('Yes') if k *500 >= x else print('No')
import numpy as np def solve(H, A, B): A_max = A.max() dp = np.zeros(H + A_max + 1, dtype=np.int64) for i in range(A_max + 1, H + A_max + 1): dp[i] = np.min(dp[i - A] + B) return dp[-1] H, N, *AB = map(int, open(0).read().split()) A = np.array(AB[::2], dtype=np.int64) B = np.array(AB[1::2], dtype=np.int64) print(solve(H, A, B))
0
null
89,431,651,983,150
244
229
x=int(input()) A=[i**5 for i in range(-2000,2000)] for i in range(4000): for j in range(i): if A[i]-A[j]==x: print(*[i-2000,j-2000]);exit()
N = int(input()) # 以下がとてもわかりやすい # https://drken1215.hatenablog.com/entry/2020/06/20/231600 for i in range(-200, 200, 1): for j in range(-200, 200, 1): if i ** 5 - j ** 5 == N: print(f'{i} {j}') exit(0)
1
25,522,688,437,218
null
156
156
x=input() a=int(x)*int(x)*int(x) print(a)
x=int(input()) y=x**3 print(y)
1
288,089,804,548
null
35
35
# 与えられた数値の桁数と桁値の総和を計算する. def calc_digit_sum(num): digits = sums = 0 while num > 0: digits += 1 sums += num % 10 num //= 10 return digits, sums n = int(input()) s = [((ord(ch) - 65 + n) % 26) + 65 for ch in input()] print("".join(map(chr, s)))
import sys input = sys.stdin.readline def solve(N, K, L): dp = [[[0] * (K + 1) for _ in range(2)] for _ in range(L + 1)] dp[0][0][0] = 1 for i in range(L): D = N[i] for j in range(2): d_max = 9 if j == 1 else D for k in range(K + 1): if k < K: for d in range(d_max + 1): dp[i + 1][int(j or (d < D))][k + int(d > 0)] += dp[i][j][k] else: dp[i + 1][j][k] += dp[i][j][k] return dp[L][0][K] + dp[L][1][K] def main(): N = list(map(int, input().rstrip())) K = int(input()) L = len(N) ans = solve(N, K, L) print(ans) if __name__ == "__main__": main()
0
null
104,646,872,751,010
271
224
N, M = map(int, input().split()) if N & 1: for m in range(1, M+1): print(m, N-m) exit() n1, n2 = N//2, N//2 cnt = 0 for n in range(N//2): if n+1 >= N//2-n: break print(n+1, N//2-n) cnt += 1 if cnt == M: exit() for n in range(N//2): if n+1 >= N//2-n-1: break print(n+1+N//2, N-n-1) cnt += 1 if cnt == M: exit()
N,M = map(int,input().split()) ans = [] s = 1 e = M+1 while e>s: ans.append([s,e]) s += 1 e -= 1 s = M+2 e = 2*M+1 while e>s: ans.append([s,e]) s += 1 e -= 1 for s,e in ans: print(s,e)
1
28,609,541,960,900
null
162
162
M = 1046527 POW = [pow(4, i) for i in range(13)] def insert(dic, string): # i = 0 # while dic[(hash1(string) + i*hash2(string)) % M]: # i += 1 # dic[(hash1(string) + i*hash2(string)) % M] = string dic[get_key(string)] = string def find(dic, string): # i = 0 # while dic[(hash1(string) + i*hash2(string)) % M] and dic[(hash1(string) + i*hash2(string)) % M] != string: # i += 1 # return True if dic[(hash1(string) + i*hash2(string)) % M] == string else False # print(dic[get_key(string)], string) return True if dic[get_key(string)] == string else False def get_num(char): if char == "A": return 1 elif char == "C": return 2 elif char == "G": return 3 else: return 4 def get_key(string): num = 0 for i in range(len(string)): num += POW[i] * get_num(string[i]) return num def main(): n = int(input()) dic = [None] * POW[12] # print(dic) for i in range(n): order, string = input().split() if order == "insert": insert(dic, string) else: if find(dic, string): print('yes') else: print('no') if __name__ == "__main__": main()
if __name__ == "__main__": n = int(input()) ops = [] words = [] for _ in range(n): op, word = input().split() ops.append(op) words.append(word) db = set() for op, word in zip(ops, words): if op=='insert': db.add(word) else: if word in db: print("yes") else: print("no")
1
81,141,476,728
null
23
23
from math import cos , sin, sqrt, radians import sys A , B , H , M = list( map( int, input().split() ) ) th1 = H * 30 + 0.5 * M th2 = M * 6 theta = min( abs( th1 - th2 ) , 360 - abs( th1 - th2 )) if theta == 180.0: print(A+B) sys.exit() theta = radians(theta) ans = sqrt( (B * sin(theta))**2 + ( B*cos(theta) - A )**2 ) print(ans)
import math a, b, h, m = map(int, input().split()) minute = 60 * h + m argA = minute / 720 * 2 * math.pi argB = minute / 60 * 2 * math.pi a_x = a * math.cos(argA) a_y = a * math.sin(argA) b_x = b * math.cos(argB) b_y = b * math.sin(argB) d = math.sqrt((a_x - b_x) ** 2 + (a_y - b_y) ** 2) print(d)
1
20,126,441,330,970
null
144
144
h= int(input()) w = int(input()) n = int(input()) a = max(h,w) print(-(-n//a))
h, w, n= [int(input()) for i in range(3)] k = max(h, w) ans = (n+k-1)//k print(ans)
1
88,802,789,857,812
null
236
236
N=int(input()) A=[0]*N B=[0]*N for i in range(N): A[i], B[i]=map(int, input().split()) A.sort() B.sort() if N%2==1: print(B[N//2]-A[N//2]+1) else: print(B[N//2]+B[N//2-1]-A[N//2]-A[N//2-1]+1)
from math import sqrt itl = lambda: list(map(float, input().strip().split())) def median(N, C): if N % 2: return C[N // 2] else: return C[N // 2 - 1] + C[N // 2] def solve(): N = int(input()) A = [] B = [] for _ in range(N): a, b = itl() A.append(int(a)) B.append(int(b)) A.sort() B.sort() ma = median(N, A) mb = median(N, B) return mb - ma + 1 if __name__ == '__main__': print(solve())
1
17,368,281,673,908
null
137
137
def check(List,mid): tmp=0 for l in List: tmp+=(-(-l//mid)-1) return tmp n,k=map(int,input().split()) a=list(map(int,input().split())) lo=0 hi=max(a)+1 while hi - lo > 1: mid=(lo+hi)//2 if check(a,mid)<=k: hi=mid else: lo=mid print(hi)
N,K = map(int,input().split()) A = list(map(int,input().split())) if K==0: high = max(A) else: low = 0 high = 10**9 while high-low>1: mid = (high+low)//2 cnt = 0 for i in range(N): if A[i]%mid==0: cnt += A[i]//mid-1 else: cnt += A[i]//mid if K>=cnt: high = mid else: low = mid print(high)
1
6,495,420,183,562
null
99
99
s=input() if len(s) % 2 == 0: if s == "hi"*(len(s)//2): print("Yes") else: print("No") else: print("No")
s=input() if len(s)%2==0 and s == 'hi'*(len(s)//2): print('Yes') else: print('No')
1
53,469,912,773,732
null
199
199
from itertools import combinations_with_replacement as comb_rplc N,M,Q = map(int,input().split()) array = [ list(map(int,input().split())) for _ in range(Q) ] ans = 0 for seq in comb_rplc(range(1, M + 1), N): score = 0 for a,b,c,d in array: if seq[b-1] - seq [a-1] == c: score += d ans = max(score,ans) print(ans)
import copy def main(): N, M, Q = [int(n) for n in input().split(" ")] q = [[int(a) for a in input().split(" ")] for i in range(Q)] all_series = get_series(N, M) points = [0] for l in all_series: points.append(get_score(l, q)) print(max(points)) def get_score(l, q): return sum([q[i][3] if l[q[i][1] - 1] - l[q[i][0] - 1] == q[i][2] else 0 for i in range(len(q))]) def get_series(N, M): # N: number of elms # M: upper limit of val of elm all_series = [] checked = [[0] * M for i in range(N)] to_check = [[0, j + 1] for j in range(M)] series = [0 for k in range(N)] while len(to_check) > 0: checking = to_check.pop(-1) series[checking[0]] = checking[1] if checking[0] == N - 1: l = copy.deepcopy(series) all_series.append(l) else: to_check.extend([[checking[0] + 1, k] for k in range(checking[1], M + 1)]) return all_series main()
1
27,648,007,104,000
null
160
160
d,t,s=list(map(int,input().split())) time=d/s if(time<t or time==t): print("Yes") else: print("No")
a,b,k=map(int,input().split()) taka=a-k if taka < 0: aoki = b-abs(taka) taka = 0 if aoki < 0: aoki = 0 else: aoki=b print(taka,aoki)
0
null
53,642,974,890,350
81
249
# 配るDP、もらうDP n, k = map(int, input().split()) mod = 998244353 kukan = [] for _ in range(k): # 区間の問題は扱いやすいように[ ) の形に直せるなら直す l, r = map(int, input().split()) l -= 1 kukan.append([l, r]) dp = [0 for i in range(n)] dp[0] = 1 # 区間のL, Rは数字が大きいため、その差一つ一つを考えると時間がない! # それゆえにL, Rの端を考えればいいようにするためにそこまでの累和を考える ruiseki = [0 for i in range(n + 1)] ruiseki[1] = 1 for i in range(1, n): for l, r in kukan: l = i - l r = i - r l, r = r, l # print(l, r) if r < 0: continue elif l >= 0: dp[i] += (ruiseki[r] - ruiseki[l]) % mod else: dp[i] += (ruiseki[r]) % mod ruiseki[i + 1] = (ruiseki[i] + dp[i]) # print(ruiseki, dp) print(dp[-1] % mod)
score = list(map(int,input().split())) kenl = list(map(int,input().split())) syoki = 0 syoki = kenl[0]+(score[0]-kenl[score[1]-1]) length = [0]*score[1] length[0] = syoki for i in range(score[1]-1): length[i+1] = kenl[i+1]-kenl[i] length.sort() answer = length[score[1]-1] print(score[0]-answer)
0
null
23,174,457,316,260
74
186
N = int(input()) data = [list(map(int,input().split())) for i in range(N-1)] G = {} for i in range(1,N+1): G[i] = [] for i in range(N-1): G[data[i][0]].append((data[i][1],i+1)) G[data[i][1]].append((data[i][0],i+1)) M = max(len(G[i]) for i in range(1,N+1)) print(M) from collections import deque E = [0]+[-1]*(N-1) #辺 E[1] = 1 q = deque([[data[0][0],1],[data[0][1],1]]) while q: n,i = q.pop() c = 1 for dn,di in G[n]: if E[di] != -1: continue else: if c == E[i]: E[di] = M c += 1 q.append([dn,di]) else: E[di] = c c += 1 q.append([dn,di]) for i in range(1,N): print(E[i])
from collections import deque n=int(input()) ab=[[] for _ in range(n+1)] for i in range(n-1): a,b=map(int,input().split()) ab[a].append([b,i]) que=deque() que.append(1) visited=[0]*(n) ans=[0]*(n-1) while que: x=que.popleft() k=1 for j in ab[x]: if visited[x-1]!=k: ans[j[1]]+=k visited[j[0]-1]+=k k+=1 que.append(j[0]) else: ans[j[1]]+=(k+1) visited[j[0]-1]+=(k+1) k+=2 que.append(j[0]) print(max(ans)) for l in ans: print(l)
1
136,469,840,080,280
null
272
272
def isprime(n): divider = 2 while divider ** 2 <= n: if n % divider == 0: return False divider += 1 return True result = 0 n = int(input()) for n in range(n): result += isprime(int(input())) print(result)
import math numbers = [] n = raw_input() for i in range(int(n)): input_num = raw_input() numbers.append(int(input_num)) count = 0 for num in numbers: prime_frag = True for i in range(2, int(math.sqrt(num)) + 1): if num % i == 0: prime_frag = False break if prime_frag: count += 1 print count
1
10,586,733,248
null
12
12
N, K = map(int, input().split()) arr = list(map(int, input().split())) jj = 0 koho=[] for i in range(K): jj+=arr[i] koho.append(jj) for i in range(N-K): jj+=arr[i+K] jj-=arr[i] koho.append(jj) a=max(koho) print(a/2+(K/2))
#!/usr/bin/python3 # -*- coding:utf-8 -*- import numpy MAX = 10 ** 9 + 7 def prod_mod(la, mod): x = 1 for a in la: x *= a x %= mod return x def main(): n, k = map(int, input().strip().split()) la = numpy.array(list(map(int, input().strip().split()))) la.sort() if n == k: print(prod_mod(la, MAX)) else: if k % 2 == 1 and (la >= 0).sum() == 0: print(prod_mod(la[-k:], MAX)) else: il, ir = 0, n-1 cnt = 0 l = [] if k % 2 == 1: l.append(la[ir]) ir -= 1 cnt += 1 while k - (cnt + 2) >= 0: if la[il] * la[il+1] > la[ir-1] * la[ir]: l.extend([la[il], la[il+1]]) il += 2 else: l.extend([la[ir-1], la[ir]]) ir -= 2 cnt += 2 print(prod_mod(l, MAX)) if __name__=='__main__': main()
0
null
42,231,727,488,540
223
112
def main(): while True: n, x = map(int, input().split()) if n == x == 0: break number = 0 for i in range(n): j = i + 1 if x - j > n*2 - 1: continue elif x - j <= j: break else: for k in range(x - j): m = k + 1 if k < j: continue elif (x - j - m) > m and x - j - m <= n: number += 1 print(number) return if __name__ == '__main__': main()
a = int(input()) b = a*a*a+a*a+a print(int(b))
0
null
5,706,087,249,244
58
115
import numpy as np n = int(input()) li_a = list(map(int, input().split())) A = [0]*(10**5) s = sum(li_a) li_a = list(map(lambda x: x-1, li_a)) for a in li_a: A[a] += 1 q = int(input()) for i in range(q): b, c = map(int, input().split()) if A[b-1]>0: A[c-1] += A[b-1] s -= b * A[b-1] s += c * A[b-1] A[b-1] = 0 print(s) else: print(s)
input() data = input().split() data.reverse() print(' '.join(data))
0
null
6,560,020,086,588
122
53
# -*- coding: utf-8 -*- """ B - TAKOYAKI FESTIVAL 2019 https://atcoder.jp/contests/abc143/tasks/abc143_b """ import sys from itertools import combinations def solve(takoyaki): return sum(x * y for x, y in combinations(takoyaki, 2)) def main(args): _ = input() takoyaki = map(int, input().split()) ans = solve(takoyaki) print(ans) if __name__ == '__main__': main(sys.argv[1:])
import sys from itertools import accumulate read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def main(): N, *D = map(int, read().split()) csum = accumulate(D) ans = sum(s * d for s, d in zip(csum, D[1:])) print(ans) return if __name__ == '__main__': main()
1
168,539,339,923,908
null
292
292
x = int(input()) print(x//2+x%2)
a,b,c,k = map(int,input().split()) if k < a: print(str(k)) elif k < (a + b): print(str(a)) else: print(str(2*a + b - k))
0
null
40,554,332,720,160
206
148
N = int(input()) A = list(map(int,input().split())) MOD = 1000000007 def factorization(n): arr = [] temp = n for i in range(2, int(-(-n**0.5//1))+1): if temp%i==0: cnt=0 while temp%i==0: cnt+=1 temp //= i arr.append([i, cnt]) if temp!=1: arr.append([temp, 1]) if arr==[]: arr.append([n, 1]) return arr lcma={} for ai in A: f=factorization(ai) for fi in f: if fi[0] in lcma: lcma[fi[0]]=max(lcma[fi[0]],fi[1]) else: lcma[fi[0]]=fi[1] l=1 for k,v in lcma.items(): l*=pow(k,v,MOD) l%=MOD ans=0 for ai in A: ans+=l*pow(ai,MOD-2,MOD) ans%=MOD print(ans)
def gcd(a,b): if not b: return a return gcd(b,a%b) def lcm(a, b): return (a*b)//gcd(a, b) N = int(input()) A = list(map(int,input().split())) l = 1 ans, mod = 0, 1000000007 for x in A: l = lcm(l, x) for x in A: ans = ans + l//x print(ans % mod)
1
87,224,699,055,998
null
235
235
N, K, S = map(int, input().split()) a = [str(S)] * K if S == 10**9: b = [str(1)] * (N-K) else: b = [str(S+1)] * (N-K) ans = a + b print(*ans)
n , k , s = map(int,input().split()) l = [] for i in range(k): l.append(s) if s == 1: t = 3 elif s == 10**9: t = 1 else: t = s + 1 for i in range(n-k): l.append(t) print(' '.join(map(str, l)))
1
91,014,276,886,208
null
238
238
s = input().split() a=s[0] b=s[1] c=s[2] if a<b<c: print ("Yes") else: print("No")
x=raw_input() list=x.split() a=int(list[0]) b=int(list[1]) c=int(list[2]) if a<b<c: print 'Yes' else: print 'No'
1
386,058,986,830
null
39
39
A, B, C = map(int, input().split()) x = A * B * 4 y = (C - A - B) ** 2 if x < y and C - A - B > 0: print("Yes") else: print("No")
K = int(input()) AB = input().split() A = int(AB[0]) B = int(AB[1]) if int(B / K) * K >= A: print("OK") else: print("NG")
0
null
39,092,191,529,740
197
158
seen = [0,0,0,0,0,0,0,0,0] seen[0],seen[1],seen[2] = (map(int,input().split())) seen[3],seen[4],seen[5] = (map(int,input().split())) seen[6],seen[7],seen[8] = (map(int,input().split())) over = "No" N = int(input()) for x in range(N): num = int(input()) if num in seen: seen[seen.index(num)] = "O" if seen[0] == "O": if seen[1] == "O" and seen[2] == "O": over = "Yes" if seen[3] == "O" and seen[6] == "O": over = "Yes" if seen[4] == "O" and seen[8] == "O": over = "Yes" if seen[8] == "O": if seen[6] == "O" and seen[7] == "O": over = "Yes" if seen[2] == "O" and seen[5] == "O": over = "Yes" if seen[4] == "O": if seen[6] == "O" and seen[2] == "O": over = "Yes" if seen[1] == "O" and seen[7] == "O": over = "Yes" if seen[3] == "O" and seen[5] == "O": over = "Yes" print(over)
bingo = [list(map(int, input().split())) for _ in range(3)] N = int(input()) for _ in range(N): b = int(input()) for i in range(3): for j in range(3): if bingo[i][j] == b: bingo[i][j] = 0 ans = "No" for k in range(3): if bingo[k][0] == bingo[k][1] == bingo[k][2] or \ bingo[0][k] == bingo[1][k] == bingo[2][k]: ans = "Yes" break if bingo[0][0] == bingo[1][1] == bingo[2][2] or \ bingo[0][2] == bingo[1][1] == bingo[2][0]: ans = "Yes" print(ans)
1
59,853,559,188,828
null
207
207
import sys input = sys.stdin.readline INF = 10**18 sys.setrecursionlimit(10**6) def li(): return [int(x) for x in input().split()] N, X, MOD = li() n = X nums = [X] loop_start_i = -INF for i in range(1, N): n = pow(n, 2, MOD) if n in nums: loop_start_i = nums.index(n) break nums.append(n) # total %= MOD loop_length = len(nums) - loop_start_i loop_cnt = (N - loop_start_i) // loop_length r = (N - loop_start_i) % loop_length sum_per_loop = sum(nums[loop_start_i:]) ans = sum(nums[:loop_start_i]) + sum_per_loop * loop_cnt + sum(nums[loop_start_i:loop_start_i+r]) print(ans)
def insertationSort(sort_list, n, g): cnt = 0 for i in range(g, n): v = sort_list[i] j = i - g while j >= 0 and sort_list[j] > v: sort_list[j + g] = sort_list[j] j -= g cnt += 1 sort_list[j + g] = v return cnt def shellSort(sort_list, n): cnt = 0 G = [1] while True: if G[len(G)-1] * 3 + 1 <= n: G.append(G[len(G)-1] * 3 + 1) else: break m = len(G) for i in G[::-1]: cnt += insertationSort(sort_list, n, i) print(m) print(' '.join([str(i) for i in G[::-1]])) print(cnt) for ans in sort_list: print(ans) if __name__ == "__main__": N = int(input()) sort_list = list() for _ in range(N): sort_list.append(int(input())) shellSort(sort_list, N)
0
null
1,421,624,888,602
75
17
N = int(input()) K = int(input()) def func(num,counter): remain = num%10 quotient = num//10 if counter == 0: return 1 if num<10: if counter ==1: return num else: return 0 return func(quotient,counter-1)*remain + func(quotient-1,counter-1)*(9-remain) + func(quotient,counter) print(func(N,K))
N, K = map(int, input().split()) minCandidate1 = N % K minCandidate2 = K - minCandidate1 if minCandidate1 <= minCandidate2: print(minCandidate1) else: print(minCandidate2)
0
null
57,628,295,824,330
224
180
N, K = map(int, input().split()) S = [] for _ in range(K): l, r = map(int, input().split()) S.append((l, r)) mod = 998244353 dp = [0] * (N+1) cumsum_dp = [0] * (N+1) dp[1] = 1 cumsum_dp[1] = 1 for i in range(2, N+1): for s in S: fr = max(0, i-s[1]-1) to = max(0, i-s[0]) dp[i] += (cumsum_dp[to]-cumsum_dp[fr]) % mod cumsum_dp[i] = (cumsum_dp[i-1] + dp[i]) % mod print(dp[N]%mod)
N = int(input()) if N%2 == 1: Answer = 0 else: Answer = 0 for i in range(1,100): Answer += N//(2*5**i) print(Answer)
0
null
59,109,761,463,060
74
258
S = input() n = len(S) c = 0 for i in range(n // 2): if S[i] != S[n - i - 1]: c += 1 print(c)
def floyd_warshall(G): for k in range(N): for i in range(N): for j in range(N): G[i][j]=min(G[i][j],G[i][k]+G[k][j]) import sys input=sys.stdin.readline INF=10**30 N,M,L=map(int,input().split()) dp1=[[INF]*N for i in range(N)] for i in range(N): dp1[i][i]=0 for _ in range(M): A,B,C=map(int,input().split()) A,B=A-1,B-1 dp1[A][B]=C dp1[B][A]=C floyd_warshall(dp1) dp2=[[INF]*N for i in range(N)] for i in range(N): for j in range(N): if i==j: dp2[i][j]=0 else: dp2[i][j]=1 if dp1[i][j]<=L else INF floyd_warshall(dp2) Q=int(input()) for _ in range(Q): s,t=map(lambda x:int(x)-1,input().split()) print (dp2[s][t]-1 if dp2[s][t]!=INF else -1)
0
null
146,658,792,211,458
261
295
#coding: UTF-8 import statistics as st while True: N = int(input()) if N == 0: break buf = list(map(float, input().split())) sd = st.pstdev(buf) print("%.8f"%sd)
import os, sys, re, math S = input() dow = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT'] print(7 - dow.index(S))
0
null
66,569,677,789,568
31
270
n, a, b = map(int,input().split()) if a % 2 == b % 2: print((b-a)//2) else: ans = min(n-b, a-1) + 1 + (b-a-1)//2 print(ans)
N = int(input()) A = list(map(int,input().split())) LEFT = A[0] RIGHT = sum(A[1:]) MIN = abs(LEFT-RIGHT) for i in range(1,N-1): LEFT += A[i] RIGHT -= A[i] MIN = min(MIN,abs(LEFT-RIGHT)) print(MIN)
0
null
126,132,044,154,652
253
276
s = input() while s != "-": n = int(input()) for i in range(n): h = int(input()) s = s[h:] + s[:h] print(s) s = input()
while True: h = input() h_list = list(h) if h == '-': break count = int(input()) for j in range(count): count1 = int(input()) for i in range(0,count1): h_list.append(h_list[0]) h_list.remove(h_list[0]) length = int(len(h_list)) for i in range(length): print("{}".format(h_list[i]),end="") print("")
1
1,916,005,079,508
null
66
66
N=int(input()) S=input() if N%2==1:print('No') else: s1,s2=S[:N//2],S[N//2:] ok=1 for i in range(N//2): if s1[i]!=s2[i]: print('No') ok=0 break if ok==1:print('Yes')
S, T = input().split() A, B = map(int, input().split()) U = input() print(A-1 if S==U else A) print(B if S==U else B-1)
0
null
109,386,348,787,018
279
220
import collections a=int(input()) b=list(map(int,input().split())) c=collections.Counter(b) n,m=zip(*c.most_common()) n,m=list(n),list(m) result=0 for i in range(len(m)): result+=(m[i]*(m[i]-1))//2 for i in b: print(result-c[i]+1)
# A - Kth Term def main(): orig = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51" seq = list(map(lambda s: s.strip(), orig.split(","))) K = int(input()) - 1 print(seq[K]) if __name__ == "__main__": main()
0
null
48,885,616,626,990
192
195
A, B, K = map(int, input().split()) print(max(0, A-K), end=" ") K = max(0, K-A) print(max(0, B-K))
a,b,k=map(int,input().split()) if k>a+b:print(0,0) elif a<=k and k<=a+b: print(0,b-(k-a)) elif a>k : print(a-k,b)
1
104,459,845,466,760
null
249
249
from sys import stdin import math import re import queue input = stdin.readline MOD = 1000000007 def solve(): N,A,B = map(int, input().split()) if(abs(A - B)%2 == 0): print(abs(A-B)//2) return print(min(A-1,N-B)+1+(B-A-1)//2) if __name__ == '__main__': solve()
N=int(input()) D=list(map(int,input().split())) isOK=True if D[0]!=0: isOK=False for i in range(1,N): if D[i]==0: isOK=False break cnt=[0]*(max(D)+1) MOD=998244353 for i in range(N): cnt[D[i]]+=1 ans=1 for i in range(len(cnt)-1): for r in range(cnt[i+1]): ans=ans*cnt[i]%MOD if isOK: print(ans) else: print(0)
0
null
132,350,757,305,180
253
284
import math L,R,d = map(int, input().strip().split()) x=math.ceil(L/d) y=math.floor(R/d) print(y-x+1)
import sys INF = 1 << 60 MOD = 10**9 + 7 # 998244353 sys.setrecursionlimit(2147483647) input = lambda:sys.stdin.readline().rstrip() def resolve(): l, r, d = map(int, input().split()) print(r // d - (l - 1) // d) resolve()
1
7,557,136,717,222
null
104
104
#!/usr/bin/env python3 S = input() T = input() count = 0 for s, t in zip(S, T): if s != t: count += 1 ans = count print(ans)
ac = input() acc ='abcdefghijklmnopqrstuvwxyz' print(acc[acc.index(ac) + 1])
0
null
51,397,967,833,508
116
239
# -*- coding: utf-8 -*- import sys import os from collections import deque N = int(sys.stdin.readline()) q = deque() lines = sys.stdin.readlines() for s in lines: lst = s.split() command = lst[0] if command == 'insert': q.appendleft(lst[1]) elif command == 'delete': try: q.remove(lst[1]) except Exception: pass elif command == 'deleteFirst': q.popleft() elif command == 'deleteLast': q.pop() print(*q)
#!/usr/bin/env python3 import sys def solve(A: int, B: int): print(A*B) # Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template) def main(): def iterate_tokens(): for line in sys.stdin: for word in line.split(): yield word tokens = iterate_tokens() A = int(next(tokens)) # type: int B = int(next(tokens)) # type: int solve(A, B) if __name__ == '__main__': main()
0
null
7,910,975,090,880
20
133
import sys def rs(): return sys.stdin.readline().rstrip() def ri(): return int(rs()) def rs_(): return [_ for _ in rs().split()] def ri_(): return [int(_) for _ in rs().split()] H, W = ri_() if H == 1 or W == 1: print(1) else: print(-(-H * W // 2))
def resolve(): h, w = map(int, input().split()) import math if w == 1 or h == 1: print(1) else: print(math.ceil(h * w / 2)) if __name__ == '__main__': resolve()
1
51,029,550,825,320
null
196
196
n = int(input()) print(" ".join(reversed(input().split())))
import sys import math n = input() a = map(int, raw_input().split()) a.reverse() for i in xrange(n) : sys.stdout.write(str(a[i])) if i < n-1 : sys.stdout.write(" ") print
1
992,571,596,562
null
53
53
import queue import numpy as np import math n = int(input()) A = list(map(int, input().split())) A = np.array(A,np.int64) ans = 0 for i in range(60 + 1): a = (A >> i) & 1 count1 = np.count_nonzero(a) count0 = len(A) - count1 ans += count1*count0 * pow(2, i) ans%=1000000007 print(ans)
n = int(input()) A = list(map(int,input().split())) ans = 0 for i,a in enumerate(A): if (i+1)%2 != 0 and a%2 != 0: ans +=1 print(ans)
0
null
65,381,158,677,372
263
105
#!/usr/bin/env python3 import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines def main(): C = readline().rstrip().decode() print(chr(ord(C) + 1)) if __name__ == '__main__': main()
def main(): c = str(input()) print(chr(ord(c)+1)) if __name__ == "__main__": main()
1
92,061,920,163,980
null
239
239
N = int(input()) A = tuple(map(int, input().split())) x = [0] * N for i in range(N - 1): x[A[i]-1] += 1 for a in x: print(a)
import sys def LI(): return list(map(int, sys.stdin.buffer.readline().split())) def I(): return int(sys.stdin.buffer.readline()) def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split() def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8') def IR(n): return [I() for i in range(n)] def LIR(n): return [LI() for i in range(n)] def SR(n): return [S() for i in range(n)] def LSR(n): return [LS() for i in range(n)] def SRL(n): return [list(S()) for i in range(n)] def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)] mod = 10 ** 9 + 7 h, w = LI() if h == 1 or w == 1: print(1) else: if (h * w) % 2 == 0: print(int(h * w / 2)) else: print(int(h * w / 2 + 1))
0
null
41,670,030,216,398
169
196
N = int(input()) S = input() print('Yes' if S[:N//2] == S[N//2:] else 'No')
n = int(input()) s = input() if n % 2 != 0: print('No') else: if s[:int((n/2))] == s[int((n/2)):]: print('Yes') else: print('No')
1
147,267,808,606,900
null
279
279
#!/usr/bin/env python3 import sys from itertools import combinations as comb from itertools import chain import numpy as np # form bisect import bisect_left, bisect_right, insort_left, insort_right # from collections import Counter def solve(H, W, K, C): answer = 0 for hn in range(H + 1): for wn in range(W + 1): for h_idxs in comb(range(H), hn): for w_idxs in comb(range(W), wn): cs = C.copy() cs[h_idxs, :] = 0 cs[:, w_idxs] = 0 answer += cs.sum() == K return answer def main(): tokens = chain(*(line.split() for line in sys.stdin)) H = int(next(tokens)) W = int(next(tokens)) K = int(next(tokens)) C = np.array( [ list(map(lambda x: {"#": 1, ".": 0}[x], line)) for line in tokens ] ) answer = solve(H, W, K, C) print(answer) if __name__ == "__main__": main()
N = int(input()) lst = list(map(int, input().split())) anslst = [0]*N for i in lst: anslst[i-1] += 1 for i in anslst: print(i)
0
null
20,725,076,486,880
110
169
import math a, b, C=map(int, input().split()) print("{0:.5f}".format((1/2)*a*b*math.sin(C*math.pi/180.0))) print("{0:.5f}".format(a+b+math.sqrt(a**2+b**2-2*a*b*math.cos(C*math.pi/180)))) print("{0:.5f}".format(b*math.sin(C*math.pi/180.0)))
import math k = int(input()) k += 1 ans = 0 for a in range(1, k): for b in range(1, k): for c in range(1, k): ans += math.gcd(a, math.gcd(b, c)) print(ans)
0
null
17,923,684,690,460
30
174
import sys input=sys.stdin.readline sys.setrecursionlimit(10 ** 6) #from collections import defaultdict #d = defaultdict(int) #import fractions #import math #import collections #from collections import deque #from bisect import bisect_left #from bisect import insort_left #N = int(input()) #A = list(map(int,input().split())) #S = list(input()) #S.remove("\n") #N,M = map(int,input().split()) #S,T = map(str,input().split()) #A = [int(input()) for _ in range(N)] #S = [input() for _ in range(N)] #A = [list(map(int,input().split())) for _ in range(N)] #import itertools #import heapq #import numpy as np #INF = float("inf") #MOD = 10**9+7 MOD = 10**9+7 import math N,K = map(int,input().split()) ans = [0]*K for i in range(K): p = K-i a = pow(math.floor(K/p),N,MOD) x = 1 while p*(x+1) <= K: a -= ans[p*(x+1)-1] x = x+1 ans[p-1] = a%MOD s = 0 for i in range(K): s += (i+1)*ans[i] s = s%MOD print(s)
N = int(input()) A = list(map(int, input().split())) # number_to_prime[i]: i の最小の素因数, iが素数ならば0 number_to_prime = [0] * (10**6 + 1) # preprocess for i in range(2, 10**6+1): if not number_to_prime[i]: j = 1 while j*i <= 10**6: number_to_prime[j*i] = i j += 1 def is_pairwise(): used_primes = [False] * (10**6 + 1) pairwise_flag = 1 for a in A: curr_primes = set() while a > 1: prime = number_to_prime[a] while a % prime == 0: a //= prime if used_primes[prime]: return False used_primes[prime] = 1 return True def is_setwise(*A): import math from functools import reduce return reduce(math.gcd, A) == 1 if is_pairwise(): print("pairwise coprime") elif is_setwise(*A): print("setwise coprime") else: print("not coprime")
0
null
20,527,610,730,330
176
85
alpha = input() if alpha.islower(): print("a") else: print("A")
from collections import Counter N = int(input()) S = input() counter = Counter(list(S)) ans = counter['R'] * counter['G'] * counter['B'] for d in range(1, N // 2 + 1): for a, b, c in zip(S, S[d:], S[2 * d:]): if a != b and b != c and c != a: ans -= 1 print(ans)
0
null
23,530,217,137,048
119
175
s1 = input() s2 = input() cnt = 0 for c1, c2 in zip(s1, s2) : if c1 != c2 : cnt += 1 print(cnt)
s=input() t=input() count=0 for i in range(len(s)): if s[i]==t[i]: pass else: count+=1 print(count)
1
10,523,407,775,708
null
116
116
h,w,k=[int(j) for j in input().split()] s=[list(map(int,list(input()))) for i in range(h)] import itertools s=tuple(itertools.chain(*zip(*s))) ans=10**18 for i in range(1<<(h-1)): dp=list(s) for j in range(h-1): if i&(1<<j): for n in range(0,h*w,h): dp[n+j+1]+=dp[n+j] tmp=h-1-bin(i).count("1") b=False for n in range(0,h*w,h): if any(dp[n+j]>k for j in range(h)): tmp=10**18 break if n+h==h*w: ans=min(ans,tmp) tmp=10**18 break if any(dp[n+j]+dp[n+j+h]>k for j in range(h)): tmp+=1 continue for j in range(h): dp[n+j+h]+=dp[n+j] ans=min(ans,tmp) print(ans)
sel='E' #A if sel=='A': N,M=map(int,input().split()) ans=0 ans+=M*(M-1)//2 ans+=N*(N-1)//2 print(ans) #B if sel=='B': def ispal(s): for i in range(len(s)//2+1): if s[i]!=s[-(i+1)]: return False return True S=input() N=len(S) if ispal(S) and ispal(S[:(N-1)//2]) and ispal(S[(N+3)//2-1:]): print('Yes') else: print('No') #C if sel=='C': L=int(input()) print((L**3)/27) #D if sel=='D': N=int(input()) A=[int(i) for i in input().split()] kin=list(set(A)) cnt={} for k in kin: cnt[k]=0 for a in A: cnt[a]+=1 SUM=0 for k in kin: SUM+=cnt[k]*(cnt[k]-1)//2 for a in A: if cnt[a]>=2: print(SUM-cnt[a]+1) else: print(SUM) #E if sel=='E': def add(in1, in2): return [a + b for a, b in zip(in1, in2)] def split(ar, k, w): a = 0 if max(max(ar)) > k: return -1 tm = ar[0] for i in range(1, w): tm = add(tm, ar[i]) if max(tm) > k: a += 1 tm = ar[i] return a h, w, k = map(int, input().split()) s = [[int(i) for i in input()] for j in range(h)] ans = h*w for i in range(2**(h-1)): data = [] temp = s[0] sp = bin(i+2**h)[4:] for j in range(1, h): if sp[j-1] == "0": temp = add(temp, s[j]) else: data.append(temp) temp = s[j] data.append(temp) ans_ = split([list(x) for x in zip(*data)], k, w) if ans_ == -1: continue ans_ += sp.count("1") if ans > ans_: ans = ans_ print(ans) # #F # if sel=='F': # N,S=map(int,input().split()) # A=[int(i) for i in input().split()]
1
48,677,306,133,960
null
193
193
from sys import stdin, setrecursionlimit def main(): input = stdin.readline n = int(input()) s_arr = [] t_arr = [] for _ in range(n): s, t = list(map(str, input().split())) t = int(t) s_arr.append(s) t_arr.append(t) x = input()[:-1] print(sum(t_arr[s_arr.index(x) + 1:])) if __name__ == "__main__": setrecursionlimit(10000) main()
n=int(input()) s=[] t=[] for i in range(n): st,tt=input().split() s.append(st) t.append(int(tt)) x=str(input()) temp=0 ans=sum(t) for i in range(n): temp=temp+t[i] if s[i]==x: break print(ans-temp)
1
96,923,113,908,400
null
243
243
length, t = map(int, input().split(" ")) target = [int(n) for n in input().split(" ")] dp = [float("inf") for n in range(length + 1)] dp[0] = 0 for i, coin in enumerate(target): for j in range(length): if coin + j <= length: dp[coin + j] = min(dp[coin + j], dp[j] + 1) print(dp[length])
n,m = map(int,input().split()) C = list(map(int,input().split())) INF = 50010 dp = [[INF]*(n+1) for _ in range(m+1)] for i in range(m): dp[i+1][0] = 0 for j in range(1,n+1): if j-C[i] >= 0: dp[i+1][j] = min(dp[i+1][j-C[i]]+1,dp[i][j]) else: dp[i+1][j] = dp[i][j] print(dp[m][n])
1
141,507,151,270
null
28
28
N, X, Y = map(int, input().split()) count = [0]*(N+1) for i in range(1, N+1): for k in range(i+1, N+1): distik = min(k-i, abs(k-X) + abs(i - Y)+1, abs(k-Y) + abs(i-X)+1) count[distik] += 1 for i in range(1, N): print(count[i])
A = input() if A[2] == A[3] and A[4] == A[5]: print('Yes') elif A[2] != A[3] or A[4] != A[5]: print('No')
0
null
43,244,992,721,590
187
184
import numpy as np from fractions import gcd def lcm(a,b): return a*b//gcd(a,b) N,M=map(int,input().split()) a=[i//2 for i in map(int,input().split())] b=np.array(a) cnt=0 while all(b%2==0): b//=2 if any(b%2==0): print(0) exit() ans=1 for i in a: ans=lcm(ans,i) print((M//ans-1)//2+1)
N, M = list(map(int, input().split())) A = list(map(lambda x: int(x),input().split())) cnt = [0 for _ in range(N)] for i in range(N): a = A[i] while a%2 == 0: a = a // 2 cnt[i] += 1 if max(cnt) > min(cnt): print(0) exit(0) C = max(cnt) A = list(map(lambda x: x // pow(2,C), A)) def gcd(a,b): if a<b: a,b = b,a while a%b > 0: a,b = b,a%b return b def lcm(a,b): return a*b//gcd(a,b) x = A[0] for a in A[1:]: x = lcm(x,a) x = x * pow(2,C-1) print((M // x + 1) // 2)
1
101,384,059,828,458
null
247
247
n,k=map(int, input().split()) a = list(map(int, input().split())) k = min(k,50) for i in range(k): aa = [0]*n for j in range(n): aa[max(0,j-a[j])] += 1 if j+a[j]+1 < n: aa[j+a[j]+1] -= 1 for j in range(n-1):aa[j+1] = aa[j]+aa[j+1] a = aa[:] print(*a)
N=int(input()) A=[0]*N ans=0 for i in range(1,N+1): ii=i while N>=ii: A[ii-1]+=1 ii+=i ans+=A[i-1]*i print(ans)
0
null
13,140,023,423,822
132
118
def main(): a,b,c = map(int,input().split()) if a == b and b==c : print("No") return if a != b and b != c and a != c: print("No") return print("Yes") return if __name__ == "__main__": main()
## necessary imports import sys input = sys.stdin.readline # from math import ceil, floor, factorial; def ceil(x): if x != int(x): x = int(x) + 1; return x; # swap_array function def swaparr(arr, a,b): temp = arr[a]; arr[a] = arr[b]; arr[b] = temp ## gcd function def gcd(a,b): if b == 0: return a return gcd(b, a % b); ## nCr function efficient using Binomial Cofficient def nCr(n, k): if(k > n - k): k = n - k res = 1 for i in range(k): res = res * (n - i) res = res / (i + 1) return int(res) ## upper bound function code -- such that e in a[:i] e < x; def upper_bound(a, x, lo=0, hi = None): if hi == None: hi = len(a); while lo < hi: mid = (lo+hi)//2 if a[mid] < x: lo = mid+1 else: hi = mid return lo ## prime factorization def primefs(n): ## if n == 1 ## calculating primes primes = {} while(n%2 == 0 and n > 0): primes[2] = primes.get(2, 0) + 1 n = n//2 for i in range(3, int(n**0.5)+2, 2): while(n%i == 0 and n > 0): primes[i] = primes.get(i, 0) + 1 n = n//i if n > 2: primes[n] = primes.get(n, 0) + 1 ## prime factoriazation of n is stored in dictionary ## primes and can be accesed. O(sqrt n) return primes ## MODULAR EXPONENTIATION FUNCTION def power(x, y, p): res = 1 x = x % p if (x == 0) : return 0 while (y > 0) : if ((y & 1) == 1) : res = (res * x) % p y = y >> 1 x = (x * x) % p return res ## DISJOINT SET UNINON FUNCTIONS def swap(a,b): temp = a a = b b = temp return a,b # find function with path compression included (recursive) # def find(x, link): # if link[x] == x: # return x # link[x] = find(link[x], link); # return link[x]; # find function with path compression (ITERATIVE) def find(x, link): p = x; while( p != link[p]): p = link[p]; while( x != p): nex = link[x]; link[x] = p; x = nex; return p; # the union function which makes union(x,y) # of two nodes x and y def union(x, y, link, size): x = find(x, link) y = find(y, link) if size[x] < size[y]: x,y = swap(x,y) if x != y: size[x] += size[y] link[y] = x ## returns an array of boolean if primes or not USING SIEVE OF ERATOSTHANES def sieve(n): prime = [True for i in range(n+1)] p = 2 while (p * p <= n): if (prime[p] == True): for i in range(p * p, n+1, p): prime[i] = False p += 1 return prime #### PRIME FACTORIZATION IN O(log n) using Sieve #### MAXN = int(1e5 + 5) def spf_sieve(): spf[1] = 1; for i in range(2, MAXN): spf[i] = i; for i in range(4, MAXN, 2): spf[i] = 2; for i in range(3, ceil(MAXN ** 0.5), 2): if spf[i] == i: for j in range(i*i, MAXN, i): if spf[j] == j: spf[j] = i; ## function for storing smallest prime factors (spf) in the array ################## un-comment below 2 lines when using factorization ################# # spf = [0 for i in range(MAXN)] # spf_sieve(); def factoriazation(x): ret = {}; while x != 1: ret[spf[x]] = ret.get(spf[x], 0) + 1; x = x//spf[x] return ret ## this function is useful for multiple queries only, o/w use ## primefs function above. complexity O(log n) ## taking integer array input def int_array(): return list(map(int, input().strip().split())) ## taking string array input def str_array(): return input().strip().split(); #defining a couple constants MOD = int(1e9)+7; CMOD = 998244353; INF = float('inf'); NINF = -float('inf'); ################### ---------------- TEMPLATE ENDS HERE ---------------- ################### n, k = int_array(); a = int_array(); pos = []; neg = []; ans = 1; for i in a: if i < 0: neg.append(i); else: pos.append(i); if n == k: for i in a: ans = (ans * i) % MOD; elif not pos: if k & 1: neg.sort(reverse = 1); else: neg.sort(); for i in range(k): ans = (ans * neg[i]) % MOD; else: pos.sort(); neg.sort(reverse = 1); if k & 1: ans = pos.pop(); for _ in range(k // 2): if len(pos) > 1 and len(neg) > 1: if pos[-1] * pos[-2] >= neg[-1] * neg[-2]: ans = (ans * pos.pop()) % MOD; ans = (ans * pos.pop()) % MOD; else: ans = (ans * neg.pop()) % MOD; ans = (ans * neg.pop()) % MOD; elif len(pos) > 1: ans = (ans * pos.pop()) % MOD; ans = (ans * pos.pop()) % MOD; else: ans = (ans * neg.pop()) % MOD; ans = (ans * neg.pop()) % MOD; print(ans);
0
null
38,927,964,894,810
216
112
n = float(input()) print(n * n * n / 27)
#!/usr/bin/env python3 import sys sys.setrecursionlimit(300000) def solve(L: int): ret = (L / 3) ** 3 print(ret) return def main(): def iterate_tokens(): for line in sys.stdin: for word in line.split(): yield word tokens = iterate_tokens() L = int(next(tokens)) # type: int solve(L) if __name__ == '__main__': main()
1
46,802,144,142,910
null
191
191
import math H = int(input()) W = int(input()) N = int(input()) for i in range(1, max(H, W)+1): if(max(H, W)*i >= N): print(i) break
H = int(input()) W = int(input()) N = int(input()) X = max(H, W) print((N + X - 1) // X)
1
88,942,531,388,132
null
236
236
S = input() if S == 'AAA': print('No') elif S == 'BBB': print('No') else: print('Yes')
s = input() if len(set(s)) ==2: print("Yes") else: print("No")
1
54,729,568,810,642
null
201
201
a,v=map(int,input().split()) b,w=map(int,input().split()) t=int(input()) if v<w: print("NO") exit() diff=abs(a-b) for _ in range(t): diff=diff-v+w if diff<=0: print("YES") exit() print("NO")
import sys import math import itertools import bisect from copy import copy from collections import deque,Counter from decimal import Decimal import functools def s(): return input() def k(): return int(input()) def S(): return input().split() def I(): return map(int,input().split()) def X(): return list(input()) def L(): return list(input().split()) def l(): return list(map(int,input().split())) def lcm(a,b): return a*b//math.gcd(a,b) sys.setrecursionlimit(10 ** 9) mod = 10**9+7 cnt = 0 ans = 0 inf = float("inf") s = s() a = ["SAT", "FRI", "THU","WED","TUE","MON","SUN"] x = a.index(s) + 1 print(x)
0
null
74,278,874,609,800
131
270
import math def main(): n = int(input()) x = list(map(float, input().split())) y = list(map(float, input().split())) print(Minkowski(n, x, y, 1)) print(Minkowski(n, x, y, 2)) print(Minkowski(n, x, y, 3)) print(Chebyshev(n, x, y)) def Minkowski(n, x, y, p): temp = 0 for i in range(n): temp += abs(y[i] - x[i])**p return temp**(1/p) def Chebyshev(n, x, y): temp = 0 for i in range(n): temp = max(temp, abs(y[i] - x[i])) return temp if __name__ == '__main__': main()
def minko_n(x,y,n): D = 0 for i in range(len(x)): D += (abs(x[i]-y[i]))**n return D**(1/n) def minko_f(x,y): l = [] for i in range(len(x)): l.append(abs(x[i]-y[i])) return max(l) n = int(input()) x = list(map(int,input().split())) y = list(map(int,input().split())) print(minko_n(x,y,1)) print(minko_n(x,y,2)) print(minko_n(x,y,3)) print(minko_f(x,y))
1
216,130,860,572
null
32
32
import math n = int(input()) a = [0] * 2 b = [0] * 2 a[0] = 0 b[0] = 100 def koch(n, a, b): if n == 0: return s = [0] * 2 t = [0] * 2 u =[0] * 2 s[0] = (2.0 * a[0] + 1.0 * b[0]) / 3.0 s[1] = (2.0 * a[1] + 1.0 * b[1]) / 3.0 t[0] = (1.0 * a[0] + 2.0 * b[0]) / 3.0 t[1] = (1.0 * a[1] + 2.0 * b[1]) / 3.0 u[0] = (t[0] - s[0]) * math.cos(math.pi/3) - (t[1] - s[1]) * math.sin(math.pi/3) + s[0] u[1] = (t[0] - s[0]) * math.sin(math.pi/3) + (t[1] - s[1]) * math.cos(math.pi/3) + s[1] koch(n - 1, a, s) print(s[0], s[1]) koch(n - 1, s, u) print(u[0], u[1]) koch(n - 1, u, t) print(t[0], t[1]) koch(n - 1, t, b) print(a[0], a[1]) koch(n, a, b) print(b[0], b[1])
import math cos60=math.cos(math.radians(60)) sin60=math.sin(math.radians(60)) def koch(d,p1_x,p2_x,p1_y,p2_y): if d==0: return s_x=(2*p1_x+1*p2_x)/3 s_y=(2*p1_y+1*p2_y)/3 t_x=(1*p1_x+2*p2_x)/3 t_y=(1*p1_y+2*p2_y)/3 u_x=(t_x-s_x)*cos60-(t_y-s_y)*sin60+s_x u_y=(t_x-s_x)*sin60+(t_y-s_y)*cos60+s_y koch(d-1,p1_x,s_x,p1_y,s_y) print(s_x,s_y) koch(d-1,s_x,u_x,s_y,u_y) print(u_x,u_y) koch(d-1,u_x,t_x,u_y,t_y) print(t_x,t_y) koch(d-1,t_x,p2_x,t_y,p2_y) d=int(input()) p1_y=0 p1_x=0 p2_x=100 p2_y=0 print(float(p1_x),float(p1_y)) koch(d,p1_x,p2_x,p1_y,p2_y) print(float(p2_x),float(p2_y))
1
131,243,071,710
null
27
27
n,m = map(int,input().split()) a = list(map(int,input().split())) b = [0]*n b = sorted(a,reverse=True) c = sum(a) if(b[m-1]>=c/(4*m)): print('Yes') else: print("No")
num = 0 def marge_sort(array): global num if len(array) < 2: return array mid = len(array) // 2 left = marge_sort(array[:mid]) right = marge_sort(array[mid:]) len_l, len_r = len(left), len(right) left += [float("inf")] right += [float("inf")] marray = [0] * (len_l + len_r) l, r = 0, 0 for i in range(len_l + len_r): num += 1 if left[l] <= right[r]: marray[i] = left[l] l += 1 else: marray[i] = right[r] r += 1 return marray n = int(input()) a = list(map(int, input().split())) print(" ".join(map(str, marge_sort(a)))) print(num)
0
null
19,364,664,334,990
179
26
n = int(input()) def count_ab(start, end): l = len(str(n)) if start == 0: return 0 if l == 1: if start == end: if n >= start: return 1 else: return 0 else: return 0 else: if start == end: cnt = 1 else: cnt = 0 if int(str(n)[0]) > start: for i in range(1, l): cnt += 10 ** i // 10 if int(str(n)[0]) == start: for i in range(1, l - 1): cnt += 10 ** i //10 cnt += int(str(n)[1:]) // 10 if int(str(n)[-1]) >= end: cnt += 1 if int(str(n)[0]) < start: for i in range(1, l - 1): cnt += 10 ** i //10 return cnt ans = 0 for i in range(10): for j in range(10): A = count_ab(i, j) B = count_ab(j, i) ans += A * B print(ans)
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys money = 100000 d = int(sys.stdin.read()) for i in range(d): money *= 1.05 if money%1000 != 0: money -= money%1000 money += 1000 print int(money)
0
null
43,125,817,951,472
234
6
import bisect,collections,copy,heapq,itertools,math,string import sys def S(): return sys.stdin.readline().rstrip() def M(): return map(int,sys.stdin.readline().rstrip().split()) def I(): return int(sys.stdin.readline().rstrip()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LS(): return list(sys.stdin.readline().rstrip().split()) a, b, c, d = M() li = list() li.append(a*c) li.append(a*d) li.append(b*c) li.append(b*d) li.sort() print(li[-1])
a,b,c,d=map(int,input().split(' ')) if a>=0: if d<=0: ans=a*d else: x=b y=d ans=b*d elif a<=0 and b>=0: if c>=0: x=b y=d ans=b*d elif c<=0 and d>=0: ans=max(a*c,b*d) else: ans=a*c else: if c>=0: ans=b*c else: ans=a*c print(ans)
1
3,083,600,647,390
null
77
77
# C - Traveling Salesman around Lake k,n = map(int,input().split()) a = list(map(int,input().split())) bet = [a[0]+k-a[n-1]] for i in range(n-1): bet.append(a[i+1]-a[i]) print(k-max(bet))
n, k = [int(i) for i in input().split()] cnt = 0 if n == 0: print(1) exit() while n != 0: n = n // k cnt += 1 print(cnt)
0
null
53,700,903,701,094
186
212
while(1): n = input() if n == '-': exit() m = int(input()) for i in range(m): h = int(input()) n = n[h:] + n[0:h] print(n)
while 1: n=input() if len(n)==1:break for i in range(int(input())): a=int(input()) n=n[a:]+n[:a] print(n)
1
1,894,251,497,340
null
66
66
def main(): a, b, c, d = map(int, input().split()) if a*b > 0 and c*d > 0 and a*c < 0: print(max(a*d, b*c)) else: print(max(a*c, b*d, 0)) if __name__ == "__main__": main()
k,x = [int(i) for i in input().split(' ')] print('Yes') if(500*k >= x) else print('No')
0
null
50,865,509,505,120
77
244
N = int(input()) X = list(map(int, input().split())) X.sort() ans = 0 data = [] for p in range(X[N-1] + 1): sum = 0 for i in range(len(X)): sum += (X[i]-p)**2 ans = sum p += 1 data.append(ans) print(min(data))
N = int(input()) X = list(map(int, input().split())) assert len(X) == N # N人が点Xiに住んでいる # 任意の整数値の点で集会を開く # 2乗距離の体力を消耗 # 点yで集会 def sum_power(y): return sum([(x - y) * (x - y) for x in X]) import sys minimum = sys.maxsize for y in range(min(X), max(X)+1): minimum = min(minimum, sum_power(y)) print(minimum)
1
65,462,327,346,152
null
213
213
from collections import defaultdict def main(): n = int(input()) d = defaultdict(int) for i in range(1, n+1): s = str(i) a = s[0] b = s[-1] d[a, b] += 1 ans = 0 d_items = list(d.items()) for (a, b), v in d_items: ans += v * d[b,a] print(ans) if __name__ == '__main__': main()
l = list(map(int, input().split())) for i in range(5): if l[i] == 0: print(i + 1)
0
null
49,813,929,845,280
234
126
import math K = int(input()) Sum = 0 for A in range(1,K+1): for B in range(1,K+1): AB = math.gcd(A,B) if AB==1: Sum = Sum+K else: for C in range(1,K+1): Sum = Sum+math.gcd(AB,C) print(Sum)
n,m = map(int,input().split()) if n % 2 == 1:ans = [[1+i,n-i] for i in range(n//2)] else:ans = [[1+i,n-i] for i in range(n//4)]+[[n//2+1+i,n//2-1-i] for i in range(n//2-n//4-1)] for i in range(m):print(ans[i][0],ans[i][1])
0
null
31,957,323,037,350
174
162
def main(): S = list(input()) K = int(input()) cnt = 0 if K == 1: T = S for i in range(len(T)-1): if T[i] == T[i+1]: T[i+1] = '.' ans = T.count('.') print(ans) return if len(S) == 1: ans = max(0, (K - (K%2==1))//2) print(ans) return if len(set(S)) == 1: tmp = len(S)*K tmp = tmp - (tmp%2 == 1) ans = tmp//2 print(ans) return T3 = S + S + S for i in range(len(T3)-1): if T3[i] == T3[i+1]: T3[i+1] = '.' T2aster = T3[len(S):(2*len(S))].count('.') T3aster = T3.count('.') ans = T3aster + T2aster * (K-3) print(ans) if __name__ == "__main__": main()
s = input() k = int(input()) li = list(s) lee = len(s) if len(list(set(li))) == 1: print((lee)*k//2) exit() def motome(n,list): count = 0 kaihi_flag = False li = list*n for i,l in enumerate(li): if i == 0: continue if l == li[i-1] and not kaihi_flag: count += 1 kaihi_flag = True else: kaihi_flag = False #print(count) #print(count*k) return count if k >= 5 and k%2 == 1: a = motome(3,li) b = motome(5,li) diff = b - a ans = b + (k-5)//2*diff print(ans) elif k >=5 and k%2 == 0: a = motome(2,li) b = motome(4,li) diff = b - a ans = b + (k-4)//2*diff print(ans) else: count = 0 kaihi_flag = False li = li*k for i,l in enumerate(li): if i == 0: continue if l == li[i-1] and not kaihi_flag: count += 1 kaihi_flag = True else: kaihi_flag = False #print(count) #print(count*k) print(count)
1
175,779,299,185,330
null
296
296
def f1(s,a,b): print(s[a:b+1]) return s def f2(s,a,b): temp = s[a:b+1] return s[:a] + temp[::-1] + s[b+1:] def f3(s,a,b,p): return s[:a] + p + s[b+1:] data = input() q = int(input()) functions = {'print':f1, 'reverse':f2, 'replace':f3} for i in range(q): temp = [s if s.isalpha() else int(s) for s in input().split(' ')] f = temp.pop(0) data = functions[f](data,*temp)
import itertools n,k=map(int,input().split()) d=[] a=[] for i in range(k): p=int(input()) d.append(p) q=list(map(int,input().split())) a.append(q) c=list(itertools.chain.from_iterable(a)) c.sort() c_set=set(c) c=list(c_set) print(n-len(c))
0
null
13,374,213,277,700
68
154
while True: a, op, b = input().split() if op == '?': break if op == '/': op = '//' print(eval(a + op + b))
ans = [] while True: arr = map(str, raw_input().split()) if arr[1] is '?': break val = eval(arr[0] + arr[1] + arr[2]) ans.append(val) print("\n".join(map(str, ans)))
1
696,046,712,672
null
47
47
a,b=map(int,input().split()) print('%d %d %.5f\n'%(a//b,a%b,a/b))
x, y = map(int, input().split()) print('{} {} {:.5f}'.format(x // y, x % y, x / y))
1
600,967,934,130
null
45
45
from numba import njit n = int(input()) @njit def solve(): f = [1] * (n + 1) for i in range(2, n + 1): if f[i] != 1: continue m = i while m <= n: tmp = m cnt = 0 while tmp % i == 0: tmp = tmp // i cnt += 1 f[m] *= cnt + 1 m += i ans = 0 for i in range(1, n + 1): ans += i * f[i] return ans print(solve())
X, K, D = map(int, input().split()) t = X // D if abs(t) >= K: if X > 0: print(abs(X-(D*K))) elif X < 0: print(abs(X+(D*K))) exit(0) nokori = K - t if X-(D*t) <= 0: if nokori % 2 == 0: print(abs(X-(D*t))) else: print(abs(X-(D*(t-1)))) else: if nokori % 2 == 0: print(abs(X-(D*t))) else: print(abs(X-(D*(t+1))))
0
null
8,174,101,249,612
118
92
n,m=map(int,input().split()) cnt = [0]*n total = [0]*n for i in range(m): P=list(input().split()) p = int(P[0]) - 1 if P[1] == 'WA' and cnt[p] == 0: total[p] += 1 if P[1] == 'AC' and cnt[p] == 0: cnt[p] = True ans = 0 for i in range(n): if cnt[i] == True: ans += total[i] print(sum(cnt),ans)
from collections import Counter n=int(input()) stri=list(input()) cc=Counter(stri) count=cc['R']*cc['G']*cc['B'] for i in range(n-2): for j in range(i+1,n-1): if stri[j]==stri[i]:continue lib=['R','G','B'] lib.remove(stri[i]) lib.remove(stri[j]) t=lib.pop() skip_k=2*j-i #print(i,j,skip_k) if skip_k>n-1:continue if stri[skip_k]==t: count-=1 print(count)
0
null
64,708,166,284,806
240
175
import sys x, k, d = map(int,input().split()) x = abs(x) ans = 0 if k <= x // d: ans = x - k*d print(ans) sys.exit() if (k - (x // d)) % 2 == 0: print(x % d) else: print(abs(x % d - d))
x, k, d = map(int, input().split()) cur = x numTimes = x // d if numTimes == 0: cur -= d k -= 1 else: numTimes = min(abs(numTimes), k) if x < 0: numTimes *= -1 cur -= numTimes * d k -= numTimes if k % 2 == 0: print(abs(cur)) else: result = min(abs(cur - d), abs(cur + d)) print(result)
1
5,225,925,668,210
null
92
92