akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> A(N, 0);
    for (auto & a : A) cin >> a;
    int a0 = accumulate(A.begin(), A.end(), 0)/N;
    int a1 = a0 + 1;
    int ans0 = 0;
    int ans1 = 0;
    for (auto a : A){
        ans0 += (a - a0) * (a - a0);
        ans1 += (a - a1) * (a - a1);
    }
    cout << min(ans0, ans1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

int n,a[200010];
int bit[25][200010];
ll ans;
bool valid (int l , int r){
    bool v = true;
    for(int i=1;i<=20;i++){
        if(bit[i][r]-bit[i][l-1]>1){v=false;break;}
    }
    return v;
}
void construct (int idx){
    int z = a[idx] ;
    queue <int> q;
    while(z>0){
        if(z%2==0)q.push(0);
        else q.push(1);
        z/=2;
    }
    int b = 1;
    for(int i=1;i<=20;i++){
        bit[i][idx] = bit[i][idx-1];
    }

    while(!q.empty()){
        bit[b][idx] += q.front();
        b++;
        q.pop();
    }
}
int binsearch (int start){
    int l = start;
    int r = n;
    int res=l;
    while(l<=r){
        int mid = (l+r)/2;
        if(valid(start,mid)){
            res = mid-start+1;
            l = mid + 1;
        }
        else{
            r = mid - 1;
        }
    }
    return res;

}
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        construct(i);
    }

    for(int i=1;i<=n;i++){
        ans += binsearch(i);
    }
    cout<<ans<<newl;



}


Measured memory_bytes: 18688
#!/usr/bin/env python3
#ABC139 C

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
h = LI()
tmp = h[0]
ans = 0
cnt = 0
for i in range(1,n):
    if tmp >= h[i]:
        cnt += 1
    else:
        ans = max(ans,cnt)
        cnt = 0
    tmp = h[i]
ans = max(ans,cnt)
print(ans)


Measured memory_bytes: 59632
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug  freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 1e6+10;
const int maxM = 1e6+10;
const int inf = 0x3f3f3f3f;

ll N,D;

int main(){
	// debug;
	ios;

	cin>>N>>D; D*=D;

	int ans = 0;
	for(int i = 1;i<=N;i++){
		ll x,y;cin>>x>>y;
		if(x*x + y*y <= D) ans++;
	}
	cout<<ans<<'\n';


	
	return 0;
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=3e2;
const long inf=1e18;
long ds[N+2][N+2],mt[N+2][N+2];
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  int n,m,l;cin>>n>>m>>l;
  for(int i=1;i<=n;i++)
  {
    for(int j=1;j<=n;j++)
    {
      ds[i][j]=inf,mt[i][j]=inf;
      if(i==j)ds[i][j]=0,mt[i][j]=0;
    }
  }
  while(m--)
  {
    int u,v,c;cin>>u>>v>>c;
    ds[u][v]=c;ds[v][u]=c;
  }
  for(int k=1;k<=n;k++)
  {
    for(int i=1;i<=n;i++)
      for(int j=1;j<=n;j++)
        ds[i][j]=min(ds[i][j],ds[i][k]+ds[k][j]);
  }
  //cout<<"*"<<ds[3][1]<<endl;
  for(int i=1;i<=n;i++)
  {
    for(int j=1;j<=n;j++)
      if(ds[i][j]<=l)mt[i][j]=1;
  }
  for(int k=1;k<=n;k++)
  {
    for(int i=1;i<=n;i++)
      for(int j=1;j<=n;j++)
        mt[i][j]=min(mt[i][j],mt[i][k]+mt[k][j]);
  }
  int q;cin>>q;
  while(q--)
  {
    int u,v;cin>>u>>v;
    if(mt[u][v]==inf)cout<<-1<<"\n";
    else cout<<mt[u][v]-1<<"\n";
  }
  return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
typedef  long long int ll;
typedef pair<ll, ll> pll;
#define pb push_back
typedef long double ld;
#define fi first
#define se second
#define PI 3.14159265358979323846264338327950288419716939937510
#define mp make_pair
ll inf = 1e18;
ll p = 1e9 + 7;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p - 2, p);
}
vector<vector<ll>>adj(1e5 + 1);
vector<ll>used(1e5 + 1, 0), sub(1e5 + 1, 0);
void dfs(ll s, ll p)
{

    sub[s] = 1;
    for (auto v : adj[s])
    {
        if (v != p)
        {
            dfs(v, s);
            sub[s] += sub[v];
        }
    }
    return;
}
int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll i, j, y, x,  z, w, g, key, l, r, n, m, t, k;
    ll a, b, c;
    ll t2, t3, t4, t1;
    ll x1, x2, y1, y2;
    string s;
    cin >> n >> x >> t;
    t1 = n / x;
    if (n % x != 0)
        t1++;
    ll ans = t1 * t;
    cout << ans;

    return 0;
}

Measured memory_bytes: 7024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
int main(){
	int a,b,c,d,e;
	std::cin>>a>>b>>c>>d>>e;
	std::cout<<std::min(std::min(a,b),c)+std::min(d,e)-50<<std::endl;
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
/*
ll npr(ll n, ll r, ll mod){
    ll val = 1;
    for(ll i=n; i<=(n-r+1); i++){
        ll k = i%mod;
        val = val*k;
        val = val%mod;
    }
return val;
}
*/
int main(){
    ll n;
    cin>>n;
    ll sum = 0;
    /*for(ll i=1; i<=n; i++){
        sum = sum + npr(n , i,  i);
        cout<<sum<<endl;
    }*/
    ll k = n;
    if(n%2 == 0){
        k = n/2;
        sum = (k)*(n-1);
    }
    else{
        k = (n-1)/2;
        sum = (k)*(n);
    }
    cout<<sum;



return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <bitset>
using namespace std;

#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)
#define iter(it,c) for(auto it=(c).begin(); it!=c.end(); ++it)

typedef vector<int> vi;
typedef map<int, int> mii;

int const score[] = { 0, 0, 60, 70, 80 };
int eval(int n){
    int s = 0;
    rep(i, 5){
        s += score[n & 7];
        n >>= 3;
    }
    return s;
}

int flip(int n, int f){
    f <<= 2;
    int r = 0;
    rep(i, 5){
        int t = n >> (i * 3) & 7;
        if (t){
            int c = (f >> (i * 2) & 3) + (f >> (i * 2 + 2) & 3);
            t = ((t - 1 + c) & 3) + 1;
        }
        r |= t << (i * 3);
    }
    return r;
}

int solve(vi const& v){
    mii prev;
    prev[v[0]] = eval(v[0]);
    rep(i, 4){
        mii next;
        iter(it, prev){
            int bef = eval(it->first);
            rep(f, 1 << 8){
                int aft = flip(it->first, f);
                int suc = flip(v[i + 1], f);
                int e = it->second - bef + eval(aft) + eval(suc);
                int x = eval(aft);
                int y = eval(suc);
                next[suc] = max(next[suc], e);
            }
        }
        swap(prev, next);
    }

    int ans = 0;
    iter(it, prev) ans = max(it->second, ans);
    return ans;
}

int main(){
    int n; cin >> n;
    while (n--){
        vi v(5);
        rep(i, 5){
            rep(j, 5){
                int t = 0; cin >> t;
                v[i] <<= 3;
                v[i] |= t;
            }
        }
        cout << solve(v) << endl;
    }
}

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	string s;
	cin>>s;
	int n=s.size()+1;
	vector<ll> a(n,0);
	
	rep(i,n-1){
		if(s[i]=='<')a[i+1]=max(a[i+1],a[i]+1);
	}
	repr(i,n-1,1){
		if(s[i-1]=='>')a[i-1]=max(a[i-1],a[i]+1);
	}

	// for(auto x:a)cout<<x<<" ";
	// cout<<endl;

	cout<<accumulate(all(a),0LL)<<endl;
	return 0;
}


Measured memory_bytes: 4740
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999999
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> LV;

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

int main() {
	llong N,X;
    cin >> N >> X;

    LV a(N);
    REP(i,N){
        cin >> a[i];
    }
    llong ans,now;
    now = ans = 0;
    ans = 1;
    REP(i,N){
        now+=a[i];
        if(now<=X){
            ans++;
        }
    }

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


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int i,a[10]={0},b,c,i2;
	for(i=0;i!=10;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i!=9;i++){
		for(i2=0;i2!=9-i;i2++){
			if(a[i2]<a[i2+1]){
			b=a[i2];
			a[i2]=a[i2+1];
			a[i2+1]=b;
			}
		}
	}
	for(i=0;i!=3;i++){
	printf("%d\n",a[i]);
	}
	return 0;
}

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

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {
			int N = Integer.parseInt(br.readLine());
			if(N == 1){
				System.out.println(br.readLine());
				System.out.println(0);
				return;
			}


			String tmp_str[] = br.readLine().split("\\s+");
			int array[] = new int[N];

			for(int i = 0; i < tmp_str.length; i++){
				array[i] = Integer.parseInt(tmp_str[i]);
			}

			int swap_count = 0,work;

			for(int i = 0; i < N-1; i++){
				for(int k = N-1; k >= i+1; k--){
					if(array[k] < array[k-1]){
						work = array[k-1];
						array[k-1] = array[k];
						array[k] = work;
						swap_count++;
					}
				}
			}

			StringBuilder sb = new StringBuilder();
			sb.append(Integer.toBinaryString(array[0]));
			for(int i = 1; i < array.length; i++){
				sb.append(" ").append(Integer.toString(array[i]));
			}
			System.out.println(sb.toString());
			System.out.println(swap_count);

		} catch (NumberFormatException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}



Measured memory_bytes: 24660
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val X = nextLong()
    val ans = Math.ceil((Math.sqrt(8.0 * X + 1) - 1.0) / 2.0).toLong()
    println(ans)
}

Measured memory_bytes: 31804
from statistics import median
N = int(input())
A, B = zip(*tuple(tuple(map(int, input().split())) for _ in range(N)))
if N & 1:
    print(median(B) - median(A) + 1)
else:
    print(int((median(B) - median(A)) * 2 + 0.1) + 1)

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

pair<int,int> topbottom(int num){
    pair<int,int> calc;
    calc.second = num%10;
    while(num/10 != 0){
        num /= 10;
    }
    calc.first = num;
    return calc;
}
 
int main(){
    int N; cin >> N;

    int dig = 1;
    int N_T = N;
    while(N_T/10 !=0){
        dig++;
        N_T /= 10;
    }

    pair<int,int> topandbottom;

    int ans = 0;
    for(int i=1; i<=N; i++){
        if(i%10 == 0){
            continue;
        }
        topandbottom = topbottom(i);

        for(int j=1; j<=dig; j++){
            //j桁のsecondがいくつあるか？

            if(j==1){
                if(topandbottom.first != topandbottom.second){
                    continue;
                }else{
                    ans ++;
                }
            }

            if(j==2){
                int counter = topandbottom.second*10 + topandbottom.first;
                if(counter <= N){
                    ans++;
                    continue;
                }
            }

            if(j>2){
                int tenth = pow(10,j-2);
                if(dig > j){
                    ans += tenth;
                }else{
                    for(int k=0; k<tenth; k++){
                        int counter = topandbottom.second*tenth*10 + k*10 + topandbottom.first;
                        if(counter <=N){
                            ans++;
                        }
                    }
                }
            }
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <climits>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <set>

using namespace std;


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

	if (n >= m)
	{
		printf("0\n");
		return 0;
	}

	set<int> a;
	multiset<int> diff;


	for (size_t i = 0; i < m; i++)
	{
		int x;
		scanf("%d", &x);

		a.emplace(x);
	}
	auto itr = a.begin();
	itr++;
	for (; itr != a.end(); ++itr) {
		diff.emplace(*itr - *prev(itr));
	}

	int count = *(--a.end()) - (*(a.begin()));

	itr = diff.end();
	for (size_t i = 1; i < n; i++)
	{
		itr--;
		count -= *itr;
	}

	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 9600
//Deep Godhani
//DAIICT

#include<bits/stdc++.h>
using namespace std;

#define N 100000000000
#define PI acos(-1)
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define ll long long int
#define ld long double
#define precision(x,d) cout << fixed << setprecision(d) << x
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL))

#include <bits/stdc++.h>
using namespace std;

const ll M = 1e9+7;

void solve()
{
  string s;
  cin >> s;
  if(s[2]==s[3] && s[4]==s[5])
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

int main()
{
  /*
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
  */

  FAST;
  ll t=1;
  //cin >> t;
  while(t--)
  {
    solve();
  }
	return 0;
}


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

#include <assert.h>    // LON
#include <math.h>    // sqrt()


using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;


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

    int now = 1;
    for (int i = 1; now * 2 <= n; i++) {
        now *= 2;
    }

    cout << now << endl;

}

Measured memory_bytes: 256
from collections import defaultdict

N,K=map(int,input().split())
d=defaultdict(int)
for i in range(N):
    a,b=map(int,input().split())
    d[a]+=b

d=d.items()
d=sorted(d,key=lambda x:x[0])

cnt=0
for key,value in d:
    cnt+=value
    if cnt>=K:
        print(key)
        exit()

Measured memory_bytes: 15440
package main

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

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var n, k int
	con.Scan(&n, &k)
	p := make([]int, n)
	for i := 0; i < n; i++ {
		con.Scan(&p[i])
	}
	sort.Ints(p)
	s := 0
	for i := 0; i < k; i++ {
		s += p[i]
	}
	con.Println(s)
	return nil
}


Measured memory_bytes: 1852
#include<stdio.h>
int main(){
  long long int n,a=10,ans=0;
  scanf("%lld\n",&n);
  if(n%2==1){
    ans=0;
  }
  else{
    while(a<=n){
      ans=ans+n/a;
      a=a*5;
    }
  }
  printf("%lld\n",ans);
}

Measured memory_bytes: 128
#include<stdio.h>
#define MAX 10000
#define NIL -1

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

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

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=0,h2=0;
  if(T[u].left!=NIL)
  h1=setHeight(T[u].left)+1;
  if(T[u].right!=NIL)
  h2= setHeight(T[u].right)+1;
  return H[u] = (h1 > h2 ? h1 : h2);
}
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){
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",getSibling(u));
  int deg = 0;
  if(T[u].left!=NIL)deg++;
  if(T[u].right!=NIL)deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);

  if(T[u].parent==NIL){
    printf("root\n");
  }
  else if(T[u].left==NIL&& T[u].right==NIL){
    printf("leaf\n");
  }
  else{
    printf("internal node\n");
  }
}

int main(){
  int i,v,l,r,root=0;
  scanf("%d\n",&n);
  for(i=0;i<n;i++)T[i].parent = NIL;
  for(i=0;i<n;i++){
    scanf("%d%d%d",&v,&l,&r);
    T[v].left=l;
    T[v].right=r;
    if(l!=NIL)T[l].parent=v;
    if(r!=NIL)T[r].parent=v;
  }
  for (i=0;i<n;i++){
    if(T[i].parent==NIL)root=i;
  }
  setdepth(root,0);
  setHeight(root);

  for(i=0;i<n;i++)print(i);

  return 0;
}



Measured memory_bytes: 2048
import java.util.Scanner;

public class Main{

	/**
	 * 各部屋の入居者数を出力する
	 * @param args	0:何件の情報が入力されるのか
	 * 				1:棟2:階数3:何番目の部屋4:入居者の増減
	 */
	static Scanner scan = new Scanner(System.in);
	public  static void main(String[] args){

		int[][] r =  new int[16][10];	//部屋番号2重リスト

		//二次元配列に入居者数の増減値を与える
		int info_num = scan.nextInt();
		for(int input_n=1;input_n< info_num * 4;input_n = input_n + 4){//

			int building = scan.nextInt() -1;
			int floor = scan.nextInt() -1;
			int room = scan.nextInt() -1;
			int value = scan.nextInt();

			//			
			//			int building = Integer.parseInt(args[input_n]) -1;		//棟数
			//			int floor = Integer.parseInt(args[input_n+1])-1;			//フロア階
			//			int room = Integer.parseInt(args[input_n+2])-1;			//部屋数
			//			int value = Integer.parseInt(args[input_n+3]);			//人数

			r[building*4+(floor)][room] += value;						//その部屋に何人いるか追加
		}

		//書き出し

		for(int tate = 0;tate<4;tate++){
			for(int k= 0;k<3;k++){
				for(int j = 0;j < 10;j++){

					System.out.print(" "+r[tate*4+k][j]);
				}
				System.out.println("");

			}
			if(tate!=3)
				System.out.println("####################");		//20個
		}


	}
}



Measured memory_bytes: 28988
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll func(ll n){
    ll res = 0;
    ll s = n / 4 * 4;
    for(ll i=s; i<= n; i++){
        res = res ^ i;
    }
    return res;
}

int main() {
    ll a, b;
    cin >> a >> b;
    ll ans = func(a - 1) ^ func(b);

    cout << ans << ln;
}
    

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int n, x, s;
int main(){
	scanf("%d", &n); s=0;
	for(int i=1; i<=n; i++){scanf("%d", &x); if(x&1)s++;}
	if(s&1)printf("NO"); else printf("YES");
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void){
	long i,j;
	long a=0,b=0;
	long x;
	scanf("%ld",&x);
	for(i=-300;i<300;i++){
		for(j=-300;j<300;j++){
			if(i*i*i*i*i-j*j*j*j*j==x){
				a=i;b=j;
			}
		}
	}
	printf("%ld %ld\n",a,b);
	return 0;
}


Measured memory_bytes: 1704
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <stack>
#include <queue>

#define ST_ARR_LEN(array) (sizeof(array)/sizeof(*array))

typedef std::stack<int> IntStack;
typedef std::queue<int> IntQueue;
 
using namespace std;
  
int main(){
  string S,T,U;
  int A, B;
  cin >> S >> T >> A >> B >> U;
  
  //int ans = 0;
  if(S == U){
    A -= 1;
  }
  if(T == U){
    B -= 1;
  }
  
  cout << A << endl << B << endl;
}

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

#define int long long

#define pb push_back
#define F first
#define S second
#define I insert
#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()

#define debug1(a) cout<<" "<<#a<<" : "<<a<<"\n"
#define debug2(a,b) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<"\n"
#define debug3(a,b,c) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<"\n"
#define debug4(a,b,c,d) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<"\n"

#define INF (int)10000000000000000
#define PI (double)3.14159265358979
// #define M 421412341324321
#define MOD 1000000007

vector <vector <string>> v(1e4+5);

void find(int n)
{
	for (auto j:v[n-1])
	{
		int l = sz(j);
		if (j[l-1]=='0')
		{
			v[n].pb(j+"0");
			v[n].pb(j+"1");
		}
		else if (j[l-1]=='9')
		{
			v[n].pb(j+"8");
			v[n].pb(j+"9");
		}
		else
		{
			char c = j[l-1];
			string temp = j;
			temp+=(c-1);
			v[n].pb(temp);
			temp = j;
			temp+=(c);
			v[n].pb(temp);
			temp = j;
			temp+=(c+1);
			v[n].pb(temp);
		}
	}
}

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

    int k;
    cin>>k;
    int x = 0, y=1;
	for (int i=1;i<=9;++i)
	{
		v[1].pb(to_string(i));
	}
	while(sz(v[y])<k)
	{
		k-=sz(v[y]);
		y++;
		find(y);
	}
	// for(auto j:v[3]) debug1(j);
	// debug1(y);
	cout<<v[y][k-1]<<"\n";


    return 0;
}

Measured memory_bytes: 14196
N, M = map(int, input().split())  # N枚のIDカード, M個のゲート

l_max = 0
r_min = N

for i in range(M):
    l, r = map(int, input().split())
    l_max = max(l, l_max)
    r_min = min(r_min, r)

if l_max > r_min:
    print(0)
else:
    print(r_min-l_max+1)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdlib.h>
using namespace std;
int main(){
  vector<int> e(12);
  vector<int> length;
  cin>>e[0];
  length.push_back(e[0]);
  for(int i=1;i<12;i++){
    cin>>e[i];
    auto it=find(length.begin(),length.end(),e[i]);
    if(it==length.end())length.push_back(e[i]);
  }
  int size=length.size();
  if(size>=4){
    cout<<"no"<<endl;
    exit(0);
  }
  int i=0;
  bool ans=true;
  while(i<size){
    if(count(e.begin(),e.end(),length[i])%4!=0){
      ans=false;
    }
    i+=1;
  }
  if(ans==true)cout<<"yes"<<endl;
  else cout<<"no"<<endl;
}

Measured memory_bytes: 3144
#include<bits/stdc++.h>
/*
g++ -std=c++11 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG abc091/b.cpp
*/
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
typedef long long ll;

int N, M;
map<string, int> m1;
map<string, int> m2;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);//おまじないでcin, cout早くする
    cin >> N;
    rep(i, N){
        string s;
        cin >> s;
        if(m1.count(s) > 0){
            m1[s]++;
        }else{
            m1.insert(make_pair(s, 1));
        }
    }
    cin >> M;
    rep(i, M){
        string s;
        cin >> s;
        if(m2.count(s) > 0){
            m2[s]++;
        }else{
            m2.insert(make_pair(s, 1));
        }
    }

    int ans = 0;
    for(auto i = m1.begin(); i != m1.end(); i++){
        string s = i->first;
        int cnt = i->second;
        cnt -= m2[i->first];
        ans = max(cnt, ans);
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/abc176/tasks/abc176_c
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n;
	cin>>n;
	
	long long maxx = 0;
	long long ans=0;
	long long x;
	for (int i=1; i<=n; i++) {
		cin>>x;
		if (x>=maxx) {
			maxx=x;
		} else {
			ans+=(maxx-x);
		}
	}
	
	cout<<ans<<"\n";
	
	return 0;
}


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

int main(){
    int k,m;
    cin >> k >> m;
    vector<vector<int>> vec(m);
    rep(i,m){
        int k; cin >> k;
        vec[i].resize(k);
        rep(j,k){
            cin >> vec[i][j];
            vec[i][j]--;
        }
    }
    vector<int> p(m);
    rep(i,m) cin >> p[i];
    int ans = 0;
    for(int i; i < (1 << k);i++){
        bool ok = true;
        for(int j = 0;j < m;j++){
            int c = 0;
            for(int id : vec[j]){
                if((i >> id) & 1){
                    c++;
                }
            }
            c %= 2;
            if(c != p[j]){
                ok = false;
            }
        }
        if(ok){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main()
{
	int n,w[100],s1=0,s2=0,t=100,i,j;

	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&w[i]);
	for(i=0;i<n;i++)
		s1+=w[i];
	for(i=0;i<n;i++){
		s1-=w[i];
		s2+=w[i];
		if(abs(s1-s2)<t)
			t=abs(s1-s2);
	}
	printf("%d",t);
	return 0;
}

Measured memory_bytes: 128
# coding: utf-8
import math
num_N, num_M = map(int, input().split())
l_stu = [list(map(int, input().split())) for __ in range(num_N)]
l_che = [list(map(int, input().split())) for __ in range(num_M)]

for stu in l_stu:
    dis_ind = []
    for index, che in enumerate(l_che):
        dis = math.fabs(che[0] - stu[0]) + math.fabs(che[1] - stu[1])
        dis_ind.append([dis, index + 1])

    dis_ind.sort(key=lambda x: (x[0], x[1]))
    print(dis_ind[0][1])

Measured memory_bytes: 3064
n=int(input())
data=list(map(int,input().split()))
pre=data[0]
count=0
ans=0
for i in range(1,n):
	now=data[i]
	if pre >= now:
		count+=1
	else:
		ans=max(ans,count)
		count=0
	pre=data[i]
ans=max(ans,count)
print(ans)




Measured memory_bytes: 14252
K = int(input())
A, B = (int(x) for x in input().split())
aq, amod = divmod(A, K)
bq, bmod = divmod(B, K)
if amod == 0:
    print('OK')
elif bmod == 0:
    print('OK')
elif aq < bq:
    print('OK')
else:
    print('NG')


Measured memory_bytes: 9180
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
#include <iostream>
#include <stack>
#include <vector>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <random>
#include <chrono>
using namespace std;

int main(){
    string s;
    cin >> s;
    int n = s.length();
    string s1 = s.substr(0, (n - 1) / 2);
    string s2 = s.substr((n + 1) / 2, (n - 1) / 2);
    string t1 = s1;
    string t2 = s2;
    string t = s;
    reverse(t1.begin(), t1.end());
    reverse(t2.begin(), t2.end());
    reverse(t.begin(), t.end());
    if(t == s and t1 == s1 and t2 == s2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PB push_back
#define PPB pop_back
typedef pair<int, int> pii;
static const int INF = 1LL<<61;
int X1[1005], X2[1005], Y1[1005], Y2[1005], w, h, n, dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
bool field[1001 * 6][1001 * 6];
vector<int> tv;
int compress(int *p1, int *p2, int w) {
    tv.clear();
    for (int i = 0; i < n; ++i) {
    for (int j = -1; j <= 1; ++j) {
    int tp1 = p1[i] + j, tp2 = p2[i] + j;
    if (0 <= tp1 && tp1 <= w) tv.PB(tp1);
    if (0 <= tp2 && tp2 <= w) tv.PB(tp2);
        }
    }
    sort(tv.begin(), tv.end());
    tv.erase(unique(tv.begin(), tv.end()), tv.end());
    for (int i = 0; i < n; ++i) {
    p1[i] = find(tv.begin(), tv.end(), p1[i]) - tv.begin();
    p2[i] = find(tv.begin(), tv.end(), p2[i]) - tv.begin();
    }
    return tv.size() - 1;
}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    while (cin >> w >> h, w) {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> X1[i] >> Y1[i] >> X2[i] >> Y2[i];
    }
    w = compress(X1, X2, w);
    h = compress(Y1, Y2, h);
    memset(field, 0, sizeof(field));
    for (int i = 0; i < n; ++i) {
        for (int y = Y1[i]; y < Y2[i]; ++y) {
            for (int x = X1[i]; x < X2[i]; ++x) {
            field[x][y] = true;
            }
        }
    }
    int ans = 0;
    for (int y = 0; y < h; ++y) {
        for (int x = 0; x < w; ++x) {
            if (field[x][y]) continue;
            ans++;
            queue<pii> q;
            q.push(pii(x, y));
            while (q.size()) {
                pii p = q.front();
                q.pop();
                int tx = p.first, ty = p.second;
                if (field[tx][ty]) continue;
                field[tx][ty] = true;
                for (int i = 0; i < 4; ++i) {
                    int nx = tx + dx[i], ny = ty + dy[i];
                    if (nx < 0 || w <= nx || ny < 0 || h <= ny) continue;
                    q.push(pii(nx, ny));
                }
            }
        }
    }
    cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 38432
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) v.erase(remove(v.begin(), v.end(), a), v.end())
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;

int A[100000];

signed main()
{
	int N;
	cin >> N;
	REP(i, N) cin >> A[i];

	ARY_SORT(A, N);

	int a = -1;
	int b = -1;
	for (int i = N - 1; i >= 1; i--)
	{
		if (A[i] == A[i - 1])
		{
			if (a < 0)
			{
				a = A[i];
				i--;
			}
			else
			{
				b = A[i];
				break;
			}
		}
	}

	if (a >= 0 && b >= 0)
	{
		cout << (a * b) << endl;
	}
	else
	{
		cout << 0 << endl;
	}
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main()
{
    ll n,w;
    cin>>n>>w;
    ll a[n],u,b[n];
    for(ll i=0;i<n;i++)cin>>a[i]>>b[i];
    ll dp[n+1][w+1];
    memset(dp,0,sizeof(dp));
    for(ll i=0;i<=n;i++){
        for(ll j=0;j<=w;j++){
            if(j==0 || i==0)dp[i][j]=0;
            else if(a[i-1]<=j){
                dp[i][j]=max(dp[i-1][j],b[i-1]+dp[i-1][j-a[i-1]]);
            }
            else dp[i][j]=dp[i-1][j];
        }
    }
    ll ans=0;
  cout<<dp[n][w]<<endl;
    return 0;
}


Measured memory_bytes: 79104
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String text = Stream.of(sc.nextLine().split(""))
                .map(s -> s.charAt(0))
                .map(c -> {
                    if (Character.isUpperCase(c)) {
                        return Character.toLowerCase(c);
                    } else {
                        return Character.toUpperCase(c);
                    }
                })
                .map(c -> c.toString())
                .collect(Collectors.joining());
        System.out.println(text);
    }
}




Measured memory_bytes: 32436
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min

val MOD = 1_000_000_007L

class Solver(stream: InputStream, private val out: java.io.PrintWriter) {
  fun solve() {
    val N = ni()
    val A = na(N).toMutableList()
    A.sort()
    var ans = 0L
    val que = ArrayDeque<Pair<Int, Int>>()
    que.add(Pair(A[N - 1], A[N - 2]))
    que.add(Pair(A[N - 1], A[N - 2]))
    ans += A[N - 1]
    for (i in N - 3 downTo 0) {
      val e = que.poll()
      ans += min(e.first, e.second)
      que.addLast(Pair(e.first, A[i]))
      que.addLast(Pair(e.second, A[i]))
    }

    out.println(ans)
  }













































  private val isDebug = try {
    // なんか本番でエラーでる
    System.getenv("MY_DEBUG") != null
  } catch (t: Throwable) {
    false
  }

  private var tokenizer: StringTokenizer? = null
  private val reader = BufferedReader(InputStreamReader(stream), 32768)
  private fun next(): String {
    while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
      tokenizer = StringTokenizer(reader.readLine())
    }
    return tokenizer!!.nextToken()
  }

  private fun ni() = next().toInt()
  private fun nl() = next().toLong()
  private fun ns() = next()
  private fun na(n: Int, offset: Int = 0): IntArray {
    return map(n) { ni() + offset }
  }
  private fun nal(n: Int, offset: Int = 0): LongArray {
    val res = LongArray(n)
    for (i in 0 until n) {
      res[i] = nl() + offset
    }
    return res
  }

  private fun na2(n: Int, offset: Int = 0): Array<IntArray> {
    val a  = Array(2){IntArray(n)}
    for (i in 0 until n) {
      for (e in a) {
        e[i] = ni() + offset
      }
    }
    return a
  }

  private inline fun map(n: Int, f: (Int) -> Int): IntArray {
    val res = IntArray(n)
    for (i in 0 until n) {
      res[i] = f(i)
    }
    return res
  }

  private inline fun debug(msg: () -> String) {
    if (isDebug) System.err.println(msg())
  }

  private fun debug(a: LongArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: IntArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: BooleanArray) {
    debug { a.map { if (it) 1 else 0 }.joinToString("") }
  }

  private fun debugDim(A: Array<LongArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }
  private fun debugDim(A: Array<IntArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }

  /**
   * 勝手にimport消されるのを防ぎたい
   */
  private fun hoge() {
    min(1, 2)
    max(1, 2)
    abs(-10)
  }
}

fun main() {
  val out = java.io.PrintWriter(System.out)
  Solver(System.`in`, out).solve()
  out.flush()
}


Measured memory_bytes: 67560
// vim: tabstop=2 softtabstop=2 shiftwidth=2
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

#define PRINT(e) cout << #e ": " << (e) << endl

void solve()
{
  int m, n;
  int a[110];
  cin >> n >> m;
  int net = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    net += a[i];
  }
  sort(a, a + n, greater<>());
  auto enough = [&](double ai) { return ai >= net / 4.0 / m; };
  int count = 0;
  for (auto ai : a) {
    if (enough(ai)) {
      ++count;
    }
    else {
      break;
    }
  }
  const char* ans = (count >= m) ? "Yes" : "No";
  cout << ans << endl;
}

int main()
{
  solve();
  return 0;
}


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

int main() {
  int a,b,c,n;
  cin>>a>>b>>c>>n;
  int count =0;
  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      for(int k=0;k<=c;k++){
        int kane=i*500+j*100+k*50;
        if(kane==n)count++;
      }
    }
  }
  cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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; }

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial{
public:
  vl Fac;
  Factrial(int MAX){
    Fac = vl(MAX+1);
    rep(i,MAX) {
      if(i == 0) Fac[i+1] = 1;
      else Fac[i+1] = ((i+1)*Fac[i])%MOD;
    }
  }
};

int main(){
  char ca,cb; cin >> ca >> cb;
  int a = ca-'0';
  int b = cb-'0';
  string sa,sb;
  rep(i,b) sa += ca;
  rep(i,a) sb += cb;
  string ans = min(sa,sb);
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#!/usr/bin/env python3
n, d = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        d2 = 0
        for k in range(d):
            d2 += (x[i][k] - x[j][k])**2
        dist = int(d2**0.5)
        if dist * dist == d2:
            ans += 1
print(ans)


Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
const int maxn=2e5+10;
ll n,m,k,d,q;

int b[maxn],a[maxn];

int main()
{
    int n,k;
    cin>>n>>k;
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]>=k)
            ans++;
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 640
N,M = map(int,input().split())
from math import factorial
ans = 0
if N<=1:
  ans+=0
else:
  ans+=factorial(N)//factorial(2)//factorial(N-2)
if M<=1:
  ans+=0
else:
  ans+=factorial(M)//factorial(2)//factorial(M-2)
  
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <cassert>
#include <vector>
#include <array>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <numeric>
using ll = long long;
using namespace std;
using pii = pair<int, int>;
using pdi = pair<double, int>;

int N,M;
vector<int> P, Y;

int main() {
	cin >> N >> M;
	for (int i = 0; i < M; i++)
	{
		int tmpP, tmpY;
		cin >> tmpP >> tmpY;
		P.push_back(tmpP);
		Y.push_back(tmpY);
	}
	vector<map<int, int>> mps(N+1);
	for (int i = 0; i < M; i++)
	{
		mps.at(P.at(i))[Y.at(i)] = i;
	}

	vector<int> x(M);
	for (int j = 1; j <= N; j++)
	{
		int tmpx = 1;
		for (const auto &e : mps.at(j)) {
			x[e.second] = tmpx;
			tmpx++;
		}
	}
	
	for (int i = 0; i < M; i++)
	{
		int tmp = P.at(i);
		int cnt;
		for (cnt=0; tmp > 0; tmp /= 10)
		{
			cnt++;
		}
		for (int j = 0; j < 6-cnt; j++)
		{
			cout << "0";
		}
		cout << P.at(i);
		tmp = x.at(i);
		for (cnt = 0; tmp > 0; tmp /= 10)
		{
			cnt++;
		}
		for (int j = 0; j < 6 - cnt; j++)
		{
			cout << "0";
		}
		cout << x.at(i) << endl;
	}
	return 0;
}

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

using namespace std;

int n, ar[100005];
long long S[100005];

int main()
{
    scanf("%d", &n);
    for(int i=1;i<=n;i++){
        scanf("%d", ar+i);
    }
    sort(ar+1, ar+n+1);
    for(int i=1;i<=n;i++){
        S[i] = S[i-1] + ar[i];
    }
    for(int i=n-1;i>=1;i--){
        if(ar[i+1]*1ll>S[i]*2ll){
            printf("%d", n-i);
            return 0;
        }
    }
    printf("%d", n);
    return 0;
}


Measured memory_bytes: 1536
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>

using namespace std;

int main() {
	int i, j, k;
	int a, b;

	cin >> a >> b;

	if ((a*b) % 2 == 0) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}


	





	getchar();
	getchar();
	return 0;
}

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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;


int main(){
  int r;
  cin>>r;
  cout<<3*r*r<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
int const INF = 1001001001;


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

int N; cin >> N;
vi A(N),B(N),C(N);
rep(i,N) cin >> A[i];
rep(i,N) cin >> B[i];
rep(i,N) cin >> C[i];

sort(all(A));
sort(all(B));
sort(all(C));

ll ans = 0;
rep(i,N) {
    ans += (lower_bound(all(A), B[i]) - A.begin()) * (N - (upper_bound( all(C), B[i]) - C.begin()));
}

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

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

using namespace std;

const int N = 2e5 + 3;
const int M = 1e6 + 6;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 3;
const int SM = 1e3 + 7;
const double EPS = 3e-16;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	long long n; cin >> n;
	
	long long ans = 0;
	char p = ' ';
	for(long long i = 0; i < n; i++){
		char c;
		cin >> c;
		if(c != p){
			ans++;
		}
		p = c;
	}

	cout << ans;
	return 0;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    N = in_n()
    ac = 0
    wa = 0
    tle = 0
    re = 0

    for i in range(N):
        s = in_s()
        if s == 'AC':
            ac += 1
        elif s == 'WA':
            wa += 1
        elif s == 'TLE':
            tle += 1
        elif s == 'RE':
            re += 1

    print('AC x', ac)
    print('WA x', wa)
    print('TLE x', tle)
    print('RE x', re)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9272
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 25

ll N,K,M;
ll POW[SIZE];
ll dp[1024*1024][10];

ll mod_pow(ll x,ll count, ll mod){

	if(count == 0)return 1;
	ll ret = mod_pow((x*x)%mod,count/2,mod);
	if(count%2 == 1){

		ret = (ret*x)%mod;
	}
	return ret;
}

int main(){

	POW[0] = 1;
	for(int i = 1; i < SIZE; i++){

		POW[i] = POW[i-1]*2;
	}

	scanf("%lld %lld %lld",&N,&K,&M);

	for(int last = 0; last < K; last++){

		dp[0][last] = 1;
	}

	for(int state = 1; state < POW[2*K]; state++){
		for(int last = 0; last < K; last++){

			dp[state][last] = 0;
		}
	}

	ll ans = 0,tmp_sum,mult,add;
	ll length;

	for(int state = 0; state < POW[2*K]; state++){

		length = 1;
		for(int loop = 0; loop < 2*K; loop++){
			if(state & (1 << loop)){
				length++;
			}
		}
		if(length >= N)continue;

		tmp_sum = 0;

		for(int last = 0; last < K; last++){
			if(dp[state][last] == 0)continue;

			for(int next = 0; next < K; next++){
				if(POW[next-last+K] & state){ //差重複

					tmp_sum += dp[state][last];
					tmp_sum %= M;

				}else{

					dp[state+POW[next-last+K]][next] += dp[state][last];
					dp[state+POW[next-last+K]][next] %= M;
				}
			}
		}
		mult = mod_pow(K,N-(length+1),M);
		add = (tmp_sum*mult)%M;
		ans += add;
		ans %= M;
	}

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

	return 0;
}



Measured memory_bytes: 85128