akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define LONGMAX 1e18
#define ll long long
#define dd double
#define MOD 1000000007
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define endl "\n"
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first	
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define INF 1e9
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
ll powe(ll x,ll y){ll res=1;while(y>0){if(y&1)res=res*x;y=y>>1;x=x*x;}return res;}
ll mpowe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}
void ceilsearch(pair<ll,ll> ar[],ll low,ll high,ll x,ll &y){ll mid=(low+high)/2;if(low>high)return;if(ar[mid].ff>=x){y=mid;ceilsearch(ar,low,mid-1,x,y);}else{ceilsearch(ar,mid+1,high,x,y);}}
int main()
{
	fastio();
	ll N,D,A;
	cin>>N>>D>>A;
	pair<ll,ll> ar[N];
	for(ll i=0;i<N;i++)
	    cin>>ar[i].ff>>ar[i].ss;
	for(ll i=0;i<N;i++)
	    ar[i].ss=(ar[i].ss+A-1)/A;
	s(ar,N);
	pair<ll,ll> v[N];
	ll m=ar[0].ss;// health destroyed by the bomb
	ll j=ar[0].ff+2*D;
    v[0].ff=j;
    v[0].ss=m;//j is x coordinate
	ll ans=ar[0].ss;
	vector<ll> pc;
	pc.pb(0);
	pc.pb(m);
	ll c=1;
	for(ll i=1;i<N;i++)
	{
	    ll hj=-1;
	    ceilsearch(v,0,c-1,ar[i].ff,hj);
	    if(hj!=-1)
	        ar[i].ss=ar[i].ss-(pc[c]-pc[hj]);
	    if(ar[i].ss>0)
	    {
	        v[c]={ar[i].ff+2*D,ar[i].ss};
	        pc.pb(ar[i].ss+pc[c]);
	        c++;
	        ans+=ar[i].ss;
	    }
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 8692
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	int boom[n+2][m+2],pd[n+2][m+2];
	for(int x=0;x<=n+1;x++)
		for(int y=0;y<=m+1;y++)
			pd[x][y]=boom[x][y]=0;
	for(int x=1;x<=n;x++)
	{
		char sr[m];
		cin>>sr;
		for(int y=0;y<m;y++)
			if(sr[y]=='#')pd[x][y+1]=1;
	}
	for(int x=1;x<=n;x++)
		for(int y=1;y<=m;y++)
			if(!pd[x][y])boom[x][y]+=pd[x-1][y-1]+pd[x-1][y]+pd[x-1][y+1]+pd[x][y-1]+pd[x][y+1]+pd[x+1][y-1]+pd[x+1][y]+pd[x+1][y+1];
	for(int y=1;y<=m;y++)
	{
		if(!pd[1][y])cout<<boom[1][y];
		else cout<<"#";
	}
	for(int x=2;x<=n;x++)
	{
		cout<<endl;
		for(int y=1;y<=m;y++)
		{
			if(!pd[x][y])cout<<boom[x][y];
			else cout<<"#";
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
#define llMAX 9223372036854775807LL
#define llMIN -9223372036854775808LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll h,w,k;


  //bit全探索
vi bt;
void setbit(ll i){
  bt.clear();
  for(ll tmp=0;i>0;i/=2){
    if (i%2==1) bt.push_back(tmp);
    tmp++;
  }
}
int calcans(vvi data){
  int vans=0;
  for(ll i=0;i<h;i++){
    for(ll j=0;j<w;j++){
      vans+=data[j][i];
    }
  }
  return vans;
}

int main(){
  ll ans=0;
  cin >> h>>w >> k;

  vvi data(w, vi(h,0));  // N * M の2次元配列
  vvi data2(w, vi(h,0));  // N * M の2次元配列

  string s;
  for(ll i=0;i<h;i++){
    cin>>s;
    for(ll j=0;j<w;j++){
      if (s[j]=='#')data[j][i]=1;
    }
  }







  ll hh=1LL<<h;
  ll ww=1LL<<w;
  for(ll i=0;i<hh;i++){
    for(ll j=0;j<ww;j++){
      copy(data.begin(), data.end(), data2.begin());
      setbit(i);
      for (auto iii : bt) {
        for(int jjj=0;jjj<w;jjj++)
        {
          data2[jjj][iii]=0;
        }
      }
      
      setbit(j);
      for (auto jjj : bt) {
        for(int iii=0;iii<h;iii++)
        {
          data2[jjj][iii]=0;
        }
      }
      ans+=(k==calcans(data2));
      //cout<<calcans(data2)<<endl;
    }
  }






  
  cout<<ans<<endl;
  return 0;
}

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

int main() {
  string S;
  int ans=700;
  cin >> S;
  for (int i=0; i<3; i++) {
    if (S.at(i)=='o') {
      ans=ans+100;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3604
/*
 * test.cpp
 *
 *
 *      Author: Fireworks
 */

#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<map>
#include<cmath>
#include<bitset>
#include<set>
#include<iomanip>
#include<fstream>
#include<bitset>
#include<cstring>
#include<cstdlib>
#include<complex>
#include<list>
#include<sstream>

using namespace std;

typedef pair<int,int> ii;
typedef pair<int,long long> il;
typedef pair<long long,long long> ll;
typedef pair<ll,int> lli;
typedef pair<long long,int> li;
typedef pair<double,double> dd;
typedef pair<ii,int> iii;
typedef pair<double,int> di;
long long mod = 1000000007LL;
long long base = 37;
long long large = 1000000000000000000LL;

long long labs(long long x){
	if(x<0) return -x;
	return x;
}
int main(){
	long long h,w;
	cin>>h>>w;
	if(h%3==0||w%3==0){
		cout<<0<<endl;
		return 0;
	}
	long long high = min(h,w);
	long long temp = 10000000000;
	for(long long i=1;i<h;i++){
		long long a =i*w;
		long long b = (h-i)*(w/2);
		long long c = (h-i)*(w-w/2);
		long long g = labs(a-b);
		g=max(g,labs(b-c));
		g=max(g,labs(c-a));
		temp=min(temp,g);
	}
	for(long long i=1;i<w;i++){
		long long a =i*h;
		long long b = (w-i)*(h/2);
		long long c = (w-i)*(h-h/2);
		long long g = labs(a-b);
		g=max(g,labs(b-c));
		g=max(g,labs(c-a));
		temp=min(temp,g);
	}

	cout<<min(temp,high)<<endl;




	/*int totalcase;
	int testcase=0;
	cin>>totalcase;
	ofstream out;
	out.open("result.txt");

	while(totalcase--){
		testcase++;
		out<<"Case #"<<testcase<<": ";
		cout<<testcase<<": "<<endl;

		//GOGOGO


		//END
	}
	out.close();*/

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;

int main(){
    int n, maxi=0, sum=0, l;
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        scanf("%d", &l);
        sum += l;
        maxi=max(maxi, l);
    }
    sum -= maxi;
    if(maxi < sum )
        printf("Yes\n");
    else
        printf("No\n");
}


Measured memory_bytes: 128
import sys
import io
import math

datalist = input().split()

data_a = int(datalist[0])
data_b = int(datalist[1])
data_k = int(datalist[2])

check_flag = 0
for i in range(data_b,0,-1):
    if data_a % i == 0 and data_b % i == 0:
        check_flag += 1
        if check_flag == data_k:
            print(i)
            sys.exit()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for(long long i = 0; i < n; i++)
#define REPR(i, n) for(long long i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(long long i = m; i <= n; i++)
#define FORR(i, m, n) for(long long i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;



int main(){FIN

    ll mx = 0; ll cnt=0;
    ll n;cin>>n;
    vll h(n);REP(i,n) cin>>h[i];
    REP(i,n){
        if (h[i]>=mx) {cnt++; mx=h[i];}
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <ios>
#include <utility>

using namespace std;

int partition(int A[], int p, int r){
    int x = A[r];
    int i = p - 1;
    for (int j = p; j != r; ++j){
        if (A[j] <= x) swap(A[++i], A[j]);
    }
    swap(A[i + 1], A[r]);
    return i + 1;
}


int main()
{
    ios::sync_with_stdio(false);
    int n = 0;
    cin >> n;
    int A[100000] = {0};
    for (int i = 0; i != n; ++i) cin >> A[i];
    int pivot = partition(A, 0, n - 1);
    for (int i = 0; i != n; ++i){
        if (i == pivot){
            cout << '[' << A[i] << ']';
        }else{
            cout << A[i];
        }
        if (i == n - 1){
            cout << endl;
        }else{
            cout << ' ';
        }
    }
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } 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(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    string s;
    cin >> s;
    string t;
    cin >> t;
    ll ans = 0;
    rep(i, 3){
        if(s[i] == t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
#define int long long
#define double long double
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define sz size()
#define bgn begin()
#define en end()
#define pb push_back
#define pp() pop_back()
#define V vector
#define P pair
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
#define Q queue
#define pri priority_queue
#define Pri priority_queue<int,vector<int>,greater<int>>
#define PriP priority_queue<P<int,int>,vector<P<int,int>>,greater<P<int,int>>>
#define all(a)  (a).begin(),(a).end()

int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}

signed main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a%2==0||b%2==0||c%2==0)
    cout<<0<<endl;
  else{
    int d=min(a,min(b,c));
    int e=max(a,max(b,c));
    int f=a+b+c-d-e;
    cout<<d*f<<endl;
  }
}

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

#define MOD 1000000007
template<typename ty1,typename ty2>
inline int add(ty1 x, ty2 y) {
	if(y>=MOD)y%=MOD;
	if(x>=MOD)x%=MOD;
    x += y; return x < MOD ? x : x - MOD;
}
template<typename ty1,typename ty2>
inline void addto(ty1 &x, ty2 y) {
		  if(y>=MOD)y%=MOD;
		  if(x>=MOD)x%=MOD;
	      x += y; if (x >= MOD) x -= MOD;
}
template<typename ty1,typename ty2>
inline int sub(ty1 x, ty2 y) {
		if(y>=MOD)y%=MOD;
		 if(x>=MOD)x%=MOD;
        x -= y; return x < 0 ? x + MOD : x;
}
template<typename ty1,typename ty2>
inline void subto(ty1 &x, ty2 y) {
	if(y>=MOD)y%=MOD;
	if(x>=MOD)x%=MOD;
    x -= y; if (x < 0) x += MOD;
}
template<typename ty1,typename ty2>
inline int mul(ty1 x, ty2 y) {
        if(y>=MOD)y%=MOD;
		if(x>=MOD)x%=MOD;
        return 1ll * x * y % MOD;
}
template<typename ty1,typename ty2>
void multo(ty1 &x, ty2 y) {
        if(y>=MOD)y%=MOD;
		if(x>=MOD)x%=MOD;
        x=1ll * x * y % MOD;
}

#define MAX 102
int n;
int x;
vector<int> v;

int dp[MAX][501][MAX];


int main(){
	cin>>n>>x;
	for(int i=0;i<n;i++){
		int l;
		scanf("%d",&l);
		v.push_back(l);
	}
	sort(v.begin(),v.end(),greater<int>());
	dp[0][0][0]=1;
	for(int i=0;i<n;i++){
		for(int j=0;j<501;j++){
			for(int k=0;k<=i;k++){
				if(dp[i][j][k]==0)continue;
				//insert alone
				if(j+v[i]<501){
					addto(dp[i+1][j+v[i]][k+1],mul(dp[i][j][k],k+1));
				}
				//merge 2
				if(k>1){
					for(int kk=2;kk<=v[i];kk++){
						if(j+v[i]-kk<501)addto(dp[i+1][j+v[i]-kk][k-1],mul(kk-1,mul(dp[i][j][k],k-1)));
					}
				}
				if(k>0){
					//merge 1
					for(int kk=1;kk<v[i];kk++){
						if(j+v[i]-kk<501)addto(dp[i+1][j+v[i]-kk][k],mul(dp[i][j][k],2*k));
					}
					addto(dp[i+1][j][k],mul(dp[i][j][k],sub(j,k*(v[i]-1))));
				}
			}
		}
	}
	int ans=0;
	for(int k=1;k<=n;k++){
		addto(ans,dp[n][x][k]);
	}
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 19200
#include <iostream>

using namespace std;

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

    int n, k; cin >> n >> k; --k;
    if(((n - 1) >> 1) < k) {cout << -1; return 0;}

    int l = 1, r = (n << 1) - (n >> 1), b = (n << 1) + 1;
    while(l <= n) {cout << l + k << ' ' << r + k << ' ' << b + k << '\n'; l += 2; --r; ++b;}
    l = 2, r = (n << 1);
    while(l <= n) {cout << l + k << ' ' << r + k << ' ' << b + k << '\n'; l += 2; --r; ++b;}
    return 0;
}


Measured memory_bytes: 2304
n,q=map(int,input().split())
s=input()
l=[0]*n
for i in range(1,n):
    l[i]+=l[i-1]
    if s[i-1:i+1]=="AC":
        l[i]+=1

for i in range(q):
    a,b=map(int,input().split())
    print(l[b-1]-l[a-1])

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

int main(){
    int n;
    cin>>n;
    int check[4][13]={0};
    char c;
    int d;
    rep(i, n){
        cin>>c>>d;
        if(c=='S'){
            check[0][d-1]=1;
        }
        if(c=='H'){
            check[1][d-1]=1;
        }
        if(c=='C'){
            check[2][d-1]=1;
        }
        if(c=='D'){
            check[3][d-1]=1;
        }
    }
    rep(i, 4){
        rep(j, 13){
            if(check[i][j]==0){
                if(i==0){
                    cout<<"S "<<j+1<<endl;
                }
                if(i==1){
                    cout<<"H "<<j+1<<endl;
                }
                if(i==2){
                    cout<<"C "<<j+1<<endl;
                }
                if(i==3){
                    cout<<"D "<<j+1<<endl;
                }
            }
        }
    }
}


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

#define REP(i,n) for(ll i=0; i < (n); ++i)
#define REPR(i,n) for(ll i=(n); i >= 0; --i)
#define FOR(i, m, n) for(ll i = (m); i < (n); ++i)

#define INF 1e9

int N, M;
vector<vector<int>> g;
vector<int> homon;

void dfs(int v){
  homon[v] = 1;
  REP(i, N){
    if(g[v][i] == 1 && homon[i] == 0){
      dfs(i);
    }
  }
}
int main(){
  cin >> N >> M;
  homon.resize(N, 0);
  g.resize(N, vector<int>(N,0));
  REP(i, M){
    int a, b;
    cin >> a >> b;
    a--, b--;
    g[a][b] = g[b][a] = 1;
  }
  int cnt = 0;
  REP(i, N){
    REP(j, N){
      if(g[i][j] == 1){
        REP(k, N){
          homon[k] = 0;
        }
        g[i][j] = g[j][i] = 0;
        dfs(0);
        if(homon[j] == 0) cnt++;
        g[i][j] = g[j][i] = 1;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
//#define uint __int128_t
 
#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define low(a,b) lower_bound(all(a),(b))-(a).begin()
#define upp(a,b) upper_bound(all(a),(b))-(a).begin()
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<vint> vvint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;
 

signed main() {
    IOS();
    //(1ll<<N)シフト演算のオーバーフローに気をつける
    //MOD同士の引き算に注意
    int N,M;
    cin>>N>>M;
    if(M==1||N>=M){
        cout<<0<<endl;
        return 0;
    }
    vint v(M);
    rep(i,0,M)cin>>v[i];
    sort(all(v));
    vint a(M-1);
    int ans=0;
    rep(i,0,M-1){
        a[i]=v[i+1]-v[i];
        ans+=a[i];
    }
    sort(all(a));
    reverse(all(a));
    rep(i,0,N-1)ans-=a[i];
    cout<<ans<<endl;
    
    
    return 0;
}

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

using lnt = long long;
using Real = long double;

#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(lnt i=0;i<(n);++i)
#define RANGE(i, a, b) for(lnt i=(a);i<(b);++i)
#define RREP(i, n) for(lnt i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define dcout cout<<fixed<<setprecision(20)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)

constexpr int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr Real eps = 1e-9; const Real pi = acosl(-1);
constexpr lnt BIG = INT_MAX/10, BBIG = LLONG_MAX/10;

template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<class T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<class T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}

using pint = pair<int, int>; using plnt = pair<lnt, lnt>;
using vint = vector<int>; using vlnt = vector<lnt>;
constexpr lnt MOD = 1e9+7;

struct UnionFind {
    vector<int> par;

    UnionFind(int size) : par(size, -1){}
    void init(int n){ par.assign(n, -1); }

    int find(int x){
        if(par[x] < 0) return x;
        else return par[x] = find(par[x]);
    }
    bool same(int x, int y){
        return find(x)==find(y);
    }
    bool unite(int x, int y){
        x = find(x); y = find(y);
        if(x == y) return 0;
        if(par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return 1;
    }
    int size(int x){
        return -par[find(x)];
    }
};

int main(){
    summon_tourist;

    int N; cin >> N;
    map<int, lnt> xcnt, ycnt;
    UnionFind uf(2e5);
    REP(i, N){
        int x, y; cin >> x >> y;
        x--; y += 99999;
        uf.unite(x, y);
    }
    REP(i, 1e5){
        xcnt[uf.find(i)]++;
    }
    RANGE(i, 1e5, 2e5){
        ycnt[uf.find(i)]++;
    }
    lnt ans = 0;
    REP(i, 2e5){
        if(uf.find(i) == i){
            ans += xcnt[i]*ycnt[i];
        }
    }
    ans -= N;
    cout << ans << endl;
}

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

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 V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

struct UnionFind {
  vector<int> par, s;
  UnionFind(int n=2e5) { init(n); }
  void init(int n) {
    s.assign(n, 1); par.resize(n);
    iota(par.begin(), par.end(), 0);
  }
  int find(int x) {
    if(par[x] == x) return x;
    return par[x] = find(par[x]);
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y) return;
    if(s[x] < s[y]) par[x] = y, s[y] = s[x] + s[y];
    else par[y] = x, s[x] = s[x] + s[y];
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return s[find(x)]; }
};

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

  ll k, a, b;
  cin >> k >> a >> b;

  ll cnt = 1;
  if(a+2 < b) {
    // a枚にする
    if(a > k+1) {
      cout << k+1 << endl;
      return 0;
    }
    k -= a-1;
    cnt = a;
    // k/2回 +b-a
    cnt += k/2 * (b - a);
    cnt += k%2;
    cout << cnt << endl;
  } else {
    cout << k+1 << endl;
  }

  return 0;
}

Measured memory_bytes: 256
a, b, m = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
XYZ = []
for i in range(m):
    XYZ.append(list(map(int,input().split())))
ans = 10**5+10**5
for i in range(m):
    a_num = XYZ[i][0]
    b_num = XYZ[i][1]
    if A[a_num-1]+B[b_num-1]-XYZ[i][2] < ans:
        ans = A[a_num-1]+B[b_num-1]-XYZ[i][2]
minAB = min(A) + min(B)
if ans < minAB:
    print(ans)
else:
    print(minAB)


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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    int num_negative = 0, mina=1000000000;
    long long sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        sum += abs(A[i]);
        mina = min(mina, abs(A[i]));
        if (A[i] < 0)
            num_negative++;
    }

    if (num_negative % 2 == 0)
        cout << sum << endl;
    else
        cout << sum - 2 * mina << endl;
    return 0;
}

Measured memory_bytes: 640
import math
[n,x] = [int(i) for i in input().split()]
xs = [int(i) for i in input().split()]
if n != 1:
    xs.append(x)
    xs.sort()
    diff = []
    for i in range(1,n+1):
        diff.append(xs[i] - xs[i-1])
    ans = 0
    for i in range(1,len(diff)):
        if i == 1:
            ans = math.gcd(diff[i-1],diff[i])
        else:
            ans = math.gcd(ans,diff[i])
    print(ans)
else:
    print(abs(x - xs[0]))


Measured memory_bytes: 91488
#include<stdio.h>
#include<string.h>
int main(void){
   char  A[10],B[10],C[10];
    int a,b,c;


    scanf("%s %s %s",A,B,C);
    a=strlen(A);
    b=strlen(B);
    c=strlen(C);

    if(A[a-1]==B[0]){
        if(B[b-1]==C[0]){
            printf("YES");
        }else{
          printf("NO");
        }
    }else{
        printf("NO");
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#pragma GCC optimize(2)
short x[16],y[16];
int p[16];
long long ans[16];
short mi[16],m1[16];
short px[16][16],py[16][16];
int ppk,st;
short cnt,now;
int main(void)
{
 
	char n;
	scanf("%hd",&n);
	for(char i=0;i<n;i++) scanf("%hd%hd%d",&x[i],&y[i],&p[i]);
	int ma=1;
	for(char i=0;i<=n;++i) ans[i]=1000000000000000;
	for(char i=0;i<n;++i) ma*=3;
	for(char i=0;i<n;++i)
	{
		short x1=x[i]>0?x[i]:-x[i],y1=y[i]>0?y[i]:-y[i];
		m1[i]=x1>y1?y1:x1;
	}
	for(char i=0;i<n;++i)
	{
		for(char j=0;j<n;++j)
		{
			px[i][j]=x[i]-x[j];
			py[i][j]=y[i]-y[j];
			if(px[i][j]<0) px[i][j]=-px[i][j];
			if(py[i][j]<0) py[i][j]=-py[i][j];
		}
	}
	for(int zhu=0;zhu<ma;++zhu)
	{
		ppk=zhu,cnt=n,st=ma/3;
		for(char i=0;i<n;i++) mi[i]=m1[i];
		for(char i=0;i<n;i++,st/=3)
		{
			now=ppk/st;
			switch(now)
			{
				case 2:for(char j=0;j<n;++j) if(mi[j]>px[i][j]) mi[j]=px[i][j];break;
				case 1:for(char j=0;j<n;++j) if(mi[j]>py[i][j]) mi[j]=py[i][j];break;
				case 0:cnt--;
			}
			ppk-=st*now;
		}
		long long sum=0;
		for(char i=0;i<n;++i) sum+=(long long)mi[i]*p[i];
		if(ans[cnt]>sum) ans[cnt]=sum;
	}
	for(char i=0;i<=n;i++) printf("%lld\n",ans[i]);
}

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

using namespace std;

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ld, ld> pll;

int main()
{

    int n;
    cin >> n;
    vector<int> a(2 * n);
    for (int i = 0; i < 2 * n; ++i) {
        cin >> a[i];
    }
    sort(all(a));

    int ans = 0;
    for (int i = 0; i < 2 * n; i += 2) {
        ans += a[i];
    }
    cout << ans << "\n";

}


Measured memory_bytes: 256
/*input
1 0
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back

#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)

#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int raise(int a,int n,int m = MOD){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= raise(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

const int N = (1<<17);
int m;
int n;
int k;
vector<int> ok;
vector<int> jo;

void solve(){
  	cin >> m >> k;
  	n = (1<<m);
  	if(k >= n){
  		cout << -1;
  		return;
  	}
  	if(!k){
  		for(int i = 0;i < n;i++){
  			cout << i << " " << i << " ";
  		}
  		return;
  	}
  	int x = -1;
  	int y = -1;
  	for(int i = 0;i < n;i++){
  		int j = i^k;
  		if(i != k and j != k){
  			x = i;
  			y = j;
  			break;
  		}
  	} 
  	if(x == -1){
      	cout << -1;
      	return;
    }
  	for(int i = 0;i < n;i++){
  		if(i != k and i != x and i != y)ok.pb(i);
  	}
    cout << x << " " << k << " ";
    for(int i = 0;i < ok.size();i++)cout << ok[i] << " ";
    cout << x << " " << y << " ";
	for(int i = (int)ok.size()-1;i >= 0;i--)cout << ok[i] << " ";
	cout << k << " "<< y;
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
  return 0;
}

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

typedef long long LL;
int H, W, A, B;
LL dp[200001] = {1,1,};
int saved = 1;
const int MOD = 1e9+7;

LL fact(int x){
  for(int i = saved+1; i <= x; i++)
    dp[i] = (dp[i-1] * i) % MOD;
  saved = max(x, saved);
  return dp[x];
}

LL pow(LL b, LL e) {
  LL ans = 1;
  while(e) {
    if(e&1) ans = (ans*b)%MOD;
    b = (b*b)%MOD;
    e /= 2;
  }
  return ans;
}

LL comb(int n, int r) {
  if(n <= r || r == 0) return 1;
  LL a = fact(n);
  LL b = (fact(r) * fact(n-r)) % MOD;
  LL inv = pow(b, MOD-2);
  return (a * inv) % MOD;
}

int main() {
  cin >> H >> W >> A >> B;
  int n = min(H-A, W-B);
  int a = H-A-1;
  int b = B;
  int c = A;
  int d = W-B-1;
  LL ans = 0;
  for(int i = 0; i < n; i++)
    ans = (ans + (comb(a-i+b+i, a-i) * comb(c+i+d-i, c+i)) % MOD) % MOD;
  cout << ans;
}



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

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct edge{
    ll to, cost;
};


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

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 素数
vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){
        IsPrime.resize(max+1,true);
    } 
    IsPrime[0] = false;
    IsPrime[1] = false;

    for(size_t i=2; i*i<=max; ++i){
        if(IsPrime[i]){
            for(size_t j=2; i*j<=max; ++j){
                IsPrime[i*j] = false;
            }
        }
    }
}

// べき乗の余り
ll modpow(ll a, ll n, ll mod){
    ll res = 1;
    while(n){
        if(n & 1){
            (res *= a) %= mod;
        }else{
            (a *= a) %= mod;
        }
        n >>= 1;
    }
    return res;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

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

    for(ll a=0;a<1e4;++a){
        for(ll b=-1e3;b<1e3;++b){
            if(a*a*a*a*a - b*b*b*b*b == x){
                cout<<a<<' '<<b<<endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3608
<?php
$l=trim(fgets(STDIN));
$c=0;
$n=[];
for($i=0;$i<$l;$i++) $n[]=trim(fgets(STDIN));
echo array_reduce($n,'isPn',$l);

function isPn($carry,$n){
  if($n<2) return --$carry;
  if($n==2) return $carry;
  if($n%2==0) return --$carry;
  $max=floor(sqrt($n));
  for($i=3;$i<=$max;$i+=2) if($n%$i==0) return --$carry;
  return $carry;
}
?>

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


int main()
{
	long long n;
	long long cpy;
	cpy = n;
	std::cin >> n;
	char alpha[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
	std::vector<char> A;

	while (n > 0)
	{
		n--;
		long long p = n % 26;
		char c = alpha[p];
		A.push_back(c);
		n /= 26;

	}
	while (!(A.empty()))
	{
		std::cout << A.back();
		A.pop_back();
	}
	std::cout << '\n';

}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    ll X; cin >> X;
    ll cnt = 0, res = 0;
    while(1){
        res++;
        cnt += res;
        if(cnt >= X) break;
    }

    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/algorithm_ext.hpp>
#include <boost/math/common_factor_rt.hpp>
using namespace std;
using namespace boost::range;
using boost::irange;
using boost::math::gcd;
using boost::math::lcm;

using ll = int64_t;
constexpr char LN = '\n';
template<class T> bool chmax(T& a, const T& b) {if(a<b){a=b;return true;}else{return false;}}
template<class T> bool chmin(T& a, const T& b) {if(b<a){a=b;return true;}else{return false;}}

#ifdef LOCAL
template<class H> void dump_(const char* s, H h) {cout<<s<<"="<<h<<LN; }
template<class H, class... T> void dump_(const char* s, H h, T... t) {for(;*s!=',';++s){cout<<*s;}cout<<"="<<h<<",";dump_(++s,t...);}
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__)
#else
#define dump(...)
#endif

struct init_ {init_(){cin.tie(nullptr);ios::sync_with_stdio(false);}} init_;

template<class C> C scan(size_t n) {C c(n);for(auto& v:c){cin>>v;}return c;}
template<class C> C scan(size_t n, size_t m) {C vss(n);for(auto& vs:vss){vs.resize(m);for(auto& v:vs){cin>>v;}}return vss;}

template<class R> struct Joined { const R& r; const char* s; };
template<class R> Joined<R> joined(const R& r, const char* s = " ") {return{r,s};}
template<class R> ostream& operator<<(ostream& out, Joined<R> j) {bool f=true;for(const auto& v:j.r){if(f){f=false;}else{out<<j.s;}out<<v;}return out;}

template<class T> using matrix = vector<vector<T>>;
template<class T> matrix<T> make_matrix(size_t n, size_t m, const T& init = T()) {matrix<T> vss(n);for(auto& vs:vss){vs.resize(m,init);}return vss;}
template<class T> ostream& operator<<(ostream& out, Joined<matrix<T>> j) {bool a=true;for(const auto& vs:j.r){if(a){a=false;}else{out<<LN;}bool f=true;for(const auto& v:vs){if(f){f=false;}else{out<<j.s;}out << v;}}return out;}

template<class T> void show_(const T& t) {cout<<t;}
template<class T> void show_(const vector<T>& v) {cout<<joined(v);}
void show_(bool b) {cout<<(b?"Yes":"No");}
void show_(double d) {cout<<fixed<<setprecision(12)<<d;}
template<class T, class... TS> void show_(const T& t, TS... ts) {show_(t);cout<<' ';show_(ts...);}
template<class T> void show(const T& t) {show_(t);cout<<LN;}
template<class T, class... TS> void show(const T& t, TS... ts) {show_(t, ts...);cout<<LN;}

int main() {
    ll N, K;
    cin >> N >> K;
    if (N >= K) {
        show(min(N % K, K - (N % K)));
    } else {
        show(min(N, K - N));
    }
}


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

int main() {
	int a, b, c, temp;
	cin >> a >> b >> c;
	if(a > b) {
 		temp = a;
		a = b;
		b = temp;
	}
	if(a > c) {
		temp = a;
		a = c;
		c = temp;
	}
	if(b > c) {
		temp = b;
		b = c;
		c = temp;
	}
	cout << a  << " " << b << " " << c << endl;
}


Measured memory_bytes: 3080
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = (ll)1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* }}} */

int main(){
  ll x, y;
  cin >> x >> y;
  ll res = inf_ll;
  rep(i, -1, 2, 2) rep(j, -1, 2, 2){
    ll t = (i == -1) + (j == -1), xx = x * i, yy = y * j;
    if (xx <= yy) chmin(res, t + yy - xx);
  }
  cout << res << endl;
}


Measured memory_bytes: 256
M1, D1 = map(int,input().split())
M2, D2 = map(int,input().split())
if M1 in [1,3,5,7,8,10] and M1+1 == M2 and D1 ==31 and D2 == 1:
    ans =1
elif M1 ==2 and M2 ==3 and D1==28 and D2 ==1:
    ans = 1
elif M1 == 12 and M2 == 1 and D1 == 31 and D2 ==1:
    ans =1
elif M1 in [4,6,9,11] and M1 +1 == M2 and D1==30 and D2 == 1:
    ans =1
else:
    ans=0
print(ans)

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

public class Main {
	static final int INF = 99999;

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			int n = Integer.parseInt(br.readLine());

			if(n == 0){
				break;
			}

			int[][] dist = new int[10][10];
			int numOfTown = 0;
			for(int i = 0; i < dist.length; i++){
				Arrays.fill(dist[i], INF);
			}

			for(int i = 0; i < n; i++){
				String[] tmpArray = br.readLine().split(" ");

				int a = Integer.parseInt(tmpArray[0]);
				int b = Integer.parseInt(tmpArray[1]);
				int c = Integer.parseInt(tmpArray[2]);

				dist[a][b] = c;
				dist[b][a] = c;

				numOfTown = Math.max(numOfTown, a + 1);
				numOfTown = Math.max(numOfTown, b + 1);


			}

			//debug
//			for(int i = 0; i < numOfTown; i++){
//				for(int j = 0; j < numOfTown; j++){
//					System.out.print(dist[i][j]+" ");
//				}
//				System.out.println();
//			}
//
//			System.out.println("------");

			int[][] shortestPath = allPairsShortestPath(dist, numOfTown);

			solve(shortestPath);
		}
	}

	static void solve(int[][] matrix){
		int n = matrix.length;

		int minId = 0;
		int minSum = Integer.MAX_VALUE;

		for(int i = 0; i < n; i++){
			int tmpSum = 0;

			for(int j = 0; j < n; j++){
//				if(matrix[i][j] != Integer.MAX_VALUE){
					tmpSum += matrix[i][j];
//				}
			}

			if(minSum > tmpSum){
				minId = i;
				minSum = tmpSum;
			}

//			System.out.println("i = "+ i+" "+minId+" "+minSum);
		}

		System.out.println(minId+" "+minSum);
	}

	static int[][] allPairsShortestPath(int[][] input, int n){
//		int n = input[0].length;

		int dist[][] = new int[n][n];

		for(int u = 0; u < n; u++){
			for(int v = 0; v < n; v++){
				dist[u][v] = INF;
			}
			dist[u][u] = 0;

			for(int v = 0; v < n; v++){
				if(u != v && input[u][v] < INF){
					dist[u][v] = input[u][v];
				}
			}
		}

		for(int k = 0; k < n; k++){
			for(int u = 0; u < n; u++){
				for(int v = 0; v < n; v++){
					dist[u][v] = Math.min(dist[u][v], dist[u][k] + dist[k][v]);
				}
			}
		}


		//debug
//		for(int i = 0; i < n; i++){
//			for(int j = 0; j < n; j++){
//				System.out.print(dist[i][j]+" ");
//			}
//			System.out.println();
//		}
		return dist;
	}

}



Measured memory_bytes: 24228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bool isPrime[100001];
void init(){
    isPrime[0]=false;
    isPrime[1]=false;
    for(int i=2;i<=100000;i++){
        if(isPrime[i]){
            for(int j=2;i*j<=100000;j++) isPrime[i*j]=false;
        }
    }
}
int main(void){
    for(int i=0;i<=100000;i++) isPrime[i]=true;
    init();
    bool nita[100001]={};
    for(int i=1;i<=100000;i+=2){
        if(isPrime[i]&&isPrime[(i+1)/2]) nita[i]=true;
    }
    int kosuu[100001]={};
    for(int i=3;i<=100000;i++){
        kosuu[i]=kosuu[i-1]+nita[i];
    }
    int Q;
    cin>>Q;
    for(int i=0;i<Q;i++){
        int L,R;
        cin>>L>>R;
        cout<<kosuu[R]-kosuu[L-1]<<endl;
    }
}

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

#define ll long long
//#define int ll
#define pii pair<int, int>
#define pb push_back
#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define FORD(i, a, b) for (int i=a; i>=b; i--)
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

using namespace std;

void solve() {
    int N, M;
    cin >> N >> M;
    priority_queue<ll> A;
    REP(i, N) {
        ll a; 
        cin >> a;
        A.push(a);
    }

    REP(i, M) {
        ll t = A.top();
        A.pop();
        A.push(t/2);
    }

    ll ans = 0;
    while (!A.empty()) {
        ans += A.top();
        A.pop();
    }
    print(ans);

}

signed main() {
    solve();
}


Measured memory_bytes: 1400
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;
int deco[1000];

void Sequence() {
	string s;
	cin >> s;
	int si = s.size() - 1;
	ll res = 0;
	for (int i = 0; i < (1 << si); i++)
	{
		ll su = 0;
		ll tm = 0;
		int v = i << 1;
		for (int j = 0; j < si + 1; j++)
		{
			if (((v >> j) % 2) == 1) {
				tm += su;
				su = 0;
			}
			su = su * 10 + (s[j] - '1' + 1);
		}
		res += tm + su;
	}
	cout << res << endl;
}
int main() {
	Sequence();
	return 0;
}



Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n,a)= readLine()!!.split(" ").map { it.toInt() }
    val x= readLine()!!.split(" ").map { it.toInt() }
    val xz = x.count{ it==a }
    val xx =(1..xz).fold(1L){acc,i->acc*2}
    val xr = x.filter { it>a }.map { it-a }.sorted()
    val xl = x.filter { it<a }.map { a-it }.sorted()

    var dpr = LongArray(3000)
    run {
        dpr[0] = 1
        var sumr = 0
        xr.forEach {
            val nextDp = LongArray(3000)
            for (i in 0..sumr) {
                nextDp[i] += dpr[i]
                nextDp[i + it] += dpr[i]
            }
            dpr = nextDp
            sumr += it
        }
    }

    var dpl=LongArray(3000)
    run {
        dpl[0]=1
        var suml=0
        xl.forEach {
            val nextDp = LongArray(3000)
            for (i in 0..suml){
                nextDp[i]+=dpl[i]
                nextDp[i+it]+=dpl[i]
            }
            dpl=nextDp
            suml+=it
        }
    }

    val comb = dpr.mapIndexed {index, it -> it*dpl[index] }
    val ans = comb.map { it*xx }.sum()-1

    println(ans)
}

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

using namespace std;

char S[100010];
int K;
int main() {
  scanf("%s", S);
  scanf("%d", &K);
  int N=strlen(S);
  for(int i=0;i<N;++i) {
    int t= S[i] == 'a' ? 0 : 'z' - S[i]+1;
    if (t <= K) {
      K-=t;
      S[i] = 'a';
    }
  }
  if (K>0) {
    S[N-1]= 'a' + (S[N-1] - 'a' + K) % 26;
  }
  printf("%s\n",S);
  return 0;
}


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

int main() {
    int N, K;
    int i;
    int sum = 0;

    cin >> N >> K;

    for(i = 0; i < N; i++){
        int x;
        cin >> x;

        if(x > K - x){
            sum = sum + 2 * (K - x);
        }
        else{
            sum = sum + 2 * x;
        }
    }

    cout << sum << endl;

    return 0;
}

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


int main() {
    int N;
    std::cin >> N;

    std::vector<long long int> A(N);
    for (int i = 0; i < N; i++) {
        std::cin >> A[i];
    }

    std::sort(A.begin(), A.end(), [](auto lhs, auto rhs) { return lhs > rhs; });
    long long int cnt = A[0];
    for (int i = 2; i < N; i++) {
        cnt += A[i / 2];
    }
    std::cout << cnt << std::endl;
}


Measured memory_bytes: 4836
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef         long double      dl;
#define		pb              push_back
#define		PB              pop_back
#define		nn              "\n"
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define		ss              ' '
#define         arrsize(a)      (sizeof(a)/sizeof(a[0]))
//#define       arrsize(a)      (sizeof(a)/sizeof(*a))
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)
typedef        pair <int, int>   pii;
typedef       pair <ll, ll>      pll;
typedef      vector< pair <ll, ll> >      vpll;
typedef		vector<ll>      vll;
typedef		map<string,ll>      msl;
typedef		map<ll,ll>      mll;
#define MAX 1000005


int main()
{
 //O_O ;

        ll t=0,t1=0;
     string a;
     cin>>a;
    for(ll i=0;i<3;i++)
    {
        if(a[i]=='A')
          t++;
         else
            t1++;

    }
    if(t!=0&&t1!=0)
        cout<<"Yes"<<nn;
    else
        cout<<"No"<<nn;





    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
using ll = long long;

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

int dp[100005];
const int INF = 1001001001;

int main() {
  int n, k;
  cin >> n >> k;
  int h[n];
  rep(i, n) cin >> h[i];

  rep(i, n) dp[i] = INF;
  dp[0] = 0;

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

  cout << dp[n - 1] << endl;
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> p(N),dp(N+1,0);
  rep(i,N) cin >> p[i];

  int res = 0;

  rep(i,N) {
    int a = p[i];
    dp[a] = dp[a - 1] + 1;
    res = max(res,dp[a]);
  }
  cout << N - res << endl;
  return 0;
}

Measured memory_bytes: 1792
n,k,s = map(int,input().split())
ans = []
kazu = 0

for i in range(n):
    if kazu != k:
        ans.append(s)
        kazu += 1
    else:
        if s == 1000000000:
            ans.append(1)
        else:
            ans.append(s+1)

for i in ans:
    print(i,end=' ')

print()


Measured memory_bytes: 13044