Harryxun/stf_run huggingface dataset:
import numpy as np
import sys
read=sys.stdin.read

h,n,*ab=map(int,read().split())
a=np.array(ab[::2])
b=np.array(ab[1::2])

magic=np.zeros(h+1)
for i in range(1,1+h):
  magic[i]=np.min(dp[np.maximum(i-a, 0)]+b)
print(magic[h])

### FIXED CODE ###

import numpy as np
import sys
read=sys.stdin.read

h,n,*ab=map(int,read().split())
a=np.array(ab[::2])
b=np.array(ab[1::2])

magic=np.zeros(h+1,dtype=np.int64)
for i in range(1,1+h):
  magic[i]=np.min(magic[np.maximum(i-a, 0)]+b)
print(magic[h])
n = int(input())
lis = [[] for i in range(n)]

for i in range(n-1):
    u,v,w = map(int,input().split())
    lis[u-1].append((v-1,w%2))
    lis[v-1].append((u-1,w%2))

li = [-1] * n

def calc(i,c):
    li[i] = c
    for j, w in lis[i]:
        if li[j] < 0:
            calc(j, li[i]^w)

calc(0,0)
for d in li:
    print(d)

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

n = int(input())
lis = [[] for i in range(n)]

for i in range(n-1):
    u,v,w = map(int,input().split())
    lis[u-1].append((v-1,w%2))
    lis[v-1].append((u-1,w%2))

li = [-1] * n

def calc(i,c):
    li[i] = c
    for j, w in lis[i]:
        if li[j] < 0:
            calc(j, li[i]^w)

calc(0,0)

for d in li:
    print(d)
a = input().split()
b = int(a[0] + a[1])
c = -1
for(i = 1; i < 100100; i=(i+1)*(i+1))
  if(b == i): c = b
if(c != -1) :
  print('yes')
else :
  print('no')

### FIXED CODE ###

a = input().split()
if(int(a[0]) * int(a[1]) % 2 == 0):
  print('Even')
else:
  print('Odd')
while 1:
    M,T,P,R=map(int,input().split())
    if not M and not T and not P and not R:break
    d={i:[0,0] for i in range(1,T+1)}
    wa=[[0 for _ in range(P)] for _ in range(T)]
    for _ in range(R):
        m,t,p,j=map(int,input().split())
        if j:
            wa[t-1][p-1]+=20
        else:
            d[t][0]+=1
            d[t][1]+=(m+wa[t-1][p-1]) 
    rank=sorted(d.items(),key=lambda x:(x[1][0],-x[1][1]),reverse=True)        
    f=lambda x:"=".join(sorted(x,key=lambda y:int(y),reverse=True))
    l=[]
    b=[]
    for (i,j) in enumerate(rank):
        if i>0 and rank[i][1]!=rank[i-1][1]:
            l.append(f(b))
            b=[]
        b.append(str(j[0]))
    if b:l.append(f(b))
    print ",".join(l)



### FIXED CODE ###

while 1:
    M,T,P,R=map(int,input().split())
    if not M and not T and not P and not R:break
    d={i:[0,0] for i in range(1,T+1)}
    wa=[[0 for _ in range(P)] for _ in range(T)]
    for _ in range(R):
        m,t,p,j=map(int,input().split())
        if j:
            wa[t-1][p-1]+=20
        else:
            d[t][0]+=1
            d[t][1]+=(m+wa[t-1][p-1]) 
    rank=sorted(d.items(),key=lambda x:(x[1][0],-x[1][1]),reverse=True)        
    f=lambda x:"=".join(sorted(x,key=lambda y:int(y),reverse=True))
    l=[]
    b=[]
    for (i,j) in enumerate(rank):
        if i>0 and rank[i][1]!=rank[i-1][1]:
            l.append(f(b))
            b=[]
        b.append(str(j[0]))
    if b:l.append(f(b))
    print(",".join(l))
S = input()
T = input()

print(T+S)

### FIXED CODE ###

def main():
    S,T = map(str,input().split())
    print(T+S)
 
if __name__ == '__main__':
    main()
a,b,x = map(int, input().split())

elif a<=x and x<=a+b:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

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

if a<=x and x<=a+b:
    print("YES")
else:
    print("NO")
n = int(input())
p = [int(input()) for i in range(n)]

price = sum(p) - max(p) / 2
print(int(price)

### FIXED CODE ###

n = int(input())
p = [int(input()) for i in range(n)]

price = sum(p) - max(p) / 2
print(int(price))
from math import gcd
while True:
    try:
        a, b= map(int, input().split())
        print(gcd(a, b))
    except:
        break

### FIXED CODE ###

while True:
    try:
        a, b= map(int, input().split())
        while b!= 0:
            a, b= b, a%b
        print(a)
    except:
        break
import math

class DataSet():
    def __init__(self,a,b):
        self.a = a
        self.b = b

    def add_size(self):
        ans = self.a+self.b
        return int(math.log10(ans)+1)

def main():
    data_set = []

    for i in range(0, 200):
        n = input().split()

        a = int(n[0])
        b = int(n[1])

        data_set.append(DataSet(a,b))

    for i in range(0, 200):
        ans = data_set[i].add_size()
        print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

import math

def main():
    data = []
    while 1:
        try:
            n = input().split()
            a = int(n[0])
            b = int(n[1])
            ans = int(math.log10(a+b)+1)
            data.append(ans)
        except EOFError:
            break

    for i in data:
        print(i)

if __name__ == "__main__":
    main()
n = int(input())

s = input()
x = 0
ans = 0
for c in s:
  if c=='I'
  	x+=1
    ans = max(x,ans)
  else:
    x-=1
print(ans)

### FIXED CODE ###

n = int(input())

s = input()
x = 0
ans = 0
for c in s:
  if c=='I':
    x+=1
    ans = max(x,ans)
  else:
    x-=1
print(ans)
C = input()
print chr(ord(C) + 1)

### FIXED CODE ###

C = input()
print(chr(ord(C) + 1))
s = input()
L = [s[0], s[1], s[2]].sort().join()
print("Yes") if L == "abc" else print("No")


### FIXED CODE ###

s = input()
L = [s[0], s[1], s[2]]
L.sort()
S = "".join(L)
print("Yes") if S == "abc" else print("No")
# -*- coding: utf-8 -*-
import sys
k=int(input())
if k%2==0 or k%5==0:
  print(-1)
  sys.exit()
h=[-1]*k
s=7
for i in range(k):
  m=s%k
  if h[0]==m:
    l=i
    break
  h[i]=m
  s=m*10+7
for i in range(l):
  if h[i]==0:
    print(i+1)
    break

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
k=int(input())
if k%2==0 or k%5==0:
  print(-1)
  sys.exit()
s=7
for i in range(k):
  m=s%k
  if m==0:
    print(i+1)
    break
  s=m*10+7
s = input()
s[3] = 8
print(s)

### FIXED CODE ###

s = input()
ss = s.replace('2017', '2018')
print(ss)
import numpy as np
N = int(input())
A = list(map(int,input().split()))
costs = [0]*N
for i in range(N):
    tmp = A[:]
    A.pop(i)
    A.insert(0,0)
    A.append(0)
    #print(A)
    costs[i] = sum(np.abs(np.diff(A)))
    A = tmp
for i in range(len(costs)):
    print(costs[i])

### FIXED CODE ###

A = int(input())
B = int(input())
C = int(input())
D = int(input())
print(min(A,B)+min(C,D))
# import sys
# readline = sys.stdin.buffer.readline

# from collections import deque
# from copy import copy,deepcopy
# from itertools import permutations,combinations
# from pprint import pprint

# def myinput():
#     return map(int,input().split())

# def mycol(data,col):
#     return [ row[col] for row in data ]

# def mysort(data,col):
#     data.sort(key=lambda x:x[col],reverse=False)
#     return data

s = input()
t = input()

for i in reversed(range(len(s)-len(t)+1)):
    flag = False
    for j in range(len(t)):
        if j==(len(t)-1):
            if s[i+j]=="?":
                flag = True
            elif s[i+j]==t[j]:
                flag = True
            else:
                flag = False
        elif s[i+j]=="?":
            pass
        elif s[i+j]==t[j]:
            pass
        else:
            flag = False
            break
    if flag:
        break
    else:
        continue

if flag:
    pass
else:
    print("UNRESTORABLE")
    exit()

ans = list(s)

for l in range(len(t)):
    ans[i+l] = t[l]

ans = "".join(ans)

ans2 = ans.replace("?","a")
print(ans2)

### FIXED CODE ###

# import sys
# readline = sys.stdin.buffer.readline

# from collections import deque
# from copy import copy,deepcopy
# from itertools import permutations,combinations
# from pprint import pprint

# def myinput():
#     return map(int,input().split())

# def mycol(data,col):
#     return [ row[col] for row in data ]

# def mysort(data,col):
#     data.sort(key=lambda x:x[col],reverse=False)
#     return data

s = input()
t = input()
if len(s)<len(t):
    print("UNRESTORABLE")
    exit()

for i in reversed(range(len(s)-len(t)+1)):
    flag = False
    for j in range(len(t)):
        if j==(len(t)-1):
            if s[i+j]=="?":
                flag = True
            elif s[i+j]==t[j]:
                flag = True
            else:
                flag = False
        elif s[i+j]=="?":
            pass
        elif s[i+j]==t[j]:
            pass
        else:
            flag = False
            break
    if flag:
        break
    else:
        continue

if flag:
    pass
else:
    print("UNRESTORABLE")
    exit()

ans = list(s)

for l in range(len(t)):
    ans[i+l] = t[l]

ans2 = "".join(ans)

# if "?" in ans2:
ans3 = ans2.replace("?","a")
print(ans3)
A = int(input()) #ここで標準入力
B = float(input()) #ここで標準入力


output = A * B
print(int(output))

### FIXED CODE ###

from math import floor
from decimal import Decimal
a, b = input().split()
a = int(a)
b = Decimal(b)
print(floor(a * b))
a,op,b=map(int,input().split())
if op=="+":
  print(a+b)
else:
  print(a-b)

### FIXED CODE ###

a,op,b=input().split()
if op=="+":
  print(int(a)+int(b))
else:
  print(int(a)-int(b))
import math
import bisect
#[int(x) for x in input().split()]
#map(int,input().split())
#for _ in range(int(input())):
a,b=input().split()
a=int(a)
b=b.split('.')
b=int(b)

print(int(((a*b)/100)))

### FIXED CODE ###

import math
import bisect
#[int(x) for x in input().split()]
#map(int,input().split())
#for _ in range(int(input())):
a,b=input().split()
a=int(a)
b=list(b.split("."))
b=''.join(b)
b=int(b)

print(a*b//100)
li = [0]*26
alpha2num = lambda c: ord(c) - ord("A")
w = input().upper()
for i in range(len(w)):
  k = alpha2num(w[i])
  li[k] += 1
else:
  for j in li:
    if(not j %= 2):
      print("No")
      break
  else:
    print("Yes")

### FIXED CODE ###

li = [0]*26
alpha2num = lambda c: ord(c) - ord('A')
w = input().upper()
for i in range(len(w)):
  k = alpha2num(w[i])
  li[k] += 1
for j in li:
  if j % 2:
    print("No")
    break
else:
  print("Yes")
R,G,B,N=map(int,input().split())
ans=0
for i in range(N//R + 1):
  for j in range(N//G + 1)
  if R*i+G*j <= N:
    if (N - (R*i+G*j))%B==0:
      ans+=1
print(ans)

### FIXED CODE ###

R,G,B,N=map(int,input().split())
ans=0
for i in range(N//R + 1):
  for j in range(N//G + 1):
    if R*i+G*j <= N:
      if (N - (R*i+G*j))%B==0:
        ans+=1
print(ans)
H, W = map( int, input().split() )
S = [ list( input() ) for _ in range(H) ]


isVisited = [ [False]*W for _ in range(H) ]
dx = [1, -1, 0, 0]
dy = [0, 0, 1, -1]
# (i, j) から行けるペアの数
def dfs( x, y ):
    isVisited[x][y] = True
    numBlack, numWhite = 0, 0
    if S[x][y] == '#': numBlack = 1
    else:              numWhite = 1
    for i in range(4):
        nx = x + dx[i]
        ny = y + dy[i]
        if 0 <= nx and nx < H and 0 <= ny and ny < W and not isVisited[nx][ny]:
            if S[x][y] != S[nx][ny]:
                tmpB, tmpW = dfs( nx, ny )
                numBlack += tmpB
                numWhite += tmpW
    return numBlack, numWhite

ans = 0
for i in range(H):
    for j in range(W):
        if not isVisited[i][j]: 
            numBlack, numWhite = dfs( i, j )
            ans += numBlack * numWhite

print( ans )

### FIXED CODE ###

from sys import setrecursionlimit
setrecursionlimit(200000)

H, W = map( int, input().split() )
S = [ list( input() ) for _ in range(H) ]


isVisited = [ [False]*W for _ in range(H) ]
dx = [1, -1, 0, 0]
dy = [0, 0, 1, -1]
# (i, j) から行けるペアの数
def dfs( x, y ):
    isVisited[x][y] = True
    numBlack, numWhite = 0, 0
    if S[x][y] == '#': numBlack = 1
    else:              numWhite = 1
    for i in range(4):
        nx = x + dx[i]
        ny = y + dy[i]
        if 0 <= nx and nx < H and 0 <= ny and ny < W and not isVisited[nx][ny]:
            if S[x][y] != S[nx][ny]:
                tmpB, tmpW = dfs( nx, ny )
                numBlack += tmpB
                numWhite += tmpW
    return numBlack, numWhite

ans = 0
for i in range(H):
    for j in range(W):
        if not isVisited[i][j]: 
            numBlack, numWhite = dfs( i, j )
            ans += numBlack * numWhite

print( ans )
x = input()
ans = len(x)


def do(i, j):
    global ans
    if x[i] == 'S' and x[j] == 'T':
        ans -= 2
        if i > 0 and j < len(x) - 1:
            do(i-1, j+1)
    if j - i == 1 and j < len(x) - 1:
        do(i+1, j+1)


do(0, 1)
print(ans)


### FIXED CODE ###

X = input()

count = 0
count_s = 0
i = 0
while i < len(X):
    if i < len(X) - 1 and X[i] == 'S' and X[i+1] == 'T':
        count += 1
        i += 1
    elif X[i] == 'S':
        count_s += 1
    elif X[i] == 'T' and count_s > 0:
        count_s -= 1
        count += 1
    else:
        count_s = 0
    i += 1

count = min(count, 10 ** 10000)
print(len(X) - count * 2)
while True:
    n = int(input())
    if n == 0:
        break
    pre = ""
    post = ""
    for _ in range(n):
        l = map(str, input().split())
        pre += l[0]
        post += l[1]
    m = int(input())
    data = ""
    for _ in range(m):
        data += input()
    print(data.translate(str.maketrans(pre, post)))

### FIXED CODE ###

while True:
    n = int(input())
    if n == 0:
        break
    pre = ""
    post = ""
    for _ in range(n):
        l = input().strip().split()
        pre += l[0]
        post += l[1]
    m = int(input())
    data = ""
    for _ in range(m):
        data += input().strip()
    print(data.translate(str.maketrans(pre, post)))
A, B, C, D = (int(x) for x in input().split())
ans = min(B, D) - max(A - C)
if ans < 0:
    ans = 0
print(ans)

### FIXED CODE ###

A, B, C, D = (int(x) for x in input().split())
ans = min(B, D) - max(A, C)
if ans < 0:
    ans = 0
print(ans)
n=int(input())

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

a.sort()

if a[0] == a[1]:
    ans = 0
else:
    ans = 1

for i in range(1,n):
    flag = True
    for j in range(i):
        if a[i] % a[j] == 0:
            flag = False
            break
    if flag:
        ans += 1
print(ans)

### FIXED CODE ###

n = int(input())
a = sorted(list(map(int, input().split())))
if n == 1:
    print(1)
    exit()  
check_list = [0] * (10**6 + 2)
ans = 0
for i in range(n):
    tmp = a[i]
    while tmp <= a[-1]:
        check_list[tmp] += 1
        tmp += a[i]
for aa in a:
    if check_list[aa] == 1:
        ans += 1
print(ans)
N = int(input())
Y = int(input())
exist_flag = False
for i in range(N+1):
    for j in range(N+1):
        for k in range(N+1):
            if not i+j+k == N:
                continue
            if Y == 10000*i + 5000*j + 1000*k:
                exist_flag = True
                break
        if exist_flag:
            break
    if exist_flag:
        break
if not exist_flag:
    i,j,k = -1, -1, -1
print(i, j, k)

### FIXED CODE ###

N,Y = map(int,input().split())
exist_flag = False
for i in range(N+1):
    for j in range(N+1-i):
        if Y == 10000*i + 5000*j + 1000*(N-i-j):
            exist_flag = True
            break
    if exist_flag:
        break
if not exist_flag:
    print(-1, -1, -1)
else:
    print(i, j, N-i-j)
N,K=map(int,input().split())
A=list(map(int,input.split()))

ans=1
X=N-K

while X>0:
  X-=K-1
  ans+=1
print(ans)

### FIXED CODE ###

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

ans=1
X=N-K

while X>0:
  X-=K-1
  ans+=1
print(ans)
import numpy as np

s = list(str(input()))
t = list(str(input()))

_, s_c = np.unique(s, return_counts=True)
_, t_c = np.unique(t, return_counts=True)
if np.array_equal(s_c, t_c):
	print('Yes')
else:
	print('No')

### FIXED CODE ###

import numpy as np
from string import ascii_lowercase
s = list(input())
t = list(input())

s_c = []
t_c = []

for a in ascii_lowercase:
  if s.count(a) != 0:
    s_c.append(s.count(a))
  if t.count(a) != 0:
    t_c.append(t.count(a))

if np.array_equal(sorted(s_c), sorted(t_c)):
	print('Yes')
else:
	print('No')
import math,sys,bisect,heapq
from collections import defaultdict,Counter,deque
from itertools import groupby,accumulate
#sys.setrecursionlimit(200000000)
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda: map(int,input().split())
alele = lambda: list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
#def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
MOD = 1000000000 + 7
def Y(c):  print(["NO","YES"][c])
def y(c):  print(["no","yes"][c])
def Yy(c):  print(["No","Yes"][c])
      
def fun(S1,S2,n,m,dp):
    if n == 0 or m == 0:
        return ""
    if dp.get((n,m),-1) != -1:
        return dp[(n,m)]
    else:
        if S1[n-1] == S2[m-1]:
            dp[(n,m)] =  S1[n-1] + fun(S1,S2,n-1,m-1,dp)
        else:
            a = fun(S1,S2,n-1,m,dp)
            b= fun(S1,S2,n,m-1,dp)
            if len(a) > len(b):
                dp[(n,m)] = a
            else:
                dp[(n,m)] = b
        return dp[(n,m)]

S1 = input()
S2 = input()
n = len(S1)
m = len(S2)
s = ""
dp = {}
print(fun(S1,S2,n,m,dp)[::-1])

### FIXED CODE ###

import math,sys,bisect,heapq
from collections import defaultdict,Counter,deque
from itertools import groupby,accumulate
#sys.setrecursionlimit(200000000)
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda: map(int,input().split())
alele = lambda: list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
#def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
MOD = 1000000000 + 7
def Y(c):  print(["NO","YES"][c])
def y(c):  print(["no","yes"][c])
def Yy(c):  print(["No","Yes"][c])
      
def fun(A,B,m,n,dp):
    for i in range(1,m+1):
        for j in range(1,n+1):
            if A[i-1] == B[j-1]:
                dp[i][j] = 1 + dp[i-1][j-1]
            else:
                dp[i][j] = max(dp[i][j-1],dp[i-1][j])
    return dp
                
def longestsub(A,B):
    m = len(A)
    n = len(B)
    if m==0 or n==0:
        return ""
    temp = [0]*(n+1)
    dp = [temp.copy() for i in range(m+1)]
    d = fun(A,B,m,n,dp)
    i= m;j = n;Ans = ""
    while i>0 and j>0:
        if A[i-1] == B[j-1]:
            Ans += A[i-1]
            i-=1;j-=1
        else:
            a = d[i][j-1] ; b =d[i-1][j]
            if a > b:
                j-=1
            else:
                i-=1
    return Ans[::-1]

A = input()
B = input()
print(longestsub(A,B))
import sys
from collections import deque
input = sys.stdin.readline
n = int(input())
hL = list(map(int, input().split()))
flag = 'Yes'
for i in range(n-1):
    for j in range(i+1, n) :
        if hL[i] -hL[j]>=2:
            flag = 'No'
            break
    if flag =='No':
        break
print(flag)

### FIXED CODE ###

import sys
input = sys.stdin.readline
limit, nowl, addl = map(int, input().split())
print(max(0, nowl+addl-limit))
A, B = list(map(int, input().split()))

def xorsum(m):
  if m==3:
    return 0
  if m==2:
    return 3
  if m==1:
    return 1
  if m==0:
    return 0
  h = 2 ** math.floor(math.log2(m))
  return xorsum(m-h)^(((m-h+1)%2)*h)
print(xorsum(B)^xorsum(A-1))

### FIXED CODE ###

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

def xorsum(m):
  if m==3:
    return 0
  if m==2:
    return 3
  if m==1:
    return 1
  if m==0:
    return 0
  if m==-1:
    return 0
  h=1
  while h<=m:
    h=h*2
  h=h//2
  return xorsum(m-h)^(((m-h+1)%2)*h)

print(xorsum(B)^xorsum(A-1))
n,q=map(int,input().split())
d = {}
ans = [0]*(n+1)
for i in range(n-1):
    sta,gol = map(int,input().split())
    if sta not in d:
        d[sta] = set() 
    d[sta].add(gol)

#print(d)
    
def cal_(ans_,sta_,val_):
    ans_[sta_]+=val_
    if sta_ in d:
        targetset = d[sta_]
        for t in targetset:
            ans_ = cal_(ans_,t,val_)
    return ans_

for i in range(q):
    sta,val = map(int,input().split())
    ans = cal_(ans,sta,val)
    
for i in range(n):
    print(ans[i+1], " ",end="")

### FIXED CODE ###

n,q=map(int,input().split())
d = {}
ans = [0]*(n+1)
for i in range(n-1):
    sta,gol = map(int,input().split())
    d[gol] = sta

for i in range(q):
    sta,val = map(int,input().split())
    ans[sta]+=val
    

for i in range(n):
    gol = i+1
    if gol in d:
        ans[gol]+=ans[d[gol]]
    

for i in range(n):
    print(ans[i+1], " ",end="")
l = [abs(a-(t-i*0.006)) for i in h]
print(l.index(min(l))+1)

### FIXED CODE ###

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

l = [abs(a-(t-i*0.006)) for i in h]
print(l.index(min(l))+1)
mod=10**9+7
r1,c1,r2,c2=map(int,input().split())

FACT=[1]
for i in range(1,2*10**6+1):
    FACT.append(FACT[-1]*i%mod)

FACT_INV=[pow(FACT[-1],mod-2,mod)]
for i in range(2*10**6,0,-1):
    FACT_INV.append(FACT_INV[-1]*i%mod)

FACT_INV.reverse()

def Combi(a,b):
    if 0<=b<=a:
        return FACT[a]*FACT_INV[b]*FACT_INV[a-b]%mod
    else:
        return 0

ANS=0

for x in range(c1+1,c2+2):
    ANS=(ANS+Combi(r2+x,r2)-Combi(r1+x-1,r1-1))%mod

print(ANS)


### FIXED CODE ###

mod=10**9+7
r1,c1,r2,c2=map(int,input().split())

FACT=[1]
for i in range(1,2*10**6+3):
    FACT.append(FACT[-1]*i%mod)

FACT_INV=[pow(FACT[-1],mod-2,mod)]
for i in range(2*10**6+2,0,-1):
    FACT_INV.append(FACT_INV[-1]*i%mod)

FACT_INV.reverse()

def Combi(a,b):
    if 0<=b<=a:
        return FACT[a]*FACT_INV[b]*FACT_INV[a-b]%mod
    else:
        return 0

ANS=0

for x in range(c1+1,c2+2):
    ANS=(ANS+Combi(r2+x,r2)-Combi(r1+x-1,r1-1))%mod

print(ANS)
apple = int(input('りんごの個数') * 3)
piece = int(input('りんごの破片の数'))

apple_pie = (apple + piece) // 2
print(apple_pie)

### FIXED CODE ###

A, P = [int(i) for i in input().split()]
print((A * 3 + P) // 2)
import math

# input d:距離（メートル） , t:待ち合わせまで何分 , s:速度（分速sメートル）
d, t, s = map(int, input().split())

output = "";

if d/s >= s:
    if math.ceil(d/s) = s:
        output = "Yes"
    else:
        output = "No"
else:
    output = "Yes"

print(output)


### FIXED CODE ###

import math

# input d:距離（メートル） , t:待ち合わせまで何分 , s:速度（分速sメートル）
d, t, s = map(int, input().split())

output = "";

if d/s > t:
    output = "No"
else:
    output = "Yes"

print(output)
h, W = map(int,input().split())
if h % 2 != 0:
    if W % 2 != 0:
        ans = ((h-1)*W//2)+(W//2+1)
else:
    ans = (h*W)//2
print(ans)

### FIXED CODE ###

K = int(input())
list_k =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

print(list_k[K-1])
H,W = [int(x) for x in input().split()]
S = ['#'*(W+2)]+['#'+input()+'#' for _ in range(H)]+['#'*(W+2)]
#%%
di_w = {}
di_h = {}
cnt_w = 0
cnt_h = 0
ans = 0
li = [[[-1 for _ in range(2)] for _ in range(W+2)]for _ in range(H+2)]

for h,s in enumerate(S):
    for w,c in enumerate(s):
        if(c=='#'):
            cnt_w += 1
            cnt_h += 1
        else:
            if(li[h-1][w][0]==-1):
                li[h][w][0] = cnt_h
                di_h[cnt_h] = 1
            else:
                li[h][w][0] = li[h-1][w][0]
                di_h[li[h][w][0]] += 1

            if(li[h][w-1][1]==-1):
                li[h][w][1] = cnt_w
                di_w[cnt_w] = 1
            else:
                li[h][w][1] = li[h][w-1][1]
                di_w[li[h][w][1]] += 1
        cnt_h+=1

for h,s in enumerate(S):
    for w,c in enumerate(s):
        if(c=='#'):
            pass
        else:
            ans = max(ans,di_h[li[h][w][0]]+di_w[li[h][w][1]]-1)

print(ans)


### FIXED CODE ###

li = [int(x) for x in input().split()]
print(min(li[0]+li[1],li[1]+li[2],li[0]+li[2]))
import math
n = int(input())

leng = int(math.log(n, 26))
org = leng
res = []
for i in reversed(range(leng)):
    leng = int(math.log(n, 26))
    num = n // 26**leng
    dum = n % 26**leng
    if dum == 0:
        res=('z'*org)
    else:
        res.append(chr(96+num))
    n -= 26**leng*num

if n%26 != 0:
    res.append(chr(96+n%26))

print(''.join(res))

### FIXED CODE ###

n = int(input())
ans = ''
while n != 0:
    n -= 1
    ans += chr(ord('a') + n % 26)
    n //= 26
print(ans[::-1])
N, K = map(int,input().split())
x = list(map(int,input().split()))

MIN = float("inf")
for i in range(N-K+1):
	l = i
	r = i + K - 1
		cur1 = 2*abs(x[l]) + abs(x[r]-x[l])
		cur2 = abs(x[l]) + 2*abs(x[r]-x[l])
#		print([l,r,cur1,cur2])
		if cur1 < MIN:
			MIN = cur1
		if cur2 < MIN:
			MIN = cur2
print(MIN)





### FIXED CODE ###

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

MIN = float("inf")
for i in range(N-K+1):
	l = i
	r = i + K - 1
	cur1 = abs(x[l]) + abs(x[r]-x[l])
	cur2 = abs(x[r]) + abs(x[r]-x[l])
#	print([l,r,cur1,cur2])
	if cur1 < MIN:
		MIN = cur1
	if cur2 < MIN:
		MIN = cur2
print(MIN)
n,w=map(int,input().split())
print(n*w(n*w-1) /2)

### FIXED CODE ###

n,w=map(int,input().split())
print((n*(n-1)//2)+(w*(w-1)//2))