akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb(x) push_back(x);
#define mp(x,y) make_pair(x,y)
#define mem(dp,a) memset(dp,a,sizeof dp);
#define all(a) a.begin(),a.end()
#define sall(a) sort(all(a))
#define X first
#define Y second
typedef long long int ll;
typedef pair<ll,ll> pp;

#define debug(x) cout << #x << " :: "<< x <<"\n";
#define debug2(x,y) cout << #x << " :: "<< x << "\t" << #y << " :: " << y << "\n";
#define debug3(x,y,z) cout << #x << " :: "<< x << "\t" << #y << " :: " << y << "\t" << #z << " :: " << z << "\n";
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree< pp , null_type,less< pp >, rb_tree_tag,tree_order_statistics_node_update>

ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	ll c=power(a,b/2);
	if(b%2==0)
		return c*c;
	else
		return c*c*a;
}

int main()
{
    boost
    ll a;
    cin >> a;
    cout << a+a*a+a*a*a;
    return 0;
}



Measured memory_bytes: 3580
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<climits>
using namespace std;

int main() {
  int N;
  int cnt=0;
  int tmp=0;
  int f1=0;
  int f2=0;

  cin >> N;

  tmp = N%10;
  f1 = f1 + tmp;
  tmp = N/10;
  tmp = tmp%10;
  f1 = f1 + tmp*10;

  tmp = N/100;
  f2 = f2 + tmp%10;
  tmp = N/1000;
  f2 = f2 + (tmp%10) * 10;


  if(f2  > 0 && f2 < 13){
    if(f1  > 0 && f1 < 13){
      cout << "AMBIGUOUS" << endl;
    }else{
      cout << "MMYY" << endl;
    }
  }else{
    if(f1  > 0 && f1 < 13){
      cout << "YYMM" << endl;
    }else{
      cout << "NA" << endl;
    }
  }

}


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

using namespace std;

vector<pair<long long, int> > prime_factorize(long long n) {
    vector<pair<long long, int> > res;
    for (long long i = 2; i * i <= n; ++i) {
        if (n % i) continue;
        int e = 0;
        while (n % i == 0) {
            ++e;
            n /= i;
        }
        res.emplace_back(i, e);
    }
    if (n != 1) res.emplace_back(n, 1);
    return res;
}

int main() {
	long long n; cin >> n;
    auto pf = prime_factorize(n);
    int ans = 0;
    for (auto a : pf) {
        int t = 1, cnt = a.second;
        while (cnt >= t) {
            cnt -= t;
            ++t;
            ++ans;
        }
    }
    cout << ans << endl;

	return 0;
}

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

#define ll long long
#define F first
#define S second
#define ii pair < int , int >
#define ever (;;)

ll x,k,d;

int main()
{
    scanf("%lld%lld%lld",&x,&k,&d);
    x = abs(x);

    ll moves = x/d;

    if( moves > k )
    {
        printf("%lld\n",x-d*k);
        return 0;
    }

    k -= moves;
    x = x%d;

    if( !(k&1) )
    {
        printf("%lld\n",abs(x));
        return 0;
    }

    x -= d;

    printf("%lld\n",abs(x));
}


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

int main() {
  int N;
  cin >> N;
  vector<int> a(3 * N);
  for (int i = 0; i < 3 * N; i++) cin >> a.at(i);

  sort(a.begin(), a.end(), greater<int>());
  
  long long sum = 0;
  for (int i = 1; i < 2 * N; i += 2) {
    sum += a.at(i);
  }
  
  cout << sum << endl;
}


Measured memory_bytes: 4520
#include <iostream>
#include <stdio.h>

#define MAX_N 100'001
#define MAX_M 100'000

using namespace std;

int B[MAX_N]{};
int C[MAX_N]{};

int main() {
  int N, M;
  cin >> N >> M;
  for (int i = 1; i <= N; ++i) {
    C[i] = 1;
  }
  bool flg = false;
  B[1] = true;
  for (int i = 0; i < M; ++i) {
    int x, y;
    cin >> x >> y;
    if (B[x]) {
      B[y] = true;
    }
    if (x == 1 && !flg && C[1] == 1) {
      B[1] = false;
      flg = true;
    }
    if (y == 1 && !flg) {
      flg = true;
    }
    --C[x];
    ++C[y];
    if (C[x] == 0) {
      B[x] = false;
    }
  }
  int res = 0;
  for (int i = 1; i <= N; ++i) {
    if (B[i] && C[i] > 0) {
      ++res;
    }
  }
  printf("%d\n", res);
}

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

#define rep(i,l,r) for(register int i = l ; i <= r ; i++)
#define repd(i,r,l) for(register int i = r ; i >= l ; i--)
#define rvc(i,S) for(register int i = 0 ; i < (int)S.size() ; i++)
#define rvcd(i,S) for(register int i = ((int)S.size()) - 1 ; i >= 0 ; i--)
#define fore(i,x)for (register int i = head[x] ; i ; i = e[i].next)
#define forup(i,l,r) for (register int i = l ; i <= r ; i += lowbit(i))
#define fordown(i,id) for (register int i = id ; i ; i -= lowbit(i))
#define pb push_back
#define prev prev_
#define stack stack_
#define mp make_pair
#define fi first
#define se second
#define lowbit(x) (x&(-x))

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pr;

const ll MAX = 2e18;
const ld inf = 2e18;
const int maxn = 220;
const ll mod = 1e9 + 7;

inline ll power(ll x,ll y){
	y = ((y % (mod - 1)) + (mod - 1)) % (mod - 1);
//	if ( y < 0 ) return power(power(x,-y),mod - 2);
	ll res = 1;
	while ( y ){
		if ( y & 1 ) res = res * x % mod;
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int a[maxn],n,odd[maxn],even[maxn],cnt1,cnt2;
set <int> s;
namespace Prime{
	const int N = 1e7;
	int prime[N + 20],tag[N + 20],mn[N + 20],Cnt;	
	void init (){
		tag[1] = 1;
		rep(i,2,N){
			if ( !tag[i] ) prime[++Cnt] = i;
			rep(j,1,Cnt){
				if ( prime[j] * i > N ) break;
				tag[i * prime[j]] = 1;
				mn[i * prime[j]] = prime[j];
				if ( i % prime[j] == 0 ) break;
			}
		}
	}
}
using namespace Prime;

struct node{
	int next,to;
}e[maxn * maxn];
int head[maxn],cnt;
int mx[maxn],my[maxn],dx[maxn],dy[maxn],q[maxn],hh,tt,tot,vis[maxn];

inline void adde(int x,int y){
	e[++cnt].to = y;
	e[cnt].next = head[x];
	head[x] = cnt;
}

bool find(int x){
	fore(i,x){
		int to = e[i].to;
		if ( !vis[to] && dy[to] == dx[x] + 1 ){
			vis[to] = 1;
			if ( !my[to] || find(my[to]) ){
				mx[x] = to;
				my[to] = x;
				return 1;
			}
		}
	}
	return 0;
}
void match(){
	memset(mx,0,sizeof(mx));
	memset(my,0,sizeof(my));
	tot = 0;
	while ( 1 ){
		bool flag = 0;
		tt = hh = 0;
		rep(i,1,cnt1) dx[i] = 0;
		rep(i,1,cnt2) dy[i] = 0;
		rep(i,1,cnt1) if ( !mx[i] ) q[tt++] = i;
		while ( hh < tt ){
			int x = q[hh++];
		
			fore(i,x){
				int to = e[i].to;
				if ( !dy[to] ){
					dy[to] = dx[x] + 1;
					if ( my[to] ){
						dx[my[to]] = dy[to] + 1;
						q[tt++] = my[to]; //入队的点只有左边的点
					}
					else flag = 1;//找到增广路
				}
			}
		}
		if ( !flag ) break;
		memset(vis,0,sizeof(vis));
		rep(i,1,cnt1) if ( !mx[i] && find(i) ) tot++;
	}
}


int main(){
	init();
	scanf("%d",&n);
	rep(i,1,n){
	   	scanf("%d",&a[i]);
		if ( s.find(a[i]) == s.end() ) s.insert(a[i]);
		else s.erase(a[i]);

		if ( s.find(a[i] + 1) == s.end() ) s.insert(a[i] + 1);
		else s.erase(a[i] + 1);
	}
	for (auto it = s.begin() ; it != s.end() ; ++it){
		int x = *it;
		if ( x & 1 ) odd[++cnt1] = x;
		else even[++cnt2] = x;
	}
	rep(i,1,cnt1){
		rep(j,1,cnt2){
			int c = abs(odd[i] - even[j]);
			if ( !tag[c] ) adde(i,j);
		}
	}
	match();
	cout<<cnt1 + cnt2 - tot + ((cnt1 - tot) & 1)<<endl;
}


Measured memory_bytes: 81920
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

typedef pair<int, int> P;

const int N = 4;

P in[N];
int ans, data[N][N];
bool used[N][N];

void solve(int y, int x){
  while(used[y][x]){
    if(++x == N){
      x = 0;
      if(++y == N){
        ans++;
        return;
      }
    }
  }
  for(int i=0;i<N;i++){
    int ny = y + in[i].first;
    int nx = x + in[i].second;
    if(ny<0 || ny>=N) continue;
    if(nx<0 || nx>=N) continue;
    if(used[ny][nx]) continue;
    used[y][x] = used[ny][nx] = true;
    solve(y, x);
    used[y][x] = used[ny][nx] = false;
  }
}

main(){
  while(cin >> in[0].second >> in[0].first && in[0].second <= N){
    for(int i=1;i<N;i++) cin >> in[i].second >> in[i].first;
    ans = 0;
    fill(used[0], used[N], false);
    solve(0, 0);
    cout << ans << endl;
  }
}

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

int N, Z, W;
vector<int> a;

int memo[2][2001][2001];
int dfs(int t, int n, int prev_n) {
  if (memo[t % 2][n][prev_n] != -1) return memo[t % 2][n][prev_n];
  int ret;
  if (t % 2 == 0) {
    ret = abs(a[N - 1] - a[prev_n]);
    for (int i = n + 1; i < N; i++) {
      ret = max(dfs(t + 1, i, i - 1), ret);
    }
  } else {
    ret = abs(a[N - 1] - a[prev_n]);
    for (int i = n + 1; i < N; i++) {
      ret = min(dfs(t + 1, i, i - 1), ret);
    }
  }
  return memo[t % 2][n][prev_n] = ret;
}

int main(void) {
  cin >> N >> Z >> W;
  memset(memo, -1, sizeof(memo));
  a = vector<int>(N + 1);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  a[N] = W;
  cout << dfs(0, 0, N) << endl;
  return 0;
}

Measured memory_bytes: 31616
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp				make_pair
#define pb				push_back
#define all(a)			(a).begin(), (a).end()
#define sz(a)			a.size()
#define md(a, b)		((a) % b + b) % b
#define mod(a)			md(a, MOD)
#define srt(a)			sort(all(a))
#define mem(a, h)		memset(a, (h), sizeof(a))
#define f 				first
#define s 				second
#define forn(i, n)			for(int i = 0; i < n; i++)
#define fore(i, b, e)	for(int i = b; i < e; i++)
#define forg(i, b, e, m)	for(int i = b; i < e; i+=m)
//int in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
using namespace __gnu_pbds;

typedef long long 		ll;
typedef long double ld;	
typedef unsigned long long 		ull;
typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//find_by_order kth largest  order_of_key <
const int tam = 100010;
const int MOD = 1000000007;
const int MOD1 = 998244353;
const double EPS = 1e-9;
const double PI = acos(-1); 
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	//freopen("asd.txt", "r", stdin);
	//freopen("qwe.txt", "w", stdout);
	int n;
	cin>>n;
	cout<<min(8, 10 - n / 200);
	return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS2	

Measured memory_bytes: 3584
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

A, B = [0], [0]
for i in range(n):
    A.append(a[i]+A[i])
for i in range(m):
    B.append(b[i]+B[i])

ans, j = 0, m
for i in range(n+1):
    if A[i] > k:
        break
    while B[j] > k - A[i]:
        j -= 1
    ans = max(ans, i+j)
print(ans)


Measured memory_bytes: 47412
#include <cstdio>

using namespace std;

int main() {
    int a, b;
    
    scanf("%d %d", &a, &b);
    
    if (a + b == 15) {
        puts("+");
    } else if (a * b == 15) {
        puts("*");
    } else {
        puts("x");
    }
    
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  int h;
  string s;
  cin>>s;
  reverse(all(s));
  int dp[100010][13]={0};
  dp[0][0]=1;
  int mul=1;
  int mod=1000000000+7;
  for(int i=1;i<=s.size();i++){
    if(s[i-1]=='?'){
      for(int j=0;j<10;j++){
        int r=j*mul;
        int g=r%13;
        rep(h,13){
          dp[i][(h+g)%13]+=dp[i-1][h];
          dp[i][(h+g)%13]%=mod;
        }
      }
    }
    else{
      int c=(s[i-1]-'0');
      int e=c*mul%13;
      rep(h,13){
        dp[i][(h+e)%13]+=dp[i-1][h];
        dp[i][(h+e)%13]%=mod;
      }
    }
    mul*=10;
    mul%=13;
  }
  int q=s.size();
  COUT(dp[q][5]);
}


Measured memory_bytes: 5504
using System;
public class Hello{
    public static void Main(){
        // Your code here!
        int N = int.Parse(Console.ReadLine());
        int X = N;
        for(int i = 1; i < 1000; i++)
        {
            X *= i;
            if(X % 2 == 0)
            {
                break;
            }
        }
        
        Console.WriteLine(X);
        
    }
}

Measured memory_bytes: 13140
// atcoder/abc118/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

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

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    vector<lli> a(n);
    cin >> a;

    lli x = a.front();
    each (i, a) x = gcd(max(i, x), min(i, x));
    cout << x << endl;
  }

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(register int i=s;i<=t;++ i)
#define re register
#define int long long
int gi(){
	char cc=getchar();int cn=0,flus=1;
	while(cc < '0' || cc > '9'){if(cc == '-')flus=-flus;cc=getchar();}
	while(cc >= '0' && cc<='9')cn=cn*10+cc-'0',cc=getchar();
	return cn*flus;
}
const int P=998244353;
const int N=1e7+5;
int n,inv[N],fac[N],fp[N],Ans;
int fpow(int x,int k){
	int ans=1,base=x;
	while(k){
		if(k&1) ans=ans*base%P;
		base=base*base%P,k >>= 1;
	}return ans;
}
void inc(int &x,int y){	((x += y) >= P) && (x -= P);}
int C(int x,int y){if(y > x) return 0;return fac[x]*inv[y]%P*inv[x-y]%P;}
signed main(){
	n=gi(),fp[0]=inv[0]=fac[0]=1;
	rep(i,1,n) fac[i]=fac[i-1]*i%P,fp[i]=fp[i-1]*2%P;
	inv[n]=fpow(fac[n],P-2);
	for(re int i=n;i >= 1;-- i) inv[i-1]=inv[i]*i%P;
	int m=(n/2)+1,num=0;
	Ans=fpow(3,n);
	for(re int i=m;i<=n;++ i){
		int dec=C(n,i);
		dec=dec*fp[n-i]%P;
		inc(num,dec);
	}
	Ans=(Ans-num*2ll%P+P)%P;
	printf("%lld\n",Ans);
	return 0;
}

Measured memory_bytes: 234624
def encode(x):
    return chr(x + 97)


N = int(input()) - 1
ans = []
while True:
    q, r = divmod(N, 26)
    ans.append(r)
    if q == 0:
        break
    N //= 26
    N -= 1
print("".join(map(encode, ans[::-1])))


Measured memory_bytes: 9080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int ,P> P3;
typedef pair<P ,P> PP;
const ll MOD = ll(1e9+7);
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

ll f(ll x){
    ll res = 0;
    while(x > 0){
        res += x%10;
        x /= 10;
    }
    return res;
}

int main() {
    ll a, n, m, ans=0;
    cin >> a >> n >> m;
    for(int i=1;ll(pow(i,n))<=m; i++){
        ll x = ll(pow(i,n));
        if(x==ll(pow(f(x)+a,n))){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3292
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			final int K = sc.nextInt();
			
			double answer = 0;
			for(long x = 1; x <= N; x++) {
				double prob = 1;
				
				for(long c = x; c < K; c *= 2) { prob /= 2; }
				answer += prob / N;
			}
			
			System.out.printf("%.11f\n", answer);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
int main(){
  char s;
  cin >> s;
  if(s == 'A'){ cout << 'T';}
  else if(s == 'T'){ cout << 'A';}
  else if(s == 'C'){ cout << 'G';}
  else {cout << 'C';}

  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
typedef long long ll;
typedef multiset<ll> S;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}
int main(){
    ll n,k;cin>>n>>k;
    vector<bool> used(n+1,false);
    vector<P> p(n),v,u;
    rep(i,n)cin>>p[i].first>>p[i].second;
    sort(all(p));
    rep(i,n-1){
        if(p[i].first!=p[i+1].first)v.eb(p[i].second,p[i].first);
        else u.eb(p[i].second,p[i].first);
    }
    v.eb(p[n-1].second,p[n-1].first);
    ll ans=0;
    sort(all(u));
    reverse(all(u));
    sort(all(v));
    reverse(all(v));
    ll s=min((ll)(v.size()),k);
    vector<P> q;
    rep(i,s){
        ans+=v[i].first;
        q.eb(v[i].first,v[i].second);
    }
    int w=0;
    if(s<k){
        rep(i,k-v.size()){
            ans+=u[i].first;
            used[u[i].second]=true;
            w++;
        }
    }
    int wh=s-1;
    while(w<u.size()){
        auto t=u[w];
        while(wh>=0){
          if(used[q[wh].second])wh--;
          else break;
        }
      if(wh<0)break;
        used[t.second]=true;
        if(u[w].first-q[wh].first<s*s-(s-1)*(s-1))break;
        ans+=u[w].first-q[wh].first;
        wh--;
        w++;
        s--;
    }
    cout<<ans+s*s<<endl;
}


Measured memory_bytes: 5236
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<algorithm>
#include<deque>
#include<queue>
#include<set>
#include<map>
#include<functional>

using namespace std;
#define LL long long
#define MOD 1000000007

int N;
string s, t;
LL alf[30] = {};

int main() {
	cin >> N >> s >> t;
	alf[s[0] - 'a'] = 1;
	for (int i = 1; i < N - 1; i++) {
		alf[s[i] - 'a'] += alf[t[i] - 'a'];
		alf[s[i] - 'a'] %= MOD;
	}
	cout << alf[t[N - 1] - 'a'] % MOD << endl;	
	return 0;
}



Measured memory_bytes: 3292
(defun calc (a b &optional (c 1) (ans "No"))
  (let ((r (* c (* a b))))
    (cond ((> c 3)
           ans)
          ((oddp r)
           "Yes")
          (t (calc a b (incf c))))))

(defun main ()
  (let ((a (read)))
    (let ((b (read)))
      (format t "~a~%" (calc a b)))))

(main)

Measured memory_bytes: 13924
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner scan = new Scanner(System.in);
        String str1 = scan.nextLine();
        scan.close();
        String mae = str1.substring(0,2);
        String ushiro = str1.substring(2,4);
        int maei = Integer.parseInt(mae);
        int ushiroi = Integer.parseInt(ushiro);
        if((1 <= maei && maei <= 12) && (1 <= ushiroi && ushiroi <= 12)){
            System.out.println("AMBIGUOUS");
        }else if(1 <= maei && maei <= 12){
            System.out.println("MMYY");
        }else if(1 <= ushiroi && ushiroi <= 12){
            System.out.println("YYMM");
        }else{
            System.out.println("NA");
        }



        }}

Measured memory_bytes: 21716
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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        x: usize
    }
    if x == 1 || x == 2 * n - 1 {
        println!("No");
        return;
    }
    println!("Yes");
    if x < n {
        for i in x + 1..n + 1 {
            println!("{}", i);
        }
        for i in 1..x + 1 {
            println!("{}", i);
        }
        for i in n + 1..2 * n {
            println!("{}", i);
        }
    } else {
        for i in 1..n {
            println!("{}", i);
        }
        for i in x..2 * n {
            println!("{}", i);
        }
        for i in n..x {
            println!("{}", i);
        }
    }
}


Measured memory_bytes: 5628
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using ll = long long;
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; }
const long long INF = 1LL << 60;

int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

uintmax_t combination(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}

int main()
{
    double r;
    cin >> r;

    double pi = 3.14159265258979323;

    double ans = 2*r*pi;

    cout << fixed << setprecision(15) << ans << endl;
    return 0;
}

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

int adj[26][26];

bool cycle(void){
  int d[26];
  for(int i=0;i<26;i++)d[i] = 0;

  for(int i=0;i<26;i++){
    for(int j=0;j<26;j++){
      for(int k=0;k<26;k++){
	if(adj[k][j] && d[j] > d[k] + adj[k][j]){
	  d[j] = d[k] + adj[k][j];
	  if(i==25)return true;
	}
      }
    }
  }
  return false;
}

int main(){
  int n,h,w;
  string pict[50];
  int rr,rd,lu,ll;
  bool flag;

  cin >> n;
  while(n){
    n--;
    cin >> h >> w;
    for(int i=0;i<h;i++)cin >> pict[i];
    for(int i=0;i<26;i++){
      for(int j=0;j<26;j++)adj[i][j] = 0;
    }

    flag = true;
    for(int i='A';i<='Z';i++){
      rr = 0;
      rd = 0;
      lu = h;
      ll = w;
      for(int j=0;j<h;j++){
	for(int k=0;k<w;k++){
	  if(pict[j][k] == i){
	    rr = max(rr,k);
	    rd = max(rd,j);
	    lu = min(lu,j);
	    ll = min(ll,k);
	  }
	}
      }

      for(int j=lu;j<=rd;j++){
	for(int k=ll;k<=rr;k++){
	  if(pict[j][k] == '.'){
	    flag = false;
	    break;
	  }else if(pict[j][k] != i){
	    adj[pict[j][k] - 'A'][i - 'A'] = -1;
	  }
	}
	if(!flag)break;
      }
      if(!flag)break;
    }

    if(flag && !cycle())cout << "SAFE" << endl;
    else cout << "SUSPICIOUS" << endl;
  }
}

Measured memory_bytes: 920
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const ll inf=(1ll<<31)-1;

struct segtree{
  int n;
  vector<ll> dat;
  segtree(int n_){
    init(n_);
  }
  void init(int n_){
    n=1;
    while(n<n_) n*=2;
    dat.resize(2*n-1);
    for(int i=0;i<2*n-1;i++) dat[i]=inf;
  }
  void update(int k,ll a){
    k+=n-1;
    dat[k]=a;
    while(k>0){
      k=(k-1)/2;
      dat[k]=min(dat[k*2+1],dat[k*2+2]);
    }
  }
  ll get(int a,int b,int k=0,int l=0,int r=-1){
    if(r<0) r=n;
    if(r<=a||b<=l) return inf;
    if(a<=l&&r<=b) return dat[k];
    else{
      ll vl=get(a,b,k*2+1,l,(l+r)/2);
      ll vr=get(a,b,k*2+2,(l+r)/2,r);
      return min(vl,vr);
    }
  }
};

int main(){
  int n,q; cin >> n >> q;
  segtree sg(n);
  vector<ll> ans(0);
  rep(i,q){
    int com,x,y;
    cin >> com >> x >> y;
    if(com==0){
      sg.update(x,y);
    }
    else{
      ans.push_back(sg.get(x,y+1));
    }
  }
  rep(i,ans.size()){
    cout << ans[i] << endl;
  }
  
}


Measured memory_bytes: 5540
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define MOD 1000000007
 
int main(){
  int N;
  ll W;
  cin>>N>>W;
  vector<vector<ll>> v(4);
  ll w, V;
  cin>>w>>V;
  v[0].push_back(V);
  for(int i=1;i<N;i++){
    ll x,y;
    cin>>x>>y;
    x-=w;
    v[x].push_back(y);
  }
  for(int i=0;i<4;i++) sort(v[i].rbegin(),v[i].rend());
  ll v2[4][101];
  for(int i=0;i<4;i++){
    for(int j=0;j<=v[i].size();j++){
      if(j==0) v2[i][j]=0;
      else if(j==1) v2[i][j]=v[i][0];
      else v2[i][j]=v2[i][j-1]+v[i][j-1];
    }
  }
 
  ll ans=-1;
  for(int i=0;i<=v[0].size();i++){
    for(int j=0;j<=v[1].size();j++){
      for(int k=0;k<=v[2].size();k++){
        for(int l=0;l<=v[3].size();l++){
          ll tmp=0;
          tmp+=i*w;
          tmp+=j*(w+1);
          tmp+=k*(w+2);
          tmp+=l*(w+3);
          if(tmp>W) continue;
          ll tmpv=0;
          tmpv+=v2[0][i];
          tmpv+=v2[1][j];
          tmpv+=v2[2][k];
          tmpv+=v2[3][l];
          ans=max(ans,tmpv);
        }
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

int main(){
    int n,y;
    cin >> n>>y;
    for(int i=0;i<=2000;i++){
        for(int j=0;j<=2000;j++){
            if(i*10000+j*5000+1000*(n-i-j)==y&&n-i-j>=0){
                cout << i << " " << j << " " << n-i-j << endl;
                return 0;
            }
        }
    }
    cout << -1<< " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <stack>
#include <string>
#include <vector>
#include <unordered_set>

using std::cin;
using std::cout;
using std::endl;
using std::unordered_set;
using std::pair;
using std::stack;
using std::string;
using std::vector;

long f(const vector<long>& as, long x) {
  long result = 0;
  for (const long a : as) {
    result += x ^ a;
  }
  return result;
}

long bitwise(const vector<long>& as, long m, long x) {
  long result = 0;
  for (const long a : as) {
    result += x ^ (a & m);
  }
  return result;
}

long keep_max_bit(long x, long k) {
  long bit = 1;
  long result = x;
  while (bit <= k) {
    bit = bit << 1;
  }
  bit = bit >> 2;

  while (bit > 0) {
    if (x & bit && !(k & bit)) {
      result = result & (~bit);
    }
    if (!(x & bit) && k & bit) {
      break;
    }
    bit = bit >> 1;
  }
  return result;
}

int main(int argc, char* argv[]) {
  int n;
  long k;
  cin >> n >> k;
  vector<long> as(n);
  for (int i = 0; i < n; ++i) {
    cin >> as[i];
  }

  long x = 0;  // x may be larger than k.
  long bit = 1;

  while (bit <= k) {
    if (bitwise(as, bit, bit) > bitwise(as, bit, 0)) {
      x = x | bit;
    }
    bit = bit << 1;
  }
  bit = bit >> 1;
  cout << std::max(f(as, keep_max_bit(x, k)), f(as, x & (~bit)));

  return 0;
}


Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
arr=limii()
chk=arr[0]
for i in range(1,n):
    chk = chk^arr[i]    

arr.sort()
a0=arr.count(arr[0])
a1=arr.count(arr[-1])

if (len(list(set(arr)))==1 and list(set(arr))[0]==0) or chk==0 or (arr[0]==0 and a0==n//3 and a1==2*n//3):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 85740
import java.util.Scanner;
     
    public class Main { //クラス名はMain
        public static void main(String[] args) {
            //コード
          Scanner sc = new Scanner(System.in);
          boolean b1 = false;		//九九フラグ
    	  int n = sc.nextInt();
          int m = 0;		//掛け算計算用変数
          //九九判定
          if (n > 81 || n <= 0) {
            System.out.println("No");
            return;
          }
         loop: for(int i=1;i<10;i++) {
           		for(int j=1;j<10;j++) {
                  m = i * j;
                    //等価判定
       				if (java.util.Objects.equals(m,n)) {
              				b1 = true;
                      		break loop;
                    }
                }
         } 
      if (b1 == true){
       System.out.println("Yes");
      }
      else{
        System.out.println("No");
      }         
      }
    }

Measured memory_bytes: 23636
#include<cstdio>
#include<algorithm>
using namespace std;
long long opt[106][100005];
int main()
{
    int v[106],w[105];
    int i,j,n,m;
    scanf("%d %d",&n,&m);
    for(i = 1; i <= n; i++)
        scanf("%d %d",&w[i],&v[i]);
    for(i = 0; i <= n; i++)
        opt[0][i] = 0;
    for(i = 1; i <= n; i++)
    {
        for(j = 0; j <= m; j++)
        {
            //printf("%d*",j - w[i]);
            if(j - w[i] >= 0)
                opt[i][j] = max(opt[i - 1][j],opt[i - 1][j - w[i]] + v[i]);
            else opt[i][j] = opt[i - 1][j];
            //printf("%d ",opt[i][j]);
        }
        //printf("\n");
    }
    printf("%lld\n",opt[n][m]);
    return 0;
}

Measured memory_bytes: 79232
import java.util.Scanner;

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

        int i = 1;
        int n = sc.nextInt();
        int x;

        do{
            x = i;
            while(true){
                if(x % 3 == 0 && x == i){
                    System.out.print(" " +i);
                    break;
                }else if(x % 10 == 3){
                    System.out.print(" " +i);
                    break;
                }
                x /=10;
                if(x != 0) continue;
                else break;
                
                
            }
        }while(++i <= n);
        System.out.println(); 

    }
}


Measured memory_bytes: 28844
#include <bits/stdc++.h>
using namespace std;
#define int long long

int solve(int n){
	return n / 2;
}

signed main(){
	int K, i;
	string S;
	cin >> S;
	scanf("%lld", &K);
	vector<int> A(0);
	int now;
	for(i = 1, now = 1; i < S.size(); i++){
		if(S[i] == S[i - 1]){
			now++;
		}
		else{
			A.push_back(now);
			now = 1;
		}
	}
	int f = 0;
	if(S[0] == S[S.size() - 1]){
		if(A.size() == 0){
			printf("%lld\n", solve(S.size() * K));
			return 0;
		}
		f = 1;
	}
	A.push_back(now);
	int ans = 0;
	for(i = 0; i < A.size(); i++){
		ans += K * solve(A[i]);
	}
	if(f == 1){
		ans -= (K - 1) * solve(A[0]);
		ans -= (K - 1) * solve(A[A.size() - 1]);
		ans += (K - 1) * solve(A[0] + A[A.size() - 1]);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

diff = [None] * N

for i in range(N):
    diff[i] = A[i] - B[i]

diff_up_0 = []
diff_equal_0 = [] 
diff_down_0 = []

for d in diff:
    if d > 0:
        diff_up_0.append(d)
    elif d == 0:
        diff_equal_0.append(d) 
    else:
        diff_down_0 .append(d)

diff_up_0.sort()
diff_up_0 = diff_up_0[::-1]
d_sum = -sum(diff_down_0)
u_sum = 0

cnt = 0
len_u = len(diff_up_0)
while cnt < len_u:
    if u_sum >= d_sum:
        break
    else:
        u_sum += diff_up_0[cnt]
        cnt += 1
if u_sum < d_sum:
    print(-1)
else:
    print(cnt + len(diff_down_0))


Measured memory_bytes: 19060
#![allow(unused_imports)]

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::{i32, i64, u32, u64, usize, f64};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::io::{stdout, Write, BufWriter};
use std::mem::{swap};

fn main() {
    input! {
        n: usize,
        m: usize,
        xs: [i64; m],
    }
    if m <= n {
        println!("0");
        return;
    }
    let xs = {
        let mut xs = xs;
        xs.sort();
        xs
    };
    let dists = {
        let mut dists: Vec<_> = xs.windows(2).map(|w| w[1] - w[0]).collect();
        dists.sort();
        dists.reverse();
        dists
    };
    let s: i64 = dists.iter().sum();
    let skip: i64 = dists.iter().take(n - 1).sum();
    println!("{}", s - skip);
}


Measured memory_bytes: 8444
#include <stdio.h>
#define N 100

void swap(int,int);
void sort(int *,int);
int main() {
  int i,n;
  int array[N];
  scanf("%d",&n);
  for (i = 0; i < n; i++) {
    scanf("%d",&array[i]);
  }

  sort(array,n);
  return 0;
}

void sort(int *A,int n){
  int i,j,minj=0,cnt=0,temp;
  for (i = 0; i < n; i++) {
    minj = i;
    for (j = i; j <= n-1; j++) {
      if (A[j] < A[minj]) {
        minj = j;
      }
    }
    if(i!=minj){
    temp = A[i];
    A[i] = A[minj];
    A[minj] = temp;
    cnt++;
    }
  }
  for (i = 0; i < n; i++) {
    if (i > 0)printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
  printf("%d\n",cnt);
}

Measured memory_bytes: 604
import heapq
def main():
  N, Q = list(map(int, input().split()))
  STX = tuple(list(map(int, input().split())) for _ in range(N))
  D = tuple([int(input()) for _ in range(Q)])

  L = []
  for s, t, x in STX:
    L.append((x, s - x, t - x))

  L.sort(key = lambda x: x[1])
  q = []
  cnt = 0
  push = heapq.heappush
  pop = heapq.heappop
  t = []
  for i in range(Q):
    while cnt < len(L) and D[i] >= L[cnt][1]:
      if t != []:
        push(q, t)
        t = []
      push(q, L[cnt])
      cnt += 1
    if t != [] and t[2] > D[i]:
      print(t[0])
    else:
      while q != []:
        t = pop(q)
        if t[2] > D[i]:
          print(t[0])
          break
      else:
        t = []
        print(-1)

main()


Measured memory_bytes: 99484
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
        String word = in.next();
        if (word.charAt(word.length() - 1) == 's') {
            System.out.println(word + "es");
        } else {
            System.out.println(word + "s");
        }
        in.close();
    }
}

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



#define pp pair<int,int>
#define oo 100000000
#define RRR ios_base::sync_with_stdio(false);cin.tie(0);
#define ll long long
#define int ll


int ar[200000];
int ar2[200000];
int32_t main()
{
    int n;
    cin >> n;
   for (int i=0;i<n;i++)
   {
       cin >> ar[i];
   }
   int z = 0;
   int z2 = 0;
    int cp = n-1;
   for (int i=n-1;i>=0;i--)
   {
       if (z % 2 == 0)
       {
            ar2[z2] = ar[i];
            z2++;
       }
       else {
        ar2[cp] = ar[i];
        cp--;
       }
       z++;
   }
   for (int i=0;i<n;i++)
   {
       cout << ar2[i] << " ";
   }
}


Measured memory_bytes: 5248
from math import floor
s = input()

len_s = len(s)
len_s_d2 = floor(len(s) / 2)
cnt_hug = 0
for i in range(len_s_d2):
	if s == s[::-1]:
		break
	if s[i] != s[len_s - 1 - i]:
		if i == 0:
			s = s[len_s - 1] + s[1:]
		else:
			s = s[:i] + s[len_s - 1 - i] + s[i+1:]
		cnt_hug += 1

print(cnt_hug)

Measured memory_bytes: 3064
package main

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

var (
	nextToken func() ([]byte, error)
	nextLine  func() ([]byte, error)

	OutputBuffer *bufio.Writer

	OutputWriter io.Writer
)

// set up IO functions
func init() {

	SetInput(os.Stdin)
	SetOutput(os.Stdout)

}
// Setup OutputBuffer and OutputWriter.
func SetOutput(w io.Writer) {
	OutputBuffer = bufio.NewWriter(w)
	OutputWriter = OutputBuffer
}

// Flushes OutputBuffer
func Flush() {
	if OutputBuffer != nil {
		OutputBuffer.Flush()
	}
}

// Returns true if c is a white space
func IsSpace(c byte) bool {
	switch c {
	case '\t', '\n', '\v', '\f', '\r', ' ':
		return true
	}
	return false
}

func IsNewLine(c byte) bool {
	switch c {
	case '\n', '\r':
		return true
	}
	return false
}

// Setup nextToken with input buffer.
func SetInput(r io.Reader) {
	buf := new(bytes.Buffer)
	var b []byte

	var i int
	rest := func() ([]byte, error) {
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		return b[j:i], nil
	}
	initial := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextToken = rest
		return rest()
	}
	nextToken = initial

	restLn := func() ([]byte, error) {
		for i < len(b) && IsNewLine(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsNewLine(b[i]) {
			i++
		}
		return b[j:i], nil
	}

	initialLn := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextLine = restLn
		return restLn()
	}
	nextLine = initialLn
}

// Reads next token and return it as []byte
func readb() []byte {
	b, err := nextToken()
	if err != nil {
		panic(err)
	}
	return b[:len(b):len(b)]
}

// Reads next token and return it as string
func reads() string {
	return string(readb())
}

// Reads next token and return it as int64
func readll() int64 {
	i, err := strconv.ParseInt(reads(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// Reads next token and return it as int
func readi() int {
	return int(readll())
}

// Write args to OutputWriter without format
func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(OutputWriter, args...)
}
func main() {
	defer Flush()

	N := readi()

	var ans int
	for A := 1; A*A < N; A++ {
		for B := A; A*B < N; B++ {
			if 1 <= N-A*B {
				if A == B {

					ans++
				} else {

					ans += 2
				}

			}
		}
	}
	println(ans)

}



Measured memory_bytes: 1808
#include <iostream>
#include <algorithm>
using namespace std;
int n, a[100], res = 0;
int main(void){
    // Your code here!
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    
    sort(a, a + n);
    reverse(a, a + n);
    
    for (int i = 0; i < n; i += 2) {
        if (i == n - 1) res += a[n - 1];
        else res += a[i] - a[i + 1];
    }
    cout << res << endl;
}


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

int main(){
  int n, count;
  cin >> n;
  count = 0;
  for(int i = 1; i < n + 1; i++){
    string s = to_string(i);
    if(s.size() % 2 == 1) count++;
  }
  cout << count << endl;
}

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

int main() {
  char c;
  cin >> c;
  if (c == 'A') cout << 'T';
  else if (c == 'T') cout << 'A';
  else if (c == 'G') cout << 'C';
  else if (c == 'C') cout << 'G';
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
const int mod=1e9+7;
int main()
{
	int a,b;
	char c;
	scanf("%d %c %d",&a,&c,&b);
	if(c=='-')
	printf("%d\n",a-b);
	else
	printf("%d\n",a+b);
	 
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  char c;
  cin >> c;
  
  if(c=='a' || c=='i' || c=='u'||c=='e'||c=='o'){
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}


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

int main() {
	int n;
	while(scanf("%d",&n)!=EOF){
		int ans=0;
		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				for(int k=0;k<10;k++){
					int l=n-i-j-k;
					if(0<=l&&l<=9)ans++;
				}
				
			}
		}
	cout << ans << endl;
	}

	
	
    	// your code goes here
	return 0;
}

Measured memory_bytes: 3120
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define MEMSET(a, n, x) REP(i, n) a[i]=x;
#define ARRIN(a, n) REP(i, n) cin>>a[i];
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  int n;
  cin>>n;
  int w[n];
  int l=0, r=0, ans=0;
  int ma=INF;
  REP(i, n){
    cin>>w[i];
    r+=w[i];
  }
  REP(i, n){
    l+=w[i];
    r-=w[i];
    if(ma>abs(l-r)){
      ma=abs(l-r);
      ans=i+1;
    }
  }
  cout<<ma<<endl;
  return 0;
}


Measured memory_bytes: 256
nd = gets.chomp.split
n = nd[0].to_i
d = nd[1].to_i

x_a = []
n.times do
    x = gets.chomp.split
    d.times do |i|
        x[i] = x[i].to_i
    end
    x_a << x
end

count = 0
n.times do |i|
    ((i+1)..(n-1)).each do |j|
        sum = 0
        distance = 0
        d.times do |k|
            sum += (x_a[i][k] - x_a[j][k]) ** 2
        end
        distance = Math.sqrt(sum)
        count += 1 if distance % 1 == 0
    end
end

puts count

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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ll> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("a.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	string s, t;
	cin >> s >> t;
	int a, b;
	cin >> a >> b;
	string g;
	cin >> g;
	if (g == s) --a;
	if (g == t) --b;
	cout << a << " " << b << "\n";

	return 0;
}


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

int main(){
  int a,b;
  cin >> a >> b;
  if((a+b)%3==0 || a%3==0 || b%3==0){
    cout << "Possible" << endl;
  }
  else{
    cout << "Impossible" << endl;
  }
}

Measured memory_bytes: 256