Harryxun/stf_run huggingface dataset:
import fractions
lst=list(int(input()) for _ in range(int(input())))
ans = a[0]
for i in range(1, N):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
print(ans)

### FIXED CODE ###

import fractions
n=int(input())
lst=list(int(input()) for _ in range(n))
ans = lst[0]
for i in range(1, n):
    ans = ans * lst[i] // fractions.gcd(ans, lst[i])
print(ans)
from math import ceil
N, K = map(int, raw_input().split())
A = map(int, raw_input().split())

print (ceil((N-1)//(K-1)))


### FIXED CODE ###

import math
N, K = map(int, input().split())
input()
     
print(math.ceil((N-1)/(K-1)))
import math
A,B,C,D = map(int, input().split())


def lcm(x, y):
    return (x * y) / math.gcd(x, y)

t = lcm(C, D)

m = B - (math.floor(B / C) + math.floor(B / D) - math.floor(B / (t)))
 
n = A - 1 - (math.floor((A-1) / C) + math.floor((A-1) / D ) - math.floor((A-1) / (t)))

print(m-n)

### FIXED CODE ###

from fractions import gcd
 
A, B, C, D = map(int, input().split())
t = C * D // gcd(C, D)
print((B - (A - 1)) - (B//C + B//D - B//t) + ((A-1)//C + (A-1)//D - (A-1)//t))
h, w = map(int, input().split())
a = []
m = []
for _ in range(h):
    a.append(list(map(int, input().split())))
for j in range(h):
    f = 0
    for i in range(w):
        if not f:
            if a[j][i] % 2:
                f = a[i][j]
        else:
            print(j+1, i, j+1, i+1)
            if a[j][i] % 2:
                f = 0
    m.append(f)

for j in m:
    f = 0
    if not f:
        if m[j] % 2:
            f = m[j]
    else:
        print(w, j, w, j+1)
        if m[j] % 2:
            f = 0


### FIXED CODE ###

h, w = map(int, input().split())
a = []
m = []
ans = []
for _ in range(h):
    a.append(list(map(int, input().split())))
for j in range(h):
    f = 0
    for i in range(w):
        if not f:
            if a[j][i] % 2:
                f = a[j][i]
        else:
            ans.append([j+1, i, j+1, i+1])
            if a[j][i] % 2:
                f = 0
    m.append(f)

f = 0
for j in range(h):
    if not f:
        if m[j] % 2:
            f = m[j]
    else:
        ans.append([j, w, j+1, w])
        if m[j] % 2:
            f = 0

print(len(ans))
for ansi in ans:
    print(" ".join([str(x) for x in ansi]))
a = int(input())
b = int(input())
if a >= 10 or b >= 10:
    print(-1)
else:
    print(a*b)

### FIXED CODE ###

a, b = map(int, input().split())
if a >= 10 or b >= 10:
    print(-1)
else:
    print(a*b)
N,T = map(int,input().split())
food = list(list(map(int,input().split()))for i in range(N))
ans = 0
if T == 1:
    for _,i in food:
        ans = max(i,ans)
    print(ans)
    exit()
DP = [[0]*(T) for i in range(N+1)]
for i in range(N):
    a,b = food[i]
    for j in range(a):
        DP[i+1][j] = DP[i][j]
    for j in range(a,T):
        DP[i+1][j] = max(DP[i][j],DP[i][j-a]+b)
ans = 0
i = N
j = T-1
while i > 0 and j > 0:
    if DP[i][j] == DP[i][j-1]:
        j -= 1
    elif DP[i][j] == DP[i-1][j]:
        i -= 1
    else:
        food[i-1][1] = 0
        j -= food[i-1][0]
        i -= 1
food.sort(reverse=True,key= lambda x:x[1])
print(DP[-1][-1]+food[0][1])

### FIXED CODE ###

N,T = map(int,input().split())
food = list(list(map(int,input().split()))for i in range(N))
DP = [[0]*(T) for i in range(N+1)]
for i in range(N):
    a,b = food[i]
    for j in range(min(a,T)):
        DP[i+1][j] = DP[i][j]
    for j in range(a,T):
        DP[i+1][j] = max(DP[i][j],DP[i][j-a]+b)
ans = 0
i = N
j = T-1
while i > 0 and j > 0:
    if DP[i][j] == DP[i][j-1]:
        j -= 1
    elif DP[i][j] == DP[i-1][j]:
        i -= 1
    else:
        food[i-1][1] = 0
        j -= food[i-1][0]
        i -= 1
food.sort(reverse=True,key= lambda x:x[1])
print(DP[-1][-1]+food[0][1])
str = input().split()
a = str[0]
a_len = len(a)
b = str[1]
b_r = str[:-1]


if b_r[0] == a and a_len <= 10 and a_len >= 1:
 	print("Yes")
else:
	print("No")


### FIXED CODE ###

a = input()
b = input()

a_len = len(a)
b_r = b[:-1]

if b_r == a and a_len <= 10 and a_len >= 1:
 	print("Yes")
else:
	print("No")
N,M=map(int, input().split())
A=[input() for _ in range(N)]
B=[input() for _ in range(M)]

for i in range(N-M+1):
    for j in range(N-M+1):
        t=[k[j:j+m] for k in a[i:i+m]]
        if t==B:
            print('Yes')
            exit()
print('No')


### FIXED CODE ###

N,M=map(int, input().split())
A=[input() for _ in range(N)]
B=[input() for _ in range(M)]

for i in range(N-M+1):
    for j in range(N-M+1):
        t=[k[j:j+M] for k in A[i:i+M]]
        if t==B:
            print('Yes')
            exit()
print('No')
def swap(a, b, k):
    if k % 2 == 0:
        if a % 2 == 1:
            a -= 1
        return a/2, b+a/2
    if b % 2 == 1:
        b -= 1
    return int(a+b/2), int(b/2)


if __name__ == '__main__':
    a, b, k = list(map(int, input().split()))
    for i in range(k):
        a,b = swap(a,b,i)
    print(int(a), int(b))


### FIXED CODE ###

from itertools import accumulate


class CoeffTable:
    def __init__(self, n):
        self.n = n
        if n == 2:
            (self.p2, self.p1, self.m1, self.m2) = (0, 1, 1, 0)
        if n % 2 == 0:
            self.p1 = self.m1 = 1
            self.p2 = self.m2 = (n - 1) // 2
        else:
            self.p1 = 0
            self.m1 = 2
            self.p2 = (n - 1) // 2
            self.m2 = (n - 2) // 2

    def reverse(self):
        (self.p2, self.p1, self.m1, self.m2) = (
            self.m2,
            self.m1,
            self.p1,
            self.p2,
        )

    def cumsum(self):
        return list(accumulate([self.p2, self.p1, self.m1, self.m2]))



def main(n, seq):
    seq = sorted(seq, reverse=True)
    coeff = CoeffTable(n)
    cm = coeff.cumsum()
    ans1 = (
        2 * sum(seq[0 : cm[0]])
        + 1 * sum(seq[cm[0] : cm[1]])
        - 1 * sum(seq[cm[1] : cm[2]])
        - 2 * sum(seq[cm[2] : cm[3]])
    )
    coeff.reverse()
    rcm = coeff.cumsum()
    ans2 = (
        2 * sum(seq[0 : rcm[0]])
        + 1 * sum(seq[rcm[0] : rcm[1]])
        - 1 * sum(seq[rcm[1] : rcm[2]])
        - 2 * sum(seq[rcm[2] : rcm[3]])
    )
    ans = max(ans1, ans2)
    print(ans)
    return


if __name__ == "__main__":
    n = int(input())
    sample = []
    for _ in range(n):
        sample.append(int(input()))
    main(n, sample)
N = int(input())
sum = 0
for i in N:
  x,u = stdin.readline().rstrip().split()
  if u == 'JPY':
    sum += int(x)
  else:
  	sum += float(x)*38000
print(sum)


### FIXED CODE ###

N = int(input())
sum = 0
for i in range (N):
  X = input().split()
  if X[1] == 'JPY':
    sum += float(X[0])
  else:
  	sum += float(X[0])*380000
print(sum)
import math
def lcm(x, y):
    return (x*y)//math.gcd(x, y)

N = int(input())
a = list(map(int, input().split()))
lcm2 = 1
for i in range(N):
    lcm2 = lcm(a[i], lcm2)
lcm2 -= 1
f = 0
for i in range(N):
    f += lcm2%a[i]
print(f)

### FIXED CODE ###

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

def lcm(x, y):
    return (x*y)//gcd(x, y)

N = int(input())
a = list(map(int, input().split()))
lcm2 = 1
for i in range(N):
    lcm2 = lcm(a[i], lcm2)
lcm2 -= 1
f = 0
for i in range(N):
    f += lcm2%a[i]
print(f)
n,k=map(int,input().split()))
i=list(map(int,input().split()))
l=[0]*(n-k)
for j in range(n-k):
  l[j]=i[j+k]-i[j]
place=0
plus=0
for j in range(n-k):
  plus=plus+l[j]
  if plus>0:
    place=j+1
    plus=0
a=0
for j in range(k):
  a+=(i[j+place]+1)//2
print(a)


### FIXED CODE ###

n,k=map(int,input().split())
i=list(map(int,input().split()))
l=[0]*(n-k)
for j in range(n-k):
  l[j]=i[j+k]-i[j]
place=0
plus=0
for j in range(n-k):
  plus=plus+l[j]
  if plus>0:
    place=j+1
    plus=0
a=0.0
for j in range(k):
  a+=float(i[j+place]+1)/2
print(a)
x, y, a, b, c = map(int, input().split())

red = sorted(list(map(int, input().split())), reverse=True)
gre = sorted(list(map(int, input().split())), reverse=True)
non = sorted(list(map(int, input().split())), reverse=True)

eat = []

for i in range(x):
    eat.append(red.pop(0))

for i in range(y):
    eat.append(gre.pop(0))

eat.sort()

for i in range(len(non)):
    n = non.pop(0)
    if eat[i] < n:
        eat[i] = n
    else:
        break

print(sum(eat))


### FIXED CODE ###

s = input()

if s[2] == s[3] and s[4] == s[5]:
    print("Yes")
else:
    print("No")
N = list(map(int,input().split()))

row = ""

if N[1] == 0:
    print(0)
else:
    remain = N[0] - N[1] - N[2]
    row += "b"*N[1]+"a"*N[2]+"b"*remain

print(row.count("b")) 

### FIXED CODE ###

N, A, B = map(int, input().split())
ans = N // (A + B) * A
rem = N % (A + B)
ans += min(rem, A)
print(ans)
n ,x = map(int, input().rstrip().split())
l = map(int, input().rstrip().split())
d=0
count = 1
for i in range(n):
    d += l[i]
    if d > x:
        continue
    count+=1
    
print(count)

### FIXED CODE ###

x, a = map(int, input().rstrip().split())
if x < a:
  print(0)
else:
  print(10)
import math

A, B = map(int, input().split())

print(A, B)
#print(int(A * B / math.gcd(A, B)))


### FIXED CODE ###

A = int(input())
B = int(input())

r = list(filter(lambda x: x != A and x != B, [1, 2, 3]))
print(r[0])
sx, sy, tx, ty = [int(x) for x in input().split()]
y = ty - sy
l = ["R"]*x + ["U"]*y + ["L"]*x + ["D"]*y + ["D"] + ["R"] * (x+1) + ["U"]*(y+1) + ["L"] + ["U"] + ["L"]*(x+1) + ["D"]*(y+1) +["R"]
print("".join(l))

### FIXED CODE ###

sx, sy, tx, ty = [int(x) for x in input().split()]
x = tx - sx
y = ty - sy
l = ["R"]*x + ["U"]*y + ["L"]*x + ["D"]*y + ["D"] + ["R"] * (x+1) + ["U"]*(y+1) + ["L"] + ["U"] + ["L"]*(x+1) + ["D"]*(y+1) +["R"]
print("".join(l))
cnt = 0
for r in range(0,N//R+1):
    for g in range(0,(N-R*r)//G+1):
        if (N - R*r - G*g) % B == 0 :
            #print(r,g,(N-r-g))
            cnt += 1

print(cnt)

### FIXED CODE ###

R, G, B, N = map(int,input().split())

cnt = 0
for r in range(0,N//R+1):
    for g in range(0,(N-R*r)//G+1):
        if (N - R*r - G*g) % B == 0 :
            #print(r,g,(N-r-g))
            cnt += 1

print(cnt)
import sys
if __name__=="__main__":
    a, b = list(map(int, input().replace("\n","").split(" ")))
    if(a > b):
	sys.stdout.write("Alice")
    elif(a == b):
	sys.stdout.write("Draw")
    else:
	sys.stdout.write("Bob")

### FIXED CODE ###

if __name__=="__main__":
    a, b = list(map(int, input().split(" ")))
    if(a==1):
        a = 14
    if(b==1):
        b = 14
    if(a > b):
        print("Alice")
    elif(a == b):
        print("Draw")
    else:
        print("Bob")
#coding: utf-8
import math
import heapq
import bisect
from scipy.special import comb

MOD = 10**9+7

N,K = map(int, input().split())

for i in range(1,K+1):
    ans = (comb(K-1,i-1,exact=True)%MOD)*(comb(N-K+1,i,exact=True)%MOD)%MOD
    print(ans)

### FIXED CODE ###

#coding: utf-8
import math
import heapq
import bisect
from scipy.misc import comb

MOD = 10**9+7

N,K = map(int, input().split())

for i in range(1,K+1):
    ans = (comb(K-1,i-1,exact=True)%MOD)*(comb(N-K+1,i,exact=True)%MOD)%MOD
    print(ans)
(n, m) = [int(i) for i in input().split()]
A = []
b = []
for i in range(n):
????????A.append([int(j) for j in input().split()])

for i in range(m):
????????b.append(int(input()))

for i in range(n):
????????s = 0
????????for j in range(m):
????????????????s += A[i][j] * b[j]
????????print(s)

### FIXED CODE ###

(n, m) = [int(i) for i in input().split()]
A = []
b = []
for i in range(n):
    A.append([int(j) for j in input().split()])

for i in range(m):
    b.append(int(input()))

for i in range(n):
    s = 0
    for j in range(m):
        s += A[i][j] * b[j]
    print(s)
a, b = map(int(input().split()))
if a == b:
  print(a + b)
else:
  print(max(a, b) * 2 - 1)

### FIXED CODE ###

# スペース区切りの整数の入力
a, b = map(int, input().split())
# 文字列の入力
s = [2*a-1, 2*b-1, a+b]
# 出力
print("{}".format(max(s)))
s = input()

ans = 0
for i in range(len(s)):
  for j in list(range(len(s)))[::-1]:
    if j < i:
      return ans
    else:
      if s[i] != s[j]:
        ans += 1

### FIXED CODE ###

s = input()
ans = 0
i = 0
j = len(s) - 1
while i <= j:
    if s[i] != s[j]:
        ans += 1
    i += 1
    j -= 1
else:
    print(ans)
s=input()
t=input()
ans=[]
for i in range(len(s)):
  s.insert(0,s.pop())
  s=''.join(s)
  m=[]
  flag=True
  for j in range(len(t)):
    if s[j]=='?' or t[j]==s[j]:
      m.append(t[j])
    else:
      flag=False
      break
  if flag:
    for j in range(len(t),len(s)):
      if s[j]=='?':
        m.append(a)
      else:
        m.append(s[j])
    ans.append(''.join(m))
ans.sort()
print(ans[0])

### FIXED CODE ###

s=input()
t=input()
ans=[]
for i in range(0,len(s)-len(t)+1):
  m=[]
  flag=True
  for p in range(i):
    if s[p]=='?':
      m.append('a')
    else:
      m.append(s[p])
  for q in range(i,len(t)+i):
    if s[q]=='?' or s[q]==t[q-i]:
      m.append(t[q-i])
    else:
      flag=False
      break
  for r in range(len(t)+i,len(s)):
    if flag==False:
      break
    if s[r]=='?':
      m.append('a')
    else:
      m.append(s[r])
  if flag:
    ans.append("".join(m))
ans.sort()
if len(ans)>0:
  print(ans[0])
else:
  print('UNRESTORABLE')
def main():
    x = int(input())

    if (n := int(x ** .2)) ** 5 == x:
        print(n, 0)
        return
    
    for i in range(1, 10000):
        if (n := int((x - i ** 5) ** .2)) ** 5 == (x - i ** 5):
            print(i, -n)
            return
    
    v = (x / 5)

    for i in range(1, 10000):
        fif = x + i ** 5
        if (n := int(fif ** .2)) ** 5 == fif:
            print(fif, i)
            return

main()


### FIXED CODE ###

def main():
    x = int(input())

    _n = int(x ** .2)
    for n in range(_n-2, _n+3):
        if n ** 5 == x:
            print(n, 0)
            return
    
    for i in range(1, 100):
        if x - i ** 5 < 0:
            continue
        _n = int((x - i ** 5) ** .2)
        for n in range(_n-2, _n+3):
            if n ** 5 == (x - i ** 5):
                print(i, -n)
                return
    
    for i in range(1, 1000):
        fif = x + i ** 5
        _n = int(fif ** .2)
        for n in range(_n-2, _n+3):
            if n ** 5 == fif:
                print(n, i)
                return

main()
N = int(input())
S = int(input())
count = 0
for i in range(0,1000):
    num = [i//100, (i//10)%10, i%10]
    digit = 0
    for j in range(N):
        if S[j] == num[digit]:
            digit += 1
        if digit == 3:
            break
    else:
        continue
    count += 1

print(count)

### FIXED CODE ###

def solve():
    N = int(input())
    S = input()
    count = 0
    for i in range(0,1000):
        num = str(i).zfill(3)
        digit = 0
        for j in range(N):
            if S[j] == num[digit]:
                digit += 1
            if digit == 3:
                break
        if digit ==3:
            count += 1

    print(count)

if __name__ == '__main__':
    solve()
N = int(input())
S = ['-1' for _ in range(N+1)]
C = {}
C['AC'] = 0; C['WA'] = 0; C['TLE'] = 0; C['RE'] = 0
for i in range(N):
  S[i+1] = input()
  C[S[i+1]] += 1
for case in ['AC', 'WA', 'TLE', 'RE']:
  print('{} x {}'.format(case,str(C[case])))

### FIXED CODE ###

N = int(input())
if N%1000 == 0:
  print(0)
else:
  print(1000 - N%1000)
import sys

def solve():
    
    while True:
        try:
            n = input()
        
        except EOFError:
            break
        d = sorted(map(int,raw_input().split()))
        for i in range(1,n):
            d[i] += d[i-1]
        print sum(d)
                            
if __name__ == "__main__":
    solve()
    n = raw_input()

### FIXED CODE ###

import sys

def solve():
    
    while True:
        try:
            n = input()        
        except EOFError:
            break
        d = sorted(map(int,raw_input().split()))
        for i in range(1,n):
            d[i] += d[i-1]
        print sum(d)
                            
if __name__ == "__main__":
    solve()
N = int(input())
W = list(map(int, input().split()))
 
sum_W = sum(W)
add_W = 0
 
for i in range(N):
   add_W += W[i]
   if add_W >= sum_W - add_W:
       print(min(abs(add_W - sum_W + add_W), abs(add_W - W[i] - sum_W + add_W - W[i])))
       break

### FIXED CODE ###

i = list(map(int,input().split()));

i.sort();

print(i[0]+i[1]);
x = int(input())

t = int(x**0.2)

for i in range(x):
    t2 = t + i
    d = x - t2 ** 5
    if(d.imag == 0):
        b = int(d**0.2)
        if(b**5 == d):
            print(t2,-d)
            exit()
    t2 = t - i
    d = x - t2 ** 5
    if(d.imag == 0):
        b = int(d**0.2)
        if(b**5 == d):
            print(t2,-d)
            exit()
    


### FIXED CODE ###

x = int(input())


for i in range(-1000,1000):
    s = x + pow(i,5)
    t = pow(s,0.2)
    if(t.imag == 0):
        t = int(t)
        if(pow(t,5) == s):
            print(t,i)
            exit()
A, B, C, K = map(int,input().split())

if K <= A:
    print(A)
elif K <= A+B:
    print(A)
else:
    print(2A+B-K)


### FIXED CODE ###

A, B, C, K = map(int,input().split())

if K <= A:
    print(K)
else:
    cards  = [A, B, C]
    points = [1, 0, -1]
    val = 0
    rem = K
    for i in range(3):
        rem -= cards[i]
        if rem <= 0:
            val += (cards[i] + rem) * points[i]
            break
        else:
            val += cards[i] * points[i]
    print(val)
n,x,t=map(int,input().split())
print((n//x+((n%x)!=0)*t)


### FIXED CODE ###

n,x,t=map(int,input().split())
print((n//x+((n%x)!=0))*t)
H, W, A, B = (int(i) for i in input().split())

#H, W, A, B = (10, 7, 3, 4)
#H, W, A, B = (2, 3, 1, 1)

def mycomb(n, k):
    return factorials[n] / (factorials[k] * factorials[n - k])

MOD = int(1e9 + 7)

factorials = []
factorials.append(1)
for i in range(1, W + H):
    factorials.append(factorials[i - 1] * i)

r = 0
for i in range(H - A):
    combination = mycomb(B-1+i, B-1) * mycomb(W+H-B-i-2, W-B-1)
    r += int(combination % MOD)

print(r)

### FIXED CODE ###

H, W, A, B = (int(i) for i in input().split())

#H, W, A, B = (10, 7, 3, 4)
#H, W, A, B = (2, 3, 1, 1)

def mycomb(n,r):
    return (factorials[n] * pow(factorials[r],MOD-2,MOD) % MOD) * pow(factorials[n-r],MOD-2,MOD) % MOD

MOD = int(1e9 + 7)

factorials = []
factorials.append(1)
for i in range(1, W + H):
    factorials.append((factorials[i - 1] * i) % MOD)

r = 0
for i in range(H - A):
    combination = mycomb(B-1+i, B-1) * mycomb(W+H-B-i-2, W-B-1)
    r += int(combination)

print(r%MOD)
N, R = map(int, input().split())
ans = 0

if N >= 10:
  ans = R
else:
  ans = R + 100*(10 - K)

print(ans)
  

### FIXED CODE ###

K, R = map(int, input().split())
ans = 0
 
if K >= 10:
  ans = R
else:
  ans = R + 100*(10 - K)
 
print(ans)
import math

n, X, D = map(int, input().split())

if D == 0:
	if X == 0:
		print(1)
	else:
		print(N + 1)
	exit()

Y = dict()

for i in range(n + 1):
	b = -2 * i * X
	r = (n - 1 + n - i) * i // 2
	l = (0 + i - 1) * i // 2
	off = b % (-2 * D)
	l += (b - off) // (-2 * D)
	r += (b - off) // (-2 * D)
	if off in Y:
		Y[off].append((l, r))
	else:
		Y[off] = [(l, r)]

def calc(u):
	pt = dict()
	for l, r in u:
		if l in pt:
			pt[l] += 1
		else:
			pt[l] = 1
		if r + 1 in pt:
			pt[r + 1] -= 1
		else:
			pt[r + 1] = -1
	cur, v = -10 ** 100, 0
	ans = 0
	for k in sorted(pt.keys()):
		if v:
			ans += k - cur
		v += pt[k]
		cur = k
	return ans

print(sum(map(calc, Y.values())))


### FIXED CODE ###

import math

n, X, D = map(int, input().split())

if D == 0:
	if X == 0:
		print(1)
	else:
		print(n + 1)
	exit()

Y = dict()

for i in range(n + 1):
	b = -2 * i * X
	r = (n - 1 + n - i) * i // 2
	l = (0 + i - 1) * i // 2
	off = b % (-2 * D)
	l += (b - off) // (-2 * D)
	r += (b - off) // (-2 * D)
	if off in Y:
		Y[off].append((l, r))
	else:
		Y[off] = [(l, r)]

def calc(u):
	pt = dict()
	for l, r in u:
		if l in pt:
			pt[l] += 1
		else:
			pt[l] = 1
		if r + 1 in pt:
			pt[r + 1] -= 1
		else:
			pt[r + 1] = -1
	cur, v = -10 ** 100, 0
	ans = 0
	for k in sorted(pt.keys()):
		if v:
			ans += k - cur
		v += pt[k]
		cur = k
	return ans

print(sum(map(calc, Y.values())))
import sys
input = sys.stdin.readline
def main():
    N, M, K=map(int, input().split())
    friend_or_block = [0] * N
    friends_chain = UnionFindTree(N)

    for _ in range(M):
        a, b = map(int, input().split())
        a, b = a-1, b-1
        friends_chain.unite(a, b)
        friend_or_block[a] += 1
        friend_or_block[b] += 1

    for _ in range(K):
        c, d = map(int, input().split())
        c, d = c-1, d-1
        if friends_chain.same(c, d):
            friend_or_block[c] += 1
            friend_or_block[d] += 1

    print(*[friends_chain.count(i) - friend_or_block[i] - 1 for i in range(N)])

    class UnionFindTree:
        def __init__(self, n):
            self.parent = [-1] * n

        def root(self, x):
            p, s = self.parent[x], list()
            while p >= 0:
                s.append(x)
                x, p = p, self.parent[p]
            for c in s: self.parent[c] = x
            return x

        def same(self, x, y): return self.root(x) == self.root(y)

        def count(self, x): return -self.parent[self.root(x)]

        def unite(self, x, y):
            xr, yr = self.root(x), self.root(y)
            if xr == yr: return
            if self.parent[xr] > self.parent[yr]: xr, yr = yr, xr
            self.parent[xr] += self.parent[yr]
            self.parent[yr] = xr

if __name__ == '__main__':
    main()



### FIXED CODE ###

N,M,K=map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(M)]
CD = [tuple(map(int, input().split())) for _ in range(K)]

def root(x,P):
    l = []
    n = x
    p = P[n]
    while p >= 0:
        l.append(n)
        n = p
        p = P[p]
    for a in l: P[a] = n
    return n

def same(a, b, P): return root(a,P) == root(b,P)

def count(x,P): return -P[root(x,P)]

def unite(a, b, P):
    if count(a,P) < count(b,P): a, b = b, a
    ar = root(a,P)
    br = root(b,P)
    if ar == br: return
    P[ar] += P[br]
    P[br] = ar

Fu = [-1] * N
F = [set() for _ in range(N)]
B = [set() for _ in range(N)]

for a,b in AB:
    a, b = a-1, b-1
    unite(a,b,Fu)
    F[a].add(b)
    F[b].add(a)
for c,d in CD:
    c, d = c-1, d-1
    B[c].add(d)
    B[d].add(c)

for i in range(N):
    block = 0
    for b in B[i]:
        if same(i,b,Fu): block += 1
    print(count(i,Fu) - len(F[i]) - block - 1, end=' ')
import random

def main():
    d = int(d)
    for _ in range(d):
        input()
    for i in range(d):
        random.randint()
        print(random.ranint(1,27))


if __name__ == '__main__':
    main()


### FIXED CODE ###



def main():

    for i in range(365):
        print(10)


if __name__ == '__main__':
    main()
import numpy as np
import math

N, K = map(int, input().split())

if K == 1:
  print(0)
else:
  # N_swp = np.abs(N - K)
  N_swp = math.sqrt((N - K)**2)
  while N_swp != 0 and N_swp < N :
    N = N_swp
    # N_swp = np.abs(N - K)
    N_swp = math.sqrt((N - K)**2)
  print(int(N))


### FIXED CODE ###


N, K = map(int, input().split())

if K == 1:
  print(0)
else:
  a = N % K
  if a > K-a:
    print(K-a)
  else:
    print(a)