Harryxun/stf_run huggingface dataset:
import sys
def input(itr=iter(sys.stdin.readlines())):  # pylint: disable= redefined-builtin
    return next(itr).rstrip('\n\r')
###############################################################################

import collections
import math as m
from fractions import Fraction

MOD = 1000000007

N = int(input())
Sardine = collections.namedtuple("Sardine", "A B")
sardines = [Sardine(*map(int, input().split())) for _ in range(N)]

def slope(sardine):
    if sardine.A == sardine.B == 0:
        return None
    elif sardine.B == 0:
        return m.inf
    else:
        return Fraction(sardine.A, sardine.B)

def perpendicular(slope):
    if slope == 0:
        return m.inf
    elif slope == m.inf:
        return 0
    else:
        return -1 / slope

groups = collections.Counter(slope(s) for s in sardines)
if groups[None]:
    zeroes = groups[None]
    del groups[None]
else:
    zeroes = 0

ways = 1
while groups:
    slope, count = groups.popitem()
    perp_slope = perpendicular(slope)
    perp_count = groups[perp_slope]

    ways *= (pow(2, count, MOD) + pow(2, perp_count, MOD) - 1) % MOD
    ways %= MOD

    del groups[perp_slope]

output = (ways-1 + zeroes) % MOD
print(output)


### FIXED CODE ###

counters = {
    'hon': {2, 4, 5, 7, 9},
    'pon': {0, 1, 6, 8},
    'bon': {3},
}

N = input()
for k, v in counters.items():
    if int(str(N)[-1]) in v:
        print(k)
        break
s = input()
l = len(s)
set_s = set(s)

if l == 4 and len(a) == 2:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

s = input()
l = len(s)
set_s = set(s)

if l == 4 and len(set_s) == 2:
    print('Yes')
else:
    print('No')
N, K = map(int, raw_input())
hs = list(map(int, raw_input().split()))
print sum(1 for h in hs if h >= K)


### FIXED CODE ###

N, K = map(int, raw_input().split())
hs = map(int, raw_input().split())
print sum(1 for h in hs if h >= K)
def multiple_factors(i, N):
  factors = []
  factors.append(int(1*i))
  for index in range(1, N//i):
    factors.append(int(index*i))
  return factors
  
def assign_ball(factors, blist, ai, b_add_index):
  sum_b = 0
  for index in range(len(factors)-1, 0, -1):
    sum_b += blist[factors[index]-1]
  
  if ai != sum_b%2:
    blist[factors[index]-1] =1
    b_add_index.append(str(factors[index]))
  return blist, b_add_index

      
N = int(input())
alist = list(map(int, input().split()))
blist = [0 for i in range(N)]
M = 0
b_add_index = []
for i in range(N-1,-1, -1):
  factors = multiple_factors(i+1, N)
  blist, b_add_index = assign_ball(factors, blist, alist[i], b_add_index)

if sum(blist)%2 != alist[0]:
  print(-1)
else:
  print(len(b_add_index))
  print(" ".join(b_add_index))

### FIXED CODE ###

def multiple_factors(i, N):
  factors = []
  for index in range(0, N//i):
    factors.append(int((index+1)*i))
  return factors
  
def assign_ball(factors, blist, ai, b_add_index):
  sum_b = 0
  for index in range(len(factors)-1, 0, -1):
    sum_b += blist[factors[index]-1]
  
  if ai != sum_b%2:
    blist[factors[0]-1] = 1
    b_add_index.append(str(factors[0]))
  return blist, b_add_index

      
N = int(input())
alist = list(map(int, input().split()))
blist = [0 for i in range(N)]
b_add_index = []
for i in range(N-1,-1, -1):
  factors = multiple_factors(i+1, N)
  blist, b_add_index = assign_ball(factors, blist, alist[i], b_add_index)

if sum(blist)%2 != alist[0]:
  print(-1)
else:
  print(len(b_add_index))
  print(" ".join(b_add_index))
[a,b] = list(map(str,input().split()))
b.rstrip(".")
print((a*b)//100)


### FIXED CODE ###

[a,b] = list(map(str,input().split()))
b = b[:1] + b[2:]
print((int(a)*int(b))//100)
s = input()
print( s ** 3)



### FIXED CODE ###

s = int(input())
print(s**3)
a = int(imput)
print(a(1+a(1+a)))

### FIXED CODE ###

a = int(input())
print(a+a**2+a**3)
n,q = map(int, input().split())
str = input()
for i in range(q):
  l,r = map(int, input().split())
  sub_str = str[(l-1):r]
  count = 0
  for j in range(len(sub_str)):
    if (sub_str[j:j+2] == 'AC'):
      count += 1
  print(count)

### FIXED CODE ###

b = input()
 
if (b == 'A'):
  print('T')
elif (b == 'T'):
  print('A')
elif (b == 'C'):
  print('G')
elif (b == 'G'):
  print('C')
#値の入力
A1 = int(input("A1:"))
A2 = int(input("A2:"))
A3 = int(input("A3:"))

#入力値の判定
if(1 > A1 or A1 > 13):
    print("もう一度入力して下さい")
    A1 = int(input("A1:"))
if(1 >A2 or A2 > 13):
    print("もう一度入力して下さい")
    A2 = int(input("A2:"))
if(1 > A3 or A3 > 13):
    print("もう一度入力して下さい")
    A3 = int(input("A3:"))

#判定
if(A1+ A2+ A3 >= 22):
    print("bust")
else:
    print("win")


### FIXED CODE ###

#値の入力
A1, A2, A3 = map(int, input(). split()) 

#値が範囲内か
if 1 > A1 or A1 > 13:
    print("もう一度入力して下さい")
    A1 = int(input("A1:"))
if 1 >A2 or A2 > 13:
    print("もう一度入力して下さい")
    A2 = int(input("A2:"))
if 1 > A3 or A3 > 13:
    print("もう一度入力して下さい")
    A3 = int(input("A3:"))

#判定
if(A1+ A2+ A3 >= 22):
    print("bust")
else:
    print("win")
print (r*r)


### FIXED CODE ###


r = int(input())
print (r*r)
N,K=map(int,input().split())
TD=[[int(j) for j in input().split()] for i in range(N)]
TD=sorted(TD,key=lambda x:-x[1])
point=0
stack=[]
kind=set()
for t,d in TD[:K]:
    point+=d
    if t in kind:stack.append(d)
    else:kind.add(t)
ans1=delicious+len(kind)**2
ans2=ans1
for t,d in TD[K:]:
    if not stack:break
    if not t in kind:
        ans2+=d-stack.pop()+2*len(kind)+1
        kind.add(t)
        ans2=max(ans1,ans2)
print(ans2)

### FIXED CODE ###

N,K=map(int,input().split())
TD=[[int(j) for j in input().split()] for i in range(N)]
TD=sorted(TD,key=lambda x:-x[1])
point=0
stack=[]
kind=set()
for t,d in TD[:K]:
    point+=d
    if t in kind:stack.append(d)
    else:kind.add(t)
point=point+len(kind)**2
ans=point
for t,d in TD[K:]:
    if not stack:break
    if not t in kind:
        point+=d-stack.pop()+2*len(kind)+1
        kind.add(t)
        ans=max(ans,point)
print(ans)
from collections import defaultdict
N = int(input())
X = list(input())
d = defaultdict(int)

for i in range(1, N):
    c = 0
    k = format(i, "b")
    for j in k:
        if j == "1":
            c += 1
    d[i] = i % c

n = 0
for i in X:
    if i == "1":
        n += 1

p = 1
total1 = 0
total2 = 0
for i in X[::-1]:
    if i == "1":
        total1 += p % (n+1)
        total2 += p % (n-1)
    p *= 2

total1 %= (n+1)
total2 %= (n-1)
Ans = []
p = 1
for i in X[::-1]:
    c = 1
    if i == "0":
        start = total1
        start += p % (n+1)
        start %= (n+1)
    else:
        start = total2
        start -= p % (n-1)
        start += n - 1
        start %= (n-1)
    if start == 0:
        Ans.append(c)
    else:
        while(True):
            start = d[start]
            c += 1
            if start == 0:
                break
        Ans.append(c)
    p *= 2

for i in Ans[::-1]:
    print(i)

### FIXED CODE ###

from collections import defaultdict
N = int(input())
X = list(input())
d = defaultdict(int)

for i in range(1, N):
    c = 0
    t = 0
    k = format(i, "b")
    for j in k:
        if j == "1":
            c += 1
    d[i] = d[i%c] + 1


n = 0
for i in X:
    if i == "1":
        n += 1

p1 = 1
p2 = 1
total1 = 0
total2 = 0
for i in X[::-1]:
    if i == "1":
        total1 += p1 % (n+1)
        if n-1 > 0:
            total2 += p2 % (n-1)
    p1 *= 2
    p1 %= n+1
    if n-1 > 0:
        p2 *= 2
        p2 %= n-1

total1 %= (n+1)
if n-1 > 0:
    total2 %= (n-1)
Ans = []
p1 = 1
p2 = 1
for i in X[::-1]:
    c = 1
    if n - 1 <= 0 and i == "1":
        Ans.append(0)
    else:
        if i == "0":
            start = total1
            start += p1
            start %= (n+1)
        else:
            start = total2
            start -= p2
            start += n - 1
            start %= (n-1)
        Ans.append(c+d[start])
    p1 *= 2
    p1 %= n+1
    if n-1 > 0:
        p2 *= 2
        p2 %= n-1

for i in Ans[::-1]:
    print(i)
a=int(input())
if a<10:
  print("ABC00"+a)
elif 10<=a<100:
  print("ABC0"+a)
elif 100<=a<1000:
  print("ABC"+a)
elif: 1000<=a<1010:
  print("ABD00"+a)
elif: 1010<=a<1100:
  print("ABD0"+a)
else:
  print("ABD"+a)

### FIXED CODE ###

a=int(input())
if a<1000:
  print("ABC")
else:
  print("ABD")
a, b, c = [int(i) for i in input().split()]
    if a < b < c:
        print "Yes"
    else:
        print "No"

### FIXED CODE ###

a, b, c = [int(i) for i in input().split()]
if a < b < c:
    print ("Yes")
 
else:
    print ("No")
import sys
lines = sys.stdin.readlines()

S = str(lines[0])
X = []
A = []
p =1
for i in range(len(S)):
  A.append(p)
  p = p*10%2019

a = 0
for i in range(len(S)):
  a = (a + int(S[len(S)-i-1])*A[i]) %2019
  X.append(a)

X.sort()
flag =1
n = 0
for i in range(len(X)-1):
  if X[i]==0:
    n +=1
  if X[i]==X[i+1]:
    flag += 1
  else:
    n += flag*(flag-1)//2
    flag = 1
print(n)
    



### FIXED CODE ###

S = str(input())

#10**nのmod計算
A = []
p =1
for i in range(len(S)):
  A.append(p)
  p = p*10%2019

#左からi文字以降の数字列のmod計算
X = []
a = 0
for i in range(len(S)):
  a = (a + int(S[len(S)-i-1])*A[i]) %2019
  X.append(a)
X.sort()
flag =1
n = 0

#modが同じになる組み合わせ、またはもともとmodが0になる数字列の個数の総和計算
for i in range(len(X)-1):
  if X[i]==0:
    n +=1
  if X[i]==X[i+1]:
    flag += 1
  else:
    n += int(flag*(flag-1)/2)
    flag = 1
n += int(flag*(flag-1)/2)
if X[len(X)-1]==0:
  n +=1
print(n)
import math
N = int(input())
int ans = 0;
for i in range(1, math.sqrt(N+1)):
  if(i == int(math.sqrt(i))*int(math.sqrt(i))):
    ans = i
    
print(i)

### FIXED CODE ###

import math
N = int(input())
ans = 0
for i in range(1, int(math.sqrt(N))+1):
  if(i == int(math.sqrt(i))*int(math.sqrt(i))):
    ans = i
    
print(i*i)
from collections import deque

def main():
    S = input().split()
    D = deque([])
    for s in S:
        if s == '+':
            b = D.pop()
            a = D.pop()
            D.append(a+b)   
        elif s == '-':
            b = D.pop()
            a = D.pop()
            D.append(a-b)
        elif s == '*':
            b = D.pop()
            a = D.pop()
            D.append(a*b)
        else:
            D.append(int(s))
        print D
    print D.pop()
    return 0

main()

### FIXED CODE ###

from collections import deque

def main():
    S = raw_input().split()
    D = deque([])
    for s in S:
        if s == '+':
            b = D.pop()
            a = D.pop()
            D.append(a+b)   
        elif s == '-':
            b = D.pop()
            a = D.pop()
            D.append(a-b)
        elif s == '*':
            b = D.pop()
            a = D.pop()
            D.append(a*b)
        else:
            D.append(int(s))
    print D.pop()
    return 0

main()
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a // gcd (a, b) * b

n, m = map(int, input().split())
s = input()
t = input()

ans = lcm(n, m)

chk = [None]*ans

for i in range(n):
    d = ans//n
    chk[i*d] = s[i]
for i in range(m):
    d = ans//m
    target = chk[i*d]
    if target is not None and target != t[i]:
        print(-1)
        exit()
print(ans)



### FIXED CODE ###

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a // gcd (a, b) * b

n, m = map(int, input().split())
s = input()
t = input()

ans = lcm(n, m)

chk = {}

for i in range(n):
    d = ans//n
    chk[i*d] = s[i]
for i in range(m):
    d = ans//m
    if i*d in chk and chk[i*d] != t[i]:
        print(-1)
        exit()
print(ans)
def main():
	N, M = [int(x) for x in input().split(" ")]
	route = [[] for i in range(N)]
	for i in range(M):
		A, B = [int(y) for y in input().split(" ")]
		route[A - 1] += [B]
		route[B - 1] += [A]

	checked = [1] + [0] * (N - 1)
	to_check = [{"src" : s, "dst" : 1} for s in route[0]]
	signal = [-1] + [0] * (N - 1)
	signal_cnt = 0

	while len(to_check) > 0:
		checking = to_check.pop(0)
		src = checking["src"]
		if checked[src - 1] == 0:
			checked[src - 1] = 1
			signal[src - 1] = str(checking["dst"])
			signal_cnt += 1
			rooms = route[src - 1]
			for r in rooms:
				if checked[r - 1] == 0:
					to_check.append({"src": r, "dst": src})
	if signal_cnt != N - 1
		print("No")
	else:
		print("Yes")
		print("\n".join(signal[1:]))

main()

### FIXED CODE ###

def main():
	N, M = [int(x) for x in input().split(" ")]
	route = [[] for i in range(N)]
	for i in range(M):
		A, B = [int(y) for y in input().split(" ")]
		route[A - 1] += [B]
		route[B - 1] += [A]

	checked = [1] + [0] * (N - 1)
	to_check = [{"src" : s, "dst" : 1} for s in route[0]]
	signal = [-1] + [0] * (N - 1)

	for r in route[0]:
		checked[r - 1] = 1

	while len(to_check) > 0:
		checking = to_check.pop(0)
		src = checking["src"]
		signal[src - 1] = str(checking["dst"])
		rooms = route[src - 1]
		for r in rooms:
			if checked[r - 1] == 0:
				to_check.append({"src": r, "dst": src})
				checked[r - 1] = 1

	if signal.count(0) > 0:
		print("No")
	else:
		print("Yes")
		print("\n".join(signal[1:]))

main()
a = int(raw_input())
b,c = map(int, raw_input().split())
s = raw_input()
print a+b+c, " ", s


### FIXED CODE ###

n,m = map(int, raw_input().split())
print((n-1)*(m-1))
n,w = map(int, input().split())
lst_weight = [0 for _ in range(N)]
lst_value = [0 for _ in range(N)]
for i in range(N):
    lst_weight[i], lst_value[i] = map(int, input().split())
dp = [[0 for i in range(w)] for j in range(n+1)]

#後者が前者よりも大きい時に更新→DPテーブルを-infに初期化
def chmax(a,b):
    if(a< b):
        return b
    else:
        return a

#各品物の選択
for i in range(n):
    for sum_w in range(w+1):
        #選択した品物を加える
        if sum_w >= lst_weight[i]:
            #今回の手の暫定最大値と1つ前までの手の確定最大値を比較する
            dp[i+1][sum_w] = chmax(dp[i+1][sum_w], dp[i][sum_w-lst_weight[i]] + lst_value[i])
        else:
            # i番目の品物を選ばない→前までの手で最適化されている最大値が次の手の最大値になるはず
            dp[i+1][sum_w] = chmax(dp[i+1][sum_w], dp[i][sum_w])
            
print(dp[n][w])

### FIXED CODE ###

import sys
import numpy as np
N, W = map(int, input().split())
def knapsack(n, w):
    # dp[i][j] : i番目の品物で重さj以下の価値の最大値
    dp = np.zeros([N+1, W+1], dtype='int64')
    # forは関数の中で回す。
    for i in range(N):
        w, v = map(int, input().split())
        # i+1番目でwより小さい場合は、i番目と変更なし
        dp[i+1][:w] = dp[i][:w]
        dp[i+1][w:] = np.maximum(dp[i][w:], dp[i][:-w] + v)
    return dp[-1][-1]

print(knapsack(N, W))
time = int(input())
jorney = [list(map(int,input().split())) for i in range(time)]
flg = True
x_before = 0
y_bfefore =0
t_before = 0

for point in jorney:
    time = point[0]
    x = point[1]
    y = point[2]
    distance = x- x_before + y - y_bfefore
    interval = time - time_before
    
    
    if time %2 == (x+y)%2 and interval = distance:
        time_before=time
        x_before=x
        y_bfefore=y

        continue
    else:
        flg=False
        break
if flg:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

time = int(input())
jorney = [list(map(int,input().split())) for i in range(time)]
flg = True
x_before = 0
y_bfefore =0
t_before = 0

for point in jorney:
    t = point[0]
    x = point[1]
    y = point[2]
    distance = abs(x- x_before) + abs(y - y_bfefore)
    interval = t - t_before
    
    
    if t %2 == (x+y)%2 and interval >= distance:
        t_before=t
        x_before=x
        y_bfefore=y

        continue
    else:
        flg=False
        break
if flg:
    print("Yes")
else:
    print("No")
#ABC057.B
N,M = map(int,input().split())
L1 = []
L2 = []

for i in range(N):
    a,b = map(int,input().split())
    L1.append([a,b])
for m in range(M):
    c,d = map(int,input().split())
    L2.append([c,d])

for j in range(N):
    L3 = []
    for l in range(M):
        L3.append(abs(L1[j][0]-L2[l][0]) + abs(L1[j][1]-L2[l][1]))
    print(L3.index(min(L3))+1)

### FIXED CODE ###

#ABC057.A
A,B = map(int,input().split())
if A+B <24:
    print(A+B)
else:
    print(A+B-24)
sute = input()
input_nums = input().split()

output = 1

x = map((lambda x: int(x)), input_nums)


for num in x:
    output *= num   
    if output > 10^18:
        output = -1

if output <= -1:
    output = -1


print(output)

### FIXED CODE ###

input_nums = input().split()

output = 1

x = map((lambda x: int(x)), input_nums)

for num in x:
    output *= num
    
print(output)
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8

@njit((i8, i8, i8, i8[:]), cache=True)
def solve(R,C,K,XYV):
  item = np.zeros((H + 1, W + 1), np.int64)
    for i in range(0, 3 * K, 3):
        x, y, v = XYV[i:i + 3]
        item[x - 1, y - 1] = v
  dp = np.zeros((C+1,4), dtype=np.int64)
  for i in range(1,R+1):
    new_dp = np.zeros((C+1,4), dtype=np.int64)
    #上から移動
    for k in range(4):
      new_dp[:,0] = np.maximum(new_dp[:,0], dp[:,k])
    dp = new_dp
    for j in range(1,C+1):
      #横から移動
      new_dp[j] = np.maximum(new_dp[j],new_dp[j-1])
      #アイテムを取る
      for k in range(2,-1,-1):
        dp[j,k+1] = np.maximum(dp[j,k+1],dp[j,k]+item[i-1][j-1])
  ans = dp[-1].max()
  return ans

R, C, K = map(int, input().split())
XYV = np.array(read().split(), np.int64)
print(solve(R,C,K,XYV))


### FIXED CODE ###

import sys
input = sys.stdin.readline
def solve():
  R, C, K = map(int, input().split())
  item = [[0]*C for _ in range(R)]
  for i in range(K):
    r,c,v = map(int, input().split())
    item[r-1][c-1] = v
  dp = [[[0]*(C+1) for _ in range(R+1)] for _ in range(4)]
  for i in range(1,R+1):
    for j in range(1,C+1):
      for k in range(4): #横から取らない
        dp[k][i][j] = dp[k][i][j-1]
      #上から取らない
      dp[0][i][j] = max(dp[0][i][j],dp[-1][i-1][j])
      if item[i-1][j-1]>0:
        #上からとる
        dp[1][i][j] = max(dp[1][i][j],dp[-1][i-1][j]+item[i-1][j-1])
        for k in range(1,4): #横から取る
          dp[k][i][j] = max(dp[k][i][j],dp[k-1][i][j-1]+item[i-1][j-1])
      for k in range(1,4):
        dp[k][i][j] = max(dp[k-1][i][j],dp[k][i][j])
  ans = 0
  for k in range(4):
    ans = max(ans,dp[k][-1][-1])
  return ans
print(solve())
n, k = map(int, input().split())
ans = 0

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

nums.sort(reverse="True")

for i in range(k):
  ans += nums.pop(0)
  
print(ans)

### FIXED CODE ###

n, k = map(int, input().split())
ans = 0

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

nums.sort(reverse=True)

for i in range(k):
  ans += nums.pop(0)
  
print(ans)
import math
import numpy as np

x = int(input())
x_sqrt = math.sqrt(x)
maxlist = []

def hoge(x, x_sqrt):
    for b in range(2, x_sqrt+1):
        i = 1
        while b ** i <= x:
            i += 1
        maxlist.append(b **(i-1))
    return np.max(np.array(maxlist))

if x - x_sqrt == 0:
    print(x)
else:
    print(hoge(x, int(x_sqrt)))

### FIXED CODE ###

import math


a,b,c,d = map(int, input().split(' '))
if math.fabs(a - c) <= d:
  print('Yes')
elif math.fabs(a-b) <= d and math.fabs(b-c) <= d:
  print('Yes')
else:
  print('No')
n = int(input())
m = {}
tot = 0
for a in map(int,input().split()):
  tot += m
  if a not in m:
    m[a]=0
  m[a] += 1
q = int(input())
for step in range(q):
  b,c = map(int,input().split())
  if c not in m:
    m[c] = 0
  if b in m:
    m[c] += m[b]
    tot += m[b]*(c-b)
    m[b] = 0
  print(tot)



### FIXED CODE ###

n = int(input())
m = {}
tot = 0
for a in map(int,input().split()):
  tot += a
  if a not in m:
    m[a]=0
  m[a] += 1
q = int(input())
for step in range(q):
  b,c = map(int,input().split())
  if c not in m:
    m[c] = 0
  if b in m:
    m[c] += m[b]
    tot += m[b]*(c-b)
    m[b] = 0
  print(tot)
import math

a, b, h,m = map(int, input().split())

# 角度を求める
a_angle = (h/12 + m/(60*12)) *360
b_angle = m/60*360

#print(a_angle)
#print(b_angle)

line = 0

if a_angle > b_angle:
    angle = a_angle - b_angle
elif a_angle < n_angle:
    angle = b_angle - a_angle 
else:
    angle = 0


    
if angle >=180:
    angle = 360-angle

#print(angle)

c2 = pow(a,2) + pow(b,2) - 2 * a * b * math.cos(math.radians(angle))

c = pow(c2, 1/2)
print(c)

### FIXED CODE ###

import math

a, b, h,m = map(int, input().split())

# 角度を求める
a_angle = (h/12 + m/(60*12)) *360
b_angle = m/60*360

#print(a_angle)
#print(b_angle)

line = 0

if a_angle > b_angle:
    angle = a_angle - b_angle
elif a_angle < b_angle:
    angle = b_angle - a_angle 
else:
    angle = 0


    
if angle >=180:
    angle = 360-angle

#print(angle)

c2 = pow(a,2) + pow(b,2) - 2 * a * b * math.cos(math.radians(angle))

c = pow(c2, 1/2)
print(c)
import sys
sys.setrecursionlimit(10**7)
N = int(input())
ts = [int(input()) for _ in range(N)]

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

def lcm(a,b):
    g = gcd(a,b)
    return int(a * b / g)

l = 1
for t in ts:
    l = lcm(l,t)
    
print(l)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
N = int(input())
ts = [int(input()) for _ in range(N)]

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

def lcm(a,b):
    g = gcd(a,b)
    return a * b // g

l = 1
for t in ts:
    l = lcm(l,t)
    
print(l)
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
S = [list(map(int, input().split())) for l in range(Q)]

l = [0] * 10**5
s = set()
for i in range(N) :
    l[A[i]]+=1
    s.add(A[i])
for i in range(Q):
    s0 = S[i][0]
    s1 = S[i][1]
    l[s1] += l[s0]
    try:
        s.remove(s0)
        s.add(s1)
    except :
        pass
    l[s0] = 0
    tot = 0
    for j in s:
        tot += j * l[j]
    print(tot)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
Q = int(input())
S = [list(map(int, input().split())) for l in range(Q)]

l = [0] * 10**6
tot = 0
for i in range(N) :
    l[A[i]]+=1
    tot += A[i]
for i in range(Q):
    s0 = S[i][0]
    s1 = S[i][1]
    tot += s1 * (l[s0] + l[s1]) - (s0 * l[s0] + s1*l[s1])
    l[s1] += l[s0]
    l[s0] = 0
    print(tot)
ABCD = input()
for i in range(8):
    ope = [{0:'+', 1:'-'}[i & (1<<j)] for j in range(3)]
    fomula = ABCD[0] + ope[0] + ABCD[1] + ope[1] + ABCD[2] + ope[2] + ABCD[3]
    if eval(fomula) == 7:
        print(f'{fomula}=7')
        break

### FIXED CODE ###

List = [int(n) for n in input()]
ans = [List[0]] * 4
for i in range(8):
    for j in range(3):
        if i & (1<<j):
            ans[j+1]= -List[j+1]
        else:
            ans[j+1] = List[j+1]
    if sum(ans) == 7:
        break
ans = [str(ans[0])] + ['+' + str(x) if x>=0 else str(x) for x in ans[1:]]
print("".join(ans) + '=7')
a = [0 for i in range(3 * 1000000 + 1)]

s = int(input().rstrip())

a[s] = 1

for i in range(2, 1000000+1):
    if s % 2 == 0:
        s = int(s / 2)
    else:
        s = int(3 * s + 1)
    #print(s)
    
    if a[s] == 1:
        break
    a[s] = 1
        
print(i)

### FIXED CODE ###

AB, BC, CA = map(int, input().split())

print( int(AB * BC / 2) )
A, B, K = map(int, input().split())

lst = []
for i in range(1,max(A,B)):
    if A % i == 0 and B % i == 0:
        lst.append(i)

print(lst[K-1])


### FIXED CODE ###

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

lst = []
for i in range(1,min(A,B)+1):
    if A % i == 0 and B % i == 0:
        lst.append(i)

print(lst[-K])
n,a,b = map(int, raw_input().split()
if (b-a) % 2 == 0:
  print "Alice"
else:
  print "Borys"


### FIXED CODE ###

n,a,b = map(int, raw_input().split())
if (b-a) % 2 == 0:
  print "Alice"
else:
  print "Borys"
N,A,B = map(int,input().split())

N -= 1
A -= 1
B -= 1

def is_valid(p):
    x,y = p
    return 0 <= x < N and 0 <= y < N

def meet(p):
    x,y = p
    return abs(x-y)//2

def dist(p1,p2):
    x1,y1 = p1
    x2,y2 = p2
    return (abs(x1-x2)+abs(y1-y2))//2

oo = []
if (A + B)//2:
    o = []
    for i in [0,N]:
        for j in [1,-1]:
            o.append((i,B + j * abs(A-i)))
            o.append((A + j * abs(B-i),i))
    for x,y in filter(is_valid,o):
        for i in [1,-1]:
            for j in [1,-1]:
                xx = max(0,min(x+i,N))
                yy = max(0,min(y+i,N))
                oo.append(meet((xx,yy))+dist((A,B),(x,y))+1)
    print(min(oo))
else:
    print(meet((A,B)))

### FIXED CODE ###

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

if (A + B)%2 == 0:
    print(abs(A - B)//2)
else:
    print(min(A-1,N-B)+1+abs(A-B+1)//2)