Harryxun/stf_run huggingface dataset:
import numpy as np
WH='.'
BK='#'
x=input()
x=x.split()
H=int(x[0])
W=int(x[1])
a=[[] for i in range(H)]
num=[]
numnum=0
for i in range(H):
    x=input()
    for j in range(W):
        a[i].append(x[j])
for i in range(H):
    flag=0
    for j in range(W):
        if a[i][j]==WH:
            flag=flag+1
        else:
            flag=flag-1
    if flag==W:
        num.append(i)
        numnum=numnum+1
for i in range(numnum):
    a.pop(num[i])
H=H-numnum
a_n=np.array(a)
tr=a_n.T
num=[]
numnum=0
for i in range(W):
    flag=0
    for j in range(H):
        if tr[i][j]==WH:
            flag=flag+1
        else:
            flag=flag-1
    if flag==H:
        num.append(i)
        numnum=numnum+1
for i in range(numnum):
    a=np.delete(tr,num[i],0)
a_n=np.array(a)
a=a_n.T
for i in range(H):
    ans=''
    for j in range(W):
        ans=ans+a[i][j]
    print(ans)

### FIXED CODE ###

import numpy as np
WH='.'
BK='#'
x=input()
x=x.split()
H=int(x[0])
W=int(x[1])
a=[[] for i in range(H)]
num=[]
numnum=0
for i in range(H):
    x=input()
    for j in range(W):
        a[i].append(x[j])
for i in range(H):
    flag=0
    for j in range(W):
        if a[i][j]==WH:
            flag=flag+1
        else:
            flag=flag-1
    if flag==W:
        num.append(i)
        numnum=numnum+1
for i in range(numnum):
    a.pop(num[i]-i)
H=H-numnum
a_n=np.array(a)
tr=a_n.T
a=tr.tolist()
num=[]
numnum=0
num_num=0
for i in range(W):
    flag=0
    for j in range(H):
        if a[i][j]==WH:
            flag=flag+1
        else:
            flag=flag-1
    if flag==H:
        num.append(i)
        numnum=numnum+1
        flag=0
    else:
        flag=0
for i in range(numnum):
    a.pop(num[i]-i)
W=W-numnum
a_n=np.array(a)
a=a_n.T
for i in range(H):
    ans=''
    for j in range(W):
        ans=ans+a[i][j]
    print(ans)
X=int(input())
ans = []
for a in range(-100,101):
    for b in range(-100,101):
        if a**5-b**5 == X:
            ans = [a,b]
            break
print(ans[0],ans[1])

### FIXED CODE ###

X=int(input())
ans = []
for a in range(1001):
    for b in range(-1000,1001):
        if a**5-b**5 == X:
            ans = [a,b]
            break
print(ans[0],ans[1])
a=input()
b=input()
if a>1 and b>1:
  C=(a-1)*(b-1)
else:
  break
print(C)

### FIXED CODE ###

A,B=list(map(int,input().split()))
C=(A-1)*(B-1)
print(C)
N = int(input())
for i in range(N):
	line = raw_input()
	l = [None]*3
	l[0] = int(line.split()[0])
	l[1] = int(line.split()[1])
	l[2] = int(line.split()[2])
	l.sort()
	if l[0]**2+l[1]**2==l[2]**2:
		print("YES")
	else:
		print("NO")

### FIXED CODE ###

N = int(input())
for i in range(N):
	line = input()
	l = [None]*3
	l[0] = int(line.split()[0])
	l[1] = int(line.split()[1])
	l[2] = int(line.split()[2])
	l.sort()
	if l[0]**2+l[1]**2==l[2]**2:
		print("YES")
	else:
		print("NO")
import sys

x = sys.stdin.readline()

a_list = x.split(" ")

if a_list[0] < a_list[1] and a_list[1] < a_list[2]:
  print Yes

else:
  print No

### FIXED CODE ###

import sys

x = sys.stdin.readline()

a_list = x.split(" ")

if int(a_list[0]) < int(a_list[1]) and int(a_list[1]) < int(a_list[2]):
  print "Yes"

else:
  print "No"
A, B, C, D = map(int, input().split())

n = int(A/D)
m = int(C/B)

if n<=m:
    print('No')
elif n>m:
    print('Yes')

### FIXED CODE ###

S, W = map(int, input().split())

if S>W:
    print('safe')
else:
    print('unsafe')
while True:
        (a, op, b) = input().split()
        a = int(a)
        b = int(b)

        if op = '?':
              break
        elif op = '+':
              print(a,op,b)
        elif op = '-':
              print(a, op, b)
        elif op = '*':
              print(a, op, b)
        elif op = '/':
              print(a, op, b)

### FIXED CODE ###

while True:
    (a, op, b) = input().split()
    a = int(a)
    b = int(b)

    if op == '?':
        break
    elif op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    elif op == '/':
        print(a // b)
import math
a, b = map(int.input().split())
x = (a + b)/2
print(math.ceil(x))


### FIXED CODE ###

import math
a, b = map(int, input().split())
x = (a + b)/2
print(math.ceil(x))
def main():
    n = input()
    D = []
    O = []
    for i in range(n):
        c, k = raw_input().split()
        if c == 'insert':
            D.append(k)
        else:
            O.append(search(D,k))

    for item in O:
        print item

    return 0


def search(D,k):
    Dc = D[:]
    if Dc == []:
        return 'no'
    else:
        d = Dc.pop()
        if d == k:
            return 'yes'
        else:
            return search(Dc,k)


if __name__ == "__main__":
    main()

### FIXED CODE ###

m = 2000003

def MyHash(k,i):
    return (k%m+i*(1+(k%m)))%m

def main():
    n = input()
    T = ['']*2000003
    O = []
    for i in range(n):
        c, k = raw_input().split()
        i = 0
        if c == 'insert':
            k_hashed = hash(k)
            while True:
                j = MyHash(k_hashed,i)
                if T[j] == '':
                    T[j] = k
                    break
                else:
                    i += 1
        else:
            O.append(search(T,k))

    for item in O:
        print item

    return 0


def search(T,k):
    k_hashed = hash(k)
    i = 0
    while True:
        j = MyHash(k_hashed,i)
        if T[j] == k:
            o = 'yes'
            break
        elif T[j] == '':
            o = 'no'
            break
        else:
            i += 1

    return o


if __name__ == "__main__":
    main()
n=int(input())
ln=map(int,input().split())
print(abs(max(ln)-min(ln)))

### FIXED CODE ###

n=int(input())
ln=[int(n) for n in map(int,input().split())]
print(max(ln)-min(ln))
def solve():
    import numpy as np
    from sys import stdin
    f_i = stdin
    
    H, W = map(int, f_i.readline().split())
    A = tuple(tuple(map(int, f_i.readline().split())) for i in range(H))
    B = tuple(tuple(map(int, f_i.readline().split())) for i in range(H))
    
    DP = np.full((H + 1, W + 1, (H * W) * 80), False)
    DP[0][1][0] = True
    for i in range(1, H + 1):
        for j in range(1, W + 1):
            diff = A[i-1][j-1] - B[i-1][j-1]
            for pre_bias in np.where(DP[i-1][j] == True):
                bias = abs(pre_bias + diff)
                DP[i][j][bias] = True
                bias = abs(pre_bias - diff)
                DP[i][j][bias] = True
            for pre_bias in np.where(DP[i][j-1] == True):
                bias = abs(pre_bias + diff)
                DP[i][j][bias] = True
                bias = abs(pre_bias - diff)
                DP[i][j][bias] = True
    
    b = np.where(DP[-1][-1] == True)[-1]
    print(min(b))

solve()

### FIXED CODE ###

def solve():
    from sys import stdin
    f_i = stdin
    
    H, W = map(int, f_i.readline().split())
    A = tuple(tuple(map(int, f_i.readline().split())) for i in range(H))
    B = tuple(tuple(map(int, f_i.readline().split())) for i in range(H))
    
    dp1 = [0] * W
    bit_width = 80 * (H + W - 2)
    dp1[0] = 1 << (bit_width)
    for A_i, B_i in zip(A, B):
        dp2 = [0] * W
        
        diff = abs(A_i[0] - B_i[0])
        dp2[0] = (dp1[0] << diff) | (dp1[0] >> diff)
        
        for j, t in enumerate(zip(A_i[1:], B_i[1:]), start=1):
            A_ij, B_ij = t
            diff = abs(A_ij - B_ij)
            b = dp1[j] | dp2[j-1]
            dp2[j] = (b << diff) | (b >> diff)
        
        dp1 = dp2
    
    b = bin(dp2[-1])
    b = b[-bit_width-1:]
    print(b.index('1'))
 
solve()
def resolve():
n, m = map(int, input().split())
denq = []
for _ in range(m):
    ks = tuple(map(lambda x: int(x)-1, input().split()))
    denq.append(ks[1:])
P = tuple(map(int, input().split()))

ans = 0
for i in range(2**n):
    kk = [0] * m
    # switch_states = [(i>>j)&1 for j in range(n)]
    for idq, dq in enumerate(denq):
        counts = 0
        for s in dq:
            counts += (i>>s)&1
        if counts%2 != P[idq]:
            break
    else:
        ans += 1
print(ans)


### FIXED CODE ###

N, M = map(int, input().split())
ds = []
for _ in range(M):
    ds.append(tuple(map(int, input().split()))[1::])
    
P = tuple(map(int, input().split()))

# スイッチのon/offについて全探索
oks = 0
for i in range(2**N):
    switch_states = [(i>>j)&1 for j in range(N)]
    # すべての電球について
    for di, d in enumerate(ds):
        # 関連するスイッチがonの個数を数える
        switch_counts = 0
        for s in d:
            switch_counts += switch_states[s-1]
        if switch_counts%2 != P[di]:
            break
    else:
        oks += 1
print(oks)
N,K = map(int,input().split())
x = list(map(int,input().split()))
if K==1 and (0 in x):
    print(0)
else:
    if 0 in x:
        pass
    else:
        K += 1
        counter = 0
        for i in x:
            if i > 0:
                break
            else:
                counter += 1
        x.insert(counter,0)

    result = []
    g,s = x.index(0),x.index(0)-K+1
    while (not s>x.index(0)):
        if s<0 or g>(len(x)-1):
            s += 1
            g += 1
            continue
        else:
            result.append(2*(-x[s]) + x[g])
            result.append(-x[s] + 2*(x[g]))
            s += 1
            g += 1
    print(result.sort()[0])

### FIXED CODE ###

N,K = map(int,input().split())
x = list(map(int,input().split()))

result = []
for i in range(N-K+1):
    s,g = i,i+K-1
    result.append(abs(x[s]) + abs(x[s] - x[g]))
    result.append(abs(x[g]) + abs(x[g] - x[s]))
result.sort()
print(result[0])
x,y,z=(map(int,input().split())

print("{} {}".format(z,x,y))

### FIXED CODE ###

x,y,z=map(int,input().split())
print(z,x,y)
#print("{} {}".format(z,x,y))
import math

# 01:10
A, B, C, D = tuple([int(a) for a in input().split(' ')])


def func1(n):
    return n - n//C - n//D + n//(C*D//math.gcd(C, D))


print(func1(B) - func1(A-1))


### FIXED CODE ###

import fractions 

# 01:10
A, B, C, D = tuple([int(a) for a in input().split(' ')])


def func1(n):
    return n - n//C - n//D + n//(C*D//fractions.gcd(C, D))


print(func1(B) - func1(A-1))
#第一回日本最強プログラマー学生選手権-予選- -B Kleene Inversion
"""
リストをk回繰り返したものの、転倒数の個数を求めよ
先ず純粋に与えられたリスト内での転倒数を求めた後、
それを1~k倍したものを足し合わせる
"""
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
mod = 10**9+7

n,k = map(int,readline().split())
lst1 = list(map(int,readline().split()))

class BinaryIndexedTree():
    def __init__(self, seq):
        self.size = len(seq)
        self.depth = self.size.bit_length()
        self.build(seq)
        
    def build(self,seq):
        data = seq
        size = self.size
        for i,x in enumerate(data):
            j = i+(i&(-i))
            if j < size:
                data[j] += data[i]
        self.data = data
        
    def __repr__(self):
        return self.data.__repr__()
        
    def get_sum(self,i):
        data = self.data
        s = 0
        while i:
            s += data[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        data = self.data
        size = self.size
        while i < size:
            data[i] += x
            i += i & -i
    
    def find_kth_element(self,k):
        data = self.data; size = self.size
        x,sx = 0,0
        dx = 1 << (self.depth)
        for i in range(self.depth - 1, -1, -1):
            dx = (1 << i)
            if x + dx >= size:
                continue
            y = x + dx
            sy = sx + data[y]
            if sy < k:
                x,sx = y,sy
        return x + 1
#バブルソート(隣り合う2数を入れ替えて順列を昇順にする時の最小手数) 
def Inversion(seq):
    # seqは、1,2,...,Nの順列
    N = len(seq)
    bit = BinaryIndexedTree([0] * (N+1))
    inv = N*(N-1)//2
    for x in seq:
        inv -= bit.get_sum(x)
        bit.add(x,1)
    return inv

res = Inversion(lst1)
#lst全体で見た時にそれより小さい値がいくつあるか
res2 = Inversion(sorted(lst1,reverse=True))
def reydeoro(n):
    return n*(n+1)//2
print((res*k+res2*reydeoro(k-1))%mod)

### FIXED CODE ###

#第一回日本最強プログラマー学生選手権-予選- -B Kleene Inversion
"""
リストをk回繰り返したものの、転倒数の個数を求めよ
先ず純粋に与えられたリスト内での転倒数を求めた後、
それを1~k倍したものを足し合わせる
"""
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
mod = 10**9+7

n,k = map(int,readline().split())
lst1 = list(map(int,readline().split()))
fall = 0
fall_al = 0
for i in range(n-1):
    for j in range(i+1,n):
        if lst1[i] > lst1[j]:
            fall += 1
lst1.sort(reverse=True)
for i in range(n-1):
    for j in range(i+1,n):
        if lst1[i] > lst1[j]:
            fall_al += 1

def reydeoro(n):
    return n*(n+1)//2
print((fall*k+fall_al*reydeoro(k-1))%mod)
s = input()
ans=[]
for i in range(len(s)):
    if s[i]=='B':
        ans.pop()
    else:
        ans.append(s[i])
print(''.join(ans))

### FIXED CODE ###

s = input()
ans=[]
for i in range(len(s)):
    if s[i]=='B' and len(ans)!=0:
        ans.pop()
    elif s[i]=='B' and len(ans)==0:
        continue
    else:
        ans.append(s[i])

print(''.join(ans))
while True:
  try:
    line = map(int, raw_input().split(","))
  except:
    break
  sum = 0
  rail = []
  for x in line[0:10]:
    sum += x
    rail.append(sum)
  # sum: レールの総距離
  # rail: スタートから各ポイントまでの距離
  cross = sum * (line[10] * 1.0 / (line[10] + line[11]))
  for i, length in enumerate(rail):
    if cross <= length:
      print i+1
      break

### FIXED CODE ###

while True:
  try:
    line = map(int, raw_input().split(","))
  except:
    break
  sum = 0
  rail = []
  for x in line[0:10]:
    sum += x
    rail.append(sum)
  cross = sum * (line[10] * 1.0 / (line[10] + line[11]))
  for i, length in enumerate(rail):
    if cross <= length:
      print i+1
      break
import bisect
# from collections import Counter, defaultdict, deque, namedtuple
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    n, k = list(map(int,ipti().split()))
    s = input()

    lg = [0] * (n+3)

    s_first = s[0]
    s_last =s[-1]

    idx = 0
    if s_first == "0":
        lg[0] = 0
        idx = 1

    s_groupby = itertools.groupby(s)

    for _, group in s_groupby:
        lg[idx] = len(list(group))
        idx += 1

    if s_last == "0":
        idx += 1

    rn = 2*k + 1
    if rn >= idx:
        print(n)
        sys.exit()

    temp = sum(lg[0:rn])
    ans = temp

    for i in range(2, idx, 2):
        temp -= (lg[i-2] + lg[i-1])
        temp += (lg[i-2+rn] + lg[i-1+rn])
        ans = max(ans, temp)

    print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import bisect
# from collections import Counter, defaultdict, deque, namedtuple
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    n, k = list(map(int,ipti().split()))
    s = input()

    lg = [0] * (n+3)

    s_first = s[0]
    s_last =s[-1]

    idx = 0

    if s_first == "0":
        lg[0] = 0
        idx = 1

    s_groupby = itertools.groupby(s)

    for _, group in s_groupby:
        lg[idx] = len(list(group))
        idx += 1

    if s_last == "0":
        idx += 1

    rn = 2*k + 1

    if rn >= idx:
        print(n)
        sys.exit()

    temp = sum(lg[0:rn])
    ans = temp

    for i in range(2, idx-rn+1, 2):
        temp -= (lg[i-2] + lg[i-1])
        temp += (lg[i-2+rn] + lg[i-1+rn])
        ans = max(ans, temp)

    print(ans)

if __name__ == '__main__':
    main()
#66 A - Two Abbreviations
import math
N,M = map(int,input().split())
S = input()
T = input()

L = N*M//math.gcd(N,M)

dist_N = L//N
dist_M = L//M
lis = [0]*L
i = 0
for n in range(0,L,dist_N):
    if i == N:
        break
    lis[n] = S[i]
    i+=1
j = 0
for m in range(0,L,dist_M):
    if j == M:
        break
    if lis[m] == 0:
        lis[m] = T[j]
        j += 1
    else:
        if lis[m] == T[j]:
            j += 1
        else:
            L = -1
            break
ans = L
print(ans)

### FIXED CODE ###

#66 A - Two Abbreviations
import math
N,M = map(int,input().split())
S = input()
T = input()

GCD = math.gcd(N,M)
L = N*M//GCD

dist_N = L//N
dist_M = L//M

# 同じ位置に書く文字は最大公約数 + 1 だけ存在する
for i in range(GCD):
    # S の s 文字目と T の t 文字目が同じ位置に来る
    s = dist_M * i
    t = dist_N * i
    if S[s] != T[t]:
        ans = -1
        break
else:
    ans = L
print(ans)
k, s = list(map(int, input().split()))
ct = 0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if x + y + z == s:
                ct += 1
                break;
print(ct)

### FIXED CODE ###

import sys
import copy
import string
from _bisect import *
from collections import *
from operator import itemgetter
from math import factorial
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

li = input().split(",")
print(*li)
import string
alphabets = string.ascii_lowercase

def alphabet_check(S, checker):
    for i, s in enumerate(S):
        checker[alphabets.index(s)] = i

S = input()
checker = [-1]*26

alphabet_check(S, checker)

if len(S) < 26:
    char_idx = checker.index(-1) 
    print(S + alphabets[char_idx])
elif S == 'zyxwvutsrqponmlkjihgfedcba':
    print(-1)
else:
    cont_flag = False
    for i in range(len(S)-1):
        if S[i] > S[i+1]:
            if cont_flag == False:
                idx = i
                cont_flag = True
    string = S[:idx]
    l = len(string)
    checker = [-1]*26
    alphabet_check(string, checker)
    char_idx = checker.index(-1)
    print(string[:l-1] + alphabets[char_idx])

### FIXED CODE ###

S = input()
alpha = 'abcdefghijklmnopqrstuvwxyz'
if S == alpha[::-1]:
    print(-1)
else:
    rest = sorted(list(set(alpha) - set(S)))
    if rest:
        print(S + rest[0])
    else:
        for i in range(len(S)-1, 0, -1):
            if S[i-1] < S[i]:
                break
        rest = sorted([s for s in S[i:] if s > S[i-1]])
        print(S[:i-1] + rest[0])
import math

r = 100000
sqrt = int(math.sqrt(r))
p = [1]*r
p[0] = 0
for i in range(1,sqrt):
    if p[i]:
        for j in range(2*i+1,r,i+1):
            p[j] = 0

while True:
    n = int(raw_input())
    if not n:
        break
    i, num, sum = 0, 0, 0
    while num < n:
        if p[i] == 1:
            num += 1
            sum += i+1
        i += 1
    print sum

### FIXED CODE ###

import math

r = 105000
sqrt = int(math.sqrt(r))
p = [1]*r
p[0] = 0
for i in range(1,sqrt):
    if p[i]:
        p[2*i+1::i+1] = [0 for x in range(2*i+1,r,i+1)]

s = [0 for i in range(11000)]
s[0] = 2
k = 1
for i in range(2,r):
    if p[i]:
        s[k] = i+1+s[k-1]
        k += 1
        
while True:
    n = int(raw_input())
    if not n:
        break
    print s[n-1]
S = input()

if S = 'Sunny':
    print('Cloudy')
elif S = 'Cloudy':
    print('Rainy')
else:
    print('Sunny')

### FIXED CODE ###

S = input()

if S == 'Sunny':
    print('Cloudy')
elif S == 'Cloudy':
    print('Rainy')
else:
    print('Sunny')
s = int(input())
if s[-1] != 's':
  s += 's'
else:
  s += 'es'
print(s)

### FIXED CODE ###

s = input()

if s[-1] != 's':

  s += 's'

else:

  s += 'es'

print(s)
X, N = map(int, input().split())
p = list(map(int, input().split()))
for d in range(X + 1):
    for s in [-1, +1]:
        
        a = X + s * d
        if p.count(a) == 0:
            print(a)
            exit(0)


### FIXED CODE ###

x1,x2,x3,x4,x5=map(int,input().split())
a=[]
a.append(x1)
a.append(x2)
a.append(x3)
a.append(x4)
a.append(x5)
for i in range(5):
    if a[i]==0:
        print(i+1)
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
num = 10**9+7
nots = [int(input()) for i in range(m)]
leng = len(nots)
cnt = 0
dp = [0]*(n+1)
dp[0] = 1
if leng > 0 and nots[0] == 1:
  dp[1] = 0
else:
  dp[1] = 1
if n < 2:
  print(1)
  exit()

for i in range(2,n+1):
  if leng > 0 and nots[cnt] == i:
    dp[i] = 0
  else:
    dp[i] = dp[i-1] + dp[i-2]
  if nots[cnt] < i and cnt < leng - 1:
    cnt += 1
print(dp[n] % num)

### FIXED CODE ###

import sys
input = sys.stdin.readline
n,m = map(int,input().split())
num = 10**9+7
nots = [int(input()) for i in range(m)]
leng = len(nots)
cnt = 0
dp = [0]*(n+1)
dp[0] = 1
if leng > 0 and nots[0] == 1:
  dp[1] = 0
  nots.pop(0)
  leng -= 1
else:
  dp[1] = 1
if n == 1:
  print(1)
  exit()

for i in range(2,n+1):
  if leng > 0 and nots[cnt] == i:
    dp[i] = 0
    if cnt < leng - 1:
      cnt += 1
  else:
    dp[i] = (dp[i-1] + dp[i-2]) % num
print(dp[n] % num)
S = input()

pritn("Yes" if S.count("A")==2 and S.count("B")==2 else "No")


### FIXED CODE ###


S = input()

print("Yes" if S.count("A")==2 or S.count("B")==2 else "No")
n = int(input())
L = [0]*(n+1)
L[1]=2
L[2]=1
for i in range(3,n+1);
	L[i]=L[i-1]+L[i-2]
print(L[n])

### FIXED CODE ###

n = int(input().rstrip())
L = [0]*(n+1)
L[0]=2
L[1]=1
for i in range(2,n+1):
	L[i]=L[i-1]+L[i-2]
print(L[n])
from sys import stdin
H,N = [int(x) for x in stdin.readline().rstrip().split()]
data = []
ans = 10**9
for i in range(N):
    A,B = [int(x) for x in stdin.readline().rstrip().split()]
    C = A / B
    if A >= H:
        ans = min(ans,B)
    data.append((C,A,B))


dp = [10**9]*(H+1)

c,a,b = sorted(data)[::-1][0]

cnt = 0
for i in range(1,H+1):
    cnt += 1
    if cnt*a >= H:
        dp[-1] = (b*cnt)
        break
    else:
        dp[cnt*a] = (b*cnt)
        

tmp = 10**9
for j in range(H,-1,-1):
    tmp = min(dp[j],tmp)
    dp[j] = tmp

for c,a,b in data:
    dp[-1] = min(dp[-a] + b ,dp[-1])

print(min(ans,dp[-1]))

### FIXED CODE ###

# 1-index
from sys import stdin
H, N = [int(x) for x in stdin.readline().rstrip().split()]

data = [0]*N

for i in range(N):
    A, B = [int(x) for x in stdin.readline().rstrip().split()]
    data[i] = (A, B)
dp = [10**9]*(H+1)
dp[0] = 0

for h in range(0,H+1):
    for a,b in data:
        if h+a >= H:
            dp[H] = min(dp[h]+b,dp[H])
        else:
            dp[h+a] = min(dp[h]+b,dp[h+a])
print(dp[H])
length = raw_input()
count = length
answer = raw_input()


def compare(current, previous, i):
  if current[i] < previous[i]:
    answer = current
  elif current[i] == previous[i]:
    compare(current, previous, i+1)

while count > 0:
  if count == length:
    current_word = answer
  if count < length:
    previous_word = current_word
    current_word = raw_input()
    min_length = min([len(current_word), len(previous_word)])
    compare(current_word, previous_word, 0)
  count -= 1

print answer
  

### FIXED CODE ###

s = []
n = input()
 
for i in range(n):
    x = raw_input()
    s.append(x)
 
s.sort()
 
print s[0]
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
a = [I() for i in range(5)]

print(math.ceil(N/min(a))+4)

### FIXED CODE ###

import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
A = [I() for i in range(5)]
num = min(A)

print(4 + math.ceil(N/num))
N=input()
M=int(N)
f=1
while 2<=M:
  if M<2:M=1
  f *= M
  M -= 2

A=len(f)-len(f.rstrip('0'))
print(A)

### FIXED CODE ###

n=int(input())

if n%2!=0:
  print(0)
else:
  A=0
  m=10
  while n//m>0:
    A+=n//m
    m*=5
  print(A)
n,m=map(int,input().split())
a=list(map(int,input().split()))

A=sum(a)
if n-A<0:
  print(-1)
else :
    print(n-A)


### FIXED CODE ###

R=float(input())

print(R*2*3.141592)
import math
x,y,z=map(int,input().split(" "))
if (x-y-z)**2-4xy>0:
	print("Yes")
else:
 
	print("No")

### FIXED CODE ###

import math
x,y,z=map(int,input().split(" "))

if (z-y-x)**2>4*x*y and z>y and z>x:
	print("Yes")
else:
 
	print("No")