akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using ll = long long;
using namespace std;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int a,b,c;
int main(){
    cin >> a >> b >> c;
    pr(min(a+b,min(b+c,c+a)));
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#define last(x, y) (x)[(x).size() - y]
#define endl '\n'
#define flush fflush(stdout), cout.flush()
#define fast ios::sync_with_stdio(0), cin.tie(0)
#define debug cout << "ok" << endl
const int md = 1e9 + 7;
typedef long long ll;
typedef long double ldb;
using namespace std;

int n;

int main() {
	fast;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a.begin(), a.end());
	int val[2];
	val[0] = val[1] = -1;
	int j = a.size() - 1;
	while (j) {
		if (a[j] == a[j - 1]) {
			if (val[0] == -1) val[0] = a[j], j -= 2;
			else val[1] = a[j], j = 0;
		}
		else j--;
	}
	if (val[1] == -1) cout << 0 << endl;
	else cout << (ll)val[0] * val[1] << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using P = pair<int,int>;
using ll = long long;
using namespace std;
int main() {
    int x, y;
    cin >> x >> y;
    int ans = 0;
    for(int i = 0; i <= x; ++i){
        ans = 2*i + 4*(x-i);
        if(ans == y){
            cout << "Yes" << endl;
            return 0;
            
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<map>
#include<cstdlib>



using namespace std;

int n;
int a[200000];
int ans=0;

int main(){
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a[i]; 
    }
    int cnt=1;
    for(int i=0;i<n;i++){
        if(cnt == a[i]){
            cnt ++;
        }
    }
    if(cnt == 1) cout << -1 << endl;
    else cout << n-cnt+1 << endl;
    return 0;
}

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

int main() {
	int n;
	cin >> n;
	int a[200];
	for (int i = 0;i < n;++i)cin >> a[i];
	int count = 0;

	while (true) {
		bool x = false;
			for (int i = 0;i < n;++i) {
				if (a[i] % 2 != 0)x = true;
			}
		if (x)break;
		for (int i = 0;i < n;++i) {
			a[i] /= 2;
		}
		++count;
	}

	cout << count << endl;
}

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

int main(){
        int h, w, d;
        scanf("%d %d %d", &h, &w, &d);

        int zah[h*w+1][2];
        for(int i=0; i<h; i++){
                for(int j=0; j<w; j++){
                        int tmp;
                        scanf("%d", &tmp);
                        zah[tmp][0] = i;
                        zah[tmp][1] = j;
                }
        }
        zah[0][0] = zah[0][1] = 0;

        int dist[h*w+1];
        for(int i=d; i<=h*w; i++){
                dist[i] = abs(zah[i-d][0]-zah[i][0]) + abs(zah[i-d][1]-zah[i][1]);
                dist[i] += dist[i-d];
        }

        int q;
        scanf("%d", &q);
        for(int i=0; i<q; i++){
                int l, r;
                scanf("%d %d", &l, &r);
                printf("%d\n", dist[r]-dist[l]);
        }
        return 0;
}

Measured memory_bytes: 2048
#include <iostream>

using namespace std;
const int MAXN = 1e5 * 2 + 10;

int n;
int p[MAXN];
int dp[MAXN];

void solve() {
  int maxSequence = 0;
  for (int i=0;i<n;i++) {
    dp[p[i]] = dp[p[i] - 1] + 1;
    maxSequence = max(maxSequence, dp[p[i]]);
  }
  cout << n - maxSequence << endl;
}

int main() {
  cin >> n;
  for (int i=0;i<n;i++) {
    cin >> p[i];
  }
  solve();
}


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

#define sz(x) (int)(x.size())

#define rep(i, a, b) for(int i=a;i<b;++i)
typedef long long ll;

int const N = 4e5 + 41;
int const INF = 1e9 + 41;

int p[N], x[N], y[N], invP[N], pos[N];
int n, color[N], cnt;
ll ans;

int getOther(int i){
	if(i >= n) return i - n;
	else return i + n;
}

int getVal(int i){
	if(i < n) return x[i];
	else return y[i-n];
}

bool comp(int i, int j){
	return getVal(i) < getVal(j);
}

multiset<int> q[2];

int getMin(multiset<int> &q){
	if(sz(q) == 0) return INF;
	int res = (*q.begin());
	return res;
}

int getMax(multiset<int> &q){
	if(sz(q) == 0) return -INF;
	auto res = (q.end());
	--res;
	return (*res);
}

bool tryMoveLp(int &lp){
	if(pos[invP[p[lp]]] < lp) return false;
	q[0].erase(q[0].find(getVal(p[lp])));
	q[0].insert(getVal(invP[p[lp]]));
	q[1].insert(getVal(p[lp]));
	q[1].erase(q[1].find(getVal(invP[p[lp]])));
	++lp;
	return true;
}

bool tryMoveRp(int &rp, int &cnt){
	if(rp == n * 2) return false;
	if(pos[p[rp]] < pos[invP[p[rp]]]){
		q[0].insert(getVal(p[rp]));
		q[1].insert(getVal(invP[p[rp]]));
		++cnt;
	}
	++rp;
	return true;
}

void solve(){
	ans = INF * 1LL * INF;
	cin >> n;
	rep(i, 0, n) cin >> x[i] >> y[i], p[i] = i, p[i+n] = i + n, invP[i] = i + n, invP[i + n] = i;
	sort(p, p + n * 2, comp);
	rep(i, 0, n * 2) pos[p[i]] = i;
	int lp = 0;
	int rp = 0;
	int cnt = 0;
	while(lp < n * 2){
		if(cnt == n){
			ans = min(ans, (getMax(q[0]) - getMin(q[0])) * 1LL * (getMax(q[1]) - getMin(q[1])));
			if(!tryMoveLp(lp)) break;
		}else{
			if(!tryMoveRp(rp, cnt)) break;
		}
	}
	cout << ans << endl;
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	solve();


	return 0;
}

Measured memory_bytes: 26880
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

ll a[200010], acc[200010];
ll s, ans;

int main(){
    int n;
    cin >> n;
    rep(i, n) cin >> a[i];
    rep(i, n) acc[i+1] = acc[i] + a[i];

    rep(i, n) {
        ll tmp = acc[n] - acc[i+1];
        tmp %= MOD;
        ans += tmp * a[i];
        ans %= MOD;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6756
n = int(input())
h = list(map(int,input().split()))
 
dp = [float("inf")]*n
 
dp[0] = 0
dp[1] = abs(h[1] - h[0])
 
for i in range(1,n):
    dp[i] = min(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]))
print(dp[-1])

Measured memory_bytes: 13928
# n = int(input())
n=input()
a=list(map(int,input().split()))
# neg = 0
# mini = 1000000000000000000000000000
# s = 0
# for i in range(n):
#     if a[i] < 0: neg += 1
#     mini = min(mini, abs(a[i]))
#     s += abs(a[i])
# print(s if neg % 2 == 0 else s - mini*2)

# print(sum(abs(x for x in a))-2*min(abs(x for x in a))if sum([x<0 for x in a])%2else sum(abs(x)for x in a))
b=[abs(x)for x in a]
print(sum(b)-2*min(b)if sum(x<0for x in a)%2else sum(b))

Measured memory_bytes: 14208
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=100000000;

#define cle(n) memset(n,0,sizeof(n))
#define MAXN 1005;

int n,m;

pair<int,int>a[100],b[100];
int main()
{
   while(cin>>n>>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;
int minx=1,miny=0;
         for(int i=0;i<n;i++)
         {
             int maxn=1e9;
             minx=1;
             for(int j=0;j<m;j++)
             {
                 int temp=abs(int(a[i].first-b[j].first))+abs(int(a[i].second-b[j].second));
                 if(maxn>temp)
                 {
                     maxn=temp;
                     minx=j;
                 }
             }
             cout<<minx+1<<endl;
         }

   }

}



Measured memory_bytes: 256
using System;

namespace ConsoleApp3
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var input = int.Parse(Console.ReadLine());
            var result = input;
            while (result > 0)
            {
                result -= 1000;
            }

            Console.WriteLine(-result);
        }
    }
}


Measured memory_bytes: 27544
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        var N = long.Parse(Console.ReadLine());
        var count = dfs("0", N);
        Console.WriteLine(count);
    }

    static long dfs(string current, long N)
    {
        var cur = long.Parse(current);
        if (cur > N)
        {
            return 0;
        }

        bool hasSeven = false;
        bool hasFive = false;
        bool hasThee = false;
        foreach (var ch in current)
        {
            if (ch == '7')
            {
                hasSeven = true;
            }
            else if (ch == '5')
            {
                hasFive = true;
            }
            else if (ch == '3')
            {
                hasThee = true;
            }
        }

        long count = 0;

        if (hasSeven && hasFive && hasThee)
        {
            count++;
        }

        var addValues = new string[] { "7", "5", "3" };
        foreach (var addValue in addValues)
        {
            count += dfs(current + addValue, N);
        }
        return count;
    }
}



Measured memory_bytes: 17232
// https://qiita.com/ofutonfuton/items/92b1a6f4a7775f00b6aeより

#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

const ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

int main()
{
    ll n,k;
    cin >> n >> k;

    //大した量ではないので，先にfax[i]とifax[i]を全て計算しておく
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<300000; i++){
        fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
        ifac[i+1] = ifac[i] * mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }

    for (ll i = 1; i <= k ;i++) {
    	ll b = k;
    	ll r = n - k;

    	ll left = comb(r + 1, i) % M;
    	ll right = comb(b - 1, i - 1) % M;

    	cout << (left * right) % M << endl;
    }

    return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
int main ()
{
	int a,b;
	cin>>a>>b;
	int product = a*b;
	if (product % 2 == 0)
		 {
		 	cout<<"Even"<<endl;
		 }
		 else {
		 	cout<<"Odd"<<endl;
		 }
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if (a * b % 2 == 0) {
      System.out.println("Even");
    } else {
      System.out.println("Odd");
    }
  }
}

Measured memory_bytes: 35564
#include <stdio.h>
#include <vector>
#include <stack>
#include <functional>
#include <numeric>
#include <complex>
#include <queue>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <assert.h>
#include <cstring>
#include <sstream>
#include <string>
#include <algorithm>
#include <iostream>
 
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second
#define pb(x) push_back(x)
#define FOR(k, n) for (int k = 0; k < n; k++)
#define FORN(k, s, n) for (int k = s; k < n; k++)
#define debug(x) printf("x = %d\n", x);
#define debug2(x, y) printf("x = %d, y = %d\n", x, y);
#define debug3(x, y, z) printf("x = %d, y = %d, z = %d\n", x, y, z);
#define debug4(x, y, z, t) printf("x = %d, y = %d, z = %d, t = %d\n", x, y, z, t);
 
#pragma warning(disable : 6031)
#pragma warning(disable : 4101)
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
typedef complex<double> cd;
 
const int INF = 1e9;
const long long LINF = 1e18;
const double PI = acos(-1);
 
// Solution

const int MAXN = 200005;

ll n, tot, sum, xor_sum, A[MAXN], DP[MAXN];
list<pair<ll, ll>> R[MAXN];

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

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

    DP[n - 1] = 0;

    for (int i = n - 2; i >= 0; i--) {
        if (A[i + 1] == 0) {
            DP[i] = 1 + DP[i + 1];
        } else {
            DP[i] = 0;
        }
    }

    if (A[n - 1] != 0) {
        R[n - 1] = {{A[n - 1], n - 1}};
    }

    for (int i = n - 2; i >= 0; i--) {
        R[i] = R[i + 1];

        if (A[i] != 0) {
            if (sz(R[i + 1]) == 20) {
                R[i].pop_back();
            }

            R[i].push_front({A[i], i});
        }
    }

    for (int i = 0; i < n; i++) {
        if (A[i] == 0) {
            tot += 1 + DP[i];
        }

        sum = xor_sum = 0;

        for (pii next : R[i]) {
            sum = sum + next.X;
            xor_sum = xor_sum ^ next.X;

            if (sum == xor_sum) {
                tot += 1 + DP[next.Y];
            }
        }
    }

    printf("%lld\n", tot);

    return 0;
}

Measured memory_bytes: 194048
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

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

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;



int main(){
    int n, tmp=0, total=0;
    cin >> n;
    vector<string> s(n);
    vi t(n);
    rep(i, n){
        cin >> s[i] >> t[i];
        total += t[i];
    }
    string x;
    cin >> x;
    rep(i, n){
        if(x==s[i]){
            tmp+=t[i];
            break;
        }
        tmp+=t[i];
    }
    cout << total - tmp << endl;
}

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

using namespace std;

int main(){
	long long int N;
	cin >> N;
	long long int ans = 1LL << 60;
	for( long long int i = 1; i < N; i++ ){
		long long int j_ = N - i;
		
		long long int i_ = i;
		long long int memo = 0;
		while( i_ ){
			memo += i_ % 10;
			i_ /= 10;
		}
		while( j_ ){
			memo += j_ % 10;
			j_ /= 10;
		}
		ans = min(ans, memo);
	}
	cout << ans << endl;

}

Measured memory_bytes: 256
n = int(input())
d = list(map(int, input().split()))

def is_big(k):
    countA = 0
    countB = 0
    for i in range(n):
        if d[i] >= k:
            countA += 1
        else:
            countB += 1

    if countA >= countB:
        return True
    else:
        return False

def solve(k):
    countA = 0
    countB = 0
    for i in range(n):
        if d[i] >= k:
            countA += 1
        else:
            countB += 1

    if countA == countB:
        return True
    else:
        return False

l = 0
r = 100000
m = (l + r) // 2
#count = 0

while l <= r:
    if is_big(m):
        l = m + 1
        m = (l + r) // 2
    else:
        r = m - 1
        m = (l + r) // 2

#print(m)
#count = 0

if solve(m):
#    print('YES')
    d.sort()
    for i in range(n):
        if d[i] == m:
            print(d[i] - d[i-1])
            break

else:
    print(0)


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

int main(){
  vector<int> a(3);
  for(int i = 0; i < 3; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  cout << a[0] << " " << a[1] << " " << a[2] << endl;
  return 0;
}



Measured memory_bytes: 3140
#include <queue>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
#define MKP make_pair

const int N=2e5+5;
ll ans;
int n,fa[N],pre[N],val[N],num[N];
int find(int x) {return fa[x]==x?fa[x]:fa[x]=find(fa[x]);}

template <typename _Tp> inline void IN(_Tp&x) {
	char ch;bool flag=0;x=0;
	while(ch=getchar(),!isdigit(ch)) if(ch=='-') flag=1;
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	if(flag) x=-x;
}

struct Node {
    long long sum[2], id;
    Node operator+(Node a) { return (Node){sum[0] + a.sum[0], sum[1] + a.sum[1], id}; }
    bool operator<(Node a) const {
        if (sum[0] * a.sum[1] == sum[1] * a.sum[0])
            return (sum[0] == a.sum[0]) ? (sum[1] == a.sum[1] ? id < a.id : sum[1] < a.sum[1])
                                    : sum[0] < a.sum[0];
        return sum[0] * a.sum[1] < sum[1] * a.sum[0];
    }
    bool operator==(Node a) const {
        return sum[0] == a.sum[0] && sum[1] == a.sum[1] && id == a.id;
    }
} P[400005];
struct Q {
    priority_queue<Node> q1, q2;
    void ins(Node t) { q1.push(t); }
    void del(Node t) { q2.push(t); }
    Node top() {
        while (!q1.empty() && !q2.empty() && q1.top() == q2.top())
            q1.pop(), q2.pop();
        return q1.top();
    }

} q;

int main() {
	IN(n);
	for(int i=2;i<=n;++i) IN(pre[i]);
	for(int i=1;i<=n;++i) IN(val[i]),fa[i]=i;
	for(int i=1;i<=n;++i) P[i].sum[0]=!val[i],P[i].sum[1]=val[i],P[i].id=i;
    for(int i=2;i<=n;++i) q.ins(P[i]);
	for (int i = 2; i <= n; ++i) {
        Node u = q.top(), v = P[find(pre[u.id])];
        if (v.id != 1) q.del(v);

        q.del(u), ans += v.sum[1] * u.sum[0], v = v + u, fa[u.id] = fa[v.id];
        P[u.id] = u, P[v.id] = v;

        if (v.id != 1) q.ins(v);
    }
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 30312
D=[1e9]*K=gets.to_i
q=[D[1]=1]
while n=q.shift;[[n*10%K,0,:unshift],[-~n%K,1,:<<]].map{|e,d,m|(D[e]>x=D[n]+d)&&(D[e]=x;q.send(m,e))};end
p D[0]

Measured memory_bytes: 4936
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (int)(1000000007)
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 9999999999999999
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back
#define mxn 200005
#define mxnn 2000005
int n;
void no(){
cout<<"No";
}
void yes(int x){
cout<<"Yes\n";
vector<int>ans(2*n);
map<int,int>mp;
int mx = 2*n-1;
if(x == 2){
ans[n] = x;
ans[n-1] = mx-1;
ans[n+1] = 1;
ans[n+2] = mx;
mp[1];
mp[x];
mp[mx];
mp[mx-1];
}
if(x != 2){
    ans[n] = x;
    ans[n-1] = 1;
    ans[n+1] = mx;
    ans[n+2] = 2;
    mp[x];
    mp[1];
    mp[mx];
    mp[2];
}
map<int,int>mp2;
for(int i = 1;i<=2*n-1;i++){
    if(mp.find(i) == mp.end()) mp2[i];
}
int i = 1;
map<int,int> :: iterator it;
for(it = mp2.begin();it != mp2.end();it++){
    while(ans[i] != 0) i++;
    ans[i] = it->f;
    i++;
}
for(int i = 1;i<=2*n-1;i++) cout<<ans[i]<<"\n";
}
int32_t main(){
sp;
int x;
cin >>n >>x;
if(n == 2){
    if(x == 2){
        cout<<"Yes\n";
        cout<<1<<"\n"<<2<<"\n"<<3<<"\n";
    }
    else no();
    return 0;
}
int a = 1, b= 2*n-1;
if(x == a || x == b) no();
else yes(x);
return 0;
}


Measured memory_bytes: 15744
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }
#define INF           1e9
#define INFL          static_cast<lint>(INF)
#define REP(i,n)      for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)     for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPI(i,ini,n) for(lint i=(ini),i##_len=(n);i<i##_len;++i)
#define REPC(i,obj)   for(auto i:obj)
#define R_UP(a,b)     (((a)+(b)-1)/(b))
#define ALL(obj)      (obj).begin(),(obj).end()
int main()
{
	int n = in(), q = in();
	vector<stack<int>>s(n);
	REP(i, q)
	{
		int t, x;
		switch (in())
		{
		case 0:
			t = in(), x = in();
			s[t].push(x);
			break;
		case 1:
			t = in();
			if (s[t].size() != 0)cout << s[t].top() << endl;
			break;
		case 2:
			t = in();
			if (s[t].size() != 0)s[t].pop();
			break;
		}
	}
}


Measured memory_bytes: 4328
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int main(){
  int n;
  cin >> n;
  long long int a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  if(n%2==1){
  for(int i=n-1;i>=0;i-=2){
    cout << a[i]<<" ";
  }
  for(int i=1;i<n-1;i+=2){
    cout << a[i];
    if(i!=n-2) cout <<" ";
  }
  cout <<endl;
}
 else{
   for(int i=n-1;i>=1;i-=2){
     cout << a[i]<<" ";
   }
   for(int i=0;i<n;i+=2){
     cout << a[i];
     if(i!=n-1) cout<<" ";
   }
   cout <<endl;
}
}


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

int main()
{
  string S;
  cin >> S;
  map<char, int> m;
  rep(i, S.size())
  {
    m[S[i]]++;
  }
  for (auto a : m)
  {
   // cout << a.first << a.second << endl;
    if (a.second != 1)
    {
      cout << "no" << endl;
      return 0;
    }
  }
  cout << "yes" << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


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


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


if __name__ == '__main__':
    N = int(input())

    cnt = {}
    for i in range(1, N + 1):
        res = prime_factorize(i)
        for n in res:
            if n not in cnt:
                cnt[n] = 1
            else:
                cnt[n] += 1

    values = cnt.values()
    ans = 1
    MOD = 1000000007
    for v in values:
        ans *= v + 1
        ans %= MOD

    print(ans)


Measured memory_bytes: 41688
# 2019/07/25

input=open(0).readline

n,k=map(int,input().split())
h=[int(input()) for _ in range(n)]

h.sort()
ans=float('inf')
for i in range(n-(k-1)):
    res=h[i+k-1]-h[i]
    ans=min(ans,res)

print(ans)

Measured memory_bytes: 7508
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
#define int                          long long
#define mod                          1000000007  // 1e9 + 7 >>>  ans%mod
#define greator_sort(arr,n)          sort(arr, arr+n, greater<int>())  //descending order sorting of array
#define mk(arr,n,type)               type*arr = new type[n];    //to make array dynamically // n = size_of_array  |  type = int or long long etc;                      
#define w(x)                         int x;cin>>x; while(x--)   //x = test cases
#define pb                           push_back

/*void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}*/



int32_t main()
{
	//c_p_c();
	string s; cin >> s;
	if (s[1] == 'B') {
		cout << "ARC" << endl;
	}
	else
		cout << "ABC" << endl;
}



Measured memory_bytes: 3580
h,w = map(int, raw_input().split())
n = input()
co = map(int, raw_input().split())
list = []
for x in range(1,n+1):
    for y in range(0,co[x-1]):
        list.append(str(x))
for x in range(0,h):
    if x % 2 == 0:
        print(" ".join(list[w*x:w*(x+1)]))
    else:
        rlist = list[w*x:w*(x+1)]
        rlist.reverse()
        print(" ".join(rlist))

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

int D[10010];

int main(){
    int n,d,s,c=0;
    cin>>n;
    for(int i=0;i<n;i++) cin>>D[i];
    cin>>d;
    for(int i=0;i<d;i++){
        cin>>s;
        D[n]=s;
        int j=0;
        while(D[j]!=s) j++;
        if(j!=n) c++;
    }
    cout<<c<<endl;
    return 0;
}



Measured memory_bytes: 3136
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<double, double> Pdd;
typedef pair<ll, ll> P;

const int mod = 1e9+7;
const int INF = 2e9;
const double epsilon = 1e-7;
const double PI = 3.1415926535;

ll ma(ll x, ll y){
    if(x>y)return x;
    return y;
}
int p[200000];
int d[200001];
int main(void){
    int n; cin >>n;
    for(int i = 0;i < n;i++)cin >> p[i];
    fill(d, d+n+1, 0);
    for(int i = 0;i < n;i++){
        if(d[p[i]-1] == 0)d[p[i]] = -1;
        else if(d[p[i]-1] == -1)d[p[i]] = p[i]-1;
        else d[p[i]] = d[p[i]-1];
    }
    int a = 1;
    for(int i = 1;i <= n;i++)if(d[i] != -1 && d[i] != 0)a = ma(a, i-d[i] + 1);
    cout << n - a << endl;
	return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(long long i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    string s; cin>>s;
    ll n;
    if(s=="SSS") n=0;
    else if(s=="RRR") n=3;
    else if(s.substr(0,2)=="RR" || s.substr(1,3)=="RR") n=2;
    else n=1;
    cout<<n<<endl;
    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>

using namespace std;

int main (){
  int N;
  cin >> N;
  switch(N%10) {
  case 2:
  case 4:
  case 5:
  case 7:
  case 9:
    cout << "hon" << endl;
    break;
  case 0:
  case 1:
  case 6:
  case 8:
    cout << "pon" << endl;
    break;
  case 3:
    cout << "bon" << endl;
  }
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
typedef long long ll;
typedef long double ld;
int main(){
    int n,a;cin>>n;
    vector<int> v(9),list={399,799,1199,1599,1999,2399,2799,3199,4800};
    REP(i,n){
        cin>>a;
        REP(j,9){
            if(a<=list[j]){
                v[j]++;
                break;
            }
        }
    }
    int color=0,mi,ma;
    REP(i,8){
        if(v[i]>0){
            color++;
        }
    }
    mi=max(1,color);
    ma=color+v[8];
    cout<<mi<<" "<<ma<<endl;
    return 0;
}


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

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

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

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

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int h1,m1,h2,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int ans = (h2-h1)*60 + (m2-m1);
    cout << ans - k << endl;
}

Measured memory_bytes: 3640
#include<queue>
#include<cctype>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
using i64=long long;
int read(){int x=0,c=getchar(),f=1;while(isspace(c))c=getchar();if(c=='-')f=-1,c=getchar();while(isdigit(c))(x*=10)+=c&15,c=getchar();return f*x;}
const int N=100007;
vector<int>e[N];queue<int>q;int fa[N];
int main()
{
    int n=read(),m=read();
    for(int i=1,u,v;i<=m;++i) u=read(),v=read(),e[u].push_back(v),e[v].push_back(u);
    q.push(1),fa[1]=-1;
    for(int u;!q.empty();)
    {
	u=q.front(),q.pop();
	for(int v:e[u]) if(!fa[v]) fa[v]=u,q.push(v);
    }
    int flg=1;
    for(int i=2;i<=n;++i) if(!fa[i]) flg=0;
    if(!flg) return puts("No"),0;
    puts("Yes");
    for(int i=2;i<=n;++i) printf("%d\n",fa[i]);
}


Measured memory_bytes: 10532
#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 <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    int n, m, l;
    cin >> n >> m >> l;

    vector<vector<pair<int, int> > > v(n*5);
    for(int i=0; i<m; ++i){
        int d, a, k, t;
        cin >> d >> a >> k >> t;
        int b = d * n + (a - 1);
        v[b].push_back(make_pair(k, t));
    }

    vector<vector<int> > dp(n*5+1, vector<int>(l+1, 0));
    for(int i=0; i<n*5; ++i){
        for(int j=0; j<=l; ++j)
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);

        for(int j=0; j<l; ++j){
            for(const auto& p : v[i]){
                dp[i+p.first][j+1] = max(dp[i+p.first][j+1], dp[i][j] + p.second);
            }
        }
    }
    cout << dp.back().back() << endl;

    return 0;
}

Measured memory_bytes: 3160
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


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

void YN(bool ans){
    if(ans)cout<<"Yes"<<endl;
    else cout <<"No"<<endl;
    return;
}

int main(){
    ll L,R,d;
    cin>>L>>R>>d;
    ll ans = 0;
    rep(i,L,R+1){
        if(i%d == 0)ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>

int main(void)
{
  long long a, b, c, k, ans;

  scanf("%lld%lld%lld%lld", &a, &b, &c, &k);

  if (k <= a )
    ans = k * 1;
  else if ( a < k && k <= a + b)
    ans = a * 1;
  else 
    ans = a * 1 + (-1) * (k - (a + b));

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 1736
#include <iostream>
#include <iomanip>
#include <ios>
#include <sstream>
#include <cstdio>

#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <regex>
#include <utility>
#include <random>

#include <cstddef>
#include <cstdint>
#include <cfloat>
#include <limits>

#include <array>
#include <bitset>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <valarray>
#include <vector>
#include <deque>
#include <forward_list>

#define FOR(i, a, b) for(auto i{a}; i < (b); ++i)
#define RFOR(i, a, b) for(auto i{(b)-1};i >= (a); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) std::begin(a), std::end(a)
#define EACH(x, xs) for (auto &x : xs)
#define CAST static_cast

template<typename T>
constexpr bool in_range(T const &l, T const &a, T const &u){ return l < a && a < u; };
constexpr double inf {std::numeric_limits<double>::infinity()};

#define FAST_TYPE
#ifdef FAST_TYPE
using i32 = std::int_fast32_t;  using i64 = std::int_fast64_t;
using u32 = std::uint_fast32_t; using u64 = std::uint_fast64_t;
#else
using i32 = std::int_least32_t;  using i64 = std::int_least64_t;
using u32 = std::uint_least32_t; using u64 = std::uint_least64_t;
#endif

using imx = std::intmax_t;
using umx = std::uintmax_t;

using namespace std;

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

  i32 N, X;
  cin >> N >> X;

  vector<i32> L(N);
  vector<i32> dp(N+1);
  EACH(li, L) cin >> li;

  i32 dist = 0;
  i32 i;

  for (i = 1; i <= N + 1; ++i) {
    if (dist <= X)
      dist += L[i-1];
    else
      break;
  }


  cout << i - 1 << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e16
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

const int maxn=100000;
const int maxm=200000;
vector<vector<pair<ll,ll>>> g(maxn);
string ans;
ll r[maxm],l[maxm],d[maxm];
ll num[maxn];
ll n,m;

void dfs(int i){
    rep(j,g[i].size()){
        int nextV = g[i][j].first;
        int cost = g[i][j].second;
        if(num[nextV]==INF){
            num[nextV] = num[i] + cost;
            dfs(nextV);
        }else{
            if(num[nextV]!=num[i]+cost){
                ans="No";
                return;
            }
        }
    }
    return;
}

int main(){
    
    cin >> n>> m;
    rep(i,m){
        cin >> l[i]>>r[i]>>d[i];
        l[i]--;r[i]--;
        g[l[i]].push_back(pair<ll,ll>(r[i],d[i]));
        g[r[i]].push_back(pair<ll,ll>(l[i],-d[i]));
    }
    
    fill(num,num+n,INF);
    ans="Yes";
    
    rep(i,n){
        if(num[i]==INF){
            num[i]=0;
            dfs(i);
        }
        if(ans=="No")break;
    }
    
    cout << ans<<endl;
    
    return 0;
}



Measured memory_bytes: 21120
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author __shangu__
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CPrison solver = new CPrison();
        solver.solve(1, in, out);
        out.close();
    }

    static class CPrison {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt(), m = in.nextInt();
            endpt[] a = new endpt[m * 2];
            for (int i = 0; i < m; ++i) {
                a[2 * i] = new endpt(in.nextInt(), 0);
                a[2 * i + 1] = new endpt(in.nextInt(), 1);
            }
            Arrays.sort(a, (b, c) -> {
                return b.v == c.v ? b.isend - c.isend : b.v - c.v;
            });

            int ans = 0, cur = 0;
            for (int i = 0; i < 2 * m; ++i) {
                if (a[i].isend == 0) {
                    ++cur;
                } else {
                    if (cur == m) {
                        ans += a[i].v - a[i - 1].v + 1;
                    }
                    --cur;
                }
            }
            out.println(ans);
        }

        class endpt {
            int v;
            int isend;

            endpt(int v1, int isbegin1) {
                v = v1;
                isend = isbegin1;
            }

        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 46824
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define REP(i, n) for(int i=0;i<(n);++i)
typedef long long ll;
const string MININF = "-";

int match[]={0,2,5,5,4,5,6,3,7,6};
string dp[11000];

void chmax(string &a, string b){
	if(a.size() < b.size()) a = b;
	else if(a.size() == b.size()){
		if(a < b) a = b;
	}
}
signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n, m, a[9];
	cin >> n >> m;
	REP(i, m) cin >> a[i];

	REP(i, 11000) dp[i] = MININF;

	dp[0] = "";
	REP(i, n+1){
		if(dp[i] == MININF) continue;
		REP(j, m) chmax(dp[i+match[a[j]]], dp[i]+(char)('0'+a[j]));
	}
	cout << dp[n] << endl;

	return 0;
}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll C[25];
ll dp[50005][30];

int main()
{
    ll N, M;
    cin >> N >> M;
    REP(i, M)
    {
        cin >> C[i];
    }

    REP(i, N + 1)
    {
        REP(j, M + 1)
        {
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    REP(i, M)
    {
        REP(j, N + 1)
        {
            dp[j][i + 1] = dp[j][i];
            if (j - C[i] >= 0)
                dp[j][i + 1] = std::min(dp[j][i + 1], dp[j - C[i]][i + 1] + 1);
            //cout<<j<<" "<<i<<" "<<dp[j][i+1]<<endl;
        }
    }
    cout << dp[N][M] << endl;
    return 0;
}


Measured memory_bytes: 14820
h,w=map(int,input().split())
a=list(list(input()) for _ in range(h))
for i in range(h):
    for j in range(w):
        if a[i][j]=='.': a[i][j]=0
        elif a[i][j]=='#': a[i][j]=1
for i in range(h):
    if sum(a[i])==0: a[i]=[]
a=[x for x in a if x]
h=len(a)
b=[row for row in zip(*a)]
for i in range(w):
    if sum(b[i])==0: b[i]=[]
b=[x for x in b if x]
w=len(b)
a=[list(row) for row in zip(*b)]
for i in range(h):
    for j in range(w):
        if a[i][j]==0: a[i][j]='.'
        elif a[i][j]==1: a[i][j]='#'
for row in a: print(''.join(row))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  int s;
  cin >> s;
  set<int> a;
  a.insert(s);
  int tmp = s;
  int id = 1;
  while(1){
    if(tmp % 2 == 0){
      tmp = tmp / 2;
    }else{
      tmp = 3*tmp + 1;
    }
    id++;
    if(a.count(tmp)){
      cout << id << endl;
      return 0;
    }
    a.insert(tmp);
  }
}


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

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

	if (R < 1200)
		cout << "ABC" << endl;
	else if( R < 2800 )
		cout << "ARC" << endl;
	else
		cout << "AGC" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    long long int sum = 0;
    for(int i=1; i<=n;i++){
        long long int d = n/i;
        long long int p = i*((d*(d+1))/2);
        sum = sum + p;
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int n,a[100];
int v,w;
int main(){
 cin>>n;
 for(int i = 0;i < n;i++)scanf("%d",&a[i]);

 for(int i = 0;i < n;i++)
 {
  v = a[i];
        w = i - 1;

        while(w >= 0 && a[w] > v)
        {
         a[w + 1] = a[w];
         w--;
         a[w + 1] = v; 
        }
        for(int j = 0;j < n;j++)
        {
       
   if(j < n-1)printf("%d ",a[j]);
         if(j == n-1)printf("%d\n",a[j]);
        }
 }
 return 0;
}


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

#define ll   long long int
#define PI 3.14159265358979
#define zig ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;


char c_turn(string& a)
{
    if(a.empty())
    {
        return '1';
    }
    char turn=a[0];
    a.erase(0, 1);
    return turn;

}

int main()
{
    zig
    string a, b, c;
    char turn='a';
    cin>>a>>b>>c;
    while(1)
    {
        if(turn=='a')
        {
            turn=c_turn(a);
            if(turn=='1')
            {
                cout<<'A';
                break;
            }
        }
        else if(turn=='b')
        {
            turn=c_turn(b);
            if(turn=='1')
            {
                cout<<'B';
                break;
            }
        }
        else
        {
            turn=c_turn(c);
            if(turn=='1')
            {
                cout<<'C';
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

  public void run() {
    
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      String[] lines = in.readLine().split(" ");
      int n = Integer.parseInt(lines[0]);
      int k = Integer.parseInt(lines[1]);

      String line = in.readLine();
      int offset=0,next=0;
      char regx = ' ';
      int[] ax = new int[n];
      for(int i=0; i<n; i++) {
        if((next = line.indexOf(regx,offset)) == -1)
          next = line.length();
        ax[i] = Integer.parseInt(line.substring(offset, next));
        offset = next + 1;
      }

      int min = Integer.MAX_VALUE;
      int sumF=0, sumB=0, sum=0;
      for(int i=0; i<n-k+1; i++) {
        sumF = Math.abs(ax[i]) + Math.abs(ax[i+k-1] - ax[i]);
        sumB = Math.abs(ax[i+k-1] + Math.abs(ax[i+k-1]) - ax[i]);
        sum = Math.min(sumF, sumB);
        if(i == 0 || sum < min) min = sum;
      }

      System.out.println(min);
    }
    catch(IOException e) {
      System.out.println(e);
    }
  }
}

Measured memory_bytes: 37628
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)
	rank := make([]int, 8+1)
	for i := 0; i < n; i++ {
		var tmp int
		fmt.Scan(&tmp)
		rank[checkRank(tmp)]++
	}
	sum := 0
	for i := 0; i < 8; i++ {
		if rank[i] > 0 {
			sum++
		}
	}
	minNum := int(math.Max(float64(1), float64(sum)))
	maxNum := sum + rank[8]
	fmt.Printf("%d %d\n", minNum, maxNum)

}

func checkRank(num int) int {
	if num >= 8*400 {
		return 8
	}
	return num / 400
}


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

using namespace std;

#define ll long long

int main()
{
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif // ONLINE_JUDGE
	ll times=1;
	// cin>>times;
	while(times--)
	{
        int m=1e9+7;
		int n;
        cin>>n;
        int  dp[n+1];
        dp[0]=0;
        dp[1]=0;
        dp[2]=0;
        dp[3]=1;
        for(int i=4;i<=n;i++)
        {
            dp[i]=1;
            for(int j=i-3;j>=0;j--)
            {
                dp[i]=dp[i]%m+dp[j]%m;
                dp[i]=dp[i]%m;
            }
        }
        cout<<dp[n]%m;
	}
}

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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (size_t i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)

const static int MOD = 1000000000 + 7;
const static llong INF = 1LL << 60;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

struct PUF { // 参考 : https://qiita.com/drken/items/cce6fc5c579051e64fab
    vector<int> par;
    vector<int> rank;
    vector<int> diff_weight;

    PUF(int n) {
        par.resize(n);
        rank.resize(n);
        diff_weight.resize(n);
        rep(i, n) par[i] = i, rank[i] = 0, diff_weight[i] = 0;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    int weight(int x) {
        root(x);
        return diff_weight[x];
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y, int w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    int diff(int x, int y) {
        return weight(y) - weight(x);
    }
};

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

    int n, m;
    cin >> n >> m;
    
    PUF people(n);
    rep(i, m) {
        int l, r, d;
        cin >> l >> r >> d;
        --l, --r;
        if (people.issame(l, r)) {
            if (people.diff(l, r) != d) {
                cout << "No" << endl;
                return 0;
            }
        } else {
            people.merge(l, r, d);
        }
    }

    cout << "Yes" << endl;

    return 0;
}

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

int main() {
    unsigned long long n,a[200005]={},b[200005]={},S=0,S1=0;
    cin>>n;
    for(unsigned long long i=1;i<=n;i++){
        cin>>a[i];
        b[a[i]]++;
    }
    for(int i=1;i<=200000;i++){
        if(b[i]!=0){
            S=S+(b[i]-1)*b[i]/2;
        }
    }
    for(int i=1;i<=n;i++){
       S1=S-(b[a[i]]-1)*b[a[i]]/2+(b[a[i]]-2)*(b[a[i]]-1)/2;
        cout<<S1<<'\n';
    }
    return 0;
}

Measured memory_bytes: 5760