akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using CompLib.Util;

public class Program
{
    int N, Ma, Mb;

    int[] A, B, C;
    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        Ma = sc.NextInt();
        Mb = sc.NextInt();

        A = new int[N];
        B = new int[N];
        C = new int[N];

        for (int i = 0; i < N; i++)
        {
            A[i] = sc.NextInt();
            B[i] = sc.NextInt();
            C[i] = sc.NextInt();
        }

        var dp = new int[401, 401];
        for (int i = 0; i <= 400; i++)
        {
            for (int j = 0; j <= 400; j++)
            {
                dp[i, j] = int.MaxValue;
            }
        }

        dp[0, 0] = 0;

        for (int i = 0; i < N; i++)
        {
            for (int j = 400; j >= 0; j--)
            {
                for (int k = 400; k >= 0; k--)
                {
                    if (dp[j, k] == int.MaxValue) continue;
                    dp[j + A[i], k + B[i]] = Math.Min(dp[j + A[i], k + B[i]], dp[j, k] + C[i]);
                }
            }
        }

        int ans = int.MaxValue;
        for (int i = 1; i * Ma <= 400 && i * Mb <= 400; i++)
        {
            ans = Math.Min(ans, dp[i * Ma, i * Mb]);
        }

        if (ans == int.MaxValue) Console.WriteLine("-1");
        else Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


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

using namespace std;

int main() {

    long long n, k, x, y, cont=0;
    
    vector<pair<long long, long long>> v;
    
    cin >> n >> k;
    
    for(int i=0; i<n; i++) {
        cin >> x >> y;
        v.push_back(make_pair(x, y));
        
    }
    
    sort(v.begin(), v.end());
    
    long long i=0;
    cont = v[i].second;
    while(cont < k) {
        cont += v[++i].second;
    }
    
    cout << v[i].first << "\n";

    return 0;

}

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

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, k;
  cin >> a >> b >> k;
  for (int i = a; i <= b; i++) {
    if ((i < a + k) || (i > b - k)) {
      cout << i << endl;
    }
  }
  return 0;
}


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

#define ll long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;

ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
int main() {
    //COMint();
    int n=in();
    vector<ll> odd;
    vector<ll> even;
    ll temp;
    REP(i,n){
        cin>>temp;
        if(i%2==0){
            
            odd.push_back(temp);
        }else{
            even.push_back(temp);
        }
    }
    if(n%2==0){
        REP(i,even.size()){
            cout<<even[even.size()-i-1]<<" ";
        }
        REP(i,odd.size()){
            cout<<odd[i];
            if(i<odd.size()-1){
                cout<<" ";
            }
        }
    }else{
        REP(i,odd.size()){
            cout<<odd[odd.size()-i-1]<<" ";
        }
        REP(i,even.size()){
            cout<<even[i];
            if(i<even.size()-1){
                cout<<" ";
            }
        }
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3948
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
static const int MAX = 2e5;
int main(){
    int n, x = 6, y = 9; sc(n)
    vector<int> six, nine;
    vector<int> dp(MAX,MAX);
    dp[0] = 0;
    while (x <= n){
        six.push_back(x);
        x *= 6;
    }
    while (y <= n){
        nine.push_back(y);
        y *= 9;
    }
    for (int i = 0; i <= n; i++){
        dp[i + 1] = min(dp[i]+1, dp[i+1]);
        for (int j = 0; j < six.size(); j++){
            dp[i+six[j]] = min(dp[i]+1, dp[i+six[j]]);
        }
        for (int j = 0; j < nine.size(); j++){
            dp[i+nine[j]] = min(dp[i]+1, dp[i+nine[j]]);
        }
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    l = list(map(int, lines.pop(0).split(' ')))
    l.sort()
    print(l[2] - l[0])

#
# main
#

# 1. use list instead of stdin
# 2. use stdin

lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

Measured memory_bytes: 2940
"use strict"

function Main(input) {
  
	var readlines = input.split("\n");
	var n = readlines[0];
	var a = readlines[1].split(" ").map(Number);
	var ans = 0;
	for(let i = 0; i < n; i++){
	  if(i % 2 === 0 && a[i] % 2 === 1){
	    ans++;
	  }
	}
	
	console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29648
n = int(input())
h = list(map(int,input().split()))
h.insert(0,0)
sum = 0
bottom = 0
for i, hn in enumerate(h):
  if (i == 0) :
    continue
  if (hn < h[i-1]):
    bottom = hn
  else:
    sum += hn - h[i-1]
print(sum)

Measured memory_bytes: 3060
#import<stdio.h>
#define f(A,B) (t=d[5-B],d[5-B]=d[5-A],d[5-A]=d[B],d[B]=d[A],d[A]=t)
main(){int d[6],t,n,r,i;char s[9];while(scanf("%d",&n),n){for(r=i=1;i<7;++i)d[i-1]=i;while(n--){scanf("%s",s);if(*s=='N')f(0,4);if(*s=='S')f(0,1);if(*s=='E')f(0,2);if(*s=='W')f(0,3);if(*s=='R')f(1,3);if(*s=='L')f(1,2);r+=*d;}printf("%d\n",r);}return 0;}

Measured memory_bytes: 2652
// Stones.cpp : Defines the entry point for the console application.
//

//#include "stdafx.h"
#include <iostream>
#include <algorithm>
using namespace std;
const int G = 1000 * 100 + 10;
int a[G];
int dp[G];

int main()
{
	int n, k;
	cin >> n >> k;
	for (int i = 1; i <= n; i++){
		cin >> a[i];
	}
	for (int i = a[1]; i <= k; i++){
		int m = 3;
		int l = lower_bound(a + 1, a + n + 1, i) - a;
		for (int j = 1; j <= l; j++){
			if (a[j] > i || j == n+1) break;
			int t = (dp[i- a[j]]+1)% 2;
			if (t == 0) t = 2;
			m = min(m,t);
		}
		dp[i] = m;
	}
	if(dp[k] == 1) cout << "First" << endl;
	else cout << "Second" << endl;
	return 0;
}



Measured memory_bytes: 3980
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.text.DecimalFormat;

class Main {
    public static void main (String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);

        int w = sc.nextInt();
        int[] nums = new int[w];
        for (int i = 0; i < w; i++) {
            nums[i] = i + 1;
        }

        int n = sc.nextInt();
        sc.nextLine();

        int a, b, temp;
        String[] pair;
        for (int i = 0; i < n; i++) {
            pair = sc.nextLine().split(",");
            a = Integer.parseInt(pair[0]) - 1;
            b = Integer.parseInt(pair[1]) - 1;

            temp = nums[a];
            nums[a] = nums[b];
            nums[b] = temp;
        }

        StringBuilder sb = new StringBuilder("");
        for (int i = 0; i < w; i++) {
            sb.append(nums[i]);
            sb.append('\n');
        }
        System.out.print(sb);
    }
}

Measured memory_bytes: 26324
N=int(input())
xlist=list(map(int,input().split()))

x2list=xlist[:]
x2list.sort()
mid_l=x2list[N//2-1]
mid_r=x2list[N//2]
#print(mid_l,mid_r)

for x in xlist:
  if x<=mid_l:
    print(mid_r)
  else:
    print(mid_l)

Measured memory_bytes: 26772
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
/*---------------------DEBUGGING--------------------------------------------*/
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 mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define N 300005
#define vi vector<int>
#define all(v) v.begin(),v.end()

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int a,b,c,d;
   cin>>a>>b>>c>>d;
   int x = (c/b);
   if(c % b !=0)x++;
   int y=(a/d);
   if(a % d !=0)y++;
   if(x<=y)
    cout<<"Yes"<<endl;
   else
   cout<<"No"<<endl;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#define    boost        ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define    nl           "\n"
#define    ll           long long
#define    pb           push_back
#define    mpr          make_pair
#define    fr(i,a,n)    for(ll i=a;i<n;++i)
#define    fr0(i,n)     for(ll i=0;i<n;++i)
#define    pii          pair<int, int>
#define    FO           find_by_order
#define    OK           order_of_key
#define    mem(a)       memset(a,0,sizeof(a))
#define    ff           first
#define    ss           second


typedef tree <
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update >
set_t;


void fio()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}


template<typename T> void TIME(T start, T end)
{
#ifndef ONLINE_JUDGE
	double time_taken =  chrono::duration_cast<chrono::nanoseconds>(end - start).count();
	time_taken *= 1e-9;
	cout << "\nExecuted in: " << fixed
	     << time_taken << setprecision(9);
	cout << " sec";
#endif
}

///----------------------------- | FUNCTIONS | --------------------------------------///

/*
const int N = 2e5 + 5;

vector<int> adj[N];
bool visited[N];
//int val[N];
//int depth[N];
//int parent[N];

void dfs(int v)
{
	visited[v] = true;
	for (int u : adj[v])
	{
		if (!visited[u])
		{
			//parent[u] = v;
			//depth[u] = depth[v] + 1;
			dfs(u);
		}
	}
}
*/

// left shift << multiply by 2
// right shift >> divide by 2

///----------------------------- | START FROM HERE | --------------------------------------///

#define int long long //change int main to int32_t main
const int INF = 1e9 + 5;

const int N = 1e5 + 5;

int dp[105][N];
int w[105], v[105];
int n, fw;


void solve()
{

	cin >> n >> fw;
	fr0(i, n) cin >> w[i + 1] >> v[i + 1];

	fr(i, 1, N)  dp[0][i] = INF;
	int ans = 0;
	fr(j, 1, n + 1) fr0(i, N)
	{
		if (i - v[j] >= 0)
			dp[j][i] = min(dp[j - 1][i], w[j] + dp[j - 1][i - v[j]]);
		else dp[j][i] = dp[j - 1][i];
		if (dp[j][i] <= fw) ans = max(ans, i);
	}



	cout << ans << nl;
}





int32_t main()
{
	auto start = chrono::high_resolution_clock::now();
	boost;
	fio();
	int t;
	t = 1;
	//cin >> t;
	while (t--) solve();
	auto end = chrono::high_resolution_clock::now();
	TIME(start, end);
	return 0;
}




Measured memory_bytes: 82532
#include <iostream>
#include <vector>
#include <set>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
int n, m, q;
int a[51], b[51], c[51], d[51];
int v[11];
int ans = 0;
 
 
int main() {
    long long  A, B, C, K;
    cin >> A >> B >> C >> K;
    long long sum = 0;
    if (K-(A+B) > 0){
        sum += (1*A);
        sum -= (1*(K-(A+B)));
    } else {
        if (A >= K) {
             sum += (1*K);
        } else {
             sum += (1*A);
        }
    }
    
    
    cout << sum <<endl;
    return 0;
}


Measured memory_bytes: 3580
#include<iostream>
#include<string>
#include<vector>
int main() {
	int in;
	std::vector<int> ins;
	while (true) {
		std::cin >> in;
		if (in == 0) {
			break;
		}
		else {
			ins.push_back(in);
		}
	}
	for (int i = 0; i < ins.size(); i++) {
		std::cout << "Case " << i + 1 << ": " << ins[i] << "\n";
	}
	return 0;
}


Measured memory_bytes: 3264
n =  int(input())
for i in range(n):
    tri_list = list(map(int,input().split(" ")))
    #tri_list = input().split(" ")
    tri_list.sort()
    a = int(tri_list[2]) ** 2
    b = int(tri_list[0]) ** 2 + int(tri_list[1]) ** 2
    if a == b:
        print("YES")
    else:
        print("NO")


Measured memory_bytes: 5592
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n),b(n),c(n);
  for(int i=0; i<n; i++) {
      cin >> a[i];
      b[i]=a[i];
      c[i]=a[i];
  }
  if(prev_permutation(b.begin(),b.end())) {
      for(int i=0; i<n; i++) {
          if(i>0) {
              cout << " ";
          }
          cout << b[i];
      }
      cout << endl;
  }
  for(int i=0; i<n; i++) {
      if(i>0) {
          cout << " ";
      }
      cout << a[i];
  }
  cout << endl;
  if(next_permutation(c.begin(),c.end())) {
      for(int i=0; i<n; i++) {
          if(i>0) {
              cout << " ";
          }
          cout << c[i];
      }
      cout << endl;
  }
}


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

int64_t ret[101];
void prime_factor(int64_t N) {
  for(int64_t i = 2; i * i <= N; i++) {
    while(N % i == 0) {
      ret[i]++;
      N /= i;
    }
  }
  if(N != 1) ret[N]++;
}

int main(){
    int64_t n;
    cin >> n;
    int two=0;
    int four=0;
    int twofour=0;
    int onefour=0;
    int sevenfour=0;
    for(int64_t i=2;i<n+1;i++)prime_factor(i);
    for(int64_t i=2;i<=n;i++){
        if(ret[i]>=74)sevenfour++;
        if(ret[i]>=24)twofour++;
        if(ret[i]>=14)onefour++;
        if(ret[i]>=4)four++;
        if(ret[i]>=2)two++;
    }
    cout << sevenfour+twofour*(two-1)+onefour*(four-1)+four*(four-1)/2*(two-2) << endl;
}


Measured memory_bytes: 256
import heapq

n, m = map(int, input().split())
a = list(map(int, input().split()))
pq = []
for i in range(n):
    pq.append((-a[i], -a[i], 0))
heapq.heapify(pq)
for i in range(m):
    if len(pq) == 0: break
    mx = heapq.heappop(pq)
    if -mx[1] >= (2 ** (mx[2] + 1)): heapq.heappush(pq, (-(-mx[1] // (2 ** (mx[2] + 1))), mx[1], mx[2] + 1))
ans = 0
while len(pq) != 0:
    ans -= heapq.heappop(pq)[0]
print(ans)

Measured memory_bytes: 22116
#include <iostream>
#include <string>
using namespace std;
 
int main(){
     int D;
     cin >> D;
     string ans;
     if (D==22) {ans = "Christmas Eve Eve Eve";}
    else if (D==23) {ans = "Christmas Eve Eve";}
    else if (D==24) {ans = "Christmas Eve";}
    else {ans = "Christmas";}
    cout << ans << endl;
}


Measured memory_bytes: 256
var readable = process.stdin;
readable.resume();
readable.setEncoding( 'utf-8' );
readable.on( 'data', function( chunk ) {
  var data = chunk.split( ' ' );
  var a = parseInt( data[0] );
  var b = parseInt( data[1] );
  if( a < b ) {
    console.log( 'a < b' );
  } else if( b < a ) {
    console.log( 'a > b' );
  } else {
    console.log( 'a == b' );
  }
} )

Measured memory_bytes: 7648
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define alpha_size 26

const int N = 1e4 + 10;
int a[N];
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);    

    int n, m;
    cin >> n >> m;
    int sum = 0;
    for (int i = 0; i < m; i++){
      int x;
      cin >> x;
      sum += x;
    }
    if (sum > n) cout << -1 << endl;
    else cout << n - sum << endl;
}



Measured memory_bytes: 3656
A = sorted(list(map(int, input().split())), reverse=True)
if ((A[0] - A[1]) + (A[0] - A[2])) % 2 == 0:
    ans = ((A[0] - A[1]) + (A[0] - A[2])) // 2
else:
    ans = ((A[0] - A[1]) + (A[0] - A[2])) // 2 + 2
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;
 
int main() {
    ll n, k;
    cin >> n >> k;
    vector<P> a(n);
    rep(i, n)cin >> a[i].first >> a[i].second;
    sort(all(a));
    rep(i, n){
        if(k <= a[i].second){
            cout << a[i].first << endl;
            return 0;
        }
        k -= a[i].second;
    }
}


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

//#define DEBUG

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

void Preorder(int);
void Inorder(int);
void Postorder(int);

node* tree;
int n;

int main(){
  int i,n,id,left,right,root;

  scanf("%d",&n);

  tree = (node *)malloc(sizeof(node)*n);

  for(i=0;i<n;i++) tree[i].parent = -1;
  for(i=0;i<n;i++){
    scanf("%d %d %d",&id,&left,&right);
    tree[id].left=left;
    tree[id].right=right;
    if(left!=-1) tree[left].parent=id;
    if(right!=-1) tree[right].parent=id;
  }

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

  #ifdef DEBUG
  printf("debug\n");
  printf("n=%d\n",n);
  for(i=0;i<n;i++){
    printf("%d %d %d parent=%d\n",i,tree[i].left,tree[i].right,tree[i].parent);
  }
  #endif

  printf("Preorder\n");
  Preorder(root);
  printf("\n");

  printf("Inorder\n");
  Inorder(root);
  printf("\n");

  printf("Postorder\n");
  Postorder(root);
  printf("\n");

  return 0;
}

void Preorder(int c){
  printf(" %d",c);
  if(tree[c].left != -1) Preorder(tree[c].left);
  if(tree[c].right != -1) Preorder(tree[c].right);
  return;
}

void Inorder(int c){
  if(tree[c].left != -1) Inorder(tree[c].left);
  printf(" %d",c);
  if(tree[c].right != -1) Inorder(tree[c].right);
  return;
}

void Postorder(int c){
  if(tree[c].left != -1) Postorder(tree[c].left);
  if(tree[c].right != -1) Postorder(tree[c].right);
  printf(" %d",c);
  return;
}

Measured memory_bytes: 616
#include <stdio.h>
#define heapsize 1024*256
long long heap[heapsize];
void qpush(long long inx) {
	heap[0]++;
	long long now = heap[0];
	long long tempo;
	heap[now] = inx;
	while (now - 1) {
		if (heap[now / 2] <= heap[now])return;//hikaku
		tempo = heap[now / 2];
		heap[now / 2] = heap[now];
		heap[now] = tempo;
		now /= 2;
	}
}
long long qout(void) {
	long long retu = heap[1];
	long long tempo = heap[0];
	long long now = 1;
	long long end;
	while (true) {
		if (now * 2 > tempo) {
			end = now;
			break;
		}
		if (now * 2 == tempo) {
			heap[now] = heap[now * 2];
			end = now * 2;
			break;
		}
		if (heap[now * 2] > heap[now * 2 + 1]) {//hikaku
			heap[now] = heap[now * 2 + 1];
			now = now * 2 + 1;
		}
		else {
			heap[now] = heap[now * 2];
			now = now * 2;
		}
	}
	heap[0] = end - 1;
	qpush(heap[tempo]);
	heap[tempo] = 0;
	heap[0] = tempo - 1;
	return retu;
}
int n;
long long a[300000];
long long s, t, m;
long long bs[100001];
long long cs[100001];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < 3 * n; i++) {
		scanf("%lld", a + i);
	}
	for (int i = 0; i < n; i++) {
		s += a[i];
		qpush(a[i]);
	}
	bs[0] = s;
	for (int i = 0; i < n; i++) {
		s += a[n + i];
		qpush(a[n + i]);
		t = qout();
		s -= t;
		bs[i + 1] = s;
	}
	for (int i = 0; i < n; i++)qout();
	s = 0;
	for (int i = 0; i < n; i++) {
		s += -a[2 * n + i];
		qpush(-a[2 * n + i]);
	}
	cs[n] = s;
	for (int i = n - 1; i >= 0; i--) {
		s -= a[n + i];
		qpush(-a[n + i]);
		t = qout();
		s -= t;
		cs[i] = s;
	}
	m = -1000000000;
	m *= 100000;
	for (int i = 0; i <= n; i++) {
		if (bs[i] + cs[i] > m)m = bs[i] + cs[i];
	}
	printf("%lld\n", m);
}

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

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

using namespace std;

int main() {
    int A,B;
    cin >> A >> B;
    if(A>=6 && A<=12) B /=2;
    else if(A<6) B = 0;
    cout << B << endl;
}

Measured memory_bytes: 256
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
ll n,m,k,ans;
void solve()
{
    string s;cin>>s;
    stack<char>st;
    for(auto it:s)
    {
        if(st.empty()||st.top()==it)
            st.push(it);
        else
            {ans+=2;st.pop();}
    }
    cout<<ans<<endl;
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int a,b;
    char op;
    cin>>a>>op>>b;
    if(op=='+')cout<<a+b<<endl;
    else cout<<a-b<<endl;
}


Measured memory_bytes: 384
H, N = map(int, input().split())
#Cost=[]
#for i in range(N):
#  A, B = map(int, input().split())
#  Cost.append([A, B])
Cost=[[int(x) for x in input().split()] for _ in range(N)]
#  Cost.append((A, B, A/B))
#Cost = sorted(Cost, key=lambda row: row[0], reverse=True)
#sortedCost = sorted(Cost, key=lambda row: row[2], reverse=True)
#print(Cost)

DP=[float('inf')]*(H+2)
DP[0]=0
DP[1]=0
for i in range(2,H+2):
    for j in range(N):
      if i-Cost[j][0]>=0:
          DP[i]=min(DP[i], DP[i-Cost[j][0]]+Cost[j][1])
      else:
          DP[i]=min(DP[i], Cost[j][1])

print(DP[H+1])

Measured memory_bytes: 42988
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
#define All(x) (x).begin(),(x).end()
#define RAll(x) (x).rbegin(),(x).rend()


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

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  string S;
  ll K;
  cin>>S>>K;
  for(int i=0;i<S.size()-1;++i) {
    if(S[i]=='a') continue;
    if(K>='z'-S[i]+1) {
      K -= 'z'-S[i]+1;
      S[i] = 'a';
    }
  }
  K %= 26;
  if(S[S.size()-1]+K>'z') S[S.size()-1] = 'a' - 1 + S[S.size()-1]+K-'z';
  else S[S.size()-1] += K;
  cout<<S<<endl;
}



Measured memory_bytes: 3760
/**
 *    author:  RM07
 *    created: July 05, 2020 5:42 PM
 *    motto: Knowledge is Power, Strive for Excellence
**/
#include<bits/stdc++.h>
using namespace std;
#define int long long 
signed main(){
    int n;
    cin >> n;
    map<string,int> mp;
    while(n--){
        string str;
        cin >> str;
        mp[str]++;
    }
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;
}

Measured memory_bytes: 3632
#include<math.h>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include<array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
#include<bitset>
//AtCoderC++.cpp

using namespace std;

vector<int> _prime;
vector<int> build_prime_table(int max) {
	vector<int> table = vector<int>(max + 1, -1);
	table[0] = 0;
	table[1] = 0;
	table[2] = 1;
	for (size_t i = 3; i <= max; i++) {
		if (i % 2 == 0) { table[i] = 0; continue; }
		if (table[i] != -1)continue;
		table[i] = 1;
		for (size_t j = i + i; j <= max; j += i) {
			table[j] = 0;
		}
	}
	return table;
}
bool is_prime(int n) {
	if (_prime[n] != -1)return _prime[n] == 1;
	if (n % 2 == 0)return false;
	for (size_t i = 3; i < n; i += 2) {
		if (n%i == 0) {
			_prime[n] = 0;
			return false;
		}
	}
	_prime[n] = 1;
	return true;
}

bool is_2017_family(int n) {
	return  is_prime(n) && is_prime((n + 1) / 2);
}


int main() {
	int Q; cin >> Q;
	auto rs = vector<pair<int, int>>(Q);
	int l, r, max_r = 0;
	for (int i = 0; i < Q; i++) {
		cin >> l >> r;
		max_r = max(max_r, r);
		rs[i] = { l, r };
	}
	auto p = build_prime_table(max_r); 
	auto count_table = vector<int>(max_r + 1, 0);
	for (size_t i = 1; i <= max_r; i++) count_table[i] = (p[i] == 1 && p[(i + 1) / 2] == 1) ? count_table[i - 1] + 1 : count_table[i - 1];
	for (size_t i = 0; i < Q; i++) cout << count_table[rs[i].second] - count_table[rs[i].first - 1] << endl;
}


Measured memory_bytes: 2176
#include <queue>
#include <algorithm>
#include <cstring>
#include <cstdio>
using namespace std;

typedef int W;
const int MAXV = 1005;
const int MAXE = 5005;
const int INF = 100000000;
int adj[100][100];

int main() {
  int n,m,s,g1,g2,b1,b2,c;

  while(~scanf("%d%d%d%d%d", &n, &m, &s, &g1, &g2),
        n|m|s|g1|g2) {
    s--,g1--,g2--;

    for(int i = 0; i < 100; ++i) {
      for (int j = 0; j < 100; ++j)
        adj[i][j] = INF;
      adj[i][i] = 0;
    }

    for(int i=0; i<m; ++i) {
      scanf("%d%d%d", &b1, &b2, &c);
      b1--,b2--;
      adj[b1][b2] = c;
    }

    for (int k = 0; k < n; ++k)
      for (int i = 0; i < n; ++i) {
        const int p = adj[i][k];
        for (int j = 0; j < n; ++j)
          adj[i][j] = min(adj[i][j], p + adj[k][j]);
      }

    int minc = INF;
    for(int i=0; i<n; ++i)
      minc = min(minc, adj[s][i]+adj[i][g1]+adj[i][g2]);

    printf("%d\n", minc);
  }
}

Measured memory_bytes: 1064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8101145141919364364;

int main(){
	int n; cin>>n;
	string s; cin>>s;
	map<string,int> mp;
	mp[s]++;
	char last=s.back();
	rep(i,n-1){
		string w; cin>>w;
		mp[w]++;
		if(w[0]!=last||mp[w]>1){
			cout<<"No"<<endl;
			return 0;
		}
		last=w.back();
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
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 (a>b) { a = b; return 1; } return 0; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;


int main(){
    ll S, W;
    cin >> S >> W;
    string res = "safe\n";
    if (S <= W) res = "unsafe\n";
    cout << res;
}


Measured memory_bytes: 3656
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    private int H,W,D;
    public void Solve()
    {
        var c="RYGB";
        var l=Console.ReadLine().Split(' ');
        H=int.Parse(l[0]);
        W=int.Parse(l[1]);
        D=int.Parse(l[2]);
        for(int i=0;i<H;i++)
        {
            for(int j=0;j<W;j++)
            {
                int ii=(i+j)/D;
                int jj=(j-i+H)/D;
                int col=0;
                if(ii%2==0)
                {
                    col+=1;
                }
                if(jj%2==0)
                {
                    col+=2;
                }
                Console.Write(c[col]);
            }
            Console.Write('\n');
        }
    } 
    
    static void Main()
    {
        new Program().Solve();
    }
}

Measured memory_bytes: 13396
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	long long n, a = 0, b = 0, d = 0, ans = 0; string s; cin >> n;
	int c = n;
	for (int h = 0; h < n; h++) {
		cin >> s;
		for (int i = 0; i < s.size(); i++) {
			if (s[i] == 'A'&&s[i + 1] == 'B') {
				ans++;
			}
		}
		if (s[0] == 'B'&&s[s.size() - 1] == 'A') { a++; b++; c--; }
		else if (s[0] == 'B') { b++; c++; }
		else if (s[s.size() - 1] == 'A') { a++; c++; }
		else { c--; d++; }
	}
	if (c == 0 && d != n) { cout << ans + min(a, b) - 1 << endl; }
	else { cout << ans + min(a, b) << endl; }
	cin >> n;
}

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

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

using namespace std;

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

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

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
const int table[]={0,1,2,3,5,7,8,9};
int main(){
	int n;
	while(cin>>n,n){
		string ans="";
		while(n){
			ans +=table[n%8]+'0';
			n /=8;
		}
		reverse(ans.begin(), ans.end());
		cout <<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1200
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <map>
#include <string>

using namespace std;

typedef long long ll;

ll N;
ll pow2[35];

int used[20];
map<ll,string>mp;
vector<ll>vec;

void dfs(int depth){

	int i;

	if(depth==17){
		ll sum=0ll;
		for(i=0;i<17;i++){
			if(used[i]==1){
				sum+=pow2[2*i];
			}
		}
		string str="";

		for(i=16;i>=0;i--){
			str+=used[i]+'0';
		}
		mp[sum]=str;
		vec.push_back(sum);
		return;
	}
	used[depth]=1;
	dfs(depth+1);
	used[depth]=0;
	dfs(depth+1);

}

void dfs2(int depth){

	int i;

	if(depth==16){
		ll sum=0ll;
		for(i=0;i<16;i++){
			if(used[i]==1){
				sum-=pow2[(2*i)+1];
			}
		}
		string str="";

		for(i=15;i>=0;i--){
			str+=used[i]+'0';
		}
		mp[sum]=str;
		return;
	}
	used[depth]=1;
	dfs2(depth+1);
	used[depth]=0;
	dfs2(depth+1);

}


int main() {

	scanf("%lld",&N);

	int i,j;

	pow2[0]=1ll;
	for(i=1;i<33;i++){
		pow2[i]=pow2[i-1]*2ll;
	}
	dfs(0);
	dfs2(0);

	string ans="";

	for(i=0;i<vec.size();i++){
		if(mp[N-vec[i]].size()>0 &&N-vec[i]<=0ll){
			j=0;
			int cnt1=0;
			int cnt2=0;
			while(1){
				if(j%2==0 && mp[vec[i]].size()>cnt1){
					ans+=mp[vec[i]][cnt1];
					cnt1++;
				}
				else if(j%2==1 && mp[N-vec[i]].size()>cnt2){
					ans+=mp[N-vec[i]][cnt2];
					cnt2++;
				}
				else{break;}
				j++;
			}
			break;
		}
	}

	int cnt=0;

	for(i=0;i<ans.size();i++){
		if(ans[i]=='1'){cnt++;}
	}

	if(cnt==0){
		printf("0\n");
	}
	else{
		int flag=0;
		for(i=0;i<ans.size();i++){
			if(ans[i]=='1'){flag=1;}
			if(flag>0){cout<<ans[i];}
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 36084
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for

int main()
{
    string S;
    cin >> S;
    rep(i, S.size())if(S[i] == ',')S[i] = ' ';
    cout << S << endl;
    return 0;
}


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

using namespace std;
const int MAX_PR = 5000000;
bitset<MAX_PR> isprime;

vector<int> run_sieve(int lim) {
	isprime.set(); isprime[0] = isprime[1] = 0;
	for (int i = 4; i < lim; i += 2) isprime[i] = 0;
	for (int i = 3; i*i < lim; i += 2) if (isprime[i])
		for (int j = i*i; j < lim; j += i*2) isprime[j] = 0;
	vector<int> pr;
	for(int i = 2; i < lim; ++i) if (isprime[i]) pr.push_back(i);
	return pr;
}
int x;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	vector<int> pr = run_sieve(100005);
	cin>>x;
	cout<<(isprime[x]?x:*upper_bound(pr.begin(),pr.end(),x))<<"\n";

	return 0;	
}



Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    char[] s = scanner.next().toCharArray();
    StringBuilder sb = new StringBuilder();
    for (char ch : s) {
      if (ch == 'B') {
        if (sb.length() > 0) sb.setLength(sb.length() - 1);
      } else {
        sb.append(ch);
      }
    }
    System.out.println(sb.toString());
  }
}


Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<string>

using namespace std;

int main(){
    int A, B;

    cin >> A >> B;

    if(1 <= A && A <= 9){
        if(1 <= B && B <= 9){
            cout << A*B;
        }
        else{
            cout << -1;
        }
    }
    else{
        cout << -1;
    }
}

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

lli n,a,b;
vll p;

int main(){
  cin >> n >> a >> b;
  if(a+b-1 > n){ cout << -1 << endl;return 0;}
  lli k = n-a;
  for(lli i = 1;i <= a;i++){
    p.push_back(i*b);
    for(lli j = 1;j < b && k > 0;j++,k--){
      p.push_back(i*b-j);
    }
  }
  if(p.size() != n){ cout << -1 << endl;return 0;}
  map<lli,lli> zip;
  for(lli x : p){
    zip[x] = 0;
  }
  lli i = 1;
  for(auto& x : zip){
    x.second = i;
    i++;
  }
  for(lli& x : p){
    x = zip[x];
  }
  for(lli i = 0;i < p.size()-1;i++){
    cout << p[i] << " ";
  }
  cout << p[p.size()-1] << endl;
  return 0;
}


Measured memory_bytes: 24172
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
using namespace std;
typedef long long ll;
const int maxn = 100005;



int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  string s;
  cin>>s;
 int ret = 0;
 int tmp = 0;
 for(int i=0;i<s.size();i++){
   if(s[i]=='A'||s[i]=='T'||s[i]=='C'||s[i]=='G')tmp++;
   else tmp = 0;
   ret=max(ret, tmp);
 }
 cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int gcd(int a, int b){
  return b ? gcd(b, a%b) : a;
}

vector<int> enum_div(int n){
    vector<int> ret;
    for(int i = 1 ; i*i <= n ; ++i){
        if(n%i == 0){
            ret.push_back(i);
            if(i != 1 && i*i != n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,k;cin>>a>>b>>k;
    int p = gcd(a,b);
    auto au = enum_div(p);
    au.push_back(p);
    sort(au.rbegin(), au.rend());
    cout << au[k-1] << endl;

}

Measured memory_bytes: 256
def BinSearch(A, hi, lo):
    b = (hi + lo) // 2
    tmp0 = FindAns(A, b - 1)
    tmp1 = FindAns(A, b)
    if hi == lo:
        tmp2 = FindAns(A, b + 1)
        return min(tmp0, tmp1, tmp2)
    if tmp0 < tmp1:
        return BinSearch(A, b - 1, lo)
    else:
        return BinSearch(A, hi, b + 1)
    
def FindAns(A, b):
    ans = 0
    for a in A:
        ans += abs(a - b)
    return ans

n = int(input())
A = list(map(int, input().split()))
for i in range(n):
    A[i] -= i + 1
    
hi = max(A)
lo = min(A)

print(BinSearch(A, hi, lo))


Measured memory_bytes: 25708
import collections
from functools import lru_cache

from math import sqrt


def read():
    return input().strip()


def readInt():
    return int(input().strip())


def readList():
    return list(map(int, input().strip().split()))


def solve(n):
    f = [0 for _ in range(n+1)]

    for x in range(1, int(sqrt(n) + 1)):
        for y in range(1, int(sqrt(n) + 1)):
            for z in range(1, int(sqrt(n) + 1)):
                s = x**2 + y**2 + z**2 + x*y + y*z + z*x

                if 0 <= s <= n:
                    f[s] += 1

    return "\n".join(map(str, f[1:]))


n = readInt()
print(solve(n))


Measured memory_bytes: 68572
from collections import defaultdict

N, M = map(int, input().split())
submit = defaultdict(int)
ac = 0
penalty = 0
accepted = [False] * N

for _ in range(M):
    P, S = input().split()
    p = int(P) - 1
    if (S == "WA") and (not accepted[p]):
        submit[p] += 1
    elif (S == "AC") and (not accepted[p]):
        accepted[p] = True
        ac += 1

for i in range(N):
    if accepted[i]:
        penalty += submit[i]

print(" ".join(map(str, [ac, penalty])))


Measured memory_bytes: 55128
#include <string>
#include <vector>
#include <iostream>

using namespace std;

inline bool compare(string S1, string S2)
{
	if (S1.size() != S2.size()) { return S1.size() > S2.size(); }

	return S1 > S2;
}

int main()
{
	int H, W; char R[71][71];

	while (true)
	{
		scanf("%d", &W);
		scanf("%d", &H);

		if (H == 0 && W == 0) { break; }

		for (int i = 0; i < H; i++)
		{
			scanf("%s", R[i]);
		}

		vector<vector<string> > dp(H, vector<string>(W, ""));

		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				if (isdigit(R[i][j]))
				{
					if (R[i][j] != '0')
					{
						dp[i][j] = R[i][j];
					}

					if (i != 0)
					{
						if (R[i][j] != '0')
						{
							if (compare(dp[i - 1][j] + R[i][j], dp[i][j]))
							{
								dp[i][j] = dp[i - 1][j] + R[i][j];
							}
						}
						else
						{
							if (compare(dp[i - 1][j] + R[i][j], dp[i][j]) && dp[i - 1][j] != "")
							{
								dp[i][j] = dp[i - 1][j] + R[i][j];
							}
						}
					}

					if (j != 0)
					{
						if (R[i][j] != '0')
						{
							if (compare(dp[i][j - 1] + R[i][j], dp[i][j]))
							{
								dp[i][j] = dp[i][j - 1] + R[i][j];
							}
						}
						else
						{
							if (compare(dp[i][j - 1] + R[i][j], dp[i][j]) && dp[i][j - 1] != "")
							{
								dp[i][j] = dp[i][j - 1] + R[i][j];
							}
						}
					}
				}
			}
		}

		string ret = "";

		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				if (compare(dp[i][j], ret))
				{
					ret = dp[i][j];
				}
			}
		}

		printf("%s\n", ret.c_str());
	}

	return 0;
}

Measured memory_bytes: 3416
#include<iostream>
#include<cmath>
using namespace std;
#define ll long long
int a,b,re;
double fa,fb;
int main(){
	cin>>a>>b;
fa=a/0.08;
fb=b/0.1; 
if(fa>fb)re=ceil(fa);
else re=ceil(fb);
for(;re<1010;re++){
	if(floor((double)re*0.08)==a&&floor((double)re*0.1)==b){cout<<re<<endl;return 0;}
}cout<<-1<<endl;
} 

Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

type Process = (usize, usize, usize, usize);

fn input_tuple() -> (usize, usize) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<usize> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn input_vec() -> Vec<u64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn print(grid: &Vec<u64>, h: usize, w: usize) {
    for i in 0..h {
        for j in 0..w {
            print!("{} ", grid[i * w + j]);
        }
        println!();
    }
}

fn idx(i: usize, h: usize, w: usize) -> (usize, usize) {
    (i / w + 1, i % w + 1)
}

fn main() {
    let (h, w) = input_tuple();
    let mut grid: Vec<u64> = Vec::new();
    for _ in 0..h {
        let mut row = input_vec();
        grid.append(&mut row);
    }
    // print(&grid, h, w);
    let mut count = 0;
    let mut processes: Vec<Process> = Vec::new();
    for i in 0..grid.len() {
        if grid[i] % 2 == 0 {
            continue;
        }
        if (i+1) % w != 0 {
            // right
            grid[i] -= 1;
            grid[i+1] += 1;
            let (y, x) = idx(i, h, w);
            let (ydash, xdash) = idx(i+1, h, w);
            processes.push((y, x, ydash, xdash));
            count += 1;
        } else if i < (h - 1) * w {
            // down
            grid[i] -= 1;
            grid[i+w] += 1;
            let (y, x) = idx(i, h, w);
            let (ydash, xdash) = idx(i+w, h, w);
            processes.push((y, x, ydash, xdash));
            count += 1;
        }
    }
    // print(&grid, h, w);
    println!("{}", count);
    for p in processes {
        println!("{} {} {} {}", p.0, p.1, p.2, p.3);
    }
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x -> left != NIL) {
    x = x -> left;
  }
  return x;
}

Node treeMaximum(Node x){
  while(x -> right != NIL) {
    x = x -> right;
  }
  return x;
}

Node treeSearch(Node u, int k){
  if(u == NIL || k == u -> key) {
    return u;
  }else if(k < u -> key) {
    return treeSearch(u -> left, k);
  }else{
    return treeSearch(u -> right, k);
  }
}

Node treeSuccessor(Node x){
  Node a;
  if(x -> right != NIL) {
    return treeMinimum(x -> right);
  }
  a = x -> parent;
  while(a != NIL && x == a -> right) {
    x = a;
    a = a -> parent;
  }
  return a;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z -> left == NIL || z -> right == NIL) {
    y = z;
  }else{
    y = treeSuccessor(z);
  }

  if(y -> left != NIL) {
    x = y -> left;
  }else{
    x = y -> right;
  }

  if(x != NIL) {
    x -> parent = y -> parent;
  }

  if(y -> parent == NIL) {
    root = x;
  }else if(y == y -> parent -> left) {
    y -> parent -> left = x;
  }else{
    y -> parent -> right = x;
  }

  if(y != z) {
    z -> key = y -> key;
  }
  free(y);
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL) {
    y = x;
    if(z -> key < x -> key) {
      x = x -> left;
    }else{
      x = x -> right;
    }
  }

  z -> parent = y;
  if(y == NIL) {
    root = z;
  }else if(z -> key < y -> key) {
    y -> left = z;
  }else{
    y -> right = z;
  }
}

void inorder(Node u){
  if(u == NIL) {
    return;
  }
  inorder(u -> left);
  printf(" %d",u -> key);
  inorder(u -> right);
}

void preorder(Node u){
  if(u == NIL) {
    return;
  }
  printf(" %d",u -> key);
  preorder(u -> left);
  preorder(u -> right);
}

void search(int x) {
  Node b;
  b = treeSearch(root, x);
  if(b != NIL) {
    printf("yes\n");
  }else{
    printf("no\n");
  }
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20444