akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
ll a[1000005],b[100005],c[100005];
ll a2[1000005],b2[100005],c2[100005];
ll sum[100005];
using namespace std;
int main(){
    int n,m;
    ll e;
    cin>>n>>m;
    ll ma=-1e18;
    for(int i=0;i<n;i++){
    	cin>>a[i]>>b[i]>>c[i];
    }
    for(int i=0;i<2;i++){
    	for(int j=0;j<2;j++){
    		for(int k=0;k<2;k++){
    		for(int l=0;l<n;l++){
    			sum[l]=0;
    			if(i)
    			sum[l]+=a[l];
    			else sum[l]-=a[l];
    			if(j)
    			sum[l]+=b[l];
    			else sum[l]-=b[l];
    			if(k)
    			sum[l]+=c[l];
    			else sum[l]-=c[l];
    			}
    			sort(sum,sum+n);
    			e=0;
    			for(int x=n-1;x>n-1-m;x--)
    			e+=sum[x];
    			if(e>ma)
    			ma=e;
    		}
    	}
    }
    cout<<ma;
   }


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

int arr[200005];
int main() {
  map<int, int> M;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    M[arr[i]]++;
  }

  for (int i = 0; i < n; i++) {
    M[arr[i]]--;
    map<int, int>::iterator it = --M.end();
    while (it->second == 0) {
      it--;
    }
    cout << it->first << endl;
    M[arr[i]]++;
  }

  return 0;
}

Measured memory_bytes: 7936
#include <set>
#include <map>
#include <list>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)

int main(){
  int n, c=0, cmax=0, s1_l;
  string s, s1, s2;
  cin >> n >> s;
  set<char> st;
  REP(i, 1, n) {
    s1 = s.substr(0,i);
    s2 = s.substr(i,n);
    REP(j, 97, 123) {
      if(s1.find(char(j)) != std::string::npos && s2.find(char(j)) != std::string::npos){
        c += 1;
      }
      if(cmax < c) cmax = c;
    }
    c = 0;
  }
  cout << cmax << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
string binal(int k){
    string res;
    REP(i,23){
        res+=char('0'+k%2);
        k/=2;
    }
    return res;
}
int main(){
    int N;cin>>N;
    typedef pair<int,int> P;
    vector<int> D(N);
    vector<int> A(13,0);
    REP(i, N){
        cin >> D[i];
        if(D[i]==0){
            cout<<0<<endl;
            return 0;
        }
        A[D[i]]++;
        if(A[D[i]]>=3){
            cout<<0<<endl;
            return 0;
        }
    }
    int ans=23;
    vector<bool> B(25,false);
    B[24]=B[0]=true;
    bool left=true;
    REP(i,13){
        if(A[i]==2){
            B[i]=true;
            B[24-i]=true;
        }
        else if(A[i]==1){
            if(left) B[i]=true;
            else B[24-i]=true;
            left=!left;
        }
    }
    int tmp=24;
    REP(i,25){
        if(!B[i]) tmp++;
        else{
            ans=min(ans,tmp+1);
            tmp=0;
        }
    }
    cout<<ans<<endl;
}

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

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define INF 9223372036854775807
#define MOD 1000000007
#define pb push_back
#define F first
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0;
string s;
bool flag;
#pragma endregion
#define MAX 111111


ll a[5];
int main(void) {
  cin >> s;
  FOR(i, 0, s.length()) {
	if (s[i] == 'N') a[0]++;
	if (s[i] == 'W') a[1]++;
	if (s[i] == 'S') a[2]++;
	if (s[i] == 'E') a[3]++;
  }
  if ((a[0] == 0 && a[2] != 0) || (a[0] != 0 && a[2] == 0)) {
	cout << "No" << endl;
	return 0;
  }
  if ((a[1] == 0 && a[3] != 0) || (a[1] != 0 && a[3] == 0)) {
	cout << "No" << endl;
	return 0;
  }
  cout << "Yes" << endl;

  return 0;
}

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

int main(void){
	char str[81];
	char str2[81];
	int key;
	int len;
	int i, j;

	while(1){
		if(scanf("%[^\n]%*c", str) == EOF) break;
		len = strlen(str);
		for(i=0; i < len; i++){
			strcpy(str2, str);
			if(str2[i] >= 't'){
				key = 't' - str2[i];
			}else{
				key ='t'  - ('z' + 1 + (str2[i] - 'a'));
			}
			for(j=0; j < len; j++){
				if(str2[j] == ' ' || str2[j] == '.') continue;
				str2[j]  += key;
				if(str2[j] < 'a'){
					str2[j] = 'z' + 1 - ('a' - str2[j]);
				}
			}
			if(!(strstr(str2, "that") == NULL && strstr(str2, "this") == NULL && strstr(str2, "the") == NULL)) goto OK;
		}
		OK :;

		printf("%s\n", str2);
	}

	return 0;
}

Measured memory_bytes: 0
/*
    Life Before Death, Strength Before Weakness, Journey Before Destination
    ------------------------------------------------------------------------
    You don't become great by trying to be great.
    You become great by wanting to do something,
    and then doing it so hard that you become great in the process.
    */

    //#pragma comment(linker, ack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    #define rep(i, n)    for(ll i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(ll i = a; i >= (n); --i)
    #define trav(a, x) for(auto& a : x)
    #define all(x) x.begin(), x.end()
    #define sz(x) (int)(x).size()
    #define fill(a)  memset(a, 0, sizeof (a))
    #define fst first
    #define snd second
    //#define mp make_pair
    #define pb push_back
    #define PI           3.141592653589793238462643383279502884197169399  /* pi */
    // #define te
    typedef long double ld;
    typedef long long ll;
    typedef pair<ll, ll> pii;
    typedef vector<ll> vi;
    const int maxN = 200100;
    typedef pair<pii, ll> piii;

    void solve() {
        ll a, b;
        cin >> a >> b;
        map<ll, ll> mp;
        mp[a]++, mp[b]++;
        for(int i=1; i<=3; i++){
            if(!mp[i]) { cout << i << endl; break;}
        }
    }

    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
      // ll ti;   cin >> ti;  while(ti--)
      solve();
      return 0;
    }


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

const int N=610,mod=1000000007;
inline void upd(int&x,const int&y){x+=y-mod;x+=x>>31&mod;}
int T,dp[2][N][N],cnt,tag[N],v[N],ans,res,n;
int main(){
	cin>>n;
	for(int i=1;i<=n;++i){
		int x,y;cin>>x>>y;
		if(x==-1&&y==-1)++res;
		else if(x!=-1&&y!=-1)tag[x]=tag[y]=1;
		else v[++cnt]=x+y+1,tag[x+y+1]=1;
	}
	for(int i=1;i<=2*n;++i)if(!tag[i])v[++cnt]=i;
	sort(v+1,v+cnt+1);reverse(v+1,v+cnt+1);
	dp[0][0][0]=1;
	for(int i=1;i<=cnt;++i){
		T^=1;memset(dp[T],0,sizeof dp[T]);
		for(int j=0;j<i;++j)
			for(int k=0;j+k<i;++k)if(dp[!T][j][k]){
				int val=dp[!T][j][k];
				if(tag[v[i]]){
					upd(dp[T][j+1][k],val);
					if(k)upd(dp[T][j][k-1],val);
				}else{
					upd(dp[T][j][k+1],val);
					if(j)upd(dp[T][j-1][k],1ll*val*j%mod);
					if(k)upd(dp[T][j][k-1],val);
				}
			}
	}
	ans=dp[T][0][0];
	for(int i=1;i<=res;++i)ans=1ll*ans*i%mod;
	cout<<ans<<'\n';
	return 0;
}


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

const int N = 100000 + 10;

int n, m;
int deg[N];

int main() {
	scanf( "%d%d", &n, &m );
	for( int i = 1; i <= m; i++ ) {
		int u, v;
		scanf( "%d%d", &u, &v );
		deg[u]++;
		deg[v]++;
	}
	for( int u = 1; u <= n; u++ ) {
		if( deg[u] & 1 ) {
			printf( "NO\n" );
			return 0;
		}
	}
	printf( "YES\n" );
}



Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    vector<int> cnt(m + 1, 0);
    for(int i = 0; i < n; i++)
    {
        int k; cin >> k;
        for(int j = 0; j < k; j++)
        {
            int x; cin >> x;
            cnt[x]++;
        }
    }
    int ans = 0;
    for(int i = 0; i <= m; i++)
    {
        if(cnt[i] == n) ans++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<int> v(n);
    vector<int>::iterator it;
    for(int i=0;i<n;i++){ cin>>v[i];}
    int q;cin>>q;
    while(q--){
        int a;cin>>a;
        it=lower_bound(v.begin(),v.end(),a);
        cout<<it-v.begin();
        cout<<" ";
        it=upper_bound(v.begin(),v.end(),a);
        cout<<it-v.begin();
        cout<<"\n";
    }

}




Measured memory_bytes: 3080
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define rep1(i,s,e) for(int i=s;i<e;i++)
#define rep2(i,s,e,c) for(int i=s;i>=e;i--)
#define pfi(x) printf("%d\n",x)
#define pfl(x) printf("%lld\n",x)
#define pfn() printf("\n")
#define pfs() printf(" ")
#define sfi(x) scanf("%d",&x)
#define sfi1(x,y) scanf("%d%d",&x,&y)
#define sff(x) scanf("%lf",&x)
#define sfl(x) scanf("%lld",&x)
#define memset1(x) memset(x,0,sizeof(x))
using namespace std;
typedef long long ll;
const int MAX = 2e5 + 50;
const int mod = 996873654;
ll ans[MAX];
vector<ll> Next[MAX];
ll gc[MAX];
struct node{
	int index;
	int v;
	void init(int _index,int _v){
		index=_index;
		v=_v;
	}
}p,p1;
int main(){
	int n,q;
	sfi1(n,q);
	memset1(ans);
	memset1(Next);
	for(int i=0;i<n-1;i++){
		ll a,b;
		scanf("%lld%lld",&a,&b);
		Next[a].push_back(b);
	}
	memset1(gc);
	rep(i,1,q){
		ll x,v;
		scanf("%lld%lld",&x,&v);
		gc[x]+=v;
	}
	queue<node> que;
	p.init(1,gc[1]);
	que.push(p);
	while(!que.empty()){
		p=que.front();
		que.pop();
		ans[p.index]=p.v;
		for(int i=0;i<Next[p.index].size();i++){
			int next_index=Next[p.index][i];
			p1.init(next_index,p.v+gc[next_index]);
			que.push(p1);
		}
	}
	for(int i=1;i<=n;i++){
		printf("%lld",ans[i]);
		if(i<n) printf(" ");
		else pfn();
	}
	return 0;
}

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

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int main(){
    int N;
    cin >> N;
    vector<int> V1(100010), V2(100010);
    rep(i, N/2){
        int tmp1, tmp2;
        cin >> tmp1 >> tmp2;
        V1.at(tmp1)++;
        V2.at(tmp2)++;
    }

    vector<int> V1_sort = V1, V2_sort = V2;
    int V1_max = 0, V2_max = 0, V1_max2, V2_max2, V1_a, V2_a;

    sort(V1_sort.rbegin(), V1_sort.rend());
    sort(V2_sort.rbegin(), V2_sort.rend());

    V1_max = V1_sort.at(0);
    V1_max2 = V1_sort.at(1);
    V2_max = V2_sort.at(0);
    V2_max2 = V2_sort.at(1);

    int ans = 0;
    for(int i = 1; i < N/2; i++){
        ans += V1_sort.at(i) + V2_sort.at(i);
    }

    rep(i, 100010){
        if(V1.at(i) == V1_max){
            V1_a = i;
        }
        
        if(V2.at(i) == V2_max){
            V2_a = i;
        }
    }

    if(V1_a == V2_a){
        int change1 = V1_max - V1_max2, change2 = V2_max - V2_max2;
        if(change1 > change2) ans += change2;
        else ans += change1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <array>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>

using namespace std;

int main() {
  int l, r, d;
  cin >> l >> r >> d;

  int cnt = 0;

  for (int i = l; i <= r; i++) {
    if (i % d == 0) {
      cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}


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

using namespace std;

int main()
{
	double ans = 0;
	int n, m, d;
	cin >> n >> m >> d;
	printf("%.8f", 1.0 * (2 * n - 2 * d) / (1ll * n * n) * (m - 1) * (0.5 * (d == 0 ? 1 : 2)));
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
    cin >> first;
    IN(rest...);
    return;
}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

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

int main() {
   SS(ll,a,b,c)
   ll ans=max(c-(a-b),0LL);
   p(ans);
}

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

int main() {
   int N,K;
   cin >> N >> K;
  for(int i = 0; i > -1; i++){
    if(N<K){
      cout << i+1 << endl;
      return 0;
    }
    else{
      N = N/K;
    }
  }
}

Measured memory_bytes: 3536
u, s, e, w, n, b = map(int, input().split())
roll = input()
for i in roll:
    if i == "E":
        e,u,w,b = u,w,b,e
    elif i == "S":
        s,u,n,b = u,n,b,s
    elif i == "W":
        w,u,e,b = u,e,b,w
    elif i == "N":
        n,u,s,b = u,s,b,n
print(u)

Measured memory_bytes: 7636
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using namespace std;


void solve(std::string S){
  for (int i = 0; i < 3; ++i) {
    std::cout << S[i];
  }
  std::cout << std::endl;
}

int main(){
  std::string S;
  std::cin >> S;
  solve(S);
  return 0;
}


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

int ctoi(char c){
    switch (c){
        case '0': return 0;
        case '1': return 1;
        case '2': return 2;
        case '3': return 3;
        case '4': return 4;
        case '5': return 5;
        case '6': return 6;
        case '7': return 7;
        case '8': return 8;
        case '9': return 9;
        default: return 0;
    }
}

int main(){
    int N,A,B;
    cin >> N >> A >> B;
    int counter = 0;
    rep(i,N + 1){
        int len = to_string(i).size();
        int somesum = 0;
        rep(j,len){
            somesum += ctoi(to_string(i)[j]);
        }
        if(A <= somesum && somesum <= B){
            counter += i;
        }
    }
    cout << counter << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cctype>
#include<vector>
using namespace std;
inline void read(int &x)
{
    int s=0,w=1;
    char c=getchar();
    while(!isdigit(c)){if(c=='-')w=-1;c=getchar();}
    while(isdigit(c)){s=(s<<3)+(s<<1)+c-'0',c=getchar();}
    x=s*w;
}
const int N=200010;
typedef long long ll;
#define rg register int
#define pb push_back
struct data
{
    ll x,y;
    data(){};
    data(ll _x,ll _y):x(_x),y(_y){}
};
inline bool cmpx(const data &A,const data &B){return A.x<B.x;}
inline bool cmpy(const data &A,const data &B){return A.y<B.y;}
vector<data>f[N];
ll d[N],mn[N];
inline void solve(vector<data>a,vector<data>b,vector<data>&c,ll e,ll mid)
{
    if(a.size()>b.size())
        swap(a,b);
    sort(a.begin(),a.end(),cmpy),sort(b.begin(),b.end(),cmpx);
    int sb=b.size();
    for(rg i=0;i<sb;i++)
        if(!i)mn[i]=b[i].y;
        else mn[i]=min(mn[i-1],b[i].y);
    for(rg i=0,j=sb-1;i<a.size();i++)
    {
        while(j>=0&&a[i].y+b[j].x-2*e>mid)j--;
        if(~j)c.pb(data(a[i].x,mn[j]));
    }
    sort(a.begin(),a.end(),cmpx),sort(b.begin(),b.end(),cmpy);
    for(rg i=0;i<sb;i++)
        if(!i)mn[i]=b[i].x;
        else mn[i]=min(mn[i-1],b[i].x);
    for(rg i=0,j=sb-1;i<a.size();i++)
    {
        while(j>=0&&a[i].x+b[j].y-2*e>mid)j--;
        if(~j)
            c.pb(data(mn[j],a[i].y));
    }
}
int ls[N],rs[N];
inline void dfs(int u,ll mid)
{
    f[u].clear();
    if(!ls[u])
    {
        f[u].pb(data(d[u],d[u]));
        return ;
    }
    dfs(ls[u],mid),dfs(rs[u],mid);
    solve(f[ls[u]],f[rs[u]],f[u],d[u],mid);
    f[ls[u]].clear(),f[rs[u]].clear();
}
int n;
ll L,R,ans;
int main()
{
    read(n);
    for(rg i=2,x,y;i<=n;i++)
    {
        read(x),read(y);
        d[i]=d[x]+y,R=max(R,d[i]);
        if(ls[x])rs[x]=i;
        else ls[x]=i;
    }
    R<<=1;
    while(L<=R)
    {
        ll mid=(L+R)>>1;
        dfs(1,mid);
        if(f[1].size())ans=mid,R=mid-1;
        else L=mid+1;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 31084
//
// Created by ?????°?????? on 2016/04/15.
//

#include<iostream>
#include <algorithm>

using namespace std;
const int MAX = 2000000;

int H,A[MAX+1];

void maxHeapify(int i){
    int l,r,largest;
    l = 2 * i;
    r = 2 * i +1;

    if (l <= H && A[l] > A[i]){
        largest = l;
    } else {
        largest = i;
    }
    if (r <= H && A[r] > A[largest]){
        largest = r;
    }

    if(largest != i){
        swap(A[i],A[largest]);
        maxHeapify(largest);
    }
}

int main(){
    cin >> H;
    for (int i = 1; i <= H ; ++i) {
        cin >> A[i];
    }

    for (int i = H/2 ; i >= 1 ; i--) {
        maxHeapify(i);
    }
    for (int i = 1; i <= H ; ++i) {
        cout << " " << A[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3112
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoderExamCS
{
    class Program
    {
        static void Main(string[] args)
        {
            int K = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();

            if (S.Length <= K)
            {
                Console.WriteLine(S);
            }
            else
            {
                for (int i = 0; i < K; i++)
                {
                    Console.Write(S[i]);
                }
                Console.WriteLine("...");
            }
        }
    }
}


Measured memory_bytes: 27296
#include<stdio.h>
int main(void)
{ 
	int a,b,c;
	scanf("%d",&a);
	scanf("%d",&b);
	c=a*b;
	if(c%2==0){
	printf("Even\n");
	}
	if(!(c%2==0)){
	printf("Odd\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
using namespace std;
bool cup[3]={false};

int main(void){
	cup[0]=true;
	char a ,tmp ,b;
	while(true){
		cin >> a >> tmp >> b;
		if(cin.eof())
			break;
		swap(cup[a-'A'],cup[b-'A']);
	}
	char ans='A';
	for(int i=0;i<3;i++)
		if(cup[i])
			ans+=i;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1132
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys


def input():
    return sys.stdin.readline()


def resolve():
    n = int(input())

    str_n = str(n)

    for s in str_n:
        if s == "7":
            print("Yes")
            exit()

    print("No")


if __name__ == "__main__":
    resolve()



Measured memory_bytes: 61672
from collections import defaultdict


class UnionFind:
    def __init__(self, n):
        self.n = n
        # 各要素の親要素の番号を格納するリスト
        # 要素が根（ルート）の場合は-(そのグループの要素数)を格納する
        self.parents = [-1] * n

    def find(self, x):
        """要素xが属するグループの根を返す
        """
        if self.parents[x] < 0:
            return x
        self.parents[x] = self.find(self.parents[x])
        return self.parents[x]

    def union(self, x, y):
        """要素xが属するグループと要素yが属するグループをくっつける
        """
        x = self.find(x)
        y = self.find(y)
        # すでにくっつてるのでそのまま返す
        if x == y:
            return
        # 大きい方(x)に小さい方(y)をくっつけたいので、
        # 大小が逆なら入れ替える
        if self.size(x) < self.size(y):
            x, y = y, x
        # xのサイズを更新する
        self.parents[x] += self.parents[y]
        # yの親をxに変更する
        self.parents[y] = x

    def size(self, x):
        """要素xが属するグループのサイズ（要素数）を返す
        """
        return -self.parents[self.find(x)]


friends = defaultdict(list)
N, M, K = map(int, input().split())
uf = UnionFind(N)
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    uf.union(a, b)
    friends[a].append(b)
    friends[b].append(a)

groups = defaultdict(list)
for i in range(K):
    c, d = map(int, input().split())
    c -= 1
    d -= 1
    groups[c].append(d)
    groups[d].append(c)

ans = []
for i in range(N):
    tmp = uf.size(i) - len(friends[i]) - 1
    for g in groups[i]:
        if uf.find(i) == uf.find(g):
            tmp -= 1
    ans.append(str(tmp))

print(' '.join(ans))


Measured memory_bytes: 137600
//https://atcoder.jp/contests/agc012/tasks/agc012_a
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
    ll N; cin>>N;
    vector<ll> a3n(3*N);
    for(auto&& a:a3n){
        cin>>a;
    }
    sort(a3n.begin(),a3n.end(),greater<ll>());
    ll ans=0;
    for(ll i=0;i<N;++i){
        ll idx=2*i+1;
        ans+=a3n[idx];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;
inline double add(double a, double b){
	return abs(a + b) <= 1e-8 ? 0 : a + b;
}
double a[1001];
int main(){
	while (true){
		int n; cin >> n; if (!n) break;
		for (int i = 0; i < n; ++i) cin >> a[i];
		double s = 0;
		for (int i = 0; i < n; ++i) s += a[i];
		s /= n;
		double v = 0;
		for (int i = 0; i < n; ++i) v += add(a[i], - s)*add(a[i],-s);
		v /= n;
		cout << fixed << setprecision(8) << sqrt(v) << '\n';
	}
}

Measured memory_bytes: 1296
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;
	int r, c;
	boolean[][] map;
	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			r = sc.nextInt();
			c = sc.nextInt();
			if((r|c) == 0) break;
			map = new boolean[r][c];
			for(int i=0;i<r;i++) for(int j=0;j<c;j++) {
				map[i][j] = sc.nextInt() == 1;
			}
			int max = 0;
			for(int i=1; i<1<<r;i++) {
				boolean[][] tmp = new boolean[r][c];
				for(int j=0;j<r;j++) for(int k=0;k<c;k++)
					tmp[j][k] = map[j][k];
				for(int j=0;j<r;j++) if( ((i>>j) & 1) == 1 ) {
					for(int k=0;k<c;k++) tmp[j][k] ^= true;
				}
				int sum=0;
				for(int j=0;j<c;j++) {
					int cnt = 0;
					for(int k=0;k<r;k++) if(tmp[k][j])
						cnt++;
					sum += max(cnt, r-cnt);
				}
				max = max(max, sum);
			}
			System.out.println(max);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int intl;
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<intl>> val(8, vector<intl>(n));
    for (int i = 0; i < n; i++) {
        intl x, y, z;
        cin >> x >> y >> z;
        for (int j = 0; j < 8; j++) {
            intl tx = (j & (1 << 0)) ? x : -x;
            intl ty = (j & (1 << 1)) ? y : -y;
            intl tz = (j & (1 << 2)) ? z : -z;
            val[j][i] = tx + ty + tz;
        }
    }
    intl ans = INT_MIN;
    for (int i = 0; i < 8; i++) {
        sort(all(val[i]), greater<intl>());
        intl temp = 0;
        for (int j = 0; j < m; j++) {
            temp += val[i][j];
        }
        ans = max(ans, temp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int A[200001],n;
ll dif(ll x){
  ll ret=0;
  for(int i=0;i<n;++i){
    ret+=abs(A[i]-x);
  }
  return ret;
}
int main(){
  cin >> n;
  for(int i=0;i<n;++i){
    cin>>A[i];
    A[i]-=(i+1);
  }
  sort(A,A+n);
  ll x = A[n/2];
  cout << dif(x) << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 5e5+1;
 
 
int n,fa[N],tot[N],fr[N],blk[N],wht[N],c[N],cnt,head[N];
 
struct nd{int ne,to;}e[N];
 
void in(int x,int y){e[++cnt].to=y;e[cnt].ne=head[x];head[x]=cnt;}
int can[5001],tmp[N];
bool dfs(int x)
{
	for(int i=head[x];i;i=e[i].ne) if(!dfs(e[i].to)) return false;
	if(!head[x]){
		blk[x]=tot[x];
		return true;
	}
	tmp[0]=0;
	int ret=tot[x],tot1=0;
	for(int i=head[x];i;i=e[i].ne)
	{
			ret-=min(blk[e[i].to],wht[e[i].to]);
			if(ret<0) return false;
			tmp[++tmp[0]]=abs(blk[e[i].to]-wht[e[i].to]);
			tot1+=blk[e[i].to]+wht[e[i].to];
	}
	memset(can,0,sizeof(can));
	can[0]=1;
	for(int i=1;i<=tmp[0];++i)
	for(int t=5000;t>=tmp[i];--t)
		can[t]|=can[t-tmp[i]];
	for(int i=ret;i>=0;--i)
	if(can[i]){ret-=i;break;}
	blk[x]=tot[x];wht[x]=tot1+ret-blk[x];
	return true;
}
 
int main()
{
	scanf("%d",&n);
	for(int i=2;i<=n;++i)
	scanf("%d",&fa[i]),in(fa[i],i);
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&tot[i]);
	}
	if(dfs(1)) cout<<"POSSIBLE";
	else cout<<"IMPOSSIBLE";
 
}

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

/***********************************************/
/* Dear online judge:
 * I've read the problem, and tried to solve it.
 * Even if you don't accept my solution, you should respect my effort.
 * I hope my code compiles and gets accepted.
 *  ___  __     _______    _______      
 * |\  \|\  \  |\  ___ \  |\  ___ \     
 * \ \  \/  /|_\ \   __/| \ \   __/|    
 *  \ \   ___  \\ \  \_|/__\ \  \_|/__  
 *   \ \  \\ \  \\ \  \_|\ \\ \  \_|\ \ 
 *    \ \__\\ \__\\ \_______\\ \_______\
 *     \|__| \|__| \|_______| \|_______|
 */
const long long mod = 1000000007;

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

	string s;
	cin>>s;
	int res = 0;
	bool can = true;
	for(int i = 0,j = (int)s.size()-1;i < j;) {
		if(s[i] == s[j]) {
			i++,j--;
			continue;
		}
		if(s[i] == 'x') {
			i++;
			res++;
			continue;
		}
		if(s[j] == 'x') {
			j--;
			res++;
			continue;
		}
		can = false;
		break;
	}
	cout<<(can?res:-1)<<'\n';
	return 0;
}


Measured memory_bytes: 512
def gcd(a, b):
    if a < b:
        return gcd(b, a)
    d = a % b
    if d == 0:
        return b
    return gcd(b, d)

def divisors(d):
    ret = []
    for a in range(1, d + 1):
        if d % a == 0:
            ret.append(a)
    return ret

l = raw_input().split()
a = int(l[0])
b = int(l[1])
k = int(l[2])

d = gcd(a, b)
ret = divisors(d)

print(ret[-k])


Measured memory_bytes: 2568
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int N;
  cin >> N;
  vector<int> v(N);
  vector<int> c(N);
  int m = 0;
  REP(i, N) {
    cin >> v[i];
  }
  REP(i, N) {
    cin >> c[i];
  }
  int tmp = 0;
  REP(i, N) {
    if (v[i] - c[i] > 0) {
      tmp+= v[i] - c[i];
    };
  }

  cout << tmp << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 100010
using namespace std;
int n,m,Ans;

struct node {
	int l,r;
}a[N];

bool cmp(node a,node b) {
	return a.l<b.l;
}

int main() {
	scanf("%d%d",&n,&m);
	for (int i=1; i<=m; i++) 
		scanf("%d%d",&a[i].l,&a[i].r);
	sort(a+1,a+m+1,cmp);
	int Now=0;
	for (int i=1; i<=m; i++) {
		if (a[i].r<=Now) Now=a[i].r-1;
		if (a[i].r>Now) {
			if (a[i].l>Now) {
				Now=a[i].r-1;
				Ans++;
			}
		}
	}
	printf("%d",Ans);
}

Measured memory_bytes: 1024
package main

import (
	"fmt"
	"strconv"
)

func parseInt(s string) int {
	i, _ := strconv.Atoi(s)
	return i
}

func createNums(num int) []int {
	nums := make([]int, num)
	for i := range nums {
		fmt.Scan(&nums[i])
	}
	return nums
}

func main() {
	var numN int
	var numsA, numsB []int

	fmt.Scan(&numN)
	numsA = createNums(numN + 1)
	numsB = createNums(numN)

	count := 0
	for i, v := range numsB {
		if numsA[i] >= v {
			count += v
		} else {

			if numsA[i]+numsA[i+1] >= v {
				count += v
				numsA[i+1] = numsA[i] + numsA[i+1] - v
			} else {
				count += numsA[i] + numsA[i+1]
				numsA[i+1] = 0
			}
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 5504
from itertools import chain

def solve(H,W,A,B):

    return '\n'.join(chain(('1'*A+'0'*(W-A) for _ in range(B)), ('0'*A+'1'*(W-A) for _ in range(H-B))))




if __name__ == '__main__':
    H,W,A,B = map(int,input().split())
    print(solve(H,W,A,B))

Measured memory_bytes: 66984
package main

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

func main() {
	var n int
	fmt.Scan(&n)

	scanner := bufio.NewScanner(os.Stdin)
	hs := strToIntSlice(scanLine(scanner))

	maxHeight := max(hs, n)

	totalCount := 0
	for height := maxHeight; height > 0; height-- {
		flag := false
		for index := 0; index < n; index++ {
			if hs[index] >= height && flag == false {
				totalCount++
				flag = true
			} else if (hs[index] < height && flag == true) {
				flag = false
			}
		}
	}

	fmt.Println(totalCount)
}

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

func strToIntSlice(line string) []int {
	strSlice := strings.Split(line, " ")

	var intSlice []int
	for _, str := range strSlice {
		intValue, _ := strconv.Atoi(str)
		intSlice = append(intSlice, intValue)
	}

	return intSlice
}

func max(hs []int, n int) int {
	max := 0
	for index := 0; index < n; index++ {
		if max < hs[index] {
			max = hs[index]
		}
	}
	return max
}

Measured memory_bytes: 640
#ifndef LOCAL
#include <bits/stdc++.h>
#else
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <random>
#include <chrono>
#include <fstream>
#include <deque>
#include <numeric>
#include <functional>
#endif
using namespace std;

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];

    int ans = numeric_limits<int>::max();
    for (int low : a) {
        vector<int> have;
        vector<int> moves;

        for (int i = 0; i < n; ++i) {
            if (a[i] < low)
                have.clear();
            else {
                have.push_back(a[i]);

                if (i + 1 == n || a[i + 1] < low) {
                    sort(have.begin(), have.end());
                    for (int j = 0; j + k <= int(have.size()); ++j)
                        moves.push_back(have[j]);
                }
            }
        }

        if (int(moves.size()) < q)
            continue;

        sort(moves.begin(), moves.end());
        ans = min(ans, moves[q - 1] - low);
    }

    cout << ans;
    return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using namespace std;

unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
    long long k,ans=0;
    cin >> k;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            for(int l=1;l<=k;l++){
                ans += euclidean_gcd(euclidean_gcd(i, j),l);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3636
// to be build tomorrow
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<pair<int, int>, null_type,less<pair<int, int>>, rb_tree_tag,tree_order_statistics_node_update> 
#include <bits/stdc++.h> 
using namespace std; 
ordered_set s[200005];
struct pt {
    long long x, y;
    pt() {}
    pt(long long _x, long long _y) : x(_x), y(_y) {}
    pt operator-(const pt& p) const { return pt(x - p.x, y - p.y); }
    long long cross(const pt& p) const { return x * p.y - y * p.x; }
    long long cross(const pt& a, const pt& b) const { return (a - *this).cross(b - *this); }
};

int sgn(const long long& x) { return x >= 0 ? x ? 1 : 0 : -1; }

bool inter1(long long a, long long b, long long c, long long d) {
    if (a > b)
        swap(a, b);
    if (c > d)
        swap(c, d);
    return max(a, c) <= min(b, d);
}

bool check_inter(const pt& a, const pt& b, const pt& c, const pt& d) {
    if (c.cross(a, d) == 0 && c.cross(b, d) == 0)
        return inter1(a.x, b.x, c.x, d.x) && inter1(a.y, b.y, c.y, d.y);
    return sgn(a.cross(b, c)) != sgn(a.cross(b, d)) &&
           sgn(c.cross(d, a)) != sgn(c.cross(d, b));
}
using pp = pair <ll, ll>;
ll dp[30][30][2];
ll valid(ll f1, ll pos, string s, string cur, ll count)
{
    if (pos == s.length())
    {
        // cout << cur << "\n";
        if (stoull(cur))
        return 1;
        return 0;
    }
    if (dp[pos][count][f1] != -1)
    return dp[pos][count][f1];
    if (f1 == 1)
    {
        dp[pos][count][f1] = valid(f1, pos+1,s, cur+'0', count) + valid(f1, pos+1,s, cur + '1', count+1);   
    }
    else 
    {
        if (s[pos] == '0')
        {
            dp[pos][count][f1] = valid (f1, pos+1, s, cur+'0', count);
        }
        else if (s[pos] == '1')
        dp[pos][count][f1] = valid(0, pos+1, s, cur+'1', count+1) + valid(1, pos+1, s, cur + '0', count);
        else 
        dp[pos][count][f1] = valid(1, pos+1, s, cur+'1',count+1) + valid(1, pos+1, s, cur+'0', count);
    }
    return dp[pos][count][f1];
}
int main ()
{
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin >> t;
    while (t--)
    {
        ll n;
        cin >> n;
        ll a[n];
        map <ll, ll> m;
        ll sum = 0;
        for (auto &i : a)
        {
            cin >> i;
            m[i]++;
            sum += i;
        }
        ll q;
        cin >> q;
        while (q--)
        {
            ll x, y;
            cin >> x >> y;
            sum -= m[x]*(x);
            sum += m[x]*(y);
            m[y] += m[x];
            m[x] = 0;
            // sum +=
            cout << sum << "\n"; 
        }
    }
    return 0;
}

Measured memory_bytes: 29000
#ifndef TEMPLATE_HPP
#define TEMPLATE_HPP
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())
using namespace std;
using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void amax(T &x, T y) { x = max(x, y); }
template <typename T> void amin(T &x, T y) { x = min(x, y); }
template <typename T> T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename U> vector<U> make_vector(T&& n, U&& val) { return vector<U>(forward<T>(n), forward<U>(val)); }
template <typename T, typename... Args> decltype(auto) make_vector(T&& n, Args&&... args) { return vector<decltype(make_vector(forward<Args>(args)...))>(forward<T>(n), make_vector(forward<Args>(args)...)); }
const int INF = 1001001001;
const i64 LINF = 1001001001001001001ll;
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
#endif

void solve() {
  int n, k;
  cin >> n >> k;
  k += n;
  vi32 a(n);
  cin >> a;
  f80 ok = 1e18, ng = 0;
  rep(_, 100) {
    f80 x = (ok + ng) / 2;
    i64 cnt = 0;
    rep(i, n) {
      i64 c = ceil((f80) a[i] / x);
      cnt += c;
    }
    (cnt <= k ? ok : ng) = x;
  }
  i64 ans = ceil(ok - (f80) (1e-9));
  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(16);
  cerr << fixed << setprecision(16);
  solve();
  return 0;
}

Measured memory_bytes: 3972
#include<iostream>
using namespace std;
int main()
{
	string s;
	int i=0,j=0,k=0;
	cin>>s;
	for(;s[i]!='A';++i){
		
	}
	for(j=s.length();s[j]!='Z';j--)
	{
	}
	j++;
	cout<<j-i<<"\n";
}

Measured memory_bytes: 640
import java.util.*;


public class Main{

    private void solve(){

    }

    private void _main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        LinkedList<Integer> l = new LinkedList();
        for(int i=0;i<n;i++){
            if(i%2==0){
                l.addLast(sc.nextInt());
            }else{
                l.addFirst(sc.nextInt());
            }
        }
        Iterator<Integer> it;
        if(n%2==0){
            it = l.iterator();
        }else{
            it = l.descendingIterator();
        }

        while(it.hasNext()){
            System.out.print(it.next() + " ");
        }
        System.out.println();
    }

    public static void main(String[] args){
            (new Main())._main(args);
    }



    
}

Measured memory_bytes: 102164
require "prime"

def solve(x)
  ix = [0,3,6,10,15,21,28,36,45]
  ix.each_with_index do |v,i|
    return i if x < v
  end
end

n = gets.to_i
ans = Prime.prime_division(n).map{|v|solve(v[1])}.sum
puts ans


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

int main(void) {
    string s, t;
    cin >> s >> t;

    int cost = -1;
    for (int i = 0; i < s.length() - t.length() + 1; i++) {
        int cnt = 0;
        for (int j = 0; j < t.length(); j++) {
            if (s[i + j] != t[j])
                cnt++;
        }
        if (cost > cnt || cost == -1) {
            cost = cnt;
        }
    }

    cout << cost << '\n';

    return 0;
}

Measured memory_bytes: 3600
package main

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

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	defer write.Flush()

	var a, b int
	fmt.Fscan(read, &a, &b)

	if a > b {
		a, b = b, a
	}

	v := 0
	for i := 0; i < b; i++ {
		v *= 10
		v += a
	}
	fmt.Fprintln(write, v)
}


Measured memory_bytes: 640
#include <stdio.h>
#define N 2000001

int A[N],B[N],C[N];
int n;


void CountingSort(int k){
  
  int i,j;
  
  for(i=0;i<=k;i++){
    C[i]=0;
  }

  for(j=1;j<=n;j++){
    C[A[j]]++;
  }
  for(i=1;i<=k;i++){
    C[i]=C[i]+C[i-1];
  }
  for(j=n;j>=1;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
}





int main(){
  int i,m=0;
 


  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
    if(m<A[i]){
      m=A[i];
    }
  }  
  CountingSort(m);

  for(i=1;i<=n;i++){
    printf("%d",B[i]);
    if(i<n) printf(" ");
  }

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

Measured memory_bytes: 17896
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll paty(ll i){
    return (ll)pow(2,i+1)-1;
}

ll all(ll i){
    return (ll)pow(2,i+2)-3;
}
ll midle(ll i){
    return (ll)pow(2,i+1)-1;
}

int main() {
    ll n,x;
    std::cin >> n>>x;
    
    ll result = 0;
    for (int i = n; i >= 0; i--) {
        if( x == all(i) ){
            result += paty(i);
            break;
        }
        
        if( x == 1 ){
            break;
        }
        
        if( x > midle(i) ){
            result += paty(i-1)+1;
            x -= midle(i);
        }else if(x < midle(i)){
            x--;
            continue;
        }else{
            result += paty(i-1)+1;
            break;
        }
    }
    std::cout << result << std::endl;
}

Measured memory_bytes: 256
#include <vector>
#include <cstdio>
#define INF (10e9+1)
#define int long long
using namespace std;
int comp;
void merge(int* A, int left, int mid, int right){
  int n1 = mid - left;
  int n2 = right - mid;
  vector<int> L(n1+1), R(n2+1);
  for( int i = 0; i < n1 ; ++i)
    L[i] = A[left + i] ;
  for( int i = 0; i < n2 ; ++i)
    R[i] = A[mid + i];
  L[n1] = INF;
  R[n2] = INF;
  int i = 0, j = 0;
  for (int k = left ; k < right ; ++k){
    if (L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
    }
    else {
      A[k] = R[j];
      j = j + 1;
    }
    comp++;
  }
}

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

int s[500000];
signed main(){
  int n;
  scanf("%lld", &n);
  for (int i=0;i<n;i++){
    scanf("%lld", s+i);
  }
  comp = 0;
  mergeSort(s, 0, n);
  for (int i=0;i<n;i++){
    if (i!=0) printf(" ");
    printf("%lld", s[i]);
  }
  printf("\n%d\n", comp);
  return 0;
}



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

int main()
{
	int a,b,c;
	cin >> a >> b >> c;
	cout << a * b / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.array;
import std.algorithm, std.regex, std.range;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

void main(){
  auto n = read.to!long, q = read.to!long;
  auto xs = readln.chomp.split("AC").map!"a.length".array;
  auto ps = xs.length.iota.map!(i => new long[](xs[i] + 2).map!(_ => i).array).join();
  foreach(_; q.iota){
    auto l = read.to!long, r = read.to!long;
    (ps[r] - ps[l]).writeln;
  }
}

Measured memory_bytes: 5244
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int mod = 1e9 + 7;
constexpr ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}
const int IMAX = 100000;
class unko {
public:
	int fac[IMAX + 1], ifac[IMAX + 1], inv[IMAX + 1];
	constexpr unko() : fac(), ifac(), inv() {
		fac[0] = 1;
		rep1(i, IMAX) fac[i] = ll(fac[i - 1]) * i % mod;
		ifac[IMAX] = modpow(fac[IMAX], mod - 2);
		for (int i = IMAX; i > 0; i--) ifac[i - 1] = ll(ifac[i]) * i % mod;
		inv[0] = 1;
		rep1(i, IMAX) inv[i] = ll(ifac[i]) * fac[i - 1] % mod;
	}
} f;

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


	int N = getint();
	int kei = 0;
	ll kotae = 0;
	int mae = getint();
	rep1(i, N - 1) {
		int tugi = getint();
		ll X = tugi - mae;
		kei = (kei + f.inv[i]) % mod;
		kotae += kei * X % mod;
		mae = tugi;
	}

	printf("%lld\n", kotae % mod * f.fac[N - 1] % mod);


	Would you please return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef pair<int,int> pii;
const int MAXN=1000010;
const int INF=~0U>>2;
int n,m;
struct node{
	int x,y,z;
} edg[MAXN];
map<int,int> mp;
int tong[MAXN];
int64 tong2[MAXN];
map<int64,int> mp2;
vector<pii> g[MAXN];
int dis[MAXN], vis[MAXN];
queue<int>Q;
void spfa()
{
	for(int i = 1; i <= n + m + m; i++) dis[i] = INF, vis[i] = 0;
	dis[1] = 0;
	Q.push(1);
	while(Q.size())
	{
		int u=Q.front();
		Q.pop();
		for(int i = 0; i < g[u].size(); i++)
			if(dis[g[u][i].first] - dis[u] > g[u][i].second)
			{
				dis[g[u][i].first] = dis[u] + g[u][i].second;
				if(!vis[g[u][i].first])
				{
					vis[g[u][i].first] = 1;
					Q.push(g[u][i].first);
				}
			}
		vis[u] = 0;
	}
}
int main()
{
	scanf("%d%d",&n, &m);
	for(int i = 1; i <= m; i++)
		scanf("%d%d%d", &edg[i].x, &edg[i].y, &edg[i].z), tong[i] = edg[i].z;
	sort(tong + 1, tong + n + 1);
	for(int i = 1; i <= m; i++)
		if(tong[i] != tong[i - 1])
			mp[tong[i]] = i;

	for(int i = 1; i <= m; i++)
	{
		int64 u = edg[i].x, v = edg[i].y, e = mp[edg[i].z];
		tong2[i] = u + e * n;
		tong2[m + i] = v + e * n;
	}
	for(int i = 1; i <= n; i++)
		tong2[m + m + i] = i;
	sort(tong2 + 1, tong2 + m + m + n + 1);
	for(int i = 1; i <= n + m + m; i++)
		if(tong2[i] != tong2[i - 1])
			mp2[tong2[i]] = i;
	for(int i = 1; i <= m; i++)
	{
		int64 u = edg[i].x, v = edg[i].y, e = mp[edg[i].z];
		g[mp2[u]].push_back(pii(mp2[u + e * n], 1));
		g[mp2[v]].push_back(pii(mp2[v + e * n], 1));
		g[mp2[u + e * n]].push_back(pii(mp2[u], 0));
		g[mp2[v + e * n]].push_back(pii(mp2[v], 0));
		g[mp2[u + e * n]].push_back(pii(mp2[v + e * n], 0));
		g[mp2[v + e * n]].push_back(pii(mp2[u + e * n], 0));
	}
	spfa();
	if(dis[n] < INF) printf("%d\n", dis[n]);
	else puts("-1");
	return 0;
}


Measured memory_bytes: 92928