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


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int ans = 0;
    REP(i, 1, N) {
        string K = to_string(i);
        if(K.length() % 2 == 1) ans++;
    }
    cout << ans << endl;

    return 0;
}


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

int main()
{
    int n;
    int i, j, save, count, max = 0;
    int a[100001] = {0};
    
    cin >> n;
    
    for(i = 0; i < n; i++) {
        cin >> save;
        a[save]++;
    }
    
    count = a[0] + a[1] + a[2];
    max = count;
    
    for(j = 0; j <= 99997; j++) {
        count = count - a[j] + a[j+3];
        if(count > max) {
            max = count;
        }
    }
    
    cout << max << endl;
    
    return 0;
}

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

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

  int cnt = 0;
  for (int i = H; i <= N; i++) {
    for (int j = W; j <= N; j++) {
      if (N >= i && N >= j) cnt++;
    }
  }

  cout << cnt << endl;
}

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

int main() {
	long long n,a,b;
	scanf("%lld%lld%lld",&n,&a,&b);
	if(a>b){
	    printf("0\n");
	    return 0;
	}
	if(n==1 && a<b){
	    printf("0\n");
	    return 0;
	}
	if(a==b){
	    printf("1\n");
	    return 0;
	}
	if(n==2){
	    printf("1\n");
	    return 0;
	}
	printf("%lld\n",(n-2)*b-(n-2)*a+1);
	
	return 0;
}


Measured memory_bytes: 256
H, W, K = [int(x) for x in input().split()]
c = [input() for _ in range(H)]

ans = 0
for h in range(1 << H):
    for w in range(1 << W):
        black = 0
        for i in range(H):
            for j in range(W):
                if ((h >> i) & 1) + ((w >> j) & 1) == 0:  # 赤く塗られない
                    black += (c[i][j] == '#')
        if black == K:
            ans += 1

print(ans)

Measured memory_bytes: 9140
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<math.h>
#include<utility>
#include<climits>
#include <algorithm> 
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>


using namespace std; 

long long int func(vector<vector<long long int> > &dp,vector<long long int> &ar,long long int i,long long int j){
    if(dp[i][j]!=-1)
        return dp[i][j];
    if(i==j)
        return ar[i];
    if(i+1==j)
        return max(ar[i],ar[j]);
    long long int x = ar[i]+min(func(dp,ar,i+2,j),func(dp,ar,i+1,j-1));
    long long int y = ar[j]+min(func(dp,ar,i,j-2),func(dp,ar,i+1,j-1));
    dp[i][j] = max(x,y);
    // cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
    return max(x,y);
    // return max(,);
}



int main(){
    long long int n;
    cin>>n;
    vector<long long int> ar(n,0);
    long long int sum=0;
    for(long long int i=0;i<n;i++){
        cin>>ar[i];
        sum+=ar[i];
    }
    vector<vector<long long int> > dp(n,vector<long long int>(n,-1));
    long long int ans = func(dp,ar,0,n-1);
    long long int y = sum-ans;
    ans = ans-y;
    cout<<ans;
}





Measured memory_bytes: 70912
#include<bits/stdc++.h>
#define N 100100
using namespace std;
int a[N];
int main(){
	int n,l,cb=-1;
	scanf("%d%d",&n,&l);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		if(i&&a[i]+a[i-1]>=l){
			cb=i;
		}
	}
	if(cb<0) puts("Impossible");
	else{
		puts("Possible");
		for(int i=1;i<cb;i++) printf("%d\n",i);
		for(int i=n-1;i>cb;i--) printf("%d\n",i);
		printf("%d\n",cb);
	}
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout<<#x<<" "<<x<<endl;
int main()
{
    int n,k;
    cin >> n >> k;
    vector<int> v(n);
    for(int i = 0; i < n; i++)
       cin >> v[i];
      int dp[n];

     for(int i=0;i<n;i++)
        dp[i] = INT_MAX;

      dp[0] = 0;
    for(int i = 1; i < n; i++)
    {
        if(i < k)
        {
            for(int j = 1; j <= i; j++)
            {
                dp[i] = min(dp[i] , dp[i-j] + abs(v[i]-v[i-j]));
            }
        }
        else
        {
            for(int j = 1; j <= k; j++)
            {
                dp[i] = min( dp[i-j] + abs(v[i] - v[i-j]) , dp[i] );
            }
        }
    }
    cout << dp[n-1];
}


Measured memory_bytes: 1024
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll
void solve() {
	while (true) {
		int n, m;
		cin >> n >> m;
		if (n == 0) return;
		vector<int> a, b;
		REP(i, n) {
			int c;
			cin >> c;
			a.push_back(c);
		}
		REP(i, m) {
			int c;
			cin >> c;
			b.push_back(c);
		}
		map<int, int> gogo;
		REP(i, n) {
			int now = 0;
			for (int q = i; q < n; ++q) {
				now += a[q];
				gogo[now]++;
			}
		}
		int ans = 0;
		REP(i, m) {
			int now = 0;
			for (int q = i; q < m; ++q) {
				now += b[q];
				ans += gogo[now];
			}
		}
		cout << ans << endl;
	}
}

#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 26612
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    string s;
    cin >> s;
    if(s.back()=='s'){
        s += "es";
    }else s.push_back('s');
    cout << s << endl;
}

Measured memory_bytes: 3592
'''input
3 2
2000000000 -9000000000 4000000000
7000000000 -5000000000 3000000000
6000000000 -1000000000 8000000000
'''
cc = [(1,1,1),(1,-1,-1),(-1,1,-1),(-1,-1,1),(1,1,-1),(1,-1,1),(-1,1,1),(-1,-1,-1)]
n,m = map(int,raw_input().split())
arr =[]
for i in range(n):
	x,y,z = map(int,raw_input().split())
	arr.append((x,y,z))
aa = -10**20
for i in range(len(cc)):
	arr1 = []
	for j in range(n):
		x1,y1,z1 = arr[j][0]*cc[i][0],arr[j][1]*cc[i][1],arr[j][2]*cc[i][2]
		arr1.append((x1+y1+z1,x1,y1,z1))
	arr1.sort(reverse = True)
	ans = 0
	for i in range(m):
		ans += arr1[i][0]
	aa = max(aa,ans)
print aa






Measured memory_bytes: 33004
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  ll N,Q,i;cin>>N>>Q;dsu d(N);
  REP(i,Q){
    int x,u,v;cin>>x>>u>>v;
    if(x==0)d.merge(u,v);
    else cout<<d.same(u,v)<<endl;
  }
  return 0;
}

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

LL n,s;

LL f(LL b, LL n){return n<b?n:f(b,n/b)+n%b;}

int main()
{
	cin>>n>>s;
	if (s>n) {puts("-1"); return 0;}
	if (s==n) {cout<<s+1<<endl; return 0;}
	for (int b=2; b<=sqrt(n); ++b)
		if (f(b,n)==s) {cout<<b<<endl; return 0;}
	LL ans=1e18;
	for (int a1=1; a1<=sqrt(n-s); ++a1)
		if ((n-s)%a1==0)
		{
			LL b=(n-s)/a1+1,a0=s-a1;
			if (s-a1>=0 && a0<b && a1<b && b>=2)
				ans=min(ans,b);
		}
	cout<<(ans==1e18?-1:ans)<<endl;
}

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

int main() {
  ll N;
  cin >> N;
  vector<ll> as(N);
  rep(i, N) cin >> as[i];

  map<string, ll> m;
  rep(i, N) {
    ll a = as[i];
    if (a%2 != 0) {
      m["odd"]++;
    } else if (a%4 == 0) {
      m["four"]++;
    } else {
      m["even"]++;
    }
  }

  ll num = m["even"] == 0 ? 0 : 1;
  string ans = "No";
  if (m["odd"]+num-1 <= m["four"] ) {
    ans = "Yes";
  }
  cout << ans << endl;
}


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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "
#define fi first
#define se second

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N, M, K;
  cin >> N >> M >> K;
  llvec A(N+1, 0);
  llvec B(M+1, 0);
  rep(i, N){
    ll a;cin >> a;
    A[i+1]=A[i]+a;
  }
  rep(i, M){
    ll a;cin >> a;
    B[i+1]=B[i]+a;
  }
  ll ans = 0;
 
  for(ll a=0, b=M, sum=0;a<=N;){
    for(; b>=0 and A[a]+ B[b]>K;){
      b--;
    }
    if(A[a]+B[b]<=K){
      ans = max(ans, b+a);
    }
    a++;
  }

  cout << ans;
  return 0;
}


Measured memory_bytes: 6348
n, m = map(int, input().split())

hasAC, pena, tmpP= [0] * n, [0] * n, [0] * n

for i in range(m):
    li = input().split()
    p = int(li[0]) - 1
    s = li[1]
    if hasAC[p]:
        continue
    if s == 'AC':
        hasAC[p] = 1
        pena[p] += tmpP[p]
    else:
        tmpP[p] += 1

print(sum(hasAC), sum(pena))

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit);

    ll k, n; cin >> k >> n;
    vector<ll> a(n);
    rep(i, 0, n) cin >> a[i];
    ll ans = k;
    rep(i, 0, n - 1) {
        ans = min(ans, k - (a[i + 1] - a[i]));
//        cout << i << " " << i + 1 << " " << a[i] << " " << a[i + 1] << endl;
//        cout << i << " " << i + 1 << " " << (k - (a[i + 1] - a[i])) << endl;
    }
    ans = min(ans, k - (a[0] + k - a[n - 1]));
    cout << ans << endl;
}

Measured memory_bytes: 2432
from collections import defaultdict
n = int(input())
a = [list(map(int,input().split())) for i in range(n)]
dic = defaultdict(lambda :0)
cut = 0
for k in range(n):
    for i in range(n):
        for j in range(n):
            if i == j:continue
            temp = a[i][k] + a[k][j]

            if a[i][j] > temp:
                print(-1)
                exit()

            if temp == a[i][j] and i < j and k != i and k != j:
                if not dic[(i, j)]:
                    cut += a[i][j]
                    dic[(i, j)] = 1
rec = 0
for i in range(n):
    for j in range(n):
        if i < j :rec += a[i][j]

print(rec - cut)

Measured memory_bytes: 50908
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define MAXN 200000
#define MO 1000000007
#define INF 0x3FFFFFFF
using namespace std;
int n,X,Y;
int c[MAXN+5],w[MAXN+5];
int fact[MAXN+5],inv[MAXN+5];
int minpos[MAXN+5],minval[MAXN+5];
int cnt[MAXN+5];
bool vis[MAXN+5];
vector<int> G[MAXN+5];
int PowMod(int a,int b)
{
	int ret=1;
	while(b)
	{
		if(b&1)
			ret=1LL*ret*a%MO;
		a=1LL*a*a%MO;
		b>>=1;
	}
	return ret;
}
void Init()
{
	for(int i=0;i<=MAXN+3;i++)
		minval[i]=INF;
	fact[0]=1;
	for(int i=1;i<=MAXN;i++)
		fact[i]=1LL*fact[i-1]*i%MO;
	inv[MAXN]=PowMod(fact[MAXN],MO-2);
	for(int i=MAXN-1;i>=0;i--)
		inv[i]=1LL*inv[i+1]*(1LL*i+1LL)%MO;
}
void DFS(int u)
{
	vis[u]=true;
	for(int i=0;i<(int)G[u].size();i++)
	{
		int v=G[u][i];
		if(vis[v]==false)
			DFS(v);
	}
}
int C(int a,int b)
{
	return 1LL*fact[a]*inv[b]%MO*inv[a-b]%MO;
}
int main()
{
	Init();
	scanf("%d %d %d",&n,&X,&Y);
	for(int i=1;i<=n;i++)
	{
		scanf("%d %d",&c[i],&w[i]);
		if(minval[c[i]]>w[i])
		{
			minval[c[i]]=w[i];
			minpos[c[i]]=i;
		}
	}
	for(int i=1;i<=n;i++)
		if(i!=minpos[c[i]]&&w[i]+minval[c[i]]<=X)
			G[i].push_back(minpos[c[i]]),G[minpos[c[i]]].push_back(i);
	int mn1=INF,mn2=INF;
	int mnp1,mnp2;
	//先找最小值 
	for(int i=1;i<=n;i++)
		if(w[i]<mn1)
			mn1=w[i],mnp1=i;
	//再找与最小值颜色不同的最小值 
	for(int i=1;i<=n;i++)
		if(w[i]<mn2&&c[i]!=c[mnp1])
			mn2=w[i],mnp2=i;
	for(int i=1;i<=n;i++)
	{
		if(i==mnp1)
			continue;
		if(c[i]!=c[mnp1]&&w[i]+w[mnp1]<=Y)
			G[i].push_back(mnp1),G[mnp1].push_back(i);
		if(mn2!=INF&&c[i]!=c[mnp2]&&w[i]+w[mnp2]<=Y)
			G[i].push_back(mnp2),G[mnp2].push_back(i);
	}
	DFS(mnp1);
	for(int i=1;i<=n;i++)
		if(vis[i]==true)
			cnt[c[i]]++;
	int tot=0,ans=1;
	for(int i=1;i<=n;i++)
		tot+=cnt[i];
	for(int i=1;i<=n;i++)
		if(cnt[i])
		{
			ans=1LL*ans*C(tot,cnt[i])%MO;
			tot-=cnt[i];
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 17904
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>

int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f; 
}

int main()
{
	int n=read(),a=read(),b=read();
	printf("%d ",std::min(a,b));
	if (n-a-b>0) printf("%d\n",0);
	else printf("%d\n",a+b-n);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
ll gcd(ll a, ll b) {
    return (b==0)?a:gcd(b,a%b);
}
ll lcm(ll a, ll b) {
    return a/gcd(a,b)*b;
}
int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    ll ans = 0;
    rep(i, n) {
        ans += a[i] -1;
    }
    cout << ans;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        double x1 = sc.nextDouble();
                        double y1 = sc.nextDouble();
                        double x2 = sc.nextDouble();
                        double y2 = sc.nextDouble();
                        System.out.println(Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)));
                }
        }
}

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

int main(){
  int n, a, b, p1, p2;
  cin >> n >> a >> b;
  p1 = n * a;
  p2 = b;
  if(p1 < p2){
    cout << p1 << endl;
  }else{
    cout << p2 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int NIL = -1;
const int MAX = 25;

struct Node
{
  int p, l, r;
};

int N;
vector<Node> Tree(MAX);

void preorder(int id)
{
  if (id == NIL)
    return;
  cout << ' ' << id;
  preorder(Tree.at(id).l);
  preorder(Tree.at(id).r);
}

void inorder(int id)
{
  if (id == NIL)
    return;
  inorder(Tree.at(id).l);
  cout << ' ' << id;
  inorder(Tree.at(id).r);
}

void postorder(int id)
{
  if (id == NIL)
    return;
  postorder(Tree.at(id).l);
  postorder(Tree.at(id).r);
  cout << ' ' << id;
}

int main()
{
  int id, left, right, root;
  cin >> N;
  for (int i = 0; i < N; i++)
  {
    Tree.at(i).p = NIL;
  }
  for (int i = 0; i < N; i++)
  {
    cin >> id >> left >> right;
    Tree.at(id).l = left;
    Tree.at(id).r = right;
    if (left != NIL)
      Tree.at(left).p = id;
    if (right != NIL)
      Tree.at(right).p = id;
  }
  for (int i = 0; i < N; i++)
  {
    if (Tree.at(i).p == NIL)
    {
      root = i;
      break;
    }
  }
  cout << "Preorder" << endl;
  preorder(root);
  cout << endl;
  cout << "Inorder" << endl;
  inorder(root);
  cout << endl;
  cout << "Postorder" << endl;
  postorder(root);
  cout << endl;
}



Measured memory_bytes: 3092
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD1 1000000007

int main() {
  string S;
  cin >> S;
  int N = S.size();
  vi ans(N, 0);

  int i = 0;
  while (i < N ) {
    int a = i;
    while (S[i] == S[i + 1]) i++;
    int b = i;
    i++;
    int c = i;
    while (S[i] == S[i + 1]) i++;
    int d = i;
    for (int j = a ; j <= d; j++) {
      if (j % 2 == b % 2) ans[b]++;
      else ans[c]++;
    }
    i++;
    //cout << a << b << c << d << i << endl;
  }

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

}


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

int main() {
    string str;
    cin >> str;
    long temp, ans = 0, n = str.length();
    vector<long> number(n);
    rep(i, n) number.at(i) = str.at(i) - '0';
    rep(i, pow(2, n - 1)) {
        temp = number.at(0);
        rep(j, n - 1) {
            if(1 & (i >> j)) {
                ans += temp;
                temp = number.at(j + 1);
            } else {
                temp = 10 * temp + number.at(j + 1);
            }
        }
        ans += temp;
    }
    cout << ans << endl;
}

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

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

  int a;
  int i = 1;
  set<int> ss;
  while (a <= 1000000) {
    if (i == 1) {
      a = s;
    } else if (a % 2 == 0) {
      a = a / 2;
    } else {
      a = 3 * a + 1;
    }
    
    if (ss.find(a) == ss.end()) {
      ss.insert(a);
    } else {
      cout << i << endl;
      return 0;
    }
    i++;
  }

  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int n = s.length();
    int min = 2000000000;
    for(int i = 0;i<n-2;i++){
      int a = Integer.parseInt(s.substring(i,i+3));
      min = Math.min(min,Math.abs(753-a));
    }
    System.out.println(min);
  }
}


Measured memory_bytes: 35732
use std::io::{self, Read};

fn reader() -> Vec<usize> {
    let mut buffer = String::new();
    io::stdin().read_to_string(&mut buffer);

    let st: Vec<&str> = buffer.lines().collect();

    let s: Vec<&str> = st.get(1).unwrap().clone().split_terminator(" ").collect();

    s.iter()
        .map(|v| v.trim().parse::<usize>().unwrap())
        .collect()
}

fn solver(mut hs: Vec<usize>) -> usize {
    let mut v: Vec<usize> = vec![0; hs.len()];;

    for i in 1..hs.len() {
        if hs[i - 1] >= hs[i] {
            v[i] = v[i - 1] + 1;
        }
    }

    let max = v.iter().max().unwrap().clone();
    println!("{}", max);
    max
}

fn main() {
    let hs = reader();

    solver(hs);
}



Measured memory_bytes: 10492
using System;
using System.Collections.Generic;
//using System.Linq;
//using System.Numerics;

class Program {
    static void Main (string[] args) {
        var input = INP();
        long N = TOL(input[0]);

        int ac = 0;
        int wa = 0;
        int tle = 0;
        int re = 0;
        for(int i = 0;i < N;i++) {
            switch(INP()[0]) {
                case "AC":
                ac++;
                break;
                case "WA":
                wa++;
                break;
                case "TLE":
                tle++;
                break;
                case "RE":
                re++;
                break;
            }
        }

        CWL("AC x " + ac);
        CWL("WA x " + wa);
        CWL("TLE x " + tle);
        CWL("RE x " + re);
    }

    public static List<int> PrimeFactors (int n) {
        var tmpList = new List<int>();
        int i = 2;
        int tmp = n;

        while(i * i <= n) {
            if(tmp % i == 0) {
                tmp /= i;
                tmpList.Add(i);
            } else {
                i++;
            }
        }

        if(tmp != 1) tmpList.Add(tmp);

        return tmpList;
    }

    static string[] INP () {
        return Console.ReadLine().Split(' ');
    }

    static void CWL (string value) {
        Console.WriteLine(value);
    }

    static void CWL (int value) {
        Console.WriteLine(value);
    }

    static void CWL (long value) {
        Console.WriteLine(value);
    }

    static void CWL (float value) {
        Console.WriteLine(value);
    }

    static void CWL (double value) {
        Console.WriteLine(value);
    }

    static int TOI (string str) {
        return int.Parse(str);
    }

    static long TOL (string str) {
        return long.Parse(str);
    }

    static float TOF (string str) {
        return float.Parse(str);
    }

    static double TOD (string str) {
        return double.Parse(str);
    }

    /*static void Main (string[] args) {
        var input = INP();
        var input2 = INP();
        var input3 = INP();

        CWL("dummy");
    }*/
}


Measured memory_bytes: 33844
n = int(input())
max_id = 0
cur_max = 0
second_max = 0
for i in range(n):
  ai = int(input())
  if ai > cur_max:
    second_max = cur_max
    cur_max = ai
    max_id = i
  elif ai > second_max:
    second_max = ai

for i in range(n):
  if (i == max_id):
    print(second_max)
  else:
    print(cur_max)


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

using namespace std;

#define ll long long
#define ini(arr, val) memset(arr, (val), sizeof(arr))
#define loop(i,n)  for(ll i=0; i<n; i++)

#define all(a)      (a).begin(),(a).end()
#define exist(s,e)  (s.find(e)!=s.end())
#define dbg(x)  cout << #x << " is " << x << endl;
#define pt(x) cout<<x<<"\n"
#define pts(x) cout<<x<<" "

#define mp make_pair
#define pb push_back
#define f first
#define s second


#define inf (int)1e9
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007


#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test   int t; cin>>t; while(t--)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef map<int,int> mii;
typedef set<int> si;

typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pll> vpll;
typedef vector<vl> vvl;
typedef map<ll,ll> mll;
typedef set<ll> sl;


//////////////////////////////////////////////////////////////////////////////////////////
//                      main starts
//////////////////////////////////////////////////////////////////////////////////////////
int const lmt=1e5+5;



int main(){

    #ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
	#endif
    fast

    string s;
    cin>>s;
   	ll n=s.size(),c=0;
   	loop(i,n){
   		if(s[i]=='7') c=1;
   	}
    if(c==1) pt("Yes");
    else pt("No");

}


/*

// 

*/

Measured memory_bytes: 3628
N, Y = map(int, input().split())
done = False
for i in range(N+1):
  a = i
  for j in range(N+1-a):
    b = j
    c = N -i -j
    sum = 10000*a + 5000 * b + 1000 *c
    if sum == Y:
      done = True
      print(a, b, c)
  if done:
    break
        
if not done:
  print(-1, -1, -1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ALL(A) A.begin(),A.end()
const long long mod=1000000007;
int main(){
    int n;
    cin>>n;
    int v[n],c[n];
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
    }
    for(int i=0;i<n;i++)
    cin>>c[i];

    int p[n];
    for(int i=0;i<n;i++)
    p[i]=v[i]-c[i];
    sort(p,p+n);
    int ans=0;
    for(int i=0;i<n;i++)
    {
        if(p[i]>0)
        ans+=p[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Mon May 18 14:53:59 2020

@author: 17664
"""

yomi = {2:'hon', 4:'hon', 5:'hon', 7:'hon', 9:'hon', 0:'pon', 1:'pon',
        6:'pon', 8:'pon', 3:'bon'}

print(yomi[int(input()[-1])])

Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
#define ff        first
#define ss        second
#define ll        long long
#define int       long long
#define inf       ((ll)1e18)
#define mod       (ll)1e9+7
#define double    long double
#define ull       unsigned long long
#define vi        vector<ll>
#define ppi       pair<int,int>
#define pii       pair<pair<int,int>,int>
#define pb        push_back
#define pi        2*acos(0.0)
#define rev       greater<int>()
#define pr(a,x,y) for(int i=x;i<y;i++){cout<<a[i]<<" ";}
#define sp(x,y)   fixed<<setprecision(y)<<x
#define w(x)      ll x; cin>>x; while(x--)
#define all(v)    v.begin(), v.end()
#define rall(v)   v.rbegin(), v.rend()
#define test      cout<<"THIS_AND_THIS"<<endl;
#define str       string
#define endl      '\n'
#define e         cout<<'\n';
void kehsihba(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif*/
}
void solve(){
	str s;cin>>s;
	ll n=s.size();
	ll i=0,j=n-1;
	ll ans=0;
	while(i<j){
		if(s[i]!=s[j]){ans+=1;}
		i+=1;j-=1;
	}
	cout<<ans;
}
int32_t main() {
	kehsihba();
	ll t=1;
	//cin>>t;
	while(t--){
		solve();
	}
}


Measured memory_bytes: 3648
import collections
n = int(input())
a = list(map(int, input().split()))
q = int(input())
#b = [list(map(int, input().split())) for _ in range(q)]
c = collections.Counter(a)
ans = sum(a)

for i in range(q):
    x,y = map(int, input().split())
    p = c[x]
    c[x] = 0
    c[y] += p
    ans -= x*p
    ans += y*p
    print(ans)
    

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int x,y,z;
  cin>>x>>y>>z;
  cout<<((x-z)/(y+z))<<endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;

namespace Project
{
    class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var X = cin.ReadInt;
            var Y = cin.ReadInt;
            var Z = false;

            for(int i= 0; i <= X; i++)
            {
                var j = X - i;
                var sum = 4 * i + 2 * j;
                if (sum == Y)
                {
                    Z = true;
                    break;
                }
            }
            if (Z)
            {
                WriteLine("Yes");
            }
            else
            {
                WriteLine("No");
            }
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } } // intの範囲は-2147483648～2147483648
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N)
        { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N)
        { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N)
        { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }

    }
}


Measured memory_bytes: 27916
#include <stdio.h>

int main(void)
{
	int n;
	int s;
	int rund;
	int i;
	int j;
	
	scanf("%d", &n);
	
	for (i = 1; i <= n; i++){
		scanf("%d", &s);
		printf("Case %d:\n", i);
		for (j = 0; j < 10; j++){
			s = s * s / 100 % 10000;
			printf("%d\n", s);
		}
	}
	
	return (0);
}

Measured memory_bytes: 592
#include <iostream>

using namespace std;

int main()
{
    int a, i, r = 0;
    float n, s = 0, v[105];

    cin >> n;
    for ( i = 1 ; i <= n ; i++ ) cin >> v[i], s += v[i];

    if ( s / n - int ( s / n ) < int ( s / n ) + 1 - s / n ) a = int ( s / n );
    else a = int ( s / n ) + 1;

    for ( i = 1 ; i <= n ; i++ ) r += ( a - v[i] ) * ( a - v[i] );

    cout << r;

    return 0;
}


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

int X;
int res = 0;

int main(){
  cin >> X;

  int n_500 = X / 500; 
  res += n_500 * 1000;
  X -= n_500 * 500;
  res += (X / 5) * 5;

  cout << res << endl;

  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	char s[5];
	cin >> s;
	sort(s, s + 4);
	if (s[0] == s[1] && s[2] == s[3]&&s[0]!=s[2]) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <math.h>
#include <cstdlib>
#include <cctype>
#include <random>

using namespace std;

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

    if (x == 7 || x == 5 || x == 3) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int W, H, N;
  scanf("%d %d %d", &W, &H, &N);

  int x, y, a;
  int xs = 0, xe = W, ys = 0, ye = H;
  for(int i=0;i<N;i++) {
    scanf("%d %d %d", &x, &y, &a);
    if(a==1 && xs < x)
      xs = x;
    else if(a==2 && xe > x)
      xe = x;
    else if(a==3 && ys < y)
      ys = y;
    else if (a==4 && ye > y)
      ye = y;
  }

  if(xs > xe || ys > ye)
    printf("0\n");
  else
    printf("%d\n", (xe - xs) * (ye - ys));

  return 0; 
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> ii;
typedef map<int, int> MPII;
typedef set<int> SETI;

const int mxN = 2e5;
const ld pi = 4.0 * atanl(1.0);
const int iinf = 1e9 + 10;
const int inf = 1e18 + iinf + 10;
const int mod = 1000000007;
const ld prec = .000001;

#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(c) c.begin(), c.end()
#define rall(c) c.end(), c.begin()

int n, m, t, a[mxN];
vi v;

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

int main() {
  fast();
  cin >> n;
  string s;
  cin >> s;
  int mx = 0, ans = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'I') ++ans;
    if (s[i] == 'D') --ans;
    mx = max(mx, ans);
  }
  cout << mx;

  return 0;
}



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

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    for (int &ai : a)
        cin >> ai;
    cout << *max_element(begin(a), end(a)) - *min_element(begin(a), end(a)) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)

using namespace std;
const int N = 2010;
char m[N][N];
int d[N][N], sd[N][N];
int st[N], top;
int main()
{
	int h, w;
	scanf("%d%d", &h, &w);
	Rep(i, h) scanf("%s", m[i] + 1); 
	Rep(i, h) for (int j = 2; j <= w; j ++){
		if (m[i][j] == m[i][j - 1]) d[i][j] = 0;
		else d[i][j] = 1;
	}
	for (int j = 2; j <= w; j ++) Rep(i, h){
		if (d[i][j] == d[i - 1][j]) sd[i][j] = sd[i - 1][j] + 1;
		else sd[i][j] = 1;
	}
	int ans = h;
	Rep(i, h) {
		top = 0;
		st[0] = 1;
		for (int j = 2; j <= w; j ++) {
			while (top && sd[i][st[top]] >= sd[i][j])
				ans = max(ans, (j - st[top - 1]) * sd[i][st[top]]), top --;
			st[++ top] = j;
		}
		while (top) ans = max(ans, (w - st[top - 1] + 1) * sd[i][st[top]]), top --;
	}
	
	printf("%d\n", ans);
	
	return 0;
}
/*
3 3
..#
##.
.#.
*/


Measured memory_bytes: 35712
N = int(input())
S = list(input())
# 一番左がリーダーの時
l = 0
r = S[1:].count('W')
ans = l + r
for i in range(1, N):
    if S[i-1] == 'E':  # 元リーダーの人が東向きの時
        l += 1
    if S[i] == 'W':  # 元リーダーが西向きの時
        r -= 1
    cnt = l+r
    ans = max(cnt, ans)  # 向きを変える必要のない人数
print(N - ans -1)  # 向きを変える必要のある人数

Measured memory_bytes: 8140
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
using P=pair<int,int>;
using PP=pair<int,P>;
struct UnionFind{
    vector<int> par,siz;
    UnionFind(int n){
        par.resize(n);
        siz.resize(n,1);
        for(int i=0;i<n;i++)par[i]=i;
    }
    int root(int a){
        if(par[a]==a)return a;
        else return par[a]=root(par[a]);
    }
    bool issame(int a,int b){
        return root(a)==root(b);
    }
    int size(int a){
        return siz[root(a)];
    }
    void marge(int a,int b){
        a=root(a);
        b=root(b);
        if(siz[a]>siz[b])swap(a,b);
        par[a]=b;
        siz[b]+=siz[a];
    }
};
int main(){
    int n;
    cin>>n;
    vector<P> x(n),y(n);
    for(int i=0;i<n;i++){
        cin>>x[i].first>>y[i].first;
        x[i].second=i;
        y[i].second=i;
    }
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    priority_queue<PP,vector<PP>,greater<>> pq;
    for(int i=0;i<n-1;i++){
        pq.push(PP(x[i+1].first-x[i].first,P(x[i].second,x[i+1].second)));
        pq.push(PP(y[i+1].first-y[i].first,P(y[i].second,y[i+1].second)));
    }
    UnionFind uf(n);
    long long ret=0;
    for(int i=0;i<(n-1)*2;i++){
        PP pp=pq.top();
        pq.pop();
        if(uf.issame(pp.second.first,pp.second.second))continue;
        else {
            ret+=pp.first;
            uf.marge(pp.second.first,pp.second.second);
        }
    }
    cout<<ret<<endl;
}

Measured memory_bytes: 6516
#include <stdio.h>

void bubbleSort(int *,int);

int main(){

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

  bubbleSort(A,N);
  
  return 0;

}

void bubbleSort(int A[],int N){
  int flag=1,i,j,tmp,n=0;

  while(flag){
    flag=0;
    for(j=N-1;j>=1;j--){
      if(A[j]<A[j-1]) {
	tmp=A[j];
	A[j]=A[j-1];
	A[j-1]=tmp;
	flag=1;
	n++;
      }
    }
  }

  for(i=0;i<N;i++){
    printf("%d",A[i]);
    if(i<N-1) printf(" ");
  }
  printf("\n");
  printf("%d\n",n);
  
}

  

  

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

int main()
{
    string suits = "SHCD";
    bool cards[4][13] = {};
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        char suit;
        int lank;
        cin >> suit >> lank;
        cards[suits.find(suit)][lank - 1] = true;
    }

    for (int s = 0; s < 4; s++)
    {
        for (int l = 0; l < 13; l++)
        {
            if (!cards[s][l])
            {
                cout << suits[s] << " " << l + 1 << "\n";
            }
        }
    }

    return 0;
}



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

int main() {
  int n; cin >> n;
  vector<int> p(n), q(n);
  for (int i = 0; i < n; i++) cin >> p[i];
  for (int i = 0; i < n; i++) cin >> q[i];

  vector<int> s(n);
  for (int i = 0; i < n; i++) s[i] = i+1;
  int i = 0;
  int pidx = 0;
  int qidx = 0;
  do {
    bool pflag = true;
    for (int i = 0; i < n; i++) {
      if (s[i] != p[i]) pflag = false;
    }
    if (pflag) {
      pidx = i;
      break;
    } else i++;
  } while (next_permutation(s.begin(), s.end()));
  sort(s.begin(), s.end());
  i = 0;
  do {
    bool qflag = true;
    for (int i = 0; i < n; i++) {
      if (s[i] != q[i]) qflag = false;
    }
    if (qflag) {
      qidx = i;
      break;
    } else i++;
  } while (next_permutation(s.begin(), s.end()));

  cout << abs(pidx - qidx) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#define int long long

using namespace std;

int A[100010], n;

signed main() {
    scanf("%lld", &n);
    for(int i = 1; i <= n; i++) scanf("%lld", &A[i]);
    sort(A + 1, A + n + 1);
    if(n % 2 == 1) {
        int ans1 = 0;
        for(int i = n; i > n - n / 2; i--) ans1 += A[i] * 2;
        for(int i = 1; i < n - n / 2 - 1; i++) ans1 -= A[i] * 2;
        ans1 = ans1 - A[n - n / 2] - A[n - n / 2 - 1];
        int ans2 = 0;
        for(int i = n; i >= n - n / 2; i--) ans2 += A[i] * 2;
        for(int i = 1; i < n - n / 2; i++) ans2 -= A[i] * 2;
        ans2 = ans2 - A[n - n / 2] - A[n - n / 2 + 1];
        printf("%lld\n", max(ans1, ans2));
        return 0;
    } else {
        int ans = 0;
        for(int i = n; i > n / 2; i--) ans += A[i] * 2;
        for(int i = 1; i <= n / 2; i++) ans -= A[i] * 2;
        printf("%lld\n", ans - A[n / 2 + 1] + A[n / 2]);
        return 0;
    }
}

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

int main() {
  ll n;
  cin >> n;
  ll a[n], i, j;
  for(i = 0; i < n; i++) {
    cin >> a[i];
  }
  for(int i = 0; i < n; i++) {
    if(a[i] == 0) {
      cout << "0";
      return 0;
    }
  }
  long double ans = 0;
  for(i = 0; i < n; i++) {
    ans += log10(a[i]);
  }
  if(ans > 18) {
    cout << "-1";
    return 0;
  }
  ll final_ans = 1;
  for(i = 0; i < n; i++) {
    final_ans *= a[i];
  }
  if(final_ans > (ll)(1e18)) {
    final_ans = -1;
  }
  cout << final_ans;
}

Measured memory_bytes: 4580
#include<iostream>
#include<algorithm>
using namespace std;
int e[12];

bool check(){
  sort(e, e + 12);
  for ( int i = 0; i < 12; i += 4)
    if ( e[i] != e[i+3] ) return false;
  return true;
}

main(){
  for ( int i = 0; i < 12; i++ ) cin >> e[i];
  if ( check() ) cout << "yes" << endl;
  else cout << "no" << endl;
}




Measured memory_bytes: 3160
n = gets.to_i
h = gets.split.map(&:to_i)
ans = 0
count =0

(0..n-2).each do |i|
  if h[i] >= h[i+1]
    count += 1
  else
    if ans < count 
      ans = count
    end
    count = 0
  end
end

puts [count,ans].max

Measured memory_bytes: 8580
N = int(input())
X = list(map(int, input().split()))

nX  = sorted(X)
l = N-1

med_1 = nX[(l+1)//2] 
med_2 = nX[(l+1)//2-1]

for x in X:
    if x<med_1:
        print(med_1)
    else:
        print(med_2)
        

Measured memory_bytes: 25556
# -*- coding: utf-8 -*-
import sys


def get_num():
    return int(input())


def get_nums(n):
    res = [0 for _ in range(n)]
    for i in range(n):
        res[i] = int(input())
    return res


def get_numbers():
    return map(int, input().split())

n, m = get_numbers()

stores = list()
for _ in range(n):
    a, b = get_numbers()
    stores.append((a, b))

cost = 0
for a, b in sorted(stores, key=lambda x: x[0]):
    num = min(b, m)
    cost += num * a
    m -= num
    if m == 0:
        break

print(cost)


Measured memory_bytes: 58968
#include<bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp> 
// using namespace boost::multiprecision;
// #define int cpp_int
using namespace std;

#define fastio 			ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int 			long long
#define ll 				long long
#define ld 				long double
#define vi 				vector<int>
#define pii 			pair<int,int>
#define vpii 			vector< pair<int,int> >
#define uset			unordered_set
#define umap 			unordered_map
#define maxpq 			priority_queue<int>
#define minpq			priority_queue<int,vi,greater<int>()>

#define all(v) 			v.begin(),v.end()
#define part(v,s,e)		v.begin()+s,v.begin()+e
#define rev(v)			reverse(v.begin(),v.end())
#define sz(x)			(int)x.size()
#define def(v)			memset(v,-1,sizeof(v));
#define def0(v)			memset(v,0,sizeof(v));
#define minv(a)			*min_element(all(a))
#define maxv(a)			*max_element(all(a))
#define sumv(a)			accumulate(all(a),0)

#define	lb				lower_bound
#define	ub				upper_bound
#define	desc			greater<int>()
#define	pb				emplace_back
#define	mp				make_pair
#define	F				first
#define	S				second

#define	mod 			1000000007
#define	inf 			1000000000000000
#define infty			1000000000000000000LL
#define	md				998244353
#define	PI				acos(-1.0)
#define	endl 			"\n"
#define	rr				return
#define	br				cout<<"\n";

#define gcd(a,b)		__gcd(a,b)
#define lcm(a,b)		(a/(__gcd(a,b)))*b

#define setbits(x) 		__builtin_popcountll(x)
#define zerobits(x)		__builtin_ctzll(x)

#define ip(v)	 		for(auto& i:v)	cin>>i;
#define op(v) 			for(auto i:v)	cout<<i<<" ";cout<<endl;
#define deb(x) 			cout <<"Value of " #x << " : " << x << endl;



void solve()
{	

	int a,v;
	cin>>a>>v;
	
	int b,w;
	cin>>b>>w;

	int t;
	cin>>t;

	if((a+t*v)>=(b+t*w) and a<b)
	{
		cout<<"YES\n";
	}
	else if((a-t*v)<=(b-t*w) and a>b)
	{
		cout<<"YES\n";
	}
	else
	{
		cout<<"NO\n";
	}

}	

int32_t main()
{

	fastio
	cout<<setprecision(15)<<fixed;


	int t=1;
	// cin>>t;
	
	for(int i=1;i<=t;i++)
	{
		// cout<<"Case "<<i<<" : "<<endl;
		solve();
	}
	
	#ifndef ONLINE_JUDGE	
		cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
	#endif

	return 0;
}

Measured memory_bytes: 3652
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end

n,k=get_i
h=get_i

h.sort!.reverse!
sum=0
k=(n<k) ? n : k
k.times do|i|
  sum+=h[i]
end
res=h.inject(:+)
puts res<sum ? 0 : res-sum

Measured memory_bytes: 19832
#include<bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(),(x).end()
using namespace  std ;
typedef long l ;
typedef long long ll ;
typedef vector<int>vi ;
typedef vector<l>vl ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<int,int> pii ;
typedef pair<ll,ll> pll ;
long long power(long long k , long long n , long long m=1e9+7)
{
    long long res = 1;
    while(n)
    {
        if(n%2!=0)
        {
            res = (res*k)%m ;
        }
        k = (k*k)%m ;
        n = n/2 ;
    }
    return(res) ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    std::cout.unsetf ( std::ios::floatfield );//this and next line for floating precision upto 6
    std::cout.precision(10);
    ll a,b,c,d,x,i,j,n,t,m,k,y;
    double p,q,r,w,u ;
    string str = "",str1 = "" ;
    ll a1,a2,b1,b2 ;
    vll v ;
    cin>>a>>b>>c>>d>>a1>>k ;
    if(a1-a<=k)
    {
        cout<<"Yay!" ;
    }
    else
    {
        cout<<":(" ;
    }
}

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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

int main()
{
    string hoge;
    getline(cin, hoge);
    rep(i, hoge.length())
    {
        if ('a' <= hoge[i] && hoge[i] <= 'z')
        {
            hoge[i] -= ('a' - 'A');
        }
    }
    cout << hoge << endl;
}

Measured memory_bytes: 3044