akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
#define NIL -1

//二分木の節点
struct Node { int parent, left, right; };

Node T[1000000];
int n, D[1000000], H[1000000];

//二分木の節点の深さ
void setDepth ( int u, int d ) {
  if ( u == NIL ) return;
  D[u] = d;
  setDepth(T[u].left, d+1);
  setDepth(T[u].right, d+1);
}

//二分木の節点の高さ
int setHeight ( int u ) {
  
  int h1,h2;
  h1 = h2 = 0;

  if ( T[u].right != NIL ) {
    h2 = setHeight( T[u].right ) + 1;
  }
  
  if ( T[u].left != NIL ) {
    h1 = setHeight( T[u].left ) + 1;
  }

  if ( h1 > h2 ) return H[u] = h1;
  else return H[u] = h2;
}

//兄弟の番号を求める
//兄弟を持たない場合は-1
int getSibling ( int u ) {
  if ( T[u].parent == NIL ) return NIL;
  if ( T[T[u].parent].left != u && T[T[u].parent].left != NIL ) {
    return T[T[u].parent].left;
  }
  if ( T[T[u].parent].right != u && T[T[u].parent].right != NIL ) {
    return T[T[u].parent].right;
  }
  return NIL;
}

//出力
void print ( int u ) {
  cout << "node " << u << ": ";
  cout << "parent = " << T[u].parent << ", ";
  cout << "sibling = " << getSibling(u) << ", ";
  int deg = 0;
  if ( T[u].left != NIL ) deg++;
  if ( T[u].right != NIL ) deg++;
  cout << "degree = " << deg << ", ";
  cout << "depth = " << D[u] << ", ";
  cout << "height = " << H[u] << ", ";

  if ( T[u].parent == NIL ) {
    cout << "root" << endl;
  } else if ( T[u].left == NIL && T[u].right == NIL ) {
    cout << "leaf" << endl;
  } else {
    cout << "internal node" << endl;
  }
}

int main() {
  int id, left, right, root = 0;
  

  
  //入力
  cin >> n;
  for ( int i = 0; i < n; i++ ) T[i].parent = NIL; //初期化
  for ( int i = 0; i < n; i++ ) {
    cin >> id >> left >> right;
    T[id].left = left;
    T[id].right = right;
    if ( left != NIL ) T[left].parent = id;
    if ( right != NIL ) T[right].parent = id;
  }

  for ( int i = 0; i < n; i++ ) {
    if ( T[i].parent == NIL ) root = i;
  }

  setDepth(root, 0);

  setHeight(root);

  //出力
  for ( int i = 0; i < n; i++ ) print(i);

  return 0;
}

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

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

ll mod_inverse(ll a,ll m){
	ll x,y;
	extgcd(a,m,x,y);
	return (m+x%m)%m;
}

ll n,m;

int main(void){
	scanf("%lld%lld",&n,&m);
	if(n==1LL){
		printf("%lld\n",(m+1LL)%MOD);
		return 0;
	}
	ll d_max=m/(n-1LL);
	ll val2=(((m+1LL)%MOD)*(d_max%MOD))%MOD;
	val2=val2*2LL%MOD;
	ll val3=d_max%MOD;
	ll val4=(n-1LL)%MOD;
	ll val5=(n-1LL)%MOD*(d_max%MOD)%MOD;
	ll val6=(val4+val5)%MOD;
	ll res=(val2-val3*val6%MOD+MOD)%MOD;
	res+=(m+1LL)%MOD;
	res%=MOD;
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 3220
#define _CRT_SECURE_NO_DEPRECATE
#include<bits/stdc++.h>
#define Rint register int
#define MP make_pair
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii; // 注意必要时改类型
typedef vector<int> vi;
const int N = 1e5+5;
int n, m;
ll f[N], w[N], v[N];


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
#ifdef _DEBUG
	int tt = clock();
	// freopen("in.txt", "r", stdin);
#endif 

	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++) scanf("%lld%lld", &w[i], &v[i]); // height and value
	memset(f, 0xcf, sizeof(f));
	f[0] = 0;
	for (int i = 1; i <= n; i++)
		for (int j = m; j >= w[i]; j--)
			f[j] = max(f[j], f[j - w[i]] + v[i]);
	cout << *max_element(f, f + m + 1) << endl;




#ifdef _DEBUG
	cerr << "\nTIME = " << clock() - tt << endl;
	tt = clock();
#endif

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>

int partition(std::vector<int> &v, int left, int right)
{
    int pivot = v[right];
    int index = left - 1;
    int tmp;

    for (int i = left; i < right; i++) {
        if (v[i] <= pivot) {
            index++;
            tmp = v[i];
            v[i] = v[index];
            v[index] = tmp;
        }
    }

    tmp = v[index + 1];
    v[index + 1] = v[right];
    v[right] = tmp;

    return index + 1;

}

int main(int argc, char const *argv[])
{
    int n;
    std::cin >> n;
    std::vector<int> v(n);
    for (int i = 0; i < n; i++) {
        std::cin >> v[i];
    }

    int pivot = partition(v, 0, n - 1);

    for (int i = 0; i < n - 1; i++) {
        if (i == pivot)
            std::cout << "[" << v[i] << "]" << " ";
        else
            std::cout << v[i] << " ";
    }
    if (pivot == n - 1)
        std::cout << "[" << v[n - 1] << "]" << std::endl;
    else
        std::cout << v[n - 1] << std::endl;

    return 0;
}

Measured memory_bytes: 1532
class Dice:
    def __init__(self, top, front, right, left, back, bottom):
        self.top = top
        self.front = front
        self.right = right
        self.left = left
        self.back = back
        self.bottom = bottom

    def print_top(self):
        print(self.top)

    def roll(self, direction):
        if direction == 'S':
            self.south()
        elif direction == 'N':
            self.north()
        elif direction == 'E':
            self.east()
        elif direction == 'W':
            self.west()

    def north(self):
        [self.top, self.back, self.bottom, self.front] = [self.front, self.top, self.back, self.bottom]

    def south(self):
        [self.top, self.back, self.bottom, self.front] = [self.back, self.bottom, self.front, self.top]

    def east(self):
        [self.top, self.right, self.bottom, self.left] = [self.left, self.top, self.right, self.bottom]

    def west(self):
        [self.top, self.right, self.bottom, self.left] = [self.right, self.bottom, self.left, self.top]


labels = input().split()
directions = input()

dice = Dice(*labels)
for direction in directions:
    dice.roll(direction)
dice.print_top()



Measured memory_bytes: 5572
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
 
#define ll              long long int
#define vll             vector<ll>
#define vs              vector <string>                                    
#define mll             map<ll,ll>
#define pll             pair<ll, ll>
#define vpll            vector < pair<ll,ll> >
#define itr             vll::iterator
#define all(c)          c.begin(),c.end()
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define pb              push_back
#define mb              make_pair
#define ff              first
#define ss              second
#define max3(a,b,c)     max(max(a,b),c)                                    
#define min3(a,b,c)     min(min(a,b),c)  
#define mod             1000000007
#define inf             1000000000000000001
#define from(i, n)      for(__typeof(n) i = 0; i <  n; ++i)
#define fromj(i, j, n)  for(__typeof(n) i = j; i <  n; ++i)
#define printv(v)       from(i,v.size())cout<<v[i]<<" ";cout<<"\n";
#define w(x)            int x; cin>>x; while(x--)
 
using namespace std;
using namespace __gnu_pbds; 
 
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);
    freopen("error.txt", "w", stderr);
#endif
}
 
bool func(const pll &a, const pll &b){
    if(a.ss==b.ss)return a.ff<b.ff;
    return a.ss < b.ss;
}
 
typedef tree<int, null_type, less<int >, rb_tree_tag, 
             tree_order_statistics_node_update> pbds; 
 
int main(){
    c_p_c();
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n,k,sum=1;
    cin>>n>>k;
    vll v(n),temp1(1,1);
    from(i,n)cin>>v[i];
    vector<vll >a(n,vll(k+1));
    from(i,n)a[i][0]=1;
    fromj(i,1,k+1){
    	if(v[0]>=i)a[0][i]=1;
    	else a[0][i]=0;
    	sum=(a[0][i]+sum)%mod;
    	temp1.pb(sum);
    } 	
    //printv(temp1);
    fromj(i,1,n){
    	fromj(j,1,k+1){
    		if(j<=v[i])a[i][j]=temp1[j];
    		else a[i][j]=(temp1[j]-temp1[j-v[i]-1]+mod)%mod;
    	}
    	sum=0;
    	from(j,k+1){
    		sum=(a[i][j]+sum)%mod;//%mod;
    		temp1[j]=sum;
    	}
    }
    /*from(i,n){
    	from(j,k+1)cout<<a[i][j]<<" ";
    	cout<<"\n";
    }*/
    cout<<a[n-1][k];
}

Measured memory_bytes: 83292
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9) + 7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int n; cin >> n;
	int a;
	int cnt[100] = {};
	int ma = 0;
	rep(i, n) {
		cin >> a; cnt[a]++; ma = max(ma, a);
	}
	bool f = true;
	if (ma % 2) {
		int d = ma / 2 + 1;
		if (cnt[d] != 2)f = false;
		rep(i, d) {
			if (cnt[i] > 0)f = false;
		}
		Rep(i, d+1, ma + 1) {
			if (cnt[i] < 2)f = false;
		}
	}
	else {
		int d = ma / 2;
		if (cnt[d] != 1)f = false;
		rep(i, d) {
			if (cnt[i] > 0)f = false;
		}
		Rep(i, d + 1, ma + 1) {
			if (cnt[i] < 2)f = false;
		}
	}
	if (f)cout << "Possible" << endl;
	else cout << "Impossible" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
long long n,a[200005];
long long d[200005];
long long sum=0,cnt=0;
vector <long long> v;
int main()
{
	cin>>n;
	for(long long i=0;i<n;i++)
	    cin>>a[i];
	for(long long i=1;i<=n;i++)
		d[i]=d[i-1]+a[i-1];
	sort(d,d+n+1);
	cnt=1;
	for(long long i=1;i<=n;i++)
	{
		if(d[i]==d[i-1])
		    cnt++;
		else
		{
			v.push_back(cnt);
			cnt=1;
		}
	}
	v.push_back(cnt);
	long long ans=0;
	for(long long i=0;i<v.size();i++)
	{
		if(v[i]%2==0)
		    ans+=v[i]/2*(v[i]-1);
		else
		    ans+=(v[i]-1)/2*v[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5492
N = int(raw_input())
CSF = [map(int, raw_input().split()) for _ in range(N-1)]

for i in range(N):
    ans = 0
    for j in range(i, N-1):
        C, S, F = CSF[j][0], CSF[j][1], CSF[j][2]
        if ans < S:
            ans = S
        elif ans % F == 0:
            pass
        else:
            ans = (ans / F + 1) * F
        ans += C

    print ans


Measured memory_bytes: 2692
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define forr(i,p,n) for(ll i=p;i<n;i++)
#define tam 310010
#define offset 30010
using namespace std;
typedef long long  ll;
typedef pair<ll,ll> ii;
typedef pair<ll,ii> iii;
const ll MOD=1e9+7;
int val[320];
int main()
{
   ios::sync_with_stdio(false);cin.tie(0);
   string txt;
   cin>>txt;
   val['g']=1;
   val['p']=-1;
   int tot=0,pos=-1;
   forr(i,0,txt.size())
   {
        tot+=val[txt[i]];
        if (tot==0)
            pos=i;
   }
   tot=0;
   forr(i,pos+1,txt.size())
   {
        tot+=val[txt[i]];   
   }
   cout<<tot/2<<endl;

}   


Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<random>
#include <chrono>
#define lowbit(i) (i&(-i))
using namespace std;

namespace _ {
	bool rEOF = 1;//为0表示文件结尾
	inline char nc() {
		static char buf[100000], *p1 = buf, *p2 = buf;
		return p1 == p2 && rEOF && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? (rEOF = 0, EOF) : *p1++;
	}
	template<class _T>
	inline bool read(_T &num) {
		char c = nc(), f = 1; num = 0;
		while (c<'0' || c>'9')c == '-' && (f = -1), c = nc();
		while (c >= '0'&&c <= '9')num = num * 10 + c - '0', c = nc();
		return (bool)(num *= f);
	}
	inline bool need(char &c) { return c >= 'A'&&c <= 'z' || c >= '0'&&c <= '9' || c >= 'A'&&c <= 'Z'; }//读入的字符范围
	inline bool read_str(char *a) {
		while ((*a = nc()) && need(*a) && rEOF)++a;
		*a = '\0'; return rEOF;
	}
}using namespace _;

void file(bool opt)
{
	if (opt&&fopen("in.txt", "r"))
	{
		freopen("in.txt", "r", stdin);
		//freopen("out.txt", "w", stdout);
	}
}



int main()
{
	//file(1);
	int n,ans=0;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		if (((int)log10(i) + 1) % 2 == 1)ans++;
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  
  auto it = unique(S.begin(), S.end());
  S.erase(it, S.end());
  
  cout << S.size() << endl;
}


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

int main() {
    int n;cin>>n;
    vector<int> a(n);
    int oddcnt=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        if(a[i]%2==1)oddcnt++;
    }
    //cout<<oddcnt<<endl;
    cout<<((oddcnt%2==1)?"NO":"YES")<<endl;

}


Measured memory_bytes: 640
#include<iostream>
#include<stdlib.h>
using namespace std;

int main(){
  int a[1000001];
  int K;
  cin>>K;
  a[1]=7%K;

  for(int i=2;i<=K;i++){
    a[i] = (a[i-1]*10+7) %K;
  }

  //for(int i=1;i<=K;i++){
    //cout<<a[i]<<" ";
  //}

  for(int i=1;i<=K;i++){
    if(a[i]==0){
      cout<<i<<endl;
      return 0;
    }
  }

  cout<<-1<<endl;
}


Measured memory_bytes: 7048
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>
#include<stack>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<ll> h(n);
	rep(i, n) cin >> h[i];
	vector<bool> ans(n, true);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		if (h[a] > h[b]) ans[b] = false;
		else if (h[a] < h[b]) ans[a] = false;
		else {
			ans[a] = false;
			ans[b] = false;
		}
	}
	int cnt = 0;
	rep(i, n) {
		if (ans[i]) cnt++;
	}
	cout << cnt << endl;
}

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

int vis[200005];

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

  int n,m;cin>>n>>m;
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    if(a==1){
      vis[b] += 1;
      if(vis[b]==6){
        cout<<"POSSIBLE"<<endl;return 0;
      }
    } else if (b==n){
      vis[a] += 5;
      if(vis[a]==6){
        cout<<"POSSIBLE"<<endl;return 0;
      }
    }
  }

  cout<<"IMPOSSIBLE"<<endl;return 0;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, e) for (ll (i) = (s); (i) < (e); ++(i))
#define per(i, s, e) for (ll (i) = (s); (i) >= (e); --(i))
#define all(x) x.begin(),x.end()
 
int main(void) {
  ll h; cin >> h;
  ll cnt = log2(h) + 1;
  ll ans = 1;
  ll tmp = 1;
  rep(i, 1, cnt) {
    tmp *= 2;
    ans += tmp;
  }
  cout << ans << endl;
}


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

typedef long long LL;
const int MAX_N = 1e5 + 6;
const LL mod = 1e9 + 7;

LL pow(LL a,LL n,LL mod) {
    if (n==1) return a%mod;
    else if (n==0) return 1%mod;
    LL ret=pow(a,n/2,mod);
    ret*=ret;
    ret%=mod;
    if (n&1) ret*=a;
    return ret%mod;
}

LL fac[MAX_N];
LL revfac[MAX_N];

int a[MAX_N];
int pos[MAX_N];

LL C(int n,int m) {
    //cout<<"n = "<<n<<" , m = "<<m<<" , val = "<<((fac[n]*revfac[m])%mod*fac[n-m])%mod<<endl;
    return ((fac[n]*revfac[m])%mod*revfac[n-m])%mod;
}

int main () {
    fac[0]=1;
    revfac[0] = pow(fac[0],mod-2,mod);
    for (int i=1;MAX_N>i;i++) {
        fac[i] = (fac[i-1]*i) % mod;
        revfac[i] = pow(fac[i],mod-2,mod);
        assert(fac[i]*revfac[i]%mod==1);
    }
    int n;
    scanf("%d",&n);
    int meruru,kirino;
    n++;
    for (int i=1;n>=i;i++) {
        scanf("%d",&a[i]);
        int x=a[i];
        if (pos[x] != 0) {
            meruru=pos[x]-1;
            kirino=n-i;
        }
        else pos[x] = i;
    }
    for (int i=1;n>=i;i++) {
        LL ans=C(n,i);
        if (i==1) {
            printf("%lld\n",ans-1);
            continue;
        }
        //if (meruru >= i-1) ans -= C(meruru,i-1);
        //if (kirino >= i-1) ans -= C(kirino,i-1);
        if (meruru + kirino >= i-1) ans -= C(meruru+kirino,i-1);
        ans = (ans%mod+mod)%mod;
        printf("%lld\n",ans);
    }
}



Measured memory_bytes: 3584
import math
n = 5
lst = []
mini = 10
for i in range(5):
    tmp=int(input())
    if tmp % 10 == 0:
        tmp2 = 10
    else:
        tmp2 = tmp % 10
    if tmp2 < mini:
        mini = tmp % 10
    tmp = math.ceil(tmp/10)
    lst.append(tmp)
print(int(sum(lst)*10) - (10 - mini))

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

string S;

int main() {
    cin >> S;
    int N = S.length();

    int g_cnt = 0;
    int p_cnt = 0;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == 'p') {
            if (p_cnt < g_cnt) {
                p_cnt++;
            }
            else {
                g_cnt++;
                ans--;
            }
        }
        else {
            if (p_cnt < g_cnt) {
                p_cnt++;
                ans++;
            } 
            else {
                g_cnt++;
            }
        }
    }

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


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

namespace ClassLibrary1
{
    public class ListNode
    {
        public int val;
        public ListNode next;
        public ListNode(int x) { val = x; }
    }


    public class Class1
    {
        static Dictionary<Tuple<long, long>, long> dic = new Dictionary<Tuple<long, long>, long>();

        static long mod = 1000000007;
        static long[] factorial = new long[100001];
        static long[] invFactorial = new long[100001];

        private static void calcFanctorial(long N)
        {
            factorial[0] = 1;
            for(int i=1; i< N+1; i++)
            {
                factorial[i] = factorial[i - 1] * i;
                factorial[i] %= mod;
            }
            invFactorial[N] = inv(factorial[N]);
            for (int i = (int)N; i > 0; i--)
            {
                invFactorial[i - 1] = invFactorial[i] * i % mod;
            }

        }

        static void Main(string[] args)
        {


            var N = ReadLong();

            int[][] xx = new int[11][];
            for(int i=0; i<11; i++)
            {
                xx[i] = new int[11];
            }


            for(int i=0; i<N+1; i++)
            {
                var ll = i % 10;
                var hh = i;
                while(hh > 0)
                {
                    if( hh < 10)
                    {
                        break;
                    }
                    hh /= 10;
                }

                xx[ll][hh]++;
            }

            long res = 0;
            for (int i = 1; i < 10; i++)
            { 
                for (int j = 1; j < 10; j++)
                {
                    res += xx[i][j] * xx[j][i];
                }
            }
            Console.WriteLine(res);

        }

        private static long nCm(long n, long m)
        {
            if (n < m) return 0;

             return (factorial[n] * invFactorial[m] % mod) * invFactorial[n-m] % mod;
        }

        public static long pow(long a, long b, long mod)
        {
            a %= mod;

            if (b <= 0) return 1;
            var t = pow(a, b / 2, mod);
            if ((b & 1) == 0) return t * t % mod;
            return t * t % mod * a % mod;
        }

        public static long pow(long a, long b) => pow(a, b, mod);
        public static long inv(long a) => pow(a, mod - 2);


        private static string ReadString()
        {
            return Console.ReadLine();
        }
        private static string[] ReadStringArr()
        {
            return Console.ReadLine().Split(' ');
        }
        private static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadLongArr()
        {
            string[] s = ReadStringArr();
            long[] l = new long[s.Length];
            for(int i=0; i<l.Length; i++)
            {
                l[i] = long.Parse(s[i]);
            }

            return l;
        }
    }

}


Measured memory_bytes: 12884
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#define ll long long
#define fr(i,l,r) for(i=(l);i<(r);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000//10^12

int main(void)
{
	//変数の宣言
	int a,b,c;
	
	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp,temp1,temp2;
	int max,min;
	int len;
	int sum=0;
	
	//データの読み込み
	
	scanf("%d %d %d",&a,&b,&c);
	
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	
	if(a==c){	
		ans=b;
	}
	if(a==b){	
		ans=c;
	}
	if(b==c){	
		ans=a;
	}
	
//	printf("計算部分終了\n");
	
	//出力
	
	printf("%d",ans);
	
	//('・ω・'）
	
//	printf("結果の出力終了\n");
	
	return 0;
}



Measured memory_bytes: 256
n,k,s = input().split()
ans = ""
for i in range(0,int(k)):
    ans += s+" "
l = int(n)-int(k)
a = int(s) - 1
if a==0:
    a = 2
for i in range(0,l):
    ans += str(a)+" "
print(ans)

Measured memory_bytes: 6292
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<int> p(n); REP(i, n) cin >> p[i];
  sort(ALL(p));
  p[n-1] /= 2;
  long long ans = 0;
  REP(i, n) ans += p[i];
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
N,HP=map(int,input().split())
As=[0]*N
Bs=[0]*N
for i in range(N):
    a,b = map(int, input().split())
    As[i] = a
    Bs[i] = b
As.sort(reverse=True)
Bs.sort(reverse=True)

cnt = 0
for b in Bs:
    if As[0] < b:
        HP -= b
        cnt += 1
    else: break
    if HP <= 0: break
print(cnt + ((HP // As[0]) + (HP % As[0] != 0) if HP > 0 else 0))


Measured memory_bytes: 11312
#include <cstdint>

template <std::uint_fast64_t mod> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 v;

  constexpr modint(const u64 x = 0) noexcept : v(x % mod) {}
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    v += rhs.v;
    if (v >= mod)
      v -= mod;
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (v < rhs.v)
      v += mod;
    v -= rhs.v;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    v = v * rhs.v % mod;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = mod - 2;
    while (exp != 0) {
      if (exp % 2 != 0)
        *this *= rhs;
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

#include <algorithm>
#include <cstdint>
#include <iostream>
#include <tuple>
#include <vector>

int main() {
  using mint = modint<1000000007>;
  using usize = std::size_t;
  using i64 = std::int64_t;

  usize n;
  i64 a, b;
  std::cin >> n >> a >> b;
  std::tie(a, b) = std::minmax({a, b});

  std::vector<i64> s(n);
  for (auto &e : s) {
    std::cin >> e;
  }
  std::sort(s.begin(), s.end());

  for (usize i = 0; i + 2 < n; ++i) {
    if (s[i + 2] - s[i] < a) {
      std::cout << 0 << "\n";
      return 0;
    }
  }

  s.insert(s.begin(), s.front() - b);
  s.push_back(s.back() + b);
  n += 2;

  std::vector<mint> dp(n + 1);
  dp[0] = 0;
  dp[1] = 1;
  usize l = 0, r = 0;
  for (usize i = 1; i != n; ++i) {
    while (s[i] - s[r] >= b) {
      r += 1;
    }

    dp[i + 1] = dp[i];
    if (l <= r) {
      dp[i + 1] += dp[r] - dp[l];
    }

    if (s[i] - s[i - 1] < a) {
      l = i - 1;
    }
  }

  std::cout << (dp[n] - dp[n - 1]).v << "\n";

  return 0;
}


Measured memory_bytes: 4932
/*
    AUTHOR:shivam51
    IIESTS
*/
  #include<bits/stdc++.h>
  using namespace std;
  //
  #define add accumulate
  #define ll long long int
  #define ff first
  #define ss second
  // typedef second ss;
  #define pb push_back
  #define mp make_pair
  #define vll vector<ll>
  #define lb lower_bound
  #define ub upper_bound
  #define pll pair<ll,ll>
  #define vpll vector<pll>
  #define all(v) v.begin(), v.end()
  #define rep(i,k,n) for(int i=k;i<n;i++)
  #define hs ios_base::sync_with_stdio(false);cin.tie(NULL);
  const ll mod=1e9+7;
  const ll MAX=3e6+10;
  //
  //
  ll solve(){
    ll x,a;
    cin>>x>>a;
    ll cnt=0,sm=0;
    rep(i,0,x){
      ll k;
      cin>>k;
      sm+=k;
      if(sm<=a)
        ++cnt;
      else
        break;
    }
    cout<<cnt+1;
  }
  int main(){ 
        ll t;
        // cin>>t;
        t=1;
        while(t--)
          solve();
    } 

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

int main() {
    int x, y, z;
    cin >> x >> y >> z;
    int p, q;

    p = x;
    x = y;
    y = p;
    q = x;
    x = z;
    z = q;

    cout << x << " " << y << " " << z << endl;
}

Measured memory_bytes: 3564
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>

#define INF 1e09

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::min;
using std::max;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set; // insert erase find count
using std::queue;
using std::priority_queue;
using std::stack;

typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, pair<int, int> > PIII;

#define MAX 1e05+1

int main(void) {
    int n;
    cin >> n;
    int start;
    int end;
    VI table(MAX + 1, 0);

    for (int i = 0; i < n; i++) {
        cin >> start >> end;
        start--;
        end--;
        table[start]++;
        table[end + 1]--;
    }

    for (int i = 1; i <= MAX; i++) {
        table[i] += table[i - 1];
    }

    for (int i = MAX; i >= 0; i--) {
        if (i <= table[i]) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3080
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        //int customers = Integer.parseInt(sc.next());
        String s = sc.next();
        if(s.equals("hi")) System.out.println("Yes");
        else if(s.equals("hihi")) System.out.println("Yes");
        else if(s.equals("hihihi")) System.out.println("Yes");
        else if(s.equals("hihihihi")) System.out.println("Yes");
        else if(s.equals("hihihihihi")) System.out.println("Yes");
        else System.out.println("No");
        
    }
    
}

Measured memory_bytes: 23252
#include <algorithm>
#include <bitset>
// #include <boost/dynamic_bitset.hpp>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <chrono>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define DEBUG(x) cout << #x << ": " << x << endl
#define INFILE() freopen("input.txt", "r", stdin)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define REPC(i, a) REP(i, 0, a)
#define RREP(i, a, b) for (int i = (a); i >= (b); i--)
#define RREPC(i, a) RREP(i, a, 0)
#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_i = pair<ll, int>;
using i_ll = pair<int, ll>;
using d_i = pair<double, int>;
using ll_ll = pair<ll, ll>;
using d_d = pair<double, double>;

static constexpr ll LL_MOD = 1000000009;
static constexpr ll LL2_MOD = 1000000007;
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr double PI = 3.14159265358979323846264338327950288;

static map<type_index, const char *const> scanType = { { typeid(int), "%d" },
{ typeid(ll), "%lld" },
{ typeid(double), "%lf" },
{ typeid(char), "%c" } };

template <class T> static void scan(vector<T> &v);
static void scan(vector<string> &v, bool isWord = true);
// static boost::dynamic_bitset<> scan(char trueValue = 'o');

int main(int argc, char *argv[]) {
	 //INFILE();
	 
	int n;
	cin >> n;

	vector<int> v(n);
	scan(v);

	int max = -1;
	for (const auto& a : v) {
		if (a > max) {
			max = a;
		}
	}

	bool del = false;
	int total = 0;
	for (const auto& a : v) {
		if (!del && a == max) {
			del = true;
			continue;
		}
		total += a;
	}

	if (max < total) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

template <class T> static void scan(vector<T> &v) {
	auto tFormat = scanType[typeid(T)];
	for (T &n : v) {
		scanf(tFormat, &n);
	}
}

static void scan(vector<string> &v, bool isWord) {
	if (isWord) {
		for (auto &n : v) {
			cin >> n;
		}
		return;
	}

	int i = 0, size = static_cast<int>(v.size());
	string s;
	getline(cin, s);

	if (s.size() != 0) {
		i++;
		v[0] = s;
	}

	for (; i < size; ++i) {
		getline(cin, v[i]);
	}
}

//static boost::dynamic_bitset<> scan(char trueValue) {
//	string s;
//	getline(cin, s);
//
//	if (s.size() == 0) {
//		getline(cin, s);
//	}
//
//	for_each(begin(s), end(s),
//		[trueValue](char &c) { c = (c == trueValue) ? '1' : '0'; });
//	return boost::dynamic_bitset<>(string(rbegin(s), rend(s)));
//}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const double PI=3.14159265358979323846;
const int64_t waru = 1000000007;
const in INF=1<<30;
using vec = vector<vector<int>>;

int main(){
  double n,x,y;
  cin>>n;
  vector<pair<double ,double>> a(n);
  rep(i,n){cin>>x>>y;a.at(i)=make_pair(x,y);}
  vector<int> b(n);
  rep(i,n) b[i]=(double)i;
  double len=0.0;
  do{
    for(int i=0;i<n-1;i++){
      len += sqrt(pow((a[b.at(i)].first-a[b.at(i+1)].first),2)
        + pow((a[b.at(i)].second-a[b.at(i+1)].second),2));
    }
     
  }while(next_permutation(all(b)));
  double ans =len;
  rep(i,n) ans /=(double)(i+1);
  cout << fixed << setprecision(10);
  cout<<ans;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <complex>

using namespace std;
using LL = long long;
using Arrow = complex<LL>;

class Solution {
public:
	double engines(vector<Arrow>& arrows) {
		const int n = arrows.size();
		auto compareAngle = [](const auto& a, const auto& b) {
			return atan2(imag(a), real(a)) < atan2(imag(b), real(b));
		};
		sort(arrows.begin(), arrows.end(), compareAngle);

		Arrow window(0, 0);
		LL ans = 0;
		int R = 0;
		for (int L = 0; L < n; ++L) {
			if (R < L)
				R = L, window = Arrow(0, 0);
			while (R - L < n && norm(window + arrows[R % n]) >= norm(window))
				window += arrows[R % n], ++R;
			ans = max(ans, norm(window)), window -= arrows[L % n];
		}
		return sqrt(ans);
	}
};

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

	vector<Arrow> arrows(n);
	for (int i = 0; i < n; ++i) {
		int x, y;
		cin >> x >> y;
		arrows[i] = Arrow(x, y);
	}

	Solution sol;
	double ans = sol.engines(arrows);
	cout << fixed << setprecision(10) << ans << endl;
	return 0;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            int value = 700;

            for (int i = 0; i < 3; i++)
            {
                if (S[i] == 'o') value += 100;
            }

            Console.WriteLine(value);
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define INF 1000000000000000000
#define N 3001
#define pb push_back
#define MOD 1000000007
#define fn(i,n) for(int i=0;i<n;i+=1)
#define rep(i,l,r) for(int i=l;i<=r;i+=1)
double p[N];
double dp[N][N];
int n;
signed main() {
    cin>>n;
    rep(i,1,n)cin>>p[i];
    dp[1][1]=p[1];
    dp[1][0]=1.0-p[1];
    rep(i,2,n)
    {
        rep(j,0,i+1)
        {
            dp[i][j]+=dp[i-1][j]*(1.0-p[i]);
            if(j>=1)
            dp[i][j]+=dp[i-1][j-1]*p[i] ;
        }
    }
    double ans=0.0;
     rep(i,(n+1)/2,n)
    {
        ans+=dp[n][i];
    }
    cout<<setprecision(10)<<fixed<<ans<<endl;
   


    return 0;
}



Measured memory_bytes: 68992
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include <cassert>
    #include <cmath>
    #include<cstdint>

    #define INF 1e7
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()

    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<int,int>;


    int main(){
        int n;cin>>n;
        cout<<(n+1)/2;
    }
    


Measured memory_bytes: 256
// ================
// Himanshu Lal
// MNIT Jaipur
// ================
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define TEZ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rf(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define INF 1e18
#define vi vector<pair<ll,ll>>
#define ff first
#define ss second
#define mp map<ll,ll>
#define test ll tp; cin>>tp; while(tp--)
#define srt(v) sort(v.begin(),v.end())
double pi=acos(-1);
void OJ(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    #endif
}
int main(){
    ll n;
    cin>>n;
    ll p=n%1000;
    if(p==0){
        cout<<"0";
        return 0;
    }
    cout<<(1000-p);
}

Measured memory_bytes: 3620
#include <stdio.h>
int main(void){
	
	int n,i,j,x;
	int cards[4][13]={0};
	char a;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%c",&a);
		scanf("%c %d",&a,&x);
		if(a=='S'){
			cards[0][x-1]=1;
		}else if(a=='H'){
			cards[1][x-1]=1;
		}else if(a=='C'){
			cards[2][x-1]=1;
		}else{
			cards[3][x-1]=1;
		}
	}
	for(i=0;i<4;i++){
		for(j=0;j<13;j++){
			if(cards[i][j]==0){
				if(i==0){
					printf("S %d\n",j+1);
				}else if(i==1){
					printf("H %d\n",j+1);
				}else if(i==2){
					printf("C %d\n",j+1);
				}else{
					printf("D %d\n",j+1);
				}
			}else{}
		}
	}
	
	return 0;
}


Measured memory_bytes: 2060
#include <bits/stdc++.h>
#define ll long long int
#define pr pair<ll, ll>
#define tp tuple<ll, ll, ll>
using namespace std;
long long int mod = 1e9 + 7;

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

    ll k, count = 1;
    cin >> k;
    ll ans[11] = {0};
    ans[0] = 1;
    for (ll i = 0; i < k - 1; i++)
    {
        ll flag = 0;
        for (ll j = count - 1; j > 0; j--)
        {
            if (ans[j] == 9)
                continue;
            if (ans[j - 1] - ans[j] == 1 || ans[j - 1] - ans[j] == 0)
            {
                ans[j]++;
                for (ll p = j + 1; p < count; p++)
                {
                    ans[p] = fmax(0, ans[p - 1] - 1);
                }
                flag = 1;
                break;
            }
        }
        if (flag == 0)
        {
            if (ans[0] != 9)
            {
                ans[0]++;
                for (ll j = 1; j < count; j++)
                {
                    ans[j] = fmax(0, ans[j - 1] - 1);
                }
            }
            else
            {
                count++;
                ans[0] = 1;
                for (ll j = 1; j < count; j++)
                {
                    ans[j] = 0;
                }
            }
        }
    }

    for (ll i = 0; i < count; i++)
    {
        cout << ans[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include"math.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std; 
int main(){
           int n;cin>>n;
           vector<pair<int,int>> a(n);
           rep(i,n){cin>>a[i].first;
                   a[i].second=i+1;}
           sort(a.begin(),a.end());
           rep(i,n)cout<<a[i].second<<" ";
             cout<<endl;
          }
           
          

Measured memory_bytes: 1664
#pragma warning(disable: 4996)
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <sstream>
#include <fstream>
#include <math.h>
#include <algorithm>
#include <map>
#include <bitset>
#include <queue>

using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
const int INF = 1000000007;
int main() {
    int n;
    cin >> n;
    ll a = 1, b = 1, c = 1;
    while (n > 0) {
        n--;
        a *= 10;
        a = a % INF;
        b *= 9;
        b = b % INF;
        c *= 8;
        c = c % INF;
    }
    ll ans = 0;
    b *= 2;
    b = b % INF;
    ans = a - b + c;
    if (ans < 0)ans += INF;
    ans = ans % INF;
    cout << ans << endl;
   
    return 0;
}

Measured memory_bytes: 3152
#include <stdio.h>
#define MAX 100000
int main(){
  int A[MAX],count=0,i,j,lef=0,rig=0,X,n,arr;

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

  for(i=0;i<n-1;i++){
    if(A[rig]<=X){
      arr=A[lef];
      A[lef]=A[rig];
      A[rig]=arr;
      rig++;
      lef++;
      count++;
    }
    else{
      rig++;
    }
  }
  arr=A[lef];
  A[lef]=X;
  A[rig]=arr;
    for(i=0;i<count;i++){
      printf("%d ",A[i]);
    }
  i++;
  printf("[%d] ",A[i-1]);
  for(i=i;i<n-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[n-1]);
  return 0;
}

Measured memory_bytes: 988
#include<stdio.h>
int main(){
  int x,y;

  while(1){
      scanf("%d %d",&x,&y);
      if(x==0&&y==0)break;
  for(int i=0;i<x;i++){
    for(int j=0;j<y;j++){
      printf("#");
    }
    printf("\n");
  }
  printf("\n");
  }
  return 0;
  
}



Measured memory_bytes: 2040
import java.util.*;

/**
 * A
 */
public class Main {

    Node root;

    public void run() {

        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        
        for(int i=0; i<m; i++) {
            String str = sc.next();
            if(str.startsWith("i")) {
                insert(sc.nextInt());
            } else {
                inorder(root);
                System.out.println();
                preorder(root);
                System.out.println();
            }
        }

        sc.close();

    }

    public void insert(int v) {

        Node x = root; // root
        Node y = null; // parent of x
        Node z = new Node(v); // it will be inserted

        while(x != null) {
            y = x;
            if(z.id < x.id) {
                x = x.left;
            } else {
                x = x.right;
            }
        }
        if(y == null) {
            root = z;
        } else if(z.id < y.id) {
            y.left = z;
        } else {
            y.right = z;
        }

    }

    public void inorder(Node tree) {
        
        if(tree == null) {
            return;
        }

        inorder(tree.left);
        System.out.print(" "+tree.id);
        inorder(tree.right);

    }

    public void preorder(Node tree) {

        if(tree == null) {
            return;
        }

        System.out.print(" "+tree.id);
        preorder(tree.left);
        preorder(tree.right);

    }

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

}

class Node {

    int id;
    Node left;
    Node right;

    Node(int id) {
        this.id = id;
    }

}


Measured memory_bytes: 209976
//#define _GLIBCXX_DEBUG
//#pragma GCC optimize "trapv"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
// #pragma optimization_level 3
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


#define pb push_back 
#define f first
#define s second
#define min3(a, b, c) min(min(a, b), c)
#define max3(a, b, c) max(max(a, b), c)
#define all(v) v.begin(), v.end()

typedef long long ll;
typedef double ld;
typedef long double lld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

template <class T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

const int INF = 1e9;
//const ll INF = 1e18;
const ll mod = 1000000007;
// const ll mod = 998244353;

void solve(int tc){
    int x;
    cin >> x;
    if(x == 0) cout << 1 << "\n";
    else cout << 0 << "\n";
}

int main(){
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    
    int tc = 1;
    //cin >> tc;
    for (int t = 0; t < tc; t++) solve(t);

    return 0;
}

Measured memory_bytes: 3604
K = int(input())

#nはstr型で入力
def f(n):
    global l
    if len(n) == 11:
        return 
    else:
        l.append(int(n))
        n_last = int(n[-1])
        n1, n2, n3 = n_last-1, n_last, n_last+1
        if n_last == 0:
            f(n+str(n2))
            f(n+str(n3))
        elif n_last == 9:
            f(n+str(n1))
            f(n+str(n2))
        else:
            f(n+str(n1))
            f(n+str(n2))
            f(n+str(n3))
            


l = [i for i in range(1, 10)]

for j in range(10):
    f(str(j))
ll = sorted(list(set(l)))
print(ll[K])

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

int main(int argc, char const *argv[])
{
	int a,memo[4]={};
	for (int i = 0; i < 6; ++i)
	{
		cin>>a;--a;
		++memo[a];
	}
	int cnt=0;
	for (int i = 0; i < 4; ++i)
	{
		if (memo[i]%2==1)
		{
			++cnt;
		}
	}
	if (cnt==0||cnt==2)
	{
		cout<<"YES\n";
	}
	else
	{
		cout<<"NO\n";
	}
	return 0;
}


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

using namespace std;
const int MAXN = 310;
int nowarn;

int n, m, a[MAXN][MAXN], ans;

int vis[MAXN], cnt[MAXN];

int main() {
	nowarn = scanf( "%d%d", &n, &m );
	for( int i = 1; i <= n; ++i )
		for( int j = 1; j <= m; ++j )
			nowarn = scanf( "%d", &a[i][j] );
	ans = n;
	for( int i = 1; i <= m; ++i ) vis[i] = 1;
	for( int t = 0; t < m-1; ++t ) {
		for( int i = 1; i <= m; ++i ) cnt[i] = 0;
		for( int i = 1; i <= n; ++i )
			for( int j = 1; j <= m; ++j ) {
				int k = a[i][j];
				if( vis[k] ) {
					++cnt[k];
					break;
				}
			}
		int p = int(max_element(cnt+1, cnt+m+1) - cnt);
		ans = min(ans, cnt[p]);
		vis[p] = 0;
	}
	printf( "%d\n", ans );
	return 0;
}


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

long long n,a[2*102400],b[2*102400],cnt;

int main(){
	cin >> n;
	for(int i=1;i<=n;i++) cin >> a[i];
	long long curr=a[1],L=1;
	for(int i=2;i<=n;i++){
		while(L<i&&(a[i]&curr)!=0l) curr^=a[L],L++;
		cnt+=i-L+1;curr|=a[i];
	}
	cout << cnt+1;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#define pb push_back
#define mp make_pair
#define pie 3.141592653589793238
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
/////////////////////////////////////////////////////////////////////
const ll mod = 1e9 + 7;
const int N = 1e6 + 9;
ll a[N][6];
ll dp[6][N];
vector <ll> v[N];
ll modexp(ll a, ll n)
{
    ll r = 1;
    while(n){
        if(n & 1)
            r = (r * a) % mod;
        a = (a * a) % mod;
        n >>= 1;
    }
    return r;
}
bool cmp(const pair<double, ll> &a, const pair<double, int> &b)
{
    if(a.first == b.first){
        return a.second < b.second;
    }
    else return a.first > b.first;
}
int main()
{
    fast;
    string a, b, c, kk;
    cin >> a >> b >> c;

    kk += toupper(a[0]);
    kk += toupper(b[0]);
    kk += toupper(c[0]);
    cout << kk << endl;
    return 0;
}


Measured memory_bytes: 24832
#include <bits/stdc++.h>
#define dbug(x) cout<<#x<<"="<<x<<endl
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
int n,a[1000010];
int main() {
	//freopen("1.txt","r",stdin);
	read(n);
	for (int i=1;i<=n;i++) read(a[i]);
	for (int i=n-1;i>=1;i--) {
		if (a[i]>a[i+1]) a[i]--;
		if (a[i]>a[i+1]) { printf("No\n"); return 0; }
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdbool.h>

bool is_equilateral_triangle(unsigned char *A, unsigned char *B, unsigned char *C)
{
    if (*A == *B && *B == *C) { return true;  }
    else                      { return false; }
}

void exawizard2019_a(unsigned char *A, unsigned char *B, unsigned char *C)
{
    if (is_equilateral_triangle(A, B, C)) { printf("%s\n", "Yes"); }
    else                                     { printf("%s\n", "No" ); }
}

int main (void)
{
    /* variables for main process */
    unsigned char A, B, C;

    /* support variables for main process */
    int retval_scanf;

    // STEP.01
    // read out the given integers
    retval_scanf = scanf("%hhu %hhu %hhu", &A, &B, &C);

    // STEP.02
    // determine if there exists an equilateral triangle whose sides have lengths A, B and C.
    exawizard2019_a(&A, &B, &C);
    
    // STEP.TRUE_END
    return 0;
}

Measured memory_bytes: 128