akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;
#define MAXN 200000
#define ll long long
#define Trav(p) for(rint u = first[p], v; ~u; u = e[u].nex)
#define rint register int
#define gc() getchar()
inline int read(rint ans = 0, rint sgn = ' ', rint ch = gc())
{
	for(; ch < '0' || ch > '9'; sgn = ch, ch = gc());
	for(; ch >='0' && ch <='9';(ans*=10)+=ch-'0', ch = gc());
	return sgn-'-'?ans:-ans;
}
#define BUF_SIZE 1000000
#define _END fwrite(_Ob,1,_O-_Ob,stdout), _O = _Ob
#define Outc(a) (*_O++ = a)
char _Ob[BUF_SIZE+5], *_O = _Ob, _Os[25], *_Ot;
template <typename T> inline void Out(T x)
{
	if(!x){Outc('0'); return;} if(x < 0) Outc('-'), x = -x;
	for(_Ot = _Os; x; *_Ot++ = x%10+'0', x /= 10);
	for(; _Ot != _Os; Outc(*--_Ot)); if(_O-_Ob >= BUF_SIZE-50) _END;
}
int first[MAXN+5], sz[MAXN+5], mx[MAXN+5], o[MAXN+5], fa[MAXN+5], X[MAXN+5], sum, tot, top, rt, n, m; ll d[MAXN+5], ans; bool book[MAXN+5];
struct Edge{int to,nex,w; Edge(){} Edge(int _to, int _nex, int _w){to=_to,nex=_nex,w=_w;}}e[(MAXN<<1)+5];
struct E{int u,v; ll w; E(){} E(int _u, int _v, ll _w){u=_u,v=_v,w=_w;}}ed[(MAXN<<5)+5]; inline bool operator < (E a, E b){return a.w < b.w;}
inline void Add(int a, int b, ll w){e[tot] = Edge(b,first[a],w), first[a] = tot++, e[tot] = Edge(a,first[b],w), first[b] = tot++;}
void DFS_sz(int p, int fa){sz[p] = 1, mx[p] = 0; Trav(p) if(!book[v=e[u].to] && v-fa) DFS_sz(v,p), sz[p] += sz[v], mx[p] = max(mx[p],sz[v]);}
void DFS_rt(int p, int fa){(mx[p]=max(mx[p],sum-sz[p]))<mx[rt]?rt=p:0; Trav(p) if(!book[v=e[u].to] && v-fa) DFS_rt(v,p);}
void DFS_d(int p, int fa){o[++top] = p; Trav(p) if(!book[v=e[u].to] && v-fa) d[v] = d[p]+e[u].w, DFS_d(v,p);}
void DCT(int p)
{
	DFS_sz(p,0), sum = sz[p], rt = p, DFS_rt(p,0), p = rt, book[p] = true, d[p] = top = 0, DFS_d(p,0);
	rt = p, d[p] += X[p]; for(rint i = 2; i <= top; (d[o[i]]+=X[o[i]])<d[rt] ? rt = o[i] : 0, i++);
	for(rint i = 1; i <= top; ed[++m] = E(rt,o[i],d[rt]+d[o[i]]), i++); Trav(p) if(!book[v=e[u].to]) DCT(v);
}
inline int getf(int x){return x-fa[x] ? fa[x] = getf(fa[x]) : x;} inline bool Union(int x, int y){return (x=getf(x))-(y=getf(y)) ? fa[x] = y, true : false;}
int main()
{
	n = read(), memset(first+1,-1,n<<2); for(rint i = 1; i <= n; fa[i] = i, X[i++] = read());
	for(rint i = 2, u, v; i <= n; u = read(), v = read(), Add(u,v,read()), i++); DCT(1), sort(ed+1,ed+m+1);
	for(rint i = 1, c = ~-n; i <= m && n; Union(ed[i].u,ed[i].v) ? --c, ans += ed[i].w : 0, i++); printf("%lld\n",ans); return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n-1; i > 0; i--)
#define FOR(i, n, m) for(int i = n; i < (int)(m); i++)
#define PRINT(x) cout << x << endl
#define ALL(v) v.begin(), v.end()
#define INF (ll)1e18
#define PI 3.14159265358979

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

ll MOD = 1000000007;

int main()
{
    ll N, K;
    cin >> N >> K;

    vector<ll> a(N);
    REP(i, N) cin >> a[i];
    vector<ll> s(N);
    s[0] = a[0];
    REP(i, N-1) s[i+1] = s[i] + a[i+1];
    vector<ll> v;
    REP(i, N) {
        FOR(j, i, N) {
            if (i == 0) v.push_back(s[j]);
            else v.push_back(s[j] - s[i-1]);
        }
    }
    ll t = 45;
    ll ans = 0;
    REP(i, t) {
        ll n = 0;
        vector<ll> tmp;
        REP(j, v.size()) {
            if (v[j] & (1LL << (t-1-i))) {
                n++;
                tmp.push_back(v[j]);
            }
        }
        if (n >= K) {
            ans += (1LL << (t-1-i));
            v.clear();
            v.resize(tmp.size());
            REP(j, tmp.size()) v[j] = tmp[j];
        }
    }
    PRINT(ans);
    return 0;
}


Measured memory_bytes: 6132
#include <stdio.h>
int main(void) {
    int M,D;
    int da,db;
    scanf("%d",&M);
    scanf("%d",&D);
    int i,m;
    int C;
    C=0;
    for(m=1;m<=M;m++){
    for(i=1;i<=D;i++){
        da=i%10;
        db=i/10;
       if((m==da*db)&&(da>=2)&&(db>=2)){
       	C++;
       }
    }
    }
    printf("%d\n",C);
    return 0;
}

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

int main()
{
    int N, M;
    int cnt = 0;
    pair < int , int > data[100005];

    cin >> N >> M;
    for ( int i = 0; i < M; i++ ) {
        cin >> data[i].second >> data[i].first;
    }
    sort(data, data + M);

    int ma = -1;
    for ( int i = 0; i < M; i++ ) {
        if ( ma <= data[i].second ) {
            ma = data[i].first;
            cnt++;
        }
    }
    cout << cnt << endl;
    return ( 0 );
}


Measured memory_bytes: 1024
import numpy as np


def main():
    n, m = map(int, input().split())
    As = [list(input()) for _ in range(n)]
    Bs = [list(input()) for _ in range(m)]

    As_arr = np.array(As)
    Bs_arr = np.array(Bs)
    for i in range(n-m+1):
        for j in range(n-m+1):
            xs, xe = i, i+m
            ys, ye = j, j+m
            if np.all(As_arr[ys:ye, xs:xe] == Bs_arr):
                print('Yes')
                exit()
    print('No')


if __name__ == "__main__":
    main()


Measured memory_bytes: 21220
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#define rep(i, n) for(i = 0; i < n; i++)
//#define int long long
using namespace std;

int power(int a, int n) {
	int ret = 1;
	for (int i = 0; i < n; i++) {
		ret *= a;
	}
	return ret;
}

int n;
vector<int> oks;
int dp[100001];

signed main() {
	int i, j;
	
	cin >> n;
	for (i = 0; power(6, i) <= n; i++) oks.push_back(power(6, i));
	for (i = 0; power(9, i) <= n; i++) oks.push_back(power(9, i));
	
	for (i = 0; i <= n; i++) dp[i] = 114514;
	
	dp[0] = 0;
	for (i = 0; i < n; i++) {
		for (j = 0; j < oks.size(); j++) {
			int nxt = i + oks[j];
			if (nxt > n) continue;
			dp[nxt] = min(dp[nxt], dp[i] + 1);
		}
	}
	
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 640
a = list(input())
b = list(input())
c = list(input())
s = []   #どれのカードを取るかの指示
s.append(a[0])
del a[0]
for i in range(len(a)+len(b)+len(c)+2): #最大のターン数
    if s[i] == "a":
        if a == []:
            print("A")
            break
        else:
            s.append(a[0])
            del a[0]
    elif s[i] == "b":
        if b == []:
            print("B")
            break
        else:           
            s.append(b[0])
            del b[0]
    elif s[i] == "c":
        if c == []:
            print("C")
            break
        else:            
            s.append(c[0])
            del c[0] 

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int N, Q;
	string S;
	cin >> N >> Q >> S;
	vector<int> l(Q);
	vector<int> r(Q);
	for (int i = 0; i < Q; i++) {
		cin >> l[i] >> r[i];
	}
	vector<int> rec(N);
	int sum = 0;
	for (int i = 0; i < S.length() - 1; i++) {
		if (S[i] == 'A' && S[i + 1] == 'C') {
			sum++;
		}
		rec[i + 1] = sum;
	}
	for (int i = 0; i < Q; i++) {
		cout << rec[r[i] - 1] - rec[l[i] - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 2176
import numpy as np
words = lambda t : list(map(t, input().split()))

n = int(input())
cs = []
for i in range(n):
    s,p = input().split()
    cs.append((s,(-1) * int(p),i+1))

cs = sorted(cs)
for (s,p,i) in cs:
    print(i)


Measured memory_bytes: 21532
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

using fint64 = int_fast64_t;
template<fint64 MOD>
struct ModInt {
	fint64 x;
	ModInt():x(0){}
	ModInt(fint64 x):
		x(x>=0?x%MOD:(MOD-(-x)%MOD)%MOD)
		{}
	// 負号
	ModInt operator -() const{
		return ModInt(-x);
	}
	// 加算
	ModInt &operator +=(const ModInt &rhs){
		x+=rhs.x;
		if(x>=MOD) x-=MOD;
		return (*this);
	}
	ModInt operator +(const ModInt &rhs) const{
		return ModInt(*this)+=rhs;
	}
	// 減算
	ModInt &operator -=(const ModInt &rhs){
		x+=MOD-rhs.x;
		if(x>=MOD) x-=MOD;
		return (*this);
	}
	ModInt operator -(const ModInt &rhs) const{
		return ModInt(*this)-=rhs;
	}
	// 乗算
	ModInt &operator *=(const ModInt &rhs){
		x*=rhs.x;
		if(x>=MOD) x%=MOD;
		return (*this);
	}
	ModInt operator *(const ModInt &rhs) const{
		return ModInt(*this)*=rhs;
	}
	// 除算
	ModInt &operator /=(const ModInt &rhs){
		(*this)*=rhs.inverse();
		return (*this);
	}
	ModInt operator /(const ModInt &rhs) const{
		return ModInt(*this)/=rhs;
	}
	// 等号
	bool operator ==(const ModInt &rhs){
		return x==rhs.x;
	}
	bool operator !=(const ModInt &rhs){
		return x!=rhs.x;
	}
	// 累乗
	ModInt pow(fint64 n) const{
		fint64 tmp=x;
		fint64 ret=1;
		while(n>0){
			if(n&1) ret=ret*tmp%MOD;
			tmp=tmp*tmp%MOD;
			n>>=1ll;
		}
		return ModInt(ret);
	}
	// 逆元
	ModInt inverse() const{
		fint64 a=x,b=MOD,s=1,t=0;
		while(b>0){
			fint64 u=a/b;
			a-=u*b;
			s-=u*t;
			swap(a,b);
			swap(s,t);
		}
		return ModInt(s);
	}
	// 入出力
	friend istream &operator >>(istream &lhs,ModInt<MOD> &rhs){
		fint64 x; lhs>>x;
		rhs=ModInt<MOD>(x);
		return lhs;
	}
	friend ostream &operator <<(ostream &lhs,const ModInt<MOD> &rhs){
		return lhs<<rhs.x;
	}
};

using mint = ModInt<LMOD>;
mint dp[3010][3010];
int main() {
	int n, s; cin >> n >> s;
	int a[n]; rep(i,n) cin >> a[i];
	dp[0][0] = 1;
	for(int i = 1; i <= n; ++i) {
		for(int j = 0; j <= s; ++j) {
			dp[i][j] += dp[i - 1][j];
			if(j - a[i - 1] >= 0) {
				if(j - a[i - 1] == 0) {
					if(j == s) {
						dp[i][j] += (dp[i - 1][j - a[i - 1]] + (i - 1)) * (n - i + 1);
					} else {
						dp[i][j] += dp[i - 1][j - a[i - 1]] + (i - 1);
					}
				} else {
					if(j == s) {
						dp[i][j] += dp[i - 1][j - a[i - 1]] * (n - i + 1);
					} else {
						dp[i][j] += dp[i - 1][j - a[i - 1]];
					}
				}
			}
		}
	}
	cout << dp[n][s] << '\n';
	return 0;
}

Measured memory_bytes: 71040
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main()
{
  long long int N;
  scanf("%lld", &N);

  long long int A[N], B[N];
  for(int i = 0; i < N; ++i) scanf("%lld", &A[i]);
  for(int i = 0; i < N; ++i) scanf("%lld", &B[i]);

  vector<int> bd;
  long long int m = 0;
  long long int ans = 0;
  for(long long int i = 0; i < N; ++i){
    if(A[i] < B[i]){
      m += B[i]-A[i];
      ++ans;
    }else if(A[i] > B[i]){
      bd.emplace_back(A[i]-B[i]);
    }
  }

  if(m == 0){
    cout << "0\n";
    return 0;
  }
  
  sort(begin(bd), end(bd), greater<long long int>());

  for(const auto& e : bd){
    if(m >= e){
      m -= e;
      ++ans;
    }else{
      cout << ans+1 << endl;
      return 0;
    }
  }

  cout << "-1\n";
}

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

int main(){
	int d;
	cin >> d;
	if(d == 25) cout << "Christmas" << endl;
	else if(d == 24) cout << "Christmas Eve" << endl;
	else if(d == 23) cout << "Christmas Eve Eve" << endl;
	else if(d == 22) cout << "Christmas Eve Eve Eve" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define forn(i, n) for (llong i = 0ll; i < (llong) n; ++i)
#define fornn(i, l, r) for (llong i = (llong) l; i < (llong) r; ++i)
#define size(x) ((int) (x.size()))
 
using namespace std;
 
typedef long long llong;
const llong inf = (llong) 1e+9 + 7ll;
const llong linf = (llong) 1e+18 + 7ll;
const long double eps = (long double) 1e-9;
const long double pi = acosl((long double) -1.0);
const int alph = 26;

mt19937 mrand(random_device{} ()); 

template<typename T, typename U> inline llong umin(const T& a, const U& b) { return a < b ? a : b; }
template<typename T, typename U> inline llong umax(const T& a, const U& b) { return a > b ? a : b; }
 
static char buff[(int) 2e6 + 17]; // reads std::string
const int maxn = (int) 1e5 + 17;

struct item
{
	int a, b, c;
	item() { }
	item(int a, int b, int c) : a(a), b(b), c(c) { }
};

int x, y, z, n;
item a[maxn];
llong L[maxn], R[maxn];

bool read()
{
	if (scanf("%d", &x) != 1)
		return false;

	scanf("%d %d", &y, &z);
	n = x + y + z;

	forn (i, n)
		scanf("%d %d %d", &a[i].a, &a[i].b, &a[i].c);

	return true;
}

bool cmp(item a, item b) { return a.a - a.b < b.a - b.b; }

void solve()
{
	llong C = 0, ans = -linf;

	forn (i, n)
	{
		C += a[i].c;
		a[i].a -= a[i].c;
		a[i].b -= a[i].c;
		a[i].c = 0;
	}

	sort(a, a + n, cmp);
	priority_queue<int, vector<int>, greater<int> > Q;
	llong sum = 0;

	forn (i, n)
	{
		Q.push(a[i].b);
		sum += a[i].b;

		if (size(Q) > y)
			sum -= Q.top(), Q.pop();

		if (size(Q) == y)
			L[i + 1] = sum;
	}

	while (!Q.empty()) Q.pop();
	sum = 0;

	for (int i = n - 1; i >= 0; --i)
	{
		Q.push(a[i].a);
		sum += a[i].a;

		if (size(Q) > x)
			sum -= Q.top(), Q.pop();

		if (size(Q) == x && i >= y)
			ans = max(ans, sum + L[i]);
	}

	printf("%lld\n", ans + C);
}

int main()
{
#if SEREZHKA
	freopen("file.in", "r", stdin);
#endif

	while (read())
		solve();

	return 0;
}


Measured memory_bytes: 2812
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vd(T) vector<vector<T>>
#define v(T) vector<T>
#define mod (ll)(1e9+7)
#define pp(T) pair<T,T>
#define pb push_back
#define mp make_pair
#define NN 100005
#define IO ios_base::sync_with_stdio(NULL),cin.tie(0),cout.tie(0)
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define DEBUG cout<<"***********DEBUGGING***********"<<endl
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; 
ll power(ll a,ll b){ if(b==0) return 1; ll s=power(a,b/2); s*=s;if(b&1) return s*a; return s;}
ll powermod(ll a,ll b,ll m){ if(b==0) return 1; ll s=power(a,b/2);s*=s; s%=m; if(b&1) return (s*a)%m; return s;}
inline int add(ll a,ll b,ll m=0){
    if(m==0) return a+b;
    return (a%m+b%m)%m;
}

inline int sub(ll a,ll b ,ll m=0){
    if(m==0) return a-b;
    return ((a%m-b%m)%m+m)%m;
}

inline int mul(ll a,ll b,ll m=0){
    if(m==0)return (a*b);
    return ((a%m)*(b%m))%m;
}

inline int div(ll a,ll b,ll m=0){
    if(m==0) return a/b;
    return ((a%m)*(powermod(a,b,m-2)%m))%m;
}

bool isopen(char c){
    return ((c=='(')||(c=='{')||(c=='['));
}

ll longest_balanced_parenthesis(string a,ll n){
    stack<char> s;
    ll start=0;
    ll ans=0,m=0;
    for(ll i=0;i<n;i++){
        if(isopen(a[i])){
            s.push(a[i]);
        }
        else{
            if(isopen(a[i])|| s.empty()){
                m=max(m,ans);
                continue;
            }
            else{
                s.pop();
                ans+=2;
                m=max(ans,m);
            }
        }
    }

    return m;

}

ll setup_k(ll *a,ll k){
  ordered_set x;
  // Now , insert and then check number of integers less than k by just using x.order_of_key(k+1)
}

int main() {

    IO; 

    ll n;
    cin>>n;
    ll ans=0;
    ll a=n%11;
    ans+=n/11;
    ans*=2;
    if(a<=6)ans++;
    else ans+=2;
    if(a==0) ans--;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;


int main(){
  int n;
  cin >> n;
  vector<ll> a(n),b(n);
  rep(i,n){ cin >> a[i]; }
  priority_queue<pair<ll,int>> q;
  rep(i,n){ cin >> b[i]; q.push({b[i],i}); }
  ll cnt = 0;
  while(!q.empty()){
    ll p; int pos;
    tie(p,pos) = q.top(); q.pop();
    int posl = pos-1; if(posl<0) posl+=n;
    int posr = pos+1; if(posr>=n) posr-=n;
    ll tmp = (b[pos]-a[pos])/(b[posl]+b[posr]);
    b[pos] -= (b[posl]+b[posr])*tmp;
    cnt+=tmp;
    if(a[pos]!=b[pos] && tmp){ q.push({b[pos],pos}); }
  }
  if(a==b){
    cout << cnt << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int r;
  cin >> r;
  cout << 3 * r * r << endl;
  return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc173/tasks/abc173_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> v(N);
    REP(i, N) { cin >> v[i]; }
    sort(ALLR(v));
    int sum = 0;
    FOR(i, 1, N) { sum += v[i / 2]; }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 4776
package main

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

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	S := readInt()
	x := S / 100
	y := S % 100
	//eprintln(x, y)

	if mm(x) && yy(y) && yy(x) && mm(y) {
		println("AMBIGUOUS")
		return
	}
	if yy(x) && mm(y) {
		println("YYMM")
		return
	}
	if mm(x) && yy(y) {
		println("MMYY")
		return
	}
	println("NA")
}

func mm(a int) bool {
	if 1 <= a && a <= 12 {
		return true
	}
	return false
}

func yy(a int) bool {
	return true
}

// -----------------------------------------------------------------------------


Measured memory_bytes: 640
A, B, K = map(int,input().split())
while K > 0:
    if A%2==1:
        A -= 1
    B += A // 2
    A //= 2
    K -= 1
    if K <= 0:
        break

    if B%2==1:
        B -= 1
    A += B // 2
    B //= 2
    K -= 1
    
print(A, B)


Measured memory_bytes: 3060
s = input()
f1 = ('N' in s and 'S' in s) or ('N' not in s and 'S' not in s)
f2 = ('W' in s and 'E' in s) or ('W' not in s and 'E' not in s)
f3 = f1 and f2
if f3:
    print("Yes")
else:
    print("No")

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

int main(){
    int k,n;
    int sum = 0;
    cin >> n >> k;
    int p[n];

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

Measured memory_bytes: 3628
import math

def computeGCD(x, y):
    if x > y:
        small = y
    else:
        small = x
    for i in range(1, small+1):
        if((x % i == 0) and (y % i == 0)):
            gcd = i
    return gcd
A, B = map(int, input().split())

print( (A*B)//computeGCD(A, B))

Measured memory_bytes: 3060
/*
    A story which will never end
    A story which never began
*/

#include <bits/stdc++.h>

using namespace std;

#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl '\n'
#define ll long long

int main(){
    int n, tim;
    cin>>n>>tim;
    int c[n], t[n];
    for(int i=0;i<n;++i)cin>>c[i]>>t[i];

    int res = 1e9;
    for(int i=0;i<n;++i){
        if(t[i] <= tim)res = min(res, c[i]);
    }
    if(res == (1e9))
        cout<<"TLE"<<endl;
    else cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
a = list(range(n))

ans = 0

for i in range(k,n+2):
    min1 = 0.5*i*(i-1)
    max1 = 0.5*(n*(n+1)-(n-i)*(n-i+1))
    sub1 = max1 - min1+1
    ans += sub1


print(int(ans%(10**9+7)))


Measured memory_bytes: 16524
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")
    };
}
 fn main() {
        input! {
             n: i64,
            }
        if n % 10 == 3 {
            println!("bon");
        }
         else if n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 ==8 {
            println!("pon");
            }
        else{
            println!("hon");
        }
    }
    //nを入力後ctrl+Z

Measured memory_bytes: 2092
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<string> s(n);
    map<string,int> m;
    for(int i=0; i<n; i++){
        cin>>s[i];
        m[s[i]]++;
    }
    cout<<"AC x "<<m["AC"]<<endl;
    cout<<"WA x "<<m["WA"]<<endl;
    cout<<"TLE x "<<m["TLE"]<<endl;
    cout<<"RE x "<<m["RE"]<<endl;

}

Measured memory_bytes: 6408
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){
  int x,y;
  cin>>x>>y;
  int a[] = {0,1,3,1,2,1,2,1,1,2,1,2,1};
  if(a[x]==a[y]) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int c,n;
main(){
	cin>>n;
	for(;n;n--)
	{
		if(n%2<1)continue;
		int m=0;
		for(int j=1;j<=n;j++)m+=n%j<1;
		if(m==8)c++;
	}
	cout<<c<<endl;
}


Measured memory_bytes: 256
import collections
n,m=map(int,input().split())
par=[i for i in range(n)]
def find(x):
    if par[x]==x:
        return x
    else:
        par[x]=find(par[x])
        return par[x]
for _ in range(m):
    a,b=map(int,input().split())
    aa=find(a-1)
    bb=find(b-1)
    
    par[aa]=bb


for i in range(n):
    par[i]=find(i)

print(len(collections.Counter(par))-1)

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

signed main(){
  int A, B;
  cin >> A >> B;
  
  int ans = 0;
  for( int i = 1; i < A; i++ ) ans += i;
  
  if( B > 1 ){
    ans += (B*(B-1))/2;
  }
  cout << ans << endl;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

const int mod = 1000000007;

int main() {
  int n, k;
  cin >> n >> k;
  int ans = k;
  ans *= pow(k - 1 ,n - 1);
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 384
S = input()

flag = True

for i in range(len(S) // 4):
    if(S[i] != S[len(S) // 2 - 1 - i]):
        flag = False

for i in range(len(S) // 2):
    if(S[i] != S[-i-1]):
        flag = False
if (flag):
    print("Yes")
else:
    print("No")



Measured memory_bytes: 2940
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <functional>
#include <vector>
#include <queue>
#include <map>
#include <stack>

using namespace std;

typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)

int const N_MAX = 200000;

int n;
int a[N_MAX + 1];
vector<int> b_o;
vector<int> b_e;

void show(vector<int> x, vector<int> y) {
  while (!x.empty()) {
    printf("%d ", x.back());
    x.pop_back();
  }
  for (int z : y) {
    printf("%d ", z);
  }
  printf("\n");
}

int main() {
  cin >> n;
  rep(i, n) scanf("%d", &a[i]);

  bool o = true;
  rep(i, n) {
    if (o) {
      b_o.push_back(a[i]);
    } else {
      b_e.push_back(a[i]);
    }
    o = !o;
  }
  if (o) {
    show(b_e, b_o);
  } else {
    show(b_o, b_e);
  }
}


Measured memory_bytes: 4724
import sys

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

if __name__ == "__main__":
    n = int(input())
    d, x = map(int, input().split())
    al = [int(input()) for i in range(n)]

    sum = 0
    for a in al:
        i = 0
        while True:
            if i * a + 1 > d:
                break

            sum += 1
            i += 1

    print(sum+x)


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

int main(){
  int n; cin >> n;
  vector<float> v(n);
  float tmp, ans;
  for(int i=0; i<n; i++){
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  tmp = v[0];
  for(int i=1; i<n; i++){
    tmp = (tmp + v[i]) / 2.0;
  }
  cout << tmp << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <functional>
#include <tuple>
#include <climits>
#include <algorithm>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <numeric>
#include <map>
#include <cmath>
#include <cstdlib>
#include <iomanip>

using namespace std;

int main()
{
    int N, sum = 0;
    cin >> N;

    for(int i=1; i<=N; i++)
        sum += i;
    cout << sum << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,M;
    cin >> N >> M;

    const int NMMAX = 50;
    int A[NMMAX], B[NMMAX];

    for (int i=0;i<M;++i){ 
        cin >> A[i] >> B[i];
    }

    int road[NMMAX];
    for (int i=0;i<N;++i){
        road[i] = 0; 
    }

    for (int i=0;i<M;++i){ 
        road[A[i] - 1] += 1; 
        road[B[i] - 1] += 1;
    }

    for (int i=0;i<N;++i){ 
        cout << road[i] << endl;
    }

    return 0;
}




Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a;
	int b;
	
	scanf("%d",&a);
	scanf("%d",&b);
	
	if(a==1 && b==2 || a==2 && b==1){
		printf("3");
	}
	else if(a==2 && b==3 || a==3 && b==2){
		printf("1");
	}
	else if(a==1 && b==3 || a==3 && b==1){
		printf("2");
	}
	else{
		printf("error");
	}

	return 0;
}

Measured memory_bytes: 3128
n = int(input())
a = [int(x) for x in input().split()]
for i in range(n):
    k, j = a[i], i-1
    while j >= 0 and a[j] > k:
        a[j+1], j = a[j], j-1
    a[j+1] = k
    print(*a)

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


string S, T;


void input() {
    cin >> S >> T;
}


int main() {
    input();
    int n = S.size();
    string ans = "No";
    rep(i, n) {
        S = S.back() + S.substr(0, n - 1);
        if (S == T) ans = "Yes";
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    while(cin>>a>>b>>c)
    {
        if(a<b) swap(a,b);
        if(a<c) swap(a,c);
        if(a==b+c) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int u[2222222];
int main() {
  int n,m;
  cin >> n >> m;
  int a[m];
  for(int i=0;i<m;i++)cin>>a[i];
  for(int i=m-1;i>=0;i--) {
    if(!u[a[i]]) {
      u[a[i]]=1;
      cout<<a[i]<<endl;
    }
  }
  for(int i=1;i<=n;i++)if(!u[i])cout<<i<<endl;
  return 0;
}


Measured memory_bytes: 4236
import numpy as np

n, x = map(int, input().split())
l = np.array(list(map(int, input().split())))
s = np.zeros(n + 1)

for i in range(1, n + 1):
    s[i] = s[i - 1] + l[i - 1]

print(len(np.where(s <= x)[0]))


Measured memory_bytes: 12396
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {
	static PrintWriter out;
	static StringBuilder sb;
	static int n, k;
	static long mod = 1000000007;
	static int[][] memo;
	static String s;
	static HashSet<Integer> nodes;
	static ArrayList<Integer>[] ad, tree;
	static boolean[] vis, taken;
	static int[] a;
	static TreeSet<Long> al;
	static long[] val;
	static ArrayList<String> aa;
	static char[] b;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
		int n=sc.nextInt();
		ad=new ArrayList[n];
		for(int i=0;i<n;i++)
			ad[i]=new ArrayList<>();
		for(int i=1;i<n;i++)
			ad[sc.nextInt()-1].add(i);
		for(int i=0;i<n;i++)
			System.out.println(ad[i].size());
		out.flush();
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

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

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

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

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

		public int[] nextArrInt(int n) throws IOException {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextArrLong(int n) throws IOException {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

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

using namespace std;
const int MAXN = 2e5 + 5;

vector<int> e[MAXN];

int main(int argc, char* argv[]) {
    int n;
    scanf("%d", &n);
    long long ans = 1LL * n * (n + 1) * (n + 2) / 6;
    for (int i = 1; i < n; i++) {
        int u, v;
        scanf("%d %d", &u, &v);
        if (u > v) swap(u, v);
        ans -= 1LL * u * (n - v + 1);
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 8504
using System;

namespace practise
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] num = new int[10];
            for (int i = 0; i < num.Length; i++)
            {
                num[i] = int.Parse(Console.ReadLine());
            }
            Array.Sort(num);
            Array.Reverse(num);
            for (int j = 0; j < 3; j++)
            {
                Console.WriteLine(num[j]);
            }
        }
    }
}

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

#define pb push_back
#define ff first
#define ss second
#define sz(x) (ll)x.size()

typedef long long ll;
typedef pair<int, int> pii;

const int MAXN = 2 * 100 * 1000 + 17;

ll n, a[MAXN], k, zer;
vector<ll> big, sml;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		if (a[i] < 0)
			sml.pb(a[i]);
		else if (a[i] > 0)
			big.pb(a[i]);
		else
			zer++;
	}
	sort(sml.begin(), sml.end());
	sort(big.begin(), big.end());
	if (k <= sz(sml) * sz(big)) {
		ll l = -1e18, r = 0;
		while (l + 1 < r) {
			ll mid = l + r >> 1, cnt = 0;
			for (auto i : big) {
				ll x = mid / i;
				cnt += upper_bound(sml.begin(), sml.end(), x - 1) - sml.begin();
			}
			if (cnt < k)
				l = mid;
			else
				r = mid;
		}
		cout << l << endl;
		return 0;
	}
	k -= sz(sml) * sz(big);
	if (k <= zer * (n - zer) + zer * (zer - 1) / 2)
		return cout << 0 << endl, 0;
	k -= zer * (n - zer) + zer * (zer - 1) / 2;
	for (int i = 0; i < sml.size(); i++)
		sml[i] = -sml[i];
	sort(sml.begin(), sml.end());
	ll l = 1, r = 1e18 + 1;
	while (l + 1 < r) {
		ll mid = l + r >> 1, cnt = 0;
		for (int i = 0; i < big.size(); i++) {
			ll x = (mid + big[i] - 1) / big[i];
			ll ind = upper_bound(big.begin(), big.end(), x - 1) - big.begin();	
			ind -= (ind > i);
			cnt += ind;
		}
		for (int i = 0; i < sml.size(); i++) {
			ll x = (mid + sml[i] - 1) / sml[i];
			ll ind = upper_bound(sml.begin(), sml.end(), x - 1) - sml.begin();
			ind -= (ind > i);
			cnt += ind;
		}
		cnt /= 2;
		if (cnt < k)
			l = mid;
		else
			r = mid;
	}
	cout << l << endl;
	return 0;
}


Measured memory_bytes: 3572
#include<iostream>
#include<algorithm>
#include<string> 
#include<map>
#include<set>
#include<vector>
#include<string.h>
#include<math.h>
#include<stdio.h>
#include<queue>
#include<utility>
#include<cstdio>
#include<cstring>
#define fo(i,w,n) for(int i=(int) w;i<(int) n;i++)
#define qui queue<int>
#define vit vector<int>
#define ll long long 
#define pb push_back
using namespace std;
bool prime(int x){
	fo(i,2,x)if(x%i==0)return false;
	return true;
}
int main()
{int n,k=0;cin>>n;
for(int i=17;;i+=10){
	if(k==n)break;
	if(prime(i))cout<<i<<" ",k++;
}
system("pause");
return 0;
}

Measured memory_bytes: 504
// ABC067_A.cpp : Defines the entry point for the console application.
//

#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
	int n, k, x, y;
	cin >> n;
	cin >> k;
	cin >> x;
	cin >> y;

	if (n > k) {
		cout << k * x + (n - k) * y << endl;
	}
	else {
		cout << n * x << endl;
	}
	
	return 0;
}



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

int main(){
	for(int i=0;i<9;i++){
		for(int j=0;j<9;j++){
			int a=(i+1)*(j+1);
				cout<<i+1<<"x"<<j+1<<"="<<a<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1116
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define MOD_Q 998244353
#define PI 3.14159265358979
#define ll long long
using namespace std;

int main()
{
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int count = 0;
	while (a >= b) {
		b *= 2;
		count++;
	}
	while (b >= c) {
		c *= 2;
		count++;
	}
	
	printf("%s", count > k ? "No" : "Yes");


	return 0;
}


Measured memory_bytes: 3724
#include <iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

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

int main() {
    int D;
    cin >> D;
    if (D == 25) {
        cout << "Christmas" << endl;
    }
    else if (D == 24) {
        cout << "Christmas Eve" << endl;
    }
    else if (D == 23) {
        cout << "Christmas Eve Eve" << endl;
    }
    else if (D == 22) {
        cout << "Christmas Eve Eve Eve" << endl;
    }
}

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

int main(){
    string s;
    cin >> s;
    ll ans = 99999;
    rep(i, 26){
        char ch = i+'a';
        ll prev = 0, m = 0;
        bool z = true;
        rep(j, s.length()){
            if(s[j] == ch){
                if(z) m = max(m, j - prev);
                else m = max(m, j - prev - 1);
                z = false;
                prev = j;
            }
        }
        if(m < s.length()-prev-1) m = s.length()-prev-1;
        
        ans = min(ans, m);
        //printf("%c %lld\n", ch, m);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i,n) for(long long i=0;i<n;i++)
#define SFOR(i,a,b) for(long long i=a;i<b;i++)
#define RFOR(i,a,b) for(long long i=b;i>a;i--)
#define elif(a) else if(a)
#define INF INT_MAX
#define F first
#define S second
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s,t;
  cin>>s>>t;
  int ans=0;
  FOR(i,3){
    if(s[i]==t[i]) ans++;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
int main() {
    int a,b;
    cin >> a >> b;
    
    vector<vector<int> > list(a, vector<int>(b));
    for(int i = 0; i<a; i++) {
        for(int j = 0; j<b; j++) {
            cin >> list[i][j];
        }
    }

    int res = 0;
    for(int i = 0; i<a; i++) {
        int wsum = 0;
        for(int j = 0; j<b; j++) {
            cout << list[i][j] << " ";
            wsum += list[i][j];
        }
        cout << wsum << endl;
        res += wsum;
    }
    for(int j = 0; j<b; j++) {
        int hsum = 0;
        for(int i = 0; i<a; i++) {
            hsum += list[i][j];
        }
        cout << hsum << " ";
    }
    cout << res << endl;
}


Measured memory_bytes: 3124
#include <stdio.h>
#define MAX 100000

int partition(int *,int,int);

int main()
{
  int i,a[MAX],n,x,k;

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

  k = partition(a,1,n);

  for(i=1 ; i<=n ; i++)
  {
    if(i!=k && i!=n)printf("%d ",a[i]);
    else if (i==k)printf("[%d] ",a[i]);
    else if(i== n) printf("%d",a[i]);
  }
  printf("\n");

  return 0;
}

int partition(int *A,int p,int r)
{
  int j,n,m,x,i;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++)
  {
    if(A[j]<=x)
    {
      i=i+1;
      n=A[i];
      A[i]=A[j];
      A[j]=n;
    }
  }
  m=A[i+1];
  A[i+1]=A[r];
  A[r]=m;
  return i+1;
}



Measured memory_bytes: 2084
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

void makePrimeNumber(int N, vector<bool>& prime) // 0ツ暗按湘」Nツ暗按可コツづ個青ョツ青板つゥツづァツ素ツ青板づーツ探ツつキ
{
    prime.assign(N+1, true);
    prime [0] = prime[1] = false;
    for(int i=2; i*i<=N; i++){
        if(prime[i]){
            for(int j=i; i*j<=N; j++){
                prime[i*j] = false;
            }
        }
    }
}

int main()
{
    vector<bool> prime;
    makePrimeNumber(10000000, prime);
    vector<int> ret;
    for(int i=13; i<=10000000; ++i){
        if(prime[i] && prime[i-2] && prime[i-6] && prime[i-8])
            ret.push_back(i);
    }

    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        cout << *(upper_bound(ret.begin(), ret.end(), n) - 1) << endl;;
    }
}

Measured memory_bytes: 0
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
int n;
ll ans = 0, a[300000], b[60] = {};
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
    for (int j = 0; j < 60; j++) {
      if (a[i] & (1LL << j)) {
        b[j]++;
      }
    }
  }
  for (int i = 0; i < 60; i++) {
    ll x = (1LL << i);
    x %= MOD;
    x *= b[i];
    x %= MOD;
    x *= ((ll)n - b[i]);
    x %= MOD;
    ans += x;
    ans %= MOD;
  }
  printf("%lld\n", ans);
}

Measured memory_bytes: 2560
import java.util.*
import kotlin.collections.ArrayList

fun main(args: Array<String>) {
    val scan = Scanner(System.`in`)
    var kotlin=scan.nextLine().toInt()
    var arr = scan.nextLine().split(" ").map{ it.trim().toInt() }.toTypedArray()
    var ans = arr[0]
    for(i in 1..arr.size-1)
    {
        ans= ans.xor(arr[i])
    }

    for(x in arr)
    {
        var z= ans.xor(x)
        print("$z ")
    }
}


Measured memory_bytes: 87556
#include<stdio.h>

int main(){
	int n;
	int i;
	int input;
	int car;
	int max = 0;

	scanf("%d %d",&n,&car);
	max = car;

	for(i = 0; i < n; i++){
		scanf("%d",&input);
		car += input;
		scanf("%d",&input);
		car -= input;
		if(car < 0){
			max = 0;
			break;
		}
		if(max < car){
			max = car;
		}
	}
	printf("%d\n",max);

	return 0;
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintStream out = new PrintStream(System.out);
        int N = sc.nextInt();

        out.println(N*800-(N/15)*200);
        

        sc.close();
    }
}

Measured memory_bytes: 21844
n,y=map(int,input().split())

for i in range(n+1):
    for j in range(n-i+1):
        if 10000*i + 5000*j + 1000*(n-i-j)==y:
            print(i,j,n-i-j)
            exit()

print("-1 -1 -1")


Measured memory_bytes: 2940
#include <stdio.h>
#include <string.h>
 
int main(void)
{
    int n, k;
    scanf("%d %d", &n, &k);
    int data[n];
    for (int i = 0; i < n; i++)
    {
        data[i] = 0;
    }
 
    int d;
    for (int i = 0; i < k; i++)
    {
        scanf("%d", &d);
        for (int j = 0; j < d; j++)
        {
            int a;
            scanf("%d", &a);
            data[a - 1]++;
        }
    }
 
    int count = 0;
    for (int i = 0; i < n; i++)
    {
        if (data[i] == 0)
        {
            count++;
        }
    }
 
    printf("%d", count);
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, m;
string s;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> s;
	n = s.size();
	ll ans = 0;
	rep(i, 1, n/2){
		if(s[i-1] != s[n-i]){///
			ans++;
		}
	}
	print(ans)
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;

int main(){
	std::vector<int> v;
	int n = 1;
	cin >> n;
	int i, j;
	cin >> i;
	int count = 0;
	for (int k = 1; k < n; k++) {
		cin >> j;
		if (i >= j) {
			count++;
		} else {
			v.push_back(count);
			count = 0;
		}
		i = j;
	}
	v.push_back(count);

	cout << *std::max_element(v.begin(), v.end());
	return 0;
}

Measured memory_bytes: 892
phrase = input()

words_list = ["dream", "dreamer", "erase", "eraser"]
reversed_words_list = [ word[::-1] for word in words_list ]
reversed_phrase = phrase[::-1]

can1 = True
for i in range(len(reversed_phrase)):
    can2 = False
    if len(reversed_phrase) == 0:
        can2 = True
        break
    for checker in reversed_words_list:
        if reversed_phrase[0:len(checker)] == checker:
            can2 = True
            reversed_phrase = reversed_phrase[len(checker):]
            break
    if not can2:
        can1 = False
        break

if can1:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3316
#include <iostream>
#include <stack>

using namespace std;

int main() {
    stack<int> s;
    char c;
    int ans = 0;
    while (cin >> c) {
        if (!s.empty() && s.top() + (c - '0') == 1) {
            s.pop();
            ans += 2;
        } else {
            s.push(c - '0');
        }
    }

    cout << ans << endl;

    return 0;
}

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

namespace A
{
    class Program
    {
        public static void Main(string[] args)
        {
            var a = ReadLine();
            var b = new int[4];
            var Re = "No";

            b = StringCharArrayIntArray(a);

            if (b[0] == b[1] && a[1] == a[2]) {
                Re = "Yes";
            }else if(a[1] == a[2] && a[2] == a[3]) {
                Re = "Yes";
            }


            Console.WriteLine(Re);
            ReadLine();
        }

        /// <summary>
        /// stringを一文字ずつintにキャストして配列に変換します。
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static int[] StringCharArrayIntArray(string str)
        {
            List<int> b = new List<int>();
            for (int i = 0; i < str.Length; i++) {
                b.Add( int.Parse(str[i].ToString()));
            }
            return b.ToArray();
        }

        public static string ReadLine()
        {
            return Console.ReadLine();
        }

        public static int ReadLineInt()
        {
            return int.Parse(Console.ReadLine());
        }

        public static string[] ReadLineStringSplit(char a = ' ')
        {
            return ReadLine().Split(a).ToArray();
        }

        public static int[] ReadLineIntSpilit(char a = ' ')
        {
            return ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
        }
    }
}

Measured memory_bytes: 11092
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    sort(v.begin(), v.end());
    if(v.back() < accumulate(v.begin(), v.end()-1, 0))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256