Problem p02983 (C++)

Buggy submission (status: Time Limit Exceeded):
// nlather (Nishant Raj Lather)
// Chrollo_Lucifer

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rnd(x, y) uniform_int_distribution<ll>(x, y)(rng)
struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};
#define boost                                                                  \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(nullptr);
#define rep(i, x, n) for (ll i = x; i < n; i++)
#define rrep(i, x, n) for (ll i = x; i >= n; i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define e emplace
#define mp make_pair
#define debug(this) cout << "> " << #this << " : " << this << "\n"
typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
const ll MOD = 1e9 + 7;
ld PI = 3.1415926535897932384626;
ld EPS = 1e-9;
#define endl '\n'

int main() {
  boost;
  ll l, r;
  cin >> l >> r;
  if (l <= 2019 and r >= 2019) {
    cout << "0";
    return 0;
  }
  ll ans = (l * r) % 2019;
  l %= (2019 * 2019), r %= (2019 * 2019);
  if (l > r)
    swap(l, r);
  rep(i, l, r) rep(j, (i + 1), (r + 1)) ans = min(ans, (i * j) % 2019);
  cout << ans;
}


Fixed submission:
// nlather (Nishant Raj Lather)
// Chrollo_Lucifer

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rnd(x, y) uniform_int_distribution<ll>(x, y)(rng)
struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};
#define boost                                                                  \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(nullptr);
#define rep(i, x, n) for (ll i = x; i < n; i++)
#define rrep(i, x, n) for (ll i = x; i >= n; i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define e emplace
#define mp make_pair
#define debug(this) cout << "> " << #this << " : " << this << "\n"
typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
const ll MOD = 1e9 + 7;
ld PI = 3.1415926535897932384626;
ld EPS = 1e-9;
#define endl '\n'

int main() {
  boost;
  ll l, r;
  cin >> l >> r;
  if (l <= 2019 and r >= 2019) {
    cout << "0";
    return 0;
  }
  ll ans = (l * r) % 2019;
  l = max(l, r - 4 * 2019);
  rep(i, l, r) rep(j, (i + 1), (r + 1)) ans = min(ans, (i * j) % 2019);
  cout << ans;
}