akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int x[100005];
int next1[100005];

int p[100005][20];

int N;

int kthparent(int x, int k){
    for(int i = 19; i >= 0; i --){
        if(k >= (1<<i)){
            x = p[x][i];
            k -= (1<<i);
            if(x == N){return x;}
        }
    }
    return x;
}

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

    for(int i = 0; i < N; i ++){
        scanf("%d", &x[i]);
        //printf("x[%d]=%d\n", i, x[i]);
    }

    int L, Q;
    scanf("%d%d", &L, &Q);

    for(int k = 0; k < 20; k ++){
        for(int i = 0; i < N; i ++){
            p[i][k] = N;
        }
    }

    for(int i = 0; i < N; i ++){
        next1[i] = upper_bound(x, x+N, x[i]+L) - x - 1;
        //printf("next1[%d]=%d x[%d]+L=%d\n", i, next1[i], i, x[i]+L);
        p[i][0] = next1[i];
    }

    for(int k = 1; k < 20; k ++){
        for(int i = 0; i < N; i ++){
            if(p[i][k-1] == N){
                p[i][k] = N;
            }else{
                p[i][k] = p[p[i][k-1]][k-1];
            }
        }
    }

    for(int i = 0; i < Q; i ++){
        int a, b;
        scanf("%d%d", &a, &b);
        a --; b --;

        if(a > b){swap(a, b);}

        int lo = 0;
        int hi = N;
        while(lo < hi){
            int mid = (lo+hi)/2;
            int temp = kthparent(a, mid);
            if(temp >= b){
                hi = mid;
            }else{
                lo = mid+1;
            }
        }

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

        /*for(int j = 0; j < 10; j ++){
            printf("(%d, %d): %d\n", a, j, kthparent(a, j));
        }*/
    }

    return 0;
}


Measured memory_bytes: 9472
#include<iostream>

using namespace std;

int main()
{
	int q_lower,bud,c_aizu,c_normal,q_aizuupper;
	while(cin>>q_lower>>bud>>c_aizu>>c_normal>>q_aizuupper){
		int q_aizu=0,q_normal=0;
		q_aizu+=q_aizuupper;
		bud-=q_aizu*c_aizu;
		if(bud<0){
			q_aizu-=(-bud+(c_aizu-1))/c_aizu;
			bud+=((-bud+(c_aizu-1))/c_aizu)*c_aizu;
			if(q_aizu<=0){
				cout<<"NA"<<endl;
				continue;
			}
		}
		q_normal+=bud/c_normal;
		bud-=q_normal*c_normal;

		while(q_aizu+q_normal<q_lower && q_aizu>0){
			q_aizu--;
			bud+=c_aizu;
			q_normal+=bud/c_normal;
			bud-=(bud/c_normal)*c_normal;
		}
		if(q_aizu<=0){
			cout<<"NA"<<endl;
			continue;
		}
		if(q_aizu+q_normal>=q_lower)	cout<<q_aizu<<' '<<q_normal<<endl;
		else	cout<<"NA"<<endl;
	}

	return 0;
}

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

using namespace std;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    multiset<int> s;
    vector<int> a(n);
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
        s.insert(a[i]);
    }
    int res=0;
    for(int i=0;i<n;i++)
    {
        s.erase(s.find(a[i]));
        bool ok=1;
        for(int j=1;j*j<=a[i];j++)
        {
            if((a[i]%j)>0) continue;
            if(s.find(j)!=s.end()) ok=0;
            if(s.find(a[i]/j)!=s.end()) ok=0;
        }
        res+=ok;
        s.insert(a[i]);
    }
    cout << res << "\n";
    return 0;
}


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

const int N = 1e5 + 10;
const int mod = 1e9 + 7;

int n, a[N];
int solve(){
	int st = 0;
    if(n & 1){
        if(a[0] != 1)	return 0;
        st = 2;
    } else {
		st = 1;
    }
    int ans = 1;
    for(int i=st; i<=n; i+=2){
		if(a[i] != 2)	return 0;
		ans = ans * 2 % mod;
    }
    return ans;
}

int main(){
	int x;
	while(~scanf("%d", &n)){
		memset(a, 0, sizeof(a));
        for(int i=0; i<n; i++){
			scanf("%d", &x);
            if(x >= n){
				x = n;
            }
            a[x]++;
        }
        printf("%d\n", solve());
	}
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
 
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, long long m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

const int N=2e5+5;

int n;
int a[N];

int32_t main()
{
    IOS;
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	int curl=1;
	int curxor=0, cursum=0, ans=0;
	for(int i=1;i<=n;i++)
	{	
		cursum+=a[i];
		curxor^=a[i];
		while(cursum!=curxor)
		{
			curxor^=a[curl];
			cursum-=a[curl];
			curl++;
		}
		ans+=(i-curl+1);
	}
	cout<<ans;
    return 0;
} 

Measured memory_bytes: 1792
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input!{
        n: usize,
        a: usize,
        b: usize,
    }

    println!("{}", min(a*n, b));
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define M 1000000007
#define sz(a) (ll)a.size()
#define pll pair<ll,ll>
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll x,y;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>x>>y;
    if(4*x-y>=0 and (4*x-y)%2==0 and y>=2*x)
        cout<<"Yes";
    else
        cout<<"No";
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <numeric>
using namespace std;


int main()
{
    
    int N;
    cin>>N;
    vector<string> s;
    for(int i=1;i<N+1;i++){
        string str;
        cin>>str;
        s.push_back(str);
    }
    
    int counter=0;
    int a_counter=0;
    int b_counter=0;
    bool flag=true;
    for(auto i=s.begin();i!=s.end();i++){
        for(int j=0;j<(*i).length()-1;j++){
            if((*i).substr(j,2)=="AB"){
                counter+=1;
            }
        }
        if((*i).front()=='B'){
            b_counter+=1;
        }
        if((*i).back()=='A'){
            a_counter+=1;
        }
        if((*i).front()=='B' && (*i).back()!='A'){
            flag=false;
        }
        if((*i).front()!='B' && (*i).back()=='A'){
            flag=false;
        }
    }
    for(auto i=s.begin();i!=s.end();i++){
        if((*i).front()=='B' || (*i).back()!='A'){
    if((*i).front()=='B' && (*i).back()!='A'){
        flag=false;
        break;
    }
    if((*i).front()!='B' && (*i).back()=='A'){
        flag=false;
        break;
    }
        }
    }
    
    
    if(a_counter==0 || b_counter==0){
        cout<<counter<<endl;
    }
    else if(flag){
        cout<<counter+a_counter-1<<endl;
    }
    else{
    if(a_counter>=b_counter){
        cout<<counter+b_counter<<endl;
    }
    else{
        cout<<counter+a_counter<<endl;
    }
    }

    
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(x) cerr << "[(" << __LINE__ << ") " << (#x) << "]: " << x << endl;

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

    ll a;
    long double b;
    cin >> a >> b;

    cout << ll(a*b) <<"\n";
}


Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  cin >> n;
  string s[n],ans="",tmp;
  int a[n]={};
  for(int i=0;i<n;i++){
    cin >> s[i];
    sort(s[i].begin(),s[i].end());
    if(i==0){
      tmp=s[i];
    }
    if(tmp.size()>s[i].size()){
      tmp=s[i];
    }
  }
  for(int i=0;i<tmp.size();i++){
    int cnt=0;
    for(int j=0;j<n;j++){
      int x=0;
      for(int k=a[j];k<s[j].size();k++){
        if(tmp[i]==s[j][k]&&x==0){
          cnt++;
          x++;
          a[j]=k+1;
        }
      }
    }
    if(cnt==n){
      ans+=tmp[i];
    }
  }
  cout << ans << endl;  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int mountains[10], i = 0, j, temp;
    
    while (i < 10) {
        scanf("%d", &mountains[i]);
        i++;
    }
    
    for (i =  0; i < 9; i++) {
        for (j = 0 ; j < 9 - i; j++) {
            if (mountains[j] < mountains[j + 1]) {
                temp = mountains[j];
                mountains[j] = mountains[j + 1];
                mountains[j + 1] = temp;
            }
        }
    }
    
    for (i = 0; i < 3; i++) {
        printf("%d\n", mountains[i]);
    }
    
    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  ll n,x;
  cin>>n>>x;
  ll a[n+1]={};
  ll mi[n+1]={};
  ll sum=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    mi[i]=a[i];
    sum+=a[i];
  }

  ll ans=sum;
  for(int k=0;k<=n;k++){
    ll tmp=k*x;
    for(int i=0;i<n;i++){
      //cout<<(i+n-1)%n<<endl;
      mi[i]=min(mi[i],a[(i-k+n)%n]);
      tmp+=mi[i];
    }
    ans=min(ans,tmp);
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
def MineSweeper():
    H, W = map(int, input().split())
    strlist = []
    newlist = []
    for _ in range(0, H):
        strlist.append(list(input()))
    for i in range(0, H):
        templist = []
        for j in range(0, W):
            templist.append(0)
            if strlist[i][j] == '#':
                templist[j] = '#'
            else:
                for k in range(-1, 2):
                    if i + k == -1 or i + k == H:continue

                    for l in range(-1, 2):
                        if l + j == -1 or l + j == W:continue
                        if strlist[i + k][j + l] == '#':
                            templist[j] += 1
        newlist.append(templist)

    for lst in newlist:
        print(''.join(map(str, lst)))

MineSweeper()


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

struct Dice{
	int num[6];
};

void move(struct Dice *dice, string str){
	int store[6];

	for(int i=0;i<str.length();i++){
		for(int j=0;j<6;j++){
			store[j] = (*dice).num[j];
		}
		switch(str[i]){
		case 'N':
			(*dice).num[0] = store[1];
			(*dice).num[1] = store[5];
			(*dice).num[5] = store[4];
			(*dice).num[4] = store[0];
			break;
		case 'E':
			(*dice).num[0] = store[3];
			(*dice).num[3] = store[5];
			(*dice).num[5] = store[2];
			(*dice).num[2] = store[0];
			break;
		case 'S':
			(*dice).num[0] = store[4];
			(*dice).num[4] = store[5];
			(*dice).num[5] = store[1];
			(*dice).num[1] = store[0];
			break;
		case 'W':
			(*dice).num[0] = store[2];
			(*dice).num[2] = store[5];
			(*dice).num[5] = store[3];
			(*dice).num[3] = store[0];
			break;
		}
	}
}

int main(){
	struct Dice dice;
	string str;

	for(int i=0;i<6;i++){
		cin>>dice.num[i];
	}
	cin>>str;

	move(&dice, str);
	cout<<dice.num[0]<<endl;
	return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
                using namespace std;
                typedef long long ll;
                #define INPUT()              freopen("input.txt", "r", stdin)
                #define OUTPUT()             freopen("output.txt", "w", stdout)
                #define F                    first
                #define S                    second
            //Templatefunctions
                template<typename T>T gcd(T x, T y) { if (y == 0)return x; else return gcd(y, x%y);}
                template <class T> T euclideanDistance(T x1 , T x2 , T y1 , T y2){return sqrt(( x1 - x2 ) * ( x1 - x2 ) + ( y1 - y2 ) * ( y1 - y2 ));}
                template <class T> T digitSum(T n){T sum = 0;while(n > 0)sum += n % 10,n /= 10;return sum;}
            //datatypes
                typedef long long int ll;
                typedef unsigned long long int ull;
                typedef long double ld;
            //constants
                const double INF = 1e+9;
                const double INFLL = 1e+18;
                const double EPS = 1e-9;
                const double PI = acos(-1);
                const int knightDir[8][2] = {{-2,-1},{-2,1},{-1,2},{1,2},{2,-1},{2,1},{-1,-2},{1,-2}};
                       //const int dx[]={0,0,0,1,1,1,-1,-1,-1};
                       //const int dy[]={-1,0,1,-1,0,1,-1,0,1};
                const int dx[] = {0 , 1 , 0 , -1};
                const int dy[] = {1 , 0 , -1 , 0};
            //helpers
                //#define MOD         1000000007LL
                #define MAX         1000005
                const ll MOD = 1000000000 + 7;
                int arr[MAX];
            //Global Variables



                int main()
                {
                   int n;
                   scanf("%d",&n);
                   int sum = 0,arr[n];
                   for(int i = 0 ; i < n ; i++)
                   {
                        scanf("%d",&arr[i]);
                        sum += arr[i];

                   }
                    int fl = floor((double)sum / (double)n);
                    int cl = ceil((double)sum / (double)n);

                    int suma = 0 , sumb = 0;
                    //printf("%d %d\n",fl,cl);
                    for(int i = 0 ; i < n ; i++)
                    {
                        suma += (arr[i]-fl)*(arr[i]-fl);
                        sumb += (arr[i]-cl)*(arr[i]-cl);
                    }

                    printf("%d\n",min(suma,sumb));
                }


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

#define rep(i,x) for(int i=0;i<x;i++)
using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    vector<double > plist(n + 1);
    plist[0] = 0;
    rep(i, n){
        double p; cin >> p;
        plist[i + 1] = plist[i] + ((p + 1) / 2);
    }
    double ans = 0;
    rep(i, n - k + 1){
        double now = plist[i + k] - plist[i];
        ans = max(ans, now);
    }
    cout << fixed << setprecision(10) << ans << endl;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;
typedef vector<vector<int>> vvi;
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 = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/
vvi G;

void dfs(int v, int pre, int d, vector<int>& bi){
    bi[v] = d % 2;
    for(auto nv: G[v]){
        if(pre == nv)continue;
        dfs(nv, v, d + 1, bi);
    }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    cin>>N;
    G.resize(N);
    rep(i,N-1){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<int> biparty(N,-1);
    dfs(0,-1,0, biparty);
    print(biparty);
    //二部グラフ
    vector<int> even, odd;
    rep(i,N){
        if(biparty[i] == 0){
            even.push_back(i);
        }
        else{
            odd.push_back(i);
        }
    }
    vector<int> nums[3];
    rep1(i,N+1){
        nums[i % 3].push_back(i);
    }
    //色塗りをする
    vector<int> ans(N, -1);

    //evenのほうが小さい保証
    if(even.size() > odd.size()){
        swap(even, odd);
    }
    //両方入る場合
    if(even.size() >= max(nums[1].size(),  nums[2].size())){
        rep(i,nums[1].size()){
            ans[even[i]] = nums[1][i];
        }
        rep(i, nums[2].size()){
            ans[odd[i]] = nums[2][i];
        }
        int idx = 0;
        for(int i = 0; i < N; i++){
            if(ans[i] == -1){
                ans[i] = nums[0][idx];
                idx++;
            }
        }
    }
    else{
        //このとき、even.size() <= num[0].size()
        //evenを0埋めする
        rep(i, even.size()){
            ans[even[i]] = nums[0][i];
        }
        //残りの0をoddへ
        int idx = 0;
        for(int i = even.size(); i < nums[0].size();i++){
            ans[odd[idx]] = nums[0][i];
            idx++;
        }
        rep(i, nums[1].size()){
            ans[odd[idx]] = nums[1][i];
            idx++;
        }
        rep(i,nums[2].size()){
            ans[odd[idx]] = nums[2][i];
            idx++;
        }
    }
    rep(i,N){
        cout<<ans[i];
        if(i == N-1)cout<<endl;
        else cout<<" ";
    }
}

Measured memory_bytes: 21876
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define l first
#define r second

using namespace std;

const int maxn = 2e5 + 1;

int a[maxn], b[maxn];

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n; cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i] >> b[i];
    int cad = 0;
    for (int i = n - 1; i >= 0; i--) {
        a[i] += cad;
        cad += (b[i] - a[i] % b[i]) % b[i];
    }
    cout << cad;
    return 0;
}


Measured memory_bytes: 1792
#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;
  if (k < u->key)return treeSearch(u->left, k);
  else return treeSearch(u->right, k);
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL)return treeMinimum(x->right); // case 1
  y = x->parent;
  while(y != NIL && x == y->right){
    x=y;
    y = y->parent;
  }
  return y; // case 2
}

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

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


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: 20528
#include<bits/stdc++.h>
using namespace std;
#define int ll
#define ll long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
// #define MOD 1000000007
#define MOD 998244353 
#define MEM_SIZE 101010
#define DEBUG_OUT true

#define ALL(x) (x).begin(), (x).end()


template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void solve(void)
{
  string str;cin>>str;
  int sum = 0;
  for (int i = 0; i < str.size(); i++)
  {
    sum += str[i] - '0';
  }
  if(sum%9 == 0)
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }
  
  
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


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

#define ll long long int

int W;
ll dp[100][100000];
ll fun(ll w[][2], ll n, ll weight, ll i)
{
	if(weight < 0)
		return -1e17;
	if(i > n-1)
		return 0;
	if(dp[i][weight] >= 0 )
		return dp[i][weight];
	else
	{
		dp[i][weight] = max(fun(w, n, weight, i+1), w[i][1] + fun(w, n, weight-w[i][0], i+1));
		return dp[i][weight];
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin >> n >> W;

	ll w[n][2];
	for (ll i = 0; i < n; ++i)
	{
		cin >> w[i][0] >> w[i][1];
		for (ll j = 1; j <= W; ++j)
		{
			dp[i][j] = -1;
		}
		// dp[i][0] = 0;
	}

	ll k = 0;
	k = fun(w, n, W, 0);

	cout << k;
	return 0;
}


Measured memory_bytes: 78336
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i > 0; i--)
#define repc(i, m, n) for (int i = m; i < n; i++)
#define reprc(i, m, n) for (int i = m; i > n; i--)
#define all(v) v.begin(), v.end()
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

int main()
{
    int N,M,c = 0;
    cin >> N >> M;
    vector<int> H(N);
    vector<vector<int>> R(N);

    rep(i, N){
        cin >> H[i];
    }

    rep(i, M){
        int a,b;
        cin >> a >> b;
        --a;
        --b;
        R[a].push_back(b);
        R[b].push_back(a);
    }

    rep(i, N){
        bool flag = true;

        rep(j, R[i].size()){
            if(H[R[i][j]] >= H[i]){
                flag = false;
                break;
            }
        }

        if(flag){
            c++;
        }
    }
    
    cout << c << endl;
}

Measured memory_bytes: 8752
X, K, D=map(int, input().split())


if D*K<=abs(X):
    print(abs(X)-D*K)
    exit()

if (abs(X)//D)%2==0:
    if K%2==0:
        print(abs(X)%D)
    else:
        print(D-abs(X)%D)
else:
    if K%2==1:
        print(abs(X)%D)
    else:
        print(D-abs(X)%D)


Measured memory_bytes: 61764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a=0,b=0;

int main()
{
	ll c,i=2;
	cin>>n;
	a=n;
	c=1;
	while(c<=a){
		c=pow(i,2);
		i++;
	}
	ll m;
	m=pow(i-2,2);
	cout<<m<<endl;
	return 0;
}

Measured memory_bytes: 256
from sys import exit
from collections import Counter
import numpy as np
from scipy.sparse.csgraph import connected_components
from scipy.sparse import csr_matrix

N, M, K = map(int, input().split())
exc = [set() for _ in range(N)]
edge = []

if M == 0:
    print(*[0 for _ in range(N)])
    exit()

for _ in range(M):
    a, b = map(int, input().split())
    exc[a - 1].add(b - 1)
    exc[b - 1].add(a - 1)
    edge.append((a - 1, b - 1))

edge = np.array(edge).T
matr = csr_matrix(([1 for _ in range(M)], edge), (N, N))
_, labels = connected_components(matr)
ct = Counter(labels)

for _ in range(K):
    c, d = map(int, input().split())
    if labels[c - 1] == labels[d - 1]:
        exc[c - 1].add(d - 1)
        exc[d - 1].add(c - 1)

ans = [ct[labels[i]] - len(exc[i]) - 1 for i in range(N)]
print(*ans)


Measured memory_bytes: 94360
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<stdio.h>
#include<vector>
#include<map>
using namespace std;

int y, m, d;
int ans;
char a, b;

int main() {
	cin >> y >> a >> m >> b >> d;
	if (m <= 4) {
		cout << "Heisei" << endl;
	}
	else {
		cout << "TBD" << endl;
	}


	return 0;
}

Measured memory_bytes: 256
package main

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

const mod = 1000000007
var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

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

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	min, c := 1000000, 0
	for i := 0; i < n; i++ {
		p := nextInt()
		if p < min {
			min = p
			c++
		}
	}

	fmt.Println(c)
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

typedef pair<string,string> Ps;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	string s,a,b;
	cin>>s;
	a=s.substr(0,n),b=s.substr(n,n);
	reverse(begin(b),end(b));
	map<Ps,ll> cnt1,cnt2;
	rep(i,1<<n){
		string k,l;
		rep(j,n){
			if(i & 1<<j){
				k.push_back(a[j]);
			}else{
				l.push_back(a[j]);
			}
		}
		cnt1[Ps(k,l)]++;
	}
	rep(i,1<<n){
		string k,l;
		rep(j,n){
			if(i & 1<<j){
				k.push_back(b[j]);
			}else{
				l.push_back(b[j]);
			}
		}
		cnt2[Ps(k,l)]++;
	}
	ll ans=0;
	for(auto itr:cnt1){
		ll num=cnt2[itr.fi];
		ans+=num*itr.se;
	}
	cout<<ans<<endl;
}

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

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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

int main(){
    string s; cin >> s;
    REP(i, 0, 3){
        if(s[i] == '7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int N, M, Q;
set<vector<int>> SE;

void f(vector<int> tmp, int n) {
  if (n == N) {
    sort(tmp.begin(), tmp.end());
    SE.insert(tmp);
    return;
  }
  int mx = (tmp.size()) ? *max_element(tmp.begin(), tmp.end()) : 1;
  for (int i = mx; i <= M; i++) {
    vector<int> tmp2;
    tmp2 = tmp;
    tmp2.push_back(i);
    f(tmp2, n + 1);
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin >> N >> M >> Q;
  vector<vector<int>> V(Q, vector<int>(4));
  for (int i = 0; i < Q; i++) {
    for (int j = 0; j < 4; j++) {
      cin >> V.at(i).at(j);
    }
  }
  vector<int> tmp;
  f(tmp, 0);
  int mx = 0;
  for (auto se : SE) {
    int sum = 0;
    for (int i = 0; i < Q; i++) {
      if (se.at(V.at(i).at(1) - 1) - se.at(V.at(i).at(0) - 1) == V.at(i).at(2)) sum += V.at(i).at(3);
    }
    mx = max(mx, sum);
  } 
  cout << mx << "\n";
}

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

ll mod_pow(ll x, ll n)
{
  if (n == 0)
    return 1;
  ll res = mod_pow(x * x % MOD, n / 2);
  if (n & 1)
    res = res * x % MOD;
  return res;
}

int main()
{
  ll m, n;
  cin >> m >> n;
  cout << mod_pow(m, n) << endl;
  return 0;
}


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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main ()
{
    fastio
    lli num1 , num2 , div , t ;
    cin >> num1 >> num2 ;
    div = num1 / 500 ;
    t = div * 500 ;
    (t + num2 >= num1 ? Yes : No) ;

    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

// 最大公約数を計算
ll gcd(ll a, ll b) {
  if (b == 0) {
    return a;
  } else {
    return gcd(b, a % b);
  }
}

// 素因数を列挙
vector<pair<ll, ll>> enumeratePrimeFactors(ll n) {
  vector<pair<ll, ll>> res;
  for (ll a = 2; a * a <= n; a++) {
    if (n % a != 0) {
      continue;
    }
    ll ex = 0; // 指数
    // 割れるだけ割る
    while (n % a == 0) {
      ++ex;
      n /= a;
    }
    res.emplace_back(a, ex);
  }
  // nが一度も割られなかった場合
  if (n != 1) {
    res.emplace_back(n, 1);
  }
  return res;
}

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a.at(i);
  bool pairwiseCoprime = true;
  vector<vector<pair<ll, ll>>> d(n);
  rep(i, n) {
    d.at(i) = enumeratePrimeFactors(a.at(i));
  }
  set<ll> s;
  rep(i, n) {
    rep(j, d.at(i).size()) {
      ll dd = d.at(i).at(j).first;
      if (s.count(dd)) {
        pairwiseCoprime = false;
        break;
      } else {
        s.insert(dd);
      }
    }
    if (!pairwiseCoprime) {
      break;
    }
  }
  ll gcdSum = 0;
  rep(i, n) {
    gcdSum = gcd(gcdSum, a.at(i));
  }
  bool setwiseCoprime = gcdSum == 1;
  if (pairwiseCoprime) {
    cout << "pairwise coprime" << endl;
  } else if (setwiseCoprime) {
    cout << "setwise coprime" << endl;
  } else {
    cout << "not coprime" << endl;
  }
  return 0;
}



Measured memory_bytes: 168352
N = int(input())


max_ = -1
min_flow = float('inf')
for i in range(5):
    x = int(input())
    min_flow = min(min_flow, x)

    q, r = divmod(N, min_flow)

    if r != 0:
        q += 1

    max_ = max(max_, i + q)


print(max_)


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

int main(){
  double N;
  cin >> N;
  int count=0;
  for(int A=1; A<N; A++){
    for(int B=1; B<N/A; B++){
      if(A*B<N){
        count++;
      }
    }
  }
  cout << count << endl;
  return 0;
}  
      

Measured memory_bytes: 3720
#include <iostream>
int main(int argc, char *argv[]) {
	int n;
	std::cin >> n;
	if (n == 1) {
		std::cout << "Hello World" << std::endl;
	} else if (n == 2) {
		int a, b;
		std::cin >> a >> b;
		const int sum = a + b;
		std::cout << sum << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define up(j,k,i) for(i=j;i<k;i++)
#define down(j,k,i) for(i=j;i>k;i--)
#define pp(n) printf("%lld\n",n)
#define pps(n) printf("%lld ",n)
#define all(x) x.begin(),x.end()
#define ps(s) printf("%s",s)
#define is(n) scanf("%lld",&n)
#define ips(n) scanf("%lld",n)
#define ss(s) scanf("%s",s)
#define cool 0
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define f(i) cout<<i<<endl;
#define pll pair<lld,lld> 
#define pi acos(-1)
#ifdef G
#define dg(x) cout<<#x<<' '<<x<<endl;
#define dg2(x,y) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<endl;
#define dg3(x,y,z) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<' '<<#z<<' '<<z<<endl;
#define dg4(x,y,z,zz) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<' '<<#z<<' '<<z<<' '<<#zz<<' '<<zz<<endl;
#else
#define dg(x) ;
#define dg2(x,y) ;
#define dg3(x,y,z) ;
#define dg4(x,y,z,zz) ;
#endif
#define ds(n,m) scanf("%lld %lld",&n,&m)
#define ts(n,m,k) scanf("%lld %lld %lld",&n,&m,&k)
#define yes printf("YES\n")
#define no printf("NO\n")
typedef long double ld;
typedef long long int lld;
using namespace std;
const lld M =2e6+10;
const lld mod=1e9+7;
const lld infi =LLONG_MAX;
lld ans,k,n,x,y,m,mymax=LLONG_MIN,mymin=LLONG_MAX,b,c,z,sum;
vector<lld> v[M];
lld sprime [M];
vector<lld> primes;
void sieve()
{
	sprime[2]=0;
	sprime[1]=1;
	lld i,temp;
	up(2,M,i)
	{
		if(sprime[i]==0)
		{
			lld j;
			sprime[i]=i;
			primes.pb(i);
			for(j=i*i;j<M;j+=i)
				sprime[j]=i;
		}
	}
}
lld binpow(lld base,lld pow,lld modulus)
{
    lld ans=1;
    base=base%modulus;
    while(pow>0)
    {   
        while(pow%2==0)
        {
            base=(base*base)%modulus;
            pow/=2;
        }
        ans=(ans*base)%modulus;
        pow--;
        
    }
    return ans;
}

int main()
{
  lld i,j;
  lld p;
  sieve();
  ds(n,p);
  lld ans=1;
  for(auto prime:primes){
  	x=0;
  	while((p%prime)==0){
  		p/=prime;
  		x++;
  	}
  	ans*=binpow(prime,x/n,mod);
  }
  if(p>1){
  	if(n<=1){
  		ans*=p;
  	}
  }
  cout<<ans<<endl;
  return 0;
}

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

public class hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var d = new Dictionary<string, int>();
            for (int i = 0; i < n; i++)
            {
                string[] line = Console.ReadLine().Trim().Split(' ');
                d[line[0]] = getTime(int.Parse(line[1]), line[2]);
            }
            var p = int.Parse(Console.ReadLine().Trim());
            var df = new Dictionary<string, int>();
            var ff = new int[p];
            for (int i = 0; i < p; i++)
            {
                var w = Console.ReadLine().Trim();
                df[w] = d[w];
                ff[i] = d[w];
            }
            if (!checkF(ff, p)) { Console.WriteLine(-1); goto exit; }
            var a = new List<int>();
            foreach (var x in d)
            {
                if (df.ContainsKey(x.Key)) continue;
                var ok = true;
                foreach (var y in df)
                    if (!checkW(y.Value, x.Value)) { ok = false; break; }
                if (ok) a.Add(x.Value);
            }
            var ans = getAns(a);
            Console.WriteLine(ans + df.Count());
            exit:;
        }
    }
    static int getAns(List<int> a)
    {
        a.Sort();
        var count = 0;
        var t = 0;
        foreach (var x in a)
        {
            if (x >= t) { count++; t = x + 30; }
        }
        return count;
    }
    static bool checkW(int f, int t) => (t <= f - 30) | (t >= f + 30);
    static bool checkF(int[] ff, int p)
    {
        Array.Sort(ff);
        var t = 0;
        foreach (var x in ff)
        {
            if (x < t) return false;
            t = x + 30;
        }
        return true;
    }
    static int getTime(int week, string s)
    {
        if (s.Length == 3) return 1440 * week + 60 * int.Parse(s.Substring(0, 1)) + int.Parse(s.Substring(1));
        else return 1440 * week + 60 * int.Parse(s.Substring(0, 2)) + int.Parse(s.Substring(2));
    }
}



Measured memory_bytes: 28912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define OK { cout << "OK" << endl; return 0; }
#define NG { cout << "NG" << endl; return 0; }
#define sz(v) ((int)(v).size())
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v)cout<<i<<' '; cout << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
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; }
template<class T>void out(T a){cout << a << endl;}
template<class T>void die(T a){cout << a << endl; exit(0);}
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

#define SIZE 200005
#define MOD 1000000007
 
typedef pair <int,int> P;
 
ll inv[SIZE], fac[SIZE], finv[SIZE];
void make(){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i=2; i<SIZE; i++)
	{
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
		fac[i] = fac[i-1] * (ll) i % MOD;
		finv[i] = finv[i-1] * inv[i] % MOD;
	}
    return ;
}
ll comb(int a,int b){
	if(a < b) return 0;
	return fac[a] * (finv[b] * finv[a-b] % MOD) % MOD;
}



ll beki(int a, int n){
    if(n == 0) return 1;
    ll ans = beki(a, n / 2);
    ans = ans * ans;
    if(n % 2 == 1) ans = ans * a;
    return ans;
}



int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
    
     int N; cin>>N;
	vi ans(10005, 0);

	for(int x = 1; x <=200; x++){
		for(int y = 1; y <=200; y++){
		for(int z = 1; z <=200; z++){
			if(x * x + y * y + z * z + x * y + y * z + z * x > 10000) continue;
			ans[x * x + y * y + z * z + x * y + y * z + z * x]++;
	}
	}
	}
	for(int i = 1; i <= N; i++){
		cout << ans[i] << endl;
	}

	
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n,x,v[200001],sol[200001];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>v[i];
        x=(x^v[i]);
    }
    for(int i=1;i<=n;i++)
        cout<<(x^v[i])<<" ";
    return 0;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 N;
	cin >> N;
	vector<int64> X(N);
	REP(i, N) cin >> X[i];
	int64 res = 0, cost = INF_LL;
	REP(x, 1000) {
	  int64 sum = 0;
	  REP(i, N) {
	    sum += (X[i]-x) * (X[i]-x);
	  }
	  if (sum < cost) {
	    cost = sum;
	    res = x;
	  }
	}
	cout << cost << endl;
}


Measured memory_bytes: 256
# coding: utf-8
n=int(input())
data=[]
for i in range(n):
    data.append(list(map(int,input().split())))
data=sorted(data,key=lambda x:-x[0]-x[1])
a=0
b=0
for i in range(n):
    if i%2==0:
        a+=data[i][0]
    else:
        b+=data[i][1]
print(a-b)

Measured memory_bytes: 33064
#include <cstdio>
using namespace std;
int main(){
    
    double r, S, L, pi=3.141592653589;
    scanf ("%lf", &r);
    S = r * r * pi;
    L = 2 * r * pi;
    printf("%lf %lf\n", S, L);
    
    return 0;
    
}


Measured memory_bytes: 2732
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;

      string str;

    cin>>n;

    ll ara[n+2];

    for(i=1; i<=n; i++)
    {

        cin>>ara[i];
    }

    ara[1]--;

    for(i=2; i<=n; i++)
    {
       if(ara[i]==ara[i-1])continue;

       else if(ara[i]>ara[i-1])ara[i]--;

       else
       {
           cout<<"No"<<endl;

           return 0;
       }
    }

  cout<<"Yes"<<endl;













}



Measured memory_bytes: 4440
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>

using namespace std;

#define REP(var, count) for(int var=0; var<count; var++)

int DP[110][10010]; //N???????????§????????????????¨?w

int main(void) {
	
	int N, W;
	cin >> N >> W;
	
	REP(i, N) {
		int v, w;
		cin >> v >> w;
		
		REP(c, W+1) {
			if ( c < w ) {
				// ????????????????????????
				DP[i+1][c] = DP[i][c];
			} else {
				DP[i+1][c] = max(DP[i+1][c-w] + v, DP[i][c]);
			}
		}
	}
	
	int ret = 0;
	REP(c, W+1) {
		ret = max(ret, DP[N][c]);
	}
	
	cout << ret << endl;
}

Measured memory_bytes: 6972
import math
a,b,c = map(float, input().split())
s = a * b * math.sin(math.radians(c)) / 2
l = math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(c)))+a+b
h = s * 2 / a

print(s)
print(l)
print(h)



Measured memory_bytes: 5696
c11,c12,c13=map(int,input().split())
c21,c22,c23=map(int,input().split())
c31,c32,c33=map(int,input().split())

b1=c11
b2=c12
b3=c13
a2=c21-b1
a3=c31-b1
if c22==a2+b2 and c23==a2+b3 and c32==a3+b2 and c33==a3+b3:
    print("Yes")
else:   
    print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;

int N, K;
vector<int> P;

int main(void) {
	cin >> N >> K;

	P.resize(N);
	for (int i = 0; i < N; ++i)
		cin >> P[i];
	sort(P.begin(), P.end());
	int ans = accumulate(P.begin(), P.begin() + K, 0);

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


Measured memory_bytes: 3604