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

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
};
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
};

// intやllをstringに変換
template <typename T> inline string toString(const T &a) {
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  ll ans = 1;
  vector<int> num(3, -1);
  for (int i = 0; i < N; i++) {
    ll cnt = 0;
    for (int j = 0; j < 3; j++) {
      if (A[i] - 1 == num[j]) {
        cnt++;
      }
    }
    for (int j = 0; j < N; j++) {
      if (A[i] - 1 == num[j]) {
        num[j]++;
        break;
      }
    }
    ans *= cnt;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
};
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
};

// intやllをstringに変換
template <typename T> inline string toString(const T &a) {
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  ll ans = 1;
  vector<int> num(3, -1);
  for (int i = 0; i < N; i++) {
    ll cnt = 0;
    for (int j = 0; j < 3; j++) {
      if (A[i] - 1 == num[j]) {
        cnt++;
      }
    }
    for (int j = 0; j < 3; j++) {
      if (A[i] - 1 == num[j]) {
        num[j]++;
        break;
      }
    }
    ans *= cnt;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}
Problem p02845 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <vector>
using namespace std;
const int MOD = 1e9 + 7;
int main() {
  long long N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++)
    cin >> A[i];
  long long ans = 1;
  vector<long long> v(3, 0);
  for (int i = 0; i < N; i++) {
    long long cnt = 0;
    int flag = -1;
    for (int j = 0; j < 3; j++) {
      if (A[i] == v[j]) {
        cnt++;
        flag = j;
      }
    }
    ans = ans * cnt % MOD;
    v[flag]++;
  }
  cout << ans << endl;
}

Fixed submission:
#include <iostream>
#include <vector>
using namespace std;
const int MOD = 1e9 + 7;
int main() {
  long long N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++)
    cin >> A[i];
  long long ans = 1;
  vector<long long> v(3, 0);
  for (int i = 0; i < N; i++) {
    long long cnt = 0;
    int flag = 0;
    for (int j = 0; j < 3; j++) {
      if (A[i] == v[j]) {
        cnt++;
        flag = j;
      }
    }
    ans = ans * cnt % MOD;
    v[flag]++;
  }
  cout << ans << endl;
}
Problem p02845 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define all(i, n) (i), (i + n)

int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, -1, 0, 1};
int dx8[8] = {1, 0, -1, 1, -1, 1, 0, -1};
int dy8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
int dx9[9] = {0, 1, 0, -1, 1, -1, 1, 0, -1};
int dy9[9] = {0, 1, 1, 1, 0, 0, -1, -1, -1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6 + 1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
int n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;

  ll ans = 1;
  int c[3];
  REP(i, 3) c[i] = 0;
  REP(i, n) {
    int a;
    cin >> a;
    int t = 0, p;
    REP(j, 3) if (c[j] == a) {
      t++;
      p = j;
    }

    ans = (ans * t) % mod;
    c[p]++;
  }

  cout << ans << endl;
}


Fixed submission:
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define all(i, n) (i), (i + n)

int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, -1, 0, 1};
int dx8[8] = {1, 0, -1, 1, -1, 1, 0, -1};
int dy8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
int dx9[9] = {0, 1, 0, -1, 1, -1, 1, 0, -1};
int dy9[9] = {0, 1, 1, 1, 0, 0, -1, -1, -1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6 + 1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
int n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;

  ll ans = 1;
  int c[3];
  REP(i, 3) c[i] = 0;
  REP(i, n) {
    int a;
    cin >> a;
    int t = 0, p = 0;
    REP(j, 3) if (c[j] == a) {
      t++;
      p = j;
    }

    ans = (ans * t) % mod;
    c[p]++;
  }

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

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

int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    int l;
    cin >> l;
    a[i] = l + 1;
  }
  long long m = 1000000007;
  int b[n];
  for (int i = 0; i < n + 1; i++)
    b[i] = 0;
  long long dp[100010];
  dp[0] = 1;
  b[0] = 3;
  for (int i = 1; i < n + 1; i++) {
    dp[i] = (dp[i - 1] * b[a[i] - 1]) % m;
    b[i]++;
    b[i - 1]--;
  }
  cout << dp[n] << endl;
}


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

int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    int l;
    cin >> l;
    a[i] = l + 1;
  }
  long long m = 1000000007;
  int b[n];
  for (int i = 0; i < n + 1; i++)
    b[i] = 0;
  long long dp[100010];
  dp[0] = 1;
  b[0] = 3;
  for (int i = 1; i < n + 1; i++) {
    dp[i] = (dp[i - 1] * b[a[i - 1] - 1]) % m;
    b[a[i - 1]]++;
    b[a[i - 1] - 1]--;
  }
  cout << dp[n] << endl;
}
Problem p02845 (C++)

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

#define INF 1e9
#define MOD 1000000007
using namespace std;

#define REPR(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()

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

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

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

typedef long long ll;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N, 0);
  REP(i, N) cin >> A[i];
  vector<int> cnt(3, 0);
  ll ans = 1;
  REP(i, N) {
    int p = 0, idx;
    REP(j, 3) {
      if (cnt[j] == A[i]) {
        p++;
        idx = j;
      }
    }
    ans *= p;
    ans %= (ll(1e9) + 7);
    cnt[idx]++;
  }
  cout << ans << endl;
  return 0;
}


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

#define INF 1e9
#define MOD 1000000007
using namespace std;

#define REPR(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()

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

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

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

typedef long long ll;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N, 0);
  REP(i, N) cin >> A[i];
  vector<int> cnt(3, 0);
  if (A[0] != 0) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = 1;
  REP(i, N) {
    int p = 0, idx;
    REP(j, 3) {
      if (cnt[j] == A[i]) {
        p++;
        idx = j;
      }
    }
    ans *= p;
    ans %= (ll(1e9) + 7);
    cnt[idx]++;
  }
  cout << ans << endl;
  return 0;
}
Problem p02845 (C++)

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

using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

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

  ll ret = 1;
  vector<int> v(3, -1);
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;

    int idx = -1;
    int count = 0;
    for (int j = 0; j < 3; j++) {
      if (v[j] == a - 1) {
        idx = j;
        count++;
      }
    }
    v[idx] = a;
    ret *= count;
    ret %= MOD;
  }

  cout << ret << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

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

  ll ret = 1;
  vector<int> v(3, -1);
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;

    int idx = -1;
    int count = 0;
    for (int j = 0; j < 3; j++) {
      if (v[j] == a - 1) {
        idx = j;
        count++;
      }
    }
    if (idx < 0) {
      cout << 0 << endl;
      return 0;
    }
    v[idx] = a;
    ret *= count;
    ret %= MOD;
  }

  cout << ret << endl;
  return 0;
}
Problem p02846 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#define _USE_MATH_DEFINES
#include <functional>
#include <math.h>
using namespace std;

#define rep(i, x) for (int i = 0; i < x; i++)
#define repn(i, x) for (int i = 1; i <= x; i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
  if (a > b) {
    return a;
  }
  return b;
}

ll min(ll a, ll b) {
  if (a > b) {
    return b;
  }
  return a;
}

///////////////////////////

ll ans(ll T1, ll T2, ll A1, ll A2, ll B1, ll B2) {
  ll x = T1 * (A1 - B1) + T2 * (A2 - B2);

  if (x == 0) {
    return INF;
  }
  if (x < 0) {
    return ans(T2, T1, A2, A1, B2, B1);
  }

  if (A1 > B1) {
    return 0;
  }

  ll y = T1 * (B1 - A1);

  if (y % x == 0) {
    return 2 * (y / x);
  }
  return 2 * (y / x) + 1;
}

int main() {

  ll T1, T2, A1, A2, B1, B2;

  cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;

  ll a = ans(T1, T2, A1, A2, B1, B2);

  if (a == INF) {
    cout << "infinity";
  } else {
    cout << a;
  }

  system("PAUSE");
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#define _USE_MATH_DEFINES
#include <functional>
#include <math.h>
using namespace std;

#define rep(i, x) for (int i = 0; i < x; i++)
#define repn(i, x) for (int i = 1; i <= x; i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
  if (a > b) {
    return a;
  }
  return b;
}

ll min(ll a, ll b) {
  if (a > b) {
    return b;
  }
  return a;
}

///////////////////////////

ll ans(ll T1, ll T2, ll A1, ll A2, ll B1, ll B2) {
  ll x = T1 * (A1 - B1) + T2 * (A2 - B2);

  if (x == 0) {
    return INF;
  }
  if (x < 0) {
    return ans(T1, T2, B1, B2, A1, A2);
  }

  if (A1 > B1) {
    return 0;
  }

  ll y = T1 * (B1 - A1);

  if (y % x == 0) {
    return 2 * (y / x);
  }
  return 2 * (y / x) + 1;
}

int main() {

  ll T1, T2, A1, A2, B1, B2;

  cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;

  ll a = ans(T1, T2, A1, A2, B1, B2);

  if (a == INF) {
    cout << "infinity";
  } else {
    cout << a;
  }

  system("PAUSE");
}
Problem p02846 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1 << 30) - 1)
#define LINF (1LL << 60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int main() {
  ll t1, t2, a1, a2, b1, b2;
  cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;

  ll l = t1 * (b1 - a1);
  ll d = t2 * (b2 - a2) + l;

  if (l + d == 0) {
    cout << "infinity" << endl;
    return 0;
  }
  if ((l > 0 && d > 0) || (l < 0 && d < 0)) {
    cout << 0 << endl;
    return 0;
  }

  l = abs(l);
  d = abs(d);

  if (l % d != 0)
    cout << 2 * (l / d) + 1 << endl;
  else
    cout << 2 * (l / d) << endl;

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1 << 30) - 1)
#define LINF (1LL << 60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int main() {
  ll t1, t2, a1, a2, b1, b2;
  cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;

  ll l = t1 * (b1 - a1);
  ll d = t2 * (b2 - a2) + l;

  if (d == 0) {
    cout << "infinity" << endl;
    return 0;
  }
  if ((l > 0 && d > 0) || (l < 0 && d < 0)) {
    cout << 0 << endl;
    return 0;
  }

  l = abs(l);
  d = abs(d);

  if (l % d != 0)
    cout << 2 * (l / d) + 1 << endl;
  else
    cout << 2 * (l / d) << endl;

  return 0;
}
Problem p02846 (C++)

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

int main() {

  // cin.tie(0);
  // ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  LL T1, T2, A1, A2, B1, B2;
  cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
  LL D1 = A1 - B1, D2 = A2 - B2;
  if (D1 > 0) {
    D1 = -D1;
    D2 = -D2;
  }

  LL X = T1 * D1, Y = T2 * D2;

  if (D2 < 0) {
    cout << 0 << endl;
  } else if (X == Y) {
    cout << "infinity" << endl;
  } else if (X + Y < 0) {
    cout << 0 << endl;
  } else {
    LL res = (-X) / (X + Y) * 2 + (((-X) % (X + Y) == 0) ? 0 : 1);
    cout << res << endl;
  }

  return 0;
}


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

int main() {

  // cin.tie(0);
  // ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  LL T1, T2, A1, A2, B1, B2;
  cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
  LL D1 = A1 - B1, D2 = A2 - B2;
  if (D1 > 0) {
    D1 = -D1;
    D2 = -D2;
  }

  LL X = T1 * D1, Y = T2 * D2;

  if (D2 < 0) {
    cout << 0 << endl;
  } else if (-X == Y) {
    cout << "infinity" << endl;
  } else if (X + Y < 0) {
    cout << 0 << endl;
  } else {
    LL res = (-X) / (X + Y) * 2 + (((-X) % (X + Y) == 0) ? 0 : 1);
    cout << res << endl;
  }

  return 0;
}
Problem p02846 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1 << 30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main() {
  ll t1, t2, a1, a2, b1, b2;
  cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
  if (a1 < b1) {
    swap(a1, b1);
    swap(a2, b2);
  }
  // かならず a1 > b1
  ll d = (t1 * a1 + t2 * a2) - (t1 * b1 + t2 * b2);
  if (d == 0) {
    cout << "infinity" << endl;
    return 0;
  }
  if (d > 0) {
    cout << 0 << endl;
    return 0;
  }
  d *= (-1);
  ll a = t1 * a1 - t1 * b1;
  ll p = (a + d - 1) / d;
  ll ex = 0;
  for (ll k = 1; k <= p + 1; ++k) {
    if (d * k + t1 * b1 == t1 * a1) {
      ex = 1;
      break;
    }
  }
  cout << p * 2 - 1 + ex << endl;
}


Fixed submission:
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1 << 30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main() {
  ll t1, t2, a1, a2, b1, b2;
  cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
  if (a1 < b1) {
    swap(a1, b1);
    swap(a2, b2);
  }
  // かならず a1 > b1
  ll d = (t1 * a1 + t2 * a2) - (t1 * b1 + t2 * b2);
  if (d == 0) {
    cout << "infinity" << endl;
    return 0;
  }
  if (d > 0) {
    cout << 0 << endl;
    return 0;
  }
  d *= (-1);
  ll a = t1 * a1 - t1 * b1;
  ll p = (a + d - 1) / d;
  ll ex = 0;
  if ((t1 * a1 - t1 * b1) % d == 0)
    ex = 1;
  cout << p * 2 - 1 + ex << endl;
}
Problem p02846 (C++)

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

signed main() {
  lint t1, t2;
  cin >> t1 >> t2;
  lint a1, a2, b1, b2;
  cin >> a1 >> a2 >> b1 >> b2;
  lint P = (a1 - b1) * t1;
  lint Q = (a2 - b2) * t2;
  if (P > 0)
    P *= -1, Q *= -1;
  if (P == Q) {
    cout << "infinity" << endl;
    return 0;
  }
  if (P + Q < 0) {
    cout << 0 << endl;
    return 0;
  }
  lint ans = 0;
  lint S = -P / (P + Q), T = -P % (P + Q);
  if (T == 0)
    ans = S * 2;
  else
    ans = S * 2 + 1;
  cout << ans << endl;
}

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

signed main() {
  lint t1, t2;
  cin >> t1 >> t2;
  lint a1, a2, b1, b2;
  cin >> a1 >> a2 >> b1 >> b2;
  lint P = (a1 - b1) * t1;
  lint Q = (a2 - b2) * t2;
  if (P > 0)
    P *= -1, Q *= -1;
  if (P == -Q) {
    cout << "infinity" << endl;
    return 0;
  }
  if (P + Q < 0) {
    cout << 0 << endl;
    return 0;
  }
  lint ans = 0;
  lint S = -P / (P + Q), T = -P % (P + Q);
  if (T == 0)
    ans = S * 2;
  else
    ans = S * 2 + 1;
  cout << ans << endl;
}
Problem p02846 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll t1, t2, a1, a2, b1, b2;
  cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
  if (t1 * a1 + t2 * a2 == t1 * b1 + t1 * b2) {
    cout << "infinity" << endl;
    return 0;
  }
  ll c1 = a1 - b1;
  ll c2 = a2 - b2;
  if (c1 < 0) {
    c1 *= -1;
    c2 *= -1;
  }
  if (c1 * t1 + c2 * t2 > 0) {
    cout << 0 << endl;
    return 0;
  }
  ll u = c1 * t1;
  ll v = c1 * t1 + c2 * t2;
  if (abs(u) % abs(v) == 0) {
    cout << abs(u) / abs(v) * 2 << endl;
  } else {
    cout << abs(u) / abs(v) * 2 + 1 << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll t1, t2, a1, a2, b1, b2;
  cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
  if (t1 * a1 + t2 * a2 == t1 * b1 + t2 * b2) {
    cout << "infinity" << endl;
    return 0;
  }
  ll c1 = a1 - b1;
  ll c2 = a2 - b2;
  if (c1 < 0) {
    c1 *= -1;
    c2 *= -1;
  }
  if (c1 * t1 + c2 * t2 > 0) {
    cout << 0 << endl;
    return 0;
  }
  ll u = c1 * t1;
  ll v = c1 * t1 + c2 * t2;
  if (abs(u) % abs(v) == 0) {
    cout << abs(u) / abs(v) * 2 << endl;
  } else {
    cout << abs(u) / abs(v) * 2 + 1 << endl;
  }
}
Problem p02846 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll t1, t2, a1, a2, b1, b2;
int main() {
  cin >> t1 >> t2;
  cin >> a1 >> a2;
  cin >> b1 >> b2;
  if (a1 * t1 + a2 * t2 > b1 * t1 + b2 * t2)
    swap(a1, b1), swap(a2, b2);
  a1 *= t1;
  a2 *= t2;
  b1 *= t1;
  b2 *= t2;
  ll tota = a1 + a2, totb = b1 + b2;
  //	cout<<"tota = "<<tota<<" totb = "<<totb<<'\n';
  //	cout<<"a1 = "<<a1<<" a2 = "<<a2<<'\n';
  //	cout<<"b1 = "<<b1<<" b2 = "<<b2<<'\n';
  //	if() {
  //		cout<<"went here\n";
  //		cout<<"0";
  //		return 0;
  //	}
  if (a1 == a2) {
    cout << "infinity";
    return 0;
  }
  if ((a1 - b1) % (totb - tota))
    cout << (a1 - b1) / (totb - tota) * 2 + 1 << '\n';
  else
    cout << (a1 - b1) / (totb - tota) * 2 << '\n';
  //	if()
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll t1, t2, a1, a2, b1, b2;
int main() {
  cin >> t1 >> t2;
  cin >> a1 >> a2;
  cin >> b1 >> b2;
  if (a1 * t1 + a2 * t2 > b1 * t1 + b2 * t2)
    swap(a1, b1), swap(a2, b2);
  a1 *= t1;
  a2 *= t2;
  b1 *= t1;
  b2 *= t2;
  ll tota = a1 + a2, totb = b1 + b2;
  //	cout<<"tota = "<<tota<<" totb = "<<totb<<'\n';
  //	cout<<"a1 = "<<a1<<" a2 = "<<a2<<'\n';
  //	cout<<"b1 = "<<b1<<" b2 = "<<b2<<'\n';
  if (tota < totb && a1 < b1) {
    //		cout<<"went here\n";
    cout << "0";
    return 0;
  }
  if (tota == totb) {
    cout << "infinity";
    return 0;
  }
  if ((a1 - b1) % (totb - tota))
    cout << (a1 - b1) / (totb - tota) * 2 + 1 << '\n';
  else
    cout << (a1 - b1) / (totb - tota) * 2 << '\n';
  //	if()
  return 0;
}
Problem p02847 (Python)

Buggy submission (status: Runtime Error):
arr = ["NONE", "SAT", " FRI", "THU", "WED", "TUE", "MON", "SUN"]
s = input()
print(arr.index(s))


Fixed submission:
arr = ["NONE", "SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN"]
s = input()
print(arr.index(s))
Problem p02847 (Python)

Buggy submission (status: Runtime Error):
s = input()

dic = {"SUN": 6, "MON": 5, "WED": 4, "THU": 3, "FRI": 2, "SAT": 1}

print(dic[s])


Fixed submission:
s = input()

dic = {"SUN": 7, "MON": 6, "TUE": 5, "WED": 4, "THU": 3, "FRI": 2, "SAT": 1}

print(dic[s])
Problem p02847 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <string>
#include <vector>
#define ll long long
const int MOD = 1e9 + 7;
using namespace std;

int main() {
  map<string, int> mp;
  mp.insert(make_pair("SUN", 7));
  mp.insert(make_pair("MON", 6));
  mp.insert(make_pair("TUE", 5));
  mp.insert(make_pair("EWD", 4));
  mp.insert(make_pair("THU", 3));
  mp.insert(make_pair("FRI", 2));
  mp.insert(make_pair("SAT", 1));
  string s;
  cin >> s;
  cout << mp.at(s) << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <string>
#include <vector>
#define ll long long
const int MOD = 1e9 + 7;
using namespace std;

int main() {
  map<string, int> mp;
  mp.insert(make_pair("SUN", 7));
  mp.insert(make_pair("MON", 6));
  mp.insert(make_pair("TUE", 5));
  mp.insert(make_pair("WED", 4));
  mp.insert(make_pair("THU", 3));
  mp.insert(make_pair("FRI", 2));
  mp.insert(make_pair("SAT", 1));
  string s;
  cin >> s;
  cout << mp.at(s) << endl;
  return 0;
}
Problem p02847 (Python)

Buggy submission (status: Runtime Error):
s = input()
week = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"]
for i in len(s):
    if s == week[i]:
        print(7 - i)
        break


Fixed submission:
s = input()
week = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"]
for i in range(7):
    if s == week[i]:
        print(7 - i)
        break
Problem p02847 (C++)

Buggy submission (status: Runtime Error):
#include <cstring>
#include <iostream>
using namespace std;
int main() {
  string day;
  string s[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  int daycounter;
  cin >> day;
  for (int i = 0; i < sizeof(s); i++) {
    if (day == s[i]) {
      daycounter = 7 - i;
    }
  }
  cout << daycounter;
  return 0;
}

Fixed submission:
#include <cstring>
#include <iostream>
using namespace std;
int main() {
  string S;
  cin >> S;
  if (S == "SUN")
    cout << "7";
  else if (S == "MON")
    cout << "6";
  else if (S == "TUE")
    cout << "5";
  else if (S == "WED")
    cout << "4";
  else if (S == "THU")
    cout << "3";
  else if (S == "FRI")
    cout << "2";
  else
    cout << "1";

  return 0;
}
Problem p02847 (C++)

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

int main() {

  string S;
  cin >> S;

  map<string, int> week; // 名前→成績
  week["SUN"] = 0;
  week["MON"] = 1;
  week["TUE"] = 2;
  week["WEN"] = 3;
  week["THU"] = 4;
  week["FRI"] = 5;
  week["SAT"] = 6;

  cout << 7 - week.at(S) << endl;
}

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

int main() {

  string S;
  cin >> S;

  map<string, int> week; // 名前→成績
  week["SUN"] = 0;
  week["MON"] = 1;
  week["TUE"] = 2;
  week["WED"] = 3;
  week["THU"] = 4;
  week["FRI"] = 5;
  week["SAT"] = 6;

  cout << 7 - week.at(S) << endl;
}
Problem p02847 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v)                                                              \
  v.erase(unique(v.begin(), v.end()), v.end()) // sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
  for (T &x : vec)
    is >> x;
  return is;
}

signed main() {
  cin >> S;
  vector<string> week = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  for (int i = 0; i < 7; i++) {
    if (S == week[i]) {
      cout << 7 - i << endl;
      return 1;
    }
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v)                                                              \
  v.erase(unique(v.begin(), v.end()), v.end()) // sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
  for (T &x : vec)
    is >> x;
  return is;
}

signed main() {
  cin >> S;
  vector<string> week = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  for (int i = 0; i < 7; i++) {
    if (S == week[i]) {
      cout << 7 - i << endl;
      return 0;
    }
  }
}
Problem p02847 (C++)

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

#define int long long
#define ll long long
#define f1(i, a, b) for (int i = a; i < b; i++)
#define f2(i, a, b) for (int i = a; i >= b; i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod = 1000000007;
ll temp;

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

#ifndef ONLINE_JUDGE
  freopen("/home/akmittal/Desktop/Competitive Programming/in.txt", "r", stdin);
  freopen("/home/akmittal/Desktop/Competitive Programming/out.txt", "w",
          stdout);
#endif

  string s;
  cin >> s;

  if (s == "SUN")
    cout << 7 << endl;
  else if (s == "SAT")
    cout << 1 << endl;
  else if (s == "FRI")
    cout << 2 << endl;
  else if (s == "THU")
    cout << 3 << endl;
  else if (s == "WED")
    cout << 4 << endl;
  else if (s == "TUE")
    cout << 5 << endl;
  else if (s == "MON")
    cout << 6 << endl;

  return 0;
}

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

#define int long long
#define ll long long
#define f1(i, a, b) for (int i = a; i < b; i++)
#define f2(i, a, b) for (int i = a; i >= b; i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod = 1000000007;
ll temp;

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  // #ifndef ONLINE_JUDGE
  // 	freopen("/home/akmittal/Desktop/Competitive
  // Programming/in.txt","r",stdin); 	freopen("/home/akmittal/Desktop/Competitive
  // Programming/out.txt","w",stdout); #endif

  string s;
  cin >> s;

  if (s == "SUN")
    cout << 7 << endl;
  else if (s == "SAT")
    cout << 1 << endl;
  else if (s == "FRI")
    cout << 2 << endl;
  else if (s == "THU")
    cout << 3 << endl;
  else if (s == "WED")
    cout << 4 << endl;
  else if (s == "TUE")
    cout << 5 << endl;
  else if (s == "MON")
    cout << 6 << endl;

  return 0;
}
Problem p02847 (C++)

Buggy submission (status: Runtime Error):
/*
@author: sharrad99
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pll pair<ll, ll>
#define vll vector<ll>
#define vpll vector<pll>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define all(x) x.begin(), x.end()
#define mod 1000000007
int main() {
#ifndef ONLINE_JUDGE
  freopen("C:\\Users\\sharr\\Documents\\Input.txt", "r", stdin);
  freopen("C:\\Users\\sharr\\Documents\\Output.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  map<string, ll> m;
  m["MON"] = 1;
  m["TUE"] = 2;
  m["WED"] = 3;
  m["THU"] = 4;
  m["FRI"] = 5;
  m["SAT"] = 6;
  m["SUN"] = 7;
  string s;
  cin >> s;
  ll res = m["SUN"] - m[s];
  if (!res) {
    res += 7;
  }
  cout << res;
}

Fixed submission:
/*
@author: sharrad99
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pll pair<ll, ll>
#define vll vector<ll>
#define vpll vector<pll>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define all(x) x.begin(), x.end()
#define mod 1000000007
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  map<string, ll> m;
  m["MON"] = 1;
  m["TUE"] = 2;
  m["WED"] = 3;
  m["THU"] = 4;
  m["FRI"] = 5;
  m["SAT"] = 6;
  m["SUN"] = 7;
  string s;
  cin >> s;
  ll res = m["SUN"] - m[s];
  if (!res) {
    res += 7;
  }
  cout << res;
}
Problem p02847 (C++)

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

#define pb push_back
#define fst first
#define snd second
#define fill(a, c) memset(&a, c, sizeof(a))
#define fore(i, x, y) for (ll i = x; i < y; i++)
#define FIN                                                                    \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0)

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main() {
  FIN;
#ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
#endif
  string line;
  cin >> line;
  if (line == "SUN")
    cout << 7 << "\n";
  else if (line == "MON")
    cout << 6 << "\n";
  else if (line == "TUE")
    cout << 5 << "\n";
  else if (line == "WED")
    cout << 4 << "\n";
  else if (line == "THU")
    cout << 3 << "\n";
  else if (line == "FRI")
    cout << 2 << "\n";
  else if (line == "SAT")
    cout << 1 << "\n";
  return 0;
}


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

#define pb push_back
#define fst first
#define snd second
#define fill(a, c) memset(&a, c, sizeof(a))
#define fore(i, x, y) for (ll i = x; i < y; i++)
#define FIN                                                                    \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0)

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main() {
  FIN;
  string line;
  cin >> line;
  if (line == "SUN")
    cout << 7 << "\n";
  else if (line == "MON")
    cout << 6 << "\n";
  else if (line == "TUE")
    cout << 5 << "\n";
  else if (line == "WED")
    cout << 4 << "\n";
  else if (line == "THU")
    cout << 3 << "\n";
  else if (line == "FRI")
    cout << 2 << "\n";
  else if (line == "SAT")
    cout << 1 << "\n";
  return 0;
}
Problem p02847 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
  string s;
  cin >> s;
  string d[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  for (int i = 0; i < sizeof(d); i++) {
    if (s == d[i]) {
      cout << 7 - i << endl;
    }
  }
}

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

int main() {
  string s;
  cin >> s;
  string d[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  for (int i = 0; i < 7; i++) {
    if (s == d[i]) {
      cout << 7 - i << endl;
    }
  }
}
Problem p02847 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int main() {
  vector<string> days = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  unordered_map<string, int> days_map;
  for (int i = 0; i <= 7; i++) {
    days_map[days[i]] = i;
  }
  string day;
  cin >> day;
  cout << 7 - days_map[day] << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int main() {
  vector<string> days = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  unordered_map<string, int> days_map;
  for (int i = 0; i < 7; i++) {
    days_map[days[i]] = i;
  }
  string day;
  cin >> day;
  cout << 7 - days_map[day] << endl;
  return 0;
}
Problem p02847 (C++)

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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

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

  string s[] = {"MON", "TUE", "WED", "THU", "FRI", "SAT"};
  string t;
  cin >> t;
  rep(i, 7) {
    if (t == s[i]) {
      cout << 6 - i << endl;
      return 0;
    }
  }
  cout << 7 << endl;
}


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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

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

  string s[] = {"MON", "TUE", "WED", "THU", "FRI", "SAT"};
  string t;
  cin >> t;
  rep(i, 6) {
    if (t == s[i]) {
      cout << 6 - i << endl;
      return 0;
    }
  }
  cout << 7 << endl;
}
Problem p02847 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main() {
  char s[3];
  cin >> s;
  if (s[0] == 'S') {
    if (s[1] == 'U')
      cout << "7";
    else
      cout << "1";
  } else if (s[0] == 'M')
    cout << "6";
  else if (s[0] == 'T') {
    if (s[1] == 'U')
      cout << "5";
    else
      cout << "3";
  } else if (s[0] == 'W')
    cout << "4";
  else
    cout << "2";
  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  char s[10];
  cin >> s;
  if (s[0] == 'S') {
    if (s[1] == 'U')
      cout << "7";
    else
      cout << "1";
  } else if (s[0] == 'M')
    cout << "6";
  else if (s[0] == 'T') {
    if (s[1] == 'U')
      cout << "5";
    else
      cout << "3";
  } else if (s[0] == 'W')
    cout << "4";
  else
    cout << "2";
  return 0;
}
Problem p02847 (C++)

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

typedef long long ll;
typedef long double ld;
typedef string str;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pair<ll, ll>> vpl;
typedef vector<vl> vvl;
typedef vector<vs> vvs;

#define f(i, start, end) for (i = start; i < end; i++)
#define trav(v) for (auto &x : v)
#define deb(x) cerr << #x << ":" << x << "\n"
#define nl cout << "\n"

int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ios::sync_with_stdio(0);
  ll t = 1;
  // cin >> t;
  while (t--) {
    ll n, i, j, k, a, b, m = 0;
    str d;
    cin >> d;
    k = -1;
    if (d == "MON") {
      k = 6;
    } else if (d == "TUE") {
      k = 5;
    } else if (d == "THU") {
      k = 3;
    } else if (d == "WED") {
      k = 4;
    } else if (d == "FRI") {
      k = 2;
    } else if (d == "SAT") {
      k = 1;
    } else {
      k = 7;
    }
    cout << k;
    nl;
  }
  return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef string str;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pair<ll, ll>> vpl;
typedef vector<vl> vvl;
typedef vector<vs> vvs;

#define f(i, start, end) for (i = start; i < end; i++)
#define trav(v) for (auto &x : v)
#define deb(x) cerr << #x << ":" << x << "\n"
#define nl cout << "\n"

int main() {

  ios::sync_with_stdio(0);
  ll t = 1;
  // cin >> t;
  while (t--) {
    ll n, i, j, k, a, b, m = 0;
    str d;
    cin >> d;
    k = -1;
    if (d == "MON") {
      k = 6;
    } else if (d == "TUE") {
      k = 5;
    } else if (d == "THU") {
      k = 3;
    } else if (d == "WED") {
      k = 4;
    } else if (d == "FRI") {
      k = 2;
    } else if (d == "SAT") {
      k = 1;
    } else {
      k = 7;
    }
    cout << k;
    nl;
  }
  return 0;
}
Problem p02847 (C++)

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

int main() {
  string s;
  cin >> s;
  vector<string> week(7);
  week = {"SAT"
          "FRI"
          "THU"
          "WHD"
          "TUE"
          "MON"
          "SUN"};
  for (int i = 0; i < 7; i++) {
    if (s == week.at(i)) {
      cout << i + 1 << endl;
    }
  }
}


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

int main() {
  string s;
  cin >> s;
  vector<string> week(7);
  week = {"SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN"};
  for (int i = 0; i < 7; i++) {
    if (s == week.at(i)) {
      cout << i + 1 << endl;
    }
  }
}
Problem p02847 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll, ll>
#define pii pair<int, int>
#define pb push_back
#define ppb pop_back
#define mp make_pair
int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string str;
  cin >> str;
  if (str == "SUN") {
    cout << 7 << endl;
  }
  if (str == "SAT") {
    cout << 1 << endl;
  }
  if (str == "FRI") {
    cout << 2 << endl;
  }
  if (str == "THU") {
    cout << 3 << endl;
  }
  if (str == "WED") {
    cout << 4 << endl;
  }
  if (str == "TUE") {
    cout << 5 << endl;
  }
  if (str == "MON") {
    cout << 6 << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll, ll>
#define pii pair<int, int>
#define pb push_back
#define ppb pop_back
#define mp make_pair
int main() {
  // #ifndef ONLINE_JUDGE
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  // #endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string str;
  cin >> str;
  if (str == "SUN") {
    cout << 7 << endl;
  }
  if (str == "SAT") {
    cout << 1 << endl;
  }
  if (str == "FRI") {
    cout << 2 << endl;
  }
  if (str == "THU") {
    cout << 3 << endl;
  }
  if (str == "WED") {
    cout << 4 << endl;
  }
  if (str == "TUE") {
    cout << 5 << endl;
  }
  if (str == "MON") {
    cout << 6 << endl;
  }
}
Problem p02847 (C++)

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

const string S[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

int main() {
  string s;
  cin >> s;
  int res = 0;
  for (int i = 1; i <= 7; i++)
    if (s == S[i])
      res = i;
  cout << 7 - res << endl;
  return 0;
}


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

const string S[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

int main() {
  string s;
  cin >> s;
  int res = 0;
  for (int i = 0; i < 7; i++)
    if (s == S[i])
      res = i;
  cout << 7 - res << endl;
  return 0;
}
Problem p02847 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
// ----------------------R00TDADA------------------------------
#define rep(i, a, b) for (__typeof((b)) i = (a); i < (b); i++)
#define nrep(i, a, b) for (__typeof((b)) i = (a); i > (b); i--)
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
#define ppi pair<int, int>
#define pppi pair<ppi, int>
#define vi vector<int>
#define vii vector<ppi>
#define viii vector<pppi>
#define vs vector<string>
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define M_PI 3.14159265358979323846
#define rootdada ios_base::sync_with_stdio(false)
#define int long long
signed 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
  rootdada;
  string s;
  cin >> s;
  if (s == "SUN")
    cout << 7 << endl;
  if (s == "SAT")
    cout << 1 << endl;
  if (s == "MON")
    cout << 6 << endl;
  if (s == "TUE")
    cout << 5 << endl;
  if (s == "WED")
    cout << 4 << endl;
  if (s == "THU")
    cout << 3 << endl;
  if (s == "FRI")
    cout << 2 << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
// ----------------------R00TDADA------------------------------
#define rep(i, a, b) for (__typeof((b)) i = (a); i < (b); i++)
#define nrep(i, a, b) for (__typeof((b)) i = (a); i > (b); i--)
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
#define ppi pair<int, int>
#define pppi pair<ppi, int>
#define vi vector<int>
#define vii vector<ppi>
#define viii vector<pppi>
#define vs vector<string>
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define M_PI 3.14159265358979323846
#define rootdada ios_base::sync_with_stdio(false)
#define int long long
signed main() {

  rootdada;
  string s;
  cin >> s;
  if (s == "SUN")
    cout << 7 << endl;
  if (s == "SAT")
    cout << 1 << endl;
  if (s == "MON")
    cout << 6 << endl;
  if (s == "TUE")
    cout << 5 << endl;
  if (s == "WED")
    cout << 4 << endl;
  if (s == "THU")
    cout << 3 << endl;
  if (s == "FRI")
    cout << 2 << endl;
}
Problem p02847 (Python)

Buggy submission (status: Runtime Error):
W = ["SUM", "MON", "TUE", "WED", "THU", "FRI", "SAT"]
S = input()
print(len(W) - W.index(S))


Fixed submission:
W = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"]
S = input()
print(len(W) - W.index(S))
Problem p02847 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define debug(x) cerr << #x " = " << (x) << endl;
#define P(x) cerr << #x << endl;
#define int long long
typedef pair<int, int> pii;
const int mod = 1000000007;

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed << setprecision(9);

  vector<string> days = {"MON", "TUES", "WED", "THU", "FRI", "SAT", "SUN",
                         "MON", "TUES", "WED", "THU", "FRI", "SAT", "SUN"};
  int n = days.size();
  string s;
  cin >> s;
  int i = 0;
  while (s != days[i])
    ++i;
  int first = i;
  ++i;
  // cout << i << '\n';
  while (days[i] != "SUN")
    ++i;
  cout << i - first << '\n';

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define debug(x) cerr << #x " = " << (x) << endl;
#define P(x) cerr << #x << endl;
#define int long long
typedef pair<int, int> pii;
const int mod = 1000000007;

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed << setprecision(9);

  vector<string> days = {"MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN",
                         "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"};
  int n = days.size();
  string s;
  cin >> s;
  int i = 0;
  while (s != days[i])
    ++i;
  int first = i;
  ++i;
  // cout << i << '\n';
  while (days[i] != "SUN")
    ++i;
  cout << i - first << '\n';

  return 0;
}
Problem p02847 (C++)

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

int main() {
  vector<string> s = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  string today;
  cin >> today;
  rep(i, 8) if (today == s[i]) cout << 7 - i << endl;
  return 0;
}

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

int main() {
  vector<string> s = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  string today;
  cin >> today;
  rep(i, 7) if (today == s[i]) cout << 7 - i << endl;
  return 0;
}
Problem p02848 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int i, j, k, n, m, l, count1 = 0;
void ABC140(void);
void ABC141(void);
void ABC142(void);
void ABC143(void);
void ABC144(void);
void ABC145(void);
void ABC146(void);
void ABC147(void);
void ABC148(void);
void ABC149(void);

int main(void) { ABC146(); }

void ABC146() {
  string s;
  cin >> n;
  cin >> s;
  cout << s.substr(n, s.length() - n) << s.substr(0, n) << endl;
}


Fixed submission:
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int i, j, k, n, m, l, count1 = 0;
void ABC140(void);
void ABC141(void);
void ABC142(void);
void ABC143(void);
void ABC144(void);
void ABC145(void);
void ABC146(void);
void ABC147(void);
void ABC148(void);
void ABC149(void);

int main(void) { ABC146(); }

void ABC146() {
  string s;
  cin >> n;
  cin >> s;
  for (i = 0; i < s.length(); i++) {
    s[i] += n;
    if (s[i] > 'Z')
      s[i] += 'A' - 'Z' - 1;
  }
  cout << s << endl;
}