Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import sys 
from collections import deque
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

def solve(n,m,a,b):
    t = -1
    for bit in range(2**(n-1)):
        bridge = [1]*(n-1)
        for rep in range(n-1):
            if (bit>>rep)&1:
                bridge[rep] = 0
        for rep in range(m):
            ok = True
            if not 0 in bridge[a[rep]:b[rep]]:
                ok = False
                break
        if ok:
            if t == -1:
                t = bin(bit).count('1')
            else:
                t = min(t,bin(bit).count('1'))
    return t
        

def main():
    tmp = deque(LI())
    N,M = tmp.popleft(),tmp.popleft()
    a,b = deque(),deque()
    for _ in range(M):
        tmp = deque(LI())
        a.append(tmp.popleft()-1)
        b.append(tmp.popleft()-1)
    print(solve(N,M,a,b))
    return

if __name__=='__main__':
    main()

### FIXED CODE ###

import sys
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def Main():
    n,m = IL()
    war = [list(IL()) for _ in range(m)]
    war.sort(key=lambda x: x[1])
    pre = war[0][1]-2
    ans = 1
    for rep in war:
        if pre<rep[0]-1:
            pre = rep[1]-2
            ans += 1
    print(ans)
    return

if __name__=='__main__':
    Main()
### BUGGY CODE ###

N=int(input())
s=set()
for i in range(N):
    s=s^{input()}
print(len(s))

### FIXED CODE ###

N=int(input())
s=[input() for _ in range(N)]
s.sort()

ans=1
k=1
for i in range(N-1):
    if s[i]==s[i+1]:
        k=k*(-1)
    else:k=1
    ans+=k
        
print(ans)
### BUGGY CODE ###


n,k = map(int,input().split())
li = [int(x) for x in input().split()]

dp = [10**8] * n

for i in range(n):
    if i == 0:
        dp[0] = 0
    elif i < k-1:
        temp = []
        for j in range(i):
            s = abs(li[i] - li[i-j-1]) + dp[i-j-1]
            temp.append(s)
        else:
            dp[i] = min(temp)
    elif i >= k-1:
        temp = []
        for j in range(k):
            s = abs(li[i] - li[i-j-1]) + dp[i-j-1]
            temp.append(s)
        else:
            dp[i] = min(temp)
            
print(dp[-1])

### FIXED CODE ###

n,k = map(int,input().split())
li = [int(x) for x in input().split()]

dp = [10**8] * n

for i in range(n):
    if i == 0:
        dp[0] = 0
    elif i < k-1:
        temp = []
        for j in range(i):
            s = abs(li[i] - li[i-j-1]) + dp[i-j-1]
            temp.append(s)
        else:
            dp[i] = min(temp)
    elif i >= k-1:
        temp = []
        for j in range(k):
            s = abs(li[i] - li[i-j-1]) + dp[i-j-1]
            temp.append(s)
        else:
            dp[i] = min(temp)
            
print(dp[-1])
### BUGGY CODE ###

import numpy as np
 
def f7(seq):
    seen = set()
    seen_add = seen.add
    return [ x for x in seq if x not in seen and not seen_add(x)]

def main():
    N = int(input())
    A = list(map(int, input().split()))
    A_uniq = f7(A)

    a_list = np.zeros(100005)

    for a in A_uniq:
        a_cnt = A.count(a)
        a_list[a] += a_cnt
        a_list[a+1] += a_cnt
        a_list[a+2] += a_cnt

    print(int(a_list.max())) 

main()

### FIXED CODE ###

import numpy as np
from collections import Counter

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

ans = 0
counter = Counter(A)
for a, cnt in counter.most_common():
    tmp = counter[a-1] + cnt + counter[a+1]
    if ans < tmp:
        ans = tmp
        

print(ans)
### BUGGY CODE ###

s = input()
l = len(s)
a = 0
for i in range(l):
  if i&1 == 1:
    a += 2**i
b = ((2**l)-1) ^ a

S = int(s, 2)
A = bin(S^a).count('1')
B = bin(S^b).count('1')
print(min(A, B))

### FIXED CODE ###

s = input()
l = len(s)
a = 0
for i in range(l):
  if i&1 == 0:
    a <<= 2
    a += 1
b = ((2**l)-1) ^ a

S = int(s, 2)
A = bin(S^a).count('1')
B = bin(S^b).count('1')
print(min(A, B))
### BUGGY CODE ###

from math import factorial as f
n,m,k=map(int,input().strip().split())
print((f(n*m-2)//(f(k-2)*f(n*m-k))*(m*m*(n**3-n)+n*n*(m**3-m))//6)%(10**9+7))

### FIXED CODE ###

from math import factorial as f
n,m,k=map(int,input().strip().split())
print((f(n*m-2)//(f(k-2)*f(n*m-k))*(m*m*(n**3-n)+n*n*(m**3-m))//6)%(10**9+7))
### BUGGY CODE ###


def solve(N, M, A):
    A = [[int(x[0]), x[1]] for x in A]

    Unsolve = [0]*(N+1)
    Solved = []
    ac = 0
    wa = 0
    for i in range(M):
        if A[i][0] not in Solved:
            if A[i][1] == 'WA':
                Unsolve[A[i][0]] += 1
            elif A[i][1] == 'AC':
                Solved.append(A[i][0])
                wa += Unsolve[A[i][0]]
                ac += 1

    return ac, wa

def main():
    N, M = map(int, input().split())
    A = [list(x for x in input().split()) for _ in range(M)]
    ans = solve(N, M, A)
    print(*ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###


def solve(N, M, A):

    A = [[int(x[0]), x[1]] for x in A]

    Unsolve = [0]*(N+1)
    Solved = set()
    ac = 0
    wa = 0
    for i in range(M):
        if A[i][0] not in Solved:
            if A[i][1] == 'WA':
                Unsolve[A[i][0]] += 1
            elif A[i][1] == 'AC':
                Solved.add(A[i][0])
                wa += Unsolve[A[i][0]]
                ac += 1

    return ac, wa

def main():
    N, M = map(int, input().split())
    A = [list(x for x in input().split()) for _ in range(M)]
    ans = solve(N, M, A)
    print(*ans)

if __name__ == "__main__":
    main()
### BUGGY CODE ###

import bisect
n = int(input())
l = [int(i) for i in input().split()]
l.sort()
k = 0
for i in range(n):
    for j in range(i + 1, n):
        m = l[j+1:]
        ind = bisect.bisect_left(m, l[i] + l[j])
        k += ind
print(k)


### FIXED CODE ###

import bisect
n = int(input())
l = [int(i) for i in input().split()]
l.sort()
k = 0
for i in range(n):
    for j in range(i + 1, n):
        ind = bisect.bisect_left(l, l[i] + l[j])
        k += max(ind-j-1, 0)
print(k)
### BUGGY CODE ###

N = int(input())


for i in range(1, N+1):
    num = 0
    sqi = int(float(i)**0.5)
    for j in range(1,sqi+1):
        sqj = int(float(i-j**2)**0.5)
        for k in range(1, sqj+1):
            sqk = int(float(i-j**2-k**2)**0.5)
            for l in range(1, sqk+1):
                if j**2+k**2+l**2+j*k+k*l+l*j == i:
                    num +=1
    print(num)

### FIXED CODE ###

N = int(input())
ans = [0]*(10**4+10)

for i in range(1,10**2+10):
    for j in range(1, 10**2+10):
        for k in range(1, 10**2+10):
            v = i**2 + j**2 + k**2 + i*j + j*k + k*i
            if v < 10**4+10:
                ans[v]+=1

for i in range(1,N+1):
    print(ans[i])
### BUGGY CODE ###

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

dict_x = {"R":1, "G":2, "B":3}
s = [dict_x[s] for s in s]

result = 0

for i in range(n):
    for j in range(i + 1, n):
        if s[i] == s[j]:
            continue
        for k in range(j + 1, n):
            if (j - i) != (k - j):
                if s[i] * s[j] * s[k] == 6:
                    result += 1

print(result)

### FIXED CODE ###

n = int(input())
s = input()
 
r_cnt = s.count('R')
g_cnt = s.count('G')
b_cnt = s.count('B')
 
ans = r_cnt * g_cnt * b_cnt
 
for i in range(n):
    for d in range(n):
        j = i + d
        k = j + d
        if k >= n:break
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            ans -= 1
 
print(ans)
### BUGGY CODE ###

# coding: utf-8
import sys

stdin = sys.stdin
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))


def main():
    n,m = na()
    path = [[] for _ in range(n)]
    ans = [0] + [-1 for i in range(n-1)]
    sumcheck = 1
    for _ in range(m):
        a,b = na()
        a -= 1
        b -= 1
        path[a] += [b]
        path[b] += [a]
    que = [0]
    while que != []:
        now = que.pop(0)
        for nxt in path[now]:
            if ans[nxt] == -1:
                ans[nxt] = now
                sumcheck += 1
                que.append(nxt)
    if sumcheck == n:
        print('Yes')
        for i in ans[1:]:
            print(i+1)
    else:
        print('No')
    return


if __name__ == '__main__':
    main()

### FIXED CODE ###

# coding: utf-8
import sys
from collections import deque

stdin = sys.stdin
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))


def main():
    n,m = na()
    path = [[] for _ in range(n)]
    ans = [0] + [-1 for i in range(n-1)]
    sumcheck = 1
    for _ in range(m):
        a,b = na()
        a -= 1
        b -= 1
        path[a] += [b]
        path[b] += [a]
    d = deque([0])
    while len(d):
        now = d.popleft()
        for nxt in path[now]:
            if ans[nxt] == -1:
                ans[nxt] = now
                sumcheck += 1
                d.append(nxt)
    if sumcheck == n:
        print('Yes')
        for i in ans[1:]:
            print(i+1)
    else:
        print('No')
    return


if __name__ == '__main__':
    main()
### BUGGY CODE ###

A,B,K=map(int,input().split())
for i in range(K):
    if A>0 :
        A=A-1
    elif B>0 :
        B=B-1
    else :
        break
print(A,B)

### FIXED CODE ###

A,B,K=map(int,input().split())
if A>=K :
    print(A-K,B)
elif A+B>=K :
    print(0,A+B-K)
else :
    print(0,0)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

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

ans = 0
for i in range(60):
  count_one = sum(a>>i & 1 for a in A)
  ans += count_one * (N - count_one) * (2 ** i)
  
    
print(ans%MOD)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

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

ans = 0
two = 1
for i in range(61):
  n = len([ a for a in A if (a >> i) & 1 ])
  ans += (n * (N - n) * two % MOD)
  two *= 2 
print(ans%MOD)
### BUGGY CODE ###

N,P = map(int, input().split())
S = input()

if P == 2 or P == 5:
    ans = 0
    for i in range(N):
        if int(S[i]) % P == 0:
            ans += i+1
    print(ans)
else:
    mod_cnt = {0: 1}
    for i in range(N):
        mod = int(S[i:]) % P
        if mod in mod_cnt:
            mod_cnt[mod] += 1
        else:
            mod_cnt[mod] = 1
    ans = 0
    for cnt in mod_cnt.values():
        ans += (cnt * (cnt-1)) // 2
    print(ans)


### FIXED CODE ###

N,P = map(int, input().split())
S = input()

if P == 2 or P == 5:
    ans = 0
    for i in range(N):
        if int(S[i]) % P == 0:
            ans += i+1
    print(ans)
else:
    mod_cnt = [0]*P
    mod_cnt[0] = 1
    k = 0.1
    t = 0
    for i in range(1, N+1):
        k = int(k * 10) % P
        t = (t + k * int(S[-i])) % P
        mod_cnt[t] += 1
    ans = 0
    for cnt in mod_cnt:
        ans += (cnt * (cnt-1)) // 2
    print(ans)
### BUGGY CODE ###

def view():
    global keyboxes
    for keybox in keyboxes:
        for key in keybox:
            print(key.value,key.cans)
        print()

class Key():
    def __init__(self,value,cans):
        self.value=value
        self.cans=cans
    
    def __eq__(self,other):
        return self.value==other.value
    
    def __lt__(self,other):
        return self.value<other.value
    
    def __gt__(self,other):
        return self.value>other.value
    
N,M=map(int,input().split())
keys=[]
for i in range(M):
    a,b=map(int,input().split())
    c=list(map(int,input().split()))
    cans=0
    for i in c:
        cans+=2**(i-1)
    keys.append(Key(a,cans))

dp=[12*(10**5)+1 for j in range(2**N)]
dp[0]=0

for key in keys:
    for j in range(2**N):
        dp[j|key.cans]=min(dp[j|key.cans],dp[j]+key.value)

print(dp[2**N-1] if dp[2**N-1]!=12*(10**5)+1 else -1)

### FIXED CODE ###

N,M=map(int,input().split())
inf=12*(10**5)+1

dp=[inf for j in range(2**N)]
dp[0]=0

for i in range(M):
    a,b=map(int,input().split())
    c=sum([1<<(i-1) for i in list(map(int,input().split()))])
#    print(a,b,c)
    for j in range(2**N):
        dp[j|c]=min(dp[j|c],dp[j]+a)
#    print(dp)

print(dp[2**N-1] if dp[2**N-1]!=inf else -1)
### BUGGY CODE ###

N=int(input())

import math
def num_divisors_trial_division(n):
    num = 0
    for i in range(1, int(math.sqrt(n) + 1e-9) + 1):
        if n % i == 0:
            num += 1
            if n != i**2:
                num += 1
    
    return num

import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

ans=0

for i in range(1,N):
  if is_prime(N-i)==True:
    ans+=2
  else:
    ans+=num_divisors_trial_division(N-i)

print(ans)

### FIXED CODE ###

N=int(input())
a=0
for i in range(1,N-1):
  a+=(N-1)//i
print(a+1)
### BUGGY CODE ###

S = input()

d = [i*10%13 for i in range(13)]

if S[0]=="?":
  res=[[1,1,1,1,1,1,1,1,1,1,0,0,0]]
else:
  res=[[0 if i!=int(S[0]) else 1 for i in range(13) ]]

for i in range(1,len(S)):
  res.append([0 for i in range(13)])
  if S[i]=="?":
    for j in range(13):
      for k in range(10):
        res[i][(d[j]+k)%13]+=res[i-1][j]
  else:
    for j in range(13):
      res[i][(d[j]+int(S[i]))%13]+=res[i-1][j]
      
print(res[len(S)-1][5]%(10**9+7))

### FIXED CODE ###

import sys
read=sys.stdin.buffer.read
readline=sys.stdin.buffer.readline
readlines=sys.stdin.buffer.readlines

MOD=10**9+7

S=read().rstrip().decode("utf-8")
#print("S:",S)

R=[0]*13
R_buffer=[0]*13

if S[0]=="?":
  for i in range(0,10):
    R[i]=1
else:
  R[int(S[0])]=1
#print("R:",R)

for i in range(1,len(S)):
  
  if S[i]=="?":
    for j in range(13):
      for k in range(10):
        R_buffer[(j*10+k)%13]+=R[j]
  else:
    for j in range(13):
      R_buffer[(j*10+int(S[i]))%13]+=R[j]
  
  for j in range(13):
    R[j]=R_buffer[j]%MOD
    R_buffer[j]=0
  #print("R:",R)
  
print(R[5])
### BUGGY CODE ###

n=int(input())
L_lst=sorted(list(map(int,input().split())))
i=n-2
j=n-1
cnt=0
x=0
while j>1:
    while x<i:
        if L_lst[i]+L_lst[x]>L_lst[j]:
            cnt+=i-x
            i-=1
            x=0
        else:
            x+=1
    x=0
    j-=1
    i=j-1
print(cnt)

### FIXED CODE ###

n=int(input())
L_lst=sorted(list(map(int,input().split())))
cnt=0
for j in range(n-1,1,-1):
    i=j-1
    x=0
    while x<i:
        if L_lst[i]+L_lst[x]>L_lst[j]:
            cnt+=i-x
            i-=1
        else:
            x+=1
print(cnt)
### BUGGY CODE ###

def main():
    N = int(input())
    A = tuple(map(int, input().split()))

    i = N - 1
    while i >= 0:
        n = A.count(i)
        if i == 0 and n != 1:
            print('0')
            break
        elif i != 0 and n != 2:
            print('0')
            break
        i -= 2
    else:
        comb = (2 ** (N // 2)) % 1000000007
        print(str(comb))

main()


### FIXED CODE ###

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

    if N % 2 == 1:
        A.append(0)

    A.sort()
    ev = tuple(A[::2])
    od = tuple(A[1::2])

    if ev == od:
        comb = (2 ** (N // 2)) % 1000000007
        print(str(comb))
    else:
        print('0')

main()
### BUGGY CODE ###

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

num = [0] * 60
for i in a:
    temp = bin(i + 2 ** 60)[3:]
    for i in range(len(temp)):
        if temp[i] == "1":
            num[i] += 1
ans = 0
for i in range(60):
    ans += (num[i] * (n - num[i]) * (2 ** (59 - i)))
    ans %= mod
print(ans)

### FIXED CODE ###

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

num = [0] * 60
for i in a:
    temp = bin(i + 2 ** 60)[3:]
    for i in range(len(temp)):
        if temp[i] == "1":
            num[i] += 1
ans = 0
for i in range(60):
    ans += (num[i] * (n - num[i]) * (2 ** (59 - i)))
    ans %= mod
print(ans)
### BUGGY CODE ###

n = int(input())
lists = [input() for i in range(n)]
cnt = 0
for i in range(n-1):
  for j in range(i+1,n):
    a = lists[i]
    b = lists[j]
    c = []
    d = []
    for x in a:
      c += [x]
    for y in b:
      d += [y]
    c.sort()
    d.sort()
    if c == d:
      cnt += 1
print(cnt)      

### FIXED CODE ###

import collections

n = int(input())
def sort_string(st):
  res = list(st)
  res.sort()
  return "".join(res)

s = [sort_string(input()) for _ in range(n)]
c = collections.Counter(s)
ans = 0
for n in c.values():
  ans += n*(n-1)//2
print(ans)
### BUGGY CODE ###

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


l = [0] * max(a)


for i in a:

    c = 1
    while True:
        if i*c-1 >= max(a):
            break
        l[i*c - 1] += 1
        c += 1



ans = 0

for i in set(a):
    if l[i-1] == 1:
        ans += 1

print(ans)


### FIXED CODE ###

n = int(input())
A = list(map(int,input().split()))
 
maxA = max(A)
ans = 0
flag = [0]*(maxA+1)
 
# print(flag)
for a in A:
    for ax in range(a,maxA+1,a):
        flag[ax] +=1
 
# print(flag)
for a in set(A):
    if flag[a] == 1:
        ans += 1
print(ans)
### BUGGY CODE ###

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

if 0 in x:
    K -= 1
    x.remove(0)

Min = -1
for i in x:
    goal = i
    if goal > 0:
        path = [j for j in x if j < goal]
        if len(path) < K-1:
            pass
        else:
            path = path[-K+1:]
            le = min(path)
            dis = abs(0-le)+abs(goal-le)
            if Min == -1:
                Min = dis
            else:
                if dis < Min:
                    Min = dis
    else:
        path = [j for j in x if j > goal]
        if len(path) < K-1:
            pass
        else:
            path = path[:K-1]
            re = max(path)
            dis = abs(0-re)+abs(goal-re)
            if Min == -1:
                Min = dis
            else:
                if dis < Min:
                    Min = dis

if Min == -1:
    Min = 0

print(Min)


### FIXED CODE ###

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

Min = 10**9
for i in range(N-K+1):
    x_l = x[i]
    x_r = x[i+K-1]
    ans_1 = abs(x_l-0) + abs(x_l-x_r)
    ans_2 = abs(x_r-0) + abs(x_l-x_r)
    Min = min(Min, ans_1, ans_2)

print(Min)
### BUGGY CODE ###

X = input()
num = len(X) // 2

for j in range(num):
    X = X.replace('ST', '')
    if 'ST' not in X:
        break

print(len(X))

### FIXED CODE ###

X = input()
s = cnt = 0

for i in range(len(X)):
    if X[i] == 'S':
        s += 1
    elif s != 0:
        cnt += 2
        s -= 1

ans = len(X) - cnt
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
h, n = [int(x) for x in input().strip().split()]
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = [int(x) for x in input().strip().split()]

dp = [float('inf')] * (h + 1)
dp[0] = 0
for i in range(1, h+1):
    for aa, bb in zip(a, b):
        dp[i] = min(dp[i], dp[max(0, i-aa)]+bb)
print(dp[h])

### FIXED CODE ###

import sys
input = sys.stdin.readline
h, n = [int(x) for x in input().strip().split()]
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = [int(x) for x in input().strip().split()]

dp = [float('inf')] * (h + 1)
dp[0] = 0
for i in range(1, h+1):
    for aa, bb in zip(a, b):
        dp[i] = min(dp[i], dp[max(0, i-aa)]+bb)
print(dp[h])
### BUGGY CODE ###

from collections import deque
import copy
H, W = map(int, input().split())
 
route = []
for _ in range(H):
  route.append(input())
  
wall = set()
start = set()
for y, r in enumerate(route):
  for x, w in enumerate(r):
    if w == '#':
      wall.add((x, y))
    else:
      start.add((x, y))

score = -1
ssize = [(-1,0),(0,-1),(1,0),(0,1)]
for xy in start:
  d = deque()
  d.append((xy+(0,)))
  step = 0
  already = copy.deepcopy(wall)
  while len(d) > 0:
    now = d.popleft()
    already.add(now[:-1])
    step = now[2]
    for xs, ys in ssize:
      nxt = (now[0]+xs, now[1]+ys)
      if nxt not in already and nxt in start:
        d.append(nxt+(step+1,))
  score = max(step, score)
  
print(score)

### FIXED CODE ###

from collections import deque
import copy
H, W = map(int, input().split())
 
route = []
for _ in range(H):
  route.append(input())
  
wall = set()
start = set()
for y, r in enumerate(route):
  for x, w in enumerate(r):
    if w == '.':
      start.add((x, y))

score = -1
ssize = [(-1,0),(0,-1),(1,0),(0,1)]
for xy in start:
  d = deque()
  d.append((xy+(0,)))
  step = 0
  can = copy.deepcopy(start)
  can.remove(xy)
  while len(d) > 0:
    now = d.popleft()
    step = now[2]
    for xs, ys in ssize:
      nxt = (now[0]+xs, now[1]+ys)
      if nxt in can:
        d.append(nxt+(step+1,))
        can.remove(nxt)
  score = max(step, score)
  
print(score)
### BUGGY CODE ###

# coding: utf-8
# Your code here!
N,Q = map(int,input().split())
S = input()
p = set()
for n,i in enumerate(S[:-1]):
    if i == "A" and S[n+1]=="C":
        p.add(n)
#print(p)
for i in range(Q):
    a,b = map(int,input().split())
    tmp = {}
    tmp = {i for i in range(a-1,b-1)}
#    print(tmp)
    print(len(tmp&p))

### FIXED CODE ###

N,Q = map(int,input().split())
S = input()
p = [0]*(N)
a = 0
for i in range(-1,N-2):
    if S[i+1] == "A" and S[i+2]=="C":
        a+=1
    p[i+2]=a
#print(p)
for i in range(Q):
    a,b = map(int,input().split())
    print(p[b-1] - p[a-1])
### BUGGY CODE ###

import math
def comb(n,k,p):
  """power_funcを用いて(nCk) mod p を求める"""
  from math import factorial
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a=factorial(n) %p
  b=factorial(k) %p
  c=factorial(n-k) %p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p

def power_func(a,b,p):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p

x, y = map(int, input().split())
X = x
Y = y
ans = 0
while True:
    # print(x, y)
    if y == x * 2:
        ans = 1
        break
    elif x < 0 or y < 0:
        ans = 0
        break
    x -= 2
    y -= 1
# print(1, ans, x, y)
xx = 0
yy = 0
if ans == 0:
    print(ans)
else:
    xx = X - x
    xx //= 2
    yy = y // 2
# print(xx, yy)
    print(comb(xx + yy, xx, 10 ** 9 + 7))
# print(xx, yy, x, y)

### FIXED CODE ###

def solve():
    x, y = map(int, input().split())
    n = (2*y-x) / 3
    m = (2*x-y) / 3

    mod = 10**9+7

    if n < 0 or m < 0 or (x+y)% 3 != 0:
        return 0
    cmb = 1
    n = int(n)
    m = int(m)
    
    cnt = 0
    for i in range(n):
        cnt += 1
        cmb *= n+m-i
        cmb *= pow(i+1, mod-2, mod)
        cmb %= mod
    return cmb

print(solve())
### BUGGY CODE ###

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


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

max_gcd = gcd(a,b)

primes = []
for i in range(2,max_gcd+1):
  if any(i % prime == 0 for prime in primes):
    continue
  primes += [i]
primes = [1] + primes
  
ans = sum(max_gcd % prime == 0 for prime in primes)

print(ans)

### FIXED CODE ###

def solve():
  import sys
  import math

  sys.setrecursionlimit(10**7)
  readline=sys.stdin.readline

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

  
  def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
  

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

  max_gcd = gcd(a,b)

  ans = set(prime_factorize(max_gcd))

  print(len(ans)+1)

  
if __name__ == '__main__':
  solve()
### BUGGY CODE ###

import sys

num_data = sys.stdin.readlines()
str_num_list = num_data[1].split()
num_list = [int(s) for s in str_num_list]
ans = 1
for i in range(int(num_data[0])):
  ans *= num_list[i]

if ans > pow(10, 18):
  print("-1")
else:
  print(ans)


### FIXED CODE ###

import sys
import numpy as np

num_data = sys.stdin.readlines()
str_num_list = num_data[1].split()
num_list = [int(s) for s in str_num_list]
ans = 1
if 0 in num_list:
  ans = 0
else:
  for i in range(int(num_data[0])):
    ans *= num_list[i]
    if ans > pow(10, 18):
      ans = -1
      break

print(ans)