akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using piii = pair<int, pii>;
using plll = pair<ll, pll>;
using pib = pair<int, bool>;
using pdi = pair<double, int>;
using pid = pair<int, double>;
using ld = long double;//__float128;
using piiii = pair<pii, pii>;

#define endl "\n"
#define inf 0x3f3f3f3f3f
#define f first
#define s second

ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

int n, d, a, x, y;
ll diff[200001];
vector<pii> arr;

int main() {
    //freopen("cowmbat.in", "r", stdin);
    //freopen("cowmbat.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> d >> a;
    for (int i=0; i<n; i++){
        cin >> x >> y;
        arr.push_back({x, y});
    }
    sort(arr.begin(), arr.end());
    int r = 0;
    ll ans = 0;
    for (int i=0; i<n; i++){
        while (r<n&&arr[r].f<=arr[i].f+2*d) r++;
        if (i>0) diff[i] += diff[i-1];
        ll div = max(0LL, (ll) ceil((ld) (arr[i].s-diff[i])/a));
        diff[i+1] += div*a;
        diff[r] -= div*a;
        ans += div;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3568
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
using namespace std;

int main(void){
 long long int A,B,C;
 cin>>A>>B>>C;
 cout<<B+min(A+B+1,C)<<endl;
 return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


template <class T> void chmin(T&a, const T&b) { a = min(a,b); }
template <class T> void chmax(T&a, const T&b) { a = max(a,b); }

const double EPS =1e-9;
const long INF =999999999;
const long MOD =1000000007; //10^9+7
#define PI 3.14159265258979

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

int main(void){
	int N,M;
	char A[51][51]={},B[51][51]={};
	bool flug;
	cin>>N>>M;
	REP(i,N)
		REP(j,N)
			cin>>A[j][i];

	REP(i,M)
		REP(j,M)
			cin>>B[j][i];

	REP(i,N-M+1){
		REP(j,N-M+1){
			flug=true;
			REP(di,M){
				REP(dj,M){
					if(B[di][dj]!=A[di+i][dj+j]){
						flug=false;
						break;
					}
				}
			}
			if(flug) goto exit;
		}
	}

exit:
	if(flug) puts("Yes");
	else puts("No");

	return 0;
}



Measured memory_bytes: 256
// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2")

#include <iostream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <chrono>
#include <vector>
#include <map>
#include <random>
#include <set>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <stdio.h>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <deque>
#include <cassert>
#include <stack>
using namespace std;

#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ppb pop_back
#define ll long long
#define ull unsigned long long
#define cntbit(x) __builtin_popcount(x)
#define endl '\n'
#define uset unordered_set
#define umap unordered_map
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define ld long double
#define pll pair<long long, long long>

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

inline void setin(string s) {
	freopen(s.c_str(), "r", stdin);
}

inline void setout(string s) {
	freopen(s.c_str(), "w", stdout);
}

template <typename T> inline T range(T l, T r) {
	return uniform_int_distribution <T>(l, r)(rng);
}

template <typename T> void Min(T &a, T b) {
    a = min(a, b);
}
 
template <typename T> void Max(T &a, T b) {
    a = max(a, b);
}

const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int N = 1e5 + 15;
int n, p[N];
string s;

int sz[N];

inline bool check(string s) {
	string t = s;
	reverse(t.begin(), t.end());
	return t == s;
}

main() {
	ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
	// setin("input.txt");
	cin >> s;
	n = s.size();
	s = "0" + s;
	if(!check(s) || s[1] == '0' || s[n] == '1')
		return cout << -1 << endl, 0;
	for(int i = 1; i <= n; ++i)
		p[i] = i-1;
	sz[1] = 1;
	for(int i = 2; i < n; ++i) {
		sz[i] = i;
		// sz[i] = sz[p[i]] + 1;
		if(s[n - i + 1] == '0') {
			p[i+1] = p[i];
		}
	}
	for(int i = 2; i <= n; ++i)
		cout << p[i] << ' ' << i << endl;
	return 0;
}

Measured memory_bytes: 2412
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int M=0;
  bool Z=false;
  cin >> N;
  vector<int>vec(N);
  for (int X=0; X<N; X++){
    cin >> vec.at(X);
  }
  for (int X=0; X<N; X++){
    Z=false;
    for (int Y=X-1; Y>=0; Y--){
      if (vec.at(X)==vec.at(Y)){
        Z=true;
      }
      else if (Y==0 && Z==false){
        M+=1;
      }
    }
  }
  cout << M+1 << endl;
}

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

vector<int> x(10), y(10);

double distance(int i, int j) {
  double dx = x[i] - x[j];
  double dy = y[i] - y[j];
  return sqrt(dx * dx + dy * dy);
  // return pow(dx * dx + dy * dy, 0.5);
}

int main() {
  int N;
  cin >> N;
  for (int i = 1; i <= N; ++i) {
    cin >> x[i] >> y[i];
  }

  // 点（町）の順番の配列を0〜N-1番まで作成
  vector<int> v(N);
  for (int i = 0; i < N; ++i) {
    v[i] = i + 1;
  }

  // 階乗の計算
  int cnt = 1;
  for (int i = 1; i <= N; ++i) cnt *= i;

  // 今いる町v[i]から、次の町v[i+1]までの距離を求め、総和（dis_sum）を計算。
  // next_permutation()で順列の総数分（vの組み合わせを変え、trueを返すので）繰り返す。
  double dis_sum = 0.0;
  do {
    for (int i = 0; i < N - 1; ++i) {
      dis_sum += distance(v[i], v[i + 1]);
    }
  } while (next_permutation(v.begin(), v.end()));

  // 浮動小数点10桁までの精度で「距離の平均」を出力。
  cout << setprecision(10) << dis_sum / cnt << endl;
  return 0;
}

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

int main()
{
    ll n,W,i,j,w;
    cin>>n>>W;
    ll ar[n+1][3];
    for(ll i=1;i<=n;i++)
        for(ll j=1;j<=2;j++)
            cin>>ar[i][j];

    ll K[n+1][W+1];
    // Build table K[][] in bottom up manner
   for (i = 0; i <= n; i++)
   {
       for (w = 0; w <= W; w++)
       {
           if (i==0 || w==0)
               K[i][w] = 0;
           else if (ar[i][1] <= w)
                 K[i][w] = max(ar[i][2] + K[i-1][w-ar[i][1]],  K[i-1][w]);
           else
                 K[i][w] = K[i-1][w];
       }
   }
    cout<<K[n][W];
}



Measured memory_bytes: 79104
#include<bits/stdc++.h>
#define pub push_back
#define x first
#define all(a) a.begin(), a.end()
#define y second
#define mp make_pair
#define ll long long
using namespace std;

const int INF = (int)1e9 + 7;

string s1, s2;
int len;
pair<int, int> d[2002];

int getPosLeft(int v, int k){
	return (v - k + len) % len;
}

int getPosRight(int v, int k){
	return (v + k) % len;
}

int getDist(int a, int b){
	if (a < 0) a += len;
	if (b < 0) b += len;
	return min(abs(a - b), len - abs(a - b));
}

int main() {
    srand(time(NULL) + 'D' + 'E' + 'N' + 'I' + 'S' + 'S' + 'O' + 'N');
   // freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);   
    cin >> s1 >> s2; len = s1.size();
    for (int i = 0; i < len; i++){
    	d[i] = mp(-1, -1);
    	for (int j = 0; j < len; j++){
    		if (d[i].x == -1 && s2[getPosLeft(i, j)] == '1'){
    			d[i].x = j;
    		}
    		if (d[i].y == -1 && s2[getPosRight(i, j)] == '1'){
    			d[i].y = j;
    		}
    	}
    }
    int ans = INF;

    for (int i = 0; i < len; i++){
    	bool f = 1;
    	vector<pair<int, int> > w1, w2;
    	set<pair<int, int> > se1, se2;
    	for (int j = 0; j < len; j++) if (s1[j] != s2[getPosLeft(j, i)]){
    		if (d[j].x == -1 || d[j].y == -1) f = 0;
    		w1.pub(mp(d[j].x, j));
    		w2.pub(mp(d[j].y, j));
    		se1.insert(mp(d[j].x, j));
    		se2.insert(mp(d[j].y, j));
    	}
    	if (!f) continue;
    	sort(all(w1));
    	sort(all(w2));
    	int now = INF;
    	for (int j = 0; j <= w1.size(); j++){
    		int ansNow = 0;
    		int bal = 0;
    		if (j != 0){
    			ansNow += w1[j - 1].x;
    			bal -= w1[j - 1].x;
    			se2.erase(mp(d[w1[j - 1].y].y, w1[j - 1].y));
    		}
    		if (se2.size()){
    			ansNow += -bal + (*(--se2.end())).x;
    			bal = (*(--se2.end())).x;
    		}
    		ansNow += getDist(bal, -i);
    		now = min(now, ansNow);
    	}

    	for (int j = 0; j <= w2.size(); j++){
    		int ansNow = 0;
    		int bal = 0;
    		if (j != 0){
    			ansNow += w2[j - 1].x;
    			bal += w2[j - 1].x;
    			se1.erase(mp(d[w2[j - 1].y].x, w2[j - 1].y));
    		}
    		if (se1.size()){
    			ansNow += bal + (*(--se1.end())).x;
    			bal = -(*(--se1.end())).x;
    		}
    		ansNow += getDist(bal, -i);
    		now = min(now, ansNow);
    	}

    	now += w1.size();
    	ans = min(ans, now);
    }

    if (ans == INF) ans = -1;
    cout << ans;
}

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

using namespace std;

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	
	int a, b, c;
	cin>>a>>b>>c;

	a -= b;
	c-= min(a, c);

	cout<<c;
	
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(void){
    long long  n,ans;
    cin >> n;
    vector<long long> V(n);
    for(int i=0;i<n;i++) cin >> V[i];
    ans = V[0];
    for(int i=1;i<n;i++)ans = V[i]/__gcd(V[i],ans) * ans;
    cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int>a[1000+10];
int main()
{
	int n;
	scanf("%d",&n);
	int i=2;
	for(;i*(i-1)/2<=n;i++)
		if(i*(i-1)/2==n)
			break;
	if(i*(i-1)/2>n)
		printf("No\n");
	else
	{
		printf("Yes\n");
		int len=1;
		printf("%d\n",i);
		for(int k=0;k<i;k++)
			for(int p=k+1;p<i;p++)
			{
				a[k].push_back(len);
				a[p].push_back(len++);
			}
		for(int k=0;k<i;k++)
		{
			printf("%d",a[k].size());
			for(int q=0;q<a[k].size();q++)
				printf(" %d",a[k][q]);
			printf("\n"); 
		}
	}
	return 0;
 } 

Measured memory_bytes: 2304
using System;
using System.Collections.Generic;

namespace Sample101
{

    class Program
    {
        static List<int> G = new List<int>();
        static int count = 0;

        static void InsertionSort(int[] A, int N, int gap)
        {
            // スタートはgap。0に向かって間隔ごとに比較する
            for (int i = gap; i < N; i++)
            {
                int v = A[i];
                int j = i - gap;
                // vより大きいものはずらす
                while (j >= 0 && A[j] > v)
                {
                    A[j + gap] = A[j];
                    j -= gap;
                    count++;
                }
                A[j + gap] = v;
            }
        }

        static void ShellSort(int[] A, int N)
        {
            // 挿入ソートの間隔の数列を作成
            for (int h = 1; h <= N; h = 3 * h + 1)
            {
                G.Add(h);
            }
            G.Reverse();

            // 間隔を使って挿入ソート
            for (int i = 0; i < G.Count; i++)
            {
                InsertionSort(A, N, G[i]);
            }
        }

        static void Main(string[] args)
        {
            // 入力
            var N = int.Parse(Console.ReadLine());
            int[] A = new int[N];
            for (int i = 0; i < N; i++)
            {
                A[i] = int.Parse(Console.ReadLine());
            }

            // シェルソート
            ShellSort(A, N);

            Console.WriteLine(G.Count);
            Console.WriteLine(string.Join(" ", G));

            Console.WriteLine(count);

            for (int i = 0; i < A.Length; i++)
            {
                Console.WriteLine(A[i]);
            }
        }
    }
}


Measured memory_bytes: 23540
#include <iostream>

using namespace std;

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

    int ans = 0;

    for (int i = 1; i <= n;i+=2){
        int cnt = 0;
        for (int j = 1; j <= n;j++){
            if(i % j == 0){
                cnt++;
            }
        }
        if(cnt == 8)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(){
  string S;
  cin >>S;
  for (int i=0;i<3;i++){
    if (S[i]==S[i+1]){
      cout <<"Bad" << endl;
      exit(0);
    }
  }
  cout <<"Good"<< endl;
}  

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////

void solve() {
	int N;
	cin >> N;
	vector<vector<pair<int,int>>>A(2, vector<pair<int,int>>
		(100001, pair<int, int>{0,0}));
	for (int i = 0; i < N; ++i) {
		int v;
		cin >> v;
		A[i & 1][v].first++;
		A[i & 1][v].second = v;
	}
	for (int i = 0; i < 2; ++i) {
		sort(A[i].begin(), A[i].end());
		reverse(A[i].begin(), A[i].end());
	}
	int ans = 0;
	if (A[0][0].second != A[1][0].second) {
		ans = N - A[0][0].first - A[1][0].first;
	}
	else {
		ans = N - max(
			A[0][1].first + A[1][0].first,
			A[0][0].first + A[1][1].first);
	}
	
	cout << ans << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 2560
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

int main(){
  string n;ll k;cin>>n>>k;
  ll m=n.size();
  vvll dp0(m,vll(k+1,0)),dp1(m,vll(k+1,0));
  dp0[0][1]=n[0]-'0'-1;dp1[0][1]=1;
  dp0[0][0]=1;
  rep(i,1,m){
    dp0[i][0]=dp0[i-1][0];
    if(n[i]!='0'){
      rep(j,1,k+1){
        dp0[i][j]=9*dp0[i-1][j-1]+dp0[i-1][j]+dp1[i-1][j]+dp1[i-1][j-1]*(n[i]-'0'-1);
        dp1[i][j]=dp1[i-1][j-1];
      }
    }
    else {
      rep(j,1,k+1){
        dp0[i][j]=9*dp0[i-1][j-1]+dp0[i-1][j];
        dp1[i][j]=dp1[i-1][j];
      }
    }
  }
  cout<<dp0[m-1][k]+dp1[m-1][k]<<endl;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	ll n;cin>>n;
	map<ll,ll>a;
	for(int i=2;i<=n;++i){
		ll m=i;
		for(int j=2;j*j<=m;++j){
			while(m%j==0){
				m/=j;
				a[j]++;
			}
		}
		if(m>1)a[m]++;
    }
	ll ans=1;
	for(int i=2;i<=n;++i){
		ans*=((a[i]+1)%MOD);
		ans%=MOD;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

#define NIL -1

void Preorder(int);
void Inorder(int);
void Postorder(int);

struct Node{
  int parent;
  int left;
  int right;
};

struct Node T[25];

int main(){

  int n,left,right,id,i,c;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    T[i].parent=NIL;
    T[i].right=NIL;
    T[i].left=NIL;   
  }
  
  
  for(i=0;i<n;i++){

    scanf("%d%d%d",&id,&left,&right);

    T[right].parent=id;
    T[left].parent=id;
    T[id].left=left;
    T[id].right=right;
    
  }

  for(i=0;i<n;i++){
    
    if(T[i].parent==NIL){
      c=i;
      break;
    }

  }

  printf("Preorder\n");
  
  Preorder(c);

  printf("\n");

  printf("Inorder\n");
  
  Inorder(c);

  printf("\n");

  printf("Postorder\n");

  Postorder(c);

  printf("\n");

  return 0;

}

void Preorder(int u){

  if(u==NIL) return ;

  printf(" %d",u);

  Preorder(T[u].left);
  Preorder(T[u].right);

}

void Inorder(int u){

  if(u==NIL) return ;

  Inorder(T[u].left);

  printf(" %d",u);

  Inorder(T[u].right);

}

void Postorder(int u){

  if(u==NIL) return ;

  Postorder(T[u].left);
  Postorder(T[u].right);

  printf(" %d",u);
  
}

  
  

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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define PB push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second

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

const int MOD = 1e9+7;


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

	int n; cin >> n;
	ll x = 0, ad = 0;
	vector<ll> v(n);
	FOR(i, n){
		cin >> v[i];
		x ^= v[i];
	}

	x ^= (v[0]^v[1]);

	if(x > v[0]+v[1] || (v[0]+v[1]-x)%2){
		cout << "-1\n";
		return 0;
	}

	ad = (v[0]+v[1]-x)/2;

	ll a = 0, b = 0;
	for(int i = 0; i < 62; i++){
		if( (ad&(1LL<<i)) ){
			a |= (1LL<<i);
			b |= (1LL<<i);
		}
	}

	if(a > v[0]){
		cout << "-1\n";
		return 0;
	}

	for(int i = 62; i >= 0; i--){
		ll j = (1LL<<i);
		if((x&j)){
			if((a|j) > v[0]){
				b|=j;
			}else{
				a|=j;
			}
		}
	}

	if(a == 0 || (ad&x)){
		cout << "-1\n";
	}else
		cout << v[0]-a << '\n';

	return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <algorithm>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VRSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD (ll)(1e9+7)
#define MAX (ll)(1e5*2+200)
#define print(x) cout << x << endl;
#define printArr(arr) REP(i, (sizeof arr / sizeof arr[0])){print(arr[i])}
#define printVec(vec) REP(i, vec.size()){print(vec[i])}
using namespace std;

int main(void){
    const int inf = 100000000;
    int N,M;
    cin >> N >> M;
    
    int a[1000], b[1000], c[1000], dist[100][100];
    
    /*初期化*/
    REP(i, N){
        REP(j, N){
            if(i == j){
                dist[i][j] = 0;
            }else{
                dist[i][j] = inf;
            }
        }
    }
    
    /*グラフの反映*/
    REP(i, M){
        cin >> a[i] >> b[i] >> c[i];
        a[i] --, b[i]--;
        dist[a[i]][b[i]] = min(dist[a[i]][b[i]], c[i]);
        dist[b[i]][a[i]] = min(dist[b[i]][a[i]], c[i]);
        
    }
    
    /*各点間の最小距離を導出*/
    REP(k, N){
        REP(i, N){
            REP(j, N){
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
    
    /*ある辺を含む経路が最短かどうかを判定*/
    int ans = M;
    REP(i, M){
        bool judge = false;
        REP(j, N){
            if(dist[j][a[i]] + c[i] == dist[j][b[i]]){
                judge = true;
            }
            if(judge){
                ans -= 1;
                break;
            }
        }
    }
    print(ans);
}

Measured memory_bytes: 256
#include <stdio.h>

int main () {
	char a[12];
	char b[12];
	char c[12];
	int lenA = 0, lenB = 0;
	scanf("%s", a);
	scanf("%s", b);
	scanf("%s", c);
	
	for(int i = 0; a[i] != '\0'; i++) {
		lenA++;
	}
	for(int i = 0; b[i] != '\0'; i++) {
		lenB++;
	}
	
	if (a[lenA-1] == b [0] && b[lenB-1] == c[0]) {
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 1664
import java.util.*;

public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
      	if(N<3){
			System.out.println(0);
			return;
		}
		Integer[] Ni = new Integer[N];

		for(int i = 0; i<N; i++){
			Ni[i]=sc.nextInt();
		}

		int cnt = 0;

		for(int i = 0; i<N; i++){
			for(int j = i+1; j<N; j++){
				for(int k = j+1; k<N; k++){
					if(makeTri(Ni[i],Ni[j],Ni[k])){
						cnt++;
					}
				}
			}
		}
		System.out.println(cnt);
		return;
	}
	public static boolean makeTri(int i1, int i2, int i3){

		if((i1==i2)||(i1==i3)||(i2==i3)){
			return false;
		}

		if((i1>i2)&&(i1>i3)){
			if(i1>=i2+i3){
				return false;
			}
		}

		if((i2>i1)&&(i2>i3)){
			if(i2>=i1+i3){
				return false;
			}
		}

		if((i3>i1)&&(i3>i2)){
			if(i3>=i1+i2){
				return false;
			}
		}
		
		return true;
	}
}


Measured memory_bytes: 36468
#include<iostream>
using namespace std;
int main(){
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  if(k<=a){
    cout << k << endl;
  }
  else if(k<=a+b){
    cout << a << endl;
  }
  else{
    cout << a-(k-a-b) << endl;
  }
}

Measured memory_bytes: 3628
#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 ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;

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



int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	int k;
	string s;
	cin >> k >> s;
	if (s.size() <= k) {
		cout << s;
	}	else {
		cout << s.substr(0, k) + "...";
	}
}


Measured memory_bytes: 3660
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;


    cout << 24 * 2 - n << endl;

    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2], R[MAX/2+2];
int cnt;

void merge(int A[], int n, int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  for ( int i = 0; i < n1; i++ ) L[i] = A[left + i];
  for ( int i = 0; i < n2; i++ ) R[i] = A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  int i = 0; int j = 0;
  for ( int k = left; k < right; k++ ) {
    cnt++;
    if ( L[i] <= R[j] )
      A[k] = L[i++];
    else
      A[k] = R[j++];
  }
}

void mergeSort(int A[], int n, int left, int right) {
  if ( left+1 < right ) {
    int mid = (left + right) / 2;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}

int main() {
  int A[MAX], n, i;
  cnt = 0;

  cin >> n;
  for ( i = 0; i < n; i++ ) cin >> A[i];

  mergeSort(A, n, 0, n);

  for ( i = 0; i < n; i++ ) {
    if ( i ) cout << " ";
    cout << A[i];
  }
  cout << endl;

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 7000
#include <bits/stdc++.h>
using namespace std ;
long long h , w ;
bool flag = false ;
int main() {
	cin >> h >> w ;
	if(h == 1 || w == 1) {
		cout << 1 << endl ;
		return 0 ;
	}
	if(h%2 && w%2) flag = true ;
	long long tmp = h * w / 2 ;
	if(flag) tmp++ ;
	cout << tmp << endl ;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
}

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input!{
        source = src,
        s: String,
        t: String,
        a: isize,
        b: isize,
        u: String,
    }

    let mut aa = a;
    let mut bb = b;
    if u == s {
        aa = aa - 1;
    } else {
        bb = bb - 1;
    }

    return format!("{} {}", aa, bb);
}


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

int main(){
  string S;
  cin >> S;
  vector<int> W(26);
  for(int i=0; i<S.size(); i++){
    W.at(S.at(i)-97)++;
  }
  string ans="None";
  for(int i=0; i<26; i++){
    if(W.at(i)==0){
      ans=i+97;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip> // << fixed << precision(10)
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

#define FOR(i,s,t) for(int i=s;i<t;i++)
#define REP(i,n) FOR(i,0,n)
#define PRINT(s) cout << s << "\n"
#define SORT(A) sort(A.begin(), A.end())
#define EACHPRINT(A, T) for_each(begin(A), end(A), [&](T i){ cout << i << " "; });cout << "\n"
#define NEWDP(N, M, ini) DP(N, vector<lint>(M, ini))
#define MOD 1000000007

typedef long long lint;
typedef pair<lint, lint> P;
typedef vector<lint> V;
typedef vector<vector<lint>> DP;
bool lessPair(const P& l, const P& r){return l.second < r.second;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    lint L; cin >> L;

    V A(L);
    REP(i, L) {
      cin >> A[i];
    }

    DP dp = NEWDP(L, 5, 0);


    if(A[0] == 0) {
      dp[0][0] = 0;
      dp[0][1] = 2;
      dp[0][2] = 1;
      dp[0][3] = 2;
      dp[0][4] = 0;
    } else if (A[0] %2 == 0) {
      dp[0][0] = A[0];
      dp[0][1] = 0;
      dp[0][2] = 1;
      dp[0][3] = 0;
      dp[0][4] = A[0];
    } else {
      dp[0][0] = A[0];
      dp[0][1] = 1;
      dp[0][2] = 0;
      dp[0][3] = 1;
      dp[0][4] = A[0];
    }
    
    FOR(i,1, L) {
      if(A[i] == 0) {
        dp[i][0] = 0;
        dp[i][1] = 2;
        dp[i][2] = 1;
        dp[i][3] = 2;
        dp[i][4] = 0;
      } else if (A[i] %2 == 0) {
        dp[i][0] = A[i];
        dp[i][1] = 0;
        dp[i][2] = 1;
        dp[i][3] = 0;
        dp[i][4] = A[i];
      } else {
        dp[i][0] = A[i];
        dp[i][1] = 1;
        dp[i][2] = 0;
        dp[i][3] = 1;
        dp[i][4] = A[i];
      }

      FOR(j, 0, 5) {
        lint res = dp[i-1][0];
        FOR(k, 1, j+1) {
          res = min(res, dp[i-1][k]);
        }
        dp[i][j] += res;
      }
    }

    lint res = dp[L-1][0];
    FOR(j, 1, 5) {
      res = min(res, dp[L-1][j]);
    }
    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 15872
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<string>
#include<functional>
using namespace std;
typedef	long long int ll;

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> v1, v2;
    int x;
    for(int i = 0; i < n; i++){
        cin >> x;
        if(x >= 0){
            v1.push_back(x);
        }
        else{
            v2.push_back(x);
        }
    }
    if(v1.size() == 0){
        cout << abs(v2[n-k]) << endl;
        return 0;
    }
    if(v2.size() == 0){
        cout << v1[k-1] << endl;
        return 0;
    }
    int res = 1000000000;
    int si = v1.size();
    int ub = min(si, k);
    for(int i = k-v2.size()-1; i < ub; i++){
        res = min(res, v1[i]-v2[v2.size()-k+i+1]+v1[i]);
        res = min(res, v1[i]-2*v2[v2.size()-k+i+1]);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1020
#include<stdio.h>
#include<math.h>

int main(void){
	int a, b, c, cnt, i;

	scanf("%d", &cnt);
	for (i = 0; i < cnt; i++) {
		scanf("%d %d %d", &a, &b, &c);
		if (a < 1 || a > 1000) {
			printf("Error!\n");
			continue;
		} else if (b < 1 || b > 1000) {
			printf("Error!\n");
			continue;
		} else if (c < 1 || c > 1000) {
			printf("Error!\n");
			continue;
		} 

		
		if (pow(a, 2.0) == pow(b, 2.0) + pow(c, 2.0) || pow(b, 2.0) == pow(a, 2.0) + pow(c, 2.0) || pow(c, 2.0) == pow(a, 2.0) + pow(b, 2.0)) {
			printf("YES\n");
		} else {
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<vector<char>> S(H, vector<char>(W));
    vector<vector<int>> T(H, vector<int>(W, 0));
    int cnt = 1;
    REP(i, H) {
        REP(j, W) {
            cin >> S[i][j];
            if(S[i][j] == '#') {
                T[i][j] = cnt;
                cnt++;
            }
        }
    }
    REP(i, H) {
        int last = 0;
        int lastcolor;
        bool flag = false;
        REP(j, W) {
            if(T[i][j] != 0) {
                lastcolor = T[i][j];
                for(int k = last; k < j; k++) {
                    T[i][k] = lastcolor;
                }
                last = j + 1;
                flag = true;
            }
        }
        if(flag) {
            if(T[i][W - 1] == 0) {
                // cout << "hoge" << last << " " << lastcolor << endl;
                for(int k = last; k < W; k++) {
                    T[i][k] = lastcolor;
                }
            }
        }
    }
    bool flag = true;
    while(flag) {
        flag = false;
        REP(i, H) {
            if(T[i][0] == 0) {
                flag = true;
                if(i < H - 1) {
                    //下からもらう
                    REP(j, W) { T[i][j] = T[i + 1][j]; }
                }
                if(T[i][0] == 0 and i > 0) {
                    //上からもらう
                    REP(j, W) { T[i][j] = T[i - 1][j]; }
                }
            }
        }
    }
    REP(i, H) {
        REP(j, W) { cout << T[i][j] << " "; }
        cout << endl;
    }
    return 0;
}

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

int L[3010][3010]; 
   

void lcs( string X, string Y) 
{ 
	int m = Y.length();
	int n = X.length();
  	int i, j; 

   for (i=0; i<=m; i++) 
   { 
     for (j=0; j<=n; j++) 
     { 
       if (i == 0 || j == 0) 
         L[i][j] = 0; 
   
       else if (X[j-1] == Y[i-1]) 
         L[i][j] = L[i-1][j-1] + 1; 
   
       else
         L[i][j] = max(L[i-1][j], L[i][j-1]); 
       // << L[i][j] << " "; 
     }
     // << endl;
   } 




   vector<char> ans;
     
   i = m, j = n;

   while(L[i][j]!=0){

   	// << i << " " << j << " " << X[j-1] <<" "<< Y[i-1] << endl;

   	if(X[j-1] == Y[i-1]){
   		ans.push_back(Y[i-1]);
   		i--,j--;
   	}
   	else if(L[i-1][j] == L[i][j]){
   		i--;
   	}
   	else{
   		j--;
   	}
   }

   reverse(ans.begin(), ans.end());


   for (auto ch: ans)
   {
   	cout << ch;
   }

   cout << endl;





} 
   

int main() 
{ 
  string X , Y; 
  cin >> X >> Y;
   
  lcs( X, Y ); 
  
  return 0; 
} 

Measured memory_bytes: 35584
#include "bits/stdc++.h"
typedef long long ll;
using namespace std;
static const int N = 5;

int main() {
    int a[N], k;

    for (int i = 0; i < N; ++i) cin >> a[i];
    cin >> k;

    for (int i = 0; i < N; ++i) {
        for (int j = i + 1; j < N; ++j) {
            if (abs(a[i] - a[j]) > k) {
                cout << ":(" << endl;
                return 0;
            }
        }
    }
    cout << "Yay!" << endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
l=[[] for i in range(n)]
for i in range(n-1):
  a,b,c=map(int,input().split())
  l[a-1].append([b-1,c])
  l[b-1].append([a-1,c])
ans=[-1]*n
q,k=map(int,input().split())
ans[k-1]=0
from collections import deque
d=deque([k-1])
while d:
  now=d.pop()
  for x in l[now]:
    a,b=x
    if ans[a]<0:
      ans[a]=ans[now]+b
      d.appendleft(a)
for i in range(q):
  a,b=map(int,input().split())
  print(ans[a-1]+ans[b-1])

Measured memory_bytes: 93344
fun main(args: Array<String>) {
    val d = readLine()!!.toInt()
    val result = when (d) {
        25 -> {
            "Christmas"
        }
        24 -> {
            "Christmas Eve"
        }
        23 -> {
            "Christmas Eve Eve"
        }
        22 -> {
            "Christmas Eve Eve Eve"
        }
        else -> {
            "Other"
        }
    }

    println(result)
}

Measured memory_bytes: 33612
H, W = map(int, input().split())
##計算の都合、 通路(.)を正の整数、壁(#)を-1に変換する
LARGE_VALUE = 100000
Mij = [[0] * W for _ in range(H)]
space_count = 0
for i in range(H):
    s = input()
    for j in range(W):
        if s[j] == ".":
            space_count += 1
            Mij[i][j] = LARGE_VALUE
        else:
            Mij[i][j] = -1

dirs = [[1, 0], [0, 1], [-1, 0], [0, -1]]

queue = [[0, 0]]

def search():
    while len(queue):
        p = queue[0]
        del queue[0]
        i = p[0]
        j = p[1]
        step = Mij[i][j]

        for d in dirs:
            i2 = i + d[0]
            j2 = j + d[1]
            if 0 <= i2 < H and 0 <= j2 < W:
                if step + 1 < Mij[i2][j2]:
                    Mij[i2][j2] = step + 1
                    queue.append([i2, j2])

Mij[0][0] = 1
search()
total_steps = Mij[H - 1][W - 1]
if total_steps == LARGE_VALUE:
    print(-1)
else:
    print(space_count - total_steps)

Measured memory_bytes: 3064
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n")
var a=Arr[1].split(" ").map(Number);
var b=Arr[3].split(" ").map(Number);
var c=[];

a.sort(function(a,b){return a-b;});
b.sort(function(a,b){return a-b;});

var cnt=0;
var ab=0;

function indexB(x){
var flag=false;
for(var i=0;i<b.length;i++){
if(b[i]==x)flag=true;
if(b[i]>x)break;
}
return flag;
}

for(var i=0;i<a.length;i++){
if(i!=0 && ab==a[i])continue;
if(indexB(a[i]))c.push(a[i]);
ab=a[i];
}

console.log(c.length);

Measured memory_bytes: 23752
N,M = map(int,input().split())
L = [list(map(int,input().split())) for i in range(M)]
L.sort()
ans = 1
l = L[0][0]
r = L[0][1]
for a,b in L:
    if r <= a:
        ans += 1
        l = a
        r = b
    else:
        l = a
        r = min(r,b)
print(ans)


Measured memory_bytes: 29616
#include <bits/stdc++.h>
#define ll long long
#define w(t) while(t--)
#include <iostream>
using namespace std;

int main()
{
    ll t=1;
    //cin>>t;
    w(t)
    {
       ll x; cin>>x;
        ll tot=x/500;
        tot*=1000;
        x%=500;
        ll p=x/5;
        p*=5;
        cout<<tot+p;
    }
}

Measured memory_bytes: 256
SX,SY,TX,TY = (int(T) for T in input().split())
print('R'*(TX-SX)+'U'*(TY-SY)+'L'*(TX-SX)+'D'*(TY-SY)+'D'+'R'*(TX-SX+1)+'U'*(TY-SY+1)+'L'+'U'+'L'*(TX-SX+1)+'D'*(TY-SY+1)+'R')

Measured memory_bytes: 9116
n = int(input())
A = [0]*n
B = [0]*n
# 入力
for i in range(n):
    a,b = map(int,input().split())
    A[i] = a
    B[i] = b
# 中央値を考えるためにソート
A.sort()
B.sort()
# 奇数の時は1ごと、偶数の時は1/2ずつ値を取るので場合分け
if n%2 == 1:
    print(B[n//2] - A[n//2] + 1)
    # 奇数の時、中央値は前からn//2番目(0-index)
else:
    print((B[n//2]+B[n//2-1])-(A[n//2]+A[n//2-1])+1)
    # 偶数の時、中央値は前からn//2-1番目とn//2番目の平均(0-index)


Measured memory_bytes: 25352
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  if(s.at(s.size()-1)=='s'){
    s.push_back('e');
    s.push_back('s');
  }else{
    s.push_back('s');
  }
  cout<<s<<endl;
}

Measured memory_bytes: 3628
{-# LANGUAGE CPP #-}
{-# LANGUAGE ScopedTypeVariables #-}

module Main where

import qualified Data.Vector.Unboxed as V
import Debug.Trace
import Data.Ord
import qualified Data.Map.Strict as M
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import Data.Char
import qualified Data.List as L

dump :: (Show a) => a -> IO ()

#if __GLASGOW_HASKELL__ >= 800
dump x = print x
#else
dump _ = pure ()
#endif

-- "101010" -> [1,0,1,0,1,0]
readToList :: String -> [ Int ]
readToList [] = []
readToList (x : xs) = read [ x ] : readToList xs

readInt :: BS.ByteString -> Int
readInt = fst . fromJust . BS.readInt

getInt :: IO Int
getInt = readInt <$> BS.getLine

-- "10 10 10" -> [10, 10, 10]
getList :: IO [ Int ]
getList = (fmap (read . BS.unpack) . BS.words) <$> BS.getLine

-- "10 10 10" -> [10, 10, 10]
getIntVec :: Int -> IO (V.Vector Int)
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readmat :: Int -> IO [ [ Int ] ]
readmat rows = replicateM rows getList

newtype UF a = UF (M.Map a a)
    deriving ( Show ) -- Map node parent

makeuf :: Int -> UF Int
makeuf n = let m = M.fromList $ zip [ 0 .. n ] [ 0 .. n ] in UF m

unionUF :: ( Eq a, Ord a ) => a -> a -> UF a -> UF a
unionUF l r uf @ (UF m) = let lp = findUF l uf
                              rp = findUF r uf in if lp == rp then uf
    else if size l uf < size r uf then UF $ M.update (const $ Just rp) lp m
        else UF $ M.update (const $ Just lp) rp m

findUF :: ( Eq a, Ord a ) => a -> UF a -> a
findUF x uf @ (UF m) = let px = m M.! x in if px == x then px else findUF px uf -- TODO 貼り直し

size :: ( Eq a, Ord a ) => a -> UF a -> Int
size x (UF m) = M.size $ M.filter (\par -> par == x) m

genbit :: Int -> [ [ Int ] ]
genbit 0 = []
genbit 1 = [ [ 0 ], [ 1 ] ]
genbit len = do
    x <- [ 0, 1 ]
    map (x :) $ genbit (len - 1)

base :: Int
base = 10 ^ 9 + 7

forn :: ( Num a, Enum a, Monad m ) => a -> (a -> m b) -> m [ b ]
forn x = forM [ 0 .. (x - 1) ]

count :: (Eq a) => a -> [ a ] -> Int
count y = length . filter (== y)

-- ここまでsnippet

f :: Int -> ( Int, Int, Int ) -> [ [ Int ] ] -> Int
f m ( p, q, r ) nss
    = let nss' = L.sortOn (\ns -> let x = (!! 0) ns
                                      y = (!! 1) ns
                                      z = (!! 2) ns in Down $ p * x + q * y + r * z)
              nss in sum $ map (\[ x, y, z ] -> p * x + q * y + r * z) $ take m nss'

main :: IO ()
main = do
    [ n, m ] <- getList
    nss <- readmat n
    let pqrs = [ ( p, q, r )
               | let piyo = [ 1, -1 ], p <- piyo, q <- piyo, r <- piyo
               ]
    print $ maximum $ map (\pqr -> f m pqr nss) pqrs


Measured memory_bytes: 1916
N = int(input())
A, B = map(int, input().split())

a = []
b = []
c = []

for i in input().split():
    item = int(i)
    if item <= A:
        a.append(item)
    elif A + 1 <= item <= B:
        b.append(item)
    elif B < item:
        c.append(item)

print(min(len(a), len(b), len(c)))


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

typedef long long ll;

ll K;
int N = 50;
vector<ll> arr;

int main() {
    cin>>K;

    ll q = K / N;
    ll r = K % N;

    arr.resize(N);
    for(int i = 0; i < N; i++) {
        if(i < r) arr[i] = (q + 1) * (N + 1) + N - K - 1;
        else arr[i] = q*(N + 1) + N - K - 1;
    }

    printf("%d\n", N);
    for(int i = 0; i < N; i++) {
        printf("%lld ", arr[i]);
    }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(){
  long long int n,k;
  cin >> n >> k;
  long long int h[n];
  for(auto i=0;i<n;i++){
    cin >> h[i];
  }
  long long int ans[n];
  ans[0]=0;
  ans[1]=abs(h[1]-h[0]);
  for(int i=2;i<n;i++){
    int x=i-2;
    ans[i]=ans[i-1]+abs(h[i]-h[i-1]);
    while(x>=i-k&&x>=0){
      ans[i]=min(ans[i],ans[x]+abs(h[i]-h[x]));
      x=x-1;
    }
  }
  cout << ans[n-1];
  return 0;
}


Measured memory_bytes: 1792
from collections import deque

N, M = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(M)]
link = [[] for _ in range(N)]

for i in range(M):
    link[L[i][0]-1].append(L[i][1]-1)
    link[L[i][1]-1].append(L[i][0]-1)

checked = [-1 for _ in range(N)]
checked[0] = 0
d = deque([0])
while d:
    now = d.popleft()
    for i in range(len(link[now])):
        if checked[link[now][i]] == -1:
            checked[link[now][i]] = now + 1
            d.append(link[now][i])


flag = False
for i in range(1, N):
    if checked[i] == -1:
        flag = True
        break

if flag:
    print('No')
else:
    print('Yes')
    for i in range(1, N):
        print(checked[i])

Measured memory_bytes: 72968
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ll long long
#define ld long double
//#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];

int main() {
  int N; cin >> N;
  int X[9] = {111, 222, 333, 444, 555, 666, 777, 888, 999};
  rep(i, 9){
    if (X[i] >= N) {
      cout << X[i] << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
while True:
    q=int(input())
    if q==-1:
        break
    x=q/2
    a=0.00001*q
    while abs(x**3-q)>=a:
        s=x*x
        t=s*x-q
        x-=t/(3*s)
    print(f"{x:.6f}")



Measured memory_bytes: 5676
import fractions as fr
from itertools import count,product
from math import ceil

N = int(input())

if N%2 == 0:
  print(N,N,N//2)
  exit()

for h in range(1,3501):
  if 4*h > N:
    a = N*h//(4*h-N)+1
    b = 3501
  else:
    a = 1
    b = N*h//(4*h-N)+1
  for n in range(a,b):
    if (N*h*n)%(4*h*n-N*h-N*n) == 0:
      print(h,n,(N*h*n)//(4*h*n-N*h-N*n))
      exit()

Measured memory_bytes: 5692
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <string>
#include <map>
using namespace std;
int pri[60010], cnt;
bool is_prime[100010];
int num[100010];

void init()
{
	is_prime[1] = 1;
	for (int i = 2; i <= 100000; i++)
	{
		if (!is_prime[i])
		{
			pri[cnt++] = i;
	//		is_prime[i] = 1;
		}
		for (int j = 0; j < cnt && i * pri[j] <= 100000; j++)
		{
			is_prime[i * pri[j]] = 1;
			if (i % pri[j] == 0) break;
		}
	}

	for (int i = 2; i <= 100000; i++)
	{
		if (is_prime[i] == 0 && is_prime[(i + 1) / 2] == 0) num[i]++;
		num[i] += num[i - 1];
	}
}

int main()
{
	int i, j;
	init();
	int q;
	scanf("%d", &q);
	while (q--)
	{
		int li, ri;
		scanf("%d%d", &li, &ri);
		printf("%d\n", num[ri] - num[li - 1]);
	}
	return 0;
}

Measured memory_bytes: 1152
var s,ss:ansistring;
var a,b,c,d,n,i,j:longint;
begin
  readln(s);
  a:=ord(s[1])-ord('0');b:=ord(s[2])-ord('0');c:=ord(s[3])-ord('0');
  d:=ord(s[4])-ord('0');
  if a+b+c+d=7 then writeln(a,'+',b,'+',c,'+',d,'=7') else
  if a+b+c-d=7 then writeln(a,'+',b,'+',c,'-',d,'=7') else
  if a+b-c+d=7 then writeln(a,'+',b,'-',c,'+',d,'=7') else
  if a+b-c-d=7 then writeln(a,'+',b,'-',c,'-',d,'=7') else
  if a-b+c+d=7 then writeln(a,'-',b,'+',c,'+',d,'=7') else
  if a-b+c-d=7 then writeln(a,'-',b,'+',c,'-',d,'=7') else
  if a-b-c+d=7 then writeln(a,'-',b,'-',c,'+',d,'=7') else
  if a-b-c-d=7 then writeln(a,'-',b,'-',c,'-',d,'=7');
end.

Measured memory_bytes: 128
#include <stdio.h>
#include <inttypes.h>

int N;
int A[271828];

int left[271828];
int right[271828];

int main(void) {
	int i;
	int64_t count = 0;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 1; i <= N; i++) {
		if (scanf("%d", &A[i]) != 1) return 1;
	}
	for (i = 1; i <= N; i++) {
		int lidx = i - A[i], ridx = i + A[i];
		if (lidx >= 1) left[lidx]++;
		if (ridx <= N) right[ridx]++;
	}
	for (i = 1; i <= N; i++) {
		count += (int64_t)left[i] * right[i];
	}
	printf("%" PRId64 "\n", count);
	return 0;
}


Measured memory_bytes: 4064