akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define fr(i,a,b) for(i=a;i<b;i++)
#define rfor(i,a,b) for(i=b-1;i>=a;i++)     // reverse loop
#define yes "YES"
#define no "NO"
#define srt(a) sort(a.begin(),a.end())
#define rsort(a) sort(a.rbegin(),a.rend())          // reverse sort

using namespace std;
const int mod = 1e9 + 7;
vector<ll>prime(1000001,1);
vector<ll>sdf(1000001,1);
long long inf=1000000000000000007;


vector<vector<int>>l;
vector<bool>visited;


/*

int isprime(ll n)
{
    ll i;
    for(i=2;i*i<=n;i++)
    {
        if(n%i==0)
            {//cout<<i<<endl;
            return 0;}
    }
    return 1;
}
int isperfectsq(ll n)
{


    long double x;
    x=(long double)(sqrt((long double )(n)));
    ll y=sqrt(n);
    if(x==y)
        return 1;
        else
            return 0;
}
*/
//ll C[101][101];
/*void ncr()
{
    C[0][0] = 1;
    for (int n = 1; n <= 500000; ++n) {
        C[n][0] = C[n][n] = 1;
        for (int k = 1; k < n; ++k)
            C[n][k] = C[n - 1][k - 1] + C[n - 1][k];
    }
}
*/
/*
void sieve()
{
    //cout<<"in1";
    ll i;
    //sdf[i]=1;
    ll j;
    //for(i=1;i<=1000000;i++)
      //  sdf[i]=i;
    prime[0]=prime[1]=0;
    for(i=2;i<=1000000;i++)
    {
            if(prime[i]){
            //isprime.push_back(i);
            for(j=2*i;j<=1000000;j+=i)
            {
                prime[j]=0;
               // if(sdf[j]==j)
                 //   sdf[j]=i;
                 a[j]++;
            }
            }

    }

}
*/

ll maxi(ll a,ll b,ll c)
{
    ll m1=max(a,b);
    ll m2=max(a,c);
    return max(m1,m2);
}

long long modular_expo(long double x,long long y)
{

    if(y==0)
        return 1;
    if(y%2==0)
        return modular_expo(x*x,y/2);
    if(y%2==1)
        return x*modular_expo(x*x,(y-1)/2);


}
/*
void dfs(int t)
{
    int temp;
    visited[t]=true;
    //cout<<t<<" ";

        for(auto i=l[t].begin();i!=l[t].end();i++)
        {
            if(!visited[*i])
                dfs(*i);
        }

}
*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

   ll n,d;
   cin>>n>>d;
   int cnt=0;
   while(n)
   {
       ll x,y,z;
       cin>>x>>y;
       z=(x*x+y*y);
       if(z<=(d*d))
        cnt++;
    n--;
   }
    cout<<cnt;

}



////////////////////// bit masking ///////////
/*
ll total=long (pow(2,n));
    ll mask,j,cnt=0,ans=0,maxi,mini;
    for(mask=0;mask<total;mask++)
    {
        if(mask==0||mask==1||mask==2||mask==4||mask==8)
                continue;
        cnt=0;maxi=-1000000000000;mini=1000000000000;
        for(i=0;i<n;i++)
        {

            ll f=1<<i;
            if(mask&f)
            {
                maxi=max(maxi,a[i]);
                mini=min(mini,a[i]);
                cnt+=a[i];
            }
        }
        if(cnt>=l&&cnt<=r&&(maxi-mini>=x))
            ans++;


    }
    cout<<ans;
*/
///////////////////////////////////////////////////////


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

using namespace std;

const int N = 2e5+5;

const int mod = 1e9+7;

string s;

int main(){
    cin >> s;
    for(int i = 0; i+1 < s.size(); i++){
        if(s[i] == s[i + 1]){
            cout << i+1 << " " << i + 2 << "\n";
            return 0;
        }
    }
    for(int i = 0; i+2 < s.size(); i++){
        if(s[i] == s[i + 2]){
            cout << i+1 << " " << i + 3 << "\n";
            return 0;
        }
    }
    cout << -1 << " " << -1 << "\n";
}


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

const int INF = 1e18L + 5;

string s,t,res="";
void backtrack(const vector<vector<int> > & dp, int i, int j)
{
if(i<=0&&j<=0)
	return;
if(j-1>=0&&dp[i][j]==dp[i][j-1])
	{
		backtrack(dp,i,j-1);
		return;
	}
else if(i-1>=0&&dp[i][j]==dp[i-1][j])
	 {
		 backtrack(dp,i-1,j);
		 return;
	 }
else if(dp[i-1][j-1]+1==dp[i][j])
	res.push_back(s[i-1]);
backtrack(dp,i-1,j-1);
}

int32_t main()
{
	cin>>s>>t;
	int len1=s.length(),len2=t.length();
	vector<vector<int> > dp(len1+1, vector<int> (len2+1,0));
	for(int i=1; i<=len1; i++)
	{
		for(int j=1; j<=len2; j++)
		{
			dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			if(s[i-1]!=t[j-1])
				dp[i][j]=max(dp[i][j],dp[i-1][j-1]);
			else
				{
					dp[i][j]=max(dp[i][j],dp[i-1][j-1]+1);
				}
		}
	}
	backtrack(dp,len1,len2);
	for(int i=res.length()-1; i>=0; i--)
		cout<<res[i];
	return 0;
}


Measured memory_bytes: 70784
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char 小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define str string
#define please return
#define AC 0
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000

using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */

int a = 0, b = 0, c = 0;

int main(void) {
	Rapid;//固定高速

	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	int k;
	cin >> k;
	if (k < e - a)cout << ":(" << rt;
	else cout << "Yay!" << rt;

	please AC;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,double> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<28;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

ll a,b,x;

int main(){
	cin>>a>>b>>x;
	if(!b) cout<<1<<endl;
	else{
		ll A=(a)?(a-1)/x+1:0,B=b/x+1;
		cout<<B-A<<endl;
	}
}

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

#define ll long long
#define ull unsigned long long 
#define endl '\n'
#define pii pair<int, int>
#define all(a) a.begin(),a.end()

int main(){
    ll a, b, x;
    cin >> a >> b >> x;
    ll fb=0, fa=0;
    if(b>=0)
        fb = b/x+1;
    if(a-1>=0)
        fa = (a-1)/x+1;
    
    cout << fb-fa;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> v(n + 1, 1);
	for (int i = 2; i <= n; i++) {
		int num = i;
		for (int j = 2; j * j <= num; j++) {
			while (num % j == 0) {
				v[j]++;
				num /= j;
			}
		}
		if (num > 1) v[num]++;
	}
	int c5 = 0, c3 = 0;
	int c25 = 0;
	int c15 = 0;
	int c75 = 0;
	for (int i = 1; i <= n; i++) {
		if (v[i] >= 3) c3++;
		if (v[i] >= 5) c5++;
		if (v[i] >= 15) c15++;
		if (v[i] >= 25) c25++;
		if (v[i] >= 75) c75++;
	}
	// cout << c3 << " " << c5 << " " << c15 << " " << c25 << " " << c75 << endl;
	cout << (c3 - c5) * c5 * (c5 - 1) / 2 + c5 * (c5 - 1) * (c5 - 2) / 2 + c15 * (c15 - 1) + (c5 - c15) * c15 + c25 * (c25 - 1) + (c3 - c25) * c25 + c75 << endl;
}


Measured memory_bytes: 3636
#include <stdio.h>

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

int
main(int argc, char *argv[])
{
    int N;
    int B[100];
    int i;
    int sum;

    scanf("%d", &N);
    for (i=0; i<N-1; i++) {
        scanf("%d", B+i);
    }
    B[N-1] = 1000000;

    sum = B[0];
//    printf("%d ", B[0]);
    for (i=0; i<N-1; i++) {
        sum += min(B[i], B[i+1]);
//       printf("%d(%d, %d) ", min(B[i], B[i+1]), B[i], B[i+1]);
    }
//   printf("\n");

    printf("%d\n", sum);

    return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>

#define rep(i,n) for (long long int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

int main()
{
    ll a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    c *= 2;

    ll ans = INF;
    rep(i,100001) {
        ans = min(ans, i*c + (max(0LL,x-i))*a + (max(0LL,y-i))*b);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <limits>
#include <set>
#include <iomanip>
 
int main()
{
    int n{};
    std::cin >> n;
    std::vector<int> nums(n);
    for (int i = 0; i < n; i++) {
        std::cin >> nums[i];
    }

    if (std::all_of(nums.begin(), nums.end(), [](auto x) {
        return (x % 2 == 1) || (x % 3 == 0) || (x % 5 == 0);
    })) {
        std::cout << "APPROVED" << std::endl;
    } else {
        std::cout << "DENIED" << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
	cin.exceptions(ios::failbit);

	int a, b, k;
	int i = 0;
	bool flg = false;
	try
	{
		cin >> k;

		cin.clear();

		cin >> a >> b;

		if ((k > 0 && k <= 1000) &&
			(a > 0 && k <= 1000) &&
			(b > 0 && b <= 1000) &&
			(a <= b))
		{
			for (i = a; i <= b; i++)
			{
				if (i % k == 0)
				{
					flg = true;
					break;
				}
			}
			if (flg)
			{
				cout << "OK" << endl;
			}
			else
			{
				cout << "NG" << endl;
			}
		}
	}
	catch (...)
	{
	}

	return 0;
}

Measured memory_bytes: 3636
#coding:utf-8
#1_6_C 2015.4.5
house = [[[0 for r in range(10)] for f in range(3)] for f in range(4)]

n = int(input())
for i in range(n):
    b,f,r,v = map(int,input().split())
    house[b - 1][f - 1][r - 1] += v

for b in range(4):
    for f in range(3):
        print(' ' + ' '.join(list(map(str,house[b][f]))))
    if b != 3:
        print('#' * 20)

Measured memory_bytes: 6724
#include <iostream>
#include <array>
#include <string>
#include <sstream>

using namespace std;

static bool isOperator(const string& st) {
  return st[0] == '+' || st[0] == '-' || st[0] == '*';
}

class Stack {
public:
  Stack() : stack(), index() {};
  virtual ~Stack() {};
  
  void push(const string& in) {
    stack[index] = in;
    index++;
  }
  string pop() {
    index--;
    return stack[index];
  }
  
private:
  array<string, 100 + 200> stack;
  int index;
};

int main() {
  Stack st;
  string  op1, op2, op, line, elem;
  int op1_i, op2_i, ans;
  
  // input line.
  getline(cin, line);
  stringstream ss(line);
  
  // sprit.
  while (getline(ss, line, ' ')) {
    st.push(line);
    if (isOperator(line)) {
      op = st.pop();
      op2 = st.pop();
      op1 = st.pop();
      op1_i = stoi(op1);
      op2_i = stoi(op2);
      
      switch (op[0]) {
      case '+':
         ans = op1_i + op2_i;
         break;
      case '-':
         ans = op1_i - op2_i;
         break;
      case '*':
         ans = op1_i * op2_i;
         break;
      default:
        break;
      }
      st.push(to_string(ans));
    }
  }
  cout << st.pop() << endl;

  return 0;
}



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

using namespace std;

int main() {
	int a, b;
	cin>>a>>b;
	string s1 = to_string(a);
	string s2 = to_string(b);

	if (s1 <= s2) {
		for (int i = 0;i < b;++i) {
			cout<<s1;
		}
	} 
	else {
		for (int i = 0;i < a;++i) {
			cout<<s2;
		}
	}

	cout<<endl;
	return 0;
}


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

const ll MOD = 1e9+7;

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  
  int w, h, n;
  cin >> w >> h >> n;
  
  vector<pair<int, int>> xy(n);
  int left_x = 0;
  int right_x = w;
  int down_y = 0;
  int up_y = h;
  
  int ans = 0;
  rep(i, n) {
    int x, y, a;
    cin >> x >> y >> a;
    xy[i].first = x;
    xy[i].second = y;
    if(a == 1) {
      if(x >= w) {
        ans = 0;
        cout << 0 << endl;
        return 0;
      }
      left_x = max(left_x, x);
    }
    if(a == 2) {
      if(x <= 0) {
        ans = 0;
        cout << ans << endl;
        return 0;
      }
      right_x = min(right_x, x);
    }
    if(a == 3) {
      if(y >= h) {
        ans = 0;
        cout << ans << endl;
        return 0;
      }
      down_y = max(down_y, y);
    }
    if(a == 4) {
      if(y <= 0) {
        ans = 0;
        cout << ans << endl;
        return 0;
      }
      up_y = min(up_y, y);
    }
  }
  
  if(right_x <= left_x || up_y <= down_y) {
    ans = 0;
    cout << ans << endl;
    return 0;
  }
  else {
    ans =(right_x - left_x)*(up_y - down_y);
    cout << ans << endl;
    return 0;
  }
}
    

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

int main(){
  int N; cin >> N;
  int D[N];
  rep(i,N) cin >> D[i];
  int d;
  rep(i,N) {
    cin >> d;
    D[i] -= d;
  }
  sort(D, D+N);

  ll ntot = 0;
  rep(i,N){
    if (D[i]>=0) break;
    ntot += D[i];
  }

  int j = N-1;
  int j0 = lower_bound(D,D+N,0) - D;
  while (j>=j0 && ntot<0) {
    ntot += D[j];
    j--;
  }
  
  if (ntot<0) cout << -1 << endl;
  else {
    int retval = j0 + N - 1 - j;
    cout << retval << endl;
  }



  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 4004
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>rec(N);
  for(int i=0;i<N;i++){
    cin>>rec.at(i);
  }
  int count=1;
  for(int i=1;i<N;i++){
    bool frag=true;
    for(int j=0;j<i;j++){
      if(rec.at(i)<rec.at(j)){
        frag=false;
        break;
      }
      else{
      }
    }
    if(frag==false){
    }
    else{
      count=count+1;
    }
  }
  cout<<count<<endl;
}
    

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

int main() {
	int a,b; cin >> a >>  b;
	cout << a*b << endl;
}


Measured memory_bytes: 3624
#include<iostream>//AT2684
#include<cstdio>
#include<cstring>
#include<string>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<set>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	cout<<(n-1)*(m-1)<<endl;
	return 0;
}

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

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int v[] = new int[n];
        for (int i = 0; i < n; i++) {
            v[i] = in.nextInt();
        }

        Arrays.sort(v);
        double ans = v[0];
        for (int i = 1; i < n; i++) {
            ans = (ans + v[i]) / 2;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35704
s = input()

#reverse str
s = s[::-1]

#print(s)

comp_eraser = "eraser"
comp_dreamer = "dreamer"
comp_erase = "erase"
comp_dream = "dream"

#reverse
comp_eraser = comp_eraser[::-1] 
comp_dreamer = comp_dreamer[::-1]
comp_erase = comp_erase[::-1] 
comp_dream = comp_dream[::-1]

#print(comp_eraser)

while len(s)>0:
  
  if s.find(comp_eraser) == 0:
    s=s[len(comp_eraser):]
#    print(s,"eraser")
  elif s.find(comp_dreamer) == 0:
#    print(s,"dreamer")
    s=s[len(comp_dreamer):]
  elif s.find(comp_erase) == 0:
#    print(s,"erase")
    s=s[len(comp_erase):]
  elif s.find(comp_dream) == 0:
#    print(s,"dream")
    s=s[len(comp_dream):]
  else:
    print("NO")
    break

if len(s) ==  0:
  print("YES") 





Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ss string
#define ll long long int
#define Endl endl
#define forn for(long long int i=0;i<n-1;i++)
#define u_b upper_bound
#define rep(i,n)         for(int i=0;i<n;i++)
#define ld long double
#define tc long long t;cin>>t;while(t--)
#define fr(i,a,b)        for(long long int i=a;i<=b;i++)
#define E endl
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define V vector<ll>v;
#define aaste long long int n;cin>>n;long long int a[n];for(long long int i=0;i<n;i++)cin>>a[i];
const ll   mod=            1000000007;
const ll   MOD1=           (int)1e9 + 9;
const ll   MOD2=           998244353;
const ld    pi=             atan2(0, -1);
const ld    eps=            1e-9;

const int MAXR = 1000005;
ll         tests=          1;

using namespace std;
int binarySearch(int arr[], int l, int r, int x)
{
	if (r >= l) {
		int mid = l + (r - l) / 2;
		if (arr[mid] == x)
			return mid;
		if (arr[mid] > x)
			return binarySearch(arr, l, mid - 1, x);
		return binarySearch(arr, mid + 1, r, x);
	}
	return l;
}
bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
} 
void swap(ll *p1, ll *p2)
{
   ll temp=*p1;
   *p1=*p2;
   *p2=temp;
}
ll cbratt(ll x)
{
    ll l = 0, r = MAXR;
    while (l != r) {
        ll m = (l + r + 1) / 2;
        if (m * m * m > x)
            r = m - 1;
        else
            l = m;
    }
    return l;
}
// ll ctr=1;
// ll vis[10001];
// ll color[10001];
// vector<ll>v[10001];
// void dfs(ll node,ll colr)
// {
// 	vis[node]=1;
// 	for(ll i=0;i<v[node].size();i++)
// 	{
//        if(!vis[v[node][i]])
//        {
//        	  if(color[v[node][i]]!=colr)
//        	  	ctr++;
//        	dfs(v[node][i],color[v[node][i]]);
//        }
// 	}
// }
 // for(ll i=2;i<=n;i++)
    // {
    //       ll x;
    //      cin>>x;
    //    v[i].push_back(x);
    //    v[x].push_back(i);
    // }
    // fr(i,1,n)
    // {
    // 	cin>>color[i];
    // }
    // ll result=0;
    // dfs(1,color[1]);
    // result+=ctr;
    // cout<<result;
   // for(ll i=1;i<=n;i++)
   // {
   // 	   cout<<i;
   // 	for(ll j=0;j<v[i].size();j++)
   // 	{
   // 		cout<<"-"<<v[i][j];
   // 	}
   // 	cout<<endl;
   // }
int main()
{
    #ifndef ONLINE_JUDGE
	{
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	}
  #endif
ll a,b,c,k;
cin>>a>>b>>c>>k;
ll sum=0;
sum+=min(a,k);
if(k>a)
{
   k=k-a;
   sum+=(min(b,k))*0;
   if(k>b)
   {
    k=k-b;
    sum+=(min(c,k))*-1;
   }
}
cout<<sum;

}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
int N,M;
int f(int X,vi &A){
  int ret=0;
  rep(i,0,N){
    ret+=N-dislow(A,X-A[i]);
  }
  return ret;
}
signed main(){
  cin>>N>>M;
  vi A(N);
  rep(i,0,N) cin>>A[i];
  sort(ALL(A));
  A.pb(INF);
  int left=0,right=INF;
  while(left+1<right){
    int mid=(left+right)/2;
    if(f(mid,A)>=M) left=mid;
    else right=mid;
  }
  int sum=left;
  if(f(right,A)>=M) sum=right;
  int ans=(M-f(sum,A))*sum;
  vi dp(N+1);
  rep(i,0,N) dp[i+1]=dp[i]+A[i];
  rep(i,0,N){
    int X=dislow(A,sum-A[i]);
    ans+=A[i]*(N-X);
    ans+=dp[N]-dp[X];
  }
  cout<<ans<<endl;
  }



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

int main()
{
  int n;cin>>n;
  vector<int> x(n);
  int i;
  for(i=0;i<n;i++)cin>>x.at(i);
  int p;
  int ans=10000000;
  for(p=1;p<=100;p++)
  {
    int kans=0;
    for(i=0;i<n;i++)
    {
      kans+=(x.at(i)-p)*(x.at(i)-p);
    }
    if(kans<ans)ans=kans;
  }
cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 2020000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    for(auto itr = a.begin(); itr != a.end(); itr++){
		cout << *itr << " ";
	}
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){
	cout << "debug: " << a << " " << b << "\n";
}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << "debug: " << a << " " << b << " " << c << "\n";
}
void mark() {cout << "#" << "\n";}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	int n; cin >> n; n--;
	ll ans = 0;
	for(int i=1; i<=n; i++){
		ans += n / i;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  long long int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  long long int f=0;
  for(int i=0;i<n;i++){
    f+=(a[i]-1);
  }
  cout <<f<<endl;
}


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

typedef long long ll;

int main(){
    int n; cin >> n;
    int arr[n][3];
    for(int i=0; i<n; i++){
        for(int j=0; j<3; j++)
            cin >> arr[i][j];
    }
    int dp[n][3];
    dp[0][0] = arr[0][0];
    dp[0][1] = arr[0][1];
    dp[0][2] = arr[0][2];
    for(int i=1; i<n; i++){
        for(int j=0; j<3; j++){
            dp[i][j] = max(dp[i-1][(int)(j+1)%3], dp[i-1][(int)(j+2)%3]) + arr[i][j];
        }
    }
    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << endl;
}

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

int main(){
  int N, t;
  cin >> N;
  string a = to_string(N);
  if(a.at(a.size() - 1) == '3'){
    cout << "bon" << endl;
  }
  else if(a.at(a.size() - 1) == '0' || a.at(a.size() - 1) == '1' || a.at(a.size() - 1) == '6' || a.at(a.size() - 1) == '8'){
    cout << "pon" << endl;
  }
  else
    cout << "hon" << endl;
}

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

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
#define bf(i,s) for(int i = head[s]; i; i = e[i].next)
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define VI vector<int>
#define sf scanf
#define pf printf
#define fp freopen
#define SZ(x) ((int)(x).size())
#ifdef MPS
#define D(x...) printf(x)
#else
#define D(x...)
#endif
typedef long long ll;
typedef double db;
typedef unsigned long long ull;
const int inf = 1<<30;
const ll INF = 1ll<<60;
const db Inf = 1e20;
const db eps = 1e-9;

void gmax(int &a,int b){a = (a > b ? a : b);}
void gmin(int &a,int b){a = (a < b ? a : b);}

int cnt[5];

int main()
{
	#ifdef MPS	
		fp("1.in","r",stdin);
		fp("1.out","w",stdout);
	#endif

	fo(i,1,3)
	{
		int a, b;
		cin >> a >> b;
		cnt[a]++;
		cnt[b]++;
	}
	int x = 0, y = 0;
	fo(i,1,4) if(cnt[i] == 1) ++ x;
	if(x != 2) return 0 * pf("NO\n");
	fo(i,1,4) if(cnt[i] == 2) ++ y;
	if(y != 2) return 0 * pf("NO\n");
	pf("YES\n"); 
	return 0;
}

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

int main(int argc, const char * argv[]) {

    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n,m;
    cin >> n >> m;
    cout << n*(n-1)/2 + m*(m-1)/2 << endl;
}


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

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

int main()
{
	char c;
	int x1,x2,y1,y2;
	int n,m,a,b,ab,ba;
	int tb[32][32];

	cin >> n >> m;
	REP(i,n)REP(j,n)
	{
		tb[i][j] = (i==j ? 0 : 1<<20);
	}

	while(m--)
	{
		cin >> a >> c >> b >> c >> ab >> c >> ba;
		a--; b--;
		tb[a][b] = ab;
		tb[b][a] = ba;
	}
	cin >> x1 >> c >> x2 >> c >> y1 >> c >> y2;

	REP(k,n)REP(i,n)REP(j,n)
	{
		if(tb[i][j]>tb[i][k]+tb[k][j]) tb[i][j]=tb[i][k]+tb[k][j];
	}

	x1--; x2--;
	cout << y1-y2-tb[x1][x2]-tb[x2][x1] << endl;
}

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

template<typename T>
struct Segtree {
    int n;
    T e;
    vector<T> dat;
    typedef function<T(T a, T b)> Func;
    Func f;

    Segtree(int n_input, Func f, T e_input):f(f), e(e_input){
        n = 1;
        while(n < n_input) n <<= 1;
        dat.resize(2*n-1, e);
    }

    void update(int k, T a){
        k += n - 1;
        dat[k] = a;
        while(k > 0){
            k = (k - 1)/2;
            dat[k] = f(dat[2*k+1], dat[2*k+2]);
        }
    }

    void update_if_less(int k, T a){
        if(dat[k+n-1] > a) update(k, a);
    }

    T get(int k){
        return dat[k+n-1];
    }

    T between(int a, int b){
        return query(a, b+1, 0, 0, n);
    }

    T query(int a, int b, int k, int l, int r){
        if(r<=a || b<=l) return e;
        if(a<=l && r<=b) return dat[k];
        T vl = query(a, b, 2*k+1, l, (l+r)/2);
        T vr = query(a, b, 2*k+2, (l+r)/2, r);
        return f(vl, vr);
    }
};

int main(){
    int N, Q, A, B;
    cin >> N >> Q >> A >> B;
    int X[200001];
    X[0] = A;
    for(int i=1; i<=Q; i++) cin >> X[i];

    const int64_t INF = 1e18;
    Segtree<int64_t> stdec(N+1, [](int64_t a, int64_t b){return min(a, b);}, INF);
    Segtree<int64_t> stinc(N+1, [](int64_t a, int64_t b){return min(a, b);}, INF);
    stdec.update(B, N-B);
    stinc.update(B, B);

    int64_t sum = 0;
    for(int i=1; i<=Q; i++){
        sum += abs(X[i] - X[i-1]);
        int64_t cost = min(stdec.between(0, X[i]) - (N-X[i]), stinc.between(X[i], N) - X[i]);
        cost -= abs(X[i] - X[i-1]);
        stdec.update_if_less(X[i-1], cost + N-X[i-1]);
        stinc.update_if_less(X[i-1], cost + X[i-1]);
    }
    int64_t ans = INF;
    for(int i=1; i<=N; i++) ans = min(ans, stinc.get(i) - i);
    ans += sum;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9344
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc159_a.cpp
 * time   : Sat May  2 19:57:06 2020
 * quest  : A - The Number of Even Pairs
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int m, n;
  cin >> n >> m;
  cout << (n < 2 ? 0 : (n * (n - 1)) / 2) + (m < 2 ? 0 : (m * (m - 1)) / 2) << "\n";
  return 0;
}


Measured memory_bytes: 256
import numpy as np
N=int(input())
x_origin=0
y_origin=0
t_origin=0
flag=0
a=[]
for i in range(N):
    a.append(list(map(int,input().split())))

for i in range(N):
    b=np.abs(a[i][0]-t_origin)
    c=np.abs(a[i][1]-x_origin)
    d=np.abs(a[i][2]-y_origin)
    if b>=c+d:
        if (b-(c+d))%2==0:
            continue
        else:
            flag=1
            break
    else:
        flag=1
        break
if flag==1:
    print("No")
else:
    print("Yes")
        
        

Measured memory_bytes: 36308
#include <bits/stdc++.h>
#define PI acos(-1)
#define falcon ios_base::sync_with_stdio(false) ; cin.tie(NULL) ;
typedef long long ll ;
using namespace std ;

char grid[1001][1001] ;
int paths[1001][1001] ;

int main()
{
    falcon ;

    int n , m ;
    cin >> n >> m ;
    for(int i = 0 ; i < n ; i++)
    {
        for(int j = 0 ; j < m ; j++)
        {
            cin >> grid[i][j] ;
            paths[i][j] = 0 ;
        }
    }
    paths[0][0] = 1 ;
    for(int i = 0 ; i < n ; i++)
    {
        for(int j = 0 ; j < m ; j++)
        {
            if(grid[i][j] == '#') continue ;
            if(i > 0) paths[i][j] = paths[i][j] + paths[i - 1][j] ;
            if(j > 0) paths[i][j] = paths[i][j] + paths[i][j - 1] ;
            paths[i][j] = paths[i][j] % 1000000007 ;
        }
    }
    cout << paths[n - 1][m - 1] << "\n" ;
}

Measured memory_bytes: 8544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
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 (a>b) { a = b; return 1; } return 0; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;


int main(){
    ll A, B;
    cin >> A >> B;
    ll res = 0;
    FOR(i, A, B+1) {
        string S = to_string(i);
        bool can = true;
        REP(j, S.size()/2) {
            if (S[j] != S[S.size()-j-1]) can = false;
        }
        if (can) res++;
    }
    cout << res << "\n";
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] tmpArray = br.readLine().split(" ");
		int n = Integer.parseInt(tmpArray[0]);
		
		Activity[] acts = new Activity[n];
		for(int i = 0; i < n; i++){
			tmpArray = br.readLine().split(" ");
			
			int start = Integer.parseInt(tmpArray[0]);
			int end = Integer.parseInt(tmpArray[1]);
			
			acts[i] = new Activity(start, end);
		}
		
		Arrays.sort(acts);
		
		int count = 1;
		int currentTime = acts[0].end;
		
		for(int i = 1; i < n ; i++){
			if(currentTime < acts[i].start){
				count++;
				currentTime = acts[i].end;
			}
		}
		
		System.out.println(count);
	}

}

class Activity implements Comparable<Activity>{
	int start;
	int end;
	
	public Activity(int s, int e){
		this.start = s;
		this.end = e;
	}

	@Override
	public int compareTo(Activity a1) {
		return this.end - a1.end;
	}
	
}



Measured memory_bytes: 65988
#include<bits/stdc++.h>
using namespace std;
using p=pair<int,int>;
#define int long long
#define rep(i,N) for(int i=0;i<N;i++)

signed main(){
  int N;
  cin>>N;
  vector<int> P(N);
  rep(i,N)cin>>P[i];
  int num=0;
  string ans="YES";
  rep(i,N){
    if(P[i]!=i+1)num++;
    if(num>=3)ans="NO";
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
//config = { input: 'tmp', newline: '\r\n' }; // win
config = { input: '/dev/stdin', newline: '\n' }; // linux

line = require('fs').readFileSync(config.input, 'ascii')
  .trim()
  .split(config.newline);
n = Number(line.shift());
adj = {};
for (i in line) {
  ary = line[i].split(' ');
  j = ary.shift();
  ary.shift();
  adj[j] = ary;
}

for (i in adj)
  adj[i].sort(function (a, b) { return Number(a) - Number(b); });

d = {};
f = {};
t = 0;
cur = null;
rest = null;
stack = [];

function detect(node) {
  stack.push([cur, rest]);
  t++;
  d[node] = t;
  cur = node;
  rest = [].concat(adj[node]);
}

function finish(node) {
  var ary;
  t++;
  f[node] = t;
  ary = stack.pop();
  cur = ary[0];
  rest = ary[1];
}

function round(from) {
  var child;
  detect(from);
  while (cur) {
    while (rest.length !== 0) {
      child = rest.shift();
      if (!d.hasOwnProperty(child)) detect(child);
    }
    finish(cur);
  }
}

for (i = 1; i <= n; i++)
  if (!d.hasOwnProperty(String(i))) round(String(i));

for (i = 1; i <= n; i++)
  console.log("%d %s %s", i, d[i], f[i]);

Measured memory_bytes: 16764
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,k,count = 0;
  cin >> n >> k;
  vector <int> h(n);
  for(int i=0;i<n;i++){
    cin >> h.at(i) ;
  }
  for(int i=0;i<n;i++){
    if(h.at(i) >=k){
      count ++;
    }
  }
  cout << count << endl;
}
      

  
  





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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

int main() {
    int A, B;
    cin >> A >> B;
    cout << A * B << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a, b;cin>>a>>b;
    if(a<b){
        for(int i=0; i<b; i++){
            cout<<a;
        }
    }
    else{
        for(int i=0; i<a; i++){
            cout<<b;
        }
    }
    cout<<endl;
}


Measured memory_bytes: 256
SA = gets.chomp.chars
SB = gets.chomp.chars
SC = gets.chomp.chars

ans = ""
t = 'a'
while true do
  (ans = 'A'; break) if t == 'a' && SA.empty?
  (ans = 'B'; break) if t == 'b' && SB.empty?
  (ans = 'C'; break) if t == 'c' && SC.empty?
  case t
  when 'a'; t = SA.shift
  when 'b'; t = SB.shift
  else    ; t = SC.shift
  end
end

puts ans


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;

ll binpow(ll a, ll b) {
    if (b == 0)
    {
        return 1;
    }
    ll res = binpow(a, b / 2);
    res*=res;
    if (b % 2)
    {
        return res * a;
    }
    return res;
}

ll gcd(ll a,ll b)
{
    if (b==0) return a;
    return gcd(b,a%b);
}

string to_upper(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
    return a;
}
 
string to_lower(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
    return a;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n,m;
    cin>>n>>m;
    cout<<n*m;
    return 0;
}

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

using pint = pair<int,int>;

int N;
vector<vector<pint>> v;

int main() {
    int N;
    cin >> N;
    v.resize(N);
    for (int i = 0;i < N;i++){
        int A; cin >> A;
        v[i].resize(A);
        for (int j = 0;j < A;j++){
            cin >> v[i][j].first >> v[i][j].second;
            v[i][j].first--;
        }
    }

    int ans = 0;

    for (int bit = 0;bit < (1 << N);bit++){
        int flag = 0;
        for (int i = 0;i < N;i++){
            if ((bit & (1 << i)) == 0) continue;
            for (pint xy :v[i]){
                int x = xy.first;
                int y = xy.second;
                if (!(bit & (1 << x)) && y == 1) flag = 1;
                if ((bit & (1 << x)) && y == 0) flag = 1;
            }
        }
        if (flag == 0){
            int count = 0;
            for (int i = 0;i < N;i++){
                if ((bit & (1 << i))) count ++;
            }
            ans = max(ans,count);
        }
    }

    cout << ans << endl;

}

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

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

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll L, R;
    cin >> L >> R;
    
    if(R-L>=2019) {
        L %= 2019;
        R = L + 2019;
    }
    ll m = 2019;
    REP(i,L,R) {
        REP(j,i+1,R+1) {
            m = MIN(m,(i*j)%2019);
        }
    }
    PR(m);

    return 0;
}

/*



*/

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

void call(int n){
    
    for (int i = 1; i <= n; i++) {
        int x = i;
        if (x % 3 == 0){
            cout << " " << i;
            continue;
        }
        while(x > 0) {
            if (x % 10 == 3){
                cout << " " << i;
                break;
            }
            x /= 10;
        }
    }

  cout << endl;
}

int main(){
    int N;
    cin >> N;
    call(N);
    return 0;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define one 1.0
#define inf 1000000000000000000
#define ret return
#define all(vl) vl.begin(),vl.end()
#define sor sort 
#define cl clear
#define m_p make_pair 
#define sz(a) a.size()
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;
typedef map<string,ll> mapstl;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string s,t;
	cin>>t>>s;
	cout<<s<<t<<endl; 
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main() {
    int n, a[1005];
    cin >> n;
    cout << fixed << setprecision(6);

    while (n > 0) {        
        double sum = 0;
        for (int i=0; i<n; i++) {
          cin >> a[i];
          sum = sum + a[i];
        }

        double mean = sum / n;
        double var = 0;
        for (int i=0; i<n; i++) {
          var = var + (a[i] - mean)*(a[i] - mean);
        }
        cout << sqrt(var/n) << endl;

        cin >> n;
    }
}


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

int main() {
	double W, H, x, y;
	cin >> W >> H >> x >> y;

	cout << W * H / 2.0 << endl;
	if (W / 2 == x && H / 2 == y) {
		cout << 1 << endl;
	}
	else {
		cout << 0 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
N, D = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(N)]

res = 0

for i in range(N):
  for j in range(i, N):
    if i != j:
      tmp = 0
      for k in range(D):
        tmp += (L[i][k] - L[j][k]) ** 2
      
      import math
      tmp = math.sqrt(tmp)
      if tmp - int(tmp) == 0:
        res += 1
        
print(res)



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

typedef long long ll;


int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	if (n % 1000 == 0) {
		cout << "0\n";
		return 0;
	}
	int sum = 0;
	while (sum < n) {
		sum += 1000;
	}
	cout << sum - n << "\n";
}


Measured memory_bytes: 3584
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main()
{
    int x,y,c,d,e,a,b;
    while(~scanf("%d%d",&x,&y))
    {
        c=x+y;
        d=x-y;
        e=x*y;
        if(c>d)
            a=c;
        else
            a=d;
        if(a>e)
            b=a;
        else
            b=e;
        printf("%d\n",b);

    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll a,b,n;
	cin>>a>>b>>n;
	ll x;
	if(n>=b){
		x=b-1;
	}
	else{
		x=n;
	}
	cout<<a*x/b-a*(x/b)<<endl;
	return 0;
}

Measured memory_bytes: 3624
/*
テヲテδ欲ツ法ツづ可づヲツづィツ嘉ーツつッツづ慊つキ(ツつ?づィツ本ツ妥ヲ2ツ氾?づ?P.24ツつセツづヲツ！)
- ツ債カツづ個暗ェツ氾板湘」ツづ個仰?づ個値ツづ? ツ右ツづ個暗ェツ氾板湘」ツづ個仰?づ個値ツづーツ個ゥツ氾、ツづ猟づ?
  ツ妥・ツつォツつ「ツ値ツづ個個環づ個陛サツづ? ツ仰?づーツ禿シツづェツづァツづェツづゥツづ按づァツ禿シツづェツつスツ陛サツつェツつ「ツつ「.
- ツつアツづェツづ? ツ渉ャツつウツつ「ツ値ツづ個個環づーツ残ツつオツつスツ陛サツつェ, ツ古」ツ々ツつィツ督セツづ可づ按づゥツつゥツづァツづ?つキ.
- ツ「ツ妥・ツつォツつ「ツ陛サツづ可禿シツづェツづァツづェツづゥツづ按づァツ禿シツづェツづゥツ」ツ?ィツ「ツつサツづェツづ?つセツづ淞づ按づァツ渉ャツつウツつ「ツ陛サツづ可禿シツづェツづゥツ」ツ?ィツ「ツつサツづェツづ?づ?ダツδ?づ按づァNOツ」ツづーツδ仰ーツプツづ?繰ツづィツ陛板つオツづ慊つオツづ・ツつ、.
 */
#include <iostream>
using namespace std;

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

  while(T--){
    int b = 0; //ツ?ゥツづ個つ?づ?
    int c = 0; //ツ?ィツづ個つ?づ?
    bool ans = true; //ans == trueツづ按づァYES, ans == falseツづ按づァNO

    for(int i = 0; i < 10; i++){
      int a;
      cin >> a;

      //ツつキツづ?づ丑Oツづ?づュツつゥツづ?づ?つ「ツづゥツづ按づァ, ツ渉按猟敖づーツつケツつクcontinue
      if(!ans) continue;

      //ツ?ゥツづ個個環づ個暗ェツ氾板湘」ツづ個値ツづヲツづィ, ツ?ィツづ個個環づ個暗ェツ氾板湘」ツづ個値ツづ個陛サツつェツ妥・ツつォツつ「
      if(b < c){
        if(c < a)      c = a;       //ツ妥・ツつォツつ「ツ陛サ(ツ?ィ)ツづ可湘ヲツつケツづァツづェツづゥツづ按づァツ湘ヲツつケツづゥ(ツつサツづ個陛サツつェツ古」ツ々ツ督セツつセツつゥツづァ)
        else if(b < a) b = a;
        else           ans = false; //ツ渉ャツつウツつ「ツ陛サ(ツ?ゥ)ツづ可づ?湘ヲツつケツづァツづェツづ按つゥツづ?つスツづァ, NOツづ?づ按づゥ
      }
      //ツ?ゥツづ個個環づ個暗ェツ氾板湘」ツづ個値ツづヲツづィ, ツ?ィツづ個個環づ個暗ェツ氾板湘」ツづ個値ツづ個陛サツつェツ渉ャツつウツつ「
      else{
        if(b < a)      b = a;       //ツ妥・ツつォツつ「ツ陛サ(ツ?ゥ)ツづ可湘ヲツつケツづァツづェツづゥツづ按づァツ湘ヲツつケツづゥ(ツつサツづ個陛サツつェツ古」ツ々ツ督セツつセツつゥツづァ)
        else if(c < a) c = a;
        else           ans = false; //ツ渉ャツつウツつ「ツ陛サ(ツ?ィ)ツづ可づ?湘ヲツつケツづァツづェツづ按つゥツづ?つスツづァ, NOツづ?づ按づゥ
      }
    }

    if(ans) cout << "YES\n";
    else    cout << "NO\n";
  }
}

Measured memory_bytes: 0
import java.util.*;

public class Main{
	
	static int countP = 0;
	static int countQ = 0;
	
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int P = 0;
		for(int i = 0; i < N; i++){
			P *= 10;
			P += sc.nextInt();
		}
		int Q = 0;
		for(int i = 0; i < N; i++){
			Q *= 10;
			Q += sc.nextInt();
		}
		
		StringBuffer seed = new StringBuffer("");
		for(int i = 0; i < N; i++){
			seed.append((i+1));
		}
		
		permutation(seed.toString(), "", P, Q);
		
		System.out.println(Math.abs((countP - countQ)));
	}
	
    public static void permutation(String q, String ans, int P, int Q){
        // Base Case
        if(q.length() <= 1) {
        	if(Integer.valueOf(ans + q) > P)
        		countP++;
        	if(Integer.valueOf(ans + q) > Q)
        		countQ++;
        }
        // General Case
        else {
            for (int i = 0; i < q.length(); i++) {
                permutation(q.substring(0, i) + q.substring(i + 1),
                        ans + q.charAt(i), P, Q);
            }
        }
    }
}

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

P p[100];
double det(P a, P b) {
	return a.first*b.second - a.second*b.first;
}
P operator-(P a, P b) { return P(a.first - b.first, a.second - b.second); }
int main() {
	int n;
	while (scanf("%d", &n), n) {
		rep(i, n)scanf("%lf,%lf", &p[i].first, &p[i].second);
		sort(p, p + n);
		vector<P>a(n * 2);
		int k = 0;
		rep(i, n) {
			while (k > 1 && det(a[k - 1] - a[k - 2], p[i] - a[k - 2]) < 0)k--;
			a[k++] = p[i];
		}
		for (int i = n - 2; i >= 0; i--) {
			while (k > 1 && det(a[k - 1] - a[k - 2], p[i] - a[k - 2]) < 0)k--;
			a[k++] = p[i];
		}
		printf("%d\n", n - k + 1);
	}
}

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

using namespace std;

int main (void) {
    int N;
    string S;
    cin >> N >> S;

    int n_l = 0;
    int n_r = 0;
    for ( int i = 0; i < N; i++ ) {
        if ( S.at(i) == '(' ) {
            n_l++;
        }
        else if ( n_l == 0 ) {
            n_r++;
        }
        else {
            n_l--;
        }
    }

    for ( int i = 0; i < n_r; i++ ) {
        cout << '(';
    }
    cout << S;
    for ( int i = 0; i < n_l; i++ ) {
        cout << ')';
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 1e9;
const LL INF = 1e9;

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n;
    cin>>n;
    LL a[n];
    loop(i,0,n) cin>>a[i];

    LL p = a[0], ans = 0;
    loop(i,1,n)
    {
        if(a[i] < p) ans += (p - a[i]);
        else p = a[i];
    }

    cout<<ans<<'\n';

    /*
    int t,n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        int a[n];
        loop(i,0,n)
        {
            cin>>a[i];
        }
    }
    */

    /*
    int n;
    cin>>n;
    int a[n];
    loop(i,0,n)
    {
        cin>>a[i];
    }
    */

    /*
    cout<<ans<<'\n';

    if(f) cout<<"YES\n";
    else cout<<"NO\n";

    if(f) cout<<"Yes\n";
    else cout<<"No\n";
    */

    return 0;
}


Measured memory_bytes: 5200