Harryxun/stf_run huggingface dataset:
n,m=map(int,input().split())
sc=[list(map(int,input().split())) for _ in range(m)]
for i in range(1,m):
  for j in range(i+1,m+1):
    if sc[i-1][0]==sc[j-1][0] and sc[i-1][1]!=sc[j-1][1]:
      print(-1)
      exit()
 
for t in range(1,m+1):
  if sc[t-1][0]>=2 and sc[t-1][1]==0:
    print(-1)
    exit()
 
for i in range(1,m):
  for j in range(i+1,m+1):
    if sc[i-1][0]==sc[j-1][0] and sc[i-1][1]==sc[j-1][1]:
      sc.remove(sc[i-1])
 
ans=[]
sc.sort(key=lambda x:x[0])
for t in range(1,m+1):
  ans.append(sc[t-1][1])
print(*ans,sep='')

### FIXED CODE ###

n,m=map(int,input().split())
sc=[list(map(int,input().split())) for _ in range(m)]
for i in range(1,m):
  for j in range(i+1,m+1):
    if sc[i-1][0]==sc[j-1][0] and sc[i-1][1]!=sc[j-1][1]:
      print(-1)
      exit()
 
for t in range(1,m+1):
  if n>=2 and sc[t-1]==[1,0]:
    print(-1)
    exit()
 
ans=[0]*n
for t in range(1,m+1):
  if ans[sc[t-1][0]-1]==0:
    ans[sc[t-1][0]-1]+=sc[t-1][1]
    
if ans[0]==0 and n>=2:
  ans[0]=1
print(*ans,sep='')
import sys
n = int(input())
h = [input() for i in range(n)]
for k in range(n-1):
    if h[k+1]==h[k]-1:
        h[k+1]=h[k]+1
    elif h[k+1]>h[k]:
        continue
    else:
        print('No')
        sys.exit()
print('Yes')

### FIXED CODE ###

import sys
n = int(input())
h = list(map(int,input().split()))
for k in range(n-1):
    if h[k+1]==h[k]-1:
        h[k+1]=h[k+1]+1
    elif h[k+1]>=h[k]:
        continue
    else:
        print('No')
        sys.exit()
print('Yes')
import sys

x, n = map(int, input().split())
p = list(map(int, input().split()))
flag = [False]*100
for i in p:
    flag[i-1] = True
for j in range(0, n+1):
    l = max(0, x-1-j)
    r = min(100, x-1+j)
    if not flag[l]:
        print(l+1)
        sys.exit()
    if not flag[r]:
        print(r+1)
        sys.exit()

### FIXED CODE ###

import sys

x, n = map(int, input().split())
p = list(map(int, input().split()))
flag = [False]*102
for i in p:
    flag[i] = True
for j in range(0, 102):
    l = max(0, x-j)
    r = min(101, x+j)
    if not flag[l]:
        print(l)
        sys.exit()
    if not flag[r]:
        print(r)
        sys.exit()
import sys, math
step = [1,1,2,4] + [0]*26
for i in range(4,31):
  step[i] = step[i-1] + step[i-2] + step[i-3]

for s in sys.stdin:
  n = int(s)
  if n == 0: break
  print int(math.ceil(step[n]/3650.0))

### FIXED CODE ###

import math

steps=[1, 1, 2, 4]+ [0]*27
for i in range(4, 31):
  steps[i] = steps[i-1] + steps[i-2] + steps[i-3]

while True:
  n = input()
  if n == 0: break
  print int(math.ceil(steps[n]/3650.0))
from functools import lru_cache


a = int(input())
b = input()
X = b.count("1")
ans1 = []
ans2 = []

@lru_cache(maxsize=None)
def func1(c):
    x = X + 1
    if x == 0:
        return 0
    n = 1
    nsum = 0
    for i in reversed(range(len(c))):
        ans1.append(n)
        nsum += n * int(c[i])
        n = n % x if n > x else n
        n *= 2
    return nsum
    
@lru_cache(maxsize=None)
def func2(c):
    x = X - 1
    if x == 0:
        return 0
    n = 1
    nsum = 0
    for i in reversed(range(len(c))):
        ans2.append(n)
        nsum += n * int(c[i])
        n = n % x if n > x else n
        n *= 2
    return nsum    

def func(c):
    x = c.count("1")
    if x == 0:
        return 0
    n = 1
    nsum = 0
    for i in reversed(range(len(c))):
        nsum += n * int(c[i])
        n = n % x if n > x else n
        if n == 0:
            break
        n *= 2
    nsum %= x
    cans = bin(nsum).count("1")
    if cans == 0:
        return 1
    else:
        return 1 + func(bin(nsum)[2:])
    
allans1 = func1(b)
allans2 = func2(b)
ans1 = ans1[::-1]
ans2 = ans2[::-1]
c = list(b)
for i in range(a):
    if c[i] == "0":
        ans = (allans1 + ans1[i]) % (X + 1)
        ans = func(bin(ans)[2:]) + 1
        print(str(ans))
    else:
        ans = (allans2 - ans2[i]) % (X - 1)
        ans = func(bin(ans)[2:]) + 1
        print(str(ans))



### FIXED CODE ###

from functools import lru_cache


a = int(input())
b = input()
X = b.count("1")
ans1 = []
ans2 = []

@lru_cache(maxsize=None)
def func1(c):
    x = X + 1
    n = 1
    nsum = 0
    for i in reversed(range(len(c))):
        ans1.append(n)
        nsum += n * int(c[i])
        n = n % x if n > x else n
        n *= 2
    return nsum
    
@lru_cache(maxsize=None)
def func2(c):
    x = X - 1
    if x == 0:
        return 0
    n = 1
    nsum = 0
    for i in reversed(range(len(c))):
        ans2.append(n)
        nsum += n * int(c[i])
        n = n % x if n > x else n
        n *= 2
    return nsum    

def func(c):
    x = c.count("1")
    if x == 0:
        return 0
    n = 1
    nsum = 0
    for i in reversed(range(len(c))):
        nsum += n * int(c[i])
        n = n % x if n > x else n
        if n == 0:
            break
        n *= 2
    nsum %= x
    cans = bin(nsum).count("1")
    if cans == 0:
        return 1
    else:
        return 1 + func(bin(nsum)[2:])
    
allans1 = func1(b)
allans2 = func2(b)
ans1 = ans1[::-1]
if allans2 == 0:
    ans2 = [0] * a
else:
    ans2 = ans2[::-1]

c = list(b)
for i in range(a):
    if c[i] == "0":
        ans = (allans1 + ans1[i]) % (X + 1)
        ans = func(bin(ans)[2:]) + 1
        print(str(ans))
    else:
        if allans2 - ans2[i] == 0 and X - 1 == 0:
            print("0")
        else:
            ans = (allans2 - ans2[i]) % (X - 1)
            ans = func(bin(ans)[2:]) + 1
            print(str(ans))
import math
import numpy as np


def main():
    N = int(input())
    SP = [list(input().split()) + [i + 1] for i in range(N)]
    SP.sort(key=lambda x: (x[0], -int(x[1])))
    _SP = np.array(SP)
    for i in _SP[:, 2]:
        print(i)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import math


def main():
    N = int(input())
    SP = [list(input().split()) + [i + 1] for i in range(N)]
    SP.sort(key=lambda x: (x[0], -int(x[1])))
    for i in map(lambda x: x[2], SP):
        print(i)


if __name__ == '__main__':
    main()
import sys
import math
import itertools
import numpy

rl = sys.stdin.readline

n, m = map(int, rl().split())
li = [[] for _ in range(m)]
for _ in range(m):
  a, b = map(int, rl().split())
  a -= 1
  b -= 1
  li[a].append(b)
  li[b].append(a)

marks = [-1]*n
marks[0] = 0
def dfs(x):
  for nr in li[x]:
    if marks[nr] == -1:
      marks[nr] = x
      dfs(nr)
  
dfs(0)
if -1 in marks:
  print('No')
else:
  print('Yes')
  for i in marks[1:]:
    print(i+1)


### FIXED CODE ###

import sys
import math
import itertools
import numpy

rl = sys.stdin.readline

n, m = map(int, rl().split())
li = [[] for _ in range(m+1)]
for _ in range(m):
  a, b = map(int, rl().split())
  a -= 1
  b -= 1
  li[a].append(b)
  li[b].append(a)

marks = [-1]*n
stack = [0]
while stack:
    for next_room in li[stack[0]]:
        if marks[next_room] == -1:
            stack.append(next_room)
            marks[next_room] = stack[0]
    del stack[0]
if -1 in marks:
  print('No')
else:
  print('Yes')
  for i in marks[1:]:
    print(i+1)
import numpy as np

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

B = np.zeros(11 * 10**8, dtype = "uint32")

ans = 0

for index, A in enumerate(As):
    if(index - A >= 0):
        ans += B[index-A]

    B[index+A] += 1
#    print(list(B[:20]))

print(ans)


### FIXED CODE ###

from collections import defaultdict
import numpy as np
import collections

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

B = defaultdict(int)

ans = 0

for index, A in enumerate(As):
    ans += B[index-A]
    
    B[index+A] += 1
#    print(B)
#    print(list(B[:20]))

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

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

L = [list(map(int, input().split())) for _ in range(K)]

S = []

for left, right in L:
    S.extend(range(left, right+1))

S = sorted(list(set(S)))

n_list = [0] * N
n_list[0] = 1

for idx, value in enumerate(n_list):
    if value == 0:
        continue
    if S[0] + idx >= N:
        break
    for s in S:
        next_idx = s + idx
        if next_idx >= N:
            break
        n_list[next_idx] += value

print(n_list[-1] % 998244353)


### FIXED CODE ###

import sys
input = sys.stdin.readline

N = int(input())

count = 0
for i in range(1, N+1):
    count += (N - 1) // i
print(count)
pi = 3.14159265368979
r = int(input())
print('{} {}'.fomrat(2*pi*r,pi*r*r))

### FIXED CODE ###

import math
r = float(input())
print('{} {}'.format(math.pi*r*r,2*math.pi*r))
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

a,b,x = I()

if a**2*b <= 2*x:
  ama = a**2*b-x
  ran = 2*ama/(a**2)
  print(90-180/math.pi*math.atan(a/ran))
else:
  ran = 2*x/(a*b)
  print(90-180/math.pi*math.atan(ran/b))

### FIXED CODE ###

import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

a,b,x = I()

if (a**2*b)<=2*x:
    c = 2*(a**2*b-x)/a**3
else:
    c = (a*b**2)/(2*x)

print(math.degrees(math.atan(c)))
H, W, M=map(int, input().split())


L=[[0]*W for _ in range(H)]
for i in range(M):
    h,w=map(int, input().split())
    L[h-1][w-1]=1

rui1=[[0]*W for _ in range(H)]
rui2=[[0]*W for _ in range(H)]

for h in range(H):
    for w in range(W):
        if h==0 and w==0:
            rui1[h][w]=L[h][w]
            rui2[-1-h][-1-w]=L[-1-h][-1-w]
        elif h==0:
            rui1[h][w]=L[h][w]+rui1[h][w-1]
            rui2[-1-h][-1-w]=L[-1-h][-1-w]+rui2[-1-h][-w]
        elif w==0:
            rui1[h][w]=L[h][w]+rui1[h-1][w]
            rui2[-1-h][-1-w]=L[-1-h][-1-w]+rui2[-h][-1-w]

        else:
            rui1[h][w]=L[h][w]+rui1[h-1][w]+rui1[h][w-1]-rui1[h-1][w-1]
            rui2[-1-h][-1-w]=L[-1-h][-1-w]+rui2[-h][-1-w]+rui2[-1-h][-w]-rui2[-h][-w]

ans=0
for h in range(H):
    for w in range(W):
        now=rui1[h][w]+rui2[h][w]-L[h][w]
        if h!=0 and w!=0:
            now-=rui1[h-1][w-1]
        if h!=H-1 and w!=W-1:

            now-=rui2[h+1][w+1]

        ans=max(ans, now)
print(ans)
#print(rui1)
#print(rui2)

### FIXED CODE ###

from collections import defaultdict
H,W,M=map(int, input().split())

hs=[0]*H
ws=[0]*W
D=defaultdict(int)
for i in range(M):
    h,w=map(int, input().split())
    hs[h-1]+=1
    ws[w-1]+=1
    D[(h-1,w-1)]+=1


hmax=max(hs)
wmax=max(ws)
Hs=[]
Ws=[]
for h in range(H):
    if hmax==hs[h]:
        Hs.append(h)

for w in range(W):
    if wmax==ws[w]:
        Ws.append(w)

for h in Hs:
    for w in Ws:
        if D[h,w]==0:
            print(hmax+wmax)
            exit()

print(hmax+wmax-1)
N,K = list(map(int, input().split()))
S = str(input())
s = [S[i] for i in range(len(S))]
s[K-1] = chr(ord(s[k-1])+32)
print(join(s))

### FIXED CODE ###

N,K = list(map(int, input().split()))
S = str(input())
s = [S[i] for i in range(len(S))]
s[K-1] = chr(ord(s[K-1])+32)
print(''.join(s))
l = list(map(int, input().split()))
a = []
while(l != None):
    length =len(str(l[0]+l[1]))
    a.append(length)
    l = list(map(int, input().split()))

for i in range(len(a)):
    print(a[i])


### FIXED CODE ###

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

while(l != []):
    try:
        length = len(str(l[0]+l[1]))
        print(length)
        l = list(map(int, input().split()))
    except:
        break
if ((0<A<9)&&(0<B<9)):
  return A*B
else:
  return "-1"

### FIXED CODE ###

A,B = [int(x) for x in input().split()]

if (A>=10)or(B>=10):
  print("-1")
else:
  print(A*B)
first = input()
seconds = list(map(int,input().split()))

print("".join(seconds.reverse()))

### FIXED CODE ###

first = input()
seconds = list(map(int,input().split()))
seconds.reverse()
t2=list(map(str, seconds))
print(" ".join(t2))
N, M = map(int, input().split())
G = [[] for _ in range(N)]
x = [None] * (N)

def dfs(s):
    for t, d in G[s]:
        if x[t] is None:
            x[t] = x[s] + d
            if not dfs(t):
                return False
        else:
            if x[t] != x[s] + d:
                return False
    return True

for _ in range(M):
    L, R, D = map(int, input().split())
    G[L-1].append([R-1,  D])
    G[R-1].append([L-1, -D])

ans = True
for i in range(N):
    if x[i] is None:
        x[i] = 0
        ans &= dfs(i)

print("Yes" if ans else "No")

### FIXED CODE ###

import sys
sys.setrecursionlimit(200002)

N, M = map(int, input().split())
G = [[] for _ in range(N)]
x = [None] * (N)

def dfs(s):
    global x, G
    for t, d in G[s]:
        if x[t] is None:
            x[t] = x[s] + d
            if not dfs(t):
                return False
        else:
            if x[t] != x[s] + d:
                return False
    return True

for _ in range(M):
    L, R, D = map(int, input().split())
    G[L-1].append([R-1,  D])
    G[R-1].append([L-1, -D])

ans = True
for i in range(N):
    if x[i] is None:
        x[i] = 0
        ans &= dfs(i)

print("Yes" if ans else "No")
from collections import defaultdict

n, m = [int(i) for i in raw_input().split()]

parents = defaultdict(list)

i = 0
while i < m:
    u, v = [int(x) for x in raw_input().split()]
    parents[v-1].append(u-1)
    i += 1

def calc_f(parents, f, i):

    if f[i] != -1:
        return f[i]

    f[i] = 0
    for v in parents[i]:
        f[i] = max(f[i], calc_f(parents, f, v)+1)

    return f[i]

f = [-1] * n
j = 0
while j < n:
    calc_f(parents, f, j)
    j += 1

if len(f) == 0:
    print 0
else:
    print max(f)

### FIXED CODE ###

from collections import defaultdict
import sys
sys.setrecursionlimit(1000000)

n, m = [int(i) for i in raw_input().split()]
parents = defaultdict(list)

i = 0
while i < m:
    u, v = [int(x) for x in raw_input().split()]
    parents[v-1].append(u-1)
    i += 1

def calc_f(parents, f, i):
    if i < 0 or i >= len(f):
        return 0

    if f[i] != -1:
        return f[i]

    f[i] = 0
    for v in parents[i]:
        f[i] = max(f[i], calc_f(parents, f, v)+1)

    return f[i]

f = [-1] * n
j = 0
while j < n:
    calc_f(parents, f, j)
    j += 1

if len(f) == 0:
    print 0
else:
    print max(f)
#!/usr/bin/env python
import sys
from collections import Counter
from itertools import permutations, combinations
#from fractions import gcd
from math import gcd
from math import ceil, floor
import bisect
sys.setrecursionlimit(10 ** 6)
inf = float("inf")

def input():
    return sys.stdin.readline()[:-1]

def main():
    n, m = map(int, input().split())
    A = tuple(map(int, input().split()))
    ans = 0
    total = sum(A)
    for a in A:
        if a >= total/(4*m):
            ans += 1
    print("Yes") if ans >= m else print("No")

if __name__ == '__main__':
    main()



### FIXED CODE ###

#!/usr/bin/env python
import sys
from collections import Counter
from itertools import permutations, combinations
#from fractions import gcd
from math import ceil, floor
import bisect
sys.setrecursionlimit(10 ** 6)
inf = float("inf")

def input():
    return sys.stdin.readline()[:-1]

def main():
    n, m = map(int, input().split())
    A = tuple(map(int, input().split()))
    ans = 0
    total = sum(A)
    for a in A:
        if a >= total/(4*m):
            ans += 1
    print("Yes") if ans >= m else print("No")

if __name__ == '__main__':
    main()
S1 = input()
S2 = S1[0]
res = 0

for s in S1:
    if S2[-1] == s:
        S2 += s
    else:
        S2 = S2[:-1:]
        res += 2

print(res)


### FIXED CODE ###

S1 = input()
S2 = ''
res = 0

for s in S1:
    if len(S2) == 0 or S2[-1] == s:
        S2 += s
    else:
        S2 = S2[:-1:]
        res += 2

print(res)
a=input()
a=int(a)
b=input()
b=int(b)


sum=0
for x in range(b-a+1):
    sum+=x
    
high=sum-b

print(high)

### FIXED CODE ###

n=input()
n=int(n)
if n>999:
    print("ABD")
else:
    print("ABC")
n = int(input())
L = list(int(x) for x in input().split())
if n <= 2:
    print(0)
    exit()
ans = 0
for a, b, c in combinations(L, 3):
    if a != b and b != c and c != a:
        if a + b > c and b + c > a and c + a > b:
            ans += 1
print(ans)

### FIXED CODE ###

from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement, groupby
from math import sqrt, ceil, floor, factorial, gcd
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce, lru_cache  # @lru_cache(None)
import sys  # def input(): return sys.stdin.readline().rstrip() # sys.setrecursionlimit(10**6)

n = int(input())
L = list(int(x) for x in input().split())
if n <= 2:
    print(0)
    exit()
ans = 0
for a, b, c in combinations(L, 3):
    if a != b and b != c and c != a:
        if a + b > c and b + c > a and c + a > b:
            ans += 1
print(ans)
import numpy as np
import copy
n, m = [int(i) for i in input().split()]
a=[]
b=[]
for i in range(m):
    x1, y1 = [int(i) for i in input().split()]
    a.append(x1)
    b.append(y1)

ans = 0
while True:
    bridge = np.array([0]*(n-1))
    for i in range(len(a)):
        bridge[a[i]-1:b[i]-1] += 1
    r = bridge.argmax() + 1

    for i,an,bn in zip(range(len(a)),a,b):
        if an <= r <= bn-1:
            a[i]=0
            b[i]=0

    ans += 1
    if len(set(a))==1 and a[0]==0:
        break

print(ans)

### FIXED CODE ###

n, m = [int(i) for i in input().split()]
a=[]
b=[]
for i in range(m):
    x1, y1 = [int(i) for i in input().split()]
    a.append(x1)
    b.append(y1)

c = zip(b,a)
c = sorted(c)
b,a = zip(*c)

#print(a,b)
ans = 0
point=0

for i in range(m):
    if a[i]<point<b[i]:
        continue
    else:
        ans += 1
        point=b[i]-0.5

print(ans)
A,B=input()
 A=input(A)
 B=input(B)
 
 turn=0
 while(1):
 	if(turn==K):
 		break
 	if(turn%2==0):#高橋くん
 		if(A%2==1):
 			A-=1
	else:#青木くん
		if(B%2==1):
			B-=1
	turn+=1
 print(A+" "+B)
 
 
 
 
 

### FIXED CODE ###


A,B,K=input().split()
A=int(A)
B=int(B)
K=int(K)
turn=0
while(1):
	if(turn==K):
		break
	if(turn%2==0):#高橋くん
		if(A%2==1):
			A-=1
		B+=A//2
		A-=A//2
	else:#青木くん
		if(B%2==1):
			B-=1
			
		A+=B//2
		B-=B//2
	turn+=1
print(str(A)+" "+str(B))
import sys
sys.setrecursionlimit(10**9)
N,M=map(int,input().split())

def find_negative_loop(n,w,es):
  dist=[float("inf")]*n
  #この始点はどこでもよい
  dist[1]=0
  
  for i in range(n):
    for j in range(w):
      e=es[j]
      if dist[e[1]]>dist[e[0]]+e[2]:
        dist[e[1]]=dist[e[0]]+e[2]
        if i==n-1:
          return True
  return False

def shortest_path(s,n,w,es):
  #s→iの最短距離
  #s:始点, n:頂点数, w:辺の数, es[i]:[辺の始点,辺の終点,辺のコスト]
  dist=[float("inf")]*n
  #d[i]: s→iの最短距離
  dist[s]=0

  while True:
    update=False
    for p,q,r in es:
      # e: 辺iについて [from,to,cost]
      if dist[p]!=float("inf") and dist[q]>dist[p]+r:
        dist[q]=dist[p]+r
        update=True
    if not update:
      break
      
  return dist

graph=[[] for _ in range(N+1)]
elist=[]
for _ in range(M):
  a,b,c=map(int,input().split())
  graph[a].append(b)
  elist.append((a,b,-c))
  
#remove unnecessary vertex and edge
visited=[None]*(N+1)
def check_reachable(s,u):
  if u==N:
    reachable_list[s]=True
    return True
  
  visited[u]=True
  for v in graph[u]:
    check_reachable(s,v)    
  return False

reachable_list=[False]*(N+1)
for i in range(1,N+1):
  visited=[False]*(N+1)
  res=check_reachable(i,i)
#print(reachable_list)
  
elist2=[]
for a,b,nc in elist:
  if reachable_list[a] and reachable_list[b]:
    elist2.append((a,b,nc))
  
M2=len(elist2)
res1=find_negative_loop(N+1,M2,elist2)

if res1:
  print("inf")
else:
  res2=shortest_path(1,N+1,M2,elist2)
  print(-res2[N])

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)
N,M=map(int,input().split())

def find_negative_loop(n,w,es):
  dist=[float("inf")]*n
  #この始点はどこでもよい
  dist[1]=0
  
  for i in range(n):
    for j in range(w):
      e=es[j]
      if dist[e[1]]>dist[e[0]]+e[2]:
        dist[e[1]]=dist[e[0]]+e[2]
        if i==n-1:
          return True
  return False

def shortest_path(s,n,w,es):
  #s→iの最短距離
  #s:始点, n:頂点数, w:辺の数, es[i]:[辺の始点,辺の終点,辺のコスト]
  dist=[float("inf")]*n
  #d[i]: s→iの最短距離
  dist[s]=0

  while True:
    update=False
    for p,q,r in es:
      # e: 辺iについて [from,to,cost]
      if dist[p]!=float("inf") and dist[q]>dist[p]+r:
        dist[q]=dist[p]+r
        update=True
    if not update:
      break
      
  return dist

graph=[[] for _ in range(N+1)]
elist=[]
for _ in range(M):
  a,b,c=map(int,input().split())
  graph[a].append(b)
  elist.append((a,b,-c))
  
#remove unnecessary vertex and edge
visited=[None]*(N+1)
def check_reachable(s,u):
  if u==N:
    reachable_list[s]=True
    return True
  
  visited[u]=True
  for v in graph[u]:
    if not visited[v]:
      check_reachable(s,v)    
  return False

reachable_list=[False]*(N+1)
for i in range(1,N+1):
  visited=[False]*(N+1)
  check_reachable(i,i)
#print(reachable_list)
  
elist2=[]
for a,b,nc in elist:
  if reachable_list[b]:
    elist2.append((a,b,nc))
  
M2=len(elist2)
res1=find_negative_loop(N+1,M2,elist2)

if res1:
  print("inf")
else:
  res2=shortest_path(1,N+1,M2,elist2)
  print(-res2[N])
import numpy as np
k,n=map(int,input().split())
a=list(int,input().split())
a=np.array(a)
if max(abs(a[1:]-a[:-1])) < k-abs(a[0]-a[-1]):b=k-abs(a[0]-a[-1])
else:b= max(abs(a[1:]-a[:-1]))
print(k-b)

### FIXED CODE ###

import numpy as np
k,n=map(int,input().split())
a=list(map(int,input().split()))
a=np.array(a)
if max(abs(a[1:]-a[:-1])) < k-abs(a[0]-a[-1]):b=k-abs(a[0]-a[-1])
else:b= max(abs(a[1:]-a[:-1]))
print(k-b)
fore, real = input().split()

ct = 0
for i in range(len(fore)):
  if fore[i] == real[i]:
    ct += 1

print(ct)

### FIXED CODE ###

fore = input()
real = input()

ct = 0
for i in range(len(fore)):
  if fore[i] == real[i]:
    ct += 1
 
print(ct)
AC_Count = WA_Count = TLE_Count = RE_Count = 0
for _ in range(int(input())):
	s = input()
	if s=="AC":
      AC_Count+=1
    elif s=="WA":
      WA_Count+=1
    elif s=="TLE":
      TLE_Count+=1
    else:
      RE_Count+=1
print("AC "+"x "+AC_count)
print("WA "+"x "+WA_count)
print("TLE "+"x "+TLE_count)
print("RE "+"x "+RE_count)

### FIXED CODE ###

a = 0
w = 0
r = 0
t = 0
for _ in range(int(input())):
	s = input()
	if s=="AC":
		a+=1
	elif s=="WA":
		w+=1
	elif s=="TLE":
		t+=1
	else:
		r+=1
print("AC "+"x "+str(a))
print("WA "+"x "+str(w))
print("TLE "+"x "+str(t))
print("RE "+"x "+str(r))
import sys, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict, Counter
from math import factorial
from bisect import bisect_left # bisect_left(list, value)
#from fractions import gcd
from operator import mul
from functools import reduce

sys.setrecursionlimit(10**7)
n, a, b = map(int, input().split())
div = 10**9+7

l = [n]*(n)
for r in range(2, n+1):
    val = (n-r+1)/r
    l[r-1] = round(val*(l[r-2]))%div

l[a-1] = 0
l[b-1] = 0

print(sum(l))


### FIXED CODE ###

import sys, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict, Counter
from math import factorial
from bisect import bisect_left # bisect_left(list, value)
#from fractions import gcd
enu = enumerate

sys.setrecursionlimit(10**7)
n, a, b = map(int, input().split())
mod = 10**9 + 7

def cmb(n, r, p):
    r = min(n - r, r)
    if r == 0:
        return 1
    over = 1
    for i in range(n, n - r, -1):
        over = over * i % p
    under = 1
    for i in range(1, r + 1):
        under = under * i % p
    inv = pow(under, p - 2, p)
    return over * inv % p

cnt = pow(2, n, mod)
ng1 = cmb(n, a, mod)
ng2 = cmb(n, b, mod)

res = (cnt - ng1 - ng2 - 1) % mod

print(res)