akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
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;}
int a[100001];
int main(){
	int n;
	cin >> n;
	REP(i,n) cin >> a[i];
	int cnt = 0;
	REP(i,n){
		if(a[a[i]-1] == i+1) cnt++;
	} 
	cout << cnt/2 << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
int main(){
 int n;
 cin>>n;
 int a=0;
 int b=0;
 int c=0;
 int d=0;
 rep(i,n){
     string s;
     cin>>s;
     if(s=="AC") a++;
     if(s=="WA") b++;
     if(s=="TLE") c++;
     if(s=="RE") d++;
 }
 cout<<"AC x"<<" "<<a<<endl;
 cout<<"WA x"<<" "<<b<<endl;
 cout<<"TLE x"<<" "<<c<<endl;
 cout<<"RE x"<<" "<<d<<endl;
}

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

int main() {
  int N, sum;
  cin >> N;//組

  sum = 0;
  for (int i = 0; i < N; i++) {
    //string syu;
    int st, en;
    cin >> st >> en;
    //if (syu == "Y") {
    //  cout << "Four"<< endl;
    //  break;
    //}
    sum = sum + en - st + 1;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int s, k, x, y, z, i, cnt = 0, sum;
	scanf("%d%d", &k, &s);
	for (x = 0;x <= k;x++) {
		sum = x;
		if (sum == s) {
			cnt ++;
			break;
		}
		for (y = 0;y <= k;y++) {
			sum = x;
			sum += y;
			if (sum == s) {
				cnt ++;
				break;
			}
			z = s - x - y;
			sum += z;
			if (sum == s&&z<=k) {
				cnt++;
				//break;
			}
		}
	}
	printf("%d", cnt);
	return 0;
}


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

int main()
{
int A;
int B;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> A;
	cin >> B;

	if( A % 2 == 0 || B % 2 == 0 )
		cout << "No" << endl;
	else
		cout << "Yes" << endl;

	return 0;
}


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


int main() {

    int n;
    string str;
    cin>>n>>str;
    
    
    char cur_char=str[0];
    int cnt=1;
    
    for(int i=1;i<n;i++){
        
        if(str[i]!=cur_char){
            cur_char=str[i];
            cnt++;
        }
    }
    
    cout<<cnt;
    
    
   
   
    return 0;
   
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
// typedef long  l;
typedef pair<int,int> P;
const int INF=10000001;
const double PI=3.141592653589;


int main(){
  int n,t; cin>>n>>t;
  vector<P> p(n);
  rep(i,n){
    cin>>p[i].first>>p[i].second;
  }
  sort(p.begin(),p.end());
  int ans=INF;
  rep(i,n){
    if(p[i].second<=t&&ans>p[i].first)
    ans=p[i].first;
  }
  if(ans==INF)
  cout<<"TLE"<<endl;
  else
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(final String[] args) {
        try(final Scanner scanner = new Scanner(System.in);) {
            final int a = scanner.nextInt();
            final int b = scanner.nextInt();
            final int c = scanner.nextInt();
            final int x = scanner.nextInt();

            int cnt = 0;
            for (int aCnt = 0; aCnt <= a; aCnt++) {
                for (int bCnt = 0; bCnt <= b; bCnt++) {
                    if (((aCnt * 500) + (bCnt * 100)) > x) {
                        break;
                    }
                    for (int cCnt = 0; cCnt <= c; cCnt++) {
                        if (((aCnt * 500) + (bCnt * 100) + (cCnt * 50)) == x) {
                            cnt++;
                        }
                    }
                }
            }
            System.out.println(cnt);

        }
    }
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int h, w;
  cin >> h >> w;
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];

  queue<int> q;
  rep(i,n) {
    rep(j,a[i]) {
      q.push(i+1);
    }
  }
  
  vvi c(h,vi(w));
  rep(i,h) {
    if (i%2 == 0) {
      rep(j,w) {
        c[i][j] = q.front(); q.pop();
      }
    }
    else {
      drep(j,w) {
        c[i][j] = q.front(); q.pop();
      }
    }
  }

  showv2(c);
  return 0;
}

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

int main(void){
    int n;
    scanf("%d",&n);
    
    ll sum=0;
    int num[100001];
    memset(num,0,sizeof(num));

    vector<int> p(n);
    for(int i=0;i<n;i++){
        scanf("%d",&p[i]);
        sum += p[i];
        num[p[i]]++;
    }

    int q;
    scanf("%d",&q);

    int b,c;
    for(int i=0;i<q;i++){
        scanf("%d %d",&b,&c);
        sum += num[b] * (c-b);
        num[c] += num[b];
        num[b] = 0;
        printf("%lld\n",sum);
    }
}


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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X,i) ((X>>i)&1)
#define REP(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define ina(x,n) rep(x_i,n) cin>>x[x_i]
#define outa(x,n) rep(x_i,n) cerr<<x[x_i]<<" \n"[x_i==n-1]

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;

const int mod = 1e9+7;
const int inf = (1<<28);
const ll infl = (1LL<<60);

int main() {
  int N, K; cin >> N >> K;
  int ans = 0;
  while (N > 0) {
    N /= K;
    ans++;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;

int max(int a, int b) { return (a > b) ? a : b; }

const int MAXN = 31;


const int INF = 1e9;

vector<int> a;

bool check(vector<int>& a, ll x)
{
    for (int i = 0; i < a.size(); i++)
    {
        x = x / a[i] * a[i];
    }
    return (x == 2);
}


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

    int n;
    int k;
    cin >> k;
    a.resize(k);
    ll min = 2, max = 2;
    for (int i = 0; i < k; i++)
    {
        cin >> a[i];
    }
    reverse(a.begin(), a.end());
//    assert(a[0] <= 2);
    if (a[0] == 2) max = 3;
    if (a[0] == 1) max = 2;
    if (a[0] > 2)
    {
        cout << -1;
        return 0;
    }
    for (int i = 1; i < k; i++)
    {
        min = (min / a[i] * a[i]) + ((min % a[i] == 0) ? 0 : a[i]);
        max = (max / a[i] * a[i]) + a[i] - 1;
    }

    reverse(a.begin(), a.end());
    if (!check(a, min) || !check(a, max)) {
        cout << -1;
        return 0;
    };

    cout << min << " " << max;

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> P; 


int main(){
    int n,m;
    while(cin >> m >> n,n){
        vector<bool> v(7400000,false);
        for (int i = m; i < 7400000; i++) {
           if(!v[i]){
                if(!n){
                    cout << i << endl;
                    break;
                }
               n--;
               for (int s = i; s < 7400000; s+=i) {
                   v[s]=true;
               }
           }
        }
    }
    return 0;
}



Measured memory_bytes: 4024
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (n); i++)
 
int main(){
    int N;
    cin >> N;
    char C[N];
    vector<int> S(N,0);
    string str;
    cin >> str;
    int countW = 0,x =0;
    for(char c : str){
        C[x] = c;
        S[x] += countW;
        if(c == 'W')countW++;
        x++;
    }
    int countE = 0;
    for(int i = N-1;i>=0;i--){
        S[i] += countE;
        if(C[i] == 'E') countE++;
    }
    sort(S.begin(),S.end());

    cout << S[0];

    return 0;
}

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

using namespace std;

typedef vector<int> Vec;

int N, maxi;
vector<string> v;
Vec num,l;
set<Vec> st;

int solve(int k, int idx, int sum, int S, int p){
    if(k == maxi){
        if(st.count(num)) return 0;
        st.insert(num);
        return 1;
    }
    int res = 0;
    if(idx == N-1){
        int val = (int)(v[idx][k]-'A');
        int ns = (sum + p) % 10;
        int np = (sum + p) / 10;
        if(k+1 == maxi && np != 0) return 0;
        if(num[val] != -1){
            if(l[idx] > 0 && k == l[idx] && num[val] == 0){
                return 0;
            }
            if(ns == num[val]){
                res = solve(k+1, 0, 0, S, np);
            }
        }else{
            for(int i = 0 ; i < 10 ; i++){
                if(S >> i & 1) continue;
                num[val] = i;
                if(ns == i && !(l[idx] > 0 && k == l[idx] && i == 0)){
                    res += solve(k+1, 0, 0, S|(1<<i), np);
                }
                num[val] = -1;
            }
        }
    }else{
        if(v[idx][k] == '*'){
            res = solve(k, idx+1, sum, S, p);
        }else{
            int val = (int)(v[idx][k]-'A');
            if(num[val] != -1){
                if(l[idx] > 0 && k == l[idx] && num[val] == 0){
                    return 0;
                }
                res += solve(k, idx+1, sum+num[val], S, p);
            }else{
                for(int i = 0 ; i < 10 ; i++){
                    if(S >> i & 1) continue;
                    num[val] = i;
                    if(!(l[idx] > 0 && k == l[idx] && i == 0)){
                        res += solve(k, idx+1, sum+i, S|(1<<i), p);
                    }
                    num[val] = -1;
                }
            }
        }
    }
    return res;
}

int main(){
    while(cin >> N, N){
        v.resize(N); l.resize(N);
        maxi = 0;
        Vec len(N);
        for(int i = 0 ; i < N ; i++){
            cin >> v[i];
            l[i] = len[i] = v[i].size();
            l[i]--;
            maxi = max(maxi, len[i]);
            reverse(v[i].begin(),v[i].end());
        }
        if(len[N-1] < maxi){
            cout << 0 << endl;
            continue;
        }
        for(int i = 0 ; i < N ; i++){
            while(len[i] != maxi){
                v[i] += '*';
                len[i]++;
            }
        }
        num.resize(26, -1); st.clear();
        cout << solve(0, 0, 0, 0, 0) << endl;
    }
    return 0;
}

Measured memory_bytes: 8156
#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
#define For(i, x, y) for(int i=x;i<=y;i++)  
#define _For(i, x, y) for(int i=x;i>=y;i--)
#define Mem(f, x) memset(f,x,sizeof(f))  
#define Sca(x) scanf("%d", &x)
#define Sca2(x,y) scanf("%d%d",&x,&y)
#define Sca3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define Scl(x) scanf("%lld",&x);  
#define Pri(x) printf("%d\n", x)
#define Prl(x) printf("%lld\n",x);  
#define CLR(u) for(int i=0;i<=N;i++)u[i].clear();
#define LL long long
#define ULL unsigned long long  
#define mp make_pair
#define PII pair<int,int>
#define PIL pair<int,long long>
#define PLL pair<long long,long long>
#define pb push_back
#define fi first
#define se second 
typedef vector<int> VI;
const double eps = 1e-9;
const int maxn = 110;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7; 
int N,M,K;
int main(){
	int a,b;
	cin >>a >> b;
	cout << max(max(a + b,a * b),a - b);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793
 
   
int main(){
  int n,x,t;
  cin >> n >> x >> t;
  int ans;
  if(n%x==0)ans=(n/x)*t;
  else{
    ans=(n/x+1)*t;
  }
  cout << ans << endl;
} 
    

Measured memory_bytes: 3628
//BELIEVE IN YOURSELF
//next_permutation

#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define pob pop_back
#define vi vector<ll>
#define mp make_pair
#define sz size()
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define maxx 100005
#define se second
#define fi first
#define be begin()
#define en end()
#define sortv(v) sort(v.begin(),v.end());
#define sortr(v) sort(v.rbegin(),v.rend());
#define w() ll _;cin>>_;while(_--)
#define edge pair<ll,ll>
#define pq priority_queue<ll>
#define mod 1000000007
#define Endl "\n"
#define cy cout<<"YES"<<endl;
#define cn cout<<"NO"<<endl;
#define lb(v,x) std::lower_bound(v.begin(),v.end(),x)
#define ub(v,x) std::upper_bound(v.begin(),v.end(),x)

using namespace std;

ll v[1000002];
ll prime[1000002];

void fact()
{
	ll n=1000001;
	ll i;
	v[0]=0;
	v[1]=0;
	ll j;
	prime[1]=1;
	for(i=1;i*i<=n;i++)
	{
		if(prime[i]==0)
		{
			v[i]+=2;
		}
	
		for(j=i*i;j<=n;j+=i)
		{
			prime[j]=1;
			if(i*i==j)
			{
				v[j]+=1;
			}
			else
			{
				v[j]+=2;	
			}
			
		}
	}
	
}

int main()
{
	fast;
	
	ll n;
	cin>>n;
	fact();
	ll c=0;
	ll ans=0;
	//cout<<v[12]<<endl;
	
	for(c=n-1;c>=1;c--)
	{
		ans += (v[n-c]);
	}	
	
	cout<<ans<<Endl;
	
	return 0;
}

Measured memory_bytes: 19276
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <map>
using namespace std;
#define _CRT_SECURE_NO_WARNINGS
#define Abs                           \
	ios_base::sync_with_stdio(false); \
	cout.tie(NULL);                   \
	cin.tie(NULL);
#define FOR(i, b, a) for (ll i = b; i < a; i++)
#define FOR1(i, b, a) for (ll i = b; i <= a; i++)
#define FORd(i, b, a) for (ll i = (a)-1; i >= b; i--)
const double PI = acos(-1);
#define all(v) ((v).begin()), ((v).end())
#define allr(v) ((v).rbegin()), ((v).rend())
#define iq(v)   v.resize(unique(v.begin(), v.end()) - v.begin())
#define endl "\n"
#define sz(v) ((ll)((v).size()))
#define fx(n)           fixed << setprecision(n)
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
const int mod = 1e9 + 7;
int main()
{
	Abs;
	ll n, k, s = 0;
	cin >> n >> k;
	vi v(n);
	FOR(i, 0, n)
	cin >> v[i];
	sort(all(v));
	FOR(i, 0, k)
	s += v[i];
	cout << s;
}

Measured memory_bytes: 3660
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
typedef vector<int> vi;

int main()
{
	int n, m,ans=100;
	ull dis,min = numeric_limits<ull>::max();
	vector<pair<int,int>> a(50),b(50);
	cin >> n >> m;
	a.resize(n);
	b.resize(m);
	for (int i = 0; i < n; i++) {
		cin >> a[i].first >> a[i].second;
	}
	for (int i = 0; i < m; i++) {
		cin >> b[i].first >> b[i].second;
	}


	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			dis = abs(a[i].first - b[j].first) + abs(a[i].second - b[j].second);
			/*cout << "dis:" << dis;
			cout << " min:" << min;
			cout << " ans:" << ans << endl;*/
			if (min > dis) {
				min = dis;
				ans = j + 1;
			}
		}
		cout << ans << endl;
		min = numeric_limits<ull>::max();
		ans = 100;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;
const ll oo = 1e18;

signed main()
{
	IO_OP;
	
	int n, x;
	cin >> n >> x;
	vi a(n);
	for(int i = 0; i < n; i++) cin >> a[i];	
	vi b = a;
	ll ans = oo;
	for(int i = 0; i < n; i++) {
		ll cur = (ll) i * x;
		for(int j = 0; j < n; j++) {
			b[j] = min(b[j], a[(i + j) % n]);
			cur += b[j];
		}
		ans = min(ans, cur);
	}	
	cout << ans << endl;

}





Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define _size(X) (int)((X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 100;
int N;

bool rec(vector<int> v, vector<int>& ans) {
    if (v.size() == 0) return true;

    for (int i = v.size() -1; i >= 0; --i) {
        if (i+1 == v[i]) {
            vector<int> nv;
            for (int j = 0; j < v.size(); ++j) {
                if (i != j) nv.push_back(v[j]);
            }
            bool judge = rec(nv, ans);
            if (judge) {
                ans.push_back(v[i]);
                return true;
            }
        }
    }

    return false;
}

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

  cin >> N;
  vector<int> b(N);
  rep(i, N) cin >> b[i];

  rep(i, N) {
      if (i+1 < b[i]) {
          cout << -1 << endl;
          return 0;
      }
  }

  vector<int> ans;

  if (!rec(b, ans)) {
      cout << -1 << endl;
  } else {
      rep(i, N) {
          cout << ans[i] << endl;
      }
  }

  return 0;
}


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

int main(){
	string str;
	cin >> str;
	int i=2;
	bool flag = true;
	for(int i = 2; i <= 4; i+=2){
		if(str[i] == str[i+1])
			continue;
		else{
			flag = false;
			break;
		}
	}
	if(flag)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string t, p;
    cin>>t>>p;
    for(int pos=0; pos<t.length(); pos++) {
        pos = t.find(p, pos);
        if(pos==string::npos) break;
        cout<<pos<<'\n';
    }
    return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
ll a[5];
int main( void )
{
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  string S;
  for( int i=0; i<N; i++ ){
    cin >> S;
    switch( S[0] ){
      case 'M': a[0]++; break;
      case 'A': a[1]++; break;
      case 'R': a[2]++; break;
      case 'C': a[3]++; break;
      case 'H': a[4]++; break;
    }
  }
  ll ret = 0;
  for( int i0=0; i0<2; i0++ ){
  for( int i1=0; i1<2; i1++ ){
  for( int i2=0; i2<2; i2++ ){
  for( int i3=0; i3<2; i3++ ){
  for( int i4=0; i4<2; i4++ ){
    if( i0+i1+i2+i3+i4 != 3 ) continue;
    ll d = 1;
    if( i0 > 0 ) d *= a[0];
    if( i1 > 0 ) d *= a[1];
    if( i2 > 0 ) d *= a[2];
    if( i3 > 0 ) d *= a[3];
    if( i4 > 0 ) d *= a[4];
    ret += d;
  }}}}}
  cout << ret << endl;
}

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

int main(){
    long long int H,W,res;
    cin >> H >> W;
    res=0;
    if (H==1 || W==1){
      res=1;
      cout << res << endl;
      return 0;
    }
    if (W%2==1){
        res=H*(W/2)+(H+1)/2;
    }else{
        res=H*(W/2);
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define END return 0
typedef int64_t ll;
const int mod7 = 1e9 + 7;
const int mod9 = 1e9 + 9;
const int inf = 1 << 30;
const ll INF = 1LL << 60;
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a % b) : abs(a);}
template<typename T> T lcm(T a, T b) {return a / gcd(a, b) * b;}
template<typename T> bool chmax(T &a, T b) {if (a < b) {a = b; return true;} return false;}
template<typename T> bool chmin(T &a, T b) {if (a > b) {a = b; return true;} return false;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) {fill((T*)array, (T*)(array+N), val);}

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    cout << n / (a + b) * a + min(n % (a + b), a) << endl;
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)

typedef long long ll;
typedef pair<ll,ll> P;

/*
0-index
functionの中を書いて使う
宣言の時に単位元を書く
*/
template<typename T>
struct segtree{
	int n;vector<T> dat;T ZERO;
	segtree(int n_,T zero):ZERO(zero){
	  n = 1;
	  while(n < n_)n*=2;
	  dat.resize(2*n);
	  for(int i = 0;i < 2*n;i++)dat[i] = ZERO;
	}
	void update(int k, T a){
	  k += n - 1;dat[k] = a;
	  while(k > 0){
		k = (k-1)/2;
		dat[k] = function(dat[k*2+1],dat[k*2+2]);
	  }
	}

	void set(int k, T a) {
		k += n - 1;dat[k] = a;
	}

	void build(){
		for(int i = n - 2;i >= 0;i--){
			dat[i] = function(dat[2 * i + 1], dat[2 * i + 2]);
		}
	}

	T function(T a,T b){
		return max(a, b);
	}

	T get(int k){return dat[k+n-1];}

	T que(int a,int b){
		T L = ZERO,R = ZERO;
		int A = a + n - 1;
		int B = b + n - 1;
		while(A < B){
			if((A & 1) == 0)L = function(L,dat[A++]);
            if((B & 1) == 0)R = function(dat[--B],R);
            A = A >> 1;
            B = B >> 1;
		}
		return function(L,R);
	}
};

int main(){
	int n;cin >> n;
	segtree<P> seg(111111, MP(-LLINF, -LLINF));
	seg.update(0, MP(0, 0));

	REP(i, n){
		ll a;cin >> a;
		P tmp = seg.que(0, a);
		tmp.FI++;
		tmp.SE += a;
		seg.update(a, tmp);
	}

	ll ma = 0;
	REP(i,111111)ma = max(ma, seg.get(i).FI);
	ll ans = 0;
	REP(i,111111){
		if(seg.get(i).FI == ma){
			ans = max(ans, seg.get(i).SE);
		}
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 7044
#include<stdio.h>

#define N 100000

typedef struct
			  {
			    int parent;
			    int left;
			    int right;
} node;

int finddepth(int);
int findheight(int);

node T[N];

int main()
{
  int pa, x, y, i, j, n, k, c;

  scanf("%d", &n);
  for(i=0; i<n; i++)
    {
      T[i].parent = -1;
      T[i].left = -1;
      T[i].right = -1;
    }
  

  for(i=0; i<n; i++)
    {
      scanf("%d", &pa);

      scanf("%d%d", &x, &y);
        if(x!=-1)T[x].parent = pa;
        if(y!=-1)T[y].parent = pa;
      T[pa].left = x;
      T[pa].right = y;
        
    }
  for(i=0; i<n; i++)
    {
      c=0;
      printf("node %d: parent = %d, ", i, T[i].parent);
      if(T[i].parent == -1)
        {
          printf("sibling = -1, ");
        }
      else if(T[T[i].parent].left == i)
        {
          printf("sibling = %d, ", T[T[i].parent].right);
        }
      else
        {
          printf("sibling = %d, ", T[T[i].parent].left);
        }

      if(T[i].left != -1) c++;
      if(T[i].right != -1) c++;

      printf("degree = %d, depth = %d, height = %d, ", c, finddepth(i), findheight(i));
      
      if(T[i].parent == -1)
        {
          printf("root\n");
        }
      else if(T[i].left != -1 || T[i].right != -1)
        {
          printf("internal node\n");
        }
      else
        {
          printf("leaf\n");
        }
    }
      
  return 0;
}

int finddepth(int x)
{
  int c=0;
  while(T[x].parent >= 0)
    {
      c++;
      x = T[x].parent;
    }
  return c;
}
int findheight(int x)
{
  int l=0, r=0;

  if(T[x].left != -1)
    {
      l = findheight(T[x].left)+1;
    }
  if(T[x].right != -1)
    {
      r = findheight(T[x].right)+1;
    }
  if(l > r)
    {
      return l;
    }
  else
    {
      return r;
    }
}

Measured memory_bytes: 612
from bisect import bisect_left

s = list(input())

total_s = len(s)

t = list(input())

alf=[[] for _ in range(26)]

for i in range(len(s)):
    alf[ord(s[i])-97].append(i+1)

coti_alt = 0
now_alf = 0
ans = 0

for i in range(len(t)):
    next_alf = ord(t[i])-97

    if len(alf[next_alf]) == 0:
        print(-1)
        exit()

    if 0 < i and t[i-1] == t[i]:
        now_alf += 1
        ans += 1
        if now_alf == total_s and t[i] == s[now_alf-1]:
            continue

    serch_next_alf = bisect_left(alf[next_alf], now_alf)

    if now_alf < alf[next_alf][-1]:
        ans += alf[next_alf][serch_next_alf] - now_alf
        now_alf = alf[next_alf][serch_next_alf]
    else:
        ans += total_s - now_alf + alf[next_alf][0]
        now_alf = alf[next_alf][0]
    #print(ans,now_alf)

print(ans)


Measured memory_bytes: 88716
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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; }
typedef pair <ll,ll> P;

int main()
{
    ll A, B;
    cin >> A >> B;
    ll cnt = 0;
    for(int i = A; i <= B; i++) {
        string tmp = to_string(i);
        if (tmp[0] == tmp[4] & tmp[1] == tmp[3]) {
            cnt++;
        }
    }
    print(cnt);
    return 0;
}


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

int main(){
  string s;
  cin >> s;
  if(s[0] == s[1] && s[1] == s[2]) cout << "No"  << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  string s;
  cin >> s;
  int sz = s.size()%2;
  int res = (s[0]==s[s.size()-1] ? 1 : 0);
  if (sz^res)
    cout << "First" << endl;
  else
    cout << "Second" << endl;
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define eb          emplace_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define mp(x,y)     make_pair(x,y) 
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,a,n)   for(ll i=a;i<n;i++)
#define frr(i,a,n)  for(ll i=n-1;i>=a;i--)


const ll N   =  500005;
const ll mod = 1e9 + 7;

using namespace std;


void solve()
{
  ll n,k;
  cin>>n>>k;
  c(n-k+1);
}

signed main(){

      ios_base::sync_with_stdio(false);   
      cin.tie(NULL);
      ll T=1;
      //cin>>T;
      while(T--)
      {
      solve();
      }
      return 0;
    }


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;
typedef pair<ll  ,ll > pll;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn  = 3e6;
const ll mod =1e9+7;
const ld PI = 4 * atan((ld) 1);

#define pb(x) push_back(x);
#define endl '\n'
#define dominance true
#define dokme(x) cout << x ;  return(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
#define ms(x , y) memset(x , y , sizeof x);
ll pw(ll a, ll b, ll md = mod) {
    ll res = 1;while(b){if(b&1){res=(a*res)%mod;}a=(a*a)%mod;b>>=1;}return(res);
}

int n;
int h[maxn];
int dp[maxn];

int main(){
    migmig
    cin >> n;
    for (int i = 1 ; i <= n ; i ++){
        cin >> h[i];
        if(i > 1){
            dp[i] = dp[i-1]+abs(h[i] - h[i-1]);
        }
        if(i > 2){
            dp[i] = min(dp[i] ,dp[i-2]+abs(h[i] - h[i-2]));
        }
    }
    cout << dp[n];
    return(0);
}

//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, life is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.
//It is important to draw wisdom from diffrent places. If you take it from only one place it becomes rigid and stale.
//kuxtal jach uts chuchul u u páajtal máak jach táaj meyajilo'ob le castigadas tumen ch'aik descansos.


Measured memory_bytes: 2688
N = int(input())
S = list(map(int, input().split()))
Q = int(input())
T = list(map(int, input().split()))

def binary_search(target_num, head, tail):
    while head <= tail:
        idx = int((head+tail)/2)
        if target_num == S[idx]:
            return True
        elif target_num < S[idx]:
            tail = idx - 1
        else:
            head = idx + 1
    return False


match_count = 0
for target_num in T:
    if binary_search(target_num, 0, len(S)-1):
        match_count += 1

print(str(match_count))


Measured memory_bytes: 16712
#include <stdio.h>
int m[] = {1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049};
int n;
int dp[100001];
int min(int a, int b) {
  return a > b ? b : a;
}
int f(int k) {
  if (k == 0)
    return 0;
  if (dp[k])
    return dp[k];
  
  int ans = n;
  for (int i = 0; i < sizeof(m)/sizeof(int); i++) {
    if (m[i] <= k)
      ans = min(ans, 1 + f(k - m[i]));
  }
  return dp[k] = ans;
}


int main() {
  scanf("%d", &n);
  
  printf("%d\n", f(n));
  
  
  
  return 0;
}

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

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<vector<int>> F(N, vector<int>(10));
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < 10; ++j) {
			cin >> F[i][j];
		}
	}
	vector<vector<int>> P(N, vector<int>(11));
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < 11; ++j) {
			cin>>P[i][j];
		}
	}
	int ans = -1e9;
	for (int i = 1; i < (1 << 10); ++i) {
		int subans = 0;
		for (int j = 0;j<N;++j) {
			int count = 0;
			for (int k = 0;k<10;++k) {
				if (1 & (i>>k)) {
					if (1 == F[j][k]) {
						count++;
					}
				}
			}
			subans += P[j][count];
		}
		ans = max(ans, subans);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int N;
ll K;
vector<ll> A;

int main(){
  cin>>N>>K;
  A.resize(N);
  rep(i,N) cin>>A[i];

  rep(i,N){
    A[i]--;
    A[i]%=K;
  }

  map<ll,ll> mp;
  mp[0]++;
  vector<ll> sum(N+1,0);
  ll ans=0;
  for(int i=0;i<N;i++){
    if(i-K+1>=0) mp[sum[i-K+1]]--;
    sum[i+1]=sum[i]+A[i];
    sum[i+1]%=K;
    ans+=mp[sum[i+1]];
    //cout<<ans<<" "<<sum[i+1]<<" "<<mp[sum[i+1]]<<endl;
    //ans+=mp[sum];
    mp[sum[i+1]]++;
  }

  cout<<ans<<endl;



  return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
int64_t INF = 1000000007;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n,k;
    cin >> n >> k;
    vi x(n);
    rep(i,n) cin >> x.at(i);
    vi pos, neg;
    rep(i,n){
        if(x.at(i)>=0){
            pos.push_back(x.at(i));
        }else{
            neg.push_back(x.at(i));
        }
    }
    sort(pos.begin(), pos.end());
    sort(neg.begin(), neg.end(), greater<>());
    int64_t res = INF;
    // 0を跨がないパターン
    if(pos.size()>=k) res = min(res, pos.at(k-1));
    if(neg.size()>=k) res = min(res, -neg.at(k-1));
    // 0を跨ぐパターン(i: 折り返しのindex)
    rep(i,k){
        if(i>=pos.size()) continue;
        if(k-2-i>=neg.size()) continue;
        int64_t resPos = 2*pos.at(i) - neg.at(k-2-i);
        int64_t resNeg = pos.at(i) - 2*neg.at(k-2-i);
        int64_t tmpRes = min(resPos, resNeg);
        res = min(res, tmpRes);
    }
    cout << res << endl;
}

Measured memory_bytes: 2424
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  
  int n; long c; rd(n, c);
  auto x=new long[](n), v=new long[](n);
  foreach(i; 0..n) rd(x[i], v[i]);

  // import std.exception;
  // enforce(n<=100);

  x=0L~x~c;
  v=0L~v~0L;

  long mx=0, inf=2e18.to!(long);

  auto a=new long[](n+2); // a[i]:=[i, n+1]
  fill(a, -inf);
  a[n+1]=0;
  for(auto r=n, s=0L; r>0; r--){
    s+=v[r];
    a[r]=max(a[r+1], s-(c-x[r]));
  }
  // writeln(a);
  for(auto l=0, s=0L; l<=n; l++){
    s+=v[l];
    mx=max(mx, (s-x[l]*2)+a[l+1]);
  }
  auto b=new long[](n+2); // b[i]:=[0, i]
  fill(b, -inf);
  b[0]=0;
  for(auto l=1, s=0L; l<=n; l++){
    s+=v[l];
    b[l]=max(b[l-1], s-x[l]);
  }
  // writeln(b);
  for(auto r=n+1, s=0L; r>0; r--){
    s+=v[r];
    mx=max(mx, (s-(c-x[r])*2+b[r-1]));
  }

  long tot=reduce!"a+b"(0L, v);
  for(int i=0; i<=n; i++){
    long cl=x[i], cr=c-x[i+1];
    long cost=cl+cr+min(cl, cr);
    mx=max(mx, tot-cost);
  }
  writeln(mx);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x) e=l[i].to!(typeof(e));
}


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

int main(){
  int a, b, c, d;
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> a >> b >> c >> d;
  cout << min(a,b) + min(c,d) << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int[] DR = { 1, 1, 1, 0, -1, -1, -1, 0 };
	static int[] DC = { -1, 0, 1, 1, 1, 0, -1, -1 };
	static char[][] f;

	public static void main(String[] args) {
		int N = sc.nextInt();
		String[] dic = new String[N];
		int[] v = new int[N];
		for (int i = 0; i < N; ++i) {
			dic[i] = sc.next();
			v[i] = sc.nextInt();
		}
		f = new char[4][];
		for (int i = 0; i < 4; ++i) {
			f[i] = sc.next().toCharArray();
		}
		int[][] count = new int[9][101];
		boolean[][] visited = new boolean[4][4];
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < 4; ++j) {
				for (int k = 0; k < 4; ++k) {
					if (f[j][k] == dic[i].charAt(0)) {
						count[dic[i].length()][v[i]] += find(dic[i], 0, j, k, visited);
					}
				}
			}
		}

		int T = sc.nextInt();
		int[] dp = new int[T + 1];
		Arrays.fill(dp, -1);
		dp[T] = 0;
		for (int i = 1; i <= 8; ++i) {
			for (int j = 1; j <= 100; ++j) {
				if (count[i][j] == 0) continue;
				for (int k = 0; k <= T; ++k) {
					if (dp[k] < 0) continue;
					int n = k - i;
					for (int l = 1; l <= count[i][j] && n >= 0; ++l, n -= i) {
						dp[n] = Math.max(dp[n], dp[k] + l * j);
					}
				}
			}
		}
		int ans = 0;
		for (int i = 0; i <= T; ++i) {
			ans = Math.max(ans, dp[i]);
		}
		System.out.println(ans);
	}

	static int find(String word, int p, int r, int c, boolean[][] visited) {
		if (p == word.length() - 1) return 1;
		visited[r][c] = true;
		int ret = 0;
		for (int i = 0; i < 8; ++i) {
			int nr = r + DR[i];
			int nc = c + DC[i];
			if (nr < 0 || 3 < nr || nc < 0 || 3 < nc) continue;
			if (visited[nr][nc]) continue;
			if (f[nr][nc] != word.charAt(p + 1)) continue;
			ret += find(word, p + 1, nr, nc, visited);
		}
		visited[r][c] = false;
		return ret;
	}
}

Measured memory_bytes: 22740
#include <stdio.h>

int main(){
  int a,b,c;
  int tmp;
  scanf("%d %d %d",&a,&b,&c);
  if(a>b){
    tmp=a;
    a=b;
    b=tmp;
  }
  if(a>c){
    tmp=a;
    a=c;
    c=tmp;
  }
  if(b>c){
    tmp=b;
    b=c;
    c=tmp;
  }
  printf("%d %d %d\n",a,b,c);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll k; cin >> k;
  int n = 50;
  vector<ll> ans(n);
  rep(i, n) {
    ans[i] = i;
    ans[i] += k/n;
  }
  k %= n;
  rep(i, n) {
    if(i < k) ans[i] += n-(k-1);
    else      ans[i] -= k;
  }
  cout << n << endk;
  rep(i, n) cout << ans[i] << ' ';
  cout << endk;
  return 0;
}


Measured memory_bytes: 3616
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#include<cstdio>
#include <iomanip>

#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

using namespace std;
typedef long long ll;
using P = pair<ll, ll>;
using R = double;

int main() {

	int n;
	string s;

	cin >> n >> s;

	int c = 0;
	int d = 0;
	for (int i = 0; i < n; i++) {
		
		if (s[i] == '(') {
			c++;
		}
		else {
			c--;
		}

		d = min(d, c);
	}

	for (int i = 0; i < abs(d); i++) {
		cout << '(';
	}

	cout << s;

	//もともとの()のバランスに加えて、(を挿入した分が増える。
	//dが0以下なので-dするとmを増やすことになる。
	int m = c -d;

	for (int i = 0; i < m; i++) {
		cout << ')';
	}

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

s = list(input())
q = int(input())
reverse_counter = 0
left = []
for q0 in range(q):
    A = [i for i in input().split()]
    if len(A) == 1:
        reverse_counter += 1
    else:
        if A[1] == '1':
            if reverse_counter % 2 == 0:
                left.append(A[2])
            else:
                s.append(A[2])
        else:
            if reverse_counter % 2 == 0:
                s.append(A[2])
            else:
                left.append(A[2])

left.reverse()

res = left + s

if reverse_counter % 2 == 1:
    res.reverse()

print(''.join(res))

Measured memory_bytes: 75368
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(c)              c.begin(), c.end()
#define FastRead ios_base::sync_with_stdio(false);cin.tie(NULL);
#define EPS 1e-9
using namespace std;

int main()
{
    FastRead
    ll x,y,z,a=0,b=0;
    cin >> x >> y >> z;
    if(x<=z)
    {
        a=0;
        z-=x;
        if(z>=y)
        {
            b=0;
            z-=y;
        }
        else
        {
            b=y-z;
        }
         cout <<a <<" "<<b <<endl;
    }
    else
    {
        a=x-z;
        b=y;
        cout << a <<" "<<b <<endl;
    }


}


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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int INF = 1e9+7;
const int MOD = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

const int N = 5e5+1;
int n;

struct BIT{
  vector <int> bit[26];
  
  void prepare(int n){
    for (int i = 0; i < 26; i++) bit[i].assign(n + 1, 0);
  }

  void Update(int p, int val, int k){
    for (; p <= n; p += p&-p) bit[k][p] += val;
  }

  int Get(int p, int k){
    int ans = 0;
    for (; p > 0; p -= p&-p) ans += bit[k][p];
    return ans;
  }

  int F(int l, int r){
    int ans = 0;
    for (int i = 0; i < 26; i++) ans += (Get(r, i) - Get(l - 1, i) != 0);
    return ans; 
  }
} cur;

int main()
{
  fastio;
  int Q; string s; 
  cin >> n >> s >> Q;
  cur.prepare(n);
  for (int i = 0; i < s.size(); i++) cur.Update(i + 1, 1, s[i] - 'a');
  while (Q--){
    int type; cin >> type;
    if (type == 1){
      int p; char c; cin >> p >> c;
      cur.Update(p, -1, s[p - 1] - 'a');
      cur.Update(p, 1, c - 'a');
      s[p - 1] = c;
    }
    else {
      int l, r; cin >> l >> r;
      cout << cur.F(l, r) << '\n';
    }
  }
  return 0;
}

Measured memory_bytes: 51740
#include <iostream>

int main(){
  int K;
  std::string S;
  std::cin >> K >> S;

  if(S.size() <= K)
    std::cout << S <<std::endl;
  else{
    S.resize(K);
    std::cout << S << "..." << std::endl;
  }

  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <numeric>
using namespace std;
int N, K, A[100];
int main() {
  cin >> N >> K;
  for(int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  sort(A, A + N);
  cout << accumulate(A + N - K, A + N, 0) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll n,k,ans=0;
vector<ll> loop(ll s,vector<ll> a){
    vector<ll> cnt(200002,0),S;
    if(s>0){
        S.push_back(s);
        cnt[s]++;
    }
    For(i,0,n){
        if(cnt[a[i]]==0){
            S.push_back(a[i]);
            cnt[a[i]]++;
        }
        else{
            while(cnt[a[i]]>0){
                cnt[S[S.size()-1]]--;
                S.pop_back();
            }
        }
    }
    return S;
}
void Main(){
    cin>>n;
    cin>>k;
    vector<ll> a(n);
    vector<vector<ll>> b(200002);
    For(i,0,n) {
        cin>>a[i];
        b[a[i]].push_back(i);
    }
    ll init=0;
    ll place,num;
    map<ll,ll> mp;//初期値と結果
    while(true){
        ll now=init;
        if(now==0)place=0;
        else place=b[now][0]+1;
        here:;
        if(place==n){
            mp[init]=0;
            break;
        }
        num=a[place];
        auto itr=upper_bound(ALL(b[num]),place);
        if(b[num].end()-itr==0){
            mp[init]=num;
            init=num;
        }
        else{
            place=*itr+1;
            now=a[place];
            goto here;
        }
    }
    ll cnt=0;
    init=0;
    vector<ll> lp;
    lp.push_back(init);
    while(true){
        cnt++;
        init=mp[init];
        if(init==0) break;
        lp.push_back(init);
    }
    init=lp[(k-1)%cnt];
    vector<ll> S;

    S=loop(init,a);
    /*愚直にやっても間に合わない
    For(i,0,k){
        S=loop(init,a);
        if(S.size()>0) init=S[0];
        else init=0;
    }
    それはそうなんだよな*/

    For(i,0,S.size()) cout<<S[i]<<" ";
    cout<<endl;
}
int main(){
    Main();
    return 0;
}

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

using namespace std;
#define FOR(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)

int main(){
  int a, b;
  cin >> a >> b;
  int ans;
  ans = a * b;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3596
using System;
using System.Collections.Generic;
class _0013
{
    public static void Main()
    {
        string str;
        byte n;
        byte[] stackTrains = new byte[10];
        for (byte i = 0; i < 10; i++) stackTrains[i] = 0;
        List<byte> ejectTrains = new List<byte>();
        byte nowStacks = 0;
        while ((str = Console.ReadLine()) != null)
        {
            n = byte.Parse(str);
            if (n != 0)
            {
                stackTrains[nowStacks] = n;
                nowStacks++;
            }
            else
            {
                nowStacks--;
                ejectTrains.Add(stackTrains[nowStacks]);
            }
        }
        for (int i = 0; i < ejectTrains.Count; i++) Console.WriteLine(ejectTrains[i]);
    }
}

Measured memory_bytes: 6232