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

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

int main() {
  int N, A, b;
  cin >> N;
  A = 0;
  b = N;
  while (A != 0) {
    A = A + N % 10;
    N = N / 10;
  }
  if (b % A == 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;
  A = 0;
  b = N;
  while (N != 0) {
    A = A + N % 10;
    N = N / 10;
  }
  if (b % A == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p03502 (C++)

Buggy submission (status: Runtime Error):

#include <cstdio>

int main() {
  int x;
  scanf("%d", &x);
  int a = x;
  int b = 0;
  while (a >= 10) {
    b = b + a % 10;
    a = (a - a % 10) / 10;
  }
  if (x % b == 0) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}

Fixed submission:

#include <cstdio>

int main() {
  int x;
  scanf("%d", &x);
  int a = x;
  int b = 0;
  while (a != 0) {
    b = b + a % 10;
    a = (a - a % 10) / 10;
  }
  if (x % b == 0) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}
Problem p03502 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>
#include <iostream> // cout, endl, cin
#include <map>      // map
#include <math.h>
#include <numeric>
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <string>        // string, to_string, stoi
#include <tuple>         // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;
const int BG = 1000000007;

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


Fixed submission:
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>
#include <iostream> // cout, endl, cin
#include <map>      // map
#include <math.h>
#include <numeric>
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <string>        // string, to_string, stoi
#include <tuple>         // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;
const int BG = 1000000007;

int main() {
  int N;
  cin >> N;
  string tmp = to_string(N);
  int s = 0;
  rep(i, tmp.size()) { s += int(tmp[i]) - 48; }
  if (N % s == 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, n, m, p;
  cin >> N;
  p = 0;

  for (; n != 0;) {
    m = n % 10;
    p += m;
    n = (n - m) / 10;
  }

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


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

int main() {
  int N, n, m, p;
  cin >> N;
  n = N;
  p = 0;

  for (; n != 0;) {
    m = n % 10;
    p += m;
    n = (n - m) / 10;
  }

  if (N % p == 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;
  int A = 0;
  cin >> N;
  M = N;

  while (N / 10 >= 1) {
    A += N % 10;
    N = N / 10;
    if (N < 10) {
      A += N;
      break;
    }
  }
  if (M % A == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

int main() {

  int N, M;
  int A = 0;
  cin >> N;
  M = N;

  while (N / 10 >= 0) {
    A += N % 10;
    N = N / 10;
    if (N < 10) {
      A += N;
      break;
    }
  }
  if (M % 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;
  cin >> N;
  int x = 0;

  for (int i = 0; i < 8; i++) {
    int a;
    a = (N / (10 ^ i)) % 10;
    x += a;
  }

  if (N % x != 0) {
    cout << "No" << endl;
  }

  else {
    cout << "Yes" << endl;
  }
}


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

int main() {
  int N;
  cin >> N;
  int x = 0;

  for (int i = 0; i < 8; i++) {
    int a, b;
    b = 1;
    for (int j = 0; j < i; j++) {
      b *= 10;
    }
    a = (N / b) % 10;
    x += a;
  }

  if (N % x != 0) {
    cout << "No" << endl;
  }

  else {
    cout << "Yes" << endl;
  }
}
Problem p03502 (C++)

Buggy submission (status: Runtime Error):
/*
  AtCoder Beginner Contest 080
  B - Harshad Number

  方針
    各桁の数字の和をどのように計算すればよいか。
    1の位を確認した後、10で割る操作を繰り返す。

  実装
    最後にX % f(X)を計算するため、Xのバッファを用意して、
    そのバッファに対して上述の操作を行う。
*/

#include <iostream>
using namespace std;

int X;

int main() {
  int sum_digits = 0;
  int bufX = X;
  while (bufX != 0) {
    sum_digits += bufX % 10;
    bufX /= 10;
  }

  if (X % sum_digits == 0)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}

Fixed submission:
/*
  AtCoder Beginner Contest 080
  B - Harshad Number

  方針
    各桁の数字の和をどのように計算すればよいか。
    1の位を確認した後、10で割る操作を繰り返す。

  実装
    最後にX % f(X)を計算するため、Xのバッファを用意して、
    そのバッファに対して上述の操作を行う。
*/

#include <iostream>
using namespace std;

int X;

int main() {
  scanf("%d", &X);

  int sum_digits = 0;
  int bufX = X;
  while (bufX != 0) {
    sum_digits += bufX % 10;
    bufX /= 10;
  }

  if (X % sum_digits == 0)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}
Problem p03502 (C++)

Buggy submission (status: Runtime Error):
// Harshad Number

#include <iostream>

using namespace std;

int sumDigits(int n) {
  if (n / 10 == 0)
    return 0;
  return sumDigits(n / 10) + n % 10;
}

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

  int sd = sumDigits(N);

  if (N % sd)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;

  return 0;
}

Fixed submission:
// Harshad Number

#include <iostream>

using namespace std;

int sumDigits(int n) {
  if (n / 10 == 0)
    return n;
  return sumDigits(n / 10) + n % 10;
}

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

  int sd = sumDigits(N);

  if (N % sd)
    cout << "No" << endl;
  else
    cout << "Yes" << 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 fx = 0;

  for (int i = N; i > 10; i /= 10) {
    int x = i % 10;
    fx += x;
  }

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

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

int main() {
  int N;
  cin >> N;
  int fx = 0;

  for (int i = N; i > 0; i /= 10) {
    int x = i % 10;
    fx += x;
  }

  if (N % fx == 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;
  cin >> n;
  int tmp = n;
  int fn = 0;

  while (tmp > 0) {
    fn += tmp % 10;
    tmp / 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 tmp = n;
  int fn = 0;

  while (tmp > 0) {
    fn += tmp % 10;
    tmp /= 10;
  }

  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() {
  int n, sum = 0;
  cin >> n;
  for (int i = 100000000; i > 9; i /= 10) {
    int x = (n % (i * 10)) / i;
    sum += x;
  }

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

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

int main() {
  int n, sum = 0;
  cin >> n;
  for (int i = 100000000; i > 0; i /= 10) {
    int x = (n % (i * 10)) / i;
    sum += x;
  }

  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 N = 0;
  int M = 100000000;
  int tmp = 0;
  int O = 0;

  // 10進数の整数の入力
  cin >> N;
  O = N;
  for (int i = 8; i > 0; i--) {
    tmp = tmp + (O / M);
    O = O % M;
    M /= 10;
  }

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

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

int main() {
  // 定義一覧
  int N = 0;
  int M = 100000000;
  int tmp = 0;
  int O = 0;

  // 10進数の整数の入力
  cin >> N;
  O = N;
  for (int i = 9; i > 0; i--) {
    // cout << M << endl;
    tmp = tmp + (O / M);
    O = O % M;
    M /= 10;
  }

  if ((N % tmp) == 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 <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;

int main() {
  int x;
  cin >> x;
  int y = x;
  y = to_string(y).length();
  int res = 0;
  for (int i = y; i > 0; i--) {
    int tmp = x;
    tmp = x / pow(10, i);
    res = res + tmp;
  }
  if (x % res == 0) {
    puts("Yes");
  } else {
    puts("No");
  }
}


Fixed submission:
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;

int main() {
  int N;
  cin >> N;
  int res = 0, x = N;
  while (N > 0) {
    res += N % 10;
    N /= 10;
  }
  if (x % res == 0) {
    puts("Yes");
  } else {
    puts("No");
  }
}
Problem p03502 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int jk(int n) {
  int count = 0;
  while (n) {
    count += n % 10;
    n / 10;
  }
  return count;
}
int main() {
  int a;
  cin >> a;
  int count = jk(a);
  if (a % count == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int jk(int n) {
  int count = 0;
  while (n) {
    count = count + n % 10;
    n /= 10;
  }
  return count;
}
int main() {
  int a;
  cin >> a;
  int count = jk(a);
  if (a % count == 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, x;
  x = 0;
  cin >> N;
  for (int a = N; a > 1; a /= 10) {
    x += a % 10;
  }
  if (N % x == 0)
    cout << "Yes" << endl;
  else if (N % x != 0)
    cout << "No" << endl;
}


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

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

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

int main() {
  int N, S;
  S = 0;
  cin >> N;
  for (int n = N; n != 0; n /= 0) {
    S += n % 10;
  }

  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;
  S = 0;
  cin >> N;
  for (int n = N; n != 0; n /= 10) {
    S += n % 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 sumdigits(int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
}
int main() {
  int n;
  cin >> n;
  int sum = sumdigits(n);
  if (n % sum == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Fixed submission:
#include <iostream>
using namespace std;
int sumdigits(int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main() {
  int n;
  cin >> n;
  int sum = sumdigits(n);
  if (n % sum == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
Problem p03502 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#ifdef DEBUG
#include "_debug.cpp"
#include "callable.hpp/callable.hpp"
#endif
#define endl '\n'
using namespace std;
using ll = long long;
int f(int n) {
  int ans = 0;
  while (n > 10) {
    ans += n % 10;
    n /= 10;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  cout << (n % f(n) ? "No" : "Yes") << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#ifdef DEBUG
#include "_debug.cpp"
#include "callable.hpp/callable.hpp"
#endif
#define endl '\n'
using namespace std;
using ll = long long;
int f(int n) {
  int ans = 0;
  while (n > 0) {
    ans += n % 10;
    n /= 10;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  cout << (n % f(n) ? "No" : "Yes") << 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 total = 0;
  int i = 0;
  int b = 1000000000;
  int n = N;
  while (i <= 8) {
    if (n / b != 0) {
      total += n / b;
      n = n - (n / b * b);
    }
    b /= 10;
    i++;
  }
  cout << (N % total == 0 ? "Yes" : "No") << endl;
}

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

int main() {
  int N;
  cin >> N;
  int total = 0;
  int i = 0;
  int b = 100000000;
  int n = N;
  while (i <= 8) {
    if (n / b != 0) {
      total += n / b;
      n = n - (n / b * b);
    }
    b /= 10;
    i++;
  }
  cout << (N % total == 0 ? "Yes" : "No") << endl;
}
Problem p03502 (C++)

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

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define repr(i, n) for (ll i = n - 1; i >= 0; --i)
#define INF 10e7
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
using namespace std;

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

Fixed submission:
#include <bits/stdc++.h>

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define repr(i, n) for (ll i = n - 1; i >= 0; --i)
#define INF 10e7
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
using namespace std;

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

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int s(int x) {
  int r = 0;
  while (x) {
    r += x % 10;
    x /= 10;
  }
  return r;
}

int main() {
  int n;
  if (n % s(n) == 0)
    printf("Yes\n");
  else
    printf("No\n");
}


Fixed submission:
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int s(int x) {
  int r = 0;
  while (x) {
    r += x % 10;
    x /= 10;
  }
  return r;
}

int main() {
  int n;
  scanf("%d", &n);
  if (n % s(n) == 0)
    printf("Yes\n");
  else
    printf("No\n");
}
Problem p03502 (C++)

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

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

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

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

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

int main() {
  int N;
  cin >> N;
  int M = N;
  int sum = 0;
  while (M = !0) {
    sum += M % 10;
    M /= 10;
  }
  if (N % sum == 0)
    cout << "Yes\n";
  else
    cout << "No\n";
  return 0;
}


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

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

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

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

  int sum = 0;

  for (int i = 0; i < N; i++) {
    int a = N / pow(10, i);
    sum += 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;

  for (int i = 0; i < N; i++) {
    int a = N / pow(10, i);

    if (a == 0) {
      break;
    }

    sum += 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>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

// 数字の各桁の和を返す
int sumDigits(int n) {
  int s;
  while (n < 0) {
    s += n % 10;
    n /= 10;
  }
  return s;
}

// 最大公約数を返す
int gcd(int x, int y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

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

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

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

// 数字の各桁の和を返す
int sumDigits(int n) {
  int s;
  while (n > 0) {
    s += n % 10;
    n /= 10;
  }
  return s;
}

// 最大公約数を返す
int gcd(int x, int y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

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

  int f = sumDigits(N);
  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;
using ll = long long;

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

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

int f(int a) {
  int res = 0;
  while (a != 0) {
    res += a % 10;
    a /= 10;
  }
  return res;
}
int main() {
  int N;
  cin >> N;
  if (N % f(N) == 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 A = 0;
  int i = N;

  while (i > 10) {
    A += N % 10;
    i /= 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;
  cin >> N;
  int A = 0;
  int i = N;

  while (i) {
    A += i % 10;
    i = i / 10;
  }

  if (N % 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, w = 0, x = 1;
  cin >> n;
  for (int i = 0; i < 8, i++;) {
    w += n / x % 10;
    x *= 10;
  }
  if (n % w == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, w = 0, x = 1;
  cin >> n;
  int digit = log10(n) + 1;
  for (int i = 0; i < digit; i++) {
    w += n / x % 10;
    x *= 10;
  }
  if (n % w == 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 Nod = 0, x, pow = 1;
  int n, N, S = 0;
  string Number;

  cin >> N;

  // 桁数計算
  n = N;
  while (n != 0) {
    n = n / 10;
    Nod++;
  }

  vector<int> vec(Nod);

  // 桁ごとの数字を求める
  n = N;
  for (int i = Nod; i > 0; i--) {
    // 10^Nod-i乗を計算
    for (int j = 0; j < i - 1; j++) {
      pow = pow * 10;
    }

    // 桁数ごとに格納
    vec.at(i - 1) = n / pow;
    n = n - vec.at(i - 1) * pow;

    pow = 1; // powを初期化
  }

  for (int i = 0; i < Nod - 1; i++) {
    S = S + vec.at(i);
  }

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


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

int main() {
  int Nod = 0, x, pow = 1;
  int n, N, S = 0;
  string Number;

  cin >> N;

  // 桁数計算
  n = N;
  while (n != 0) {
    n = n / 10;
    Nod++;
  }

  vector<int> vec(Nod);

  // 桁ごとの数字を求める
  n = N;
  for (int i = Nod; i > 0; i--) {
    // 10^Nod-i乗を計算
    for (int j = 0; j < i - 1; j++) {
      pow = pow * 10;
    }

    // 桁数ごとに格納
    vec.at(i - 1) = n / pow;
    n = n - vec.at(i - 1) * pow;

    pow = 1; // powを初期化
  }

  for (int i = 0; i < Nod; i++) {
    S = S + vec.at(i);
  }

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;

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

Fixed submission:
#include <algorithm>
#include <iostream>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;
  int tmp = n;
  int wa = 0;
  while (tmp) {
    wa += tmp % 10;
    tmp = tmp / 10;
  }
  if (n % wa == 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 X, fx = 0;
  cin >> X;

  // ここにプログラムを追記
  int i = 100000000;
  for (int j = 0; j < 9; j++) {
    fx += (X / i) / 10;
    i /= 10;
  }
  if (X % fx)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  return 0;
}

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

int main() {
  int X, fx = 0;
  cin >> X;

  // ここにプログラムを追記
  int tmp_X = X;
  while (tmp_X != 0) {
    fx += tmp_X % 10;
    tmp_X /= 10;
  }
  if (X % fx)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  return 0;
}
Problem p03502 (C++)

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

using namespace std;

int main() {
  int n, i, j, a, c = 0;

  cin >> n;
  j = n;
  while (j < 0) {
    a = j % 10;
    c += a;
    j = j / 10;
  }
  cout << (n % c == 0 ? "Yes" : "No") << endl;
  return 0;
}

Fixed submission:
#include <iostream>

using namespace std;

int main() {
  int n, i, j, a, c = 0;

  cin >> n;
  j = n;
  while (j > 0) {
    a = j % 10;
    c += a;
    j = j / 10;
  }
  cout << (n % c == 0 ? "Yes" : "No") << endl;
  return 0;
}
Problem p03502 (C++)

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

int main() {
  int N, sum, a, b, C;
  sum = 0;
  cin >> N;
  a = 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10;
  b = N;

  for (int i = 0; i < 8; i++) {
    a /= 10;
    sum += b / a;
    b %= a;
  }

  C = N % sum;

  if (C == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

int main() {
  int N, sum, a, b, C;
  sum = 0;
  cin >> N;
  a = 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10;
  b = N;

  for (int i = 0; i < 9; i++) {
    a /= 10;
    sum += b / a;
    b %= a;
  }

  C = N % sum;

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <array>
#include <bitset>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <type_traits>
#include <utility>
#include <vector>
#define INT_MAX 2147483647
#define _LIBCPP_DEBUG 0
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int max(int a, int b) {
  int max;
  if (a > b)
    max = a;
  else
    max = b;
  return max;
}
int min(int a, int b) {
  int min;
  if (a < b)
    min = a;
  else
    min = b;
  return min;
}

int main() {
  int n;
  cin >> n;
  int t = n;
  int s = 0;
  bool a = false;

  while (n > 0) {
    s += t % 10;
    t /= 10;
  }

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

Fixed submission:
#include <algorithm>
#include <array>
#include <bitset>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <type_traits>
#include <utility>
#include <vector>
#define INT_MAX 2147483647
#define _LIBCPP_DEBUG 0
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int max(int a, int b) {
  int max;
  if (a > b)
    max = a;
  else
    max = b;
  return max;
}
int min(int a, int b) {
  int min;
  if (a < b)
    min = a;
  else
    min = b;
  return min;
}

int main() {
  int n;
  cin >> n;
  int t = n;
  int s = 0;
  bool a = false;

  while (t > 0) {
    s += t % 10;
    t /= 10;
  }

  if ((n % s) == 0) {
    a = true;
  }
  if (a) {
    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, S, sum = 0, A = 100000000;
  cin >> N;
  int L = N;
  for (int i = 0; i < 8; i++) {
    S = L / A;
    sum += S;
    L = L % A;
    A /= 10;
  }

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


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

int main() {
  int N, S, sum = 0, A = 100000000;
  cin >> N;
  int L = N;
  for (int i = 0; i < 9; i++) {
    S = L / A;
    sum += S;
    L = L % A;
    A /= 10;
  }

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

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

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

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


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

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

int main(void) {
  int n;
  int sum = 0;
  cin >> n;
  sum = SumOfDigits(n);
  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 i, p = 0;
  long N;
  cin >> N;
  for (i = 0; i < 10; i++)
    p += (N / (long)powl(10, i + 1)) % 10;

  cout << ((N % p) ? "No" : "Yes") << endl;

  // ここにプログラムを追記
}

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

int main() {
  int i, p = 0;
  long N;
  cin >> N;
  for (i = 0; i < 8; i++)
    p += (N / (long)powl(10, i)) % 10;

  cout << ((N % p) ? "No" : "Yes") << endl;

  // ここにプログラムを追記
}
Problem p03502 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main() {
  int a, b, s = 0, t;
  cin >> a;
  t = a;
  while (a = 0) {
    b = a % 10;
    a = a / 10;
    s += b;
  }
  if (t % s == 0)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int a, b, s = 0, t;
  cin >> a;
  t = a;
  while (a != 0) {
    b = a % 10;
    a = a / 10;
    s += b;
  }
  if (t % s == 0)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}
Problem p03502 (C++)

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

int f_func(int x) {
  int ans = 0;
  while (x / 10 > 0) {
    ans += x % 10;
    x /= 10;
  }
  return ans;
}

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

  if (n % f_func(n) == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

int f_func(int x) {
  int ans = 0;
  while (x > 0) {
    ans += x % 10;
    x /= 10;
  }
  return ans;
}

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

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

Buggy submission (status: Runtime Error):
#include <stdio.h>
int main() {
  int N, fx = 0;
  scanf("%d", &N);
  for (int i = 1; N > i; i *= 10) {
    fx += ((N - (N % i)) / i) % 10;
  }
  printf("%s", N % fx == 0 ? "Yes" : "No");
}

Fixed submission:
#include <stdio.h>
int main() {
  int N, fx = 0;
  scanf("%d", &N);
  for (int i = 1; N > i; i *= 10) {
    fx += ((N - (N % i)) / i) % 10;
  }
  printf("%s", fx == 0 ? "Yes" : (N % fx == 0 ? "Yes" : "No"));
}
Problem p03502 (C++)

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

int main() {
  int N, N1;
  cin >> N;
  N1 = N;

  int sum = 0;

  while (N1 > 10) {
    sum += N1 % 10;
    N1 /= 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, N1;
  cin >> N;
  N1 = N;

  int sum = 0;

  while (N1 > 0) {
    sum += N1 % 10;
    N1 /= 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, n, x, y;
  cin >> n;
  x = 10;

  for (i = 0; i < n && i < 8; i++) {
    y += n / x;
    x *= 10;
  }
  if (n % y == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
signed main() {
  int x, c = 0;
  string s;
  cin >> x;
  s = to_string(x);
  for (int i = 0; i < (int)s.size(); i++)
    c += s[i] - '0';
  cout << (x % c == 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, m, a = 0;
  cin >> n;
  m = n;
  while (m >= 0) {
    a += m % 10;
    m = m / 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, m, a = 0;
  cin >> n;
  m = n;
  while (m > 0) {
    a += m % 10;
    m = m / 10;
  }
  if (n % a == 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 sumofdigits(int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n / 10;
  }
  return sum;
}
int main() {
  int n;
  cin >> n;
  if (n % sumofdigits(n) == 0)
    cout << "Yes";
  else
    cout << "No";
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int sumofdigits(int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main() {
  int n;
  cin >> n;
  if (n % sumofdigits(n) == 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, j;
  int sum;
  int x, y, z;

  j = 0;
  sum = 0;
  cin >> N;
  y = N;

  for (int i = 8; i > 0; i--) {

    j++;

    z = std::pow(10, i);

    x = y / z;

    sum += x;

    y -= x * z;

    /*
    cout << z << endl;
    cout << "No." << j << endl;
    cout << "x=" << x <<endl;
    cout << "sum=" << sum <<endl;
    cout << "y=" << y << endl;
    */
  }

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


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

int main() {
  int N, j;
  int sum;
  int x, y, z;

  j = 0;
  sum = 0;
  cin >> N;
  y = N;

  for (int i = 8; i >= 0; i--) {

    j++;

    z = std::pow(10, i);

    x = y / z;

    sum += x;

    y -= x * z;

    /*
    cout << z << endl;
    cout << "No." << j << endl;
    cout << "x=" << x <<endl;
    cout << "sum=" << sum <<endl;
    cout << "y=" << y << endl;
    */
  }

  if (N % 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, M;
  cin >> N;
  int A;
  N = M;

  while (M > 0) {
    A = A + M % 10;
    M = M / 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, M;
  cin >> N;
  int A = 0;
  M = N;

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

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

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

int main() {
  int t = N, c = 0;

  while (t > 0)
    c += t % 10, t /= 10;
  if (N % c == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

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

  while (t > 0)
    c += t % 10, t /= 10;
  if (N % c == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
Problem p03502 (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;

int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int N, n;
  cin >> N;
  n = N;
  int x = 0;
  while (n) {
    x += n / 10;
    n /= 10;
  }
  if (N % x)
    cout << "No\n";
  else
    cout << "Yes\n";
}


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

int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int N, n;
  cin >> N;
  n = N;
  int x = 0;
  while (n) {
    x += n % 10;
    n /= 10;
  }
  if (N % x)
    cout << "No\n";
  else
    cout << "Yes\n";
}
Problem p03502 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int yeah(int a) {
  int sum = 0;
  while (a > 0) {
    sum += a % 10;
    a /= 10;
  }
}

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

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int yeah(int a) {
  int sum = 0;
  while (a > 0) {
    sum += a % 10;
    a /= 10;
  }
  return sum;
}

int main() {
  int N;
  cin >> N;
  if (N % yeah(N) == 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 A;
  A = 0;

  for (int i = 100000000; 1 < i; i /= 10) {
    A += N / i % 10;
  }

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


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

int main() {
  int N;
  cin >> N;
  int A;
  A = 0;

  for (int i = 100000000; 1 <= i; i /= 10) {
    A += N / i % 10;
  }

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

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

using namespace std;

int main() {
  long long i, j, n, f = 0;
  cin >> n;
  j = n;

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

  if (j % f)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;

  return 0;
}

Fixed submission:
#include <iostream>

using namespace std;

int main() {
  long long i, j, n, f = 0;
  cin >> n;
  j = n;

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

  if (j % f)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;

  return 0;
}
Problem p03502 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int X = N;
  int Y = 0;
  while (X >= 0) {
    Y += X % 10;
    X /= 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;
  cin >> N;
  int X = N;
  int Y = 0;
  while (X > 0) {
    Y += X % 10;
    X /= 10;
  }

  if (N % Y == 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;
  int X;
  int sum = 0;

  cin >> N;

  for (int i = 0; i < to_string(N).length(); i++) {
    sum += X % 10;
    X /= 10;
  }

  N % sum == 0 ? cout << "Yes" << endl : cout << "No" << endl;
}

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

int main() {
  int N;
  int X;
  int sum = 0;

  cin >> N;
  X = N;

  for (int i = 0; i < to_string(N).length(); i++) {
    sum += X % 10;
    X /= 10;
  }

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

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

int main() {
  long n;
  std::cin >> n;

  long val = 0;
  long nBuf = n;
  for (int i = 0; i < (int)log10(n); ++i) {
    val += nBuf % 10;
    nBuf = nBuf / 10;
  }

  if (0 == n % val) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }

  return 0;
}


Fixed submission:
#include <cmath>
#include <iostream>

int main() {
  long n;
  std::cin >> n;

  long val = 0;
  long nBuf = n;
  while (0 != nBuf) {
    val += nBuf % 10;
    nBuf = nBuf / 10;
  }

  if (0 == n % val) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }

  return 0;
}
Problem p03502 (Python)

Buggy submission (status: Runtime Error):
N = int(input())

print("Yes" if sum(map(N)) % N == 0 else "No")


Fixed submission:
N = input()
print("No" if int(N) % sum(map(int, N)) else "Yes")
Problem p03502 (C++)

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

int main() {
  int N, f, sum;
  cin >> N;
  f = N;
  while (N > 0) {
    if ((N % 10) != 0) {
      sum += N % 10;
      N = N / 10;
    }
  }
  if ((f % sum) == 0)
    puts("Yes");
  else
    puts("No");
}


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

int main() {
  int N, f, sum;
  cin >> N;
  f = N;
  while (N > 0) {
    if ((N % 10) != 0) {
      sum += N % 10;
      N = N / 10;
    } else
      break;
  }
  if ((f % sum) == 0)
    puts("Yes");
  else
    puts("No");
}
Problem p03502 (C++)

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

int main() {
  int N, sum;
  cin >> N;
  for (int i = 1; i <= N; i * 10) {
    sum += N / i % 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, sum;
  cin >> N;
  for (int i = 1; i <= N; i *= 10) {
    sum += N / i % 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 n;
  cin >> n;

  int a;
  a = n;

  int m = 0;

  while (n / 10 != 0) {
    m += n % 10;
    n /= 10;
  }

  cout << (a % m == 0 ? "Yes" : "No") << endl;
}

Fixed submission:
#include <bits/stdc++.h>

using namespace std;

int main() {

  int n;
  cin >> n;

  int a;
  a = n;

  int m = 0;

  while (n != 0) {
    m += n % 10;
    n /= 10;
  }

  cout << (a % m == 0 ? "Yes" : "No") << endl;
}
Problem p03502 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>

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 sum = findSumOfDigits(N);

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

  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>

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 sum = findSumOfDigits(N);

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

  return 0;
}
Problem p03502 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>￼
using namespace std;
int main() {
  int a, b, c, d = 0;
  cin >> a;
  c = a;
  while (a > 0) {
    b = a % 10;
    d += b;
    a / 10;
  }
  if (c % d == 0)
    cout << "Yes";
  else
    cout << "No";
}


Fixed submission:
#include <bits/stdc++.h>￼
using namespace std;
int main() {
  int a, b, c, d = 0;
  cin >> a;
  c = a;
  while (a > 0) {
    b = a % 10;
    d += b;
    a /= 10;
  }
  if (c % d == 0)
    cout << "Yes";
  else
    cout << "No";
}
Problem p03502 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main() {
  int N, i, sum;
  i = N;
  sum = 0;
  while (N > 0) {
    sum += N % 10;
    N /= 10;
  }
  if (i % sum == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int N, i, sum;
  cin >> N;
  i = N;
  sum = 0;
  while (N > 0) {
    sum += N % 10;
    N /= 10;
  }
  if (i % 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 x;
  cin >> x;
  int f = 0;
  for (int p = x; p >= 10; p = (p - p % 10) / 10) {
    f += p % 10;
  }
  if (x % f == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

int main() {
  int x;
  cin >> x;
  int f = 0;
  for (int p = x; p >= 1; p = (p - p % 10) / 10) {
    f += p % 10;
  }
  if (x % 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 = 0;
  cin >> N;
  int n = N;
  while (true) {
    M += n / 10;
    n = n / 10;
    if (n == 0) {
      break;
    }
  }
  if (N % M == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

int main() {
  int N, M = 0;
  cin >> N;
  int n = N;
  while (true) {
    M += n % 10;
    n = n / 10;
    if (n == 0) {
      break;
    }
  }
  if (N % M == 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 fn = 0;
  for (int i = 1; i < N; i * 10) {
    fn += (N % i) % 10;
  }

  if (N % fn == 0) {
    cout << "Yes" << endl;
  }

  if (N % fn != 0) {
    cout << "No" << endl;
  }
}


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

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

  int fn = 0;
  int x = N;
  while (x > 0) {
    fn += x % 10;
    x = x / 10;
  }

  if (N % fn == 0) {
    cout << "Yes" << endl;
  }

  if (N % fn != 0) {
    cout << "No" << endl;
  }
}