Problem p00070 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <map>
using namespace std;
int main() {
  int n, s;
  map<pair<int, int>, int> data;
  data[make_pair(1, 0)] = 1;
  data[make_pair(1, 1)] = 1;
  data[make_pair(1, 2)] = 1;
  data[make_pair(1, 3)] = 1;
  data[make_pair(1, 4)] = 1;
  data[make_pair(1, 5)] = 1;
  data[make_pair(1, 6)] = 1;
  data[make_pair(1, 7)] = 1;
  data[make_pair(1, 8)] = 1;
  data[make_pair(1, 9)] = 1;
  data[make_pair(2, 1)] = 1;
  data[make_pair(2, 2)] = 2;
  data[make_pair(2, 3)] = 1;
  data[make_pair(2, 4)] = 3;
  data[make_pair(2, 5)] = 3;
  data[make_pair(2, 6)] = 3;
  data[make_pair(2, 7)] = 4;
  data[make_pair(2, 8)] = 5;
  data[make_pair(2, 9)] = 4;
  data[make_pair(2, 10)] = 5;
  data[make_pair(2, 11)] = 5;
  data[make_pair(2, 12)] = 4;
  data[make_pair(2, 13)] = 5;
  data[make_pair(2, 14)] = 5;
  data[make_pair(2, 15)] = 4;
  data[make_pair(2, 16)] = 5;
  data[make_pair(2, 17)] = 5;
  data[make_pair(2, 18)] = 4;
  data[make_pair(2, 19)] = 5;
  data[make_pair(2, 20)] = 4;
  data[make_pair(2, 21)] = 3;
  data[make_pair(2, 22)] = 3;
  data[make_pair(2, 23)] = 3;
  data[make_pair(2, 24)] = 1;
  data[make_pair(2, 25)] = 2;
  data[make_pair(2, 26)] = 1;
  data[make_pair(3, 4)] = 1;
  data[make_pair(3, 5)] = 3;
  data[make_pair(3, 6)] = 2;
  data[make_pair(3, 7)] = 6;
  data[make_pair(3, 8)] = 5;
  data[make_pair(3, 9)] = 6;
  data[make_pair(3, 10)] = 8;
  data[make_pair(3, 11)] = 13;
  data[make_pair(3, 12)] = 8;
  data[make_pair(3, 13)] = 16;
  data[make_pair(3, 14)] = 14;
  data[make_pair(3, 15)] = 14;
  data[make_pair(3, 16)] = 16;
  data[make_pair(3, 17)] = 23;
  data[make_pair(3, 18)] = 15;
  data[make_pair(3, 19)] = 26;
  data[make_pair(3, 20)] = 22;
  data[make_pair(3, 21)] = 21;
  data[make_pair(3, 22)] = 24;
  data[make_pair(3, 23)] = 30;
  data[make_pair(3, 24)] = 19;
  data[make_pair(3, 25)] = 31;
  data[make_pair(3, 26)] = 26;
  data[make_pair(3, 27)] = 22;
  data[make_pair(3, 28)] = 26;
  data[make_pair(3, 29)] = 31;
  data[make_pair(3, 30)] = 19;
  data[make_pair(3, 31)] = 30;
  data[make_pair(3, 32)] = 24;
  data[make_pair(3, 33)] = 21;
  data[make_pair(3, 34)] = 22;
  data[make_pair(3, 35)] = 26;
  data[make_pair(3, 36)] = 15;
  data[make_pair(3, 37)] = 23;
  data[make_pair(3, 38)] = 16;
  data[make_pair(3, 39)] = 14;
  data[make_pair(3, 40)] = 14;
  data[make_pair(3, 41)] = 16;
  data[make_pair(3, 42)] = 8;
  data[make_pair(3, 43)] = 13;
  data[make_pair(3, 44)] = 8;
  data[make_pair(3, 45)] = 6;
  data[make_pair(3, 46)] = 5;
  data[make_pair(3, 47)] = 6;
  data[make_pair(3, 48)] = 2;
  data[make_pair(3, 49)] = 3;
  data[make_pair(3, 50)] = 1;
  data[make_pair(4, 10)] = 1;
  data[make_pair(4, 11)] = 4;
  data[make_pair(4, 12)] = 4;
  data[make_pair(4, 13)] = 9;
  data[make_pair(4, 14)] = 11;
  data[make_pair(4, 15)] = 14;
  data[make_pair(4, 16)] = 16;
  data[make_pair(4, 17)] = 25;
  data[make_pair(4, 18)] = 20;
  data[make_pair(4, 19)] = 32;
  data[make_pair(4, 20)] = 29;
  data[make_pair(4, 21)] = 38;
  data[make_pair(4, 22)] = 38;
  data[make_pair(4, 23)] = 56;
  data[make_pair(4, 24)] = 45;
  data[make_pair(4, 25)] = 70;
  data[make_pair(4, 26)] = 61;
  data[make_pair(4, 27)] = 74;
  data[make_pair(4, 28)] = 69;
  data[make_pair(4, 29)] = 92;
  data[make_pair(4, 30)] = 71;
  data[make_pair(4, 31)] = 103;
  data[make_pair(4, 32)] = 88;
  data[make_pair(4, 33)] = 105;
  data[make_pair(4, 34)] = 100;
  data[make_pair(4, 35)] = 136;
  data[make_pair(4, 36)] = 98;
  data[make_pair(4, 37)] = 131;
  data[make_pair(4, 38)] = 113;
  data[make_pair(4, 39)] = 131;
  data[make_pair(4, 40)] = 119;
  data[make_pair(4, 41)] = 150;
  data[make_pair(4, 42)] = 118;
  data[make_pair(4, 43)] = 150;
  data[make_pair(4, 44)] = 119;
  data[make_pair(4, 45)] = 160;
  data[make_pair(4, 46)] = 119;
  data[make_pair(4, 47)] = 150;
  data[make_pair(4, 48)] = 118;
  data[make_pair(4, 49)] = 150;
  data[make_pair(4, 50)] = 119;
  data[make_pair(4, 51)] = 131;
  data[make_pair(4, 52)] = 113;
  data[make_pair(4, 53)] = 131;
  data[make_pair(4, 54)] = 98;
  data[make_pair(4, 55)] = 136;
  data[make_pair(4, 56)] = 100;
  data[make_pair(4, 57)] = 105;
  data[make_pair(4, 58)] = 88;
  data[make_pair(4, 59)] = 103;
  data[make_pair(4, 60)] = 71;
  data[make_pair(4, 61)] = 92;
  data[make_pair(4, 62)] = 69;
  data[make_pair(4, 63)] = 74;
  data[make_pair(4, 64)] = 61;
  data[make_pair(4, 65)] = 70;
  data[make_pair(4, 66)] = 45;
  data[make_pair(4, 67)] = 56;
  data[make_pair(4, 68)] = 38;
  data[make_pair(4, 69)] = 38;
  data[make_pair(4, 70)] = 29;
  data[make_pair(4, 71)] = 32;
  data[make_pair(4, 72)] = 20;
  data[make_pair(4, 73)] = 25;
  data[make_pair(4, 74)] = 16;
  data[make_pair(4, 75)] = 14;
  data[make_pair(4, 76)] = 11;
  data[make_pair(4, 77)] = 9;
  data[make_pair(4, 78)] = 4;
  data[make_pair(4, 79)] = 4;
  data[make_pair(4, 80)] = 1;
  data[make_pair(5, 20)] = 1;
  data[make_pair(5, 21)] = 5;
  data[make_pair(5, 22)] = 7;
  data[make_pair(5, 23)] = 13;
  data[make_pair(5, 24)] = 22;
  data[make_pair(5, 25)] = 25;
  data[make_pair(5, 26)] = 32;
  data[make_pair(5, 27)] = 49;
  data[make_pair(5, 28)] = 52;
  data[make_pair(5, 29)] = 62;
  data[make_pair(5, 30)] = 76;
  data[make_pair(5, 31)] = 88;
  data[make_pair(5, 32)] = 91;
  data[make_pair(5, 33)] = 119;
  data[make_pair(5, 34)] = 114;
  data[make_pair(5, 35)] = 146;
  data[make_pair(5, 36)] = 160;
  data[make_pair(5, 37)] = 170;
  data[make_pair(5, 38)] = 172;
  data[make_pair(5, 39)] = 231;
  data[make_pair(5, 40)] = 223;
  data[make_pair(5, 41)] = 249;
  data[make_pair(5, 42)] = 269;
  data[make_pair(5, 43)] = 298;
  data[make_pair(5, 44)] = 297;
  data[make_pair(5, 45)] = 372;
  data[make_pair(5, 46)] = 326;
  data[make_pair(5, 47)] = 375;
  data[make_pair(5, 48)] = 404;
  data[make_pair(5, 49)] = 407;
  data[make_pair(5, 50)] = 424;
  data[make_pair(5, 51)] = 484;
  data[make_pair(5, 52)] = 464;
  data[make_pair(5, 53)] = 481;
  data[make_pair(5, 54)] = 514;
  data[make_pair(5, 55)] = 553;
  data[make_pair(5, 56)] = 533;
  data[make_pair(5, 57)] = 581;
  data[make_pair(5, 58)] = 554;
  data[make_pair(5, 59)] = 589;
  data[make_pair(5, 60)] = 653;
  data[make_pair(5, 61)] = 597;
  data[make_pair(5, 62)] = 601;
  data[make_pair(5, 63)] = 657;
  data[make_pair(5, 64)] = 630;
  data[make_pair(5, 65)] = 647;
  data[make_pair(5, 66)] = 660;
  data[make_pair(5, 67)] = 643;
  data[make_pair(5, 68)] = 643;
  data[make_pair(5, 69)] = 660;
  data[make_pair(5, 70)] = 647;
  data[make_pair(5, 71)] = 630;
  data[make_pair(5, 72)] = 657;
  data[make_pair(5, 73)] = 601;
  data[make_pair(5, 74)] = 597;
  data[make_pair(5, 75)] = 653;
  data[make_pair(5, 76)] = 589;
  data[make_pair(5, 77)] = 554;
  data[make_pair(5, 78)] = 581;
  data[make_pair(5, 79)] = 533;
  data[make_pair(5, 80)] = 553;
  data[make_pair(5, 81)] = 514;
  data[make_pair(5, 82)] = 481;
  data[make_pair(5, 83)] = 464;
  data[make_pair(5, 84)] = 484;
  data[make_pair(5, 85)] = 424;
  data[make_pair(5, 86)] = 407;
  data[make_pair(5, 87)] = 404;
  data[make_pair(5, 88)] = 375;
  data[make_pair(5, 89)] = 326;
  data[make_pair(5, 90)] = 372;
  data[make_pair(5, 91)] = 297;
  data[make_pair(5, 92)] = 298;
  data[make_pair(5, 93)] = 269;
  data[make_pair(5, 94)] = 249;
  data[make_pair(5, 95)] = 223;
  data[make_pair(5, 96)] = 231;
  data[make_pair(5, 97)] = 172;
  data[make_pair(5, 98)] = 170;
  data[make_pair(5, 99)] = 160;
  data[make_pair(5, 100)] = 146;
  data[make_pair(5, 101)] = 114;
  data[make_pair(5, 102)] = 119;
  data[make_pair(5, 103)] = 91;
  data[make_pair(5, 104)] = 88;
  data[make_pair(5, 105)] = 76;
  data[make_pair(5, 106)] = 62;
  data[make_pair(5, 107)] = 52;
  data[make_pair(5, 108)] = 49;
  data[make_pair(5, 109)] = 32;
  data[make_pair(5, 110)] = 25;
  data[make_pair(5, 111)] = 22;
  data[make_pair(5, 112)] = 13;
  data[make_pair(5, 113)] = 7;
  data[make_pair(5, 114)] = 5;
  data[make_pair(5, 115)] = 1;
  data[make_pair(6, 35)] = 1;
  data[make_pair(6, 36)] = 6;
  data[make_pair(6, 37)] = 11;
  data[make_pair(6, 38)] = 19;
  data[make_pair(6, 39)] = 38;
  data[make_pair(6, 40)] = 44;
  data[make_pair(6, 41)] = 62;
  data[make_pair(6, 42)] = 88;
  data[make_pair(6, 43)] = 106;
  data[make_pair(6, 44)] = 124;
  data[make_pair(6, 45)] = 170;
  data[make_pair(6, 46)] = 188;
  data[make_pair(6, 47)] = 221;
  data[make_pair(6, 48)] = 271;
  data[make_pair(6, 49)] = 276;
  data[make_pair(6, 50)] = 323;
  data[make_pair(6, 51)] = 397;
  data[make_pair(6, 52)] = 395;
  data[make_pair(6, 53)] = 438;
  data[make_pair(6, 54)] = 533;
  data[make_pair(6, 55)] = 544;
  data[make_pair(6, 56)] = 568;
  data[make_pair(6, 57)] = 687;
  data[make_pair(6, 58)] = 694;
  data[make_pair(6, 59)] = 769;
  data[make_pair(6, 60)] = 861;
  data[make_pair(6, 61)] = 893;
  data[make_pair(6, 62)] = 942;
  data[make_pair(6, 63)] = 1114;
  data[make_pair(6, 64)] = 1078;
  data[make_pair(6, 65)] = 1180;
  data[make_pair(6, 66)] = 1293;
  data[make_pair(6, 67)] = 1342;
  data[make_pair(6, 68)] = 1351;
  data[make_pair(6, 69)] = 1574;
  data[make_pair(6, 70)] = 1491;
  data[make_pair(6, 71)] = 1640;
  data[make_pair(6, 72)] = 1748;
  data[make_pair(6, 73)] = 1775;
  data[make_pair(6, 74)] = 1764;
  data[make_pair(6, 75)] = 2029;
  data[make_pair(6, 76)] = 1920;
  data[make_pair(6, 77)] = 2026;
  data[make_pair(6, 78)] = 2162;
  data[make_pair(6, 79)] = 2178;
  data[make_pair(6, 80)] = 2191;
  data[make_pair(6, 81)] = 2430;
  data[make_pair(6, 82)] = 2292;
  data[make_pair(6, 83)] = 2383;
  data[make_pair(6, 84)] = 2552;
  data[make_pair(6, 85)] = 2488;
  data[make_pair(6, 86)] = 2488;
  data[make_pair(6, 87)] = 2709;
  data[make_pair(6, 88)] = 2583;
  data[make_pair(6, 89)] = 2598;
  data[make_pair(6, 90)] = 2777;
  data[make_pair(6, 91)] = 2618;
  data[make_pair(6, 92)] = 2659;
  data[make_pair(6, 93)] = 2841;
  data[make_pair(6, 94)] = 2657;
  data[make_pair(6, 95)] = 2657;
  data[make_pair(6, 96)] = 2841;
  data[make_pair(6, 97)] = 2659;
  data[make_pair(6, 98)] = 2618;
  data[make_pair(6, 99)] = 2777;
  data[make_pair(6, 100)] = 2598;
  data[make_pair(6, 101)] = 2583;
  data[make_pair(6, 102)] = 2709;
  data[make_pair(6, 103)] = 2488;
  data[make_pair(6, 104)] = 2488;
  data[make_pair(6, 105)] = 2552;
  data[make_pair(6, 106)] = 2383;
  data[make_pair(6, 107)] = 2292;
  data[make_pair(6, 108)] = 2430;
  data[make_pair(6, 109)] = 2191;
  data[make_pair(6, 110)] = 2178;
  data[make_pair(6, 111)] = 2162;
  data[make_pair(6, 112)] = 2026;
  data[make_pair(6, 113)] = 1920;
  data[make_pair(6, 114)] = 2029;
  data[make_pair(6, 115)] = 1764;
  data[make_pair(6, 116)] = 1775;
  data[make_pair(6, 117)] = 1748;
  data[make_pair(6, 118)] = 1640;
  data[make_pair(6, 119)] = 1491;
  data[make_pair(6, 120)] = 1574;
  data[make_pair(6, 121)] = 1351;
  data[make_pair(6, 122)] = 1342;
  data[make_pair(6, 123)] = 1293;
  data[make_pair(6, 124)] = 1180;
  data[make_pair(6, 125)] = 1078;
  data[make_pair(6, 126)] = 1114;
  data[make_pair(6, 127)] = 942;
  data[make_pair(6, 128)] = 893;
  data[make_pair(6, 129)] = 861;
  data[make_pair(6, 130)] = 769;
  data[make_pair(6, 131)] = 694;
  data[make_pair(6, 132)] = 687;
  data[make_pair(6, 133)] = 568;
  data[make_pair(6, 134)] = 544;
  data[make_pair(6, 135)] = 533;
  data[make_pair(6, 136)] = 438;
  data[make_pair(6, 137)] = 395;
  data[make_pair(6, 138)] = 397;
  data[make_pair(6, 139)] = 323;
  data[make_pair(6, 140)] = 276;
  data[make_pair(6, 141)] = 271;
  data[make_pair(6, 142)] = 221;
  data[make_pair(6, 143)] = 188;
  data[make_pair(6, 144)] = 170;
  data[make_pair(6, 145)] = 124;
  data[make_pair(6, 146)] = 106;
  data[make_pair(6, 147)] = 88;
  data[make_pair(6, 148)] = 62;
  data[make_pair(6, 149)] = 44;
  data[make_pair(6, 150)] = 38;
  data[make_pair(6, 151)] = 19;
  data[make_pair(6, 152)] = 11;
  data[make_pair(6, 153)] = 6;
  data[make_pair(6, 154)] = 1;
  data[make_pair(7, 56)] = 1;
  data[make_pair(7, 57)] = 7;
  data[make_pair(7, 58)] = 16;
  data[make_pair(7, 59)] = 28;
  data[make_pair(7, 60)] = 59;
  data[make_pair(7, 61)] = 75;
  data[make_pair(7, 62)] = 109;
  data[make_pair(7, 63)] = 151;
  data[make_pair(7, 64)] = 206;
  data[make_pair(7, 65)] = 234;
  data[make_pair(7, 66)] = 335;
  data[make_pair(7, 67)] = 360;
  data[make_pair(7, 68)] = 467;
  data[make_pair(7, 69)] = 529;
  data[make_pair(7, 70)] = 630;
  data[make_pair(7, 71)] = 675;
  data[make_pair(7, 72)] = 896;
  data[make_pair(7, 73)] = 878;
  data[make_pair(7, 74)] = 1053;
  data[make_pair(7, 75)] = 1141;
  data[make_pair(7, 76)] = 1340;
  data[make_pair(7, 77)] = 1294;
  data[make_pair(7, 78)] = 1632;
  data[make_pair(7, 79)] = 1571;
  data[make_pair(7, 80)] = 1895;
  data[make_pair(7, 81)] = 1896;
  data[make_pair(7, 82)] = 2184;
  data[make_pair(7, 83)] = 2129;
  data[make_pair(7, 84)] = 2632;
  data[make_pair(7, 85)] = 2485;
  data[make_pair(7, 86)] = 2926;
  data[make_pair(7, 87)] = 2909;
  data[make_pair(7, 88)] = 3356;
  data[make_pair(7, 89)] = 3190;
  data[make_pair(7, 90)] = 3911;
  data[make_pair(7, 91)] = 3583;
  data[make_pair(7, 92)] = 4259;
  data[make_pair(7, 93)] = 4158;
  data[make_pair(7, 94)] = 4663;
  data[make_pair(7, 95)] = 4477;
  data[make_pair(7, 96)] = 5370;
  data[make_pair(7, 97)] = 4886;
  data[make_pair(7, 98)] = 5622;
  data[make_pair(7, 99)] = 5475;
  data[make_pair(7, 100)] = 6171;
  data[make_pair(7, 101)] = 5776;
  data[make_pair(7, 102)] = 6772;
  data[make_pair(7, 103)] = 6186;
  data[make_pair(7, 104)] = 7073;
  data[make_pair(7, 105)] = 6776;
  data[make_pair(7, 106)] = 7435;
  data[make_pair(7, 107)] = 6953;
  data[make_pair(7, 108)] = 8178;
  data[make_pair(7, 109)] = 7344;
  data[make_pair(7, 110)] = 8270;
  data[make_pair(7, 111)] = 7927;
  data[make_pair(7, 112)] = 8551;
  data[make_pair(7, 113)] = 8030;
  data[make_pair(7, 114)] = 9184;
  data[make_pair(7, 115)] = 8285;
  data[make_pair(7, 116)] = 9227;
  data[make_pair(7, 117)] = 8758;
  data[make_pair(7, 118)] = 9408;
  data[make_pair(7, 119)] = 8650;
  data[make_pair(7, 120)] = 9937;
  data[make_pair(7, 121)] = 8868;
  data[make_pair(7, 122)] = 9716;
  data[make_pair(7, 123)] = 9281;
  data[make_pair(7, 124)] = 9870;
  data[make_pair(7, 125)] = 9035;
  data[make_pair(7, 126)] = 10092;
  data[make_pair(7, 127)] = 9035;
  data[make_pair(7, 128)] = 9870;
  data[make_pair(7, 129)] = 9281;
  data[make_pair(7, 130)] = 9716;
  data[make_pair(7, 131)] = 8868;
  data[make_pair(7, 132)] = 9937;
  data[make_pair(7, 133)] = 8650;
  data[make_pair(7, 134)] = 9408;
  data[make_pair(7, 135)] = 8758;
  data[make_pair(7, 136)] = 9227;
  data[make_pair(7, 137)] = 8285;
  data[make_pair(7, 138)] = 9184;
  data[make_pair(7, 139)] = 8030;
  data[make_pair(7, 140)] = 8551;
  data[make_pair(7, 141)] = 7927;
  data[make_pair(7, 142)] = 8270;
  data[make_pair(7, 143)] = 7344;
  data[make_pair(7, 144)] = 8178;
  data[make_pair(7, 145)] = 6953;
  data[make_pair(7, 146)] = 7435;
  data[make_pair(7, 147)] = 6776;
  data[make_pair(7, 148)] = 7073;
  data[make_pair(7, 149)] = 6186;
  data[make_pair(7, 150)] = 6772;
  data[make_pair(7, 151)] = 5776;
  data[make_pair(7, 152)] = 6171;
  data[make_pair(7, 153)] = 5475;
  data[make_pair(7, 154)] = 5622;
  data[make_pair(7, 155)] = 4886;
  data[make_pair(7, 156)] = 5370;
  data[make_pair(7, 157)] = 4477;
  data[make_pair(7, 158)] = 4663;
  data[make_pair(7, 159)] = 4158;
  data[make_pair(7, 160)] = 4259;
  data[make_pair(7, 161)] = 3583;
  data[make_pair(7, 162)] = 3911;
  data[make_pair(7, 163)] = 3190;
  data[make_pair(7, 164)] = 3356;
  data[make_pair(7, 165)] = 2909;
  data[make_pair(7, 166)] = 2926;
  data[make_pair(7, 167)] = 2485;
  data[make_pair(7, 168)] = 2632;
  data[make_pair(7, 169)] = 2129;
  data[make_pair(7, 170)] = 2184;
  data[make_pair(7, 171)] = 1896;
  data[make_pair(7, 172)] = 1895;
  data[make_pair(7, 173)] = 1571;
  data[make_pair(7, 174)] = 1632;
  data[make_pair(7, 175)] = 1294;
  data[make_pair(7, 176)] = 1340;
  data[make_pair(7, 177)] = 1141;
  data[make_pair(7, 178)] = 1053;
  data[make_pair(7, 179)] = 878;
  data[make_pair(7, 180)] = 896;
  data[make_pair(7, 181)] = 675;
  data[make_pair(7, 182)] = 630;
  data[make_pair(7, 183)] = 529;
  data[make_pair(7, 184)] = 467;
  data[make_pair(7, 185)] = 360;
  data[make_pair(7, 186)] = 335;
  data[make_pair(7, 187)] = 234;
  data[make_pair(7, 188)] = 206;
  data[make_pair(7, 189)] = 151;
  data[make_pair(7, 190)] = 109;
  data[make_pair(7, 191)] = 75;
  data[make_pair(7, 192)] = 59;
  data[make_pair(7, 193)] = 28;
  data[make_pair(7, 194)] = 16;
  data[make_pair(7, 195)] = 7;
  data[make_pair(7, 196)] = 1;
  data[make_pair(8, 84)] = 1;
  data[make_pair(8, 85)] = 8;
  data[make_pair(8, 86)] = 22;
  data[make_pair(8, 87)] = 40;
  data[make_pair(8, 88)] = 83;
  data[make_pair(8, 89)] = 122;
  data[make_pair(8, 90)] = 173;
  data[make_pair(8, 91)] = 248;
  data[make_pair(8, 92)] = 350;
  data[make_pair(8, 93)] = 408;
  data[make_pair(8, 94)] = 575;
  data[make_pair(8, 95)] = 669;
  data[make_pair(8, 96)] = 842;
  data[make_pair(8, 97)] = 963;
  data[make_pair(8, 98)] = 1211;
  data[make_pair(8, 99)] = 1264;
  data[make_pair(8, 100)] = 1652;
  data[make_pair(8, 101)] = 1767;
  data[make_pair(8, 102)] = 2083;
  data[make_pair(8, 103)] = 2248;
  data[make_pair(8, 104)] = 2752;
  data[make_pair(8, 105)] = 2671;
  data[make_pair(8, 106)] = 3274;
  data[make_pair(8, 107)] = 3352;
  data[make_pair(8, 108)] = 3928;
  data[make_pair(8, 109)] = 3978;
  data[make_pair(8, 110)] = 4624;
  data[make_pair(8, 111)] = 4554;
  data[make_pair(8, 112)] = 5428;
  data[make_pair(8, 113)] = 5384;
  data[make_pair(8, 114)] = 6115;
  data[make_pair(8, 115)] = 6158;
  data[make_pair(8, 116)] = 7195;
  data[make_pair(8, 117)] = 6897;
  data[make_pair(8, 118)] = 8052;
  data[make_pair(8, 119)] = 7886;
  data[make_pair(8, 120)] = 8928;
  data[make_pair(8, 121)] = 8772;
  data[make_pair(8, 122)] = 10083;
  data[make_pair(8, 123)] = 9670;
  data[make_pair(8, 124)] = 11309;
  data[make_pair(8, 125)] = 10830;
  data[make_pair(8, 126)] = 12110;
  data[make_pair(8, 127)] = 11865;
  data[make_pair(8, 128)] = 13681;
  data[make_pair(8, 129)] = 12871;
  data[make_pair(8, 130)] = 14740;
  data[make_pair(8, 131)] = 14098;
  data[make_pair(8, 132)] = 15900;
  data[make_pair(8, 133)] = 15138;
  data[make_pair(8, 134)] = 17241;
  data[make_pair(8, 135)] = 15947;
  data[make_pair(8, 136)] = 18464;
  data[make_pair(8, 137)] = 17353;
  data[make_pair(8, 138)] = 19307;
  data[make_pair(8, 139)] = 18345;
  data[make_pair(8, 140)] = 20745;
  data[make_pair(8, 141)] = 18949;
  data[make_pair(8, 142)] = 21681;
  data[make_pair(8, 143)] = 20236;
  data[make_pair(8, 144)] = 22624;
  data[make_pair(8, 145)] = 21027;
  data[make_pair(8, 146)] = 23607;
  data[make_pair(8, 147)] = 21467;
  data[make_pair(8, 148)] = 24536;
  data[make_pair(8, 149)] = 22553;
  data[make_pair(8, 150)] = 24793;
  data[make_pair(8, 151)] = 23187;
  data[make_pair(8, 152)] = 26012;
  data[make_pair(8, 153)] = 23373;
  data[make_pair(8, 154)] = 26355;
  data[make_pair(8, 155)] = 24094;
  data[make_pair(8, 156)] = 26581;
  data[make_pair(8, 157)] = 24463;
  data[make_pair(8, 158)] = 27187;
  data[make_pair(8, 159)] = 24377;
  data[make_pair(8, 160)] = 27453;
  data[make_pair(8, 161)] = 24768;
  data[make_pair(8, 162)] = 27006;
  data[make_pair(8, 163)] = 24768;
  data[make_pair(8, 164)] = 27453;
  data[make_pair(8, 165)] = 24377;
  data[make_pair(8, 166)] = 27187;
  data[make_pair(8, 167)] = 24463;
  data[make_pair(8, 168)] = 26581;
  data[make_pair(8, 169)] = 24094;
  data[make_pair(8, 170)] = 26355;
  data[make_pair(8, 171)] = 23373;
  data[make_pair(8, 172)] = 26012;
  data[make_pair(8, 173)] = 23187;
  data[make_pair(8, 174)] = 24793;
  data[make_pair(8, 175)] = 22553;
  data[make_pair(8, 176)] = 24536;
  data[make_pair(8, 177)] = 21467;
  data[make_pair(8, 178)] = 23607;
  data[make_pair(8, 179)] = 21027;
  data[make_pair(8, 180)] = 22624;
  data[make_pair(8, 181)] = 20236;
  data[make_pair(8, 182)] = 21681;
  data[make_pair(8, 183)] = 18949;
  data[make_pair(8, 184)] = 20745;
  data[make_pair(8, 185)] = 18345;
  data[make_pair(8, 186)] = 19307;
  data[make_pair(8, 187)] = 17353;
  data[make_pair(8, 188)] = 18464;
  data[make_pair(8, 189)] = 15947;
  data[make_pair(8, 190)] = 17241;
  data[make_pair(8, 191)] = 15138;
  data[make_pair(8, 192)] = 15900;
  data[make_pair(8, 193)] = 14098;
  data[make_pair(8, 194)] = 14740;
  data[make_pair(8, 195)] = 12871;
  data[make_pair(8, 196)] = 13681;
  data[make_pair(8, 197)] = 11865;
  data[make_pair(8, 198)] = 12110;
  data[make_pair(8, 199)] = 10830;
  data[make_pair(8, 200)] = 11309;
  data[make_pair(8, 201)] = 9670;
  data[make_pair(8, 202)] = 10083;
  data[make_pair(8, 203)] = 8772;
  data[make_pair(8, 204)] = 8928;
  data[make_pair(8, 205)] = 7886;
  data[make_pair(8, 206)] = 8052;
  data[make_pair(8, 207)] = 6897;
  data[make_pair(8, 208)] = 7195;
  data[make_pair(8, 209)] = 6158;
  data[make_pair(8, 210)] = 6115;
  data[make_pair(8, 211)] = 5384;
  data[make_pair(8, 212)] = 5428;
  data[make_pair(8, 213)] = 4554;
  data[make_pair(8, 214)] = 4624;
  data[make_pair(8, 215)] = 3978;
  data[make_pair(8, 216)] = 3928;
  data[make_pair(8, 217)] = 3352;
  data[make_pair(8, 218)] = 3274;
  data[make_pair(8, 219)] = 2671;
  data[make_pair(8, 220)] = 2752;
  data[make_pair(8, 221)] = 2248;
  data[make_pair(8, 222)] = 2083;
  data[make_pair(8, 223)] = 1767;
  data[make_pair(8, 224)] = 1652;
  data[make_pair(8, 225)] = 1264;
  data[make_pair(8, 226)] = 1211;
  data[make_pair(8, 227)] = 963;
  data[make_pair(8, 228)] = 842;
  data[make_pair(8, 229)] = 669;
  data[make_pair(8, 230)] = 575;
  data[make_pair(8, 231)] = 408;
  data[make_pair(8, 232)] = 350;
  data[make_pair(8, 233)] = 248;
  data[make_pair(8, 234)] = 173;
  data[make_pair(8, 235)] = 122;
  data[make_pair(8, 236)] = 83;
  data[make_pair(8, 237)] = 40;
  data[make_pair(8, 238)] = 22;
  data[make_pair(8, 239)] = 8;
  data[make_pair(8, 240)] = 1;
  data[make_pair(9, 120)] = 1;
  data[make_pair(9, 121)] = 9;
  data[make_pair(9, 122)] = 28;
  data[make_pair(9, 123)] = 51;
  data[make_pair(9, 124)] = 107;
  data[make_pair(9, 125)] = 177;
  data[make_pair(9, 126)] = 234;
  data[make_pair(9, 127)] = 360;
  data[make_pair(9, 128)] = 498;
  data[make_pair(9, 129)] = 619;
  data[make_pair(9, 130)] = 819;
  data[make_pair(9, 131)] = 1040;
  data[make_pair(9, 132)] = 1252;
  data[make_pair(9, 133)] = 1528;
  data[make_pair(9, 134)] = 1824;
  data[make_pair(9, 135)] = 2010;
  data[make_pair(9, 136)] = 2533;
  data[make_pair(9, 137)] = 2837;
  data[make_pair(9, 138)] = 3180;
  data[make_pair(9, 139)] = 3676;
  data[make_pair(9, 140)] = 4305;
  data[make_pair(9, 141)] = 4493;
  data[make_pair(9, 142)] = 5130;
  data[make_pair(9, 143)] = 5672;
  data[make_pair(9, 144)] = 6156;
  data[make_pair(9, 145)] = 6909;
  data[make_pair(9, 146)] = 7424;
  data[make_pair(9, 147)] = 7830;
  data[make_pair(9, 148)] = 8773;
  data[make_pair(9, 149)] = 9392;
  data[make_pair(9, 150)] = 9892;
  data[make_pair(9, 151)] = 10678;
  data[make_pair(9, 152)] = 11647;
  data[make_pair(9, 153)] = 12141;
  data[make_pair(9, 154)] = 13026;
  data[make_pair(9, 155)] = 13918;
  data[make_pair(9, 156)] = 14519;
  data[make_pair(9, 157)] = 15611;
  data[make_pair(9, 158)] = 16278;
  data[make_pair(9, 159)] = 16780;
  data[make_pair(9, 160)] = 18686;
  data[make_pair(9, 161)] = 19280;
  data[make_pair(9, 162)] = 19586;
  data[make_pair(9, 163)] = 20795;
  data[make_pair(9, 164)] = 22385;
  data[make_pair(9, 165)] = 22896;
  data[make_pair(9, 166)] = 23948;
  data[make_pair(9, 167)] = 24970;
  data[make_pair(9, 168)] = 26012;
  data[make_pair(9, 169)] = 27096;
  data[make_pair(9, 170)] = 28467;
  data[make_pair(9, 171)] = 28427;
  data[make_pair(9, 172)] = 30540;
  data[make_pair(9, 173)] = 31272;
  data[make_pair(9, 174)] = 31774;
  data[make_pair(9, 175)] = 33264;
  data[make_pair(9, 176)] = 34748;
  data[make_pair(9, 177)] = 34499;
  data[make_pair(9, 178)] = 36299;
  data[make_pair(9, 179)] = 36596;
  data[make_pair(9, 180)] = 38456;
  data[make_pair(9, 181)] = 38926;
  data[make_pair(9, 182)] = 39984;
  data[make_pair(9, 183)] = 39386;
  data[make_pair(9, 184)] = 42068;
  data[make_pair(9, 185)] = 42848;
  data[make_pair(9, 186)] = 42424;
  data[make_pair(9, 187)] = 42925;
  data[make_pair(9, 188)] = 45044;
  data[make_pair(9, 189)] = 44584;
  data[make_pair(9, 190)] = 46040;
  data[make_pair(9, 191)] = 45496;
  data[make_pair(9, 192)] = 46890;
  data[make_pair(9, 193)] = 47036;
  data[make_pair(9, 194)] = 47341;
  data[make_pair(9, 195)] = 47646;
  data[make_pair(9, 196)] = 48887;
  data[make_pair(9, 197)] = 48840;
  data[make_pair(9, 198)] = 48044;
  data[make_pair(9, 199)] = 48540;
  data[make_pair(9, 200)] = 50066;
  data[make_pair(9, 201)] = 48970;
  data[make_pair(9, 202)] = 49062;
  data[make_pair(9, 203)] = 49062;
  data[make_pair(9, 204)] = 48970;
  data[make_pair(9, 205)] = 50066;
  data[make_pair(9, 206)] = 48540;
  data[make_pair(9, 207)] = 48044;
  data[make_pair(9, 208)] = 48840;
  data[make_pair(9, 209)] = 48887;
  data[make_pair(9, 210)] = 47646;
  data[make_pair(9, 211)] = 47341;
  data[make_pair(9, 212)] = 47036;
  data[make_pair(9, 213)] = 46890;
  data[make_pair(9, 214)] = 45496;
  data[make_pair(9, 215)] = 46040;
  data[make_pair(9, 216)] = 44584;
  data[make_pair(9, 217)] = 45044;
  data[make_pair(9, 218)] = 42925;
  data[make_pair(9, 219)] = 42424;
  data[make_pair(9, 220)] = 42848;
  data[make_pair(9, 221)] = 42068;
  data[make_pair(9, 222)] = 39386;
  data[make_pair(9, 223)] = 39984;
  data[make_pair(9, 224)] = 38926;
  data[make_pair(9, 225)] = 38456;
  data[make_pair(9, 226)] = 36596;
  data[make_pair(9, 227)] = 36299;
  data[make_pair(9, 228)] = 34499;
  data[make_pair(9, 229)] = 34748;
  data[make_pair(9, 230)] = 33264;
  data[make_pair(9, 231)] = 31774;
  data[make_pair(9, 232)] = 31272;
  data[make_pair(9, 233)] = 30540;
  data[make_pair(9, 234)] = 28427;
  data[make_pair(9, 235)] = 28467;
  data[make_pair(9, 236)] = 27096;
  data[make_pair(9, 237)] = 26012;
  data[make_pair(9, 238)] = 24970;
  data[make_pair(9, 239)] = 23948;
  data[make_pair(9, 240)] = 22896;
  data[make_pair(9, 241)] = 22385;
  data[make_pair(9, 242)] = 20795;
  data[make_pair(9, 243)] = 19586;
  data[make_pair(9, 244)] = 19280;
  data[make_pair(9, 245)] = 18686;
  data[make_pair(9, 246)] = 16780;
  data[make_pair(9, 247)] = 16278;
  data[make_pair(9, 248)] = 15611;
  data[make_pair(9, 249)] = 14519;
  data[make_pair(9, 250)] = 13918;
  data[make_pair(9, 251)] = 13026;
  data[make_pair(9, 252)] = 12141;
  data[make_pair(9, 253)] = 11647;
  data[make_pair(9, 254)] = 10678;
  data[make_pair(9, 255)] = 9892;
  data[make_pair(9, 256)] = 9392;
  data[make_pair(9, 257)] = 8773;
  data[make_pair(9, 258)] = 7830;
  data[make_pair(9, 259)] = 7424;
  data[make_pair(9, 260)] = 6909;
  data[make_pair(9, 261)] = 6156;
  data[make_pair(9, 262)] = 5672;
  data[make_pair(9, 263)] = 5130;
  data[make_pair(9, 264)] = 4493;
  data[make_pair(9, 265)] = 4305;
  data[make_pair(9, 266)] = 3676;
  data[make_pair(9, 267)] = 3180;
  data[make_pair(9, 268)] = 2837;
  data[make_pair(9, 269)] = 2533;
  data[make_pair(9, 270)] = 2010;
  data[make_pair(9, 271)] = 1824;
  data[make_pair(9, 272)] = 1528;
  data[make_pair(9, 273)] = 1252;
  data[make_pair(9, 274)] = 1040;
  data[make_pair(9, 275)] = 819;
  data[make_pair(9, 276)] = 619;
  data[make_pair(9, 277)] = 498;
  data[make_pair(9, 278)] = 360;
  data[make_pair(9, 279)] = 234;
  data[make_pair(9, 280)] = 177;
  data[make_pair(9, 281)] = 107;
  data[make_pair(9, 282)] = 51;
  data[make_pair(9, 283)] = 28;
  data[make_pair(9, 284)] = 9;
  data[make_pair(9, 285)] = 1;
  data[make_pair(10, 165)] = 1;
  data[make_pair(10, 166)] = 9;
  data[make_pair(10, 167)] = 28;
  data[make_pair(10, 168)] = 51;
  data[make_pair(10, 169)] = 107;
  data[make_pair(10, 170)] = 177;
  data[make_pair(10, 171)] = 234;
  data[make_pair(10, 172)] = 360;
  data[make_pair(10, 173)] = 498;
  data[make_pair(10, 174)] = 619;
  data[make_pair(10, 175)] = 819;
  data[make_pair(10, 176)] = 1040;
  data[make_pair(10, 177)] = 1252;
  data[make_pair(10, 178)] = 1528;
  data[make_pair(10, 179)] = 1824;
  data[make_pair(10, 180)] = 2010;
  data[make_pair(10, 181)] = 2533;
  data[make_pair(10, 182)] = 2837;
  data[make_pair(10, 183)] = 3180;
  data[make_pair(10, 184)] = 3676;
  data[make_pair(10, 185)] = 4305;
  data[make_pair(10, 186)] = 4493;
  data[make_pair(10, 187)] = 5130;
  data[make_pair(10, 188)] = 5672;
  data[make_pair(10, 189)] = 6156;
  data[make_pair(10, 190)] = 6909;
  data[make_pair(10, 191)] = 7424;
  data[make_pair(10, 192)] = 7830;
  data[make_pair(10, 193)] = 8773;
  data[make_pair(10, 194)] = 9392;
  data[make_pair(10, 195)] = 9892;
  data[make_pair(10, 196)] = 10678;
  data[make_pair(10, 197)] = 11647;
  data[make_pair(10, 198)] = 12141;
  data[make_pair(10, 199)] = 13026;
  data[make_pair(10, 200)] = 13918;
  data[make_pair(10, 201)] = 14519;
  data[make_pair(10, 202)] = 15611;
  data[make_pair(10, 203)] = 16278;
  data[make_pair(10, 204)] = 16780;
  data[make_pair(10, 205)] = 18686;
  data[make_pair(10, 206)] = 19280;
  data[make_pair(10, 207)] = 19586;
  data[make_pair(10, 208)] = 20795;
  data[make_pair(10, 209)] = 22385;
  data[make_pair(10, 210)] = 22896;
  data[make_pair(10, 211)] = 23948;
  data[make_pair(10, 212)] = 24970;
  data[make_pair(10, 213)] = 26012;
  data[make_pair(10, 214)] = 27096;
  data[make_pair(10, 215)] = 28467;
  data[make_pair(10, 216)] = 28427;
  data[make_pair(10, 217)] = 30540;
  data[make_pair(10, 218)] = 31272;
  data[make_pair(10, 219)] = 31774;
  data[make_pair(10, 220)] = 33264;
  data[make_pair(10, 221)] = 34748;
  data[make_pair(10, 222)] = 34499;
  data[make_pair(10, 223)] = 36299;
  data[make_pair(10, 224)] = 36596;
  data[make_pair(10, 225)] = 38456;
  data[make_pair(10, 226)] = 38926;
  data[make_pair(10, 227)] = 39984;
  data[make_pair(10, 228)] = 39386;
  data[make_pair(10, 229)] = 42068;
  data[make_pair(10, 230)] = 42848;
  data[make_pair(10, 231)] = 42424;
  data[make_pair(10, 232)] = 42925;
  data[make_pair(10, 233)] = 45044;
  data[make_pair(10, 234)] = 44584;
  data[make_pair(10, 235)] = 46040;
  data[make_pair(10, 236)] = 45496;
  data[make_pair(10, 237)] = 46890;
  data[make_pair(10, 238)] = 47036;
  data[make_pair(10, 239)] = 47341;
  data[make_pair(10, 240)] = 47646;
  data[make_pair(10, 241)] = 48887;
  data[make_pair(10, 242)] = 48840;
  data[make_pair(10, 243)] = 48044;
  data[make_pair(10, 244)] = 48540;
  data[make_pair(10, 245)] = 50066;
  data[make_pair(10, 246)] = 48970;
  data[make_pair(10, 247)] = 49062;
  data[make_pair(10, 248)] = 49062;
  data[make_pair(10, 249)] = 48970;
  data[make_pair(10, 250)] = 50066;
  data[make_pair(10, 251)] = 48540;
  data[make_pair(10, 252)] = 48044;
  data[make_pair(10, 253)] = 48840;
  data[make_pair(10, 254)] = 48887;
  data[make_pair(10, 255)] = 47646;
  data[make_pair(10, 256)] = 47341;
  data[make_pair(10, 257)] = 47036;
  data[make_pair(10, 258)] = 46890;
  data[make_pair(10, 259)] = 45496;
  data[make_pair(10, 260)] = 46040;
  data[make_pair(10, 261)] = 44584;
  data[make_pair(10, 262)] = 45044;
  data[make_pair(10, 263)] = 42925;
  data[make_pair(10, 264)] = 42424;
  data[make_pair(10, 265)] = 42848;
  data[make_pair(10, 266)] = 42068;
  data[make_pair(10, 267)] = 39386;
  data[make_pair(10, 268)] = 39984;
  data[make_pair(10, 269)] = 38926;
  data[make_pair(10, 270)] = 38456;
  data[make_pair(10, 271)] = 36596;
  data[make_pair(10, 272)] = 36299;
  data[make_pair(10, 273)] = 34499;
  data[make_pair(10, 274)] = 34748;
  data[make_pair(10, 275)] = 33264;
  data[make_pair(10, 276)] = 31774;
  data[make_pair(10, 277)] = 31272;
  data[make_pair(10, 278)] = 30540;
  data[make_pair(10, 279)] = 28427;
  data[make_pair(10, 280)] = 28467;
  data[make_pair(10, 281)] = 27096;
  data[make_pair(10, 282)] = 26012;
  data[make_pair(10, 283)] = 24970;
  data[make_pair(10, 284)] = 23948;
  data[make_pair(10, 285)] = 22896;
  data[make_pair(10, 286)] = 22385;
  data[make_pair(10, 287)] = 20795;
  data[make_pair(10, 288)] = 19586;
  data[make_pair(10, 289)] = 19280;
  data[make_pair(10, 290)] = 18686;
  data[make_pair(10, 291)] = 16780;
  data[make_pair(10, 292)] = 16278;
  data[make_pair(10, 293)] = 15611;
  data[make_pair(10, 294)] = 14519;
  data[make_pair(10, 295)] = 13918;
  data[make_pair(10, 296)] = 13026;
  data[make_pair(10, 297)] = 12141;
  data[make_pair(10, 298)] = 11647;
  data[make_pair(10, 299)] = 10678;
  data[make_pair(10, 300)] = 9892;
  data[make_pair(10, 301)] = 9392;
  data[make_pair(10, 302)] = 8773;
  data[make_pair(10, 303)] = 7830;
  data[make_pair(10, 304)] = 7424;
  data[make_pair(10, 305)] = 6909;
  data[make_pair(10, 306)] = 6156;
  data[make_pair(10, 307)] = 5672;
  data[make_pair(10, 308)] = 5130;
  data[make_pair(10, 309)] = 4493;
  data[make_pair(10, 310)] = 4305;
  data[make_pair(10, 311)] = 3676;
  data[make_pair(10, 312)] = 3180;
  data[make_pair(10, 313)] = 2837;
  data[make_pair(10, 314)] = 2533;
  data[make_pair(10, 315)] = 2010;
  data[make_pair(10, 316)] = 1824;
  data[make_pair(10, 317)] = 1528;
  data[make_pair(10, 318)] = 1252;
  data[make_pair(10, 319)] = 1040;
  data[make_pair(10, 320)] = 819;
  data[make_pair(10, 321)] = 619;
  data[make_pair(10, 322)] = 498;
  data[make_pair(10, 323)] = 360;
  data[make_pair(10, 324)] = 234;
  data[make_pair(10, 325)] = 177;
  data[make_pair(10, 326)] = 107;
  data[make_pair(10, 327)] = 51;
  data[make_pair(10, 328)] = 28;
  data[make_pair(10, 329)] = 9;
  data[make_pair(10, 330)] = 1;
  while (cin >> n >> s) {
    cout << data[make_pair(n, s)] << endl;
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <set>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)

int bit(int bits) {
  bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
  bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
  bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
  bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
  return (bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff);
}

int main() {
  int n, s, sum;
  vector<int> src;
  set<vector<int>> ret;
  while (cin >> n >> s) {
    ret.clear();
    for (int msk = 1; msk < (1 << 10); msk++) {
      if (bit(msk) != n)
        continue;
      src.clear();
      for (int j = 0; j < 10; j++) {
        if (msk & (1 << j))
          src.push_back(j);
      }
      do {
        sum = 0;
        for (int i = 0; i < n; i++) {
          sum += (i + 1) * src[i];
        }
        if (sum == s) {
          ret.insert(src);
        }
      } while (next_permutation(src.begin(), src.end()));
    }
    cout << ret.size() << endl;
  }
}