Harryxun/stf_run huggingface dataset:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

a,b,m = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a = min(A); b=min(B)
mans = a+b
for _ in range(m):
  x,y,c = map(int,input().split())
  x-=1;b-=1
  tmp = A[x] + B[x] - c
  mans = min(mans,tmp)
print(mans)

### FIXED CODE ###

#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

a,b,m = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a = min(A); b=min(B)
mans = a+b
for _ in range(m):
  x,y,c = map(int,input().split())
  x-=1;y-=1
  tmp = A[x] + B[y] - c
  mans = min(mans,tmp)
print(mans)
n, k = map(int, input().split())
x = list(int(i) for i in input().split())
inf = 10**9
max_x = x[-1]
min_x = x[1]
if min_x >= 0:
    print(x[k-1])
elif max_x <= 0:
    print(x[-k])
else:
    for i in range(n-1):
        if x[i]<0 and x[i+1]>=0:
            key = i+1
            break
    if n-key>=k:
        ans1 = sum(x[key:key+k])
    else:
        ans1 = inf
    if key>=k:
        ans2 = abs(sum(x[key-k:key]))
    else:
        ans2 = inf
    ans3 = inf
    for i in range(max(0, key-k+1), min(n-k, key+k-1)):
        a, b = abs(x[i]), abs(x[i+k-1])
        t = max([a, b])+min([a, b])*2
        if t < ans3:
            ans3 = t
    print(min([ans1, ans2, ans3]))

### FIXED CODE ###

n, k = map(int, input().split())
x = list(int(i) for i in input().split())
inf = 10**9
max_x = x[-1]
min_x = x[0]
if min_x >= 0:
    print(x[k-1])
elif max_x <= 0:
    print(abs(x[-k]))
else:
    for i in range(n-1):
        if x[i]<0 and x[i+1]>=0:
            key = i+1
            break
    if n-key>=k:
        ans1 = sum(x[key:key+k])
    else:
        ans1 = inf
    if key>=k:
        ans2 = abs(sum(x[key-k:key]))
    else:
        ans2 = inf
    ans3 = inf
    for i in range(max(0, key-k+1), min(n-k+1, key+k-1)):
        a, b = abs(x[i]), abs(x[i+k-1])
        t = max([a, b])+min([a, b])*2
        if t < ans3:
            ans3 = t
    print(min([ans1, ans2, ans3]))
n, k, l = map(int, input().split())
roads = list(range(n))
railways = list(range(n))
ans = []
for _ in range(k):
    a, b = map(lambda x : int(x) - 1, input().split())
    i = min(roads[a], roads[b])
    roads[roads[a]], roads[a] = i, i
    roads[roads[b]], roads[b] = i, i
for _ in range(l):
    a, b = map(lambda x : int(x) - 1, input().split())
    i = min(railways[a], railways[b])
    railways[railways[a]], railways[a] = i, i
    railways[railways[b]], railways[b] = i, i

roads_dic = dict()
railways_dic = dict()
for i in range(n):  
    if roads[i] == i:
        roads_dic[i] = {i}
    else:
        roads_dic[roads[i]].add(i)
    if railways[i] == i:
        railways_dic[i] = {i}
    else:
        railways_dic[railways[i]].add(i)

ans = [len(roads_dic[roads[i]] & railways_dic[railways[i]]) for i in range(n)]
print(" ".join(map(str, ans)))

### FIXED CODE ###

class UnionFindTree:
    def __init__(self, n):
        self.nodes = [-1] * n #根にサイズを負の値で格納する。
    def find(self, i):
        if self.nodes[i] < 0: #値が負の場合は根
            return i
        else:
            self.nodes[i] = self.find(self.nodes[i]) #縮約
            return self.nodes[i]

    def union(self, i, j):
        i = self.find(i)
        j = self.find(j)
        if i == j:
            return
        if self.nodes[i] > self.nodes[j]: #サイズ比較してiの方がサイズが大きいようにする
            i, j = j, i
        self.nodes[i] += self.nodes[j] #大きい方に小さい方を統合しサイズを登録する。
        self.nodes[j] = i # jの親はi
    
    def size(self, i): # 所属する集合の大きさを返す
        i = self.find(i)
        return -self.nodes[i]


n, k, l = map(int, input().split())
roads = UnionFindTree(n)
railways = UnionFindTree(n)
ans = []
for _ in range(k):
    a, b = map(lambda x : int(x) - 1, input().split())
    roads.union(a, b)
    
for _ in range(l):
    a, b = map(lambda x : int(x) - 1, input().split())
    railways.union(a, b)

counter = dict()
for i in range(n):
    p = (roads.find(i), railways.find(i))
    if not p in counter:
        counter[p] = 1
    else:
        counter[p] += 1

ans = [counter[(roads.find(i), railways.find(i))] for i in range(n)]
print(" ".join(map(str, ans)))
A = list(map(int, input().split()))

m = 0
t = 0

for i in range(1, n):
    count = A.count(i)
    print(count)
    m += count
    t = i
    if m == n - 1:
        break
for _ in range(t, n):
    print(0)


### FIXED CODE ###

n = int(input())
A = list(map(int, input().split()))

# m = 0
# t = 0

# for i in range(1, n):
#     count = A.count(i)
#     print(count)
#     m += count
#     t = i
#     if m == n - 1:
#         break
# for _ in range(t, n):
#     print(0)

B = [0] * n
for i in A:
    B[i-1] += 1
for i in B:
    print(i)
a = int(input())
b = int(input())

mul = a * b

if mul % 2 == 0:
    print("Even")
else:
    print("Odd")


### FIXED CODE ###

# coding: utf-8

# １行の入力データを分割
data = input().split(" ")


a = int(data[0])
b = int(data[1])

mul = int(a * b)

if mul % 2 == 0:
    print("Even")
else:
    print("Odd")
n=int(input())
rec=[2,1]
if n>=2:
    for i in range(2,n):
        rec.append(rec[i-2]+rec[i-1])
print(rec[n])


### FIXED CODE ###

n=int(input())
rec=[2,1]
if n>=2:
    for i in range(2,n+1):
        rec.append(rec[i-2]+rec[i-1])
print(rec[n])
n=input()
s,t=input().split()

word=""
for i in range(n):
    word+=(s[i]+t[i])
print(word)


### FIXED CODE ###

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

word=""
for i in range(n):
    word+=(s[i]+t[i])
print(word)
N = int(input())
G = [[] for i in range(N)]

for i in range(N-1):
    u, v, w = map(int, input().split())
    if w % 2 == 0:
        G[u-1].append((v-1, 1))
        G[v-1].append((u-1, 1))
    else:
        G[u-1].append((v-1, -1))
        G[v-1].append((u-1, -1))

color = [None for i in range(N)]


def set_color(v, c):
    color[v] = c
    for next_v, d in G[v]:
        if color[next_v] is None:
            set_color(next_v, d*c)


set_color(0, 1)

for c in color:
    if c == 1:
        print(1)
    else:
        print(0)


### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)


N = int(input())
G = [[] for i in range(N)]

for i in range(N-1):
    u, v, w = map(int, input().split())
    if w % 2 == 0:
        G[u-1].append((v-1, 1))
        G[v-1].append((u-1, 1))
    else:
        G[u-1].append((v-1, -1))
        G[v-1].append((u-1, -1))

color = [None for i in range(N)]


def set_color(v, c):
    color[v] = c
    for next_v, d in G[v]:
        if color[next_v] is None:
            set_color(next_v, d*c)


set_color(0, 1)

for c in color:
    if c == 1:
        print(1)
    else:
        print(0)
mod=1000000007
n,m=map(int,input().split())
a=[1]*n
for i in range(m):
  a[int(input())-1]=0
a[1]=a[0]+1
for i in range(2,n):
  if a[i]==0:continue
  else:a[i]=(a[i-1]+a[i-2])%mod
print(a[n-1])

### FIXED CODE ###

n,m=map(int,input().split())
mod=10**9+7

a=set([int(input()) for i in range(m)])

dp=[0]*(n+1)
dp[0]=1

for i in range(1,n+1):
  dp[i]=(dp[i-1]+dp[i-2])%mod
  if i in a:dp[i]=0
print(dp[n])
import sys
from collections import deque


N, M = [int(i) for i in input().split()]
A = []
B = []
for i in range(M):
    l = [int(i) for i in input().split()]
    A.append(l[0])
    B.append(l[1])

# BFS
G = [[] for _ in range(N)]
for i in range(N):
    G[A[i] - 1].append(B[i] - 1)
    G[B[i] - 1].append(A[i] - 1)
G = [list(set(x)) for x in G]

q = deque([])
dist = [-1] * N
ans = [-1] * N
dist[0] = 0
q.appendleft(0)
while(len(q) > 0):
    v = q.pop()
    for nv in G[v]:
        if not dist[nv] == -1:
            continue
        dist[nv] = dist[v] + 1
        ans[nv] = v
        q.appendleft(nv)

for i in ans[1:]:
    if i == -1:
        print('No')
        sys.exit()

for i, v in enumerate(ans):
    if i == 0:
        print('yes')
        continue
    print(v + 1)
    

### FIXED CODE ###

import sys
from collections import deque


N, M = [int(i) for i in input().split()]
A = []
B = []
for i in range(M):
    l = [int(i) for i in input().split()]
    A.append(l[0])
    B.append(l[1])

# BFS
G = [[] for _ in range(N)]
for i in range(M):
    G[A[i] - 1].append(B[i] - 1)
    G[B[i] - 1].append(A[i] - 1)
# G = [list(set(x)) for x in G]

q = deque([])
ans = [-1] * N
ans[0] = 0
q.appendleft(0)
while(len(q) > 0):
    v = q.pop()
    for nv in G[v]:
        if not ans[nv] == -1:
            continue
        ans[nv] = v
        q.appendleft(nv)

# for i in ans[1:]:
#     if i == -1:
#         print('No')
#         sys.exit()

for i, v in enumerate(ans):
    if i == 0:
        print('Yes')
        continue
    print(v + 1)
input_size = int(input())
inputs = map(int, input().split())
sum = 0
for i in range(input_size):
  sum += 1 / inputs[i]
print(1 / sum)

### FIXED CODE ###

input_size = int(input())
inputs = input().split()
sum = 0
for i in range(input_size):
  sum += 1 / int(inputs[i])
print(1 / sum)
N,M=map(int,input().split())
SC=[input().split() for _ in range(M)]
ans=["0"]*N
for s,c in SC:
  if ans[int(s)-1]!="0" and ans[int(s)-1]!=c:
    print(-1)
    exit()
  if N>1 and s=="1" and c=="0":
    print(-1)
    exit()
  ans[int(s)-1]=c
if ans[0]=="0" and N>1:
  ans[0]=1
print("".join(ans))

### FIXED CODE ###

N, M = map(int, input().split())
SC = [input().split() for _ in range(M)]
ans = ["0"] * N
for s, c in SC:
  # check duplicated s
  if ans[int(s) - 1] != "0" and ans[int(s) - 1] != c:
    print(-1)
    exit()
  # check impossible case
  if N > 1 and s == "1" and c == "0":
    print(-1)
    exit()
  ans[int(s) - 1] = c
# replace head
if ans[0] == "0" and N > 1:
  ans[0] = "1"
print("".join(ans))
# -*- coding: utf-8 -*-
def main():
    N, M =  [int(i) for i in input().split()]

    S = []
    for i in range(M):
        S.append([int(i) for i in input().split()])

    answer = "0" * N

    for s in S:
        if answer[int(s[0])-1] == "0":
            answer = answer[:int(s[0])-1] + str(s[1]) + answer[int(s[0]):]
            #print(answer)
        elif answer[int(s[0])-1] != str(s[1]):
            #print(answer)
            print(-1)
            return
        else:
            continue

    if answer[0] == "0" && len(answer) != 1:
        print(-1)
    else:
        print(answer)

if __name__ == "__main__":
    main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
def main():
    N, M =  [int(i) for i in input().split()]

    S = []
    for i in range(M):
        S.append([int(i) for i in input().split()])

    S.sort(reverse=True)
    #print(S)
    answer = "0" * N
    if N != 1 and [1, 0] in S:
        print(-1)
        return

    for s in S:
        if answer[int(s[0])-1] == "0":
            answer = answer[:int(s[0])-1] + str(s[1]) + answer[int(s[0]):]
            #print(answer)
        elif answer[int(s[0])-1] != str(s[1]):
            #print(answer)
            print(-1)
            return
        else:
            continue

    if answer[0] == "0" and len(answer) != 1:
        print("1" + answer[1:])
    else:
        print(answer)

if __name__ == "__main__":
    main()
def main():
    n,m = map(int,input().split())
    g = [[] for _ in range(n+1)]
    for _ in range(m):
        x,y = map(int,input().split())
        g[x].append(y)

    dp = [-1]*(n+1)

    def memo(v):
        if dp[v]!=-1:return dp[v]
        ans = 0
        for next_v in g[v]:
            ans = max(ans,memo(next_v)+1)
        dp[v] = ans
        return dp[v]

    ans = 0
    for v in range(n):
        ans = max(ans, memo(v))

    print(ans)

main()

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**5+10)
def memo(v):
    if dp[v]!=-1:return dp[v]
    ans = 0
    for next_v in g[v]:
        ans = max(ans,memo(next_v)+1)
    dp[v] = ans
    return ans

n,m = map(int,input().split())
g = [[] for _ in range(n+1)]
for _ in range(m):
    x,y = map(int,input().split())
    g[x].append(y)
    
dp = [-1]*(n+1)

ans = 0
for v in range(1,n+1):
    ans = max(ans, memo(v))
    
print(ans)
count = 0
a = min(m,n)
b = max(m,n)

if a/x == int(a//x) and b/x == int(b//x):
    print(int(1 + b//x - a//x))

elif a/x == int(a//x) and b/x != int(b//x):
    print(int(int(b//x) - int(a//x) + 1))

elif a/x != int(a//x) and b/x == int(b//x):
    print(int(int(b//x) - int(a//x)))

elif a/x != int(a//x) and b/x != int(b//x):
    print(int(int(b//x) - int(a//x)))

### FIXED CODE ###

a,b,x = map(int,input().split())
print(b//x-(a-1)//x)
import sys,collections
sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def S(): return input()

s = S()
gx,gy = Is()
xlis,ylis = [],[]
x,y = 0,0
h = 0
for e in s:
    if e == "F":
        if h == 0:
            x += 1 
        else:
            y += 1 
    else:
        if h == 0:
            if x:
                xlis.append(x) 
        else:
            if y:
                ylis.append(y)
        x,y = 0,0
        h = not h
if h == 0:
    if x:
        xlis.append(x) 
else:
    if y:
        ylis.append(y)
sx = xlis.pop(0) if len(xlis)>0 else 0
sy = 0
xmat = [[False]*16001 for i in range(len(xlis)+1)]
ymat = [[False]*16001 for i in range(len(ylis)+1)]
xmat[0][sx] = True
ymat[0][sy] = True
def xdp(i,d):
    if xmat[i][d]:
        return True
    if i == 0:
        return False
    xmat[i][d] = xdp(i-1,d + lis[i-1]) or xdp(i-1,d - lis[i-1])
    return xmat[i][d]
def ydp(i,d):
    if ymat[i][d]:
        return True
    if i == 0:
        return False
    ymat[i][d] = ydp(i-1,d + lis[i-1]) or ydp(i-1,d - lis[i-1])
    return xmat[i][d]
if xdp(len(xlis),gx) and ydp(len(ylis),gy):
    print("Yes")
else:
    print("No")


### FIXED CODE ###

import sys,collections
sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def S(): return input()
 
s = S()
gx,gy = Is()
l = s.split("T")
for i in range(len(l)):
    l[i] = len(l[i])
xlis,ylis = l[::2],l[1::2]
sx = xlis.pop(0) if len(xlis)>0 else 0
sy = 0
xlis.sort(reverse=True)
ylis.sort(reverse=True)
def calc(start,goal,lis):
    p = start
    for e in lis:
        if p < goal:
            p += e
        else:
            p -= e
    return p == goal
if calc(sx,gx,xlis) and calc(sy,gy,ylis):
    print("Yes")
else:
    print("No")
from collections import deque
n,k=map(int, input().split())

A = deque(map(int, input().split()))
li = []
li2 = [0]*n
li.append(1)

next = 0
t=0
rep = False

for i in range(n):
    li.append(A[next])
    li2[next] = 1
    next = A[next]-1

    if li2[next] == 1:
        t = li.index(A[next])
        rep = True
        break


if rep == True:
    tmp = (k%len(li[t:])) - len(li[0:t])
    g=li[t:]
    print(g[tmp])
else:
    print(li[k-1])


### FIXED CODE ###

from collections import deque
n,k=map(int, input().split())

A = deque(map(int, input().split()))
li = []
li2 = [0]*n
li.append(1)

next = 0

t=0
rep = False

for i in range(k):
    if i == k:
        print(next+1)
        exit()

    if li2[next] == 1:
        t = li.index(next+1)
        rep = True
        li.pop()
        break

    li.append(A[next])
    li2[next] = 1
    next = A[next]-1


tmp = (k-t)%len(li[t:])
print(li[tmp+t])
n,m = map(int,input().split())
l = dict()
tl = []
for i in range(n+1):
  l[i] = []
for _ in range(m):
  a,b,c = map(int,input().split())
  l[a].append((b,c))
  l[b].append((a,-c))
  tl.append((a,b,c))
pos = [None]*(n+1)

def dfs(v,p,pos):
  pos[v] = p
  for i,d in l[v]:
    if pos[i] == None:
      dfs(i,p+d,pos)
  return

for i in range(1,n):
  if pos[i] == None:
    dfs(i,0,pos)
for a,b,c in tl:
  if pos[b] - pos[a] != c:
    print("No")
    break
else:
  print("Yes")

### FIXED CODE ###

n,m = map(int,input().split())
l = dict()
tl = []
for i in range(n+1):
  l[i] = []
for _ in range(m):
  a,b,c = map(int,input().split())
  l[a].append((b,c))
  l[b].append((a,-c))
  tl.append((a,b,c))
pos = [None]*(n+1)

def dfs(v,p,pos):
  q = [(v,p)]
  while q:
    cv,cp = q.pop()
    if pos[cv] != None:
      continue
    pos[cv] = cp
    for i,d in l[cv]:
      if pos[i] == None:
        q.append((i,cp+d))
  return

for i in range(1,n+1):
  if pos[i] == None:
    dfs(i,0,pos)
for a,b,c in tl:
  if pos[b] - pos[a] != c:
    print("No")
    break
else:
  print("Yes")
A, B = map(int, input())

A_x = (B-A)-1

print(sum(list(range(A_x+1)))-A)

### FIXED CODE ###

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

A_x = (B-A)-1

print(sum(list(range(A_x+1)))-A)
from sys import stdin, stdout

if __name__ == '__main__':
  S = stdin.readlines().replace("\n","")
  d = {'SUN':7, "MON":6, "TUE":5, "WED":4, "THU":3, "FRI":2, "SAT":1}
  stdout.writelines("%d" % d[S])

### FIXED CODE ###

if __name__ == '__main__':
    S = input()
    d = {'SUN':7, "MON":6, "TUE":5, "WED":4, "THU":3, "FRI":2, "SAT":1}
    if d.get(S, False):
        print(d[S])
    else:
        res = -1
        for i in d.keys():
            if i in S or i.lower() in S:
                res = d[i]
                break
        print(res)
tracks = []
while 1:
    try:
        c0 = raw_input()
        c = int(c0)
        if c == 0:
            print tracks.pop()
        else:
            tracks.append(c)
    except EOFError:
        break

### FIXED CODE ###

tracks = []
while 1:
    try:
        c0 = raw_input()
        if c0 == '':
            break
        c = int(c0)
        if c == 0:
            print tracks.pop()
        else:
            tracks.append(c)
    except EOFError:
        break
# coding: utf-8
A=input('数字を入力＞')
op=input('＞')
B=input('数字を入力＞')
if op == '+':
    print(int(A)+int(B))
else:
    print(int(A)-int(B))

### FIXED CODE ###

# -*- coding: utf-8 -*-

a, op, b = input().split()

if op == '+':
    print(int(a) + int(b))
else:
    print(int(a) - int(b))
n = int(input())
li = [0]*4
for _ in n:
  s = input()
  if s == 'AC':
    li[0]+=1
  elif s == 'WA':
    li[1]+=1
  elif s == 'TLE':
    li[2]+=1
  elif s == 'RE':
    li[3]+=1
print('AC x ',li[0])
print('WA x ',li[1])
print('TLE x ',li[2])
print('RE x ',li[3])

### FIXED CODE ###

n = int(input())
li = [0]*4
for _ in range(n):
    s = input()
    if s == 'AC':
        li[0]+=1
    elif s == 'WA':
        li[1]+=1
    elif s == 'TLE':
        li[2]+=1
    elif s == 'RE':
        li[3]+=1
print('AC x ',li[0])
print('WA x ',li[1])
print('TLE x ',li[2])
print('RE x ',li[3])
count = 0
s = [input() for i in range(0,3)] #複数行の数値の入力を取得

if s[i]=1:
    count += 1
    
else:
    count = count

### FIXED CODE ###

print(int(input()) % 9)
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(M)]

def DFS(v, ab_list, DFS_list):
    DFS_list[v] = True
    for j in ab_list[v]:
        if not DFS_list[j]:
            DFS(j, ab_list, DFS_list)

ans = 0
for i in range(M):
    ab_list = [[] for i in range(N)]
    for j in range(M):
        if i != j:
            k = ab[j]
            ab_list[k[0] - 1].append(k[1] - 1)
            ab_list[k[1] - 1].append(k[0] - 1)
            
    DFS_list = [False] * N
    
    DFS(i, ab_list, DFS_list)
    
    if False in DFS_list:
        ans += 1
print(ans)

### FIXED CODE ###

def wf(this_graf):
    s = len(graf)
    for k in range(s):
        for i in range(s):
            for j in range(s):
                this_graf[i][j] = min(this_graf[i][j], this_graf[i][k] + this_graf[k][j])
    return this_graf

n, m = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(m)]
graf = [[10 ** 10 for i in range(n)] for j in range(n)]

for i, j in ab:
    graf[i - 1][j - 1] = 1
    graf[j - 1][i - 1] = 1

import copy
cnt = 0

for i, j in ab:
    this_graf = copy.deepcopy(graf)
    tmp = 0
    this_graf[i - 1][j - 1] = 10 ** 10
    this_graf[j - 1][i - 1] = 10 ** 10
    this_graf = wf(this_graf)
    for i in range(n):
        for j in range(n):
            if this_graf[i][j] == 10 ** 10:
                tmp = 1
                break
        if tmp:
            break
    cnt += tmp

print(cnt)
def solve(A: int, B: int):
    ans = max(0, A - (2 * B))
    print(ans)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    ans = max(0, A - (2 * B))
    print(ans)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)


if __name__ == '__main__':
    main()
N = int(input())

for h, n in product(range(1, 3501), range(1, 3501)):
    a = (4 * h * n - N * n - N * h)
    if a != 0:
        w = (N * h * n) / a
        if w == int(w) and w > 1:
            print(n,h,int(w))
            exit()

### FIXED CODE ###

from itertools import product
N = int(input())

for h in range(1, 3501):
    for n in range(1, 3501):
        a = (4 * h * n - N * n - N * h)
        if a > 0 and (N * h * n) % a == 0:
            w = (N * h * n) / a
            int_w = int(w)
            if w == int_w:
                print(n,h,int_w)
                exit()
S = stdin.readline().rstrip()

if S == 'ABC':
    print('ARC')
else:
    print('ABC')


### FIXED CODE ###

from sys import stdin

S = stdin.readline().rstrip()

if S == 'ABC':
    print('ARC')
else:
    print('ABC')
import sys
from fractions import gcd
from functools import reduce

sys.setrecursionlimit(2147483647)

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

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def main():
    N = int(input())
    A = list(map(int, input().split()))

    lcm = lcm_list(A)
    S = 0
    for i in range(N):
        S += lcm // A[i]

    print(round(S % (1e9 + 7)))

main()


### FIXED CODE ###

import sys
from fractions import gcd
from functools import reduce

sys.setrecursionlimit(2147483647)

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

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def main():
    N = int(input())
    A = list(map(int, input().split()))

    lcm = lcm_list(A)
    S = 0
    for i in range(N):
        S += lcm // A[i]

    print(round(S % (round(1e9) + 7)))

main()
A, B, C = map(int,input())
if A < B + C :
  print(C - (A - B))
else:
  print(0)



### FIXED CODE ###

A, B, C = map(int,input().split())
if A < B + C :
  print(C - (A - B))
else:
  print(0)
n = int(input())
ans = 10
for i in range(1, n/2+1):
    if n % i == 0:
        if len(str(max(i, n/i))) <= ans:
            ans = len(str(max(i, n/i)))
print(ans)


### FIXED CODE ###

n = int(input())
ans = 11
for i in range(1, int(n**0.5)+1):
    if n % i != 0:
        continue
    b = n // i
    ans = min(ans, max(len(str(i)),len(str(b))))
print(ans)
x = [int(v) for v in input().split()]
del x[0]
print(min(x), max(x), sum(x))


### FIXED CODE ###

n = int(input())
x = [int(v) for v in input().split()]
print(min(x), max(x), sum(x))