akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
vector<long long> N;
map<pair<long long, long long>, long long> memo;
long long pow_mod(long long a, long long b) {
    if (b == 0) return 1;
    if (memo.find(make_pair(a, b)) != memo.end()) return memo[make_pair(a, b)];
    long long k = pow_mod(a, b/2);
    long long kk = (k * k) % mod;
    if (b & 1) {
        return memo[make_pair(a, b)] = (kk * a) % mod;
    }
    return memo[make_pair(a, b)] = kk;
}
long long nCr (long long n, long long r) {
    if (r == 0 || r == n) {
        return 1;
    }
    if (r < 0 || r > n) {
        return 0;
    }
    long long res = N[n];
    res *= pow_mod(N[r], mod-2);
    res %= mod;
    res *= pow_mod(N[n-r], mod-2);
    res %= mod;
    return res;
}
int main () {
    int n, k;
    cin >> n >> k;
    N.push_back(1);
    for (int i = 1; i < n; i++) {
        N.push_back((N.back() * i) % mod);
    }
    vector<int> A(n);
    map<int, int> mp, mm;
    for (int i = 0; i < n; i++) {
        cin >> A[i];
        mp[+A[i]]++;
        mm[-A[i]]++;
    }
    long long ans = 0;
    long long l = 0;
    for (auto x: mp) {
        for (int i = min(1LL, max(1LL, k-l)); i <= x.second && k-i >= 0; i++) {
            ans += ((nCr(l, k-i)*nCr(x.second, i)) % mod * x.first) % mod;
            ans %= mod;
        }
        l += x.second;
    }
    l = 0;
    for (auto x: mm) {
        for (int i = min(1LL, max(1LL, k-l)); i <= x.second && k-i >= 0; i++) {
            ans += ((nCr(l, k-i)*nCr(x.second, i)) % mod * x.first) % mod;
            ans %= mod;
        }
        l += x.second;
    }
    cout << ans << endl;
}

Measured memory_bytes: 101492
H, N = map(int, input().split())

magic = [list(map(int, input().split())) for _ in range(N)]
inf = float('inf')
dp = [inf] * (H + 1)
dp[0] = 0
for i in range(H):
    if dp[i] == inf:
        continue
    currCost = dp[i]
    for dmg, cost in magic:
        totalDmg = i + dmg
        if totalDmg > H:
            totalDmg = H
        totalCost = currCost + cost
        if totalCost < dp[totalDmg]:
            dp[totalDmg] = totalCost
print(dp[H])

Measured memory_bytes: 43100
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(x) push_back(x)
#define f(i,st,n) for(i=st;i<n;i++)
#define qu queue
#define ps(x) push(x)
#define vec vector
#define ft() front()
#define mst(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define sfl(x) scanf("%lld",&x)
#define pfl(x) printf("%lld\n",x)
#define pf(x) printf("%lld",x)
#define mpr make_pair
#define fs first
#define se second
 
 
 
 
ll gcd(ll a,ll b){
    if(a==0){
        return b;
    }                     
    return gcd(b%a,a);
}
ll power(ll x,ll y){            
    ll res=1;
    while(y>0){
        if(y%2==1){
            res=(res*x);
        }
        x=(x*x);
        y=y/2;
    }
    return res;
}
 
 
int main(){
 
 /*#ifndef ONLINE_JUDGE
    
   freopen("input.txt", "r", stdin);
   
   freopen("output.txt", "w", stdout);
   #endif*/
   
ll n,i,k,j;
sfl(n);sfl(k);
ll a[n];
f(i,0,n)sfl(a[i]);

vec<ll>dp(n,LLONG_MAX);
dp[0]=0;

f(i,0,n){
  for(j=1;j<=k;j++){
   if(i+j<n){
    dp[i+j]=min(dp[i+j],dp[i]+abs(a[i+j]-a[i]));
   }

  }

}

cout<<dp[n-1];

 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
   return 0;
 }

Measured memory_bytes: 1792
L , n = map(int, input().split())
a = [int(input()) for i in range(n)]


psumL = [0 for i in range(n + 2)]
for i in range(n) :
    psumL[i + 1] = psumL[i] + a[i];
psumR = [0 for i in range(n + 2)]
for i in range(n) :
    psumR[n - i] = psumR[n - i + 1] + L - a[n - i - 1];


ans = max(a[n - 1], L - a[0])
for useL in range(1, n) :
    useR = n - useL
    if (useL == useR) : 
        ans = max(ans, 2 * (psumL[useL] + psumR[n - useR + 1]) - min(a[useL  - 1], L - a[n - useR]))
    if (useL > useR) : 
        skipL = useL - useR 
        ans = max(ans, 2 * (psumL[useL] - psumL[skipL] + psumR[n - useR + 1]) - (L - a[n - useR]))
        ans = max(ans, 2 * (psumL[useL] - psumL[skipL - 1] + psumR[n - useR + 1]) - a[useL - 1])
    if (useR > useL) :
        skipR = useR - useL
        #print(psumR[n - useR + 1] - psumR[n - skipR + 1], psumL[useL])
        ans = max(ans, 2 * (psumL[useL] + psumR[n - useR + 1] - psumR[n - skipR + 1]) - a[useL - 1])
        ans = max(ans, 2 * (psumL[useL] + psumR[n - useR + 1] - psumR[n - skipR + 2]) - (L - a[n - useR]))

print(ans)




Measured memory_bytes: 28436
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <bitset>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(int argc, const char * argv[]) {
    int N; cin >> N;
    vector<int> X(N, 0);
    double avg = 0.0;
    for (int i = 0; i < N; i++) {
        cin >> X[i];
        avg += X[i];
    }
    avg /= (double)N;

    int t1 = 0, t2 = 0;
    for (int i = 0; i < N; i++) {
        t1 += (floor(avg) - X[i]) * (floor(avg) - X[i]);
        t2 += (ceil(avg) - X[i]) * (ceil(avg) - X[i]);
    }
    cout << min(t1, t2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include <algorithm>

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

int main(){
int X,A,B;
cin >> X >> A >> B;

cout << (X - A) % B << endl;


return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long llu;

int main(int argc, char *argv[]) {
  ll n, k;
  cin >> n >> k;

  // a+b, b+c, c+aがKで割り切れるとき
  // a+b, b+c, c+aはKの倍数である
  //
  // a+bでみたとき
  // (a % K) + (b % K) = 0 or Kとなる
  // なのでa ≡ b ≡ 0 or K/2 (mod K)となる
  // e.g. 
  //   K = 2
  //   a = 2, b = 2のとき
  //   a % K = 0
  //   b % K = 0
  //
  //   K = 2
  //   a = 3, b = 3のとき 
  //   a % K = 1
  //   b % K = 1
  //
  // あらためて
  // a+b ≡ b+c ≡ c+a ≡ 0 (mod K)なので
  // a+b ≡ b+c (mod K)をみたとき
  // a ≡ c (mod K)となる
  // 同じようにしてa ≡ b ≡ c (mod K)
  // なのでa ≡ b ≡ c ≡ 0 or K/2 (mod K)となる
  //
  // 1つずつ順番に
  // a ≡ b ≡ c ≡ 0 (mod K)
  // a ≡ b ≡ c ≡ K/2 (mod K)
  // となる値を調べて結果を3乗（重複順列）する
  ll zero = 0, khalf = 0;
  for (ll i = 1; i <= n; ++i) {
    if (k % 2 == 0) {
      // 偶数のとき
      if (i%k == 0) zero++;
      else if (i%k == k/2) khalf++;
    } else {
      // 奇数のとき
      // 整数という制約があるので、k/2は小数点になるので考えない
      if (i%k == 0) ++zero;
    }
  }

  cout << zero*zero*zero + khalf*khalf*khalf << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
ll n;
cin >> n;
vector<ll> a(n);
for(ll i=0;i<n; i++)cin >> a[i];
ll b[200005]={0};
for(ll i=0;i<n; i++) b[a[i]]++;
ll ans = 0;
for(ll i=0;i<200005; i++) {
   ll m = b[i];
   if(m>=2) ans += m*(m-1) / 2;
}
for(ll i=0;i<n; i++){
   ll sum = ans;
   sum -= b[a[i]]-1;
cout << sum << endl;
}
 return 0;
}

Measured memory_bytes: 6404
import Control.Applicative
import Control.Monad
import Text.Printf

eval [a, b, c]
    | b == "+" = show $ numA + numC
    | b == "/" = show $ numA `div` numC
    | b == "-" = show $ numA - numC
    | b == "*" = show $ numA * numC
    | b == "?" = "" 
    | otherwise = ""
    where
        numA = read a
        numC = read c

main = do
    line <- (map (eval . words)) . takeWhile (notElem '?') . lines <$> getContents
    mapM_ putStrLn line 



Measured memory_bytes: 4104
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <deque>
using namespace std;

int const DX[4] = { -1, 1, 0, 0 };
int const DY[4] = { 0, 0, -1, 1 };

char s[2048][2048], nnew[2048][2048];
int dst[2048][2048];
deque<pair<int, int> > q;

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		string st;
		cin >> st;
		for (int j = 0; j < m; j++) {
			nnew[i][j] = 0;
			s[i][j] = st[j];
			if (s[i][j] == '#') q.push_back(make_pair(i, j));
		}
	}
	while (!q.empty()) {
		int x = q[0].first;
		int y = q[0].second;
		q.pop_front();
		for (int k = 0; k < 4; k++) {
			int xx = x + DX[k];
			int yy = y + DY[k];
			if (xx >= 0 && yy >= 0 && xx < n && yy < m && s[xx][yy] == '.' && !nnew[xx][yy]) {
				nnew[xx][yy] = 1;
				dst[xx][yy] = dst[x][y] + 1;
				q.push_back(make_pair(xx, yy));
			}
		}
	}
	int mx = 0;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			mx = max(mx, dst[i][j]);
	cout << mx;
	return 0;
}


Measured memory_bytes: 17664
//#define _GLIBCXX_DEBUG//実行時、何も出なかったらこれを使う
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>
#include<climits>
#include<limits>//
#include <stdio.h>//
#include<cmath>
#include<iomanip>

using namespace std;

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

typedef long long ll;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

int dy[] = {1,0,-1,0}; //次に行くところ
int dx[] = {0,1,0,-1}; //s上に同じ

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll a,b,c,d;
  cin >> a >> b >> c >> d;

  cout << max({a*c,a*d,b*c,b*d}) << '\n';

  return 0;
}

Measured memory_bytes: 3644
#include<iostream>
using namespace std;
#define lli long long int
#include<bits/stdc++.h>
int main(){
  lli s,i=1,j;
  cin>>s;
  vector<lli>v(1000000);
  v[0]=s;
  map<lli,lli>m;
  m[s]++;
  while(1){
    if(v[i-1]%2==0){
      v[i]=v[i-1]/2;
      m[v[i]]++;
      if(m[v[i]]==2){
        cout<<i+1;
        return 0;
      }
    }
    else{
      v[i]=3*v[i-1]+1;
      m[v[i]]++;
      if(m[v[i]]==2){
        cout<<i+1;
        return 0;
      }
    }
    i++;
  }
  return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
int c[100005];
int main()
{
  int n,i,q;
  cin>>n>>q;
  string s;
  cin>>s;
  int l[q],r[q];
  for(i=0;i<q;i++)
  {
    cin>>l[i]>>r[i];
  }
  for(i=1;i<n;i++)
  {
    if(s[i-1]=='A' && s[i]=='C') c[i]++;
    c[i]+=c[i-1];
  }
  c[n]+=c[n-1];
  for(i=0;i<q;i++)
  {
    cout<<c[r[i]-1]-c[l[i]-1]<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 2176
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int n, x;

            while (true) {
                int cnt = 0;
                n = sc.nextInt();
                x = sc.nextInt();

                if (n == 0 && x == 0) break;

                for (int i = 1; i <= n; i++) {
                    for (int j = i + 1; j <= n; j++) {
                        for (int k = j + 1; k <= n; k++) {
                            if (i + j + k == x) cnt++;
                        }
                    }
                }
                System.out.println(cnt);
            }
        }
    }
}


Measured memory_bytes: 26528
#include<bits/stdc++.h>

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll inf = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

const int N = 105, W = 1e5 + 5;
ll w[N], v[N];
ll dp[W][N];
int n;

ll sol(int idx, int tot) {
    if(tot < 0) return -1e17;

    if(idx == n) return 0;

    ll &ret = dp[tot][idx];

    if(ret != -1) return ret;

    return ret = max(ret, max(sol(idx + 1, tot), sol(idx + 1, tot - w[idx]) + v[idx]));
}

int main(){
    fIO

    memset(dp, -1, sizeof(dp));

    int maxW;
    cin >> n >> maxW;
    for(int i = 0; i < n; i++) cin >> w[i] >> v[i];

    cout << sol(0, maxW);
}








Measured memory_bytes: 82304
#include <stdio.h>

int main(void)
{
	int sx, sy, tx, ty;
	int cnt;

	scanf("%d %d %d %d", &sx, &sy, &tx, &ty);

	for (cnt = 0; cnt < (tx - sx); cnt++) {
		putchar('R');
	}
	for (cnt = 0; cnt < (ty - sy); cnt++) {
		putchar('U');
	}

	for (cnt = 0; cnt < (tx - sx); cnt++) {
		putchar('L');
	}
	for (cnt = 0; cnt < (ty - sy); cnt++) {
		putchar('D');
	}

	putchar('D');
	for (cnt = 0; cnt < (tx - sx + 1); cnt++) {
		putchar('R');
	}
	for (cnt = 0; cnt < (ty - sy + 1); cnt++) {
		putchar('U');
	}
	putchar('L');

	putchar('U');
	for (cnt = 0; cnt < (tx - sx + 1); cnt++) {
		putchar('L');
	}
	for (cnt = 0; cnt < (ty - sy + 1); cnt++) {
		putchar('D');
	}
	putchar('R');

	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;



void solve()
{
    ll x, y;
    scanf("%lld%lld", &x, &y);
    if (abs(x-y)<=1) {
        printf("Brown\n");
    }
    else {
        printf("Alice\n");
    }

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const double pi = acos(-1);

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

    for(ll i = 1000; i <= 10000; i += 1000) {
        if(i >= n) {
            out(i - n);
            re0;
        }
    }
    
    re0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a,b,c,d,tmp[ohara],tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>s>>x>>y;
    bitset<8000*2+100> dpx;
    bitset<8000*2+100> dpy;
    dpx[8000]=true;
    dpy[8000]=true;
    ll cntt=0;
    ll xqu=true;
    ll spe=0;
    rep(i,Size(s)){
        if(s[i]=='T'){
            b=0;
            if(xqu){
                if(s[0]=='F'&&spe==0)dpx=(dpx<<cnt);
                else dpx=(dpx<<cnt)|(dpx>>cnt);
            }
            else{
                dpy=(dpy<<cnt)|(dpy>>cnt);
            }
            while(1){
                if(s[i]=='T')b++;
                else break;
                i++;
                if(i==Size(s)-1)break;
            }
            i--;
            if(b%2==1){
                if(xqu)xqu=false;
                else xqu=true;
            }
            cnt=0;
            spe=1;
        }
        else cnt++;
    }
     b=0;
    if(xqu){
        if(s[0]=='F'&&spe==0)dpx=(dpx<<cnt);
        else dpx=(dpx<<cnt)|(dpx>>cnt);
    }
    else{
        dpy=(dpy<<cnt)|(dpy>>cnt);
    }
    if(dpx[8000+x]&&dpy[8000+y])Cout("Yes");
    else Cout("No");
    return 0;
}


Measured memory_bytes: 256
DBG = !true
R = 1000000007
h,w,k = gets.split.map{|x| x.to_i}
printf("h:%d w:%d k:%d\n", h, w, k) if DBG

if w == 1
  print 1
  exit
end

f = [1, 1, 2, 3, 5, 8, 13, 21]
p = []
p << Array.new(w,0)
p[0][0] = 1

for y in 1..(h)
  if DBG
    print "y:#{y-1} "
    print p[y-1]
    print "\n"
  end
  p << Array.new(w,0)
  p[y][0] = (p[y-1][0]*f[w-1] + p[y-1][1]*f[w-2]) % R
  for i in 1..(w-2)
    p[y][i] = (p[y-1][i-1]*f[i-1]*f[w-i-1] + p[y-1][i]*f[i]*f[w-i-1] +
               p[y-1][i+1]*f[i]*f[w-i-2]) % R
  end
  p[y][w-1] = (p[y-1][w-2]*f[w-2] + p[y-1][w-1]*f[w-1]) % R
end

if DBG
  print "y:#{h} "
  print p[h]
  print "\n"
end
print p[h][k-1]


Measured memory_bytes: 1788
#include<stdio.h>
int main()
{
	int A,B;
	scanf("%d %d",&A,&B);
	if(A==1) A=14;
	if(B==1) B=14;
	if(A==B){
		printf("Draw");
		}else if(A>B){
			printf("Alice");
			}else{
				printf("Bob");
			}
	return 0;
		}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
const double PI = acos(-1.0);
const long mod = 1000000007;
const long INF = 1e9 + 1;

int main() { 
  string s;
  cin >> s;
  int n = s.size();
  if(n == 1) {
    cout << s << endl;
    return 0;
  }
  long sum = 0;

  for(int bit = 0; bit < (1 << n-1); bit++) {
    int cnt = 0;
    for(int i = 0; i < n-1; i++) {
      sum += (s[n-1-i] - '0') * pow(10,cnt);
      if(bit & (1 << i)) {
        cnt = 0;
        if(i == n-2) sum += (s[0] - '0');
      }
      else {
        cnt++;
        if(i == n-2) sum += (s[0] - '0') * pow(10,cnt);
      }
    }
  }
  
  cout << sum << endl;
}


Measured memory_bytes: 4036
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let (l, r) = get!(usize, usize);
    if r - l == 1 {
        println!("{}", (r * l) % 2019);
        return;
    }
    let mut min = 2020;
    for i in l..r + 1 {
        for j in l..r + 1 {
            if j <= i {
                //eprintln!("j <= i, j: {}, i: {}", j, i);
                continue;
            }
            //eprintln!("i: {}, j: {}", i, j);
            let t = (i * j) % 2019;
            if t < min {
                min = t;
            }
            if min == 0 {
                println!("{}", min);
                return;
            }
        }
    }
    println!("{}", min);
}


Measured memory_bytes: 4352
//It doesn't matter as long as you rise to the top - Katsuki Bakugo
#include<bits/stdc++.h>
using namespace std;
     
     
#define Fast_as_duck ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back 
#define forn(i,st,n) for(int i = st; i < n ; i++)
#define rev(i,st,n) for(int i = st; i >= n ; i--)
#define ss second
#define ff first
#define ll long long 

typedef pair <int , int> pii;

const int N = 1e5 + 10 , mod =  1000000007;

void solve(){

   
    string str; cin >> str;
    int ans = 0;
    int r = 0;
    forn(i,0,3){
        if(str[i] == 'R'){
            r++;
        }else r = 0;
        if(r > ans)ans = r;
    }


    
    cout << ans << "\n";

    
    
        


}

int main(){
    Fast_as_duck;

/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
*/
    int t = 1; 
    
    // cin >> t;
    

    while(t--){
        solve();
    }




    return 0;
}
      
       


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;

int main(){
	int a[10];
	while(scanf("%d",&a[0]),a[0]){
		for(int i=1;i<10;i++)scanf("%d",&a[i]);
		int sum=0;
		for(int i=1;i<10;i++)sum+=a[i];
		printf("%d\n",a[0]-sum);
	}
}

Measured memory_bytes: 1188
N = int(input())
A = list(map(int,input().split()))

import math

flag = 0
count = 0
while flag == 0:
    for n in range(N):
        A[n] = A[n]/2
        if math.modf(A[n])[0] != 0:
            flag = 1
            break
    if flag ==0:
        count += 1
        
print(count)

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);

	long x, y,i = 0;
	cin >> x >> y;
	while (true) {
		if ((long long)pow(2,i) * x > y)break;
		i ++;
	}
	cout << i << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        int[] n = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        Console.WriteLine(
            n[0] + n[1] == n[2] + n[3] ? "Balanced" :
            n[0] + n[1] > n[2] + n[3] ? "Left" : "Right"
            );
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
#define LL long long int 
#define LD long double
#define PI 3.14159265358979323846
#define MOD ((LL)1e9+7)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const LL N=1e5+10;
LL A[N][3];
LL dp[N][3];
LL n;
int main()
{
	IOS
	cin>>n;
	for(LL i=0;i<n;i++)
	{
		for(LL j=0;j<3;j++)
		cin>>A[i][j];
	}
	
	dp[0][0]=A[0][0];
	dp[0][1]=A[0][1];
	dp[0][2]=A[0][2];
	
	for(LL i=1;i<n;i++)
	{
		for(LL j=0;j<3;j++)
		{
			dp[i][j]+=A[i][j]+max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3]);
		}
	}
	cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
}
	
			
				
			
	
	
	
			
		



Measured memory_bytes: 4992
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

const int maxn = 2e5 + 5;

int a[maxn];

int main(){
    int n;
    while(cin >> n){
        long long x = 0,y = 0;
        for(int i = 1;i <= n;i++){
            scanf("%d",a + i);
            y += a[i];
        }
        long long ans = 1e18;

        for(int i = 1;i <= n;i++){
            if(i > 1)ans = min(ans,abs(x - y ));
            x += a[i];
            y -= a[i];
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;

int gcd(int x, int y, int z) {
    int r;
    if (x < y) {
        swap(x, y);
    }

    while (y > 0) {
        r = x % y;
        x = y;
        y = r;
    }
    
    if (x < z) {
        swap(x, z);
    }

    while (z > 0) {
        int s = x % z;
        x = z;
        z = s;
    }
    return x;
}

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

    int sum = 0;

    for (int i = 1; i <= k; i++) {
        for (int j = 1; j <= k; j++) {
            for (int l = 1; l <= k; l++) {
                sum += gcd(i, j, l);
            }
        }
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3636
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

x,y = ism()

if x<y:
    print('<')
elif y<x:
    print('>')
else:
    print('=')

Measured memory_bytes: 3064
fun main(args: Array<String>) {
    val (n, a, b, c) = readLine()!!.split(' ').map { it.toInt() }
    val ls = (0 until n).map { readLine()!!.toInt() }
    println(Solver(n, a, b, c ,ls).solve())
}

private class Solver(val N: Int, val A: Int, val B: Int, val C: Int, val ls: List<Int>) {

    fun solve(): Int {
        return dfs(0, 0, 0, 0)
    }

    fun dfs(cur: Int, a: Int, b: Int, c: Int): Int {
        if (cur == N) {
            return if (listOf(a, b, c).min()!! > 0) {
                Math.abs(a - A) + Math.abs(b - B) + Math.abs(c - C) - 30
            } else {
                1000000000
            }
        }

        val r0 = dfs(cur + 1, a, b, c)
        val r1 = dfs(cur + 1, a + ls[cur], b, c) + 10
        val r2 = dfs(cur + 1, a, b + ls[cur], c) + 10
        val r3 = dfs(cur + 1, a, b, c + ls[cur]) + 10

        return listOf(r0, r1, r2, r3).min()!!
    }

}

Measured memory_bytes: 47276
n, m = gets.split(" ").map(&:to_i)
line = m.times.map{gets.split(" ")}
keys = {}
n.times do |i|
  keys["#{i+1}"] = 0
end

success = {}
fail_c = 0

line.each do |l|

  if l[1] == "AC"
    unless success.has_key?(l[0])
      success["#{l[0]}"] = "ok"
      fail_c += keys["#{l[0]}"]
    end
  else
      keys["#{l[0]}"] += 1
  end

end

success_c = success.length

puts("#{success_c} #{fail_c}")

Measured memory_bytes: 50556
#include<stdio.h>
#include<iostream>
#include<algorithm> // sort(ALL())
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue> // push(), front(), pop() 先入れ先出し
#include<map> // 連想配列 map<string, int>
#include<iomanip>
#include<set>
#include<utility>
#include<limits>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<(b);  i++)
#define REP(i, n)    for(int i=0;   i<(n);  i++)
#define REP1(i, n)   for(int i=1;   i<=(n); i++)
#define pb push_back
#define mp make_pair
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define EPS 1e-7
#define ALL(obj) (obj).begin(), (obj).end()
using ul    = unsigned long;
using ll    = long long;
using ull   = unsigned long long;
using ld    = long double;
using vint  = vector<int>;
using vll   = vector<ll>;
using pint  = pair<int, int>;
using pll   = pair<ll, ll>;
using vpint = vector<pint>;
using vpll  = vector<pll>;
const int INF = (int)1e9 + 1;
const int MOD = (int)1e9 + 7;
#define INT(argu) (int)(argu+EPS)

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

  ll s;
  scan(s);

  if(s%2!=0) cout << 0 << endl;
  else{
    ll ans = 0;
    s /= 2;
    for(;;){
      s /= 5;
      ans += s;
      if(s<5) break;
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

ll dp[51][51][3000]; // dp[i][j][k] := x[0]...x[i-1]からj個選んだ合計がk

int main(){
    int N; cin >> N;
    int A; cin >> A;
    vi x(N); rep(i,N) cin >> x[i];

    dp[0][0][0] = 1;
    for(int i=0;i<N;i++){
        for(int j=0;j<=i;j++){
            for(int k=0;k<=2500;k++){
                // select x[i]
                dp[i+1][j+1][k+x[i]] += dp[i][j][k];
                // no select x[i]
                dp[i+1][j][k] += dp[i][j][k];
            }
        }
    }

    ll ans = 0;
    for(int i=1;i<=N;i++){
        ans += dp[N][i][i*A];
    }
    cout << ans << endl;
}

Measured memory_bytes: 59136
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define MOD 100000
int main()
{
	int n,m;
	cin >> n >> m;
	int dist[100010];
	dist[1]=0;
	for(int i=2;i<=n;i++)
	{
		cin >> dist[i];
	}
	for(int i=2;i<=n;i++)
	{
		dist[i]+=dist[i-1];
	}
	int now=1;
	ll ans=0;
	for(int i=0;i<m;i++)
	{
		int k;
		cin >> k;
		ans+=abs(dist[now]-dist[now+k]);
		now+=k;
	}
	cout << ans%MOD << endl;
	return 0;
}

Measured memory_bytes: 1548
import sys

def solve():
    N = int(input())
    ans = 800 * N - 200 * (N // 15)
    print(ans)
    
def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None


if __name__ == '__main__':
    solve()

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>

int main()
{
    int n, shuffle;
    char str[500];
    char tmp;
    
    while (true){
        for (int i = 0; i < 500; i++){
            str[i] = '\0';
        }

        scanf(" %s", str);
        if (!strcmp(str, "-")){
            break;
        }

        scanf(" %d", &n);
        for (int i = 0; i < n; i++){
            scanf(" %d", &shuffle);
            for (int j = 0; j < shuffle; j++){
                tmp = str[0];
                for (int k = 0; k < strlen(str) - 1; k++){
                    str[k] = str[k+1];
                }
                str[strlen(str)-1] = tmp;
            }
        }

        printf("%s\n", str);
    }

    return 0;
}
                    


Measured memory_bytes: 2600
#include <cstdio>
int f[1000001],a[1000001];
int main()
{
	int ans=0,n=0;
	scanf("%d",&n);
	for (int i=1;i<=n;++i)	scanf("%d",&a[i]);
	f[0]=-1,ans=0;
	for(int i=n;i>=1;--i){
		if(f[ans]<=a[i])	f[++ans]=a[i];
		else{
			int l=0,r=ans;
			while(l<r){
				int mid=(l+r)/2;
				if(f[mid]>a[i])	r=mid;
				else	l=mid+1;
			}
			f[l]=a[i];
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 4608
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#define ll long long
//vector<int> g1;
//g1.push_back(i);

using namespace std;

int main()
{
	ll a;
	cin >> a;
	vector <int> prime;
	prime.push_back(2);
	if (a==2) cout << 2;
	else
	{
	bool notprime;
	for (int i=3;i<a;i++)
	{
		notprime = false;
		for (int j=0;j<prime.size();j++)
		{
			if(i%prime[j]==0)
			{
				notprime = true;
				break;
			}
		}
		if(notprime == false)
		{
			prime.push_back(i);
		}
	}
	int otpt = a;
	while(1)
	{
		notprime = false;
		for (int j=0;j<prime.size();j++)
		{
			if(otpt%prime[j]==0)
			{
				notprime = true;
				break;
			}
		}
		if(notprime == false)
		{
			cout << otpt;
			return 0;
		}
		otpt++;
	}
	}
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mk make_pair
#define all(a) a.begin(), a.end()
#define len(a) (int)a.size()

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef pair <int, int> pii;

int main(){
	int n;
	cin >> n;
	cout << (n % 1000 != 0 ? 1000 - n % 1000 : 0) << endl;
	
	return 0;
}


Measured memory_bytes: 3628
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // fixed, setprecision 
#include <math.h> // double sqrt
#define rep(i,n) for(int i=0;i<(n);++i)
#define ll long long
using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int>a(n+1);
    rep(i,n)cin>>a[i];
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    int ans=0;
    for(int i=0;i<n;i+=2){
        ans+=a[i]-a[i+1];
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3192
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){

	int n;
	cin>>n;
	int nums[10];
	char colors[10];
	for(int i = 0; i < n; i++){
		//vector<int> R,G,B;
		int R[10];
		int G[10];
		int B[10];
		for(int i = 0; i < 10; i++){
			R[i]=G[i]=B[i]=0;
		}

		int rsize=0;
		int gsize=0;
		int bsize=0;
		for(int j = 0; j < 9; j++)
			cin>>nums[j];
		for(int j = 0; j < 9; j++){
			cin>>colors[j];
			if(colors[j]=='R'){
				R[nums[j]]++;
				rsize++;
			}
			else if(colors[j]=='G'){
				G[nums[j]]++;
				gsize++;
			}
			else if(colors[j]=='B'){
				B[nums[j]]++;
				bsize++;
			}
		}
		if(rsize%3!=0||gsize%3!=0||bsize%3!=0){
			cout<<0<<endl;
		}
		else{
			bool f=false;
			while(1){
				if(rsize==0)
					break;
				for(int i = 1; i < 10; i++){
					if(R[i]!=0){
						// ツ督ッツつカツカツーツド
						if(R[i]>=3){
							R[i]-=3;
							rsize-=3;
							break;
						}
						else if(i<=7&&R[i]!=0&&R[i+1]!=0&&R[i+2]!=0){
							R[i]--;
							R[i+1]--;
							R[i+2]--;
							rsize-=3;
							break;
						}
						else{
							f=true;
							break;
						}
					}
				}
				if(f)
					break;
			}
			while(1){
				if(gsize==0)
					break;
				for(int i = 1; i < 10; i++){
					if(G[i]!=0){
						// ツ督ッツつカツカツーツド
						if(G[i]>=3){
							G[i]-=3;
							gsize-=3;
							break;
						}
						else if(i<=7&&G[i]!=0&&G[i+1]!=0&&G[i+2]!=0){
							G[i]--;
							G[i+1]--;
							G[i+2]--;
							gsize-=3;
							break;
						}
						else{
							f=true;
							break;
						}
					}
				}
				if(f)
					break;
			}
			while(1){
				if(bsize==0)
					break;
				for(int i = 1; i < 10; i++){
					if(B[i]!=0){
						// ツ督ッツつカツカツーツド
						if(B[i]>=3){
							B[i]-=3;
							bsize-=3;
							break;
						}
						else if(i<=7&&B[i]!=0&&B[i+1]!=0&&B[i+2]!=0){
							B[i]--;
							B[i+1]--;
							B[i+2]--;
							bsize-=3;
							break;
						}
						else{
							f=true;
							break;
						}
					}
				}
					if(f)
						break;
			}


			if(!f){
				cout<<1<<endl;
			}
			else
				cout<<0<<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    int a, b;
    char s;
    cin >> a >> s >> b;
    if(s == '+'){
        cout << a + b;
    }
    else
    {
        cout << a -b;
    }
    cout << endl;
}


Measured memory_bytes: 256
import heapq
n = int(input())
a = list(map(int, input().split()))
p = [0] * (n + 1)
hq = a[:n]
heapq.heapify(hq)
for i in range(n, 2 * n):
    heapq.heappush(hq, a[i])
    p[i + 1 - n] = heapq.heappop(hq) + p[i - n]
q = [0] * (n + 1)
hq = list(map(lambda x: -x, a[2 * n:]))
heapq.heapify(hq)
for i in range(2 * n, n, -1):
    heapq.heappush(hq, -a[i - 1])
    q[i - 1 - n] = -heapq.heappop(hq) + q[i - n]
s = sum(a[:n])
t = sum(a[n:])
ans = -float('inf')
for i in range(n + 1):
    ans = max(ans, s - t + q[i] - p[i])
    s += a[n + i]
    t -= a[n + i]
print(ans)


Measured memory_bytes: 119952
#include <cstdio>
using namespace std;

int main() {
  int P, Q, R;
  scanf("%d %d %d", &P, &Q, &R);
  int m = P;
  if (m < Q) m = Q;
  if (m < R) m = R;
  printf("%d\n", P+Q+R-m);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define _GLIBCXX_DEBUG
static const int MAX = 100;

int main(){
  int N, W[MAX], sum = 0, s1 = 0, ans = 100000;
  cin >> N;
  rep(i, N) {
    cin >> W[i];
    sum += W[i];
  }
  rep(i, N){
    s1 += W[i];
    ans = min(ans, abs(s1 - (sum - s1)));
  }
  
cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  int s = 12.5*a+0.5;
  int p = 10*b;
  int q = 12.5*(a+1)-0.5;
  int r = 10*(b+1)-1;
  int x;
  if(q<p||r<s){
    cout << -1 << endl;
  }
  else if(p<=q&&s<=p){
    cout << p << endl;
  }
  else if(s<=p&&r<=q){
    cout << p << endl;
  }
  else{
    cout << s << endl;
  }

 
   

  }

Measured memory_bytes: 256
#include <iostream>
#include <vector>

#define MAX 100005

using namespace std;

int main()
{
	int N;
	vector<int> a(MAX);
	int now;
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> a[i];
	}
	
	int flag = 0;
	int count = 0;
	now = 1;
	for (int i = 1; i <= N; i++) {
		if (now == 2) {
			flag = 1;
			break;
		}
		now = a[now];	//オス
		count++;
	}

	if (flag) cout << count << endl;
	else cout << -1 << endl;
	
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define VI vector<int>
#define PII pair<int, int>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30; const ll LINF=1LL<<60 ; const ll MOD=1e9+7 ;
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 (b<a) { a = b; return 1; } return 0; }
//-------------------
ll l,r;
ll NUM = 2019;

int main(){
	cin >> l >> r;
	if(r-l > NUM) cout << 0 << endl;
	else{
		ll ans = LINF;
		FOR(i,l,r-1){
			FOR(j,i+1,r){
				ans = min(ans, ((i%NUM)*(j%NUM))%NUM);
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;

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


// std::vector Declaration
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
   return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// std::vector Initialization
template<typename T>
void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U>
void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
   os << "[";
   bool a = 1;
   for (auto e : v ) {
      os << (a ? "" : " "); 
      os << e;
      a = 0;
   }
   os << "]";
   return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
   os << "(" << p.first << " " << p.second << ")";
   return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
   os << "{";
   bool a = 1;
   for (auto e : st) {
      os << (a ? "" : " ");
      os << e;
      a = 0;
   }
   os << "}";
   return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
   os << "{";
   bool a = 1;
   for (auto e : mp) {
      os << (a ? "" : " ");
      os << e.first << ":" << e.second;
      a = 0;
   }
   os << "}";
   return os;
}

// std::tuple Debug
template<int N,class Tuple>
void out(ostream &os,const Tuple &t){}
template<int N,class Tuple,class H,class ...Ts>
void out(ostream &os,const Tuple &t){
   if(N)os<<" ";
   os<<get<N>(t);
   out<N+1,Tuple,Ts...>(os,t);
}
template<class ...Ts>
ostream& operator<<(ostream &os, const tuple<Ts...> &t){
   os<<"(";
   out<0,tuple<Ts...>,Ts...>(os,t);
   os<<")";
   return os;
}

// Debug
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl

struct edge { int to, cost; };

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;

int main()
{
   int N; cin >> N;
   LL K; cin >> K;
   vector<LL> A(N);
   for (int i = 0; i < N; ++i) {
      cin >> A[i];
   }

   const int SIZE = 40;
   auto dp = make_v<LL>(SIZE+1, 2);
   fill_all(dp, -1LL);
   dp[0][0] = 0;

   for (int k = 0; k < SIZE; ++k) {
      LL mask = 1LL << (SIZE-1-k);

      int cnt = 0;
      for (int i = 0; i < N; ++i) {
         if (A[i] & mask) ++cnt;
      }

      LL score0 = cnt * mask;
      LL score1 = (N-cnt) * mask;

      if (K & mask) {
         chmax(dp[k+1][0], dp[k][0] + score1);
         if (dp[k][1] != -1) {
            chmax(dp[k+1][1], dp[k][1] + max(score0, score1));
         }
         chmax(dp[k+1][1], dp[k][0] + score0);
      } else {
         chmax(dp[k+1][0], dp[k][0] + score0);
         if (dp[k][1] != -1) {
            chmax(dp[k+1][1], dp[k][1] + max(score0, score1));
         }
      }

   }

   cout << max(dp[SIZE][0], dp[SIZE][1]) << endl;

   return 0;
}


Measured memory_bytes: 1152
//q095.cpp
//Tue Sep 15 20:18:23 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	ll a,b,k;
	cin >> a >> b >> k;

	if (a>=k){
		cout << a-k << " " << b << endl;
	}else if (a+b>=k){
		cout << 0 << " " << a+b-k << endl;
	}else {
		cout << 0 << " " << 0 <<  endl;
	}
}

Measured memory_bytes: 3592
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.IO.Pipes;
using System.Linq;
using System.Windows.Markup;

namespace AtCoder
{
	public class ABC
	{
		static public void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			Solve(args);
			Console.Out.Flush();
		}

		private const int mod = 1000000007;  // 10^9+7

		static public void Solve(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			//string s = Console.ReadLine();
			//long x = long.Parse(Console.ReadLine());
			//int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
			long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();

			long ans = 1;
			double log = 0;
			for (int i = 0; i < n; i++) {
				if (a[i] == 0) {
					ans = 0;
					log = 0;
					break;
				} else {
					log += Math.Log10(a[i]);
					ans *= a[i];
					//System.Diagnostics.Debug.WriteLine($"log={log} ans={ans}");
				}
			}
			if (log != 0 && (log > 18 || ans > 1000000000000000000) ) {
				ans = -1;
			}
			Console.WriteLine(ans);
		}
	}
}


Measured memory_bytes: 41736
#include<bits/stdc++.h>
#include<algorithm>

using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef long int li;

int main()
{
    IOS;
    //freopen("fr.txt","r",stdin);
    int x;
    cin>>x;
    while(1){
       
        bool ok=true;
        for(int i=2;i*i<x;i++){
            if(x%i==0)
                ok=false;
        }
        if(ok){
            cout<<x<<endl;
            break;
        }
         x++;
    }
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()
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; }

long D;
vector<long> c(26);
vector<vector<long>> s(365,vector<long>(26));
vector<long> t(365);
vector<long> kari(365);
long karians = -1e15;
map<long, vector<long>> mp;

void INPUT(){
  cin >> D;
  rep(i,26) cin >> c.at(i);
  rep(i,D){
    rep(j,26) cin >> s.at(i).at(j);
  }
}

long greedy(){
  vector<long> lastday(26,-1);

  long ans = 0;
  rep(i,D){
    vector<long> tmpscore(26,ans);
    rep(j,26){
      tmpscore.at(j) += s.at(i).at(j);
      rep(k,26){
        if(j != k){
          tmpscore.at(j) -= (i - lastday.at(k))*c.at(k);
        }
      }
    }
    long day = 0;
    long maxi = tmpscore.at(0);
    rep(j,26){
      if(tmpscore.at(j) > maxi){
        maxi = tmpscore.at(j);
        day = j;
      }
    }
    ans = maxi;
    //cout << day+1 << endl;
    t.at(i) = day;
    lastday.at(day) = i;
  }
  return ans;
}

long calc(){
  vector<long> lastday(26,-1);
  long ans = 0;
  rep(i,D){
    long tt = t.at(i);
    ans += s.at(i).at(tt);
    lastday.at(tt) = i;
    rep(j,26){
      ans -= (i - lastday.at(j)) * c.at(j);
    }
    //cout << ans << endl;
  }
  return ans;
}

void OUTPUT(){
  rep(i,D){
    cout << kari.at(i)+1 << endl;
  }
}

int main(){
  long start = clock();
  INPUT();
  long now = greedy();
  karians = now;
  kari = t;
  srand(time(NULL));
  long cnt = 0;
  while((clock() - start)/(CLOCKS_PER_SEC/1000) < 1700){
    cnt++;
    long d = rand() % D;
    long q = rand() % 26;
    long prev_q = t.at(d);
    t.at(d) = q;
    long res = calc();
    if(res > now){
      now = res;
    }else if(cnt >= 10000){
      cnt = 0;
      if(now > karians){
        karians = now;
        t.at(d) = prev_q;
        kari = t;
        t.at(d) = q;
      }
      now = res;
    }else{
      t.at(d) = prev_q;
    }
  }
  if(now > karians){
    kari = t;
  }
  OUTPUT();
}

Measured memory_bytes: 3708
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]
ws = [x[0] for x in wv]
vs = [x[1] for x in wv]

dp = [[None] * (10**5 + 1) for _ in range(100 + 1)]
# def dfs(weight=0, depth=N - 1):
#     if dp[depth][weight] is not None:
#         return dp[depth][weight]
#
#     if depth == -1:
#         dp[depth][weight] = 0
#         return 0
#
#     if weight + ws[depth] <= W:
#         result = max(dfs(weight, depth - 1), dfs(weight + ws[depth], depth - 1) + vs[depth])
#     else:
#         result = dfs(weight, depth - 1)
#     dp[depth][weight] = result
#     return result
#
# print(dfs())

dp[-1] = [0] * len(dp[-1])
for depth in range(0, N):
    for weight in range(10**5 + 1):
        v = dp[depth - 1][weight]
        if weight + ws[depth] <= W:
            dp[depth][weight] = max(v, dp[depth - 1][weight + ws[depth]] + vs[depth])
        else:
            dp[depth][weight] = v

print(dp[N - 1][0])


Measured memory_bytes: 258040