akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define endl "\n"
#define ll long long
#define eb emplace_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define MA 10e+18
int va=10e8+7;
ll val[200007]={0};
using namespace std;
//Conditional Operator (condition?true part:false part) eg : cout<<(y<=3?"YES":"NO")<<endl;
//string s(3,'1');
// if number of elements in array >10^5 then declare global array.
ll getmul(ll n){ll int k{0};while(n>0){k+=n%10;n=n/10;}return k;}//Sum OF n DIGITS 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t{1};
 //   cin>>t;
    while(t--){
        int x;
        cin>>x;
        if(x==0) cout<<"1"<<endl;
        else cout<<"0"<<endl;
        
    }
 return 0;
}

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

int main(){
    ll n;
    cin >> n;
    ll ans=0;
    if(n%2==0){
        ll kani=5;
        while(n>=kani){
            ans+=n/(kani*2);
            kani*=5;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
import java.io.*;
import java.util.*;

public class Main {
    static PrintWriter out = new PrintWriter(System.out);
    static Scanner sc = new Scanner(System.in);
    static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    int k;
    long[] d;
    public static void main(String[] args) throws IOException {
        Main main = new Main();
        main.solve();
//        System.out.println(main.solve());
    }
    void solve() throws IOException{
        k = sc.nextInt(); int q = sc.nextInt();
        d = new long[k];
        for(int i=0;i<k;i++) d[i] = sc.nextInt();
        while(q-->0){
            int n = sc.nextInt(), x = sc.nextInt(), m = sc.nextInt();
            long ans = helper(n,x,m);
            out.println(ans);
        }
        out.flush();
    }
    long helper(long n, long x, long m){
        long[] tempD = new long[k];
        for(int i=0;i<k;i++) tempD[i] = d[i]%m;
        long res = 0;
        // firstly count the "=" case
        for(int j=0;j<k;j++){
            if(tempD[j]!=0) continue;
            long cur = (n-1)/k;
            cur += (n-1)%k>j?1:0;
            res += cur;
        }
        // then count the ">" case
        // compute a[n-1]
        long time = (n-1)/k, r = (n-1)%k;
        long sumD = 0;
        for(long num:tempD) sumD += num;
        // end = a[n-1]
        long end = x + time*sumD;
        for(int i=0;i<r;i++) end += tempD[i];
        long diff = end/m-x/m;
        res += diff;
        return n-1-res;
    }
}



Measured memory_bytes: 86264
n, m = map(int, input().split())
a = [int(input())for i in range(n)]

for k in range(1, m+1):
    for i in range(1, n):
        if a[i-1]%k>a[i]%k:
            a[i-1], a[i] = a[i], a[i-1]
for i in a: print(i)


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

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;
    long X, Y, Z, K;
    long[] A, B, C;

    public void Do()
    {
        cin = new Scanner();
        X = cin.nextLong();
        Y = cin.nextLong();
        Z = cin.nextLong();
        K = cin.nextLong();
        A = cin.arrayLong();
        B = cin.arrayLong();
        C = cin.arrayLong();

        long[] calc1 = new long[X * Y];

        for (int i = 0; i < X; i++)
        {
            for (int j = 0; j < Y; j++)
            {
                calc1[i * Y + j] = A[X - 1 - i] + B[Y - 1 - j];
            }
        }

        Array.Sort(calc1);

        long[] calc2 = new long[K * Z];

        for (int i = 0; i < Math.Min(K, X * Y); i++)
        {
            for (int j = 0; j < Z; j++)
            {
                calc2[i * Z + j] = calc1[X * Y - 1 - i] + C[Z - 1 - j];
            }
        }

        Array.Sort(calc2);

        for (int i = 0; i < K; i++)
        {
            Console.WriteLine(calc2[K * Z - 1 - i]);
        }
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }

    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}

Measured memory_bytes: 44768
n=int(input())
s=input()

ans=0
for i in range(1000):
    cs=str(i).zfill(3)
    p=0
    for c in cs:
        p=s.find(c,p)

        if p==-1:
            break
        p+=1

    else:
        ans+=1

print(ans)

Measured memory_bytes: 66844
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;

int main(){
  int n,m;cin >> n >> m;
  vector<pair<int,int>> k(n);
  rep(i,m){
    int a,b;cin >> a >> b;
    if(a==1){
      k[b-1].first = 1;
    }
    if(b==n){
      k[a-1].second = 1;
    }
  }
  rep(i,k.size()){
    if(k[i].first==1&&k[i].second==1){cout << "POSSIBLE" << endl;return 0;}
  }
  cout << "IMPOSSIBLE" << endl;

}


Measured memory_bytes: 1792
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let n = read::<i32>();
    let sub = (n-1) /999;
    if sub == 0 {
        println!("ABC");
    } else {
         println!("ABD");
    }
}

Measured memory_bytes: 4352
n = int(raw_input())
blue={}
for x in range(0, n):
  tmp=raw_input()
  if(tmp in blue):
	blue[tmp]+=1
  else:
    blue[tmp]=1

m = int(raw_input())
for x in range(m):
  tmp=raw_input()
  if(tmp in blue):
	blue[tmp]-=1
  else:
    blue[tmp]=-1

max=0
for key, val in blue.items():
  if(max<val):
    max=val

print max

Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep2(i,x,n) for(int i=x;i<n;++i)

int main()
{
    string s;
    cin >> s;
    if(s == "Sunny") cout << "Cloudy" << endl;
    else if(s == "Cloudy") cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
//BEGIN CUT HERE
template<typename T>
vector<T> convert_base(T x,T b){
  vector<T> res;
  T t=1,k=abs(b);
  while(x){
    res.emplace_back((x*t)%k);
    if(res.back()<0) res.back()+=k;
    x-=res.back()*t;
    x/=k;
    t*=b/k;
  }
  if(res.empty()) res.emplace_back(0);
  reverse(res.begin(),res.end());
  return res;
}
//END CUT HERE

//INSERT ABOVE HERE
signed ABC105_C(){
  long long p;
  cin>>p;
  auto ans=convert_base(p,-2LL);
  for(auto x:ans) cout<<x;
  cout<<endl;
  return 0;
}

signed main(){
  ABC105_C();
  return 0;
}


Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

s = input()
t = input()
n = len(s)
res = 0
for i in range(n):
    if s[i] != t[i]:
        res += 1
print(res)

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

using namespace std;

long long mem[100005];
int arr[100005];
int n;

long long go(int ind)
{
	if(ind==n-1) return 0;
	if(ind>n-1) return (1LL<<50);
	if(mem[ind]!=-1) return mem[ind];
	return mem[ind]=min(go(ind+1)+abs(arr[ind]-arr[ind+1]),go(ind+2)+abs(arr[ind]-arr[ind+2]));
}

int main()
{
	cin >> n;
	for(int i=0;i<n;i++)
		cin >> arr[i];
	memset(mem,-1,sizeof mem);
	cout << go(0) << endl;
}

Measured memory_bytes: 2944
#include<stdio.h>

int main(void){
	int a[10][3][4]={};
	int n,i,j,k;
	int b,f,r,v;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d %d %d %d",&b,&f,&r,&v);
		a[r-1][f-1][b-1] += v;
	}
	for(k=0;k<4;k++){
		for(i=0;i<3;i++){
			for(j=0;j<10;j++){
				printf(" %d",a[j][i][k]);
			}
			printf("\n");
		}
		if(k!=3) printf("####################\n");
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
	int r, d;
	ll x;
	cin >> r >> d >> x;
	
	for(int i=0; i < 10; i++) {
		x = r * x - d;
		cout << x << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define VI vector<int>
#define PII pair<int, int>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30; const ll LINF=1LL<<60 ; const ll MOD=1e9+7 ;
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; }
//-------------------
int n;
const int MX = 105;
int d[MX];
/*
int main(){
    cin >> n;
    FOR(i,0,n-1) cin >> d[i];
    sort(d, d+n);
    int i = 0; int ans = 0;
    while(i < n){
        ans += 1;
        int cur = d[i];
        while(d[i] == cur && i < n){
            i++;
        }
    }
    cout << ans;
    return 0;
}*/

int main(){
    cin >> n;
    set<int> s;
    FOR(i,0,n-1){
        int d; cin >> d;
        if(s.find(d) == s.end()){
            s.insert(d);
        }
    }
    cout << s.size() ;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<map>
#include<set>

using namespace std;

#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 ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000
#define INFL (long long)(4e18)
#define MOD 1000000007

using vi = vector<int>;

template<class T>
struct Edge {
	int to;
	T cost;
	Edge() {};
	Edge(int to, T cost) : to(to), cost(cost) {};
};

template<class T>
class Graph {
	int n;
	bool directed;
	vector<vector<Edge<T>>> edges;
public:

	Graph(int n, bool directed) :n(n), directed(directed), edges(vector<vector<Edge<T>>>(n)) {};
	Graph() {};

	void add(int to, T cost) {
		emplace_back(to, cost);
	}

	int size() {
		return n;
	}
};


int main() {

	long long N, K;

	cin >> N >> K;

	long long MAX, MIN;

	long long ans = 0;

	for (long long i = K; i < N + 2; i++) {
		MIN = i * (i - 1) / 2.0;
		MAX = ((N + 1) * N - (N + 1 - i) * (N - i)) / 2;
		ans += MAX - MIN + 1;
		ans = ans%MOD;
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
using namespace std;
const int N = 1000000;


int main() {
    int n,t,a; cin >> n >> t >> a;

    vector<double> h(n);
    rep(i,n) cin >> h[i];

    double diff_min = N;
    int ans;
    double temp;

    for (int i = 0; i < n; ++i) {
        temp = t - 0.006 * h[i];
        if(abs(a-temp) < diff_min){
            diff_min = abs(a - temp);
            ans = i + 1;
        }

        temp = 0;
    }
    print(ans);
}

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

# print(s[2])
if d < c:
    ans = "No"
    for j in range(b-2, d-1, 1):
        # print(s[j],s[j+1],s[j+2])
        if s[j] == "." and s[j+1] == "." and s[j+2] == ".":
            ans = "Yes"
else:
    ans = "Yes"
e = max(c, d)
for i in range(a, e-1, 1):
    if s[i] == "#" and s[i+1] == "#":
        ans = "No"

if s[c-1] == "#" or s[d-1] == "#":
    ans = "No"

print(ans)


Measured memory_bytes: 4916
/*
ID: hafiz.i1
TASK: milk2
LANG: C++
*/
#include<bits/stdc++.h>

#define ll long long
#define debug(x) cout<<x<<"DE"<<endl;

using namespace std;



int main()
{
//    freopen("milk2.in", "r", stdin);
//    freopen("milk2.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n,q;
    cin>>n>>q;ll l[n+1];l[1]=0,l[0]=0;
    string s;
    cin>>s;
    for(int i=2;i<=n;i++){
        if(s[i-2]=='A'&&s[i-1]=='C')l[i]=l[i-1]+1;
        else l[i]=l[i-1];
    }
    for(int i=1;i<=q;i++){
        ll a,b;
        cin>>a>>b;
        cout<<l[b]-l[a]<<endl;
    }
}


Measured memory_bytes: 4536
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    int N, ans;
    cin >> N;
    double pi = 3.14159265;
    printf("%10.10e\n",2 * pi * N);
    return 0;
}

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

int s[100];

int main(){
	int n,m,sum=0,j;
	cin >> n;
	m = n;
	while(m>0){
		j=m%10;
		sum+=j;
		m=m/10;
	}		
	if(n%sum==0)
		cout << "Yes";
	if(n%sum!=0)
		cout << "No";
	
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def read():
    H, W = map(int, input().strip().split())
    return H, W

def solve(H, W):
    if H == 1 or W == 1:
        return 1
    n = H * W
    return n // 2 + n % 2

if __name__ == '__main__':
    inputs = read()
    print("%d" % solve(*inputs))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define lcm( a, b ) ((a)/__gcd(a,b)*(b))
#define MP make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef pair< LL, LL > L_P;

const int INF = INT_MAX;
const int MIN = INT_MIN;
const LL LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const int SIZE = 100005;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string fb[10005];
    for( int i = 1; i <= 10000; ++i ) {
        if( i % 3 == 0 && i % 5 == 0 ) fb[i] = "FB";
        else if( i % 3 == 0 ) fb[i] = "F";
        else if( i % 5 == 0 ) fb[i] = "B";
        else {
            string t;
            int tmp = i;
            while( tmp != 0 ) {
                char c = ( tmp % 10 ) + '0';
                t += c;
                tmp /= 10;

            }
            reverse( all(t) );
            fb[i] = t;

        }
    }

    bool player[1005];

    while( true ) {
        for( int i = 0; i < 1005; ++i ) player[i] = true;

        int m, n;
        cin >> m >> n;
        if( m == 0 && n == 0 ) break;

        int turn = 1;
        int p = m;
        for( int i = 1; i <= n; ++i ) {
            string s;
            cin >> s;
            
            if( p == 1 ) continue;
            if( s == "FizzBuzz" ) {
                if( fb[i] != "FB" ) {
                    --p;
                    player[turn] = 0;

                }

            } else if( s == "Fizz" ) {
                if( fb[i] != "F" ) {
                    --p;
                    player[turn] = 0;

                }

            } else if( s == "Buzz" ) {
                if( fb[i] != "B" ) {
                    --p;
                    player[turn] = 0;

                }
                
            } else {
                if( fb[i] != s ) {
                    --p;
                    player[turn] = 0;

                }
            
            }
            ++turn;
            while( turn <= m && !player[turn] ) ++turn;

            if( turn > m ) {
                turn = 1;
                while( turn <= m && !player[turn] ) ++turn;

            }
        }
        
        for( int i = 1; i <= m; ++i ) {
            if( player[i] ) {
                if( p == 1 ) {
                    cout << i << endl;
                    break;

                } else {
                    cout << i << " ";

                }
                --p;
            }
        }

    }
    return 0;
}





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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){


}

void solve(){


}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();
	int n;cin>>n;
	int g = __gcd(360,n);
	cout<<360/g;
	return 0;
}



Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i, n) REP(i, 0, n)
#define REP(i, l, r) for (int i = l; i < r; i++)
using namespace std;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, a[100000];
	cin >> n;
	rep(i, n) cin >> a[i];
	sort(a, a + n);
	int ans = 0;
	deque<int> que;
	rep(i, n) {
		if (i == 0 && a[i] >= 0 || a[i] < 0)
			ans -= a[i];
		else
			ans += a[i];
		que.push_back(a[i]);
	}
	if (a[n - 1] < 0) ans += a[n - 1] * 2;
	cout << ans << endl;
	rep(i, n - 1) {
		if (que.front() > 0) {
			int x = que.front();
			que.pop_front();
			int y = que.front();
			que.pop_front();
			cout << x << " " << y << endl;
			que.push_front(x - y);
		}
		else {
			if (que[que.size() - 2] <= 0) {
				int x = que.front(), y = que.back();
				que.pop_front();
				que.pop_back();
				cout << y << " " << x << endl;
				que.push_back(y - x);
			}
			else {
				int x = que.front(), y = que.back();
				que.pop_front();
				que.pop_back();
				cout << x << " " << y << endl;
				que.push_front(x - y);
			}
		}
	}
}


Measured memory_bytes: 2688
import java.io.*;
import java.util.*;

public class Main {
    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long N;
        N = sc.nextLong();

        final Solver solver = new Solver();
        System.out.println(solver.solve(N));
    }
}

class Solver {
    static final String YES = "Yes";
    static final String NO = "No";

    public String solve(long N) {
        for (int i = 1; i <= 9; i++) {
            if (N % i == 0 && N / i <= 9) {
                return YES;
            }
        }
        return NO;
    }
}



Measured memory_bytes: 23892
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

int main() {

    int n, x;
    cin >> n >> x;

    vector<int> child(n);

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

    sort(child.begin(), child.end());

    int cnt = 0;
    
    for (int i = 0; i < n - 1; i++) {
        if (x >= child[i]) {
            x -= child[i];
            cnt ++;
        }
    }

    if (x == child[n-1]) cnt ++; 
    
    cout << cnt << endl;

    return 0;   

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

int compare(string s, int n, string t)
{
	int flag = 1;
	rep(i, t.length()) {
		if (n + i == s.length() || s[n + i] != t[i]) {
			flag = 0;
			break;
		}
	}
	return flag;
}

int main(void)
{
	string s;
	cin >> s;

	reverse(s.begin(), s.end());
	int n = 0;
	while(n < s.length()) {
		if (s[n] == 'r') {
			if (compare(s, n, "remaerd")) {
				n += 7;
				continue;
			} else if (compare(s, n, "resare")) {
				n += 6;
				continue;
			} else {
				break;
			}
		} else if (s[n] == 'm') {
			if (compare(s, n, "maerd")) {
				n += 5;
				continue;
			} else break;
		} else if (s[n] == 'e') {
			if (compare(s, n, "esare")) {
				n += 5;
				continue;
			} else break;
		} else break;
	}
	if (n == s.length()) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 512
X,Y,Z,K = map(int, input().split())
A = [int(i) for i in input().split()] 
B = [int(i) for i in input().split()] 
C = [int(i) for i in input().split()] 

ans = []
for x in range(X):
    for y in range(Y):
        ans.append(A[x]+B[y])

ans.sort(reverse=True)
C.sort(reverse=True)
ans2 = []
for k in range(min(K,X*Y)):
    for z in range(min(Z,K)):
        ans2.append(ans[k]+C[z])
ans2.sort(reverse=True)

for k in range(K):
    print(ans2[k])

Measured memory_bytes: 151896
#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) long long((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;

int main() {
    string s, t;
    cin >> s >> t;
    int dicS[s.size()], dicT[t.size()];
    for (int i = 0; i < s.size(); i++) {
        int tmp = s[i] - 'a';
        dicS[i] = tmp;
    }
    for (int i = 0; i < t.size(); i++) {
        int tmp = t[i] - 'a';
        dicT[i] = tmp;
    }
    sort(dicS, dicS + s.size());
    sort(dicT, dicT + t.size(), greater<int>());

    string newS = "", newT = "";
    for (int i : dicS) {
        char c = 'a' + i;
        newS += c;
    }
    for (int i : dicT) {
        char c = 'a' + i;
        newT += c;
    }
    if (newS < newT)
        OUT("Yes");
    else
        OUT("No");
}


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

int main() {
  int N,S;
  cin >> N;
  rep(i,N) {
    int l_i,r_i;
    cin >> l_i >> r_i;
    S += r_i - l_i + 1;
  }
  cout << S << endl;
}

Measured memory_bytes: 256
N, M = map(int,input().split())
A = sorted(list(map(int,input().split())))
L = []
for k in range(M):
    B, C = map(int,input().split())
    L.append([B,C])
L = sorted(L,key=lambda x: -x[1])
ans = 0
i = 0
for k in range(N):
    if i < M:
        if A[k] < L[i][1]:
            L[i][0] -= 1
            ans += L[i][1]
            if L[i][0] == 0:
                i += 1
        else:
            ans += A[k]
    else:
        ans += A[k]
print(ans)


Measured memory_bytes: 81516
sx, sy, tx, ty = map(int, input().split())

x = tx - sx
y = ty - sy

print('U'*y+'R'*x+'U'+'L'*(x+1)+'D'*(y+1)+'R'*(x+1)+'U'*y+'R'+'D'*(y+1)+'L'*(x+1)+'U')


Measured memory_bytes: 3060
def distance(a, b)
  sum = 0
  a.length.times do |idx|
    sum += (a[idx] - b[idx])**2
  end
  Math.sqrt(sum)
end

N, D = gets.split(' ').map(&:to_i)
x = []
N.times do
  x.push(gets.split(' ').map(&:to_i))
end
count = 0
x.combination(2).each do |y, z|
  dist = distance(y, z)
  count += 1 if dist == dist.floor
end
puts count

Measured memory_bytes: 1788
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	a := nextInt()
	b := nextInt()

	if 1 <= a && a <= 9 && 1 <= b && b <= 9 {
		fmt.Println(a * b)
	} else {
		fmt.Println(-1)
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

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 int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

bool is_inside(int x1, int y1, int r, int x2, int y2) {
  if (pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2) <= r * r) {
    return true;
  } else {
    return false;
  }
}

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

  int n;
  cin >> n;

  int sum = 0;
  int m = 0;
  for (int i = 1; i <= n; i++) {
    sum = (i * (1 + i)) / 2;
    if (sum >= n) {
      m = i;
      break;
    }
  }

  for (int i = 1; i <= m; i++) {
    if (i == sum - n) continue;
    cout << i << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
const int N = 5010;
int wa[N], wb[N], wv[N], ws[N];
int rank[N]; 
int  height[N]; 
char str[N];
int s[N], sa[N],aans; 
 
int Max(int a, int b)
{
    return a > b ? a:b;
}
int Min(int a, int b)
{
    return a < b ? a:b;
}
int cmp(int *r, int a, int b, int l)
{
    return r[a]==r[b] && r[a+l]==r[b+l];
}
void get_sa(int *r, int *sa, int n, int m) 
{
    int i,j,p,*x=wa,*y=wb,*t;
    for(i=0; i<m; i++) ws[i]=0;
    for(i=0; i<n; i++) ws[x[i]=r[i]]++;
    for(i=1; i<m; i++) ws[i]+=ws[i-1];
    for(i=n-1; i>=0; i--) sa[--ws[x[i]]]=i; 
    for(p=1,j=1; p<n; j*=2,m=p)
    {
        for(p=0,i=n-j; i<n; i++) y[p++]=i;
        for(i=0; i<n; i++) if(sa[i]>=j) y[p++]=sa[i]-j; 
 
        for(i=0; i<n; i++) wv[i]=x[y[i]];
        for(i=0; i<m; i++) ws[i]=0;
        for(i=0; i<n; i++) ws[wv[i]]++;
        for(i=1; i<m; i++) ws[i]+=ws[i-1];
        for(i=n-1; i>=0; i--) sa[--ws[wv[i]]]=y[i]; 
 
        for(t=x,x=y,y=t,p=1,x[sa[0]]=0,i=1; i<n; i++)
            x[sa[i]]=cmp(y,sa[i-1],sa[i],j)?p-1:p++; 
    }
    return;
}
void get_height(int *r, int *sa, int n) 
{
    int i, j, k=0;
    for(i=1; i<=n; i++) rank[sa[i]]=i;
    for(i=0; i<n; height[rank[i++]]=k)
        for(k?k--:0,j=sa[rank[i]-1]; r[i+k]==r[j+k]; k++);
    return;
}
 
int main()
{
	int asd;
	scanf("%d",&asd);
    scanf("%s",str);
        int len = strlen(str);
        for(int i = 0; i < len; i++)
            s[i] = str[i]-'a'+1;
        s[len] = 0;
        get_sa(s,sa,len+1,27);
        get_height(s,sa,len);
        int ans = 0;
        for(int i = 1; i <= (len+1)/2; i++)
        {
            int minn = N;
            int maxn = -1;
            for(int j = 1; j <= len; j++)
            {
                if(height[j] >= i)
                {
                    minn = Min(minn,Min(sa[j-1],sa[j]));
                    maxn = Max(maxn,Max(sa[j-1],sa[j]));
                }
                else
                {
                    if(minn+i <= maxn)
                        ans++,aans=Max(aans,i);
                    minn = N, maxn = -1;
                }
            }
            if(minn+i <= maxn){
                ans++;
				aans=Max(aans,i);
			}
        }
        printf("%d\n",aans);
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, v1, v2, sum, i;
	double ter;
	vector<int> s;
	while (scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &l1, &l2, &l3, &l4, &l5, &l6, &l7, &l8, &l9, &l10, &v1, &v2) != EOF) {
		s.clear();
		s.push_back(l1);
		s.push_back(l2);
		s.push_back(l3);
		s.push_back(l4);
		s.push_back(l5);
		s.push_back(l6);
		s.push_back(l7);
		s.push_back(l8);
		s.push_back(l9);
		s.push_back(l10);
		sum = l1 + l2 + l3 + l4 + l5 + l6 + l7 + l8 + l9 + l10;
		ter = (double(sum*v1)) / (v1 + v2);
		sum = 0;
		for (i = 0; i < 10; i++) {
			sum += s[i];
			if (ter <= (double)sum) {
				cout << i + 1 << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
ll mod=1e9+7;

int main() {
  ll n,k;
  cin >> n >> k;
  if(k>(n-1)*(n-2)/2) {
    cout << -1 << endl;
    return 0;
  }
  if(k==0) {
    cout << n*(n-1)/2 << endl;
    for(ll i=1;i<=n;i++) {
      for(ll j=i+1;j<=n;j++) {
        cout << i << " " << j << endl;
      }
    }
    return 0;
  }
  k=(n-1)*(n-2)/2-k;
  cout << n-1+k<< endl;
  for(ll i=1;i<n;i++) {
    cout << 1 << " " << i+1 << endl;
  }
  for(ll i=2;i<=n;i++) {
    for(ll j=i+1;j<=n;j++) {
      if(k>0) {
        cout << i << " " << j << endl;
        k--;
      }
      else {
        break;
      }
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vlll = vector<vll>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
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; }
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second > secondElof.second;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod, LIS, digitDP, treeDP, Rerooting//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA, FordFulkerson//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q, T;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vl flag, D; vector<vpll> path; vll A;
//***********//
int main() {
	cin >> N;
	string S;
	cin >> S;
	ll W = 0; R = 0;
	vl sum(N + 1);
	for (i = 0; i < N; i++) {
		sum[i + 1] = sum[i];
		if (S[i] == 'W') W++;
		else {
			R++; sum[i + 1]++;
		}
	}
	ans = INF;
	// 前のi個をRにする
	for (i = 0; i <= N; i++) {
		ll pre = abs(i - R);
		pre += i - sum[i];
		ans = min(ans, pre);
		//debug(pre);
	}
	co(ans);
}

Measured memory_bytes: 5240
import Control.Monad
import Text.Printf

main :: IO ()
main = do
    n <- readLn
    unless (n == 0) $ do
        ns <- fmap (map read . words) getLine
        printf "%.8f\n" (sd ns)
        main

sd :: [Double] -> Double
sd xs = sqrt v
    where v = sum [(x-m)^2 | x <- xs] / n
          m = sum xs / n
          n = fromIntegral (length xs)


Measured memory_bytes: 4900
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> p(n), q(n);
	rep(i, n) {
		cin >> p[i];
	}
	rep(i, n) {
		cin >> q[i];
	}
	vector<int> v = p;
	sort(v.begin(), v.end());
	int cp, cq, cnt = 0;
	do {
		cnt++;
		if (v == p) cp = cnt;
		if (v == q) cq = cnt;
	} while (next_permutation(v.begin(), v.end()));
	cout << abs(cp - cq) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  cin >> H >> W;
  for(int i = 0; i < W + 2; i++){
    cout << "#";
  }
  cout << endl;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      char a;
      cin >> a;
      if(W == 1){cout << "#" << a << "#" << endl;}
      else{
        if(j == 0){cout << "#" << a;}
      	else if(j == W - 1){cout << a << "#" << endl;}
      	else{cout << a;}
      }
    }
  }
  for(int i = 0; i < W + 2; i++){
    cout << "#";
  }
  cout << endl;
}
      
 
   
  

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

	public static void main(String [] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int m = sc.nextInt();
		
		int[][] A = new int[n][m];
		
		for(int i = 0;i < n;i++) {
			for(int j = 0;j < m;j++) {
				
				int a = sc.nextInt();
				
				
				A[i][j] = a;
				
						
						
			}
		}
		
		int[] B = new int[m];
		
		for(int k = 0;k < m;k++) {
			
			int b = sc.nextInt();
			
			
			B[k] = b;
			
			
		}
		
		//Aは要素Aの配列、Bは要素Bの配列
		
		int sum = 0;
		int seki;
		
		for(int x = 0;x < n;x++) {
			sum = 0;
			
			
			for(int y = 0;y < m;y++) {
				
				
				
				
				seki = A[x][y] * B[y];
				sum = sum + seki;
				
				
			}
			
			System.out.println(sum);
		}
		
		
		
		
		
		
		
		}



}



Measured memory_bytes: 41136
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
void init_fact(){
	kaijo[0]=1;
	for(int i=1;i<=200000;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	if(!kaijo[0])init_fact();
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
	x=modpow(x,MOD-2);
	return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
double dist(double ax,double ay,double bx,double by){
	return sqrt((bx-ax)*(bx-ax)+(ay-by)*(ay-by));
}
int n;
string s;
signed main(){
	cin>>n>>s;
	if(n%2==1)puts("No");
	else{
		if(s.substr(0,n/2)==s.substr(n/2,n/2))puts("Yes");
		else puts("No");
	}
	return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($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:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

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

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        n: usize,
        a: [i64; n],
    }
    let mut a = a.iter().fold(0, |a, b| a | b);
    let mut x = 0;
    while a % 2 == 0 {
        x += 1;
        a /= 2;
    }
    puts!("{}\n", x);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include <iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;

int N, D, Q;
int d[500005];
int A[500005];
int B[500005];
int q[500005];
int near = 10000000;

int main() {

  cin >> N >> D;
  A[0] = D;

  for(int i = 0; i < N; i++) {
    cin >> d[i];
    A[i+1] = min(A[i],abs(A[i] - d[i]));
  }

  cin >> Q;
  for(int i = 0; i < Q; i++) cin >> q[i];

  B[N] = 1;

  for(int i = N; i > 0; i--) {
    if(B[i] <= (d[i-1] / 2)) {
      B[i-1] = B[i];
    }
    else B[i-1] = B[i] + d[i-1];
  }

  for(int i = 0; i < Q; i++) {
    if(A[q[i] - 1] >= B[q[i]]) cout << "YES" <<endl;
    else cout << "NO" <<endl;
  }
}
      
      
    
    
    
  


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

typedef struct{
  int id;
  int p;
  int s;
  int c;
  int r;
  int l;
} Tree;
 
int n;
Tree *T;
 
int getdepth(int u){
 
  int a = 0;
 
  while(T[u].p >= 0){
    u = T[u].p;
    a++;
  }
  return a;
}

int getheight(int x, int y){

  int a=0, b=0;
   
  if(T[x].r != -1){
    a = getheight(T[x].r, y+1);
  }  
  if(T[x].l != -1){
    b = getheight(T[x].l, y+1);
  } 
  if(T[x].l == -1 && T[x].r == -1){
    return y;
  }
  if(a>=b){
    return a;
  }
  else return b;
}
 
void print(void){
 
  int i;
 
  for(i=0;i<n;i++){
 
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",T[i].id,T[i].p,T[i].s,T[i].c,getdepth(i),getheight(i,0));

    if(T[i].c == 0 && T[i].p != -1)
      printf("leaf");
    else if(T[i].c != 0 && T[i].p != -1)
      printf("internal node");
    else
      printf("root");
    printf("\n");
  }
}
 
 
int main(){
 
  int i,node,c,l,r;

  scanf("%d",&n);
 
  T = malloc(n * sizeof(Tree));
 
  for(i=0;i<n;i++){
    T[i].id = T[i].p = T[i].s = T[i].l = T[i].r = -1;
    T[i].c = 0;
  }
 
  for(i=0;i<n;i++){
    c = 0;
    scanf("%d",&node);
    scanf("%d %d",&T[node].l,&T[node].r);
    T[node].id = node;
    if(T[node].l != -1){
      T[T[node].l].p = node;
      T[T[node].l].s = T[node].r;
    }

    if(T[node].r != -1){
      T[T[node].r].p = node;
      T[T[node].r].s = T[node].l;
    }



    if(T[node].l == -1) c++;
    if(T[node].r == -1) c++;

    if(c == 0) T[node].c = 2;
    else if(c == 1) T[node].c = 1;
    else T[node].c = 0;

  }
  print();
  free(T);
  return 0;
}



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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  ll n, ms, c=0, non=0;
  cin >> n;
  vecll m(5, 0);
  string s;
  forll(i, 0, n){
	cin >> s;
	if (s[0] == 'M')
	  m[0]++;
	if (s[0] == 'A')
	  m[1]++;
	if (s[0] == 'R')
	  m[2]++;
	if (s[0] == 'C')
	  m[3]++;
	if (s[0] == 'H')
	  m[4]++;
  }
  forll(i, 0, 5){
	if (m[i] == 0)
	  non++;
  }
  if (non > 2){
	cout << 0 << endl;
	return 0;
  }
  forll(i, 0, 5){
	forll(j, i+1, 5){
	  forll(k, j+1, 5){
		c += m[i] * m[j] * m[k];
	  }
	}
  }
  cout << c << endl;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = ReadInts();
            WriteLine(s.Max() - s.Min());
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13268
#include "bits/stdc++.h"
using namespace std;typedef long long lint;typedef vector<lint> liv;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(),v.end()
#define linf 1152921504606846976
#define MAXN 100010

#define md 1000000007
int main(){
	lint n;cin>>n;
	string s;cin>>s;
	lint a[26]={};
	rep(i,n)a[s[i]-'a']++;
	lint ans=1;
	rep(i,26)if(a[i]){
		ans*=a[i]+1;
		ans%=md;
	}cout<<ans-1<<endl;
}

//lint n;
//vector<int> u;
//set<int> last;
//int dfs(int d,int x){
//	int ret=0;
//	if(d==(1<<n)){
//		//for(auto i:u)cout<<i<<" ";cout<<endl;
//		last.insert(u.back());
//		return 1;
//	}
//	rep(i,n)if(!count(all(u),x^(1<<i))){
//		int c=x^(1<<i);
//		u.push_back(c);
//		ret+=dfs(d+1,c);
//		u.pop_back();
//	}
//	return ret;
//}
//
//int main(){
//	cin>>n;
//	u.push_back(15);
//	u.push_back(7);
//	dfs(2,7);
//	for(auto i:last)cout<<i<<" ";
//}

//#define md 1000000007
//int main(){
//	lint n;cin>>n;
//	lint x=1LL<<n;
//	liv a(x);rep(i,x)a[i]=i;
//	lint cnt=0;
//	set<pair<int,int> >s;
//	do{
//		bool ok=1;
//		rep(i,x-1){
//			lint cur=(a[i]^a[i+1]);
//			if((cur&-cur)!=cur){
//				ok=0;break;
//			}
//		}//lint cur=a[0]^a[x-1];
//		//if((cur&-cur)!=cur)ok=0;
//		if(ok&&!s.count({a[0],a[x-1]})){
//			rep(i,x)cout<<a[i]<<' ';cout<<endl;++cnt;
//			s.insert({a[0],a[x-1]});
//		}
//	} while(next_permutation(all(a)));cout<<cnt<<endl;
//}

//sub-EOF


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

int main(){
	int n; cin >> n;
	vector<int> l(n);
	rep(i,n) cin >> l[i];
	sort(l.begin(),l.end());
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = i+1; j < n; ++j) {
			auto itr = lower_bound(l.begin(),l.end(), l[i]+l[j]) - l.begin();
			ans += itr - j - 1;
		}
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define int long long
 
// loop
#define FOR(i, a, b) for (int i = (a); i < (b); i++) 	// a ~ b-1	(ascending)
#define REP(i, n) FOR(i, 0, n)							// 0 ~ n-1
#define NREP(i, n) FOR(i, 1, n + 1)						// 1 ~ n
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)	// a ~ b	(descending)
#define RREP(i, n) RFOR(i, n, 0)						// n ~ 0
#define RNREP(i, n) RFOR(i, n, 1)						// n ~ 1
 
// container operation
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ASORT(c) std::sort((c).begin(), (c).end())
#define DSORT(c) std::sort((c).begin(), (c).end(), std::greater<typeof((c).front())>())
#define SIZE(x) ((int)(x).size())
 
// debug
#define check(x) std::cout << #x << " = " << x << '\n'
 
// print
#define cout(x) std::cout << x << '\n'
 
// typedef
typedef std::vector<int> VI;
typedef std::vector<VI> VII;
typedef std::vector<std::string> VS;

std::string yes = "Yes\n";
std::string no = "No\n";

void solve();

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

void solve() {
  int t, x;
  std::cin >> t >> x;
  cout(1.*t / x);
}

Measured memory_bytes: 256
// C - Attention
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

char in(){char x;cin>>x;return x;}

int main(){
	int N; cin>>N;
	int w = 0, count = 0;
	rp(i, 0, N) if(in()=='W') w++; else if(w>0){ w--; count++; }
	cout<< count <<endl;
}

Measured memory_bytes: 256
import itertools

def check_p(p):
    #(a, b)の左上から右下への斜め線は(k, k+(b-a))
    for i in range(8):
        for j in range(i+1, 8):
            if p[j] - j == p[i] - i:
                return 0
    
    #(a, b)の右上から左下への斜め線は(a, b)について和一定
    for i in range(8):
        for j in range(i+1, 8):
            if p[j] + j == p[i] + i:
                return 0

    return 1

def print_p(p):
    for i in range(8):
        q = p[i]
        for j in range(8):
            if j != q:
                print(".", end = "")
            else:
                print("Q", end = "")
    
        print()
    return 0

k = int(input())
put_Q = list()
for i in range(k):
    put_Q.append(list(map(int, input().split())))

board = [["n" for _ in range(8)] for _ in range(8)]

error = 0
for p in itertools.permutations(list(range(8))):
    # print(p)
    for i in range(k):
        if p[put_Q[i][0]] != put_Q[i][1]:
            error = 1

    if error == 0:
        if check_p(p) == 1:
            print_p(p)
            break
    
    error = 0


Measured memory_bytes: 5664