alexjercan/bugnet huggingface dataset:
Problem p00008 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;

int main() {
  int n;
  int ans;
  while (cin >> n) {
    ans = 0;
    for (int i = 0; i < 10; i++) {
      for (int j = 0; j < 10; j++) {
        for (int k = 0; k < 10; k++) {
          for (int l = 0; l < 10; l++) {
            ans += (i + j + k + l == n);
          }
        }
      }
    }
    cout << ans << endl;
  }
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  int n;
  int ans;
  while (1) {
    ans = 0;
    cin >> n;
    for (int i = 0; i < 10; i++) {
      for (int j = 0; j < 10; j++) {
        for (int k = 0; k < 10; k++) {
          for (int l = 0; l < 10; l++) {
            ans += (i + j + k + l == n);
          }
        }
      }
    }
    cout << ans << endl;
  }
}
Problem p00008 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int n, i, S;
  while (cin >> n) {
    i = 0;
    for (S = 0; S <= 9999; S++) {
      if ((S / 1000) + ((S - S / 1000 * 1000) / 100) +
              ((S - S / 100 * 100) / 10) + (S - S / 10 * 10) ==
          n)
        i = i + 1;
    }
    cout << i << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int n, i, S;
  while (1) {
    i = 0;
    cin >> n;
    for (S = 1; S <= 9999; S++) {
      if ((S / 1000) + ((S - S / 1000 * 1000) / 100) +
              ((S - S / 100 * 100) / 10) + (S - S / 10 * 10) ==
          n)
        i = i + 1;
    }
    cout << i << endl;
  }
  return 0;
}
Problem p00008 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <iostream>

using namespace std;

int main(void) {
  int n = 0;

  while (scanf("%d", &n) != EOF) {
    int ans = 0;

    for (int i = 0; i <= 9; i++) {
      for (int j = 0; j <= 9; j++) {
        for (int k = 0; k <= 9; k++) {
          for (int l = 0; l <= 9; l++) {
            if (n == i + j + k + l) {
              ans++;
            }
          }
        }
      }
    }

    cout << ans << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <iostream>

using namespace std;

int main(void) {
  int n = 0;

  while (scanf("%d", &n) && n != EOF) {
    int ans = 0;

    for (int i = 0; i <= 9; i++) {
      for (int j = 0; j <= 9; j++) {
        for (int k = 0; k <= 9; k++) {
          for (int l = 0; l <= 9; l++) {
            if (n == i + j + k + l) {
              ans++;
            }
          }
        }
      }
    }

    cout << ans << endl;
  }

  return 0;
}
Problem p00008 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <vector>

void calc(std::vector<int> &v) {
  int total;
  for (int i = 0; i <= 9; i++) {
    for (int j = 0; j <= 9; j++) {
      for (int k = 0; k <= 9; k++) {
        for (int l = 0; l <= 9; l++) {
          total = i + j + k + l;
          v[total]++;
        }
      }
    }
  }
  return;
}

int main(void) {
  std::vector<int> v(37, 0);
  calc(v);

  int total;
  while (std::cin >> total) {
    if (total > 36) {
      std::cout << 0 << std::endl;
    } else {
      std::cout << v[total] << std::endl;
    }
  }
  return 0;
}

Error: -6
malloc(): corrupted top size


Fixed submission:

#include <iostream>
#include <vector>

void calc(std::vector<int> &v) {
  std::vector<int> g(10, 0);
  for (int i = 1; i <= 9; i++) {
    v[i] = 4 * i;
  }
  for (int i = 0; i <= 9; i++) {
    g[i + 9] = 3 * i;
  }
  for (int i = 1; i <= 9; i++) {
    v[i + 9] = g[i + 8] * 3 + (v[i + 8] - g[i + 8]);
  }
  return;
}

int main(void) {
  std::vector<int> v(19, 0);
  calc(v);
  int total;

  while (std::cin >> total) {
    if (total > 36) {
      std::cout << '0' << std::endl;
    } else if (total > 18) {
      total = 36 - total;
      std::cout << v[total] << std::endl;
    } else {
      std::cout << v[total] << std::endl;
    }
  }
  return 0;
}
Problem p00008 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <stdio.h>

int main() {
  int n, a, b, c, d, count;
  while (scanf("%d", &n) == 1) {
    count = 0;
    for (a = 0; a < 10; a++) {
      for (b = 0; b < 10; b++) {
        for (c = 0; c < 10; c++) {
          for (d = 0; d < 10; d++) {
            if (a + b + c + d == n)
              count = count + 1;
          }
        }
      }
    }
    printf("%d\\n", count);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <stdio.h>

int main() {
  int n, a, b, c, d, count;
  while (scanf("%d", &n)) {
    count = 0;
    for (a = 0; a < 10; a++) {
      for (b = 0; b < 10; b++) {
        for (c = 0; c < 10; c++) {
          for (d = 0; d < 10; d++) {
            if (a + b + c + d == n)
              count = count + 1;
          }
        }
      }
    }
    printf("%d\\n", count);
  }
  return 0;
}
Problem p00008 (C++) — buggy submission, verdict: Time Limit Exceeded

// ↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n) n.begin(), n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1}, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long> dij;
struct edge {
  long long to, cost;
};
vector<vector<edge>> G;

long long mod_pow(long long a, long long b) {
  long long res = 1, mul = a;
  for (int i = 0; i < 31; ++i) {
    if (b >> i & 1) {
      res *= mul;
      res %= MOD;
    }
    mul = (mul * mul) % MOD;
  }

  return res;
}

void addedge(int from, int to, int cost) {
  G[from].push_back({to, cost});
  G[to].push_back({from, cost});
}

// ↑template↑

int main() {
  int n;
  while (cin >> n) {
    int ans = 0;
    for (int i = 0; i <= 9; ++i) {
      for (int j = 0; j <= 9; ++j) {
        for (int k = 0; k <= 9; ++k) {
          int mon = n - i - j - k;
          if (0 <= mon && mon <= 9) {
            ++ans;
          }
        }
      }
    }
    cout << ans << endl;
  }
}


Error: TLE

Fixed submission:

// ↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n) n.begin(), n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1}, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long> dij;
struct edge {
  long long to, cost;
};
vector<vector<edge>> G;

long long mod_pow(long long a, long long b) {
  long long res = 1, mul = a;
  for (int i = 0; i < 31; ++i) {
    if (b >> i & 1) {
      res *= mul;
      res %= MOD;
    }
    mul = (mul * mul) % MOD;
  }

  return res;
}

void addedge(int from, int to, int cost) {
  G[from].push_back({to, cost});
  G[to].push_back({from, cost});
}

// ↑template↑

int main() {
  int n;
  while (cin >> n) {
    int ans = 0;
    for (int i = 0; i <= 9; ++i) {
      for (int j = 0; j = 9; ++j) {
        for (int k = 0; k <= 9; ++k) {
          int mon = n - i - j - k;
          if (0 <= mon && mon <= 9) {
            ++ans;
          }
        }
      }
    }
    cout << ans << endl;
  }
}
Problem p00008 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int dp[40];
int main() {
  for (int i = 0; i <= 9; i++) {
    for (int j = 0; j <= 9; j++) {
      for (int k = 0; k <= 9; k++) {
        for (int l = 0; l <= 9; l++) {
          dp[i + j + k + l]++;
        }
      }
    }
  }
  int n;
  while (cin >> n) {
    if (n == 0) {
      break;
    }
    cout << dp[n] << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int dp[40];
int main() {
  for (int i = 0; i <= 9; i++) {
    for (int j = 0; j <= 9; j++) {
      for (int k = 0; k <= 9; k++) {
        for (int l = 0; l <= 9; l++) {
          dp[i + j + k + l]++;
        }
      }
    }
  }
  while (true) {
    int n;
    cin >> n;
    if (n == 0) {
      break;
    }
    cout << dp[n] << endl;
  }
  return 0;
}
Problem p00008 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

int main(void) {
  int n;
  int a, b, c, d;
  int count;

  while (scanf("%d", &n) == 1) {

    count = 0;
    for (a = 0; a <= 9; a++) {
      for (b = 0; b <= 9; b++) {
        for (c = 0; c <= 9; c++) {
          for (d = 0; d <= 9; d++) {
            if (a + b + c + d == n) {
              count++;
            }
          }
        }
      }
    }
    printf("%d\\n", count);
  }

  return (0);
}

Error: TLE

Fixed submission:

#include <stdio.h>

int main(void) {
  int n;
  int a, b, c, d;
  int count;

  while (1) {
    scanf("%d", &n);

    count = 0;
    for (a = 0; a <= 9; a++) {
      for (b = 0; b <= 9; b++) {
        for (c = 0; c <= 9; c++) {
          for (d = 0; d <= 9; d++) {
            if (a + b + c + d == n) {
              count++;
            }
          }
        }
      }
    }
  }

  printf("%d\\n", count);

  return (0);
}
Problem p00008 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int n;
  while (cin >> n) {
    int ans = 0;
    for (int a = 0; a < 10; a++) {
      for (int b = 0; b < 10; b++) {
        for (int c = 0; c < 10; c++) {
          for (int d = 0; d < 10; d++) {
            if (a + b + c + d == n)
              ans++;
          }
        }
      }
    }
    cout << ans << "\\n";
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  int n;
  while (scanf("%d", &n)) {
    int ans = 0;
    for (int a = 0; a < 10; a++) {
      for (int b = 0; b < 10; b++) {
        for (int c = 0; c < 10; c++) {
          for (int d = 0; d < 10; d++) {
            if (a + b + c + d == n)
              ans++;
          }
        }
      }
    }
    printf("%d\\n", ans);
  }
  return 0;
}
Problem p00008 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
#include <string.h>
int main(void) {
  int n, count = 0;
  while (scanf("%d", &n) != EOF) {
    for (size_t a = 0; a <= 9; a++) {
      for (size_t b = 0; b <= 9; b++) {
        for (size_t c = 0; c <= 9; c++) {
          for (size_t d = 0; d <= 9; d++) {
            if (a + b + c + d == n) {
              count++;
            }
          }
        }
      }
    }
    printf("%d\\n", count);
    count = 0;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>
#include <string.h>
int main(void) {
  int n, count = 0;
  while (1) {
    scanf("%d", &n);
    if (n == EOF)
      break;
    for (size_t a = 0; a <= 9; a++) {
      for (size_t b = 0; b <= 9; b++) {
        for (size_t c = 0; c <= 9; c++) {
          for (size_t d = 0; d <= 9; d++) {
            if (a + b + c + d == n) {
              count++;
            }
          }
        }
      }
    }
    printf("%d\\n", count);
    count = 0;
  }
  return 0;
}
Problem p00008 (C++) — buggy submission, verdict: Runtime Error

#define _CRT_SECURE_NO_WARNINGS
#define M_PI 3.14159265358979
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

int main() {
  int n, counter = 0;
  while (scanf("%d", &n) != -1) {
    counter = 0;
    for (int a = 0; a < 10; a++) {
      for (int b = 0; b < 10; b++) {
        for (int c = 0; c < 10; c++) {
          for (int d = 0; d < 10; d++) {
            if (a + b + c + d == n)
              counter++;
          }
        }
      }
    }
    cout << counter << endl;
  }
  return 0;
}

Error: -11

Fixed submission:

#define _CRT_SECURE_NO_WARNINGS
#define M_PI 3.14159265358979
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

int main() {
  int n, counter = 0;
  while (scanf("%d", n) == -1) {
    for (int a = 0; a < 10; a++) {
      for (int b = 0; b < 10; b++) {
        for (int c = 0; c < 10; c++) {
          for (int d = 0; d < 10; d++) {
            if (a + b + c + d == n)
              counter++;
          }
        }
      }
    }
    cout << counter << endl;
  }
  return 0;
}
Problem p00008 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int n, g, ans = 0;
  while (cin >> n) {
    for (int a = 0; a <= 9; a++) {
      for (int b = 0; b <= 9; b++) {
        for (int c = 0; c <= 9; c++) {
          for (int d = 0; d <= 9; d++) {
            g = a + b + c + d;
            if (g == n)
              ans++;
          }
        }
      }
    }
    cout << ans << endl;
    ans = 0;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int n, g, ans = 0;
  while (1) {
    cin >> n;
    for (int a = 0; a <= 9; a++) {
      for (int b = 0; b <= 9; b++) {
        for (int c = 0; c <= 9; c++) {
          for (int d = 0; d <= 9; d++) {
            g = a + b + c + d;
            if (g == n)
              ans++;
          }
        }
      }
    }
    cout << ans << endl;
    ans = 0;
  }
  return 0;
}
Problem p00008 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int n;

  while (cin >> n) {
    int ans = 0;
    for (int a = 0; a <= 9; a++) {
      for (int b = 0; b <= 9; b++) {
        for (int c = 0; c <= 9; c++) {
          for (int d = 0; d <= 9; d++) {
            if (a + b + c + d == n) {
              ans++;
            }
          }
        }
      }
    }
    cout << ans << endl;
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int n;
  int ans;

  cin >> n;

  while (n > 0) {
    for (int a = 0; a < 10; a++) {
      for (int b = 0; b < 10; b++) {
        for (int c = 0; c < 10; c++) {
          for (int d = 0; d < 10; d++) {
            if ((a + b + c + d) == n) {
              ans++;
            }
          }
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}
Problem p00008 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main(void) {
  int n;
  int counter;
  int a, b, c, d;
  while (cin >> n) {

    counter = 0;
    for (a = 0; a <= 9; a++) {
      for (b = 0; b <= 9; b++) {
        for (c = 0; c <= 9; c++) {
          for (d = 0; d <= 9; d++) {
            if (a + b + c + d == n) {
              counter++;
            }
          }
        }
      }
    }

    cout << counter << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main(void) {
  int n;
  int counter;
  int a, b, c, d;
  while (cin >> n) {
    counter = 0;
    for (a = 1; a <= 9; a++) {
      for (b = 1; b <= 9; b++) {
        for (c = 1; c <= 9; c++) {
          for (d = 1; c <= 9; d++) {
            if (a + b + c + d == n) {
              counter++;
            }
          }
        }
      }
    }
    cout << counter << endl;
  }

  return 0;
}
Problem p00008 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <cstdlib>

int main() {
  int n;
  int ans = 0;
  while (true) {
    n = 0;
    scanf("%d\\n", &n);
    if (n == 0)
      break;
    ans = 0;
    for (int a = 9; a >= 0; a--) {
      for (int b = 9; b >= 0; b--) {
        for (int c = 9; c >= 0; c--) {
          for (int d = 9; d >= 0; d--) {
            if (a + b + c + d == n) {
              ans++;
              break;
            }
            if (a + b + c + d < n)
              break;
          }
        }
      }
    }
    printf("%d\\n", ans);
  }
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <cstdlib>

int main() {
  int n;
  int ans = 0;
  while (true) {
    scanf("%d\\n", &n);
    if (n == EOF)
      break;
    ans = 0;
    for (int a = 9; a >= 0; a--) {
      for (int b = 9; b >= 0; b--) {
        for (int c = 9; c >= 0; c--) {
          for (int d = 9; d >= 0; d--) {
            if (a + b + c + d == n) {
              ans++;
              break;
            }
            if (a + b + c + d < n)
              break;
          }
        }
      }
    }
    printf("%d\\n", ans);
  }
}
Problem p00008 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

int main() {
  int n;

  while (std::cin >> n) {
    int count = 0;
    for (int a = 0; a < 10; ++a) {
      for (int b = 0; b < 10; ++b) {
        for (int c = 0; c < 10; ++c) {
          for (int d = 0; d < 10; ++d) {
            if (a + b + c + d == n) {
              ++count;
            }
          }
        }
      }
    }
    std::cout << count << std::endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

int main() {
  int n;

  while (std::cin >> n) {
    int count = 0;
    for (int a = 0; a < 10; ++a) {
      for (int b = 0; a < 10; ++b) {
        for (int c = 0; a < 10; ++c) {
          for (int d = 0; a < 10; ++d) {
            if (a + b + c + d == n) {
              ++count;
            }
          }
        }
      }
    }
    std::cout << count << std::endl;
  }

  return 0;
}
Problem p00008 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

int func(int n) {
  int count = 0;

  for (int a = 0; a <= 9; a++) {
    for (int b = 0; b <= 9; b++) {
      for (int c = 0; c <= 9; c++) {
        for (int d = 0; d <= 9; d++) {
          if (a + b + c + d == n) {
            count++;
          }
        }
      }
    }
  }

  return count;
}

int main() {
  int input;

  while (std::cin >> input) {
    std::cout << func(input) << "\\n";
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

int func(int n) {
  int count = 0;

  for (int a = 0; a <= 9; a++) {
    for (int b = 0; b <= 9; b++) {
      for (int c = 0; c <= 9; c++) {
        for (int d = 0; d <= 9; d++) {
          if (a + b + c + d == n) {
            count++;
          }
        }
      }
    }
  }

  return count;
}

int main() {
  int input;

  while (true) {
    if (std::cin >> input) {
      std::cout << func(input) << "\\n";
    }
  }

  return 0;
}
Problem p00008 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <math.h>
#include <string>
#include <vector>

int main(void);
int combination(int n);
bool combination_sub();

int main() {
  int n;          // 入力されるデータセット
  int cnt = 0;    // データセット入力カウント
  int result[50]; // 組み合わせ個数を格納する配列

  while (std::cin >> n) {
    // while (cnt < 2){
    // std::cin >> n;
    result[cnt] = combination(n);
    cnt++;
  }

  for (int i = 0; i < cnt; i++) {
    std::cout << result[i] << std::endl;
  }

  // while (1);
  return 0;
}

int combination(int n) {
  int rtn = 0;

  // 全部同じ場合
  for (int x = 0; x <= 9; x++) {
    if (x * 4 == n) {
      rtn++;
    }
  }

  // 「全部同じ」以外の場合
  for (int a = 0; a <= 9; a++) {
    for (int b = 0; b <= 9; b++) {
      for (int c = 0; c <= 9; c++) {
        for (int d = 0; d <= 9; d++) {
          if (!((a == b) && (a == c) && (a == d))) {
            if ((a + b + c + d) == n) {
              rtn++;
            }
          }
        }
      }
    }
  }

  return rtn;
}


Error: -11

Fixed submission:

#include <iostream>
#include <math.h>
#include <string>
#include <vector>

int main(void);
int combination(int n);
bool combination_sub(int a, int b, int c, int d, int n);

int main() {
  int n;                   // 入力されるデータセット
  int cnt = 0;             // データセット入力カウント
  std::vector<int> result; // 組み合わせ個数を格納する配列

  while (std::cin >> n) {
    // while (cnt < 2){
    // std::cin >> n;
    result[cnt] = combination(n);
    cnt++;
  }

  for (int i = 0; i < (sizeof(result) / sizeof(result[0])); i++) {
    std::cout << result[i] << std::endl;
  }

  // while (1);
  return 0;
}

int combination(int n) {
  int rtn = 0;

  for (int a = 0; a <= 9; a++) {
    for (int b = 0; b <= 9; b++) {
      for (int c = 0; c <= 9; c++) {
        for (int d = 0; d <= 9; d++) {
          if (combination_sub(a, b, c, d, n)) {
            rtn++;
          }
        }
      }
    }
  }

  return rtn;
}

bool combination_sub(int a, int b, int c, int d, int n) {
  if ((a + b + c + d) == n) {
    return true;
  } else {
    return false;
  }
}
Problem p00008 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
#include <string.h>

int dp[2][51];

int main() {
  while (1) {
    int n;
    if (EOF == scanf("%d", &n)) {
      break;
    }
    int now = 0;
    for (int i = 0; i <= 50; i++) {
      dp[now][i] = 0;
    }
    dp[now][0] = 1;
    for (int k = 0; k < 4; k++) {
      int nex = (now + 1) % 2;
      for (int i = 0; i <= 50; i++) {
        dp[nex][i] = 0;
      }
      for (int j = 0; j <= 50; j++) {
        for (int i = 0; i <= 9; i++) {
          if (j + i <= 50) {
            dp[nex][j + i] += dp[now][j];
          }
        }
      }
      now = nex;
    }
    printf("%d\\n", dp[now][n]);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>
#include <string.h>

int dp[2][51];

int main() {
  while (1) {
    int n;
    if (0 == scanf("%d", &n)) {
      break;
    }
    int now = 0;
    for (int i = 0; i <= 50; i++) {
      dp[now][i] = 0;
    }
    dp[now][0] = 1;
    for (int k = 0; k < 4; k++) {
      int nex = (now + 1) % 2;
      for (int i = 0; i <= 50; i++) {
        dp[nex][i] = 0;
      }
      for (int j = 0; j <= 50; j++) {
        for (int i = 0; i <= 9; i++) {
          if (j + i <= 50) {
            dp[nex][j + i] += dp[now][j];
          }
        }
      }
      now = nex;
    }
    printf("%d\\n", dp[now][n]);
  }
  return 0;
}
Problem p00008 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

template <class T> int streamvar(std::istream &in, T &var) {
  if (!in) {
    cerr << "invalid istream" << endl;
    return 1;
  }
  in >> var;
  if (in.fail()) {
    // cerr << "no var" << endl;
    return 1;
  }
  return 0;
}
template <class T> int streamvec(std::istream &in, std::vector<T> &v) {
  v.clear();
  string s;

  if (!in) {
    cerr << "invalid istream" << endl;
    return 1;
  }
  getline(in, s);
  if (in.fail()) {
    cerr << "no line" << endl;
    return 1;
  }
  istringstream is(s);
  while (1) {
    T tmp;
    is >> tmp;
    if (is.fail())
      break;
    v.push_back(tmp);
  }
  return 0;
}

int main(void) {
  int n;
  while (!streamvar(cin, n)) {
    int counter = 0;
    for (int a = 0; a < 10; a++)
      for (int b = 0; b < 10; b++)
        for (int c = 0; c < 10; c++)
          for (int d = 0; d < 10; d++)
            if (a + b + c + d == n)
              counter++;
    cout << counter << endl;
  }
  return 0;
}

Error: 0
no var


Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

template <class T> int streamvar(std::istream &in, T &var) {
  if (!in) {
    cerr << "invalid istream" << endl;
    return 1;
  }
  in >> var;
  if (in.fail()) {
    cerr << "no var" << endl;
    return 1;
  }
  return 0;
}
template <class T> int streamvec(std::istream &in, std::vector<T> &v) {
  v.clear();
  string s;

  if (!in) {
    cerr << "invalid istream" << endl;
    return 1;
  }
  getline(in, s);
  if (in.fail()) {
    cerr << "no line" << endl;
    return 1;
  }
  istringstream is(s);
  while (1) {
    T tmp;
    is >> tmp;
    if (is.fail())
      break;
    v.push_back(tmp);
  }
  return 0;
}

int main(void) {
  int n;
  while (!streamvar(cin, n)) {
    int counter = 0;
    for (int a = 0; a < 10; a++)
      for (int b = 0; b < 10; b++)
        for (int c = 0; c < 10; c++)
          for (int d = 0; d < 10; d++)
            if (a + b + c + d == n)
              counter++;
    cout << counter << endl;
  }
  return 0;
}