Harryxun/stf_run huggingface dataset:
import numpy as np

tmp = list(map(int, input().split()))

N = tmp[0]
K = tmp[1]


# i = N % K

if N < K:
    print(N)
elif N == K:
    print(0)    
else:



    solve = [0] * K

    for i in range(0, K-1):
        solve[i] = N % (K - i)

    solve.reverse()

    for iter in range(0,K-1):
        if solve[iter] == 0:
            continue
        else:
            print(solve[iter])
            break
    print(0)



### FIXED CODE ###

import numpy as np

tmp = list(map(int, input().split()))

N = tmp[0]
K = tmp[1]


# i = N % K


# if N > K:
#     N = N + K

# solve = [0] * (K+1)

# for i in range(0, K-1):
#     solve[i] = N % (K - i)

solve = N % K
if solve > abs(solve - K):
    solve = abs(solve - K)

print(solve)

# solve.reverse()

# for iter in range(0,K-1):
#     if solve[iter] == 0:
#         continue
#     else:
#         print(solve[iter])
#         break
# print(0)
n=int(input())
sp_lis=[]
for i in range(n):
    s,p=input().split()
    sp_lis.append([s,100-p,i+1])
sp_lis.sort()
for j in range(n):
    print(sp_lis[j][2])

### FIXED CODE ###

n=int(input())
sp_lis=[]
for i in range(n):
    s,p=input().split()
    sp_lis.append([s,100-int(p),i+1])
sp_lis.sort()
for j in range(n):
    print(sp_lis[j][2])
x = input())
a = list(map(int, input().split()))
print("%d %d %d"%(min(a), max(a), sum(a)))


### FIXED CODE ###

x = input()
a = list(map(int, input().split()))
print("%d %d %d"%(min(a), max(a), sum(a)))
from collections import defaultdict

table = defaultdict(lambda: 0)

n = int(input())
xylist = []
for _ in range(n):
    x, y = map(int, input().split())
    xylist += [[x, y]]

xylist.sort()

for i in range(n):
    for j in range(0, i):
        x = xylist[i][0] - xylist[j][0]
        y = xylist[i][1] - xylist[j][1]
        table[x+y*10**10] += 1

max_v = max(table.values())
print(n-max_v)

### FIXED CODE ###

from collections import defaultdict

table = defaultdict(lambda: 0)

n = int(input())
if (n==1):
    print(1)
elif n == 2:
    print(1)
else:
    xylist = []
    for _ in range(n):
        x, y = map(int, input().split())
        xylist += [[x, y]]

    xylist.sort()

    for i in range(n):
        for j in range(0, i):
            x = xylist[i][0] - xylist[j][0]
            y = xylist[i][1] - xylist[j][1]
            table[x+y*10**10] += 1

    max_v = max(table.values())
    print(n-max_v)
n,m = list(map(int,input().split()))
counter = 0
data = []
checkd = []
tmp = {}

wa = 0
#入力処理
for i in range(m):
  a,b = input().split()
  if b == "WA":
    if int(a) not in tmp:
      tmp[int(a)] = 0
    tmp[int(a)] += 1  
  elif (( b == "AC") and (tmp[int(a)] != -1)):
    counter += 1
    #checkd.append(int(a))
    if int(a) not in tmp:
      tmp[int(a)] = 0  
    wa += tmp[int(a)]
    tmp[int(a)] = -1


"""
for i in range(m):
  if data[i][1] == "WA":
    if int(data[i][0]) not in tmp:
      tmp[int(data[i][0])] = 0
    tmp[int(data[i][0])] += 1  
  elif ((data[i][1]) == "AC") and (int(data[i][0]) not in checkd):
    counter += 1
    checkd.append(int(data[i][0]))
    if int(data[i][0] ) not in tmp:
      tmp[int(data[i][0])] = 0  
    wa += tmp[int(data[i][0])]
"""    
print(counter,wa)

  
  



### FIXED CODE ###

n,m = list(map(int,input().split()))
counter = 0
data = []
tmp = {}#問題番号をkeyとしてWAをカウント

wa = 0
#入力処理
for _ in range(m):
  a,b = input().split() #入力処理
  if b == "WA": #解答がWA→tmpに問題番号をkeyとしてカウント
    if int(a) not in tmp:
      tmp[int(a)] = 0
    if tmp[int(a)] != -1:
      tmp[int(a)] += 1
  if int(a) not in tmp: #WA無しのACの対応 
    tmp[int(a)] = 0
  if (( b == "AC") and (tmp[int(a)] != -1)):#解答がACでtmp[問題番号]が出力済みでない場合
    counter += 1
    #checkd.append(int(a))
    wa += tmp[int(a)] #問題番号aの値をWAの合計に加算
    tmp[int(a)] = -1 #問題番号aが加算済み


"""
for i in range(m):
  if data[i][1] == "WA":
    if int(data[i][0]) not in tmp:
      tmp[int(data[i][0])] = 0
    tmp[int(data[i][0])] += 1  
  elif ((data[i][1]) == "AC") and (int(data[i][0]) not in checkd):
    counter += 1
    checkd.append(int(data[i][0]))
    if int(data[i][0] ) not in tmp:
      tmp[int(data[i][0])] = 0  
    wa += tmp[int(data[i][0])]
"""    
print(counter,wa)
x,y=map(int,input().split())  
p=(y-2x)/2
if int(p) and 1<=p<=100 :
    print("Yes")
else :
    print("No")

### FIXED CODE ###

x,y=map(int,input().split())  
 
if (y%2==0) and (2*x<=y<=4*x) :
    print("Yes")
else :
    print("No")
N, K = [int(n) for n in input().split()]
S = input()

sentous = []
sentou = 0
counts = [0]
count = 0
prev = 0
for s in S:
    count += 1
    if s == prev and count > 0:
        sentou += 1
    elif s != prev and s == '1':
        sentou += 1
    elif s != prev and s == '0':
        sentous.append(sentou + 1)
        sentou = 0
        if K > 0:
            K -= 1
        else:
            count -= sentous.pop(0)
        counts.append(count)
    prev = s

print(max(*counts, count))


### FIXED CODE ###

N, K = [int(n) for n in input().split()]
S = input()

sentous = []
sentou = 0
counts = [0]
count = 0
prev = 0
for s in S:
    count += 1
    sentou += 1
    if s != prev and s == '1':
        if count > 1:
            sentous.append(sentou - 1)
        sentou = 1
    elif s != prev and s == '0':
        # sentou = 0
        if K > 0:
            K -= 1
        else:
            counts.append(count - 1)
            count -= sentous.pop(0)
    prev = s

print(max(max(counts), count))
n, p = map(int,input().split())
D = input()
count = [0] * p
out = 0

if 10 % p == 0:
    for i, d in enumerate(D):
        if int(d) % p == 0:
            out += i + 1
else:
    ten = 1
    for i in range(n):
        mod = (mod + int(D[n-i-1]) * ten) % p
        count[mod] += 1
        ten *= 10
    print(count)
    for c in count:
        out += (c * (c - 1)) // 2
print(int(out) + count[0])

### FIXED CODE ###

n, p = map(int,input().split())
D = input()
out = 0


if 10 % p == 0:
    for i in range(n):
        if int(D[i]) % p == 0:
            out += i + 1
else:
    mod = 0
    count = [0] * p
    ten = 1
    count[mod] += 1
    for i in range(n):
        mod = (mod + int(D[n-i-1]) * ten) % p
        ten = ten * 10 % p
        count[mod] += 1
    for c in count:
        out += (c * (c - 1)) // 2
print(out)
s = input()

for i in range(s):
  if s[i] % 2 == 0 and s[i] == 'R':
    s = False
    break
  elif s[i] % 2 == 1 and s[i] == 'L':
    s = False
    break

if s:
  print('Yes')
else:
  print('No')
    

### FIXED CODE ###

s = input()

for i in range(len(s)):
  if i % 2 == 1 and s[i] == 'R':
    s = False
    break
  elif i % 2 == 0 and s[i] == 'L':
    s = False
    break

if s:
  print('Yes')
else:
  print('No')
n = int(input())
G = [[] for _ in range(n)]
for _ in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)

dist = [(0,-1) for _ in range(n)]
def dfs(now,prev=-1):
    for nxt in G[now]:
        if nxt == prev: continue
        dist[nxt] = (dist[now][0]+1,now)
        dfs(nxt,now)
dfs(0)

color = ["?"]*n
cnt = 0
now = n-1
w = (dist[n-1][0]+1)//2
while now != -1:
    if cnt < w: color[now] = -1
    else: color[now] = 1
    cnt += 1
    now = dist[now][1]

def coloring(now,prev=-1):
    for nxt in G[now]:
        if nxt == prev: continue
        if color[nxt] != "?" and color[now] != color[nxt]: continue
        color[nxt] = color[now]
        coloring(nxt,now)
coloring(0)
coloring(n-1)
print("Fennec" if sum(color) > 0 else "Snuke")

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000000)

n = int(input())
G = [[] for _ in range(n)]
for _ in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)

dist = [(0,-1) for _ in range(n)]
def dfs(now,prev=-1):
    for nxt in G[now]:
        if nxt == prev: continue
        dist[nxt] = (dist[now][0]+1,now)
        dfs(nxt,now)
dfs(0)

color = ["?"]*n
cnt = 0
now = n-1
w = (dist[n-1][0]+1)//2
while now != -1:
    if cnt < w: color[now] = -1
    else: color[now] = 1
    cnt += 1
    now = dist[now][1]

def coloring(now,prev=-1):
    for nxt in G[now]:
        if nxt == prev: continue
        if color[nxt] != "?" and color[now] != color[nxt]: continue
        color[nxt] = color[now]
        coloring(nxt,now)
coloring(0)
coloring(n-1)

print("Fennec" if sum(color) > 0 else "Snuke")
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, A, *X = map(int, read().split())

    M = sum(X)
    dp = [[0] * (M + 1) for j in range(N + 1)]
    dp[0][0] = 1

    for i in range(N):
        for j in range(N, 0, -1):
            for k in range(X[i], M + 1):
                dp[j][k] += dp[j - 1][k - X[i]]

    ans = 0
    for j in range(1, N + 1):
        ans += dp[j][A * j]

    print(ans)
    return


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, A, *X = map(int, read().split())

    dp = [[0] * (N * 50 + 1) for j in range(N + 1)]
    dp[0][0] = 1

    for i in range(N):
        for j in range(N, -1, -1):
            for k in range(N * 50 + 1):
                if k - X[i] >= 0 and j > 0:
                    dp[j][k] += dp[j - 1][k - X[i]]

    ans = 0
    for j in range(1, N + 1):
        ans += dp[j][A * j]

    print(ans)
    return


if __name__ == '__main__':
    main()
i=int(input())
    i1=i*(i+1)/2
    i2=i//3
    i3=i//5
    i4=i2*(i2+1)/2
    i5=i3*(i3+1)/2
    i6=i//15
    i7=i6*(i6+1)/2
    print(i1-i4-i5+i6)

### FIXED CODE ###

i=int(input())
i1=i*(i+1)//2
i2=i//3
i3=i//5
i4=i2*(i2+1)//2
i5=i3*(i3+1)//2
i6=i//15
i7=i6*(i6+1)//2
print(i1-i4*3-i5*5+i7*15)
m=24*60*60
while True:
	n=int(input())
	if n==0:break
	dp=[0]*(m+1)
	for _ in range(n):
		a,d=input().split()
		a,b,c=map(int,a.split(':'));
		d,e,f=map(int,d.split(':'));
#		dp[a*3600+b*60+c]+=1
#		dp[d*3600+e*60+f]-=1
	for i in range(m):
		dp[i+1]+=dp[i]
	print(max(dp))

### FIXED CODE ###

m=24*60*60
while True:
	n=int(raw_input())
	if n==0:break
	dp=[0]*(m+1)
	for _ in range(n):
		a,d=raw_input().split()
		a,b,c=map(int,a.split(':'));
		d,e,f=map(int,d.split(':'));
		dp[a*3600+b*60+c]+=1
		dp[d*3600+e*60+f]-=1
	for i in range(m):
		dp[i+1]+=dp[i]
	print(max(dp))
coordinates = list(map(int, input().split()))
w = coordinates[0]
h = coordinates[1]
x = coordinates[2]
y = coordinates[3]
if x == w and y == h:
    x = y = 0
prod1 = x * h
prod2 = y * w
area = min(prod1, prod2)
area = format(area, '.6f') if area != 0 else 0
addit = 0 if prod1 != prod2  else 1
print(f"{area} {addit}")

### FIXED CODE ###

w,h,x,y = list(map(int, input().split()))

if((x == w/2 and y == h/2)):
  print((w*h)/2 , 1)
else:
  print((w*h)/2, 0)
N=int(input())
A=list(map(int,input().split()))
t=sum(a)
for i in range(N):
  A[i]=abs(A[i]*N-t)
dif = min(A)
for i in range(N):
  if dif==A[i]:
    print(i)
    break

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
t=sum(A)
for i in range(N):
  A[i]=abs(A[i]*N-t)
dif = min(A)
for i in range(N):
  if dif==A[i]:
    print(i)
    break
import sys
sys.setrecursionlimit(10**6)
import numpy as np
N, K = map(int, input().split())
h = np.array(list(map(int, input().split())))
dp = np.zeros(N,dtype=int)
for i in range(1, N):
    s=max(0, i-k)
    dp[i] = min(dp[s:i]+abs(h[s:i]-h[i]))
print(dp[-1])

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**5)
N = int(input())
h = list(map(int, input().split()))
dp = [-1 for i in range(N)]
def rec(n):
    if dp[n] == -1:
        if n == 0:
            dp[n] = 0
        elif n == 1:
            dp[n] = abs(h[1]-h[0])
        else:
            dp[n] = min(rec(n-2)+abs(h[n]-h[n-2]), rec(n-1)+abs(h[n]-h[n-1]))
    return dp[n]
rec(N-1)
print(dp[N-1])
N=int(input())
h=[]
a=list(map(int,input().split()))
cnt_dic=defaultdict(int)
for i in range(N):
  cnt_dic[a[i]]+=1
cnt_l=sorted(cnt_dic.values(),reverse=True)
ans=len(cnt_l)
tmp=0
for i in range(ans):
  if cnt_l[i]%2==0:
    tmp+=1
if tmp%2==0:
  pass
else:
  ans-=1
print(ans)

### FIXED CODE ###

from collections import defaultdict
N=int(input())
h=[]
a=list(map(int,input().split()))
cnt_dic=defaultdict(int)
for i in range(N):
  cnt_dic[a[i]]+=1
cnt_l=sorted(cnt_dic.values(),reverse=True)
ans=len(cnt_l)
tmp=0
for i in range(ans):
  if cnt_l[i]%2==0:
    tmp+=1
if tmp%2==0:
  pass
else:
  ans-=1
print(ans)
s=input()
n=s.split(" ")[0]
m=s.split(" ")[1]

n=n-1
m=m-1

r=n*m

print(m)

### FIXED CODE ###

s=input()
n=int(s.split(" ")[0])
m=int(s.split(" ")[1])
n=n-1

m=m-1
r=n*m
print(r)
n=int(input())
h=list(map(int,input().split()))
arr=[x for x in h]
cnt=0

while 1:
  for i in range(n):
    if h[i]!=0:
      s=i
      break
  e=s
  for i in range(s,n-1):
    if h[s]<=h[i+1]:
      e+=1
    else:
      break
  h=[h[i]-1 if s<=i<=e else h[i] for i in range(n)]
  cnt+=1
  if all([x==0 for x in h]):
    break
print(cnt)

### FIXED CODE ###

n=int(input())
h=list(map(int,input().split()))
arr=[x for x in h]
cnt=0

while 1:
  if all([x==0 for x in h]):
    break
  for i in range(n):
    if h[i]!=0:
      s=i
      break
  e=s
  for i in range(s,n-1):
    if h[s]<=h[i+1]:
      e+=1
    else:
      break
  h=[h[i]-1 if s<=i<=e else h[i] for i in range(n)]
  cnt+=1
print(cnt)
from itertools import chain

s = input().rstrip()

def f(s):
    l = s.split('01')
    for i in range(len(l)):
        l[i] = l[i].split('10')
    l = list(chain.from_iterable(l))
    if len(l) == 1:
        return 0
    else:
        r = (len(l) - 1) * 2
        return r + f(''.join(l))

print(f(s))

### FIXED CODE ###

s = input().rstrip()

print(2 * min(s.count('0'), s.count('1')))
N, M, X, Y = map(int, input().split())
xlist = input().split() # string
ylist = input().split() # string

def judge(z):
    for i in xlist:
        i = int(i)
        if not i < z:
            return 0
    for j in ylist:
        j = int(j)
        if j < z:
            return 0
        else:
            if str(j) == ylist[-1]:
                print('No War')
                sys.exit()

for z in range(X+1, Y+1):
    judge(z)
    if z == Y-1:
        print('War')

### FIXED CODE ###

import sys
N, M, X, Y = map(int, input().split())
xlist = input().split() # string
ylist = input().split() # string

#intXlist = intYlist = []
intXlist = []
intYlist = []
for i in xlist:
    intXlist.append(int(i))
#intXlist.append(X)
for i in ylist:
    intYlist.append(int(i))
#intYlist.append(Y)

# print(max(intXlist))
# print(min(intYlist))

# mx = max(intXlist)
# my = min(intYlist)

# for z in range(X+1, Y+1):
#     return my <= mx:
#         print('No War')
#         sys.exit()
#     else:
#         continue
# print('War')


def judge(z):
    try:
        for i in xlist:
            i = int(i)
            if not i < z:
                return 0
            else:
                continue
        for j in ylist:
            j = int(j)
            if j < z:
                return 0
            else:
                if str(j) == ylist[-1]:
                    #print(z)
                    print('No War')
                    sys.exit()
    except Exception as e:
        print(e)
for z in range(X+1, Y+1):
    judge(z)
    if z == Y:
        print('War')
n,m=map(int,input().split())
lis=[i for i in range(1,n+1)]
for i in range(m):
    d=int(input())
    for j in range(d):
        a=int(input())
        if a in lis:
            lis.remove(a)
print(len(lis))

### FIXED CODE ###

n,m=map(int,input().split())
lis=[i for i in range(1,n+1)]
for i in range(m):
    d=int(input())
    a=list(map(int,input().split()))
    for j in range(d):
        if a[j] in lis:
            lis.remove(a[j])
print(len(lis))
S = list(input())
r = S[0]
for i in range(4)
 S.remove(r)
if S[0] == S[1] and len(S) == 2:
 print('Yes')
else:
 print('NO')

### FIXED CODE ###

S = set(input())
print('Yes' if len(S) == 2 else 'No')
n = int(input())
task = [int(j) for j in input().split()]

for i in range(n):
    task.append([int(j) for j in input().split()])

task.sort(key = lambda x:x[1])

### FIXED CODE ###

n = int(input())
task = []

for i in range(n):
    task.append([int(j) for j in input().split()])

task.sort(key = lambda x:x[1])

ans = "Yes"
cur = 0
remaining = 0
for i in task:
    remaining += i[1] - cur - i[0]
    if remaining < 0:
        ans = "No"
        break
    cur = i[1]

print(ans)
n = int(input())
alist = list(map(int, input().split(" ")))

result = 1
m = 0
while result <= 10**18:
  result *= alist[m]
  m += 1

if m < n or result > 10**18:
  print("-1")
else:
  print(result)

### FIXED CODE ###

n = int(input())
alist = list(map(int, input().split(" ")))

if 0 in alist:
  print("0")
else:
  result = 1
  m = 0
  while result <= 10**18 and m < n:
    result *= alist[m]
    m += 1
  if m < n or result > 10**18:
    print("-1")
  else:
    print(result)
N = int(input())
A = [list(map(int,input().split())) for _ in range(N)]
C = {}
for i in range(N):
    a,b = A[i]
    if a not in C:
        C[a] = 0
    C[a] += 1
    if b not in C:
        C[b] = 0
    C[b] += 1
C = sorted(list(C.keys()))
if N%2==1:
    k = (N+1)//2
    a = C[k-2]
    b = C[-(k-1)]
    print(b-a+1)
else:
    k = N//2
    a = C[k-2]
    a1 = C[k-1]
    b = C[-(k-1)]
    b1 = C[-(k-1)-1]
    print(b+b1-a-a1+1)
    

### FIXED CODE ###

N = int(input())
X = [list(map(int,input().split())) for _ in range(N)]
A = sorted([X[i][0] for i in range(N)])
B = sorted([X[i][1] for i in range(N)])
if N%2==1:
    k = (N+1)//2
    a = A[k-1]
    b = B[k-1]
    print(b-a+1)
else:
    a2 = A[N//2-1]+A[N//2]
    b2 = B[N//2-1]+B[N//2]
    print(b2-a2+1)
a,b=map(int,input().split())
for i in range(2*a-1)
 print(b-a+i+1)
 print(' ')

### FIXED CODE ###

a,b=map(int,input().split())
for i in range(2*a-1):
 print(b-a+i+1)
 print(' ')
N,T = map(int,input().split())
dic = {}
for i in range(N):
    dic[int(input())] = int(input())
L = sorted(dic.dict_keys)
for i in range(N):
    if dic[i] <T:
        print(L[i])
        break
print("TLE")

### FIXED CODE ###

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

ct = [list(map(int,input().split())) for i in range(N)]

c = []
t = []

for i in range(N):
    c.append(ct[i][0])
    t.append(ct[i][1])

minc = 10000

for i in range(len(c)):
    if t[i] <= T and c[i] < minc:
        minc = c[i]

if minc == 10000:
    print("TLE")
else:
    print(minc)
X = int(input())
for A in range(201):
  for B in range(A):
    if A ** 5 - B ** 5 == X:
      Ans = [A, B]
      break
      
print(Ans.split())

### FIXED CODE ###

X = int(input())
Ans = []
for A in range(201):
  for B in range(A):
    if A ** 5 - B ** 5 == X:
      Ans = [A, B]
    if A ** 5 + B ** 5 == X:
      Ans = [A, B * (-1)]
      break
      
print(Ans[0], Ans[1])
n, k = map(int, input().split())
p = list(map(int, input().split()))

p_sum = [0] * (n + 1)

for i in range(1, n + 1):
    p_sum[i] = p_sum[i - 1] + p[i]

ans = 0
for i in range(-k + 1):
    ans = max(ans, p_sum[i + k] - p_sum[i])

ans = (ans + k) / 2
print(ans)


### FIXED CODE ###

n, k = map(int, input().split())
p = list(map(int, input().split()))

if n != k:
    memo = [0] * (n + 1)

    for i in range(n):
        memo[i] = memo[i - 1] + p[i]

    ans = 0
    for i in range(k, n):
        ans = max(ans, memo[i] - memo[i - k])

    ans = (ans + k) / 2
    print(ans)
else:
    ans = (sum(p) + k) / 2
    print(ans)
N,D = (int(x) for x in input().split())
X = []*N
for i in range(N):
  X[i] = [float(x) for x in input().split()]
count = 0
for i in range(N-1):
  for j in range(i+1,N):
    sq = [(X[i][k]-X[j][k])**2 for k in range(D)]
    if isinstance(sum(sq)**0.5 , int):
      count += 1
print(count)

### FIXED CODE ###

N,D = (int(x) for x in input().split())
X = [None]*N
for i in range(N):
  X[i] = [float(x) for x in input().split()]
count = 0
for i in range(N-1):
  for j in range(i+1,N):
    sq = [(X[i][k]-X[j][k])**2 for k in range(D)]
    dist = sum(sq)**0.5
    if dist == int(dist):
      count += 1
print(count)
import sys
from bisect import bisect
from itertools import accumulate


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    a = sorted(map(int, input().split()))
    b = sorted(map(int, input().split()))
    c = sorted(map(int, input().split()))
    # 各中部パーツを乗せられる下部パーツの個数
    # b_c_cnt = [len(c[bisect(c, b[i]) :]) for i in range(n)]
    b_c_cnt = [0] * n
    past = 0
    for i in range(n):
        pos = bisect(c, b[i], lo=past)
        past = pos
        b_c_cnt[i] = n - pos

    # b_c_cntに後ろから累積和をとる
    acc = list(accumulate(b_c_cnt[::-1]))[::-1]
    ans = 0
    past = 0
    for i in range(n):
        pos = bisect(b, a[i], lo=past)
        ans += acc[pos]
        past = pos
    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
from bisect import bisect
from itertools import accumulate


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    a = sorted(map(int, input().split()))
    b = sorted(map(int, input().split()))
    c = sorted(map(int, input().split()))
    # 各中部パーツを乗せられる下部パーツの個数
    # b_c_cnt = [len(c[bisect(c, b[i]) :]) for i in range(n)]
    b_c_cnt = [0] * n
    past = 0
    for i in range(n):
        pos = bisect(c, b[i], lo=past)
        past = pos
        b_c_cnt[i] = n - pos

    # b_c_cntに後ろから累積和をとる
    acc = list(accumulate(b_c_cnt[::-1]))[::-1] + [0]
    ans = 0
    past = 0
    for i in range(n):
        pos = bisect(b, a[i], lo=past)
        ans += acc[pos]
        past = pos
    print(ans)


if __name__ == "__main__":
    main()
l = []
for i in range(5):
  l.append(input())

ans = 0
if int(l[0][-1]) <= int(l[1][-1]):
  min_val = l[0]
  ans += (-(-int(l[1])//10))*10
else:
  min_val = l[1]
  ans += (-(-int(l[0])//10))*10
  
for i in range(2, 5):
  if min_val[-1] <= int(l[i][-1]):
    ans += (-(-int(l[i])//10))*10
  else:
    ans += (-(-min_val//10))*10
    min_val = l[i]
    
ans += (-(-min_val//10))*10
print(ans)

### FIXED CODE ###

l = []
for i in range(5):
  l.append(input())

ans = 0
min_val = 99
flag = False

for i in range(5):
  if l[i][-1] == "0":
    ans += int(l[i])
  else:
    if int(l[i][-1]) <= int(str(min_val)[-1]):
      if flag:
        ans += (-(-int(min_val)//10))*10
      flag = True
      min_val = l[i]
    else:
      ans += (-(-int(l[i])//10))*10
if flag:
  ans += int(min_val)
print(ans)
N = int(input())
nums = [int(i) for i in input().split()]
from math import gcd
from functools import reduce
def compute_gcd(numbers):
    return reduce(gcd, numbers)
from copy import copy
gcds = []
for i in range(len(nums)):
    n = copy(nums)
    n.pop(i)
    gcds.append(compute_gcd(n))
print(max(gcds))

### FIXED CODE ###

N = int(input())
nums = [int(i) for i in input().split()]
nums_sorted = sorted(list((set(nums))), reverse=True)
def compute_divs(n):
    divs = []
    if n == 1: return [1]
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            divs.append(i)
            if i != n // i:
                divs.append(n//i)
    divs.append(n)
    return divs
ans = 1
if len(nums_sorted) == 1: ans = nums[0]
else:
    divs1 = compute_divs(nums_sorted[0])
    divs2 = compute_divs(nums_sorted[1])
    divs = sorted(list(set(divs1+divs2)))
    for i in reversed(divs):
        c= 0
        for j in nums:
            if j % i != 0:
                c += 1
                if c == 2:
                    break
        if c <= 1:
            ans = i
            break
print(ans)