akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define MAX 1000000001
void mergesort(int *,int ,int );
void merge(int *,int ,int ,int );
int count=0,n,Left[250001],Right[250001],i,j,k,n1,n2;

int main(void){
  int S[500000];
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&S[i]);
  mergesort(S,0,n);

  for(i=0;i<n;i++){
    printf("%d",S[i]);
    if(i!=n-1)printf(" ");
  }
  printf("\n%d\n",count);
  return 0;
}
void mergesort(int *S,int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergesort(S,left,mid);
    mergesort(S,mid,right);
    merge(S,left,mid,right);
  }
}
void merge(int *S,int left,int mid,int right){
  n1=mid-left;n2=right-mid;
  for(i=0;i<n1;i++)
    Left[i]=S[left+i];//not include mid
  for(i=0;i<n2;i++)
    Right[i]=S[mid+i];//include mid
  Left[n1]=MAX;
  Right[n2]=MAX;
  for(i=0,j=0,k=left;k<right;k++){
    if(Left[j]>Right[i])S[k]=Right[i++];
    else S[k]=Left[j++];
  }
  count+=right-left;
}


Measured memory_bytes: 5604
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define ct(string) cout << string << endl
#define all(s) (s).begin(), (s).end()

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if ((a-b) < c) ct(c-(a-b));
    else ct(0);
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define eps 1e-15
int sleep(){
	int j=0;
	for(int i=1;i<=2000001;i++) j++;
	return j;
}
inline int read() {
	res s=0;
	bool w=0;
	char ch=getchar();
	while(ch<'0'||ch>'9') {
		if(ch=='-')w=1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
	return w?-s:s;
}
inline void _swap(res &x,res &y) {
	x^=y^=x^=y;
}
inline int _abs(const res &x) {
	return x>0?x:-x;
}
inline int _max(const res &x,const res &y) {
	return x>y?x:y;
}
inline int _min(const res &x,const res &y) {
	return x<y?x:y;
}
const int N=1e5+10;
namespace MAIN {
	int n,l;
	int a[N];
	int tot;
	int step[N],stepx;
	inline void MAIN() {
		n=read(),l=read();
		for(res i=1; i<=n; i++)a[i]=read();
		res j=1;
		for(res i=1; i<n; i++)if(a[i]+a[i+1]>a[j]+a[j+1])j=i;
		if(a[j]+a[j+1]<l)puts("Impossible");
		else {
			puts("Possible");
			for(res i=n-1; i>j; i--)printf("%d\n",i);
			for(res i=1; i<=j; i++)printf("%d\n",i);
		}
	}
}
int main() {
	MAIN::MAIN();
	sleep();
	return 0;
}

Measured memory_bytes: 1152
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<ll,ll>;
using um = unordered_map<ll,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=(ll)1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;


signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N,A,B,C,D;
    cin>>N>>A>>B>>C>>D;
    bool ans=0;
    for(ll i=0;i<=N-1;++i)if(A+C*(N-i-1)-D*i<=B&&A+D*(N-i-1)-C*i>=B)ans=1;
    if(ans)prt("YES");
    else prt("NO");

    return 0;
}



Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main() {
  string o, e; cin >> o >> e;
  for (size_t i = 0; i < e.size(); i++) {
    cout << o[i] << e[i];
  }
  if (o.size() > e.size()) cout << o.back();
  cout << endl;
}

Measured memory_bytes: 256
/// Containers Start
#include <algorithm>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <set>
#include <unordered_set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Extra Start
#define nn '\n'
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl
/// Debug End

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

int main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cini(n);
    vector<long long> a(n),b(n),c(n);
    vector<vector<long long> > A(n+1,vector<long long>(2,0)),B(n+1,vector<long long>(2,0)),C(n+1,vector<long long>(2,0));
    rep(i,n){
        cin >> a[i] >> b[i] >> c[i];
    }
    for(long long i=1;i<=n;i++){
        A[i][0LL] = max(B[max(i-1,0LL)][0LL],max(B[max(i-1,0LL)][1],max( C[max(i-1,0LL)][0LL],C[max(i-1,0LL)][1]))) + a[max(i-1,0LL)];
        B[i][0LL] = max(C[max(i-1,0LL)][0LL],max(C[max(i-1,0LL)][1],max( A[max(i-1,0LL)][0LL],A[max(i-1,0LL)][1]))) + b[max(i-1,0LL)];
        C[i][0LL] = max(A[max(i-1,0LL)][0LL],max(A[max(i-1,0LL)][1],max( B[max(i-1,0LL)][0LL],B[max(i-1,0LL)][1]))) + c[max(i-1,0LL)];
        
    }
    cout << max(A[n][0],max(A[n][1],max(B[n][0],max(B[n][1],max(C[n][0],C[n][1]))))) << nn;
    return 0;
}

Measured memory_bytes: 19072
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int H,N,X,Y;
	int i,j,k;
	int wk1,wk2,wk3;
	int mask[4]={3,6,12,15},smask[4]={1,2,4,8};
	int cnt[4]={1,1,1,2};
	int dp[10001][16],syogai[10001];
	cin>>H>>N;
	for(i=0;i<H;i++){
		syogai[i]=0;
	}
	
	for(i=0;i<N;i++){
		cin>>X>>Y;
		syogai[Y]=(syogai[Y]|smask[X]);
	}
//	for(i=0;i<H;i++) cout<<" syogai= "<<syogai[i]<<endl;

	for(i=0;i<H;i++){
		for(j=0;j<16;j++){
			dp[i][j]=0;
		}
	}
	
	for(i=0;i<4;i++){
		wk1=syogai[0]&mask[i];
		wk2=syogai[1]&mask[i];
		if(wk1==0&&wk2==0){
			//cout<<" i= "<<i<<endl;
			wk3=syogai[1]|mask[i];
			dp[1][wk3]=cnt[i];
		}
	}
	
	//for(i=0;i<16;i++) cout<<dp[1][i]; cout<<endl;
	
	for(i=1;i<H-1;i++){
		for(j=0;j<16;j++){
			wk3=syogai[i+1];
			dp[i+1][wk3]=max(dp[i+1][wk3],dp[i][j]);
			for(k=0;k<4;k++){
				wk1=(j|syogai[i])&mask[k];
				wk2=syogai[i+1]&mask[k];
				if(wk1==0&&wk2==0){
					wk3=syogai[i+1]|mask[k];
					dp[i+1][wk3]=max(dp[i+1][wk3],dp[i][j]+cnt[k]);
				}
			}
		}
	}
	/*for(i=0;i<16;i++){cout<<i;}
	cout<<endl;
	
	for(i=0;i<H;i++){
		for(j=0;j<16;j++){
			if(j>9){
				cout<<" ";
			}
			cout<<dp[i][j];
		}
		cout<<endl;
		
	}*/
	
	
	int Max=-1;
	for(i=0;i<16;i++){
		Max=max(dp[H-1][i],Max);
	}
	cout<<Max<<endl;
	return 0;
}


Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define left (ind * 2)
#define right (ind * 2 + 1)
#define mp make_pair
#define timer ((double)clock() / CLOCKS_PER_SEC)
#define endl "\n"
#define spc " "
#define d1(x) cerr<<#x<<":"<<x<<endl
#define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl
#define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, double> dd;

const int N = (int)(1e6 + 5);
const int LOG = (int)(20);

int n, ar[N], ar1[N], ar2[N], up1[N], up2[N];

int main() {
	fast_io();
	// freopen("inp.in", "r", stdin);
	
	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> ar[i];
	for(int i = 1; i <= n; i++) {
		ar1[i] = i;
		ar2[i] = n - i + 1;
	}
	for(int i = 1; i <= n; i++) {
		up1[ar[i]] += i;
		up2[1] += i;
		up2[ar[i] + 1] -= i;
	}
	int val1 = 0, val2 = 0;
	for(int i = 1; i <= n; i++) {
		val1 += up1[i];
		ar1[i] += val1;
		val2 += up2[i];
		ar2[i] += val2;
	}
	for(int i = 1; i <= n; i++)
		cout << ar1[i] << spc;
	cout << endl;
	for(int i = 1; i <= n; i++)
		cout << ar2[i] << spc;
}

Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;

int main(){
    int H, W, h, w, next_sharp_num;
    bool can_paint = true;
    cin >> H >> W;
    string s[H];
    for (int i=0; i<H; i++) cin >> s[i];

    for (h=0; h<H; h++) {
        for (w=0; w<W; w++) {
            if (s[h][w] == '#') {
                next_sharp_num = 0;
                if ((h>0) && (s[h-1][w] == '#')) next_sharp_num++;
                if ((h<H-1) && (s[h+1][w] == '#')) next_sharp_num++;
                if ((w>0) && (s[h][w-1] == '#')) next_sharp_num++;
                if ((w<W-1) && (s[h][w+1] == '#')) next_sharp_num++;
                if (next_sharp_num == 0) {
                    can_paint = false;
                    break;
                }
            }
        }
        if (can_paint == false) break;
    }

    if (can_paint) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


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

int main()
{
	int A, B;
	cin >> A >> B;

	for (int i = 1; i <= 1000; i++)
	{
		if (floor(i * 0.08) == A && floor(i * 0.1) == B)
		{
			cout << i << endl;
			return 0;
		}
	}

	cout << -1 << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, A, B;
  cin>>N>>A>>B;

  int cnt[3] = {};
  for(int i=0;i<N;i++){
    int p;
    cin>>p;
    if(p <= A) cnt[0]++;
    else if(p <= B) cnt[1]++;
    else cnt[2]++;
  }

  int ans = min({cnt[0], cnt[1], cnt[2]});
  cout<<ans<<endl;
  return 0;
}


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

int n;
map<int, int> cnt;

int main() {
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		int x;
		cin >> x;
		++cnt[x - 1];
		++cnt[x];
		++cnt[x + 1];
	}
	int ans = 0;
	for (auto &&now : cnt) {
		ans = max(ans, now.second);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4736
#include <iostream>
#include <queue>
using namespace std;
typedef long long ll;
int n;ll a[10005],b[10005];
priority_queue<int,vector<int>, greater<int>>q1,q2;
int main(){
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<=n;i++)
        cin>>b[i];
    ll b_a=0,a_b=0;
    for (int i=1;i<=n;i++){
        if (a[i]>b[i]){
            a_b+=(a[i]-b[i]);
        }
        else if (a[i]<b[i]){
            b_a+=(b[i]-a[i])/2;
        }
    }
    if(a_b>b_a){
        cout<<"No";
    } else{
        cout<<"Yes";
    }
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<ll, ll>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

// int main() {
//     ios::sync_with_stdio(false);
//     cin.tie(0);
    
//     int n;
//     cin >> n;
//     vp bracket_p;
//     vp bracket_n;
//     ll sm = 0;
//     rep(i, n) {
//         string t;
//         cin >> t;
//         ll now = 0;
//         ll mn = 0;
//         rep(j, sz(t)) {
//             if (t[j] == '(') {
//                 now++;
//             } else {
//                 now--;
//                 chmin(mn, now);
//             }
//         }
//         if (now > 0) bracket_p.eb(-mn, -now);
//         else {
//             now = -now;
//             mn = mn + now;
//             bracket_n.eb(-mn, -now);
//             now = -now;
//         }
//         sm += now; 
//     }
//     if (sm != 0) {
//         cout << "No" << endl;
//         return 0;
//     }
//     sort(all(bracket_p));
//     sort(all(bracket_n));
//     ll now = 0;
//     rep(i, sz(bracket_p)) {
//         ll depth = -bracket_p[i].fi, size = -bracket_p[i].se;
//         if (now + depth >= 0) {
//             now += size;
//         } else {
//             cout << "No" << endl;
//             return 0;
//         }
//     }
//     for (int i = sz(bracket_n) - 1; i >= 0; --i) {
//         ll depth = -bracket_n[i].fi, size = -bracket_n[i].se;
//         if (now + depth >= 0) {
//             now += size;
//         } else {
//             cout << "No" << endl;
//             return 0;
//         }
//     }
//     cout << "Yes" << endl;
// }

bool check(vp s) {
    int h = 0;
    for (P p : s) {
        int b = h + p.fi;
        if (b < 0) return false;
        h += p.se;
    }
    return true;
} 

int main() {
    int n;
    cin >> n;
    vp ls, rs;
    int sm = 0;
    rep(i, n) {
        string s;
        cin >> s;
        int b = 0, h = 0;
        rep(j, sz(s)) {
            if (s[j] == '(') h++; else h--;
            chmin(b, h);
        }
        if (h > 0) ls.eb(b, h);
        else rs.eb(b-h, -h);
        sm += h;
    }
    sort(rall(ls));
    sort(rall(rs));
    if (check(ls) && check(rs) && sm == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 34476
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<functional>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef queue<P> Q;

int main(){
    string s;
    cin >> s;
    cout<< s[0] << s.size()-2 << s[s.size()-1];
    return 0;
}

Measured memory_bytes: 256
/******************
*  Author: BD747  *
******************/
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
#include<bits/stdc++.h>
using namespace std;

#define MP make_pair

typedef long long ll;

ll n,x,y,now,whi,ai,bi;
vector<pair<int,pair<int,int> > > v;
ll ans[2];

bool cmp(pair<int,pair<int,int> > a,pair<int,pair<int,int> > b){
	return a.first>b.first;
}

int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x>>y;
		v.push_back(MP(x+y,MP(x,y)));
	}
	sort(v.begin(),v.end(),cmp);
	for(int i=0;i<v.size();i++){
		if(i%2==0) ans[0]+=v[i].second.first;
		else ans[1]+=v[i].second.second;
	}
	cout<<ans[0]-ans[1];
	return 0;
}



Measured memory_bytes: 1912
#include <bits/stdc++.h>
 
using namespace std;
 
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
 
 
 
int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
 
    double r;
 
    cin >> r;
 
    printf("%.10lf", 2.0*r*M_PI);
 
    return 0;
}

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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

template<typename A>
void UNIQUE(vector< A > &a,int mode=0){
    if(mode==0){ sort(ALL(a),greater< A >());}else{ sort(ALL(a));}
    a.erase(unique(ALL(a)),a.en());
}

int main(){
    int n;
    cin>>n;
    Vi a(n);
    REP(i,n) cin>>a[i];
    
    Vi b = a;
    UNIQUE(b);

    if(a.size() == b.size()){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const int MAX = 510000;

ll fac[510000], finv[510000], inv[510000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}


// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
/*
int main() {
    // 前処理
    COMinit();

    // 計算例
    cout << COM(100000, 50000) << endl;
}*/

//printf("%.10f\n", N);
/*
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
    */
int main(){
    ll N,M;
    while(cin >> N >> M){
        ll n= gcd(N,M);
        cout << n << " " << N / n * M << endl;
    }
}


Measured memory_bytes: 3012
def mi(): return map(int,input().split())
def lmi(): return list(map(int,input().split()))
def ii(): return int(input())
def isp(): return input().split()

import sys
import numpy as np

sys.setrecursionlimit(10**8)
n,m,x=mi()
list_ans=[]
for i in range(n):
  c_=lmi()
  list_ans.append(c_)

ans=float('inf')

def dfs(i,suma,count):
  global ans
  if i==n:
    
    if np.all(count>=x):
      ans=min(ans,suma)
      return ans

  else:
    dfs(i+1,suma,count)
    dfs(i+1,suma+list_ans[i][0],count+np.array(list_ans[i][1:]))

dfs(0,0,np.array([0]*m))
if ans==float('inf'):
  print(-1)
  exit()
  
else:
  print(ans)

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

int main(){
  string S,T;
  cin>>S>>T;
  int i=0,m=0;
  
  while(i<T.size()){
    if(S.at(i)!=T.at(i)){
      S.at(i)=T.at(i);
      i++;
      m++;
    }
    else{
      i++;
    }
  }
  cout<<m<<endl;
}  

Measured memory_bytes: 3848
/**Coder Khỏe ♥♥♥ Code Vui**/
#include<bits/stdc++.h>

using namespace std;

#define ii pair<int, int>
#define li pair<long long, int>
#define si pair<string, int>
#define is pair<int, string>
#define ci pair<char, int>
#define ic pair<int, char>
#define iii pair<pair<int, int>, int>
#define fi first
#define se second
#define FOR(i,x,y) for (int i=x; i<=y; i++)
#define FOD(i,x,y) for (int i=x; i>=y; i--)

const int oo=1e9+9;
const int nmax=1e6+9;
const int cot[4]={0, 0, -1, 1};
const int dong[4]={-1, 1, 0, 0};
int n;
long long k, a[59];
priority_queue<long long> pq;
//------------------------------------------
int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    //freopen("text.inp",  "r", stdin);
    //freopen("text.out", "w", stdout);
    cin>>n;
    FOR(i,1,n)
    {
        cin>>a[i];
        pq.push(a[i]);
    }
    while (pq.top()+k>=n)
    {
        long long x=pq.top()+k;
        pq.pop();
        long long m=x/n;
        x-=m*n;
        k+=m;
        pq.push(x-k);
    }
    cout<<k<<endl;
    return 0;
}
/**NXKhang ♥ VNgHT**/





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define SORT(i) sort((i).begin(), (i).end())
#define INF 2000000000
constexpr ll mod = 1e9 + 7;
 
int main(){
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    int L = A + B, R = C + D;
    if (L > R){
        cout << "Left" << "\n";
    }
    else if(L < R){
        cout << "Right" << "\n";
    }
    else {
        cout << "Balanced" << "\n";
    }

        return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def main():
	N = INT()
	A = MAP()

	cur = 1
	cnt = []
	for i in range(N):
		# print(i, A[i])
		if A[i] == cur:
			cnt.append(i)
			cur += 1

	# print(cur)
	# print(cnt)
	print(N-len(cnt) if len(cnt)>0 else -1)

if __name__ == '__main__':
	main()

Measured memory_bytes: 24988
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,X,Y;
  cin>>A>>B>>C>>X>>Y;
  int mi=A*X+B*Y;
  for(int z=0;z<2*max(X,Y)+1;z++){
    mi=min(mi,A*max(0,X-z/2)+B*max(0,Y-z/2)+C*z);
  }
  cout<<mi<<endl;
}

Measured memory_bytes: 256
def resolve():
    N = int(input())
    B = list(map(int, input().split()))
    ans = []
    while B:
        for i in range(len(B) - 1, -1, -1):
            if B[i] == i + 1:
                ans.append(i + 1)
                del B[i]
                break
        else:
            print(-1)
            return 
    print(*ans[::-1], sep='\n')



if __name__ == "__main__":
    resolve()

Measured memory_bytes: 9188
# クラスカル法
class Kruskal_UnionFind():
    # 無向グラフであるという前提に注意
    def __init__(self, N):
        self.edges = []
        self.rank = [0] * N
        self.par = [i for i in range(N)]
        self.counter = [1] * N

    def add(self, u, v, d):
        """
        u = from, v = to, d = cost
        """
        self.edges.append([u, v, d])

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            z = self.counter[x] + self.counter[y]
            self.counter[x], self.counter[y] = z, z
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def size(self, x):
        x = self.find(x)
        return self.counter[x]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def Kruskal(self):
        """
        return: 最小全域木のコストの和
        """
        edges = sorted(self.edges, key=lambda x: x[2])  # costでself.edgesをソートする
        res = 0
        for e in edges:
            if not self.same(e[0], e[1]):
                self.unite(e[0], e[1])
                res += e[2]
        return res

V, E = map(int, input().split())

Krus = Kruskal_UnionFind(V)

for _ in range(E):
    s, t, w = map(int, input().split())
    Krus.add(s, t, w)

ans = Krus.Kruskal()

print(ans)



Measured memory_bytes: 27168
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
string s;cin>>s;
int a=0;
for(char x:s){
    if(x=='o')a++;
}
cout<<700+a*100;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int n, i;
	
	scanf("%d", &n);
		
	for(i=0; i<n; i++){
		int x, y, b, p, cost=0;
		scanf(" %d %d %d %d", &x, &y, &b, &p);
		
		if(b<5 && p<2)	{
			cost = x*b + y*p;
		}
		else if(b>=5 && p>=2){
			cost = (x*b + y*p) *4/5;
		}
		else if(b>=5 && p<2){
			cost = x*b + y*p;
			int alt = (x*b + y*2) *4/5;
		
			if(alt<cost) cost = alt;
		}
		else{
			cost = x*b + y*p;
			int alt = (x*5 + y*p) *4/5;
		
			if(alt<cost) cost = alt;
		}
	
		printf("%d\n", cost);
	}
	
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;
#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 2 * 105000;

struct seg {
  bool odd;
  int l, r;
  bool any = true;
};

int n, kn;
vector <int> g[MAXN];
bool used[MAXN];
int p[MAXN];
int root;
seg s[MAXN];

void print(seg a) {
  cerr << a.odd << " " << a.l << " " << a.r << " " << a.any << endl;
}

bool combine(seg &a, seg &b) {
  if (a.any) {
    a = b;
    return true;
  }
  if (b.any) {
    return true;
  }
  if (a.odd != b.odd) {
    return false;
  }
  a.l = max(a.l, b.l);
  a.r = min(a.r, b.r);
  if (a.l > a.r) {
    return false;
  }
  return true;
}

bool inside(seg a, int x) {
  if (a.any) {
    return true;
  }
  return (x & 1) == a.odd && x >= a.l && x <= a.r;
}

void dfs(int v, int par = -1) {
  for (int to : g[v]) {
    if (to != par) {
      dfs(to, v);
    }
  }
  if (!used[v]) {
    s[v].any = true;
  } else {
    s[v].any = false;
    s[v].odd = (p[v] & 1);
    s[v].l = p[v];
    s[v].r = p[v];
  }
  for (int to : g[v]) {
    if (to == par) {
      continue;
    }
    seg sc = s[to];
    sc.odd ^= true;
    sc.l--; sc.r++;
    bool ok = combine(s[v], sc);
    if (!ok) {
      puts("No");
      exit(0);
    }
  }
}

void dfs2(int v, int par = -1) {
  for (int to : g[v]) {
    if (to == par) {
      continue;
    }
    if (inside(s[to], p[v] - 1)) {
      p[to] = p[v] - 1;
    } else {
      p[to] = p[v] + 1;
    }
    dfs2(to, v);
  }
}

int main() {

  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    int from, to;
    scanf("%d %d", &from, &to);
    from--; to--;
    g[from].push_back(to);
    g[to].push_back(from);
  }

  scanf("%d", &kn);
  for (int i = 0; i < kn; i++) {
    int v, x;
    scanf("%d %d", &v, &x);
    v--;
    used[v] = true;
    p[v] = x;
    root = v;
  }

  dfs(root);

  puts("Yes");
  dfs2(root);

  for (int i = 0; i < n; i++) {
    // print(s[i]);
    printf("%d\n", p[i]);
  }

  return 0;
}

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

#define int long long

#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define ALL(v) (v).begin(), (v).end()

#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

using pi = pair<int, int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vvi = vector<vi>;
using vvb = vector<vb>;

const int INF = 1e16;
const int MOD = 1e9+7;

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


signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int n, m; cin >> n >> m;
    vvi A(n, vi(m)); REP(i, n) REP(j, m) cin >> A[i][j];
    vi b(m); REP(i, m) cin >> b[i];
    vi ans(n);
    REP(i, n)
    {
        int sum = 0;
        REP(j, m) sum += A[i][j] * b[j];
        ans[i] = sum;
    }
    REP(i, n) cout << ans[i] << endl;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x,h,w) (y) < 0 || (h) <= (y) || (x) < 0 || (w) <= (x)
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    int n; cin >> n;
    VI a(n + 1);
    eFOR(i, 1, n)cin >> a[i];

    VI ans, cnt(n + 1, 0);
    erFOR(i, 1, n) {
        if (a[i] == cnt[i])continue;
        ans.push_back(i);
        for (int j = 1; j * j <= i; ++j) {
            if (i % j == 0) {
                cnt[j] ^= 1;
                if (j * j != i)cnt[i / j] ^= 1;
            }
        }
    }

    cout << ans.size() << "\n";
    FOR(i, 0, ans.size())cout << ans[i] << (i == ans.size() - 1 ? "\n" : " ");
}


Measured memory_bytes: 3192
#include <iostream>
#include <algorithm>
#include <initializer_list>

using namespace std;

int main(void) {
    int A1, A2, A3;
    cin >> A1 >> A2 >> A3;
    cout << max({A1, A2, A3}) - min({A1, A2, A3}) << endl;
    return 0;
}


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

int main(){
  int n, k;
  cin >> n >> k;
  vector<ll> h(n);
  rep(i, n) cin >> h[i];
  sort(h.begin(), h.end());
  ll ans = 1e9;
  for(int i = 0; i < n-k+1; i++){
    ans = min(ans, h[i+k-1]-h[i]);
  }
  cout << ans << endl;

  
  
  
}

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

#include <bits/stdc++.h>
using namespace std;

class ATheNumberOfEvenPairs {
 public:
  void solveOne(int caseNumber, std::istream &in, std::ostream &out) {
    int n, m;
    in >> n >> m;

    int ans = n * (n - 1) / 2;
    ans += m * (m - 1) / 2;
    out << ans << endl;
  }
  void solve(std::istream &in, std::ostream &out) {
    int nt = 1;
    for (int i = 0; i < nt; ++i)
      solveOne(i + 1, in, out);
  }
};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ATheNumberOfEvenPairs solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 256
using System;

namespace ABC079_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = int.Parse(Console.ReadLine());
            var a = s/1000;
            var b = s%1000/100;
            var c = s%100/10;
            var d = s%10;
            if (a + b + c + d == 7)
            {
                Console.WriteLine("{0}+{1}+{2}+{3}=7",a,b,c,d);
            }
            else if (a + b + c - d == 7)
            {
                Console.WriteLine("{0}+{1}+{2}-{3}=7", a, b, c, d);
            }
            else if (a + b - c + d == 7)
            {
                Console.WriteLine("{0}+{1}-{2}+{3}=7", a, b, c, d);
            }
            else if (a - b + c + d == 7)
            {
                Console.WriteLine("{0}-{1}+{2}+{3}=7", a, b, c, d);
            }
            else if (a - b - c + d == 7)
            {
                Console.WriteLine("{0}-{1}-{2}+{3}=7", a, b, c, d);
            }
            else if (a - b + c - d == 7)
            {
                Console.WriteLine("{0}-{1}+{2}-{3}=7", a, b, c, d);
            }
            else if (a + b - c - d == 7)
            {
                Console.WriteLine("{0}+{1}-{2}-{3}=7", a, b, c, d);
            }
            else
            {
                Console.WriteLine("{0}-{1}-{2}-{3}=7", a, b, c, d);
            }
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>
#include <random>
#include <chrono>
#include <iomanip>
#define lint unsigned long long int
#define FOR(x, to) for(int x=0; x<(int)(to); x++)
#define DUMP(ar) for(auto itd=begin(ar); itd != end(ar); itd++) cout << "["s << itd - begin(ar) << "]:"s << *itd << endl
#define DUMPL(ar) for(auto itd=begin(ar); itd != end(ar); itd++) { cout << *itd; if(end(ar)-itd > 1) cout << ' '; } cout << endl
#define COUT(x) cout << (x) << endl
#define VCIN(ar) for(auto &vcin: (ar)) cin >> vcin
#define ALL(ar) ar.begin(), ar.end()
#define LOOPD(i) cout << "ループ["s << i << "]回目---------------"s << endl
using namespace std;
// lint:64ビット 10^19

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

    string s, t, u;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    cin >> u;

    if(s == u){
        cout << a-1 << ' ' << b << endl;
    }else{
        cout << a << ' ' << b-1 << endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAXN 200005
using namespace std;
//小号提交大号的代码别棕啊qwq
int n,cnt,last[MAXN];
int father[MAXN],deep[MAXN],dis[MAXN];
int q[MAXN],nnn[MAXN],mx[MAXN];
int tim,a[MAXN][2],xx,yy;
bool vis[MAXN],win[MAXN];

struct edge
{
    int to,next,h;
}t[MAXN*4];

void add(int u,int v,int h)
{
    t[++cnt].to=v;t[cnt].h=h;
    t[cnt].next=last[u];last[u]=cnt;
    t[++cnt].to=u;t[cnt].h=h;
    t[cnt].next=last[v];last[v]=cnt;
}

void dfs(int x)
{
    deep[x]=deep[father[x]]+1;nnn[x]=++tim;
    for (int i=last[x];i;i=t[i].next)
        if (t[i].to!=father[x]) father[t[i].to]=x,dfs(t[i].to);
    mx[x]=++tim;
}

bool check(int x,int y)
{
    if (nnn[x]>nnn[y]) swap(x,y);
    if (nnn[x]<nnn[y]&&mx[x]>nnn[y]) return deep[y]-deep[x]>2 ? true : false;
    if (father[x]==father[y]) return false;
    return true;
}

void bfs()
{
    int h=1,tt=1;q[1]=xx;vis[xx]=1;
    while (h<=tt)
    {
        int x=q[h++];
        for (int i=last[x];i;i=t[i].next)
            if (!t[i].h&&!vis[t[i].to])
            {
                dis[t[i].to]=dis[x]+1;
                if (dis[t[i].to]<deep[t[i].to]) vis[t[i].to]=1,q[++tt]=t[i].to;
            }
    }
}

int max(int a,int b){return a>b?a:b;}

template<class T>inline void read(T &res)
{
    static char ch;T flag=1;
    while((ch=getchar())<'0'||ch>'9')if(ch=='-')flag=-1;res=ch-48;
    while((ch=getchar())>='0'&&ch<='9')res=res*10+ch-48;res*=flag;
}

int main()
{
    int ans=0;
    read(n);read(xx);read(yy);

    for (int i=1;i<n;i++) {read(a[i][0]);read(a[i][1]);}
    for (int i=1;i<n;i++)
    {
        int x,y;
        read(x);read(y);
        add(x,y,1);
    }

    deep[0]=-1;
    dfs( yy );

    for (int i=1;i<n;i++)
    {
        if (check(a[i][0],a[i][1]))
            win[a[i][0]]=win[a[i][1]]=1;
        else add(a[i][0],a[i][1],0);
    }

    bfs();

    for (int i=1;i<=n;i++)
        if (win[i]&&vis[i])
            {putchar('-');putchar('1');return 0;}

    for (int i=1;i<=n;i++)
        if (vis[i])
            ans=max(ans,deep[i]<<1);

    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 22656
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

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








ll n;

void dfs(ll k, string s, ll u){
    if(k == n){
        cout << s << endl;
        return;
    }
    for(char c = 'a'; c <= 'a' + u; c++){
        dfs(k + 1, s + c, c == 'a' + u? u + 1 : u);
    }
}



int main(){
    cin >> n;
    dfs(0, "", 0);
}

Measured memory_bytes: 1536
#include<stdio.h>
int main(void)
{
	int n,d,x,a,k,c,i;
	scanf("%d %d %d", &n, &d, &x);
	for(i=0; i<n; i++)
	{
		scanf("%d", &a);
		k=1;
		c=0;
		while(k<=d)
		{
			c++;
			k+=a;
		}
		x+=c;
	}
	printf("%d\n", x);
	
	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#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 ll long long int
#define fast ios_base::sync_with_stdio(false)
#define fast_input cin.tie(NULL)
#define fast_output cout.tie(NULL)
#define vi vector<long long int> 
#define pb push_back
#define pa pair<long long int ,long long int> 
#define f(a,x,b) for(int a=x;a<b;a++)
#define fr(a,x,b) for(int a=x;a>=b;a--)
#define sort(x) sort(x.begin(),x.end());
#define siz(a) (int)a.size()
#define mod 1000000007
#define F first
#define S second
#define um unordered_map<ll,ll>
#define ordered_set tree<pa, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
void solve()
{
	ll n,m;
	cin>>n>>m;
	vi g[n];
	f(i,0,m)
	{
       ll x,y;
	   cin>>x>>y;
	   x--,y--;
       g[x].pb(y);
	   g[y].pb(x);
	}
	ll visited[n]={0};
	vi res;
	f(i,0,n)
	{
	   ll siz=0;
       if(!visited[i])
	   {
		   queue<ll>q;
		   q.push(i);
		   visited[i]=1;
		   while(!q.empty())
		   {
			   ll de=q.front();
			   q.pop();
			   siz++;
			   for(ll d:g[de])
			   {
                  if(!visited[d])
				  {
					  q.push(d);
					  visited[d]=1;
				  }
			   }
		   }
	   }
	   res.pb(siz);
	}
	sort(res);
	ll ans=0;
	f(i,0,res.size())
	{
		res[i]-=ans;
		ans+=res[i];
	}
	cout<<ans<<endl;
}
int main() {
	fast;
	fast_input;
	fast_output;
	// ll t;
	// cin>>t;
	// f(i,0,t)
	// {
        //  cout<<"Case #"<<i+1<<":"<<" ";
	     solve();
	// }
	return 0;
}

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] d = new int[n];
        for(int i=0;i<n;i++){
            d[i] = Integer.parseInt(sc.next());
        }
        Arrays.sort(d);
        sc.close();
        int lower = d[n/2-1];
        int higher = d[n/2];
        System.out.println(higher-lower);
    }
}

Measured memory_bytes: 49556
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <map>

#define ST_ARR_LEN(array) (sizeof(array)/sizeof(*array))

using namespace std;

using ll = long long;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;
typedef vector<int> IntVector;
typedef list<int> IntList;

typedef struct S{
  int a;
  int b;
} Object;

int main(){
  int N, M;
  cin >> N >> M;
  int s[M], c[M];
  for(int i=0;i<M;i++){
    cin >> s[i] >> c[i];
  }
  
  int n[N];
  for(int i=0;i<N;i++){
    n[i] = -1;
  }
  for(int i=0;i<M;i++){
    if(n[s[i]-1] == -1){
      n[s[i]-1] = c[i];
    }else{
      if(n[s[i]-1] == c[i]){
      }else{
        cout << -1 << endl;
        return 0;
      }
    }
  }
  if((n[0] == -1) && (N > 1)){
    n[0] = 1;
  }
  for(int i=0;i<N;i++){
    if(n[i] == -1){
      n[i] = 0;
    }
  }
  if((N > 1) && (n[0] == 0)){
    cout << -1 << endl;
    return 0;
  }
  for(int i=0;i<N;i++){
    cout << n[i];
  }
  
    
  cout << endl;
}

Measured memory_bytes: 256
'use strict'
const main = arg => {
	const input = arg.trim().split("\n");
	let a = Number(input[0])
	let b = Number(input[1])
	let h = Number(input[2])
	console.log((a + b) * h / 2)
}   
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define N 300005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
main()
{
    ll k;
    cin>>k;
    int c=1;
    ll n=7;
    ll mod=0;
    while(c<=2000000)
    {
        mod=(mod*10+7)%k;
        if(mod==0)
        {
            cout<<c;
            return 0;
        }
        c++;
    }
    cout<<-1;
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int h;
	cin >> h;
	int ans = 0;
	int now = 1;
	while(h){
		ans += now;
		now += now;
		h /= 2;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

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

        if(H%A == 0){
            ans = H/A;
        }else{
            ans = (int) H/A + 1;
        }

        System.out.println(ans);
         
    }
}

Measured memory_bytes: 22996
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
//#include"testlib.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define sz(s)    (int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
#define watch(x) cout << (#x)<<" = "<<x<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}

int main() {
	file();
	fast();
	int a, b, c, k; cin >> a >> b >> c >> k;
	int cnt = 0;
	while (b <= a)
		b *= 2, cnt++;
	while (c <= b)
		c *= 2, cnt++;
	cout << (cnt <= k ? "Yes\n" : "No\n");
	return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<string.h>

int main()
{
	char A[11],B[11],C[11];
	scanf("%s %s %s",A,B,C);
	int l1,l2,l3;
	l1=strlen(A);
	l2=strlen(B);
	l3=strlen(C);
	if(C[0]==B[l2-1] && B[0]==A[l1-1])
	{
		printf("YES\n");
	}
	else
	{
		printf("NO\n");
	}

  
    return 0;  
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <set>

using namespace std;

int main(){
  int n;
  vector<string> s;
  set<string> doublicate_checker;

  cin >> n;
  for(int i=0; i<n; i++){
    string temp;
    cin >> temp;
    s.push_back(temp);
    doublicate_checker.insert(temp);
  }

  bool out_flag = false;
  string first = s.at(0);
  for(int i=1; i<n; i++){
    if(first.at(first.size()-1) == s.at(i).at(0) ){
      first = s.at(i);
    }else{
      out_flag = true;
      break;
    }
  }

  if(out_flag || doublicate_checker.size() != s.size()){
    cout << "No";
  }else{
    cout << "Yes";
  }
}


Measured memory_bytes: 256