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

import collections as cl
def l(): #intのlist
    return list(map(int,input().split()))
def onem(): #Nとかの取得
    return int(input())
n = onem()

on = []
de = cl.deque()
ppp = [n-2 for i in range(n)]
for i in range(n):
    k = l()
    for j in range(n-1):
        k[j] -= 1
    de.append([k[-1],i])
    on.append(cl.deque(k))


co = 1
ddd = cl.deque()
de.append([-1,-1])
cl = [1 for i in range(n)]
while de:
    kkk = de.popleft()
    if kkk[0] == -1 and kkk[1] == -1:
        if sum(cl) == n:
            co = -1
            break
        if sum(ppp) == -n:
            break
        de.append([-1,-1])
        co += 1
        cl = [1 for i in range(n)]

    elif ppp[kkk[0]] != -1 and on[kkk[0]][ppp[kkk[0]]] == kkk[1] and cl[kkk[0]] and cl[kkk[1]]:
        cl[kkk[0]] = 0
        cl[kkk[1]] = 0
        ppp[kkk[0]] -= 1
        ppp[kkk[1]] -= 1
        if ppp[kkk[1]] != -1 and ppp[kkk[0]] != -1 and on[kkk[1]][ppp[kkk[1]]] == kkk[0] and on[kkk[0]][ppp[kkk[0]]] == kkk[1]:
            de.append([on[kkk[1]][ppp[kkk[1]]],kkk[1]])
        else:
            if len(on[kkk[1]]) != 0:
                de.append([on[kkk[1]][ppp[kkk[1]]],kkk[1]])
            if len(on[kkk[0]]) != 0:
                de.append([on[kkk[0]][ppp[kkk[0]]],kkk[0]])


print(co)


### FIXED CODE ###

import collections as cl
def l(): #intのlist
    return list(map(int,input().split()))
def onem(): #Nとかの取得
    return int(input())
n = onem()

on = []
de = cl.deque()
ppp = [n-1 for i in range(n)]
for i in range(n):
    k = l()
    for j in range(n-1):
        k[j] -= 1
    k.reverse()
    de.append([k[0],i])
    on.append(cl.deque(k))


co = 1
ddd = cl.deque()
de.append([-1,-1])
ppppp = [1 for i in range(n)]
cl = ppppp[:]
while de:
    kkk = de.popleft()
    if kkk[0] == -1 and kkk[1] == -1:
        if sum(cl) == n:
            co = -1
            break
        if len(de) == 0:
            break
        de.append([-1,-1])
        co += 1
        cl = ppppp[:]

    elif ppp[kkk[0]] != 0 and on[kkk[0]][0] == kkk[1] and cl[kkk[0]] and cl[kkk[1]]:
        cl[kkk[0]] = 0
        cl[kkk[1]] = 0
        on[kkk[0]].popleft()
        on[kkk[1]].popleft()
        ppp[kkk[0]] -= 1
        ppp[kkk[1]] -= 1
        if ppp[kkk[1]] != 0 != 0 and ppp[kkk[0]] != 0 and on[kkk[1]][0] == kkk[0] and on[kkk[0]][0] == kkk[1]:
            de.append([on[kkk[1]][0],kkk[1]])
        else:
            if len(on[kkk[1]]) != 0:
                de.append([on[kkk[1]][0],kkk[1]])
            if len(on[kkk[0]]) != 0:
                de.append([on[kkk[0]][0],kkk[0]])


print(co)
### BUGGY CODE ###

N,M = list(map(int, input().split()))
S = list(map(int, input().split())) #N
T = list(map(int, input().split())) #M

MOD = 10**9+7

dp = [[0]*M for _ in range(N)]
# dp[n][m] Sのn文字目，Tのm文字目までの場合の数

dp[0][0] = 1 + int(S[0] == T[0])

for i in range(1,N):
  dp[i][0] = dp[i-1][0] + int(S[i]==T[0])
  
for j in range(1,M):
  dp[0][j] = dp[0][j-1] + int(T[j]==S[0])
  
for n in range(1,N):
  for m in range(1,M):
    dp[n][m] = (dp[n-1][m] + dp[n][m-1] - dp[n-1][m-1] + dp[n-1][m-1]*int(S[n]==T[m]))%MOD
    

#print(dp)
print(dp[N-1][M-1])

### FIXED CODE ###

N,M = list(map(int, input().split()))
S = list(map(int, input().split())) #N
T = list(map(int, input().split())) #M

MOD = 10**9+7

dp = [[0]*M for _ in range(N)]
# dp[n][m] Sのn文字目，Tのm文字目までの場合の数

dp[0][0] = 1 + int(S[0] == T[0])

for i in range(1,N):
  dp[i][0] = dp[i-1][0] + int(S[i]==T[0])
  
for j in range(1,M):
  dp[0][j] = dp[0][j-1] + int(T[j]==S[0])
  
for n in range(1,N):
  for m in range(1,M):
    dp[n][m] = (dp[n-1][m] + dp[n][m-1] - dp[n-1][m-1] + dp[n-1][m-1]*int(S[n]==T[m]))%MOD
    

#print(dp)
print(dp[N-1][M-1])
### BUGGY CODE ###

N, K, Q = map(int, input().split())
A = [int(input()) for _ in range(Q)]

for i in range(N):
    if K - (Q - A.count(i+1)) > 0:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

from collections import Counter

N, K, Q = map(int, input().split())
A = [int(input()) for _ in range(Q)]

c = Counter(A)
for i in range(N):
    if K - (Q - c[i+1]) > 0:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

n,k = (int(x) for x in input().split())
h = list(int(x) for x in input().split())
dp = []

#i = 0の時
dp.append(0)

# i = 1の時
dp.append(abs(h[1] - h[0]))

# i番目までの必要な体力を求める
for i in range(2,n):

    # i >= 2の時
    # i番目に必要な体力の最小値を求める
    dp.append(min(dp[j] + abs(h[i] - h[j]) for j in range(max(0,i-k),i)))

print(dp[-1])
                  



### FIXED CODE ###

def main():
    n,k = map(int,input().split())
    h = list(map(int,input().split()))
    dp = [0]*n
    dp[1] = abs(h[1] - h[0])
    for i in range(2,n):
        dp[i] = min(abs(h[i] - h[j]) + dp[j] for j in range(max(0,i-k),i))
    print(dp[-1])

main()
### BUGGY CODE ###

n, q = list(map(int, input().split()))
s = input()

lst = []

for _ in range(q):
  lst.append(list(map(int, input().split())))

for i in range(q):
  print(s[lst[i][0] - 1:lst[i][1]].count("AC"))

### FIXED CODE ###

n, q = list(map(int, input().split()))
s = input()


ac = [0] * n

for i in range(n - 1):
  if s[i : i + 2] == "AC":
    ac[i + 1] = ac[i] + 1
  else:
    ac[i + 1] = ac[i]

for _ in range(q):
  l, r = list(map(int, input().split()))
  print(ac[r - 1] - ac[l - 1])
### BUGGY CODE ###

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

after = 1
for i in range(k):
  after *= a[i]

ans_list = [after]
for i in range(n-k):
  ans_list.append(ans_list[i] / a[i] * a[k+i])

for i in range(n-k):
  if ans_list[i] < ans_list[i+1]:
    print("Yes")
  else:
    print("No")

### FIXED CODE ###

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

for i in range(n-k):
  if a[i] < a[i+k]:
    print("Yes")
  else:
    print("No")
### BUGGY CODE ###

# Python profram to check if n is a multiple of 3 
  
# Function to check if n is a multiple of 3 
def isMultipleOf3(n): 
  
    odd_count = 0
    even_count = 0
  
    # Make no positive if + n is multiple of 3 
    # then is -n. We are doing this to avoid 
    # stack overflow in recursion 
    if(n < 0):  
        n = -n 
    if(n == 0): 
        return 1
    if(n == 1):  
        return 0
  
    while(n): 
          
        # If odd bit is set then 
        # increment odd counter  
        if(n & 1):  
            odd_count += 1
  
        # If even bit is set then 
        # increment even counter  
        if(n & 2): 
            even_count += 1
        n = n >> 2
  
    return isMultipleOf3(abs(odd_count - even_count))
num=int(input())
if (isMultipleOf3(num)):  
    print("Yes") 
else: 
    print("No") 


### FIXED CODE ###

n=int(input())
if(n%9==0):
	print("Yes")
else:
	print("No")
### BUGGY CODE ###

n = int(input())
s = input()

r = s.count('R')
g = s.count('G')
b = s.count('B')

# 1つ目の条件を満たす
first_conditions = r*g*b
# 一つ目の条件は満たすが、2つ目の条件は満たさない
second_condition = 0
sum_ = 0
for i in range(n):
    r_ = s[i]
    for j in range(i,n):
        g_ = s[j]
        for k in range(j,n):
            if j-i == k-j and r_ != g_ and g_ != s[k] and r_ != s[k]:
                second_condition += 1
print(first_conditions-second_condition)

### FIXED CODE ###

n = int(input())
s = input()
r_ary = []
g_ary = []
b_ary = []
for i in (s):
    if i == 'R':
        r_ary.append(i)
    elif i == 'G':
        g_ary.append(i)
    elif i == 'B':
        b_ary.append(i)
r = len(r_ary)
g = len(g_ary)
b = len(b_ary)
first_conditions = r*g*b
for i in range(n-2):
    for j in range(i+1,n-1):
        if 2*j-i<n and s[i]!=s[2*j-i] and s[j]!=s[2*j-i] and s[i]!=s[j]:
            first_conditions -= 1
print(first_conditions)
### BUGGY CODE ###

import copy

N = int(input())
cost = list(map(int,input().split()))
for i in range(N):
    ans = 0
    temp_cost = cost.copy()
    temp_cost.pop(i)
    ans += abs(temp_cost[0]) + abs(temp_cost[-1])
    for i in range(0,N-2):
        ans += abs(temp_cost[i] - temp_cost[i+1])
        
    print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
a.insert(0,0)
a.insert(n+1,0)
total = 0
for i in range(n+1):
    total += abs(a[i+1] - a[i])
for i in range(1, n+1):
    print(total + abs(a[i+1] - a[i-1]) - abs(a[i+1] - a[i]) - abs(a[i-1] - a[i]))
### BUGGY CODE ###

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


lst = []
for i, j in enumerate(LR):
    lst_ = set(list(range(j[0],j[1]+1)))
    lst.append(lst_)

lst = set.intersection(*lst)
print(len(lst))

### FIXED CODE ###

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

L = [0] * M
R = [0] * M
for i in range(M):
    L[i], R[i] = map(int, input().split())

print(max(min(R) - max(L) + 1, 0))
### BUGGY CODE ###

import sys
MOD = 10**9 + 7
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
def adj(n): return [[] for _ in range(n)]

def inv(a): return pow(a, MOD-2, MOD) #逆元
def comb(n,r):
    ans = 1
    for i in range(r): ans *= n-i; ans *= inv(r-i); ans %= MOD
    return ans
    
def func(n,k,i):
    ans = 1
    for tmp in range(i): ans *= (n-k+1-tmp) * inv(i-tmp); ans %= MOD
    for tmp in range(i-1): ans *= (k-1-tmp) * inv(i-1-tmp); ans %= MOD
    return ans
    
    
n,k = imap()
for i in range(1,k+1):
    ans = func(n,k,i)
    print(ans)


### FIXED CODE ###

import sys
MOD = 10**9 + 7
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
def adj(n): return [[] for _ in range(n)]

def inv(a): return pow(a, MOD-2, MOD) #逆元
def comb(n,r):
    ans = 1
    for i in range(r): ans *= n-i; ans *= inv(r-i); ans %= MOD
    return ans

    
n,k = imap()
ans = n-k+1
print(ans)
for i in range(2,k+1):
    ans *= (n-k-i+2) * (k-i+1) * inv(i) * inv(i-1)
    print(ans %MOD)
### BUGGY CODE ###

N = int(input())
A_list = list(map(int, input().split()))
Q = int(input())
for _ in range(Q):
    B, C = map(int, input().split())
    A_list = [C if j == B else j for j in A_list]
    print(sum(A_list))

### FIXED CODE ###

import collections

N = int(input())
A_list = list(map(int, input().split()))
A_count_list = collections.Counter(A_list)
A_sum = sum(A_list)
Q = int(input())
for _ in range(Q):
    B, C = map(int, input().split())
    A_sum += (C - B)*A_count_list[B]
    A_count_list[C] += A_count_list[B]
    A_count_list[B] = 0
    print(A_sum)
### BUGGY CODE ###

import heapq
n, k = map(int, input().split())
list_A = list(map(int, input().split()))
list_H = []

for a in list_A:
    list_H.append(((-1)*a, a, 1))
heapq.heapify(list_H)

for _ in range(k):
    l = heapq.heappop(list_H)
    c = 0
    if l[1] % (l[2]+1) == 0:
        c = l[1] // (l[2]+1)
    else:
        c = l[1] // (l[2]+1) + 1

    h = ((-1)*c, l[1], l[2]+1)
    heapq.heappush(list_H, h)

ans = heapq.heappop(list_H)
print(abs(ans[0]))

### FIXED CODE ###

n, k = map(int, input().split())
list_A = list(map(int, input().split()))
l, r = 0, max(list_A)

while l + 1 < r:
    m, cnt = (r + l) // 2, 0

    for a in list_A:
        cnt += (a-1)//m

    if cnt > k:
        l = m
    else:
        r = m

print(r)
### BUGGY CODE ###



tmp = input().split(" ")
n = tmp[0]
q = int(tmp[1])

s = input()

ac_indexes=[]
start=0
while True:
    ind = s.find("AC", start)
    if ind != -1:
        start=ind+2
        ac_indexes.append(ind)
    else:
        break

for i in range(q):

    if len(ac_indexes) == 0:
        print ("0")
        continue

    tmp = input().split(" ")
    a = int(tmp[0]) - 1
    b = int(tmp[1]) - 2

    left = 0
    right = len(ac_indexes)-1
    left_kari=-1
    left_kakutei = -1
    while left <= right:
        center = (left+right)//2
        if ac_indexes[center] > a:
            right = center-1
            left_kari = center
        elif ac_indexes[center] < a:
            left = center+1
        else:
            left_kakutei = center
            break
    if left_kakutei == -1:
        left_kakutei = left_kari
    
    left = 0
    right = len(ac_indexes)-1
    right_kari = -1
    right_kakutei = -1
    while left <= right:
        center = (left+right)//2
        #print (left, center, right)
        if ac_indexes[center] > b:
            right = center-1
        elif ac_indexes[center] < b:
            left = center+1
            right_kari = center
        else:
            right_kakutei = center
            break
    if (right_kakutei == -1):
        right_kakutei = right_kari

    if (left_kakutei > right_kakutei or left_kakutei==-1 or right_kakutei==-1):
        print ("0")
        continue

    print(str(right_kakutei - left_kakutei + 1))


### FIXED CODE ###

import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

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

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def rangeI(it, l, r):
    for i, e in enumerate(it):
        if l <= i < r:
            yield e
        elif l >= r:
            break

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

INF = 999999999999999999999999
MOD = 10**9+7

n,q = get_nums_l()
s = input()

ruiseki_ac = [0] * (n+1)

for i in range(n-1):
    x = 0
    if s[i] == "A" and s[i+1] == "C":
        x = 1
    ruiseki_ac[i+1] = ruiseki_ac[i] + x
ruiseki_ac[n] = ruiseki_ac[n-1]

log(ruiseki_ac)

for i in range(q):

    a,b = get_nums_l()
    print(ruiseki_ac[b-1] - ruiseki_ac[a-1])
### BUGGY CODE ###

S = input()

def comn(n,m):
    originamN = n
    s1 = 1
    s2 = 1
    while n >= (originamN-m + 1):
        s1 = s1 * n
        n = n - 1

    while m >= 1:
        s2 = s2 * m
        m = m - 1

    return s1 // s2



def calculate(s):
    length = len(s)

    dict = {0:1}
    for i in range(len(s)):
        index = (int(s[i:length]) % 2019)
        if dict.get(index) != None:
            dict.__setitem__(index, dict.get(index) + 1)
        else:
            dict.__setitem__(index, 1)

    result = 0
    for val in dict.values():
        if val > 1:
            result = result + comn(val,2)

    print(result)
calculate(S)


### FIXED CODE ###

s = input()[::-1] # 入力文字列を逆順でsに格納

counts = [0] * 2019
counts[0] = 1

num, d = 0, 1

for char in s:
    num += int(char) * d
    num %= 2019
    d *= 10
    d%= 2019
    counts[num] += 1

ans = 0
for cnt in counts:
    ans += cnt * (cnt - 1) // 2

print(ans) # 答えの出力
### BUGGY CODE ###

n, m, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))

sb = [0] * (m + 1)
for j in range(m):
  sb[j + 1] = sb[j] + b[j]

sa = 0
anses = []
for i in range(n + 1):
  for j in range(m + 1):
    # print(sa,sb[j])
    if sa + sb[j] <= k:
      anses.append(i + j)
  if i == n:
    break
  sa += a[i]

print(max(anses))


### FIXED CODE ###

import bisect

n, m, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))


sa = [0] * (n + 1)
for i in range(n):
  sa[i + 1] = sa[i] + a[i]

sb = [0] * (m + 1)
for j in range(m):
  sb[j + 1] = sb[j] + b[j]

anses = [0]
for i in range(n + 1):
  if sa[i] > k:
    continue
  anses.append(i + bisect.bisect(sb, k - sa[i]) - 1)

print(max(anses))
### BUGGY CODE ###

R, C, K = map(int, input().split())

V = [[0]*(C+1) for _ in range(R+1)]
dp = [[[0,0,0,0] for _ in range(C+1)] for _ in range(R+1)]

for _ in range(K):
    r, c, v = map(int, input().split())
    V[r][c] = v

for r in range(1,R+1):
    for c in range(1,C+1):
        v = V[r][c]
        dprc  = dp[r][c]
        dprcL = dp[r][c-1]
        if v==0:
            dprc[0] = max(max(dp[r-1][c]), dprcL[0])
            for n in range(1,4): dprc[n] = dprcL[n]
        else:
            dprc[0] = max(max(dp[r-1][c])  ,             dprcL[0])
            dprc[1] = max(max(dp[r-1][c])+v, dprcL[0]+v, dprcL[1])
            dprc[2] = max(                   dprcL[1]+v, dprcL[2])
            dprc[3] = max(                   dprcL[2]+v, dprcL[3])

print(max(dp[R][C]))


### FIXED CODE ###

R, C, K = map(int, input().split())

V = [[0]*(C+1) for _ in range(R+1)]
dp1 = [[0,0,0,0] for _ in range(C+1)]

for _ in range(K):
    r, c, v = map(int, input().split())
    V[r][c] = v

for r in range(1,R+1):
    dp0 = dp1
    dp1 = [[0,0,0,0] for _ in range(C+1)]
    
    for c in range(1,C+1):
        v = V[r][c]
        dprc  = dp1[c]
        dprcL = dp1[c-1]
        if v==0:
            dprc[0] = max(max(dp0[c]), dprcL[0])
            for n in range(1,4): dprc[n] = dprcL[n]
        else:
            maxT = max(dp0[c])
            dprc[0] = max(maxT  ,             dprcL[0])
            dprc[1] = max(maxT+v, dprcL[0]+v, dprcL[1])
            dprc[2] = max(        dprcL[1]+v, dprcL[2])
            dprc[3] = max(        dprcL[2]+v, dprcL[3])
        

print(max(dp1[C]))
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
result = 1
target = 10**18
 
if a.count(0) >= 1:
  result = 0
else:
  for an in a:
    result = an*result
  
  if result > 10**18:
    result = -1
 
print(result)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
result = 1
target = 10**18
 
if a.count(0) >= 1:
  result = 0
else:
  for an in a:
    result = an*result
    if result > target:
      result = -1
      break
 
print(result)
### BUGGY CODE ###

from collections import deque
n=int(input())
s=deque([])
cnt=0
for _ in range(n):
    s.append(sorted(input()))
for i in range(n):
    for j in range(n):
        if i<j:
            if s[i]==s[j]:
                cnt+=1
print(cnt)

### FIXED CODE ###

n=int(input())
L=[[] for _ in range(n)]
ans=0
for i in range(n):
    L[i]=sorted(list(input()))
L=sorted(L)
tmp=1
ans=0
for i in range(n-1):
    if L[i]==L[i+1]:
        tmp+=1
    else:
        ans+=tmp*(tmp-1)//2
        tmp=1
ans+=tmp*(tmp-1)//2
print(ans)
### BUGGY CODE ###

import numpy as np
n = int(input())
p_arr = np.array(list(map(int, input().split())))
res = 0
for k, i in enumerate(p_arr):
  if i == 1 or k == 0:
    res += 1
  else:
    left_arr = p_arr[:k]
    b_arr = i > left_arr
    if not b_arr.any():
      res += 1
print(res)

### FIXED CODE ###

n = int(input())
p_arr = list(map(int, input().split()))
min_i = 9999999999999999999999999
res = 0
for i in p_arr:
  if i == 1:
    res += 1
    break
  else:
    if i < min_i:
      res += 1
      min_i = i
print(res)
### BUGGY CODE ###


def p_e():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    ans = [[-1]]

    for a in A:
        is_set = False
        for l in ans:
            if l[-1] < a:
                l.append(a)
                is_set = True
                break

        if not is_set:
            ans.append([a])
            
    print(len(ans))


if __name__ == '__main__':
    p_e()

### FIXED CODE ###

from bisect import *


def p_e():
    N = int(input())
    # A = [int(input()) for _ in range(N)]
    ans = [-1] * N

    for _ in range(N):
        a = int(input())
        ans[bisect(ans, a - 1) - 1] = a

    print(N - bisect(ans, -1))


if __name__ == '__main__':
    p_e()
### BUGGY CODE ###

N = int(input())
a = list(map(int, input().split()))
ans=[]
for i in range(N):
    ind=a.index(min(a))
    ans.append(ind+1)
    a[ind]=100090
print(*ans, sep=" ")

### FIXED CODE ###

N = int(input())
a = list(map(int, input().split()))
ans=[0]*N
for i in range(N):
    ans[a[i]-1]=i+1
print(*ans,sep=" ")
### BUGGY CODE ###

import sys
from copy import copy

N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

# 時刻nに都市xにいる人数をI_x_n, 都市xで載せられる人数をJ_xとする
# I_x_n+1_prov = I_x_n - J_x (if I_x_n >= J_x)
# I_x_n+1_prov = 0           (if I_x_n < J_x)
# I_x_n+1 = I_x_n+1_prov + I_x-1_n (if I_x-1_n <= J_x-1)
# I_x_n+1 = I_x_n+1_prov+ J_x-1    (if I_x-1_n > J_x-1)
# 都市6の人数がNになった時が求める時刻である

# 以下仮想の都市0を加える
I = [0, N, 0, 0, 0, 0, 0]
I_buf = [0, 0, 0, 0, 0, 0, 0]
J = [0, A, B, C, D, E, 0]

time = 0
while(True):
    if sum(I) != N:
        sys.exit()
    if I[6] == N:
        print(time)
        break
    time += 1
    for num in range(1, 7, 1):
        if I[num] > J[num]:
            I_buf[num] = I[num] - J[num]
        else:
            I_buf[num] = 0

        if I[num - 1] > J[num - 1]:
            I_buf[num] += J[num - 1]
        else:
            I_buf[num] += I[num - 1]
    I = copy(I_buf)

### FIXED CODE ###

N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

num = N

if num >= A:
    num = A 

if num >= B:
    num = B

if num >= C:
    num = C

if num >= D:
    num = D

if num >= E:
    num = E

if N % num == 0:
    print(N // num + 4)
else:
    print(N // num + 5)
### BUGGY CODE ###

def main():
  N = int(input())
  Sp = []
  Sm = []
  total = 0
  for i in range(N):
    l = input()
    u = 0
    h = 0
    for j in range(len(l)):
      if l[j] == '(':
        h += 1
      else:
        h -= 1
      u = min(u, h)
    if h > 0:
      Sp.append([u, h])
    else:
      Sm.append([u-h, -h])
    total += h
  if total != 0:
    print('No')
    exit()
  Sp.sort(key=lambda x:x[0], reverse=True)
  p = check(Sp)
  if not p:
    print('No')
    exit()
  Sm.sort(key=lambda x:x[0], reverse=True)
  m = check(Sm)
  if not m:
    print('No')
    exit()
  print('Yes')

def check(S):
  h = 0
  for i in range(len(S)):
    if h + S[i][0] < 0:
      return False
    else:
      h += S[i][1]
  return True

if __name__ == '__main__':
  main()

### FIXED CODE ###

import sys
readline = sys.stdin.readline

def main():
  N = int(readline())
  Sp = []
  Sm = []
  total = 0
  bm = 0
  for i in range(N):
    l = readline().strip()
    b = 0
    h = 0
    for j in range(len(l)):
      if l[j] == '(':
        h += 1
      else:
        h -= 1
      b = min(b, h)
    if h == 0 and b != 0:
      bm = min(bm, b)
    elif h > 0:
      Sp.append([b, h])
    elif h < 0:
      Sm.append([b-h, -h])
    total += h
  Sp.append([bm, 0])
  if total != 0:
    print('No')
    exit()
  Sp.sort(key=lambda x:x[0], reverse=True)
  p = check(Sp)
  if p < 0:
    print('No')
    exit()
  Sm.sort(key=lambda x:x[0], reverse=True)
  m = check(Sm)
  if m < 0:
    print('No')
    exit()
  print('Yes')

def check(S):
  h = 0
  for i in range(len(S)):
    if h + S[i][0] < 0:
      return -1
    else:
      h += S[i][1]
  return h

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

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

ball=[]

while len(ball)<=N:
    for x in range(A):
        ball.append(1)
        if len(ball)>=N:
            break
    for x in range(B):
        ball.append(-1)
        if len(ball)>=N:
            break

print(ball[0:N].count(1))

### FIXED CODE ###

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

r=N//(A+B)*A
s=N%(A+B)

x=r+min(A,s)
print(x)