Harryxun/stf_run huggingface dataset:
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = int(input())
A = [int(input()) for _ in range(N)]

from collections import deque
from bisect import bisect_left

D = deque([])

for a in A:
    i = bisect_left(D,a)
    if i==0:
        D.appendleft(a)
    else:
        D[i-1] = a
    print(i,D)

print(len(D))

### FIXED CODE ###

# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = int(input())
A = [int(input()) for _ in range(N)]

from collections import deque
from bisect import bisect_left

D = deque([])

for a in A:
    i = bisect_left(D,a)
    if i==0:
        D.appendleft(a)
    else:
        D[i-1] = a

print(len(D))
n = int(input())
l = list( map(int, input().split())) 
ans = 0

lsorted = sorted(l, reverse=True)

for longest in range(len(l)-2):

    for second in range(longest+1, len(l)):
        se
        if lsorted[longest] - 2*lsorted[second] >= 0:
            break 
        for third in lsorted[second+1:]:
            if lsorted[longest] - lsorted[second] - third >= 0:                
                break
            else:
                ans += 1

print(ans)

### FIXED CODE ###

from bisect import bisect_left

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

for i in range(n-2):
    shortest = l[i]
    for j in range(i+1, n-1):
        second = l[j]
        # このスライスしたやつと地味にTLEになる...
        # k = bisect_left(l[j], shortest + second)
        # ans += k

        k = bisect_left(l, shortest + second)
        ans += k - j - 1

print(ans)
n, *a = map(int, open(0).read().split())
print(*a[::-2], *a[n%2::2])

### FIXED CODE ###

n = int(input())
a = input().split()
print(' '.join(a[::-2] + a[n%2::2]))
N = int(input())
a = []

for i in range(1,10):
    for j in range(1,10):
        a.append(i*j)

if N in a:
    print("Yes")
else:
    prtin("NO")



### FIXED CODE ###

N = int(input())
a = []

for i in range(1,10):
    for j in range(1,10):
        a.append(i*j)

if N in a:
    print("Yes")
else:
    print("No")
list = list(map(int,input().split(" ")))

olist = []
for i in range(1, int(min(list[0],list[1]) / 2)):
  if(list[0] % i == 0 and list[1] % i == 0):
    olist.append(i)
print(olist[len(olist) + 1 - list[2]])

### FIXED CODE ###

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

X = []
cnt = 0
for i in range(1, 1 + int(min(list[0],list[1]))):
  if(list[0] % i == 0 and list[1] % i == 0):
    X.append(i)
    cnt = 1
X.sort(reverse=True)
if (cnt == 1):
  print(X[list[2]-1])
else:
  print(1)
n=int(input())
a=list(map(int,input().split()))
a.sort()
print(eval("+".join(a[::2]))-eval("+".join(a[1::2])))

### FIXED CODE ###

n=input()
a=list(map(int,input().split()))
a.sort(reverse=True)
print(sum(a[::2])-sum(a[1::2]))
A = input()
B = input()

if (A > 8 or B > 8)
  print ":("
else:
  print "Yay!"

### FIXED CODE ###

a, b = (int(i) for i in input().split())

if a > 8 or b > 8:
  print(":(")
else:
  print("Yay!")
= [[0 for x in range(1)]for y in range(3)]
one_count = 0
two_count = 0
three_count = 0
four_count = 0
for i in range(3):
     A[i] = [int(x) for x in input().split()]

     if(A[i][0]==1 or A[i][1]==1):
         one_count += 1
     if(A[i][0]==2 or A[i][1]==2):
         two_count += 1
     if(A[i][0]==3 or A[i][1]==3):
         three_count += 1
     if(A[i][0]==1 or A[i][1]==1):
         four_count += 1

if(one_count >= 3 or two_count >= 3 or three_count >= 3 or four_count >= 3):
    print("NO")
else:
    print("YES")



### FIXED CODE ###

A = [[0 for x in range(1)]for y in range(3)]
one_count = 0
two_count = 0
three_count = 0
four_count = 0
for i in range(3):
     A[i] = [int(x) for x in input().split()]

     if(A[i][0]==1 or A[i][1]==1):
         one_count += 1
     if(A[i][0]==2 or A[i][1]==2):
         two_count += 1
     if(A[i][0]==3 or A[i][1]==3):
         three_count += 1
     if(A[i][0]==4 or A[i][1]==4):
         four_count += 1

if(one_count >= 3 or two_count >= 3 or three_count >= 3 or four_count >= 3):
    print("NO")
else:
    print("YES")
from collections import deque
x0,y0,a,b,c = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort()
q.sort()
r.sort()
p = deque(p)
q = deque(q)
r = deque(r)
x,y = 0,0
red = p.pop()
green = q.pop()
mu = r.pop()
ans = 0

def newmu():
  if r:
    return r.pop()
  return 0


while x < x0 or y < y0:
  if x < x0 and y < y0:
    if red >= mu and green >= mu:
      ans += red + green
      red = p.pop()
      green = q.pop()
    elif red >= mu:
      ans += red + mu
      red = p.pop()
      mu = newmu()
    elif green >= mu:
      ans += green + mu
      green = q.pop()
      mu = newmu()
    elif r:
      r2 = r.pop()
      if red >= green and red >= r2:
        ans += mu + red
        mu = r2
        red = p.pop()
      elif green >= red and green >= r2:
        ans += mu + green
        mu = r2
        green = q.poop()
      else:
        ans += mu + r2
        mu = newmu()
    elif red >= green:
      ans += mu + red
      red = p.pop()
      newmu()
    else:
      ans += mu + green
      green = q.pop()
      newmu()
    x += 1
    y += 1
  elif x < x0:
    if red >= mu:
      ans += red
      red = p.pop()
    else:
      ans += mu
      newmu()
    x += 1
  else:
    if green >= mu:
      ans += green
      green = q.pop()
    else:
      ans += mu
      newmu()
    y += 1
print(ans)

### FIXED CODE ###

from collections import deque
x,y,a,b,c = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
l = p[:x] + q[:y] + r
l.sort(reverse=True)
print(sum(l[:(x+y)]))
from math import gcd

A, B, C, D = map(int, input().split())
C_div = B // C - (A - 1) // C
D_div = B // D - (A - 1) // D
CD = C * D // gcd(C, D)
CD_div = B // CD - (A - 1) // CD
print(B - A + 1 - C_div - D_div + CD_div)


### FIXED CODE ###

from fractions import gcd

A, B, C, D = map(int, input().split())
C_div = B // C - (A - 1) // C
D_div = B // D - (A - 1) // D
CD = C * D // gcd(C, D)
CD_div = B // CD - (A - 1) // CD
print(B - A + 1 - C_div - D_div + CD_div)
def gcd(a,b):
    if a < b:
        a,b = b,a
    if b == 0:
        return a
    if a%b == 0:
        return b
    return gcd(b, a%b)
N = int(input())
a = map(int,input().split())
g1=[0 for i in range(N)]
g2=[0 for i in range(N)]
g1[0]=a[0]
g2[N-1]=a[N-1]
for i in range(1,N):
  g1[i]=gcd(g1[i-1],a[i])
for i in range(N-2,-1,-1):
  g2[i]=gcd(g2[i+1],a[i])
ans=1
for i in range(N-2):
  a=gcd(g1[i],g2[i+2])
  ans=max(ans,a)
ans=max(ans,g1[N-2],g2[1])
print(ans)

### FIXED CODE ###

def gcd(a,b):
    if a < b:
        a,b = b,a
    if b == 0:
        return a
    if a%b == 0:
        return b
    return gcd(b, a%b)
N = int(input())
a = list(map(int,input().split()))
g1=[0 for i in range(N)]
g2=[0 for i in range(N)]
g1[0]=a[0]
g2[N-1]=a[N-1]
for i in range(1,N):
  g1[i]=gcd(g1[i-1],a[i])
for i in range(N-2,-1,-1):
  g2[i]=gcd(g2[i+1],a[i])
ans=1
for i in range(N-2):
  a=gcd(g1[i],g2[i+2])
  ans=max(ans,a)
ans=max(ans,g1[N-2],g2[1])
print(ans)
N, A, B = map(int, input().split())
ABalls = "B" * A
BBalls = "R" * B

Balls = ABalls + BBalls
AB = A + B
NumBBalls = 0

NumBBalls = N//AB * A
M = N%AB

for m in range(M):
  if Balls[m] == "B":
    NumBBalls += 1
  else:
    break

print(NumBBalls)

### FIXED CODE ###

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

AB = A + B
NumABalls = 0

NumABalls = N//AB * A
M = N%AB

if A - M >= 0:
  NumABalls += M
else:
  NumABalls += A

print(NumABalls)
n, k =map(int, input().split()) 
s = input()
count = 0
for i in range(n-1):
    if s[i] == s[i+1]:
        count += 1
print(str(count+k*2)

### FIXED CODE ###

n, k =map(int, input().split()) 
s = input()
count = 0
even =0
for i in range(n-1):
    if s[i] == s[i+1]:
        count += 1
    else:
        even +=1

for i in range(k):
        if even >= 2:
            count +=2
            even -= 2
        elif even ==1:
            count+=1
            even -=2
print(str(count))
N = int(input())

if N%2:
    print(0)
else:
    t = N//10
    f = N//50
    
    ans = t+f+(N//200) - t//f
    print(ans)


### FIXED CODE ###

# coding: utf-8
# Your code here!

import sys
input = sys.stdin.readline

def main():
    N = int(input())
    
    # 奇数は終わる
    if N%2:
        print('0')
        quit()
    
    def calc(x,ans):
        fl = 2*(5**x)
        if N >= fl:
            ans += N//fl
            return calc(x+1,ans)
        else:
            return ans
    
    print(calc(1, 0))
        
    
    
if __name__ == '__main__':
    main()
N = int(input())
S = input()
print("Yes" if N%2 == 0 and S[:(N/2)+1] == S[(N/2)+1:N+1])

### FIXED CODE ###

N = int(input())
S = input()
print("Yes" if S[:N//2] == S[N//2:N] else "No")
n = int(input())
s = []
for i in range(n):
    s.append(input())
    
dic = dict()
ans = 0
for i in s:
    if "".join(sorted(i)) in dic.keys():
        ans += dic[i].values()
        dic[i] +=1
    else:
        dic[i] = 1
print(ans)

### FIXED CODE ###

n = int(input())
s = []
for i in range(n):
    s.append(input())
    
dic = dict()
ans = 0
for i in s:
    if "".join(sorted(i)) in dic:
        ans += dic["".join(sorted(i))]
        dic["".join(sorted(i))] +=1
    else:
        dic["".join(sorted(i))] = 1
print(ans)
H, W = map(int, input().split())
S = ["."+input()+"." for i in range(H)]
#print(S)
S = ["."*(H+2)]+S+["."*(W+2)]
#print(S)
flag = 0
for i in range(H):
  for j in range(W):
    if S[i][j] == "#":
      #print(i, j)
      if S[i-1][j] == "." and S[i+1][j] == "." and S[i][j-1] == "." and S[i][j+1] == ".":
        flag = 1
print("Yes" if flag==0 else "No")      

### FIXED CODE ###

H,W=map(int,input().split())
S=["."+input()+"." for i in range(H)]
S=["."*(W+2)]+S+["."*(W+2)]
flag=0
for i in range(H):
    for j in range(W):
        if S[i][j]=="#":
            if S[i-1][j]=="." and S[i+1][j]=="." and S[i][j-1]=="." and S[i][j+1]==".":
                flag=1
print("Yes" if flag==0 else "No")
a,b = input()

if a>=10:
    print(b)
else:
    print(b+100*(10-a))


### FIXED CODE ###

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

if a>=10:
    print(b)
else:
    print(b+100*(10-a))
# coding: utf-8
# Your code here!
n = int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
list = make_divisors(n)
root = int(n**0.5)+1
for i in range(len(list)-1):
    if (list[i] <= root and list[i+1] >root):
        a= list[i]
if n == 1:
    a=1
b = n //a
print(a+b-2)

### FIXED CODE ###

# coding: utf-8
# Your code here!
n = int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
list = make_divisors(n)
root = n**0.5
for i in range(len(list)-1):
    if (list[i] <= root and list[i+1] >root):
        a = list[i]
b = n //a
print(a+b-2)
n=int(input())
d={'AC':0,"WA":0,'TLE':0,'RE':0}
for i in range(n):
    s=str(input())
    if(s=='AC'):
        d['AC']=d['AC']+1
    elif(s=='WA'):
        d['WA']=d['WA']+1
    elif(s=='RE'):
        d['RE']=d['RE']+1
    elif(s=='TLE'):
        d['TLE']=d['TLE']+1
print('AC'+" "+"*"+" "+str(d['AC']))
print('WA'+" "+"*"+" "+d['WA'])
print('TLE'+" "+"*"+" "+d['TLE'])
print('RE'+" "+"*"+" "+d['RE'])

### FIXED CODE ###

n=int(input())
d={'AC':0,"WA":0,'TLE':0,'RE':0}
for i in range(n):
    s=str(input())
    if(s=='AC'):
        d['AC']=d['AC']+1
    elif(s=='WA'):
        d['WA']=d['WA']+1
    elif(s=='RE'):
        d['RE']=d['RE']+1
    elif(s=='TLE'):
        d['TLE']=d['TLE']+1
print("AC x"+' '+str(d['AC']))
print('WA x'+' '+str(d['WA']))
print('TLE x'+' '+str(d['TLE']))
print('RE x'+' '+str(d['RE']))
n,k = lr()
p = lr()

p.sort()
print(sum(p[:k]))

### FIXED CODE ###

# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""
def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# a^n
def power(a,n,mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod

# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n-1
    while(tmp >= l):
        a = a*tmp%mod
        tmp -= 1
    return a

inf = 10**18
mod = 10**9+7

n, k = lr()
p = lr()

p.sort()
print(sum(p[:k]))
a,b,N = map(int, input().split())

Ansermax = 0

if b < N :
    N = b
    
for x in range(N+1):

    Anser = 0

    Anser = int((a*x)//b)-a*int(x//b)
    
    if Ansermax < Anser:
        Ansermax = Anser
    
    if x//b >= 1:
     break

print(Ansermax)

### FIXED CODE ###

X = int(input())

#A**5,B**5でとり得る可能性のある数をあらかじめリストで用意する

N = [i**5 for i in range(1000)]
 
#A,Bで別々の処理をするため、変数はi,jの２種を用意する


for i in range(1000):
	for j in range(1000):

#リストから２つの数を抽出し、Xになるか計算を繰り返す
#Xは正の整数であるため、Aが負になる可能性は除外

		if N[j] - N[i] == X:
			print(j, i)
			exit()

#Bが負の場合、符号が変わる可能性があるため、もう１パターン計算

		if N[j] + N[i] == X:
			print(j, -i)
			exit()
N = int(input())
C = [int(input()) for _ in range(N)]

L = [-1]*(10**5+10)
dp = [-1]*(10**5+10)
dp[0] = 1

for i in range(N):
    if L[C[i]] == -1:
        dp[i+1] = dp[i]
    elif C[i] == C[i-1]:
        dp[i+1] = dp[i]
    else:
        dp[i+1] = dp[i]+dp[L[C[i]]]
    L[C[i]] = i+1
print(dp[N])


### FIXED CODE ###

from collections import defaultdict

N=int(input())
C=[int(input()) for _ in range(N)]

d = defaultdict(int)

ans=1
for i,c in enumerate(C):
    if i>=1 and C[i-1]==C[i]:
        continue
    else:
        ans+=d[c]
        d[c]=ans
        
        ans%=10**9+7
        d[c]%=10**9+7
print(ans)
import sys

# 関数 solve は，もちろん，問題に応じて書き換える
def solve(a,b,c,d):
    x = c-a
    y = d-b
    x3 = 0
    x4 = 0
    y3 = 0
    y4 = 0
    #print(x,y)
    x3 = c-y
    y3 = d+x
    x4 = x3-x
    y4 = y3-y
    return str(x3) + ' '  + str(y3) + ' ' str(x4) + ' '  str(y4) + ' '

# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line = sys.stdin.readline().rstrip()
    [str_a, str_b, str_c, str_d] = line.split(' ')
    return (int(str_a), int(str_b), int(str_c), int(str_d))

def main():
    a, b, c, d = readQuestion()
    answer = solve(a, b, c, d)
    print(answer)
    
if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys

# 関数 solve は，もちろん，問題に応じて書き換える
def solve(a,b,c,d):
    x = c-a
    y = d-b
    x3 = 0
    x4 = 0
    y3 = 0
    y4 = 0
    #print(x,y)
    x3 = c-y
    y3 = d+x
    x4 = x3-x
    y4 = y3-y
    return str(x3) + ' '  + str(y3) + ' ' + str(x4) + ' ' + str(y4) + ' '

# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line = sys.stdin.readline().rstrip()
    [str_a, str_b, str_c, str_d] = line.split(' ')
    return (int(str_a), int(str_b), int(str_c), int(str_d))

def main():
    a, b, c, d = readQuestion()
    answer = solve(a, b, c, d)
    print(answer)
    
if __name__ == '__main__':
    main()
N = int(input())
ListH = list(map(int,input().split()))
result = 1
for i in range(N):
    out = False
    for k in range(i):
        if k >= 0:
            if ListH[k] > ListH[i]:
                out = True
    if not out :
        result += 1
print(result)

### FIXED CODE ###

a, b = map(int,input().split())
if a > b:
  c = a
  a-=1
else:
  c = b
  b-=1
if a > b:
  c += a
else:
  c += b
print(c)
import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))



n = readint()
x = readstr()

a = int(x,2)

bit = x.count('1')

z = [0]*(n+1)
for i in range(1,n+1):
    b = i
    while b>0:
        c = 0
        for j in range(b.bit_length()):
            if b&(1<<j):
                c += 1
        b%=c
        z[i]+=1

print(z)
ans = [1]*n
for i in range(n):
    if a&(1<<i):
        b = a-(1<<i)
        if b==0:
            ans[i]-=1
        b%=bit-1
    else:
        b = a + (1<<i)
        b%=bit+1
    ans[i]+=z[b]

printrows(reversed(ans))





### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))



n = readint()
x = readstr()

a = int(x,2)

bit = x.count('1')

z = [0]*(n+1)
for i in range(1,n+1):
    b = i
    while b>0:
        c = 0
        for j in range(b.bit_length()):
            if b&(1<<j):
                c += 1
        b%=c
        z[i]+=1

if bit!=1:
    p = a%(bit-1)
q = a%(bit+1)

ans = [1]*n
for i in range(n):
    if x[i]=='1':
        if bit==1:
            b = 0
            ans[i]-=1
        else:
            b = p-pow(2,n-i-1,bit-1)+bit-1
            b%=bit-1
    else:
        b = q+pow(2,n-i-1,bit+1)
        b%=bit+1
    ans[i]+=z[b]

printrows(ans)
n, m = map(int, input().split())
d = {i+1 : [] for i  in range(n)}
for _ in range(m):
    u, v = map(int, input().split())
    d[u].append(v)
s, t = map(int, input().split())
q = [s]
visited = set([s])
c = 1
def solve():
    while True:
        global visited, c
        flag = True
        for i, v in enumerate(q[:]):
            q.pop(i)
            es = [e3 for e1 in d[v] for e2 in d[e1] for e3 in d[e2] if not e3 in visited]
            if len(es):
                flag = False
            if t in es:
                return c
            else:
                visited |= set(es)
                q.extend(es)
        if flag:
            return -1
        c += 1
print(solve())


### FIXED CODE ###

n, m = map(int, input().split())
d = {i+1 : [] for i  in range(n)}
for _ in range(m):
    u, v = map(int, input().split())
    d[u].append(v)

visited1 = [False for i in range(n+1)]
visited2 = [False for i in range(n+1)]
visited3 = [False for i in range(n+1)]

s, t = map(int, input().split())
q = set([s])
c = 1
def solve():
    global visited1, visited2,visited3,  c, q
    while True:
        q2 = list(q)
        q = set([])
        for v in q2:
            for e1 in d[v]:
                if visited1[e1]:
                    continue
                visited1[e1] = True
                for e2 in d[e1]:
                    if visited2[e2]:
                        continue
                    visited2[e2] = True
                    for e3 in d[e2]:
                        if visited3[e3]:
                            continue
                        visited3[e3] = True
                        if e3 == t:
                            return c
                        else:
                            q.add(e3)
        if not len(q):
            return -1
        c += 1
print(solve())
# _*_ coding:utf-8 _*_
#  Atcoder_Grand_Contest013-A
#  TODO https://atcoder.jp/contests/agc013/tasks/agc013_a


def solveProblem(allNumber,aList):
	flag = "Flat"
	count = 1
	for i in range(allNumber - 1):
		b = aList[i + 1] - aList[i]
		if flag == "Plus":
			if b < 0:
				flag = "Flat"
				count = count+1
		elif flag == "Minus":
			if b > 0:
				flag = "Flag"
				count = count+1
		else:
			if b > 0:
				flag = "Plus"
			elif b < 0:
				flag = "Minus"
		answer = count
	return answer

if __name__ == '__main__':
	N = int(input().strip())
	As = list(map(int,input().split()))
	solution = solveProblem(N,As)
	print("{}".format(solution))

### FIXED CODE ###

# _*_ coding:utf-8 _*_
#  Atcoder_Grand_Contest013-A
#  TODO https://atcoder.jp/contests/agc013/tasks/agc013_a


def solveProblem(allNumber,aList):
	flag = "Flat"
	count = 1
	for i in range(allNumber - 1):
		b = aList[i + 1] - aList[i]
		if flag == "Plus":
			if b < 0:
				flag = "Flat"
				count = count+1
		elif flag == "Minus":
			if b > 0:
				flag = "Flag"
				count = count+1
		else:
			if b > 0:
				flag = "Plus"
			elif b < 0:
				flag = "Minus"
	answer = count
	return answer

if __name__ == '__main__':
	N = int(input().strip())
	As = list(map(int,input().split()))
	solution = solveProblem(N,As)
	print("{}".format(solution))
print(sum(sorted(list(map(int, intput().split())))[0:2]))

### FIXED CODE ###

print(sum(sorted(list(map(int, input().split())))[0:2]))
N, W = map(int, input().split())
dp = np.zeros(W + 1, dtype=np.int)
for _ in range(N):
  w, v = map(int, input().split())
  dp[w:] = np.maximum(dp[w:], dp[:-w] + v)
print(dp[W])

### FIXED CODE ###

import numpy as np

N, W = map(int, input().split())
dp = np.zeros(W + 1, dtype=np.int)
for _ in range(N):
  w, v = map(int, input().split())
  dp[w:] = np.maximum(dp[w:], dp[:-w] + v)
print(dp[W])
H, N = map(int, input().split())
damage = []
mp = []

for i in range(N):
    a, b = map(int, input().split())
    damage.append(a)
    mp.append(b)

dp = [[0]+[float("inf")]*H for _ in range(N + 1)]

for j in range(1, H + 1):
    if j % damage[0] == 0:
        x = j // damage[0]
    else:
        x = j // damage[0] + 1 
    dp[1][j] = x * mp[0]

for i in range(1, N):
    for j in range(H + 1):
        dp[i + 1][j] = min(dp[i][j], dp[i][j - damage[i]] + mp[i])

for i, row in enumerate(dp):
    if i == 0:
        continue
    buf = float("inf")
    for j in range(H + 1):
        if row[H - j] > buf:
            row[H - j] = buf
        buf = row[H - j]

print(dp[N][H])

### FIXED CODE ###

H, N = map(int, input().split())
damage = []
mp = []
 
for i in range(N):
    a, b = map(int, input().split())
    damage.append(a)
    mp.append(b)
 
dp = [[0]+[float("inf")]*H for _ in range(N + 1)]

for i in range(N):
    for j in range(H + 1):
        if j - damage[i] >= 0:
            dp[i + 1][j] = min(dp[i][j], dp[i + 1][j - damage[i]] + mp[i])
        else:
            dp[i + 1][j] = min(dp[i][j], dp[i + 1][0] + mp[i])

print(dp[N][H])