Harryxun/stf_run huggingface dataset:
n,m,k=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
from collections import deque
p=deque(a)
q=deque(b)

import sys
time=0
ans=0
while(1):
    if len(p)==0 and len(q)==0:
        print(ans)
        sys.exit()
    if len(p)>0 and len(q)>0:
        if p[0]>q[0]:
            time=time+q.popleft()
            if time>k:
                print(ans)
                sys.exit()
            else:
                ans=ans+1
        elif p[0]<q[0]:
            time=time+p.popleft()
            if time>k:
                print(ans)
                sys.exit()
            else:
                ans=ans+1
        else:
            if p[1]>=q[1]:
                la=q.popleft()
                if la==1000000000:
                    print(ans)
                    sys.exit()
                time=time+la
                if time>k:
                    print(ans)
                    sys.exit()
                else:
                    ans=ans+1
            elif p[0]<q[0]:
                la=p.popleft()
                if la==1000000000:
                    print(ans)
                    sys.exit()
                time=time+la
                if time>k:
                    print(ans)
                    sys.exit()
                else:
                    ans=ans+1
    elif len(p)==0:
        la=q.popleft()
        if la==1000000000:
            print(ans)
            sys.exit()
        time=time+la
        if time>k:
            print(ans)
            sys.exit()
        else:
            ans=ans+1
    elif len(q)==0:
        la=p.popleft()
        if la==1000000000:
            print(ans)
            sys.exit()
        time=time+la
        if time>k:
            print(ans)
            sys.exit()
        else:
            ans=ans+1


### FIXED CODE ###

#Aの上からi冊、Bの上からj冊をとりi+jを条件を満たしながら最大化したい
#累積和と二分探索の練習問題
#値を固定するという概念。iが決まればjが決まる
from bisect import bisect_left
from itertools import accumulate
n,m,k=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
A=[0]+list(accumulate(a))
B=[0]+list(accumulate(b))

ans=0
sup_i=bisect_left(A,k+1)
for i in range(sup_i):
  ans=max(ans,i+bisect_left(B,k-A[i]+1)-1)
 
print(ans)
def calc( s , k , n):

	bruh = {}
	for i  in range(1, n + 1): # length
		for j in range( n - ( i - 1)): # start 
			bruh[s[j: j + i:]] = 0
	another = bruh.keys()
	another = sorted(another)
	print( another[k - 1])

s = raw_input()

k = int(raw_input())

n = len(s)
 
calc( s , k , n)

### FIXED CODE ###

def calc( s , k , n):

	bruh = {}
	for i  in range(1, k + 1): # length
		for j in range( n - ( i - 1)): # start 
			bruh[s[j: j + i:]] = 0
	another = bruh.keys()
	another = sorted(another)
	print( another[k - 1])

s = input()

k = int(input())

n = len(s)
 
calc( s , k , n)
import sys

# import bisect

# from collections import Counter, deque, defaultdict

# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
import math

# import numpy as np

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    q = int(input())

    for i in range(q):
        a, b = list(map(int, readline().split()))
        if a > b:
            a, b = b, a

        if a == b or a + 1 == b:
            print(2 * a - 2)
        else:
            ab = a * b
            sqab = math.floor(math.sqrt(ab))

        if sqab * (sqab + 1) >= ab:
            print(2 * sqab - 2)
        else:
            print(2 * sqab - 1)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

import bisect

# from collections import Counter, deque, defaultdict

# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
import math

# import numpy as np

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    q = int(input())

    for i in range(q):
        a, b = list(map(int, readline().split()))

        if a > b:
            a, b = b, a

        if a == b or a + 1 == b:
            print(2 * a - 2)
        else:
            ab = a * b
            ok = 0
            ng = int(ab ** 0.5) + 1000000
            while abs(ng - ok) > 1:
                mid = (ok + ng) // 2
                if mid ** 2 < ab:
                    ok = mid
                else:
                    ng = mid
            c = ok

            if c * (c + 1) < ab:
                print(2 * c - 1)
            else:
                print(2 * c - 2)


if __name__ == '__main__':
    main()
import numpy as np

m = np.array(int(input()))

a = 1
b = m

# for i in reversed(range(2, int(round(np.sqrt(n))))):
#     if n % i ==  0:
#         a = int(i)
#         b = int(n / i)
#         break

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

soin = prime_factorize(n)

soin_r = soin[::-1]

tmp = 1
for i in range(len(soin) // 2):
    tmp *= soin[i]

zan = m / tmp

print(int(tmp + zan - 2))

"""
10
5

50
13

10000000019
10000000018

"""

### FIXED CODE ###

n = int(input())
i = 1
ans = n
 
while i * i <= n:
    j, m = divmod(n, i)
    if m == 0:
        ans = min(ans, i + j - 2)
    i += 1
 
print(ans)
from itertools import product

H, W, K = map(int, input().split())

C = [list(input().split()) for _ in range(H)]

ans = 0

for row_bit in product(range(2), repeat = H):
    for col_bit in product(range(2), repeat = W):
        cnt = 0
        for row in range(H):
            for col in range(W):
                if C[row][col] == '#' and (row_bit[row] and col_bit[col]):
                    cnt += 1
            if cnt == K:
                ans += 1
print(ans)

### FIXED CODE ###

from itertools import product

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

ans = 0

for row_bit in product(range(2), repeat=h):
    for col_bit in product(range(2), repeat=w):
        cnt = 0
        for row in range(h):
            for col in range(w):
                if c[row][col] == "#" and (row_bit[row] and col_bit[col]):
                    cnt += 1
        if cnt == k:
            ans += 1

print(ans)
l = map(int, input().split())
l.sort()

print(l[2] * 10 + sum(l[:2]))

### FIXED CODE ###

l = list(map(int, input().split()))
l.sort()

print(l[2] * 10 + sum(l[:2]))
n = int(input())

sayTable = []
for i in range(n):
	a = int(input())
	
	sayArray = []
	for j in range(a):
		x, y = [int(v) for v in input().split()]
		sayArray.append((x-1, y+1))
sayTable.append(sayArray)

def count(honest):
	count = 0
	for v in honest:
		if v == 2:
			count += 1
	return count

def checkHonest(sayArray, honest):
	for x, y in sayArray:
		if y == 2 and honest[x] != 2:
return False
	return True

def checkHonestAll(sayTable, honest):
	for i in range(n):
		h = honest[i]
		if h != 2:
			continue
		for x, y in sayArray:
		if honest[x] != y:
return False
	return True

def setHonest(sayArray, honest):
	for x, y in sayArray:
		honest[x] = y

def search(sayTable, honest, i):
	if i >= n;
		if checkHonestAll(sayTable, honest):
return count(honest)
else:
	return 0

count = 0
h = honest[i]
if (h == 0 or h == 2) and checkHonest(sayTable, honest):
copyHonest = honest[:]
setHonest(honest, sayTable[i])
copyHonest[i] = 2
c = search(sayTable, copyHonest, i + 1)
if count < c:
	count = c

honest[i] = 1
c = search(sayTable, honest, i+1)
	if count < c:
		count = c
return count

print(search(sayTable, [0] * n, 0));

### FIXED CODE ###

n = int(input())

sayTable = []
for i in range(n):
	a = int(input())
	
	sayArray = []
	for j in range(a):
		x, y = [int(v) for v in input().split()]
		sayArray.append((x-1, y+1))
	sayTable.append(sayArray)

def countHonest(honest):
	count = 0
	for v in honest:
		if v == 2:
			count += 1
	return count

def checkHonest(sayArray, honest):
	for x, y in sayArray:
		if honest[x] == 0:
				continue
		if y == 2 and honest[x] != 2:
			return False
	return True

def checkHonestAll(sayTable, honest):
	for i in range(n):
		h = honest[i]
		if h != 2:
			continue
		sayArray = sayTable[i]
		for x, y in sayArray:
			if y != honest[x]:
				return False
	return True

def setHonest(sayArray, honest):
	for x, y in sayArray:
		honest[x] = y

def search(sayTable, honest, i):
	if i >= n:
		if checkHonestAll(sayTable, honest):
			return countHonest(honest)
		else:
			return 0

	count = 0
	h = honest[i]
	sayArray = sayTable[i]
	if (h == 0 or h == 2) and checkHonest(sayArray, honest):
		copyHonest = honest[:]
		setHonest(sayArray, copyHonest)
		copyHonest[i] = 2
		c = search(sayTable, copyHonest, i+1)
		if count < c:
			count = c

	honest[i] = 1
	c = search(sayTable, honest, i+1)
	if count < c:
		count = c
	return count

print(search(sayTable, [0] * n, 0))
[a11, a12, a13],[a21, a22, a23],[a31, a32, a33] = [input().split() for l in range(3)]

if : a == [a11, a12, a13]
    print(Yes)
elif :is [a11, a22, a33]
    print(Yes)
elif :is [a11, a21, a31]
    print(Yes)
elif :is [a12, a22, a32]
    print(Yes)
elif :is [a13, a23, a33]
    print(Yes)
elif :is [a13, a22, a31]
    print(Yes)
elif :is [a21, a22, a23]
    print(Yes)
elif :is [a31, a32, a33]
    print(Yes)
else:
    print(No)

### FIXED CODE ###

a,b,c=map(int,input().split())
d,e,f=map(int,input().split())
g,h,i=map(int,input().split())
N=int(input())
L=[int(input()) for i in range(N)]
if a in L and b in L and c in L:
  print('Yes')
elif d in L and e in L and  f in L:
  print('Yes')
elif g in L and h in L and  i in L:
  print('Yes')
elif a in L and d in L and  g in L:
  print('Yes')
elif b in L and e in L and  h in L:
  print('Yes')
elif c in L and f in L and  i in L:
  print('Yes')
elif a in L and e in L and  i in L:
  print('Yes')
elif c in L and e in L and  g in L:
  print('Yes')
else:
  print('No')
S, T = input().split()
 
n = len(S) - len(T) + 1
min = len(T)
 
for a in range(n):
  count = 0 
	for b in range(len(T)):
      if S[a+b] != T[b]:
        count += 1
  if count < min:
    min = count
print(min)

### FIXED CODE ###

x = [input() for i in range(2)]
S = x[0]
T = x[1]
moji = len(T)

for a in range(len(S) - len(T) + 1):
  count = 0
  for b in range(len(T)):
    
    if S[a+b] != T[b]:
      count += 1
  if count < moji:
    moji = count

print(moji)
from itertools import combinations
l,r = map(int,input().split())

sc = list(combinations(range(l%2019,(r+1)%2019),2))

print(min([s[0]*s[1] for s in sc]))


### FIXED CODE ###

l,r = map(int,input().split())

a = []
r = min(r,l+2019)
for i in range(l,r):
    for j in range(i+1,r+1):
        a.append(i*j%2019)

print(min(a))
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n,a,b = map(int,ipt().split())
    if a*b < n or a+b-1 > n:
        print(-1)
        exit()
    ans = [str(b-i) for i in range(b)]
    si = n-a+2
    ue = n+1
    i = 0
    while True:
        if si <= b:
            break
        ans[i] += " "+" ".join(map(str,range(si,ue)))
        ue = si
        si -= a-1
        i += 1
    if i < b and b+1 < ue-1:
        ans[i] += " "+" ".join(map(str,range(b+1,ue)))
    print(" ".join(ans))
    return

if __name__ == '__main__':
    main()


### FIXED CODE ###

import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n,a,b = map(int,ipt().split())
    if a*b < n or a+b-1 > n:
        print(-1)
        exit()
    ans = [str(b-i) for i in range(b)]
    si = n-a+2
    ue = n+1
    i = 0
    while True:
        if si <= b or a == 1:
            break
        ans[i] += " "+" ".join(map(str,range(si,ue)))
        ue = si
        si -= a-1
        i += 1
    if i < b and b+1 < ue:
        ans[i] += " "+" ".join(map(str,range(b+1,ue)))
    print(" ".join(ans))
    return

if __name__ == '__main__':
    main()
a = [int(input()) for i in range(4)]
count = 0

for (i = 0; i <= a[0]; i++) :
  for (j = 0; j <= a[1]; j++) :
    for (k = 0; k <= a[2]; k++) :
      sum = 500*i + 100*j + 50*k
      if sum == a[3] :
        count += 1
print(count)

### FIXED CODE ###

a = [int(input()) for i in range(4)]
count = 0

for i in range(a[0]+1) :
  for j in range(a[1]+1) :
    for k in range(a[2]+1) :
      sum = 500*i + 100*j + 50*k
      if sum == a[3] :
        count += 1
print(count)
import math
N, K = list(map(int, input().split()))

def combo(n, k):
    x = math.factorial(n)//(math.factorial(k)*math.factorial(n-k))
    return x

if N == K:
    print(1)
else:
    for i in range(1,K+1):
        k = combo(N-K+1,i) * combo(K-1,i-1)
        ans = k%(math.pow(10,9)+7)
        print("%d" %(ans))


### FIXED CODE ###

import math
N, K = list(map(int, input().split()))

def combo(n, k):
    x = math.factorial(n)//(math.factorial(k)*math.factorial(n-k))
    return x

for i in range(1,K+1):
    if N-K+1 < i or K-1 < i-1:
        print(0)
    else:
        k = combo(N-K+1,i) * combo(K-1,i-1)
        ans = k%(10**9+7)
        print("%d" %(ans))
def main():
    N, K  = map(int, input().split())
    h = list(map(int, input().split()))
    dp = [10**9] * N
    dp[0] = 0

    for i in range(N):
        dp[i] = min([dp[i-j] + abs(h[i]-h[i-j]) for j in range(1, min(K,i)+1)])
    print(dp[N-1])

if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    N, K  = map(int, input().split())
    h = list(map(int, input().split()))
    dp = [10**9] * N
    dp[0] = 0

    for i in range(N):
        dp[i] = min([dp[i-j] + abs(h[i]-h[i-j]) for j in range(min(K,i)+1)])
    print(dp[N-1])

if __name__ == "__main__":
    main()
n,m=map(int,input().split())
i1=[input() for _ in range(n)]
i2=[input() for _ in range(m)]
ans="No"
for i in range(n-m+1):
    for j in range(n-m+1):
        if i1[i][j:m+j]==i2[0] and i1[i+1][j:j+m]==i2[1]:
            ans="Yes"
print(ans)

### FIXED CODE ###

n,m=map(int,input().split())
i1=[input() for _ in range(n)]
i2=[input() for _ in range(m)]
ans="No"
for i in range(n-m+1):
    for j in range(n-m+1):
        count=0
        for k in range(m):
            if i1[i+k][j:m+j]==i2[k]:
                count+=1
                if count==m:
                    ans="Yes"
print(ans)
print(x**3)

### FIXED CODE ###

x = int(input())
print (x ** 3)
n = int(input())
s = input()

black_right, min_val = 0, 2000001
white_left = s.count('.')

for moji in range(s):
    if moji == '.':
        white_left -=1
    else:
        black_right += 1
    min_val = min(min_val, white_left+black_right)

print(min_val)

### FIXED CODE ###

import sys
input = sys.stdin.readline
 
 
def main():
    N = int(input())
    S = input().strip()
    ans = 0
    x = 0
    for c in S:
        if c == "#":
            x += 1
        else:
            if x > 0:
                ans += 1
                x = max(x-1, 0)
    print(ans)
 
 
if __name__ == '__main__':
    main()
Si = int(input())
S1 = int(str(Si[-3]))
S2 = int(str(Si[-2]))
S3 = int(str(Si[-1]))
result = 0
if S1:
  result += 1
if S2:
  result += 1
if S3:
  result += 1
print(result)

### FIXED CODE ###

Si = input()
S1 = int(Si[0])
S2 = int(Si[1])
S3 = int(Si[2])
n = 0
if S1:
  n += 1
if S2:
  n += 1
if S3:
  n += 1
print(n)
import numpy as np

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

dp = [[0]*(W+1) for _ in range(N+1)]

for i in range(1, N+1):
  w, v = map(int, input().split())
  for j in range(1, W+1):
    if j >= w:
      dp[i][j] = max(dp[i-1][j], dp[i-1][j-w]+v)
    else:
      dp[i][j] = dp[i-1][j]

print(dp[N][W])

### FIXED CODE ###

N, W = map(int, input().split())
items = [list(map(int, input().split())) for _ in range(N)]

table = {i: [0]*(W+1) for i in range(N+1)}
def dp(N, W):
  for i in range(1, N+1):
    w, v = items[i-1]
    for j in range(1, W+1):
      if w <= j:
        table[i][j] = max(table[i-1][j-w]+v, table[i-1][j])
      else:
        table[i][j] = table[i-1][j]
  return table[N][W]

print(dp(N, W))
S = input()
if S[5] == "1":
  print("TBD")
  elif int(S[6]) > 4:
    print("TBD")
else:
  print("Heisei")


### FIXED CODE ###

S = input()
if S[5] == "1":
  print("TBD")
elif int(S[6]) > 4:
  print("TBD")
else:
  print("Heisei")
from itertools import accumulate

N = int(input())
tu = tuple(map(int,input().split()))

p = list(accumulate(tu))[N-1]

if p > 1000000000000000000:
    print(-1)

else:
    print(p)

### FIXED CODE ###

A, B = map(int,input().split())
print(A*B)
x = input()

for i in x:

        if x == 0:
        break

    print("Case " +i+ ": " + x)

### FIXED CODE ###

print(*sorted(input().split(" ")))
N = int(input())
A = [ord(a) - 97 for a in input()]
NN = 5
BIT=[[0]*(2**NN+1) for _ in range(26)]
 
def addbit(t, i, x):
    while i <= 2**NN:
        BIT[t][i] += x
        i += i & (-i)

def getsum(t, i):
    ret = 0
    while i != 0:
        ret += BIT[t][i]
        i -= i&(-i)
    return ret


for i, a in enumerate(A):
    BIT[a][i+1] += 1

for t in range(26):
    B = [0] * (2**NN+1)
    for i in range(1<<NN):
        B[i+1] = B[i] + BIT[t][i]
    for i in range(1<<NN):
        BIT[t][i] = B[i] - B[i - (i & (-i))]

Q = int(input())
for _ in range(Q):
    a, b, c = input().split()
    if a == "1":
        b = int(b)
        c = ord(c) - 97
        t = A[b-1]
        addbit(t, b, -1)
        addbit(c, b, 1)
    else:
        b, c = int(b), int(c)
        s = 0
        for t in range(26):
            s += 1 if getsum(t, c+1) - getsum(t, b) else 0
        print(s)

### FIXED CODE ###

N = int(input())
A = [ord(a) - 97 for a in input()]
NN = 19
BIT=[[0]*(2**NN+1) for _ in range(26)]
 
def addbit(t, i, x):
    while i <= 2**NN:
        BIT[t][i] += x
        i += i & (-i)

def getsum(t, i):
    ret = 0
    while i != 0:
        ret += BIT[t][i]
        i -= i&(-i)
    return ret

for i, a in enumerate(A):
    BIT[a][i+1] += 1

for t in range(26):
    B = [0] * (2**NN+1)
    for i in range(1<<NN):
        B[i+1] = B[i] + BIT[t][i]
    for i in range(1<<NN):
        BIT[t][i] = B[i] - B[i - (i & (-i))]

Q = int(input())
for _ in range(Q):
    a, b, c = input().rstrip().split()
    if a == "1":
        b = int(b)
        c = ord(c) - 97
        t = A[b-1]
        addbit(t, b+1, -1)
        addbit(c, b+1, 1)
        A[b-1] = c
    else:
        b, c = int(b), int(c)
        s = 0
        for t in range(26):
            s += 1 if getsum(t, c+1) - getsum(t, b) else 0
        print(s)
for i in range(int(input())):
    xa, ya, xb, yb = map(int, input().split(' '))
    n = int(input())
    ip = []
    for j in range(n):
        xs, ys, xt, yt, o, l = map(int, input().split(' '))
        d = (xb - xa) * (yt - ys) - (yb - ya) * (xt - xs)
        if d == 0:
            continue
        t0 = ((yt - ys) * (xs - xa) - (xt - xs) * (ys - ya)) / d
        t1 = ((yb - ya) * (xs - xa) - (xb - xa) * (ys - ya)) / d
        if (t0 >= 0 and t0 <= 1) and (t1 >= 0 and t1 <= 1):
            ip.append((t0, o == l))
    count = 0
    if len(ip) > 0
        ip.sort(key=lambda x: x[0])
        for j in range(len(ip) - 1):
            if ip[i][1] != ip[i + 1][1]:
                count += 1
    print(count)

### FIXED CODE ###

for i in range(int(input())):
    xa, ya, xb, yb = map(int, input().split())
    n = int(input())
    ip = []
    for j in range(n):
        xs, ys, xt, yt, o, l = map(int, input().split())
        d = (xb - xa) * (yt - ys) - (yb - ya) * (xt - xs)
        if d == 0:
            continue
        t0 = ((yt - ys) * (xs - xa) - (xt - xs) * (ys - ya)) / d
        t1 = ((yb - ya) * (xs - xa) - (xb - xa) * (ys - ya)) / d
        if (t0 > 0 and t0 < 1) and (t1 > 0 and t1 < 1):
            ip.append((t0, o == l))
    count = 0
    if len(ip) > 0:
        ip.sort(key=lambda x: x[0])
        for j in range(len(ip) - 1):
            if ip[j][1] != ip[j + 1][1]:
                count += 1
    print(count)
N,M = map(int,input().split())

V = [[] for _ in range(M)]

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

from collections import deque

q = deque([0])

ans = [-1]*N
ans[0] = 0

while q:
    v = q.popleft()
    for nv in V[v]:
        if ans[nv] == -1:
            ans[nv] = v + 1
            q.append(nv)

print("Yes")
print(*ans[1:],sep="\n")


### FIXED CODE ###

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

V = [[] for _ in range(N)]

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

from collections import deque

q = deque([0])

ans = [-1]*N
ans[0] = 0

while q:
    v = q.popleft()
    for nv in V[v]:
        if ans[nv] == -1:
            ans[nv] = v + 1
            q.append(nv)

print("Yes")
print(*ans[1:],sep="\n")
from math import ceil
n,k = map(int,input().split())
a = [int(i) for i in input().split()]
l = -1
r = 10**9
while l+1 < r:
    m = (l+r)//2
    cnt = 0
    for i in range(n):
        cnt += ceil(a[i]/m)-1
    if cnt <= k: r = m
    else: l = m
print(r)

### FIXED CODE ###

n,k = map(int,input().split())
a = [int(i) for i in input().split()]
l = 0
r = 10**9
while l+1 < r:
    m = (l+r)//2
    cnt = 0
    for i in range(n): cnt += (a[i]+m-1)//m-1
    if cnt > k: l = m
    else: r = m
print(r)
n = int(input())
a = [input() for i in range(n)]
a_swap = 0

flag = 1
while flag:
    flag = 0
    for j in range(n-1,0,-1):
      if int(a[j]) < int(a[j-1]):
       a[j],a[j-1] = a[j-1],a[j]
       flag = 1
       a_swap += 1

print(" ".join(a))
print(a_swap)

### FIXED CODE ###

n = int(input())
a = list(map(str, input().split()))
a_swap = 0

flag = True
while flag:
    flag = False
    for j in range(n-1,0,-1):
      if int(a[j]) < int(a[j-1]):
       a[j],a[j-1] = a[j-1],a[j]
       flag = True
       a_swap += 1

print(" ".join(a))
print(a_swap)
import math
N,X=map(int,input().split())
x=list(map(int,input().split()))
d=abs(x[0]-X)
if N==1:
    print(d)
    exit()
for i in range(1,len(x)):
    d=math.gcd(d,abs(x[i]-X))
print(d)

### FIXED CODE ###

import fractions
N,X=map(int,input().split())
x=list(map(int,input().split()))
d=abs(x[0]-X)
if N==1:
    print(d)
    exit()
for i in range(1,len(x)):
    d=fractions.gcd(d,abs(x[i]-X))
print(d)
N, H, W = list(map(int, input().strip().split(' ')))

AB = []

cnt = 0

for i in range(N):
	AB.append(input().strip().split(' '))	#[A][B]
	

for i in range(N):
	if int(AB[i][0]) >= H:
		if int(AB[0][i]) >= W:
			cnt += 1

		
		


	
print(cnt)

### FIXED CODE ###

N, H, W = list(map(int, input().strip().split(' ')))

AB = []

cnt = 0

for i in range(N):
	AB.append(list(map(int, input().strip().split(' '))))	#[A][B]
	
	
for i in range(N):
	if int(AB[i][0]) >= H:
			if int(AB[i][1]) >= W:
				cnt += 1

print(cnt)
from math import gcd
# def lcm(x,y):
#   return (x*y)//gcd(x,y)

n=int(input())
a=list(map(int,input().split()))
ans=10**18
t=0
for i in range(1,n):
  if i==1:
    t=gcd(a[i-1],a[i])
    continue
  t=gcd(t,a[i])
  ans=min(t,ans)
print(ans)


### FIXED CODE ###

# ABC118 C - Monsters Battle Royale
from fractions import gcd
n = int(input())
a = list(map(int,input().split()))
ans = 10**10

for i in range(n-1):
    t = gcd(a[i],a[i+1])
    ans = min(ans,t)
print(ans)
import math
n = int(input())
a = list(map(int,input().split()))

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

val = a[0]
for i in range(1,n):
    val = lcm(val,a[i])

ans = 0
for i in range(n):
    ans += val // a[i]
print(ans % (10**9+7))

### FIXED CODE ###

import fractions
n = int(input())
a = list(map(int,input().split()))

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

val = a[0]
for i in range(1,n):
    val = lcm(val,a[i])

ans = 0
for i in range(n):
    ans += val // a[i]
print(ans % (10**9+7))