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

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

magics = []
max_cost = 0
for _ in range(n):
    at, cost = map(int, input().split())
    max_cost = max(max_cost, cost)
    magics.append((at, cost))

dp = [float('inf')] * (h+max_cost)
dp[0] = 0
for i in range(len(dp)):
    for at, cost in magics:
        if at <= i:
            dp[i] = min(dp[i], dp[i-at] + cost)
print(min(dp[h:]))

### FIXED CODE ###

h, n = map(int, input().split())
magics = sorted(list(map(int, input().split())) for _ in range(n))
max_cost = max(magic[1] for magic in magics)

dp = [float('inf')] * (h+max_cost)
dp[0] = 0
for i in range(h+max_cost):
    for at, cost in magics:
        if at <= i:
            dp[i] = min(dp[i], dp[i-at] + cost)
        else:
            break
print(min(dp[h:]))
### BUGGY CODE ###

def o():return map(int,input().split())
n,m=o()
c=[[0] for i in range(m)]
for i in range(n):
  a,b=o()
  if a<=m:
    c[m-a]+=[b]
d=[]
for i in range(m):
  c[i].sort()
  d+=[c[i].pop()]
ans=0
for i in range(m-1,-1,-1):
  j=i+d[i:].index(max(d[i:]))
  if d[j]>0:
    ans+=d[j]
    d[j]=c[j].pop()
print(ans)

### FIXED CODE ###

import heapq as hp
def o():return map(int,input().split())
n,m=o()
c=[[0] for i in range(m)]
for i in range(n):
  a,b=o()
  if a<=m:
    c[m-a]+=[-b]
d=[]
ans=0
for i in range(m-1,-1,-1):
  for j in c[i]:
    hp.heappush(d,j)
  ans-=hp.heappop(d)
print(ans)
### BUGGY CODE ###

def N(x,y,n): # no of x...y < n
    r=0
    for i in range(1,n+1):
        if str(i)[0]==str(x) and str(i)[-1]==str(y):
            r+=1
    return r

ans=0
n=int(input())
for x in range(1,10):
    for y in range(1,10):
        ans+=N(x,y,n)*N(y,x,n)
        
print(ans)

### FIXED CODE ###

def N(x,y,n): # no of x...y < n
    if n<100:
        r=0
        for i in range(1,n+1):
            if str(i)[0]==str(x) and str(i)[-1]==str(y):
                r+=1
        return r
    
    r=N(x,y,99)
    d=len(str(n))
    for i in range(1,d-2):
        r+=10**i
    top=int(str(n)[0])
    if top<x:
        r+=0
    elif top==x:
        r+=int(str(n)[1:-1])
        if str(n)[-1]>=str(y):
            r+=1
    else:
        r+=10**(d-2)

        
    return r


ans=0
n=int(input())
for x in range(1,10):
    for y in range(1,10):
        ans+=N(x,y,n)*N(y,x,n)
print(ans)
### BUGGY CODE ###

import fractions
c=0
N=int(input())
L=list(map(int,input().split()))
a=L[0]
for i in range(1,N):
  a=(L[i]*a)//fractions.gcd(L[i], a)
for i in range(N):
  c=(c+(a//L[i]))%(10**9+7)
print(c)

### FIXED CODE ###

import fractions
c=0
N=int(input())
L=list(map(int,input().split()))
a=L[0]
for i in range(1,N):
  a=(L[i]*a)//fractions.gcd(L[i], a)
for i in range(N):
  c+=(a//L[i])
print(c%(10**9+7))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 6)

N = int(input())
A = list(map(int, input().split(" ")))
dp = dict()
mod = 10 ** 9 + 7

def f(i, r, b):
    if i == N:
        return 1
    if (i, r, b) in dp:
        return dp[(i, r, b)]
    ans = 0
    # iがr, b, gを被って矛盾がないかを見ていく
    if A[i] == r:
        ans += f(i + 1, r + 1, b)
    if A[i] == b:
        ans += f(i + 1, r, b + 1)
    if A[i] == i - r - b:
        ans += f(i + 1, r, b)

    dp[(i, r, b)] = ans % mod
    return dp[(i, r, b)]

print(f(0, 0, 0) % mod)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 6)

N = int(input())
A = list(map(int, input().strip().split(" ")))
dp = {i: dict() for i in range(N)}
mod = 10 ** 9 + 7

def f(i, ma, mi):
    if i == N:
        return 1
    if (ma, mi) in dp[i]:
        return dp[i][(ma, mi)]
    if A[i] != ma and A[i] != mi and A[i] != i - ma - mi:
        dp[i][(ma, mi)] = 0
        return 0

    ans = 0
    # iがr, b, gを被って矛盾がないかを見ていく
    if A[i] == ma:
        ans += f(i + 1, ma + 1, mi)
    if A[i] == mi:
        if ma > mi + 1:
            ans += f(i + 1, ma, mi + 1)
        else:
            ans += f(i + 1, mi + 1, ma)
    if A[i] == i - ma - mi:
        ans += f(i + 1, ma, mi)

    dp[i][(ma, mi)] = ans % mod
    return ans % mod

print(f(0, 0, 0) % mod)
### BUGGY CODE ###

import sys

n,m = (int(i) for i in input().split())
abstart=[]
abgoal=[]
for i in range(0,m):
    inp=[int(i) for i in input().split()]
    if inp[0]==1:
        abstart.append(inp[1])
    elif inp[1]==n:
        abgoal.append(inp[0])

for st in abstart:
    for go in abgoal:
        if st == go:
            print('POSSIBLE')
            sys.exit()
print('IMPOSSIBLE')


### FIXED CODE ###

n,m = (int(i) for i in input().split())
abstart=[]
abgoal=[]
for i in range(0,m):
    inp=[int(i) for i in input().split()]
    if inp[0]==1:
        abstart.append(inp[1])
    elif inp[1]==n:
        abgoal.append(inp[0])

start = set(abstart)
goal = set(abgoal)
matched = list(start & goal)

if len(matched)>0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
### BUGGY CODE ###


import numpy as np

def read_input():
    n, a = map(int, input().split())
    xlist = list(map(int, input().split()))
    return n, a, xlist


def submit():
    n, a, xlist = read_input()

    dp = np.zeros((n + 1, n + 1, (n + 1) * max(max(xlist), a)))

#   dp[j][k][s] : j枚目までのカードでk枚選び、合計sにする方法の数
#         (1) dp[0][0][0] : 1枚も選ばずに合計0にする方法は1種類
#               j = k = s = 0のとき
#         (2) dp[j][k][s] = dp[j - 1][k][s] if xj > s : j枚目のカードがsより大きいとき、sを作りようがないのでj-1枚目までの手法と一緒
#               j > 0, xj > sのとき
#         (3) dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - xj]
#               : xj <= sのとき、j-1枚目まででsを作る方法と、j-1枚目まででs-xjをつくり、j枚目を選んでk枚にする
#               j > 0, k > 0, s >= xjのとき
#         (4) dp上記以外は無理なので0

    dp[0][0][0] = 1

    for j in range(n + 1):
        for k in range(n + 1):
            for s in range((n + 1) * max(xlist)):
                if j > 0 and xlist[j - 1] > s:
                    dp[j][k][s] = dp[j - 1][k][s]
                elif j > 0 and k > 0 and xlist[j - 1] <= s:
                    dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - xlist[j - 1]]

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

    print(int(methods))


if __name__ == '__main__':
    submit()


### FIXED CODE ###

def read_input():
    n, a = map(int, input().split())
    xlist = list(map(int, input().split()))
    return n, a, xlist


def make_matrix():
    dp = [
        [
            [0] * ((n + 1) * max(max(xlist), a)) for _ in range(n + 1)
        ] for _ in range(n + 1)
    ]



def submit():
    n, a, xlist = read_input()

    dp = [
        [
            [0] * ((n + 1) * max(max(xlist), a)) for _ in range(n + 1)
        ] for _ in range(n + 1)
    ]

#   dp[j][k][s] : j枚目までのカードでk枚選び、合計sにする方法の数
#         (1) dp[0][0][0] : 1枚も選ばずに合計0にする方法は1種類
#               j = k = s = 0のとき
#         (2) dp[j][k][s] = dp[j - 1][k][s] if xj > s : j枚目のカードがsより大きいとき、sを作りようがないのでj-1枚目までの手法と一緒
#               j > 0, xj > sのとき
#         (3) dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - xj]
#               : xj <= sのとき、j-1枚目まででsを作る方法と、j-1枚目まででs-xjをつくり、j枚目を選んでk枚にする
#               j > 0, k > 0, s >= xjのとき
#         (4) dp上記以外は無理なので0

    dp[0][0][0] = 1

    for j in range(n + 1):
        for k in range(n + 1):
            for s in range((n + 1) * max(xlist)):
                if j > 0 and xlist[j - 1] > s:
                    dp[j][k][s] = dp[j - 1][k][s]
                elif j > 0 and k > 0 and xlist[j - 1] <= s:
                    dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - xlist[j - 1]]

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

    print(int(methods))


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

import sys
sys.setrecursionlimit(10**9)

H, N = map(int, input().split())
AB = []
for _ in range(N):
    a, b = map(int, input().split())
    AB.append((a, b))
AB = sorted(AB, key=lambda x: (x[0], x[1]))

cost = [-1 for i in range(H + 1)]


def f(H):
    c = []
    for damage, mp_cost in AB:
        tmp = H - damage
        if tmp <= 0:
            c.append(mp_cost)
            continue
            break
        if cost[tmp] != -1:
            c.append(cost[tmp] + mp_cost)
        else:
            cost[tmp] = f(tmp)
            c.append(cost[tmp] + mp_cost)
    return min(c)


# print('H', H)
# print('f(H)', f(H))
print(f(H))
# print('after cost', cost)


### FIXED CODE ###

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

INF = 10**20
dp = [0]
for i in range(1, H + 1):
    min_mp_cost = INF
    for damage, mp_cost in AB:
        parent = max(0, i - damage)
        new_cost = dp[parent] + mp_cost
        if new_cost < min_mp_cost:
            min_mp_cost = new_cost
    dp.append(min_mp_cost)
print(dp[-1])
### BUGGY CODE ###

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


# [ok, ng) - Maximum
# (ng, ok] - Minimum
# ok が 最終的な答え
ok = N
ng = -1
while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    n = mid
    dp = [0] * (K + 1)
    dp[0] = 1
    for i in range(N):
        a = A[i]
        if i == n or a >= K:
            continue
        for j in range(K, -1, -1):
            dp[min(K, j + a)] |= dp[j]
    rst = any(dp[k] for k in range(max(0, K - A[n]), K))
    if rst:
        ok = mid
    else:
        ng = mid
print(ok)


### FIXED CODE ###

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()


    # [ok, ng) - Maximum
    # (ng, ok] - Minimum
    # ok が 最終的な答え
    ok = N
    ng = -1
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        n = mid
        dp = [0] * (K + 1)
        dp[0] = 1
        for i in range(N):
            a = A[i]
            if i == n or a >= K:
                continue
            for j in range(K, -1, -1):
                dp[min(K, j + a)] |= dp[j]
        rst = any(dp[k] for k in range(max(0, K - A[n]), K))
        if rst:
            ok = mid
        else:
            ng = mid
    print(ok)


main()
### BUGGY CODE ###

N = input()
a = map(int,input().split())
ans = 1
for i in a:
    ans *= i
if ans > 10**18:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

def aaa(a_list):
    ans = 1
    for i in a_list:
        ans = ans * i
        if ans > 10**18:
            return -1
    return ans

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

if 0 in a:
    print(0)
else:
    print(aaa(a))
### BUGGY CODE ###

x=int(input())
n=10**5
def sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i
    table = [ i for i in range(1, n+1) if is_prime[i-1]]
    return  table
q=sieve(n)
ans=[0]*(10**5+1)
for i in range(10**5):
    ans[i+1]=ans[i]+(1 if i+1 in q and (i+1+1)//2 in q else 0 )
for i in range(x):
    l,r = map(int,input().split())	
    print(ans[r]-ans[l-1])

### FIXED CODE ###

x=int(input())
n=10**5
import math
def eratosthenes(n):
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
q=eratosthenes(n)

ans=[0]*(10**5+1)
for i in range(10**5):
    ans[i+1]=ans[i]+(1 if i+1 in q and (i+1+1)//2 in q else 0 )
for i in range(x):
    l,r = map(int,input().split())	
    print(ans[r]-ans[l-1])
### BUGGY CODE ###

# -*- coding: utf-8 -*-
n, m = map(int, input().split())
a= list(map(int, input().split()))
bc=[[0, 0]]
for i in range(m):
  bc.append(list(map(int, input().split())))
del bc[0]
bc=sorted(bc, key=lambda x: x[1], reverse=True)
a.sort()
for j in range(m):
  for i in range(bc[j][0]):
    if a[0] < bc[j][1]:
      del a[0]
      a.append(bc[j][1])
    else:
      break
  else: 
    continue
  break
print(sum(a))

### FIXED CODE ###

# -*- coding: utf-8 -*-
n, m = map(int, input().split())
a= list(map(int, input().split()))
bc=[[0, 0]]
for i in range(m):
  bc.append(list(map(int, input().split())))
del bc[0]
bc=sorted(bc, key=lambda x: x[1], reverse=True)
a.sort()
count = 0
s = 0
for j in range(m):
  for i in range(bc[j][0]):
    if a[count] < bc[j][1]:
      s = s + bc[j][1]
      count = count + 1
    else:
      break
    if count > n - 1 :
      break
  else: 
    continue
  break
if count > n - 1:
  print(s)
else:
  print(s + sum(a[count:]))
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
import numpy
B=[0]+list(numpy.cumsum(A))
dp=[[0]*(N+1) for i in range(N)]
#k:いくつのスライムを合体しているか
for k in range(2,N+1):
  #i:どこのスライムを起点に合体しているか
  for i in range(N-k+1):
    dp[i][k]=min(dp[i][j]+dp[i+j][k-j] for j in range(1,k))+B[i+k]-B[i]
print(dp[0][N])

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
B=[0]*(N+1)
for i in range(N):
  B[i+1]=B[i]+A[i]

dp=[[0]*(N+1) for i in range(N)]
#k:いくつのスライムを合体しているか
for k in range(2,N+1):
  #i:どこのスライムを起点に合体しているか
  for i in range(N-k+1):
    dp[i][k]=min(dp[i][j]+dp[i+j][k-j] for j in range(1,k))+B[i+k]-B[i]
print(dp[0][N])
### BUGGY CODE ###

A,B = map(int, input().split())
if B == 1:
  print("0")
else:
  ans = 0
  while (A-1)*ans + A << B:
    ans += 1
  print(ans)  

### FIXED CODE ###

A,B = map(int, input().split())
print(-((1-B)//(A-1)))
### BUGGY CODE ###

N=int(input())
A=[a-i-1 for i,a in enumerate(map(int,input().split()))]
k=sum(A)//N+1
print(min(sum(abs(a-x)for a in A)for x in range(min(0,k-1),max(k+1,1))))

### FIXED CODE ###

N=int(input())//2
A=sorted(a-i-1 for i,a in enumerate(map(int,input().split())))
print(sum(abs(a-A[N])for a in A))
### BUGGY CODE ###

from collections import deque
h,w=map(int,input().split())
a=[input() for _ in range(h)]
visited=[[-1]*w for _ in range(h)]
queue=deque()
for i in range(h):
  for j in range(w):
    if a[i][j]=='#':
      visited[i][j]=0
      queue.append([i,j])
while queue:
  y,x=queue.popleft()
  for j,k in ([1,0],[-1,0],[0,1],[0,-1]):
    n_y,n_x=y+j,x+k
    if 0<=n_y<h and 0<=n_x<w and a[n_y][n_x]=='.' and visited[n_y][n_x]<0:
      visited[n_y][n_x]=visited[y][x]+1
      queue.append([n_y,n_x])
ans=0
for l in visited:
  ans=max([ans]+l)
print(ans)

### FIXED CODE ###

from collections import deque
h,w=map(int,input().split())
a=[input() for _ in range(h)]
visited=[[-1]*w for _ in range(h)]
queue=deque()
for i in range(h):
  for j in range(w):
    if a[i][j]=='#':
      visited[i][j]=0
      queue.append([i,j])
while queue:
  y,x=queue.popleft()
  for j,k in ([1,0],[-1,0],[0,1],[0,-1]):
    n_y,n_x=y+j,x+k
    if 0<=n_y<h and 0<=n_x<w and a[n_y][n_x]=='.' and visited[n_y][n_x]<0:
      visited[n_y][n_x]=visited[y][x]+1
      queue.append([n_y,n_x])
ans=0
for l in visited:
  ans=max([ans]+l)
print(ans)
### BUGGY CODE ###

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

afters = []
for ai in range(N):
	for sign in [-1,0,1]:
		afters.append(A[ai]+sign)
		
uniq = set(afters)

counts = []
for u in list(uniq):
	counts.append(afters.count(u))
	
print(max(counts))

### FIXED CODE ###

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

afters = []
for ai in range(N):
	for sign in [-1,0,1]:
		afters.append(A[ai]+sign)
		
uniq = set(afters)

countDic = {}
sas = sorted(afters)
for a in sas:
	if a in countDic.keys():
		countDic[a] += 1
	else:
		countDic[a] = 1
	
print(max(countDic.values()))
### BUGGY CODE ###

l=list(map(int,input().split()))
a=l[0]
b=l[1]
n=l[2]
x=0
for i in range(1,n+1):
  y=(((a*i)/b)//1)-(a*((i/b)//1))
  if(y>x):
    x=y
print(int(x))

### FIXED CODE ###

l=list(map(int,input().split()))
a=l[0]
b=l[1]
n=l[2]
if b-1<=n:
  i=b-1
else:
  i=n
y=(((a*i)/b)//1)-(a*((i/b)//1))
print(int(y))
### BUGGY CODE ###

n=int(input())
A=list(map(int,input().split()))
A.sort()
A.reverse()
ans=0
conf=[A[0]]
A.pop(0)


for elem in A:
    ans+=conf.pop(0)
    
    for _ in range(2):
        conf.append(elem)

print(ans)

### FIXED CODE ###

from collections import deque
n=int(input())
A=list(map(int,input().split()))
A.sort()
A.reverse()
conf=[A[0]]
ans=0
con=deque(conf)
A.pop(0)


for elem in A:
    ans+=con.popleft()
    
    for _ in range(2):
        con.append(elem)

print(ans)
### BUGGY CODE ###

n, m = map(int, input().split())
d = [0]*(10**5)
for _ in range(m):
    l, r = map(int, input().split())
    for i in range(l-1, r):
        d[i] += 1
ans = 0
for i in d:
    if i == m:
        ans += 1
print(ans)

### FIXED CODE ###

n, m = map(int, input().split())
l, r = map(int, input().split())
for _ in range(1, m):
    l_, r_ = map(int, input().split())
    l = max(l, l_)
    r = min(r, r_)
if r-l<0:
    print(0)
else:
    print(r-l+1)
### BUGGY CODE ###

N = int(input())
A = [int(i) for i in input().split(' ')]

A.sort(reverse=True)
ring = []
max_value = A.pop(0)
ring.append(max_value)
ring.append(max_value)
ans = 0
for i in A:
    buf = [x for x in ring]
    n = []
    for j in range(0, len(ring) - 1):
        n.append(min(ring[j:j+2]))
    ans = ans + max(n)
    ring.insert(n.index(max(n)) + 1, i)

print(ans)

### FIXED CODE ###

import sys
from collections import deque

N = int(sys.stdin.readline())
A = [int(i) for i in sys.stdin.readline().split(' ')]

A.sort(reverse=True)
max_value = A.pop(0)
diff = deque([max_value])
ans = 0
for i in A:
    ans = ans + diff.popleft()
    diff.append(i)
    diff.append(i)

print(ans)
### BUGGY CODE ###

n= int(input())
l=[]

for i in range(n):
    x = input()
    if (x in l)==False:
        l.append(x)
print(len(l))
    

### FIXED CODE ###

n= int(input())
l=[]

for i in range(n):
    x=input()
    l.append(x)
    
l2=list(set(l))    
print(len(l2))
### BUGGY CODE ###

n = int(input())
h = str(input())
h = list(h)
h2 = list(h)
def mojiretu(n, h):
    for i in range(0, n - 1):
            if h[i] == h[i + 1]:
                h2.remove(h[i])
    return len(h2)
print(mojiretu(n,h))

### FIXED CODE ###

n = int(input())
h = str(input())
h = list(h)
h2 = []
def mojiretu(n, h):
    h2.append(h[0])
    for i in range(1, len(h)):
            if h[i] != h[i - 1]:
                h2.append(h[i])
    return len(h2)
print(mojiretu(n,h))
### BUGGY CODE ###

import os
import io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline


n, q = list(map(int, input().split()))
count = (n - 2) ** 2
c = [n] * n
r = [n] * n
mc = n
mr = n
for _ in range(q):
  m,q = list(map(int, input().split()))
  if m == 1:
    pos = r[q-1]
    if q < mc:
        mc = q
        c[:pos] = [min(q, v) for v in c[:pos]]
    if q not in [1,n]:
      count -= max(0, pos - 2)
  else:
    pos = c[q-1]
    if q < mr:
        mr = q
        r[:pos] = [min(q, v) for v in r[:pos]]
    if q not in [1,n]:
      count -= max(0, pos-2)
print(count)

### FIXED CODE ###

import os
import io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline


n, q = list(map(int, input().split()))
count = (n - 2) ** 2
c = [n] * (n + 1)
r = [n] * (n + 1)
mc = n
mr = n
for _ in range(q):
    m,q = list(map(int, input().split()))
    if m == 1:
        if q <= mc:
            count -= mr -2
            for p in range(q+1, mc):
                c[p] = mr
            c[q] = 0
            mc = q
        else:
            count -= c[q] - 2
    else:
        if q <= mr:
            count -= mc -2
            for p in range(q+1, mr):
                r[p] = mc
            r[q] = 0
            mr = q
        else:
            count -= r[q] - 2
print(count)
### BUGGY CODE ###

R,G,B,N=list(map(int, input().split()))
cnt = 0
for r in range(N//R+1):
    for g in range(N//G+1):
        tmp = (N-(r*R+g*G))
        if tmp>=0:
            if tmp%B==0:
                cnt += 1
print(cnt)

### FIXED CODE ###

R,G,B,N=list(map(int, input().split()))
arr = [R,G,B]
arr = sorted(arr, reverse=True)
R,G,B = arr

cnt = 0
for r in range(N//R+1):
    for g in range((N-r*R)//G+1):
        tmp = (N-(r*R+g*G))
        if tmp>=0:
            if tmp%B==0:
                cnt += 1
print(cnt)
### BUGGY CODE ###

data = input().split()
n,k = int(data[0]),int(data[1])

while True:
    ans = abs(n - k)
    if ans < n:
        n = ans
    else:
        break
print(n)

### FIXED CODE ###

data = input().split()
n,k = int(data[0]),int(data[1])
print(min(n%k,k-n%k))
### BUGGY CODE ###

N=int(input())
A=list(map(int, input().split()))
for i in range(1,N+1):
    print(A.count(i))

### FIXED CODE ###

N=int(input())
A=list(map(int, input().split()))
b=[0]*N
for i in A:
    b[i-1]+=1
for j in b:
    print(j)
### BUGGY CODE ###

def resolve():
    N, M = list(map(int, input().split()))
    interval = []
    for i in range(M):
        L, R = list(map(int, input().split()))
        interval.append(list(range(L, R + 1)))
    # print(interval)
    interval = [set(l) for l in interval]
    interval = set.intersection(*interval)

    print(len(set(range(1, N + 1)) & interval))

    return


resolve()

### FIXED CODE ###

def resolve():
    N, M = list(map(int, input().split()))
    interval = []
    l, r = 0, 10**5
    for i in range(M):
        L, R = list(map(int, input().split()))
        l = max(l, L)
        r = min(r, R)

    interval = set(list(range(l, r + 1)))
    interval = interval & set(range(1, N + 1))

    print(len(interval))

    return


resolve()
### BUGGY CODE ###

N,k = map(int,input().split())
a = list(map(int,input().split()))
i = 0
while i < N:
    if a[i] >= 0:
        break
    i += 1
x = []
for j in range(i-k,i+1):
    if j>=0 and j+k-1<N:
        x.append(a[j:j+k])
y = []
for i in range(len(x)):
    if x[i][0] < 0 and x[i][k-1] > 0:
        y.append(min(-x[i][0],x[i][k-1])*2 + max(-x[i][0],x[i][k-1]))
    else:
        y.append(max(-x[i][0],x[i][k-1]))
print(min(y))

### FIXED CODE ###

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

if 0 in x:
    K -= 1

cand = []
hasleft = x[0] < 0
hasright = x[N-1] > 0
if K == 0:
    cand = [0]
else:
    for i in range(N-K+1):
        left = x[i]
        right = x[i+K-1]
        if left < 0 and right > 0:
            cand.append(min(abs(left)*2+right, right*2+abs(left)))
        elif right < 0:
            cand.append(abs(left))
        elif left > 0:
            cand.append(right)
print(min(cand))
### BUGGY CODE ###

def change(A,B,C):
    move=True
    a=A
    b=B
    c=C
    A=b+c
    B=a+c
    C=a+b
    if (a==A)&(b==B)&(c==C):
        move=False
    return A,B,C,move
A,B,C,K=map(int,input().split())
ans=A-B
for i in range(K):
    A,B,C,move=change(A,B,C)
    ans=A-B
    if abs(ans)>1000000000000000000:
        print("Unfair")
        break
    elif not(move):
        print(ans)
        break
    elif A==B:
        print(0)
        break
else:
    print(ans)

### FIXED CODE ###

A,B,C,K=map(int,input().split())
if K%2==0:
    ans=A-B
else:
    ans=B-A
if ans>1000000000000000000:
    ans="Unfair"
print(ans)
### BUGGY CODE ###

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

x = int(input())

l = make_divisors(x)

for i in range(max(len(l)//2,1)):
	a = -10**4+l[i]
	b = -10**4
	#print(a,b)
	while True:
		num = a**4 + (a**3)*b + (a**2)*(b**2) + a*(b**3) + b**4
		if num == l[-i-1]:
			print(a,b)
			#print('Yes!')
			break
		if a == 10**4:
			break
		#print(l[-i-1],num)
		a += 1
		b += 1



### FIXED CODE ###

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

x = int(input())

l = make_divisors(x)

for i in range(max(len(l)//2,1)):
	a = -10**3+l[i]
	b = -10**3
	#print(a,b)
	while True:
		num = a**4 + (a**3)*b + (a**2)*(b**2) + a*(b**3) + b**4
		if num == l[-i-1]:
			print(a,b)
			#print('Yes!')
			break
		if b == 10**3:
			break
		#print(l[-i-1],num)
		a += 1
		b += 1
### BUGGY CODE ###

# coding: utf-8
kaisuu = int(input())
getprizelist = []
for i in range(kaisuu):
    keihin = input()
    if keihin not in getprizelist:
        getprizelist.append(keihin)
print(len(getprizelist))


### FIXED CODE ###

# coding: utf-8
kaisuu = int(input())
getprizelist = {}
for i in range(kaisuu):
    keihin = input()
    if keihin not in getprizelist:
        getprizelist[keihin] = i
print(len(getprizelist))