akhauriyash/Code-Regression huggingface dataset:
#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; 
  
#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int mod = (int)1e9 + 7;
const int MX = (int)1e5 + 10;

void add_self(int &x, int y){x += y; if(x >= mod) x -= mod;}
void sub_self(int &x, int y){x -= y; if(x < 0) x += mod;}
void mul(int &x, int y){x = x * 1LL * y % mod;}

int main(){

	cin.tie(0); cout.tie(0);
	ios_base::sync_with_stdio(0);

	int l;
	cin >> l;
	
	double side = l / 3.0;
	cout << fixed << setprecision(10) << side * side * side << endl;
	
	return 0;
}

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

using namespace std;

#define sz(v)           ((int)((v).size()))
#define clr(v, d)       memset(v, d, sizeof(v))
#define rep(i, v)       for(int i=0; i<sz(v); ++i)
#define lp(i, n)        for(int i=0; i<(int)(n); ++i)
#define lpi(i, j, n)    for(int i=(j); i<(int)(n); ++i)
#define lpd(i, j, n)    for(int i=(j); i>=(int)(n); --i)
#define INF             1000000000

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

void init(){
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

const int N = 55;

int main()
{
	init();
	int ans = 0, s_sofar = 0;
	string str;
	cin >> str;
	lp(i, sz(str)){
		if(str[i] == 'S')
			++s_sofar;
		else{
			if(s_sofar){
				ans += 2;
				--s_sofar;
			}
		}
	}
	cout << sz(str) - ans;
	return 0;
}



Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define vll vector<ll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll> 
#define fo(i,n) for(ll i=0;i<n;i++)
#define foa(i,s,e) for(ll i=(s);i<e;i++)
#define fod(i,s,e) for(ll i= (s);i>=(e);i--)
const ld pi = 3.14159265358979323846;
ll mod1 = 1e9 + 7;
ll mod2 = 998244353;
ll mul(ll x,ll y){
    return (1ll* (x%mod1)*(y%mod1));
}
ll modpow(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=z*x;x =x*x ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);} 
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}
ll sq(ll a){
    ll ans = (1ll*a*a);
    return ans;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    //freopen("error.txt" , "w" , stderr) ;
    #endif
    ll n;
    cin>>n;
    ll a[n];
    ll p = 1;
    fo(i,n){
        cin>>a[i];
    }
    sort(a,a+n);
    fo(i,n){
        if(p && a[i]>LLONG_MAX/p){
            cout<<-1<<"\n";
            return 0;
        }
        p*=a[i];
        if(p>(ll)1e18 || p<0LL){
            cout<<-1<<"\n";
            return 0;
        }
        
    }
    
    cout<<p<<"\n";

}


Measured memory_bytes: 4444
#include<stdio.h>

int main (void)

{

 int W,H,x,y,r;
 scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
 if(x+r<=W && x-r>=0 && y+r<=H && y-r>=0){

 printf("Yes\n");

}

else{

 printf("No\n");

}

return 0;

}

Measured memory_bytes: 584
n, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
tally = Hash.new { 0 }
a.each do |num|
  tally[num] += 1
end

sorted_tally_count = tally.values.sort

puts sorted_tally_count[0...sorted_tally_count.size - k].inject(:+) || 0


Measured memory_bytes: 32880
# 逆数 x^(-1)
def inv(x):
    global p
    res=1
    prod=x
    e=p-2
    while e>0:
        if e%2==1:
            res=(res*prod)%p
        prod=(prod*prod)%p
        e//=2
    return res

# 階乗 x!
def fact(x):
    if x<1:
        return 1
    global p
    res=1
    for i in range(2, x+1):
        res=(res*i)%p
    return res

p=10**9+7
N,M=map(int,input().split())

if abs(N-M)>1:
    ans=0
else:
    ans=(fact(N)*fact(M))%p
if N==M:
    ans=(ans*2)%p

print(ans)

Measured memory_bytes: 3064
N = int(input())
A = [int(input()) for i in range(N)]
Amax = max(A)
cnt = A.count(Amax)
if cnt >= 2:
    for i in range(N):
        print(Amax)
else:
    A[A.index(Amax)] = 0
    b = max(A)
    for a in A:
        if a == 0:
            print(b)
        else:
            print(Amax)

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  while (1) {
    C -= B;
    if (C <= 0) {
      cout << "Yes" << endl;
      break;
    }
    A -= D;
    if (A <= 0) {
      cout << "No" << endl;
      break;
    }
  }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long 
#define MAXN 1000010

using namespace std;

int n, m, d, x;
int f;
int a[MAXN];
ll t;
string s;

int main() {
	scanf("%d", &n);
	
//	for (int i = 1; i <= n; i++) {
//		scanf("%d", &a[i]);
//	}
	for (int i = 1; i <= n - 1; i++) {
		t += i;
	}
	cout << t << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
inline int read()
{int x=0;
char c=getchar();
while (c<'0'||c>'9') c=getchar();
while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
return x;
}
int sg[100005],head[100005],nxt[200005],v[200005],n,tot=0;
inline void add(int a,int b)
{tot++;nxt[tot]=head[a];head[a]=tot;v[tot]=b;}
void dfs(int pos,int f)
{for (int i=head[pos];i;i=nxt[i])
{if (v[i]==f) continue;
dfs(v[i],pos);
sg[pos]^=(sg[v[i]]+1);
}
}
int main (){
	int i,a,b;
	n=read();
	for (i=1;i<n;i++)
	{a=read();b=read();
	add(a,b);add(b,a);
	}
	dfs(1,0);
	puts(sg[1]?"Alice":"Bob");
	return 0;
}

Measured memory_bytes: 7296
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            String str = sc.next();
            if(str.equals("-")){
                break;
            }
            int shuf = sc.nextInt();
            int[] h = new int[shuf];
            for(int i = 0; i < shuf; i++){
                h[i] = sc.nextInt();
            }
            for(int i = 0; i < shuf; i++){
                str = str.substring(h[i]) + str.substring(0, h[i]);
            }
            System.out.println(str);
        }
    }
}


Measured memory_bytes: 26432
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define prtd(var, i) cout << fixed << setprecision(i) << var << endl;
#define ll long long
using namespace std;

int main(){
    int a;
    cin >> a;
    int b = a + (a*a) + (a*a*a);
    cout << a+pow(a,2)+pow(a,3) << endl;
}

Measured memory_bytes: 4284
def moves(pos)
    return [[-1, 0], [1, 0], [0, -1], [0, 1]].map do |move|
        pos.zip(move).map{|x, d| x + d}
    end
end

h, w = gets.chomp.split(" ").map(&:to_i)

# input padded with wall
s = [[false] * (w + 2)]
h.times do
    s << [false, gets.chomp.split("").map{|chr| chr == "."}, false].flatten
end
s << [false] * (w + 2)

brank_cell = s.flatten.count(true)

# bfs
visited = Array.new(h + 2).map{|row| Array.new(w + 2)}
visited[1][1] = true
queue = [[1, 1]]
step = 1
while !visited[h][w] && brank_cell - step > -1
    new_queue = []
    queue.each do |pos|
        moves(pos).each do |newpos|
            x, y = newpos
            if s[x][y] && !visited[x][y]
                new_queue << newpos
                visited[x][y] = true
            end
        end
    end
    step += 1
    queue = new_queue
end

# puts brank_cell - step > 0 ? brank_cell - step : -1
puts [brank_cell - step, -1].max

Measured memory_bytes: 1916
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) begin(x),end(x)
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
	int a, b, h;
	cin >> a >> b >> h;
	cout << ( a + b ) * h / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 50
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int n;
   double v[N] = {}, ans = 0;
   cin >> n;
   for (int i = 0; i < n; i++)
      cin >> v[i];   
   sort(v,v+n);
   ans = v[0];
   for (int i = 1; i < n; i ++)
      ans = (ans+v[i])/2;
   
   cout << ans << endl;

   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;
//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}
 
 
 
 
 
 
 













const int N=2005;
int u[N][N],l[N][N],r[N][N],d[N][N];
char s[N][N];
int main()
{
     int h,w;
     cin>>h>>w;
     string t;
     for(int i=1;i<=h;i++){
          cin>>t;
          for(int j=0;j<t.length();j++){
               s[i][j+1]=t[j];
          }
     }
     for(int i=1;i<=h;i++){
          for(int j=1;j<=w;j++){
               if(s[i][j]=='#'){l[i][j]=0;u[i][j]=0;}
               else {
                    l[i][j]=1+l[i][j-1];
                    u[i][j]=1+u[i-1][j];
               }
          }
     }
     for(int i=h;i>=1;i--){
          for(int j=w;j>=1;j--){
               if(s[i][j]=='#'){r[i][j]=0;d[i][j]=0;}
               else{
                    r[i][j]=1+r[i][j+1];
                    d[i][j]=1+d[i+1][j];
               }
          }
     }
    /* for(int i=1;i<=h;i++){
          for(int j=1;j<=w;j++)cout<<r[i][j]<<" ";
          cout<<"\n";
     }*/
     int mx=0;
     for(int i=1;i<=h;i++){
          for(int j=1;j<=w;j++){
               if(s[i][j]=='.'){
                    mx=max(mx,l[i][j]+r[i][j]+u[i][j]+d[i][j]-3);
               }
          }
     }
     cout<<mx;
    
}

























Measured memory_bytes: 66944
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b){
  ll r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


ll LCM(ll a,ll b){
  ll c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}


ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n,ans=0,a=50,b=50;
  bool flag=true;
  cin>>n;
  if(n%2==1){
    cout<<0<<endl;
  }else{
    ans+=n/10;
    while((n/a)>0){
      ans+=n/a;
      a*=5;
    }

    cout<<ans<<endl;
  }
  
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip> //fixed << setprecision(10)

using namespace std;

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

typedef long long ll;
typedef vector<int> vi;

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

    cout << (n-1)/2 << endl;
    
    return 0;
}


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

int main() {
    int x;
    cin >> x;
    int ans = 1;
    for (int i = 2; i <= x; i++){
        int b = i * i;
        while(b <= x){
            ans = max(ans, b);
            b *= i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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


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

int E=1000000007;
int main() {
   int S;
   cin >> S;
   int dp[S+1];
   for (int i=0; i<S+1; i++) dp[i]=0;
   dp[0]=1;
   for (int i=3; i<S+1; i++) {
       for (int j=3; j<i+1; j++) {
           dp[i]+=dp[i-j];
           dp[i]%=E;
       }
   }
   cout << dp[S] << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep( i, n ) for (ll i = 0; i < ( ll )(n); i++)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair< int , int > P;
typedef tuple<int, int, int> T;



int main(){
    ll n,d;
    ll ans =0;
    cin>>n>>d;

    ll d2=d*d;
    rep(i,n){
        ll x,y;
        cin>>x>>y;
        if ((x*x+y*y)<=d2) ans++;
    }
    cout<<ans;
}


Measured memory_bytes: 3632
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))
import math
from decimal import Decimal
'''
A, B = map(str, sys.stdin.readline().split())
A = Decimal(A)
B = Decimal(B)
print(A * B//1)
'''
A, B = map(str, sys.stdin.readline().split())
A = int(A)
B = int(round(float(B)*100))
print(A*B//100)

Measured memory_bytes: 9952
from scipy.misc import comb

N,P=map(int,input().split())
A=list(map(int,input().split()))
e,o = 0,0

for i in A:
    if i%2==0:
        e +=1
    else:
        o +=1
#print(e,o)
       
if P==0:
    e_x = 2**e
    o_x = 0
    for j in range(0,o+1,2):
        #print(j,comb(o,j,exact=True))
        o_x += comb(o,j,exact=True)
else:
    e_x = 2**e
    if o==0:
        o_x = 0
    else:
        o_x = 0
        for j in range(1,o+1,2):
            #print(j,comb(o,j,exact=True))
            o_x += comb(o,j,exact=True)

ans = e_x * o_x
print(ans)        


Measured memory_bytes: 13848
c,t,d[4010]={1};char s[4010];i;main(j){for(gets(s);s[i/2];d[j]=!++i)for(j=c+=s[i]?t+=2,s[i]%3:0;j>i+c-t&&~j;d[j--]%=998244353)d[j]+=d[j-1];printf("%d",d[c]);}

Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] nums = new int[n - 1];
        for (int i = 0; i < n - 1; i++) {
            nums[i] = sc.nextInt();
        }
        int[] A = new int[n];
        int max = Integer.MIN_VALUE;
        for (int i = 0; i < n - 1; i++) {
            A[i] = nums[i];
            A[i + 1] = nums[i];
            if (i != 0) {
                if (A[i] > nums[i - 1]) {
                    A[i] = nums[i - 1];
                }
            }
        }
        int sum = 0;
        for (int tmp : A) {
            sum += tmp;
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

struct BinomialCoefficient  {
    BinomialCoefficient() {
        
    }
    
    BinomialCoefficient(int n) : fac(n + 2), finv(n + 2), inv(n + 2) {
        initialize(n, false);
    }
    
    void initialize(int n, bool resize = true) {
        if (resize) {
            fac.resize(n + 2);
            finv.resize(n + 2);
            inv.resize(n + 2);
        }
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i <= n; i++) {
            fac[i] = fac[i - 1] * i % mod;
            inv[i] = mod - inv[mod % i] * (mod / i) % mod;
            finv[i] = finv[i - 1] * inv[i] % mod;
        }
    }
    
    ll factorial(int n) {
        return fac[n];
    }
    
    ll combination(int n, int r) {
        if ((n < r) || (n < 0) || (r < 0)) return 0;
        return fac[n] * (finv[r] * finv[n - r] % mod) % mod;
    }
    
    ll permutation(int n, int r) {
        if ((n < r) || (n < 0) || (r < 0)) return 0;
        return fac[n] * finv[n - r] % mod;
    }
    
private:
    int mod = 1e9 + 7;
    vector<ll> fac, finv, inv;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    const ll mod = 1e9 + 7;
    ll n, k;
    cin >> n >> k;
    BinomialCoefficient bc(n + k);
    reps(i, 1, k + 1) {
        cout << (bc.combination(n - k + 1, i) * bc.combination(k - 1, i - 1)) % mod << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>

typedef struct _wordspec wordspec;
struct _wordspec {
    int occur;
    char *word;
    wordspec *next;
};

int main(void) {
    char text[1001], wbuf[33], *word, dlm = ' ', *max_occur_word, *max_len_word;
    int i, len, spc_idx = 0, max_occur = 0, max_len = 0;
    wordspec *wspc[58], spc[500], *ws;

    for (i = 0; i < 58; i++) {
        wspc[i] = NULL;
    }
    gets(text);
    word = strtok(text, &dlm);
    do {
        ws = wspc[word[0] - 'A'];
        while (ws != NULL) {
            if (strcmp(ws->word, word) == 0) {
                ws->occur++;
                if (max_occur < ws->occur) {
                    max_occur = ws->occur;
                    max_occur_word = word;
                }
                break;
            }
            ws = ws->next;
        }
        if (ws == NULL) {
            ws = &spc[spc_idx++];
            ws->occur = 1;
            ws->word = word;
            ws->next = wspc[word[0] - 'A'];
            wspc[word[0] - 'A'] = ws;
        }
        len = strlen(word);
        if (max_len < len) {
            max_len = len;
            max_len_word = word;
        }
    }while ((word = strtok(NULL, &dlm)) != NULL);
    printf("%s %s\n", max_occur_word, max_len_word);
    return 0;
}

Measured memory_bytes: 540
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE LambdaCase #-}
module Main where

import           Data.List
import           Control.Monad
import           Debug.Trace
import qualified Data.ByteString.Char8         as BC
import           Data.Maybe                     ( fromJust )
import qualified Data.Set                      as S
import qualified Data.IntMap.Strict            as IM
import qualified Data.IntMap.Lazy            as IML
import qualified Data.Map.Strict               as M
import           Data.Char
import qualified Data.Array.IArray as A
import qualified Data.Array.Unboxed as UA
import Data.Bits
import Control.Monad.State.Strict
import qualified Data.Array.ST as STA
import qualified Data.Array.MArray as MA
import Control.Monad.ST



readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as =
    let (fo, la) = span f as
        las      = case la of
            [] -> []
            xs -> split f $ tail xs
    in  case fo of
            [] -> las
            xs -> xs : las


main :: IO ()
main = do
    (n, k) <- readTuple2
    ass <- replicateM k $ do
        _ <- getLine
        readInts
    let as = join ass
    let s = S.fromList as
    print $ n - S.size s





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

using namespace std;

#define ll long long
constexpr ll inf = 1e9+7;

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

    ll X;
    cin>>X;
    ll ans = 1;
    for (ll x = 2; x < (ll)sqrt(X) + 1; x++) {
        ll a = x * x;
        while (a * x <= X) a *= x;
        ans = max(a, ans);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int main(){
   // freopen("file.in", "r", stdin);
    ll n,p;cin>>n>>p;
    if(n==1)
    	cout<<p<<endl;
    else{
    	int ans=1;
		for(int i=2;i;i++){
			ll cur=1;bool f=1;
			for(int j=0;j<n;j++){
				cur*=i;
				if(cur>p){
					f=0;
					break;
				}
			}
			if(!f)
				break;	
			if(p%cur==0)
				ans=i;
		}
		printf("%d\n",ans);
	}
	return 0;
}
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
int n;
ll a[maxx];

int main() {
	int l, r;
	ll ans;
	while(cin >> n && n) {
		memset(a, 0, sizeof(a));
		for(int i = 1; i <= n; i++) cin >> a[i];
		sort(a + 1, a + 1 + n);
		l = 1, r = n;
		ans = abs(a[1] - a[n]);
		for(int i = 2; i <= n / 2; i++) {
			int dd = abs(a[l] - a[n - i + 1]);
			int pp = abs(a[r] - a[i]);
			ans += dd + pp;
			l++;
			r--;
		}
		if(n & 1) {
			int x = abs(a[n / 2 + 1] - a[r]);
			int y = abs(a[n / 2 + 1] - a[l]);
			ans += max(x, y);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1024
n = gets.chomp.to_i
parr = gets.chomp.split(" ").map(&:to_i)
qarr = gets.chomp.split(" ").map(&:to_i)
perm = (1..n).to_a.permutation(n)
puts (perm.find_index{|a| a == parr} - perm.find_index{|a| a == qarr}).abs


#puts [1,2,3].permutation(3).to_a.find_index{|a| a == [3,2,1]}


Measured memory_bytes: 2172
#include <stdio.h>
 
 int main(void)
 {
	 int a,b,c;
	 scanf("%d",&a);
	 scanf("%d",&b);
	 scanf("%d",&c);
	 
	 if(a < b && b < c)
		 printf("Yes\n");
	 else
		 printf("No\n");
	return 0;
 }

Measured memory_bytes: 580
#include<iostream>
#include <string>
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define M 1000000007
#define all(v) v.begin(),v.end()
#define fr(a,b,c) for(ll i=a;i<=b;i+=c)
#define inarr(arr,n); for(ll i=0;i<n;i++) cin >> arr[i];
#define outarr(arr,n); for(ll i=0;i<n;i++) cout<<arr[i]<<" ";
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int main() {
    ios;
	ll n,m;
    cin>>n>>m;
    vector <ll> a(n);
    inarr(a,n);
    ll votes=0;
    for(int i=0;i<n;i++){
        votes+=a[i];
    }
    ll count=0;
    ll ne=0;
    if(votes%(4*m)==0){
        ne=votes/(4*m);
    }
    else{
        ne=votes/(4*m);
        ne+=1;
    }
    for(int i=0;i<n;i++){
        if(a[i]>=ne){
            count++;
        }
    }
    if(count>=m){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
/*素因数分解*/
void prime_factor(ll n){
	for(ll i =2;i*i<=n;i++){
		while(n%i==0){
			n /=i;
			cout <<" "<<i;
		}
	}
	if(n!=1)cout <<" "<<n;
	return ;
}
int main(){
	ll n;
	cin>>n;
	cout <<n<<":";
	prime_factor(n);
	cout <<endl;
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main(void){
    int n, k;
    int i;
    int v;

    scanf("%d%d", &n, &k);

    v = 1;
    for(i = 0; i < n; i++){
        int op_a = v * 2;
        int op_b = v + k;
        v = op_a < op_b ? op_a : op_b;
    }

    printf("%d\n", v);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>

using ll = long long;
using namespace std;
#define modmod 1000000007

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


int main(){
    int N;
    ll T;
    cin >> N >> T;
    if(N==1){
        cout << T << endl;
        return 0;
    }
    ll t[N];
    ll dif[N-1];
    for(int i = 0; i < N; i++){
        cin >> t[i];
    }
    for(int i = 0; i< N-1; i++){
        dif[i] = t[i+1] - t[i];
    }
    ll result = 0;
    for(int i = 0; i < N-1; i++){
        if(dif[i] < T){
            result += dif[i];
        }else{
            result += T;
        }
    }
    result += T;

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
#define mod  1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

int main(){
ll t;
t=1;
fast;
//  cin>>t;

while(t--){
ll n;
cin>>n;
vector<ll> a,b,c,d;

for(ll i=0; i<n;i++){
    ll x,y;
    cin>>x>>y;

    a.push_back(x+y);
    b.push_back(x-y);
}
sort(a.begin(), a.end());
sort(b.begin(), b.end());
cout<<max(a[n-1]- a[0], b[n-1] - b[0]);
}
return 0;
}

Measured memory_bytes: 6680
N = int(input())
X = input()   
              
x_val = int(X, 2)
pc_x = X.count('1')
              
x_mod_pc_x_plus_1 = x_val % (pc_x + 1)
x_mod_pc_x_minus_1 = x_val % max(pc_x - 1, 1)
              
for i in range(N):
    if X[i] == '1':
        pc = pc_x - 1
        if pc == 0:
            print(0)
            continue
        val = (x_mod_pc_x_minus_1 - pow(2, N-i-1, pc)) % pc
    else:     
        pc = pc_x + 1
        val = (x_mod_pc_x_plus_1 + pow(2, N-i-1, pc)) % pc
    ans = 1   
    while val > 0:
        val %= bin(val).count('1')
        ans += 1
    print(ans)
              

Measured memory_bytes: 9556
#include <iostream>
#include <string>
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
int main()
{
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5])	cout << "Yes" << endl;
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(snip_i, n) cin >> a.at(snip_i);
  vector<bool> box(n, false);
  rrep(i, n){
    int ii = i + 1;
    int chk = 0;
    for(int j = i; j < n; j += ii){
      if(box.at(j) == true) chk++;
    }
    if(chk % 2 != a.at(i)){
      box.at(i) = true;
    }
  }
  vector<int> ans;
  rep(i, n){
    if(box.at(i) == true){
      ans.push_back(i+1);
    }
  }
  cout << ans.size() << endl;
  if(ans.size() != 0){
    rep(i, ans.size()){
      if(i != 0) cout << " ";
      cout << ans.at(i);
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 2428
H, W, K = map(int, input().split())
C = [input() for _ in range(H)]

total = 0

for i in range(2**(H)):
  for j in range(2**(W)):
    pattern = 0
    bin_H = '{:09b}'.format(i)[-H:]
    bin_W = '{:09b}'.format(j)[-W:]
    for hi,h in enumerate(bin_H):
      if h == '0':
        for wi,w in enumerate(bin_W):
          if w == '0' and C[hi][wi] == "#":
            pattern += 1
    if pattern == K:
      total += 1
print(total)


Measured memory_bytes: 9024
#include <stdio.h>
#include<math.h>
#include<string.h>
/* 
int mypow(int a,int b)
{
    int i,ans=1;
    for (i = 0; i < b;i++)
    {
        ans *= a;
    }
    return ans;
}

int main()
{
    int n,i,rank=1,kosu=0;
    scanf("%d", &n);
    for (i = 1; i <= n;i++)
    {
        if(i % mypow(10,rank)==0)
        {
            rank++;
            //printf("%d %d\n",i,rank);
        }
        if(rank%2==1)
        {
            kosu++;
        }
    }
    printf("%d", kosu);
    return 0;
}
*/

int main()
{
    int i,n,rank,kosu=0;
    char buf[10];
    scanf("%d", &n);
    for (i = 1; i <= n;i++)
    {
        //printf("test");
        snprintf(buf, 10, "%d", i);
        //printf("test");
        rank = strlen(buf);
        //printf("%d", rank);
        if (rank % 2 == 1)
            kosu++;
    }  
    printf("%d", kosu);
    return 0;
}



Measured memory_bytes: 128
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>
#include <locale>
#include <random>
#include <type_traits>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

using LL = long long;

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

constexpr int MAX_N = 200200;
constexpr LL mod = 1e9 + 7;

LL mul[MAX_N];
LL inv[MAX_N];

LL POW_MOD(LL N, LL P, LL M) {
    LL ret = 1;
    while (P > 0) {
        if (P & 1LL) ret = (ret * N) % M;
        N = (N * N) % M;
        P >>= 1LL;
    }
    return ret;
}

void setup() {
    mul[0] = mul[1] = 1;
    inv[0] = inv[1] = 1;
    for (LL i = 2; i <= MAX_N - 2; i++) {
        mul[i] = mul[i - 1] * i;
        mul[i] %= mod;
        inv[i] = POW_MOD(mul[i], mod - 2, mod);
    }
}

LL nCr_mod(LL n, LL r) {
    if (n < r) return 0;
    return mul[n] * inv[r] % mod * inv[n - r] % mod;
}

int main() {

    int H, W, A, B;
    cin >> H >> W >> A >> B;

    setup();

    LL ans = 0;

    int y = H - A - 1;
    int x = B;
    while (y >= 0 && x < W) {
        LL n = y + x;
        LL r = y;
        ans += (nCr_mod(n, r) * nCr_mod(W - x - 1 +  H - y - 1, H - y - 1)) % mod;
        ans %= mod;
        y--;
        x++;
    }

    cout << ans << endl;

    return 0;
}




































Measured memory_bytes: 3328
from collections import defaultdict
n=int(input())
a=list(map(int,input().split()))
cnt_dic=defaultdict(int)
for i in range(n):
  v=a[i]
  cnt_dic[v+1]+=1
  cnt_dic[v]+=1
  cnt_dic[v-1]+=1
ans=0
for key in cnt_dic.keys():
  ans=max(ans,cnt_dic[key])
print(ans)

Measured memory_bytes: 64748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}


int main(){
    ll A,B,N;cin >> A >> B >>N;
    ll t = min(N,B-1);
    ll a = ((t*A)/B);
    
    cout <<a << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>

int main(void)
{
    int a[3];
    int i;
    int j;
    int tmp;

    for (i = 0; i < 3; i++) {
        scanf("%d",&a[i]);
    }
 
    for (i = 0; i < 3; i++) {
        for (j = i + 1; j < 3; j++) {
            if (a[i] > a[j]) {
                tmp = a[i];
                a[i] = a[j];
                a[j] = tmp;
            }
        }
    }
/*    
    if (a[0] > a[1]){
        tmp = a[0];
        a[0] = a[1];
        a[1] = tmp;
    }
    if (a[1] > a[2]){
        tmp = a[1];
        a[1] = a[2];
        a[2] = tmp;
    }

    if (a[0] > a[1]){
        tmp = a[0];
        a[0] = a[1];
        a[1] = tmp;
    }
*/
    printf("%d %d %d\n",a[0],a[1],a[2]);
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll> > vvl;
typedef vector<vector<P> > vvp;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=998244353;
const int INF=1e9;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


  
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  string s;
  cin >> s;
  int n=s.size();
  map<ll,ll>mp;
  mp[0]++;
  
  ll p=2019;
  ll tenfactor=1;
  ll now=0;
  rep(i,n){
    now=(now+(s[n-1-i]-'0')*tenfactor)%p;
    mp[now]++;
    tenfactor=(tenfactor*10)%p;
  }
  ll ans=0;
  for(auto p:mp){
    ans+=p.second*(p.second-1)/2;
  }
  
  cout << ans << endl;
  return 0;     
}


Measured memory_bytes: 3792
#include <stdio.h>

int main()
{
    int a, b;
    scanf("%d %d", &a, &b);
    if (a < b)
    printf("a < b\n");
    else if (a > b)
    printf("a > b\n");
    else
    printf("a == b\n");
    
    return 0;
}



Measured memory_bytes: 2036
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int> 

int main(){
  ll A, B, C, K; cin >> A >> B >> C >> K;

  if (K%2==1) cout << B - A << endl;
  else cout << A - B << endl;
  
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N, K = map(int, input().split())

h_array = [int(input()) for i in range(N)]
h_array.sort()
ans = 10**10
for i in range(N-K+1):
    ans = min(ans, h_array[i+K-1] - h_array[i])

print(ans)


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

struct Node {
  int parent;
  int left;
  int right;
};

Node tree[100010];
int depth[100010];
int height[100010];

// 先行順巡回
void preParse(int v) {
  if (v == -1) {
    return;
  }
  printf(" %d", v);
  preParse(tree[v].left);
  preParse(tree[v].right);
}

// 中間順巡回
void inParse(int v) {
  if (v == -1) {
    return;
  }
  inParse(tree[v].left);
  printf(" %d", v);
  inParse(tree[v].right);
}

// 後行順巡回
void postParse(int v) {
  if (v == -1) {
    return;
  }
  postParse(tree[v].left);
  postParse(tree[v].right);
  printf(" %d", v);
}

int main() {

  int n;
  cin >> n;

  for (int i = 0; i < n; i++) {
    tree[i].parent = -1;
  }

  for (int i = 0; i < n; i++) {
    int id, left, right;
    cin >> id >> left >> right;
    tree[id].left = left;
    tree[id].right = right;
    if (left != -1) {
      tree[left].parent = id;
    }
    if (right != -1) {
      tree[right].parent = id;
    }
  }

  int root = 0;

  for (int i = 0; i < n; i++) {
    if (tree[i].parent == -1) {
      root = i;
    }
  }

  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");
  return 0;

}


Measured memory_bytes: 3208
N = int(input())
A = list(map(int, input().split()))
B = [i if i > 0 else i * -1 for i in A]
c = 0
s = 0
for j in A:
    if j < 0:c += 1
if c % 2 == 0:
    s = sum(B)
else:
    s = sum(B) - min(B) * 2
print(s)

Measured memory_bytes: 14412
import java.util.*;

public class  Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int n1 = n % 1000;
        int n2 = n / 10;
        if(n1%111==0 || n2%111 ==0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21844
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_macros)]
#![allow(unused_variables)]
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}


fn main() {
    input! {
        N: usize,
        S: chars,
    }
    let mut dp = vec![0; N];
    dp[0] = S[1..].iter().filter(|&&s| s=='E').count();

    for ind in 1..N {
        dp[ind] = dp[ind-1];
        if S[ind-1] == 'W' {
            dp[ind] += 1;
        }
        if S[ind] == 'E' {
            dp[ind] -= 1;
        }
    }
    println!("{}", dp.iter().min().unwrap());
}


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

int main(){
    int N;cin>>N;
    int info[N];
    rep(i,N)cin>>info[i];
    int count=0;
    rep(i,N-1){
        if(i!=N-2){
            if(info[i]==i+1){
                swap(info[i],info[i+1]);
                count++;
            }
        }
        else if(info[i]==i+1 or info[i+1]==i+2){
            swap(info[i],info[i+1]);
            count++;
        }
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 640
//Shiritori.cpp (A)
#include <iostream>
#include <string>
using namespace std;

int main(){
  string A, B, C;
  cin >> A >> B >> C;
  if(A[A.size()-1]==B[0]&&B[B.size()-1]==C[0]) printf("YES\n");
  else printf("NO\n");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <algorithm>
 
using namespace std;
using LL = long long;
const int INF = 0x3f3f3f3f;
const int N = 400005;
LL a[N];
LL sum[N];
int main()
{
	LL k, n;
	scanf("%lld%lld", &k, &n);
 
	LL res = INF;
	for (int i = 1; i <= n; ++i)
	{
		scanf("%lld", &a[i]);
		a[n + i] = a[i] + k;
	}
 
	//for (int i = 1; i <= 2 * n; ++i) sum[i] = sum[i - 1] + a[i];
 
	for (int i = 1; i + n - 1 <= 2 * n; ++i)
	{
		res = min(res, a[i + n - 1] - a[i]);
	}
 
	printf("%lld\n", res);
 
 
	return 0;
}

Measured memory_bytes: 4480
N = int(input())
A = list(map(int, input().split()))
A.sort()
flag = N % 2 == 0
if not flag:
	flag = A[0] == 0
if flag:
	index = N % 2
	while index < N:
		if A[index] != index + 1 or A[index] != A[index]:
			flag = False
			break
		index += 2
if flag:
	print((2**(N//2))%(10**9+7))
else:
	print(0)

Measured memory_bytes: 52204
//Robs Code

/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <iomanip>

/***********MACROS***************/
#define int long long int
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define pii pair<int,int>

using namespace std;

const int N = 1e5 + 1;
int n,m,i,j,k,l,x,y,z,cnt[3],sum[3];

/***********MAIN**************/
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin >> n;
	vector<int> v(n);
	int sum = 0;
	for(auto &x : v){
		cin >> x;
		sum ^= x;
	}
	for(int i = 0;i < n;i++){
		cout << (sum ^ v[i]) << " ";
	}
}
//.........

Measured memory_bytes: 4764
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MMOD 998244353
#define MAX 2010101
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,M;
  cin>>N>>M;
  vector<int> A(M);
  REP(i,M) cin>>A[i];
  int match[10]={2,5,5,4,5,6,3,7,6};
  
  string DP[10101];
  REP(i,10101) DP[i]="Q";
  DP[0]="";
  
  for(int i=0; i<=N; ++i){
    if(DP[i]=="Q") continue;
    for(auto a:A){
      string X=DP[i+match[a-1]],Y=DP[i]+(char)(a+'0');
      if(X=="Q") X=Y;
      else if(X.size()<Y.size()) X=Y;
      else if(X.size()==Y.size()){
        if(X<Y) X=Y;
      }
      
      DP[i+match[a-1]]=X;
    }
  }
  
  cout<<DP[N]<<endl;
  return 0;
}

Measured memory_bytes: 54880