Harryxun/stf_run huggingface dataset:
n,d,a=map(int,input().split())
xh=[list(map(int,input().split())) for _ in range(n)]
xh.sort(key=itemgetter(0))

import collections
pq=collections.deque()

ans = 0
totalDamage = 0


for i in range(n):
    x,h = xh[i]
    if len(pq) and pq[0][0] < x:
        totalDamage -= pq[0][1]
        pq.popleft()
    h -=totalDamage
    if h <= 0:
        continue
    num = (h + a -1) //a
    ans += num
    dam = num*a
    totalDamage += dam
    pq.append((x+2*d,dam))

print(ans)

### FIXED CODE ###

n,d,a=map(int,input().split())
xh=[list(map(int,input().split())) for _ in range(n)]
xh.sort()

import collections
pq=collections.deque()

ans = 0
totalDamage = 0


for i in range(n):
    x,h = xh[i]
    while len(pq) > 0 and pq[0][0] < x:
        totalDamage -= pq[0][1]
        pq.popleft()
    h -=totalDamage
    if h <= 0:
        continue
    num = (h + a -1) //a
    ans += num
    dam = num*a
    totalDamage += dam
    pq.append((x+2*d,dam))

print(ans)
import sys
readline = sys.stdin.buffer.readline

def main():
    N = int(readline())
    A = [0] *(10**5)
    total = 0
    for a in map(int, readline().split()):
        total += a
        A[a] += 1
 
 
    Q = int(readline())
    for _ in range(Q):
        b, c = map(int, readline().split())
        total += A[b]*(c-b)
        print(total)
        A[c] += A[b]
        A[b] = 0
 
 
if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
readline = sys.stdin.buffer.readline
read = sys.stdin.read
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7
 
def main():
    N = int(readline())
    A = [0] *(10**5+1)
    total = 0
    for a in map(int, readline().split()):
        total += a
        A[a] += 1
 
 
    Q = int(readline())
    for _ in range(Q):
        b, c = map(int, readline().split())
        total += A[b]*(c-b)
        print(total)
        A[c] += A[b]
        A[b] = 0
 
 
if __name__ == '__main__':
    main()
n, m = map(int, input())
a = sum([int(i) for i in input().split()])

print(n-a if n-a>=0 else '-1')

### FIXED CODE ###

n, m = map(int, input().split())
a = sum([int(i) for i in input().split()])

print(n-a if n-a>=0 else '-1')
station = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQESTUVWXYZ"
while True:
    n = input()
    if n==0:
        break
    k = map(int, raw_input().split())
    s = raw_input()
    print "".join(station[station.find(s[i])-k[i%n]] for i in xrange(len(s)))

### FIXED CODE ###

station = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
while True:
    n = input()
    if n==0:
        break
    k = map(int, raw_input().split())
    s = raw_input()
    print "".join(station[(station.find(s[i])-k[i%n]+52)%52] for i in xrange(len(s)))
N, M = map(int, input().split())
C = [[0, 0, 0] for i in range(M)] # Cities
for i in range(M):
    P, Y = map(int, input().split())
    C[i][:] = [i, P, Y]

C.sort(key=lambda x: x[2])

I = [[0, 0] for i in range(M)]
Num = [0]*M

for i in range(M):
    P = C[i][1]
    I[i][:] = [C[i][0], "%06d%06d" % (P, Num[P-1] + 1)]
    Num[P-1] += 1

I.sort(key=lambda x: x[0])
for i in range(M):
    print(I[i][1])

### FIXED CODE ###

N, M = map(int, input().split())
C = [[0, 0, 0] for i in range(M)] # Cities
for i in range(M):
    P, Y = map(int, input().split())
    C[i] = [i, P, Y]

C.sort(key=lambda x: x[2])

I = [[0, 0] for i in range(M)]
Num = [0]*N

for i in range(M):
    P = C[i][1]
    Num[P-1] += 1
    I[i] = [C[i][0], "%06d%06d" % (P, Num[P-1])]

I.sort(key=lambda x: x[0])
for i in range(M):
    print(I[i][1])
N, L = raw_input().split()
l = []
for _ in range(N):
    l.append(raw_input().strip())
print "".join(sorted(l))

### FIXED CODE ###

N, L = map(int, raw_input().split())
l = []
for _ in range(N):
    l.append(raw_input().strip())
print "".join(sorted(l))
from heapq import heappop, heappush, heapify
N = int(input())
A = list(map(int, input().split()))
p = []
for i in A:
    if i > 0:
        tmp = [i, 1]
    elif i < 0:
        tmp = [-i, -1]
    else:
        N -= 1
        continue
    heappush(p, tmp)
res = []
for i in range(N-1):
    x, y = heappop(p), heappop(p)
    x = x[0] * x[1]
    y = y[0] * y[1]
    if p == []:
        if x-y > y-x:
            res.append([x,y])
            tmp = x-y
        else:
            res.append([y,x])
            tmp = y-x
        continue
    if p[0][1] > 0:
        tmp = min(x-y, y-x)
    else:
        tmp = max(x-y, y-x)
    if tmp == y-x:
        x,y=y,x
    if tmp > 0:
        tmp = [tmp, 1]
    else:
        tmp = [-tmp, -1]
    res.append([x,y])
    heappush(p, tmp)
    
print(tmp)
for i in res:
    print(*i)

### FIXED CODE ###

n = int(input())
a = list(map(int , input().split()))
pos = sorted([i for i in a if i >= 0], reverse=True)
neg = sorted([i for i in a if i < 0], reverse=True)

ans = []
if len(neg) == 0 and len(pos) == 2:
    print(pos[0] - pos[1])
    print(pos[0], pos[1])
    exit()
elif len(pos) == 0:
    tmp = neg[0]
    for i in range(1,len(neg)):
        ans.append([tmp, neg[i]])
        tmp -= neg[i]
    print(tmp)
    [print(*i) for i in ans]
    exit()
elif len(neg) == 0:
    neg.append(pos.pop())

tmp = neg.pop()
while len(pos) > 1:
    a = pos.pop()
    ans.append([tmp, a])
    tmp -= a
neg.append(tmp)

tmp = pos[0]
for i in neg:
    ans.append([tmp, i])
    tmp -= i

print(tmp)
[print(*i) for i in ans]
# N：全種類数、M：今回種類数
N,M = map(int, input().split())
# 得票数
hyou = list(map(int, input().split()))

# 総得票数
total_hyou = 0
for i in hyou:
  total_hyou += i

# 得票数基準クリア数
count = 0
border = int(total_hyou*(1/4*M))
for j in hyou:
  if j >= border:
    count += 1
    
# 人気商品をM個選べるかどうか
if count >= M:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

# [箱A, 箱B, 箱C]
list = input().split()

# 箱Aと箱B入れ替え
temp = list[0]
list[0] = list[1]
list[1] = temp

# 箱Aと箱C入れ替え
temp = list[0]
list[0] = list[2]
list[2] = temp              
              
print(' '.join(list))
n, p = map(int,input().split())
D = input()
count = [0] * p
out = 0

if 10 % p == 0:
    for i in range(n):
        if int(D[i]) % p == 0:
            out += i + 1
else:
    ten = 1
    count[0] = 1
    for i in range(n):
        mod = (mod + int(D[n-i-1]) * ten) % p
        count[mod] += 1
        ten *= 10
    for c in count:
        out += (c * (c - 1)) // 2
print(out)

### FIXED CODE ###

A = False
B = False
s=input()
for char in s:
    if char == "A":
        A = True
    if char == "B":
        B = True
if(A and B):
    print("Yes")
else:
    print("No")
S = input()
count = 0
list = []

for c in S:
  if c == 'A' or c == 'C' or c == 'G' or c == 'T':
    count++
  else:
    list.append(count)
    count = 0
print(max(list))
    

### FIXED CODE ###

S = input()
count = 0
list = []

for c in S:
  if c == 'A' or c == 'C' or c == 'G' or c == 'T':
    count+=1
  else:
    list.append(count)
    count = 0
list.append(count)

if len(list)==0:
    print('0')
else:
    print(max(list))
from itertools import combinations


def main():
    N = int(input())
    x = []
    y = []
    for _ in range(N):
        x_n, y_n = map(int, input().split())
        x.append(x_n)
        y.append(y_n)
    comb = list(combinations([i for i in range(N)], 2))
    dic = {}
    for c in comb:
        i, j = c[0], c[1]
        dx = x[j] - x[i]
        dy = y[j] - y[i]
        if not (dx, dy) in dic.keys():
            dic[(dx, dy)] = 0
        dic[(dx, dy)] += 1
    dic_sorted = sorted(dic.items(), key=lambda x:x[1])[::-1]
    print(N - dic_sorted[0][1])
    return


if __name__ == '__main__':
    main()


### FIXED CODE ###

from itertools import combinations


def main():
    N = int(input())
    x = []
    y = []
    for _ in range(N):
        x_n, y_n = map(int, input().split())
        x.append(x_n)
        y.append(y_n)
    if N == 1:
        print(1)
        return
    comb = list(combinations([i for i in range(N)], 2))
    dic = {}
    for c in comb:
        i, j = c[0], c[1]
        dx = x[j] - x[i]
        dy = y[j] - y[i]
        if not (dx, dy) in dic.keys():
            dic[(dx, dy)] = 0
        if not (-dx, -dy) in dic.keys():
            dic[(-dx, -dy)] = 0
        dic[(dx, dy)] += 1
        dic[(-dx, -dy)] += 1
    dic_sorted = sorted(dic.items(), key=lambda x:x[1])[::-1]
    print(N - dic_sorted[0][1])
    return


if __name__ == '__main__':
    main()
r1, c1, r2, c2 = list(map(int, input().split()))

mod = 1000000007

# return an integer k s.t. (a * k) % p = 1 and 0 <= k < p.
def inversion(a):
    b = mod
    u, v = 1, 0
    while b >= 1:
        t = a // b
        a -= t * b
        a, b = b, a
        u -= t * v
        u, v = v, u
    u %= mod
    if u < 0:
        u += mod
    return u

fact = [0 for i in range(20003)]
for i in range(20003):
    if i <= 1:
        fact[i] = 1
    else:
        fact[i] = (fact[i-1] * i) % mod

# return nCr % p.
def combination(n, r):
    return (((fact[n] * inversion(fact[r])) % mod) * inversion(fact[n-r])) % mod

answer = (
combination(r2 + c2 + 2, r2 + 1) -
combination(r2 + c1 + 1, r2 + 1) -
combination(r1 + c2 + 1, c2 + 1) +
combination(r1 + c1    , c1    ) )

answer %= mod

if answer < 0:
    answer += mod

print(answer)


### FIXED CODE ###

r1, c1, r2, c2 = list(map(int, input().split()))

mod = 1000000007

# return an integer k s.t. (a * k) % p = 1 and 0 <= k < p.
def inversion(a):
    b = mod
    u, v = 1, 0
    while b >= 1:
        t = a // b
        a -= t * b
        a, b = b, a
        u -= t * v
        u, v = v, u
    u %= mod
    if u < 0:
        u += mod
    return u

fact = [0 for i in range(2000003)]
for i in range(2000003):
    if i <= 1:
        fact[i] = 1
    else:
        fact[i] = (fact[i-1] * i) % mod

# return nCr % p.
def combination(n, r):
    return (((fact[n] * inversion(fact[r])) % mod) * inversion(fact[n-r])) % mod

answer = (
combination(r2 + c2 + 2, r2 + 1) -
combination(r2 + c1 + 1, r2 + 1) -
combination(r1 + c2 + 1, c2 + 1) +
combination(r1 + c1    , c1    ) )

answer %= mod

if answer < 0:
    answer += mod

print(answer)
def resolve():
    from fractions import gcd
    n = int(input())
    a = list(map(int, input().split()))
    mod = 10**9 + 7
    lsd = a[0]
    for i in range(1, n):
        lsd = int((lsd * a[i]) / (gcd(lsd, a[i])))
 
    ans = 0
    for i in range(n):
        ans += int(lsd/a[i]) % mod
 
    print(int(ans % mod))
resolve()

### FIXED CODE ###

def resolve():
    def lcm(X, Y):
        x = X
        y = Y
        if y > x:
            x, y = y, x
        while x % y != 0:
            x, y = y, x % y
        return X * Y // y
    n = int(input())
    a = list(map(int, input().split()))
    mod = 10**9 + 7
    lsd = a[0]
    for i in range(1, n):
        lsd = lcm(lsd, a[i])
    lsd = lsd % mod

    ans = 0
    for i in range(n):
        ans += (lsd * pow(a[i], mod-2, mod)) % mod

    print(int(ans % mod))

resolve()
n,k = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
A = (10**9)+7
c_in = 0
for i in range(n):
  for j, t in enumerate(a[:i]):
    c_in += int(t > a[i])
  count[a[i]-1] += 1
c_out = 0
for i in range(n):
  for j, t in enumerate(a):
    c_out += int(t > a[i])
N = (k*c_in)%A + ((k*(k-1)//2)*c_out)%A
print(int(N))


### FIXED CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
x=0
for i in range(n):
    for j in range(i+1,n):
        if a[i]>a[j]:
            x+=1
y=0
for i in range(n):
    for j in range(n):
        if a[i]>a[j]:
            y+=1
cnt=(x*k)+(k*(k-1)//2*y)
print(cnt%(10**9+7))
N=int(input())
for i in range(N):
  S[i+1]=str(input())
print(len(set(S)))

### FIXED CODE ###

N=int(input())
S=[]
for i in range(N):
  S.append(str(input()))
print(len(set(S)))
import math
A,B=map(int, input().split())
flag=False
for i in range(1250):
  A_X=math.floor(i*0.08)
  if(A_X==A):
    B_X=math.floor(i*0.10)
    if(B_X==B):
      print(i)
      flag=True
      break
if(flag==False):
  print(-1)

### FIXED CODE ###

S=input()
Sset=set(S)
if(len(Sset)==2):
  print('Yes')
else:
  print('No')
#coding:utf-8
import fractions
#import math

#素因数分解
def prime_factorial(num):
    fact = []
    for i in range(2, int(num**0.5)+1):
        if num % i == 0:
            fact.append(i)
            num = num // i
    if num != 1:
        fact.append(num)
        return fact

if __name__ == "__main__":
    #最大公約数を素因数分解し、その個数＋1が答え
    a, b = map(int, input().split())
    #g = math.gcd(a, b)
    g = fractions.gcd(a, b)
    #print(g)
    #最大公約数が1の場合は1しかないのでそのまま出力。それ以外は素因数分解させる
    if g == 1:
        print(1)
    else:
        fact = prime_factorial(g)
        print(len(set(fact)) + 1)

### FIXED CODE ###

#coding:utf-8
import fractions
#import math
import collections
#素因数分解
def prime_factorial(num):
    fact = []
    for i in range(2, int(num**0.5)+1):
        while num % i == 0:
            fact.append(i)
            num = num // i
    if num != 1:
        fact.append(num)
    return fact

if __name__ == "__main__":
    #最大公約数を素因数分解し、その個数＋1が答え
    a, b = map(int, input().split())
    #g = math.gcd(a, b)
    g = fractions.gcd(a, b)
    #print(g)
    #print(prime_factorial(g))

    c = collections.Counter(prime_factorial(g))
    print(len(list(c.keys())) + 1)
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))
c = [1] * N
s = [C[P[i]-1] for i in range(N)]
m = [[0] * (N+1) for i in range(N)]
for i in range(N):
    m[i][1] = (C[P[i]-1])
for i in range(N):
    j = i
    while P[j]-1 != i:
        j = P[j]-1
        c[i] += 1
        s[i] += C[P[j]-1]
        if  c[i] <= K:
            if s[i] > m[i][c[i]-1]:
                m[i][c[i]] = s[i]
            else:
                m[i][c[i]] = m[i][c[i]-1]
print(c)
print(s)
print(m)
ans = max(C)
for i in range(N):
    if s[i] > 0:
        print(s[i] * (K//c[i]) + m[i][K%c[i]])
        if  s[i] * (K//c[i]) + m[i][K%c[i]] > ans:
            ans = s[i] * (K//c[i]) + m[i][K%c[i]]
    else:
        print(max(m[i][1:min(c[i]+1,K+1)]))
        if m[i][min(c[i],K)] > ans:
            ans = m[i][min(c[i],K)]
print(ans)


### FIXED CODE ###

N, K = map(int, input().split())
P, C = [list(map(int, input().split())) for _ in range(2)]
c = [1] * N
m = [[0] * (N+1) for i in range(N)]
for i in range(N):
    m[i][1] = (C[P[i]-1])
ans = max(C)
for i in range(N):
    j = i
    while P[j]-1 != i:
        j = P[j]-1
        c[i] += 1
        m[i][c[i]] = m[i][c[i]-1] + C[P[j]-1]
    if m[i][c[i]] > 0:
        ans = max(ans, m[i][c[i]] * (K//c[i]-1) + max(m[i] + [m[i][c[i]] + m[i][j+1] for j in range(K%c[i])]))
    else:
        ans = max(ans, max(m[i][1:min(c[i],K)+1]))
print(ans)
from collections import deque
from bisect import bisect_left as bile

    # while stack:
    #     node = stack.pop()
    #     for v in adj[node]:
    #         if v == parent[node]:
    #             continue
    #         parent[v] = node
    #         stack.append(v)
    #     dp
    

def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n = int(input())
    arr = list(map(int, input().split()))
    adj = [[] for _ in range(n)]
    for i in range(n-1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        adj[a].append(b)
        adj[b].append(a)

    ans = [0]*n
    inf = 1e18
    dp = [inf]*n
    parent = [-1]*n
    def dfs(s):
        
        idx = bile(dp, arr[s])
        tmp = dp[idx]
        dp[idx] = arr[s]
        ans[s] = bile(dp, inf)

        for v in adj[s]:
            if v == parent[s]:
                continue
            parent[v] = s
            dfs(v)
        dp[idx] = tmp
        return ans
        
    ans = dfs(0)
    for a in ans:
        print(a)


if __name__ == '__main__':
    main()

### FIXED CODE ###

from collections import deque
from bisect import bisect_left as bile

def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    sys.setrecursionlimit(10**6)
    n = int(input())
    arr = list(map(int, input().split()))
    adj = [[] for _ in range(n)]
    for i in range(n-1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        adj[a].append(b)
        adj[b].append(a)

    ans = [0]*n
    inf = 1e18
    dp = [inf]*(n+10)
    parent = [-1]*n
    def dfs(s):
        idx = bile(dp, arr[s])
        tmp = dp[idx]
        dp[idx] = arr[s]
        ans[s] = bile(dp, inf)

        for v in adj[s]:
            if v == parent[s]:
                continue
            parent[v] = s
            dfs(v)
        dp[idx] = tmp
        return ans
        
    ans = dfs(0)
    for a in ans:
        print(a)


if __name__ == '__main__':
    main()
n, k = map(int, input().split())
h = list(map(int, input().split()))
sum = 0
for i in h:
    if h >= k:
        sum += 1
print(sum) 

### FIXED CODE ###

n, k = map(int, input().split())
h = list(map(int, input().split()))
sum = 0
for i in h:
    if i >= k:
        sum += 1
print(sum)
import string

N = int(input())

res = []
while True:
    d, m = divmod(N, 26)
    res.append(m)
    if d < 26:
        if d != 0:
            res.append(d)
        break
    else:
        N = d

smap = dict(enumerate(string.ascii_lowercase, 1))
print("".join(smap[a] for a in reversed(res)))

### FIXED CODE ###

import string

N = int(input()) - 1
smap = dict(enumerate(string.ascii_lowercase))

res = []
while True:
    d, m = divmod(N, 26)
    res.append(m)
    if d-1 > 25:
        N = d-1
    else:
        if d == 0:
            break
        else:
            res.append(d-1)
            break

print("".join(smap[i] for i in reversed(res)))
N, M, X, Y = map(int, input().split())
x=list(map(int, input().split()))
y=list(map(int, input().split()))

if max(x)<min(y):
  for i in range(max(x)+1,min(y)+1):
    if i>X and i<=Y:
      print('No War')
      break
  else
    print('War')
else:
  print('War')

### FIXED CODE ###

N, M, X, Y = map(int, input().split())
x=list(map(int, input().split()))
y=list(map(int, input().split()))

if max(x)<min(y):
  for i in range(max(x)+1,min(y)+1):
    if i>X and i<=Y:
      print('No War')
      break
  else:
    print('War')
else:
  print('War')
a,b = list(map(int, input().split()))
 print(a*b, 2(a+b))

### FIXED CODE ###

a,b = list(map(int, input().split()))
print(a*b, 2*(a+b))
N,M = map(int, input().split())

town_road_dict = {}

for i in range(M):
    a,b = map(int, input().split())
    
    if a not in town_road_dict:
        town_road_dict[a] = [b]
    else:
        town_road_dict[a].append(b)
    if b not in town_road_dict:
        town_road_dict[b] = [a]
    else:
        town_road_dict[b].append(a)
        
for i in range(N):
    print(len(town_road_dict[i+1]))

### FIXED CODE ###

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

town_road = [0 for _ in range(N+2)]

for i in range(M):
    a,b = map(int, input().split())
           
    town_road[a] += 1
    town_road[b] += 1
        
for i in range(1,N+1):
    print(town_road[i])
a, b, k = map(int, input().split())
divs = []

for i in range(1, int(max(a, b) / 2)):
    if a % i == 0:
        if a % i == 0:
            divs.append(i)
print(divs[-k])

### FIXED CODE ###

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

for i in range(min(a, b), 0, -1):
    if a % i == 0 and b % i == 0:
        k -= 1
        if k == 0:
            print(i)
turn = int(input())

lista = []
while True:
    inpy = tuple(map(int, input().split()))
    if inpy:
        lista.append(inpy)
    else:
        break

counter = 0
for challenge in range(len(lista)):
    inp = lista[challenge]
   
    if sum(inp[1:]) <= inp[0] and sum(inp[1:]) >= -inp[0]:
        if inp[0] % 2 == 0 and sum(inp[1:]) % 2 ==0:
            counter += 1
            # print('Yes')
        elif inp[0] % 2 != 0 and sum(inp[1:]) % 2 != 0:
            counter += 1
            # print('Yes')
        else:
            pass
            # print('No')
    else:
        pass
        # print('No')

if counter == 2:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

n = int(input())
t_ = 0
xy_ = [0,0]
for _ in range(n):
    t, *xy = map(int, input().split())
    ta = t - t_
    xya = [abs(xy[0]-xy_[0]), abs(xy[1]-xy_[1])]
    if sum(xya) > ta or (ta - sum(xya))%2 != 0:
        print("No")
        break
    t_ = t
    xy_ = xy
else:
    print("Yes")
import collections
N = int(input())
A = deque(map(int, input().split()))

C = collections.Counter(A)

for i in range(1, N+1):
    if i in C.keys():
        print(C[i])
    else:
        print(0)

### FIXED CODE ###

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

C = collections.Counter(A)

for i in range(1, N+1):
    if i in C.keys():
        print(C[i])
    else:
        print(0)
def solve():
    N, M = map(int, input().split())
    a = abs(N-M)
    
    if a >= N:
        return N
    
    return min(N % a, N % M)

print(solve())

### FIXED CODE ###

def solve():
    N, M = map(int, input().split())
    
    if N % M == 0:
        return 0
    
    a = N % M

    return min(a, abs(a-M))

print(solve())
A = list(map(int, input().split()))
A =sorted(A)
if A[0]=5 and A[1]=5 and A[2]=7:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

A = list(map(int, input().split()))
A =sorted(A)
if A[0]==5 and A[1]==5 and A[2]==7:
  print("YES")
else:
  print("NO")
import fractions
import functools

def multiple(a, b):
    return a*b // fractions.gcd(a, b)
def lcm(nums):
  return functools.reduce(multiple, nums)
 l[0]

N = int(input())
A = list(map(int, input().split()))
n = lcm(A)
ans = 0
mod = 10**9+7
for a in A:
  ans += n//a
  ans %= mod
print(ans)



### FIXED CODE ###

from fractions import gcd

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

x = 1
for i in range(N):
  x = (x*A[i]) // gcd(x, A[i])

ans = 0
for a in A:
  ans += x//a
  #ans %= mod
print(ans%mod)
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

n = int(input())
a = [int(i) for i in input().split()]
l = a[0]
for i in a[1:]:
    l = lcm(l,i)
b = []
for i in a:
    b.append(l//i)
ans = sum(b) % (10 ** 9 + 7)
print(ans)

### FIXED CODE ###

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

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
def lcm(x, y):
    return (x * y) // gcd(x, y)

l = a[0]
for i in a[1:]:
    l = lcm(l, i)
b = []
for i in a:
    b.append(l//i)
ans = sum(b) % (10 ** 9 + 7)
print(ans)
n = int(input())
a = list(map(int, input().split()))

xs = [0] * (2 * (10 ** 5) + 1)

for v in a:
    if xs[v] == 0:
        for j in range(v, len(xs), v):
            xs[j] += 1
    else:
        xs[v] += 1
print(len(list(filter(lambda v: xs[v] == 1, a))))


### FIXED CODE ###

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

xs = [0] * (max(a) + 1)

for v in a:
    if xs[v] == 0:
        for j in range(v, len(xs), v):
            xs[j] += 1
    else:
        xs[v] += 1
print(len(list(filter(lambda v: xs[v] == 1, a))))
n,k,x,y=map(int,input().split() for i in range(4)]
if n>k:
    print(x*k+y*(n-k))
else:
    print(x*k)


### FIXED CODE ###

n=int(input())
k=int(input())
x=int(input())
y=int(input())
if n>k:
    print(x*k+y*(n-k))
else:
    print(x*n)
container = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
unser = int(input())
print(container[unser])

### FIXED CODE ###

container = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
unser = int(input())
print(container[unser - 1])