akhauriyash/Code-Regression huggingface dataset:
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int x, y, z;
const int maxN = 1e5 + 100;
int a[3][maxN];
int n;
set < pair < int, int > > f[3][3];
int tp[maxN];
void del(int i) {
    int where = tp[i];
    for (int j = 0; j < 3; j++) {
        if (where == j) continue;
        f[j][where].erase({a[j][i] - a[where][i], i});
    }
}
void add(int i, int where) {
    tp[i] = where;
    for (int j = 0; j < 3; j++) {
        if (where == j) continue;
        f[j][where].insert({a[j][i] - a[where][i], i});
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("input.txt", "r", stdin);
    cin >> x >> y >> z;
    n = x + y + z;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> a[j][i];
        }
    }
    ll tot = 0;
    for (int i = 1; i <= x; i++) {
        add(i, 0);
        tot += a[0][i];
    }
    for (int i = x + 1; i <= x + y; i++) {
        add(i, 1);
        tot += a[1][i];
    }
    for (int i = x + y + 1; i <= x + y + z; i++) {
        add(i, 2);
        tot += a[2][i];
    }
    while (true) {
        bool fnd = false;
        for (int a = 0; a < 3; a++) {
            for (int b = 0; b < 3; b++) {
                if (a == b) continue;
                auto t1 = *prev(f[a][b].end());
                auto t2 = *prev(f[b][a].end());
                if (t1.first + t2.first > 0) {
                    fnd = true;
                    tot += t1.first + t2.first;
                    del(t1.second);
                    del(t2.second);
                    add(t1.second, a);
                    add(t2.second, b);
                }
            }
        }
        vector < int > p(3);
        iota(p.begin(), p.end(), 0);
        do {
            auto t1 = *prev(f[p[0]][p[1]].end());
            auto t2 = *prev(f[p[1]][p[2]].end());
            auto t3 = *prev(f[p[2]][p[0]].end());
            if (t1.first + t2.first + t3.first > 0) {
                fnd = true;
                tot += t1.first + t2.first + t3.first;
                del(t1.second);
                add(t1.second, p[0]);
                del(t2.second);
                add(t2.second, p[1]);
                del(t3.second);
                add(t3.second, p[2]);
            }
        } while (next_permutation(p.begin(), p.end()));
        if (!fnd) {
            break;
        }
    }
    cout << tot;
    return 0;
}

Measured memory_bytes: 11264
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#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 all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
unsigned XorShift(void){static unsigned x = 123456789;static unsigned y = 362436069;static unsigned z = 521288629;static unsigned w = 88675123;unsigned t;t = x ^ (x << 11);x = y; y = z; z = w;return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

struct unionfind{
	
	vint data;
	unionfind(int sz){
		data.assign(sz,-1);
	}
	
	bool unite(int x,int y){
		x=find(x),y=find(y);
		if(x==y)return false;
		if(data[x]>data[y])swap(x,y);
		data[x]+=data[y];
		data[y]=x;
		return true;
	}
	
	int find(int k){
		if(data[k]<0)return k;
		return (data[k]=find(data[k]));
	}
	
	
	int size(int k){
		return (-data[find(k)]);
	}
};

main(){
	int n,m,ans;
	cin>>n>>m;
	ans=n*(n-1)/2;
	int a[m],b[m];
	unionfind uf(n+1);
	rep(i,m)cin>>a[i]>>b[i];
	rev(a,a+m);rev(b,b+m);
	vint q;
	//hi;
	rep(i,m){
		q.pb(ans);
		//dans;
		if(uf.find(a[i])!=uf.find(b[i])){
			ans-=uf.size(a[i])*uf.size(b[i]);
			uf.unite(a[i],b[i]);
		}
	}
	rev(all(q));
	for(auto x:q)dump(x);
}

Measured memory_bytes: 4596
#include <stdio.h>

int main(){
    int k, s;
    int count=0;
    scanf("%d %d", &k, &s);
    for(int x=0;x<=k;x++)
    {
        //if(x>s) break;
        for(int y=0;y<=x;y++)
        {
            //if(x+y>s) break;
            for(int z=0;z<=y;z++)
            {
                //if(x+y+z>s) break;
                if(x+y+z==s){
                    if(x==y&&y==z) count+=1;
                    else if(x!=y&&y!=z&&z!=x) count+=6;
                    else count+=3;
                }
            }
        }
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 256
N, U, V = map(int, input().split())
edge = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    x, y = map(int, input().split())
    edge[x].append(y)
    edge[y].append(x)


def dist(s):
    dist = [-1] * (N + 1)
    node = [s]
    dist[s] = 0
    while node:
        s = node.pop()
        for t in edge[s]:
            if dist[t] == -1:
                dist[t] = dist[s] + 1
                node.append(t)
    return dist


taka = dist(U)
aoki = dist(V)
can_go = taka[V]

ans = 0
for t, a in zip(taka[1:], aoki[1:]):
    if t <= a:
        ans = max(ans, a - 1)
print(ans)

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

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

	for (int i = 0; i < n; i++) {
		cout << a[n - 1 - i];
		cout << ((i != (n - 1)) ? " " : "\n");
	}

	return 0;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
int read();
int n, k;
char s[10004], res[10004], c = 'z';
int l[10004], len, mx, vis;

void cpy(int p) {
    for (int i = 1; i <= n; ++i) res[i] = s[p + i - 1];
}

void check(int p) {
    if (!vis) cpy(p), vis = 1;
    for (int i = 1; i <= n; ++i) {
        if (res[i] < s[p + i - 1]) return;
        if (res[i] > s[p + i - 1]) return cpy(p);
    }
}

int main() {
    scanf("%d%d%s", &n, &k, s + 1);
    for (int i = 1; i <= n; ++i) c = min(c, s[(n << 1) + 1 - i] = s[i]);
    if (k >= 15) {for(int i = 1; i <= n; ++i) putchar(c); return 0;}
    if (k == 1) 
	{
        for (int i = 1; i <= n + 1; ++i) check(i);
        for (int i = 1; i <= n; ++i) putchar(res[i]);
        return 0;
    }
    for (int i = 1; i <= n + n; ++i) (s[i] == c) ? mx = max(mx, l[i] = l[i - 1] + 1) : 0;

    if ((len = mx << k - 1) >= n) {for (int i = 1; i <= n; ++i) putchar(c); return 0;}
    for (int i = 1; i <= n + mx; ++i) if (l[i] == mx) check(i - l[i] + 1);
    for (int i = 1; i <= len; ++i) putchar(c);
    for (int i = len + 1; i <= n; ++i) putchar(res[i - len + mx]);
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 10007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------
int dp[1<<21];
int cnt[21][100010];
int ccnt[21];
//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll n;cin>>n;
    V<ll>a(n);
    REP(i,0,n)cin>>a[i];
    ll cnt=0;
    int abc=-1;
    for(ll i=0;i<n-1;i++){
        if(abc==-1){
            if(a[i+1]>a[i]){
                abc=1;
            }
            else if(a[i+1]<a[i]){
                abc=0;
            }
            else abc=-1;
        }
        else{
            if(abc==1){
                if(a[i+1]>=a[i]){
                    continue;
                }
                else{
                    cnt++;
                    abc=-1;
                }
            }
            else{
                if(a[i+1]<=a[i]){
                    continue;
                }
                else{
                    cnt++;
                    abc=-1;
                }
            }
        }
    }
    cout<<cnt+1<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------

































Measured memory_bytes: 1024
def print_table(t):
    for c in t:
        for r in c:
            print("{0:d}".format(r),end="")
        print("")

def play(t,x,y):
    q = [[x,y]]
    while True:
        p = q.pop(0)

        x = p[0]
        y = p[1]

        t[y][x] = 0
        for i in range(1,4):
            if x+i < 8:
                if t[y][x+i] == 1:
                    q.append([x+i,y])
                    t[y][x+i] = 0
            if x-i >= 0:
                if t[y][x-i] == 1:
                    q.append([x-i,y])
                    t[y][x-i] = 0
            if y+i < 8:
                if t[y+i][x] == 1:
                    q.append([x,y+i])
                    t[y+i][x] = 0
            if y-i >= 0:
                if t[y-i][x] == 1:
                    q.append([x,y-i])
                    t[y-i][x] = 0

        if q == []:
            break
    return t
        
n = int(input())

for i in range(1,n+1):
    input() # ?????????skip

    t = [[int(i) for i in list(input())]]
    for j in range(0,7):
        t.append([int(i) for i in list(input())])
    x = int(input())
    y = int(input())

    tt = play(t,x-1,y-1)
    
    print('Data {0:d}:'.format(i))
    print_table(tt)

Measured memory_bytes: 7816
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;


int main(){
    ll N, A, B;
    ll closer;
    ll ans = 0;

    //input
    cin >> N >> A >> B;

    if((B - A) % 2 == 0){
        ans = (B - A) / 2;
    }else{
        if(N - B <= A - 1){
            closer = N - B;
        }else{
            closer = A - 1;
        }
        ans += closer;
        ans += 1;
        ans += (B - A - 1) / 2;
    }

    //output
    cout << ans << endl;

    return 0;
}


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

int N, M, cnt_1, cnt_2;
vector<vector<int> > G;

vector<bool> seen;
bool rec(int v, int p, int s, int t) {
    if (v == s && p != -1) return true; // Ò»ÖÜ»Ø¤Ã¤Æ¤­¤Æ s ¤Ë‘ø¤Ã¤ÆÀ´¤¿¤é OK
    if (v != s) seen[v] = true;
    for (auto nv :  G[v]) {
        if (nv == p || nv == t || seen[nv]) continue;
        if (rec(nv, v, s, t)) return true;
    }
    return false;
}
        
bool solve() {
    cin >> N >> M;
    G.assign(N, vector<int>());
    for (int i = 0; i < M; ++i) {
        int a, b; cin >> a >> b; --a, --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    map<int,int> degs;
    for (int v = 0; v < N; ++v) {
//		degs[(int)G[v].size()]++;
		if (G[v].size() >= 6) cnt_1++;
		else if (G[v].size() == 4) cnt_2++;
		if (G[v].size() & 1) return false;
	}

////    for (auto it : degs) if (it.first % 2 != 0) return false;
//    if (degs[6] > 0) return true;
//    if (degs[4] > 2) return true;
//    if (degs[4] <= 1) return false;
	if (cnt_1) return true;
	if (cnt_2 > 2) return true;
	if (cnt_2 < 2) return false;

    vector<int> four;
    for (int v = 0; v < N; ++v) if (G[v].size() == 4) four.push_back(v);
    int s = four[0], t = four[1];
    seen.assign(N, 0);
    return rec(s, -1, s, t);
}

int main() {
    if (solve()) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

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

    vector<ll> l(n);
    rep(i, n)cin >> l[i];
    
    sort(ALL(l));

    ll ans = 0;
    rep(a, n){
        for(ll b = a+1; b < n; ++b){
            ll r_pos, l_pos;

            if(l[a]+l[b] > l.back())r_pos = n-1;
            else r_pos = lower_bound(ALL(l), l[a]+l[b]) - l.begin(), r_pos--;

            l_pos = upper_bound(ALL(l), l[b]-l[a]) - l.begin();
            l_pos = max(l_pos, b);

            ans += r_pos - l_pos;
        }
    }

    cout << ans << endl;
}


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

void solveproblem(int ar[][20] , int n ,int d){
  	int count=0;
	for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            int ans=0;
            for(int k=0;k<d;k++){
              ans += pow(abs(ar[i][k] - ar[j][k]),2);
            }
            float res=sqrt(ans*1.0);
            if(res==int(res)){
                count++;
            }
        }
    }
    cout<<count<<endl;
}

int main(){
  int n,d;
  cin>>n>>d;
  int ar[20][20];
  for(int i=0;i<n;i++){
    for(int j=0;j<d;j++){
      cin>>ar[i][j];
    }
  }
  solveproblem(ar,n,d);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

string s[52];ll t[52];
int main() {
	ll n,sum=0;
	cin>>n;
	for(ll i=0;i<n;i++){
		string x;ll y;
		cin>>x>>y;
		s[i]=x;
		t[i]=y;
		sum+=y;
	}
	for(ll i=1;i<n;i++){
		t[i]+=t[i-1];
	}
	string now;
	cin>>now;
	for(ll i=0;i<n;i++){
		if(s[i]==now){
			cout <<sum-t[i];
			return 0;
		}
	}
	// your code goes here
	return 0;
}

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


int main() {
  int N, K;
  cin >> N >> K;
  
  vector<int> price(N);
  for (int i=0; i<N; i++){
    cin >> price.at(i);
  }

  sort(price.begin(), price.end());

  
  int sum = 0;
  for (int i=0; i<K; i++){
    sum += price.at(i);
  }
  
  cout << sum << endl;
}


Measured memory_bytes: 3628
import math
import itertools
n = int(input())
x = [0]*n
y = [0]*n
town =[[0 for _ in range(2)]for _ in range(n)]
dist = [[0 for _ in range(n)]for _ in range(n)]
comb = [[0 for _ in range(n)]for _ in range(n)]
ans = 0
for i in range(n):
	x[i],y[i] = map(int,input().split())
	town[i] = (x[i],y[i])



#dist[i][j] = すべての町の距離の配列
for i in range(n):
	for j in range(n):
		if i!=j:
			dist[i][j] = math.sqrt((x[i]-x[j])**2 + (y[i]-y[j])**2)
			dist[j][i] = dist[i][j]
for i in range(n):
	for j in range(n):
		ans += dist[i][j]

print(ans/n)

Measured memory_bytes: 3064
import bisect
n, m = map(int, input().split())

prefecture = [[] for i in range(n)]
li = []

for i in range(m):
    a, b = map(int, input().split())
    li.append([a,b])
    prefecture[a-1].append(b)

for i in prefecture:
    i.sort()

for i in li:
    a = i[0]-1
    b = i[1]
    index = bisect.bisect_left(prefecture[a], b) + 1
    print(str(i[0]).zfill(6)+str(index).zfill(6))



Measured memory_bytes: 32792
N, K = map(int, input().split())
h = [0]*N
for i in range(N):
  h[i] = int(input())

h.sort()
#print(h)
result = h[-1] -h[0]
for i in range(N-K+1):
  result = min(result, h[i+K-1]-h[i])

print(result)

Measured memory_bytes: 7472
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

string s;

bool check1(int l, int r){
	for(int i=l; i+1<r; i++){
		if(s[i]=='#' && s[i+1]=='#'){
			return false;
		}
	}
	return true;
}

bool check2(int l, int r){
	for(int i=l-1; i+1<=r; i++){
		if(s[i]=='.' && s[i+1]=='.' && s[i+2]=='.'){
			return true;
		}
	}
	return false;
}

int main(){
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d >> s;
	a--; b--; c--; d--;
	bool bl;
	if(d<c){
		bl=check1(a, c)&check2(b, d);
	}else{
		bl=check1(a, c)&check1(b, d);
	}
	if(bl) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 640
local H,W,M=io.read("n","n","n")
local bombh={}
local bombw={}
local map={}
for i=1,math.max(H,W) do
    bombh[i]={}
    bombw[i]={}
    map[i]={}
end

for i=1,M do
    local h,w=io.read("n","n")
    table.insert(bombh[h],w)
    table.insert(bombw[w],h)
    map[h][w]=true
end

local hmax=0
local wmax=0
for i=1,math.max(H,W) do
    hmax=math.max(hmax,#bombh[i])
    wmax=math.max(wmax,#bombw[i])
end

local max=hmax+wmax-1
local maxh={}
local maxw={}
for i=1,math.max(H,W) do
    if #bombh[i]==hmax then
        table.insert(maxh,i)
    end
    if #bombw[i]==wmax then
        table.insert(maxw,i)
    end
end

for i=1,#maxh do
    local h=maxh[i]
    for j=1,#maxw do
        local w=maxw[j]
        if (map[h] and (not map[h][w])) then
            max=max+1
            print(max)
            return
        end
    end
end
print(max)

Measured memory_bytes: 132456
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Jun 25 12:46:40 2019

@author: YudNK
"""

n,x = map(int, input().split())
l = [int(i) for i in input().split()]
count = 1
px = 0
for i in range(n):
    nx = px + l[i]
    if nx <= x:
        count += 1
    px = nx
print(count)

Measured memory_bytes: 3060
# ABC050b
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n = int(input())
t = list(map(int, input().split()))
m = int(input())
p = [list(map(int, input().split())) for _ in range(m)]

for i in range(m):
    print(sum(t)-t[p[i][0]-1]+p[i][1])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	int n;
	cin >> n;
	ll ans = 0;
	rep1(i, n) {
		rep1(j, n / i + 1) {
			ll x = i * j;
			if (x < n) ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#define bogo_sort   std::sort
#define bozo_sort   std::stable_sort
#define alles(obj)  obj.begin(), obj.end()
#define elif        else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo        std::cout <<
#define read        std::cin >>
#define endl        std::endl
#define fin         << '\n'
#define bash        push_back
#define makePair    std::make_pair
#define _           << ' ' <<
// type-define
#define Stack       std::stack
#define Queue       std::queue
#define Set         std::set
#define PQueue      std::priority_queue
#define Vector      std::vector
#define Pair        std::pair
#define Map         std::map
#define Greater     std::greater
using String  =     std::string;
using llong   =     long long;
using boolean =     bool;
using Pii     =     Pair<int, int>;
using Vi      =     Vector<int>;
using Vii     =     Vector<Pii>;
// utils
constexpr int   dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int   dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int   INF  = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    llong power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    llong power ( llong x, llong n ) { return power( x, n, 1000000007 ); }
    llong gcd   ( llong x, llong y ) { return x % y ? gcd( y, x % y ) : y; }
    llong lcm   ( llong x, llong y ) { return ( x / gcd(x, y) * y ); }
    llong abs   ( llong n )          { return ( n < 0 ) ? -n : n; }
    boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {

    signed call_of_Cthulhu( signed datum ) {

        int n, h, w;
        read n >> h >> w;
        echo (n-h+1) * (n-w+1) fin;

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try{
            int n  = Integer.parseInt(br.readLine());
            for(int i=0;i<n;i++){
            String st = br.readLine();
            String[] s = st.split(" ",0);
            int[] k = new int[3];
            k[0]=Integer.parseInt(s[0]);
            k[1]=Integer.parseInt(s[1]);
            k[2]=Integer.parseInt(s[2]);
            Arrays.sort(k);
            if(k[2]*k[2]==(k[1]*k[1])+(k[0]*k[0])){
                System.out.println("YES");
            }else{
                System.out.println("NO");
            }
            }
        }catch (Exception ex){
            System.exit(0);
        }
    }
}

Measured memory_bytes: 26232
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    int n,k;
    string s;
    cin>>n>>k>>s;
    
    int x=0;
    rep(i,0,n-1){
        if(s[i]==s[i+1]) x++;
    }
    cout<<min(n-1,x+2*k)<<endl;
}


Measured memory_bytes: 512
import java.util.*;
import java.io.*;

// Template for atcoder
public class Main {

    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;
    boolean eof;
    final long MOD = 1000L * 1000L * 1000L + 7;
    private static final int[] dx = {0, -1, 0, 1};
    private static final int[] dy = {1, 0, -1, 0};

    int[] arr;
    long[][] dp;
    void solve() throws IOException {
        int N = nextInt();
        arr = nextIntArr(N);
        dp = new long[N][N];
        long first = rec(0, N - 1);
        long sum = 0;
        for (int v : arr) {
            sum += v;
        }
        outln(2 * first - sum);
    }

    long rec(int start, int end) {
        if (start > end) {
            return 0;
        }
        if (start == end) {
            return arr[start];
        }
        if (dp[start][end] > 0) {
            return dp[start][end];
        }

        long res1 = arr[start] + Math.min(rec(start + 1, end - 1), rec(start + 2, end));
        long res2 = arr[end] + Math.min(rec(start + 1, end - 1), rec(start, end - 2));
        long res = Math.max(res1, res2);
        dp[start][end] = res;
        return res;
    }

    void shuffle(int[] a) {
        int n = a.length;
        for(int i = 0; i < n; i++) {
            int r = i + (int) (Math.random() * (n - i));
            int tmp = a[i];
            a[i] = a[r];
            a[r] = tmp;
        }
    }
    private void outln(Object o) {
        out.println(o);
    }
    private void out(Object o) {
        out.print(o);
    }
    public Main() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }
    public static void main(String[] args) throws IOException {
        new Main();
    }

    public long[] nextLongArr(int n) throws IOException{
        long[] res = new long[n];
        for(int i = 0; i < n; i++)
            res[i] = nextLong();
        return res;
    }
    public int[] nextIntArr(int n) throws IOException {
        int[] res = new int[n];
        for(int i = 0; i < n; i++)
            res[i] = nextInt();
        return res;
    }
    public String nextToken() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                eof = true;
                return null;
            }
        }
        return st.nextToken();
    }
    public String nextString() {
        try {
            return br.readLine();
        } catch (IOException e) {
            eof = true;
            return null;
        }
    }
    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }
}


Measured memory_bytes: 106932
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>

#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define reps(i, s, n) for(int i = (int)s; i < (int)n; i++)
#define in(i) std::cin >> i;
#define print(i) std::cout << i;
#define println(i) std::cout << i << std::endl;

int main() {
    long long N, D, x, y;
    std::cin >> N >> D;
    int cnt = 0;
    for(int i = 0; i < N; i++) {
        std::cin >> x >> y;
        if(std::sqrt((x * x) + (y * y)) <= D)
            cnt++;
    }
    print(cnt);
    return 0;
}

Measured memory_bytes: 3148
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#define llint long long
#define inf 1e18

using namespace std;
typedef pair<llint, llint> P;
typedef pair<llint, P> E;

struct SegTree{
	int size;
	vector<llint> seg;
	
	SegTree(){}
	SegTree(int size){
		this->size = size;
		seg.resize(1<<(size+1));
	}
	
	void init()
	{
		for(int i = 0; i < (1<<(size+1)); i++) seg[i] = inf;
	}
	
	void update(int i, llint val)
	{
		i += (1 << size);
		seg[i] = val;
		while(i > 1){
			i /= 2;
			seg[i] = min(seg[i*2], seg[i*2+1]);
		}
	}

	llint query(int a, int b, int k, int l, int r)
	{
		if(b < l || r < a) return inf;
		if(a <= l && r <= b) return seg[k];
		llint lval = query(a, b, k*2, l, (l+r)/2);
		llint rval = query(a, b, k*2+1, (l+r)/2+1, r);
		return min(lval, rval);
	}
	llint query(int a, int b)
	{
		return query(a, b, 1, 0, (1<<size)-1);
	}
};

struct UnionFind{
	int size;
	vector<int> parent;
	
	UnionFind(){}
	UnionFind(int size){
		this->size = size;
		parent.resize(size+1);
		init();
	}
	void init(){
		for(int i = 0; i <= size; i++) parent[i] = i;
	}
	int root(int i){
		if(parent[i] == i) return i;
		return parent[i] = root(parent[i]);
	}
	bool same(int i, int j){
		return root(i) == root(j);
	}
	void unite(int i, int j){
		int root_i = root(i), root_j = root(j);
		if(root_i == root_j) return;
		parent[root_i] = root_j;
	}
};

llint n, Q;
llint a[200005], b[200005], c[200005];
vector<E> vec;
SegTree seg(19);
UnionFind uf(200005);

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> Q;
	for(int i = 1; i <= Q; i++) cin >> a[i] >> b[i] >> c[i];
	
	seg.init();
	for(int i = 1; i <= Q; i++){
		llint u = a[i], v = b[i], w = c[i];
		if(u > v) v += n;
		
		llint val = seg.query(u, u); 
		seg.update(u, min(val, w-2*(u-1)-1));
		u += n;
		val = seg.query(u, u); 
		seg.update(u, min(val, w-2*(u-1)-1));
		
		val = seg.query(v, v); 
		seg.update(v, min(val, w-2*(v-1)));
		v += n;
		if(v < 2*n){
			val = seg.query(v, v); 
			seg.update(v, min(val, w-2*(v-1)));
		}
	}
	
	for(int i = 1; i <= Q; i++) vec.push_back(make_pair(c[i], make_pair(a[i], b[i])));
	for(int i = 0; i < n; i++){
		llint mn = seg.query(0, i) + 2*i;
		mn = min(mn, seg.query(0, n+i) + 2*(n+i));
		vec.push_back(make_pair(mn, make_pair(i, (i+1)%n)));
	}
	sort(vec.begin(), vec.end());
	
	llint ans = 0;
	for(int i = 0; i < vec.size(); i++){
		llint w = vec[i].first, u = vec[i].second.first, v = vec[i].second.second;
		if(uf.same(u, v)) continue;
		ans += w;
		uf.unite(u, v);
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 28396
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
        int h1 = Integer.parseInt(str);
        str = sc.next();
        int m1 = Integer.parseInt(str);
        str = sc.next();
        int h2 = Integer.parseInt(str);
        str = sc.next();
        int m2 = Integer.parseInt(str);
        str = sc.next();
        int k = Integer.parseInt(str);
        int g;
         g =(h2*60)-(h1*60)+m2-m1-k;
        sc.close();
        System.out.println(g);

	}
}

Measured memory_bytes: 35688
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<31)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
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; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n, k;
ll ans = INF;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n >> k;
    vector<ll> x(n);
    rep(i, 0, n) cin >> x[i];
    rep(l, 0, n - k + 1) {
        int r = l + k - 1;
        ans = min(ans, min(abs(x[l]) + abs(x[l] - x[r]), abs(x[r]) + abs(x[r] - x[l])));
    }    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    int h,w,cnt=0; cin>>h>>w;
    rep(i,h*w){
        char ch; cin>>ch;
        if(ch=='#') cnt++;
    }
    cout<<(cnt==h+w-1 ? "Possible" : "Impossible");
}

Measured memory_bytes: 256
n=int(input())

ans=[1]
i=1
s=1
while True:
    if s>=n:
        break
    i+=1
    s+=i
    ans.append(i)

dif = s-n
if dif==0:
    for i in range(len(ans)):
        print(ans[i])
    exit(0)

for i in range(len(ans)):
    if ans[i]==dif:
        continue
    print(ans[i])




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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl '\n';
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);

template <typename T> inline T bigMod(T A,T B,T M = MOD){A %= M;T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invMod (T A,T M = MOD){return bigMod(A,M-2,M);}

const int N = 200005;
int ar[N + 5];
int tree[(N << 2) + 5];
int lazy[(N << 2) + 5];

void updateRange(int pos, int L, int R, int l, int r, int val){
  int nxt = pos << 1;
  if(lazy[pos] != 0){
    tree[pos] += (R - L + 1) * lazy[pos];
    if (L != R){
      lazy[nxt] += lazy[pos];
      lazy[nxt + 1] += lazy[pos];
    }
    lazy[pos] = 0;
  }
  if (r < L || l > R){
    return ;
  }
  if (L >= l && R <= r){
    tree[pos] += (R - L + 1) * val;
    if (L != R){
      lazy[nxt] += val;
      lazy[nxt + 1] += val;
    }
    return ;
  }
  int mid = (L + R) >> 1;
  updateRange(nxt, L, mid, l, r, val);
  updateRange(nxt + 1, mid + 1, R, l, r, val);
  tree[pos] = tree[nxt] + tree[nxt + 1];
}
int queryRange(int pos, int L, int R, int l, int r){
  if (r < L || l > R){
    return 0;
  }
  int nxt = pos << 1;
  if (lazy[pos] != 0){
    tree[pos] += (R - L + 1) * lazy[pos];
    if (L != R){
      lazy[nxt] += lazy[pos];
      lazy[nxt + 1] += lazy[pos];
    }
    lazy[pos] = 0;
  }
  if (L >= l && R <= r){
    return tree[pos];
  }
  int mid = (L + R) >> 1;
  int x = queryRange(nxt, L, mid, l, r);
  int y = queryRange(nxt + 1, mid + 1, R, l, r);
  return x + y;
}
int main(){
  FASTER;
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++){
    int l, r;
    cin >> l >> r;
    updateRange(1, 1, n, l, r, 1);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++){
    if (queryRange(1, 1, n, i, i) == m){
      ans++;
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 5376
import sys
readline = sys.stdin.buffer.readline

from collections import deque
from copy import copy,deepcopy
from itertools import permutations,combinations
from pprint import pprint

def myinput():
    return map(int,input().split())

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col):
    return data.sort(key=lambda x:x[col],reverse=True)

n = int(input())
xl = [ list(myinput()) for _ in range(n) ]
# print(xl)

ls = []
for i in range(n):
    x = xl[i][0]
    l = xl[i][1]
    s = x - l
    e = x + l
    d = [s,e]
    ls.append(d)
# print(ls)
ls.sort(key=lambda x:x[1],reverse=False)
# print(ls)

count = 0
e = -1*float("inf")
for i in range(n):
    ns,ne = ls[i]
    if ns>=e:
        count += 1
        e = copy(ne)
    else:
        pass

print(count)

Measured memory_bytes: 75864
#include <stdio.h>

int main()
{
    int tenant[4][3][10] = {0};
    int count = 0, n, b, f, r, v, i, j, k;
    
    scanf("%d", &n);
    do{
        scanf("%d %d %d %d", &b, &f, &r, &v);
        tenant[b-1][f-1][r-1] += v;
        count++;
    }while (count!=n);
    count = 0;
    
    for (i = 0; i < 4; i++){
        for (j = 0; j < 3; j++){
            for (k = 0; k < 10; k++){
                printf(" %d", tenant[i][j][k]);
            }
            printf("\n");
        }
        if (i < 3){
            printf("####################\n");
        }
    }
    
    
    return 0;
}

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

typedef long long ll;

int main()
{
    int n,r;
    cin >> n >> r;
    if(n >= 10){
        cout << r << endl;
    }else{
        cout << r + 100*(10-n) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
 
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
using ld = long double;
 
// ------------------------------------------------------------------------------------------------

ll cnt;
string s, ans;

int main() {
    fast_io; cout_precision;
    cin >> s;
    for (ll i = s.length() - 1; i >= 0; i--) {
        if (s[i] == 'B') {
            cnt++;
        } else if (cnt > 0) {
            cnt--;
        } else {
            ans += s[i];
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.Scanner;

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

		BigDecimal a = new BigDecimal(sc.next());
		BigDecimal b = new BigDecimal(sc.next());

		System.out.println(a.multiply(b).setScale(0, BigDecimal.ROUND_DOWN));
	}
}


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

using namespace std;

const long long inf = 1e9;

struct cast {
	long long a;
	long long b;
	
	bool operator < (const cast& el) const {
		return (b < el.b);
	}
};

int main() {
	ios::sync_with_stdio(false);
	long long h, n;
	cin>>h>>n;
	long long maxv = 0;
	vector < cast > v(n + 1);
	for (long long i = 0; i < n; i++) {
		cin>>v[i + 1].a>>v[i + 1].b;
		maxv = max(maxv, v[i + 1].a);
	}
	
	sort(v.begin() + 1, v.end());
	vector < long long > m(h + maxv);
	for (long long i = 0; i < h + maxv; i++)
		m[i] = inf;
	m[0] = 0;
	for (long long w = 1; w < h + maxv; w++)
	for (long long i = 1; i <= n && (w - v[i].a >= 0); i++)
		m[w] = min(m[w], v[i].b + m[w - v[i].a]);
	long long ind = h;
	for (long long i = h; i < h + maxv; i++)
		if (m[i] < m[ind]) ind = i;
		
	cout<<m[ind];
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;

//素数判定
inline bool IsPrime(int p) {
	if (p == 1) return false;
	for (int i = 2; i <= sqrt(p); i++) {
		if (p%i == 0) return false;
	}
	return true;
}

//10進数の自然数の桁数を返す
inline int GetDigit(int num) {
	return (int)log10(num) + 1;
}

//各位の和を返す
int GetDigitsSum(int num) {
	int N = 0;
	while (num > 0) {
		N += num % 10;
		num /= 10;
	}
	return N;
}



//異なるn個からr個の整数を取り出す組合せの数を求める
int combination(int n, int r) {
	if (r == 0 || n == r) {
		return 1;
	}
	else if (r == 1) {
		return n;
	}
	else {
		return combination(n - 1, r - 1) + combination(n - 1, r);
	}

}


int main() {
	long long N, M;
	long long ans = 0;
	long long X[100010] = { 0 };

	cin >> N >> M;

	for (long long i = 0; i < N; i++)
	{
		long long a, b;
		cin >> a >> b;
		X[a] += b;
	}


	long long sum = 0;
	long long i = 0;
	while (1)
	{
		if (sum >= M) {
			break;
		}
		sum += X[i++];
		ans = i - 1;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
using namespace std;

int main(void){
	char c;
	cin >> c;
	if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o')
		cout << "vowel" << endl;
	else
		cout << "consonant" << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}

int main(void){
	int a,b,c,f[11],sum,i,cnt;
	while(scanf("%d %d %d",&a,&b,&c)!=EOF){
		memset(f,0,sizeof(f));
		f[a]=f[b]=f[c]=1;
		sum=a+b;
		cnt=0;
		for(i=1;i<=10;i++){
			if(!f[i]&&sum+i<=20){
				cnt++;
			}
		}
		puts(cnt>3?"YES":"NO");
	}
	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++) 
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    //ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    ll L,R; cin >> L >> R;
    R=min(R,L+2019);
    ll lit=INF;
    for(ll i=L;i<R;i++){
        for(ll j=i+1;j<R+1;j++){
            chmin(lit,(i*j)%(ll)2019);
        }
    }
    cout << lit;


}

/*



 */



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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A + B > C + D) {
    cout << "Left" << endl;
  } else if (A + B == C + D) {
	cout << "Balanced" << endl;
  } else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_imports)]

use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        ss: [i64; n],
    }
    let s = ss.iter().fold(0, |sum, item| sum + item);
    if s % 10 != 0 {
        println!("{}", s);
        return;
    } else {
        let mut f = false;
        let mut ma = std::i64::MAX;
        for i in ss.iter() {
            if i % 10 != 0 {
                f = true;
                if i < &ma {
                    ma = i.clone();
                }
            }
        }
        if !f {
            println!("0");
        } else {
            println!("{}", s - ma);
        }
    }
}

Measured memory_bytes: 4352
#include <stdio.h>
int main(void){
    // Here your code !
    int r,g,b;
    scanf("%d %d %d",&r,&g,&b);
    if((g*10+b)%4 == 0){
        printf("YES\n");
    }
    else {
        printf("NO\n");
    }
    return 0;
    
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
 
int main(void) {
  char S[11],T[12];
  int i;
  if(scanf("%s\n%s", S, T)==1);
  if (strlen(S)==strlen(T)-1) {
    for(i=0;i<strlen(S);i++) {
      if(S[i]!=T[i]) {
    	printf("No");
        return 0;
      }
    }
    printf("Yes");
  }
  else {
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
int main()
{
    
     int x=0;
    string s;
   cin>>s;
   
    
    for(int i=0;i<s.length();++i)
    {
        x += (s[i] - '0');
    }
    if( x % 9 ==0)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 3688
#include <iostream>
#include <list>
#include <utility>

int main(){
  using namespace std;
  int M, N;
  std::cin >> N >> M;
  list<pair<int, int> > v;
  for(size_t i = 0; i < M; ++i){
  	int a, b;
    std::cin >> a >> b;
    v.push_back(make_pair(a, b));
  }
  size_t count = 0;
  while(!v.empty()){
    ++count;
  	int a_max = 0;
    for(auto p : v)
    	a_max = max(a_max, p.first);
   	for(auto iter = v.begin(); iter != v.end();){
      if(iter->second > a_max) v.erase(iter++);
      else ++iter;
    }
  }
  std::cout << count << "\n";

}

Measured memory_bytes: 3328
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yosiiii
 */


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

class B1 {
public:
	void solve(std::istream& in, std::ostream& out) {
        ll x;
        in >> x;
        ll cnt=0L;
        ll t=100L;
        for(;t<x;cnt++){
            t*=1.01;
        }
        out << cnt << endl;
	}
};


int main() {
	B1 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<int>L(n);
	for(auto&i:L)cin>>i;
	sort(L.begin(),L.end());
	int ans=0;
	for(int i=0;i<n;++i){
		for(int j=i+1;j<n;++j){
			int low=abs(L.at(i)-L.at(j)),
				high=L.at(i)+L.at(j);
				auto a=upper_bound(L.begin()+j+1,L.end(),low),
					 b=lower_bound(L.begin()+j+1,L.end(),high);
				ans+=b-a;
		}
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 256
fun main(argc:Array<String>){
    val (N,K) = readLine()!!.split(" ").map(String::toInt)
    var Q : Double = 0.0
    var Cnt : Int
    var Point : Int
    for(i in 1..N){
        Cnt = 0
        Point = i
        while(Point < K){
            Point *= 2
            Cnt++
        }
        Q += (1.0/N) * pow(0.5F,Cnt) 
    }
    println(Q)
}

fun pow(x:Float,y: Int):Float{
    var Ans:Float = 1.0F
    for(i in 1..y){
        Ans *= x
    }
    return Ans
}

Measured memory_bytes: 36024
#include <iostream>
#include <vector>
using namespace std;

int main(){
  string s , t;
  cin >> s >> t;
  int ans = 0;
  for (int i = 0 ; i < (int)s.size() ; i ++) {
    if (s.at(i) != t.at(i)){
      ans ++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3916
#include <stdio.h>

int main(void)
{
	int n;
	
	while (scanf("%d", &n) * n != 0){
		int a, b;
		
		a = b = 0;
		while (n-- > 0){
			int ca, cb;
			
			scanf("%d %d", &ca, &cb);
			if (ca > cb){
				a += ca + cb;
			}
			else if (ca < cb){
				b += ca + cb;
			}
			else {
				a += ca;
				b += cb;
			}
		}
		printf("%d %d\n", a, b);
	}
	
	return 0;
}

Measured memory_bytes: 600