Harryxun/stf_run huggingface dataset:
import numpy as np

S = input()
MOD = 10 ** 9 + 7

dp = [0] * 13
dp[0] = 1

for s in S:
    prev = [x for x in dp]
    dp = [0] * 13
    if s == '?':
        add = range(10)
    else:
        add = [int(s)]
    for i in range(13):
        for a in add:
            dp[(10*i+a)%13] += prev[i]
    dp = [x%MOD for x in dp]
print(dp[5])


### FIXED CODE ###

MOD = 10 ** 9 + 7
S = input()

dp = [0] * 13
dp[0] = 1

for s in S:
  prev = [x for x in dp]
  dp = [0] * 13
  if s == '?':
    add = range(10)
  else:
    add = [int(s)]
  for i in range(13):
    for x in add:
      dp[(10*i+x)%13] += prev[i]
  dp = [x % MOD for x in dp]
  
print(dp[5])
a,b = map(str,input().split())
a2 = int(a)
b2 = 100*int(b[0:1])+10*int(b[2:3])+int(b[3:4])
tmp = str(a2*b2)
l = len(tmp)
ans = int(tmp[0:l-2])
print(ans)

### FIXED CODE ###

a,b = map(str,input().split())
a2 = int(a)
b2 = 100*int(b[0:1])+10*int(b[2:3])+int(b[3:4])
if a2 == 0 or b2 == 0:
    ans = 0
else:
    tmp = str(a2*b2)
    l = len(tmp)
    if l <= 2:
        ans = 0
    else:
        ans = int(tmp[0:l-2])
print(ans)
import math
a, b = map(int, input().split())
ans = (a * b) // math.gcd(a, b)
print(ans)

### FIXED CODE ###

import fractions
a, b = map(int, input().split())
ans = (a * b) // fractions.gcd(a, b)
print(ans)
N, R = map(int, input().spit())
if N < 10:
  print(R+100*(10-N))
else:
  print(R)

### FIXED CODE ###

N, R = map(int, input().split())
if N < 10:
  print(R+100*(10-N))
else:
  print(R)
N, M, K =map(int,input().aplit())
bases = list(map(int,input()))
ans=0

for i in range(M):
  A = list(map(int,input().split()))
  tmp=0
  for j in range(3):
    tmp+= bases[j]*A[j]
  if tmp>0:
    ans+=1
    
print(ans)


### FIXED CODE ###

N, M, K =map(int,input().split())
bases = list(map(int,input().split()))
ans=0

for i in range(N):
  a= list(map(int,input().split()))
  tmp=0
  for j in range(M):
    tmp+= bases[j]*a[j]
  
  if tmp+K>0:
    ans+=1
    
print(ans)
a,n=map(int,input().split())

amari=int(n%500)

if amari<=a:
    print('Yes')

else:
    print('No')

### FIXED CODE ###

n=int(input())
a=int(input())

amari=int(n%500)

if amari<=a:
    print('Yes')

else:
    print('No')
N = int(input())
red = [tuple(map(int,input().split())) for _ in range(N)]
blue = [tuple(map(int,input().split())) for _ in range(N)]
 
red.sort(key=lambda x:x[0])
red.sort(key=lambda x:x[1])
blue.sort(key=lambda x:x[0])
blue.sort(key=lambda x:x[1])
 
ans = 0
for i in range(N):
    a,b = red[i]
    for j in range(len(blue)):
        c,d = blue[j]
        if a < c and b < d:
            print(a,b,c,d)
            blue.pop(j)
            ans += 1
            break
print(ans)
N = int(input())
red = [tuple(map(int,input().split())) for _ in range(N)]
blue = [tuple(map(int,input().split())) for _ in range(N)]

red.sort(key=lambda x:x[0])
red.sort(key=lambda x:x[1])
blue.sort(key=lambda x:x[0])
blue.sort(key=lambda x:x[1])

ans = 0
for i in range(N):
    a,b = red[i]
    for j in range(len(blue)):
        c,d = blue[j]
        if a < c and b < d:
            blue.pop(j)
            ans += 1
            break
print(ans)

### FIXED CODE ###

N = int(input())
red = [tuple(map(int,input().split())) for _ in range(N)]
blue = [tuple(map(int,input().split())) for _ in range(N)]
 
red.sort(key=lambda x:x[0], reverse=True)
blue.sort(key=lambda x:x[1])
 
ans = 0
for i in range(N):
    a,b = red[i]
    for j in range(len(blue)):
        c,d = blue[j]
        if a < c and b < d:
            blue.pop(j)
            ans += 1
            break
print(ans)
import math
a, b = map(int, input().split())
a = a // math.gcd(a, b)
print(a * b)

### FIXED CODE ###

import fractions
a, b = map(int, input().split())
a = a // fractions.gcd(a, b)
print(a * b)
n=input()
a=map(int,raw_input().split())
z=[0]*n
z[1]=abs(a[1]-a[0])
for i in xrange(2,n):
  z[i]=min(z[i-1]+abs(a[i]-a[i-1],z[i-2]+abs(a[i]-a[i-2]))
print z[-1]

### FIXED CODE ###

n=input()
a=map(int,raw_input().split())
z=[0]*n
z[1]=abs(a[1]-a[0])
for i in xrange(2,n):
  z[i]=min(z[i-1]+abs(a[i]-a[i-1]),z[i-2]+abs(a[i]-a[i-2]))
print z[-1]
from itertools import *
def f(s):
 for t in["({a} {x} {b}) {y} ({c} {z} {d})","(({a} {x} {b}) {y} {c}) {z} {d}","{a} {x} ({b} {y} ({c} {z} {d}))","({a} {x} ({b} {y} {c})) {z} {d}","{a} {x} (({b} {y} {c}) {z} {d})"]:
  for a,b,c,d in permutations(s):
   for x,y,z in product('+-*',repeat=3):
    t='f"'+t+'"'
    if eval(eval(t))==10:return'('+eval(t)+')'
 else:return 0
for e in iter(input,'0 0 0 0'):print(f(list(map(int,e.split()))))


### FIXED CODE ###

from itertools import *
g=lambda a,x,b:{'+':a+b,'-':a-b,'*':a*b}[x]
def f(s):
 for a,b,c,d in permutations(s):
  for x,y,z in product('+-*',repeat=3):
   if g(g(g(a,x,b),y,c),z,d)==10:return f"(({a}{x}{b}){y}{c}){z}{d}"
   if g(g(a,x,b),y,g(c,z,d))==10:return f"({a}{x}{b}){y}({c}{z}{d})"
 return 0
for e in iter(input,'0 0 0 0'):print(f(list(map(int,e.split()))))
N = int(input())
P_lis = list(map(int,input().split()))
count = 0
min_P = P_lis[0]
for p in P_list:
  if p <= min_P:
    min_P = p
    count += 1

print(count)

### FIXED CODE ###

N = int(input())
P_lis = list(map(int, input().split()))
 
dummy = 2*10**5
answer = 0
 
for p in P_lis:
  if p <= dummy:
    answer += 1
    dummy = p
print(answer)
N, K = map(int, input().split())
H = list(map(int, input().split()))
if N <= K:
  print(0)
elif K == 0:
  print(sum(H))
else:
  H = sort(H)
  print(sum(H[:-K]))

### FIXED CODE ###

N, K = map(int, input().split())
H = list(map(int, input().split()))
if N <= K:
  print(0)
elif K == 0:
  print(sum(H))
else:
  H = sorted(H)
  print(sum(H[:-K]))
n = input()
sum = 0
for i in range(len(n)):
    sum += int(n[i])

if n % sum == 0:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

n = input()
sum = 0
for i in range(len(n)):
    sum += int(n[i])

if int(n) % sum == 0:
    print("Yes")
else:
    print("No")
import fractions
from functools import reduce

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

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

print(gcd(*A))

### FIXED CODE ###

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

if int(B % A) == 0:
    print(A+B)
else:
    print(B-A)
input = input()
print(input**3)

### FIXED CODE ###

input = int(input())
print(input ** 3)
n = input()
a = input()

print(n**n-a)

### FIXED CODE ###

n = int(input())
a = int(input())

print((n**2)-a)
import collections
n,m=map(int,input().split())
par=[i for i in range(n+1)]
def find(x):
    if par[x]==x:
        return x
    else:
        par[x]=find(par[x])
for _ in range(m):
    a,b=map(int,input().split())
    A=find(a)
    B=find(b)
    par[max(A,B)]=par[min(A,B)]
l=[]
for i in range(1,n+1):
    l.append(find(i))
l=collections.Counter(l)
print(max(l.values()))

### FIXED CODE ###

import collections
n,m=map(int,input().split())
par=[i for i in range(n+1)]
def find(x):
    if par[x]==x:
        return x
    else:
        par[x]=find(par[x])
        return par[x]
for _ in range(m):
    a,b=map(int,input().split())
    A=find(a)
    B=find(b)
    par[max(A,B)]=par[min(A,B)]
l=[]
for i in range(1,n+1):
    l.append(find(i))
l=collections.Counter(l)
print(max(l.values()))
a=input()
a[3]='8'
print(a)

### FIXED CODE ###

a=input()

print(a[0:3]+"8"+a[4:])
import sys

x = []

for line in sys.stdin.readlines():
  x.append(line.strip())

max = -(10**9)
min = int(x[1])

for i in range(2, int(x[0]+1)):
  sa = int(x[i]) - min
  if max < sa:
    max = sa
  if min > int(x[i]):
    min = int(x[i])

  

print max

### FIXED CODE ###

import sys

x = []

for line in sys.stdin.readlines():
  x.append(line.strip())

max = -(10**9)
min = int(x[1])

for i in range(2, int(x[0])+1):
  sa = int(x[i]) - min
  if max < sa:
    max = sa
  if min > int(x[i]):
    min = int(x[i])

  

print max
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
INF = float("inf")
import sys
sys.setrecursionlimit(10000)

def manhattan(y1, x1, y2, x2): return abs(y1 - y2) + abs(x1 - x2)


def solve(H, W, D, A, query):
    num_pos = dict()
    for y in range(H):
        for x in range(W):
            num_pos[A[y][x]] = (y, x)

    dp = [None] * (H * W + 1)
    for i in range(1, D + 1):
        dp[i] = 0
        for j in range(i + D, len(dp), D):
            dp[j] = dp[j - D] + manhattan(*num_pos[j - D], *num_pos[j])

    for q in query:
        L, R = q
        print(dp[R] - dp[L])


def main():
    H, W, D = map(int, input().split())
    A = []
    for _ in range(H):
        A.append(list(map(int, input().split())))
    Q = int(input())
    query = []
    for _ in range(Q):
        query.append(list(map(int, input().split())))

    solve(H, W, D, A, query)


if __name__ == "__main__":
    main()


### FIXED CODE ###

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
INF = float("inf")
import sys
sys.setrecursionlimit(10000)

def manhattan(y1, x1, y2, x2): return abs(y1 - y2) + abs(x1 - x2)


def solve(H, W, D, A, query):
    num_pos = dict()
    for y in range(H):
        for x in range(W):
            num_pos[A[y][x]] = (y, x)

    dp = [None] * (H * W + 1)
    for i in range(1, D + 1):
        dp[i] = 0
        for j in range(i + D, len(dp), D):
            y1, x1 = num_pos[j - D]
            y2, x2 = num_pos[j]
            dp[j] = dp[j - D] + manhattan(y1, x1, y2, x2)

    for q in query:
        L, R = q
        print(dp[R] - dp[L])


def main():
    H, W, D = map(int, input().split())
    A = []
    for _ in range(H):
        A.append(list(map(int, input().split())))
    Q = int(input())
    query = []
    for _ in range(Q):
        query.append(list(map(int, input().split())))

    solve(H, W, D, A, query)


if __name__ == "__main__":
    main()
N=int(input())
t=[]
x=[]
y=[]
x_2=0
y_2=0
counter=0
hantei=[-1,1]
for i in range(N):
  t_1, x_1, y_1=map(int, input().split())
  t.append(t_1)
  x.append(x_1)
  y.append(y_1)
  
for i in range(N):
  x_2=0
  y_2=0
  for j in range(t[i]):
    for k in hantei:
      for l in hantei:
        x_2+=k
        y_2+=l
        if x_2==x[i] and y_2==y[i]:
          counter+=1
 
if counter==N:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

a,b=map(int, input().split())
c=a*b
if c%2==0:
  print('Even')
else:
  print('Odd')
L=set("A","B")
print(L)

### FIXED CODE ###

L={"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"}
a=input()
if a in L:
  print("A")
else:
  print("a")
import math
A,B=map(int,input().split())
lcm=A*B/math.gcd(A,B)
print(int(lcm))

### FIXED CODE ###

from fractions import gcd
A,B=map(int,input().split())
lcm=A*B/gcd(A,B)
print(int(lcm))
i = [input() for i in range(2)]
a = [i for i in i[0]]
b = [i for i in i[1]]
c = 0
for i in range(3):
  if a[i] == b[i]:
    c += 1
  else:
    c += 0
print(c)

### FIXED CODE ###

a,b = map(int, input().split())
i = a
c = 1
while int(i) < b:
  i += a - 1
  c += 1
if b == 1:
  print(0)
else:
  print(c)
H, W = map(int, input().split)
S=H*W
if S%2 ==1:
  print(H*W//2+1)
  
else:
  print(H*W/2)

### FIXED CODE ###

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

if H==1 or W==1:
  print(1)
elif H%2 == 1 and W%2 == 1:
  print((H*W)//2+1)
  
else:
  print((H*W)//2)
N, M, K = map(int, input().split())

to = [[] for i in range(N)]
block = [[] for i in range(N)]
sets = []

for i in range(M):
    A, B = map(int, input().split())
    to[A-1].append(B-1)
    to[B-1].append(A-1)
    flg = False
    A_idx = None
    B_idx = None
    for tmp_idx, tmp_set in enumerate(sets):
        if A - 1 in tmp_set:
            A_idx = tmp_idx
        if B - 1 in tmp_set:
            B_idx = tmp_idx
        if A - 1 in tmp_set or B - 1 in tmp_set:
            flg = True
            tmp_set.add(A - 1)
            tmp_set.add(B - 1)

    if not flg:
        sets.append({A-1, B-1})
    elif A_idx != None and B_idx != None and A_idx != B_idx:
        for j in sets[B_idx]:
            sets[A_idx].add(j)
        sets.pop(B_idx)

for i in range(K):
    C, D = map(int, input().split())
    block[C-1].append(D-1)
    block[D-1].append(C-1)

for i in range(N):
    i_idx = -1
    for tmp_idx, tmp_set in enumerate(sets):
        if i in tmp_set:
            i_idx = tmp_idx
    l = len(sets[i_idx])
    m1 = len(to[i])
    
    m2 = 0
    for j in block[i]:
        if j in sets[i_idx]:
            m2 += 1

    if i != N-1:
        print(l - 1 - m1 - m2, end=' ')
    else:
        print(l - 1 - m1 - m2)

### FIXED CODE ###

import sys
sys.setrecursionlimit(4100000)

from collections import Counter

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

to = [[] for i in range(N)]
block = [[] for i in range(N)]
sets = []

is_visited = [False] * N
graph_g = [None] * N
graph_cnt = -1

def dfs(s, g):
    global graph_cnt
    if is_visited[s]:
        return 0

    is_visited[s] = True
    if g == None:
        graph_cnt += 1
        graph_g[s] = graph_cnt
    else:
        graph_g[s] = g

    for edge in to[s]:
        if graph_g[edge] == None:
            dfs(edge, graph_cnt)


for i in range(M):
    A, B = map(int, input().split())
    to[A-1].append(B-1)
    to[B-1].append(A-1)

for i in range(N):
    if is_visited[i]:
        continue
    dfs(i, None)

for i in range(K):
    C, D = map(int, input().split())
    if graph_g[C-1] == graph_g[D-1]:
        block[C-1].append(D-1)
        block[D-1].append(C-1)

ct = Counter(graph_g)

ret = []
for i in range(N):
    cand = ct[graph_g[i]]
    fri = len(to[i])
    tmp_block = len(block[i])

    tmp_ret = cand - fri - tmp_block - 1
    ret.append(tmp_ret)

print(*ret)
S = input()
strs = list(reversed(S))
rev_S = ''.join(strs)
while True:
  if rev_S[:6] == 'resare'
    rev_S = rev_S[6:]
    continue
  elif rev_S[:7] == 'remaerd':
    rev_S = rev_S[7:]
    continue
  elif rev_S[:5] == 'esare' or rev_S[:5] == 'maerd':
    rev_S = rev_S[5:]
    continue
  else:
    break

if rev_S == '':
  print('YES')
else:
  print('NO')

### FIXED CODE ###

S = input()
strs = list(reversed(S))
rev_S = ''.join(strs)
while True:
  if rev_S[:6] == 'resare':
    rev_S = rev_S[6:]
    continue
  elif rev_S[:7] == 'remaerd':
    rev_S = rev_S[7:]
    continue
  elif rev_S[:5] == 'esare' or rev_S[:5] == 'maerd':
    rev_S = rev_S[5:]
    continue
  else:
    break

if rev_S == '':
  print('YES')
else:
  print('NO')
N, M = map(int, raw_input().split())
A = map(int, raw_input().split())
rewritelist = []
for i in range(0, M):
	rewritelist.append(map(int, raw_input().split()))
A.sort()
rewritelist.sort(key = lambda val: val[1], reverse = True)
cardlist = []
for i in range(0, N):
	if rewritelist == []: break
	cardlist.append(rewritelist[0][1])
	rewritelist[0][0] -= 1
	if rewritelist[0][0] == 0: rewritelist.pop(0)
for i in range(0, len(cardlist)):
	if cardlist[i] <= A[i]: break
	A[i] = cardlist[i]
sum = 0
for i in range(0, N):
	sum += A[i]
print(sum)

### FIXED CODE ###

def smaller(x, y):
	if x < y: return x
	return y
def larger(x, y):
	if x > y: return x
	return y

N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
Asum = []
sum = 0
for i in range(0, N):
	sum += A[i]
	Asum.append(sum)
controllist = []
for i in range(0, M):
	controllist.append(list(map(int, input().split())))
controllist.sort(key = lambda v: v[1], reverse = True)
addlist = []
flag = False
for i in range(0, M):
	for j in range(0, controllist[i][0]):
		addlist.append(controllist[i][1])
		if len(addlist) == N:
			flag = True
			break
	if flag: break
sum = 0
for i in range(0, smaller(N, len(addlist))):
	sum += larger(A[i], addlist[i])
for i in range(len(addlist), N):
	sum += A[i]
print(sum)
ans = 0
H,W = map(int,input().split())
s = [list(input()) for _ in range(W)]

print(ans)

### FIXED CODE ###

H,W = map(int,input().split())
s = [list(input()) for _ in range(H)]
dp = [[0] * W for _ in range(H)]
dp[0][0] = int(s[0][0]=="#")

for i in range(1, W):
    dp[0][i] = dp[0][i-1] + (int(s[0][i]=="#") if s[0][i-1]=="." else 0)
for h in range(1,H):
  dp[h][0] = dp[h-1][0] + (int(s[h][0]=="#") if s[h-1][0]=="." else 0)
  for w in range(1,W):
    dp[h][w] = min(dp[h-1][w]+(int(s[h][w]=="#") if s[h-1][w]=="." else 0), 
    dp[h][w-1]+(int(s[h][w]=="#") if s[h][w-1]=="." else 0))
print(dp[-1][-1])
# encoding: utf-8

P_MAX = 100

num_and_pnt = lambda x: [int(x[0]), int(x[1]) // 100]

def mycounter(item, G):
    Gtmp = (item[1] + 1) * (item[2] - 1)
    p = item[2]
    for i in range(p):
        if Gtmp < G: break
        else:
            Gtmp -= (item[1] + 1)
            p -= 1
    return p

D, G = num_and_pnt(input().split())

# [flag, index, pi, ci]
pc = [[1, i] + num_and_pnt(input().split()) for i in range(D)]

cnt = 0
while True:
    # print(pc)
    # last point
    state = -1
    p_tmp = P_MAX
    for item in filter(lambda x: x[0] > 0, pc):
        Gtmp = (item[1] + 1) * item[2] + item[3]
        if G <= Gtmp:
            p = mycounter(item, G)
            if p < p_tmp:
                state = item[1]
                p_tmp = p
    # escape
    if state > -1:
        cnt += p_tmp
        break
    # completed point
    item = max(filter(lambda x: x[0] > 0, pc), key=lambda x: x[1] + x[3] / x[2])
    G -= (item[1] + 1) * item[2] + item[3]
    cnt += item[2]
    pc[item[1]][0] = 0
    
print(cnt)

### FIXED CODE ###

# encoding: utf-8
D_MAX = 10
P_MAX = 100

num_and_pnt = lambda x: [int(x[0]), int(x[1]) // 100]
D, G = num_and_pnt(input().split())
# [pi, ci]
pc = [num_and_pnt(input().split()) for i in range(D)]

G_list = [(i + 1) * x[0] + x[1] for i, x in enumerate(pc)]
cnt_list = [x[0] for i, x in enumerate(pc)]
idx = [map(int, format(i, "b")) for i in range(2 ** D)]

# i, G_comp, cnt_comp
table = [ (i, sum([((i // (2 ** j)) % 2) * G_list[j] for j in range(D)]), sum([((i // (2 ** j)) % 2) * cnt_list[j] for j in range(D)])) for i in range(2 ** D)] # very long
# print(table)
mincnt = D_MAX * P_MAX
for i, (G_last, cnt_last) in enumerate(zip(G_list, cnt_list)):
    for j, G_comp, cnt_comp in filter(lambda x: (((x[0] // (2 ** i)) % 2 == 0) and (x[1] <= G < x[1] + G_last) and (x[2] < mincnt)), table):
        # print(i, (G_last, cnt_last), j, G_comp, cnt_comp)
        cnt_last_tmp = min((-((G_comp - G) // (i + 1)), cnt_last))
        if cnt_comp + cnt_last_tmp < mincnt: mincnt = cnt_comp + cnt_last_tmp

print(mincnt)
#ABC070
n = int(input())
t = []
for i in range(n):
    t.append(int(input()))

def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)
def lcm(a,b):
    return int(a*b/gcd(a,b))

# a,b,cの最小公倍数→lcm(lcm(a,b),c)で表される

# t[i]の最小公倍数を求めればよい。
res=t[0]
for i in range(1,n):
    if res>=t[i]:
        res = lcm(res,t[i])
    else:
        res = lcm(t[i],res)
print(res)

### FIXED CODE ###

n = int(raw_input())

def gcd(a,b):
    if a > b:
        a,b = b,a
    # a <= b
    while a > 0:
        a,b = b%a, a
    return b

def lcm(a,b):
    g = gcd(a,b)
    return a/g * b

x = 1
for i in range(n):
    ti = int(raw_input())
    x = lcm(x, ti)

print x
import math
import sys
n, x, d = map(int, input().split())
if d < 0:
    d = -d
    x = -x
if d == 0:
    print(n+1 if x != 0 else 0)
    sys.exit()
g = math.gcd(d, x)
mod = d//g
hani = [[] for _ in range(n)]
for k in range(n+1):
    l = x*k+k*(k-1)//2*d
    r = x*k+k*(n*2-k-1)//2*d+d
    hani[k%mod].append((l, 0))
    hani[k%mod].append((r, 1))
ans = 0
for i in range(n):
    if not hani[i]:
        break
    hani[i].sort()
    cnt = 0
    l = None
    for a, f in hani[i]:
        if f == 0:#l
            if cnt == 0:
                l = a
            cnt+=1
        else:
            cnt-=1
            if cnt == 0:
                ans+=(a-l)//d
print(ans)

            





        

### FIXED CODE ###

from fractions import gcd
import sys
n, x, d = map(int, input().split())
if d < 0:
    d = -d
    x = -x
if d == 0:
    print(n+1 if x != 0 else 1)
    sys.exit()
g = gcd(d, x)
mod = abs(d//g)
hani = [[] for _ in range(n+1)]
for k in range(n+1):
    l = x*k+k*(k-1)//2*d
    r = x*k+k*(n*2-k-1)//2*d+d
    hani[k%mod].append((l, 0))
    hani[k%mod].append((r, 1))
ans = 0
for i in range(n+1):
    if not hani[i]:
        break
    hani[i].sort()
    cnt = 0
    l = None
    for a, f in hani[i]:
        if f == 0:#l
            if cnt == 0:
                l = a
            cnt+=1
        else:
            cnt-=1
            if cnt == 0:
                ans+=(a-l)//d
print(ans)
def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)
        
def lcm(a,b):
    res = int(a/gcd(a,b)*b)
    return res
    

n = int(input())

ans=1
for i in range(n):
    t = int(input())
    ans = lcm(ans,t)
    
print(ans)

### FIXED CODE ###

n = int(raw_input())

def gcd(a,b):
    if a > b:
        a,b = b,a
    # a <= b
    while a > 0:
        a,b = b%a, a
    return b

def lcm(a,b):
    g = gcd(a,b)
    return a/g * b

x = 1
for i in range(n):
    ti = int(raw_input())
    x = lcm(x, ti)

print x
import numpy as np
import math

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

l = np.zeros(N+1)

for i in range(1,N+1):
    l[i] = math.floor((A*i)/B) - A * math.floor(i/B)

print(int(np.max(l)))

### FIXED CODE ###

import numpy as np
import math

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

i = B-1

if i >= N:
  x = N
else:
  x = B-1

print(math.floor((A*x)/B) - A * math.floor((x/B)))
d=[0]*13
d[0]=1
mul=1
mulmod=1
t=input()[::-1]
mod=10**9+7
zero=[0]*13
l=len(t)
for n,c in enumerate(t):
    e=zero[:]
    if c=="?":
        for i in range(10):
            for j in range(13):
                k=(i*mulmod+j)%13
                e[k]+=d[j]
                e[k]%=mod
    else:
        for j in range(13):
            k=(i*mulmod+int(c)%13
            e[k]+=d[int(c)]
            e[k]%=mod
    d=e
    mul*=10
    mulmod=mul%13
print(d[5])
               

### FIXED CODE ###

# coding: utf-8
# Your code here!
 
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意
 
s = input()
l = len(s)
MOD = 10**9+7
 
dp = [0]*13
dp[0] = 1
for i in s:
    new = [0]*13
    if i == "?":
        for i in range(10):
            for j in range(13):
                new[(10*j+i)%13] += dp[j]
    else:
        i = int(i)
        for j in range(13):
            new[(i+10*j)%13] += dp[j]
    
    for i in range(13):
        new[i] %= MOD
    dp,new = new,dp
#    print(dp)
 
print(dp[5]%MOD)
import sys
from heapq import heappush, heappop

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
works = [[] for _ in range(M+1)]
#Bが報酬
for _ in range(N):
    a, b = lr()
    works[a].append(b)

cand = []
answer = 0
for i in range(1, M+1):
    for work in works[i]:
        heappush(cand, -work)
    if cand:
        answer -= heappop(cand)

print(answer)


### FIXED CODE ###

import heapq

n,m=map(int,input().split())
jobs=[[] for _ in range(m)]
for i in range(n):
    d,r=map(int,input().split())
    if d-1<m:
        jobs[d-1].append(-r)
rewards=0
heap=[]
for i in range(m):
    for reward in jobs[i]:
        heapq.heappush(heap,reward)
    if len(heap)>0:
        rewards+=-heapq.heappop(heap)

print(rewards)
N = input()
even = N // 2
print((N - even) / N)

### FIXED CODE ###

N = int(input())
even = N // 2
print((N - even) / N)
r,g,b = input().split()
print('YES' if r+g+b%4==0 else 'NO')

### FIXED CODE ###

c = input().split()
c = int(''.join(c))
if c % 4 == 0:
	print('YES')
else:
	print('NO')
N = int(input())
T = [[0,0,0]]+[map(int, input().split()) for _ in range(N)]
flag = 'Yes'
i = 0
while flag=='Yes' and i<len(T)-1:
    t1,x1,y1 = T[i] 
    t2,x2,y2 = T[i+1]
    dis = (x2-x1)+(y2-y1)
    _t = t2-t1
    if dis > _t or _t%2 != dis%2:
        flag = 'No'
    i += 1        
print(flag)
    

### FIXED CODE ###

N = int(input())
T = [[0,0,0]]+[ [int(x) for x in input().split()] for _ in range(N)]

flag = 'Yes'
i = 0
while flag=='Yes' and i<len(T)-1:
    t1,x1,y1 = T[i] 
    t2,x2,y2 = T[i+1]
    dis = abs(x2-x1)+abs(y2-y1)
    _t = t2-t1
    if dis > _t or _t%2 != dis%2:
        flag = 'No'
    i += 1        
print(flag)