akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define all(c) (c).begin(),(c).end()
#define show(x) cout << #x << " " << x << endl
struct State{int ax,ay,bx,by,cx,cy;};
string s[16];
int W,H,N,dx[5]={1,0,-1,0,0},dy[5]={0,1,0,-1,0},inf=1e4;
int Ax,Ay,Bx,By,Cx,Cy,ax,ay,bx,by,cx,cy;
short int d[16][16][16][16][16][16];
bool is(int x,int y){
	return (0<=x&&x<H&&0<=y&&y<W&&s[x][y]!='#');
}
void three(){
	queue<State> que;
	rep(ai,H) rep(aj,W) rep(bi,H) rep(bj,W) rep(ci,H) rep(cj,W) d[ai][aj][bi][bj][ci][cj]=inf;
	d[Ax][Ay][Bx][By][Cx][Cy]=0;
	que.push(State{Ax,Ay,Bx,By,Cx,Cy});
	while(!que.empty()){
		State st=que.front();
		que.pop();
		rep(ad,5){
			int nax=st.ax+dx[ad],nay=st.ay+dy[ad];
			if(!is(nax,nay)) continue;
			rep(bd,5){
				int nbx=st.bx+dx[bd],nby=st.by+dy[bd];
				if(!is(nbx,nby)) continue;
				rep(cd,5){
					int ncx=st.cx+dx[cd],ncy=st.cy+dy[cd];
					if(!is(ncx,ncy)) continue;
					if(d[nax][nay][nbx][nby][ncx][ncy]!=inf) continue;
					if(nax==nbx&&nay==nby) continue;
					if(nbx==ncx&&nby==ncy) continue;
					if(ncx==nax&&ncy==nay) continue;
					if(nax==st.bx&&nay==st.by&&nbx==st.ax&&nby==st.ay) continue;
					if(nbx==st.cx&&nby==st.cy&&ncx==st.bx&&ncy==st.by) continue;
					if(ncx==st.ax&&ncy==st.ay&&nax==st.cx&&nay==st.cy) continue;
					d[nax][nay][nbx][nby][ncx][ncy]=d[st.ax][st.ay][st.bx][st.by][st.cx][st.cy]+1;
					que.push(State{nax,nay,nbx,nby,ncx,ncy});
				}
			}
		}
	}
}
void two(){
	queue<State> que;
	rep(ai,H) rep(aj,W) rep(bi,H) rep(bj,W) d[ai][aj][bi][bj][0][0]=inf;
	d[Ax][Ay][Bx][By][0][0]=0;
	que.push(State{Ax,Ay,Bx,By,0,0});
	while(!que.empty()){
		State st=que.front();
		que.pop();
		rep(ad,5){
			int nax=st.ax+dx[ad],nay=st.ay+dy[ad];
			if(!is(nax,nay)) continue;
			rep(bd,5){
				int nbx=st.bx+dx[bd],nby=st.by+dy[bd];
				if(!is(nbx,nby)) continue;
				if(d[nax][nay][nbx][nby][0][0]!=inf) continue;
				if(nax==nbx&&nay==nby) continue;
				if(nax==st.bx&&nay==st.by&&nbx==st.ax&&nby==st.ay) continue;
				d[nax][nay][nbx][nby][0][0]=d[st.ax][st.ay][st.bx][st.by][0][0]+1;
				que.push(State{nax,nay,nbx,nby,0,0});
			}
		}
	}
}
void one(){
	queue<State> que;
	rep(ai,H) rep(aj,W) d[ai][aj][0][0][0][0]=inf;
	d[Ax][Ay][0][0][0][0]=0;
	que.push(State{Ax,Ay,0,0,0,0});
	while(!que.empty()){
		State st=que.front();
		que.pop();
		rep(ad,5){
			int nax=st.ax+dx[ad],nay=st.ay+dy[ad];
			if(!is(nax,nay)) continue;
			if(d[nax][nay][0][0][0][0]!=inf) continue;
			d[nax][nay][0][0][0][0]=d[st.ax][st.ay][0][0][0][0]+1;
			que.push(State{nax,nay,0,0,0,0});
		}
	}
}
int main(){
	while(true){
		scanf("%d%d%d\n",&W,&H,&N);
		if(W==0) break;
		rep(i,H) getline(cin,s[i]);
		ax=0,ay=0,bx=0,by=0,cx=0,cy=0;
		rep(i,H) rep(j,W){
			if(s[i][j]=='A') Ax=i,Ay=j;
			if(s[i][j]=='B') Bx=i,By=j;
			if(s[i][j]=='C') Cx=i,Cy=j;
			if(s[i][j]=='a') ax=i,ay=j;
			if(s[i][j]=='b') bx=i,by=j;
			if(s[i][j]=='c') cx=i,cy=j;
		}
		if(N==3) three();
		if(N==2) two();
		if(N==1) one();
		cout<<d[ax][ay][bx][by][cx][cy]<<endl;
	}
}

Measured memory_bytes: 37572
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

double h,w,bmi,best;
int n,i,num;

int main(){
	while(scanf("%d",&n)*n){
		best=9999999;
		for(;n>0;n--){
			scanf("%d %lf %lf",&i,&h,&w);
			bmi=fabs(22-w*10000/h/h);
			if(bmi<best || (bmi==best && i<num)){
				best=bmi;
				num=i;
			}
		}
		printf("%d\n",num);
	}
	return 0;
}

Measured memory_bytes: 628
#include<bits/stdc++.h>
using namespace std;
int N;
string s;
set<string>st;
int main(){
    cin>>N;
    while(N--){
        cin>>s;
        st.insert(s);
    }
    if(st.size()==3)cout<<"Three";
    else cout<<"Four";
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){

    int N;
    scanf("%d", &N);

    int p[N];
    int index[N];
    for(int i = 0; i < N; i += 1){
        scanf("%d", &p[i]);
        index[i] = i + 1;
    }

    int judge = 0;
    for (int i = 0; i < N; i += 1){
        if(index[i] != p[i]){
            judge += 1;
        }
    }

    if(judge < 3){
        printf("YES");
    }else{
        printf("NO");
    }

    return 0;
}

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

using namespace std;

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

    set<int> st;
    for (int i = 1; i <= 9; ++i) {
        for (int j = i; j <= 9; ++j) {
            st.insert(i * j);
        }
    }

    if (st.find(n) != st.end()) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;

    }

//    for (int i = 1; i <= 9; ++i) {
//        if (n % i == 0 and n / i <= 9) {
//            cout << "Yes" << endl;
//            return 0;
//        }
//    }
//    cout << "No" << endl;
    return 0;
}

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

int n;
int r[1010], w[1010];
int dp[1000010];

int main(){
    while(cin >> n && n){
        int sum_r = 0, sum_w = 0, max_r = 0;
        for(int i = 0; i < n; ++i){
            cin >> r[i] >> w[i];
            if(r[max_r] < r[i]){
                max_r = i;
            }
            sum_r += r[i];
            sum_w += w[i];
        }

        if(r[max_r] * 2 <= sum_r){
            cout << sum_r + sum_w << endl;
        } else {
            swap(r[n-1], r[max_r]);
            swap(w[n-1], w[max_r]);
            int rem = r[n-1]*2 - sum_r;
            for(int i = 0; i <= rem; ++i) dp[i] = false;
            dp[0] = true;
            for(int i = 0; i < n-1; ++i){
                for(int j = rem; j >= w[i]; --j){
                    dp[j] |= dp[j-w[i]];
                }
            }
            int dead = -1;
            for(int i = rem; i >= 0; --i){
                if(dp[i]){
                    dead = rem - i;
                    break;
                }
            }
            cout << sum_r + sum_w + dead << endl; 
        }
    }
}

Measured memory_bytes: 3068
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int m,n,aa[110000],a,b,cnt=0;
pair<int,int> p[220000];
string s,ss[220000];
char c;
signed main(){
    cin>>a>>b>>n;
    if(n-a-b<0){
        cout<<"No";
        return 0;
    }
    if(a*b<(n-a-b)*(n-a-b)/4||(a*b==(n-a-b)*(n-a-b)/4&&((n-a-b)*(n-a-b))%4>0)){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
string S, T;
int ss[100005][26];
int main() {
        
        cin >> S >> T;

        int nowpos[26];
        fill_n(*ss, 100005 * 26, -1);
        fill_n(nowpos, 26, -1);

        for (int i = S.size() - 1; i >= 0; i--) {
                nowpos[S[i] - 'a'] = i;
                for (int j = 0; j < 26; j++) {
                        ss[i][j] = nowpos[j];
                }
        }
        
        int pos = 0;
        int loop = 0;
        ll ans = 0;
        for (int i = 0; i < T.size(); i++) {
                if (ss[pos][T[i] - 'a'] == -1) {
                        pos = 0;
                        loop++;
                }
                int finded = ss[pos][T[i] - 'a'];
                if (finded == -1) { cout << -1 << endl; return (0); }
                pos = finded + 1;
                ans = (ll)loop * S.size() + finded + 1;
        }
                
        cout << ans << endl;
        return (0);
}

Measured memory_bytes: 10752
#include<iostream>
#include<vector>
#include <string>

using namespace std;

bool is_kaibun(string S){
    int N = S.size();
    for(int i=0; i < N/2; i++){
        if(S[i] != S[N-1-i]) return false;
    }
    return true;
}

int main(){
    bool ans;
    string S;
    cin >> S;
    int N = S.size();
    // cout << (N-1)/2 << endl;
    // cout << S.substr(0,(N-1)/2) << endl;
    // cout << S.substr((N+1)/2) << endl;
    if(is_kaibun(S) && is_kaibun(S.substr(0,(N-1)/2)) && is_kaibun(S.substr((N+1)/2))){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int n,m,x,a[100]={0},i,ans=0,tmp=0;
	scanf("%d%d%d",&n,&m,&x);
	for(i=0;i<m;i++){
		scanf("%d",&tmp);
		a[tmp-1]=1;
	}tmp=0;
	for(i=x-1;i>=0;i--){
		tmp+=a[i];
	}
	for(i=x-1;i<n;i++){
		ans+=a[i];
	}
	if(ans>tmp)ans=tmp;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

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

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100;

int main() {
	int n,k;cin>>n>>k;
	bool f[10];rep(i,10) f[i]=true;
	rep(i,k) {int d;cin>>d;f[d]=false;}
	int ans=n;
	while(true) {
		int tmp=ans;
		bool flag=true;;
		while(tmp!=0) {
			flag=flag&&f[tmp%10];
			tmp/=10;
		}
		if(flag) break;
		ans++;
	}
	cout<<ans<<endl;
}


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

int main(){
    int x, n;

    std::cin >> x >> n;
    if (n == 0)
    {
        std::cout << x << std::endl;
        return 0;
    }
    
    std::vector<int> p(n);
    for (int i = 0; i < n; i++)
    {
        std::cin >> p[i];
    }

    int min = 101;
    int a = 0;
    for (int i = 0; i <= 101; i++)
    {
        auto itr = std::find(p.begin(), p.end(), i);
        if (itr == p.end()) {
            if (abs(x - i) < min)
            {
                min = abs(x - i);
                a = i;
            }
        }
    }
    std::cout << a << std::endl;

    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9 + 7;
const int INF = 2e18;

signed main() {
    int N;
    cin >> N;
    const int V = 1e5 + 10;
    vector<vector<int>> G(2 * V);
    for (int i = 0; i < N; i++) {
        int x, y;
        cin >> x >> y;
        y += V;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    vector<bool> check(2 * V, false);
    vector<int> count(2, 0);
    function<void(int)> dfs = [&](int v) {
        if (check[v]) return;
        check[v] = true;
        if (v >= V) count[1]++;
        else count[0]++;
        for (int next : G[v]) dfs(next);
    };
    int ans = 0;
    for (int i = 0; i <= V; i++) {
        if (check[i]) continue;
        count = vector<int>(2, 0);
        dfs(i);
        ans += count[0] * count[1];
    }
    ans -= N;
    cout << ans << endl;
}


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

typedef long long int LL;
typedef unsigned long long uLL;
typedef pair < int , int > ii;
const int inf = 1e9;
const LL INF = 1e18;
const int N = 1e5 + 5;
const int mod = 1000000007;
const double eps = 1e-8;
const double pi = acos( -1.0 );

int main( int argc , char const *argv[] ) {
        ios_base :: sync_with_stdio(false); cin.tie(NULL);
        string a , b;
        cin >> a >> b;
        if( a == b ) return cout << "Yes" << endl,0;
        int cnt = a.size();
        while( cnt-- ) {
               a = ( a[a.size()-1] ) + a;
               a.pop_back();
               if( a == b ) return cout << "Yes" << endl,0;
        } return cout << "No" << endl,0;
        return 0;
}








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

using namespace std;


const long long MOD = 1000000007;


int main(){
    int n;
    cin >> n;
    string s1, s2;
    cin >> s1 >> s2;
    long long ans = 1;
    int last;
    if (s1[0] == s2[0]){
        last = 1;
        ans = 3;
    } else {
        last = 0;
        ans = 6;
    }
    for (int i = 1; i < n - 1; i++){
        ans %= MOD;
        if (last == 0 && s1[i] == s1[i + 1]){
            ans *= 3;
            continue;
        }
        if (last == 0 && s1[i] == s2[i]){
            last = 1;
            continue;
        }
        if (last == 1 && s1[i] == s2[i]){
            ans *= 2;
            continue;
        }
        if (last == 1 && s1[i] == s1[i + 1]){
            ans *= 2;
            last = 0;
            continue;
        }
    }
    ans %= MOD;
    if (last == 1 && n != 1){
        ans *= 2;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
ll f[1<<6][305],ans;
int n,C,L[15];
int main(){
	cin>>n>>C;
	for(int i=0;i<n;++i)cin>>L[i];
	sort(L,L+n);
	int tot=0,T=(1<<n-1)-1;
	do{
		++tot;memset(f,0,sizeof(f));
		f[0][n*L[n-1]]=1;
		for(int i=1;i<=n*C;++i){
			if(i%n){
				int id=i%n-1,t=min(i+L[id]*n,n*C);
				for(int s=0;s<=T;++s){
					if(!(s>>id&1)){
						for(int k=i;k<=n*C;++k){
							f[s|(1<<id)][max(t,k)]+=f[s][k];
						}
					}
				}
			}
		}
		ans+=f[T][n*C];
	}while(next_permutation(L,L+n-1));
	printf("%.16lf\n",1.0*ans/tot/pow(C,n-1));
	return 0;
}

Measured memory_bytes: 3708
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////


int main(){fastio
    /*
    ll n=10;
    ll dp[n][n][n][n];memset(dp,0,sizeof(dp));
    rep(i,0,n-1){
        rep(j,0,n-1){
            rep(k,0,n-1){
                rep(l,0,n-1){
                    if(i-1>=0&&dp[i-1][j][k][l]==0)dp[i][j][k][l]=1;
                    if(j-1>=0&&dp[i][j-1][k][l]==0)dp[i][j][k][l]=1;
                    if(k-1>=0&&dp[i][j][k-1][l]==0)dp[i][j][k][l]=1;
                    if(l-1>=0&&dp[i][j][k][l-1]==0)dp[i][j][k][l]=1;
                    if(i*j*k*l>0&&dp[i-1][j-1][k-1][l-1]==0)dp[i][j][k][l]=1;
                }
            }
        }
    }
    rep(i,0,n-1){
        rep(j,0,n-1){
            cout<<"ij:"<<i<<" "<<j<<endl;
            rep(k,0,n-1){
                rep(l,0,n-1){
                    cout<<dp[i][j][k][l]<<" ";
                }cout<<endl;
            }cout<<endl;
        }cout<<endl;
    }*/
    ll n;cin>>n;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    sort(a,a+n);
    ll sum=0;
    rep(i,0,n-1)sum+=a[i];
    if(n%2==1){
        if(sum%2==1)cout<<"First"<<endl;
        else cout<<"Second"<<endl;
        return 0;
    }
    if(a[0]%2==1){
        cout<<"First"<<endl;
    }else{
        if(sum%2==1)cout<<"First"<<endl;
        else cout<<"Second"<<endl;
    }
    
    return 0;
}


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

int main() {
	int n,m;
	cin>>n;
	cin>>m;
	string s(m+2,'#');
	cout<<s<<endl;
	string t;
	while(n--){
		cin>>t;
		cout<<"#"<<t<<"#"<<endl;
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;
char S[3],T[3];
int main() {
	for(int i=0;i<3;i++){
		cin>>S[i];
	}
	for(int i=0;i<3;i++){
		cin>>T[i];
	}

	if(S[0]==T[2] && S[1]==T[1] && S[2]==T[0]){
		cout<<"YES"<<endl;
	}else cout<<"NO"<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
const int mod=1e9+7;

int main() {
  int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  map<int,int>k;
  for(int i=0;i<N;i++){
    k[A[i]]++;
  }
  int even=0;
  for(auto c:k){
    if(c.second%2==0){even++;}
  }
  if(even%2!=0){cout<<k.size()-1<<endl;}
  else{cout<<k.size()<<endl;}
  return 0;
}

Measured memory_bytes: 8092
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;
#define dbg4(w,x, y, z) cerr << #w << " = " << w << ", " <<#x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

double p[3100];
double dp[3100][3100];
int main()
{
    //FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
    //cin >> T;
    T = 1;
    for (int cs = 1; cs <= T; cs++) {
        int n;
        cin >> n;
        for (int i = 0; i < n; i++) cin >> p[i];
        dp[0][0] = 1;

        for (int i = 1; i <= n; i++) {
            for (int j = 0; j <= i; j++) {
                if (j)dp[i][j] += dp[i - 1][j - 1] * p[i-1];
                dp[i][j] += dp[i - 1][j] * (1 - p[i-1]);
            }
        }

        double ret = 0;
        for (int i = 0; i <= n; i++) {
            if (i > n - i)ret += dp[n][i];
        }

        printf("%.12lf\n", ret);
    }

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);
    return 0;
}

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

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==1 && b==1){
        cout<<"Open"<<endl;
    }
    else if(c==1){
        cout<<"Open"<<endl;
    }
    else cout<<"Close"<<endl;
    return 0;
}

Measured memory_bytes: 1156
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long
#define INF             __LONG_LONG_MAX__

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve2(ll w, ll h) {
  vector<vector<int>> grid(h);
  rep(i, h) {
    grid[i].resize(w);
    rep(j, w) cin >> grid[i][j];
  }

  ll ans = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (grid[i][j] != 1) continue;

      queue<ll> qx, qy;
      qx.push(j); qy.push(i); grid[i][j] = -1;
      while (!qx.empty()) {
        ll x = qx.front(); qx.pop();
        ll y = qy.front(); qy.pop();

        for (int k = 0; k < 8; k++) {
          ll nx = x + dx[k];
          ll ny = y + dy[k];

          if (nx >= 0 && nx < w && ny >= 0 && ny < h && grid[ny][nx] == 1) {
            grid[ny][nx] = -1;
            qx.push(nx);
            qy.push(ny);
          }
        }
      }

      ans++;
    }
  }
  outl(ans);
}

void solve() {
  while (true) {
    ll w, h; cin >> w >> h;
    if (w == 0 && h == 0) break;
    solve2(w, h);
  }
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}



Measured memory_bytes: 3184
#include <cstdio>

int n;

int main()
{
    scanf("%d", &n);
    while (n > 0) {
        if (n % 10 == 9) {
            printf("Yes\n");
            return 0;
        } else {
            n /= 10;
        }
    }

    printf("No\n");
    return 0;
}

Measured memory_bytes: 128
import * as fs from 'fs';

const lines = fs.readFileSync('/dev/stdin', 'utf-8').trim().split('\n');
const [s, t] = lines[1].split(' ');

let result = '';
for (const [x, y] of zip(s, t)) {
  result += x + y;
}
console.log(result);

function* zip(xs: string, ys: string) {
  const len = Math.min(xs.length, ys.length);
  for (let i = 0; i < len; i++) {
    yield [xs[i], ys[i]] as const;
  }
}


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

using namespace std;

const int mod = 998244353;

int fact[500050],inv[500050];

int qpow(int base,int tms)
{
    int tmp = 1;
    while(tms)
    {
        if(tms & 1) tmp = tmp * 1ll * base % mod;
        base = base * 1ll * base % mod;
        tms >>= 1;
    }
    return tmp;
}

int C(int n,int r)
{
    return fact[n] * 1ll * inv[r] % mod * inv[n - r] % mod;
}

int main()
{
    fact[0] = inv[0] = 1;
    for(int i = 1;i <= 500000; ++ i)
        fact[i] = fact[i - 1] * 1ll * i % mod;
    inv[500000] = qpow(fact[500000],mod - 2);
    for(int i = 499999;i >= 1; -- i)
        inv[i] = inv[i + 1] * 1ll * (i + 1) % mod;
    int n,m; scanf("%d%d",&n,&m);
    int lim = min(n,m),ans = 0;
    for(int i = 0,sgn = 1;i <= lim; ++ i,sgn = mod - sgn)
        ans = (ans + sgn * 1ll * C(n,i) % mod * C(m,i) % mod * qpow(n + 1,m - i) % mod * qpow(m + 1,n - i) % mod * fact[i] % mod) % mod;
    printf("%d\n",ans);
    return 0;
}

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

int main(){
  string s,t;cin>>s>>t;
  int ans=0;
  rep(i,s.size()){
    if(s[i]!=t[i])ans++;
  }
  cout<<ans;
}

Measured memory_bytes: 3828
from bisect import bisect_left,bisect_right

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n = ii()
l = li()
l.sort()

ans = 0

lset = list(set(l))
lset.sort()
l_dup = []
for i in range(len(lset)):
    l_dup.append(l.count(lset[i]))

# 3辺が異なる
for i in range(len(lset)-1):
    for j in range(i+1,len(lset)):
        if lset[i]*2 < lset[j]:
            minside = lset[j] - lset[i] +1 
        else:
            minside = lset[i] + 1

        msi = bisect_left(lset,minside)
        ans += l_dup[i] * l_dup[j] * sum(l_dup[msi:j])


        # print('---')
        # print(lset[i], lset[j],minside)
        # print(lset[msi+1:j])
        
# 二等辺
# 正△
for i in range(len(lset)):
    if l_dup[i] >= 2:
        msi = bisect_left(lset,lset[i]*2)
        ans += l_dup[i] * (l_dup[i]-1)/2 * (sum(l_dup[:msi]) - l_dup[i])

    if l_dup[i] >= 3:
        ans += l_dup[i] * (l_dup[i]-1) * (l_dup[i]-2)/6

print(int(ans))

Measured memory_bytes: 3188
N = int(input())
li = list(map(int,input().split()))
li.sort(reverse = True)
al = 0
bob = 0
for i in range(N):
  if i % 2 == 0:
    al = al + li[i]
  else:
    bob = bob + li[i]
an = al - bob
print(an)

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll X, t;
    cin >> X >> t;
    cout << max(X-t, 0LL) << endl;
    return 0;   
}

Measured memory_bytes: 3568
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 998244353;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
//combination(Nが小さい時はこれを使う
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; 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 COMB(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;
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

//繰り返し二乗法（Nが大きい時の場合のcombination)
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= (i % mod); res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
//UnionFind
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int dight(int n) {
	int ans = 1;
	while (n >= 10) {
		n /= 10;
		ans++;
	}
	return ans;
}
int dight_sum(int n) {
	int sum = 0;
	rep(i, 20)sum += (n % (int)pow(10, i + 1)) / (pow(10, i));
	return sum;
}
int a, b, c, k;
signed main() {
	cin >> a >> b >> c >> k;
	if (a >= k)cout << k << endl;
	else if (a + b >= k)cout << a << endl;
	else cout << a - (k - (a + b)) << endl;
	ggr
}


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

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	int a[3]; scanf("%d%d%d", a, a+1, a+2);
	sort(a, a+3);
	puts(a[0]+a[1]==a[2] ? "Yes" : "No");
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int N;
int a[100010];

int main(){
	cin >> N;
	repp(i,0,N) cin >> a[i];
	sort(a,a+N);
	int ans = 0;
	int z = 1;
	repp(i,0,N){
		if(a[i] == a[i+1]) ++z;
		else {
			if(z < a[i]) ans += z;
			else ans += z-a[i];
			z = 1;
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main()
{
    int n, r;
    cin >> n >> r;
    if (n < 10)
    {
        cout << r + 100 * (10 - n) << endl;
    }
    else
    {
        cout << r << endl;
    }
}

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

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

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

    ll N,M;
    string S;
    cin >> N>>M;
    vector<ll> a(M+2);
    REPS(i, M)
        cin >> a.at(i);

        a.at(0) = -1;
        a.at(M + 1) = N+1;

        bool flag = true;
        REPS(i,M-1){
            if(a.at(i)+1==a.at(i+1)){
                flag = flase;
            }
        }

        /*REP(i,M+2){
            cout << i << ":" << a.at(i) << endl;
        }*/

        vector<ll> b(M+1);

        REP(i,M+1){
            b.at(i) = a.at(i + 1) - a.at(i) - 2;
            //cout << i << " " << b.at(i) << endl;
        }

        ll dp[N+10];

        dp[1] = 1;
        dp[0] = 1;

    REP(i,N){
        dp[i + 2] = dp[i] + dp[i + 1];
        dp[i + 2] %= MOD;
    }

    ll ans = 1;

    if(flag){
    REP(i,M+1){
        //cout << i<<" "<<b.at(i) <<" "<< dp[b.at(i)] << endl;
        ans *= dp[b.at(i)];
        //cout << ans << endl;
        ans %= MOD;
    }
    cout << ans << endl;
    }
    else{
        cout << 0 << endl;
    }
}


Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static void Main()
    {
        var r = ReadLine().Split().Select(long.Parse).ToArray();
        int N = (int)r[0];
        var C = (int)r[1];
        var K = r[2];
        var T = new long[N];
        for (int i = 0; i < N; i++)
        {
            T[i] = long.Parse(ReadLine());
        }
        Array.Sort(T);

        int ans = 0;
        int index = 0;
        
        
        while (index < N)
        {
            long maxtime = T[index] + K;
            int c = 0;
            while (index < N && c < C && T[index]<=maxtime)
            {
                c++;
                index++;

            }
            ans++;
        }
        WriteLine(ans);
    }
}


Measured memory_bytes: 32776
#include<stdio.h>

int main() {
int n;
scanf("%d",&n);
int rem = n%10;
if( rem == 2 || rem == 4 || rem == 5 || rem == 7 || rem == 9)
printf("hon");
else if ( rem == 0 || rem == 1 || rem == 6 || rem == 8 )
printf("pon");
else
printf("bon");
return 0;
}

Measured memory_bytes: 1720
#include<iostream>
#include<cstring>
#include<cstdio>
#include<unordered_map>
#include<vector>
#include<algorithm>

using namespace std;

#define LL long long
#define fgx cerr<<"--------------"<<endl;
#define dgx cerr<<"=============="<<endl;

inline int read(){
	int x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int MAXN = 200010;
const int INF = 2147483600;

unordered_map<int,int> mp;
int a[MAXN+1];
int N; int ans;

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	N=read(); for(int i=1;i<=N;i++) {
		int x=read(); mp[x]++; a[i]=x;
	} sort(a+1,a+N+1);
	for(int i=N;i>=1;i--){
		if(a[i]==a[i+1]) continue;
		bool flag=0; int now=mp[a[i]];
		for(int j=30;j>=0;j--) if((1LL<<j)==a[i]) flag=1;
		if(flag) {ans+=now/2; now&=1;}
		for(int j=30;j>=0&&now;j--){
			int to=(1<<j); if(to-a[i]>=a[i]) continue;
			if(to<=a[i]) break;
			int d=to-a[i],p=min(now,mp[d]);
			if(p){ mp[d]-=p; now-=p; ans+=p; }
		}
	} printf("%d\n",ans);
	return 0;
}

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

const int maxn = 100010;
int n, K, a[maxn];

int main() {
    scanf("%d %d", &n, &K);
    int g = 0;
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]), g = __gcd(a[i], g);
    }
    if (K <= *max_element(a + 1, a + n + 1) && !(K % g)) {
        printf("POSSIBLE\n");
    } else {
        printf("IMPOSSIBLE\n");
    }
    return 0;
}

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

using namespace std;

vector<int> g[100010];

int dfs(int v, int p = 0)
{
    int r = 0;
    for (int nv : g[v])
    {
        if (nv == p)
            continue;
        r ^= dfs(nv, v) + 1;
    }
    return r;
}

void solve()
{
    int n;
    cin >> n;
    for (int i = 0; i < n - 1; i++)
    {
        int u, v;
        cin >> u >> v;
        u--, v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    int grundy = 0;
    for (int v : g[0])
    {
        grundy ^= dfs(v) + 1;
    }
    cout << (grundy ? "Alice" : "Bob") << endl;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 10368
S = input()
T = input()
N, M = len(S), len(T)
ans = 1000
for i in range(N - M + 1):
	sub = S[i:i + N]
	temp = 0
	for j in range(M):
		if sub[j] != T[j]:
			temp += 1
	if (temp < ans):
		ans = temp
print(ans)

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

int main(){
    //let's make せかいのナベアツ!!
   
    int n,i,x;
    cin>>n;
    i=1;
    while(i<=n){
		if(i%10==3||i%3==0){
			cout<<" "<<i;  
			 
		}else{
			 x=i;
			 while(x!=0){
			      x=x/10;
			      if(x%10==3){
					cout<<" "<<i;
					break;
			      }
			 }
		}
        i+=1;
	}
	cout<<endl;
	return 0;	 
}



Measured memory_bytes: 3088
#include<iostream>
#include <bits/stdc++.h>
#include <cstdio>
#include<set>
using namespace std;
int main()
{
    int N, K;
    int ans = 0;
    cin >> N;
    cin >> K;
    vector<int> h(N);
    
    for (int i = 0; i < N; i++){
        cin >> h[i];
        if (h[i] >= K){
            ans++;
        }
    }
    cout << ans<< endl;;
    return 0;    
}


Measured memory_bytes: 640
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]
A, B = map(list, zip(*AB))

A.sort()
B.sort()

def median(a):
    n = N
    return a[(n+1)//2-1] if n%2 else (a[n//2-1]+a[n//2])/2

A_mid = median(A)
B_mid = median(B)

r = int((B_mid-A_mid) * [2, 1][N%2]) + 1

print(r)

Measured memory_bytes: 61140
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    if (N % 2 == 0) {
        int cnt = ((N - 2) * N) / 2;
        int S = 0;
        cout << ((N - 2) * N) / 2 << endl;
        rep(i, N - 1) {
            REP(j, i + 1, N - 1) {
                if (j == N - i - 1) continue;
                cout << i + 1 << " " << j + 1 << endl;
            }
        }
        return 0;
    } else {
        cout << ((N - 2) * (N - 1)) / 2 + (N / 2) << endl;
        rep(i, N - 1) {
            REP(j, i + 1, N - 1) {
                if (j == N - i - 2) continue;
                cout << i + 1 << " " << j + 1 << endl;
            }
            //cout << i + 1 << " " << N << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		
		Scanner scanner = new Scanner(System.in);
		
		int n = Integer.parseInt(scanner.nextLine());
		int num[] = new int[n];
		
		for(int i = 0;i < n;i++){
			num[i] = Integer.parseInt(scanner.next());
		}
		
		int flag = 1;
		int tmp = 0;
		int cnt = 0;
		while(flag == 1){
			flag = 0;
			for(int j = n-1;j >= 1;j--){
				if(num[j] < num[j-1]){
					tmp = num[j];
					num[j] = num[j-1];
					num[j-1] = tmp;
					flag = 1;
					cnt++;
				}
			}
		}
		
		for(int i = 0;i < n;i++){
			if(i > 0){
				System.out.print(" ");
			}
			System.out.print(num[i]);
		}
		System.out.println();
		System.out.println(cnt);
	}
}


Measured memory_bytes: 26264
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int a[50][50];
int cnt=0;
int main()
{
	int n,d;
	cin>>n>>d;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=d;j++){
			cin>>a[i][j];
		}
	}
	for(int i=1;i<n;i++){
		for(int j=i+1;j<=n;j++){
			double c=0;
			for(int k=1;k<=d;k++){
				c+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
			}
			c=sqrt(c);
			if(floor(c)==c){
				cnt++;
			}
		}
	}
	cout<<cnt;
	return 0;
}

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

long long int MOD = 1e9 + 7;
map<long long int, long long int> bag;
map<long long int, long long int> :: iterator itr;
long long int n, m;

long long int mult(long long int x, long long int y){
	return (x*y)%MOD;
}

long long int fast_exp(long long int x, long long int y){
	long long int e[64];
	e[0] = 1;
	e[1] = x;
	for(int i=2; i < 64; i++){
		e[i] = mult(e[i-1], e[i-1]);
	}
	int index = 1;
	long long int ans = 1;
	while(y != 0){
		if(y%2 == 1) ans = mult(ans, e[index]);
		y /= 2;
		index++;
	}
	return ans;
}

long long int bs(long long int b, long long int s){
	long long int x = 1;
	long long int y = 1;
	long long int xx = (b+s);
	long long int yy = b;
	for(int i=0; i < b; i++){
		x = mult(x, xx), xx--;
		y = mult(y, yy), yy--;
	}
	return mult(x, fast_exp(y, MOD-2));
}

void build(long long int xx){
	long long int x = xx;
	long long int y = 2;
	while(y*y <= xx and x > 1){
		if(x%y == 0) bag[y]++, x /= y;
		else y++;
	}

	if(x > 1) bag[x]++;
}

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

	long long int ans = 1;
	for(itr=bag.begin(); itr != bag.end(); ++itr){
		long long int p = itr->first;
		long long int tmp = bs(bag[p], n-1);
		ans = mult(ans, tmp);
	}
	cout << ans << endl;
}

Measured memory_bytes: 888
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i,j;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  string s,t;
  cin>>s>>t;
  if(s.size() < t.size()){
    cout<<"UNRESTORABLE"<<endl;
    return ;
  }
  ll flg=0;
  for(int i = s.size()-t.size();i > -1;i--){
    bool ok = true;
    for(int j = 0;j<t.size();j++){
      // cout<<s[i+j]<<endl;
      if(s[i+j] == '?') continue;
      else if(s[i+j] != t[j]){
        ok = false;
        break;
      }
    }
    if(ok == true) {
      flg=1;
      rep(j,t.size()) s[j+i] = t[j];
      break;
    }
  }

  if(flg == 0) {
    cout<<"UNRESTORABLE"<<endl;
    return ;
  } else {
    rep(i,s.size()){
      if(s[i] == '?') s[i] = 'a';
    }
  }
  cout<<s<<endl;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

template<class T> class segtree {
	int n;
	vector<T> data;
	T id;
	function<T(T, T)> operation;
	function<T(T, T)> update;
public:
	segtree(int _n, T _id, function<T(T, T)> _operation, function<T(T, T)> _update)
		:id(_id), operation(_operation), update(_update) {
		n = 1;
		while (n < _n + 2) n <<= 1;
		data = vector<T>(2 * n, id);
	}
	void change(int i, T x) {
		i += n;
		data[i] = update(data[i], x);
		while (i > 1) {
			i >>= 1;
			data[i] = operation(data[i << 1], data[i << 1 | 1]);
		}
	}
	T get(int a, int b) {
		T left = id; T right = id;
		a += n; b += n;
		while (a < b) {
			if (a & 1) left = operation(left, data[a++]);
			if (b & 1) right = operation(data[--b], right);
			a >>= 1; b >>= 1;
		}
		return operation(left, right);
	}
	T get_all() { return data[1]; }
	T operator[](int i) { return data[i + n]; }
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	rep(i, n) {
		if (!((i + a[i]) & 1)) {
			cout << "No\n";
			return 0;
		}
	}
	segtree<int> seg(n, 0, [](int a, int b) {return a + b; }, [](int a, int b) {return a + b; });
	segtree<int> evenseg(n, 0, [](int a, int b) {return a + b; }, [](int a, int b) {return a + b; });
	segtree<int> oddseg(n, 0, [](int a, int b) {return a + b; }, [](int a, int b) {return a + b; });
	ll cnt = 0, evencnt = 0, oddcnt = 0;
	rep(i, n) {
		ll now = seg.get(a[i] + 1, n + 1); cnt += now;
		seg.change(a[i], 1);
		if (i & 1) {
			ll x = oddseg.get(a[i] + 1, n + 1); oddcnt += x;
			oddseg.change(a[i], 1);
		}
		else {
			ll x = evenseg.get(a[i] + 1, n + 1); evencnt += x;
			evenseg.change(a[i], 1);
		}
	}
	cout << (cnt == (evencnt + oddcnt) * 3 ? "Yes" : "No") << '\n';
}

Measured memory_bytes: 13696
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;// (int)3e18;
const int maxn = 2000100;



int main(){
        _
        ll a,b,c; cin >> a >> b >> c;
        int cnt = 0;
        while(true){

            if(a%2 or b%2 or c%2)break;
            if(a==b and b==c){
                cnt = -1;
                break;
            }

            ll x,y,z;
            x = a/2, y = b/2, z = c/2;
            a = y+z, b = x+z, c = x+y;
            cnt++;
        }
        cout<<cnt<<endl;


return 0;
}




Measured memory_bytes: 256
def ina;gets.split(' ').map(&:to_i);end
n,m,k=ina
an=ina
bn=ina
baccv,baccc=0,0
bn.each do |x|
  break unless baccv+x<=k
  baccv+=x
  baccc+=1
end
aaccv,aaccc=0,0
an.each do |x|
  break unless aaccv+x<=k-baccv
  aaccv+=x
  aaccc+=1
end
res=baccc+aaccc
bn[0,baccc].reverse.each do |bi|
  baccv-=bi
  baccc-=1
  an[aaccc..-1].each do |ai|
    break unless aaccv+ai<=k-baccv
    aaccv+=ai
    aaccc+=1
  end
  tmp=baccc+aaccc
  res=tmp if res<tmp
end
p res

Measured memory_bytes: 50692