Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

A,B,C,K = (int(x) for x in input().split())

score = 0

for i in range(K):
    if A > 0:
        score = score + 1
        A = A - 1
    elif B > 0:
        score = score
        B = B - 1
    else:
        score = score - 1
        C = C - 1

print(score)

### FIXED CODE ###

A,B,C,K = (int(x) for x in input().split())

score = 0

if K < A:
    score = K

else:
    score = A
    K = K - A
    if K > 0 and K < B:
        score = score
    elif K > 0 and K >= B:
        score = score
        K = K - B
        
        if K > 0:
            score = score - K

print(score)
### BUGGY CODE ###

n = int(input().split()[1])
s=input()

for i in range(n):
    lr=input().split()
    print(s[int(lr[0])-1:int(lr[1])].count('AC'))
    



### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])
### BUGGY CODE ###

from collections import defaultdict
N, M, K = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(M)]
cd = [list(map(int, input().split())) for _ in range(K)]

class UnionFind():
  def __init__(self, n):
    self.n = n
    self.root = [-1]*(n+1)
    self.rnk = [0]*(n+1)
  def Find_Root(self, x):
    if(self.root[x] < 0):
      return x
    else:
      self.root[x] = self.Find_Root(self.root[x])
      return self.root[x]
  def Unite(self, x, y):
    x = self.Find_Root(x)
    y = self.Find_Root(y)
    if(x == y):
      return 
    if self.root[x] > self.root[y]:
      x, y = y, x
    self.root[x] += self.root[y]
    self.root[y] = x 
  def isSameGroup(self, x, y):
    return self.Find_Root(x) == self.Find_Root(y)
  def Count(self, x): # xが属するグループのサイズを返す
    return -self.root[self.Find_Root(x)]
  def Members(self, x): # xが属するグループに属する要素をリストで返す
    return [i for i in range(self.n) if self.Find_Root(i)==self.Find_Root(x)]
  def Roots(self): # 全ての根の要素をリストで返す
    return [i for i, x in enumerate(self.root) if x < 0]
  def Group_Count(self): # グループの数を返す
    return len(self.Roots())

uf = UnionFind(N+1)
friends = [[0]*(N+1) for _ in range(N+1)]
blocks = [[0]*(N+1) for _ in range(N+1)]
ans = [0]*(N+1)
roots = defaultdict(int)
ad = [0]*(N+1)
for a, b in ab:
  uf.Unite(a, b)
  friends[a][b] = 1
  friends[b][a] = 1
  ad[a] += 1
  ad[b] += 1

for i in range(1, N+1):
  roots[uf.Find_Root(i)] += 1

for c, d in cd:
  if uf.isSameGroup(c, d):
    ad[c] += 1
    ad[d] += 1

for i in range(1, N+1):
  ans[i] = roots[uf.Find_Root(i)]

for i in range(1, N+1):
  print(ans[i]-ad[i]-1, end=" ")

### FIXED CODE ###

import sys
input = sys.stdin.readline
N, M, K = map(int, input().split())
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.root = [-1]*(n+1)
    self.rnk = [0]*(n+1)
  def Find_Root(self, x):
    if(self.root[x] < 0):
      return x
    else:
      self.root[x] = self.Find_Root(self.root[x])
      return self.root[x]
  def Unite(self, x, y):
    x = self.Find_Root(x)
    y = self.Find_Root(y)
    if(x == y):
      return 
    if self.root[x] > self.root[y]:
      x, y = y, x
    self.root[x] += self.root[y]
    self.root[y] = x 
  def isSameGroup(self, x, y):
    return self.Find_Root(x) == self.Find_Root(y)
  def Count(self, x): # xが属するグループのサイズを返す
    return -self.root[self.Find_Root(x)]
  def Members(self, x): # xが属するグループに属する要素をリストで返す
    return [i for i in range(self.n) if self.Find_Root(i)==self.Find_Root(x)]
  def Roots(self): # 全ての根の要素をリストで返す
    return [i for i, x in enumerate(self.root) if x < 0]
  def Group_Count(self): # グループの数を返す
    return len(self.Roots())

uf = UnionFind(N+1)
roots = {i:0 for i in range(1, N+1)}
each_root = [0]*(N+1)
ad = [0]*(N+1)

for _ in range(M):
  a, b = map(int, input().split())
  uf.Unite(a, b)
  ad[a] += 1
  ad[b] += 1

for i in range(1, N+1):
  r = uf.Find_Root(i)
  roots[r] += 1
  each_root[i] = r

for _ in range(K):
  c, d = map(int, input().split())
  if each_root[c] == each_root[d]:
    ad[c] += 1
    ad[d] += 1

for i in range(1, N+1):
  print(roots[each_root[i]]-ad[i]-1, end=" ")
### BUGGY CODE ###

while 1:
	n = input()
	if n == 0: break
	N = [int(raw_input()) for i in range(n)]
	s = input()
	i = n/2
	c = 1
	while i > 0:
		c += 1
		if N[i] == s:
			break
		elif N[i] < s:
			i /= 2
		else:
			i = min(n-1,i+i/2)
	print c

### FIXED CODE ###

while 1:
	n = input()
	if n == 0: break
	N = [input() for i in range(n)]
	s = input()
	l,r= 0,n-1
	c = 0
	while l <= r:
		i = (l + r)/2
		c += 1
		if N[i] == s:
			break
		elif N[i] < s:
			l = i + 1
		else:
			r = i - 1
	print c
### BUGGY CODE ###

a,b,c,d=map(int,input().split())

XY=[]

for i in range(a,b+1):
    for j in range(c,d+1):
        xy=i*j
        XY.append(xy)
        
print(max(XY))

### FIXED CODE ###

a,b,c,d=map(int,input().split())

XY=[]

XY.append(a*c)
XY.append(a*d)
XY.append(b*c)
XY.append(b*d)

print(max(XY))
### BUGGY CODE ###

n, k = map(int, input().split())
XY = []
xs = []
ys = []
for i in range(n):
    x, y = map(int, input().split())
    XY.append((x, y))
    xs.append(x)
    ys.append(y)

xs.sort()
ys.sort()
ans = float('inf')
for a in range(n-1):
    for b in range(a+1, n):
        for c in range(n-1):
            for d in range(c+1, n):
                xl = xs[a]
                xr = xs[b]
                yl = ys[c]
                yu = ys[d]
                cnt = 0
                for x, y in XY:
                    if xl <= x <= xr and yl <= y <= yu:
                        cnt += 1
                if cnt >= k:
                    ans = min(ans, (xr-xl)*(yu-yl))
print(ans)


### FIXED CODE ###

n, k = map(int, input().split())
XY = []
xs = []
ys = []
for i in range(n):
    x, y = map(int, input().split())
    XY.append((x, y))
    xs.append(x)
    ys.append(y)

xs.sort()
ys.sort()
ans = float('inf')
for a in range(n-1):
    for b in range(a+1, n):
        for c in range(n-1):
            for d in range(c+1, n):
                xl = xs[a]
                xr = xs[b]
                yl = ys[c]
                yu = ys[d]
                cnt = 0
                for x, y in XY:
                    if xl <= x <= xr and yl <= y <= yu:
                        cnt += 1
                if cnt >= k:
                    ans = min(ans, (xr-xl)*(yu-yl))
print(ans)
### BUGGY CODE ###

import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
N,K = map(int,input().split())
A = list(map(int,input().split()))
if N == 1:
    print(1)
else:
    
    old = A
    for _ in range(K):
        li = [0]*N
        for i in range(N):
            MIN = max(0,i-old[i])
            MAX = min(N-1,i+old[i])
            li[MIN] += 1
            if MAX != N-1:
                li[MAX+1] -= 1
        s = 0
        for i in range(N):
            s += li[i]
            old[i] = s
        if min(old) == N:
            break
    print(*old)


### FIXED CODE ###

import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
N,K = map(int,input().split())
A = list(map(int,input().split()))
if N == 1:
    print(1)
else:
    
    old = A
    for _ in range(K):
        li = [0]*N
        for i in range(N):
            MIN = max(0,i-old[i])
            MAX = min(N-1,i+old[i])
            li[MIN] += 1
            if MAX != N-1:
                li[MAX+1] -= 1
        s = 0
        for i in range(N):
            s += li[i]
            old[i] = s
        if min(old) == N:
            break
    print(*old)
### BUGGY CODE ###


import sys
from collections import deque, defaultdict
import copy
import bisect
#sys.setrecursionlimit(10 ** 9)
import math
import heapq
from itertools import combinations, permutations

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


class Union_Find():
	def __init__(self, n):
		self.union = [i for i in range(n)]
		self.level = [0 for i in range(n)]

	def root(self, i, mode=0):
		keiro = [i]
		ans = i
		while ans != self.union[ans]:
			ans = self.union[ans]
			keiro.append(ans)
		if mode == 0:
			return ans
		else:
			return ans, keiro

	def unite(self, i, j):
		root_i, list_i = self.root(i, 1)
		root_j, list_j = self.root(j, 1)
		if root_i != root_j:
			if self.level[root_i] < self.level[root_j]:
				self.level[root_j] = max(self.level[root_i] + 1, self.level[root_j])
				for node in list_i:
					self.union[node] = root_j
			else:
				self.level[root_i] = max(self.level[root_j] + 1, self.level[root_i])
				for node in list_j:
					self.union[node] = root_i

N = int(input())
xy1 = []
xy2 = []
for i in range(N):
	x, y = list(map(int, input().split()))
	xy1.append([x, i])
	xy2.append([y, i])
xy1.sort()
xy2.sort()
edge = []
heapq.heapify(edge)
for i in range(N - 1):
	heapq.heappush(edge, [xy1[i + 1][0] - xy1[i][0], xy1[i + 1][1], xy1[i][1]])
	heapq.heappush(edge, [xy2[i + 1][0] - xy2[i][0], xy2[i + 1][1], xy2[i][1]])

UF = Union_Find(N)
road = 0
total = 0
while road < N - 1:
	edge_now = heapq.heappop(edge)
	if UF.root(edge_now[1]) != UF.root(edge_now[2]):
		road += 1
		total += edge_now[0]
		UF.unite(edge_now[1], edge_now[2])

print(total)

### FIXED CODE ###


import sys
from collections import deque, defaultdict
import copy
import bisect
#sys.setrecursionlimit(10 ** 9)
import math
import heapq
from itertools import combinations, permutations

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


N = int(input())
xy1 = []
xy2 = []
for i in range(N):
	x, y = list(map(int, input().split()))
	xy1.append((x, i))
	xy2.append((y, i))
xy1.sort()
xy2.sort()

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

for i in range(N - 1):
	edge_list[xy1[i][1]].append((xy1[i + 1][0] - xy1[i][0], xy1[i + 1][1]))
	edge_list[xy1[i + 1][1]].append((xy1[i + 1][0] - xy1[i][0], xy1[i][1]))
	edge_list[xy2[i][1]].append((xy2[i + 1][0] - xy2[i][0], xy2[i + 1][1]))
	edge_list[xy2[i + 1][1]].append((xy2[i + 1][0] - xy2[i][0], xy2[i][1]))

judge = [0]*N
G = []
heapq.heapify(G)
for edge in edge_list[0]:
	heapq.heappush(G, edge)

judge[0] = 1
total = 0
num = 0
while num < N - 1:
	edge = heapq.heappop(G)
	if judge[edge[1]] == 0:
		judge[edge[1]] = 1
		total += edge[0]
		num += 1
		for add in edge_list[edge[1]]:
			if judge[add[1]] == 0:
				heapq.heappush(G, add)

print(total)
### BUGGY CODE ###

def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    BC = []
    for i in range(M):
        bc = list(map(int, input().split()))
        BC.append(bc)

    BC.sort(key=lambda x: x[1], reverse=True)
    B = []
    for b, c in BC:
        B = B + [c] * b
        if len(B) > N:
            break

    A.sort(reverse=True)
    
    i = 0
    j = 0
    r = [None] * N
    while i + j < N:
        if i == N:
            r[i+j] = B[j]
            j += 1
        elif j == len(B):
            r[i+j] = A[i]
            i += 1
        elif A[i] > B[j]:
            r[i+j] = A[i]
            i += 1
        else:
            r[i+j] = B[j]
            j += 1

    # print(r)
    ans = sum(r)
    print(ans)


if __name__ == "__main__":
    main()

### FIXED CODE ###

from operator import itemgetter

def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    BC = []
    for i in range(M):
        bc = list(map(int, input().split()))
        BC.append(bc)

    BC.sort(key=itemgetter(1), reverse=True)
    # B = []
    # for b, c in BC:
    #     B = B + [c] * b
    #     if len(B) > N:
    #         break

    A.sort(reverse=True)
    
    i = 0
    j = 0
    r = []

    cnt = 0
    while len(r) != N:
        # print(i, j)
        if j > M - 1:
            r.append(A[i])
            i += 1
            continue

        b, c = BC[j]
        if A[i] >= c:
            r.append(A[i])
            i += 1
        else:
            r.append(c)
            cnt += 1
            if cnt == b:
                j += 1
                cnt = 0

    # print(r)
    ans = sum(r)
    print(ans)


if __name__ == "__main__":
    main()
### BUGGY CODE ###

import sys

N, Q = map(int, sys.stdin.readline().split())
S = sys.stdin.readline()
AC = 'AC'

ans = []
for i in range(Q):
    l, r = map(int, sys.stdin.readline().split())
    ans.append(S[max(l - 1, 0):r].count(AC))

for i in range(len(ans)):
    print(ans[i])


### FIXED CODE ###

N, Q = map(int, input().split())
S = input()

cumsum = [0] * (N + 1)
for i in range(1, N):
    if S[i - 1] == 'A' and S[i] == 'C':
        cumsum[i + 1] = cumsum[i] + 1
    else:
        cumsum[i + 1] = cumsum[i]
for i in range(Q):
    l, r = map(int, input().split())
    print(cumsum[r] - cumsum[l])
### BUGGY CODE ###

n,x = map(int,input().split())
b = "P"
for _ in range(n):
    b = "B"+b+"P"+b+"B"

print(b[:x].count("P"))

### FIXED CODE ###

n,x = map(int,input().split())
burger = [1]
patty = [1]

for i in range(n):
    burger.append(burger[i]*2+3)
    patty.append(patty[i]*2+1)

def f(n,x):
    if n == 0:
        return 1
    elif x == 1:
        return 0
    elif x <= 1+burger[n-1]:
        return f(n-1,x-1)
    elif x == 2+burger[n-1]:
        return 1+patty[n-1]
    elif x <= 2+2*burger[n-1]:
        return 1+patty[n-1]+f(n-1,x-2-burger[n-1])
    else:
        return patty[n]

print(f(n,x))
### BUGGY CODE ###

n = int(input())
h = list(map(int, input().split()))
a = 0
for i in range(n-1):
    for j in h[i+1:]:
        if h[i]-j >= 2:
            a += 1
if a == 0:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

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

c = 0
for i in range(n-1):
    if h[i] <= h[i+1]-1:
        h[i+1] = h[i+1]-1
    elif h[i] == h[i+1]:
        continue
    else:
        c = 1
if c == 1:
    print('No')
else:
    print('Yes')
### BUGGY CODE ###

N_K = input().split()
N = int(N_K[0])
K = int(N_K[1])
Hs = sorted([int(input()) for i in range(N)])
Hs_diff = [Hs[i+1] - Hs[i] for i in range(N) if i<(N-1)]
Hs_diff_K = [sum(Hs_diff[(i):(i+K-1)]) for i in range(len(Hs_diff)) if i < len(Hs_diff)-K+2]
print(min(Hs_diff_K))

### FIXED CODE ###

N_K = input().split()
N = int(N_K[0])
K = int(N_K[1])
Hs = sorted([int(input()) for i in range(N)])
Hs_diff_K = [Hs[K+i-1] - Hs[i] for i in range(N) if i < N-K+1]
print(min(Hs_diff_K))
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
sumA=0
for i in range(N-1):
    sumB=0
    for j in range(i+1,N):
        sumB=sumB+A[j]
        j=j+1
    sumB=sumB%(10**9+7)
    sumA=sumA+(A[i]*sumB)%(10**9+7)
    i=i+1
print(sumA%(10**9+7))

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
sumA=0
sumB=[0]
for i in range(N):
    sumB.append(sumB[i]+A[i])
    i=i+1
for j in range(N-1):
    sumA=sumA+(A[j]*(sumB[N]-sumB[j+1]))%(10**9+7)
    j=j+1
print(sumA%(10**9+7))
### BUGGY CODE ###

def main(N, K, A):
    for i in range(K-1, N): # 0 から数えるから K-1
        this = 1

        # 総積
        for a in A[i-(K-1):i+1]:   # 直近3学期． i+1はスライスのときその数字は入らないから．
            this *= a

        # print
        if i != K-1:
            if this > before:
                print('Yes')
            else:
                print('No')
        before = this


if __name__ == '__main__':
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))
    main(N, K, A)

### FIXED CODE ###

def main(N, K, A):
    for i in range(K, N): # 0 から数えるから K-1
        this = A[i]
        before = A[i-K]

        if this > before:
            print('Yes')
        else:
            print('No')



if __name__ == '__main__':
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))
    main(N, K, A)
### BUGGY CODE ###

N , K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
cnt = []
while len(A) > 0:
    temp = A[0]
    i_cnt = 0
    while A[0] == temp:
        i_cnt += 1
        del A[0]
        if len(A) == 0:
            break
    cnt.append(i_cnt)
cnt.sort()
result = 0
for i in range(len(cnt) - K):
    result += cnt[i]
print(result)

### FIXED CODE ###

N , K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
A.append(0)
cnt = []
i_cnt = 1
for i in range(N):
    if A[i] == A[i + 1]:
        i_cnt += 1
    else:
        cnt.append(i_cnt)
        i_cnt = 1
cnt.sort()
result = 0
for i in range(len(cnt) - K):
    result += cnt[i]
print(result)
### BUGGY CODE ###



MOD = 1000000007

n = input()
a = []
for _ in range(n):
    a.append(map(int, raw_input().split()))

dp = [[0] * (1 << n) for _ in range(n + 1)]
for i in range(1 << n):
    dp[0][i] = 1
for i in range(1, n + 1):
    for mask in range(1, 1 << n):
        for j in range(n):
            if a[i - 1][j] == 1 and mask & (1 << j):
                dp[i][mask] += dp[i - 1][mask ^ (1 << j)]
                dp[i][mask] %= MOD
print(dp[n][(1 << n) - 1])

### FIXED CODE ###



MOD = 1000000007

n = input()
a = []
for _ in range(n):
    a.append(map(int, raw_input().split()))

# dp[S] cant de match usando |S| primeros hombres y S mujeres
dp = [0] * (1 << n)
dp[0] = 1
for mask in range(1, 1 << n):
    i = bin(mask).count('1') - 1  # bin(6) => 0x110
    for j in range(n):
        if a[i][j] == 1 and mask & (1 << j):
            dp[mask] += dp[mask ^ (1 << j)]
            dp[mask] %= MOD
print(dp[(1 << n) - 1])
### BUGGY CODE ###

import numpy as np 
n = int(input())
a = np.array(list(map(int, input().split())))
for i in range(n):
    np.delete(a, i)
    _a = np.delete(a, i)
    unique = np.unique(_a)
    for j in range(len(unique)):
        k = np.count_nonzero(_a == unique[j])
        if j == 0:
            if k >= 2:
                total = k * (k - 1) / 2 
            else:
                total = 0
        else:
            if k >= 2:
                total += k * (k - 1) / 2 
    print(int(total))

### FIXED CODE ###

import collections

def solve(N, A):
    c_dict = collections.Counter(A)
    originals = [0 for i in range(N + 1)]
    minus = [0 for i in range(N + 1)]
    
    for (k, v) in c_dict.items():
        originals[k] = v * (v - 1) // 2
        minus[k] = ((v * (v - 1)) - (v - 1) * (v - 2)) // 2
        
    total = sum(originals)
    
    ans = []
    for a in A:
        ans.append(str(total - minus[a]))
    return '\n'.join(ans)
    
if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))
    print(solve(N, A))
### BUGGY CODE ###

import numpy as np

LARGE = 10 ** 9 + 7


def solve(n, a_list):

    # inverse
    res = 0
    for i in range(n):
        res += pow(a_list[i], LARGE - 2, LARGE)
        res %= LARGE

    # primes
    p_candidate_arr = np.ones(10 ** 3, dtype=np.int)
    p_candidate_arr[:2] = 0
    for p in range(2, 10 ** 3):
        if p_candidate_arr[p]:
            p_candidate_arr[p * p::p] = 0
    primes_1000 = np.where(p_candidate_arr == 1)[0]

    lcm = 1
    for p in primes_1000:
        r_max = 0
        for i in range(n):
            r = 0
            while a_list[i] % p == 0:
                r += 1
                a_list[i] = a_list[i] // p
            r_max = max(r_max, r)
        lcm *= pow(int(p), r_max, LARGE)
        lcm %= LARGE

    for q in np.unique(a_list):
        lcm *= q
        lcm %= LARGE

    return res * lcm % LARGE


def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    res = solve(n, a_list)
    print(res)


def test():
    assert solve(3, [2, 3, 4]) == 13
    assert solve(5, [12, 12, 12, 12, 12]) == 5
    assert solve(3, [1000000, 999999, 999998]) == 996989508


if __name__ == "__main__":
    test()
    main()


### FIXED CODE ###

LARGE = 10 ** 9 + 7


def solve(n, a_list):

    # inverse
    res = 0
    for i in range(n):
        res += pow(a_list[i], LARGE - 2, LARGE)
        res %= LARGE

    # primes
    p_candidate_list = [1] * 10 ** 3
    p_candidate_list[0] = 0
    p_candidate_list[1] = 0
    for p in range(2, 10 ** 3):
        if p_candidate_list[p]:
            for q in range(p * p, 10 ** 3, p):
                p_candidate_list[q] = 0
    primes_1000 = [p for p in range(1000) if p_candidate_list[p]]

    lcm = 1
    for p in primes_1000:
        r_max = 0
        for i in range(n):
            r = 0
            while a_list[i] % p == 0:
                r += 1
                a_list[i] = a_list[i] // p
            r_max = max(r_max, r)
        lcm *= pow(int(p), r_max, LARGE)
        lcm %= LARGE

    for q in set(a_list):
        lcm *= q
        lcm %= LARGE

    return res * lcm % LARGE


def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    res = solve(n, a_list)
    print(res)


def test():
    assert solve(3, [2, 3, 4]) == 13
    assert solve(5, [12, 12, 12, 12, 12]) == 5
    assert solve(3, [1000000, 999999, 999998]) == 996989508


if __name__ == "__main__":
    test()
    main()
### BUGGY CODE ###

import heapq
H, W, M = map(int, input().split())
bomb = []
for i in range(M):
    h, w = map(int, input().split())
    h-=1; w-=1
    bomb.append((h, w))

row = [0] * H
col = [0] * W

for h, w in bomb:
    row[h] += 1
    col[w] += 1

lmax = max(row) + max(col)
row = [(r, i) for i, r in enumerate(row)]
col = [(c, i) for i, c in enumerate(col)]
bomb = set(bomb)

for r, i in row:
    for c, j in col:
        if r+c < lmax: continue
        if not (i, j) in bomb:
            print(lmax)
            exit()
print(lmax-1)

        





### FIXED CODE ###

import heapq
H, W, M = map(int, input().split())
bomb = []
for i in range(M):
    h, w = map(int, input().split())
    h-=1; w-=1
    bomb.append((h, w))

row = [0] * H
col = [0] * W

for h, w in bomb:
    row[h] += 1
    col[w] += 1

lmax = max(row) + max(col)
row = [(r, i) for i, r in enumerate(row)]
col = [(c, i) for i, c in enumerate(col)]
row.sort(reverse=True)
col.sort(reverse=True)
bomb = set(bomb)

for r, i in row:
    for c, j in col:
        if r+c < lmax: break
        if not (i, j) in bomb:
            print(lmax)
            exit()
print(lmax-1)
### BUGGY CODE ###

## ABC113C - ID
import sys
input = sys.stdin.readline

n, m = list(map(int, input().rstrip().split()))
arr = [list(map(int, input().rstrip().split())) for _ in range(m)]
pref = [[] for _ in range(n)]
for i in arr:
    pref[i[0] - 1] += [i]
pref = [sorted(i) for i in pref]
for i in arr:
    j = pref[i[0] - 1].index(i) + 1
    print("{:0>6}{:0>6}".format(i[0], j))

### FIXED CODE ###

import sys
input = sys.stdin.readline

n, m = list(map(int, input().rstrip().split()))
ans = [""] * m
arr = []
cnt = 1
for i in range(m):
    p, y = map(int, input().split())
    arr += [(p, y, i)]
arr = sorted(arr)

ans[arr[0][2]] = "{:06}{:06}".format(arr[0][0], cnt)
for i in range(1, m):
    if arr[i - 1][0] == arr[i][0]:
        cnt += 1
    else:
        cnt = 1
    ans[arr[i][2]] = "{:06}{:06}".format(arr[i][0], cnt)

for i in ans:
    print(i)