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

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

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

  ll ans = 0;

  if (n < 10) {
    cout << "Yes" << endl;
    return 0;
  }

  for (int i = 1; i < n; i *= 10) {
    ans += n / i - n / (i * 10) * 10;
  }

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


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

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

  ll ans = 0;

  if (n < 10) {
    cout << "Yes" << endl;
    return 0;
  }

  for (int i = 1; i < n + 1; i *= 10) {
    ans += n / i - n / (i * 10) * 10;
  }

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

Buggy submission (status: Runtime Error):
#include <iostream>
#include <vector>
using namespace std;
int main() {
  long n;
  cin >> n;
  long s = 0;
  for (long i = 1; n > i; i = i * 10) {
    s += (n / i) % 10;
  }
  if (n % s == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Fixed submission:
#include <iostream>
#include <vector>
using namespace std;
int main() {
  long n;
  cin >> n;
  long s = 0;
  for (long i = 1; n >= i; i = i * 10) {
    s += (n / i) % 10;
  }
  if (n % s == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
Problem p03316 (C++)

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

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

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

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

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

using namespace std;

int main() {

  int n;
  cin >> n;
  int m = n;
  int summ = 0;
  for (int i = 0; i <= int(log(n) / log(10)); i++) {
    summ += m - int(m / 10) * 10;
    m = int(m / 10);
  }
  if (n % summ == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

using namespace std;

int main() {

  int n;
  cin >> n;
  int m = n;
  int summ = 0;
  for (int i = 0; i <= int((double)log(n) / log(10)) + 1; i++) {
    summ += m - int(m / 10) * 10;
    m = int(m / 10);
  }
  if (n % summ == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p03316 (C++)

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

int S(int n) {
  int sum = 0;
  for (int i = 0; i < 9; i++) {
    if (n != 0) {
      sum += n % 10;
      n = n / 10;
    } else
      break;
  }
  return sum;
}

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

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

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

int S(int n) {
  int sum = 0;
  for (int i = 0; i < 100; i++) {
    if (n != 0) {
      sum += n % 10;
      n = n / 10;
    } else
      break;
  }
  return sum;
}

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

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

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

using namespace std;

typedef long long ll;

int main() {
  ll N;

  cin >> N;

  int tmp = 0;
  int s = 0;

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

  if (N % s)
    cout << "No\n";
  else
    cout << "Yes\n";
}


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

using namespace std;

typedef long long ll;

int main() {
  ll N;

  cin >> N;

  int tmp = N;
  int s = 0;

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

  if (N % s)
    cout << "No\n";
  else
    cout << "Yes\n";
}
Problem p03316 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
using namespace std;
int a, b, c;
int main() {
  scanf("%d", &a);
  c = a;
  while (a != 0) {
    b += a % 10;
    a = a % 10;
  }
  if (c % b == 0)
    printf("Yes");
  else
    printf("No");
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
using namespace std;
int a, b, c;
int main() {
  scanf("%d", &a);
  c = a;
  while (a != 0) {
    b += a % 10;
    a = a / 10;
  }
  if (c % b == 0)
    printf("Yes");
  else
    printf("No");
  return 0;
}
Problem p03316 (C++)

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

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int S, M;
  S = 0;
  M = N;
  for (int i = 0; i < 10; i++) {
    S += M % 10;
    M /= 10;
  }
  if (N % S == 0) {
    cout << "Yes" << endl;
  }
  if (N % S != 0) {
    cout << "No" << endl;
  }
  return 0;
}
Problem p03316 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
long long n, temp, i, j, s[100];

int main() {
  cin >> n;
  temp = n;
  for (i = 0; i <= n; i++) {
    s[i] = temp % 10;
    temp /= 10;
  }
  temp = 0;
  for (j = 0; j <= i; j++)
    temp += s[j];
  if (n % temp == 0)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
long long n, temp, i, j, s[100];

int main() {
  cin >> n;
  temp = n;
  for (i = 0; temp >= 1; i++) {
    s[i] = temp % 10;
    temp /= 10;
  }
  temp = 0;
  for (j = 0; j <= i; j++)
    temp += s[j];
  if (n % temp == 0)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}
Problem p03316 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>

using namespace std;

int main() {

  int n, s = 0;

  cin >> n;

  int tmp = n;

  while (tmp) {
    s += n % 10;
    n /= 10;
  }

  if (n % s)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;

  return 0;
}

Fixed submission:
#include <iostream>

using namespace std;

int main() {

  int n, s = 0;

  cin >> n;

  int tmp = n;

  while (tmp) {
    s += tmp % 10;
    tmp /= 10;
  }

  if (n % s)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;

  return 0;
}
Problem p03316 (C++)

Buggy submission (status: Runtime Error):
#include <math.h>
#include <stdio.h>

int main() {
  int n;
  scanf("%d", &n);
  char nstr[10];
  sprintf(nstr, "%d", n);

  int sn = 0;
  for (int i = 0;; i++) {
    if (nstr[i] == '\0')
      break;
    sn += nstr[i] - '0';
  }
  if (n % sn)
    printf("No\n");
  else
    printf("Yes\n");
}

Fixed submission:
#include <math.h>
#include <stdio.h>

int main() {
  int n;
  scanf("%d", &n);
  char nstr[11];
  sprintf(nstr, "%d", n);

  int sn = 0;
  for (int i = 0;; i++) {
    if (nstr[i] == '\0')
      break;
    sn += nstr[i] - '0';
  }
  if (n % sn)
    printf("No\n");
  else
    printf("Yes\n");
}
Problem p03316 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define fi first
#define se second
#define repl(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repl(i, 0, n)
#define sort(a) sort((a).begin(), (a).end())
#define rev(a) reverse((a).begin(), (a).end())
using db = double;
using namespace std;
typedef long long ll;

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


Fixed submission:
#include <bits/stdc++.h>
#define fi first
#define se second
#define repl(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repl(i, 0, n)
#define sort(a) sort((a).begin(), (a).end())
#define rev(a) reverse((a).begin(), (a).end())
using db = double;
using namespace std;
typedef long long ll;

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

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

int main() {
  int n, ans = 0, tep;
  cin >> n;
  n = tep;
  for (int i = 0; i < 11; i++) {
    ans += tep % 10;
    if (tep / 10 == 0) {
      break;
    }
    tep = tep / 10;
  }
  if (n % ans == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

int main() {
  int n, ans = 0, tep;
  cin >> n;
  tep = n;
  for (int i = 0; i < 11; i++) {
    ans += tep % 10;
    if (tep / 10 == 0) {
      break;
    }
    tep = tep / 10;
  }
  if (n % ans == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p03316 (C++)

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

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

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

int SumDigit(int N) {
  int sum = 0;
  while (N / 10 > 0) {
    sum += N % 10;
    N = (N - N % 10) / 10;
  }
  return sum;
}

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


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

int SumDigit(int N) {
  int sum = 0;
  while (N > 0) {
    sum += N % 10;
    N = (N - N % 10) / 10;
  }
  return sum;
}

int main() {
  int N;
  cin >> N;
  int sum = SumDigit(N);
  if (N % sum == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p03316 (C++)

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

using namespace std;

int main() {
  long n, m, a, b, c;
  char N, M, A, B, C;
  c = 0;
  cin >> a;
  b = 1;
  for (int i = 0; i < 9; i++) {
    c += int(a / b) % 10;
    b *= 10;
  }

  if (a % c)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}


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

using namespace std;

int main() {
  long n, m, a, b, c;
  char N, M, A, B, C;
  c = 0;
  cin >> a;
  b = 1;
  for (int i = 0; i <= 9; i++) {
    c += int(a / b) % 10;
    b *= 10;
  }

  if (a % c)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}
Problem p03316 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string.h>
#include <string>
using namespace std;

int main() {
  int N, S = 0, keta = 0, p = 1, k = 0;
  cin >> N;
  k = N;
  for (int i = N; i > 0; i /= 10) {
    keta++;
    p *= 10;
  }
  for (int i = 0; i < keta; i++) {
    p /= 10;
    S += k / p;
    k = k % p;
  }
  if (N % S == 0)
    cout << "Yes";
  else
    cout << "No";
}

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

int main() {
  long long int N, S = 0, keta = 0, p = 1, k = 0;
  cin >> N;
  k = N;
  for (int i = N; i > 0; i /= 10) {
    keta++;
    p *= 10;
  }
  for (int i = 0; i < keta; i++) {
    p /= 10;
    S += k / p;
    k = k % p;
  }
  if (N % S == 0)
    cout << "Yes";
  else
    cout << "No";
}
Problem p03316 (C++)

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

int main() {
  int N;
  cin >> N;
  int sum = 0;
  int tmp = N;
  int tmp1;
  while (tmp / 10 != 0) {
    tmp1 = tmp;
    sum += tmp % 10;
    tmp = tmp1 / 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 tmp = N;
  int tmp1;
  while (tmp != 0) {
    tmp1 = tmp;
    sum += tmp % 10;
    tmp = tmp1 / 10;
  }
  if (N % sum == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
Problem p03316 (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 main() {
  int n;
  cin >> n;
  int a = n;
  int b = 0;
  while (n == 0) {
    b += n % 10;
    n /= 10;
  }
  if (a % b == 0) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
int main() {
  int n;
  cin >> n;
  int a = n;
  int b = 0;
  while (n) {
    b += n % 10;
    n /= 10;
  }
  if (a % b == 0) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  return 0;
}
Problem p03316 (Python)

Buggy submission (status: Runtime Error):
# python template for atcoder1
import sys

sys.setrecursionlimit(10**9)

N = input()
di = 0
for c in N:
    di += int(c)
if N % di == 0:
    print("Yes")
else:
    print("No")


Fixed submission:
# python template for atcoder1
import sys

sys.setrecursionlimit(10**9)

N = input()
di = 0
for c in N:
    di += int(c)
if int(N) % di == 0:
    print("Yes")
else:
    print("No")
Problem p03316 (Python)

Buggy submission (status: Runtime Error):
def sum_digits(n):
    s = 0
    while n:
        s += n % 10
        n //= 10
    return s


while True:
    num = int(input())
    if num % sum_digits(num) == 0:
        print("Yes")
    else:
        print("No")


Fixed submission:
def sum_digits(n):
    s = 0
    while n:
        s += n % 10
        n //= 10
    return s


num = int(input())
if num % sum_digits(num) == 0:
    print("Yes")
else:
    print("No")
Problem p03316 (Python)

Buggy submission (status: Runtime Error):
N = input()
S = 0
for i in N:
    S += int(i)
print("Yes" if N % S == 0 else "No")


Fixed submission:
N = input()
S = 0
for i in N:
    S += int(i)
print("Yes" if int(N) % S == 0 else "No")
Problem p03316 (Python)

Buggy submission (status: Runtime Error):
def main():
    s = input()
    total = 0
    for i in range(len(s)):
        total += int(s[i])

    if int(s) % total == 0:
        print("Yes")
    else:
        print("No")


def main2():
    n = int(input())
    total = 0
    tmp = n
    while tmp > 0:
        total += n % 10
        tmp = tmp // 10

    if n % total == 0:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main2()


Fixed submission:
def main():
    s = input()
    total = 0
    for i in range(len(s)):
        total += int(s[i])

    if int(s) % total == 0:
        print("Yes")
    else:
        print("No")


def main2():
    n = int(input())
    total = 0
    tmp = n
    while tmp > 0:
        total += tmp % 10
        tmp = tmp // 10

    if n % total == 0:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main2()
Problem p03316 (C++)

Buggy submission (status: Runtime Error):
// floyd2.cpp : アプリケーションのエントリ ポイントを定義します。
//

// floyd.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

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

int main() {
  string N;
  int sum, s[10], len, k, num;

  cin >> N;
  num = stoi(N);
  len = N.length();
  k = 0;
  sum = 0;

  while (k < len) {
    s[k] = N[k] - '0';
    sum = +s[k];
    k++;
  }

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

  cout << endl;
}

Fixed submission:
// floyd2.cpp : アプリケーションのエントリ ポイントを定義します。
//

// floyd.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

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

int main() {
  string N;
  int sum, s[10], len, k, num;

  cin >> N;
  num = stoi(N);
  len = N.length();
  k = 0;
  sum = 0;

  while (k < len) {
    s[k] = N[k] - '0';
    sum += s[k];
    k++;
  }

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

  cout << endl;
}
Problem p03316 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

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

  int dig = 0, tmp_n = 0;
  while (tmp_n != 0) {
    dig += tmp_n % 10;
    tmp_n /= 10;
  }

  string result = N % dig == 0 ? "Yes" : "No";
  cout << result << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

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

  int dig = 0, tmp_n = N;
  while (tmp_n != 0) {
    dig += tmp_n % 10;
    tmp_n /= 10;
  }

  string result = N % dig == 0 ? "Yes" : "No";
  cout << result << endl;
  return 0;
}
Problem p03316 (C++)

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

#define len length()
#define sz size()
#define rep(i, n) for (int i = 0; i < n; i++)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)

int ndg(int x, int n) { return (x % int(pow(10, n))) / pow(10, n - 1); }

int main() {
  int N;
  cin >> N;
  int S = 0;
  for (int i = 1; i < 10; i++)
    S += ndg(N, i);
  if (N % S == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

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

#define len length()
#define sz size()
#define rep(i, n) for (int i = 0; i < n; i++)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)

int ndg(int x, int n) { return (x % int(pow(10, n))) / pow(10, n - 1); }

int main() {
  int N;
  cin >> N;
  int S = 0;
  for (int i = 1; i < 11; i++)
    S += ndg(N, i);
  if (N % S == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
Problem p03316 (C++)

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

int main() {
  int n, cp, s = 0;
  cin >> n;
  cp = n;
  for (int i = 0; i < 9; i++) {
    s += n % 10;
    n /= 10;
  }
  if (cp % s)
    cout << "No\n";
  else
    cout << "Yes\n";
}

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

int main() {
  int n, cp, s = 0;
  cin >> n;
  cp = n;
  for (int i = 0; i < 10; i++) {
    s += n % 10;
    n /= 10;
  }
  if (cp % s)
    cout << "No\n";
  else
    cout << "Yes\n";
}
Problem p03316 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
const int N = 1000000;

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

  int sum = 0;
  for (int i = 0; i < stoi(n); ++i) {
    sum += stoi(n.substr(i, 1));
  }
  if (stoi(n) % sum == 0)
    print("Yes");
  else
    print("No");
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
const int N = 1000000;

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

  int sum = 0;
  for (int i = 0; i < n.length(); ++i) {
    sum += stoi(n.substr(i, 1));
  }
  if (stoi(n) % sum == 0)
    print("Yes");
  else
    print("No");
}
Problem p03316 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>

#define f(i, x) for (int i = 0; i < x; i++)

using namespace std;

int main() {
  int a, b = 0, x;

  cin >> a;

  x = a;
  while (a % 10 != 0) {
    b += a % 10;
    a /= 10;
  }
  if (x % b == 0)
    cout << "Yes";
  else
    cout << "No";

  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>

#define f(i, x) for (int i = 0; i < x; i++)

using namespace std;

int main() {
  int a, b = 0, x;

  cin >> a;

  x = a;
  while (a != 0) {
    b += a % 10;
    a /= 10;
  }
  if (x % b == 0)
    cout << "Yes";
  else
    cout << "No";

  return 0;
}
Problem p03316 (C++)

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

using namespace std;

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

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

Fixed submission:
#include <iostream>

using namespace std;

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

int main() {
  int n;
  cin >> n;
  cout << (n % f(n) == 0 ? "Yes" : "No") << endl;
}
Problem p03316 (C++)

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

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

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

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


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

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

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

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

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

int main() {
  int n, x;
  cin >> n;
  x = 0;
  int a = n;
  while (a == 0) {
    x += a % 10;
    a = a / 10;
  }

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


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

int main() {
  int n, x;
  cin >> n;
  x = 0;
  int a = n;
  while (a > 0) {
    x += a % 10;
    a = a / 10;
  }

  if (n % x == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p03316 (C++)

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

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


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

int main() {
  long long n, w = 10, s = 0;
  cin >> n;
  while (w <= 10000000000) {
    s += (n % w) / (w / 10);
    w = w * 10;
  }
  if (n % s == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p03316 (C++)

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

int SumOfEachDits(long long N) {
  int ans = 0;
  string S = to_string(N);
  for (int i = 0; i < S.size(); i++) {
    ans += (N % 10);
    ans /= 10;
  }
  return ans;
}

int main() {
  long long A;
  cin >> A;
  int Sn = SumOfEachDits(A);
  bool jdg = false;
  if (A % Sn == 0)
    jdg = true;
  if (jdg)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int SumOfEachDits(long long N) {
  int ans = 0;
  string S = to_string(N);
  for (int i = 0; i < S.size(); i++) {
    ans += (N % 10);
    N /= 10;
  }
  return ans;
}

int main() {
  long long A;
  cin >> A;
  int Sn = SumOfEachDits(A);
  bool jdg = false;
  if (A % Sn == 0)
    jdg = true;
  if (jdg)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
Problem p03316 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

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


Fixed submission:
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

int main() {
  int N;
  cin >> N;
  int cnt = 0;
  int tmpN = N;
  while (tmpN > 0) {
    cnt += tmpN % 10;
    tmpN /= 10;
  }
  if (N % cnt == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}
Problem p03316 (C++)

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

int main() {
  int N;
  cin >> N;
  int amari = 0;
  int K = N;
  for (int i = 0; i < 10; i++) {
    amari = amari + N % 10;
    K = K / 10;
    if (K == 0) {
      break;
    }
  }

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

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

int main() {
  int N;
  cin >> N;
  int amari = 0;
  int K = N;
  for (int i = 0; i < 10; i++) {
    amari = amari + K % 10;
    // cout << amari << endl;
    K = K / 10;
    if (K == 0) {
      break;
    }
  }

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

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

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int sn = 0;
  int al = n;
  for (int i = 0; i < 10; i++) {
    sn += n - n / 10 * 10;
    n /= 10;
  }
  if (al % sn == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
Problem p03316 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;
int main() {
  int a, i = 1, sum = 0;
  cin >> a;

  while (a > i) {
    if (a == 10) {
      cout << "Yes" << endl;
      return 0;
    }
    sum += a % (10 * i) / i;
    i = i * 10;
  }
  if (a % sum == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;
int main() {
  int a, i = 1, sum = 0;
  cin >> a;

  while (a >= i) {
    sum += a % (10 * i) / i;
    i = i * 10;
  }
  if (a % sum == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p03316 (C++)

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


Fixed submission:
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int main(void) {
  int n, s, a, b;
  cin >> n;
  a = n;
  b = n;
  s = 0;
  while (1) {
    a = b % 10;
    b = b / 10;
    s = s + a;
    if (b == 0)
      break;
  }
  if (n % s == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p03316 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  int S = 0;
  cin >> N;
  int temp = N;
  while (N) {
    S += temp % 10;
    temp = temp / 10;
  }
  if (N % S == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  int S = 0;
  cin >> N;
  int temp = N;
  while (temp) {
    S += temp % 10;
    temp = temp / 10;
  }
  if (N % S == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
Problem p03316 (C++)

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

int main() {
  long N;
  int S = 0;
  cin >> N;
  for (int i = 0; i < 9; i++) {
    S += (N / (long)pow(10, i)) % 10;
  }
  if (N % S == 0) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}

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

int main() {
  long N;
  int S = 0;
  cin >> N;
  for (int i = 0; i <= 9; i++) {
    S += (N / (long)pow(10, i)) % 10;
  }
  if (N % S == 0) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}
Problem p03316 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  int ans = 0;
  int tmp = n;
  while (tmp != 0) {
    ans + tmp % 10;
    tmp = tmp / 10;
  }
  if (n % ans == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

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

int main() {
  int n;
  cin >> n;
  int m = n;
  int s = 0;
  while (m > 0) {
    s += n % 10;
    m /= 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;
  cin >> n;
  int m = n;
  int s = 0;
  while (m > 0) {
    s += m % 10;
    m /= 10;
  }
  if (n % s == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
Problem p03316 (C++)

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

int main() {
  int n;
  int SN = 0;
  cin >> n;
  int a = n;
  for (int i = 0; i < 9; i++) {
    SN += (n % 10);
    n = n / 10;
  }
  if (a % SN == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

int main() {
  int n;
  int SN = 0;
  cin >> n;
  int a = n;
  for (int i = 0; i < 10; i++) {
    SN += (n % 10);
    n = n / 10;
  }
  if (a % SN == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}
Problem p03316 (C++)

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

int main() {
  int n;
  cin >> n;
  int s = 0;
  int m = n;
  for (int i = 0; i < 9; i++) {
    s += m % 10;
    m /= 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;
  cin >> n;
  int s = 0;
  int m = n;
  for (int i = 0; i < 10; i++) {
    s += m % 10;
    m /= 10;
  }

  if ((n % s) == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p03316 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int s = 0;
  int m = n;
  while (m)
    s += m % 10, m /= 10;
  cout << (n % m == 0 ? "Yes" : "No");
}


Fixed submission:
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int s = 0;
  int m = n;
  while (m)
    s += m % 10, m /= 10;
  cout << (n % s == 0 ? "Yes" : "No");
}
Problem p03316 (C++)

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int _loop_int;
#define REP(i, n) for (_loop_int i = 0; i < (_loop_int)(n); ++i)
#define FOR(i, a, b) for (_loop_int i = (_loop_int)(a); i < (_loop_int)(b); ++i)
#define FORR(i, a, b)                                                          \
  for (_loop_int i = (_loop_int)(b)-1; i >= (_loop_int)(a); --i)

#define DEBUG(x) cout << #x << ": " << x << endl
#define DEBUG_VEC(v)                                                           \
  cout << #v << ":";                                                           \
  REP(i, v.size()) cout << " " << v[i];                                        \
  cout << endl
#define ALL(a) (a).begin(), (a).end()

int main() {
  string ans;
  ll n;
  cin >> n;

  int nsize = 0;

  int ins = 0;

  for (ll i = 1; i < n; i = i * 10)
    nsize++;

  REP(i, nsize) ins += (n % (ll)pow(10, i + 1)) / pow(10, i);

  ans = (n % ins == 0) ? "Yes" : "No";

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

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int _loop_int;
#define REP(i, n) for (_loop_int i = 0; i < (_loop_int)(n); ++i)
#define FOR(i, a, b) for (_loop_int i = (_loop_int)(a); i < (_loop_int)(b); ++i)
#define FORR(i, a, b)                                                          \
  for (_loop_int i = (_loop_int)(b)-1; i >= (_loop_int)(a); --i)

#define DEBUG(x) cout << #x << ": " << x << endl
#define DEBUG_VEC(v)                                                           \
  cout << #v << ":";                                                           \
  REP(i, v.size()) cout << " " << v[i];                                        \
  cout << endl
#define ALL(a) (a).begin(), (a).end()

int main() {
  string ans;
  ll n;
  cin >> n;

  int nsize = 0;

  int ins = 0;

  for (ll i = 1; i < n; i = i * 10)
    nsize++;

  REP(i, nsize + 1) { ins += (n % (ll)pow(10, i + 1)) / pow(10, i); }

  // DEBUG(ins);

  ans = (n % ins == 0) ? "Yes" : "No";

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

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  long long N;
  cin >> N;
  long long A = N;
  long long n = 0;
  for (int i = 1; i <= 9; i++) {
    n += A % 10;
    A /= 10;
  }
  if (N % n == 0)
    cout << "Yes";
  else
    cout << "No";
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  long long N;
  cin >> N;
  if (N == 1000000000) {
    cout << "Yes";
    return 0;
  }
  long long A = N;
  long long n = 0;
  for (int i = 1; i <= 9; i++) {
    n += A % 10;
    A /= 10;
  }
  if (N % n == 0)
    cout << "Yes";
  else
    cout << "No";
}
Problem p03316 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int a = 0, n = N;
  while (N) {
    a += N % 10;
    N /= 10;
  }
  cout << (n % N == 0 ? "Yes" : "No") << endl;
  return 0;
}

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

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

int main() {
  int N;
  int t = N, fn = 0;
  while (t > 0) {
    fn += t % 10;
    t /= 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 t = N, fn = 0;
  while (t > 0) {
    fn += t % 10;
    t /= 10;
  }
  if (N % fn == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
Problem p03316 (Python)

Buggy submission (status: Runtime Error):
N = input()
sn = sum([int(i) for i in str(N)])
if N % sn == 0:
    print("Yes")
else:
    print("No")


Fixed submission:
N = input()
sn = sum([int(i) for i in str(N)])
if int(N) % sn == 0:
    print("Yes")
else:
    print("No")
Problem p03316 (C++)

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

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

int main() {
  int n;
  cin >> n;
  int y = digsum(n);
  cout << ((n % y == 0) ? "Yes" : "No") << endl;
}

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

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

int main() {
  int n;
  cin >> n;
  int y = digsum(n);
  cout << ((n % y == 0) ? "Yes" : "No") << endl;
}
Problem p03316 (Python)

Buggy submission (status: Runtime Error):
# Nは最大9桁
n = input()
sn = 0
for ni in n:
    sn += int(ni)
if n % sn == 0:
    print("Yes")
else:
    print("No")


Fixed submission:
# Nは最大9桁
n = input()
sn = 0
for ni in n:
    sn += int(ni)
if int(n) % sn == 0:
    print("Yes")
else:
    print("No")
Problem p03316 (C++)

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

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


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

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

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

int main() {
  std::cin.tie(nullptr);
  std::cin.sync_with_stdio(false);
  int n;
  std::cin >> n;
  int m = 0;
  for (int i = n; i > 0; i /= 10) {
    m += n % 10;
  }
  std::cout << (n % m == 0 ? "Yes" : "No") << std::endl;
}

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

int main() {
  std::cin.tie(nullptr);
  std::cin.sync_with_stdio(false);
  int n;
  std::cin >> n;
  int m = 0;
  for (int i = n; i > 0; i /= 10) {
    m += i % 10;
  }
  std::cout << (n % m == 0 ? "Yes" : "No") << std::endl;
}
Problem p03316 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repb(i, n) for (int i = (int)n; i >= 0; i--)
#define reps(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define repsb(i, m, n) for (int i = (int)m; i >= (int)n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999999999999
using namespace std;
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
using namespace std;
int main(int argc, char const *argv[]) {
  int n, s = 0, t;
  cin >> n;
  t = n;
  while (t > 0) {
    s += t % 10;
    t /= 10;
  }
  if (n % t == 0)
    cout << "Yes" << '\n';
  else
    cout << "No" << '\n';
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repb(i, n) for (int i = (int)n; i >= 0; i--)
#define reps(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define repsb(i, m, n) for (int i = (int)m; i >= (int)n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999999999999
using namespace std;
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
using namespace std;
int main(int argc, char const *argv[]) {
  int n, s = 0, t;
  cin >> n;
  t = n;
  while (t > 0) {
    s += t % 10;
    t /= 10;
  }
  if (n % s == 0)
    cout << "Yes" << '\n';
  else
    cout << "No" << '\n';
  return 0;
}
Problem p03316 (C++)

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

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


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

int main() {
  int n;
  cin >> n;
  int keta = log10(n) + 1;
  int N = n;
  int t;
  for (int i; i < keta; i++) {
    t += n % 10;
    n /= 10;
  }
  if (N % t == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p03316 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int i, sum = 0;
  int N = n;
  for (i = 0; i < n; i++) {
    sum += N % 10;
    N /= 10;
  }
  if (n % sum == 0) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int i, sum = 0;
  int N = n;
  for (i = 0; i < 10; i++) {
    sum += N % 10;
    N /= 10;
  }
  if (n % sum == 0) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}
Problem p03316 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int f(long long l) {
  int r = 0;
  while (l) {
    r += l % 10;
    l /= 10;
  }
}
int main() {
  long long n;
  cin >> n;
  if (!(n % f(n)))
    cout << "Yes\n";
  else
    cout << "No\n";
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int f(long long l) {
  int r = 0;
  while (l) {
    r += l % 10;
    l /= 10;
  }
  return r;
}
int main() {
  long long n;
  cin >> n;
  if (!(n % f(n)))
    cout << "Yes\n";
  else
    cout << "No\n";
  return 0;
}
Problem p03316 (C++)

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

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


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

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

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

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

  int tmp = n, sum = 0;
  while (tmp / 10 != 0) {
    sum += tmp % 10;
    tmp /= 10;
  }

  cout << (n % sum == 0 ? "Yes" : "No") << endl;
}

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

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

  int tmp = n, sum = 0;
  while (tmp / 10 != 0) {
    sum += tmp % 10;
    tmp /= 10;
  }

  sum += tmp;

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

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

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

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

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

  return 0;
}

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

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

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

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

  return 0;
}
Problem p03316 (C++)

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

using namespace std;

int main() {
  int n, nn, sum = 0;

  cin >> n;

  nn = n;

  for (int i = 0; i < 9; i++) {
    sum += nn % 10;
    nn /= 10;
    if (nn == 0)
      break;
  }

  if (n % sum)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;

  return 0;
}


Fixed submission:
#include <iostream>

using namespace std;

int main() {
  int n, nn, sum = 0;

  cin >> n;

  nn = n;

  for (int i = 0; i < 10; i++) {
    sum += nn % 10;
    nn /= 10;
    if (nn == 0)
      break;
  }

  if (n % sum)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;

  return 0;
}
Problem p03316 (C++)

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

int s(int n) {
  int ans = 0;
  while (n == 0) {
    ans += n % 10;
    n /= 10;
  }
  return ans;
}

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

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

int s(int n) {
  int ans = 0;
  while (n) {
    ans += n % 10;
    n /= 10;
  }
  return ans;
}

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

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

int main() {
  int n, t;
  int sum = 0;
  cin >> n;
  t = n;
  for (int i = 0; i < 9; i++) {
    sum += t % 10;
    t /= 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, t;
  int sum = 0;
  cin >> n;
  t = n;
  for (int i = 0; i < 10; i++) {
    sum += t % 10;
    t /= 10;
  }
  if (n % sum == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}