Problem p02983 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
#define ll long long
ll mod = 1000000007;
using namespace std;
priority_queue<ll int> QUE; // きゅー
int length(char *str) {
  int len = strlen(str);
  return len;
}
ll GCD(ll a, ll b) {

  ll r, tmp;

  /* 自然数 a > b を確認・入替 */
  if (a < b) {
    tmp = a;
    a = b;
    b = tmp;
  }

  /* ユークリッドの互除法 */
  r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }

  return b;
}
ll LCM(ll a, ll b) {

  ll r, x, tmp;
  ll i, j;
  ll lcm;
  i = a;
  j = b;

  /* 自然数 a > b を確認・入替 */
  if (a < b) {
    tmp = a;
    a = b;
    b = tmp;
  }

  /* ユークリッドの互除法 */
  r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  lcm = (i / b) * j;

  return lcm;
}
ll checkTen(ll a) {
  ll ans = 0;
  while (true) {
    ans++;
    if ((a / 10) % 10 != 0) {
      break;
    }
    a = a / 10;
  }
  return ans;
}
ll checkFive(ll a) {
  ll ans = 0;
  while (true) {
    ans++;
    if ((a / 5) % 5 != 0) {
      break;
    }
    a = a / 5;
  }
  return ans;
}
ll checkTwo(ll a) {
  ll ans = 0;
  while (true) {
    ans++;
    if ((a / 2) % 2 != 0) {
      break;
    }
    a = a / 2;
  }
  return ans;
}
ll checkf(ll a) {
  ll ans = 0;
  while (true) {
    ans++;
    if ((a / 10) % 10 != 0) {
      break;
    }
    a = a / 10;
  }
  return a;
}
int main() {
  ll L, R;
  ll Min = 2019;
  cin >> L >> R;
  for (ll i = L; i < R; i++) {
    for (ll j = L + 1; j <= R; j++) {
      Min = min(Min, (i * j) % 2019);
      if (Min == 0) {
        cout << Min << endl;
      }
    }
  }
  cout << Min << endl;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
#define ll long long
ll mod = 1000000007;
using namespace std;
priority_queue<ll int> QUE; // きゅー
int length(char *str) {
  int len = strlen(str);
  return len;
}
ll GCD(ll a, ll b) {

  ll r, tmp;

  /* 自然数 a > b を確認・入替 */
  if (a < b) {
    tmp = a;
    a = b;
    b = tmp;
  }

  /* ユークリッドの互除法 */
  r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }

  return b;
}
ll LCM(ll a, ll b) {

  ll r, x, tmp;
  ll i, j;
  ll lcm;
  i = a;
  j = b;

  /* 自然数 a > b を確認・入替 */
  if (a < b) {
    tmp = a;
    a = b;
    b = tmp;
  }

  /* ユークリッドの互除法 */
  r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  lcm = (i / b) * j;

  return lcm;
}
ll checkTen(ll a) {
  ll ans = 0;
  while (true) {
    ans++;
    if ((a / 10) % 10 != 0) {
      break;
    }
    a = a / 10;
  }
  return ans;
}
ll checkFive(ll a) {
  ll ans = 0;
  while (true) {
    ans++;
    if ((a / 5) % 5 != 0) {
      break;
    }
    a = a / 5;
  }
  return ans;
}
ll checkTwo(ll a) {
  ll ans = 0;
  while (true) {
    ans++;
    if ((a / 2) % 2 != 0) {
      break;
    }
    a = a / 2;
  }
  return ans;
}
ll checkf(ll a) {
  ll ans = 0;
  while (true) {
    ans++;
    if ((a / 10) % 10 != 0) {
      break;
    }
    a = a / 10;
  }
  return a;
}
int main() {
  ll L, R;
  ll Min = 2019;
  cin >> L >> R;
  for (ll i = L; i < R; i++) {
    for (ll j = L + 1; j <= R; j++) {
      Min = min(Min, (i * j) % 2019);
      if (Min == 0) {
        cout << Min << endl;
        return 0;
      }
    }
  }
  cout << Min << endl;
}