alexjercan/bugnet huggingface dataset:
Problem p02576 (C++) — buggy submission, verdict: Runtime Error

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

using namespace std;

int Compare_Func_A(const int &arg_a, int &arg_b);
int Compare_Func_B(const int &arg_a, int &arg_b);

const int MIN_TAKO = 1;
const int LIMIT_TIME = 1000;
const int ERROR = -1;

int main() {
  int Int_N = 0;
  int Int_X = 0;
  int Int_T = 0;

  int Result_N = 0;
  int Result_T = 0;
  int Total_Time = 0;

  std::cin >> Int_N >> Int_X >> Int_T;

  Result_N = Compare_Func_A(MIN_TAKO, Int_N);
  if (ERROR == Result_N) {
    return -1;
  }

  Result_T = Compare_Func_B(LIMIT_TIME, Int_T);
  if (ERROR == Result_T) {
    return -1;
  }

  while (0 < Int_N) {
    Total_Time = Total_Time + Int_T;
    Int_N = Int_N - Int_X;
  }

  std::cout << Total_Time << std::endl;

  return 0;
}

int Compare_Func_A(const int &arg_a, int &arg_b) {
  if (arg_a > arg_b) {
    return ERROR;
  }
  return 0;
}

int Compare_Func_B(const int &arg_a, int &arg_b) {
  if (arg_a < arg_b) {
    return ERROR;
  }
  return 0;
}

Error: 0

Fixed submission:

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

using namespace std;

int Compare_Func_A(const int &arg_a, int &arg_b);
int Compare_Func_B(const int &arg_a, int &arg_b);

const int MIN_TAKO = 1;
const int LIMIT_TIME = 1000;
const int ERROR = -1;

int main() {

  int Result_N = 0;
  int Result_T = 0;
  int Total_Time = 0;

  std::string str_N;
  std::string str_X;
  std::string str_T;
  std::cin >> str_N >> str_X >> str_T;

  int Int_N = stoi(str_N.c_str());
  int Int_X = stoi(str_X.c_str());
  int Int_T = stoi(str_T.c_str());

  Result_N = Compare_Func_A(MIN_TAKO, Int_N);
  if (ERROR == Result_N) {
    return -1;
  }

  Result_T = Compare_Func_B(LIMIT_TIME, Int_T);
  if (ERROR == Result_T) {
    return -1;
  }

  while (0 <= Int_N) {
    Total_Time = Total_Time + Int_T;
    Int_N = Int_N - Int_X;
  }

  std::cout << Total_Time << std::endl;

  return 0;
}

int Compare_Func_A(const int &arg_a, int &arg_b) {
  if (arg_a > arg_b) {
    return ERROR;
  }
  return 0;
}

int Compare_Func_B(const int &arg_a, int &arg_b) {
  if (arg_a <= arg_b) {
    return ERROR;
  }
  return 0;
}
Problem p02576 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>

int main() {
  int i;
  int a[3];
  int q = 0;
  int output;

  for (i = 0; i < 3; i++) {
    if (scanf("%d", &a[i]) == 1) {
    } else {
    }
  }

  while (a[0] > a[1]) {
    a[0] = a[0] - a[1];
    q++;
  }

  if (a[0] != 0) {
    output = (q + 1) * a[2];
  }

  if (a[0] = 0) {
    output = q * a[2];
  }

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

  return 0;
}


Error: -6
*** stack smashing detected ***: terminated


Fixed submission:



#include <stdio.h>

int main(void) {
  int i;
  int input[2];
  int q = 0;
  int output;

  for (i = 0; i < 3; i++)
    (void)scanf("%d", &input[i]);

  while (input[0] > input[1]) {
    input[0] = input[0] - input[1];
    q++;
  }

  if (input[0] != 0) {
    output = (q + 1) * input[2];
  }

  if (input[0] = 0) {
    output = q * input[2];
  }

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

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

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

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> pi;
typedef vector<pi> vpi;
typedef vector<string> vsi;
typedef map<ll, ll> mape;
#define rep(i, a, b) for (ll i = (ll)a; i <= (ll)b; i++)
#define per(i, a, b) for (ll i = (ll)a; i >= (ll)b; i--)
#define fastio                                                                 \\
  {                                                                            \\
    ios_base::sync_with_stdio(false);                                          \\
    cin.tie(NULL);                                                             \\
    cout.tie(NULL);                                                            \\
  }
#define N 1000010
#define MAX 1234567890

void solve() {
  ll n, x, t;
  cin >> n >> x >> t;
  cout << (n + x - 1) / x * t << endl;
}

int main() {
  fastio;

  solve();

  return 0;
}

Error: 0

Fixed submission:

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

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> pi;
typedef vector<pi> vpi;
typedef vector<string> vsi;
typedef map<ll, ll> mape;
#define rep(i, a, b) for (ll i = (ll)a; i <= (ll)b; i++)
#define per(i, a, b) for (ll i = (ll)a; i >= (ll)b; i--)
#define fastio                                                                 \\
  {                                                                            \\
    ios_base::sync_with_stdio(false);                                          \\
    cin.tie(NULL);                                                             \\
    cout.tie(NULL);                                                            \\
  }
#define N 1000010
#define MAX 1234567890

ll solve() {
  ll n, x, t;
  cin >> n >> x >> t;
  cout << (n + x - 1) / x * t << endl;
}

int main() {
  fastio;

  solve();

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

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

int main() {
  int tako, min, sum;
  cin >> sum >> tako >> min;
  int i = 1;
  while (true) {

    if (sum <= tako * i) {

      break;
    }

    i++;
  }

  cout << min * i << endl;
}

Error: TLE

Fixed submission:

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

int main() {
  int tako, min, sum;
  int N = 100000;
  cin >> sum >> tako >> min;
  int i = 1;
  while (true) {

    if (sum < tako * i) {

      break;
    }
  }

  cout << min * i << endl;
}
Problem p02576 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int N, X, T;
  cin >> N >> X >> T;

  int count;

  if (N == X) {
    cout << T << endl;
  }

  else if (N % X == 0) {
    cout << (N / X) * T << endl;
  }

  else if (X != 1) {

    count = N / X;

    cout << (count + 1) * T << endl;

  }

  else {
    cout << N * T << endl;
  }
}

Error: -8

Fixed submission:

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

int main() {
  int N, X, T;
  cin >> N >> X >> T;

  int count;

  if (N == X) {
    cout << T << endl;
  }

  else if ((N / X) % 0) {
    cout << (N / X) * T << endl;
  }

  else if (X != 1) {

    count = N / X;

    cout << (count + 1) * T << endl;

  }

  else {
    cout << N * T << endl;
  }
}
Problem p02576 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

#define ll long long
#define pii pair<ll, ll>

using namespace std;

int main(void) {
  double n, x, t;
  cin >> n >> x >> t;

  cout << (ll)(t * (ceil(n / x))) << endl;
  return 0;
}

Error: -6
malloc(): corrupted top size


Fixed submission:

#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main(void) {
  ll T;
  cin >> T;

  while (T--) {
    string s;
    cin >> s;

    int ocr[27] = {0};

    for (int i = 0; i < s.size(); i++) {
      ocr[s[i] - 'a'] += 1;
    }

    int m;
    cin >> m;

    vector<int> v(m);
    vector<char> ans(m);

    for (auto &it : v)
      cin >> it;

    for (int i = 0; i < m; i++) {
      int cnt = 0;
      for (int j = 0; j < m; j++) {
        if (v[j] == 0)
          ++cnt;
      }
      if (cnt == 0) {
        break;
      }

      for (int i = 25; i >= 0; i--) {
        if (v[i] >= cnt) {
          v[i] = -1;
          cnt = i;
          break;
        }
      }

      for (int i = 0; i < m; i++) {
        if (v[i] = 0) {
          v[i] = -1;
          ans[i] = (char)('a' + cnt);

          for (int k = i; k >= 0; --k) {
            if (v[k] != 0)
              v[k] -= abs(k - i);
          }

          for (int k = i; k < m; k++) {
            if (v[k] != 0)
              v[k] -= abs(k - i);
          }
        }
      }
    }

    for (char c : ans) {
      cout << c;
    }
    cout << endl;
  }

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

#include <iostream>
using namespace std;

int main() {
  int N, X, T;
  cin >> N >> X >> T;
  int times = (N + X - 1) / X;
  int ans = times * T;
  cout << ans << endl;
}

Error: TLE

Fixed submission:

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

int main() {
  int n, x, t, sum = 1, ans = 0;
  cin >> n >> x >> t;
  while (x < n) {
    sum += 1;
  }
  ans = sum * t;
  cout << ans << endl;
}
Problem p02576 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

// =======================================================

using namespace std;

// =======================================================

#define rep(i, n) for (int i = 0; i < n; i++)
#define pi 3.14159265358979

// =======================================================

// ライブラリ(*'▽')
int gcd(int a, int b) // 最大公約数
{
  if (a % b == 0) {
    return (b);
  } else {
    return (gcd(b, a % b));
  }
}

int lcm(int a, int b) // 最小公倍数
{
  return a * b / gcd(a, b);
}

// =======================================================

int main() {
  int n, x, t;
  int ans;
  cin >> n >> x >> t;
  if (n % x == 0) {
    ans = n / x * t;
  } else {
    ans = (n / x + 1) * t;
  }
  cout << ans << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

// =======================================================

using namespace std;

// =======================================================

#define rep(i, n) for (int i = 0; i < n; i++)
#define pi 3.14159265358979

// =======================================================

// ライブラリ(*'▽')
int gcd(int a, int b) // 最大公約数
{
  if (a % b == 0) {
    return (b);
  } else {
    return (gcd(b, a % b));
  }
}

int lcm(int a, int b) // 最小公倍数
{
  return a * b / gcd(a, b);
}

// =======================================================

int main() {
  int n, x, t;
  cin >> n >> x >> t;
  int ans = 0;
  for (int i = 1;; i++) {
    if (i * x >= n) {
      cout << i << endl;
    }
  }
  return 0;
}
Problem p02576 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

int main() {
  int N, X, T;
  cin >> N >> X >> T;

  if (N % X == 0) {
    cout << (N / X) * T;
  } else {
    cout << (N / X) * T + T;
  }
}

Error: 12

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int N, X, T;
  cin >> N >> X >> T;
  int time = T;
  int i = X;

  if (N % X == 0) {
    return (N / X) * T;
  } else {
    return (N / X) * T + T;
  }
}
Problem p02576 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, t, i, p;
  cin >> n >> x >> t;
  for (i = 0; i < n; i++) {
    i = i + x;
  }
  p = i / x;
  cout << p * t << '\\n';
  return (0);
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, t, i, p;
  p = 0;
  cin >> n >> x >> t;
  for (i = 0; i < n; i++) {
    i = x;
  }
  p = i / x;
  cout << p * t << '\\n';
  return (0);
}
Problem p02576 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  int X, T, N, A;
  cin >> N >> X >> T;
  A = N / X;
  if (N % X)
    A++;
  cout << A * T;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int X, T, N;
  cin >> N >> X >> T;
  X = N / X;
  if (N % X)
    X++;
  cout << X * T;
}
Problem p02577 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
#include <string.h>
int main() {
  char s[1000000];
  long long int i, j, p = 0, a, k;
  scanf("%s", s);
  a = strlen(s); // printf("%d",a);
  for (i = 0; i < a; i++) {
    p = p + (s[i] - '0');
    p = p % 9;
  }
  if (p % 9 == 0)
    printf("Yes\\n");
  else
    printf("No\\n");
  return 0;
}


Error: 0

Fixed submission:

#include <stdio.h>
#include <string.h>
int main() {
  char s[100000];
  long long int i, j, p = 0, a, k;
  scanf("%s", s);
  a = strlen(s); // printf("%d",a);
  for (i = 0; i < a; i++) {
    p = p + (s[i] - '0');
    p = p % 9;
  }
  if (p % 9 == 0)
    printf("Yes\\n");
  else
    printf("No\\n");
  return 0;
}
Problem p02577 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int sum = 0;
  for (int i = 0; i < s.size(); i++) {
    sum = sum + (s[i] - '0');
  }
  if (sum == 0) {
    cout << "Yes" << endl;
  } else if (sum < 9) {
    cout << "No" << endl;
  } else if (sum % 9 == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  char str[1000];
  cin >> str;
  int i, result = 0, n;
  for (i = 0; i < strlen(str); i++) {
    n = str[i] - 48;
    result = result + n;
  }
  if (result % 9 == 0) {
    cout << "Yes" << endl;
  } else
    cout << "No" << endl;
}
Problem p02577 (C++) — buggy submission, verdict: Runtime Error

#include <cstring>
#include <iostream>
using namespace std;
char s[10000009];
int main() {
  cin >> s;
  long long sum = 0;
  for (int i = 0; i < strlen(s); i++)
    sum += int(s[i] - '0');
  if (sum % 9 == 0)
    cout << "Yes";
  else {
    cout << "No";
  }
  system("pause");
}

Error: WA

Fixed submission:

#include <cstring>
#include <iostream>
using namespace std;
char s[100009];
int main() {
  cin >> s;
  long long sum = 0;
  for (int i = 0; i < strlen(s); i++)
    sum += int(s[i] - '0');
  if (sum % 9 == 0)
    cout << "Yes";
  else {
    cout << "No";
  }
  system("pause");
}
Problem p02577 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;

int main() {
  Bint n, sum = 0, dig = 0;

  cin >> n;
  if (n % 9 == 0) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#include <boost/multiprecision/cpp_int.hpp> // <-- add!!!

using namespace boost::multiprecision; // <-- add!!!

int main() {
  cpp_int n, sum = 0, dig = 0;

  cin >> n;
  while (n) {
    sum += n % 10;
    n /= 10;
  }
  if (sum % 9 == 0) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}
Problem p02577 (C++) — buggy submission, verdict: Runtime Error

// BISMILLAH
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  int n, x, t, res, cnt = 0, flag = 0, temp = 0;
  string str;
  cin >> str;
  // int len=strlen(str);
  int sum = 0;
  for (int i = 0; i < str.size(); i++) {
    // int a=str[i]-'0';
    sum += str[i] - '0';
  }
  // cout<<sum<<endl;
  if (sum % 9 == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Error: 0

Fixed submission:

// BISMILLAH
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  int n, x, t, res, cnt = 0, flag = 0, temp = 0;
  char str[1000];
  scanf("%s", str);
  int len = strlen(str);
  int sum = 0;
  for (int i = 0; i < len; i++) {
    int a = str[i] - '0';
    sum += a;
  }
  // cout<<sum<<endl;
  if (sum % 9 == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
Problem p02577 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  long int n = 0;
  int c = cin.get();
  while (c >= '0' && c <= '9') {
    n += c - '0';
    c = cin.get();
  }
  if (n % 9 == 0)
    cout << "Yes";
  else
    cout << "No";
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int n = 0;
  char c = cin.get();
  while (!cin.eof()) {
    n += c - '0';
  }
  if (c % 9) {
    cout << "No";
  }
  cout << "Yes";
}
Problem p02577 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
#include <string.h>
int main() {
  int i, sm = 0;
  char s[2000009];
  scanf("%s", s);
  for (i = 0; i < strlen(s); i++)
    sm += s[i] - '0';
  if (sm % 9 == 0)
    printf("Yes\\n");
  else
    printf("No\\n");
}

Error: 0

Fixed submission:

#include <stdio.h>
#include <string.h>
int main() {
  int i, sm = 0;
  char s[100000];
  scanf("%s", s);
  for (i = 0; i < strlen(s); i++)
    sm += s[i] - '0';
  if (sm % 9 == 0)
    printf("Yes\\n");
  else
    printf("No\\n");
}
Problem p02577 (C++) — buggy submission, verdict: Runtime Error

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

char s[200010];
int main() {
  scanf("%s", s);
  int len = strlen(s);
  int sum = 0;
  for (int i = 0; i < len; i++)
    sum += s[i] - '0';
  if (sum % 9 == 0) {
    puts("Yes");
  } else {
    puts("No");
  }
}


Error: WA

Fixed submission:

#include <iostream>
using namespace std;

int A[20000000];
;

int main() {

  int ite = 0, m = 1, N, n, sum = 0, mod;

  cin >> N;

  while (n == 0) {

    ++ite;

    n = N / m;

    if (ite != 1)
      m = m * 10;
  }

  for (int i = 0; i < ite; i++) {

    A[i] = N / m;
    N = N - A[i] * m;
    m = m / 10;
  }

  for (int i = 0; i < ite; i++) {

    sum += A[i];
  }

  mod = sum % 9;

  if (mod == 0)
    cout << "Yes";
  else
    cout << "No";

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

#include <bits/stdc++.h>

using namespace std;

int main() {

  string s;
  cin >> s;

  unsigned long long sum = 0;
  int arr[100005];
  for (int i = 0; i < (int)s.length(); i++) {
    arr[i] = s[i] - '0';
    sum += arr[i];
  }

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

  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int arr[100005];

int main() {

  string s;
  cin >> s;

  long long sum = 0;
  for (int i = 0; i < (int)s.length(); i++) {
    arr[i] = s[i] - '0';
    sum += arr[i];
  }

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

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

//  SMOKE SHISHA PLAY FIFA  //
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;

#define fastio                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);
#define pll pair<ll, ll>
#define MP make_pair
#define ff first
#define ss second
#define PB push_back
#define mod 1000000007
#define lp(i, start, end) for (ll i = start; i <= end; i++)
#define deb1(a) cout << #a << " = " << (a) << endl;
#define deb2(a, b)                                                             \\
  cout << #a << " = " << (a) << ", " << #b << " = " << (b) << endl;
#define deb3(a, b, c)                                                          \\
  cout << #a << " = " << (a) << ", " << #b << " = " << (b) << ", " << #c       \\
       << " = " << (c) << endl;

ll modu(ll a, ll b) {
  ll ans = 1;
  while (b > 0) {
    if (b & 1)
      ans = (ans * a) % mod;
    b /= 2;
    a = (a * a) % mod;
  }
  return ans;
}

int main() {
  fastio string n;
  cin >> n;
  ll sum = 0;
  for (ll i = 0; i < n.size(); i++) {
    sum += n[i] - '0';
  }
  if (sum % 9)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  return 0;
}


Error: TLE

Fixed submission:

//  SMOKE SHISHA PLAY FIFA  //
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;

#define fastio                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);
#define pll pair<ll, ll>
#define MP make_pair
#define ff first
#define ss second
#define PB push_back
#define mod 1000000007
#define lp(i, start, end) for (ll i = start; i <= end; i++)
#define deb1(a) cout << #a << " = " << (a) << endl;
#define deb2(a, b)                                                             \\
  cout << #a << " = " << (a) << ", " << #b << " = " << (b) << endl;
#define deb3(a, b, c)                                                          \\
  cout << #a << " = " << (a) << ", " << #b << " = " << (b) << ", " << #c       \\
       << " = " << (c) << endl;

ll modu(ll a, ll b) {
  ll ans = 1;
  while (b > 0) {
    if (b & 1)
      ans = (ans * a) % mod;
    b /= 2;
    a = (a * a) % mod;
  }
  return ans;
}

int main() {
  fastio ll n;
  cin >> n;
  ll sum = 0;
  while (n >= 0) {
    sum += n % 10;
    n /= 10;
  }
  if (sum % 9)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  return 0;
}
Problem p02577 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <cstring>
using namespace std;
int sum;
char ch[200005];
int main() {
  scanf("%s", ch);
  int t = (int)strlen(ch);
  for (int i = 0; i < t; ++i)
    sum += ch[i] - '0';
  if (sum % 9)
    printf("No\\n");
  else
    printf("Yes\\n");
  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <cstring>
using namespace std;
int sum;
char ch[200005];
int main() {
  scanf("%s", ch);
  for (int i = 0; i < (int)strlen(ch); ++i)
    sum += ch[i] - '0';
  if (sum % 9)
    printf("No\\n");
  else
    printf("Yes\\n");
  return 0;
}
Problem p02577 (C++) — buggy submission, verdict: Runtime Error

#include <cstring>
#include <iostream>
using namespace std;
int main() {
  int i, sum = 0;
  char a[200001];
  cin >> a;
  for (i = 0; i < strlen(a); i++) {
    sum = sum + (a[i] - '0');
  }
  if (sum % 9 == 0)
    cout << "Yes\\n";
  else
    cout << "No\\n";
  return 0;
}


Error: WA

Fixed submission:

#include <cstring>
#include <iostream>
using namespace std;
int main() {
  int i, sum = 0;
  char a[210];
  cin >> a;
  for (i = 0; i < strlen(a); i++) {
    sum = sum + (a[i] - '0');
    i++;
  }
  if (sum % 9 == 0)
    cout << "Yes\\n";
  else
    cout << "No\\n";
  return 0;
}
Problem p02577 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
string n;
long long ans;
int main() {
  cin >> n;
  int length = n.length();
  for (int i = 0; i < length; i++) {
    ans += n[i] - '0';
  }
  if (ans % 9)
    printf("No");
  else
    printf("Yes");
  return 0;
}


Error: -11

Fixed submission:

#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int main() {
  int n, i, j;
  scanf("%d", &n);
  long int a[n];
  for (i = 0; i < n; i++) {
    scanf("%ld", &a[i]);
  }
  long int t = a[0];
  long int sum = 0;
  for (i = 1; i < n; i++) {
    if (t > a[i]) {
      sum = sum + t - a[i];
      t = t;
    } else {
      t = a[i];
    }
  }
  printf("%ld\\n", sum);
  return 0;
}
Problem p02577 (C++) — buggy submission, verdict: Time Limit Exceeded

/// ShzFahad
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  ll m = 0, i;
  cin >> s;
  for (i = 0; i < s.size(); i++) {
    m = ((m * 10) + (s[i] - '0')) % 9;
  }
  if (m == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, sum = 0;
  cin >> n;
  for (i = 0; i < n; ++i) {
    sum = sum + n;
    sum = sum % 9;
  }
  if (sum % 9 == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
Problem p02577 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  string str;
  string strin[200100];
  int a[200100];
  long sum = 0;
  long size;
  cin >> str;
  size = str.size();
  for (long i = 0; i < size; i++) {
    strin[i] = str.at(i);
  }

  for (long i = 0; i < size; i++) {
    a[i] = atoi(strin[i].c_str());
  }

  for (int i = 0; i < str.size(); i++) {
    sum += a[i];
  }

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

Error: 0

Fixed submission:

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

int main() {
  string str;
  string strin[20000];
  int a[200000];
  int sum = 0;
  cin >> str;
  for (int i = 0; i < str.size(); i++) {
    strin[i] = str.at(i);
  }
  for (int i = 0; i < str.size(); i++) {
    a[i] = atoi(strin[i].c_str());
  }

  for (int i = 0; i < str.size(); i++) {
    sum += a[i];
  }

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