Harryxun/stf_run huggingface dataset:
import collections
N = int(input())
P = list(map(int,input().split()))
A = []
for i in range(N-1):
    if P[i]>P[i+1]:
        A.append([(P[i],i),(P[i+1],i+1)])
l = len(A)
if l > 2:
    print("NO")
elif l == 0:
    print("YES")
else:
    a = max(A[0])
    b = min(A[1])
    P[a[1]],P[b[1]] = b[0],a[0]
    #print(P)
    for j in range(N-1):
        if P[j] > P[j+1]:
            print("NO")
            break
    if j == N-2:
        print("YES")

### FIXED CODE ###

N = int(input())
P = list(map(int,input().split()))
A = []
for i in range(N-1):
    if P[i]>P[i+1]:
        A.append([(P[i],i),(P[i+1],i+1)])
l = len(A)
if l > 2 or l == 1:
    print("NO")
elif l == 0:
    print("YES")
elif l == 2:
    a = max(A[0])
    b = min(A[1])
    P[a[1]],P[b[1]] = b[0],a[0]
    for j in range(N-1):
        if P[j] > P[j+1]:
            print("NO")
            j = "j"
            break
    if j != "j":
        print("YES")
import sys
from functools import lru_cache
import random
#read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**6)
def input(): return sys.stdin.readline().rstrip()
def read():
  return int(readline())
def reads():
  return map(int, readline().split())
dic={}
n=read()
s=[]
for i in range(n):
  s.append(input())
for i in range(5*10**2):
  count=0
  for j in range(min(10**3,n)):
    b=random.randrange(0,max(len(s[j])-99,1))
    for k in range(b,min(len(s[j]),100+b)):
      if s[j][k]=="(":
              count+=1
      elif s[j][k]==")":
              count-=1
      else:raise Exception
  try:
    dic[count]+=1
  except:
    dic[count]=1
#print(dic)
try:
  if dic[0]>10:
    print("Yes")
  else:
    print("No")
except:print("No")

### FIXED CODE ###

import sys
from functools import lru_cache
 
#read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**6)
def read():
  return int(readline())
def reads():
  return map(int, readline().split())
def cmb(n, r):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % mod
n,m,k=reads()
N = n-1 # N は必要分だけ用意する
mod =  998244353
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod // i)) % mod)
    factinv.append((factinv[-1] * inv[-1]) % mod)

mod=998244353
numbers=[m]
for i in range(n-1):
  numbers.append(numbers[i]*(m-1)%mod)
ans=0
for i in range(k+1):
  ans+=numbers[n-i-1]*cmb(n-1,i)
ans%=mod
#print(numbers)
print(ans)
if A == B:
    print('YES')
elif A < B:
    print('NO')
else:
    if A + V * T >= B + W * T:
        print('YES')
    else:
        print('NO')

### FIXED CODE ###

A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

a_dis = V * T
b_dis = W * T
dis_diff = abs(B - A)

if dis_diff <= a_dis - b_dis:
    print('YES')
else:
    print('NO')
a, b = input()
c = a*b
if c%2==0:
  r = 'Even'
else:
  r = 'Odd'
  
print(r)

### FIXED CODE ###

a, b = map(int, input().split())
if (a*b) % 2:
    print("Odd")
else:
    print("Even")
n,l = map(int,input().split())
s = []
for i in range(l):
    s.append(input())
s.sort()
print(*s,sep="")

### FIXED CODE ###

n,l = map(int,input().split())
s = []
for i in range(n):
    s.append(input())
s.sort()
print(*s,sep="")
q = int(input())
p = [False]*(10**5)
c = [0]*(10**5)
temp = [True]*(N+1)
temp[0] = False
temp[1] = False
for i in range(2, 10**5):
  c[i] = c[i-1]
  if temp[i]:
    temp[2*i::i] = [False]*(len(temp[i+i::i]))
    if temp[(i+1)//2] and i%2:
      c[i] += 1

for _ in range(q):
  l, r = map(int, input().split())
  print(c[r] - c[l-1])

### FIXED CODE ###

q = int(input())
p = [False]*(10**5)
c = [0]*(10**5)
temp = [True]*(10**5)
temp[0] = False
temp[1] = False
for i in range(2, 10**5):
  c[i] = c[i-1]
  if temp[i]:
    temp[2*i::i] = [False]*(len(temp[i+i::i]))
    if temp[(i+1)//2] and i%2:
      c[i] += 1

for _ in range(q):
  l, r = map(int, input().split())
  print(c[r] - c[l-1])
N_input = int(input())
t_input = []
x_input = []
y_input = []

for _ in range(N_input):
    t, x, y = map(int, input().split())
    t_input.append(t)
    x_input.append(x)
    y_input.append(y)

def rest_travel(t_now, n_now, x_now, y_now): # 現在時刻t、通過済チェックポイント数n、現在位置x, y
    if t_now == max(t_input): # ゴール
        print("Yes")
        exit()
    elif t_input[n_now] == t_now+1:  # 次の移動で目標地点に到着している必要あり
        if abs(x_input[n_now] - x_now) + abs(y_input[n_now] - y_now) == 1:  # 次の地点との距離が1なら到達可能
            rest_travel(t_now+1, n_now+1, x_input[n_now], y_input[n_now])
        else: # 到達不可。探索終了
            return
    else: # ゴールしておらず、次の移動で目標地点に到着している必要がない
        rest_travel(t_now+1, n_now, x_now+1, y_now)
        rest_travel(t_now+1, n_now, x_now, y_now+1)
        rest_travel(t_now+1, n_now, x_now-1, y_now)
        rest_travel(t_now+1, n_now, x_now, y_now-1)

rest_travel(0,0,0,0)
print("No")

### FIXED CODE ###

N = int(input())

t_b = x_b = y_b = 0 # 直前の時刻と位置保存用

def dist(x, x_b, y, y_b):
    return abs(x-x_b) + abs(y-y_b)

miss_flg = 0

for i in range(N):
    t, x, y = map(int, input().split())
    if dist(x, x_b, y, y_b) > t - t_b or ((t - t_b) + dist(x, x_b, y, y_b))% 2 == 1: # 到達不能もしくは距離と残り時間の偶奇が不一致
        miss_flg = 1
    t_b, x_b, y_b = t, x, y

print("Yes" if miss_flg == 0 else "No")
def resolve():
    N = int(input())
    H = list(map(int, input().split()))
    ans = []
    count = 0
    for i in range(len(H) - 1):
        if H[i] >= H[i + 1]:
            count += 1
        else:
            ans.append(count)
            count = 0
    if count != 0:
        ans.append(count)
    print(max(ans))
resolve()

### FIXED CODE ###

def resolve():
    N = int(input())
    H = list(map(int, input().split()))
    ans = [0]
    count = 0
    for i in range(len(H) - 1):
        if H[i] >= H[i + 1]:
            count += 1
        else:
            ans.append(count)
            count = 0
    if count != 0:
        ans.append(count)
    print(max(ans))
resolve()
P, n = map(int, input().split())
struct = [list(map(int, input().split())) for x in range(P-1)]
act = [list(map(int, input().split())) for y in range(n)]

A = []


def add_val(action):
    idx = action[0]
    val = action[1]

    A[idx][0] += val

    if A[idx][1]:
        for r in A[idx][1]:
            add_val([r, val])


for a in range(P + 1):
    A.append(list([0, []]))

for z in struct:
    p = z[0]
    p_ = z[1]
    A[p][1].append(p_)

for _ in act:
    add_val(_)


As = []
for _ in range(1, len(A)):
    As.append(A[_][0])

print(*As, sep=' ')




### FIXED CODE ###

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

if n >= 3200:
  print(s)
else:
  print('red')
from math import factorial

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

def cmb(n,r):
    return factorial(n) / (factorial(r) * factorial(n-r))

for i in range(1,k+1):
    if i > n-k+1:
        print(0)
    else:
        x = cmb(k-1,i-1) % mod
        y = cmb(n-k+1,i) % mod
        ans = (x*y) % mod
        print(int(ans))

### FIXED CODE ###

from math import factorial

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

def cmb(n,r):
    return factorial(n) // (factorial(r) * factorial(n-r))

for i in range(1,k+1):
    if n-k+1 < i or k-1 < i-1:
        print(0)
    else:
        x = cmb(k-1,i-1) % mod
        y = cmb(n-k+1,i) % mod
        ans = (x*y) % mod
        print(int(ans))
N = input()
Ti = []

def gcd(a,b):
    gcd = 1
    for i in range(2,a+1):
        if a%i == 0 and b%i == 0:
            gcd = i
    return gcd

for i in range(int(N)):
    tmp = input()
    Ti.append(int(tmp))
Ti.sort()

ans_gcd = gcd(Ti[0],Ti[1])
ans_lcm = (Ti[0]*Ti[-1])/ans_gcd
for i in range(2,len(Ti)):
    ans_gcd = gcd(ans_gcd,Ti[i])
    ans_lcm = (ans_gcd*Ti[-1])/ans_gcd

print(int(ans_lcm))

### FIXED CODE ###

def gcd(a,b):
    m = max(a,b)
    n = min(a,b)
    if n==0:
        return m
    return gcd(n, m%n)

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

N = input()
Ti = []

for i in range(int(N)):
    tmp = input()
    Ti.append(int(tmp))

ans_lcm = 1
for i in range(len(Ti)):
    ans_lcm = lcm(ans_lcm,Ti[i])
print(ans_lcm)
import sys
input=sys.stdin.readline
n=int(input())
s=list(input())
r=[]
g=[]
b=[]
for i in s:
    if i=='R':
        r.append(i)
    elif i=='G':
        g.append(i)
    else:
        b.append(i)
ans=len(r)*len(g)*len(b)
r=set(r)
g=set(g)
b=set(b)
for i in r:
    for j in g:
        if (i+j)%2==0 and (i+j)//2 in b:
            ans-=1
for i in r:
    for j in b:
        if (i+j)%2==0 and (i+j)//2 in g:
            ans-=1
for i in b:
    for j in g:
        if (i+j)%2==0 and (i+j)//2 in r:
            ans-=1
print(ans)

### FIXED CODE ###

import sys
input=sys.stdin.readline
n=int(input())
s=list(input())
r=[]
g=[]
b=[]
for i in range(n):
    if s[i]=='R':
        r.append(i)
    elif s[i]=='G':
        g.append(i)
    else:
        b.append(i)
ans=len(r)*len(g)*len(b)
r=set(r)
g=set(g)
b=set(b)
for i in r:
    for j in g:
        if (i+j)%2==0 and ((i+j)//2 in b):
            ans-=1
for i in r:
    for j in b:
        if (i+j)%2==0 and ((i+j)//2 in g):
            ans-=1
for i in b:
    for j in g:
        if (i+j)%2==0 and ((i+j)//2 in r):
            ans-=1
print(ans)
def solve(N: int, W: int, w: "List[int]", v: "List[int]"):
    dp = [[0]*(W+1) for _ in range(N+2)]
    #dp = [0]*(W+1)
    for i in range(N):
        for sum_w in range(W):
            if sum_w+w[i] <=W:
                dp[i+1][sum_w+w[i]] = max(dp[i][sum_w+w[i]], dp[i][sum_w]+v[i])
                #dp[sum_w+w[i]] = max(dp[sum_w+w[i]], dp[sum_w]+v[i])
            #dp[i+1][sum_w] = dp[i][sum_w]
        dp[i+2] = dp[i+1].copy()
    return max(dp[-1])

N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]
w,v=[], []
for i in wv:
    w.append(i[0])
    v.append(i[1])

print(solve(N, W, w, v))

### FIXED CODE ###

import copy

def solve(N, W, w, v):
    dp = [[0]*(W+1) for _ in range(N+2)]
    for i in range(N):
        for sum_w in range(W):
            if sum_w+w[i] <=W:
                dp[i+1][sum_w+w[i]] = max(dp[i][sum_w+w[i]], dp[i][sum_w]+v[i])
        dp[i+2] = copy.copy(dp[i+1])
    return max(dp[-1])

N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]
w,v=[], []
for i in wv:
    w.append(i[0])
    v.append(i[1])

print(solve(N, W, w, v))
n,k = map(int,input().split())
mod = 10**9+7
anwer = 0

for i in range(k,n+1)

max_value = sum(range(n-i+1,n+1))
lowest_value = sum(range(1,i+1))
 
answer = answer + max_value - lowest_value + 1
 
print(answer % mod)

### FIXED CODE ###

n,k = map(int,input().split())
mod = 10**9+7
answer = 0

for i in range(k,n+2):
  answer = answer + (n-i+1)*i + 1

print(answer % mod)
A, B = map(int, input().split())
import math
print(A*B//math.gcd(A,B))

### FIXED CODE ###

A, B = map(int, input().split())
import fractions
print(A*B//fractions.gcd(A,B))
s,t =input().split()
a,b = map(int, input().split())
u = input()

print(f'{s} {t}')

# if s == u:
#     a-=1
#     print(f'{a} {b}')
# else:
#     b-=1
#     print(f'{a} {b}')


### FIXED CODE ###

s,t =input().split()
a,b = map(int, input().split())
u = input()


if u == s:
    print(a-1, b)
elif u == t:
    print(a, b-1)
def judgePrime(n):
  result = True
  for i in xrange(2, n):
    if n % i == 0:
      result = False
      break
  return result

def getPrimeNumFromList(list):
  count = 0
  for i in xrange(len(list)):
    target = 0
    if i == 0:
      target = list[0]
      if judgePrime(target):
        count += 1
    else:

  return count

n = int(raw_input())
list = []
for i in xrange(n):
  list.append(int(raw_input()))
list.sort()
#print judgePrime(list[len(list) - 1])
print getPrimeNumFromList(list)

### FIXED CODE ###

import pdb

n = int(raw_input())
count = 0
for x in xrange(n):
  target = int(raw_input())
  # pdb.set_trace()
  if target == 2:
    count += 1
  elif target < 3 or not target & 1:
    continue
  else:
    if pow(2, target - 1, target) == 1:
      count += 1

print count
# -*- coding: utf-8 -*-
#DISCO C
import sys
import math
import collections
#sys.setrecursionlimit(100000)

#n=int(input())

tmp = input().split()
h,w,k = list(map(lambda a: int(a), tmp))

list = [[0 for i in range(w+1)] for j in range(h)]
for i in range(0,h):
	tmp = input()
	for j in range(0,w):
		if(tmp[j]=='#'):
			list[i][j]+=1
			list[i][w]+=1

ans = [[0 for i in range(w)] for j in range(h)]
index=1
for i in range(0,h):
	if(list[i][w]!=0):
		flg=0
		for j in range(0,w):
#			print(index)
			if(list[i][j]==1):
				if(flg==0):
					flg=1
				else:
					index+=1
			ans[i][j] = index
		index+=1
#			print(list[i][j])
for i in range(1,h):
	if(list[i][w]==0)and(list[i-1][w]!=0):
		for j in range(0,w):
			ans[i][j]=ans[i-1][j]
		list[i][w]==1
for i in range(1,h):
	if(list[h-i][w]==0)and(list[h-i+1][w]!=0):
		for j in range(0,w):
			ans[h-i][j]=ans[h-i+1][j]
		list[h-i][w]==1

#print(list)
#print(ans)


for i in range(0,h):
	outstr=""
	for j in range(0,w):
		outstr+=str(ans[i][j])
		if(j!=w-1):
			outstr+=" "
	print(outstr)




### FIXED CODE ###

# -*- coding: utf-8 -*-
#DISCO C
import sys
import math
import collections
#sys.setrecursionlimit(100000)

#n=int(input())

tmp = input().split()
h,w,k = list(map(lambda a: int(a), tmp))

list = [[0 for i in range(w+1)] for j in range(h)]
for i in range(0,h):
	tmp = input()
	for j in range(0,w):
		if(tmp[j]=='#'):
			list[i][j]+=1
			list[i][w]+=1

ans = [[0 for i in range(w)] for j in range(h)]
index=1
for i in range(0,h):
	if(list[i][w]!=0):
		flg=0
		for j in range(0,w):
			if(list[i][j]==1):
				if(flg==0):
					flg=1
				else:
					index+=1
			ans[i][j] = index
		index+=1
for i in range(1,h):
	if(list[i][w]==0)and(list[i-1][w]!=0):
		for j in range(0,w):
			ans[i][j]=ans[i-1][j]
		list[i][w]=1
for i in range(1,h):
	if(list[h-i-1][w]==0):
		for j in range(0,w):
			ans[h-i-1][j]=ans[h-i][j]
		list[h-i-1][w]=1

#print(list)
#print(ans)


for i in range(0,h):
	outstr=""
	for j in range(0,w):
		outstr+=str(ans[i][j])
		if(j!=w-1):
			outstr+=" "
	print(outstr)
N,T=map(int,input().split())
cc=1000
for i in range(N):
  c,t=map(int,input().split())
  if cc>c and T=>t:
    cc=c
if cc==1000:
  print("TLE")
else:
  print(cc)

### FIXED CODE ###

N,T=map(int,input().split())
cc=1001
for i in range(N):
  c,t=map(int,input().split())
  if cc>c and T>=t:
    cc=c
if cc==1001:
  print("TLE")
else:
  print(cc)
N = input()
list_input = map(int, raw_input().split())

list_input = sorted(list_input)
sums = 0
for i in range(N,2*N):
    sums += list_input[i]

print(sums)

### FIXED CODE ###

N = int(raw_input())
L = map(int,raw_input().split())
L.sort(reverse = True)
ans = 0
for i in xrange(N):
    ans += min(L[2*i],L[2*i+1])
print ans
n=int(input())
if n=="A":
  print("T")
if n=="T":
  print("A")
if n=="C":
  print("G")
if n=="G":
  print("C")

### FIXED CODE ###

n=str(input())
if n=="A":
  print("T")
if n=="T":
  print("A")
if n=="C":
  print("G")
if n=="G":
  print("C")
from collections import Counter
s=input()
c=Counter(s)
flag=0
a=c.values()
for i in range(len(a)):
  if a[i]%2==1:
    flag=1
    break
if flag==0:
  print("Yes")
else:
  print("No")


### FIXED CODE ###

from collections import Counter
s=input()
c=Counter(s)
flag=0
a=list(c.values())
for i in range(len(a)):
  if a[i]%2==1:
    flag=1
    break
if flag==0:
  print("Yes")
else:
  print("No")
nums = input().split()
a = int(nums[0])
b = int(nums[1])
c = int(nums[2])
if a < b < c:
    print('Yes')
elif;
    print('No')

### FIXED CODE ###

nums = input().split()
a = int(nums[0])
b = int(nums[1])
c = int(nums[2])
if a < b < c:
    print('Yes')
else:
    print('No')
date= [
    [[0 for r in range(10)] for f in range(3)] for b in range(4)
    ]

count = int(input())
for c in range(count):
    b, f, r, v = [int(i) for i in input().split()]
    data[b - 1][f - 1][r - 1] += v

for bi, b in enumerate(data):
    for f in b:
        for r in f:
            print(' {0}'.format(r), end='')

        print()
    if bi < 3:
        print('#' * 20)

### FIXED CODE ###

data = [
    [[0 for r in range(10)] for f in range(3)] for b in range(4)
    ]

count = int(input())
for c in range(count):
    b, f, r, v = [int(i) for i in input().split()]
    data[b - 1][f - 1][r - 1] += v

for bi, b in enumerate(data):
    for f in b:
        for r in f:
            print(' {0}'.format(r), end='')

        print()
    if bi < 3:
        print('#' * 20)
import math
import fractions
"""
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd (a, b)
"""
n=int(input())
A=list(map(int,input().split()))

a=A[0]
for b in A:
    #a=lcm(a,b)
    a = a /fractions.gcd(a, b)*b

count=0
[count+=a/i for i in A]
    #count+=a/i
    #if count>(10**9)+7:
    #    count=count%((10**9)+7)
print(math.floor(count%((10**9)+7)))

### FIXED CODE ###

import fractions
n=int(input())
A=list(map(int,input().split()))

a=A[0]
for b in A:
    a = (a * b) // fractions.gcd(a, b)

count=0
for i in A:
    count+=a//i

print((count%((10**9)+7)))
from statistics import mean

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

S = [A[0]]
for i in range(1, N):
    S.append(S[i - 1] + A[i])   

A = 0
C = 0
SUM_ALL = S[-1]
answer = SUM_ALL

for B in range(2, N - 1):
    C = max(B + 1, C)
    SA = S[A]
    SB = S[B] - S[A]
    SC = S[C] - S[B]
    SD = SUM_ALL - S[C]

    left_score = abs(SA - SB)
    while True:
        A_ = A + 1
        SA_ = S[A_]
        SB_ = S[B] - SA_
        diff = abs(SA_ - SB_)
        if left_score > diff:
            A, SA, SB, left_score = A_, SA_, SB_, diff
        else:
            break
    
    right_score = abs(SD - SC)
    while True:
        C_ = C + 1
        SC_ = S[C_]
        SD_ = SUM_ALL - SD_
        diff = abs(SC_ - SD_)
        if right_score > diff:
            C, SC, SD, right_score = C_, SC_, SD_, diff
        else:
            break
    
    score = max(SA, SB, SC, SD) - min(SA, SB, SC, SD)
    answer = min(score, answer)

print(answer)




### FIXED CODE ###

from statistics import mean

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

S = [A[0]]
for i in range(1, N):
    S.append(S[i - 1] + A[i])   

left_middle = 0
right_middle = 2

ans = float('inf')

for middle in range(1, N - 2):
    left_sum = S[left_middle]
    right_sum = S[middle] - left_sum
    diff = abs(left_sum - right_sum)

    for i in range(left_middle+1, middle):
        left_sum = S[i]
        right_sum = S[middle] - left_sum
        if diff > abs(left_sum - right_sum):
            left_middle = i
            diff = abs(left_sum - right_sum)
        else:
            break
    
    left_sum = S[right_middle] - S[middle]
    right_sum = S[-1] - S[right_middle]
    diff = abs(left_sum - right_sum)

    for i in range(right_middle + 1, N):
        left_sum = S[i] - S[middle]
        right_sum = S[-1] - S[i]
        if diff > abs(left_sum - right_sum):
            right_middle = i
            diff = abs(left_sum - right_sum)
        else:
            break
    
    s1 = S[left_middle]
    s2 = S[middle] - s1
    s3 = S[right_middle] - s1 - s2
    s4 = S[-1] - s1 - s2 - s3

    score = max(s1, s2, s3, s4) - min(s1, s2, s3, s4)
    ans = min(ans, score)

print(ans)
a = int(input())
  print(2 * a * 3.1415926)

### FIXED CODE ###

import math
a = int(input())
print(2 * a * math.pi)
import sys
import math
cin = sys.stdin.readline
n, x, t = map(int, cin().split())

count = math.ceil(n / x)
print(count * t)


### FIXED CODE ###

import sys
cin = sys.stdin.readline
n = list(cin())
ans = 0

n.pop(-1)
for i in n:
    ans += int(i)
if ans % 9 == 0:
    print('Yes')
else:
    print("No")
r = input()

print(3*r*r)

### FIXED CODE ###

r = int(input())

print(3*r*r)
a, b = map(int, input().split())
multi = math.ceil((a + b) / 2)

print(str(multi))

### FIXED CODE ###


import math
a, b = map(int, input().split())
multi = math.ceil((a + b) / 2)

print(str(multi))
raw_input = input
input1 = raw_input()
print 1000 - int(input1) % 1000

### FIXED CODE ###

input1 = input()
result = 1000 - int(input1) % 1000
if result == 1000:
    print(0)
else:
    print(result)
def prepare(n, MOD):
    f = 1
    for m in range(1, n + 1):
        f *= m
        f %= MOD
    fn = f

    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    return fn, invs


def solve(x, y):
    d, m = divmod(x + y, 3)
    if m != 0:
        return 0
    c = abs(d - x)

    MOD = 10 ** 9 + 7

    f, invs = prepare(d, MOD)

    return f * invs[c] * invs[d - c] % MOD


x, y = map(int, input().split())
print(solve(x, y))


### FIXED CODE ###

def prepare(n, MOD):
    f = 1
    for m in range(1, n + 1):
        f *= m
        f %= MOD
    fn = f

    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    return fn, invs


def solve(x, y):
    d, m = divmod(x + y, 3)
    if m != 0 or x / y > 2 or y / x > 2:
        return 0
    c = abs(d - x)

    MOD = 10 ** 9 + 7
    f, invs = prepare(d, MOD)
    return f * invs[c] * invs[d - c] % MOD


x, y = map(int, input().split())
print(solve(x, y))
# 写経
# https://atcoder.jp/contests/m-solutions2020/submissions/15454214

import sys
import numpy as np
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
XYP = np.array(read().split(), np.int64)

def resolve():
	X, Y, P = XYP[::3], XYP[1::3], XYP[2::3]
	N = len(X)
	X_cost = np.empty((1 << N,N), np.int64)
	X_cost[0] = np.abs(X) * P
	for n in range(N):
		B = 1 << n
		X_cost[B:2 * B] = np.minimum(X_cost[:B], np.abs((X-X[n]) * P))
	#print(X_cost)
	Y_cost = np.empty((1 << N,N), np.int64)
	Y_cost[0] = np.abs(Y) * P
	for n in range(N):
		B = 1 << n
		Y_cost[B:2 * B] = np.minimum(Y_cost[:B], np.abs((Y-Y[n]) * P))
	#print(Y_cost)
	popcount = np.zeros(1 << N, np.int64)
	for n in range(N):
		popcount[1 << n:1 << n + 1] = popcount[:1 << n] + 1
	#print(popcount)

	INF = 10**18
	ans = np.full(N + 1, INF, np.int64)
	for s in range(1 << N):
		size = popcount[s]
		t = s
		#print("s" + str(s))
		#print("size" + str(size))
		while True:
			u = s ^ t
			#print("u" + str(u))
			#print("t" + str(t))
			cost = (np.minimum(X_cost[t], Y_cost[u])).sum()
			ans[size] = min(ans[size], cost)
			if t == 0:
				break
			t = (t - 1) & s
	for Ans in ans:
		print(Ans)
if sys.argv[-1] == 'ONLINE_JUDGE':
	import numba
	from numba.pycc import CC
	i8 = numba.int64
	cc = CC('my_module')
 
	def cc_export(f, signature):
		cc.export(f.__name__, signature)(f)
		return numba.njit(f)
 
	main = cc_export(main, (i8[:], ))
	cc.compile()
 
from my_module import main

resolve()

### FIXED CODE ###

# 写経
# https://atcoder.jp/contests/m-solutions2020/submissions/15454214

import sys
import numpy as np
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def resolve(XYP):
	X, Y, P = XYP[::3], XYP[1::3], XYP[2::3]
	N = len(X)
	X_cost = np.empty((1 << N,N), np.int64)
	X_cost[0] = np.abs(X) * P
	for n in range(N):
		B = 1 << n
		X_cost[B:2 * B] = np.minimum(X_cost[:B], np.abs((X-X[n]) * P))
	#print(X_cost)
	Y_cost = np.empty((1 << N,N), np.int64)
	Y_cost[0] = np.abs(Y) * P
	for n in range(N):
		B = 1 << n
		Y_cost[B:2 * B] = np.minimum(Y_cost[:B], np.abs((Y-Y[n]) * P))
	#print(Y_cost)
	popcount = np.zeros(1 << N, np.int64)
	for n in range(N):
		popcount[1 << n:1 << n + 1] = popcount[:1 << n] + 1
	#print(popcount)

	INF = 10**18
	ans = np.full(N + 1, INF, np.int64)
	for s in range(1 << N):
		size = popcount[s]
		t = s
		#print("s" + str(s))
		#print("size" + str(size))
		while True:
			u = s ^ t
			#print("u" + str(u))
			#print("t" + str(t))
			cost = (np.minimum(X_cost[t], Y_cost[u])).sum()
			ans[size] = min(ans[size], cost)
			if t == 0:
				break
			t = (t - 1) & s
	return ans 

if sys.argv[-1] == 'ONLINE_JUDGE':
	import numba
	from numba.pycc import CC
	i8 = numba.int64
	cc = CC('my_module')
 
	def cc_export(f, signature):
		cc.export(f.__name__, signature)(f)
		return numba.njit(f)
 
	resolve = cc_export(resolve, (i8[:], ))
	cc.compile()
 
from my_module import resolve

N = int(readline())
XYP = np.array(read().split(), np.int64)

ans = resolve(XYP)
print('\n'.join(map(str, ans.tolist())))