Harryxun/stf_run huggingface dataset:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin
from itertools import count, combinations

for case in count(1):
    W = int(stdin.readline())
    if not W:
        break

    N = int(stdin.readline())
    data = []
    for _ in range(N):
        data.append([int(s) for s in stdin.readline().split(',')])

    total = []
    for i in range(1, N+1):
        for cmb in combinations(data, i):
            tv, tw = 0, 0
            for value, weight in cmb:
                tv += value
                tw += weight
            if tw < W:
                total.append((tv, tw))

    tv, tw = max(total, key=lambda(tv, tw): (tv, -tw))
    print('Case {}:\n{}\n{}'.format(case, tv, tw))

### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin
from itertools import count

def douteki(limit, data):
    V = [[0 for w in xrange(limit+1)] for i in xrange(len(data)+1)]
    W = [[0 for w in xrange(limit+1)] for i in xrange(len(data)+1)]
    for i in xrange(len(data)+1):
        for w in xrange(limit+1):
            diff = w - data[i-1][1]
            if i - 1 >= 0 and diff >= 0:
                v1 = V[i-1][diff] + data[i-1][0]
                w1 = W[i-1][diff] + data[i-1][1]
            else:
                v1 = 0
                w1 = 0
            v2 = V[i-1][w]
            w2 = W[i-1][w]

            V[i][w], W[i][w] = (v1, w1) if v1 >= v2 else (v2, w2)
    return V[-1][-1], W[-1][-1]

for case in count(1):
    W = int(stdin.readline())
    if not W:
        break

    N = int(stdin.readline())
    data = []
    for _ in xrange(N):
        data.append([int(s) for s in stdin.readline().split(',')])

    value, weight = douteki(W, data)
    print('Case {}:\n{}\n{}'.format(case, value, weight))
k, s = map(int, input().split())
x <= k
y <= k
z <= k
count = 0
for e in range(s+1):
  for f in range(s+1):
    for g in range(s+1):
      if e + f + g == s:
        count =count+1
print(count)


### FIXED CODE ###

K, S = map(int, input().split())
count = 0
for X in range(K+1):
  for Y in range(K+1):
    Z = S - X - Y
    if 0 <= Z and Z <= K:
        count += 1
print(count)
n, k = input().split()
a = {}
for i in [int(j) for j in input().split()]:
  if i in a:
    a[i] += 1
   else:
    a[i] = 1
if len(a) <= k:
  print(0)
else:
	print(sum(sorted(a.values())[len(a) - k]))

### FIXED CODE ###

n, k = map(int, input().split())
a = {}
for i in [int(j) for j in input().split()]:
    if i in a:
        a[i] += 1
    else:
        a[i] = 1
if len(a) <= k:
    print(0)
else:
    print(sum(sorted(a.values())[:len(a) - k]))
n = int(input())

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

ans = 0
for i in range(len(X) - 2):
  if (X[i] > X[i+1] > X[i+2]) or (X[i] < X[i+1] < X[i+2])
  	ans += 1

print(ans)

### FIXED CODE ###

n = int(input())

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

ans = 0
for i in range(len(X) - 2):
  if (X[i] > X[i+1] > X[i+2]) or (X[i] < X[i+1] < X[i+2]):
  	ans += 1

print(ans)
import math
n,m=map(int,input().split())
a=list(map(int,input().split()))
t=sum(a)
a=list(filter(lambda x: math.ceil(t/(4*m)) < x, a))
print('Yes' if m <= len(a) else 'No')


### FIXED CODE ###

k=int(input())
l=list(map(str,range(1,10)))
for i in range(k):
    x=l[i][-1]
    if x=='0':
        l.append(l[i]+x)
        l.append(l[i]+'1')
    elif x=='9':
        l.append(l[i]+'8')
        l.append(l[i]+x)
    else:
        n=int(x)
        l.append(l[i]+str(n-1))
        l.append(l[i]+x)
        l.append(l[i]+str(n+1))
print(sorted(map(int,l))[k-1])
nq=input().split()
n=int(nq[0])
q=int(nq[1])
block_word=[""]
block_num=[""]
block_move=[""]
golem=n
s=input()
t=""
d=""

for i in range(q):
  block_num += [1]

for word in s:
  block_word += [word]
  block_move+=[0]

for i in range(q):
  print(golem)
  td=input().split()
  t=td[0]
  d=td[1]
  for j in range(1,n+1):
    if t==block_word[j]:
      if j==n and d=="R":
        golem-=block_num[n]
        block_num[n]=0
      elif j==1 and d=="L":
        golem-=block_num[1]
        block_num[1]=0
      else:
        if d=="R":
          block_move[j+1]=block_num[j]
          block_num[j]=0
        if d=="L":
          block_move[j-1]=block_num[j]
          block_num[j]=0
    else:
        block_move[j]=0
  for k in range(1,n+1):
    block_num[k]+=block_move[k]
  for i in range(1,n+1):
    block_move[i]=0

print(golem)

### FIXED CODE ###

N,Q=map(int,input().split())
s="0"+input()+"0"
queri=[input().split() for i in range(Q)]
 
L,R=0,N+1
for i in range(Q-1,-1,-1):
    t,d=queri[i]
    if t==s[L] and d=="R":
        L-=1
    elif t==s[L+1] and d=="L":
        L+=1
    if t==s[R] and d=="L":
        R+=1
    elif t==s[R-1] and d=="R":
        R-=1
 
print(R-L-1)
from sys import stdin
if m >= n:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

from sys import stdin
n,m=map(int,input().split())
if m >= n:
    print("Yes")
else:
    print("No")
def back_oturigation(fee, coin_values, coin_nums):
    """
    1. ????????????????????????????????£??????????????????
    2. 1????????????????????????????????????????????????????????????
       ???????????§?????????????????????-> ?°????????????????????¶???????????????????
    3. 2????????????????????°?????????????????????????????????????????????
    """
    # 1.
    oturi = coin_values[0]*coin_nums[0]\
            +coin_values[1]*coin_nums[1]\
            +coin_values[2]*coin_nums[2]\
            +coin_values[3]*coin_nums[3]\
            -fee
    use_coins = [0] * len(coin_value)
    no_use_coins = [0]*len(coin_value)

    # 2.
    for i in range(len(coin_value)-1, -1, -1):
        print(coin_value[i])
        import pdb;pdb.set_trace()

        no_use_coins[i] = int(oturi / coin_value[i])
        oturi = oturi - (coin_value[i] * no_use_coins[i])


    #3.
    for i in range(0, len(use_coins), 1):
        use_coins[i] = coin_nums[i] - no_use_coins[i]
        if use_coins[i] > 0:
            print(coin_value[i],' ',use_coins[i])

if __name__ == "__main__":
    total_fee = int(input('total_fee:'))
    coins = input('total_coins:')
    coins = coins.split(' ') #10, 50, 100, 500????????§????????????
    coins = [int(coin) for coin in coins]
    coin_value=[10, 50, 100, 500]
    back_oturigation(total_fee, coin_value, coins)

### FIXED CODE ###

import math
def back_oturigation(fee, coin_values, coin_nums):
    """
    1. ?????????????????????????????????£??????????????????
    2. 1????????????????????????????????????????????????????????????
       ????????????§?????????????????????-> ??°?????????????????????¶???????????????????
    3. 2?????????????????????°?????????????????????????????????????????????
    """
    # 1.
    oturi = coin_values[0] * coin_nums[0] \
            + coin_values[1] * coin_nums[1] \
            + coin_values[2] * coin_nums[2] \
            + coin_values[3] * coin_nums[3] \
            - fee

    use_coins = [0] * len(coin_values)
    no_use_coins = [0] * len(coin_values)
 
    # 2.
    for i in range(len(coin_values) - 1, -1, -1):
        no_use_coins[i] = int(oturi / coin_values[i])
        oturi = oturi - (coin_values[i] * no_use_coins[i])
 
    # 3.
    for i in range(0, len(use_coins), 1):
        use_coins[i] = coin_nums[i] - no_use_coins[i]
        if use_coins[i] > 0:
            print(str(coin_values[i]) + ' ' + str(use_coins[i]))
 
if __name__ == "__main__":
    first = True
    while (True):
        total_fee = int(input(''))
        if total_fee == 0:
            break
        if first:
            first = False
        else:
            print('')
        coins = input('')
        coins = coins.split(' ')  # 10, 50, 100, 500?????????§????????????
        coins = [int(coin) for coin in coins]
        coin_values = [10, 50, 100, 500]
        back_oturigation(total_fee, coin_values, coins)
n = int(raw_input())
a = map(int,raw_input().split())
a.reverse()
for i in range(len(n)):
    print a

### FIXED CODE ###

n = int(raw_input())
a = map(int,raw_input().split())
a.reverse()
for i in a:
    print i,
import bisect

N = int(input())

A = list(map(int, input().split()))
T = [[] for _ in range(N)]
for i in range(N - 1):
    a, b = map(int, input().split())
    T[a - 1].append(b - 1)
    T[b - 1].append(a - 1)

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


def dfs(s):
    for d in T[s]:
        if not F[d]:
            F[d] = F[s][:]
            t = bisect.bisect_left(F[d], A[d])
            if t == len(F[d]):
                F[d].append(A[d])
            else:
                F[d][t] = A[d]
            dfs(d)


F[0] = [A[0]]
dfs(0)

for f in F:
    print(len(f))


### FIXED CODE ###

import sys
import bisect

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

N = int(input())

A = list(map(int, input().split()))
T = [[] for _ in range(N)]
for i in range(N - 1):
    a, b = map(int, input().split())
    T[a - 1].append(b - 1)
    T[b - 1].append(a - 1)

F = [-1 for _ in range(N)]
F[0] = 1
INF = 10 ** 9
dp = [INF for _ in range(N + 1)]
dp[0] = A[0]


def dfs(s):
    for d in T[s]:
        if F[d] == -1:
            t = bisect.bisect_left(dp, A[d])
            p = dp[t]
            dp[t] = A[d]
            F[d] = bisect.bisect_left(dp, INF)
            dfs(d)
            dp[t] = p


dfs(0)

print("\n".join(map(str, F)))
K = int(input())
S = input()

if len(S) <= K:
    print(S)
else
    print(S[0:K]　+ '...')

### FIXED CODE ###

N = int(input())
N = N % 10
if N in [2, 4, 5, 7, 9]:
    print('hon')

elif N in [0, 1, 6, 8]:
    print('pon')

else:
    print('bon')
import math
PI = math.pi

r = int(input())
men = r*r * PI
sen = r*2 * PI

print('%.6f %.6f' % (men, sen))

### FIXED CODE ###

import math
PI = math.pi

r = input()
men = r*r * PI
sen = r*2 * PI

print('%.6f %.6f' % (men, sen))
N = int(input())
S = list(input())

slime = 1

for i in range(0,N-1):
  if S[i] != S[i+1]:
    slime += 1
  else:
    slime += 0
    
print(slime)



### FIXED CODE ###

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

if A >= B*2:
  print(A-B*2)
  
else:
  print(0)
n,m=map(int,input().split())
bridge=[[] for i in range(m)]
leader=[i for i in range(n+1)]
member=[1 for i in range(n+1)]
for i in range(m):
    bridge[i]=list(map(int,input().split()))
ans=[0 for i in range(m+1)]
ans[0]=int((n-1)*n/2)
k=1
for i in reversed(bridge):
    print(leader)
    print(member)
    le0=leader[i[0]]
    le1=leader[i[1]]
    if le0!=le1:
        ans[k]=ans[k-1]-member[le0]*member[le1]
        if member[le0]>=member[le1]:
            member[le0]+=member[le[1]]
            leader[i[1]]=le0
        else:
            member[le1]+=member[le0]
            leader[i[0]]=le1
    else:
        ans[k]=ans[k-1]
    if ans[k]==0:
        ans[k:]=[0 for l in range(m-k)]
        break
    k+=1
for i in range(m):
    print(ans[m-1-i])

### FIXED CODE ###

n,m=map(int,input().split())
bridge=[[] for i in range(m)]
leader=[i for i in range(n+1)]
member=[1 for i in range(n+1)]
for i in range(m):
    bridge[i]=list(map(int,input().split()))
ans=[0 for i in range(m+1)]
ans[0]=int((n-1)*n/2)
k=1
for i in reversed(bridge):
    le0=leader[i[0]]
    le1=leader[i[1]]
    while le0!=leader[le0]:
        le0=leader[le0]
        leader[i[0]]=le0
        
    while le1!=leader[le1]:
        le1=leader[le1]
        leader[i[1]]=le1
        
    if le0!=le1:
        ans[k]=ans[k-1]-member[le0]*member[le1]
        if member[le0]>=member[le1]:
            member[le0]+=member[le1]
            leader[le1]=le0
        else:
            member[le1]+=member[le0]
            leader[le0]=le1
    else:
        ans[k]=ans[k-1]
    if ans[k]==0:
        ans[k:]=[0 for l in range(m-k)]
        break
    k+=1
for i in range(m):
    print(ans[m-1-i])
def app(numlist, A ):
  counter = 0
  N = len(numlist)
  for i in range(1,N):
    counter += f(numlist, i, A*i)
  return int(counter)
 
def f(numlist, rest, sum):
  result = 0
  numset = set(numlist)
  if rest == 1:
    return numlist.count(sum)
 
  elif rest == 2:
    for big in numset:
      if (sum - big in numset) and (big >= sum - big):
        result += counter(numlist, big, sum-big)
    return result
  else:
    for i in numset:
      i_place = numlist.index(i)
      result += f(numlist[i_place+1:], rest-1, sum-i)
    return result
 
 
def counter(numlist, big, small):
  hist = mkhist(numlist)
  if big == small:
    N = hist[big]
    return N * (N - 1) / 2
  else: 
    big_N = hist[big]
    small_N = hist[small]
    return big_N * small_N
 
def mkhist(numlist):
  hist = dict()   
  for char in numlist:
    if not char in hist.keys():
      hist[char] = 1
    else:
      hist[char] += 1
  return hist
 
 
 
 
N, A = map(int, input().split(' '))
inputs = input()
 
inputnum = map(int, inputs.split(' '))
inputnum = sorted(list(inputnum))
 
print (app(inputnum, A))

### FIXED CODE ###

n = 4
input_list = []
for i in range(4):
    input_list.append(int(input()))

N = input_list[0]
K = input_list[1]
X = input_list[2]
Y = input_list[3]

if N > K :
    result = K * X + (N-K) * Y
else:
    result = N * X

print ( result )
x=raw_input().split()

x(reversed(xrange(len(x))))

### FIXED CODE ###

n = int(raw_input())
a = map(int,raw_input().split())
a.reverse()
for i in a:
    print i,
K = int(input())
A, B = list(map(int, input().split()))
 
N = (B // K)  * K
if (A <= N):
  print(‘OK’)
else:
  print(‘NG’)

### FIXED CODE ###

K = int(input())
A, B = list(map(int, input().split()))
 
N = (B // K)  * K
if (A <= N):
  print('OK')
else:
  print('NG')
n,m = map(int, input().split())
div = 1000000007
ok [True] * n
for _ in range(m):
  a = int(input())
  ok[a] = False
dp = [0] * (n + 1)
dp[0] = 1
if ok[1]:
  dp[1] = 1
else:
  dp[1] = 0

for i in range(2, n+1):
  if ok[i]:
    dp[i] = dp[i-1] + dp[i-2]
    dp[i] %= div

print(dp[n])
  

### FIXED CODE ###

n,m = map(int, input().split())
div = 1000000007
ok = [True] * (n + 1)
for _ in range(m):
  a = int(input())
  ok[a] = False
dp = [0] * (n + 1)
dp[0] = 1
if ok[1]:
  dp[1] = 1
else:
  dp[1] = 0

for i in range(2, n+1):
  if ok[i]:
    dp[i] = dp[i-1] + dp[i-2]
    dp[i] %= div

print(dp[n])
'''input
3 5
1 2 3
'''
from fractions import gcd
n,x = map(int,raw_input().split())
arr = map(int,raw_input().split())
arr.append(x)
arr.sort()
diff = []
for i in range(1,n):
	diff.append(arr[i]-arr[i-1])
gc = diff[0]
for i in range(1,len(diff)):
	gc = gcd(gc,diff[i])
print gc


### FIXED CODE ###

'''input
2 1
555 556
'''
from fractions import gcd
n,x = map(int,raw_input().split())
arr = map(int,raw_input().split())
arr.append(x)
arr.sort()
diff = []
for i in range(1,n+1):
	diff.append(arr[i]-arr[i-1])
gc = diff[0]
for i in range(1,len(diff)):
	gc = gcd(gc,diff[i])
print gc
from collections import deque


def main():
    N, K = map(int, input().split())
    sushis = [None] * N
    for i in range(N):
        t, d = map(int, input().split())
        sushis[i] = (t, d)
    sushis.sort(key=lambda a: (-a[1], a[0]))
    tmp = 0
    types = set()
    stack = deque()
    ans = 0
    for i in range(len(sushis)):
        t, d = sushis[i]
        if i < K:
            if t in types:
                stack.append(d)
            types.add(t)
            tmp += d
        else:
            if t not in types:
                types.add(t)
                tmp += d
                tmp -= stack.pop()
        ans = max(ans, tmp + len(types)**2)
    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

from collections import deque


def main():
    N, K = map(int, input().split())
    sushis = [None] * N
    for i in range(N):
        t, d = map(int, input().split())
        sushis[i] = (t, d)
    sushis.sort(key=lambda a: (-a[1], a[0]))
    tmp = 0
    types = set()
    stack = deque()
    ans = 0
    for i in range(len(sushis)):
        t, d = sushis[i]
        if i < K:
            if t in types:
                stack.append(d)
            types.add(t)
            tmp += d
        else:
            if t not in types and len(stack):
                types.add(t)
                tmp += d
                tmp -= stack.pop()
        ans = max(ans, tmp + len(types)**2)
    print(ans)


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

def iterate(mapdata, passed, curr, count):
    if curr == (passed.shape[0] - 1, passed.shape[1] - 1):
        return count

    if mapdata[curr[0]][curr[1]] == '#':
        return 100000 #passed[curr]
    
    #if passed[curr] < 100000:
    #    print(passed[curr], count)
    if passed[curr] > 0:
        return 100000 #passed[curr]
    passed[curr] = 1
    
    ret = 100000
    if curr[0] < passed.shape[0] - 1:
        tmp = iterate(mapdata, passed, (curr[0] + 1, curr[1]), count + 1)
        ret = min(ret, tmp)
    if curr[1] < passed.shape[1] - 1:
        tmp = iterate(mapdata, passed, (curr[0], curr[1] + 1), count + 1)
        ret = min(ret, tmp)
    if curr[0] > 0:
        tmp = iterate(mapdata, passed, (curr[0] - 1, curr[1]), count + 1)
        ret = min(ret, tmp)
    if curr[1] > 0:
        tmp = iterate(mapdata, passed, (curr[0], curr[1] - 1), count + 1)
        ret = min(ret, tmp)

    return ret


h, w = map(int, input().split())
mapdata = [input() for y in range(h)]
dotsum = sum(mapdata[y].count('.') for y in range(h))

passed = np.zeros((h, w), np.int32)
#passed[:, :] = 100000
count = iterate(mapdata, passed, (0, 0), 0)
#print(count)
print(dotsum - count - 1)

### FIXED CODE ###

import numpy as np

def iterate2(mapdata, passed, start):
    queue = [(start, 0)]

    while len(queue) > 0:
        curr, count = queue[0]
        del queue[0]
        if curr == (passed.shape[0] - 1, passed.shape[1] - 1):
            return count
        if mapdata[curr[0]][curr[1]] == '#':
            continue
        if passed[curr] > 0:
            continue
        passed[curr] = 1

        if curr[0] < passed.shape[0] - 1:
            queue.append(((curr[0] + 1, curr[1]), count + 1))
        if curr[1] < passed.shape[1] - 1:
            queue.append(((curr[0], curr[1] + 1), count + 1))
        if curr[0] > 0:
            queue.append(((curr[0] - 1, curr[1]), count + 1))
        if curr[1] > 0:
            queue.append(((curr[0], curr[1] - 1), count + 1))
    
    return -1

h, w = map(int, input().split())
mapdata = [input() for y in range(h)]
dotsum = sum(mapdata[y].count('.') for y in range(h))

passed = np.zeros((h, w), np.int8)
count = iterate2(mapdata, passed, (0, 0))
#print(dotsum)
#print(count)
if count > 0:
    print(dotsum - count - 1)
else:
    print(-1)
S = str(input())
if S == 'ABC'
	print('ARC')
elif S == 'ARC'
	print('ABC')

### FIXED CODE ###

S = str(input())
if S == 'ABC':
	print('ARC')
else:
	print('ABC')
a1, a2, a3 = map(int, input().split())

total = sum(a1, a2, a3)

if total >= 22:
	print('bust')
else:
	print('win')

### FIXED CODE ###

a1, a2, a3 = map(int, input().split())

total = a1 + a2 + a3

if total >= 22:
	print('bust')
else:
	print('win')
import bisect

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

target = 0
l = [399, 799, 1199, 1599, 1999, 2399, 2799, 3199]
cnt = [0 for i in range(len(l))]

for i in range(n):
    if a[i] >= 3200:
        target += 1
    else:
        x = bisect.bisect(l, a[i])
        # print ("value = " + str(a[i]) + ", x = " + str(x))
        cnt[x] += 1

mi = 0
ma = 0
for i in range(len(l)):
    if cnt[i] != 0:
        mi += 1

ma = mi + target
if mi == 0:
    mi = 1

print (str(mi) + " " + str(ma))

### FIXED CODE ###

import bisect

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

target = 0
l = [399, 799, 1199, 1599, 1999, 2399, 2799, 3199]
cnt = [0 for i in range(len(l))]

for i in range(n):
    if a[i] >= 3200:
        target += 1
    else:
        x = bisect.bisect_left(l, a[i])
        # print ("value = " + str(a[i]) + ", x = " + str(x))
        cnt[x] += 1

mi = 0
ma = 0
for i in range(len(l)):
    if cnt[i] != 0:
        mi += 1

ma = mi + target
if mi == 0:
    mi = 1

print (str(mi) + " " + str(ma))
from bisect import bisect_left

n = int(input())
ls = list(map(int, input().split())).sort()
count = 0
for i in range(n - 2):
  for j in range(i + 1, n - 1):
    two_sides_sum = ls[i]+ ls[j]
    bi = bisect_left(ls, two_sides_sum)
    count += bi - j - 1
print(count)

### FIXED CODE ###

import bisect
n = int(input())

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

count = 0

for i in range(n - 2):
  for j in range(i + 1, n - 1):
    bi = bisect.bisect_left(li, li[i] + li[j])
    count += bi - j - 1
print(count)
R=int(input())
if R<1200:S='B'
elif R<2800:S='R'
else:S='G'
print('A'+S+'C')

### FIXED CODE ###

S = list(input())
if S[0] != 'A':
    print('WA')
    exit()
S[0] = 'a'
if S.count('C') != 1:
    print('WA')
    exit()
i = S.index('C')
if i == 1 or i == len(S)-1:
    print('WA')
    exit()
S[S.index('C')] = 'c'
if ''.join(S) == ''.join(S).lower():
    print('AC')
else:
    print('WA')
K,N = map(int,input().split())
A = list(map(int,input()))
L = 0
for i in range(0,N-1):
    if A[i+1]-A[i] >L:
        L = A[i+1]-A[i]
print(K-L)

### FIXED CODE ###

K,N = map(int,input().split())
A = list(map(int,input().split()))
L = []
T = K+A[0]-A[-1]
for i in range(N-1):
  L.append(A[i+1]-A[i])
L.append(T)
print(K-max(L))
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=[]
R=a.pop()
L=a.pop(0)
s=L
while a[-1]>0:
    r=a.pop()
    ans.append([s,r])
    s=s-r
    if not a:break
ans.append([R,s])
s=R-s
while a:
    L=a.pop()
    ans.append([s,L])
    s=s-L
print(s)
for x in ans:
    print(*x)


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=[]
R=a.pop()
L=a.pop(0)
s=L
if a:
    while a[-1]>0:
        r=a.pop()
        ans.append([s,r])
        s=s-r
        if not a:break
ans.append([R,s])
s=R-s
while a:
    L=a.pop()
    ans.append([s,L])
    s=s-L
print(s)
for x in ans:
    print(*x)
from math import gcd

def resolve():
	n = int(input())
	ans = int(input())
	for i in range(n-1):
		v = int(input())
		ans = ans * v // gcd(ans, v)
	print(ans)
resolve()

### FIXED CODE ###

def gcd(a, b):
	"""Compute the greatest common divisor of a and b"""
	while b > 0:
		a, b = b, a % b
	return a

def lcm(a, b):
	"""Compute the lowest common multiple of a and b"""
	return a * b // gcd(a, b)

def resolve():
	n = int(input())
	T = []
	for _ in range(n):
		T.append(int(input()))
	ans = 1
	for i in range(n):
		ans = lcm(ans, T[i])
	print(int(ans))
resolve()
H, W = map(int,input().split())
S = [list(input()) for _ in range(H)]
ans = "Yes"
for i in range(H):
  for j in range(W):
    if(S[i][j] == "#"):
      if(i != 0 and S[i-1][j] == "#"):
        continue
      if(i != H and S[i+1][j] == "#"):
        continue
      if(j != 0 and S[i][j-1] == "#"):
        continue
      if(j != W and S[i][j+1] == "#"):
        continue
      ans = "No"
print(ans)

### FIXED CODE ###

H, W = map(int,input().split())
HW = [input() for _ in range(H)]

ans = "Yes"
for i in range(H-1):
  for j in range(W-1):
    if(HW[i][j] == "."):
      continue
    if(i != 0 and HW[i-1][j] == "#"):
      continue
    if(j != 0 and HW[i][j-1] == "#"):
      continue
    if(j != H and HW[i+1][j] == "#"):
      continue
    if(j != W and HW[i][j+1] == "#"):
      continue
    ans = "No"
print(ans)
N=int(input())
S=map(int,input().split())
if 'Y' in N :
  print('Three')
else:
  print('Four')

### FIXED CODE ###

N=int(input())
S=input()
if 'Y' in S :
  print('Four')
else:
  print('Three')
N, K = input().strip().split()
N = int(N)
K = int(K)

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

count = 0
for i in range(N):
    if h[i] >= K:
        count += 1
print(count)


### FIXED CODE ###

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

values = [i for i in range(1, N+1)]
dic = dict(zip(keys, values))
keys.sort()
for i in range(1, N+1):
    value = dic[i]
    print('{} '.format(value), end='')