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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<" ";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n,m;
    cin>>n>>m;
    string ans="";
    if (n==m){
        ans="Yes";
    }else{
        ans="No";
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
  int n,a[1005];
  cin>>n;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }
  int q;
  cin>>q;
  while(q--)
  {
    int l,r;
    cin>>l>>r;
    reverse(a+l,a+r);
  }
  for(int i=0;i<n-1;i++)
  {
    cout<<a[i]<<" ";
  }
  cout<<a[n-1]<<endl;
}



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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

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

  ll ans = 1;
  rep(i, n) {
    ll t;
    cin >> t;
    ll g = __gcd(ans, t);
    ans = ans / g * t;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
signed main()
{
   SPEED;
   int n,m,x;
   cin>>n>>m>>x;
   int c[n],a[n][m];
   for(int i=0;i<n;i++)
   {
       cin>>c[i];
       for(int j=0;j<m;j++)
       {
           cin>>a[i][j];
       }
   }
   int mn=1e18;
   for(int t=1;t<=powl(2,n)-1;t++)
   {
       int sum[m]={0},res=0,flag=1;
       for(int i=0;i<n;i++)
       {
            int p=powl(2,i);
            p&=t;
            if(p==powl(2,i))
            {
                res+=c[i];
                for(int j=0;j<m;j++)
                {
                    sum[j]+=a[i][j];
                }
            }
       }
       for(int j=0;j<m;j++)
       {
           if(sum[j]<x)
           {
               flag=-1;
               break;
           }
       }
       if(flag==1)
       {
           mn=min(mn,res);
       }
   }
   if(mn==1e18)
   {
       cout<<-1;
   }
   else
   {
       cout<<mn;
   }
}

Measured memory_bytes: 3636
main = do
  (a:b:_) <- return . (map head) . words =<< getLine
  putStrLn $ f a b
  where
    f 'H' 'H' = "H"
    f 'D' 'H' = "D"
    f 'H' 'D' = "D"
    f 'D' 'D' = "H"


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

int N, M, R;
int r[8];
const int MAX_N = 202;
int mp[MAX_N][MAX_N];
int P[8];
bool used[8];
int res = 1e9 + 7;

void warshall_floyd() {
    for(int k = 0; k < N; ++k)
        for(int i = 0; i < N; ++i) 
            for(int j = 0; j < N; ++j)
                mp[i][j] = min(mp[i][j], mp[i][k] + mp[k][j]);
}

void perm(int cur) {
    if(cur >= R) {
        int tmp = 0;
        for(int i = 1; i < R; ++i) {
            int j = r[P[i-1]], k = r[P[i]];
            tmp += mp[j][k];
        }
        /*
        for(int i = 0; i < R; ++i) cout << r[P[i]] << " ";
        cout << endl;
        cout << "tmp : " << tmp << endl;
        */
        res = min(res, tmp);
    }
    else {
        for(int i = 0; i < R; ++i) {
            if(!used[i]) {
                used[i] = true;
                P[i] = cur;
                perm(cur + 1);
                used[i] = false;
            }
        }
    }
}

void solve() {
    warshall_floyd();
    /*
    for(int i = 0; i < N; ++i){
        for(int j = 0; j < N; ++j) cout << mp[i][j] << " ";
        cout << endl;
    }
    cout << endl;
    */
    perm(0);
    cout << res << endl;
}

int main()
{
    cin >> N >> M >> R;
    for(int i = 0; i < N; ++i) 
        for(int j = 0; j < N; ++j) 
            if(i != j) mp[i][j] = 1e8;

    for(int i = 0; i < R; ++i) { cin >> r[i]; --r[i]; }
    for(int i = 0; i < M; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        --a, --b;
        mp[a][b] = mp[b][a] = c;
    }

    solve();
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std; 
int main()
{
	int a,b;
	cin>>a>>b;
	if(a+b == 3) {
		cout<<"3"<<endl;
	}else if(a+b == 4) {
		cout<<"2"<<endl;
	}else if(a+b==5) {
		cout<<"1"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<ll,ll>;
#define For(i,a,b)  for(int i=a;i<=b;i++)
#define Forr(i,a,b) for(int i=a;i>=b;i--)
#define F first
#define S second
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define bpc __builtin_popcount
#define MOD (ll)(1e9+7)
#define INF (1e18)
#define EPS (1e-6)
#define NATHANLEE_IS_EVIL_AND_ELECTRIC true
#define int ll
#ifdef LOCAL_TEST
#define debug(...) do{\
	cerr<<__PRETTY_FUNCTION__<<" - "<<__LINE__<<\
	" : ("#__VA_ARGS__<<") = ";\
	_OUT(__VA_ARGS__);\
}while(0)
template<typename T>void _OUT(T x){cerr<<x<<"\n";}
template<typename T,typename...I>void _OUT(T x,I ...tail){cerr<<x<<", ";_OUT(tail...);}
#else
#define debug(...)
#endif
void INIT(){
#ifdef LOCAL_TEST
	freopen("D:\\input.in","r",stdin);
	freopen("D:\\output.out","w",stdout);
	freopen("D:\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(!NATHANLEE_IS_EVIL_AND_ELECTRIC);
	cin.tie(0);
}

ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll fpow(ll b,ll p){
	b%=MOD;
	ll ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

int dp[410][410];
int a[410];

inline int s(int i,int j){return a[j+1]-a[i];}

int go(int i,int j){
	if(i==j) return 0;
	if(dp[i][j]!=-1) return dp[i][j];
	dp[i][j]=INF;
	For(k,i+1,j) dp[i][j]=min(dp[i][j],go(i,k-1)+go(k,j));
	dp[i][j]+=a[j+1]-a[i];
	return dp[i][j];
}

int32_t main() {
	INIT();
	//code...
	int n; cin>>n;
	For(i,1,n) cin>>a[i];
	a[0]=0;
	For(i,1,n) a[i]+=a[i-1];
	memset(dp,-1,sizeof(dp));
	cout<<go(0,n-1)<<"\n";
	return 0;
}

Measured memory_bytes: 4984
import numpy as np

n, k = map(int, input().split())
h = np.array(input().split(), dtype=np.int64)

dp = np.zeros(n, dtype=np.int64)
for i in range(1, n):
    l = max(0, i-k)
    dp[i] = np.min(np.abs(h[i] - h[l:i]) + dp[l:i])

print(dp[-1])

Measured memory_bytes: 22384
#include <iostream>

using namespace std;

int main(void){
	while(1){
		int n, m; cin >> n >> m;
		if(!n && !m) break;
		int a[1001];
		for(int i=0; i<n; i++){
			cin >> a[i];
		}

		int ans = -1;
		for(int i=0; i<n-1; i++){
			for(int j=i+1; j<n; j++){
				int tmp = a[i] + a[j];
				if(ans < tmp && tmp <= m) ans = tmp;
			}
		}

		if(ans != -1) cout << ans << endl;
		else cout << "NONE" << endl;
	}
	return 0;
}


Measured memory_bytes: 3084
#include<algorithm>
#include<cassert>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-8;

const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

void print(double x){
    int t = 0;
    if(x < 0.0){
        t = ceil(x);
    }else{
        t = floor(x);
    }
    cout << t << endl;
    return;
}

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

    string s;
    while(getline(cin, s)){
        vector< P > v;
        rep(i, s.size()){
            if('a' <= s[i] && s[i] <= 'z'){
                int j = i;
                while(j < i_len && 'a' <= s[j] && s[j] <= 'z'){
                    ++j;
                }
                if(3 <= j - i && j - i <= 4){
                    v.emplace_back(i, j - i);
                }
                i = j;
            }
        }

        string ans;
        for(auto p : v){
            int d = (('t' - 'a') - (s[p.first] - 'a') + 26) % 26;
            string t;
            REP(i, p.first, p.first + p.second){
                t.push_back((((s[i] - 'a') + d) % 26) + 'a');
            }
            if(t == "the" || t == "this" || t == "that"){
                rep(i, s.size()){
                    if('a' <= s[i] && s[i] <= 'z'){
                        ans.push_back((((s[i] - 'a') + d) % 26) + 'a');
                    }else{
                        ans.push_back(s[i]);
                    }
                }
                break;
            }
        }

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
const double PI = acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

int N,K;
vector<int> w(0);

int f(int P) {
  int m = 0;
  int count = 1;
  rep(i,N) {
    if (m + w[i] <= P) m += w[i];
    else {
      count++;
      m = w[i];
    }
  }
  return count;
}

int main() {
  cin >> N >> K;
  w.resize(N);
  int M = 0;
  rep(i,N) {
    cin >> w[i];
    if (w[i] > M) M = w[i];
  } 
  
  int left = M-1;
  int right = 1e9;
  while (left + 1 < right) {
    int mid = left + (right - left) / 2;
    if (f(mid) > K) left = mid;
    else right = mid;
  }

  cout << right << endl;
}


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

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }


int main(){
  int k;
  cin >> k;
  string s;
  cin >> s;
  if(s.size() <= k){
    cout << s << endl;
    return 0;
  }
  else{
    rep(i,k)cout << s[i];
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3628
i,N=40,K=5;main(j){for(puts("40");i<N;puts(""),i++)
	if(i<K)for(j=0;j<N;j++)putchar(j==i?'N':'Y');
	else for(j=0;j<N;j++)putchar(j<K?'Y':'N');
exit(0);}

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

#define INF 1010101010

using namespace std;

int main()
{
	long long n;
	cin >> n;
	long long ans = 0;
	for (long long i = 1; i * i < n; i++) {
		long long t = (n - i) / i;
		if ((n - i) % i == 0 && n / t == n % t) {
			ans += (n - i) / i;
		}
	}
	cout << ans << endl;

	return 0;
}

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

using namespace std;
using ll = long long;

int main() {
	string s;
	cin >> s;
	bool ok = true;
	for (int i = 0; i < 3; ++i) {
		if (s[i] == s[i + 1]) { ok = false; }
	}

	if (ok) { cout << "Good" << endl; }
	else { cout << "Bad" << endl; }

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

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

using namespace std;
typedef long long unsigned int ll;

int main() {
	ll n;
	cin >> n;
	ll min = n - 1;
	for (ll i = 1; i*i <= n; i++) {
		if (n%i == 0) {
			ll tmp = i + (n / i) - 2;
			if (tmp < min)min = tmp;
		}
	}

	cout << min;
}

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

int main(){
  string S;
  cin >> S;
  int cnt=0;
  char c=S[0];
  rep(i,S.size()){
    if(c!=S[i]){
      cnt++;
      c=S[i];
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>

int main() {
    using namespace std;
    int n[3];
    cin >> n[0] >> n[1] >> n[2];
    int nf = 0, ns = 0;
    for (int i = 0; i < 3; i++) {
        if (n[i] == 5) {
            nf++;
        } else if (n[i] == 7) {
            ns++;
        }
    }
    if (nf == 2 && ns == 1) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 888
s = list(input())
n = len(s)

mod = 10**9 + 7

dp = [[0] * 13 for _ in range(n+1)]
dp[0][0] = 1

for i in range(n):
    for j in range(13):
        if s[i] == '?':
            for k in range(10):
                dp[i+1][(j*10+k)%13] += dp[i][j] 
                dp[i+1][(j*10+k)%13] %= mod
        else:
            k = int(s[i])
            dp[i+1][(j*10+k)%13] += dp[i][j]
            dp[i+1][(j*10+k)%13] %= mod

print(dp[n][5])


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

int main(void){
	int N;
	cin >> N;
	int cmax = 0, Nmax = 1;
	for (int i = 1; i <= N; i++) {
		int c = 0;
		int t = i;
		while (t%2 == 0){
			c++;
			t /= 2;	
		}
		if (c > cmax){
			cmax = c;
			Nmax = i;
		}	
	}
	cout << Nmax << endl;
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,max=0;
  string s;
  cin >> n >> s;
  for(int i=1;i<n-1;++i){
  	char a[26]={},b[26]={};
    for(int j=0;j<i;++j){
    	a[s[j]-'a']++;
    }
    for(int j=i;j<n;++j){
    	b[s[j]-'a']++;
    }
    int tmp=0;
    for(int j=0;j<26;++j){
    	if(a[j]!=0&&b[j]!=0)tmp++;
    }
    if(tmp>max)max=tmp;
  }
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
a2 = 0
a4 = 0

for i in range(n):
    if a[i] % 4 == 0:
        a4 += 1
    elif a[i] % 2 == 0:
        a2 += 1

a2 //= 2

if (a4 + a2) >= n // 2:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 14252
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

const int MXN=10000,MXM=100;
const int MOD=1e9+7;
int dp[MXN][MXM][2];
string s;
int n,m;

int solve(int i,int r,int f){
	if(i>=n){
		return r==0;
	}
	if(dp[i][r][f]!=-1)return dp[i][r][f];
	dp[i][r][f]=0;
	if(f==0)
	{
		for(int d=0;d<10;d++)
		{
			dp[i][r][f]+=solve(i+1,(r+d)%m,f);
			dp[i][r][f]%=MOD;
		}
	}
	else
	{
		for(int d=0;d<(s[i]-'0');d++)
		{
			dp[i][r][f]+=solve(i+1,(r+d)%m,0);
			dp[i][r][f]%=MOD;
		}
		dp[i][r][f]+=solve(i+1,(r+(s[i]-'0'))%m,f);
		dp[i][r][f]%=MOD;
	}
	return dp[i][r][f];
}

int32_t main()
{
   IOS
   memset(dp,-1,sizeof(dp));
   cin>>s>>m;
   n=s.length();
   cout << (solve(0,0,1)-1+MOD)%MOD << endl;
}


Measured memory_bytes: 16512
#include<cstdio>
#include<bits/stdc++.h> 
using namespace std; 
int main() 
{
    int a,b,s,g;
    cin>>a;
    b=a/100;
    g=a%10;
    if(b==g)cout<<"Yes"<<endl;
    if(b!=g)cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#define rep(i,a) for( int i = 0; i != (a); ++i )

int n;
int id[1000], p[1000], q[1000], r[1000];
int P, Q, R, C;

int main()
{
	while( scanf( "%d", &n ), n )
	{
		rep( i, n )
			scanf( "%d%d%d%d", id+i, p+i, q+i, r+i );

		scanf( "%d%d%d%d", &P, &Q, &R, &C );
	
		bool fl = false;
		rep( i, n )
			if( p[i] <= P && q[i] <= Q && r[i] <= R && 4*p[i]+9*q[i]+4*r[i] <= C )
				printf( "%d\n", id[i] ), fl = true;

		if( !fl )
			puts("NA");
	}

	return 0;
}

Measured memory_bytes: 1056
using System;

namespace AtCoderBeginnerContest148
{
    class B_StringsWithTheSameLength
    {
        static void Main(string[] args)
        {
            var length = int.Parse(Console.ReadLine());
            var st = Console.ReadLine().Split();

            var result = string.Empty;
            for (var i = 0; i < length; i++)
            {
                result += $"{st[0][i]}{st[1][i]}";
            }
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 13140
N=int(input())
S=input()

indices = list(map(ord, S))
indices2 = []
for idx in indices:
  if idx + N > 90: indices2.append(idx - 26 + N)
  else: indices2.append(idx + N)

S2 = list(map(chr,indices2))
print(''.join(S2))

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

int main()
{
    while(1){
        int h,w;
        cin>>h>>w;

        if(h==0&&w==0){
            break;
        }
        int d=h*h+w*w;

        int H=150;
        int W=150;
        int D=150*150+150*150;

        for(int y=1;y<=150;y++){
            for(int x=y+1;x<=150;x++){
                int z=y*y+x*x;

                if(z<=d){
                    continue;
                }
                else{
                    if(z<D){
                        H=y;
                        W=x;
                        D=z;
                    }
                    break;
                }
            }
        }

        for(int y=h+1;y<150;y++){
            bool flg=0;

            for(int x=y+1;x<=150;x++){
                int z=y*y+x*x;

                if(z==d){
                    H=y;
                    W=x;
                    D=z;

                    flg=1;
                }

                if(z>=d)
                    break;
            }

            if(flg)
                break;
        }

        cout<<H<<' '<<W<<endl;
    }

    return 0;
}



Measured memory_bytes: 3076
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <ctime>
#include <unordered_map>
#include <iomanip>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()

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

int N;
map<ll,ll> cnt;

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

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

    ll res=0; vector<ll> arr;
    for (auto it : cnt){
        ll v=it.fi,k=it.se;
        if (k>3) res=max(res,v*v);
        if (k>1) arr.pb(v);
    }

    sort(all(arr));
    reverse(all(arr));
    if (arr.size()>1) res=max(res,arr[0]*arr[1]);
    cout << res << "\n";
    return 0;
}


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

int main(void)
{
    long N;
    cin >> N;
    int buf;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> buf;
        A.at(buf - 1) = i;
    }
    for (int x : A) {
        cout << x + 1 << " ";
    }
    cout << endl;
}


Measured memory_bytes: 1152
/******************************************************************************
 
рассвет. 
 
*******************************************************************************/
#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define rapgame ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define eb emplace_back
#define vi vector <int>
#define vlli vector <lli>
#define vulli vector <ulli>
#define vchar vector <char>
#define vstr vector <string>
#define vb vector <bool>
#define fst first
#define sec second
#define srt(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define vpii vector <pair <int,int> >
#define pii pair <int,int> 
#define vplli vector <pair <lli,lli> >
#define vpulli vector <pair <ulli,ulli> >
#define vvi vector <vector <int> >
#define vvlli vector <vector <lli> >
#define vvpii vector <vector <pair <int,int>> >
#define fr(i,n) for (int i = 0; i < (n); ++i)
#define frbig(i,n) for (lli i = 0; i < (n); ++i)
#define fra(i,a,n) for (lli i = a; i < (n); ++i)
#define run(c,s) for(auto c:s) 
#define read(n) int n; cin >> n;
#define readchar(n) char n; cin >> n;
#define readstr(n) string n; cin >> n;
#define readarr(a,n) fr(i,n) cin >> a[i];
#define read2(x,y) int x,y; cin >> x >> y;
#define read2ll(x,y) long long int x,y; cin >> x >> y;
#define readll(n) lli n; cin >> n;
#define watch(x) cout << (#x) << " is " << (x) << endl
#define print_array(x) fr(i,x.size()) cout << x[i] << " ";
using namespace std;
 
const lli MOD=1e9+7;
const lli MAXN=1e6+1;
const ld PI=acos(-1);
 
int main(){
    rapgame
    read(n);
    vi ans(n);
    fr(i,n){
        read(x);
        ans[x-1]=i+1;
    }
    print_array(ans);
    return 0;
}

Measured memory_bytes: 1280
n,X=map(int,input().split())
x=list(map(int,input().split()))
for i in range(n):
    x[i]=abs(x[i]-X)
def gcd(a,b):
    if a<b:
        a,b=b,a
    if b==0:
        return a
    else:
        return gcd(b,a%b)
ans=x[0]
for i in range(1,n):
    ans=gcd(x[i],ans)
print(ans)

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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define File(a) freopen(a".in", "r", stdin), freopen(a".out", "w", stdout)
#define rep(i, j) for (register int i = 0, i##_end_ = j; i < i##_end_; ++ i)
#define For(i, j ,k) for (register int i = (j), i##_end_ = (k); i <= i##_end_; ++ i)
#define Fordown(i, j, k) for (register int i = (j), i##_end_ = (k); i >= i##_end_; -- i)
#define Set(a, b) memset(a, b, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define SZ(a) ((int)(a.size()))
#define ALL(a) a.begin(), a.end()
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define x first
#define y second
#define INF (0x3f3f3f3f)
#define INF1 (2139062143)
#define y1 wozenmezhemecaia 
#ifdef hany01
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif

template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }

inline int read() {
    register char c_; register int _, __;
    for (_ = 0, __ = 1, c_ = getchar(); !isdigit(c_); c_ = getchar()) if (c_ == '-')  __ = -1;
    for ( ; isdigit(c_); c_ = getchar()) _ = (_ << 1) + (_ << 3) + (c_ ^ 48);
    return _ * __;
}

const int maxn = 5e3 + 5, MOD = 1e9 + 7;

int n, uu, vv, beg[maxn], v[maxn << 1], nex[maxn << 1], e = 1, f[maxn][maxn], dp[maxn], sz[maxn], g[maxn];

inline void add(int uu, int vv) { v[++ e] = vv, nex[e] = beg[uu], beg[uu] = e; }
inline int ad(int x, int y) { return (x += y) >= MOD ? x - MOD : x; }

void DFS(int u, int pa) {
    f[u][sz[u] = 1] = 1;
    for (register int i = beg[u]; i; i = nex[i]) if (v[i] != pa) {
        DFS(v[i], u);
        For(j, 1, sz[u] + sz[v[i]]) dp[j] = 0;
        For(j, 1, sz[u]) For(k, 0, sz[v[i]])
            dp[j + k] = ad(dp[j + k], (LL)f[u][j] * f[v[i]][k] % MOD);
        For(j, 1, sz[u] += sz[v[i]]) f[u][j] = dp[j];
    }
    for (register int i = 2; i <= sz[u]; i += 2)
        f[u][0] = ad(f[u][0], MOD - (LL)f[u][i] * g[i] % MOD);
}

int main()
{
#ifdef hany01
    File("arc101e");
#endif

    For(i, 2, n = read()) uu = read(), vv = read(), add(uu, vv), add(vv, uu);
    g[0] = 1;
    for (register int i = 2; i <= n; i += 2) g[i] = (LL)g[i - 2] * (i - 1) % MOD;
    DFS(1, 0), printf("%d\n", MOD - f[1][0]);

    return 0;
}

Measured memory_bytes: 97152
import java.util.*;
public class Main{ 
 
   public static void main(String args[]) {
	 
	   Scanner s=new Scanner(System.in);
	   int r=s.nextInt();
	   int c=s.nextInt();
	   char arr[][]=new char[r][c];
		 
			  	   
		   for(int i=0;i<r;i++) {
			 String str=s.next();
		      for(int j=0;j<c;j++) {
		    	  arr[i][j]=str.charAt(j);
		      }
	      }
		   
		   
		   
	   int dp[][]=new int[r][c];
	   dp[0][0]=1;
	   for(int i=1;i<c;i++) {
		   if(arr[0][i]=='#') {
			   dp[0][i]=0;
		   }
		   else {
			   dp[0][i]=dp[0][i-1];
		   }
	   }
	   
	   for(int i=1;i<r;i++) {
		   if(arr[i][0]=='#') {
			   dp[i][0]=0;
		   }
		   else {
			   dp[i][0]=dp[i-1][0];
		   }
	   }
	   
	   for(int i=1;i<r;i++) {
		   for(int j=1;j<c;j++) {
			   if(arr[i][j]=='#') {
				   dp[i][j]=0;
				   continue;
			   }
			   dp[i][j]=(dp[i-1][j]+dp[i][j-1]) % 1000000007;
		   }
	   }
	  
	   System.out.println(dp[r-1][c-1]);
   }
}

Measured memory_bytes: 47544
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 302;

double res[N][N][N];
int a, t1, t2, t3, i, j, k, n;

double go(int t1, int t2, int t3) {
	if (res[t1][t2][t3] > -1.0) return res[t1][t2][t3];
	double r = 0.0;
	if (t1 > 0) r += t1 * 1.0 / n * (go(t1 - 1, t2, t3) + 1);
	if (t2 > 0) r += t2 * 1.0 / n * (go(t1 + 1, t2 - 1, t3) + 1);
	if (t3 > 0) r += t3 * 1.0 / n * (go(t1, t2 + 1, t3 - 1) + 1);
	r += 1 - (t1 + t2 + t3) * 1.0 / n;
	r = r * n / (t1 + t2 + t3);
	res[t1][t2][t3] = r;
	//printf("%d %d %d %.3lf\n", t1, t2, t3, r);
	return r;
}

int main() {
scanf("%d", &n);
t1 = t2 = t3 = 0;
for (i=0;i<n;i++) {
	scanf("%d", &a);
	if (a == 1) t1++; else if (a == 2) t2++; else t3++;
}
for (i=0;i<=n;i++) for (j=0;j<=n;j++) for (k=0;k<=n;k++) res[i][j][k] = -2.0;
res[0][0][0] = 0.0;
printf("%.11lf\n", go(t1, t2, t3));
return 0;
}

Measured memory_bytes: 215296
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define int intl
#define itn intl
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool flag){
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}
void fp(bool flag, string s, string t){
    if(flag)cout << s << endl;
    else cout << t << endl;
}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
signed main(){
    cout << fixed << setprecision(10);
    intl n;
    cin >> n;
    intl l[n];
    cin(i,l);
    sort(l,l + n);
    intl cnt = 0;
    repd(i, n - 1){
        repid(j, i - 1, 0){
            intl a = l[i];
            intl b = l[j];
            auto itr = lower_bound(l, l + n, a + b);
            cnt += (n - 1 - i) - distance(itr,l + n);
        }
    }
    cout << cnt << endl;
    return 0;
}

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

typedef long long ll;

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

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	string s;
	cin >> s;
	char last = 'A';
	int ans = -1;
	FOR(i,0,(int)s.size()){
		if(s[i] != last){
			ans++;
			last = s[i];
		}
	}
	ANS(ans);
	return 0;
}


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

int main() {

  int i;
  int s = 0, h = 0, len;  
  char n[1001];
  
  while(1) {
    h = 0;
    scanf("%s", n);
    if(strcmp(n, "0") == 0) break;
    len = strlen(n);

    for(i = 0; i < len; i++) {
      h += n[i]-'0';
  }
    printf("%d\n", h);

  }

  return 0;

}

Measured memory_bytes: 536
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

inline double calc(double x, double y, double a, double b){
	double k = (x-a)*(x-a)+(y-b)*(y-b);
	return pow(k, 0.5);
}
int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	lli n;
	cin >> n;
	vector<double> x(n);
	vector<double> y(n);
	vector<lli> t(n);
 
	iota(all(t), 0);
	//rep(i,n) cout << t[i];
 
	rep(i,n){
		cin >> x[i];
		cin >> y[i];
	}
	double sum=0.0;
	do{
		rep(j,n-1){
			sum += calc(x[t[j]], y[t[j]], x[t[j+1]], y[t[j+1]]);
		}
	}while(next_permutation(all(t)));
 
	double u = 1;
	while(n > 0){
		u *= n;
		--n;
	}

	double ans = sum/u;
	cout << fixed << setprecision(15) << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
const int N = 2e5 + 5;
typedef long long ll;
const ll INF = 1e15; 
using namespace std;

int n, m, A, B, x[N]; 
ll ans;
struct SegTree
{
	struct Tree { ll tag, mx[3]; } t[N << 2]; 
	void pushup(int p)
		{
			for(int i = 0; i < 3; i++)
				t[p].mx[i] = min(t[p << 1].mx[i], t[p << 1 | 1].mx[i]); 
		}
	void pushdown(int p)
		{
			if(t[p].tag)
			{
				t[p << 1].tag += t[p].tag, t[p << 1 | 1].tag += t[p].tag;
				for(int i = 0; i < 3; i++)
					t[p << 1].mx[i] += t[p].tag, t[p << 1 | 1].mx[i] += t[p].tag;
				t[p].tag = 0; 
			}
		}
	void build(int p, int l, int r)
		{
			if(l == r)
			{
				t[p].mx[0] = t[p].mx[1] = t[p].mx[2] = INF;
				t[p].mx[1] += l, t[p].mx[2] -= l; return; 
			}
			int mid = (l + r) >> 1; 
			build(p << 1, l, mid), build(p << 1 | 1, mid + 1, r); 
			pushup(p); 
		}
	void modify(int p, int l, int r, int k, ll x)
		{
			if(l == r)
			{
				t[p].mx[0] = t[p].mx[1] = t[p].mx[2] = x;
				t[p].mx[1] += l, t[p].mx[2] -= l; return; 
			}
			pushdown(p); int mid = (l + r) >> 1;
			if(k <= mid) modify(p << 1, l, mid, k, x);
			else modify(p << 1 | 1, mid + 1, r, k, x);
			pushup(p); 
		}
	ll query(int p, int l, int r, int ql, int qr, int op)
		{
			if(ql <= l && r <= qr) return t[p].mx[op];
			pushdown(p); int mid = (l + r) >> 1; ll ans = INF;
			if(ql <= mid) ans = query(p << 1, l, mid, ql, qr, op);
			if(mid < qr) ans = min(ans, query(p << 1 | 1, mid + 1, r, ql, qr, op));
			return ans; 
		}
} T; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

int mabs(int x) { return x > 0 ? x : -x; }

int main()
{
#ifndef ONLINE_JUDGE
	freopen("cpp.in", "r", stdin); 
#endif
	n = read <int> (), m = read <int> (), A = read <int> (), B = read <int> ();
	T.build(1, 1, n);
	for(int i = 1; i <= m; i++) x[i] = read <int> ();
	T.modify(1, 1, n, A, mabs(x[1] - B)), T.modify(1, 1, n, B, mabs(x[1] - A)); 
	for(int i = 2; i <= m; i++)
	{
		ans = T.query(1, 1, n, x[i], n, 1) - x[i]; 
		ans = min(ans, T.query(1, 1, n, 1, x[i], 2) + x[i]);
		T.t[1].tag += mabs(x[i] - x[i - 1]), T.modify(1, 1, n, x[i - 1], ans); 
	}
	printf("%lld\n", T.query(1, 1, n, 1, n, 0)); 
	return 0; 
}


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

int main(){
    int n;
    long long a;
    long long minValue = 1000000;
    long long maxValue = -1000000;
    long long sum = 0;
    
    cin >> n;
    
    for(int i = 0; i<n;i++){
        cin >> a;
        if(a<minValue)minValue=a;
        if(a>maxValue)maxValue=a;
        sum += a;
        
    }
    
    cout << minValue << " " << maxValue << " "<<sum<<endl;
    return 0;
}


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

int main() {
  std::ios_base::sync_with_stdio(false);
      std::cin.tie(NULL);
      int t;
      std::cin >>t;
      int arr[t];
      std::vector<int> v(t);
        for(int i=0;i<t;i++){
          std::cin >>v[i];
        }

             // sort(arr, arr+t);
            sort(v.begin(),v.end(),greater<>());

        long long int ans =0;
        int id =0;
        for(int i=0;i<t-1;i++){
           ans +=(long long int) v[id];
           if(i%2==0)
             id++;
        }
      std::cout << ans << '\n';


return 0;
}


Measured memory_bytes: 3988
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	string s;
	cin >> s;
		if (s == "abc" || s == "acb" || s == "bac" || s == "bca" || s == "cab" || s == "cba") {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
		return 0;
}

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

int main() {
	long long int n;
	scanf("%lld",&n);
	if(n%2==0){
       long long int count = 0 ;
       long long int r=10;
      int flag =0;
       while(flag!=1){
	   count = count + (n/r) ; 
	    r = r*5;
	   if(r>n){
	   break;
	    }
	   }
	printf("%lld\n",count);
	}
	else{
	    printf("0\n");
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int multiple_knapsack(int N, int W, int *v, int *w){
  int dp[N + 1][W + 1];
  memset(dp, -1, sizeof(dp));
  REP(i, W + 1) dp[0][i] = 0;
  REP(i, N){
    REP(j, W + 1){
      if(dp[i][j] < 0) continue;
      dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
      if(j - w[i] >= 0) dp[i + 1][j] = max(dp[i + 1][j], dp[i + 1][j - w[i]] + v[i]);
      if(j + w[i] <= W) dp[i + 1][j + w[i]] = max(dp[i + 1][j + w[i]], dp[i][j] + v[i]);
    }
  }
  int ans = 0;
  REP(i, W + 1) ans = max(ans, dp[N][i]);
  return ans;

}

int main() {
  int N, W; cin >>N >>W;
  int v[N], w[N];
  REP(i, N) cin >>v[i] >>w[i];
  cout <<multiple_knapsack(N, W, v, w) <<endl;
  return 0;
}

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

int main() {
    int H, W; cin >> H >> W;

    vector<string> S(100);
    rep(i,H){
        cin >> S[i];
    }

    vector<int> dx = {-1,0,1,0};
    vector<int> dy = {0,1,0,-1};

    rep(i,H){
        rep(k,W){
            if(S[i][k]=='.')continue;

            int count = 0;
            rep(j,4){
                int di = i + dx[j];
                int dk = k + dy[j];

                if (di < 0 || dk < 0 || di > H-1 || dk > W-1)continue;
                if (S[di][dk] == '#')count++;
            }
            if (count == 0){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int A[] = new int[n];
        for(int i = 0 ; i < n ; i++)
            A[i] = sc.nextInt();
        int x = A[n-1];
        int i = -1;
        for(int j = 0 ; j < n-1 ; j++){
            if(A[j] <= x){
                i++;
                int tmp = A[i];
                A[i] = A[j];
                A[j] = tmp;
            }
        }
        int tmp = A[n-1];
        A[n-1] = A[i+1];
        A[i+1] = tmp;
        StringBuilder sb = new StringBuilder();
        for(int j = 0 ; j < n-1 ; j++){
            if(j == i+1)
                sb.append("[" + A[j] + "] ");
            else
                sb.append(A[j] + " ");
        }
        if(i == n-2)
            System.out.println(sb.append("[" + A[n-1] + "]"));
        else
            System.out.println(sb.append(A[n-1]));
    }
}


Measured memory_bytes: 69644
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define ff first
#define ss second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 1000000007;
#define int long long int
int dp[1001][1001];
int h, w;
int arr[1001][1001];

void reset()
{
    for (int i = 0; i <= h; i++)
    {
        for (int j = 0; j <= w; j++)
        {
            dp[i][j] = -1;
        }
    }
}

int32_t main()
{

    cin >> h >> w;
    //char arr[h + 1][w + 1];
    reset();
    queue<pair<int, int>> pnt;
    for (int i = 1; i <= h; i++)
    {   
        string s;
        cin>>s;

        for (int j = 1; j <= w; j++)
        {
            
            char c = s[j-1];
            if (c == '#')
            {
                arr[i][j] = 0;
                pnt.push(mp(i, j));
            }
            else
            {
                arr[i][j] = -1;
            }
        }
    }
    int dir[4][2] = {{1, 0}, {-1, 0}, {0, -1}, {0, 1}};
    while (!pnt.empty())
    {
        pair<int, int> p = pnt.front();
        pnt.pop();
        int x = p.ff, y = p.ss;

        for (int i = 0; i < 4; i++)
        {
            int xx = x + dir[i][0];
            int yy = y + dir[i][1];

            if (xx >= 1 and yy >= 1 and xx <= h and yy <= w)
            {
                if (arr[xx][yy] == -1)
                {
                    arr[xx][yy] = arr[x][y] + 1;
                    pnt.push(mp(xx, yy));
                }
            }
        }
    }

    int ans = 0;

    for (int i = 1; i <= h; i++)
    {
        for (int j = 1; j <= w; j++)
        {

            ans = max(ans, arr[i][j]);
        }
    }
    cout << ans;
}


Measured memory_bytes: 32308
#include <iostream>

using namespace std;

#define N_MAX 25
#define NIL -1

struct Node{int p, l, r;}; //parent, left, right

Node T[N_MAX];

void preorder_treeWalk(int v);
void inorder_treeWalk(int v);
void postorder_treeWalk(int v);

int main()
{
    int n, i,l, r, v;
    cin >> n;

    //??¨????????????
    for (i = 0; i < N_MAX; i++)
        T[i].p = T[i].r = T[i].l = NIL;

    //??¨?????\???
    for (i = 0; i < n; i++) {
         cin >> v >> l >> r; // value, left, right
         T[v].l = l;
         T[v].r = r;
         T[l].p = T[r].p = v;
    }

    //??¨???root?????¢???
    for(i = 0; i < n; i++) {
        if (T[i].p == NIL) {
            v = i;
            break;
        }
    }

    //??¨?????????
    cout << "Preorder" << endl;
    preorder_treeWalk(v);
    cout << endl;

    cout << "Inorder" << endl;
    inorder_treeWalk(v);
    cout << endl;

    cout << "Postorder" << endl;
    postorder_treeWalk(v);
    cout << endl;

    return 0;
}

//root????????????
void preorder_treeWalk(int v) {
    cout << " " << v;

    if (T[v].l == NIL && T[v].r == NIL) return;
    if (T[v].l != NIL)
        preorder_treeWalk(T[v].l);
    if (T[v].r != NIL)
        preorder_treeWalk(T[v].r);
}

void inorder_treeWalk(int v) {
    if (T[v].l != NIL) inorder_treeWalk(T[v].l);
    cout << " " << v;
    if (T[v].r != NIL) inorder_treeWalk(T[v].r);
}

void postorder_treeWalk(int v) {
    if (T[v].l != NIL) postorder_treeWalk(T[v].l);
    if (T[v].r != NIL) postorder_treeWalk(T[v].r);
    cout << " " << v;
}

Measured memory_bytes: 3092
#include<iostream>

using namespace std;

int main(void)
{
  char str0[]="Christmas Eve Eve Eve";
  char str1[]="Christmas";
  char str2[]="Christmas Eve";
  char str3[]="Christmas Eve Eve";
  
  int a;  
  cin>>a;
  
  if(a==22){cout<<str0<<endl;}
  if(a==23){cout<<str3<<endl;}
  if(a==24){cout<<str2<<endl;}
  if(a==25){cout<<str1<<endl;}
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(v.begin(), v.end())
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 999999999
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int dS(int num) {
  int sum = 0;
  while (num != 0) {
    sum += num % 10;
    num /= 10;
  }
  return sum;
}

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

  int fx = dS(n);
  if (n % fx == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
class hoge
{
    static void Main()
    {
        string input = Console.ReadLine();
        int width = int.Parse(input.Split(' ')[0]);
        int height = int.Parse(input.Split(' ')[1]);
        int centerX = int.Parse(input.Split(' ')[2]);
        int centerY = int.Parse(input.Split(' ')[3]);
        int radius = int.Parse(input.Split(' ')[4]);
        if (centerX - radius >= 0
            & centerX + radius <= width
            & centerY - radius >= 0
            & centerY + radius <= height)
        {
            Console.WriteLine("Yes");
        }else
        {
        Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 8936
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(v) for (int i = 0; i < v.size(); i++)
#define SORT(v) sort(v.begin(), v.end())
typedef long long ll;
typedef unsigned long long ull;
const ull INF = 1e7;
const ll MOD = 1e9 + 7;

int main()
{
  int n;
  vector<int> a;
  cin>>n;

  REP(i,n) {
    int tmp;
    cin>>tmp;
    a.push_back(tmp);
  }
  SORT(a);

  bool flag = true;
  if (n%2 == 0) {
    for (int i = 0; i < n; i+=2) {
      if (!(a[i] == i+1 && a[i+1] == i+1))
        flag = false;
    }
  } else {
    if (a[0] != 0)
      flag = false;
    for (int i = 1; i < n; i+=2) {
      //cout<<i+1<<a[i]<<a[i+1];
      if (!(a[i] == i+1 && a[i+1] == i+1))
        flag = false;
    }
  }

  ull ans = 1;
  if (flag) {
    REP(i,n/2) {
      ans = (ans * 2) % MOD;
    }
  } else {
    ans = 0;
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#define MAXX 200
#define ll long long
using namespace std;

int A[111111];
int main() {
    int N;
    cin>>N;
    for(int i=0;i<N;i++)
        cin>>A[i];
    sort(A,A+N);
    
    
    if (A[N-1]-A[0] >= 2)
    {
        printf("No\n");
        return 0;
    }
    
    if (A[0]==A[N-1]) {
        if (A[0]==N-1 || 2*A[0] <= N)
            printf("Yes\n");
        else
            printf("No\n");
        return 0;
    }
    
    int C=A[N-1];
    
    
    


    
    // each group is either 1 or > 1
    // if 1 : (C-1) [x]
    // if >1 : C
    // 1,1,1,g_1,g_2,..
    
    // sum_{i=x to C-1} g_i + x = N
    // sum_{i=x to C-1} g_i = N-x
    
    // x is C-1 (size = 1) and (C-x) is C (size >= 2)
    // x+2*(C-x) <= N
    // 2*(C-x) <= N-x
    
    
    int x=0;
    for(int i=0;i<N;i++)
        if (A[i]==C) {
            x=i;
            break;
        }
    
    if (2*(C-x) > N-x || x >= C)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
    
    // (N-C) <= N-x
    
    // x + 2*(N-x) <= N
    // 2*N-x <= N
    //
    
}

Measured memory_bytes: 640