Вот и код)
import java.util.*;
import java.math.BigInteger;
public class LuckyTickets {
static int MAXN = 50;
static int MAXS = 1000;
static BigInteger[][] mem=new BigInteger[MAXN + 1][MAXS + 1];
static BigInteger z=BigInteger.valueOf(0);
static BigInteger calc(int n, int s) {
if (mem[n][s].compareTo(z)>=0)
return mem[n][s];
if (n == 0) {
if (s == 0) return BigInteger.ONE;
return z;
}
mem[n][s] = z;
for (int i = 0; i < 10; i++) {
if (s - i >= 0)
mem[n][s]=(mem[n][s].add(calc(n - 1, s - i)));
}
return mem[n][s];
}
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int s=sc.nextInt();
if (s % 2 != 0) {
System.out.println(0);
return;
}
BigInteger one=BigInteger.valueOf(-3);
s /= 2;
for(int i=0;i<51;i++){
for(int j=0;j<1001;j++){
mem[i][j]=one;
}
}
BigInteger ans=calc(n, s).multiply(calc(n, s));
System.out.println(ans);
}
}