Harryxun/stf_run huggingface dataset:
from collections import deque
HW = input(),split()
H, W = int(HW[0]), int(HW[1])
C = input()split()
Ch, Cw = int(C[0]), int(C[1])
D = input().split()
Dh, Dw = int(D[0]), int(D[1])
route = []
for h in range(H):
    tmpr = input().split()
    route.append(tmp)

visited = [[False]*W for x in range(H)]
kouho = deque()
kouho.append([Ch-1, Cw-1])
warpkouho = deque()

def check_walk(a, b):
    if 0 <= a <= H-1 and 0 <= b <= W-1: 
        if visited[a][b] == False and route[a][b] == ".":
            kouho.append([a, b])
def check_warp(a, b, cwarp):
    if 0 <= a <= H-1 and 0 <= b <= W-1:
        if visited[a][b] == False and route[a][b] == ".":
            warpkouho.append([a, b, cwarp+1])

def wizard():
    warp = 1
    while True:
        if len(kouho) != 0:
            tmp = kouho.pop()
        elif len(warpkouho) != 0:
            tmp = warpkouho.pop()
            warp = tmp[2]
        else:
            break
        h = tmp[0]
        w = tmp[1]
        if visited[h][w] == False:
            visited[h][w] = warp
            check_walk(h-1, w)
            check_walk(h+1, w)
            check_walk(h, w-1)
            check_walk(h, w+1)
            for n in range(5):
                for m in range(5):
                    check_warp(h-2+n, w-2+m, warp)
        if h == Dh-1 and w == Dw-1:
            print(visited[h][w]-1)
            return
    print(-1)
wizard()
        
        

### FIXED CODE ###

from collections import deque
HW = input().split()
H, W = int(HW[0]), int(HW[1])
C = input().split()
Ch, Cw = int(C[0]), int(C[1])
D = input().split()
Dh, Dw = int(D[0]), int(D[1])
route = []
for h in range(H):
    route.append(input())

visited = [[False]*W for x in range(H)]
kouho = deque()
kouho.append([Ch-1, Cw-1])
warpkouho = deque()

def check_walk(a, b):
    if 0 <= a <= H-1 and 0 <= b <= W-1: 
        if visited[a][b] == False and route[a][b] == ".":
            kouho.append([a, b])
def check_warp(a, b, cwarp):
    if 0 <= a <= H-1 and 0 <= b <= W-1:
        if visited[a][b] == False and route[a][b] == ".":
            warpkouho.append([a, b, cwarp+1])

def wizard():
    warp = 1
    while True:
        if len(kouho) != 0:
            tmp = kouho.popleft()
        elif len(warpkouho) != 0:
            tmp = warpkouho.popleft()
            warp = tmp[2]
        else:
            break
        h = tmp[0]
        w = tmp[1]
        if visited[h][w] == False:
            visited[h][w] = warp
            check_walk(h-1, w)
            check_walk(h+1, w)
            check_walk(h, w-1)
            check_walk(h, w+1)
            for n in range(5):
                for m in range(5):
                  check_warp(h-2+n, w-2+m, warp)
        if h == Dh-1 and w == Dw-1:
            print(visited[h][w]-1)
            return
    print(-1)
wizard()
s = input()
print("{} {}".format(s[:4], s[4:])

### FIXED CODE ###

s = input()
print("{} {}".format(s[:4], s[4:]))
S=input()
s=S[6:8]
if '0' in s:
  if s == '10':
     s = s
  else:
     s = s.strip('0')
n = int(s)
if n<=4:
  print('Heisei')
else:
  print('TBD')
  
  


### FIXED CODE ###

y,m,d = map(int,input().split("/"))
if m<=4:
  print('Heisei')
else:
  print('TBD')
text = input()
if text[1] == "S":
	if text[0] == "R" or text[2] == "R":
    	print(1)
    else:
        print(0)
else:
    if text[0] == "R" and text[2] == "R":
    	print(3)
    elif text[0] == "R" or text[2] == "R":
        print(2)

### FIXED CODE ###

text = input()
if text[1] == "S":
    if text[0] == "R" or text[2] == "R":
        print(1)
    else:
        print(0)
else:
    if text[0] == "R" and text[2] == "R":
        print(3)
    elif text[0] == "R" or text[2] == "R":
        print(2)
    else:
        print(1)
x, y, z = input() * 3
print(x[0] + y[1] + z[2])

### FIXED CODE ###

x, y, z = input(), input(), input()
print(x[0] + y[1] + z[2])
n=int(input())
t,a=map(int,input().split())
h=[]
for i in range(n):
    tmp=int(input)
    c=t-tmp*0.006
    h.append(abs(a-c))

m=0
for i in range(1,n):
    if(h[i]<h[m]):
        m=i
print(m)


### FIXED CODE ###

n=int(input())
t,a=map(int,input().split())
h=[]
tmp=input()
lst=tmp.split(' ')

for i in range(n):
    c=t-int(lst[i])*0.006
    h.append(abs(a-c))

m=0
for i in range(1,n):
    if(h[i]<h[m]):
        m=i
print(m+1)
def solve(H,W,h,w):
    A=[[0]*W for _ in range(H)]
    for i in range(H+1-h):
        for j in range(W+1-w):
            A[-1-i][-1-j]=-1
    A[-1][-1]=1
    if H==h:
        A[-1][-w-1]+=1
    else:
        A[-h-1][-1]+=1
    if W==w:
        A[-h-1][-1]+=1
    else:
        A[-1][-w-1]+=1
    for i in range(H)[::-1]:
        for j in range(W-1)[::-1]:
            A[i][j+1]-=A[i][j]
    for i in range(H-1)[::-1]:
        for j in range(W)[::-1]:
            A[i+1][j]-=A[i][j]
    return A

H,W,h,w=map(int, input().split())
if h*2<H+1 and w*2<W+1 or H==h and W==w or h==w==1:
    print("No")
elif H!=h==1:
    if w*2<W+1:
        print("No")
    else:
        A=solve(1,W,1,w)[0]
        print("Yes")
        for i in range(H):
            print(*A)
elif W!=w==1:
    if h*2<H+1:
        print("No")
    else:
        A=solve(1,H,1,h)[0]
        print("Yes")
        for i in range(H):
            print(*[A[i]]*W)
else:
    A=solve(H,W,h,w)
    print("Yes")
    for i in range(H):
        print(*A[i])

### FIXED CODE ###

def solve(W,w):
    A=[1]*W
    for i in range(W-1,w-1,-1):
        A[i-w]=A[i]+1
    A[w-1::w]=[-i for i in range(1,W//w+1)]
    for i in range(W-2,-1,-1):
        A[i+1]-=A[i]
    return A

H,W,h,w=map(int, input().split())
if W%w:
    print("Yes")
    A=solve(W,w)
    for _ in range(H):
        print(*A)
elif H%h:
    print("Yes")
    A=solve(H,h)
    for i in range(H):
        print(*[A[i]]*W)
else:
    print("No")
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    from collections import Counter
    n = input_int()
    A = input_int_list()
    A_cnt = Counter(A).most_common()
    A_cnt = [list(a) for a in A_cnt]
    cnt = 0
    for i in range(len(A_cnt)):
        if A_cnt[i][1] > 2:
            if A_cnt[i][1] % 2 == 1:
                cnt += A_cnt[i][1] // 2
                A_cnt[i][1] = 1
            elif A_cnt[i][1] % 2 == 0:
                cnt += (A_cnt[i][1] // 2) - 1
                A_cnt[i][1] = 2
        if A_cnt[i][1] == 2:
            if i + 1 < n:
                A_cnt[i + 1][1] -= 1
            A_cnt[i][1] = 1
            cnt += 1
    print(n - cnt * 2)
    return


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    from collections import Counter
    n = input_int()
    A = input_int_list()
    A_cnt = Counter(A).most_common()
    A_cnt = [list(a) for a in A_cnt]
    cnt = 0
    for i in range(len(A_cnt)):
        if A_cnt[i][1] > 2:
            if A_cnt[i][1] % 2 == 1:
                cnt += A_cnt[i][1] // 2
                A_cnt[i][1] = 1
            elif A_cnt[i][1] % 2 == 0:
                cnt += (A_cnt[i][1] // 2) - 1
                A_cnt[i][1] = 2
        if A_cnt[i][1] == 2:
            if i + 1 < len(A_cnt):
                A_cnt[i + 1][1] -= 1
            A_cnt[i][1] = 1
            cnt += 1
    print(n - cnt * 2)
    return


if __name__ == "__main__":
    main()
n, k = map(int, input().split())
s = input()
h = 0
for i in range(n-1):
    if s[i] == s[i+1]:
        h += 1
print(min(h + 2 * k, n - 1))

### FIXED CODE ###

print(int(input())**3)
n=int(input())
import sys
place=[]
place_0=[]
for i in range(n):
    x,y,h=map(int,input().split())
    if h==0:
        place_0.append((x,y,h))
    else:
        place.append((x,y,h))
for x in range(0,101):
    for y in range(0,101):
        for i in range(n-1):
            a=abs(place[i][0]-x)+abs(place[i][1]-y)
            b=abs(place[i+1][0]-x)+abs(place[i+1][1]-y)
            if b-a==place[i][2]-place[i+1][2]:
                count=1
            else:
                count=0
                break
        if count==1:
            H=abs(place[0][0]-x)+abs(place[0][1]-y)+place[0][2]
            print(x,y,H)
            sys.exit()
        


### FIXED CODE ###

n=int(input())
import sys
place=[]
place_0=[]
place_all=[]
for i in range(n):
    x,y,h=map(int,input().split())
    place_all.append((x,y,h))
    if h==0:
        place_0.append((x,y,h))
    else:
        place.append((x,y,h))
for x in range(0,101):
    for y in range(0,101):
        if not place==[]:
            H=abs(place[0][0]-x)+abs(place[0][1]-y)+place[0][2]
        else:
            H=1
        for i in range(0,n):
            d=abs(place_all[i][0]-x)+abs(place_all[i][1]-y)
            if place_all[i][2]>0:
                if H==place_all[i][2]+d:
                    count=1
                else:
                    count=0
                    break
            else:
                if d>=H:
                    count=1
                else:
                    count=0
                    break
        if count==1:
            print(x,y,H)
            sys.exit()
a = int(input())
b = a*pi()
print(b)

### FIXED CODE ###

import math
a = int(input())
b = 2*a*math.pi
print(b)
a, b =int(input())
if a < b:
    print("a < b")
if a > b:
    print("a > b")
if a == b:
    print("a == b")

### FIXED CODE ###

a, b = [int(i) for i in input().split()]

if a < b:
    print("a < b")
elif a > b:
    print("a > b")
else:
    print("a == b")
import collections
import math
def calculateProb(counts):
    ways = 0
    for key in counts.keys():
        if counts[key] < 2:
            continue
        if counts[key] in cache:
            ways += cache[counts[key]]
        else:
            val = counts[key]
            cache[val] = math.factorial(val)/math.factorial(2)/math.factorial(val - 2)
            ways += cache[val]
    return ways

        


n = int(input())

values = list(map(int, input().split(' ')))
counts = collections.Counter(values)

cache = {}

for k in range(n):
    curVal = values[k]
    counts[curVal] -= 1
    print(int(calculateProb(counts)))
    counts[curVal] += 1

### FIXED CODE ###

import collections
import math
def calculateProb(counts):
    ways = 0
    for key in counts.keys():
        if counts[key] < 2:
            continue
        else:
            val = counts[key]
            ret = val*(val-1)/2
            ways += ret
    return ways

def getfact(val):
    if val < 2:
        return 0
    return val*(val-1)/2


n = int(input())

values = list(map(int, input().split(' ')))
counts = collections.Counter(values)

ways = calculateProb(counts)
for k in range(n):
    curVal = values[k]
    count = counts[curVal]
    temp = ways
    ways = ways - getfact(count)  + getfact(count - 1)
    print(int(ways))
    ways = temp
import math
x1, y1, x2, y2=map(int, input().split())
print("{0:.8f}".format(math.sqrt((x2-x1)**2+(y2-y1)**2)))

### FIXED CODE ###

import math
x1, y1, x2, y2=map(float, input().split())
print("{0:.8f}".format(math.sqrt((x2-x1)**2+(y2-y1)**2)))
umber=list(map(int,input().split()))
H,W,K=number[0],number[1],number[2]
answer=0
nums=[]
for i in range(H):
    tmp=list(str(input()))
    nums.append(tmp)
count=0
for cowmask in range(1<<H):
    for rowmask in range(1<<W):
        count=0
        for x in range(H):
            for y in range(W):
                if (cowmask>>x)&1==0 and (rowmask>>y)&1==0 and nums[x][y]=="#":
                    count+=1
        if count==K:
            answer+=1
            
print(answer)

### FIXED CODE ###

number=list(map(int,input().split()))
H,W,K=number[0],number[1],number[2]
M=[]
for i in range(H):
    tmp=list(input())
    M.append(tmp)
answer=0
for rowmask in range(1<<W):
    for cowmask in range(1<<H):
        count=0
        for x in range(H):
            for y in range(W):
                if (rowmask>>y)&1==0 and (cowmask>>x)&1==0 and M[x][y]=="#":
                    count+=1
        if count==K:
            answer+=1
print(answer)
# ??±???????????¢?´¢(Depth First Search)

def DFS(n = 1, A = [0], i = 0, d = [0], f = [0], time = 1):
    for j in range(n):
        if A[i][j] == 1 and d[j] == 0:
            time = time + 1
            d[j] = time
            DFS(n, A, j, d, f, time)
    time = time + 1
    f[i] = time

n = int(raw_input())
A = [0] * n
for i in range(n):
    A[i] = [0] * n

for i in range(n):
    value = map(int, raw_input().split())
    u = value[0] - 1
    k = value[1]
    nodes = value[2:]
    for i in range(k):
        v = nodes[i] - 1
        A[u][v] = 1

d = [0] * n
f = [0] * n
time = 1
d[0] = time
DFS(n, A, 0, d, f, time)

for i in range(n):
    print(str(i + 1) + " " + str(d[0]) + " " + str(f[0]))

### FIXED CODE ###


def DFS(n = 1, i = 0, time = 1):
    for j in range(n):
        if A[i][j] == 1 and d[j] == 0:
            time = time + 1
            d[j] = time
            time = DFS(n, j, time)
    time = time + 1
    f[i] = time
    return time

n = int(raw_input())
A = [0] * n
for i in range(n):
    A[i] = [0] * n

for i in range(n):
    value = map(int, raw_input().split())
    u = value[0] - 1
    k = value[1]
    nodes = value[2:]
    for j in range(k):
        v = nodes[j] - 1
        A[u][v] = 1

d = [0] * n
f = [0] * n

time = 0
for i in range(n):
    if d[i] == 0:
        time = time + 1
        d[i] = time
        time = DFS(n, i, time)

for i in range(n):
    print(str(i + 1) + " " + str(d[i]) + " " + str(f[i]))
S = input()
if S = 'AAA' and S = 'BBB':
  print('No')
else:
  print('No')

### FIXED CODE ###

S = input()
if S == 'AAA' or S == 'BBB':
  print('No')
else:
  print('Yes')
A,B = map(float,input().split())
Aint = int(A)
Bint = int(B*100)
print(int((A*B100)//100))

### FIXED CODE ###

from decimal import *
A,B = map(str,input().split())
print(int(Decimal(A)*Decimal(B)))
N = int(input())
data = list(map(int,input().split()))
remain = [0]*N
res = 0
while max(remain) == 0:
    exist_odd: bool = False
    for i in range(N):
        if data[i]%2 == 1:
            exist_odd = True
    if exist_odd == True:
        break
        
    for i in range(N):
        data[i] = data[i]//2
    
    res += 1
        
print(res)

### FIXED CODE ###

n = input()
a = list(map(int, input().split()))
cnt = 0
while all(i%2==0 for i in a):
    a = [i/2 for i in a]
    cnt += 1
print(cnt)
5
30 44
26
18
81
18
6

### FIXED CODE ###

import math
N=int(input())
D,X=map(int,input().split())
choco=[0]*D
ans=0
for _ in range(N):
  A=int(input())
  ans+=math.ceil(D/A)
print(ans+X)
a, b, x = [ int(v) for v in input().split() ]
v = a*a*b

if x < v/2:
    print(math.atan(b*b*a/(2*x))*(180/math.pi))
else:
    print(math.atan(2*(v-x)/(a**3))*(180/math.pi))

### FIXED CODE ###

import math
a, b, x = [ int(v) for v in input().split() ]
v = a*a*b

if x < v/2:
    print(math.atan(b*b*a/(2*x))*(180/math.pi))
else:
    print(math.atan(2*(v-x)/(a**3))*(180/math.pi))
MOD = 10 ** 9 + 7
import numpy as np
n, m = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

# 前計算
for i in range(n - 1):
    x[i] = x[i + 1] - x[i]

for i in range(m - 1):
    y[i] = y[i + 1] - y[i]

N = [n - 1]
for i in range((n)//2 - 1):
    N.append((N[i] + (n - 1 - 2 * (i + 1))) % MOD)

M = [m - 1]
for i in range((m)//2 - 1):
    M.append((M[i] + (m - 1- 2 * (i + 1))) % MOD)

if N[0] % 2 == 0:
    N += N[::-1]
elif N[0] != 1:
    N += N[1::-1]
if M[0] % 2 == 0:
    M += M[::-1]
elif M[0] != 1:
    M += M[1::-1]

# print (N)
# print (M)

N = np.array(N, dtype = 'int64')
M = np.array(M, dtype = 'int64')

X = np.array(x[:-1], dtype = 'int64')
Y = np.array(y[:-1], dtype = 'int64')

# print (N)
# print (M)
# print (X)
# print (Y)

X *= N
Y *= M

X %= MOD
Y %= MOD

# print (X)
# print (Y)
# print ((np.sum(X) * np.sum(Y)) % MOD)

# X_sum = np.sum(X) % MOD
# Y_sum = np.sum(Y) % MOD

X_sum = 0
for i in X:
    X_sum += i
    X_sum %= MOD

Y_sum = 0
for i in Y:
    Y_sum += i
    Y_sum %= MOD

print ((X_sum * Y_sum) % MOD)


### FIXED CODE ###

MOD = 10 ** 9 + 7
n, m = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

# 前計算
for i in range(n - 1):
    x[i] = x[i + 1] - x[i]

for i in range(m - 1):
    y[i] = y[i + 1] - y[i]

N = [n - 1]
for i in range(n - 3, 0, -2):
    N.append(N[-1] + i)
    # N.append((N[i] + (n - 1 - 2 * (i + 1))) % MOD)

M = [m - 1]
for i in range(m - 3, 0, -2):
    M.append(M[-1] + i)
    # M.append((M[i] + (m - 1- 2 * (i + 1))) % MOD)

if N[0] % 2 == 0:
    N += N[::-1]
elif N[0] != 1:
    N += N[-2::-1]

if M[0] % 2 == 0:
    M += M[::-1]
elif M[0] != 1:
    M += M[-2::-1]

# print (x)
# print (y)
# print (N)
# print (M)

if len(x) - 1 > len(N):
    while True:
        pass

if len(y) - 1 > len(M):
    while True:
        pass


X_sum = 0
for i in range(n - 1):
    X_sum += x[i] * N[i]
    X_sum %= MOD

Y_sum = 0
for i in range(m - 1):
    Y_sum += y[i] * M[i]
    Y_sum %= MOD

print ((X_sum * Y_sum) % MOD)
N, M = map(int, input().split())
H = [0] + list(map(int, input().split()))
kouho = [i + 1 for i in range(N)]
for i in range(M):
    a, b = map(int, input(),split())
    if H[a] > H[b] and b in kouho:
        kouho.remove(b)
    elif H[a] < H[b] and a in kouho:
        kouho.remove(a)
    elif H[a] == H[b]:
        if a in kouho:
            kouho.remove(a)
        if b in kouho:
            kouho.remove(b)
print(len(kouho))


### FIXED CODE ###

N, M = map(int, input().split())
H = [0] + list(map(int, input().split()))
kouho = set([i + 1 for i in range(N)])
hazure = set()
for i in range(M):
    a, b = map(int, input().split())
    Ha = H[a]
    Hb = H[b]
    if Ha >= Hb:
        hazure.add(b)
    if Ha <= Hb:
        hazure.add(a)
ans = kouho - hazure
print(len(ans))
import sys

def dfs(x, y, sym):
	tile[x][y] = "."
	for i in range(len(DX)):
		nx = x + DX[i]
		ny = y + DY[i]
		if 0<=nx and nx<N and 0<=ny and ny<M and tile[nx][ny] is sym:
			dfs(nx, ny, sym)

def solve():
	res = 0
	for i in range(N):
		for j in range(M):
			sym = tile[i][j]
			if tile[i][j] != ".":
				if tile[i][j] is sym:
					dfs(i, j, sym)
					res += 1
	print(res)

counter=0
flg=1
DX = [-1, 0, 1, 0]
DY = [0, -1, 0, 1]
sys.setrecursionlimit(10**7)
while True:
	line = input()
	counter += 1
	if flg is 1:
		nums = line.split(" ")
		N = int(nums[0])
		M = int(nums[1])
		tile = [[0 for i in range(N)] for j in range(M)]
		flg=0
	else:
		tile[counter-2] = list(line)
	if N is 0 and M is 0:
		break
	if counter-1 is M:
		solve()
		flg = 1
		counter = 0

### FIXED CODE ###

# -*- coding:utf-8 -*-
import sys
def dfs(x, y, sym):
	tile[x][y] = "."
	for i in range(len(DX)):
		nx = x + DX[i]
		ny = y + DY[i]
		if (0<=nx and nx<N and 0<=ny and ny<M and tile[nx][ny] is sym):
			dfs(nx, ny, sym)

def solve():
	res = 0
	for i in range(N):
		for j in range(M):
			sym = tile[i][j]
			if tile[i][j] != ".":
				if tile[i][j] is sym:
					dfs(i, j, sym)
					res += 1
	print(res)

counter=0
DX = [-1,0,1,0]
DY = [0,-1,0,1]
sys.setrecursionlimit(10**7)
while True:
	line = input()
	if " " in line:
		nums = line.split(" ")
		N = int(nums[0])
		M = int(nums[1])
		tile = [[0 for i in range(M)] for j in range(N)]
	else:
		tile[counter-1] = list(line)
	if N is 0 and M is 0:
		break
	counter += 1
	if counter-1 is N:
		solve()
		counter = 0
def main():

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

    ab = [tuple(map(int, input().split())) for _ in range(N)]

    INF = float("inf")
    dp = [[INF for _ in range(H+1)] for _ in range(N+1)]
    dp[0][0] = 0


    for i in range(1, N+1):
        for h in range(H+1):

            tmp = dp[i][h-ab[i-1][0]] if dp[i][h-ab[i-1][0]] != INF else 0
            #if ab[i-1][0] <= h:
            dp[i][h] = min(dp[i-1][h], tmp + ab[i-1][1])

            #else:
            #    dp[i][h] = dp[i-1][h]

            #if i == 3 and h == 9:
            #    print(dp[i][h-ab[i-1][0]], h, ab[i-1][0], tmp, ab[i-1][1] )

    print(dp[-1][H])
    #print(dp)

if __name__ == "__main__":
    main()

### FIXED CODE ###


def main():

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

    ab = [tuple(map(int, input().split())) for _ in range(N)]

    INF = float("inf")
    dp = [[INF for _ in range(H+1)] for _ in range(N+1)]
    dp[0][0] = 0


    for i in range(1, N+1):
        for h in range(H+1):
            aaa = h-ab[i-1][0] if h-ab[i-1][0] >= 0 else 0
            tmp = dp[i][aaa] if dp[i][aaa] != INF else 0
            dp[i][h] = min(dp[i-1][h], tmp + ab[i-1][1])

    print(dp[-1][H])


if __name__ == "__main__":
    main()
n=int(input())
arr=list(map(int,input().strip().split()))
k=int(input())
d=dict()
for i in range(n):
    d[arr[i]]=0
for i in range(n):
    d[arr[i]]=d[arr[i]]+1
sumi=0
for i in range(n):
    sumi=sumi+arr[i]
for i in range(k):
    a,b=[int(a) for a in input().split()]
    e1=d[a]*a
    e2=d[b]*b
    sumi=sumi+e2-e1
    print(sumi)
    d[b]=d[b]+d[a]
    d[a]=0
    
    

    

### FIXED CODE ###

n=int(input())
arr=list(map(int,input().strip().split()))
k=int(input())
d=dict()
for i in range(10**5+1):
    d[i]=0
for i in range(n):
    d[arr[i]]=d[arr[i]]+1
sumi=0
for i in range(n):
    sumi=sumi+arr[i]
for i in range(k):
    a,b=[int(a) for a in input().split()]
    e1=d[a]
    d[b]=d[b]+e1
    sumi=sumi+(e1)*(b-a)
    print(sumi)
    d[a]=0
H,W=map(int,input().solit())
h,w=map(int,input().split())

print(h*W+H*w-h*w)

### FIXED CODE ###

H,W=map(int,input().split())
h,w=map(int,input().split())

print(H*W-h*W-H*w+h*w)
from math import gcd


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


def greatLCM(a):
    ans = lcm(a[0], a[1])
    p = 2
    while p < len(a):
        ans = lcm(ans, a[p])
        p += 1
    return ans


n = int(input())
arr = list(map(int, input().split()))
g = greatLCM(arr)
answer = 0
for i in arr:
    answer += g / i
    answer %= 1e9 + 7

print(int(answer))


### FIXED CODE ###

import fractions

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

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

def solve():
    memo = A[0]
    for i in range(1, N):
        memo = lcm(memo, A[i])

    ans = 0
    for i in range(N):
        ans += memo // A[i]

    return ans % (10 ** 9 + 7)

print(solve())