akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

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

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> As(N);
    REP(n, N) cin >> As[n];
    vector<ll> A2s(N);
    REP(i, N) {
        A2s[i] = As[i] - (i + 1);
    }
    sort(ALL(A2s));
    // for(auto a: A2s) cout << a << ","; cout << endl;

    map<ll, int> keys;
    for(auto a2: A2s) {
        ++keys[a2];
    }
    ll ans = 1e18;
    ll b = -1;
    int used = 0;
    bool first = true;
    ll tmp_ans = 0;
    for(auto kv: keys) {
        ll key = kv.first;
        ll value = kv.second;
        if (first) {
            b = key;
            for(auto a2: A2s) tmp_ans += abs(a2 - b);
            first = false;
        }
        else {
            ll next_b = key;
            tmp_ans
                = tmp_ans + (next_b - b) * used
                - (next_b - b) * (N - used);
            b = next_b;
        }
        used += value;
        // cout << "tmp_ans:" << tmp_ans << endl;
        ans = min(ans, tmp_ans);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 15872
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li      int32_t
#define lli     long long
#define ulli unsigned long long

#define pn           printf("\n")
#define nl           cout<<'\n'
#define sf(N)        scanf("%lld",&N)
#define pf(N)        printf("%lld",N)
#define sf1(N1,N2)    scanf("%lld %lld",&N1,&N2)
#define pf1(N1,N2)    printf("%lld %lld",N1,N2)
#define sf2(N1,N2,N3) scanf("%lld %lld %lld",&N1,&N2,&N3)
#define pf2(N1,N2,N3) printf("%lld %lld %lld",N1,N2,N3)

#define sl          cout<<' '
#define ps          printf(" ")

#define rep(i,a,b)  for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define elif        else if
#define mset(a,b)   memset(a,b,sizeof(a))

#define pb      push_back
#define pob     pop_back
#define itr     iterator
#define sz()    size()
#define szof    sizeof
#define lb      lower_bound
#define ub      upper_bound
#define mp      make_pair
#define vlli    vector<lli>
#define plli    pair<lli,lli>
#define vplli   vector<plli >
#define F       first
#define S       second
#define Dup     erase(unique(V.begin(),V.end()),V.end())

#define bs      binary_search
#define ub      upper_bound
#define lb      lower_bound

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

#define MX1     100000
#define MX2     1000000
#define MX3     10000
#define mod     1000000007
#define Inf     1000000000000000
using namespace std;

lli Power(lli a,lli b)
{
    lli result=1;

    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }

        b=b>>1;
        a=(a*a)%mod;
    }

 return result;
}

lli Count[MX2+1];

int main()
{
    opt;
    
    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // */
    
    lli N,i;
    cin>>N;
    
    rep(i,0,N)
    {
        lli x;
        cin>>x;
        
        if(x>0)
        Count[x-1]++;
        Count[x]++;
        Count[x+1]++;
    }
    
    lli Max=1;
    rep(i,0,MX1+2)
    {
        if(Count[i]>=Max)
        {
            Max=Count[i];
        }
    }
    
    cout<<Max;

    


    
    
    

 return 0;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)c.size())

typedef unsigned long long ull;
const int INF = (int)1e8;

bool prime[1000001]; //10^6
int t[1000001*2];

//素数列挙
void init_prime()
{
	memset(prime,1,sizeof(prime));
	prime[0] = prime[1] = false;
	for(int i = 2; i < sizeof(prime); i++) if(prime[i])
		for(int j = i * 2; j < sizeof(prime); j += i) prime[j] = false;
	t[0] = 0;
	for(int i = 0; i < sizeof(prime); i++) t[i+1] = t[i] + prime[i+1];
	for(int i = sizeof(prime); i < sizeof(t)/sizeof(int); i++) t[i+1] = t[i];
}

int main(){
	init_prime();
	int n;
	while(cin>>n,n){
		int p = 0;
		FOR(i,n){
			int x,y; cin>>x>>y;
			int cnt = t[x+y]-t[max(x-y-1,0)];
			p += cnt-1;
		}
		cout << p << endl;
	}

	return 0;
}

Measured memory_bytes: 9956
# coding=utf-8

if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))

    before = -1
    satisfied = 0

    for num in A:
        satisfied += B[num-1]
        if (before != -1) and ((before + 1) == num):
            satisfied += C[num-2]
        before = num
    print(satisfied)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=998244353;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

const int M=500005;
ll F[M];

void Init(){
	F[0]=1;
	for(int i=1;i<M;i++) F[i]=F[i-1]*i%mod;
}

ll Div(ll n,ll m){
	return n*Pow(m,mod-2)%mod;
}

ll nCk(ll n,ll k){
	return Div(F[n],F[n-k]*F[k]%mod);
}

ll n,A,B,m;

int main(){
	Init();
	cin>>n>>A>>B>>m;
	ll res=0;
	for(ll i=0;i<=n;i++){
		ll m_=m-A*i;
		if(m_>=0&&m_%B==0){
			ll x=i,y=m_/B;
			if(x>n||y>n) continue;
			(res+=nCk(n,x)*nCk(n,y))%=mod;
		}
	}
	cout<<res<<endl;
}

Measured memory_bytes: 4096
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using lint = long long;

int main()
{

    lint n;
    scanf("%lld", &n);

    std::string s;
    std::cin >> s;

    std::vector<lint> cum_sum_w(n);
    std::vector<lint> cum_sum_b(n);

    lint sum_w, sum_b;
    sum_w = sum_b = 0;

    for (int i = 0; i < n; ++i)
    {
        if (s[i] == '.')
            sum_w++;
        else
            sum_b++;

        cum_sum_b[i] = sum_b;
        cum_sum_w[i] = sum_w;
    }

    lint ans = 200001;

    for (int i = 0; i < n + 1; ++i)
    {
        lint cand;
        if (i == 0)
        {
            cand = n - cum_sum_b.back();
        }
        else if (i == n)
        {
            cand = n - cum_sum_w.back();
        }
        else
        {
            cand = cum_sum_b[i - 1] + cum_sum_w.back() - cum_sum_w[i - 1];
        }

        ans = std::min(ans, cand);
    }

    printf("%lld", ans);

    return 0;
}


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

const int MaxN=2e5+5;
const int Mod=1e9+7;

int N,Ans;
int BIT[MaxN],F[MaxN];

struct Node{
	int x,v,id;
}A[MaxN];

pair<int,int> B[MaxN];

void Add(int i,int v){
	for(i++;i<=N+1;i+=i&-i)
		BIT[i]=(BIT[i]+v)%Mod;
}

int Get_Pre(int i){
	int sum=0;
	for(i++;i;i-=i&-i)
		sum=(sum+BIT[i])%Mod;
	return sum;
}

int main(){
	int i,j,tmp;
	scanf("%d",&N);
	for(i=1;i<=N;i++)
		scanf("%d%d",&A[i].x,&A[i].v);
	sort(A+1,A+N+1,[](Node a,Node b){return a.v<b.v;});
	for(i=1;i<=N;i++)
		A[i].id=i;
	sort(A+1,A+N+1,[](Node a,Node b){return a.x<b.x;});
	for(tmp=0,i=1;i<=N;i++)
		B[A[i].id].first=tmp=max(tmp,A[i].id);
	for(tmp=1<<30,i=N;i;i--)
		B[A[i].id].second=tmp=min(tmp,A[i].id);
	sort(B+1,B+N+1);
	F[0]=1;
	Add(0,1);
	for(i=1;i<=N;i++){
		F[i]=(Get_Pre(B[i].first)-Get_Pre(B[i].second-2)+Mod)%Mod;
		if(B[i].first==N)
			Ans=(Ans+F[i])%Mod;
		Add(B[i].first,F[i]);
	}
	printf("%d\n",Ans);
	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

vector<pair<ll,ll>> p;

// index が条件を満たすかどうか
bool isOK(int index, int key) {
    if (p[index].first > key) return true;
    else return false;
}

// 汎用的な二分探索のテンプレ
int binary_search(int key) {
    int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok = (int)p.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key)) ok = mid;
        else ng = mid;
    }
    return ok;
}


signed main(){
	int n; ll d,a; cin>>n>>d>>a;
	rep(i,n){
		ll x,h; cin>>x>>h; p.PB(MP(x,h));
	}
	p.PB(MP(LINF,0LL));
	sort(ALL(p));
	VI idx(n); // x[i]を左端に爆発させたときの右端のindex
	rep(i,n) idx[i]=binary_search(p[i].first+2*d)-1; // 二分探索

	// rep(i,n) cerr<<idx[i]<<' ';
	// cerr<<endl;

	ll ans=0,cnt=0; queue<pair<int,long>> q;
	// cnt:累積の爆風
	rep(i,n){
		ll x=p[i].first, h=p[i].second;
		while(q.size()&&q.front().first<x){
			cnt-=q.front().second; // 到達しない爆風は減らす
			q.pop();
		}
		ll need=max((h+a-1)/a-cnt,0LL);
		ans+=need; cnt+=need; // x[i]で爆発させた分は累積させる
		q.push(MP(p[idx[i]].first,need));
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 7660
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,s=0,ans=0;
    cin >> n;
    vector<int> a(n),b(n),c(n);
    for (int i=0;i<n;i++){
        cin >> a.at(i);
    }
    for (int i=0;i<n;i++){
        cin >> b.at(i);
                c.at(i)=a.at(i)-b.at(i);
    }
    sort(c.begin(), c.end());
    reverse(c.begin(), c.end());
    while (true){
        if (s==n) break;
        if (c.at(s)<0) break;
        ans=c.at(s)+ans;
        s++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <set>
#define LL long long
using namespace std;
int main()
{
	int n,x,y,t,i,j,x1,y1,t1;
	cin>>n;
	bool yes = true;
	x1 = y1 = t1 = 0;
	for(i=0;i<n;i++){ 
		scanf("%d%d%d",&t,&x,&y);
		if(!yes) continue;	 
		x = abs(x-x1);
		y = abs(y-y1);
		t = abs(t-t1);
		if(    (t>=x+y) && ((t-x-y)%2==0) )   yes = true;
		else {
			yes = false;
		}
		x1 = x;    y1 = y;    t1 = t;
    }
    if(yes) printf("Yes\n");
	else printf("No\n");
		
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 100 + 5, inf = 1e9;
#define pb push_back
#define mp make_pair
#define ll long long
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define sz(x) (int)x.size()
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int dp[N][N];
bool a[N][N];
int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int n, m;
	cin >> n >> m;
	for(int i = 1; i <= n; i++){
		string s;
		cin >> s;
		for(int j = 0; j < m; j++){
			a[i][j + 1] = (s[j] == '#');
		}
	}
	memset(dp, 0x3f3f3f, sizeof dp);
	dp[1][1] = a[1][1];
	for(int j = 2; j <= m; j++){
		if(!a[1][j])dp[1][j] = dp[1][j - 1];
		else{
			if(a[1][j - 1]){
				dp[1][j] = dp[1][j - 1];
			}else{
				dp[1][j] = dp[1][j - 1] + 1;
			}
		}
	}
	for(int i = 2; i <= n; i++){
		if(!a[i][1])dp[i][1] = dp[i - 1][1];
		else{
			if(a[i - 1][1]){
				dp[i][1] = dp[i - 1][1];
			}else{
				dp[i][1] = dp[i - 1][1] + 1;
			}
		}
	}
	for(int i = 2; i <= n; i++){
		for(int j = 2; j <= m; j++){
			if(!a[i][j]){
				dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]);
			}else{
				if(a[i][j - 1])dp[i][j] = min(dp[i][j], dp[i][j - 1]);
				else dp[i][j] = min(dp[i][j], dp[i][j - 1] + 1);
				if(a[i - 1][j])dp[i][j] = min(dp[i][j], dp[i - 1][j]);
				else dp[i][j] = min(dp[i][j], dp[i - 1][j] + 1);
			}
		}
	}
	cout << dp[n][m] << '\n';
	return 0;
}



Measured memory_bytes: 384
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2) 
const int MGN = 10;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions 

#endif


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

    int N, K, Q; cin >> N >> K >> Q;
    vi A(Q); 
    REP(i, Q) {
        cin >> A[i];
        A[i]--;
    }

    vs ans(N, "Yes");
    if (K <= Q) {
        vi b(N, 0);
        REP(i,Q) {
            b[A[i]]++;
        }

        REP(i,N) {
            if (K - Q + b[i] <= 0) ans[i] = "No";
        }
    }

    REP(i,N) cout << ans[i] << endl;


    return 0;
}

Measured memory_bytes: 6528
I = int(''.join(input().split()))

primes = [3, 5, 7, 11, 13, 17, 19]

for p in primes:
    l = [(i * i) % p for i in range(p // 2 + 1)]
    if I % p not in l:
        print('No')
        exit()

print('Yes')


Measured memory_bytes: 2940
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int N, a;
    cin >> N;
    
    vector<int> vec;
    for(int i = 0; i < N; ++i)
    {
        cin >> a;
        vec.push_back(a);
    }
    
    for(int i = vec.size() - 1; i >= 0; --i)
    { 
        cout << vec[i];
        if(i != 0) 
        { cout << " "; }
        
    }
    cout << endl;
    
    return 0;
}


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

int main()
{
  int N;
  cin >> N;
  vector<pair<long, pair<int, int>>> pairs(N);

  vector<long> x(N), y(N), h(N);
  rep(i, N)
  {
    int X, Y;
    long H;
    cin >> X >> Y >> H;
    x[i] = X;
    y[i] = Y;
    h[i] = H;
    pairs[i] = make_pair(H, make_pair(X, Y));
  }
  sort(pairs.begin(), pairs.end());

  rep(x_i, 101)
  {
    rep(y_i, 101)
    {
      long H = pairs[N - 1].first + abs(pairs[N - 1].second.first - x_i) + abs(pairs[N - 1].second.second - y_i);
      bool is_equal = true;
      rep(i, N - 1)
      {
        long Hi = pairs[i].first + abs(pairs[i].second.first - x_i) + abs(pairs[i].second.second - y_i);
        if (pairs[i].first == 0)
        {
          if (H - Hi > 0)
          {
            is_equal = false;
            break;
          }
        }
        else if (H != Hi)
        {
          is_equal = false;
          break;
        }
      }
      if (is_equal)
      {
        cout << x_i << " " << y_i << " " << H << endl;
        return 0;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>

using namespace std;

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

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main() {
  int n,x,sum = 0,cnt = 1;
  cin >> n >> x;
  vector<int> l(n);
  for (int i = 0; i < n; i++){
    cin >> l[i];
    sum += l[i];
    if (sum <= x){
      cnt++;
    }
  }
  cout << cnt << '\n';
  return 0;
}

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

int main() {
  
  string S; cin >> S;
  int count = 0;
  
  for (int i = 0; i < S.size(); i++) {
    
    if (i % 2 == 0 && S[i] == 'L') {
      cout << "No" << endl;
      count = 1;
      break;
    }
    
    if (i % 2 == 1 && S[i] == 'R') {
      cout << "No" << endl;
      count = 1;
      break;
    }
    
  }
  
  if (count == 0) cout << "Yes" << endl;
  
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N;
string W[105];
bool flag = true;
map<string,int> mp={};
int main(){
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> W[i];
        if(mp[W[i]]!=0){
            flag = false;
        }
        mp[W[i]]++;
    }
    
    for(int i=0;i<N-1;i++){
        if(W[i].back() != W[i+1].front()){
            flag = false;
        }
    }
    
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream> // C++の入出力
#include <stdio.h> // C の入出力
#include <algorithm> // sort などのアルゴリズム 
#include <string.h> // C の文字列用
#include <ctype.h> // C の文字種用
#include <string> // C++の文字列
using namespace std; // std 名前空間を使用する

int main(void){
    string str1,str2,work;
    int n,ans=0,p;
    cin>>str1;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>str2;
        for(int j=0;j<str2.size();j++){
            for(int k=0;k<str1.size();k++){
                p=0;
                if(str2[k]!=str1[k])break;
                if(k==str1.size()-1){p=1;break;}
            }
            work = str2.substr(0,1);
            str2 = str2.substr(1,str2.size()) + work;
            if(p==1){
                ans++;
                break;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1212
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

struct Node {
    int key;
    Node * parent, *left, *right;
};

Node *root, *NIL;

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    while(x != NIL) {
        y = x;
        if(z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    z->parent = y;   
    if(y == NIL) {
        root = z;
    } else if(z->key < y->key) {
        y->left = z;
    } else {
        y->right = z;
    }
}

void inorder(Node *u) {
    if(u == NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u) {
    if(u == NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main() {
    int n, x;
    string com;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> com;
        if(com == "insert") {
            cin >> x;
            insert(x);
        } else if(com == "print") {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    return 0;
}


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

#define sp <<" "
#define el <<"\n"
#define S second
#define F first
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define obit __builtin_popcount
#define pof pop_front
#define For(i,a,n) for(i=a;i<n;i++)
#define all(ar) ar.begin(),ar.end() 
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned short int us;
typedef short int ss;
typedef long double ld;
const ll mod = 1000000007;



int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    /*
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    //*/
    ll n,l,r,ans;
    cin>>n;
    r = ans = n;
    l = 1;
    while(l<=r){
        ll mid = l + (r-l)/2, pw;
        pw = (mid * (mid + 1))/2;
        if(pw>=n){
            ans = mid;
            r = mid - 1;
        }
        else l = mid + 1;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
int mod=1e9+7;

signed main(){
  while(true){
    int n;
    cin>>n;
    if(!n)break;
    vector<int> a(n);
    double ave=0;
    for(int i=0;i<n;i++){
      cin>>a[i];
      ave+=a[i];
    }
    ave/=n;
    double ve=0;
    for(int i=0;i<n;i++)ve+=(a[i]-ave)*(a[i]-ave);
    ve/=n;
    ve=sqrt(ve);
    cout<<fixed<<setprecision(20)<<ve<<endl;
  }
}



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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    if (b / a > c) {
        cout << c << endl;
    } else {
        cout << b / a << endl;
    }
    return 0;
}

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

int main () {
    string str;
    string str1, str2;
    int x, y;
    cin >> str;
    str1 = str.substr(0, 2);
    str2 = str.substr(2, 2);
    x = stoi(str1);
    y = stoi(str2);
    if (((1 <= x) && (x <= 12)) && ((1 <= y) && (y <= 12))) {
        cout << "AMBIGUOUS" << endl;
    }
    else if ((1 <= x) && (x <= 12)) {
        cout << "MMYY" << endl;
    }
    else if ((1 <= y) && (y <= 12)) {
        cout << "YYMM" << endl;
    }
    else {
        cout << "NA" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
N = int(input())
H = [int(x) for x in input().split()]
ans = 0
now = 0
count = 0
for i in H:
    if now >= i:
        count += 1
        ans = max(ans,count)
    else:
        ans = max(ans,count)
        count = 0
    now = i

print(ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  string a, s, c;
  cin >> a >> s >> c;
  cout << a[0] << s[0] << c[0] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
typedef pair<P,PP> PPP;
ll a,b,c,d,e;
ll h,w,k,sx,sy,gx,gy,dx[]={1,-1,0,0},dy[]={0,0,1,-1},ans,nx,ny;
priority_queue<PPP,vector<PPP>,greater<PPP>> que;
string s[1000000];
int main(void){
    cin>>h>>w>>k>>sx>>sy>>gx>>gy;
    sx--,sy--,gx--,gy--;
    P dp[h][w][4];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            for(int k=0;k<4;k++){
                dp[i][j][k]={1e9,0};
            }
        }
    }
    for(int i=0;i<h;i++)cin>>s[i];
    for(int i=0;i<4;i++){
        que.push({{1,0},{{sx,sy},i}});
    }
    while(que.size()){
        PPP p=que.top();
        que.pop();
        a=p.F.F;
        b=p.F.S;
        c=p.S.F.F;
        d=p.S.F.S;
        e=p.S.S;
        P q={a,b};
        if(dp[c][d][e]<=q)continue;
        dp[c][d][e]=q;
      	//cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl;
        if(k>b){
            nx=c+dx[e],ny=d+dy[e];
            if(0<=nx&&nx<h&&0<=ny&&ny<w&&s[nx][ny]=='.'){
              P o={a,b+1};
                if(dp[nx][ny][e]>o)que.push({{a,b+1},{{nx,ny},e}});
            }
        }
      else{
        nx=c+dx[e],ny=d+dy[e];
            if(0<=nx&&nx<h&&0<=ny&&ny<w&&s[nx][ny]=='.'){
              P o={a+1,1};
                if(dp[nx][ny][e]>o)que.push({{a+1,1},{{nx,ny},e}});
            }
      }
        for(int i=0;i<4;i++){
          P o={a+1,0};
           if(dp[c][d][i]>o)que.push({{a+1,0},{{c,d},i}});
        }
    }
    ans=1e9;
    for(int i=0;i<4;i++){
        ans=min(ans,dp[gx][gy][i].F);
    }
    if(ans==1e9){
        cout<<-1<<endl;
    }
    else cout<<ans<<endl;
}


Measured memory_bytes: 119004
def KiriageTime(x):
  return (x+9)//10*10

def sabun(x):
  return KiriageTime(x)-x

A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())
KiriageTotal=KiriageTime(A)+KiriageTime(B)+KiriageTime(C)+KiriageTime(D)+KiriageTime(E)
print(KiriageTotal-max(sabun(A),sabun(B),sabun(C),sabun(D),sabun(E)))


Measured memory_bytes: 9020
n,m,x=map(int,input().split())
a=list(map(int,input().split()))
l_cou=0
r_cou=0
for i in range(0,x,1):
	if (i in a):
		l_cou+=1

for j in range(x+1,n+1,1):
	if (j in a):
		r_cou+=1

print(min(r_cou,l_cou))

Measured memory_bytes: 3064
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  int n;
  cin >> n;
  int a;
  set<int> chk;
  rep(i,n){
    cin >> a;
    chk.insert(a);
  }
  if(chk.size() != n) printf("NO\n");
  else printf("YES\n");
  return 0;
}


Measured memory_bytes: 9600
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	a := getNextString(scanner)

	n := len(a)
	next := make([][26]int, n+1)
	for i := 0; i < 26; i++ {
		next[n][i] = n
	}
	for i := n - 1; i >= 0; i-- {
		for j := 0; j < 26; j++ {
			if int(a[i]-'a') == j {
				next[i][j] = i
				continue
			}
			next[i][j] = next[i+1][j]
		}
	}

	dp := make([]int, n+1)
	for i := n - 1; i >= 0; i-- {
		mn := n
		for j := 0; j < 26; j++ {
			if mn > dp[next[i+1][j]] {
				mn = dp[next[i+1][j]]
			}
		}
		dp[i] = mn + 1
	}

	s := 0
	for i := dp[0]; i >= 0; i-- {
		mn := n
		mj := 0
		for j := 0; j < 26; j++ {
			if mn > dp[next[s][j]] {
				mn = dp[next[s][j]]
				mj = j
			}
		}
		fmt.Fprint(writer, fmt.Sprintf("%c", 'a'+mj))
		i = dp[next[s][mj]]
		s = next[s][mj] + 1
	}

	fmt.Fprintln(writer, "")
	writer.Flush()
}


Measured memory_bytes: 44672
#include <iostream>
#include<algorithm>
#include <string>
using namespace std;
typedef long long ll;

//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(int argc, char *argv[]) {

  int n, k;
  cin >> n;
  cin >> k;

  int p[n];
  for(int i = 0; i<n; i++){
    cin >> p[i];
  }
  sort(p, p + n);
  ll result = 0;
  REP(i,k){
    result += p[i];
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3636
module Main where

main :: IO ()
main = do
	let
		patternOfQQ = [(x,y)|x<-[1..9],y<-[1..9]]
		str = map getStrQQ patternOfQQ
	mapM_ putStrLn str

getStrQQ :: (Int,Int)->String
getStrQQ (x,y) = (show x) ++ "x" ++ (show y) ++ "=" ++ (show (x * y))

Measured memory_bytes: 3544
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N, M;
  cin >> N >> M;
  ll a, b;
  map<ll, ll> m;
  for (int i = 0; i < M; i++) {
    cin >> a >> b;
    m[a]++;
    m[b]++;
  }
  bool succ = true;
  for (auto p : m) {
    if (p.second % 2 == 1) succ = false;
  }
  if (succ) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 8996
N, M = map(int, input().split())
H = list(map(int, input().split())) 

ans = set()

for i in range(M) :
  A, B = map(int, input().split())
  if H[A - 1] == H[B - 1] :
    ans.add(B)
    ans.add(A)
  elif H[A - 1] > H[B - 1] :
    ans.add(B)
  else :
    ans.add(A)
    
print(N - len(ans))

Measured memory_bytes: 20112
#import math
#import bisect
#import numpy as np
#import itertools
#import copy
import sys

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    n = int(input())
    d = list(map(int,ipti().split()))
    d.sort()
    sita = d[len(d)//2 - 1]
    ue = d[len(d)//2]

    print(ue-sita)

if __name__ == '__main__':
    main()

Measured memory_bytes: 52636
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[]
smax=0
for i in range(k-1,n):
    if i==k-1:
        sumnow=sum(a[:i+1])
    else:
        sumnow+=a[i]-a[i-k]
    smax=max(smax,sumnow)
print((smax+k)/2)

Measured memory_bytes: 25060
import java.util.*;
import java.io.*;
import java.math.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		boolean[] che = new boolean[n + 1];
		Arrays.fill(che , true);
		long yono = 0;
		for(int i = 1 ; i <= n ; i++) if(i == Integer.parseInt(sc.next())) che[i - 1] = false;
		for(int i = 0 ; i < n ; i++){
			if(!che[i]){
				che[i + 1] = true;
				yono++;
			}
		}
		ou.println(yono);
		ou.flush();
	}
}

Measured memory_bytes: 58884
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner keyboard = new Scanner(System.in);

		String S = keyboard.next();
		String T = keyboard.next();
		
		String ans = "Yes"; 
		for(int x=0; x<S.length(); x++) {
			if(S.charAt(x) != T.charAt(x))
			ans = "No";
		}
		
		System.out.println(ans);
		keyboard.close();
	}
}


Measured memory_bytes: 35812
#include<bits/stdc++.h>
using namespace std;
#define l long
#define ll long long
#define nitro ios_base::sync_with_stdio(false);cin.tie(0);
#define vi vector<int>
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define PI 3.141592653589793238
int main()
{
    nitro
    double c,r;cin>>r;
    c=2*PI*r;
    printf("%.20lf",c);
    return 0;
}


Measured memory_bytes: 3788
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<map>
#include<string>
#include<sstream>
using namespace std;
int inf = 1000000000;
int n, C;
int calc(vector<int> x, int c, vector< vector<int> > d){
  int n = x.size();
  int sum = 0;
  for(int i=0; i<C; i++){
    sum += d[i][c] * x[i];
  }
  return sum;
}

int main(){

  cin >> n >> C;
  vector< vector<int> > d(C, vector<int> (C));
  for(int i=0; i<C; i++){
    for(int j=0; j<C; j++) cin >> d[i][j];
  }
  vector< vector<int> > c(n, vector<int>(n));
  vector< vector<int> > x(3, vector<int>(C+1, 0));
  for(int i=0; i<n; i++){
    for(int j=0; j<n; j++){
      cin >> c[i][j];
      c[i][j]--;
      x[ (i+j)%3 ][ c[i][j] ]++;
    }
  }

  int ans = inf;
  for(int i=0; i<C; i++){
    int tmp = calc(x[0], i, d);
    for(int j=0; j<C; j++){
      if( i == j ) continue;
      int tmp2 = calc(x[1], j, d);
      for(int k=0; k<C; k++){
        if( i==k || j==k ) continue;
        int tmp3 = calc(x[2], k, d);
        ans = min(ans, tmp+tmp2+tmp3);
      }
    }
  }
  cout << ans << endl;


  return 0;
}

//


Measured memory_bytes: 1280
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::VecDeque;

fn main() {
    input! {
        T: f64,
        X: f64,
    }

    let ans = T / X;
    println!("{}", ans);
}


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

string solve() {
    string s;
    cin >> s;
    if ( s == "ABC" ) return "ARC";
    else return "ABC";
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3556
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
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;}

int main(){
	ll n;
	cin >> n;
	vector<ll> L(n);
	REP(i,n) cin >> L[i];
	sort(L.begin(),L.end());
	
	int ans=0;
	for(int i=0; i<=n-3; ++i){
		for(int j=i+1; j<=n-2; ++j){
			int ue,shita;
			int ok = j;
			int ng = n;
			
			while(abs(ok-ng)>1){
				int mid = (ok+ng)/2;
				if(L[i]+L[j]>L[mid]) ok=mid;
				else ng = mid;
			}
			ue = ok;
			
			ok = n;
			ng = j;
			while(abs(ok-ng)>1){
				int mid = (ok+ng)/2;
				if(L[i]+L[mid]>L[j]) ok=mid;
				else ng = mid;
			}
			shita = ok;
			if(ue!=j && shita!=n){
				ans += ue-shita+1;
			}
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3628
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    println(problem096a(a, b))
}

fun problem096a(a: Int, b: Int): Int {
    return if (a > 12) return 12 else (a - 1) + if (a <= b) 1 else 0
}

Measured memory_bytes: 31392
#include<cstdio>
#include<stdlib.h>
int top, S[1000];

void push(int x)
{
    S[++top] = x;
}

int pop()
{
    top--;
    return S[top+1];
}

int main()
{
    int a,b;
    int top = 0;
    char s[100];
    while(scanf("%s",s) != EOF)
    {
        if(s[0] == '+')
        {
            a = pop();
            b = pop();
            push(a+b);
        }
        else if(s[0] == '-')
        {
            b = pop();
            a = pop();
            push(a-b);
        }
        else if(s[0] == '*')
        {
            a = pop();
            b = pop();
            push(a*b);
        }
        else{
            push(atoi(s));
        }
    }
    
    printf("%d\n",pop());
    
    return 0;
}


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

int main()
{
    ll x;
    cin >> x;
    ll c = 100;
    int res = 0;
    while(c < x)
    {
        c *= 1.01;
        res++;
    }
    cout << res;

    return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=n-1;i > m;i--)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
#define mod 1000000007;
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main() {
  lli A,B,C,D,E,F,N,M,K;
  cin >> A;
  vector<int>P;
  rep(i,0,INF){
    P.pb(A%2);
    if(P[i]<0)P[i]+=2;
    A-=P[i];
    A/=-2;
    if(A==0)break;
  }
  Rev(P);
  N=P.size();
  rep(i,0,N)NeOut(P[i]);
  cout << endl;
} 

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

int main(){
  int n, x;
  cin >> n;
  vector<int> a(n);
  rep(i,n-1){
    cin >> x;
    a[x-1]++;
  }
  rep(i,n)cout << a[i] << endl;
  return 0;
}


Measured memory_bytes: 4032
#include <bits/stdc++.h>
using namespace std;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int m,k;
  cin >> m >> k;
  if(k == 0){
    for(int i = 0; i < (1<<m); ++i)
      cout << i << ' ' << i << ' ';
  }
  else if(m >= 2){
    if(k < (1<<m)){
      for(int i = 0; i < (1<<m); ++i){
        if(i != k) cout << i << ' ';
      }
      cout << k << ' ';
      for(int i = (1<<m)-1; i >= 0; --i){
        if(i != k) cout << i << ' ';
      }
      cout << k << ' ';
    }
    else cout << -1;
  }
  else cout << -1;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);  
	cin.tie(NULL);
	string s;cin>>s;
	if(s[2]==s[3] && s[4]==s[5]){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
use input::{Input, ReadMode};
use std::collections::HashMap;

fn main() {
    let mut input = Input::new(ReadMode::Line);

    let x: i64 = input.parse();
    let mut ha: HashMap<i64, i64> = HashMap::new();
    let mut hb: HashMap<i64, i64> = HashMap::new();

    for i in -1000..1000 {
        let x = i * i * i * i * i;
        ha.insert(x, i);
        hb.insert(i, x);
    }
    for (b, v) in hb {
        let y = v + x;
        if ha.contains_key(&y) {
            println!("{} {}", ha[&y], b);
            return;
        }
    }
}

#[allow(dead_code)]
pub mod input {
    use std::io::{BufRead, Read};

    pub enum ReadMode {
        Full,
        Line,
    }

    pub struct Input<'a> {
        lock: std::io::StdinLock<'static>,
        iter: Option<std::str::SplitAsciiWhitespace<'a>>,
        mode: ReadMode,
    }

    impl<'a> Input<'a> {
        fn naive_read(&mut self) -> Option<std::str::SplitAsciiWhitespace<'a>> {
            let mut s = Box::leak(Box::new(String::new()));
            let res = match self.mode {
                ReadMode::Full => self.lock.read_to_string(&mut s),
                ReadMode::Line => self.lock.read_line(&mut s),
            };
            res.ok().expect("failed to read");
            Some(s.split_ascii_whitespace())
        }
        pub fn new(mode: ReadMode) -> Self {
            let lock = Box::leak(Box::new(std::io::stdin())).lock();
            let iter = None;
            Self { lock, iter, mode }
        }
        pub fn read_line(&mut self) -> String {
            let mut s = String::new();
            self.lock.read_line(&mut s).ok().expect("failed to read");
            s
        }
        pub fn parse<T: std::str::FromStr>(&mut self) -> T {
            match &mut self.iter {
                Some(iter) => {
                    let x = match iter.next() {
                        Some(x) => x,
                        None => {
                            self.iter = self.naive_read();
                            self.iter.as_mut().unwrap().next().expect("reached EOF")
                        }
                    };
                    x.parse().ok().expect("failed to parse")
                }
                None => {
                    self.iter = self.naive_read();
                    self.parse()
                }
            }
        }
    }
}


Measured memory_bytes: 2336
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

constexpr size_t    operator""_sz(unsigned long long value) { return value; };
constexpr intmax_t  operator""_im(unsigned long long value) { return value; };
constexpr uintmax_t operator""_um(unsigned long long value) { return value; };
// }}} End

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

    intmax_t N;
    cin >> N;

    intmax_t res = 0;
    for (intmax_t i = 1; i * i <= N; ++i) {
        if (N / i == N % i) {
            res += i;
        } else if (N / (i + 1) == N % (i + 1)) {
            res += i + 1;
        } else if (N / i - 1 != 0 && N / (N / i - 1) == (N % (N / i - 1))) {
            res += (N / i - 1);
        }
    }

    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,BTreeMap,VecDeque};

// Functions
fn f(b:i64, n:i64) -> i64{
    if n/b == 0{
        return n;
    }else{
        return n%b + f(b,n/b);
    }
}

// Main
fn main(){
    input!{
        N: i64,
        S: i64,
    }
    let mut ans = -1;
    if N==S{
        ans = N+1;
    }else{
        let limN = (N as f64).powf(0.5).ceil() as usize;
        for b in 2..limN{
            if f(b as i64,N)==S{
                ans = b as i64;
                break;
            }
        }
        if ans == -1{
            for i in 0..limN{
                let b = (N-S)/(limN-i) as i64+1;
                if b>1{
                    if f(b,N)==S{
                        ans = b;
                        break;
                    }
                }
            }
        }
    }
    println!("{}",ans);
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

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

    int n;
    cin >> n;
    string s;
    set<string> st[n];
    for (int i = 0; i < n; i++)
    {
        cin >> s;
        int len = s.length();
        for (int j = 0; j < len - 1; j++)
        {
            string s1 = "", s2 = "", revs1 = "", revs2 = "";
            for (int k = 0; k <= j; k++)
            {
                s1 += s[k];
                revs1 += s[j - k];
            }
            for (int k = j + 1; k <= len - 1; k++)
            {
                s2 += s[k];
                revs2 += s[len + j - k];
            }
            st[i].insert(s1 + s2);
            st[i].insert(s1 + revs2);
            st[i].insert(s2 + s1);
            st[i].insert(s2 + revs1);
            st[i].insert(revs1 + s2);
            st[i].insert(revs1 + revs2);
            st[i].insert(revs2 + s1);
            st[i].insert(revs2 + revs1);
        }
        cout << st[i].size() << endl;
    }
}


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

int main() {
  int n,alice=0,bob=0;
  cin>>n;
  vector<int> a(n);
  for (int i=0;i<n;i++) cin>>a.at(i);
  sort(a.begin(),a.end(),greater<int>());
  for (int i=0;i<n;i++) {
    if (i%2==0) alice+=a.at(i);
    else bob+=a.at(i);
  }
  cout<<alice-bob<<endl;
}

Measured memory_bytes: 256
n = gets.to_i
house = Array.new(4, 0).map{ Array.new(3, 0).map { Array.new(10, 0) } }

for i in 1..n
  b, f, r, v = gets.split(" ").map{ |x| x.to_i }
  house[b - 1][f - 1][r - 1] += v
end

for i in 0..3
  for j in 0..2
    puts " " + house[i][j].to_s.gsub(/[\[\]\,]/, "")
  end
  puts "####################" if i != 3
end

Measured memory_bytes: 6116