Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

from  collections import deque
K = int(input())
# 素因数分解
# 戻り値: リスト
def prime_factor(n):
    ass = deque
    for i in range(2,int(n**0.5)+1):
        while n % i==0:
            ass.append(i)
            n = n//i
    if n != 1:
        ass.append(n)
    return ass

# 最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)

ans = 0
d = {}
for a in range(1, K+1):
    for b in range(1, K+1):
        t = (a, b)
        d[t] = gcd(a, b)
for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(1, K+1):
            ab = d[(a, b)]
            ans += d[(ab, c)]
print(ans)

### FIXED CODE ###

from  collections import deque
K = int(input())
# 素因数分解
# 戻り値: リスト
def prime_factor(n):
    ass = deque
    for i in range(2,int(n**0.5)+1):
        while n % i==0:
            ass.append(i)
            n = n//i
    if n != 1:
        ass.append(n)
    return ass

# 最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)

ans = 0
d = {}
for a in range(1, K+1):
    for b in range(1, K+1):
        t = (a, b)
        d[t] = gcd(a, b)
for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(1, K+1):
            ab = d[(a, b)]
            ans += d[(ab, c)]
print(ans)
### BUGGY CODE ###

S = list(input())
Q = int(input())
# L = [input().split() for _ in range(Q)]

count = 0 # ['1']の数
for i in range(Q):
    L = input().split()
    if L[0] == '1':
        count += 1
    if L[0] == '2':
        if (count % 2) == 0:
            if L[1] == '1':
                S = [L[2]] + S
            else:
                S = S + [L[2]]
        else:
            if L[1] == '2':
                S = [L[2]] + S
            else:
                S = S + [L[2]]



# print(L)
if (count % 2) == 0:
    print(''.join(S))
else:
    S.reverse()
    print(''.join(S))

### FIXED CODE ###

s = input()
q = int(input())
query = []
lead = ''
end = ''
inversion_flg = False
 
for j in range(q):
    i = input().split()
    if i[0] == "1":
        if inversion_flg:
            inversion_flg = False 
        else:
            inversion_flg = True
    else:
        if inversion_flg:
            if i[1] == "1":
                i[1] = "2"
            else:
                i[1] = "1"
        if i[1] == "1":
            lead+=i[2]
        else:
            end+=i[2]
 
lead = lead[::-1]
s = lead+s+end
if inversion_flg:
    s = s[::-1]
print(s)
### BUGGY CODE ###

import numpy as np
a = int(raw_input())
Ali = (np.array( map(int,raw_input().split())))
Bli =(np.array(map(int,raw_input().split())))
Cli =(np.array(map(int,raw_input().split())))
Bli = np.sort(Bli)[::-1]
Cli = np.sort(Cli)[::-1]
co=0
for A in Ali:
    for B in Bli:
        if A >= B:
            break
        for C in Cli:
            if B >= C:
                break
            co +=1 
print(co)


### FIXED CODE ###

import bisect
N = int(input())
Alist = list(map(int,input().split()))
Blist = list(map(int,input().split()))
Clist = list(map(int,input().split()))
Alist.sort()
Clist.sort()
retnum = 0 
for i in Blist:
    Anum = bisect.bisect_left(Alist,i)
    Cnum =  N - bisect.bisect_right(Clist,i)
    retnum +=(Anum * Cnum)
print(retnum)
### BUGGY CODE ###

from collections import namedtuple
Item = namedtuple('Item', ['weight', 'value'])
N, W = map(int, input().split())
items = [Item(*map(int, input().split())) for _ in range(N)]
dp = [[0] * (W + 1) for _ in range(N + 1)]
for i, item in enumerate(items, 1):
    for cap in range(1, W + 1):
        if cap - item.weight >= 0:
            dp[i][cap] = max(dp[i - 1][cap],
                             dp[i - 1][cap - item.weight] + item.value)
        else:
            dp[i][cap] = dp[i - 1][cap]
print(dp[-1][-1])

### FIXED CODE ###

import sys
LI = lambda: list(map(int, sys.stdin.readline().split()))
N, W = LI()
dp = [0] * (W + 1)
for weight, value in sorted(LI() for _ in range(N)):
    for w in range(W - weight, -1, -1):
        if dp[w + weight] < dp[w] + value:
            dp[w + weight] = dp[w] + value
print(dp[-1])
### BUGGY CODE ###

s = input()
u = [0]
for i in range(len(s)):
    u.append((u[i]+int(s[::-1][i])*10**i)%2019)
import collections
u2 = collections.Counter(u)
print(sum([int(i*(i-1)/2) for i in u2.values()]))

### FIXED CODE ###

import collections
s = input()
u = collections.deque([0])
for i in range(len(s)):
    u.append((u[i]+int(s[-i-1])*10**(i%224))%2019)
u2 = collections.Counter(u)
sum = 0
for i in u2.values():
    sum += i*(i-1)/2
print(int(sum))
### BUGGY CODE ###

MOD = 998244353
N,M,K = [int(hoge) for hoge in input().split()]
NcK = []
cur = 1#Nc0
for k in range(K+1):
    NcK.append(cur)
    cur *= (N-1-k)
    if k==K:break
    cur //= (k+1)    

ans = 0
def power_func(a,n,p):#a**n mod P
  bi=str(format(n,"b"))#2進表現に
  res=1
  for i in range(len(bi)):
    res=(res*res) %p
    if bi[i]=="1":
      res=(res*a) %p
  return res
for k in range(K+1):
    ans += M * power_func(M-1,N-1-k,MOD) * NcK[k]
    ans %= MOD
print(ans)

### FIXED CODE ###

#互いに素なa,bについて、a*x+b*y=1の一つの解
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

import math
MOD = 998244353
N,M,K = [int(hoge) for hoge in input().split()]
NcK = []
POWER = []
cur = 1#Nc0
for k in range(K+1):
    NcK.append(cur)
    cur *= (N-1-k)* mod_inv(k+1,MOD)
    cur %= MOD    

ans = 0
Power = 1
for k in range(N-1-K):#M-1**n-1-K
    Power *= M-1
    Power %= MOD

for k in range(K,-1,-1):
    ans += Power * NcK[k]
        #M-1 ** N-1-k ということは…？
    if k:
        Power *= M-1
        Power %= MOD
    

print((M*ans)%MOD)
### BUGGY CODE ###

from collections import deque

H, W = map(int, input().split())
score = H * W
S = [[] for i in range(H)]
for i in range(H):
    for s in input():
        if s == "#":
            score -= 1
        S[i].append(s)


ls = deque([[0, 0, 0]])
dir = [[1,0], [-1,0], [0,1], [0,-1]]
while len(ls) > 0:
    x, y, depth = ls.popleft()

    if x == H-1 and y == W-1:
        print(score-depth-1)
        break
    
    S[x][y] = "#"

    for dx, dy in dir:
        if (x+dx < 0) or (x+dx > H-1) or (y+dy < 0) or (y+dy > W-1):
            continue
        else:
            if S[x+dx][y+dy] == ".":
                ls.append([x+dx, y+dy, depth+1])

else:
    print(-1)

### FIXED CODE ###

from collections import deque

H, W = map(int, input().split())
score = H * W
S = [[] for i in range(H)]
for i in range(H):
    for s in input():
        if s == "#":
            score -= 1
        S[i].append(s)


ls = deque([[0, 0]])
dir = [[1,0], [-1,0], [0,1], [0,-1]]
dp = [[float("inf") for i in range(W)] for j in range(H)]
dp[0][0] = 0
while len(ls) > 0:
    x, y = ls.popleft()

    if x == H-1 and y == W-1:
        print(score-dp[H-1][W-1]-1)
        break

    for dx, dy in dir:
        if (x+dx < 0) or (x+dx > H-1) or (y+dy < 0) or (y+dy > W-1):
            continue
        else:
            if S[x+dx][y+dy] == "." and dp[x][y]+1 < dp[x+dx][y+dy]:
                dp[x+dx][y+dy] = dp[x][y] + 1
                ls.append([x+dx, y+dy])

else:
    print(-1)
### BUGGY CODE ###

N = int(input())
a = list(map(int, input().split()))

s = [a.index(i)+1 for i in range(1, N+1)]

result = " ".join(map(str, s))
print(result)


### FIXED CODE ###


N = int(input())
a = list(map(int, input().split()))
s = [-1]
s.extend(0 for _ in range(N))

for i, item in enumerate(a):
    s[item] = i+1

result = " ".join(map(str, s[1:]))
print(result)
### BUGGY CODE ###

n = int(input())

S = 0
for i in range(200001):
    S += n % 10
    n //= 10
    if n == 0:
        break

if S % 9 == 0:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

n = input()

S = 0
for i in range(len(n)):
    S += int(n[i])

if S % 9 == 0:
    print("Yes")
else:
    print("No")
### BUGGY CODE ###

import sys
input = sys.stdin.readline
N , W = map(int , input().split())
weight = []
value = []
for _ in range(N):
    w , v = map(int , input().split())
    weight.append(w)
    value.append(v)

def knapsack():
    dp = [[-1] * (W + 1) for _ in range(N + 1)]
    def solve(i,w):
        if dp[i][w] != -1:
            return dp[i][w]
        if N == i:
            ret_val = 0
        elif w - weight[i] < 0:
            ret_val = solve(i + 1,w)
        else:
            ret_val = max(solve(i + 1, w), solve(i + 1,w - weight[i]) + value[i])
        dp[i][w] = ret_val
        return ret_val
    ans = solve(0,W)
    #print(dp)
    return ans

if __name__ == "__main__":
    print(knapsack())


### FIXED CODE ###

import numpy as np
N , W = map(int, input().split())
goods = np.array([list(map(int , input().split())) for _ in range(N)])
dp = np.zeros((N + 1 , W + 1) , dtype = np.int)

for i in range(0,N):
    w, v = goods[i,:]
    dp[i + 1, w:] = np.maximum(dp[i,w:] , dp[i,:-w] + v)
    dp[i + 1, :] = np.maximum(dp[i + 1,:],dp[i,:])
print(int(dp[N,W]))
### BUGGY CODE ###

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

while True:
    nokori=K
    maisu1=0
    maisu2=0
    maisu3=0
    if A<=nokori:
        maisu1=A
        nokori=nokori-maisu1
    else:
        maisu1=nokori
        break

    if B<=nokori:
        maisu2=B
        nokori=nokori-maisu2
    else:
        maisu2=nokori
        break
    
    maisu3=nokori

print(maisu1-maisu3)

### FIXED CODE ###

A,B,C,K=list(map(int,input().split()))
nokori=K
maisu1=0
maisu2=0
maisu3=0
while True:
    if A<=nokori:
        maisu1=A
        nokori=nokori-maisu1
    else:
        maisu1=nokori
        break

    if B<=nokori:
        maisu2=B
        nokori=nokori-maisu2
    else:
        maisu2=nokori
        break
    
    maisu3=nokori
    break

print(maisu1-maisu3)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
from collections import  deque
def inpl(): return tuple(map(int, input().split()))
 
N, M = inpl()
 
adj = [[] for _ in range(N+1)]  
 
for _ in range(M):
    l, r, d = inpl()
    adj[l].append([r, d])
    adj[r].append([l, -d])
 
X = [-1 for _ in range(N+1)]
searched = [False for _ in range(N+1)]
S = 0 # == sum(searched)
res = True
g = 1
Q = deque([])
while True:
    if S >= N:
        break
    g = g + searched[g:].index(False)
    X[g] = 0
    Q.append(g)
    searched[g] = True
    S += 1
    while Q:
        p = Q.popleft()
        for np, d in adj[p]:
            if searched[np]:
                if X[np] != X[p] + d:
                    Q = []
                    res = False
                    break
            else:
                X[np] = X[p] + d
                Q.append(np)
                searched[np] = True
                S += 1
    if not res:
        break
 
if res:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10000)
from collections import defaultdict, deque
def inpl(): return tuple(map(int, input().split()))
 
N, M = inpl()
Q = [inpl() for _ in range(M)]
# グループごとにトポロジカルソートをして、最後の方から遡って計算
 
tree = [[-1, 1]  for _ in range(N+1)] # [next, rank]
  
def find(i):
    if tree[i][0] == -1:
        group = i
    else:
        group = find(tree[i][0]) 
        tree[i][0] = group
    return group
  
def unite(x, y):
    px = find(x)
    py = find(y)
      
    if tree[px][1] == tree[py][1]: # rank is same
        tree[py][0] = px
        tree[px][1] += 1
    else:
        if tree[px][1] < tree[py][1]:
            px, py = py, px
        tree[py][0] = px
 
adj = [[] for _ in range(N+1)]  
 
for l, r, d in Q:
    if find(l) != find(r):
        unite(l, r)
    adj[l].append([r, d])
    adj[r].append([l, -d])
 
 
G = set([find(n) for n in range(1, N+1)])
 
X = [-1 for _ in range(N+1)]
searched = [False for _ in range(N+1)]
res = True
 
for g in G:
    X[g] = 0
    Q = deque([g])
    searched[g] = True
    while Q:
        p = Q.popleft()
        for np, d in adj[p]:
            if searched[np]:
                if X[np] != X[p] + d:
                    Q = []
                    res = False
                    break
            else:
                X[np] = X[p] + d
                Q.append(np)
                searched[np] = True
    if not res:
        break
 
if res:
    print("Yes")
else:
    print("No")
### BUGGY CODE ###

h, w = map(int, input().split())
S = [list(input()) for _ in range(h)]

def calc(s):
    res = []
    for v in s:
        v.append('-')
        tmp = []
        nc = v[0]
        nn = 0
        for c in v:
            if nc == c:
                nn += 1
                continue
            else:
                if nc == '#':
                    tmp.extend([0 for _ in range(nn)])
                else:
                    tmp.extend( [nn for _ in range(nn)])
                nc = c
                nn = 1
        res.append(tmp)
    return res

def calc2(s):
    res = []
    for j in range(w):
        tmp = []
        nc = s[0][j]
        nn = 0
        for i in range(h+1):
            if i == h:
                c = '-'
            else:
                c = s[i][j]
            if nc == c:
                nn += 1
                continue
            else:
                if nc == '#':
                    tmp.extend([0 for _ in range(nn)])
                else:
                    tmp.extend( [nn for _ in range(nn)])
                nc = c
                nn = 1
        res.append(tmp)
    return res

tate = calc2(S)
yoko = calc(S)

print(max([tate[j][i] + yoko[i][j] for i in range(h) for j in range(w) if tate[j][i] * yoko[i][j] != 0]) - 1)


### FIXED CODE ###

h, w = map(int, input().split())
S = [input() for _ in range(h)]

def calc(s):
    res = []
    for v in s:
        v = v + '-'
        tmp = []
        nc = v[0]
        nn = 0
        for c in v:
            if nc == c:
                nn += 1
                continue
            else:
                if nc == '#':
                    tmp.extend([0 for _ in range(nn)])
                else:
                    tmp.extend( [nn for _ in range(nn)])
                nc = c
                nn = 1
        res.append(tmp)
    return res

def calc2(s):
    res = []
    for j in range(w):
        tmp = []
        nc = s[0][j]
        nn = 0
        for i in range(h):
            c = s[i][j]
            if nc == c:
                nn += 1
                continue
            else:
                if nc == '#':
                    tmp.extend([0 for _ in range(nn)])
                else:
                    tmp.extend( [nn for _ in range(nn)])
                nc = c
                nn = 1
        if nc == '#':
            tmp.extend([0 for _ in range(nn)])
        else:
            tmp.extend( [nn for _ in range(nn)])
        res.append(tmp)
    return res

tate = calc2(S)
yoko = calc(S)

print(max([tate[j][i] + yoko[i][j] for i in range(h) for j in range(w) if tate[j][i] * yoko[i][j] != 0]) - 1)
### BUGGY CODE ###

n = int(input())
s = input()

c = 0

for k in range(n):
    for j in range(k):
        if s[j] != s[k]:
            for i in range(j):
                if (k-j) != (j-i):
                    if s[i] != s[j] and s[i] != s[k]:
                        c += 1

print(c)

### FIXED CODE ###

n = int(input())
s = list(input())

r = s.count('R')
g = s.count('G')
b = s.count('B')

# 1つ目の条件を満たす組の数
ans = r * g * b

# 2つ目の条件を満たす組の数
c = 0
for i in range(n):
    for j in range(i+1,n):
        k = 2 * j -i
        if k > n-1:
            break
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            c += 1

print(ans - c)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
cnt = 0
for i in range(len(a)):
    for j in range(len(a)):
        if i == j:
            pass
        elif a[i] % a[j] == 0:
            break
        if j == len(a) - 1:
            cnt += 1
print(cnt)

### FIXED CODE ###

import numpy as np

n = int(input())
a = list(map(int, input().split()))
a_max = max(a)
lst = [0] * (a_max + 1)
cnt = 0
# if len(a) <= 1:
#     print(0)
# else:
for i in a:
    if lst[i] > 1:  # 配列中のカウントが2以上なら以降の処理を省略
        continue
    for j in range(a_max // i + 1):  # Aiの倍数にインクリメント(配列の上限はa[-1])
        lst[i * j] += 1
    # lst[1::i] += 1
for i in a:
    if lst[i] == 1:
        cnt += 1
print(cnt)
### BUGGY CODE ###

# coding: utf-8

import sys
input = sys.stdin.readline

def f(n, k):
    global a
    mod = int(1e9 + 7)
    dp = [[0] * (k + 1) for _ in range(n + 1)]
    for i in range(n + 1):
        dp[i][0] = 1
    for i in range(1, n + 1):
        # csum: Cumulative sum
        # csum[j + 1] = dp[i-1][0] + dp[i-1][1] + ... + dp[i-1][j]
        csum = [0] + list(dp[i - 1])
        for j in range(k + 1):
            csum[j + 1] += csum[j]
            csum[j + 1] %= mod
        dpi = dp[i]
        for j in range(1, k + 1):
            dpi[j] = csum[j + 1] - csum[max(0, j - a[i])]
            if dpi[j] < 0:
                dpi[j] += mod
    return(dp[n][k])

n, k = map(int, input().split()) # 1 <= n <= 100, 0 <= k <= 10^5
a = list(map(int, input().split()))
a.insert(0, 0)
print(f(n, k))


### FIXED CODE ###

# coding: utf-8

from itertools import accumulate as accum
import sys
input = sys.stdin.readline

def f(n, k, ai):
    mod = int(1e9 + 7)
    dp = [0] * (k + 1)
    dp[0] = 1
    for a in ai:
        # csum: Cumulative sum
        # dp[j] = dp[0] + dp[1] + ... + dp[j]
        # dp = list(accum(dp, lambda x, y: (x + y) % mod))
        dp = list(accum(dp))
        # j = 0 ～ a[i] までは累積和の結果そのままで a[i] + 1 以降は
        # dp[j] -= dp[j] - dp[j - a[i] - 1]
        dp[a + 1:] = [x - y for x, y in zip(dp[a + 1:], dp)]
        dp = [x % mod for x in dp]
    return(dp[k])

n, k = map(int, input().split()) # 1 <= n <= 100, 0 <= k <= 10^5
a = list(map(int, input().split()))
print(f(n, k, a))
### BUGGY CODE ###

n,k=map(int,input().split())
x,y=[[0,0] for i in range(n)],[[0,0] for i in range(n)]
xy=[list(map(int,input().split())) for i in range(n)]
for i in range(n):
    x_sub,y_sub=xy[i]
    x[i][0]=x_sub
    x[i][1]=i
    y[i][0]=y_sub
    y[i][1]=i
x.sort()
y.sort()
w=[[(i1,l1) for l1 in range(n-i1,1,-1)] for i1 in range(n)]
v=[[(i2,l2) for l2 in range(n-i2,1,-1)] for i2 in range(n)]
#print(w)
#print(v)
ans=(10**18)*5
for w_sub in w:
    for v_sub in v:
        for i1l1 in w_sub:
            for i2l2 in v_sub:
                i1,l1=i1l1
                i2,l2=i2l2
                if l1*l2<k:
                    continue
                x_sub1=x[i1][0]
                x_sub2=x[i1+l1-1][0]
                y_sub1=y[i2][0]
                y_sub2=y[i2+l2-1][0]
                z=[0]*n
                for i in range(n):
                    if x_sub1<=xy[i][0]<=x_sub2 and y_sub1<=xy[i][1]<=y_sub2:
                        z[i]=1
                if sum(z)>=k:
                    ans=min((x_sub2-x_sub1)*(y_sub2-y_sub1),ans)
print(ans)


### FIXED CODE ###

n,k=map(int,input().split())
x,y=[[0,0] for i in range(n)],[[0,0] for i in range(n)]
xy=[list(map(int,input().split())) for i in range(n)]
for i in range(n):
    x_sub,y_sub=xy[i]
    x[i][0]=x_sub
    x[i][1]=i
    y[i][0]=y_sub
    y[i][1]=i
x.sort()
y.sort()
ans=(10**18)*5
for i1 in range(n):
    for l1 in range(n-i1,1,-1):
        for i2 in range(n):
            for l2 in range(n-i2,1,-1):
                x_sub1=x[i1][0]
                x_sub2=x[i1+l1-1][0]
                y_sub1=y[i2][0]
                y_sub2=y[i2+l2-1][0]
                z=[0]*n
                for i in range(n):
                    if x_sub1<=xy[i][0]<=x_sub2 and y_sub1<=xy[i][1]<=y_sub2:
                        z[i]=1
                if sum(z)>=k:
                    ans=min((x_sub2-x_sub1)*(y_sub2-y_sub1),ans)
                else:
                    break
print(ans)
### BUGGY CODE ###

N = int(input())
a_list = list(map(int,input().split()))

from collections import Counter
a_dict = Counter(a_list)

start = a_list[0]
# 数を減らさない。
# a_dict[a] -= 1

a_keys = a_dict.keys()

def check():
    for a1 in a_keys:
#         print("for1",start,a1)
        a0 = start
        tmp_dict = a_dict.copy()
#         tmp_dict[a1] -= 1
        for i in range(N):
#             print(" for2",i,a0,a1)
#             print(tmp_dict)
            next_a = int(bin(a0^a1), 0)
            if not next_a in tmp_dict:
#                 print(next_a," not in dict")
                break
            if tmp_dict[next_a] <= 0:
#                 print(next_a," dict 0")
                break
            a0 = a1
            a1 = next_a
            tmp_dict[next_a] -= 1
            if i == N-1:
                return True
    return False

if check():
    print("Yes")
else:
    print("No")

### FIXED CODE ###

from collections import Counter
N = int(input())
a_list = list(map(int,input().split()))

l = len(set(a_list))

def check():
    counter = Counter(a_list)
    if l == 1:
        if a_list[0] == 0:
            return True
        return False
    if l == 2:
        if counter[0] == N/3:
            return True
        return False
    if l == 3:
        x,y,z = set(a_list)
        if int(bin(x^y^z), 0) == 0 and set(list(counter.values()))==set([N/3]):
            return True
        return False
    return False

if check():
    print("Yes")
else:
    print("No")
### BUGGY CODE ###

#また、50ぷんはかかった、しかもTLE
#マジで死にたくなってくる
import copy
import fractions
from functools import reduce

n=int(input())
#この方法だと、参照型なので全部変えられてしまう
#a1=[[int(i) for i in input().split()]]*n
a1=[int(i) for i in input().split()]
a2=[[a1[j] for j in range(n) if i!=j] for i in range(n)]
#print(a2)
#高階関数reduce
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

#def gcd_list(numbers):
#    nul = numbers[0]
#    for i in range(1, len(numbers)):
#        nul = fractions.gcd(nul, numbers[i])
#    return nul

c=1

for i in range(n):
    c=max([c,gcd_list(a2[i])])
print(c)



### FIXED CODE ###

import fractions
from functools import reduce

n=int(input())
a1=[int(i) for i in input().split()]
a2=[]
a3=[]
nul2 = a1[0]
nul3 = a1[-1]
a2.append(nul2)
a3.append(nul3)
#nが2以上?
for i in range(1,n-1):
    nul2=fractions.gcd(nul2,a1[i])
    nul3=fractions.gcd(nul3,a1[-i-1])
    a2.append(nul2)
    a3.append(nul3)
#print(a2)
#print(a3)
c=max([a2[-1],a3[-1]])
for i in range(n-2):
    d=fractions.gcd(a2[i],a3[-i-2])
    if d>c:
        c=d
print(c)
### BUGGY CODE ###

import math
a, b, n = map(int, input().split())
ans = 0
c = min(b, n)
for i in range(1, c+1):
    ans = max(ans, math.floor(a/b*i) - a * math.floor(i/b))
print(ans)

### FIXED CODE ###

import math
a, b, n = map(int, input().split())
if b - 1 <= n:
    print(math.floor(a/b*(b-1)) - a * math.floor((b-1)/b))
else:
    print(math.floor(a/b*n) - a * math.floor(n/b))
### BUGGY CODE ###

s = input().split()

A = int(s[0])
B = int(s[1])
N = int(s[2])

result = 0

start = N - (N // B) * B

for x in range(start, N+1):
  y = (A*x)//B - A*(x//B)
  if y > result:
    result = y
    
print(result)  

### FIXED CODE ###

s = input().split()

A = int(s[0])
B = int(s[1])
N = int(s[2])

result = 0

n = (N // B) * B - 1
if (n < 0):
  n = 0

a = (A*N)//B - A*(N//B)
b = (A*n)//B - A*(n//B)
"""
for x in range(N+1):
  y = (A*x)//B - A*(x//B)
  if y > result:
    result = y
"""
    
if (a > b):
  result = a
else:
  result = b
print(result)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
x = 1

for i in range(N):
  x = x * A[i]
  
if x > 10**18:
  print(-1)
else:
  print(x)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
x = 1

for i in range(N):
  if A[i] == 0:
    print(0)
    exit()  
 
for i in range(N):
  x = x * A[i]
  if x > 10**18:
    print(-1)
    exit()
  
print(x)
### BUGGY CODE ###

from bisect import bisect_left

N = int(input())
A, B, C = (sorted([int(i) for i in input().split()]) for _ in range(3))

result = 0
for c in C:
    i = bisect_left(B, c)
    for b in B[:i]:
        j = bisect_left(A, b)
        result += j

print(result)

### FIXED CODE ###

from bisect import bisect_left, bisect_right

N = int(input())
A, B, C = (sorted([int(i) for i in input().split()]) for _ in range(3))

print(sum(bisect_left(A, b) * (N - bisect_right(C, b)) for b in B))
### BUGGY CODE ###

N, K = map(int, input().split())
temp = N
while True:
    if temp < abs(temp - K):
        break
    temp -= K
print(abs(temp))

### FIXED CODE ###

N, K = map(int, input().split())
t = N % K
print(min(K-t, t))