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

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def query(i):
    print(i)
    sys.stdout.flush()
    s = in_s()
    if s == 'Vacant':
        exit(0)
    elif s == 'Male':
        return 0
    elif s == 'Female':
        return 1


def main():

    N = in_n()

    min_i = 0
    max_i = N

    fm = query(0)

    while True:
        now_i = (min_i + max_i) // 2
        now_fm = query(now_i)

        if (now_i - min_i) % 2 == 0:
            if now_fm == fm:
                min_i = now_i
            else:
                max_i = now_i
        elif (now_i - min_i) % 2 == 1:
            if now_fm == fm:
                max_i = now_i
            else:
                min_i = now_i

        now_fm = fm


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import random

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def query(i):
    print(i)
    sys.stdout.flush()
    s = in_s()

    if s == 'Vacant':
        exit(0)
    elif s == 'Male':
        return 0
    elif s == 'Female':
        return 1


def main():

    N = in_n()

    min_i = 0
    max_i = N

    min_fm = query(0)
    max_fm = min_fm

    while max_i - min_i != 1:
        now_i = (min_i + max_i) // 2
        now_fm = query(now_i)

        if abs(now_i - min_i) % 2 == 0 and now_fm != min_fm:
            max_i = now_i
            max_fm = now_fm
        elif abs(now_i - min_i) % 2 == 1 and now_fm == min_fm:
            max_i = now_i
            max_fm = now_fm
        elif abs(now_i - max_i) % 2 == 0 and now_fm != max_fm:
            min_i = now_i
            min_fm = now_fm
        elif abs(now_i - max_i) % 2 == 1 and now_fm == max_fm:
            min_i = now_i
            min_fm = now_fm


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

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

rsl = []
for i in range(1,n):
    rsl.append(a[i-1:].count(i))

for _ in rsl:
    print(_)
print(0)

### FIXED CODE ###

import numpy as np
n = int(input())
a = list(map(int,input().split()))

rsl = np.zeros(n)

for i in a:
    rsl[i-1] += 1

for i in range(n):
    print(int(rsl[i]))
### BUGGY CODE ###

import copy
n = int(input())
string_list = [input() for i in range(n)]

j = 0

for j in range(n):
    temp_list = copy.deepcopy(string_list)
    temp_list.pop(j)
    j += 1
    print(max(temp_list))

### FIXED CODE ###

import copy
n = int(input())
string_list = [int(input()) for i in range(n)]

sorted_list = sorted(string_list)
max_num = max(string_list)

for j in string_list:
    if j != max_num:
        print(max_num)
    else:
        print(sorted_list[-2])
### BUGGY CODE ###

def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    l = len(bin(max(A))[2:])
    mask = int("1"*N, 2)
    for i in range(N):
        A[i] = list(bin(A[i])[2:].zfill(l))
    cols = [list(c) for c in zip(*A)]
    joinedcols = ["".join(c) for c in cols]
    #print(joinedcols)
    #print(A)
    #print(cols)
    colssum = [c.count("1") for c in cols]
    for i in range(l):
        if (colssum[i]-int(cols[i][0])) % 2 == int(A[0][i]):
            cols[i] = joinedcols[i]
        else:
            cols[i] = bin(int(joinedcols[i], 2) ^ mask)[2:].zfill(N)
    #print(cols)
    ans = ["".join(a) for a in zip(*cols)]
    #print(ans)
    print(*(map(lambda x: int(x, 2), ans))) 
    


if __name__ == "__main__":
    resolve()


### FIXED CODE ###

def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    B = A[0]
    for i in range(1, N):
        B = B^A[i]
    ans = []
    for i in range(N):
        ans.append(B^A[i])
    print(*ans)

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

n = int(input())
x = list(map(int, input().split()))
ans = []
for i in range(n):
    xx = x.copy()
    delete = xx.pop(i)
    xxx = sorted(xx)
    print(xxx[(n-1)//2])


### FIXED CODE ###

n = int(input())
x = list(map(int, input().split()))
xsort = sorted(x)

n1, n2 = xsort[n//2-1], xsort[n//2]

for i in range(n):
    if x[i]  <= n1:
        print(n2)
    else:
        print(n1)
### BUGGY CODE ###

s = list(input())
q = int(input())

for _ in range(q):
    t = [x for x in input().split()]
    if t[0] == "1":
        s.reverse()
    else:
        if t[1] == "1":
            s.insert(0,t[2])
        else:
            s.append(t[2])

print("".join(s))


### FIXED CODE ###

from collections import deque
s = deque(input())
q = int(input())

rev = False

for _ in range(q):
    t = [x for x in input().split()]
    if t[0] == "1":
        rev = not rev
    else:
        if t[1] == "1":
            s.append(t[2]) if rev else s.appendleft(t[2])
        else:
            s.appendleft(t[2]) if rev else s.append(t[2])

if rev:
    s.reverse()
print("".join(s))
### BUGGY CODE ###

N = int(input())
a = []
visited = []
place = 1
for i in range(N):
    a.append(int(input()))
for i in range(N):
    if place in visited:
        print(-1)
        exit()
    elif a[place - 1] == 2:
        print(i + 1)
        exit()
    else:
        visited.append(place)
        place = a[place - 1]

### FIXED CODE ###

N = int(input())
a = []
visited = []
place = 1
for i in range(N):
    a.append(int(input()))
for i in range(N):
    visited.append(place)
    place = a[place - 1]
if 2 in visited:
    print(visited.index(2))
else:
    print(-1)
### BUGGY CODE ###

k,s=map(int,input().split())
l=list(range(k+1))
count=0
for i in l:
    for j in l:
        for k in l:
            if i+j+k==s:
                count+=1
print(count)

### FIXED CODE ###

k,s=map(int,input().split())
l=list(range(k+1))
count=0
for i in l:
    for j in l:
        q=s-i-j
        if 0<=q<=k:
            count+=1
            
print(count)
### BUGGY CODE ###

# writer解(c++)を写経した．answerのfor文のところ何やってるかさっぱりわかりませんが…
# https://atcoder.jp/contests/m-solutions2020/submissions/15122924
import sys
input = sys.stdin.readline
INF = 10**13


def main():
    N = int(input())
    X = []
    Y = []
    P = []
    for _ in range(N):
        a, b, c = (int(i) for i in input().split())
        X.append(a)
        Y.append(b)
        P.append(c)
    X_dist = [[0]*N for _ in range(1 << N)]
    Y_dist = [[0]*N for _ in range(1 << N)]

    # bitという道路群を建設したときの，各集落の評価距離
    # bit 001001 とかの1が立っている集落に道を作る
    for bit in range(1 << N):
        cur_x = [0]
        cur_y = [0]
        for i in range(N):
            if bit & (1 << i):
                cur_x.append(X[i])
                cur_y.append(Y[i])
        for i in range(N):
            X_dist[bit][i] = P[i]*min(abs(cx - X[i]) for cx in cur_x)
            Y_dist[bit][i] = P[i]*min(abs(cy - Y[i]) for cy in cur_y)

    # これはなに？
    answer = [INF] * (N+1)
    for i in range(1 << N):
        cnt = 0
        for j in range(N):
            if (i >> j) & 1:
                cnt += 1
        for j in range(i+1)[::-1]:
            j &= i
            cost = 0
            for k in range(N):
                if not((i >> k) & 1):
                    cost += min(X_dist[j][k], Y_dist[i - j][k])
            answer[cnt] = min(answer[cnt], cost)

    for ans in answer:
        print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

# writer解(c++)を写経した．answerのfor文のところ何やってるかさっぱりわかりませんが…
# https://atcoder.jp/contests/m-solutions2020/submissions/15122924
import sys
input = sys.stdin.readline
INF = 10**13


def main():
    N = int(input())
    X = []
    Y = []
    P = []
    for _ in range(N):
        a, b, c = (int(i) for i in input().split())
        X.append(a)
        Y.append(b)
        P.append(c)
    X_dist = [[0]*N for _ in range(1 << N)]
    Y_dist = [[0]*N for _ in range(1 << N)]

    # bitという道路群を建設したときの，各集落の評価距離
    # bit 001001 とかの1が立っている集落に道を作る
    for bit in range(1 << N):
        for i in range(N):
            X_dist[bit][i] = P[i]*abs(X[i])
            Y_dist[bit][i] = P[i]*abs(Y[i])
            for k in range(N):
                if bit & (1 << k):
                    X_dist[bit][i] = \
                        min(X_dist[bit][i], P[i]*abs(X[i] - X[k]))
                    Y_dist[bit][i] = \
                        min(Y_dist[bit][i], P[i]*abs(Y[i] - Y[k]))

    # これはなに？
    answer = [INF] * (N+1)
    for i in range(1 << N):
        cnt = 0
        for j in range(N):
            if (i >> j) & 1:
                cnt += 1
        j = i
        while j >= 0:
            j &= i
            cost = 0
            for k in range(N):
                if not((i >> k) & 1):
                    cost += min(X_dist[j][k], Y_dist[i - j][k])
            answer[cnt] = min(answer[cnt], cost)
            j -= 1

    for ans in answer:
        print(ans)


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

a,b,q=[int(it) for it in input().split()]
dummy=10**20
s=[-dummy] + [int(input()) for it in range(a)] + [dummy]
t=[-dummy] + [int(input()) for it in range(b)] + [dummy]
x=[int(input()) for it in range(q)]

def find_left(l, p):
    a,b=0,len(l)-1
    while True:
        c=(a+b)//2
        if p <= l[c]:
            b = c-1
        elif l[c+1] <= p:
            a = c+1
        else:
            return c
def find_right(l, p):
    a,b=0,len(l)-1
    while True:
        c=(a+b)//2
        if p <= l[c-1]:
            b = c-1
        elif l[c] <= p:
            a = c+1
        else:
            return c
for xi in x:
    s_w = s[find_left(s, xi)]
    s_e = s[find_right(s, xi)]
    t_w = t[find_left(t, xi)]
    t_e = t[find_right(t, xi)]

    d = min(
        abs(xi - s_w) + abs(s_w - t_w),
        abs(xi - s_e) + abs(s_e - t_w),
        abs(xi - s_w) + abs(s_w - t_e),
        abs(xi - s_e) + abs(s_e - t_e),
        abs(xi - t_w) + abs(t_w - s_w),
        abs(xi - t_e) + abs(t_e - s_w),
        abs(xi - t_w) + abs(t_w - s_e),
        abs(xi - t_e) + abs(t_e - s_e)
    )
    print(d)


### FIXED CODE ###

import bisect

a,b,q=[int(it) for it in input().split()]
dummy=10**20
s=[-dummy] + [int(input()) for it in range(a)] + [dummy]
t=[-dummy] + [int(input()) for it in range(b)] + [dummy]
x=[int(input()) for it in range(q)]

for xi in x:
    s_w = s[bisect.bisect_left(s, xi)-1]
    s_e = s[bisect.bisect_left(s, xi)]
    t_w = t[bisect.bisect_left(t, xi)-1]
    t_e = t[bisect.bisect_left(t, xi)]

    d = min(
        abs(xi - s_w) + abs(s_w - t_w),
        abs(xi - s_e) + abs(s_e - t_w),
        abs(xi - s_w) + abs(s_w - t_e),
        abs(xi - s_e) + abs(s_e - t_e),
        abs(xi - t_w) + abs(t_w - s_w),
        abs(xi - t_e) + abs(t_e - s_w),
        abs(xi - t_w) + abs(t_w - s_e),
        abs(xi - t_e) + abs(t_e - s_e)
    )
    print(d)
### BUGGY CODE ###

from itertools import permutations

n, c = map(int, input().split())
D = [list(map(int, input().split())) for i in range(c)]
C = [list(map(int, input().split())) for i in range(n)]
zero = []
one = []
two = []
ans = float('Inf')
for i in range(n):
  for j in range(n):
    if (i + j) % 3 == 0:
      zero.append(C[i][j])
    elif (i + j) % 3 == 1:
      one.append(C[i][j])
    elif (i + j) % 3 == 2:
      two.append(C[i][j])

combo = list(permutations(range(0,c), 3))


for a, b, c in combo:
  temp = 0
  
  for v in zero:
    temp += D[v-1][a]
  for v in one:
    temp += D[v-1][b]
  for v in two:
    temp += D[v-1][c]

  ans = min(ans, temp)

print(ans)

### FIXED CODE ###

from itertools import permutations

n, c = map(int, input().split())
D = [list(map(int, input().split())) for i in range(c)]
C = [list(map(int, input().split())) for i in range(n)]
oc = []
for i in range(3):
  oc.append([0]*c)
ans = float('Inf')
for i in range(n):
  for j in range(n):
    if (i + j + 2) % 3 == 0:
      oc[0][C[i][j]-1] += 1
    elif (i + j + 2) % 3 == 1:
      oc[1][C[i][j]-1] += 1
    elif (i + j + 2) % 3 == 2:
      oc[2][C[i][j]-1] += 1

combo = list(permutations(range(0,c), 3))
for a, b, c in combo:
  temp = 0
  for i in range(len(oc[0])):
    temp += oc[0][i] * D[i][a]
    temp += oc[1][i] * D[i][b]
    temp += oc[2][i] * D[i][c]
  ans = min(ans, temp)

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

A,B,N = map(int, input().split())
ans = -1145141919810931931
Flag = True
for x in range(1, N+1, max(1, int(B/A) - 1)):
    a = int(A*x/B) - A*int(x/B)
    if a>=ans:
        ans = a
        Flag = True
    elif Flag:
        Flag = False
    else:
        break

a = int(A*N/B) - A*int(N/B)
if a>ans:
    ans = a
print(ans)

### FIXED CODE ###

A,B,N = map(int, input().split())
ans = 0
if N >= B:
    ans = int(A*(2*B-1)/B) - A*int((2*B-1)/B)
else:
    ans = int(A*N/B)
print(ans)
### BUGGY CODE ###

n=int(input())
c=list(map(int,input().split()))
k=n
u=n
for i in range(1,n):
    p=(c.count(i))
    print(p)
    k=k-p
    u=u-1
    if k<2:
        break
while u>0:
    print(0)
    u=u-1

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
d = dict()
for i in range(n):
    d[i] = 0
for e in a:
    d[e-1] += 1
for i in range(n):
    print(d[i])
### BUGGY CODE ###

import itertools
A, B = [], []
N, M = (int(x) for x in input().split())
for i in range(N):
    a, b = (int(x) for x in input().split())
    A.append(a)
    B.append(b)

Max = 0
list = []
for i in range(N):
    Max += A[i] * B[i]
    list.append(range(B[i]+1))

def SumOfList(l):
    ret = 0
    for i in l:
        ret += i
    return ret

def TotalFee(l):
    ret, index = 0, 0
    for z in l:
        ret += A[index] * z
        index += 1
    return ret

for l in itertools.product(*list):
    if SumOfList(l) == M and TotalFee(l) < Max:
        Max = TotalFee(l)

print(Max)

### FIXED CODE ###

List = []
N, M = (int(x) for x in input().split())
for i in range(N):
    a, b = (int(x) for x in input().split())
    List.append([a, b])

num_of_drink, total_fee = 0, 0
List = sorted(List, key=lambda x:x[0])

temp_M = M
list_of_num = []
for i in range(N):
    if temp_M <= List[i][1]:
        list_of_num.append(temp_M)
        break
    else:
        list_of_num.append(List[i][1])
        temp_M += -List[i][1]
index = 0
for x in list_of_num:
    total_fee += List[index][0] * x
    index += 1
print(total_fee)
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
ans=[]
for i in range(1,n+1):
    ans.append(a.count(i))
print(*ans,sep="\n")



### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
ans=[0]*n
for i in a:
    ans[i-1]+=1
for k in ans:
    print(k)
### BUGGY CODE ###

# -*- coding: utf-8 -*-


def main():
    from math import sqrt

    n, p = map(int, input().split())
    ans = 1
    numbers = set()

    for i in range(1, int(sqrt(p)) + 1):
        a, b = divmod(p, i)

        if b == 0:
            numbers.add(i)
            numbers.add(a)

    for number in numbers:
        c, d = divmod(p, number ** n)

        if d == 0 and number ** n <= p:
            ans = max(ans, number)

    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

# -*- coding: utf-8 -*-


def run_prime_factorization(max_number: int):
    from math import sqrt

    ans = dict()
    remain = max_number

    for j in range(2, int(sqrt(max_number)) + 1):
        if remain % j == 0:
            count = 0

            while remain % j == 0:
                count += 1
                remain //= j

            ans[j] = count

    if remain != 1:
        ans[remain] = 1

    return ans


def main():
    n, p = map(int, input().split())
    ans = 1

    # See:
    # https://www.youtube.com/watch?v=z0bIhkaSXY4
    results = run_prime_factorization(p)

    for base, exponent in results.items():
        ans *= base ** (exponent // n)

    print(ans)


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

import sys
MOD = 10**9 + 7
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
def adj(n): return [[] for _ in range(n)]

def inv(a): return pow(a, MOD-2, MOD) #逆元
def comb(n,r):
    ans = 1
    for i in range(r): ans *= n-i; ans *= inv(r-i); ans %= MOD
    return ans
    
n,k = imap()
for i in range(1,k+1):
    ans = comb(n-k+1, i) * comb(k-1, i-1)
    print(ans %MOD)


### FIXED CODE ###

import sys
MOD = 10**9 + 7
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
def adj(n): return [[] for _ in range(n)]

def inv(a): return pow(a, MOD-2, MOD) #逆元
def comb(n,r):
    ans = 1
    for i in range(r): ans *= n-i; ans *= inv(r-i); ans %= MOD
    return ans

    
n,k = imap()
ans = n-k+1
print(ans)
for i in range(2,k+1):
    ans *= (n-k-i+2) * (k-i+1) * inv(i) * inv(i-1)
    print(ans %MOD)
### BUGGY CODE ###

import datetime

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()
    
    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result


arr_data = getinputdata()

x = int(arr_data[0][0])
y = int(arr_data[0][1])


cnt=1

if x // y>=1 and x % y==0:
    
    print(-1)

else:
    while cnt<10**18:

        if cnt%x==0 and cnt%y!=0:

            print(cnt)
            break

        else:
            cnt+=1
            
#print(-1)



### FIXED CODE ###

import datetime

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()
    
    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result


arr_data = getinputdata()

x = int(arr_data[0][0])
y = int(arr_data[0][1])


cnt = 1
#
#if x // y>=1 and x % y==0:
#    
#    print(-1)
#
#else:
#    while cnt<10**18:
#
#        if cnt%x==0 and cnt%y!=0:
#
#            print(cnt)
#            break
#
#        else:
#            cnt+=1
#            
##print(-1)
#

if x // y >= 1 and x % y == 0:
    
    print(-1)
else:
    for i in range(x, 10 ** 18, x):

        if i % y != 0:

            print(i)
            break

    else:

        print(-1)
### BUGGY CODE ###

l = (1260-540+1)
while True:
	N,M = map(int,input().split(" "))
	if N == 0 and M == 0:
		break
	T = [[0]*l for _ in range(M)]
	r = int(input())
	for i in range(r):
		t,n,m,s = map(int,input().split(" "))
		if s == 1:
			T[m-1][t-540] += 1
		else:
			T[m-1][t-540] -= 1

	for i in range(M):
		for j in range(l-1):
			T[i][j+1] += T[i][j]

	q = int(input())
	for i in range(q):
		t1,t2,m = map(int,input().split(" "))
		ans = 0
		for t in range(t1-540,t2-540):
			if T[m-1][t] >= 1:
				ans += 1
		print(ans)




### FIXED CODE ###

l = (1260-540)+1
while True:
	N,M = map(int,input().split(" "))
	if N == 0 and M == 0:
		break
	T = [[0]*l for _ in range(M)]
	r = int(input())
	for i in range(r):
		t,n,m,s = map(int,input().split(" "))
		if s == 1:
			T[m-1][t-540] += 1
		else:
			T[m-1][t-540] -= 1

	q = int(input())
	used = {}
	for i in range(q):
		t1,t2,m = map(int,input().split(" "))
		if not (m-1) in used:
			T_range = []
			flg = True if T[m-1][0] >= 1 else False
			lb = 0
			for j in range(l-1):
				T[m-1][j+1] += T[m-1][j]
				if flg and T[m-1][j+1] == 0:
					T_range.append((lb+540,j+1+540))
					flg = False
				elif (not flg) and T[m-1][j+1] >= 1:
					flg = True
					lb = (j+1)
			if flg:
				T_range.append((lb+540,1261))
			used[m-1] = T_range

		ans = 0
		for a,b in used[m-1]:
			if not (b < t1 or t2 < a):
				ans += (min(t2,b) - max(t1,a))

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

N = int(input())
A = list(map(int,input().split()))
cnt = [0 for i in range(60)]
mod = 10 ** 9 + 7

for i in A:
    tmp = format(i, '060b')
    for j in range(60):
        if tmp[j] == "1":
            cnt[j] += 1

ans = 0

lst = [1 for i in range(60)]

for i in range(59):
    lst[58-i] = (lst[59-i] * 2) % mod

for i in range(60):
    ans += (lst[i] * cnt[i] * (N -cnt[i])) % mod
    
ans %= mod

print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
mod = 10 ** 9 + 7
cnt = [0 for _ in range(60)]
for a in A:
    for i in range(60):
        cnt[i] += a & 1
        a >>= 1
cnt = [x * (N - x) % mod for x in cnt]
power = 1
ans = 0
for i in range(60):
    ans += power * cnt[i]
    power *= 2
    power %= mod
ans %= mod
print(ans)
### BUGGY CODE ###

from math import factorial

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


def c(n, r):
    u = 1
    l = 1
    for i in range(min(r, n - r)):
        u *= n - i
        l *= i + 1
    return u // l


def solve(x, y):
    if (x + y) % 3 != 0:
        return 0
    if x * 2 < y or y * 2 < x:
        return 0
    
    n = (x + y) // 3
    r = ((x - y) + n) // 2
    return factorial(n) // factorial(r) // factorial(n - r)


print(solve(x, y) % 1000000007)

### FIXED CODE ###

MAX = 1000000
MOD = 1000000007

fac = [None] * MAX
finv = [None] * MAX
inv = [None] * MAX


def comb_init():
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, MAX):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD


def comb(n, k):
    if n < 0 or k < 0 or n < k:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD


comb_init()
x, y = [int(x) for x in input().split()]


def solve(x, y):

    if (x + y) % 3 != 0:
        return 0

    n = (2 * y - x) // 3
    m = (2 * x - y) // 3
    if n < 0 or m < 0:
        return 0

    return comb(n + m, n)


print(solve(x, y))
### BUGGY CODE ###

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

lst = []
for i in range(n):
    total = s[:i].count("W") + s[i+1:].count("E")
    lst = lst + [total]
    
print(min(lst))

### FIXED CODE ###

n = int(input())
s = input()
s_min = s[1:].count("E")
s_now = s[1:].count("E")

for i in range(1,n):
    if s[i-1] == "E" and s[i] == "E":
        s_now -= 1
    if s[i-1] == "W" and s[i] == "W":
        s_now += 1
    s_min = min(s_min, s_now)
print(s_min)