Problem:
Score : 400 points

Problem Statement

There is a knight - the chess piece - at the origin (0, 0) of a two-dimensional grid.

When the knight is at the square (i, j), it can be moved to either (i+1,j+2) or (i+2, j+1).

In how many ways can the knight reach the square (X, Y)?

Find the number of ways modulo 10^9 + 7.

Constraints

1 \leq X \leq 10^6

1 \leq Y \leq 10^6

All values in input are integers.

Input

Input is given from Standard Input in the following format:

X Y

Output

Print the number of ways for the knight to reach (X, Y) from (0, 0), modulo 10^9 + 7.

Sample Input 1

3 3

Sample Output 1

2

There are two ways: (0,0) \to (1,2) \to (3,3) and (0,0) \to (2,1) \to (3,3).

Sample Input 2

2 2

Sample Output 2

0

The knight cannot reach (2,2).

Sample Input 3

999999 999999

Sample Output 3

151840682

Print the number of ways modulo 10^9 + 7.

Solution in C# (Mono 4.6.2.0) (judge verdict: Wrong Answer)

using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;


class Program {


	static long mod = 1000000007;
	//static long mod =998244353; 
	static void Main(string[] args) {

		char[] cs = new char[] { ' ' };
		//char[] cs = new char[] { ' ', ',' };

		//int n = int.Parse(Console.ReadLine());
		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		//string res = "";


		long res = 0;



		int[] vals = parseAry(Console.ReadLine().Split(cs));

		//int[] vals = new int[2]; ;
		int xp = vals[0] % 3;
		int yp = vals[1] % 3;
		if ( ( xp == 0 && yp == 0 ) || ( xp == 1 && yp == 2 ) || ( xp == 2 && yp == 1 ) ) { } else { Console.WriteLine(0); return; }

		int xx = vals[0];
		int yy = vals[1];
		int yoko = 0;
		int dan = 0;
		while ( true ) {
			if ( ( xx * 2 ) == yy ) { dan = xx; break; }
			xx--;
			yy++;
			yoko++;
		}
		res=combination(dan, yoko);

			Console.WriteLine(res);

		return;

	}

	
static long combination(long n, long r) {
  if ( r * 2 > n ) r = n - r;
  long dividend = 1;
  long divisor  = 1;
  for ( long i = 1; i <= r; ++i ) {
    dividend =(dividend* (n-i+1))%mod;
    divisor  =(divisor*i)%mod;
  }
  return dividend * mod_pow(divisor, mod - 2)%mod;
 // return dividend / divisor;
}
//	x^nを求める
static public long mod_pow(long x, long n) {
	long mod = 1000000007;
	long res = 1;
	while ( n > 0 ) {
		if ( ( n & 1 ) == 1 ) { res = res * x % mod; }
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}

	//	int配列をスペース区切りの文字列に変換
	static string stringBuilderArrayInt(int[] a) {
		StringBuilder sb = new StringBuilder();

		for ( int i = 0; i < a.Length; i++ ) {
			sb.Append(a[i] + " "); 
		}
		if ( sb.Length > 1 ) {
			sb = sb.Remove(sb.Length - 1, 1);
		}
		return sb.ToString(); ;
	}


	//	文字列strをindex番目からdで上書き
	static string strOverWrite(string str, int i, string s) {
		return str.Remove(i, s.Length).Insert(i, s);
	}

	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryL(string[] str) {
		long[] nums = new long[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = long.Parse(str[i]); }
		return nums;
	}

	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { re[i] = str[i].ToString(); }
		return re;
	}



}