prithivMLmods/Coder-Stat huggingface dataset:
Problem p03502 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  int A = 0;
  cin >> N;
  int x = N;
  for (int i = 0; i > 0; i++) {
    A += x % 10;
    x = x / 10;
  }
  if (N % A == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  int A = 0;
  cin >> N;
  int x = N;
  for (int i = 0; i < 8; i++) {
    A += x % 10;
    x = x / 10;
  }
  if (N % A == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p03502 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;

int main() {
  int n;
  cin >> n;
  int temp = n;
  int sum = 0;
  while (temp / 10 != 0) {
    sum += temp % 10;
    temp /= 10;
  }
  cout << (n % sum == 0 ? "Yes" : "No") << endl;
  return 0;
}


Fixed submission:
#include <iostream>
using namespace std;

int main() {
  int n;
  cin >> n;
  int temp = n;
  int sum = 0;
  while (temp != 0) {
    sum += temp % 10;
    temp /= 10;
  }
  cout << (n % sum == 0 ? "Yes" : "No") << endl;
  return 0;
}
Problem p03502 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, sum = 0;
  cin >> n;
  int res = n;
  while (n >= 0) {
    sum += n % 10;
    n /= 10;
  }
  if (res % sum == 0)
    cout << "Yes";
  else
    cout << "No";
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, sum = 0;
  cin >> n;
  int res = n;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  if (res % sum == 0)
    cout << "Yes";
  else
    cout << "No";
}
Problem p03502 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  int fN;
  int a, b, c, d, e, f, g, h, i;
  a = N % 100000000;
  b = N / 100000000 % 10000000;
  c = N / 100000000 / 10000000 % 1000000;
  d = N / 100000000 / 10000000 / 1000000 % 100000;
  e = N / 100000000 / 10000000 / 1000000 / 100000 % 10000;
  f = N / 100000000 / 10000000 / 1000000 / 100000 / 10000 % 1000;
  g = N / 100000000 / 10000000 / 1000000 / 100000 / 10000 / 1000 % 100;
  h = N / 100000000 / 10000000 / 1000000 / 100000 / 10000 / 1000 / 100 % 10;
  i = N / 100000000 / 10000000 / 1000000 / 100000 / 10000 / 1000 / 100 / 10;
  if (N % fN == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  int fN;
  int a, b, c, d, e, f, g, h, i;
  a = N / 100000000;
  b = N % 100000000 / 10000000;
  c = N % 100000000 % 10000000 / 1000000;
  d = N % 100000000 % 10000000 % 1000000 / 100000;
  e = N % 100000000 % 10000000 % 1000000 % 100000 / 10000;
  f = N % 100000000 % 10000000 % 1000000 % 100000 % 10000 / 1000;
  g = N % 100000000 % 10000000 % 1000000 % 100000 % 10000 % 1000 / 100;
  h = N % 100000000 % 10000000 % 1000000 % 100000 % 10000 % 1000 % 100 / 10;
  i = N % 100000000 % 10000000 % 1000000 % 100000 % 10000 % 1000 % 100 % 10;
  fN = a + b + c + d + e + f + g + h + i;
  if (N % fN == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p03502 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  long long n, nm = 0;
  cin >> n;
  int m = n;
  while (m > 0) {
    nm += m / 10;
    m /= 10;
  }
  if (n % nm == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int main() {
  long long n, nm = 0;
  cin >> n;
  int m = n;
  while (m > 0) {
    nm += m % 10;
    m /= 10;
  }
  if (n % nm == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p03502 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(x) (x).begin(), (x).end()

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x = 0, xx = 0;
  cin >> x;
  int tx = x;
  while (tx > 0) {
    xx += tx % 10;
    tx /= 10;
  }
  if (x % tx)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Fixed submission:
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(x) (x).begin(), (x).end()

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x = 0, xx = 0;
  cin >> x;
  int tx = x;
  while (tx > 0) {
    xx += tx % 10;
    tx /= 10;
  }
  if (x % xx == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}
Problem p03502 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int k;
  for (int i = 1; i < 1000000000; i *= 10) {
    k = N / i % 10;
  }
  if (N % k == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int k = 0, t = N;
  while (t > 0) {
    k = k + t % 10;
    t = t / 10;
  }
  if (N % k == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}
Problem p03502 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  int c = N;
  int t = 0;
  while (c > 0) {
    t += c % 10;
    c /= 10;
  }
  cout << (N % c == 0 ? "Yes" : "No") << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  int c = N;
  int t = 0;
  while (c > 0) {
    t += c % 10;
    c /= 10;
  }
  cout << (N % t == 0 ? "Yes" : "No") << endl;
}
Problem p03502 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for (ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

void print(const std::vector<int> &v) {
  std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
  std::cout << std::endl;
}

int main() {
  string N;
  int fx = 0;
  REP(i, N.size()) { fx += (N[i] - '0'); }
  int n = stoi(N);
  if (n % fx == 0) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for (ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

void print(const std::vector<int> &v) {
  std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
  std::cout << std::endl;
}

int main() {
  string N;
  cin >> N;
  int fx = 0;
  REP(i, N.size()) { fx += (N[i] - '0'); }
  int n = stoi(N);
  if (n % fx == 0) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}
Problem p03502 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {

  int N, keep, sum = 0;
  cin >> N;
  keep = N;

  while (N != 0) {
    sum += N % 10;
    N /= 10;
  }

  if (keep % N == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int main() {

  int N, keep, sum = 0;
  cin >> N;
  keep = N;

  while (N != 0) {
    sum += N % 10;
    N /= 10;
  }

  if (keep % sum == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p03502 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, a, b;
  cin >> N;
  int c = N;

  while (N >= 0) {
    a = N % 10;
    N = N / 10;
    b += a;
  }

  if (c % b == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, a, b;
  cin >> N;
  int c = N;

  while (N > 0) {
    a = N % 10;
    N = N / 10;
    b += a;
  }

  if (c % b == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p03502 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M, f = 0;
  cin >> N;
  int i = 1;
  M = N;

  for (i; M != 0; i++) {
    f += M % 10;
    M = (M - (M % 10)) / 10;
  }
  if (f % M == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M, f = 0;
  cin >> N;
  int i = 1;
  M = N;

  for (i; M != 0; i++) {
    f += M % 10;
    M = (M - (M % 10)) / 10;
  }
  if (N % f == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
Problem p03502 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;

  int sum = 0;
  int A = N;

  while ((A / 10) > 0) {
    sum += A % 10;
    A /= 10;
  }

  if (N % sum == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;

  int sum = 0;
  int A = N;

  while ((A / 10.0) > 0) {
    sum += A % 10;
    A /= 10;
  }

  if (N % sum == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p03502 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int i, m, n, sum, N, N1;

  cin >> N;
  N1 = N;
  sum = 0;

  for (i = 0; i < 8; i++) {
    m = pow(10, 8 - i);
    n = N1 / m;
    N1 -= n * m;
    sum += n;
  }

  if ((N % sum) == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int i, m, n, sum, N, N1;

  cin >> N;
  N1 = N;
  sum = 0;

  for (i = 0; i < 9; i++) {
    m = pow(10, 8 - i);
    n = N1 / m;
    N1 -= n * m;
    sum += n;
  }

  if ((N % sum) == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
Problem p03502 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>

using namespace std;

int main() {
  int N;
  cin >> N;

  int tmp = N;
  int sum = 0;
  while (tmp > 10) {
    sum += tmp % 10;
    tmp /= 10;
  }
  if (N % sum == 0) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}

Fixed submission:
#include <iostream>

using namespace std;

int main() {
  int N;
  cin >> N;

  int tmp = N;
  int sum = 0;
  while (tmp > 10) {
    sum += tmp % 10;
    tmp /= 10;
  }
  sum += tmp;
  if (N % sum == 0) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}
Problem p03502 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll, ll> pll;
const ll mod = 1e9 + 7;
// const ll mod=998244353;
const ll inf = 1LL << 61;

int main() {
  ll n;
  ll f = 0;
  ll tmp = n;
  while (tmp) {
    f += tmp % 10;
    tmp /= 10;
  }
  if (n % f == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll, ll> pll;
const ll mod = 1e9 + 7;
// const ll mod=998244353;
const ll inf = 1LL << 61;

int main() {
  ll n;
  cin >> n;
  ll f = 0;
  ll tmp = n;
  while (tmp) {
    f += tmp % 10;
    tmp /= 10;
  }
  if (n % f == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
Problem p03502 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M, x = 0, y = 1, i, j;
  cin >> N;
  M = N;

  for (i = 8; i >= 0; i--) {
    for (j = i; j >= 0; j--) {
      y *= 10;
    }
    x += M / y;
    M = M % y;
    y = 1;
  }

  if (N % x == 0) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M, x = 0, y = 1, i, j;
  cin >> N;
  M = N;

  for (i = 7; i >= 0; i--) {
    for (j = i; j > 0; j--) {
      y *= 10;
    }
    x += M / y;
    M = M % y;
    y = 1;
  }

  if (N % x == 0) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}
Problem p03502 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const string YES = "Yes";
const string NO = "No";

void solve(long long N) {
  string s = to_string(N);
  int sum = 0;
  REP(i, s.size()) {
    if (i == 0)
      continue;
    sum += s[i] - '0';
  }
  if (N % sum)
    cout << NO << '\n';
  else
    cout << YES << '\n';
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


Fixed submission:
#include <iostream>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const string YES = "Yes";
const string NO = "No";

void solve(long long N) {
  string s = to_string(N);
  long long sum = 0;
  REP(i, s.size())
  sum += s[i] - '0';
  if (N % sum)
    cout << NO << '\n';
  else
    cout << YES << '\n';
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}
Problem p03502 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M, num = 0, k = 100000000, j = 0;

  cin >> N;
  M = N;

  for (int i = 0; i < 8; i++) {
    j += M / k;
    num += j;
    M -= j * k;
    k /= 10;
  }

  if (N % num == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M, num = 0, k = 100000000, j = 0;

  cin >> N;
  M = N;

  for (int i = 0; i < 9; i++) {
    j = M / k;
    num += j;
    M -= j * k;
    k /= 10;
  }

  if (N % num == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p03502 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;

int IT_MAX = 1 << 18;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for (int i = 0; i < n; i++)
#define Se second
#define Fi first

int main() {
  int x, y = 0, t;
  scanf("%d", &x);
  t = x;
  while (t) {
    y += t % 10;
    t /= 10;
  }
  if (x % t == 0)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}

Fixed submission:
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;

int IT_MAX = 1 << 18;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for (int i = 0; i < n; i++)
#define Se second
#define Fi first

int main() {
  int x, y = 0, t;
  scanf("%d", &x);
  t = x;
  while (t) {
    y += t % 10;
    t /= 10;
  }
  if (x % y == 0)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}
Problem p03502 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int X, Y, sum = 0, count = 100000000;
  cin >> X;
  Y = X;
  for (int i = 0; i < 8; i++) {
    sum += X / count;
    X = X % count;
    count /= 10;
  }
  if (Y % sum == 0)
    cout << "Yes";
  else
    cout << "No";
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int X, Y, sum = 0, count = 100000000;
  cin >> X;
  Y = X;
  for (int i = 0; i < 9; i++) {
    sum += X / count;
    X = X % count;
    count /= 10;
  }
  if (Y % sum == 0)
    cout << "Yes";
  else
    cout << "No";
}
Problem p03502 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <iostream>
#include <mutex>
#include <numeric>
#include <set>
#include <vector>

#define mod 1000000007
#define mp make_pair
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG

using namespace std;
using ll = long long;
using lli = long long int;
using pii = pair<int, int>;

int main() {
  int N, n, digit = 0;
  cin >> N;
  n = N;
  int a = 0;
  while (n > 0) {
    a += n % 10;
    n / 10;
  }
  if (N % a == 0)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}

Fixed submission:
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <iostream>
#include <mutex>
#include <numeric>
#include <set>
#include <vector>

#define mod 1000000007
#define mp make_pair
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG

using namespace std;
using ll = long long;
using lli = long long int;
using pii = pair<int, int>;

int main() {
  int N, n, digit = 0;
  cin >> N;
  n = N;
  int a = 0;
  while (n > 0) {
    a += n % 10;
    n /= 10;
  }
  if (N % a == 0)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}
Problem p03502 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  int fx = 0;
  int tmp_N = N;
  while (tmp_N >= 10) {
    fx += tmp_N % 10;
    tmp_N /= 10;
  }
  if (N % fx == 0) {
    cout << "Yes" << endl;
  } else if (N % fx != 0) {
    cout << "No" << endl;
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  int fx = 0;
  int tmp_N = N;
  if (N < 10) {
    cout << "Yes" << endl;
    return 0;
  }
  while (tmp_N >= 1) {
    fx += tmp_N % 10;
    tmp_N /= 10;
  }
  if (N % fx == 0) {
    cout << "Yes" << endl;
  } else if (N % fx != 0) {
    cout << "No" << endl;
  }
  return 0;
}
Problem p03502 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, S = 0;
  cin >> N;

  for (int i = 1; i < N + 1; i *= 10) {
    S += (N / (i * 10)) / i;
  }
  if (N % S == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, S = 0;
  cin >> N;

  for (int i = 1; i < N + 1; i *= 10) {
    S += (N / i) % 10;
  }
  if (N % S == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p03502 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main() {
  int N, sum = 0, n;
  cin >> N;
  n = N;

  for (int i = 8; i >= 0; i--) {
    sum += n / (10 ^ i);
    n = n % (10 ^ i);
  }
  if (N % sum == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int N, sum = 0, n;
  cin >> N;
  n = N;

  while (n > 0) {
    sum += n % 10;
    n = n / 10;
  }
  if (N % sum == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
Problem p03502 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, l, a = 0;
  cin >> n;
  l = n;

  for (int i = 8; i > 0; i--) {
    int m = 1;
    for (int j = 0; j < i; j++) {
      m *= 10;
    }
    int b = n / m;
    a += b;
    n -= (b * m);
  }

  if (l % a == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, l, a = 0;
  cin >> n;
  l = n;

  for (int i = 8; i > 0; i--) {
    int m = 1;
    for (int j = 0; j < i; j++) {
      m *= 10;
    }
    int b = n / m;
    a += b;
    n -= (b * m);
  }
  a += n;

  if (l % a == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p03502 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M, sum = 0;
  cin >> N;

  M = N;
  while (10 <= N) {
    sum += (N % 10);
    N /= 10;
    if (10 > N)
      sum += N;
  }
  cout << (M % sum == 0 ? "Yes" : "No") << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M, sum = 0;
  cin >> N;

  M = N;
  while (10 <= N) {
    sum += (N % 10);
    N /= 10;
    if (10 > N)
      sum += N;
  }
  if (sum == 0)
    sum = N;
  cout << (M % sum == 0 ? "Yes" : "No") << endl;
}
Problem p03502 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, n;
  int fn = 0;
  cin >> N;
  n = N;
  while (n > 0) {
    fn += (n % 10);
    n /= 10;
  }
  if (N % n == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, n;
  int fn = 0;
  cin >> N;
  n = N;
  while (n > 0) {
    fn += (n % 10);
    n /= 10;
  }
  if (N % fn == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p03502 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int f(int n) {
  int ret = 0;
  while (n >= 10) {
    ret += n % 10;
    n /= 10;
  }
  return ret;
}

int main() {
  int n;
  cin >> n;
  if (n % f(n) == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int f(int n) {
  int ret = 0;
  while (n >= 1) {
    ret += n % 10;
    n /= 10;
  }
  return ret;
}

int main() {
  int n;
  cin >> n;
  if (n % f(n) == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}
Problem p03502 (C++)

Buggy submission (status: Runtime Error):

#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  int j;
  int k;
  for (int i = 10; n % i <= n; i = i * 10) {
    if (i == 10) {
      j = n % i;
      continue;
    }
    k = n % (i / 10);
    j = (n % i - k) / (i / 10) + j;
    if (n % i == n) {
      n++;
    }
  }
  if (n % j == 0) {
    cout << "Yes" << endl;
    return 0;
  } else {
    cout << "No" << endl;
    return 0;
  }
}

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  int j;
  int k;
  for (int i = 10; n % i <= n; i = i * 10) {
    if (i == 10) {
      j = n % i;
      continue;
    }
    k = n % (i / 10);
    j = (n % i - k) / (i / 10) + j;
    if (n % i == n) {
      break;
    }
  }
  if (n % j == 0) {
    cout << "Yes" << endl;
    return 0;
  } else {
    cout << "No" << endl;
    return 0;
  }
}
Problem p03502 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  int num = N;
  int sum = 0;
  while (N >= 10) {
    sum += N % 10;
    N /= 10;
  }
  if (num % sum == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  int num = N;
  int sum = 0;
  while (N >= 10) {
    sum += N % 10;
    N /= 10;
  }
  sum += N;
  if (num % sum == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
Problem p03502 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return 0;
}

int main() {
  int N;
  cin >> N;
  int f_N = findSumOfDigits(N);
  if (N % f_N == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int N;
  cin >> N;
  int f_N = findSumOfDigits(N);
  if (N % f_N == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}
Problem p03502 (C++)

Buggy submission (status: Runtime Error):

#include <iostream>
using namespace std;

int main() {
  long n, fx, x;
  cin >> n;
  fx = 0;
  x = n;

  while (n > 1) {
    fx += n % 10;
    n = n / 10;
  }

  if (x % fx == 0)
    cout << "Yes";
  else
    cout << "No";
}


Fixed submission:

#include <iostream>
using namespace std;

int main() {
  long n, fx, x;
  cin >> n;
  fx = 0;
  x = n;

  while (n >= 1) {
    fx += n % 10;
    n = n / 10;
  }

  if (x % fx == 0)
    cout << "Yes";
  else
    cout << "No";
}
Problem p03502 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, y, r = 0;
  int p = 100000000;
  cin >> N;
  r = N;
  for (int i = 1; i < 9; i++) {
    y = y + r / p;
    r = r % p;
    p /= 10;
  }
  if (N % y == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, y, r = 0;
  int p = 100000000;
  cin >> N;
  r = N;
  for (int i = 1; i < 10; i++) {
    y = y + r / p;
    r = r % p;
    p /= 10;
  }
  if (N % y == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p03503 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <utility>
#include <vector>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[4] = {-1, 0, 1, 0};
ll dy[4] = {0, 1, 0, -1};

int main(void) {
  ll n;
  cin >> n;
  ll f[15][15], p[15][15];
  for (ll i = 0; i < n; i++)
    for (ll j = 0; j < 10; j++)
      cin >> f[i][j];
  for (ll i = 0; i < n; i++)
    for (ll j = 0; j <= 10; j++)
      cin >> p[i][j];
  ll ans = -1e+11;
  for (ll bit = 0; bit < (1 << 10); bit++) {
    ll check = 0;
    vector<bool> all(n, false);
    for (ll i = 0; i < n; i++) {
      ll count = 0;
      for (ll j = 0; j < 10; j++) {
        if ((bit >> j) & f[i][j]) {
          count++;
          all[j] = true;
        }
      }
      check += p[i][count];
    }
    bool zero = true;
    for (ll i = 0; i < n; i++) {
      if (all[i] == true)
        break;
      if (i == n - 1)
        zero = false;
    }
    if (zero == true)
      ans = max(check, ans);
  }
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <utility>
#include <vector>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[4] = {-1, 0, 1, 0};
ll dy[4] = {0, 1, 0, -1};

int main(void) {
  ll n;
  cin >> n;
  ll f[1000][15], p[1000][15];
  for (ll i = 0; i < n; i++)
    for (ll j = 0; j < 10; j++)
      cin >> f[i][j];
  for (ll i = 0; i < n; i++)
    for (ll j = 0; j <= 10; j++)
      cin >> p[i][j];
  ll ans = -1e+11;
  for (ll bit = 0; bit < (1 << 10); bit++) {
    ll check = 0;
    vector<bool> all(n, false);
    for (ll i = 0; i < n; i++) {
      ll count = 0;
      for (ll j = 0; j < 10; j++) {
        if ((bit >> j) & f[i][j]) {
          count++;
          all[j] = true;
        }
      }
      check += p[i][count];
    }
    bool zero = true;
    for (ll i = 0; i < n; i++) {
      if (all[i] == true)
        break;
      if (i == n - 1)
        zero = false;
    }
    if (zero == true)
      ans = max(check, ans);
  }
  cout << ans << endl;
  return 0;
}
Problem p03503 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

#define REP(i, N) for (int i = 0; i < (int)(N); i++)

// chmax, chmin
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

int main() {
  int N, M = 10;
  cin >> N;
  vector<vector<int>> F(N, vector<int>(10, 0));
  REP(i, N) REP(j, 10) cin >> F[i][j];
  vector<vector<int>> P(N, vector<int>(10, 0));
  REP(i, N) REP(j, 11) cin >> P[i][j];

  ll ans = -1e+16;
  vector<int> S;
  for (int bit = 1; bit < (1 << M); ++bit) {
    S.clear();
    for (int i = 0; i < M; ++i)
      if (bit & (1 << i))
        S.push_back(i);

    ll ans_sub = 0;
    for (int i = 0; i < N; ++i) {
      int num = 0;
      for (auto a : S) {
        num = num + F[i][a];
      }
      /*for ( int j = 0; j < S.size(); ++j){
          num = num + F[i][S[j]];
      }*/
      ans_sub = ans_sub + P[i][num];
    }
    if (ans_sub > ans)
      ans = ans_sub;
  }
  cout << ans << endl;

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

#define REP(i, N) for (int i = 0; i < (int)(N); i++)

// chmax, chmin
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

int main() {
  int N, M = 10;
  cin >> N;
  vector<vector<int>> F(N, vector<int>(10, 0));
  REP(i, N) REP(j, 10) cin >> F[i][j];
  vector<vector<int>> P(N, vector<int>(11, 0));
  REP(i, N) REP(j, 11) cin >> P[i][j];

  ll ans = -1e+16;
  vector<int> S;
  for (int bit = 1; bit < (1 << M); ++bit) {
    S.clear();
    for (int i = 0; i < M; ++i)
      if (bit & (1 << i))
        S.push_back(i);

    ll ans_sub = 0;
    for (int i = 0; i < N; ++i) {
      int num = 0;
      for (auto a : S) {
        num = num + F[i][a];
      }
      /*for ( int j = 0; j < S.size(); ++j){
          num = num + F[i][S[j]];
      }*/
      ans_sub = ans_sub + P[i][num];
    }
    if (ans_sub > ans)
      ans = ans_sub;
  }
  cout << ans << endl;

  return 0;
}
Problem p03503 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  ll n;
  cin >> n;
  vector<vector<int>> f(n, vector<int>(10)), p(n, vector<int>(10, 0));
  rep(i, n) rep(j, 10) cin >> f[i][j];
  rep(i, n) rep(j, 11) cin >> p[i][j];

  ll ans = -1e9;
  for (int si = 1; si < (1 << 10); si++) {
    vector<int> d(10);
    rep(i, 10) d[i] = (si >> i & 1);

    ll profit = 0;
    rep(i, n) {
      ll c = 0;
      rep(j, 10) if (d[j] == 1 && f[i][j] == 1) c++;
      profit += p[i][c];
    }
    ans = max(ans, profit);
  }
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  ll n;
  cin >> n;
  vector<vector<int>> f(n, vector<int>(10)), p(n, vector<int>(11));
  rep(i, n) rep(j, 10) cin >> f[i][j];
  rep(i, n) rep(j, 11) cin >> p[i][j];

  ll ans = -1e9;
  for (int si = 1; si < (1 << 10); si++) {
    vector<int> d(10);
    rep(i, 10) d[i] = (si >> i & 1);

    ll profit = 0;
    rep(i, n) {
      ll c = 0;
      rep(j, 10) if (d[j] == 1 && f[i][j] == 1) c++;
      profit += p[i][c];
    }
    ans = max(ans, profit);
  }
  cout << ans << endl;
  return 0;
}
Problem p03503 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int(i) = 0; (i) < n; (i)++)
#define SORT(a) sort((a).begin(), (a).end())
#define MOD 1000000007
typedef long long ll;

int main(void) {
  int n;
  cin >> n;
  vector<vector<int>> p(n, vector<int>(10, 0));
  vector<vector<int>> f(n, vector<int>(11, 0));
  rep(i, n) rep(j, 10) cin >> f[i][j];
  rep(i, n) rep(j, 11) cin >> p[i][j];

  int sum = 0;
  int ans = -MOD;
  for (int bit = 1; bit < (1 << 10); bit++) {
    vector<int> count(n, 0);
    sum = 0;
    for (int i = 0; i < 10; i++) {
      if (bit & (1 << i)) {
        for (int j = 0; j < n; j++) {
          if (f[j][i])
            count[j]++;
        }
      }
    }
    for (int k = 0; k < n; k++)
      sum += p[k][count[k]];
    ans = max(sum, ans);
  }
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int(i) = 0; (i) < n; (i)++)
#define SORT(a) sort((a).begin(), (a).end())
#define MOD 1000000007
typedef long long ll;

int main(void) {
  int n;
  cin >> n;
  vector<vector<int>> p(n, vector<int>(15, 0));
  vector<vector<int>> f(n, vector<int>(15, 0));
  rep(i, n) rep(j, 10) cin >> f[i][j];
  rep(i, n) rep(j, 11) cin >> p[i][j];

  int sum = 0;
  int ans = -MOD;
  for (int bit = 1; bit < (1 << 10); bit++) {
    vector<int> count(n, 0);
    sum = 0;
    for (int i = 0; i < 10; i++) {
      if (bit & (1 << i)) {
        for (int j = 0; j < n; j++) {
          if (f[j][i])
            count[j]++;
        }
      }
    }
    for (int k = 0; k < n; k++)
      sum += p[k][count[k]];
    ans = max(sum, ans);
  }
  cout << ans << endl;
  return 0;
}
Problem p03503 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main(void) {
  int n;
  cin >> n;

  int input;
  vector<unsigned int> f(n, 0);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> input;
      if (input == 1) {
        f[i] |= (1 << j);
      }
    }
  }

  vector<vector<int>> p(n, vector<int>(10));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= 10; j++) {
      cin >> p[i][j];
    }
  }

  int ans = -1e9;
  for (unsigned int i = 1; i < (1 << 10); i++) {
    int profits = 0;
    for (int j = 0; j < n; j++) {
      unsigned int open = i & f[j];
      profits += p[j][__builtin_popcount(open)];
    }

    if (ans < profits) {
      ans = profits;
    }
  }

  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main(void) {
  int n;
  cin >> n;

  int input;
  vector<unsigned int> f(n, 0);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> input;
      if (input == 1) {
        f[i] |= (1 << j);
      }
    }
  }

  vector<vector<int>> p(n, vector<int>(11));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= 10; j++) {
      cin >> p[i][j];
    }
  }

  int ans = -1e9;
  for (unsigned int i = 1; i < (1 << 10); i++) {
    int profits = 0;
    for (int j = 0; j < n; j++) {
      unsigned int open = i & f[j];
      profits += p[j][__builtin_popcount(open)];
    }

    if (ans < profits) {
      ans = profits;
    }
  }

  cout << ans << endl;
  return 0;
}
Problem p03503 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <vector>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
double pi = 3.141592653589793;
ll mod = 1000000007;

int main() {
  int N;
  cin >> N;
  int f[N][10];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> f[i][j];
    }
  }
  int p[11][11];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 11; j++) {
      cin >> p[i][j];
    }
  }
  ll ans = -922337203685477580;
  for (int i = 1; i < (1 << 10); i++) {
    int pp[N];
    for (int j = 0; j < N; j++) {
      pp[j] = 0;
    }
    for (int j = 0; j < 10; j++) {
      if ((i >> j) % 2 == 1) {
        for (int k = 0; k < N; k++) {
          if (f[k][j] == 1) {
            pp[k]++;
          }
        }
      }
    }
    ll sum = 0;
    for (int j = 0; j < N; j++) {
      sum += p[j][pp[j]];
    }
    if (sum > ans) {
      ans = sum;
    }
  }
  cout << ans << endl;
}


Fixed submission:
#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <vector>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
double pi = 3.141592653589793;
ll mod = 1000000007;

int main() {
  int N;
  cin >> N;
  int f[N][10];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> f[i][j];
    }
  }
  int p[N][11];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 11; j++) {
      cin >> p[i][j];
    }
  }
  ll ans = -922337203685477580;
  for (int i = 1; i < (1 << 10); i++) {
    int pp[N];
    for (int j = 0; j < N; j++) {
      pp[j] = 0;
    }
    for (int j = 0; j < 10; j++) {
      if ((i >> j) % 2 == 1) {
        for (int k = 0; k < N; k++) {
          if (f[k][j] == 1) {
            pp[k]++;
          }
        }
      }
    }
    ll sum = 0;
    for (int j = 0; j < N; j++) {
      sum += p[j][pp[j]];
    }
    if (sum > ans) {
      ans = sum;
    }
  }
  cout << ans << endl;
}
Problem p03503 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int a[20][20];
int p[20][20];
int q[1 << 10];
int main() {
  int n;
  cin >> n;
  rep(i, n) { rep(j, 10) cin >> a[i][j]; }
  rep(i, n) { rep(j, 11) cin >> p[i][j]; }
  int ans = -inf;
  rep(bit, 1 << 10) {
    if (bit == 0) {
      continue;
    } else {
      vector<int> cnt(n);
      rep(j, 10) {
        if ((bit >> j) & 1) {
          rep(k, n) {
            if (a[k][j] == 1)
              cnt[k]++;
          }
        }
      }
      int tmp = 0;
      rep(i, n) { tmp += p[i][cnt[i]]; }
      ans = max(ans, tmp);
    }
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int a[200][20];
int p[200][20];
int q[1 << 10];
int main() {
  int n;
  cin >> n;
  rep(i, n) { rep(j, 10) cin >> a[i][j]; }
  rep(i, n) { rep(j, 11) cin >> p[i][j]; }
  int ans = -inf;
  rep(bit, 1 << 10) {
    if (bit == 0) {
      continue;
    } else {
      vector<int> cnt(n);
      rep(j, 10) {
        if ((bit >> j) & 1) {
          rep(k, n) {
            if (a[k][j] == 1)
              cnt[k]++;
          }
        }
      }
      int tmp = 0;
      rep(i, n) { tmp += p[i][cnt[i]]; }
      ans = max(ans, tmp);
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p03503 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  vector<vector<int>> f(n, vector<int>(10));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> f[i][j];
    }
  }
  vector<vector<int>> p(n, vector<int>(10));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= 10; j++) {
      cin >> p[i][j];
    }
  }
  int ans = -1000000000;
  for (int i = 1; i < 1024; i++) {
    int score = 0;
    for (int j = 0; j < n; j++) {
      int open = 0;
      for (int k = 0; k < 10; k++) {
        if ((i >> k & 1) && f[j][k]) {
          open++;
        }
      }
      score += p[j][open];
    }
    ans = max(ans, score);
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  vector<vector<int>> f(n, vector<int>(10));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> f[i][j];
    }
  }
  vector<vector<int>> p(n, vector<int>(11));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= 10; j++) {
      cin >> p[i][j];
    }
  }
  int ans = -1000000000;
  for (int i = 1; i < 1024; i++) {
    int score = 0;
    for (int j = 0; j < n; j++) {
      int open = 0;
      for (int k = 0; k < 10; k++) {
        if ((i >> k & 1) && f[j][k]) {
          open++;
        }
      }
      score += p[j][open];
    }
    ans = max(ans, score);
  }
  cout << ans << endl;
  return 0;
}
Problem p03503 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<vector<int>> f(n, vector<int>(10));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> f[i][j];
    }
  }
  vector<vector<int>> p(n, vector<int>(11));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 11; j++) {
      cin >> p[i][j];
    }
  }
  int l = 1 << 10;
  int ans = -1000000009;
  for (int i = 1; i < l; i++) {
    int m[10] = {};
    int tmp = 0;
    for (int bit = 0; bit < 10; bit++) {
      if (i & (1 << bit)) {
        for (int j = 0; j < n; j++) {
          m[j] += f[j][bit];
        }
      }
    }
    for (int j = 0; j < n; j++) {
      tmp += p[j][m[j]];
    }

    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<vector<int>> f(n, vector<int>(10));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> f[i][j];
    }
  }
  vector<vector<int>> p(n, vector<int>(11));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 11; j++) {
      cin >> p[i][j];
    }
  }
  int l = 1 << 10;
  int ans = -1000000009;
  for (int i = 1; i < l; i++) {
    int m[n] = {};
    int tmp = 0;
    for (int bit = 0; bit < 10; bit++) {
      if (i & (1 << bit)) {
        for (int j = 0; j < n; j++) {
          m[j] += f[j][bit];
        }
      }
    }
    for (int j = 0; j < n; j++) {
      tmp += p[j][m[j]];
    }

    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}
Problem p03503 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  vvi o(n, vi(10));
  vvi p(n, vi(10));
  REP(i, n) REP(j, 10) cin >> o[i][j];
  REP(i, n) REP(j, 11) cin >> p[i][j];

  ll ans = -1e9;
  FOR(i, 1, 1 << 10) {
    vi a(n);
    ll score = 0;
    REP(j, 10) {
      if (i >> j & 1) {
        REP(k, n) {
          if (o[k][j])
            a[k]++;
        }
      }
    }
    REP(j, n) { score += p[j][a[j]]; }
    ans = max(ans, score);
  }
  cout << ans << endl;

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  vvi o(n, vi(10));
  vvi p(n, vi(11));
  REP(i, n) REP(j, 10) cin >> o[i][j];
  REP(i, n) REP(j, 11) cin >> p[i][j];

  ll ans = -1e9;
  FOR(i, 1, 1 << 10) {
    vi a(n);
    ll score = 0;
    REP(j, 10) {
      if (i >> j & 1) {
        REP(k, n) {
          if (o[k][j])
            a[k]++;
        }
      }
    }
    REP(j, n) { score += p[j][a[j]]; }
    ans = max(ans, score);
  }
  cout << ans << endl;

  return 0;
}