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

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define ALLR(v) v.rbegin(), v.rend()
typedef long long ll;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
// isPrime
// modpow modinv
// getDigit
int main() {
  cout << fixed << setprecision(10);
  string a, b, c;
  if (a.at(a.size() - 1) == b.at(0) && b.at(b.size() - 1) == c.at(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 < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define ALLR(v) v.rbegin(), v.rend()
typedef long long ll;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
// isPrime
// modpow modinv
// getDigit
int main() {
  cout << fixed << setprecision(10);
  string a, b, c;
  cin >> a >> b >> c;
  if (a.at(a.size() - 1) == b.at(0) && b.at(b.size() - 1) == c.at(0)) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}
Problem p03729 (C++)

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

int main() {
  string A, B, C;
  cin >> A >> B >> C;
  int a = A.size(), b = B.size(), c = C.size();

  string ans;
  if (A.at(b - 1) == B.at(0) && B.at(c - 1) == C.at(0))
    ans = "YES";
  else
    ans = "NO";

  cout << ans << endl;
}


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

int main() {
  string A, B, C;
  cin >> A >> B >> C;
  int a = A.size(), b = B.size(), c = C.size();

  string ans;
  if (A.at(a - 1) == B.at(0) && B.at(b - 1) == C.at(0))
    ans = "YES";
  else
    ans = "NO";

  cout << ans << endl;
}
Problem p03729 (C++)

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

int main() {
  string A, B, C;
  cin >> A;
  cin >> B;
  cin >> C;

  if (A[A.length() - 1] == B[0] && B[B.length() - 1] == C[0]) {
    printf("YES");
    return 0;
  } else {
    printf("NO");
    return 1;
  }
}

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

int main() {
  string A, B, C;
  cin >> A;
  cin >> B;
  cin >> C;

  if (A[A.length() - 1] == B[0] && B[B.length() - 1] == C[0]) {
    printf("YES");
    return 0;
  } else {
    printf("NO");
    return 0;
  }
}
Problem p03729 (C++)

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

int main() {
  string A, B, C;
  cin >> A >> B >> C;
  int a = A.size();
  int b = B.size();
  if (A.at(a) == B.at(0) && B.at(b) == C.at(0)) {
    cout << "YES" << endl;
  } else
    cout << "NO" << endl;
}

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

int main() {
  string A, B, C;
  cin >> A >> B >> C;
  int a = A.size();
  int b = B.size();
  if (A.at(a - 1) == B.at(0) && B.at(b - 1) == C.at(0)) {
    cout << "YES" << endl;
  } else
    cout << "NO" << endl;
}
Problem p03729 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, N)                                                              \
  for (int i = 0; i < N; i++) {                                                \
    ;
int main() {
  string A, B, C;
  if (A.at(A.size() - 1) == B.at(0) && B.at(B.size() - 1) == C.at(0)) {
    cout << "YES" << endl;
  } else
    cout << "NO" << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, N)                                                              \
  for (int i = 0; i < N; i++) {                                                \
    ;
int main() {
  string A, B, C;
  cin >> A >> B >> C;
  if (A.at(A.size() - 1) == B.at(0) && B.at(B.size() - 1) == C.at(0)) {
    cout << "YES" << endl;
  } else
    cout << "NO" << endl;
}
Problem p03729 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b, c;
  cin >> a >> b >> c;
  if (a.at(a.size()) == b.at(b.size()) == c.at(c.size()))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b, c;
  cin >> a >> b >> c;
  if (a.at(a.size() - 1) == b.at(0) && b.at(b.size() - 1) == c.at(0))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
Problem p03729 (C++)

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

int main() {
  string A, B, C;
  cin >> A >> B >> C;
  if (A.at(A.size() - 1) == B.at(0) && B.at(B.size() - 1) == C.at(1)) {
    cout << "YES";
  } else {
    cout << "NO";
  }
}


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

int main() {
  string A, B, C;
  cin >> A >> B >> C;
  if (A.at(A.size() - 1) == B.at(0) && B.at(B.size() - 1) == C.at(0)) {
    cout << "YES";
  } else {
    cout << "NO";
  }
}
Problem p03729 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  string A, B, C;
  cin >> A >> B >> C;
  int a;
  a = A.size();
  if (A.at(a) == B.at(0) && B.at(0) == C.at(0)) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  string A, B, C;
  cin >> A >> B >> C;

  int a = A.size();
  int b = B.size();
  if (A.at(a - 1) == B.at(0) && B.at(b - 1) == C.at(0)) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}
Problem p03729 (C++)

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

int main(void) {
  string a, b, c;
  cin >> a >> b >> c;
  if ((a.at(a.size()) == b.at(b.size())) && (b.at(b.size()) == c.at(c.size())))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

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

int main(void) {
  string a, b, c;
  cin >> a >> b >> c;
  if ((a.at(a.size() - 1) == b.at(0)) && (b.at(b.size() - 1) == c.at(0)))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
Problem p03729 (Python)

Buggy submission (status: Runtime Error):
A, B, C = map(int, input().split())
print("YES" if A[-1] == B[0] and B[-1] == C[0] else "NO")


Fixed submission:
A, B, C = input().split()
print("YES" if A[-1] == B[0] and B[-1] == C[0] else "NO")
Problem p03729 (Python)

Buggy submission (status: Runtime Error):
A, B, C = map(int, input().split())

if A[-1] == B[0] and B[-1] == C[0]:
    print("YES")
else:
    print("NO")


Fixed submission:
A, B, C = input().split()

if A[-1] == B[0] and B[-1] == C[0]:
    print("YES")
else:
    print("NO")
Problem p03730 (C++)

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  int remAB = A % B;
  if (C % remAB == 0)
    cout << "YES"
         << "\n";
  else
    cout << "NO"
         << "\n";
}

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  for (int i = 0; i < B; i++) {
    if (A * i % B == C) {
      cout << "YES"
           << "\n";
      return 0;
    }
  }
  cout << "NO"
       << "\n";
}
Problem p03730 (Python)

Buggy submission (status: Runtime Error):
a, b, c = map(int, input().split())
n = max(int(b / a), 1)
p = "NO"
s = set()
r = n * a % b

while r not in s:
    if r == c:
        p = "YES"
        break
    else:
        s.append(r)
        n += 1
        r = n * a % b
print(p)


Fixed submission:
a, b, c = map(int, input().split())
n = max(int(b / a), 1)
p = "NO"
s = set()
r = n * a % b

while r not in s:
    if r == c:
        p = "YES"
        break
    else:
        s.add(r)
        n += 1
        r = n * a % b
print(p)
Problem p03730 (Python)

Buggy submission (status: Runtime Error):
from math import gcd

A, B, C = map(int, open(0).read().split())

if C % gcd(A, B) == 0:
    print("YES")
else:
    print("NO")


Fixed submission:
from fractions import gcd

A, B, C = map(int, open(0).read().split())

if C % gcd(A, B) == 0:
    print("YES")
else:
    print("NO")
Problem p03730 (C++)

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

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

  int a, b, c;
  cin >> a >> b >> c;
  a %= b;
  if (c % a == 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}


Fixed submission:
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

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

  int a, b, c;
  cin >> a >> b >> c;
  bool f = false;
  for (int i = 1; i <= b; i++) {
    if ((i * a) % b == c)
      f = true;
  }
  if (f)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
Problem p03730 (C++)

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  for (int i = 1; i <= b; c) {
    if ((a * i) % b == c) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  for (int i = 1; i <= b; i++) {
    if ((a * i) % b == c) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}
Problem p03730 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
typedef unsigned long long ll;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define lp(i, a, n) for (ll i = (a); i <= (n); i++)
#define MAX 500000000

int main() {
  ll a, b, c;
  ll x = 0;
  cin >> a >> b >> c;
  if (a == b && c != 0) {
    goto end;
  } else if (a == 1) {
    x = 1;
    goto end;
  }
  rep(i, 1, MAX) {
    if (a * i % b == c) {
      x = 1;
      break;
    }
  }
end:;
  if (x == 0)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
  return 0;
}


Fixed submission:
#include <iostream>
using namespace std;
typedef unsigned long long ll;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define lp(i, a, n) for (ll i = (a); i <= (n); i++)
#define MAX 500000000

int main() {
  ll a, b, c;
  ll x = 0;
  cin >> a >> b >> c;
  if (a == b && c != 0) {
    goto end;
  } else if (a == 1) {
    x = 1;
    goto end;
  }
  rep(i, 1, b) {
    if (a * i % b == c) {
      x = 1;
      break;
    }
  }
end:;
  if (x == 0)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
  return 0;
}
Problem p03730 (C++)

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

ll a, b, c;

int main(void) {

  scanf("%lld %lld %lld", &a, &b, &c);

  bitset<101> bit;
  for (int i = a; !bit[i % b]; i += a) {
    if (i % b == c) {
      printf("YES\n");
      return 0;
    }
  }
  printf("NO\n");

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

ll a, b, c;

int main(void) {

  scanf("%lld %lld %lld", &a, &b, &c);

  bitset<101> bit;
  for (int i = a; !bit[i % b]; i += a) {
    if (i % b == c) {
      printf("YES\n");
      return 0;
    }
    bit[i % b] = true;
  }
  printf("NO\n");

  return 0;
}
Problem p03730 (C++)

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

int main() {

  long long a, b, c;
  cin >> a >> b >> c;

  rep(i, 1000000000) {
    if ((a * i + 1) % b == 0) {
      cout << "YES" << endl;
      return 0;
    }
  }

  cout << "NO" << endl;
}

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

int main() {

  long long a, b, c;
  cin >> a >> b >> c;

  rep(i, a * b + 1) {
    if ((a * i) % b == c) {
      cout << "YES" << endl;
      return 0;
    }
  }

  cout << "NO" << endl;
}
Problem p03730 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ll long long int
#define py printf("Yes\n")
#define pn printf("No\n")
#define in cin >>
using namespace std;
int INF = 1001001001;

int main() {
  int a, b, c;
  if (a == 1) {
    cout << "YES" << endl;
    return 0;
  }
  for (int i = 1; i < 1000; i++) {
    if ((a * i) % b == c) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}


Fixed submission:
#include <algorithm>
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ll long long int
#define py printf("Yes\n")
#define pn printf("No\n")
#define in cin >>
using namespace std;
int INF = 1001001001;

int main() {
  int a, b, c;
  in a >> b >> c;
  if (a == 1) {
    cout << "YES" << endl;
    return 0;
  }
  for (int i = 1; i < 1000; i++) {
    if ((a * i) % b == c) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}
Problem p03730 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define ll long long
using namespace std;
int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  if (a == b && c > 0) {
    cout << "NO" << endl;
    exit(0);
  }
  for (ll i = 1; i < 1000000000; i++) {
    if ((a * i) % b == c) {
      cout << "YES" << endl;
      exit(0);
    }
  }
  cout << "NO" << endl;
}


Fixed submission:
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define ll long long
using namespace std;
int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  if (a == b && c > 0) {
    cout << "NO" << endl;
    exit(0);
  }
  for (ll i = 1; i < 100000000; i++) {
    if ((a * i) % b == c) {
      cout << "YES" << endl;
      exit(0);
    }
  }
  cout << "NO" << endl;
}
Problem p03730 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  for (int i = 1; i < 1000000000; i++) {
    b *= i;
    if ((b + c) % a == 0) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  for (int i = 1; i <= a * b; i++) {
    if ((a * i) % b == c) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}
Problem p03730 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
#define MAX 10000
int main() {
  int a, b, c;
  bool flag = false;
  for (unsigned long long i = 1; i < MAX; i++) {
    if ((a * i) % b == c) {
      flag = true;
      break;
    }
  }
  if (flag) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;
#define MAX 10000
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  bool flag = false;
  for (unsigned long long i = 1; i < MAX; i++) {
    if ((a * i) % b == c) {
      flag = true;
      break;
    }
  }
  if (flag) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
Problem p03730 (C++)

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

int calc(int a, int b) {
  if (a > b)
    swap(a, b);
  if (a == 0)
    return a;
  return calc(b % a, a);
}

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << (c % calc(a, b) == 0 ? "YES" : "NO") << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1 << 30;

int calc(int a, int b) {
  if (a > b)
    swap(a, b);
  if (a == 0)
    return b;
  return calc(b % a, a);
}

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << (c % calc(a, b) == 0 ? "YES" : "NO") << endl;
}
Problem p03730 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
int main(void) {
  long long int num;
  int a, b, c;
  int flag = 0;
  cin >> a >> b >> c;
  for (num = a; num < 1000000000; num = num + a) {
    if (num % b == c) {
      flag = 1;
      break;
    }
  }
  if (flag == 1) {
    cout << "YES" << endl;
  } else if (flag == 0) {
    cout << "NO" << endl;
  }
  return 0;
}


Fixed submission:
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
int main(void) {
  long long int num;
  int a, b, c;
  int flag = 0;
  cin >> a >> b >> c;
  for (num = a; num < 100000000; num = num + a) {
    if (num % b == c) {
      flag = 1;
      break;
    }
  }
  if (flag == 1) {
    cout << "YES" << endl;
  } else if (flag == 0) {
    cout << "NO" << endl;
  }
  return 0;
}
Problem p03730 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
// #define MODE 1
#ifdef MODE
#define DEB(X) cout << #X << ": " << X << " ";
#define ARDEB(i, X) cout << #X << "[" << i << "]: " << X[i] << " ";
#define END cout << endl;
#else
#define DEB(X)                                                                 \
  {}
#define ARDEB(i, X)                                                            \
  {}
#define END                                                                    \
  {}
#endif
typedef long long int ll;
typedef pair<int, int> P;
struct edge {
  int to, cost;
};
#define REP(i, n) for (int i = 0; i < (n); i++)
const int INF = 100000000;

int main() {
  int a, b, c;
  REP(i, 10000000) {
    if (a * i % b == c) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
// #define MODE 1
#ifdef MODE
#define DEB(X) cout << #X << ": " << X << " ";
#define ARDEB(i, X) cout << #X << "[" << i << "]: " << X[i] << " ";
#define END cout << endl;
#else
#define DEB(X)                                                                 \
  {}
#define ARDEB(i, X)                                                            \
  {}
#define END                                                                    \
  {}
#endif
typedef long long int ll;
typedef pair<int, int> P;
struct edge {
  int to, cost;
};
#define REP(i, n) for (int i = 0; i < (n); i++)
const int INF = 100000000;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  REP(i, 10000000) {
    if (a * i % b == c) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}
Problem p03730 (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;
typedef long long ll;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int can = false;
  for (int i = a; i <= a * b; i * a) {
    if (i % b == c)
      can = true;
  }
  if (can)
    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;
typedef long long ll;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int can = false;
  for (int i = 1; i < b; i++) {
    if (i * a % b == c)
      can = true;
  }
  if (can)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
Problem p03730 (C++)

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

int main() {
  int a, b, c;
  std::cin >> a >> b >> c;

  // ( n * a ) % b == c

  std::string ans = "NO";
  for (int i = 0; i <= i * b; i++) {
    if ((i * a) % b == c) {
      ans = "YES";
      break;
    }
  }

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


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

int main() {
  int a, b, c;
  std::cin >> a >> b >> c;

  // ( n * a ) % b == c

  std::string ans = "NO";
  for (int i = 0; i <= b; i++) {
    if ((i * a) % b == c) {
      ans = "YES";
      break;
    }
  }

  std::cout << ans << std::endl;
  return 0;
}
Problem p03730 (C++)

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

int main(void) {
  int a, b, c, x;
  vector<int> vec;

  cin >> a >> b >> c;
  vec = vector<int>(b);
  fill(vec.begin(), vec.end(), 0);
  for (x = a; true; (x += a) %= b) {
    if (vec[x])
      break;
    if (x % b == c)
      break;
    vec[x] = 1;
  }
  cout << (x % b == c ? "YES" : "NO") << endl;
  return 0;
}

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

int main(void) {
  int a, b, c, x;
  vector<int> vec;

  cin >> a >> b >> c;
  vec = vector<int>(b * 2);
  fill(vec.begin(), vec.end(), 0);
  for (x = a; true; (x += a) %= b) {
    if (vec[x])
      break;
    if (x % b == c)
      break;
    vec[x] = 1;
  }
  cout << (x % b == c ? "YES" : "NO") << endl;
  return 0;
}
Problem p03730 (C++)

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  for (int i = A; i < 100000; A += A) {
    if (A % B == C)
      return cout << "YES"
                  << "\n",
             0;
  }
  cout << "NO"
       << "\n";
}

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  for (int i = A; i < 100000; i += A) {
    if (i % B == C)
      return cout << "YES"
                  << "\n",
             0;
  }
  cout << "NO"
       << "\n";
}
Problem p03730 (C++)

Buggy submission (status: Runtime Error):
/**
 *      ABC 60 B
 *      author  : kyomukyomupurin
 *      created : 2018-09-05 22:25:17
 **/

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

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

  int A, B, C;
  cin >> A >> B >> C;
  ((B - C) % (A % B) == 0) ? cout << "YES" : cout << "NO";

  return 0;
}


Fixed submission:
/**
 *      ABC 60 B
 *      author  : kyomukyomupurin
 *      created : 2018-09-05 22:25:17
 **/

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

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

  int A, B, C;
  cin >> A >> B >> C;
  for (int i = 1; i <= B; ++i) {
    if ((i * (A % B)) % B == C) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;

  return 0;
}
Problem p03730 (C++)

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

using ll = long long;

void solve() {
  int a, b, c;
  cin >> a >> b >> c;
  bool mod[110];
  memset(mod, 0, sizeof mod);
  for (int i = a;; i += a) {
    if (mod[i % b]) {
      cout << "NO" << endl;
      return;
    }
    if (i % b == c) {
      cout << "YES" << endl;
      return;
    }
    mod[i % b] = 1;
  }
}

signed main() {
  while (1)
    solve();
}

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

using ll = long long;

void solve() {
  int a, b, c;
  cin >> a >> b >> c;
  bool mod[110];
  memset(mod, 0, sizeof mod);
  for (int i = a;; i += a) {
    if (mod[i % b]) {
      cout << "NO" << endl;
      return;
    }
    if (i % b == c) {
      cout << "YES" << endl;
      return;
    }
    mod[i % b] = 1;
  }
}

signed main() {
  // while(1)
  solve();
}
Problem p03730 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007 // 1e9+7
using namespace std;
typedef long long ll;
typedef vector<int> vecint;
typedef vector<string> vecstr;
int main() {
  int a, b, c;
  REP(i, 10000) {
    if (a * i % b == c) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}

Fixed submission:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007 // 1e9+7
using namespace std;
typedef long long ll;
typedef vector<int> vecint;
typedef vector<string> vecstr;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  REP(i, 10000) {
    if (a * i % b == c) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}
Problem p03730 (C++)

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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

  int A, B, C;
  cin >> A >> B >> C;
  bool ans = false;

  if (A % B == C)
    ans = true;

  int t = 2;

  while (true) {
    if ((A * t) % B == A % B)
      break;
    if ((A * t) % B == C)
      ans = true;
  }

  cout << (ans ? "YES" : "NO") << endl;

  return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

  int A, B, C;
  cin >> A >> B >> C;
  bool ans = false;

  if (A % B == C)
    ans = true;

  int t = 2;

  while (true) {
    if ((A * t) % B == A % B)
      break;
    if ((A * t) % B == C)
      ans = true;
    t++;
  }

  cout << (ans ? "YES" : "NO") << endl;

  return 0;
}
Problem p03730 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;

int A[1000];

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int baisu = a;
  while (!A[baisu]) {
    baisu += a;
    int amari = baisu % b;
    baisu = amari;
    if (amari == c) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}


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

int A[1000];

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int baisu = a;
  while (!A[baisu]) {
    A[baisu] = 1;
    baisu += a;
    int amari = baisu % b;
    baisu = amari;
    if (amari == c) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}
Problem p03730 (C++)

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

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

  vector<int> amari;
  for (int i = 1; i <= b; i++) {
    amari[i - 1] = a * i % b;
  }

  for (int i = 0; i < b; i++) {
    if (amari[i] == c) {
      puts("YES");
      exit(0);
    }
  }
  puts("NO");
}

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

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

  vector<int> amari(b);
  for (int i = 1; i <= b; i++) {
    amari[i - 1] = a * i % b;
  }

  for (int i = 0; i < b; i++) {
    if (amari[i] == c) {
      puts("YES");
      exit(0);
    }
  }
  puts("NO");
}
Problem p03730 (C++)

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  vector<int> m(b, -1);

  for (int i = 0;; i++) {
    m[i] = a * (i + 1) % b;
    if (i > 0) {
      if (m[0] == m[i])
        break;
    }
  }

  for (int i = 0; i < m.size(); i++) {
    if (m[i] == c) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  vector<int> m(b + 10, -1);

  for (int i = 0;; i++) {
    m[i] = a * (i + 1) % b;
    if (i > 0) {
      if (m[0] == m[i])
        break;
    }
  }

  for (int i = 0; i < m.size(); i++) {
    if (m[i] == c) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}
Problem p03730 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <utility>
#include <vector>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "STACK:36777216")
using namespace std;
using i64 = int64_t;
using i128 = __int128_t;
constexpr i64 MOD = 1e9 + 7;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
using vi = vector<i64>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ii = pair<i64, i64>;

int main() {
  i64 a, b, c;
  for (int i = 1; i < 100000; i++) {
    if (a * i % b == c) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}


Fixed submission:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <utility>
#include <vector>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "STACK:36777216")
using namespace std;
using i64 = int64_t;
using i128 = __int128_t;
constexpr i64 MOD = 1e9 + 7;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
using vi = vector<i64>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ii = pair<i64, i64>;

int main() {
  i64 a, b, c;
  cin >> a >> b >> c;
  for (int i = 1; i < 100000; i++) {
    if (a * i % b == c) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}
Problem p03730 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
#ifndef ONLINE_JUDGE
  // for getting input from input.txt
  freopen("input.txt", "r", stdin);
  // for writing output to output.txt
  freopen("output.txt", "w", stdout);
#endif

  int a, b, c;
  cin >> a >> b >> c;
  for (int i = 1; i < 1000000; ++i) {
    int p = a * i;
    if (p % b == c) {
      cout << "YES"
           << "\n";
      return 0;
    }
  }
  cout << "NO"
       << "\n";
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  // #ifndef ONLINE_JUDGE
  // 	// for getting input from input.txt
  // 	freopen("input.txt", "r", stdin);
  // 	// for writing output to output.txt
  // 	freopen("output.txt", "w", stdout);
  // #endif

  int a, b, c;
  cin >> a >> b >> c;
  for (int i = 1; i < 1000000; ++i) {
    int p = a * i;
    if (p % b == c) {
      cout << "YES"
           << "\n";
      return 0;
    }
  }
  cout << "NO"
       << "\n";
  return 0;
}
Problem p03730 (C++)

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

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

  int a, b, c, sum = 0;
  cin >> a >> b >> c;
  for (int i = a; i < 0x7fffffff; i *= 2) {
    sum += i;
    if (sum % b == c) {
      cout << "YES";
      return 0;
    }
  }

  cout << "NO";

  return 0;
}


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

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

  int a, b, c, sum = 0;
  cin >> a >> b >> c;
  for (int i = 1; i < 100000; i++) {
    sum += a;
    if (sum % b == c) {
      cout << "YES";
      return 0;
    }
  }

  cout << "NO";

  return 0;
}
Problem p03730 (C++)

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

using namespace std;

int main() {

  int a, b, c;
  cin >> a >> b >> c;

  //    int x = 17;
  //    int y = 11;
  int n;
  //    int N = 100;

  /**
   * 実験
   */
  //    for (int i = 0; i < N; ++i) {
  //         n = i * x;
  //         int t = n % y;
  //
  //         cout << n << ":" << t << endl;
  //    }

  // 実験からB回ループすれば十分であることがわかる

  bool can = false;

  for (int i = 1; i < b + 1; ++i) {
    n = i * a;
    int t = n % b;
    if (t == c) {
      // can = true;
      cout << "YES" << endl;
      return true;
    }
  }

  cout << "NO" << endl;
}


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

using namespace std;

int main() {

  int a, b, c;
  cin >> a >> b >> c;

  //    int x = 17;
  //    int y = 11;
  int n;
  //    int N = 100;

  /**
   * 実験
   */
  //    for (int i = 0; i < N; ++i) {
  //         n = i * x;
  //         int t = n % y;
  //
  //         cout << n << ":" << t << endl;
  //    }

  // 実験からB回ループすれば十分であることがわかる

  bool can = false;

  for (int i = 1; i < b + 1; ++i) {
    n = i * a;
    int t = n % b;
    if (t == c) {
      // can = true;
      cout << "YES" << endl;
      return 0;
    }
  }

  cout << "NO" << endl;
}
Problem p03730 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;
typedef vector<double> vec3;

int main() {

  int a, b, c;
  cin >> a >> b >> c;
  ll x = a;
  for (int i = 0; i < 10e8; i++) {
    if (x % b == c) {
      cout << "YES" << endl;
      return 0;
    } else {
      x = x + a;
    }
  }
  cout << "NO" << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;
typedef vector<double> vec3;

int main() {

  int a, b, c;
  cin >> a >> b >> c;
  ll x = a;
  for (int i = 0; i < 10e5; i++) {
    if (x % b == c) {
      cout << "YES" << endl;
      return 0;
    } else {
      x = x + a;
    }
  }
  cout << "NO" << endl;
}
Problem p03730 (C++)

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

int main() {
  int A, a, b, c;
  cin >> A >> b >> c;
  a = A % b;
  if (c % a == 0) {
    cout << "Yes" << endl;
  } else
    cout << "No" << endl;
}

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

int main() {
  int A, a, b, c;
  cin >> A >> b >> c;
  a = A % b;
  for (int i = 0; i < b; i++) {
    if (a * i % b == c) {
      cout << "YES" << endl;
      break;
    } else if (i == b - 1) {
      cout << "NO" << endl;
    }
  }
}
Problem p03730 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int A, B, C, i = 1, x;
  cin >> A >> B >> C >> i >> x;

  while (true) {
    x = A * i;
    if (x >= A * B)
      break;

    if (x % B == C) {
      cout << "YES" << endl;
      return 0;
    }
    x++;
  }
  cout << "NO" << endl;
}


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

int main() {
  int A, B, C, i = 1, x;
  cin >> A >> B >> C >> i >> x;

  while (true) {
    x = A * i;
    if (x >= A * B)
      break;

    if (x % B == C) {
      cout << "YES" << endl;
      return 0;
    }
    ++i;
  }
  cout << "NO" << endl;
}
Problem p03730 (C++)

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

int main() {

  int A, B, C;
  cin >> A >> B >> C;
  vector<int> mB(B);

  for (int i = 1; i <= B; i++) {
    mB.at(i) = (A * i) % B;
  }

  for (int i = 0; i < B; i++) {
    if (mB.at(i) == C) {
      cout << "YES" << endl;
      break;
    }
    if (i == B - 1) {
      cout << "NO" << endl;
    }
  }
}


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

int main() {

  int A, B, C;
  cin >> A >> B >> C;
  vector<int> mB(B + 1);

  for (int i = 1; i <= B; i++) {
    mB.at(i) = (A * i) % B;
  }

  for (int i = 0; i < B; i++) {
    if (mB.at(i) == C) {
      cout << "YES" << endl;
      break;
    }
    if (i == B - 1) {
      cout << "NO" << endl;
    }
  }
}
Problem p03730 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;

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

  for (int i = a; i < a * b; i + a) {
    if (i % b == c) {
      puts("YES");
      return 0;
    }
  }
  puts("NO");

  return 0;
}

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

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

  for (int i = a; i < a * b; i = i + a) {
    if (i % b == c) {
      puts("YES");
      return 0;
    }
  }
  puts("NO");

  return 0;
}
Problem p03731 (C++)

Buggy submission (status: Time Limit Exceeded):
#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() {
  ll N, T;
  cin >> N >> T;
  ll t[N];
  rep(i, N) cin >> t[i];

  ll result = T;
  for (int i = N - 2; i >= 0; i++)
    result += min(t[i + 1] - t[i], T);
  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() {
  ll N, T;
  cin >> N >> T;
  ll t[N];
  rep(i, N) cin >> t[i];

  ll result = T;
  for (int i = N - 2; i >= 0; i--)
    result += min(t[i + 1] - t[i], T);
  cout << result << endl;
  return 0;
}
Problem p03731 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define REP(i, b) FOR(i, 0, b)
#define INF 1e9

int main() {
  int N, T, t[1000000000], X;

  cin >> N >> T;

  REP(i, N) { cin >> t[i]; }

  FOR(i, 1, N) {
    // 間がT秒以上の時は、T秒加算
    if (t[i] - t[i - 1] > T) {
      X += T;
      // 間がT秒以下の時は、その間分加算
    } else {
      X += t[i] - t[i - 1];
    }
  }

  // 最後にT秒加算
  X += T;

  cout << X << endl;

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define REP(i, b) FOR(i, 0, b)
#define INF 1e9

int main() {
  int N, T, t[200200], X;

  cin >> N >> T;

  REP(i, N) { cin >> t[i]; }

  FOR(i, 1, N) {
    // 間がT秒以上の時は、T秒加算
    if (t[i] - t[i - 1] > T) {
      X += T;
      // 間がT秒以下の時は、その間分加算
    } else {
      X += t[i] - t[i - 1];
    }
  }

  // 最後にT秒加算
  X += T;

  cout << X << endl;

  return 0;
}
Problem p03731 (C++)

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

int main(int argc, const char *argv[]) {

  int T, N;
  cin >> T >> N;
  int t[N];
  rep(i, 0, N) scanf("%d", &t[i]);

  long long ans = 0;
  rep(i, 1, N) ans += min(T, t[i] - t[i - 1]);
  ans += T;

  cout << ans;

  return 0;
}


Fixed submission:
#include <iostream>
using namespace std;
#define rep(i, a, b) for (int i = a; i < b; i++)

int main(int argc, const char *argv[]) {

  int N, T;
  cin >> N >> T;
  int t[N];
  rep(i, 0, N) scanf("%d", &t[i]);

  long long ans = 0;
  rep(i, 1, N) ans += min(T, t[i] - t[i - 1]);
  ans += T;

  cout << ans;

  return 0;
}
Problem p03731 (C++)

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

int main() {
  int N, T, d;
  int tim[N];
  cin >> N >> T;
  for (int t = 0; t < N; t++)
    cin >> tim[t];
  int sum = 0;

  for (int t = 0; t < N; t++) {
    if (t != N - 1) {
      int g = tim[t + 1] - tim[t];
      d = min(T, g);
      sum += d;
    } else {
      sum += T;
    }
  }

  cout << sum << "\n";

  return 0;
}


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

int main() {
  int N, T, d;
  int tim[200001];
  cin >> N >> T;
  for (int t = 0; t < N; t++)
    cin >> tim[t];
  int sum = 0;

  for (int t = 0; t < N; t++) {
    if (t != N - 1) {
      int g = tim[t + 1] - tim[t];
      d = min(T, g);
      sum += d;
    } else {
      sum += T;
    }
  }

  cout << sum << "\n";

  return 0;
}
Problem p03731 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll n, t, a[100010];
  cin >> n >> t;
  ll ans = t;
  cin >> a[0];
  for (int i = 1; i < n; i++) {
    cin >> a[i];
    ans += min(t, a[i] - a[i - 1]);
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll n, t, a[200010];
  cin >> n >> t;
  ll ans = t;
  cin >> a[0];
  for (int i = 1; i < n; i++) {
    cin >> a[i];
    ans += min(t, a[i] - a[i - 1]);
  }
  cout << ans << endl;
  return 0;
}
Problem p03731 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  long T, N, ans = 0;
  cin >> T >> N;
  long t[N];
  for (int i = 0; i < N; i++)
    cin >> t[i];
  for (int i = 1; i < N; i++) {
    long div;
    div = t[i] - t[i - 1];
    ans += div < T ? div : T;
  }
  ans += T;
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  long T, N, ans = 0;
  cin >> N >> T;
  long t[N];
  for (int i = 0; i < N; i++)
    cin >> t[i];
  for (int i = 1; i < N; i++) {
    long div;
    div = t[i] - t[i - 1];
    ans += div < T ? div : T;
  }
  ans += T;
  cout << ans << endl;
  return 0;
}
Problem p03731 (C++)

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

#define rep(i, s, n) for (ll i = s; i < n; i++)
#define repe(i, s, n) for (ll i = s; i <= n; i++)
ll MOD = 1000000007;

int main() {
  ll N, T;
  cin >> N >> T;
  ll t[100001];
  rep(i, 0, N) { cin >> t[i]; }

  ll sum = 0;
  rep(i, 1, N) {
    ll d = t[i] - t[i - 1];
    sum += ((d < T) ? d : T);
  }
  sum += T;

  cout << sum << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;

#define rep(i, s, n) for (ll i = s; i < n; i++)
#define repe(i, s, n) for (ll i = s; i <= n; i++)
ll MOD = 1000000007;

int main() {
  ll N, T;
  cin >> N >> T;
  ll t[200001];
  rep(i, 0, N) { cin >> t[i]; }

  ll sum = 0;
  rep(i, 1, N) {
    ll d = t[i] - t[i - 1];
    sum += ((d < T) ? d : T);
  }
  sum += T;

  cout << sum << endl;
  return 0;
}
Problem p03731 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
long long a[100005];
int main() {
  long long int s, i, n, t;
  scanf("%lld%lld", &n, &t);
  scanf("%lld", &a[1]);
  s = t;
  for (i = 2; i <= n; i++) {
    scanf("%lld", &a[i]);
    if (a[i] - a[i - 1] > t)
      s += t;
    else
      s += (a[i] - a[i - 1]);
  }
  printf("%lld\n", s);
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
long long a[200005];
int main() {
  long long int s, i, n, t;
  scanf("%lld%lld", &n, &t);
  scanf("%lld", &a[1]);
  s = t;
  for (i = 2; i <= n; i++) {
    scanf("%lld", &a[i]);
    if (a[i] - a[i - 1] > t)
      s += t;
    else
      s += (a[i] - a[i - 1]);
  }
  printf("%lld\n", s);
}
Problem p03731 (C++)

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

#define MAX_N 100002
typedef long long ll;
typedef pair<ll, ll> P;

ll n, x[MAX_N], y[MAX_N], cum1, cum2, ans, T;

int main() {
  cin >> n >> T;
  for (int i = 0; i < n; i++)
    cin >> x[i];
  for (int i = 1; i < n; i++)
    if (x[i] - x[i - 1] <= T)
      ans += (x[i] - x[i - 1]);
    else
      ans += T;
  cout << ans + T;
  return 0;
}


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

#define MAX_N 200002
typedef long long ll;
typedef pair<ll, ll> P;

ll n, x[MAX_N], y[MAX_N], cum1, cum2, ans, T;

int main() {
  cin >> n >> T;
  for (int i = 0; i < n; i++)
    cin >> x[i];
  for (int i = 1; i < n; i++)
    if (x[i] - x[i - 1] <= T)
      ans += (x[i] - x[i - 1]);
    else
      ans += T;
  cout << ans + T;
  return 0;
}
Problem p03731 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, a, b) for (ll i = ll(a); i < ll(b); i++)
#define irep(i, a, b) for (ll i = ll(a); i >= ll(b); i--)
using ll = long long;
using ld = long double;
using namespace std;
const ll mod = 1e9 + 7;
ll x[200];
int main() {
  ll n, t, tmp = 0;
  cin >> n >> t;
  ll ans = t;
  rep(i, 0, n) cin >> x[i];
  rep(i, 0, n - 1) {
    if (x[i + 1] - x[i] <= t)
      ans += (x[i + 1] - x[i]);
    else
      ans += t;
  }
  cout << ans;
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, a, b) for (ll i = ll(a); i < ll(b); i++)
#define irep(i, a, b) for (ll i = ll(a); i >= ll(b); i--)
using ll = long long;
using ld = long double;
using namespace std;
const ll mod = 1e9 + 7;
ll x[220000];
int main() {
  ll n, t, tmp = 0;
  cin >> n >> t;
  ll ans = t;
  rep(i, 0, n) cin >> x[i];
  rep(i, 0, n - 1) {
    if (x[i + 1] - x[i] <= t)
      ans += (x[i + 1] - x[i]);
    else
      ans += t;
  }
  cout << ans;
}
Problem p03731 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
using namespace std;
long long mod = 1000000007;
long long N, T, t[100010];
int main() {
  cin >> N >> T;
  for (int i = 0; i < N; i++) {
    cin >> t[i];
  }
  long long an = T;
  for (int i = 0; i < N - 1; i++) {
    if (t[i + 1] - t[i] >= T) {
      an += T;
    } else {
      an += t[i + 1] - t[i];
    }
  }
  cout << an;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
using namespace std;
long long mod = 1000000007;
long long N, T, t[200010];
int main() {
  cin >> N >> T;
  for (int i = 0; i < N; i++) {
    cin >> t[i];
  }
  long long an = T;
  for (int i = 0; i < N - 1; i++) {
    if (t[i + 1] - t[i] >= T) {
      an += T;
    } else {
      an += t[i + 1] - t[i];
    }
  }
  cout << an;
}
Problem p03731 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i <= end; i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main() {
  int N, T;
  int t[110000];
  int res = 0;
  cin >> N >> T;

  rep(i, N) cin >> t[i];

  FOR(i, 1, N - 1) { res += min(T, t[i] - t[i - 1]); }
  res += T;

  cout << res << endl;
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i <= end; i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main() {
  int N, T;
  int t[210000];
  int res = 0;
  cin >> N >> T;

  rep(i, N) cin >> t[i];

  FOR(i, 1, N - 1) { res += min(T, t[i] - t[i - 1]); }
  res += T;

  cout << res << endl;
}