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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <array>
#include <assert.h>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>

using namespace std;
typedef long long ll;

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T> T gcd(T a, T b) {
  a = abs(a), b = abs(b);
  while (b > 0) {
    tie(a, b) = make_pair(b, a % b);
  }
  return a;
}
// mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
// constexpr long long mod = 1000000007LL;
constexpr long long mod = 998244353LL;

int main() {

  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  constexpr ll mod = 2019;
  ll L, R;
  cin >> L >> R;
  ll res = INF;
  for (ll i = L; i <= R; i++) {
    for (ll j = i + 1; j <= R; j++) {
      chmin(res, (i * j) % mod);
      if (res == 0)
        break;
    }
  }
  cout << res << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <array>
#include <assert.h>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>

using namespace std;
typedef long long ll;

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T> T gcd(T a, T b) {
  a = abs(a), b = abs(b);
  while (b > 0) {
    tie(a, b) = make_pair(b, a % b);
  }
  return a;
}
// mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
// constexpr long long mod = 1000000007LL;
constexpr long long mod = 998244353LL;

int main() {

  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  constexpr ll mod = 2019;
  ll L, R;
  cin >> L >> R;
  ll res = INF;
  for (ll i = L; i <= R; i++) {
    for (ll j = i + 1; j <= R; j++) {
      chmin(res, (i * j) % mod);
      if (res == 0)
        break;
    }
    if (res == 0)
      break;
  }
  cout << res << endl;
  return 0;
}
Problem p02983 (C++)

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

constexpr int MOD = 2019;

int main() {
  int L, R;
  std::cin >> L >> R;
  if (R - L > (MOD + 10) * (MOD + 10)) {
    R = L + (MOD + 10) * (MOD + 10);
  }
  int min = MOD;
  for (int i = L; i <= R; ++i) {
    for (int j = i + 1; j <= R; ++j) {
      int r = ((i % MOD) * (j % MOD)) % MOD;
      min = std::min(min, r);
    }
  }
  std::cout << min << std::endl;
  return 0;
}

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

constexpr int MOD = 2019;

int main() {
  int L, R;
  std::cin >> L >> R;
  if (R - L > MOD + 10) {
    R = L + MOD + 10;
  }
  int min = MOD;
  for (int i = L; i <= R; ++i) {
    for (int j = i + 1; j <= R; ++j) {
      int r = ((i % MOD) * (j % MOD)) % MOD;
      min = std::min(min, r);
    }
  }
  std::cout << min << std::endl;
  return 0;
}
Problem p02983 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using Int = long long int;
template <typename T> void swap(T *t1, T *t2) {
  T *tmp = t1;
  t1 = t2;
  t2 = tmp;
}
Int tmpi = 0;
double tmpd = 0.0;

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

  Int l, r;
  cin >> l >> r;

  Int min = pow(10, 18);
  for (Int i = l; i < r; i++) {
    for (Int j = i + 1; j <= r; j++) {
      if (i % 2019 == 0) {
        cout << 0 << endl;
        break;
      }
      min = i * j % 2019 < min ? i * j % 2019 : min;
    }
  }
  cout << min << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using Int = long long int;
template <typename T> void swap(T *t1, T *t2) {
  T *tmp = t1;
  t1 = t2;
  t2 = tmp;
}
Int tmpi = 0;
double tmpd = 0.0;

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

  Int l, r;
  cin >> l >> r;

  Int min = pow(10, 18);
  for (Int i = l; i < r; i++) {
    for (Int j = i + 1; j <= r; j++) {
      if (i * j % 2019 == 0) {
        cout << '0' << endl;
        return 0;
      }
      min = i * j % 2019 < min ? i * j % 2019 : min;
    }
  }
  cout << min << endl;
  return 0;
}
Problem p02983 (C++)

Buggy submission (status: Time Limit Exceeded):
/*
 */
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

int main() {
  long long l, r;
  int ans = 2019;
  cin >> l >> r;

  vector<bool> a(2019, false);

  for (int i = l; i <= r; i++)
    a[i % 2019] = true;

  for (int i = 0; i < 2019; i++) {
    for (int j = i + 1; j < 2019; j++) {
      if (a[i] && a[j])
        ans = min(ans, (i * j) % 2019);
    }
  }

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

Fixed submission:
/*
 */
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

int main() {
  long long l, r;
  int ans = 2019;
  cin >> l >> r;

  vector<bool> a(2019, false);
  if (r - l < 2019) {
    for (int i = l; i <= r; i++)
      a[i % 2019] = true;
  } else {
    for (int i = 0; i < 2019; i++)
      a[i] = true;
  }
  for (int i = 0; i < 2019; i++) {
    for (int j = i + 1; j < 2019; j++) {
      if (a[i] && a[j])
        ans = min(ans, (i * j) % 2019);
    }
  }

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

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

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

  for (long i = L; i <= R; i++) {
    for (long j = i + 1; j <= R; j++) {
      if (i % 2019 == 0) {
        cout << 0;
        return 0;
      }

      if (i * j % 2019 < ans) {
        ans = i * j % 2019;
      }
    }
  }

  cout << ans;
  return 0;
}

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

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

  for (long i = L; i <= R; i++) {
    for (long j = i + 1; j <= R; j++) {
      if (j % 2019 == 0) {
        cout << 0;
        return 0;
      }

      if (i * j % 2019 < ans) {
        ans = i * j % 2019;
      }
    }
  }

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define endl "\n"

using namespace std;

long long int l, r, i, j, a;

int main() {

  cin >> l >> r;
  int x = 2018;

  for (i = l; i <= r; i++) {
    for (j = i + 1; j <= r; j++) {
      a = (i * j) % 2019;
      if (a < x) {
        x = a;
      }
      if (a == 0) {
        break;
      }
    }
  }

  cout << x;
}

// g++ -std=c++14 comp.cpp; ./a.exe


Fixed submission:
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define endl "\n"

using namespace std;

long long int l, r, i, j, a;

int main() {

  cin >> l >> r;
  int x = 2018;

  for (i = l; i <= r; i++) {
    for (j = i + 1; j <= r; j++) {
      a = (i * j) % 2019;
      if (a < x) {
        x = a;
      }
      if (x == 0) {
        cout << 0;
        return 0;
      }
    }
  }

  cout << x;
}

// g++ -std=c++14 comp.cpp; ./a.exe
Problem p02983 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <climits>
#include <cstdint> // int64_t, int*_t
#include <cstdio>  // printf
#include <deque>   // deque
#include <functional>
#include <iomanip> //setprecision
#include <iostream>
#include <map> // map
#include <math.h>
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <string>        // string, to_string, stoi
#include <tuple>         // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define mod 1000000007
vector<ll> to[1000005];
ll dp[2000000];
int gcd(int a, int b) {
  if (a % b == 0) {
    return (b);
  } else {
    return (gcd(b, a % b));
  }
}
int main() {
  ll a, b, c = INT_MAX;
  cin >> a >> b;
  if (b - a >= 2019) {
    cout << 0;
  }
  for (ll i = a; i < b + 1; i++) {
    for (ll o = i + 1; o < b + 1; o++) {
      c = min(c, i % 2019 * o % 2019);
    }
  }
  cout << c;
}


Fixed submission:
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <climits>
#include <cstdint> // int64_t, int*_t
#include <cstdio>  // printf
#include <deque>   // deque
#include <functional>
#include <iomanip> //setprecision
#include <iostream>
#include <map> // map
#include <math.h>
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <string>        // string, to_string, stoi
#include <tuple>         // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define mod 1000000007
vector<ll> to[1000005];
ll dp[2000000];
int gcd(int a, int b) {
  if (a % b == 0) {
    return (b);
  } else {
    return (gcd(b, a % b));
  }
}
int main() {
  ll a, b, c = INT_MAX;
  cin >> a >> b;
  if (b - a >= 2019) {
    cout << 0;
    return 0;
  }
  for (ll i = a; i < b + 1; i++) {
    for (ll o = i + 1; o < b + 1; o++) {
      c = min(c, i % 2019 * o % 2019);
    }
  }
  cout << c;
}
Problem p02983 (C++)

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

int main() {
  ll ans = 2018;
  bool fin = false;
  ll L, R;
  cin >> L >> R;
  for (ll i = L; i < R; i++) {
    for (ll j = i + 1; j < R + 1; j++) {
      ll mod = (i * j) % 2019;
      if (mod < ans)
        ans = mod;
      if (mod = 0) {
        fin = true;
        break;
      }
    }
    if (fin)
      break;
  }

  cout << ans << endl;
}

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

int main() {
  ll ans = 2018;
  bool fin = false;
  ll L, R;
  cin >> L >> R;
  for (ll i = L; i < R; i++) {
    for (ll j = i + 1; j < R + 1; j++) {
      ll mod = (i * j) % 2019;
      if (mod < ans)
        ans = mod;
      if (ans == 0) {
        fin = true;
        break;
      }
    }
    if (fin)
      break;
  }

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

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

int main() {
  long L, R;
  cin >> L >> R;
  long answer = L * R;
  if (!(L * R < 2019)) {
    for (long i = L; i < R; i++) {
      for (long j = L + 1; j <= R; j++) {
        long mod = (i * j) % 2019;
        if (answer > mod) {
          answer = mod;
        }
      }
    }
  }
  cout << answer << endl;
}

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

int main() {
  long L, R;
  cin >> L >> R;
  long answer = L * R;
  if (R - L + 1 >= 2019) {
    cout << 0 << endl;
    return 0;
  }
  if (!(L * R < 2019)) {
    for (long i = L; i < R; i++) {
      for (long j = L + 1; j <= R; j++) {
        long mod = (i * j) % 2019;
        if (answer > mod) {
          answer = mod;
        }
      }
    }
  }
  cout << answer << endl;
}
Problem p02983 (C++)

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

int main(void) {
  long long int l;
  long long int r;
  long long int a, b;
  long long int n = 0;
  int min = 10000000;

  cin >> l >> r;

  for (a = l; a < r; a++) {

    for (b = l + 1; b < r + 1; b++) {

      n = a * b % 2019;

      if (n < min) {
        min = n;
      }
    }
  }

  cout << min << endl;

  return 0;
}

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

int main(void) {
  long long int l;
  long long int r;
  long long int a, b;
  long long int n = 0;
  int min = 10000000;

  cin >> l >> r;
  if (r - l > 2020) {

    cout << "0" << endl;
    return 0;
  }

  for (a = l; a < r; a++) {

    for (b = l + 1; b < r + 1; b++) {

      n = a * b % 2019;

      if (n < min) {
        min = n;
      }
    }
  }

  cout << min << endl;

  return 0;
}
Problem p02983 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
long long l, r, ans = 2020, a[2020];
int main(int argc, char const *argv[]) {
  scanf("%lld%lld", &l, &r);
  for (long long i = l; i <= r; ++i) {
    memset(a, 0, sizeof(a));
    for (long long j = i + 1; j <= r; ++j) {
      if (a[(i * j) % 2019] == 1)
        break;
      a[(i * j) % 2019] = 1;
      ans = min(ans, (i * j) % 2019);
    }
  }
  printf("%lld\n", ans);
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
long long l, r, ans = 2020, a[2020];
int main(int argc, char const *argv[]) {
  scanf("%lld%lld", &l, &r);
  if (l / 2019 != r / 2019) {
    printf("0\n");
    return 0;
  }
  for (long long i = l; i <= r; ++i) {
    memset(a, 0, sizeof(a));
    for (long long j = i + 1; j <= r; ++j) {
      if (a[(i * j) % 2019] == 1)
        break;
      a[(i * j) % 2019] = 1;
      ans = min(ans, (i * j) % 2019);
    }
  }
  printf("%lld\n", ans);
  return 0;
}
Problem p02983 (C++)

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

int main() {
  int l, r;
  cin >> l >> r;
  int d = r - l;
  int ans = 2019;

  for (int i = 0; i < d; i++) {
    for (int j = i + 1; j <= d; j++) {
      int x = (l + i) % 2019;
      int y = (l + j) % 2019;
      ans = min(ans, (x * y) % 2019);
    }
  }
  cout << ans << endl;
}

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

int main() {
  int l, r;
  cin >> l >> r;
  int d = min(2019, (r - l));
  int ans = 2019;

  for (int i = 0; i < d; i++) {
    for (int j = i + 1; j <= d; j++) {
      int x = (l + i) % 2019;
      int y = (l + j) % 2019;
      ans = min(ans, (x * y) % 2019);
    }
  }
  cout << ans << endl;
}
Problem p02983 (C++)

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

ll P = 2019;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll l, r;
  cin >> l >> r;
  if (r - l > 2019) {
    cout << 0 << endl;
  }
  ll ans = 2019 * 2019;
  for (ll i = l; i < r; i++) {
    for (ll j = i + 1; j <= r; j++)
      ans = min(ans, (i % P * j % P) % P);
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

ll P = 2019;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll l, r;
  cin >> l >> r;
  if (r - l > 2019) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = 2019 * 2019;
  for (ll i = l; i < r; i++) {
    for (ll j = i + 1; j <= r; j++)
      ans = min(ans, (i % P * j % P) % P);
  }
  cout << ans << endl;
  return 0;
}
Problem p02983 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vi = vector<int>;
using vii = vector<vi>;

int main() {
  long long int l, r;
  cin >> l >> r;
  bool flag = false;
  int m = 2019;

  if (l - r + 1 >= 2019) {
    m = 0;
    flag = true;
  }

  if (!flag) {
    for (long long int i = l; i < r; i++) {
      for (long long int j = l + 1; j <= r; j++) {
        long long int a, b;
        a = i % 2019;
        b = j % 2019;
        if (m > (a * b) % 2019) {
          m = (a * b) % 2019;
          if (m == 0)
            break;
        }
      }
    }
  }
  cout << m << endl;
}


Fixed submission:
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vi = vector<int>;
using vii = vector<vi>;

int main() {
  long long int l, r;
  cin >> l >> r;
  bool flag = false;
  int m = 2019;

  if (l - r + 1 >= 2019) {
    m = 0;
    flag = true;
  }

  if (!flag) {
    for (long long int i = l; i < r; i++) {
      for (long long int j = l + 1; j <= r; j++) {
        long long int a, b;
        a = i % 2019;
        b = j % 2019;
        if (m > (a * b) % 2019) {
          m = (a * b) % 2019;
          if (m == 0)
            break;
        }
      }
      if (m == 0)
        break;
    }
  }
  cout << m << endl;
}
Problem p02983 (C++)

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

using namespace std;

int main() {

  long int l, r;
  long int min = 3000;
  cin >> l >> r;

  for (long int i = l; i <= r - 1; i++) {
    for (long int j = i + 1; j <= r; j++) {
      int tmp = (i * j) % 2019;
      if (tmp < min) {
        min = tmp;
      }
    }
  }

  cout << min << endl;

  return 0;
}


Fixed submission:
#include <iostream>

using namespace std;

int main() {

  long int l, r;
  long int min = 3000;
  cin >> l >> r;

  for (long int i = l; i <= r - 1; i++) {
    for (long int j = i + 1; j <= r; j++) {
      int tmp = (i * j) % 2019;
      if (tmp < min) {
        min = tmp;
      }
      if (min == 0) {
        break;
      }
    }
    if (min == 0) {
      break;
    }
  }

  cout << min << endl;

  return 0;
}
Problem p02983 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF = 200000000000000;
double pi = 3.141592653589793;

const int MOD = 1000000007;

long long gcd(long long a, long long b) {
  if (a < b)
    swap(a, b);
  if (a % b == 0)
    return b;
  return gcd(a % b, b);
}

long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long myPow(long long x, long long n, long long m = MOD) {
  if (n == 0)
    return 1;
  if (n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

ll digit(ll num) {
  ll ret = 0;
  string s = to_string(num);
  return s.length();
}

class Edge {
public:
  ll num;
  ll a;
  ll b;
  ll color = 0;
  Edge(ll _num, ll _a, ll _b) {
    num = _num;
    a = _a;
    b = _b;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll l, r;
  cin >> l >> r;
  if (r - l >= 3000) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = INF;
  for (ll i = l; i < r; i++) {
    for (ll j = i + 1; j <= r; j++) {
      ans = min(ans, (ll)(i * j) % 2019);
    }
  }
  cout << ans << endl;
  return 1;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF = 200000000000000;
double pi = 3.141592653589793;

const int MOD = 1000000007;

long long gcd(long long a, long long b) {
  if (a < b)
    swap(a, b);
  if (a % b == 0)
    return b;
  return gcd(a % b, b);
}

long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long myPow(long long x, long long n, long long m = MOD) {
  if (n == 0)
    return 1;
  if (n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

ll digit(ll num) {
  ll ret = 0;
  string s = to_string(num);
  return s.length();
}

class Edge {
public:
  ll num;
  ll a;
  ll b;
  ll color = 0;
  Edge(ll _num, ll _a, ll _b) {
    num = _num;
    a = _a;
    b = _b;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll l, r;
  cin >> l >> r;
  if (r - l >= 3000) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = INF;
  for (ll i = l; i < r; i++) {
    for (ll j = i + 1; j <= r; j++) {
      ans = min(ans, (ll)(i * j) % 2019);
    }
  }
  cout << ans << endl;
  // return 1;
}
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;

  long long min = 2020;
  for (long long i = l; i <= r; i++) {
    long long tmp = i % 2019;
    if (tmp < min)
      min = tmp;
  }

  if (min == 0) {
    cout << 0 << endl;
    return 0;
  }

  long long start = l % 2019;
  long long end = r % 2019;
  if (start > end) {
    long long tmp = start;
    start = end;
    end = tmp;
  }
  long long answer = 2020;

  for (long long i = start; i < end; i++) {
    for (long long j = start + 1; j <= end; j++) {
      long long tmp = i * j;
      tmp %= 2019;
      if (answer > tmp)
        answer = tmp;
      if (answer == 0)
        break;
    }
  }

  cout << answer << endl;
}

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

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

  long long min = 2020;
  for (long long i = l; i <= r; i++) {
    long long tmp = i % 2019;
    if (tmp < min)
      min = tmp;
    if (min == 0)
      break;
  }

  if (min == 0) {
    cout << 0 << endl;
    return 0;
  }

  long long start = l % 2019;
  long long end = r % 2019;
  if (start > end) {
    long long tmp = start;
    start = end;
    end = tmp;
  }
  long long answer = 2020;

  for (long long i = start; i < end; i++) {
    for (long long j = start + 1; j <= end; j++) {
      long long tmp = i * j;
      tmp %= 2019;
      if (answer > tmp)
        answer = tmp;
      if (answer == 0)
        break;
    }
  }

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

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

  long long l, r;
  cin >> l >> r;
  long long mind = 1e9;
  for (long long i = l; i < r; i++) {
    for (long long j = i + 1; j < r + 1; j++) {
      mind = min(((i * j) % 2019), mind);
      if (mind == 0)
        break;
    }
  }
  cout << mind << endl;

  // cout << (((l <= 2019  && r > 2019)|| l == 0 ) ? 0 : (l*(l+1))%2019 )<<
  // endl;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {

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

  for (long long i = l % 2019; i < r % 2019; i++) {
    for (long long j = i + 1; j <= r % 2019; j++) {
      mind = min(((i * j) % 2019), mind);
      if (mind == 0)
        break;
    }
  }
  cout << mind << endl;

  // cout << (((l <= 2019  && r > 2019)|| l == 0 ) ? 0 : (l*(l+1))%2019 )<<
  // endl;
}
Problem p02983 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <assert.h>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <cmath>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility> // pair make_pair
#include <vector>

#define m0(x) memset(x, 0, sizeof(x))
#define m1(x) memset(x, 63, sizeof(x))
#define fill(x, y) memset(x, y, sizeof(x))
#define ll long long
#define int ll
#define INF LLONG_MAX / 10

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int>>;
using WeightGraph = vector<vector<Pi>>;

signed main() {
  int L, R;
  cin >> L >> R;
  if (R - L >= 2018) {
    cout << 0 << endl;
    return 0;
  }
  int x = L % 2019;
  int y = R % 2019;

  int ans = INF;

  for (int i = x; i < y; i = (i + 1) % 2019) {
    for (int j = (i + 1) % 2019; j <= y; j = (j + 1) % 2019) {
      ans = min(ans, (i * j) % 2019);
    }
  }

  cout << ans << endl;
}


Fixed submission:
#include <algorithm>
#include <assert.h>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <cmath>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility> // pair make_pair
#include <vector>

#define m0(x) memset(x, 0, sizeof(x))
#define m1(x) memset(x, 63, sizeof(x))
#define fill(x, y) memset(x, y, sizeof(x))
#define ll long long
#define int ll
#define INF LLONG_MAX / 10

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int>>;
using WeightGraph = vector<vector<Pi>>;

signed main() {
  int L, R;
  cin >> L >> R;
  if (R - L >= 2018) {
    cout << 0 << endl;
    return 0;
  }
  int x = L % 2019;
  int y = R % 2019;

  int ans = INF;

  for (int i = x; i < y; i = (i + 1) % 2019) {
    for (int j = (i + 1) % 2019; j <= y; j = (j + 1) % 2019) {
      if (i == 0 || j == 0) {
        cout << 0 << endl;
        return 0;
      }
      ans = min(ans, (i * j) % 2019);
    }
  }

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

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i, m, n) for (ll(i) = (m), i_len = (n); (i) < (i_len); ++(i))
#define FORR(i, v) for (auto(i) : v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define pb push_back
#define mp make_pair

int main() {
  ll L, R;
  cin >> L >> R;
  ll m = 2018;
  REP(i, L, R) {
    REP(j, i + 1, R + 1) {
      m = MIN((i * j) % 2019, m);
      if (m == 0)
        break;
    }
  }
  PR(m);

  return 0;
}

/*



*/

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i, m, n) for (ll(i) = (m), i_len = (n); (i) < (i_len); ++(i))
#define FORR(i, v) for (auto(i) : v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define pb push_back
#define mp make_pair

int main() {
  ll L, R;
  cin >> L >> R;
  ll m = 2018;
  if ((R - L + 1) >= 2019)
    m = 0;
  else {
    REP(i, L, R) {
      REP(j, i + 1, R + 1) { m = MIN((i * j) % 2019, m); }
    }
  }
  PR(m);

  return 0;
}

/*



*/
Problem p02983 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)

//-----------------------------------------------
int mod = 2019;
//------------------------------------------------
int main() {
  int l, r, ans, a;
  cin >> l >> r;
  ans = 2018;
  rep(i, l, r) {
    rep(k, i + 1, r + 1) {
      a = (i % mod) * (k % mod);
      ans = min(ans, a % mod);
      if (ans == 0)
        break;
    }
  }
  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)

//-----------------------------------------------
int mod = 2019;
//------------------------------------------------
int main() {
  int l, r, ans, a;
  cin >> l >> r;
  ans = 2018;
  rep(i, l, r) {
    if (r / 673 - l / 673 > 0) {
      ans = 0;
      break;
    }
    rep(k, i + 1, r + 1) {
      a = (i % mod) * (k % mod);
      ans = min(ans, a % mod);
      if (ans == 0)
        break;
    }
  }
  cout << ans << endl;
}
Problem p02983 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define FOR(i, l, r) for (int i = (l), i##R = (r); i <= i##R; i++)
#define DOR(i, r, l) for (int i = (r), i##L = (l); i >= i##L; i--)
#define loop(i, n) for (int i = 0, i##R = (n); i < i##R; i++)
#define sf scanf
#define pf printf
#define mms(a, x) memset(a, x, sizeof a)
using namespace std;
typedef long long ll;
template <typename A, typename B> inline void chkmax(A &x, const B y) {
  if (x < y)
    x = y;
}
template <typename A, typename B> inline void chkmin(A &x, const B y) {
  if (x > y)
    x = y;
}
const int N = 25;
int main() {
  int L, R;
  sf("%d%d", &L, &R);
  if (L - R > 2019)
    puts("0");
  else {
    int ans = 1e9;
    FOR(i, L, R) FOR(j, i + 1, R) chkmin(ans, (int)(1ll * i * j % 2019));
    pf("%d\n", ans);
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define FOR(i, l, r) for (int i = (l), i##R = (r); i <= i##R; i++)
#define DOR(i, r, l) for (int i = (r), i##L = (l); i >= i##L; i--)
#define loop(i, n) for (int i = 0, i##R = (n); i < i##R; i++)
#define sf scanf
#define pf printf
#define mms(a, x) memset(a, x, sizeof a)
using namespace std;
typedef long long ll;
template <typename A, typename B> inline void chkmax(A &x, const B y) {
  if (x < y)
    x = y;
}
template <typename A, typename B> inline void chkmin(A &x, const B y) {
  if (x > y)
    x = y;
}
const int N = 25;
int main() {
  int L, R;
  sf("%d%d", &L, &R);
  if (R - L > 2019)
    puts("0");
  else {
    int ans = 1e9;
    FOR(i, L, R) FOR(j, i + 1, R) chkmin(ans, (int)(1ll * i * j % 2019));
    pf("%d\n", ans);
  }
  return 0;
}
Problem p02983 (C++)

Buggy submission (status: Time Limit Exceeded):
//* AuThOr GaRyMr *//
#include <bits/stdc++.h>
#define rb(a, b, c) for (LL a = b; a <= c; ++a)
#define rl(a, b, c) for (LL a = b; a >= c; --a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a, b) make_pair(a, b)
#define FIR first
#define SEC second
using namespace std;
const int INF = 0x3f3f3f3f;
typedef pair<int, int> mp;
typedef pair<mp, mp> superpair;
int main() {
  int l, r;
  cin >> l >> r;
  if (r - l + 1 >= 2019) {
    cout << 0;
  }
  int tot = r - l;
  LL sum = INF;
  rb(i, l, r) {
    rb(j, i + 1, r) { sum = min(sum, (i * j) % 2019); }
  }
  cout << sum;
  return 0;
}

Fixed submission:
//* AuThOr GaRyMr *//
#include <bits/stdc++.h>
#define rb(a, b, c) for (LL a = b; a <= c; ++a)
#define rl(a, b, c) for (LL a = b; a >= c; --a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a, b) make_pair(a, b)
#define FIR first
#define SEC second
using namespace std;
const int INF = 0x3f3f3f3f;
typedef pair<int, int> mp;
typedef pair<mp, mp> superpair;
int main() {
  int l, r;
  cin >> l >> r;
  if (r - l + 1 >= 2019) {
    cout << 0;
    return 0;
  }
  int tot = r - l;
  LL sum = INF;
  rb(i, l, r) {
    rb(j, i + 1, r) { sum = min(sum, (i * j) % 2019); }
  }
  cout << sum;
  return 0;
}
Problem p02983 (C++)

Buggy submission (status: Time Limit Exceeded):
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i, j, k) for (int(i) = (j); (i) < (int)(k); ++(i))
#define rep(i, j) FOR(i, 0, j)
#define each(x, y) for (auto &(x) : (y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << (x) << endl
#define smax(x, y) (x) = max((x), (y))
#define smin(x, y) (x) = min((x), (y))
#define MEM(x, y) memset((x), (y), sizeof(x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

void solve() {

  int mi = INT_MAX;
  int L, R;
  cin >> L >> R;
  for (int i = L; i < min(R, i + 2019); ++i) {
    int x = i % 2019;
    for (int j = i + 1; j < min(R + 1, i + 2020); ++j) {
      int y = j % 2019;
      int z = x * y % 2019;
      smin(mi, z);
    }
  }
  cout << mi << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);
  solve();
  return 0;
}


Fixed submission:
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i, j, k) for (int(i) = (j); (i) < (int)(k); ++(i))
#define rep(i, j) FOR(i, 0, j)
#define each(x, y) for (auto &(x) : (y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << (x) << endl
#define smax(x, y) (x) = max((x), (y))
#define smin(x, y) (x) = min((x), (y))
#define MEM(x, y) memset((x), (y), sizeof(x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

void solve() {

  int mi = INT_MAX;
  int L, R;
  cin >> L >> R;
  for (int i = L; i < min(R, L + 2019); ++i) {
    int x = i % 2019;
    for (int j = i + 1; j < min(R + 1, i + 2020); ++j) {
      int y = j % 2019;
      int z = x * y % 2019;
      smin(mi, z);
    }
  }
  cout << mi << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);
  solve();
  return 0;
}
Problem p02983 (C++)

Buggy submission (status: Time Limit Exceeded):
/* long long or int */
/* xx 396*/

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

typedef long long ll;

ll l, r;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> l >> r;
  if (l - r + 1 >= 2019) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = 2019;
  for (ll i = l; i < r; i++) {
    for (ll j = i + 1; j <= r; j++) {
      ll sum = i * j;
      ans = min(sum % 2019, ans);
    }
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
/* long long or int */
/* xx 396*/

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

typedef long long ll;

ll l, r;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> l >> r;
  if (r - l + 1 >= 2019) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = 2019;
  for (ll i = l; i < r; i++) {
    for (ll j = i + 1; j <= r; j++) {
      ll sum = i * j;
      ans = min(sum % 2019, ans);
    }
  }
  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++)
#define PI acos(-1)
typedef long long ll;
ll gcd(ll x, ll y) {
  if (y == 0)
    return x;
  else
    return gcd(y, x % y);
}
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

using namespace std;

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

  ll ml = 10000, mr = 0;
  for (ll i = l; i <= r; i++) {
    ml = min(ml, i % 2019);
    mr = max(mr, i % 2019);
  }
  ll ans = 10000;
  for (ll i = ml; i < mr + 1; i++) {
    for (ll j = i + 1; j < mr + 1; j++) {
      ans = min(ans, i * j % 2019);
    }
  }

  cout << ans;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define PI acos(-1)
typedef long long ll;
ll gcd(ll x, ll y) {
  if (y == 0)
    return x;
  else
    return gcd(y, x % y);
}
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

using namespace std;

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

  ll ml = 10000, mr = 0;
  for (ll i = l; i <= r; i++) {
    ml = min(ml, i % 2019);
    mr = max(mr, i % 2019);
    if (i - l > 5000)
      break;
  }
  ll ans = 10000;
  for (ll i = ml; i < mr + 1; i++) {
    for (ll j = i + 1; j < mr + 1; j++) {
      ans = min(ans, i * j % 2019);
    }
  }

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define repn(i, n) for (int i = 1; i <= n; i++)
using namespace std;
typedef long long ll;

const int MOD = 2019;
int L, R;

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

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

  int ans = MOD - 1;
  for (int i = L; i <= R - 1; i++) {
    for (int j = i + 1; j <= R; j++) {
      if ((i % MOD) * (j % MOD) % MOD < ans)
        ans = (i % MOD) * (j % MOD) % MOD;
    }
  }

  cout << ans << endl;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define repn(i, n) for (int i = 1; i <= n; i++)
using namespace std;
typedef long long ll;

const int MOD = 2019;
int L, R;

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

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

  int ans = MOD - 1;
  for (int i = L; i <= R - 1; i++) {
    for (int j = i + 1; j <= R; j++) {
      if ((i % MOD) * (j % MOD) % MOD < ans)
        ans = (i % MOD) * (j % MOD) % MOD;
    }
  }

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  long long L, R;
  cin >> L >> R;
  long long Min = 2018;
  if (L - R < 2019) {
    for (long long i = L; i < R; i++) {
      for (long long j = i + 1; j <= R; j++) {
        Min = min(Min, (i * j) % 2019);
      }
    }
    printf("%lld", Min);
  } else {
    cout << 0 << endl;
  }
}


Fixed submission:
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  long long L, R;
  cin >> L >> R;
  long long Min = 2018;
  if (R - L < 2019) {
    for (long long i = L; i < R; i++) {
      for (long long j = i + 1; j <= R; j++) {
        Min = min(Min, (i * j) % 2019);
      }
    }
    printf("%lld", Min);
  } else {
    cout << 0 << endl;
  }
}
Problem p02983 (C++)

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

int main() {
  int l, r, min = 2018;
  cin >> l >> r;

  for (int i = l; i <= r - 1; i++) {
    for (int j = r; j >= l + 1; j--) {
      int left = i, right = j;
      left %= 2019;
      right %= 2019;
      if (left * right % 2019 < min)
        min = left * right % 2019;
    }
    if (min == 0)
      break;
  }
  cout << min << endl;
}


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

int main() {
  int l, r, min = 2018;
  cin >> l >> r;

  for (int i = l; i <= r - 1; i++) {
    for (int j = r; j >= l + 1; j--) {
      if (min == 0)
        break;
      int left = i, right = j;
      left %= 2019;
      right %= 2019;
      if (left * right % 2019 < min)
        min = left * right % 2019;
    }
    if (min == 0)
      break;
  }
  cout << min << endl;
}
Problem p02983 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

#define Rep(i, a, b) for (int i = a; i < b; i++)
#define rep(i, b) Rep(i, 0, b)
#define rrep(i, a) for (int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

/*
// 最大公約数
ll gcd(ll a, ll b) {
        if (b == 0) return a;
        return gcd(b, a % b);
}

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

int main() {

  ll l, r;
  cin >> l >> r;

  // 2019で割ったあまりの最小値

  // 全探索したいなぁ

  ll ans = inf;

  for (ll i = l; i <= r && i <= l + (ll)2019; i++) {
    for (ll j = i + 1; j <= r && i <= l + (ll)2020; j++) {
      ans = min(ans, (i * j) % (ll)2019);
    }
  }

  cout << ans << endl;

  return 0;
}


Fixed submission:
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

#define Rep(i, a, b) for (int i = a; i < b; i++)
#define rep(i, b) Rep(i, 0, b)
#define rrep(i, a) for (int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

/*
// 最大公約数
ll gcd(ll a, ll b) {
        if (b == 0) return a;
        return gcd(b, a % b);
}

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

int main() {

  ll l, r;
  cin >> l >> r;

  // 2019で割ったあまりの最小値

  // 全探索したいなぁ

  ll ans = inf;

  for (ll i = l; i <= r && i <= l + (ll)2019; i++) {
    for (ll j = i + 1; j <= r && j <= l + (ll)2020; j++) {
      ans = min(ans, (i * j) % (ll)2019);
    }
  }

  cout << ans << endl;

  return 0;
}
Problem p02983 (C++)

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

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

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int L, R;
  cin >> L >> R;
  int min = 99999;

  for (int i = L; i <= R - 1; i++) {
    for (int j = i + 1; j <= R && j < i + 2050; j++) {
      int a = i % 2019;
      int b = j % 2019;
      if ((a * b) % 2019 < min)
        min = (a * b) % 2019;
    }
  }

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

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int L, R;
  cin >> L >> R;
  int min = 99999;

  for (int i = L; i <= R - 1 && i < L + 2050; i++) {
    for (int j = i + 1; j <= R && j < i + 2050; j++) {
      int a = i % 2019;
      int b = j % 2019;
      if ((a * b) % 2019 < min)
        min = (a * b) % 2019;
    }
  }

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

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

int main() {
  long long L, R;
  cin >> L >> R;
  R = min(R, R + 4038);
  int ans = 2018;
  for (long long i = L; i < R; ++i) {
    for (long long j = i + 1; j <= R; ++j) {
      int x = i * j % 2019;
      ans = min(ans, x);
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  long long L, R;
  cin >> L >> R;
  R = min(R, L + 4038);
  int ans = 2018;
  for (long long i = L; i < R; ++i) {
    for (long long j = i + 1; j <= R; ++j) {
      int x = i * j % 2019;
      ans = min(ans, x);
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p02983 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1 << 30;
bool m[2020] = {};
int main() {
  int l, r;
  cin >> l >> r;
  for (int i = l; i <= r; i++) {
    m[i % 2019] = true;
  }
  int ans = INF;
  for (int i = 0; i < 2019; i++) {
    if (!m[i])
      continue;
    for (int j = 0; j < i; j++) {
      if (!m[j])
        continue;
      ans = min(ans, (i * j) % 2019);
    }
  }
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1 << 30;
bool m[2020] = {};
int main() {
  int l, r;
  cin >> l >> r;
  if (2019 * (l / 2019) + 2019 <= r) {
    r %= 2019;
    r += 2019;
    l %= 2019;
  } else {
    r %= 2019;
    l %= 2019;
  }
  for (int i = l; i <= r; i++) {
    m[i % 2019] = true;
  }
  int ans = INF;
  for (int i = 0; i < 2019; i++) {
    if (!m[i])
      continue;
    for (int j = 0; j < i; j++) {
      if (!m[j])
        continue;
      ans = min(ans, (i * j) % 2019);
    }
  }
  cout << ans << endl;
}
Problem p02983 (C++)

Buggy submission (status: Time Limit Exceeded):
/**
 *    author:  yuya1234
 *    created: 10.07.2020 16:33:27
 **/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)

#define SORT(s) sort((s).begin(), (s).end())
#define SORTD(s) sort((s).rbegin(), (s).rend())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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

  ll l, r;
  cin >> l >> r;

  ll ans = 2019;
  FOR(i, l, r - 1) {
    FOR(j, i + 1, r) { ans = min(ans, (i * j) % 2019); }
  }

  cout << ans << endl;

  return 0;
}

Fixed submission:
/**
 *    author:  yuya1234
 *    created: 10.07.2020 16:33:27
 **/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)

#define SORT(s) sort((s).begin(), (s).end())
#define SORTD(s) sort((s).rbegin(), (s).rend())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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

  ll l, r;
  cin >> l >> r;

  ll ans = 2019;
  FOR(i, l, r - 1) {
    FOR(j, i + 1, r) {
      ans = min(ans, (i * j) % 2019);
      if (ans == 0) {
        i = r;
        j = r;
      }
    }
  }

  cout << ans << endl;

  return 0;
}