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

Buggy submission (status: Time Limit Exceeded):
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  long long int L, R;
  cin >> L >> R;
  if (L - R >= 2018) {
    cout << 0 << endl;
    return 0;
  }
  int out = 10000;
  for (long long int i = L; i < R + 1; i++) {
    for (long long int j = i + 1; j < R + 1; j++) {
      int tmpout = (i * j) % 2019;
      if (out > tmpout) {
        out = tmpout;
      }
    }
  }
  cout << out << endl;
  return 0;
}


Fixed submission:
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  long long int L, R;
  cin >> L >> R;
  if (L - R >= 2018) {
    cout << 0 << endl;
    return 0;
  }
  int out = 10000;
  for (long long int i = L; i < R + 1; i++) {
    for (long long int j = i + 1; j < R + 1; j++) {
      int tmpout = (i * j) % 2019;
      if (out > tmpout) {
        out = tmpout;
        if (out == 0) {
          cout << 0 << endl;
          return 0;
        }
      }
    }
  }
  cout << out << endl;
  return 0;
}
Problem p02983 (C++)

Buggy submission (status: Time Limit Exceeded):
#include "stdio.h"
#include <math.h>
#include <stdlib.h>

int main() {
  int L, R;
  scanf("%d %d", &L, &R);
  int valid[2019];
  for (int i = 0; i < 2019; i++) {
    valid[i] = 0;
  }

  int mod = 0;
  for (int i = L; i <= R; i++) {
    mod = i % 2019;
    if (valid[mod] < 2) {
      valid[mod]++;
    }
  }

  int min_value = 2019 * 2019;
  for (int i = 0; i < 2019; i++) {
    if (valid[i] == 0) {
      continue;
    }
    for (int j = 0; j < 2019; j++) {
      if (j == i) {
        if (valid[j] <= 1) {
          continue;
        }
      } else {
        if (valid[j] == 0) {
          continue;
        }
      }
      if (j * i % 2019 < min_value) {
        min_value = j * i % 2019;
      }
    }
  }
  printf("%d\n", min_value);
}

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

int main() {
  int L, R;
  scanf("%d %d", &L, &R);
  int valid[2019];
  for (int i = 0; i < 2019; i++) {
    valid[i] = 0;
  }

  int mod = 0;
  if (R - L > 2019 * 2) {
    for (int i = 0; i < 2019; i++) {
      valid[i] = 2;
    }
  } else {
    for (int i = L; i <= R; i++) {
      mod = i % 2019;
      if (valid[mod] < 2) {
        valid[mod]++;
      }
    }
  }

  int min_value = 2019 * 2019;
  for (int i = 0; i < 2019; i++) {
    if (valid[i] == 0) {
      continue;
    }
    for (int j = 0; j < 2019; j++) {
      if (j == i) {
        if (valid[j] <= 1) {
          continue;
        }
      } else {
        if (valid[j] == 0) {
          continue;
        }
      }
      if (j * i % 2019 < min_value) {
        min_value = j * i % 2019;
      }
    }
  }
  printf("%d\n", min_value);
}
Problem p02983 (C++)

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

using namespace std;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (long long i = (a), i##Len_ = (b); i < i##Len_; i++)
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;

int main() {
  ll L, R, res;

  cin >> L >> R;

  ll iMin = 2020;

  for (ll i = L; i <= R - 1; ++i) {
    for (ll j = L + 1; j <= R; ++j) {
      iMin = min(iMin, (i * j) % 2019);
    }
  }
  cout << iMin << endl;
  return 0;
}


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

using namespace std;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (long long i = (a), i##Len_ = (b); i < i##Len_; i++)
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;

int main() {
  ll L, R, res;

  cin >> L >> R;

  ll iMin = 2020;

  if (R - L >= 2019) {
    cout << 0 << endl;
    return 0;
  }
  for (ll i = L; i <= R; ++i) {
    if (i % 2019 == 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  for (ll i = L; i <= R - 1; ++i) {
    for (ll j = L + 1; j <= R; ++j) {
      iMin = min(iMin, (i * j) % 2019);
    }
  }
  cout << iMin << endl;
  return 0;
}
Problem p02983 (C++)

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

using namespace std;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (long long i = (a), i##Len_ = (b); i < i##Len_; i++)
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;

int main() {
  ll L, R;
  cin >> L >> R;

  ll iMin = 2020;

  for (ll i = L; i <= R - 1; ++i) {
    for (ll j = i + 1; j <= R; ++j) {
      iMin = min(iMin, (i * j) % 2019);
      // 2019で割れる値
      if (iMin == 0)
        break;
    }
  }
  cout << iMin << endl;
  return 0;
}


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

using namespace std;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (long long i = (a), i##Len_ = (b); i < i##Len_; i++)
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;

int main() {
  ll L, R;
  cin >> L >> R;

  ll iMin = 2020;

  for (ll i = L; i <= R - 1; ++i) {
    for (ll j = i + 1; j <= R; ++j) {
      iMin = min(iMin, (i * j) % 2019);
      // 2019で割れる値
      if (iMin == 0)
        break;
    }
    if (iMin == 0)
      break;
  }
  cout << iMin << endl;
  return 0;
}
Problem p02983 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
using namespace std;

typedef long long ll;

const ll MOD = 2019;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll l, r;
  cin >> l >> r;
  //	map<ll,ll> ma;

  int ma[2019] = {0};
  for (int i = l; i <= r; ++i) {
    int m = i % MOD;
    ma[m]++;
  }

  ll res = 30000;
  for (int i = 0; i < 2019; ++i) {
    if (ma[i] == 0)
      continue;
    for (int j = 0; j < 2019; ++j) {
      if (ma[j] == 0)
        continue;
      if (i == j && ma[i] <= 1)
        continue;
      res = min(res, (i * j) % MOD);
      if (res == 0) {
        cout << res << endl;
        return 0;
      }
    }
  }

  cout << res << endl;

  return 0;
}


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

typedef long long ll;

const ll MOD = 2019;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll l, r;
  cin >> l >> r;
  //	map<ll,ll> ma;

  int ma[2019] = {0};
  for (int i = l; i <= r && i <= l + 2019 * 4; ++i) {
    int m = i % MOD;
    ma[m]++;
  }

  ll res = 30000;
  for (int i = 0; i < 2019; ++i) {
    if (ma[i] == 0)
      continue;
    for (int j = 0; j < 2019; ++j) {
      if (ma[j] == 0)
        continue;
      if (i == j && ma[i] <= 1)
        continue;
      res = min(res, (i * j) % MOD);
      if (res == 0) {
        cout << res << endl;
        return 0;
      }
    }
  }

  cout << res << endl;

  return 0;
}
Problem p02983 (C++)

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

bool w[105];
vector<int> v[105];

int main() {
  ll l, r;
  cin >> l >> r;
  ll nin = INF;
  while (r > l + 2019 * 10) {
    l -= 2019 * 10;
  }
  while (r > l + 2019) {
    l -= 2019;
  }
  for (ll i = l; i < r; i++) {
    for (ll j = i + 1; j <= r; j++) {
      nin = min(nin, (i * j) % 2019);
    }
  }
  cout << nin << endl;
  return 0;
}


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

bool w[105];
vector<int> v[105];

int main() {
  ll l, r;
  cin >> l >> r;
  ll nin = INF;
  if (r > l + 2019) {
    cout << 0 << endl;
    return 0;
  }
  for (ll i = l; i < r; i++) {
    for (ll j = i + 1; j <= r; j++) {
      nin = min(nin, (i * j) % 2019);
    }
  }
  cout << nin << endl;
  return 0;
}
Problem p02983 (C++)

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

int main() {
  ll l, r;
  cin >> l >> r;
  ll ans;
  ll modans = LLONG_MAX;
  for (ll x = l; x < r; x++) {
    for (ll y = x + 1; y <= r; y++) {
      ans = (x * y);
      modans = min(modans, (ans % 2019));
    }
  }
  cout << modans;
}

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

int main() {
  ll l, r;
  cin >> l >> r;
  if ((r - l) >= 2019) {
    cout << 0;
    return 0;
  }
  l = l % 2019;
  r = r % 2019;

  ll ans;
  ll modans = LLONG_MAX;
  for (ll x = l; x < r; x++) {
    for (ll y = x + 1; y <= r; y++) {
      ans = (x * y);
      modans = min(modans, (ans % 2019));
    }
  }
  cout << modans;
}
Problem p02983 (C++)

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

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

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

// constexpr ll mod = 998244353;
constexpr ll mod = 1e9 + 7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int l, r;
  cin >> l >> r;
  if (r - l >= 2018) {
    cout << 0 << endl;
  }

  vector<int> vec;
  for (int i = l; i <= r; i++) {
    vec.push_back(i % 2019);
  }

  int ans = INT_MAX;
  int n = vec.size();
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      chmin(ans, vec[i] * vec[j] % 2019);
    }
  }
  cout << ans << endl;
}

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

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

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

// constexpr ll mod = 998244353;
constexpr ll mod = 1e9 + 7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int l, r;
  cin >> l >> r;
  if (r - l >= 2018) {
    cout << 0 << endl;
    return 0;
  }

  vector<int> vec;
  for (int i = l; i <= r; i++) {
    vec.push_back(i % 2019);
  }

  int ans = INT_MAX;
  int n = vec.size();
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      chmin(ans, vec[i] * vec[j] % 2019);
    }
  }
  cout << ans << endl;
}
Problem p02983 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <map>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

int main() {
  long long L, R;
  cin >> L >> R;

  long long m = LLONG_MAX;
  for (long long i = L; i < R; i++) {
    for (long long j = i + 1; j <= R; j++) {
      long long c = (i * j) % 2019;
      m = min(m, c);
    }
  }

  cout << m << endl;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <map>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

int main() {
  long long L, R;
  cin >> L >> R;

  L = L;
  R = min(R, L + 2019);
  long long m = 2018;
  for (long long i = L; i < R; i++) {
    for (long long j = i + 1; j <= R; j++) {
      long long c = (i * j) % 2019;
      m = min(m, c);
    }
  }

  cout << m << endl;

  return 0;
}
Problem p02983 (C++)

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

int32_t main() {

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int l, r;
  cin >> l >> r;
  if (l - r > 2019)
    cout << 0 << endl;
  else {
    int ans = 2020;
    for (int i = l; i < r; i++) {
      for (int j = l + 1; j <= r; j++) {
        ans = min(ans, i % 2019 * j % 2019);
      }
    }
    cout << ans << endl;
  }

  return 0;
}

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

int32_t main() {

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int l, r;
  cin >> l >> r;
  if (r - l > 2019)
    cout << 0 << endl;
  else {
    int ans = 2020;
    for (int i = l; i < r; i++) {
      for (int j = l + 1; j <= r; j++) {
        ans = min(ans, i % 2019 * j % 2019);
      }
    }
    cout << ans << endl;
  }

  return 0;
}
Problem p02983 (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() {
  ll l, r;
  cin >> l >> r;
  ll cnt = 2019;
  bool t = false;
  for (ll i = 0; i < r - l; i++) {
    for (ll j = 1; j < r - l + 1; j++) {
      if ((l + i) * (l + j) == 0) {
        cnt = 0;
        t = true;
        break;
      } else {
        cnt = min((l + i) * (l + j) % 2019, cnt);
      }
    }
    if (t)
      break;
  }
  cout << cnt << 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() {
  ll l, r;
  cin >> l >> r;
  ll cnt = 2019;
  bool t = false;
  for (ll i = 0; i < r - l; i++) {
    for (ll j = 1; j < r - l + 1; j++) {
      if ((l + i) * (l + j) % 2019 == 0) {
        cnt = 0;
        t = true;
        break;
      } else {
        cnt = min((l + i) * (l + j) % 2019, cnt);
      }
    }
    if (t)
      break;
  }
  cout << cnt << endl;
  return 0;
}
Problem p02983 (C++)

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

int a[1001][1001];

int main() {
  int a, b;
  cin >> a >> b;
  int ans = 2020;
  for (int i = a; i < b; i++) {
    for (int j = i + 1; j <= b; j++) {
      ans = min((i % 2019) * (j % 2019) % 2019, ans);
    }
  }
  cout << ans;
  return 0;
}

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

int a[1001][1001];

int main() {
  int a, b;
  cin >> a >> b;
  int ans = 2020;
  for (int i = a; i < b; i++) {
    for (int j = i + 1; j <= b; j++) {
      if (ans != 0)
        ans = min((i % 2019) * (j % 2019) % 2019, ans);
      else {
        cout << ans;
        return 0;
      }
    }
  }
  cout << ans;
  return 0;
}
Problem p02983 (C++)

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

using namespace std;

int main() {
  int exists[2019];
  int l, r, min;

  cin >> l >> r;
  for (int i = 0; i < 2019; i++) {
    exists[i] = 0;
  }
  for (int i = l; i <= r; i++) {
    exists[i % 2019] = 1;
  }

  min = 2019;
  for (int i = 0; i < 2018; i++) {
    if (exists[i]) {
      for (int j = i + 1; j < 2019; j++) {
        if (exists[j]) {
          int rem = (i * j) % 2019;
          if (rem < min) {
            min = rem;
          }
        }
      }
    }
  }

  cout << min << endl;
  return 0;
}


Fixed submission:
#include <iostream>

using namespace std;

int main() {
  int exists[2019];
  int l, r, min;

  cin >> l >> r;
  for (int i = 0; i < 2019; i++) {
    exists[i] = 0;
  }
  for (int i = l; i <= r && i <= l + 2019; i++) {
    exists[i % 2019] = 1;
  }

  min = 2019;
  for (int i = 0; i < 2018; i++) {
    if (exists[i]) {
      for (int j = i + 1; j < 2019; j++) {
        if (exists[j]) {
          int rem = (i * j) % 2019;
          if (rem < min) {
            min = rem;
          }
        }
      }
    }
  }

  cout << min << endl;
  return 0;
}
Problem p02983 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
const int INF = 0x3fffffff;
const ll MOD = 1000000007;
const ll MODD = 998244353;
#define rrep(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define REP(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) REP(i, 0, n)
template <typename T> bool chmax(T &m, const T q) {
  if (m < q) {
    m = q;
    return true;
  } else
    return false;
}
template <typename T> bool chmin(T &m, const T q) {
  if (m > q) {
    m = q;
    return true;
  } else
    return false;
}

int main() {
  ll l, r, ans = 0;
  cin >> l >> r;
  if ((r < l + 2019) || (l % 2019 < r % 2019)) {
    ans = 2019;
    REP(i, l, r) {
      REP(j, i + 1, r + 1) { ans = min(ans, i * j % 2019); }
    }
  }
  cout << ans << "\n";
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
const int INF = 0x3fffffff;
const ll MOD = 1000000007;
const ll MODD = 998244353;
#define rrep(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define REP(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) REP(i, 0, n)
template <typename T> bool chmax(T &m, const T q) {
  if (m < q) {
    m = q;
    return true;
  } else
    return false;
}
template <typename T> bool chmin(T &m, const T q) {
  if (m > q) {
    m = q;
    return true;
  } else
    return false;
}

int main() {
  ll l, r, ans = 0;
  cin >> l >> r;
  if (r < l + 2019) {
    if (l % 2019 < r % 2019) {
      ans = 2019;
      REP(i, l, r) {
        REP(j, i + 1, r + 1) { ans = min(ans, i * j % 2019); }
      }
    }
  }
  cout << ans << "\n";
}
Problem p02983 (C++)

Buggy submission (status: Time Limit Exceeded):
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)2e9 + 1;
const ll mod = (ll)1e9 + 7;

int main() {
  ll l, r;
  cin >> l >> r;

  ull ans = inf;
  for (ll i = l; i <= r; i++) {
    for (ll j = i + 1; j <= r; j++) {
      ull x = (i * j) % 2019;
      ans = min(ans, x);
      if (x == 0) {
        break;
      }
    }
  }

  cout << ans << endl;
}

Fixed submission:
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)2e9 + 1;
const ll mod = (ll)1e9 + 7;

int main() {
  ll l, r;
  cin >> l >> r;

  ull ans = inf;
  for (ll i = l; i <= r; i++) {
    for (ll j = i + 1; j <= r; j++) {
      ull x = (i * j) % 2019;
      ans = min(ans, x);
      if (x == 0) {
        cout << ans << endl;
        return 0;
      }
    }
  }

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

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

using namespace std;

#define LL long long
#define reg register
#define debug(x) cerr << #x << " = " << x << endl;
#define rep(a, b, c) for (reg int a = (b), a##_end_ = (c); a <= a##_end_; ++a)
#define ret(a, b, c) for (reg int a = (b), a##_end_ = (c); a < a##_end_; ++a)
#define drep(a, b, c) for (reg int a = (b), a##_end_ = (c); a >= a##_end_; --a)

inline int Read() {
  int res = 0, f = 1;
  char c;
  while (c = getchar(), c < 48 || c > 57)
    if (c == '-')
      f = 0;
  do
    res = (res << 3) + (res << 1) + (c ^ 48);
  while (c = getchar(), c >= 48 && c <= 57);
  return f ? res : -res;
}

template <class T> inline bool Min(T &a, T const &b) {
  return a > b ? a = b, 1 : 0;
}
template <class T> inline bool Max(T &a, T const &b) {
  return a < b ? a = b, 1 : 0;
}

const int N = 15;

char S[5];

int L, R;

int main() {
  L = Read(), R = Read();
  if (L + 2018 <= R)
    return puts("0");
  int Ans = 1e9;
  ret(i, L, R) rep(j, i + 1, R) Min(Ans, ((i % 2019) * (j % 2019)) % 2019);
  cout << Ans;
  return 0;
}

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

using namespace std;

#define LL long long
#define reg register
#define debug(x) cerr << #x << " = " << x << endl;
#define rep(a, b, c) for (reg int a = (b), a##_end_ = (c); a <= a##_end_; ++a)
#define ret(a, b, c) for (reg int a = (b), a##_end_ = (c); a < a##_end_; ++a)
#define drep(a, b, c) for (reg int a = (b), a##_end_ = (c); a >= a##_end_; --a)

inline int Read() {
  int res = 0, f = 1;
  char c;
  while (c = getchar(), c < 48 || c > 57)
    if (c == '-')
      f = 0;
  do
    res = (res << 3) + (res << 1) + (c ^ 48);
  while (c = getchar(), c >= 48 && c <= 57);
  return f ? res : -res;
}

template <class T> inline bool Min(T &a, T const &b) {
  return a > b ? a = b, 1 : 0;
}
template <class T> inline bool Max(T &a, T const &b) {
  return a < b ? a = b, 1 : 0;
}

const int N = 15;

char S[5];

int L, R;

int main() {
  L = Read(), R = Read();
  if (L + 2018 <= R)
    return !puts("0");
  int Ans = 1e9;
  ret(i, L, R) rep(j, i + 1, R) Min(Ans, ((i % 2019) * (j % 2019)) % 2019);
  cout << Ans;
  return 0;
}
Problem p02983 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T> ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v)
    out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007              // 1e9+7(prime number)
#define INF 1000000000              // 1e9
#define LLINF 2000000000000000000LL // 2e18
#define SIZE 200010

int main() {
  int L, R;

  cin >> L >> R;

  ll ans = LLINF;

  for (int i = L; i <= R; i++) {
    for (int j = i + 1; j <= R; j++) {
      ans = min(ans, (ll)i * j % 2019);
      if (ans == 0)
        break;
    }
  }

  cout << ans << endl;

  return 0;
}


Fixed submission:
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T> ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v)
    out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007              // 1e9+7(prime number)
#define INF 1000000000              // 1e9
#define LLINF 2000000000000000000LL // 2e18
#define SIZE 200010

int main() {
  int L, R;

  cin >> L >> R;

  ll ans = LLINF;

  for (int i = L; i <= R; i++) {
    for (int j = i + 1; j <= R; j++) {
      ans = min(ans, (ll)i * j % 2019);
      if (ans == 0)
        break;
    }
    if (ans == 0)
      break;
  }

  cout << ans << endl;

  return 0;
}
Problem p02983 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long l, r, i, val, j;
  cin >> l >> r;
  long long minn = ((l % 2019) * ((l + 1) % 2019)) % 2019;
  for (i = l; i < r; i++) {
    for (j = i + 1; j <= r; j++) {
      val = ((i % 2019) * (j % 2019)) % 2019;
      if (val < minn) {
        minn = val;
      }
      if (minn == 0) {
        break;
      }
    }
  }
  cout << minn;
  return 0;
}

//  long long result = ((l%2019)*((l+1)%2019))%2019;

// for(i=l;i<=r-1;i++){
//   if(result == 0){
//     break;
//   }
//   for(j=i+1;j<=r;j++){
//     if(result == 0){
//       break;
//     }
//     if(result > ((i%2019)*(j%2019))%2019){
//       result = ((i%2019)*(j%2019))%2019;
//       cout<<"i "<<i<<"j: "<<j<<endl;
//     }
//   }
// }
// cout<<result;
// return 0;
// }


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long l, r, i, val, j;
  cin >> l >> r;
  long long minn = ((l % 2019) * ((l + 1) % 2019)) % 2019;
  for (i = l; i < r; i++) {
    if (minn == 0) {
      break;
    }
    for (j = i + 1; j <= r; j++) {
      val = ((i % 2019) * (j % 2019)) % 2019;
      if (val < minn) {
        minn = val;
      }
      if (minn == 0) {
        break;
      }
    }
  }
  cout << minn;
  return 0;
}

//  long long result = ((l%2019)*((l+1)%2019))%2019;

// for(i=l;i<=r-1;i++){
//   if(result == 0){
//     break;
//   }
//   for(j=i+1;j<=r;j++){
//     if(result == 0){
//       break;
//     }
//     if(result > ((i%2019)*(j%2019))%2019){
//       result = ((i%2019)*(j%2019))%2019;
//       cout<<"i "<<i<<"j: "<<j<<endl;
//     }
//   }
// }
// cout<<result;
// return 0;
// }
Problem p02983 (C++)

Buggy submission (status: Time Limit Exceeded):

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main() {
  long long L, R;
  cin >> L >> R;

  int N = R - L + 1;

  // vector<int> mod_list(N,0);

  int min_mod = 1e9;
  int max_mod = 0;
  int buf;
  for (int ni = 0; ni < N; ni++) {
    // mod_list[ni] = (L + ni) % 2019;
    buf = (L + ni) % 2019;
    if (buf < min_mod) {
      min_mod = buf;
    }
    if (buf > max_mod) {
      max_mod = buf;
    }
  }

  int ans = 1e9;
  ;
  if (min_mod == 0) {
    ans = 0;
  } else {
    for (int i = min_mod; i <= max_mod - 1; i++) {
      for (int j = i + 1; j <= max_mod; j++) {
        if ((i * j) % 2019 < ans) {
          ans = (i * j) % 2019;
        }
      }
    }
  }

  printf("%d", ans);

  return 0;
}


Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main() {
  long long L, R;
  cin >> L >> R;

  int N = R - L + 1;

  // vector<int> mod_list(N,0);

  int min_mod = 1e9;
  int max_mod = 0;
  int buf;
  for (int ni = 0; ni < N; ni++) {
    // mod_list[ni] = (L + ni) % 2019;
    buf = (L + ni) % 2019;
    if (buf < min_mod) {
      min_mod = buf;
      if (min_mod == 0)
        break;
    }
    if (buf > max_mod) {
      max_mod = buf;
    }
  }

  int ans = 1e9;
  ;
  if (min_mod == 0) {
    ans = 0;
  } else {
    for (int i = min_mod; i <= max_mod - 1; i++) {
      for (int j = i + 1; j <= max_mod; j++) {
        if ((i * j) % 2019 < ans) {
          ans = (i * j) % 2019;
        }
      }
    }
  }

  printf("%d", ans);

  return 0;
}
Problem p02983 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <string.h>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL = (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll L, R;
  cin >> L >> R;
  vector<int> mp;
  for (ll i = L; i <= min(L + 2019 + 2018, R); i++) {
    mp[i % 2019]++;
  }
  int ans = INF;
  for (int i = 0; i < 2019; i++) {
    for (int j = 0; j < 2019; j++) {
      if (i == j) {
        if (mp[i] >= 2) {
          ans = min(ans, i * j % 2019);
        }
      } else {
        if (mp[j] > 0 && mp[i] > 0) {
          ans = min(ans, i * j % 2019);
        }
      }
    }
  }
  cout << ans << endl;
}


Fixed submission:
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <string.h>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL = (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll L, R;
  cin >> L >> R;
  map<int, int> mp;
  for (ll i = L; i <= min(L + 2019 + 2018, R); i++) {
    mp[i % 2019]++;
  }
  int ans = INF;
  for (int i = 0; i < 2019; i++) {
    for (int j = 0; j < 2019; j++) {
      if (i == j) {
        if (mp[i] >= 2) {
          ans = min(ans, i * j % 2019);
        }
      } else {
        if (mp[j] > 0 && mp[i] > 0) {
          ans = min(ans, i * j % 2019);
        }
      }
    }
  }
  cout << ans << endl;
}
Problem p02983 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9 + 100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0);

int main() {
  FIN;

  ll l, r;
  cin >> l >> r;
  ll minmum = 1000000;
  for (ll i = 0; i < 2030; i++) {
    for (ll j = l; j < r; j++) {
      for (ll k = l + 1; k <= r; k++) {
        minmum = min(minmum, (j * k) % 2019);
        if (minmum == 0)
          break;
      }
    }
  }

  cout << minmum << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9 + 100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0);

int main() {
  FIN;

  ll l, r;
  cin >> l >> r;
  ll minmum = 1000000;
  if (r - l > 2030) {
    cout << 0 << endl;
    return 0;
  }
  for (ll j = l; j < r; j++) {
    for (ll k = l + 1; k <= r; k++) {
      minmum = min(minmum, (j * k) % 2019);
    }
  }

  cout << minmum << endl;
  return 0;
}
Problem p02983 (C++)

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

int main() {
  long long int L, R;
  cin >> L >> R;

  int min = 9999;
  long long int tmp;
  for (long long int i = L; i < R; i++) {
    for (long long int j = i + 1; j <= R; j++) {
      tmp = i * j;
      tmp %= 2019;
      if (min > tmp) {
        min = tmp;
      }
    }
  }
  cout << min << endl;

  return 0;
}


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

int main() {
  long long int L, R;
  cin >> L >> R;

  if (R - L >= 2019) {
    cout << 0 << endl;
    return 0;
  }

  int min = 9999;
  long long int tmp;
  for (long long int i = L; i < R; i++) {
    for (long long int j = i + 1; j <= R; j++) {
      tmp = i * j;
      tmp %= 2019;
      if (min > tmp) {
        min = tmp;
      }
    }
  }
  cout << min << endl;

  return 0;
}
Problem p02983 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define mfill(x, y) memset(x, y, sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x, y, h, w) if (0 <= x && x < h && 0 <= y && y < w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
void initvv(vector<vector<T>> &v, int a, int b, const T &t = T()) {
  v.assign(a, vector<T>(b, t));
}
template <class T> T gcd(T &a, T &b) {
  if (a < b) {
    swap(a, b);
  }
  T r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  debug("debug test\n");
  int n, m;
  ll l, r;
  cin >> l >> r;
  if ((r - l) >= 2020) {
    cout << 0 << endl;
  }
  ll ans = 2019ll;
  for (ll i = l; i < r; i++) {
    for (ll j = i + 1; j <= r; j++) {
      chmin(ans, i * j % 2019ll);
    }
  }
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define mfill(x, y) memset(x, y, sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x, y, h, w) if (0 <= x && x < h && 0 <= y && y < w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
void initvv(vector<vector<T>> &v, int a, int b, const T &t = T()) {
  v.assign(a, vector<T>(b, t));
}
template <class T> T gcd(T &a, T &b) {
  if (a < b) {
    swap(a, b);
  }
  T r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  debug("debug test\n");
  int n, m;
  ll l, r;
  cin >> l >> r;
  if ((r - l) >= 2020) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = 2019ll;
  for (ll i = l; i < r; i++) {
    for (ll j = i + 1; j <= r; j++) {
      chmin(ans, i * j % 2019ll);
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p02983 (C++)

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

int main() {
  long long l, r;
  cin >> l >> r;
  if (l - r >= 2019)
    cout << 0 << endl;
  else {
    long long kotae = LLONG_MAX;
    for (long long i = l; i < r; i++) {
      for (long long j = i + 1; j <= r; j++) {
        kotae = min(kotae, (i % 2019 * j) % 2019);
      }
    }
    cout << kotae << endl;
  }
  return 0;
}


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

int main() {
  long long l, r;
  cin >> l >> r;
  if (r - l >= 2019)
    cout << 0 << endl;
  else {
    long long kotae = LLONG_MAX;
    for (long long i = l; i < r; i++) {
      for (long long j = i + 1; j <= r; j++) {
        kotae = min(kotae, (i % 2019 * j) % 2019);
      }
    }
    cout << kotae << endl;
  }
  return 0;
}
Problem p02983 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define uLL unsigned long long
using namespace std;
#define LL long long
int mark[2333];
int main() {
  int L, R;
  cin >> L >> R;
  for (int i = L, s = 1; i <= R && s <= 2019 * 3; i++)
    mark[i % 2019]++;
  int ans = 2019;
  for (int i = 0; i <= 2019; i++) {
    if (!mark[i])
      continue;
    mark[i]--;
    for (int j = 0; j <= 2019; j++)
      if (mark[j])
        ans = min(ans, i * j % 2019);
    mark[i]++;
  }
  cout << ans;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define uLL unsigned long long
using namespace std;
#define LL long long
int mark[2333];
int main() {
  int L, R;
  cin >> L >> R;
  for (int i = L, s = 1; i <= R && s <= 2019 * 3; i++, s++)
    mark[i % 2019]++;
  int ans = 2019;
  for (int i = 0; i <= 2019; i++) {
    if (!mark[i])
      continue;
    mark[i]--;
    for (int j = 0; j <= 2019; j++)
      if (mark[j])
        ans = min(ans, i * j % 2019);
    mark[i]++;
  }
  cout << ans;
  return 0;
}
Problem p02983 (C++)

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

using namespace std;

int main() {
  int l, r;
  cin >> l >> r;
  if (l - r > 3000)
    cout << 0 << endl;
  else {
    int ret = 1145141919;
    for (int i = l; i <= r; i++) {
      for (int j = i + 1; j <= r; j++) {
        int a = i % 2019;
        int b = j % 2019;
        ret = min(ret, (a * b) % 2019);
      }
    }
    cout << ret << endl;
  }
  return 0;
}

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

using namespace std;

int main() {
  int l, r;
  cin >> l >> r;
  if (r - l > 3000)
    cout << 0 << endl;
  else {
    int ret = 1145141919;
    for (int i = l; i <= r; i++) {
      for (int j = i + 1; j <= r; j++) {
        int a = i % 2019;
        int b = j % 2019;
        ret = min(ret, (a * b) % 2019);
      }
    }
    cout << ret << endl;
  }
  return 0;
}
Problem p02983 (C++)

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

int main() {
  int l, r;
  cin >> l >> r;
  int ans = INF;
  if (l - r > 2019) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = l; i < r; i++) {
    for (int j = i + 1; j <= r; j++) {
      int ii = i % 2019;
      int jj = j % 2019;
      ans = min(ans, ii * jj % 2019);
      if (ans == 0)
        break;
    }
  }
  cout << ans % 2019 << endl;
  return 0;
}

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

int main() {
  int l, r;
  cin >> l >> r;
  int ans = INF;
  if (l - r > 2019) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = l; i < r; i++) {
    for (int j = i + 1; j <= r; j++) {
      int ii = i % 2019;
      int jj = j % 2019;
      ans = min(ans, ii * jj % 2019);
      if (ans == 0)
        break;
    }
    if (ans == 0)
      break;
  }
  cout << ans % 2019 << endl;
  return 0;
}
Problem p02984 (C++)

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;
const ll MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  V<ll> a(n);
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }

  ll tmp = 0;
  for (int i = 1; i < n; i += 2) {
    tmp += 2 * a[i];
  }

  V<ll> ans(n);
  ans[0] = sum - tmp;
  for (int i = 0; i < n; i++) {
    ans[i + 1] = 2 * a[i] - ans[i];
  }

  for (int i = 0; i < n; i++) {
    if (i != n - 1)
      cout << ans[i] << " ";
    else
      cout << ans[i] << endl;
  }
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;
const ll MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  V<ll> a(n);
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }

  ll tmp = 0;
  for (int i = 1; i < n; i += 2) {
    tmp += 2 * a[i];
  }

  V<ll> ans(n);
  ans[0] = sum - tmp;
  for (int i = 1; i < n; i++) {
    ans[i] = 2 * a[i - 1] - ans[i - 1];
  }

  for (int i = 0; i < n; i++) {
    if (i != n - 1)
      cout << ans[i] << " ";
    else
      cout << ans[i] << endl;
  }
}
Problem p02984 (C++)

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

using namespace std;

int main(void) {
  int n;
  long box = 0;
  cin >> n;
  vector<int> a(n);
  vector<int> mo(n - 1);
  vector<int> al(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    al[i] = a[i];
  }
  while (al.size() != 1) {
    box = al[0] + al[2] - al[1];
    al.erase(al.begin());
    al.erase(al.begin());
    al[0] = box;
  }
  mo[0] = al[0];
  cout << mo[0] << " ";
  for (int i = 0; i < n - 1; i++) {
    mo[i + 1] = 2 * (a[i] - mo[i] / 2);
    cout << mo[i + 1] << " ";
  }
  cout << "" << endl;
}

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

using namespace std;

int main(void) {
  int n;
  long box = 0;
  cin >> n;
  vector<int> a(n);
  vector<int> mo(n);
  vector<int> al(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    al[i] = a[i];
  }
  while (al.size() != 1) {
    box = al[0] + al[2] - al[1];
    al.erase(al.begin());
    al.erase(al.begin());
    al[0] = box;
  }
  mo[0] = al[0];
  cout << mo[0] << " ";
  for (int i = 0; i < n - 1; i++) {
    mo[i + 1] = 2 * (a[i] - mo[i] / 2);
    cout << mo[i + 1] << " ";
  }
  cout << "" << endl;
}
Problem p02984 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];

  ll sum = 0;
  for (int i = 0; i < n; i++)
    sum += a[i];

  int r = n / 2;
  vector<ll> m(n);
  for (int i = 0; i < n; i++) {
    m[i] = sum;
    for (int j = (i + 1) % n;; j = (j + 2) % n) {
      m[i] -= a[j] * 2;
      if (j == (i + 2 * r - 1) % n) {
        break;
      }
    }
  }

  for (int i = 0; i < n; i++) {
    printf("%lld%c", m[i], i == n - 1 ? '\n' : ' ');
  }
}


Fixed submission:
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];

  ll sum = 0;
  for (int i = 0; i < n; i++)
    sum += a[i];

  int r = n / 2;
  vector<ll> m(n);
  m[0] = sum;
  for (int j = 1; j < 2 * r; j = j + 2) {
    m[0] -= a[j] * 2;
  }
  for (int i = 1; i < n; i++) {
    m[i] = 2 * a[i - 1] - m[i - 1];
  }

  for (int i = 0; i < n; i++) {
    printf("%lld%c", m[i], i == n - 1 ? '\n' : ' ');
  }
}
Problem p02984 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

long long A[9999];
long long y[9999];
int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  long long y1minusyn = A[0];
  for (int i = 1; i < N - 1; i++) {
    if (i % 2 == 1) {
      y1minusyn -= A[i];
    } else {
      y1minusyn += A[i];
    }
  }
  y[0] = A[N - 1] + y1minusyn;
  for (int i = 1; i < N; i++) {
    y[i] = 2 * A[i - 1] - y[i - 1];
  }
  for (int i = 0; i < N; i++) {
    if (i != N - 1) {
      cout << y[i] << " ";
    } else {
      cout << y[i] << endl;
    }
  }
  return 0;
}


Fixed submission:
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

long long A[99999];
long long y[99999];
int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  long long y1minusyn = A[0];
  for (int i = 1; i < N - 1; i++) {
    if (i % 2 == 1) {
      y1minusyn -= A[i];
    } else {
      y1minusyn += A[i];
    }
  }
  y[0] = A[N - 1] + y1minusyn;
  for (int i = 1; i < N; i++) {
    y[i] = 2 * A[i - 1] - y[i - 1];
  }
  for (int i = 0; i < N; i++) {
    if (i != N - 1) {
      cout << y[i] << " ";
    } else {
      cout << y[i] << endl;
    }
  }
  return 0;
}
Problem p02984 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cctype>
#include <climits>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
// typedef pair<string,string> P;
// double dat[100][100];
// int dp[6][1010];//動的計画法
// int prime[100001];
// char str[1010][1010];
// typedef pair<ll,ll> A;
// vector<A> pc;
// int ABS(int a){return max(a,-a);}
ll a[100000];
ll dom[100001];
int main() {
  int n;
  ll su = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    su += a[i];
  }
  ll cnt = 0;
  ll tmp = 0;
  for (ll i = 1; i <= n; i++) {
    dom[i] = su;
    cnt = 0;
    tmp = i + 1;
    while (cnt != (n - 1) / 2) {
      if (tmp > n)
        tmp %= n;
      dom[i] -= (2 * a[tmp]);
      // cout<<dom[i]<<endl;
      tmp = (tmp + 2);
      cnt++;
    }
    cout << dom[i] << " ";
  }
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cctype>
#include <climits>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
// typedef pair<string,string> P;
// double dat[100][100];
// int dp[6][1010];//動的計画法
// int prime[100001];
// char str[1010][1010];
// typedef pair<ll,ll> A;
// vector<A> pc;
// int ABS(int a){return max(a,-a);}
ll a[100000];
ll dom[100001];
int main() {
  int n;
  ll su = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    su += a[i];
  }
  ll cnt = 0;
  ll tmp = 0;
  for (ll i = 1; i <= n; i++) {
    dom[i] = su;
    cnt = 0;
    tmp = i + 1;
    if (i == 1) {
      while (cnt != (n - 1) / 2) {
        if (tmp > n)
          tmp %= n;
        dom[i] -= (2 * a[tmp]);
        // cout<<dom[i]<<endl;
        tmp = (tmp + 2);
        cnt++;
      }
    } else {
      dom[i] = 2 * a[i - 1] - dom[i - 1];
    }
    cout << dom[i] << " ";
  }
  return 0;
}