Harryxun/stf_run huggingface dataset:
cost = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
def solve(yoshida, possible, dp):
    if(yoshida == 0):
        dp[0] = 0
    elif(dp[yoshida] == -1):
        for x in possible:
            if(yoshida >= cost[x]):
                idx = yoshida - cost[x]
                solve(idx, possible, dp)
                a = (dp[idx]) * 10 + x
                dp[yoshida] = max(dp[yoshida], a)

if __name__ == '__main__':
    n, m = map(int, input().split())
    lst = list(map(int, input().split(" ")))
    DP = [-1] * (n + 1)
    solve(n, lst, DP)
    '''
    for i in range(n + 1):
        print("{} : {}".format(i, DP[i]))
    '''
    print(DP[n])


### FIXED CODE ###

cost = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

''' 再帰が深すぎて, 再起不能
def solve(yoshida, possible, dp):
    if(yoshida == 0):
        dp[0] = 0
    elif(dp[yoshida] == -1):
        for x in possible:
            if(yoshida >= cost[x]):
                idx = yoshida - cost[x]
                solve(idx, possible, dp)
                a = (dp[idx]) * 10 + x
                dp[yoshida] = max(dp[yoshida], a)
'''

def solve(yoshida, possible, dp):
    dp[0] = 0
    for i in range(n):
        a = 10 * dp[i]
        for x in possible:
            dp[i + cost[x]] = max(dp[i + cost[x]], a + x)
if __name__ == '__main__':
    n, m = map(int, input().split())
    lst = list(map(int, input().split(" ")))
    DP = [-1] * (n + 10)
    solve(n, lst, DP)
    '''
    for i in range(n + 1):
        print("{} : {}".format(i, DP[i]))
    '''
    print(DP[n])
a, b, c = map(int, input().split(" "))
print("{} {} {}".format(c, a, b)

### FIXED CODE ###

a, b, c = map(int, input().split(" "))
print(c, a, b)
N = int(input())
a = input().split()
ans = 0
min = max(a)
for i in range(0,N):
	a[i] = int(a[i])
for i in range(0,N-1):
	for j in range(1,N):
		if abs(a[i]-a[j]) < min
			min = abs(a[i]-a[j])
print(min)

### FIXED CODE ###

N = int(input())
a = input().split()


for i in range(0,N):
	a[i] = int(a[i])
mi = 0
for i in range(0,N-1):
	for j in range(i+1,N):
		if abs(a[i]-a[j]) > mi:
			mi = abs(a[i]-a[j])
print(mi)
n = int(input())
if n == 1:
  print(0)
else:
  PFs = []
  PNs = []
  for div in range(2, int(n**(0.5) + 1)):
    for pn in PNs:
      if div % pn == 0:
        break
    else:
      PNs.append(div)
      while n % div == 0:
        n /= div
        PFs.append(div)
if len(PFs) == 0:
  PFs = [n]
#print(PFs)
  
Pats = [[]]
for i in range(len(PFs)):
  temp = []
  for pat in Pats:
    temp.append(pat + [0])
    temp.append(pat + [1])
  Pats = temp
  
min_max = 1000000000000000
for pat in Pats:
  a = 1
  b = 1
  for i, num in enumerate(pat):
    if num == 0:
      a *= PFs[i]
    else:
      b *= PFs[i]
#  print(a, b, pat)
  fx = max(len(str(a)), len(str(b)))
  min_max = min(min_max, fx)
print(min_max)

### FIXED CODE ###

import sys
n = int(input())
if n == 1:
  print(1)
  sys.exit()
min_max = 1000
for div in range(1, int(n**(0.5) + 1)):
  if n % div == 0:
    a = div
    b = n // div
    fx = max(len(str(a)), len(str(b)))
    min_max = min(min_max, fx)
print(min_max)
n,m = map(int,input().split())

x = []
y = []
ans = [10]*n 

for i in range(m):
    s = input().split()
    x.append(int(s[0]))
    y.append(int(s[1]))

cnt = 0

q = 0

for i in x:
    if i == 1 and y[cnt] == 0 and n!=1:
        print(-1)
        q = 1
        break
    else:
        if ans[i-1] !=10:
            if ans[i-1]==y[cnt]:
                cnt += 1
            else:
                print(-1)
                q = 1
                break
        else:
            ans[i-1] = y[cnt]
            cnt += 1
            
cnt2 = 0

if q ==0:
    for i in ans:
        if i == 10:
            if cnt2 == 0:
                ans[cnt2] = 1
                cnt2 += 1
            else:
                ans[cnt2] = 0
        cnt2 += 1
    for i in ans:
        print(i,end = "")

### FIXED CODE ###

n,m = map(int,input().split())

x = []
y = []
ans = [10]*n 

for i in range(m):
    s = input().split()
    x.append(int(s[0]))
    y.append(int(s[1]))

cnt = 0

q = 0

for i in x:
    if i == 1 and y[cnt] == 0 and n!=1:
        print(-1)
        q = 1
        break
    else:
        if ans[i-1] !=10:
            if ans[i-1]==y[cnt]:
                cnt += 1
            else:
                print(-1)
                q = 1
                break
        else:
            ans[i-1] = y[cnt]
            cnt += 1
            
cnt2 = 0

if q ==0:
    for i in ans:
        if i == 10:
            if cnt2 == 0:
                if n == 1:
                    ans[cnt] = 0
                else:
                    ans[cnt2] = 1
            else:
                ans[cnt2] = 0
        cnt2 += 1
    for i in ans:
        print(i,end = "")
N = int(input())
str =input()

S = str.count("R")
if S > N//2 :
    print("Yes")
else:
    print("No")

### FIXED CODE ###

A, B, C = map(int, input().split())
if A == B == C:
    print("Yes")
else:
    print("No")
import itertools
import math

N = int(input())
town = list(itertools.permutations(range(N)))
dis = []
for i in range(N):
    s = tuple(map(int,input().split()))
    dis.append(s)
    
ans = 0
for i,j,k in town:
    calc = math.sqrt((dis[i][0]-dis[j][0])**2 + (dis[i][1]-dis[j][1])**2 ) + math.sqrt((dis[j][0]-dis[k][0])**2 + (dis[j][1]-dis[k][1])**2 )
    ans += calc
    
ans/len(town)

### FIXED CODE ###

import itertools
import math
n = int(input())
s = []
for i in range(n):
    x,y = map(int,input().split())
    s.append([x,y])
s = list(itertools.permutations(s))
ans = 0
for i in s:
    for j in range(n-1):
        ans += math.sqrt((i[j][0] - i[j+1][0])**2 + (i[j][1] - i[j+1][1])**2)
print(ans/len(s))
import numpy as np
a,b = map(int, input().split())
grid1 = np.full((50,100), '.')
grid2 = np.full((50,100), '#')
a = a-1
b = b-1
x = y = 1
for i in range(a):
    grid2[x, y] = '.'
    y += 2
    if y != y % 100:
        x += 2
    y = y % 100
    
x = y = 1
for i in range(b):
    grid1[x, y] = '#'
    y += 2
    if y != y % 100:
        y += 2
    y = y % 100

print(100, 100)
grid = np.concatenate((grid1, grid2), axis=0)
for row in grid:
    print(''.join(row))

### FIXED CODE ###

import numpy as np
a,b = map(int, input().split())
grid1 = [['.' for j in range(100)] for i in range(50)]
grid2 = [['#' for j in range(100)] for i in range(50)]
a -= 1
b -= 1
x = y = 1

for i in range(a):
    grid2[x][y] = '.'
    y += 2
    if y != y % 100:
        x += 2
    y = y % 100
    if x >= 50 or y >= 100:break

x = y = 1
for i in range(b):
    grid1[x][y] = '#'
    y += 2
    if y != y % 100:
        x += 2
    y = y % 100
    if x >= 50 or y >= 100:break

print(100, 100)
grid = np.concatenate((grid1, grid2), axis=0)
for row in grid:
    print(''.join(row))
n,k = map(int,input().split())
if n >= k:
    print(min(n%k,abs(n%k-k)))
else:
    print(min(n,abs(k%n)))

### FIXED CODE ###

n,k = map(int,input().split())
rest = n%k
print(min(rest,k-rest))
from sys import exit
input = sys.stdin.readline

n = int(input())
task = []
time_total = [-1 for i in range(n)]
for i in range(n):
    task.append([int(i) for i in input().split()])
task_sorted = sorted(task, key = lambda x:x[1])
time_total[0] = task_sorted[0][0]
for i in range(n - 1):
    time_total[i + 1] = time_total[i] + task_sorted[i + 1][0]
for i in range(n):
    if time_total[i] > task_sorted[i][1]:
        print("No")
        exit()
print("Yes")

### FIXED CODE ###

import sys
input = sys.stdin.readline

n = int(input())
task = []
time_total = [-1 for i in range(n)]
for i in range(n):
    task.append([int(i) for i in input().split()])
task_sorted = sorted(task, key = lambda x:x[1])
time_total[0] = task_sorted[0][0]
for i in range(n - 1):
    time_total[i + 1] = time_total[i] + task_sorted[i + 1][0]
for i in range(n):
    if time_total[i] > task_sorted[i][1]:
        print("No")
        sys.exit()
print("Yes")
def travel(here, lb, ub, field, label):
	if field[here[1]][here[0]] == 1:
		field[here[1]][here[0]] = label
		if lb[0] < here[0] :
			travel((here[0]-1, here[1]), lb, ub, field, label)
			if lb[1] < here[1]:
				travel((here[0]-1, here[1]-1), lb, ub, field, label)

		if lb[1] < here[1] :
			travel((here[0], here[1]-1), lb, ub, field, label)
			if ub[0] > here[0] :
				travel((here[0]+1, here[1]-1), lb, ub, field, label)

		if ub[0] > here[0] :
			travel((here[0]+1, here[1]), lb, ub, field, label)
			if ub[1] > here[1]:
				travel((here[0]+1, here[1]+1), lb, ub, field, label)
				 
		if ub[1] > here[1] :
			travel((here[0], here[1]+1), lb, ub, field, label)
			if lb[0] < here[0] :
				travel((here[0]-1, here[1]+1), lb, ub, field, label)

while 1:
	w, h = map(int, raw_input().split(" "))
	if (w,h) == (0,0):
		break
	island = []
	for j in range(h):
		island.append(map(int, raw_input().split(" ")))
	label = 1
	for j in range(h):
		for i in range(w):
			if island[j][i] == 1:
				label += 1
				travel((i,j), (0,0), (w-1,h-1), island, label)
	print label - 1

### FIXED CODE ###

def travel(here, lb, ub, field, label):
	if field[here[1]][here[0]] == 1:
		field[here[1]][here[0]] = label
		if lb[0] < here[0] :
			travel((here[0]-1, here[1]), lb, ub, field, label)
			if lb[1] < here[1]:
				travel((here[0]-1, here[1]-1), lb, ub, field, label)

		if lb[1] < here[1] :
			travel((here[0], here[1]-1), lb, ub, field, label)
			if ub[0] > here[0] :
				travel((here[0]+1, here[1]-1), lb, ub, field, label)

		if ub[0] > here[0] :
			travel((here[0]+1, here[1]), lb, ub, field, label)
			if ub[1] > here[1]:
				travel((here[0]+1, here[1]+1), lb, ub, field, label)
				 
		if ub[1] > here[1] :
			travel((here[0], here[1]+1), lb, ub, field, label)
			if lb[0] < here[0] :
				travel((here[0]-1, here[1]+1), lb, ub, field, label)

import sys
sys.setrecursionlimit(100000)
while 1:
	w, h = map(int, raw_input().split(" "))
	if (w,h) == (0,0):
		break
	island = []
	for j in range(h):
		island.append(map(int, raw_input().split(" ")))
	label = 1
	for j in range(h):
		for i in range(w):
			if island[j][i] == 1:
				label += 1
				travel((i,j), (0,0), (w-1,h-1), island, label)
	print label - 1
lst_str = [input() for _ in range(5)]
lst_int = [int(x) for x in lst_str]

sum_lst = sum(lst_int)

lst_diff = []
for i in lst_str:
    val = int(i[-1])
    if val != 0:
        lst_diff.append(10 - val)

diff = sum(lst_diff) - max(lst_diff)

ans = sum_lst + diff
print(ans)

### FIXED CODE ###

lst_str = [input() for _ in range(5)]
lst_int = [int(x) for x in lst_str]

sum_lst = sum(lst_int)

lst_diff = []
for i in lst_str:
    val = int(i[-1])
    if val != 0:
        lst_diff.append(10 - val)

if lst_diff == []:
    lst_diff = [0]
diff = sum(lst_diff) - max(lst_diff)

ans = sum_lst + diff
print(ans)
w,h,x,y,r = [int(x) for x in input().split()]

if (x+r) =< w and (y+r) =< h:
	print("yes")
else:
	print("No")


### FIXED CODE ###

w,h,x,y,r = [int(x) for x in input().split()]

if x >= r and y >= r and (x+r) <= w and (y+r) <= h:
	print("Yes")
else:
	print("No")
import itertools
 
N=int(input())
P=list(map(int,input().split()))
Q=list(map(int,input().split()))
nlis=[i for i in range(1,N+1)]
 
j=list(itertools.permutations(nlis))
cp=j.index(P)+1
cq=j.index(Q)+1
print(abs(cp-cq))

### FIXED CODE ###

K,X=map(int,input().split())
if K*500>=X:
  print('Yes')
else:
  print('No')
import sys
sys.setrecursionlimit(10**8)

from collections import deque
from itertools import chain

def bfs(maze,visited,gy,gx):
    que = deque([[1,1]])
    visited[1][1] = 0
    
    while que:
        y,x = que.popleft()
        if [y,x] == [gy,gx]:
            return visited[y][x]
        for j,k in ([1,0],[-1,0],[0,1],[0,-1]):
            ny,nx = y+j,x+k
            if maze[ny][nx] == "." and visited[ny][nx] == -1:
                visited[ny][nx] = visited[y][x] + 1
                que.append([ny,nx])

h,w = map(int,input().split())
maze = ["#"*(w+2)] + ["#"+input()+"#" for _ in range(h)] + ["#"*(w+2)]
visited = [[-1]*(w+2) for _ in range(h+2)]
sr = bfs(maze,visited,h,w)

num_dot = list(chain.from_iterable(maze))
num_dot = num_dot.count('.')
num_sharp = h*w - num_dot
print(h*w - num_sharp - sr - 1)

### FIXED CODE ###

from collections import deque

def bfs(maze,visited,sy,sx,gy,gx):
    Step = ([1,0],[0,1],[-1,0],[0,-1])
    
    que = deque([[sx,sy]])
    visited[sx][sy] = 1
    
    while que:
        y,x = que.popleft()
        if [y,x] == [gy,gx]:
            return visited[y][x]
        for j,k in Step:
            ny,nx = y+j , x+k
            if 0 <= ny <= gy and 0 <= nx <= gx:
                if maze[ny][nx] == '.' and visited[ny][nx] == INF:
                    visited[ny][nx] = visited[y][x] + 1
                    que.append([ny,nx])


h,w = map(int,input().split())
maze = [input().strip() for _ in range(h)]

cntSharp = 0
for i in range(h):
    cntSharp += maze[i].count('.')

INF = 10**5
visited = [[INF]*w for _ in range(h)]

sx,sy = 0,0
gy,gx = h-1,w-1

minStep = bfs(maze,visited,sy,sx,gy,gx)
print(cntSharp - minStep if visited[gy][gx] != INF else -1)
from collections import defaultdict
MOD = 998244353

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

cnt = defaultdict(int)
m = 0
for i in range(n):
    cnt[d[i]] += 1
    m = max(d[i], m)

if d[0] != 0 or dd[0] != 1:
    ans = 0
else:
    ans = 1
    for i in range(1, m + 1):
        ans *= cnt[i - 1]**cnt[i]
        ans %= MOD

print(ans)


### FIXED CODE ###

from heapq import heappush, heappop
import sys
input = sys.stdin.readline


def dijkstra(graph: list, node: int, start: int) -> list:
    # graph[node] = [(cost, to)]
    INF = float('inf')
    dist = [INF] * node

    dist[start] = 0
    heap = [(0, start)]
    while heap:
        cost, thisNode = heappop(heap)
        for NextCost, NextNode in graph[thisNode]:
            dist_cand = dist[thisNode] + NextCost
            if dist_cand < dist[NextNode]:
                dist[NextNode] = dist_cand
                heappush(heap, (dist[NextNode], NextNode))
    return dist
    # dist = [costs to nodes]


n, m = map(int, input().split())
edge = [[] for _ in range(n)]
for _ in range(m):
    l, r, c = map(int, input().split())
    l -= 1
    r -= 1
    edge[l].append((c, r))
for i in range(1, n):
    edge[i].append((0, i - 1))

dist = dijkstra(edge, n, 0)
ans = dist[-1] if dist[-1] != float("inf") else -1

print(ans)
import sys
input = sys.stdin.readline
import math

a,b,x=map(int,input().split())
cm2=a*a*b
long1=(cm2-x)/(a*a)
if b-long1*2>=0:
    ans=(math.degrees(math.atan((b-long1*2)/a)))
else:
    ans=math.degrees(math.atan(a**3/2(a*a*b-x)))
print(ans)


### FIXED CODE ###

import math

a,b,x=map(int,input().split())
x/=a
half=a*b/2
if x>half:
    print(math.degrees(math.atan(2*(a*b-x)/a/a)))
else:
    print(math.degrees(math.atan(b/(2*x/b))))
N, M =map(int, input().split())
if('Yes' if N==M else 'No')

### FIXED CODE ###

N, M =map(int, input().split())
print('Yes' if N==M else 'No')
def main():
  D, G = list(map(int, input().split()))
  P = []
  for i in range(1, D+1):
    P.append(tuple(map(int, input().split())))

  # print(D, G, P)
  minp = float('inf')
  for bit in range(1 << D):
    total = 0
    num_p = 0
    bset = set()
    for i in range(D):
      mask = 1 << i
      if bit & mask:
        total += P[i][1] + 100*(i+1)*P[i][0]
        num_p += P[i][0]
        bset.add(i)

    # print(f'bset:{bset}, num_p:{num_p}')

    res = G - total
    if res <= 0:
      if num_p < minp:
        minp = num_p
      continue

    for i in reversed(sorted(set([i for i in range(D)]) - bset)):
      maxv = 100*(i+1) * (P[i][0]-1)

      if res <= maxv:
        num_take = max(min(bisect.bisect(list(range(0, maxv+100*(i+1), 100*(i+1))), res)-1, P[i][0]-1), 1)
        # print(i, list(range(0, maxv, 100*(i+1))))
        # print(f'res:{res} so solve {100*(i+1)} * {num_take}')
        num_p += num_take
        res -= 100*(i+1)*num_take
        if num_p < minp:
          minp = num_p
        break

      res -= maxv
      # print(f'solve {i+1} * {P[i][0]-1}')
      num_p += (P[i][0]-1)

  print(minp)


if(__name__ == '__main__'):
  main()

### FIXED CODE ###

import bisect


def main():
  D, G = list(map(int, input().split()))
  P = []
  for i in range(1, D+1):
    P.append(tuple(map(int, input().split())))

  # print(D, G, P)
  minp = float('inf')
  for bit in range(1 << D):
    total = 0
    num_p = 0
    bset = set()
    for i in range(D):
      mask = 1 << i
      if bit & mask:
        total += P[i][1] + 100*(i+1)*P[i][0]
        num_p += P[i][0]
        bset.add(i)

    # print(f'bset:{bset}, num_p:{num_p}')

    res = G - total
    if res <= 0:
      if num_p < minp:
        minp = num_p
      continue

    for i in reversed(sorted(set([i for i in range(D)]) - bset)):
      maxv = 100*(i+1) * (P[i][0]-1)

      if res <= maxv:
        num_take = max(min(bisect.bisect(list(range(0, maxv+100*(i+1), 100*(i+1))), res)-1, P[i][0]-1), 1)
        # print(i, list(range(0, maxv, 100*(i+1))))
        # print(f'res:{res} so solve {100*(i+1)} * {num_take}')
        num_p += num_take
        res -= 100*(i+1)*num_take
        if num_p < minp:
          minp = num_p
        break

      res -= maxv
      # print(f'solve {i+1} * {P[i][0]-1}')
      num_p += (P[i][0]-1)

  print(minp)


if(__name__ == '__main__'):
  main()
N = input()
K = input()
c = 1
for i in range(N):
  c = min(c*2, c+K)
print(c)

### FIXED CODE ###

N = int(input())
K = int(input())
c = 1
for i in range(N):
  c = min(c*2, c+K)
print(c)
#include <iostream>

#include <unordered_set> 
#include <vector>
#include <algorithm>

using namespace std;


int main() {
	    int a,b;
	    cin>>a;
	    std::unordered_set<string> s;
	    
	    while(a--){
	        string str;
	        cin>>str;
	        string key=str;
	        	if (!(s.find(key) != s.end())){
	        	    s.insert(str); 
	        	}
	    }
	    cout<< s.size()<<endl;
	return 0;
}

### FIXED CODE ###

list1 =[]
number = int(input())
for i in range(0,number):    
    numbers = input()
    list1.append(numbers)
setOfMarks=set(list1)
print(len(setOfMarks))
a,b = map(int, input().slplit())
if (b-a)%2==0: print((a+b)//2)
else: print('IMPOSSIBLE')

### FIXED CODE ###

a,b = map(int, input().split())
if (b-a)%2==0: print((a+b)//2)
else: print('IMPOSSIBLE')
N = int(input())
S = input()
East = [0] * (N)
if S[0] == "E":
    East[0] = 1
for i in range(N-1):
    if i == N-1:
        break
    if S[i+1] == 'E':
        East[i+1] = East[i] + 1
    else:
        East[i+1] = East[i]
# print(East)
result = East[N-1] -East[1]
for i in range(1,N):
    if i == N-1:
        ans = (i-1) -East[i-2]
    elif i == 1:
        ans = East[N-1] - East[i+1]
    else:
        right_E = East[N-1] - East[i+1]
        left_W = (i-1) -East[i-2]
        ans = right_E + left_W
    if result > ans:
        result = ans
        # print(i)
print(result)



### FIXED CODE ###

a, b = map(int, input().split())
max = a+b
if max < a - b:
    max = a-b
if max < a * b:
    max = a*b
print(max)
s = input().split()
s = [int(i) for i in s]
N = s[0]

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

L = [0] * N
L[0] = a[0] - sum(a[1 : ])

if N == 2 : 
    print(abs(a[0] - a[1]))
else : 
    MIN = float("inf")
    for i in range(1 , N - 1 ) : 
        L[i] = L[i - 1] + 2 * a[i]
        if L[i] * L[i - 1] <= 0 : 
            if MIN > min( abs(L[i]) , abs(L[i - 1])) : MIN = min( abs(L[i]) , abs(L[i - 1]))

print(MIN)

### FIXED CODE ###


s = input().split()
s = [int(i) for i in s]
N = s[0]

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

L = [0] * N
L[0] = a[0] - sum(a[1 : ])

if N == 2 : 
    print(abs(a[0] - a[1]))
else : 
    MIN = float("inf")
    for i in range(1 , N - 1 ) : 
        L[i] = L[i - 1] + 2 * a[i]
        if MIN > min( abs(L[i]) , abs(L[i - 1])) : MIN = min( abs(L[i]) , abs(L[i - 1]))
    print(MIN)
input_data = list(map(int,input().split()))
import sys

sys.setrecursionlimit(10**6)
mini = min(input_data[1:])
length=max(input_data[1:])-mini
zahyo = [n-mini for n in input_data[1:]]
energy=[0 for i in range(length+1)]
for i in range(length+1):
    for j in range(input_data[0]):
        energy[i]=energy[i]+(i-zahyo[j])**2
print(min(energy))


### FIXED CODE ###

N= int(input())
input_data = [int(x) for x in input().split()]
mini = min(input_data)
length=max(input_data)-mini
zahyo = [n-mini for n in input_data]
energy=[0 for i in range(length+1)]
for i in range(length+1):
    for j in range(N):
        energy[i]=energy[i]+(i-zahyo[j])**2
print(min(energy))
N = int(input())
V = map(int,input().split(" "))
C = map(int,input().split(" "))
P = []

for i in range(N):
    P.append(V[i] - C[i])

result = list(filter(lambda x:x>=1,P))
print(sum(result))

### FIXED CODE ###

N = int(input())
V = list(map(int,input().split(" ")))
C = list(map(int,input().split(" ")))
P = []

for i in range(N):
    P.append(V[i] - C[i])

result = list(filter(lambda x:x>=1,P))
print(sum(result))
input()
line = reverse(input().split())
print(' '.join(line))

### FIXED CODE ###

input()
print(" ".join(input().split()[::-1]))
import numpy as np
N = int(input())
A = list(map(int, input().split()))

x = np.identity(N)
y = np.identity(N)
y0 = y[0]
y = np.delete(y, 0, 0)
y = np.append(y, y0)
y = np.reshape(y, (N, N))
a = x + y
b = np.array(A)

ans = np.linalg.solve(a, b)
ans = [int(n * 2) for n in ans]

print(" ".join(map(str, ans)))


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
X = [0] * N

X[0] = sum(A) - 2 * (sum([A[i] for i in range(N) if i % 2 == 1]))

for i in range(N - 1):
	X[i + 1] = 2 * A[i] - X[i]

print(" ".join(map(str, X)))
n = int(input())
d, x = map(int, input().split())
ans = x
for i in range(n):
    a = int(input())
	ans += (d-1)//a+1
    
print(ans)

### FIXED CODE ###

n = int(input())
d, x = map(int, input().split())
ans = x
for i in range(n):
    a = int(input())
    ans = ans+(d-1)//a+1
    
print(ans)
N, Q = map(int, input().split())
tree = [[] for _ in range(N)]

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

X = [0]*N
for _ in range(Q):
    p, x = map(int, input().split())
    X[p-1] += x

ans = [0]*N

def dfs(u, parent=None):
    """
    u: 子ノード
    parent: 親ノード
    """
    ans[u] = ans[parent] + X[u]
    for v in tree[u]:
        if v != parent:
            dfs(v, u)

dfs(0, 0)
print(' '.join([str(i) for i in ans]))

### FIXED CODE ###

from collections import deque
import sys
input = sys.stdin.readline
 
 
def main():
    n, q = map(int, input().split())
    node = [[]for _ in range(n)]
    looked = [1] * n
    for i in range(n - 1):
        a, b = map(int, input().split())
        node[b - 1].append(a - 1)
        node[a - 1].append(b - 1)
    counter = [0] * n
    for i in range(q):
        p, x = map(int, input().split())
        counter[p - 1] += x
    queue = deque([0])
    looked[0] = 0
    while queue:
        now = queue.pop()
        for i in node[now]:
            if looked[i]:
                queue.append(i)
                counter[i] += counter[now]
                looked[i] = 0
    print(*counter)
 
main()
import math                                             
                                                        
N = input()                                             
t = []                                                  
a = []                                                  
for i in range(int(N)):                                 
    t_n, a_n = input().split()                          
    t.append(int(t_n))                                  
    a.append(int(a_n))                                  
                                                        
t_ans = 0                                               
a_ans = 0                                               
for t_n, a_n in zip(t, a):                              
    k = max(math.ceil(t_ans/t_n), math.ceil(a_ans/a_n)) 
    if not k:                                           
        k = 1                                           
    t_ans = int(k*t_n)                                  
    a_ans = int(k*a_n)                                  
print(t_ans+a_ans)                                      
                                                        


### FIXED CODE ###

a = []              
a = input().split() 
s = set(a)          
print(len(s))