akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
inline int read(){
	int f=1,ans=0;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
	return ans*f;
}
const int MAXN=300001;
int N,M,tot;
struct BIT{
	int Ans[MAXN];
	int lowbit(int x){return x&-x;}
	void Modify(int x,int w){for(;x<=N;x+=lowbit(x)) Ans[x]+=w;}
	int Query(int x){int res=0;for(;x;x-=lowbit(x)) res+=Ans[x];return res;}
	void Add(int l,int r,int w){tot++;Modify(l,w),Modify(r+1,-w);return;}
}T;
vector<pii> vec[MAXN];
int main(){
	M=read(),N=read();
	for(int i=1;i<=M;i++){int l=read(),r=read();vec[r-l+1].pb(mp(l,r));}
	for(int i=1;i<=N;i++){
		int cur=i-1;for(int j=0;j<vec[cur].size();j++) T.Add(vec[cur][j].fi,vec[cur][j].se,1);
		int Ans=M-tot;for(int j=i;j<=N;j+=i) Ans+=T.Query(j);printf("%d\n",Ans);
	}return 0;
}


Measured memory_bytes: 13440
#include<bits/stdc++.h>
using namespace std;
#define itn int
#define int long long
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string o,e;
  cin>>o>>e;
  int p=0,q=0;
  for(int i=0;i<o.size()+e.size();i++){
    if(i%2==0){
      cout<<o[p];
      p++;
    }
    else{
      cout<<e[q];
      q++;
    }
  }
  cout<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll a,b,c;
  cin>>a>>b>>c;
  set<ll> S;
  S.insert(a);
  S.insert(b);
  S.insert(c);
  cout<<S.size()<<endl;
}

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

int main()
{
  int a, b, x, y;
  while( cin >> a >> b, a+b ) {
    int cnt = 0;
    if( a >= b ) { 
      x = a;
      y = b;
    } else {
      x = b;
      y = a;
    }

    while( y ) {
      x = x % y;
      swap(x, y);
      cnt++;
    }

    cout << x << " " << cnt << endl;
  }

}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std; 
int main(){
	fastIO;         
	int h,w;
	cin>>h>>w;
	for(int i=0;i<h;i++){
		string s;
		cin>>s;
		cout<<s<<'\n'<<s<<'\n';
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String day = sc.next();
		int num = -1;

		switch (day) {
		case "SUN":
			num = 0;
			break;
		case "MON":
			num = 1;
			break;
		case "TUE":
			num = 2;
			break;
		case "WED":
			num = 3;
			break;
		case "THU":
			num = 4;
			break;
		case "FRI":
			num = 5;
			break;
		case "SAT":
			num = 6;
			break;
		}
		if (num == 0) {
			System.out.println(7);
		} else {
			int cnt = num;
			while (cnt % 7 != 0) {
				cnt++;
			}
			num = cnt - num;
			System.out.println(num);
		}
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

int dp[111][101010];
int sum[101010];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;

    dp[0][0] = 1;
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        sum[0] = 0;
        for(int j=0;j<=K+1;j++) sum[j+1] = (sum[j] + dp[i][j]) % MOD;
        for(int j=0;j<=K;j++) dp[i+1][j] = (sum[j+1] - sum[max(0,j-a)] + MOD) % MOD;
    }
    cout << dp[N][K] << endl;
}


Measured memory_bytes: 40960
#ifdef LOCAL111
#else
	#pragma GCC optimize ("O3")
	#define NDEBUG
#endif
// #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
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;}

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...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

const array<int, 4> dx = {0, 1, 0, -1};
const array<int, 4> dy = {1, 0, -1, 0};


typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	int m, d;
	while(cin >> m >> d) {
		int ans = 0;
		FOR(i, 1, m + 1) {
			FOR(j, 1, d + 1) {
				int d1 = j % 10;
				int d2 = j / 10;
				if(d1 >= 2 and d2 >= 2 and d1 * d2 == i) {
					ans++;
				}
			}
		}
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5+10;
typedef long long ll;
ll a[maxn],sum[maxn];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	ll ans =1e15;
	for(int i=1;i<=n;i++)
	{
		sum[i] = sum[i-1]+a[i];
	}
	ll cnt = a[1];
	for(int i=2;i<=n;i++)
	{
		//cout<<sum[n]-sum[i]-sum[i]<<endl;
		ans = min(ans,abs(sum[n]-2*cnt));
		cnt += a[i]; 
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 3328
def A():
    n, x, t = map(int, input().split())
    print(t * ((n+x-1)//x))

def B():
    n = list(input())
    s = 0
    for e in n:
        s += int(e)
    print("Yes" if s % 9 == 0 else "No")

def C():
    int(input())
    a = list(map(int, input().split()))
    l = 0
    ans = 0
    for e in a:
        if e < l: ans += l - e
        l = max(l, e)
    print(ans)

def E():
    h, w, m = map(int, input().split())
    row = [0] * h
    col = [0] * w
    exist = set([])
    th = 1000000000
    for i in range(m):
        x, y = map(int, input().split())
        x -= 1
        y -= 1
        row[x] += 1
        col[y] += 1
        exist.add(x*th + y)

    max_row = max(row)
    max_col = max(col)
    candi_row = []
    candi_col = []
    for i in range(h):
        if row[i] == max_row: candi_row.append(i)
    for i in range(w):
        if col[i] == max_col: candi_col.append(i)

    ans = max_row + max_col
    for x in candi_row:
        for y in candi_col:
            if x*th + y in exist: continue
            print(ans)
            return
    print(ans - 1)

E()


Measured memory_bytes: 168844
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<map>
#include<unordered_map>
#include<queue>
#include<deque>
 
using namespace std;
using ll=long long;
#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()
 
int main(){
    ll n, k, s;
    cin >> n >> k >> s;
    rep(i, k)cout << s << " ";
    if(s > 1)rep(i, n-k)cout << s-1 << " ";
    else rep(i, n-k)cout << 2 << " ";

}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;
int dx[4]={0,1,0,-1};
int dy[4]={-1,0,1,0};

int h,w,n;
string str;
int fie[1001][1001];
int sx,sy,gx,gy;
int dir[100005];
int next[100005][4];
int dp[1001][1001][4];

void solve(void){
	int nowdir=0;
	dir[0]=0;
	for(int i=0;i<n;i++){
		if(str[i]=='L'){
			nowdir=(nowdir+3)%4;
		}else{
			nowdir=(nowdir+1)%4;
		}
		dir[i+1]=nowdir;
	}
	for(int i=0;i<4;i++){
		next[n+1][i]=n+1;
	}
	for(int i=n;i>=0;i--){
		for(int j=0;j<4;j++){
			next[i][j]=next[i+1][j];
		}
		next[i][dir[i]]=i;
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			for(int k=0;k<4;k++){
				dp[i][j][k]=n+1;
			}
		}
	}
	dp[sy][sx][0]=0;
	priority_queue<PP,vector<PP>,greater<PP> > que;
	que.push(PP(0,P(sy,sx)));
	while(que.size()){
		PP q=que.top();
		que.pop();
		int v=q.first;
		int cy=q.second.first;
		int cx=q.second.second;
		if(dp[cy][cx][dir[v]]<v)continue;
		for(int i=0;i<4;i++){
			int nv=next[v][i];
			if(nv<dp[cy][cx][i]){
				dp[cy][cx][i]=nv;
				que.push(PP(nv,P(cy,cx)));
			}
		}
		int nx=cx+dx[dir[v]];
		int ny=cy+dy[dir[v]];
		if(nx>=0 && nx<w && ny>=0 && ny<h){
			if(fie[ny][nx]==0){
				if(v<dp[ny][nx][dir[v]]){
					dp[ny][nx][dir[v]]=v;
					que.push(PP(v,P(ny,nx)));
				}
			}
		}
	}
	bool flag=false;
	for(int i=0;i<4;i++){
		if(dp[gy][gx][i]<=n){
			flag=true;
		}
	}
	printf("%s\n",flag?"Yes":"No");
}

int main(void){
	while(1){
		scanf("%d%d%d",&h,&w,&n);
		if(h==0 && w==0 && n==0)break;
		cin >> str;
		memset(fie,0,sizeof(fie));
		for(int i=0;i<h;i++){
			string s;
			cin >> s;
			for(int j=0;j<w;j++){
				if(s[j]=='#')fie[i][j]=-1;
				if(s[j]=='S'){
					sx=j;
					sy=i;
				}
				if(s[j]=='G'){
					gx=j;
					gy=i;
				}
			}
		}
		solve();
	}
}

Measured memory_bytes: 24284
#include<stdio.h>
int main(void){
    int i,n,a_n[1000];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a_n[i]);
    }
    for(i=n-1;i>=0;i--){
        if(i>0){
            printf("%d ",a_n[i]);
        }else{
            printf("%d",a_n[i]);
        }
    }
    putchar('\n');
    return 0;
}


Measured memory_bytes: 2032
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		
		while(true){
			int n=in.nextInt(),m=in.nextInt();
			if(n==0)break;
			List<Integer> A=new ArrayList<>(), B=new ArrayList<>();

			int sumA=0,sumB=0;
			for(int i=0;i<n;i++){
				A.add(Integer.parseInt(in.next()));
				sumA+=A.get(i);
			}
			for(int i=0;i<m;i++){
				B.add(Integer.parseInt(in.next()));
				sumB+=B.get(i);
			}

			int a=-1,b=-1;
			for(int i=0;i<n;i++){
				for(int j=0;j<m;j++){
					int x=A.get(i),y=B.get(j);
					if(sumA-x+y == sumB-y+x){
						a=x;b=y;break;
					}
				}
				if(a!=-1)break;
			}
			if(a!=-1)System.out.printf("%d %d\n",a,b);
			else System.out.println(-1);
		}
		
	}

}



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


int main() {
    int N,T;
    cin>>N>>T;
    map<int,int>mp;
    rep(i,N){
        int c,t;
        cin>>c>>t;
        mp[c]=t;
    }
    for(auto p:mp){
        if(p.second>T)continue;
        else{
            cout<<p.first<<endl;
            return 0;
        }
    }
    cout<<"TLE"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;



const long double PI = 3.14159265359;
const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	VE a(4); rep(i, 4)cin >> a[i];
	sort(ALL(a));
	if (a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var N int
  fmt.Scanf("%d", &N)
  a := make([]int, N)
  for i:=range a {
    fmt.Scanf("%d", &a[i])
  }
  fmt.Println(solve(N, a))
}

func solve(n int, a []int) float64 {
  ones, twos, threes := 0, 0, 0
  for _, num := range a {
    switch num {
      case 1:
       ones++
      case 2:
       twos++
      case 3:
       threes++
    }
  }
  max_ones := ones+twos+threes
  max_twos := twos+threes
  max_threes := threes
  //
  dp := make([][][]float64, n+1)
  for i:=range dp {
    dp[i] = make([][]float64, n+1)
    for j:=range dp[i] {
      dp[i][j] = make([]float64, n+1)
    }
  }
  //
  var i, j, k int
  for k=0;k<=max_threes;k++ {
    for j=0;j<=max_twos-k;j++ {
      for i=0;i<=max_ones-j-k;i++ {
        if i+j+k == 0 {
          continue
        }
        dp[i][j][k] = float64(n)/float64(i+j+k)
        if i>0 {
          dp[i][j][k] += (dp[i-1][j][k]*float64(i))/float64(i+j+k)
        }
        if j>0 {
          dp[i][j][k] += (dp[i+1][j-1][k]*float64(j))/float64(i+j+k)
        }
        if k>0 {
          dp[i][j][k] += (dp[i][j+1][k-1]*float64(k))/float64(i+j+k)
        }
      }
    }
  }
  return dp[i-1][j-1][k-1]
}

Measured memory_bytes: 256496
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

int main()
{
    i64 h, w, hd, wd;
    cin >> h >> w >> hd >> wd;
    cout << (h - hd) * (w - wd) << endl;
    return 0;
}


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

int main(){
  long long N;
  cin >> N;
  vector<long long> div(1000);
  long long temp=pow(N, 0.5);
  for(long long i=temp; i>0; i--){
    if(N%i==0){
      temp=N/i;
      break;
    }
  }
  
  long long ans=0;
  
  while(temp!=0){
    ans++;
    temp=temp/10;
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin>>n;
  vector<ll> v(n);
  for(int i=0;i<n;i++){
      cin>>v[i];
  }
  vector<vector<ll>> dp(n,vector<ll>(n,0));
  for(int i=0;i<n;i++){
      dp[i][i] = v[i];
  }
  for(int len=2;len<=v.size();len++){
      for(int i=0;i<v.size()-len+1;i++){
          int j = i+len-1;
          dp[i][j] = max((v[i]-dp[i+1][j]),v[j]-dp[i][j-1]);
      }
  }
  cout<<dp[0][n-1];
}

Measured memory_bytes: 70784
N = int(input())

X = [int(n) for n in input().split()]
Y = [int(n) for n in input().split()]

d1,d2,d3,dinf= 0,0,0,0


for i in range(N):
    # p=1
    d1 += abs(X[i]-Y[i])
    # p=2
    d2 += (X[i]-Y[i])**2
    # p=3
    d3 += (abs(X[i]-Y[i]))**3
    # p=inf
    dinf = max(abs(X[i]-Y[i]),dinf)

print(d1)
print(d2**(1/2))
print(d3**(1/3))
print(dinf)


Measured memory_bytes: 5644
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
d = 0
x = 0
for i in range(n):
  y = a[i]
  if x == y:
    d += c[y-2]
  # print(y)
  d += b[y-1]
  # print(d)
  x = y + 1
print(d)

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

int main(){
        int n;
        cin >> n;
        int a[2*n];
        int now;
        int max=0;
        for(int i=0;i<2*n;i++){
                cin >> a[i];
        }
        for(int i=0;i<n;i++){
                now=0;
                for(int j=0;j<=i;j++){
                        now=now+a[j];
                }
                for(int k=i;k<n;k++){
                        now=now+a[n+k];
                }
                if(now>max){
                        max=now;
                }
        }
        cout << max << endl;
        return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define LEN 100005

typedef struct pp{
    char name[100];
    int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x){
    Q[tail] = x;
    tail = (tail + 1) % LEN;
}

P dequeue(){
    P x = Q[head];
    head = (head + 1) % LEN;
    return x;
}

int min(int a, int b){ return a < b ? a : b; }

int main(){
    int elaps = 0, c;
    int i, q;
    P u;
    scanf("%d %d", &n, &q);

    for (i = 1; i <= n; i++){
        scanf("%s", Q[i].name);
        scanf("%d", &Q[i].t);
    }
    head = 1; tail = n + 1;

    while(head != tail){
        u = dequeue();
        c = min(q, u.t);
        u.t -= c;
        elaps += c;
        if(u.t > 0) enqueue(u);
        else{
            printf("%s %d\n", u.name, elaps);
        }
    }

    return 0;
}



Measured memory_bytes: 11856
#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define sc(x) cin >> x
#define sc2(x, y) cin >> x >> y
#define sc3(x, y, z) cin >> x >> y >> z
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


signed main(void){
  int i, j;
  for(int testcase = 0;testcase < 1234567;testcase++){
    string s;
    vector< pair<i_i, bool> > lis;
    for(;;){
      getline(cin, s);
      if(!s.size())break;
      int sum = 0;
      rep(i, s.size()){
        if(s[i] == ',')break;
        sum *= 10;
        sum += (int)(s[i] - '0');
      }
      rep(i, lis.size())if(lis[i].X.X == sum)break;
      if(i == lis.size())lis.pb(mp(mp(sum, 1), false));
      else ++lis[i].X.Y;
    }
    sort(all(lis));
    for(;getline(cin, s);){
      int sum = 0;
      rep(i, s.size()){
        if(s[i] == ',')break;
        sum *= 10;
        sum += (int)(s[i] - '0');
      }
      rep(i, lis.size())if(lis[i].X.X == sum)break;
      if(i != lis.size()){
        lis[i].Y = true;
        ++lis[i].X.Y;
      }
    }
    rep(i, lis.size())if(lis[i].Y)pri2(lis[i].X.X, lis[i].X.Y);

/*/

//*/ break;
  }
  return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7, N = 1e6 + 7, M = 1e9 + 7;

int f[N], inv[N], fi[N];

int C(int n, int k) {
	return (ll) f[n] * fi[k] % M * fi[n - k] % M;
}
int P(int n, int k) {
	return (ll) f[n] * fi[n - k] % M;
}

signed main()
{
	IO_OP;


	f[0] = 1;
	for(int i = 1; i < N; i++) f[i] = (ll) f[i - 1] * i % M;
	inv[1] = 1;
	for(int i = 2; i < N; i++) inv[i] = M - (ll) M / i * inv[M % i] % M;
	fi[0] = 1;
	for(int i = 1; i < N; i++) fi[i] = (ll) fi[i - 1] * inv[i] % M;
	
	int n, m;
	cin >> n >> m;
	int ans = 0;
	for(int i = 0; i <= n; i++) {
		int cur = (ll) C(n, i) * P(m - i, n - i) % M;
		if(i & 1) ans = (ans - cur + M) % M;
		else ans = (ans + cur) % M;
	}
	ans = (ll) ans * P(m, n) % M;
	cout << ans << endl;

	
}





Measured memory_bytes: 15360
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	// Code for C - Many Medians
	var N int
	fmt.Scanf("%d", &N)

	sc.Split(bufio.ScanWords)
	X := make([]int, N)
	Y := make([]int, N)
	for i := 0; i < N; i++ {
		X[i] = nextInt()
		Y[i] = X[i]
	}

	sort.Sort(sort.IntSlice(Y))
	ans := make(map[int]int, N)
	for i := 0; i < N; i++ {
		if i < N/2 {
			//fmt.Println(X[N/2])
			ans[Y[i]] = Y[N/2]
		} else {
			//fmt.Println(X[(N/2)-1])
			ans[Y[i]] = Y[(N/2)-1]
		}
	}

	for i := 0; i < N; i++ {
		fmt.Println(ans[X[i]])
	}

}


Measured memory_bytes: 13740
#include <bits/stdc++.h>
using namespace std;
 
#define MOD 1000000007
#define INF 100000000
#define MAX 100001
//#define int ll
#define ll long long
#define ld long double
#define vi vector<int>
#define pa pair<int, int>
#define pb push_back
#define mp make_pair
 
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void MACRO_VAR_Scan(First& first, Rest&...rest) { cin >> first; MACRO_VAR_Scan(rest...); }
#define VEC(type, c, n) vector<type> c(n);for(auto& i:c)cin>>i;
#define MAT(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
 
#define BR cout << "\n";
#define SP cout << " ";
#define ENDL cout<<endl;
#define OUT(d) cout<<(d);
#define OUTL(d) cout<<(d)<<endl;
#define YES OUTL("YES")
#define Yes OUTL("Yes")
#define NO OUTL("NO")
#define No OUTL("No")
#define RET return 0;
 
#define REP(i, n) for(int i=0;i<(n);i++)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define FOR(i, m, n) for(int i = m;i < n; i++)
#define RFOR(i, a, b) for(int i=(a)-1;i>=(b);--i)
#define AREP(a, n) for(auto (a):(n))
#define ALL(a) (a).begin(),(a).end()
#define IN(n, a, b) ((a)<=(n)&&(n)<(b))


signed main(){ INIT;
    VAR(int, n, m);
    int d[n][n], a[m], b[m], c[m];
    REP(i, n) REP(j, n) d[i][j] = (i == j ? 0 : MAX);
    REP(i, m){
        VAR(int, s, t, u);
        s--; t--;
        d[s][t] = d[t][s] = u;
        a[i] = s; b[i] = t; c[i] = u;
    }

    REP(k, n) REP(i, n) REP(j, n){
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    }

    int ans = 0;
    REP(i, m){
        int f = 1;
        REP(j, n) if(d[j][a[i]] + c[i] == d[j][b[i]]) f = 0;
        ans += f;
    }
    OUTL(ans);
RET;}


Measured memory_bytes: 256
class UnionFind
    attr_reader :set_size
    def initialize(n)
        @par = Array.new(n)
        n.times{ |i| @par[i] = i }
        @rank = Array.new(n, 0)
        @set_size = Array.new(n, 0)
    end

    def find(x)
        if @par[x] == x
            x
        else
            @par[x] = find(@par[x])
        end
    end

    def unite(x,y)
        x = find(x)
        y = find(y)
        return if x == y

        if @rank[x] < @rank[y]
            @par[x] = y
            @set_size[y] += @set_size[x]
        else
            @par[y] = x
            @set_size[x] += @set_size[y]
            @rank[x] += 1 if @rank[x] == @rank[y]
        end
    end

    def same?(x, y)
        find(x) == find(y)
    end
end

n, m, q = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)

if m % 7 != 0
    (1..6).each do |i|
        as.concat(as[0, q].map{|a| a+i*m})
    end
    m *= 7
    q *= 7
end

uf = UnionFind.new(m)
white = Array.new(m, true)
as.each{|a| white[a] = false}
m.times do |i|
    next unless white[i]
    uf.unite(i, i+1) if white[i+1] && i%7<6
    uf.unite(i, i+7) if white[i+7] && i+7<m 
end

blocks = 7*n/m
num = m.times.count{|i| white[i] && uf.find(i) == i} * blocks

used = {}
7.times do |i|
    j = m-7+i
    if white[i] && white[j] && !(used[uf.find(i)] && used[uf.find(j)])
        num -= blocks - 1
        used[uf.find(i)] = true
        used[uf.find(j)] = true
    end
end
puts num

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

using namespace std;

int main(){
    int n,a[4];
    cin>>n;
    for(int i=3;i>=0;i--){
        a[i]=n%10;
        n/=10;
    }
    int b;
    for(b=0;b<8;b++){
        int ans=a[0];
        for(int i=0;i<3;i++){
            if(b>>i&1)ans+=a[i+1];
            else ans-=a[i+1];    
        }
        if(ans==7)break;
    }
    cout<<a[0]<<(b>>0&1?'+':'-');
    cout<<a[1]<<(b>>1&1?'+':'-');
    cout<<a[2]<<(b>>2&1?'+':'-');
    cout<<a[3]<<"=7"<<"\n";
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		
		int n=s.nextInt();
		int k=s.nextInt();
		
		int[] arr=new int[n];
		
		for(int i=0;i<n;i++)
		{
			arr[i]=s.nextInt();
		}
		
		int[] dp=new int[n];
		
		for(int i=1;i<n;i++)
		{
			int min=Integer.MAX_VALUE;
			
			for(int j=i-1;j>=Math.max(0,i-k);j--)
			{
				if(dp[j]+Math.abs(arr[j]-arr[i])<min)
					min=dp[j]+Math.abs(arr[j]-arr[i]);
			}
			
			dp[i]=min;
		}
		
		System.out.println(dp[n-1]);
		
	}
	
}

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

using namespace std;


int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int ans = pow(3, n);
    int counter = 1;
    for(int i = 0; i < n; i++) {
        if(a[i] % 2 == 0) {
            counter *= 2;
        }
    }
    cout << ans - counter << "\n";
    return 0;
}

Measured memory_bytes: 4036
s = str(input())
n = len(s)
#print(s,n)
ans = 0
for bit in range(1 << (n-1)):
    f = s[0]
    for j in range(n-1):
        if bit & (1 << j):
            f += '+'
        f += s[j+1]
    ans += sum(map(int,f.split('+')))
#    print(f)
print(ans)


Measured memory_bytes: 9180
MOD = 10**9 + 7
def solve(h, w, a):
    dp = [[0]*(w+1) for y in range(h+1)]
    dp[0][0] = 1
    for y in range(h):
        for x in range(w):
            if a[y][x] == ".":
                dp[y+1][x] = (dp[y+1][x] + dp[y][x]) % MOD
                dp[y][x+1] = (dp[y][x+1] + dp[y][x]) % MOD
    return dp[h-1][w-1]

h, w = map(int, input().split())
a = [input() for y in range(h)]
print(solve(h, w, a))

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

int N, M, Q, L[200009], R[200009], X[509][509], C[509][509];

int main() {
	//N, M, Qを読み込む
	cin >> N >> M >> Q;
	//{L}, {R}を読み込み、二次元座標に記録
	for (int i = 1; i <= M; i++) {
		cin >> L[i] >> R[i]; X[L[i]][R[i]]++;
	}
	//座標平面を走査して累積和を求める
	for (int i = 1; i <= N; i++)
		for (int j = 1; j <= N; j++)
			C[i][j] = C[i][j - 1] + X[i][j];
	//クエリにこたえていく
	for (int i = 1; i <= Q; i++) {
		//クエリを読み込む
		int p, q; cin >> p >> q;
		//累積和を利用して、このクエリの問いに答える
		int sum = 0;
		for (int j = p; j <= q; j++) sum += C[j][q] - C[j][p - 1];
		cout << sum << endl;
	}
	return 0;
}


Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;

/* 1fは入力が巨大になるが同様と思われる */
namespace f{
  int main(){
    int N,W;
    cin>>N>>W;
    //vi v(N+1), w(N+1);
    //for(int i=1;i<=N;i++)cin>>v[i]>>w[i];
    vi dp(W+1, 0);

    int v, w;
    for(int i=1; i<=N; i++){
      cin>>v>>w;
      for(int j=W; j>=1; j--){
        if(j>=w){
          dp[j] = max(dp[j], dp[j-w]+v);
        }
      }
    }
    cout<<dp[W]<<endl;
    return 0;
  }
}

int main(){
    f::main();
}


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

int main() {
	int N, D, X;
	cin >> N >> D >> X;
	vector<int> a(N);
	for (int i = 0; i < N; ++i) { cin >> a[i]; }

	int res = X;
	for (int i = 0; i < N; ++i) {
		int d = 1;
		++res;
		while (d + a[i] <= D) {
			++res;
			d += a[i];
		}
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;

#define next '\n'
#define sp " "
#define print(x) cout << (x)
#define println(x) cout << (x) << next
#define stop return(0)
#define rep(i, n) for(int (i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for(int (i) = (start); (i) < (end); (++i))
#define foreach(e, elem) for(auto& (e) : (elem))
#define FAST ios::sync_with_stdio(false); cin.tie(nullptr)
#define size(s) (s).size()
#define all(vec) (vec).begin(), (vec).end()
#define pb(e) push_back(e);
using ll = long long;
using ull = unsigned long long;

int main() {
    FAST;

    int h, w;
    cin >> h >> w;

    rep(i, h){
        rep(j, w){
            string s;
            cin >> s;
            if(s == "snuke"){
                cout << (char)('A' + j) << (i + 1) << endl;
                return 0;
            }
        }
    }
}

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

int main() {
  int a;
  cin >> a;
  if(a<1200){
    cout << "ABC" << endl;
  }
  else if(a>2799){
    cout << "AGC" << endl;
  }
  else{
    cout << "ARC" << endl;
  }
}

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

using namespace std;

#define ll long long int

int main() {
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n; cin >> n;
	
	ll ans = 1;
	
	for(int i = 1; i <= n; i++) {
		ans *= i;
		ans %= ((ll)1e9 + 7);
	}
	
	cout << ans << '\n';
		
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
void rec(int bw[], int w, int bw_w[]);
 
int main(void)
{
    int w;
    int i, k;
    int bw_flag[10];
    int bw_w[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
     
    while (scanf("%d", &w) != EOF){
        for (i = 0; i < 10; i++){
            bw_flag[i] = 0;
        }
         
        rec(bw_flag, w, bw_w);
 
        k = 9;
        while (bw_flag[k] != 1){
            k--;
        }
        for (i = 0; i <= k - 1; i++){
            if (bw_flag[i] == 1){
                printf("%d ", bw_w[i]);
            }
        }
        printf("%d\n", bw_w[k]);
    }
    return (0);
}
void rec(int bw[], int w, int bw_w[])
{
    int i;
     
    for (i = 9; i >= 0; i--){
        if (w - bw_w[i] >= 0){
            w -= bw_w[i];
            bw[i] = 1;
        }
    }
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
int main(){
//    ios::sync_with_stdio(false);
    //freopen("data.txt", "r", stdin);

    string s;
    cin>>s;
    for(auto itr=s.begin();itr!=s.end();++itr){
        if(*itr == ','){
            *itr = ' ';
        }
    }
    cout<<s<<endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
const ll MOD = 998244353;

ll pow(int a, int b){
    ll x = 1;
    for(int i=0;i<b;++i){
        x *= a;
        x %= MOD;
    }
    return x;
}

int main()
{
    int N;
    cin >> N;
    vector<int> D(N);
    int c, max_v = 0;
    bool flag = true;
    for (int i = 0; i < N; ++i)
    {
        cin >> c;
        if(i == 0 && c != 0) flag = false;
        ++D[c];
        max_v = max(c, max_v);
    }

    ll ans = 0;
    if (flag && D[0] == 1)
    {
        ans = 1;
        for (int i = 0; i < max_v; ++i)
        {
            ans *= pow(D[i], D[i+1]);
            ans %= MOD;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"

using namespace std;

constexpr char endl('\n');

long long abso(long long x) {
    return x > 0 ? x : -x;
}

using r_t = size_t;


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

    size_t x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<r_t> p(a);
    vector<r_t> q(b);
    vector<r_t> r(c);
    for (auto& v : p) {
        cin >> v;
    }
    for (auto& v : q) {
        cin >> v;
    }
    for (auto& v : r) {
        cin >> v;
    }

    sort(p.begin(), p.end(), [](r_t a, r_t b) {
        return a > b;
        });
    sort(q.begin(), q.end(), [](r_t a, r_t b) {
        return a > b;
        });
    sort(r.begin(), r.end(), [](r_t a, r_t b) {
        return a > b;
        });
    long long p_i, q_i;
    p_i = x - 1;
    q_i = y - 1;
    for (auto v : r) {
        if (p.at(p_i) > v && q.at(q_i) > v) break;
        if (p.at(p_i) > q.at(q_i)) {
            q.at(q_i--) = v;
        }
        else {
            p.at(p_i--) = v;
        }
        if (p_i < 0) p_i = 0;
        if (q_i < 0) q_i = 0;
    }
    r_t sum = 0;
    for (auto i = 0; i < x; ++i) {
        sum += p.at(i);
    }
    for (auto i = 0; i < y; ++i) {
        sum += q.at(i);
    }
    cout << sum << ::endl;

    return 0;
}


Measured memory_bytes: 2560
#include<iostream>

using namespace std;

void Cal(int N, int X, int T)
{
    int i = 0;
    for( i = 0; N > 0; i++)
    {
        N -= X;
    }
    cout << i * T;
}
int main()
{
    int X, T, N;
    cin >> N >> X >> T;
    Cal(N, X, T);
    return 0;
}

Measured memory_bytes: 3544
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}

int main() {
    int x;
    cin >> x;
    for(int i = 1;i<=100000;i++) {
        int tmp = (ll(i)*ll(i+1))/2;
        if(tmp>=x) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3592
import java.util.*;
 
public class Main {
 	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int K = sc.nextInt();

		for(int i=A; i<=B; i++){
			if(isRange(i, A, A+K-1)==true){
				System.out.println(i);
			}else if(isRange(i, B-K+1, B)==true){
				System.out.println(i);
			}
		}
	}

	public static boolean isRange(int x, int from, int to){
		return (x>=from && x<=to);
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
using namespace std;

typedef pair<int, int> P;

const int MAX_N=100005;

int N, M, S, T;
vector<int> to[MAX_N];
int d[MAX_N][3];
bool visited[MAX_N][3];

void bfs(int st) {
  queue<P> q;
  q.push(P(st, 0));
  d[st][0] = 0;
  visited[st][0] = true;
  while(!q.empty()) {
    int v = q.front().first;
    int l = q.front().second;
    q.pop();
    for(int u : to[v]) {
      if(visited[u][(l+1)%3]) continue;
      visited[u][(l+1)%3] = true;
      d[u][(l+1)%3] = l+1;
      q.push(P(u, l+1));
    }
  }
}

int main() {
  cin >> N >> M;
  int u,v;
  rep(i, M) {
    cin >> u >> v;
    to[--u].push_back(--v);
  }
  cin >> S >> T;
  --S; --T;
  rep(i, N) rep(j, 3) d[i][j] = -1;
  rep(i, N) rep(j, 3) visited[i][j] = false;
  bfs(S);
  int ans = d[T][0];
  cout << (ans!=-1 ? ans/3 : -1) << endl;
  return 0;
}


Measured memory_bytes: 7168
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int count;
		int n;
		
		while(true){
			count = 0;
			if(!sc.hasNext())break;
			n = sc.nextInt();
			for(int i=0;i<10;i++){
				for(int j=0;j<10;j++){
					for(int k=0;k<10;k++){
						for(int l=0;l<10;l++){
							if(i+j+k+l == n)++count;
						}
					}
				}
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 18824
def is_prime(N):
    if N == 1: return False
    if N == 2: return True
    
    d = 2 
    while d*d <= N:
        if N % d == 0: return False
        d += 1
    return True

Q = int(input())

S = [0]*100010
for i in range(3,100010,2):
    S[i] += S[i-2]
    if is_prime(i) and is_prime((i+1)//2):
        S[i] += 1

for q in range(Q):
    l, r = map(int,input().split())
    print(S[r] - S[max(0,l-2)])


Measured memory_bytes: 77016
/*
 * L R
*/

#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <cassert>

using namespace std;

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

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

  int answer = 2020;

  for (long long i = L; i < R; i++) {
    for (long long j = i + 1; j <= R; j++) {
      // printf("%d, %d, %d, %d\n", i, j, (i % 2019) * (j % 2019) % 2019, answer);
      answer = min(answer, (int)((i % 2019) * (j % 2019) % 2019));
    }
  }

  cout << answer << endl;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
N = int(input())
X = input()

x_num = int(X, 2)
cnt1 = X.count('1')

p_zero = x_num % (cnt1 + 1)
p_one = (x_num % (cnt1 - 1) if cnt1 - 1 > 0 else 1)


def f(cnt):
    if (cnt > 0):
        pcount = p_count(cnt)
        return f(cnt % pcount) + 1
    else:
        return 0


def p_count(x):
    cnt = 0
    while (x > 0):
        if x % 2 != 0:
            cnt += 1
        x //= 2
    return cnt


def f1(x):
    cnt = 0
    while (x > 0):
        x %= bin(x).count('1')
        cnt += 1
    return cnt


for i, x in enumerate(list(X)):
    if (x == '1'):
        #x_num = int(''.join(X), 2)
        if cnt1 - 1 > 0:
            xxx = (p_one - pow(2, (N - (i + 1)), cnt1 - 1)) % (cnt1 - 1)
            xxx += cnt1 - 1 if xxx < 0 else 0
            print(f1(xxx) + 1)
        else:
            print(0)
    else:
        #x_num = int(''.join(X), 2)
        xxx = (p_zero + pow(2, (N - (i + 1)), cnt1 + 1)) % (cnt1 + 1)
        xxx += cnt1 + 1 if xxx < 0 else 0
        print(f1(xxx) + 1)


Measured memory_bytes: 90160
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;


signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    int N;cin >> N;
    REPP(h,1,3501){
        REPP(n,1,3501){
        	if(4*h*n - N*n - N*h == 0) continue;
            if((N*n*h) % (4*h*n - N*n - N*h) == 0 && N*n*h / (4*h*n - N*n - N*h) >= 0){
                cout << h << ' ' << n << ' ' << N*n*h / (4*h*n - N*n - N*h) << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s,t;
    cin>>s>>t;
    int S[26]={},T[26]={};
    for(int i=0;i<s.size();i++){
        S[s[i]-'a']++;
        T[t[i]-'a']++;
    }
    sort(S,S+26);
    sort(T,T+26);
    for(int i=0;i<26;i++){
        if(S[i]!=T[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 776
#include <iostream>
#include <cstdio>
#include <cstring>
typedef long long LL;
using namespace std;
int n;
const int M=1046527;
const int L=14;
char dic[M][L];
int Getchar(char ch){
	if(ch=='A') return 1;
	else if(ch=='C') return 2;
	else if(ch=='G') return 3;
	else if(ch=='T')return 4;
}
LL Getkey(const char *str){
	LL p=1,key=0;
	for(int i=strlen(str)-1;i>=0;i--){
		key+=p*Getchar(str[i]);
		p*=5;
	}
	return key;
}
int h1(int k){
	return k % M;
}
int h2(int k){
	return 1+k%(M-1);
}
void insert(const char *str){
	LL key=Getkey(str);
	for(int i=0;;i++){
		LL h=(h1(key)+i*h2(key))%M;
		if(strcmp(dic[h],str)==0) return;
		else if(strlen(dic[h])==0){
			strcpy(dic[h],str);
			return;
		}
	}
}
bool find(const char *str){
	LL key=Getkey(str);
	for(int i=0;;i++){
		LL h=(h1(key)+i*h2(key))%M;
		if(strcmp(dic[h],str)==0) return true;
		else if(strlen(dic[h])==0) return false;
	}
	return false;
}
int main()
{
	scanf("%d",&n);
	for(int i=0;i<M;i++){
		dic[i][0]='\0';
	}
	char com[L],str[L];
	for(int i=0;i<n;i++){
		scanf("%s %s",com,str);
		if(com[0]=='i') insert(str);
		else if(com[0]=='f'){
			if(find(str)) printf("yes\n");
			else printf("no\n");
		}
	}
	return 0;
}



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

int main()
{
    int i, n, k;
    string s;

    cin >> k >> s;
    n = s.size();

    if(n<=k)    cout << s << endl;
    else
    {
        for(i=0; i<k; i++)
            cout << s[i];
        cout << "..." << endl;
    }

    return 0;
}


Measured memory_bytes: 3632
import sys
from functools import reduce
import copy
import math


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    persons = list(inputs[0])

    count = [persons[1:].count("E")]

    for i in range(1, len(persons)):
        if i == 0:
            continue

        tmp = count[-1]
        if persons[i - 1] == 'W':
            tmp += 1
        if persons[i] == 'E':
            tmp -= 1
        count.append(tmp)

    return min(count)


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    input()
    ret = solve(inputs(1))
    print(ret)


Measured memory_bytes: 19832
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;

int main() {
  int n; cin>>n;
  int a[n];
  int count[100002]={0};
  rep(i, n){cin>>a[i];}
  
 rep(i, n){
   int p=a[i];
   count[p-1]++;count[p]++;count[p+1]++;
}

  sort(count,count+100002);
  cout<<count[100001]<<endl;
}


Measured memory_bytes: 1024
ab =input()
ab_list = ab.split(" ")
a = int(ab_list[0])
b = int(ab_list[1])
r = a % b
d = int((a - r) / b)
f = a / b
print(str(d) + " " + str(r) + " " + str("{0:.5f}".format(f)))




Measured memory_bytes: 5608
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string X;
  cin >> X;
  ll count = 0;
  ll count2 = 0;
  ll ans = 0;
  REP(i, X.size()) {
    if (X[i] == 'S') {
      count++;
    } else {
      if (count > 0) {
        count--;
        ans++;
      }
    }
  }
  cout << X.size() - (ans * 2) << endl;
  return 0;
}


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

int main(void) {
  int n;
  cin >> n;
  char a[n + 1], b[n + 1], c[n + 1];
  cin >> a >> b >> c;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == b[i] && b[i] == c[i]) continue;
    else if (a[i] == b[i] || b[i] == c[i] || c[i] == a[i]) {
      cnt++;
      continue;
    } else {
      cnt += 2;
      continue;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256