Harryxun/stf_run huggingface dataset:
N=int(input())
LA=[0]*N
LB=[0]*N
for i in range(N):
    A,B=[int(x) for x in input().split()]
    LA[i]=A
    LB[i]=B

PA=0
PB=0

LD=[0]*N
for i in range(N):
    LD[i]=LA[i]+LB[i]

isRunned=True
while(isRunned):
    isRunned=False
    for i in range(N-1):
        if LD[i]<LD[i+1]:
            LD[i],LD[i+1]=LD[i+1],LD[i]
            LA[i],LA[i+1]=LA[i+1],LA[i]
            LB[i],LB[i+1]=LB[i+1],LB[i]
            isRunned=True
        

print(sum(LA[::2])-sum(LB[1::2]))


### FIXED CODE ###

N,A,B=input().split()
N=int(N)
A=int(A)
B=int(B)
if A+B-N<0:
    print(str(min(A,B))+" 0")
else:
    print(str(min(A,B))+" "+str(A+B-N))
import fractions
s=list(map(int,input().split()))
t=[int(i)//2 for i in input().split()]
ans = t[0]
a=0
for i in range(1,s[0]):
  ans=(ans*t[i])//fractions.gcd(ans,t[i])
  if i==1:
    if (int(ans/t[0])%2==0) or (int(ans/t[i])%2==0):
      print(0)
      a=1
  else:
    if (int(ans/t[i])%2==0):
      print(0)
      a=1
if a==0:
  if ans<=s[1]:
    print(int((s[1]//ans+1)//2))
  else:
    print(0)

### FIXED CODE ###

import fractions
s=list(map(int,input().split()))
t=[int(i)//2 for i in input().split()]
ans = t[0]
for i in range(1,s[0]):
  ans=(ans*t[i])//fractions.gcd(ans,t[i])
  if ans>10**10:
    print(0)
    exit()
for j in t:
  if (ans//j)%2==0:
    print(0)
    exit()
if ans<=s[1]:
  print(int((s[1]//ans+1)//2))
else:
  print(0)
N,M = map(int, input().split())
"""
if M == 0:
    print(-1)
    exit()
"""
pqcs = [list(map(int, input().split())) for _ in range(M)]
c_max = max(list(map(lambda x: x[2],pqcs)))
node_num = (c_max+1)*N
unsearached_nodes = list(range(node_num))#0～N-1(n-1)が乗換経由ノード/路線iの駅nは3*i+(n-1)番ノード
#opt_nodes = [-1]*node_num
distance = [float('inf')]*node_num
distance[0] = 0
cost = 0
edges = [[float('inf')]*node_num for _ in range(node_num)]
#辺へ重み付け
for p,q,c in pqcs:
    edges[3*c+(p-1)][3*c+(q-1)] = 0
    edges[3*c+(q-1)][3*c+(p-1)] = 0
    edges[p-1][3*c+(p-1)] = 1
    edges[q-1][3*c+(q-1)] = 1
    edges[3*c+(p-1)][p-1] = 0
    edges[3*c+(q-1)][q-1] = 0

while (distance[N-1] == float('inf')):
    temp_min_dist = float('inf')
    for unsearched_ind in unsearached_nodes:
        if temp_min_dist > distance[unsearched_ind]:
            temp_min_dist = distance[unsearched_ind]
            target_min_ind = unsearched_ind
    unsearached_nodes.remove(target_min_ind)
    target_node = edges[target_min_ind]
    flag = False
    for index, rota_dist in enumerate(target_node):
        if rota_dist != float('inf'):
            if distance[index] > distance[target_min_ind] + rota_dist:
                distance[index] = distance[target_min_ind] + rota_dist
                #opt_nodes[index] = target_min_ind

print(distance[N-1] if distnce[N-1] != float('inf') else -1)

### FIXED CODE ###

from collections import deque
N, M = map(int, input().split())
F_C_of_S = [{} for i in range(N)]
#Companies of Station
C_of_S = {}

#def Union-find
parent = [-1]*M
def root(x):
	if (parent[x] < 0): return x
	else:
		parent[x] = y = root(parent[x])
		return y

def unite(x, y):
	px = root(x)
	py = root(y)
	if (px == py): return False
	if (parent[px] > parent[py]):
		px = root(y)
		py = root(x)
	parent[px] += parent[py]
	parent[py] = px
	return True


#Union-find
pqcs = []
for i in range(M):
	p, q, c = map(int, input().split())
	p -= 1; q -= 1;
	pqcs += [(p, q, c)]
	
	#The first
	if not c in F_C_of_S[p]: F_C_of_S[p][c] = i
	#else
	else: unite(F_C_of_S[p][c], i)
	C_of_S.setdefault(p, set()).add(c)
	
	#The first
	if not (c in F_C_of_S[q]):F_C_of_S[q][c] = i
	#else
	else: unite(F_C_of_S[q][c], i)
	C_of_S.setdefault(q, set()).add(c)

#stations of company
S_of_C = {}
for i in range(M):
	p, q, c = pqcs[i]
	c_set = S_of_C.setdefault(root(i), set())
	c_set.add(p)
	c_set.add(q)


Q = deque([(0, 0, 0)])
#cost to go to the stations from station_0
dist = [float('inf')]*N
dist[0] = 0

gdist = [float('inf')]*M

while Q:
	cost, v, flag = Q.popleft()
	
	if not (flag):#(flag == 0) then gdist_update
		if (dist[v] < cost) or (v not in C_of_S):
			continue
		for l in F_C_of_S[v].values():
			l = root(l)
			if (cost < gdist[l]):
				gdist[l] = cost
				Q.appendleft((cost, l, 1))
	
	else:#(flag == 1) then dist_update
		if (gdist[v] < cost) or (v not in S_of_C):
			continue
		for s in S_of_C[v]:
			if (cost+1 < dist[s]):
				dist[s] = cost+1
				Q.append((cost+1, s, 0))

print(dist[N - 1] if dist[N - 1] < float('inf') else -1)
import statistics
import math
import numpy as np

N, K = map(int, input().split())
h = [int(input()) for i in range(N)]

h.sort()
median = statistics.median(h)
result = 10 ** 9

idx = np.abs(np.asarray(h) - median).argmin()
if h[idx] - h[idx-(K-1)] <= h[idx+(K-1)] - h[idx]:
    result = h[idx] - h[idx-(K-1)]
else:
    result = h[idx+(K-1)] - h[idx]
print(result)


### FIXED CODE ###

N, K = map(int, input().split())
h = [int(input()) for i in range(N)]
h.sort()
print(min(h[i+K-1] - h[i] for i in range(N-K+1)))
def f(c):
    """
    入力に対する勝ち手を出力
    """
    if c=="r":
        return "p"
    elif c=="s":
        return "r"
    else:
        return "s"

def main():
    """
    まずは全て勝つ組み合わせを作って、合計ポイントを求める。
    iを0からN-Kまで変化させ、T(i)=T(k+i)となる時、
    T(k+i)をT(i)、T(i+2K)と異なる手に変更する。
    ※T(i)を変更すると、T(i)=T(i+k)=T(i+2K)=...=と連続した時に、
    全て変更されてスコアが最大にならない。
    T(k+i)は勝ちから"あいこまたは負け"に変化するので、合計ポイントから差っ引く。
    """

    #input
    N,K=map(int,input().strip().split())
    R,S,P=map(int,input().strip().split())
    T=list(input())
    win_T=list(map(lambda x:f(x),T))
    point={"r":R,"s":S,"p":P}
    score=sum([point[win_T[n]] for n in range(N)])
    for i in range(N-K):
        l=["r","s","p"]
        if win_T[i]==win_T[i+K]:
            score-=point[win_T[i+K]]
            l.remove(win_T[i])
            if i<=N-2*K and win_T[i]!=win_T[i+2*K]:
                l.remove(win_T[i+2*K])
            win_T[i+K]=l[0]
    return score

if __name__=="__main__":
    print(main())

### FIXED CODE ###

def f(c):
    """
    入力に対する勝ち手を出力
    """
    if c=="r":
        return "p"
    elif c=="s":
        return "r"
    else:
        return "s"

def main():
    """
    まずは全て勝つ組み合わせを作って、合計ポイントを求める。
    iを0からN-Kまで変化させ、T(i)=T(k+i)となる時、
    T(k+i)をT(i)、T(i+2K)と異なる手に変更する。
    ※T(i)を変更すると、T(i)=T(i+k)=T(i+2K)=...=と連続した時に、
    全て変更されてスコアが最大にならない。
    T(k+i)は勝ちから"あいこまたは負け"に変化するので、合計ポイントから差っ引く。
    """

    #input
    N,K=map(int,input().strip().split())
    R,S,P=map(int,input().strip().split())
    T=list(input())
    
    win_T=list(map(lambda x:f(x),T))
    point={"r":R,"s":S,"p":P}
    score=sum([point[win_T[n]] for n in range(N)])
    for i in range(N-K):
        l=["r","s","p"]
        if win_T[i]==win_T[i+K]:
            score-=point[win_T[i+K]]
            l.remove(win_T[i])
            if i<=N-2*K-1 and win_T[i]!=win_T[i+2*K]:
                l.remove(win_T[i+2*K])
            win_T[i+K]=l[0]
    return score

if __name__=="__main__":
    print(main())
n,k=map(int,input().split())
A=sorted(list(map(int,input().split())) , key=abs , reverse=1)
import bisect as bi
# print(A)
# import numpy as np
# G=np.prod(A[:k])
def seki(A,mod=10**9+7):
    now=1
    for i in A:
        i=abs(i)
        if i>0 : now*=i
        # if i<0 : now*=i
        if i==0 :return 0
        if now>0 : now%=mod
    return now


# G=seki(A[:k])

mod=10**9+7
# if G>=0 : print(G%mod) ; exit()
if sum([A[i]>0 for i in range(n)])==0 and k%2==1:
  print((-seki(A[n-k:]))%mod) ;exit()
if n==k and len(A[bi.bisect_left(A,-1):])%2==1 :
    print((-seki(A))%mod) ;exit()
if sum([i<0 for i in A[:k]])%2==0 :
    print(seki(A[:k])%mod) ; exit()
  
  
# done=0 ; done2=0
# # ch=-73267983297 ; ch2=-9263498381621
# 
# for i in range(k-1,-1,-1):
#     if A[i]<0 and done==0:
#         for j in range(i+1,n):
#             if A[j]>=0: 
#                 # ch=G*A[j]//A[i]
#                 x1=A[j] ; y1=A[i]
#                 done=1
#                 break
#     if A[i]>0 and done2==0:
#         for j in range(i+1,n):
#             if A[j]<=0: 
#                 # ch2=G*A[j]//A[i]
#                 x2=A[j] ; y2=A[i]
#                 done2=1
#                 break
# #     if done==1 and done2==1 : break
# 
# G=seki(A[:k])
# G=-G
# if done and done2 :
#     if x1 * y2 > x2 * y1 :
#         print((G*x1//y1)%mod)
#     else:
#         print((G*x2//y2)%mod)
# elif done==1:
#     print((G*x1//y1)%mod)
# elif done2==1:
#     print((G*x2//y2)%mod)
        
CH=A[:k]
NO=A[k:]
done=0 ; done2=0
x1,x2,y1,y2=0,0,0,0
if sum([i<0 for i in CH])==0 : #CH全部+
    done=1
if sum([i<0 for i in NO])==0 : #NO全部+
    done2=1
if done==0:
    y1= [i for i in CH if i<0][-1]
    x1= [i for i in NO if i>0][0]
if done2==0:
    y2= [i for i in CH if i>0][-1]
    x2= [i for i in NO if i<0][0]

if x1 * y2 > x2 * y1 :
    print((-seki(CH)*x1//y1)%mod)
else:
    print((-seki(CH)*x2//y2)%mod)

### FIXED CODE ###

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

if K%2==1 and A[-1]<0:
    for i in range(K):
        ans=ans*A[N-(i+1)]%mod
    print(ans)
    exit()

l=0
r=N-1
if K%2==1:
    ans=ans*A[r]
    r-=1

for _ in range(K//2):
    ml=A[l]*A[l+1]
    mr=A[r]*A[r-1]
    if ml>mr:
        ans=ans*ml%mod
        l+=2
    else:
        ans=ans*mr%mod
        r-=2

print(ans)
# coding: utf-8
# Here your code !



for i in xrange(50):
    for j in xrange(50):
        dp[i][j] = 0
        
def solve(i,m):
    if dp[i][m] != -1:
        return dp[i][m]
    if m == 0:
        dp[i][m] = True
    elif i >= n:
        dp[i][m] = False
    elif solve(i+1, m):
        dp[i][m] = True
    elif solve(i+1, m-a[i]):
        dp[i][m] = True
    else:
        dp[i][m] = False
    return dp[i][m]

n = input()
a = map(int,raw_input().split())
q = input()
p = map(int,raw_input().split())
dp =[[-1]*1000]*1000

for i in xrange(0,q):
    if solve(0,p[i]):
        print "yes"
    else:
        print "no"

### FIXED CODE ###


        
def solve(i,m):
    if dp[i][m] != -1:
        return dp[i][m]
    if m == 0:
        dp[i][m] = True
    elif i >= n:
        dp[i][m] = False
    elif solve(i+1, m):
        dp[i][m] = True
    elif solve(i+1, m-a[i]):
        dp[i][m] = True
    else:
        dp[i][m] = False
    return dp[i][m]

n = input()
a = map(int,raw_input().split())
q = input()
p = map(int,raw_input().split())
dp = [[-1 for i in xrange(2001)] for j in xrange(21)]
for i in xrange(q):
    if solve(0,p[i]):
        print "yes"
    else:
        print "no"
N = int(input())
sum = 0
for i in range N:
  X = input().split()
  if X[1] == 'JPY':
    sum += float(X[0])
  else:
  	sum += float(X[0])*380000
print(sum)


### FIXED CODE ###

N = int(input())
sum = 0
for i in range (N):
  X = input().split()
  if X[1] == 'JPY':
    sum += float(X[0])
  else:
  	sum += float(X[0])*380000
print(sum)
def main():
	a,b,c = [int(x) for x in input().split()]
    a, b = b, a
    a, c = c, a
  	print(a, b, c)

main()

### FIXED CODE ###

def main():
	a,b,c = [int(x) for x in input().split()]
	a, b = b, a
	a, c = c, a
	print(a, b, c)
    
main()
N = int(input())
S = str(input())
if S[0:N/2] * 2 == S:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

N = int(input())
S = str(input())
if S[0:N//2] * 2 == S:
    print("Yes")
else:
    print("No")
n = int(input())
s = str(input())
alp = 'abcdefghijklmnopqrstuvwxyz' * 2
lst = []

for i in range(len(s)):

    lst.append(alp[alp.index(s[i])+n])

print(''.join(lst))

### FIXED CODE ###

n = int(input())
s = str(input())
alp = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'
ss = ''

for i in range(len(s)):

    ss += str(alp[alp.index(s[i])+n])

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

dist = []
for i in range(N-K+1): 
    l, r = x[i], x[i+k-1]
    t = min(abs(l)+abs(l-r), abs(r)+abs(r-l))
    dist.append(t)

print(min(dist))

### FIXED CODE ###

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

dist = []
for i in range(N-K+1): 
    l, r = x[i], x[i+K-1]
    t = min(abs(l)+abs(l-r), abs(r)+abs(r-l))
    dist.append(t)

print(min(dist))
import numpy as np
A = []
for i in range(3):
    A.append(list(map(int, input().split())))
A = np.array(A)

N = int(input())
 
for n in range(N):
    called_num = int(input())
    exist_list = [called_num in A[i] for i in range(3)]
    if True in exist_list:
      	called_row = exist_list.index(True)
    
    A[called_row] = [0 if x==called_num else x for x in A[called_row]]
    
sum_row = np.sum(A, axis=1)
sum_col = np.sum(A, axis=0)
sum_diag1 = np.diag(A).sum()
sum_diag2 = A[0][2] + A[1][1] + A[2][0] #良い実装が思いつかなかった
 
if 0 in sum_row or 0 in sum_col or 0 in [sum_diag1, sum_diag2]: #書き方イマイチ
    print('Yes')
else:
    print('No')

### FIXED CODE ###

import numpy as np
A = []
for i in range(3):
    A.append(list(map(int, input().split())))
A = np.array(A)

N = int(input())

for n in range(N):
    called_num = int(input())
    exist_list = [called_num in A[i] for i in range(3)]
    if True in exist_list:
        called_row = exist_list.index(True)
        A[called_row] = [0 if x==called_num else x for x in A[called_row]]
        
sum_row = np.sum(A, axis=1)
sum_col = np.sum(A, axis=0)
sum_diag1 = np.diag(A).sum()
sum_diag2 = A[0][2] + A[1][1] + A[2][0] #良い実装が思いつかなかった

if 0 in sum_row or 0 in sum_col or 0 in [sum_diag1, sum_diag2]: #書き方イマイチ
    print('Yes')
else:
    print('No')
import math
a,b,c,d=map(int, input().split()) 
count =0

i = ((b- a)//c)+1
j = ((b- a)//d)+1

f=math.gcd(c,d)
k = c*d//f

count = i + j - f

print(b-a+1-count)

### FIXED CODE ###

import fractions
a,b,c,d=map(int, input().split()) 

i = b//c- (a-1)//c
j = b//d- (a-1)//d

f=fractions.gcd(c,d)
f2= int(c * d / f)
k = b//f2 - (a-1)//f2

pot = i + j - k

print(b-(a-1)-pot)
def gcd(a, b):
    while b > 0:
        a, b = b, a % b
    return a




N = int(input())
A = [int(x) for x in input().split()]
a2 = A.copy()
max = 0
for i,_ in enumerate(A):
    A.pop(i)
    res = A[0]
    for i in A[1:]:
        res = gcd(res,i)
    max = res if res >= max else max
    A = list(a2)


print(max)

### FIXED CODE ###

def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)


gcdL = []
gcdR = []

N = int(input())
A = [int(x) for x in input().split()]
gcdL.append(0)
length_A = len(A)
for i in range(1,length_A):
    gcdL.append(gcd(A[i-1],gcdL[i-1]))


gcdR.append(0)
for i in range(1,length_A):
    gcdR.append(gcd(A[length_A-i],gcdR[i-1]))



list_gcd = []
for i in range(length_A):
        list_gcd.append(gcd(gcdL[i],gcdR[length_A-i-1]))

print(max(list_gcd))
a, b, c = map(int, input().split())
if a == b+c or b == a+c or c == a+b: print 'Yes'
else: print 'No'

### FIXED CODE ###

a, b, c = map(int, input().split())
if a == b+c or b == a+c or c == a+b: print('Yes')
else: print('No')
s = input()
a=0
b=0
for i in range(len(s)):
  if s[i]=='A':
    a = i
    break
for i in range(len(s),-1,-1):
  if s[i] == 'Z':
    b = i
    break
print(b-a+1)
  

### FIXED CODE ###

s = input()
a=0
b=0
for i in range(len(s)):
  if s[i]=='A':
    a = i
    break
for i in range(len(s)-1,-1,-1):
  if s[i] == 'Z':
    b = i
    break
print(b-a+1)
x, n = map(int, input().split())
if n > 0:
    P = list(map(int, input().split()))
    Q = sorted(
        [[i, abs(i - x)] for i in range(1, 101) if i not in P],
        key=lambda x:x[1])
    print(Q[0][0])
else:
    print(x)

### FIXED CODE ###

x, n = map(int, input().split())
if n > 0:
    P = list(map(int, input().split()))
else:
    P = []

ans, dist = 0, 1000
for i in range(-200, 200):
    if i not in P:
        if abs(i - x) < dist:
            dist = abs(i - x)
            ans = i
print(ans)
n = int(input())
for i in range(n):
    t, x, y = map(int, input().split())
    if x + y < t or (X + y + t) % 2:
        print("No")
        exit()
print("Yes") 

### FIXED CODE ###

n = int(input())
for i in range(n):
    t, x, y = map(int, input().split())
    if x + y > t or ((x + y) % 2 != t % 2):                                                                       
        print("No")
        exit()
print("Yes")
s=input()
if 'A','B' in s:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

s=input()
if 'A' in s and 'B' in s:
  print('Yes')
else:
  print('No')
def fibonacci(n):
    if n == 0:
        return 0
    elif n == 1:
        return 1
    return fibonacci_sub2(n-2, 1, 0)

def fibonacci_sub2(n, fibo_minus1, fibo_minus2):
    return fibo_minus1 if n==0 else fibonacci_sub2(n-1, fibo_minus1+fibo_minus2, fibo_minus1)

# from functools import lru_cache
# @lru_cache(maxsize=None)
# def fibonacci(n):
#     if n == 1:
#         return 0
#     elif n == 2:
#         return 1
#     else:
#         return fibonacci(n-1) + fibonacci(n-2)

N,M = map(int, input().split()) #1 2
if M != 0:
    a = [int(input()) for i in range(M)]
else:
    if N == 1:
        print(1)
        exit()
    else:
        print(fibonacci(N)%1000000007)
        exit()
ans = []
nstep = range(N)
preidx = 0

for idx,i in enumerate(a):
    if i - preidx == 1 and idx != 0:
        print(0)
        exit()
    if idx == 0 and i-preidx-1 != 0:
        ans.append([idx,max(0,i-preidx-1)])
    elif idx > 0:
        ans.append([idx,max(0,i-preidx-2)])
    preidx = i
else:
    if preidx != N:
        ans.append([idx,max(0,N-preidx-1)])

fibsum = 1
for idx,val in enumerate(ans):
    fibsum *= max(1,fibonacci(val[1] + 2))
    fibsum %= 1000000007 
print(fibsum)







### FIXED CODE ###

import sys
sys.setrecursionlimit(10000001)
def fibonacci(n):
    if n == 0:
        return 0
    elif n == 1:
        return 1
    n+=2
    return fibonacci_sub2(n-2, 1, 0)%1000000007

def fibonacci_sub2(n, fibo_minus1, fibo_minus2):
    return fibo_minus1%1000000007 if n==0 else fibonacci_sub2(n-1, (fibo_minus1+fibo_minus2)%1000000007, fibo_minus1%1000000007)%1000000007


N,M = map(int, input().split()) #1 2
if M != 0:
    a = [int(input()) for i in range(M)]
else:
    if N == 1:
        print(1)
        exit()
    else:
        print(fibonacci(N)%1000000007)
        exit()
ans = []
nstep = range(N)
preidx = 0

for idx,i in enumerate(a):
    if i - preidx == 1 and idx != 0:
        print(0)
        exit()
    if idx == 0 and i-preidx-1 != 0:
        ans.append([idx,max(0,i-preidx-1)])
    elif idx > 0:
        ans.append([idx,max(0,i-preidx-2)])
    preidx = i
else:
    if preidx != N:
        ans.append([idx,max(0,N-preidx-1)])

fibsum = 1
for idx,val in enumerate(ans):
    fibsum *= max(1,fibonacci(val[1]))
    fibsum %= 1000000007 
print(fibsum)
def factorize(n):
    b,e = 2,0
    fct = []
    while b*b <= n:
        while n%b==0:
            n//=b
            e+=1
        if e>0:
            fct.append((b,e))
        b+=1
        e=0
    if n!=1:
        fct.append((n,1))
    return fct
    
N,M = list(map(int,input().split()))
 
pl = factorize(M)
 
max_coef=max([p[1] for p in pl])
 
 
if max_coef==0:
    print(N)
else:
 
    comb_list = [1]
    c = 1
    mod = 10**9+7
    for i in range(max_coef):
        c *= N+i
        c *= pow(i+1,mod-2,mod)
        c %= mod
        comb_list.append(c)
 
    ans = 1
 
    for p in pl:
        ans*=comb_list[p[1]]
        ans %= mod
 
    print(ans)

### FIXED CODE ###

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

def factorize(n):
	fct = []  # prime factor
	b, e = 2, 0  # base, exponent
	while b * b <= n:
		while n % b == 0:
			n = n / b
			e = e + 1
		if e > 0:
			fct.append((b, e))
		b, e = b + 1, 0
	if n > 1:
		fct.append((n, 1))
	return fct

def comb(n,r):
	ans = 1
	for i in range(r):
		ans=ans*(n-i)
		ans=ans/(i+1)
	return ans%(10**9 + 7)

fct= factorize(M)

ans = 1

for f in fct:
	ans=(ans *comb(f[1]+N-1,f[1]))%(10**9+7)

print ans
from math import floor, ceil, sqrt, factorial, log, gcd
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop
from copy import deepcopy
import numpy as np
import sys
INF = float('inf')
mod = 10**9+7


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

# 1 2 3
# a, b, c = LI()


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I()


def I(): return int(sys.stdin.buffer.readline())

# abc def
# a, b = LS()


def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S()


def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2]


def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]]


def LIR(n): return [LI() for i in range(n)]

# 2
# abc
# def
# [abc, def]


def SR(n): return [S() for i in range(n)]

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]]


def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]]


def SRL(n): return [list(S()) for i in range(n)]


def main():
    n = I()
    h = list(LI())
    n = int(input())
    ans = h[0]
    for i in range(1, n):
        if h[i] > h[i-1]:
            ans += h[i] - h[i-1]
    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

from math import floor, ceil, sqrt, factorial, log, gcd
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop
import copy
import numpy as np
import sys
INF = float('inf')
mod = 10**9+7


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

# 1 2 3
# a, b, c = LI()


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I()


def I(): return int(sys.stdin.buffer.readline())

# abc def
# a, b = LS()


def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S()


def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2]


def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]]


def LIR(n): return [LI() for i in range(n)]

# 2
# abc
# def
# [abc, def]


def SR(n): return [S() for i in range(n)]

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]]


def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]]


def SRL(n): return [list(S()) for i in range(n)]


def main():
    n = I()
    h = list(LI())
    ans = h[0]
    for i in range(1, n):
        if h[i] > h[i-1]:
            ans += h[i] - h[i-1]
    print(ans)


if __name__ == "__main__":
    main()
s = input()
n = len(s)

s1 = s[:(n/2)]
s2 = s[(n/2):]

print( s1 == s2 ? 'Yes' : 'No')

### FIXED CODE ###

n = int(input())
s = str(input())

s1 = s[:(n//2)]
s2 = s[(n//2):]

print( 'Yes' if s1 == s2 else 'No')
while True:
    s = input()
    if s == '_': 
        break

   m = int(input())
   for mi in range(m):
       h = int(input())
       s = s[0] + s[1]


   print(s)

### FIXED CODE ###

while True:
    s =input()
    if s =='-':   break
    loop=int(input())
    for i in range(loop):
        ch=int(input())
 
        s = s[ch:]+s[:ch]
    print(s)
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
n=i1()
p=[]
q=[0 for i in range(n)]
for i in range(n):   
 p.append(i1())
 q[p[-1]-1]=i
k=1
s=0
while n-1>j:
  if q[i+1]-q[i]>0:
     k+=1
  else:
     s=max(s,k)
     k=1
  j+=1
s=max(s,k)
print(n-s)

### FIXED CODE ###

def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
n=i1()
p=[]
q=[0 for i in range(n)]
for i in range(n):   
 p.append(i1())
 q[p[-1]-1]=i
k=1
s=0
for i in range(n-1):
  if q[i+1]-q[i]>0:
     k+=1
  else:
     s=max(s,k)
     k=1
s=max(s,k)
print(n-s)
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
B = [list(map(int,input().split())) for _ in range(Q)]
numList = [0]*10**5
sum=0
for i in A:
    numList[i] += 1
    sum+=i



for i in range(Q):
    dev = B[i][1]-B[i][0]
    sum += numList[B[i][0]]*dev
    numList[B[i][1]] +=numList[B[i][0]]
    numList[B[i][0]] = 0
    print(sum)
    

### FIXED CODE ###

if str(input()).islower():
  print("a")
else:
  print("A")