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

int main(){
    size_t N;
    cin >> N;
    vector<unsigned long> A(3 * N);
    for(auto& i : A)cin >> i;
    
    vector<long> ans(N + 1);
    {
        vector<unsigned long> B, C;
        {
            unsigned long sum{accumulate(A.cbegin(), A.cbegin() + N, 0UL)};
            priority_queue<unsigned long, vector<unsigned long>, greater<>> pq(A.cbegin(), A.cbegin() + N);
            B.push_back(sum);
            transform(A.cbegin() + N, A.cbegin() + 2 * N, back_inserter(B), [&sum, &pq](auto a){
                sum += a;
                pq.push(a);
                sum -= pq.top();
                pq.pop();
                return sum;
            });
        }
        {
            unsigned long sum{accumulate(A.crbegin(), A.crbegin() + N, 0UL)};
            priority_queue<unsigned long, vector<unsigned long>, less<>> pq(A.crbegin(), A.crbegin() + N);
            C.push_back(sum);
            transform(A.crbegin() + N, A.crbegin() + 2 * N, back_inserter(C), [&sum, &pq](auto a){
                sum += a;
                pq.push(a);
                sum -= pq.top();
                pq.pop();
                return sum;
            });
        }
        transform(B.cbegin(), B.cend(), C.crbegin(), ans.begin(), minus<long>());
    }
    cout << *max_element(ans.cbegin(), ans.cend()) << endl;
    return 0;
}

Measured memory_bytes: 7016
import heapq
from sys import stdin
input = stdin.readline

#入力
# s = input()[0:-1]
# n = int(input())
n,k = map(int, input().split())
# a = list(map(int,input().split()))
# a = [int(input()) for i in range()]


# ab=[]
# for i in range():
#     a,b = map(int, input().split())
#     ab.append([a,b])


     
def main():
  if k ==1 :
      print(0)
  else:
      print(n-k)
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import sys

input = sys.stdin.readline


def main():
    S, T = input().split()
    A, B = map(int, input().split())
    U = input().rstrip()

    if S == U:
        ans = [A - 1, B]
    else:
        ans = [A, B - 1]

    print(*ans)


if __name__ == "__main__":
    main()


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define p_ll pair<ll, ll>
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  double n, m, d; cin >> n >> m >> d;
  double num = d ? (n-d)*2 : n;
  double result = num*(m-1)/(n*n);
  cout << fixed << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;


int main(){
    int n;
    cin >> n;
    vector<int> si(n);
    for (int i = 0; i < n; i++)
        cin >> si[i];
    sort(si.begin(), si.end());
    cout << si[n - 1] - si[0] << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;




public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {
    	Scanner sc=new Scanner(System.in);

    	int N=sc.nextInt();
    	int K=sc.nextInt();

    	int sum=0;

    	for(int i=0;i<N;i++) {
    		int buf=sc.nextInt();

    		sum+=getMinDistance(K, buf);

    	}

    	System.out.println(sum);

    }

    public static int getMinDistance(int K,int buf) {

    	int distanceA=2*buf;
    	int distatnceB=2*(K-buf);

    	return distanceA<=distatnceB?distanceA:distatnceB;


    }


}



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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)+1):((m)-(n)+1)),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

vector<int>
factor(int n, int m) {
  vector<int> r;
  while (n > 0) {
    r.push_back(n % 10);
    n /= 10;
  }
  while (r.size() < m) r.push_back(0);
  return r;
}

int
mul(vector<int>&v) {
  int r = 0;
  for (int n : v) {
    r = r * 10 + n;
  }
  return r;
}

Integer
next(int n, int m) {
  auto f = factor(n, m);
  sort(all(f));
  int a = mul(f);
  reverse(all(f));
  int b = mul(f);
  return b - a;
}

void solve(Integer n, int m) {
  Integer a[21];
  a[0] = n;
  rep (i, 20) {
    n = next(n, m);
    a[i + 1] = n;
    rep (j, i + 1) {
      if (a[j] == n) {
        cout << j << ' ' << n << ' '  << (i - j + 1) << endl;
        return;
      }
    }
  }
}

int main()
{

  for (;;) {
    int n, m; cin >> n >> m;
    if (n || m) solve(Integer(n), m);
    else break;
  }

  return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

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)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

template<class T> inline bool chmax(T& a, T b) { if (a <= b) { a = b; return true; } else return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } else return false; }

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


	int n, m; cin >> n >> m;
	vector<ll> h(n);
	rep(i, n) {
		 cin >> h[i];
	}

	vector<vector<ll>> graph(n, vector<ll>());
	rep(i, m) {
	  int a, b; cin >> a >> b;
		a--; b--;
		graph[b].push_back(a);
		graph[a].push_back(b);
	}

	vector<bool> used(n);
	ll ans = 0;
	rep(v, n) {
	  bool ok = true;
		for (auto w : graph[v]) {
			if (h[v] <= h[w]) { ok = false; break;}
		}

		if (ok) ans++;

	}

	cout << ans << endl;
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	int ans = 1;
	rep(i,n){
		ans = min(ans*2, ans+k);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;
typedef vector<double> vec3;

int main() {

  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  ll d = 0;
  ll ans = 0;
  if(k <= a) {
    cout << k << endl;
    return 0;
  } else {
    ans = a;
    d = a;
  }
  if((k-d) <= b) {
    cout << ans << endl;
    return 0;
  } else {
    d = d + b;
  }
  cout << ans - (k-d) << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
 
 
int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
 
    int n;
    cin>>n;
    ll x[n],y[n];
    ll ans = n;
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i];
    }
    ll ret=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i==j) continue;
            ll s=x[i]-x[j], t=y[i]-y[j];
            if(x==0 && y==0) continue;
            ll cnt=0;
            for(int a=0;a<n;a++){
                for(int b=0;b<n;b++){
                    if(a==b) continue;
                    if(x[a]-x[b]==s && y[a]-y[b]==t) cnt++;
                }
            }
            ret = max(ret,cnt);
        }
    }
    ans -= ret;
    cout<<ans<<endl;

    
}

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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++ i)
#define ALL(r) r.begin(), r.end()
#define DUP(x, y) (((x) + (y) - 1) / (y))
#define YES puts("YES")
#define NO puts("NO")
#define Yes puts("Yes")
#define No puts("No")
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end())

using ll = std::int64_t;
using vint = std::vector<int>;
using vll = std::vector<ll>;
using vstr = std::vector<std::string>;
using pint = std::pair<int, int>;

constexpr std::int32_t INF = 1001001001;

// z-algorithm
// s と s[ i : |s| - 1 ] の最長共通接頭辞(Longest Common Prefix, LCP)を計算する : O(|S|)
vector<int> zalgo(const string& s) {
    vector<int> Z(s.size());
    for (int i = 1, j = 0; i < s.size(); ++i) {
        if (i + Z[i - j] < j + Z[j]) {
            Z[i] = Z[i - j];
        }
        else {
            int k = max(0, j + Z[j] - i);
            while (i + k < s.size() && s[k] == s[i + k]) ++k;
            Z[i] = k;
            j = i;
        }
    }
    Z[0] = (int)s.size();
    return Z;
}

void Main() {
    int n;
    string s;
    cin >> n >> s;

    int ans = 0;
    rep(i, n) {
        string t = s.substr(i);
        auto lcp = zalgo(t);
        rep(j, t.size()) {
            int l = min(lcp[j], j);
            ans = max(ans, l);
        }
    }
    cout << ans << endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}



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

int main(){
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;

	if ( 0 <= x - r && x + r <= W && 0 <= y - r && y + r <= H )
	{
		cout << "Yes" << endl;
	} 
	else 
	{
		cout << "No" << endl;
	}

}

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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayLong();
            var A = input[0];
            var B = input[1];
            var fA = (A - 1) % 2 != 0 ? EO(A - 1) : A - 1 + EO(A - 1);
            var fB = B % 2 != 0 ? EO(B + 1) : B + EO(B);

            Console.WriteLine(fA ^ fB);
            Console.ReadLine();
        }

        static long EO(long num)
        {
            long ret = 0;
            if (num % 2 == 0)
            {
                if (num / 2 % 2 == 0) ret = 0;
                else ret = 1;
            }
            else
            {
                if ((num + 1) / 2 % 2 == 0) ret = 0;
                else ret = 1;
            }
            return ret;
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13396
/*
   TASK: nocows
   LANG: C++14
 */

#include "bits/stdc++.h"

//region Template

typedef long long ll;
typedef long double ld;

using namespace std;
#define finish(x) return cout << x, 0;
#define fastIO cin.tie(0); cin.sync_with_stdio(false);

void setIn(string s) { freopen(s.c_str(), "r", stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }

const string USCAO_TAG = "nocows";
void usaco() { setIn(USCAO_TAG + ".in"); setOut(USCAO_TAG + ".out"); }


template<typename... Args>
void print(Args... args) {
	#ifdef LOCAL
	((std::cout << args << " "), ...);
	cout << endl;
	#endif
}
//endregion

/* Notes:
 * I didn't wanna do this round :/
 */


int main() {
	#ifdef LOCAL
	setIn("in.txt");
	#endif

	string s, t;
	cin >> s >> t;

	set<int> idx[30];

	for(int i = 0; i < s.size(); i++){
		idx[s[i] - 'a'].insert(i);
	}

	int cur = -1;
	int cnt = 1;
	for(int i = 0; i < t.size(); i++){
		if(idx[t[i] - 'a'].size() == 0){
			finish(-1);
		}

		auto x = idx[t[i] - 'a'].upper_bound(cur);

		if(x == idx[t[i] - 'a'].end() || *x <= cur){
			cur = -1;
			cnt++;
			i--;
		}
		else{
			cur = *x;
		}
	}
	cout << (cnt - 1) * s.size() + cur + 1;
}


Measured memory_bytes: 5120
import numpy as np
from itertools import combinations

N, D = map(int, input().split())
X = np.zeros([N, D], dtype=int)
ans = []

def judge_int(array):
    return np.sqrt((array**2).sum()).is_integer()

for i in range(N):
    X[i] = np.array(list(map(int, input().split())))

for i, j in list(combinations(range(0, N), 2)):
    ans.append(judge_int(X[i] - X[j]))

print(sum(ans))

Measured memory_bytes: 12500
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath>      // abs など
#include <numeric>    // accumulate など
#include <stdexcept>
#include <cassert> // assert
using namespace std;

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
// typedef int128_t ll;
// typedef cpp_int ll;

// GCC, 配列のアクセスなど
#define _GLIBCXX_DEBUG
// Clang, 配列のアクセスなど
#define _LIBCPP_DEBUG 0

// #define NDEBUG 1
// debug用出力 https://trap.jp/post/998/
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << H << " ";
    debug_out(T...);
}
#ifdef NDEBUG
#define debug(...)
#else
#define debug(...) debug_out(__VA_ARGS__)
#endif

//////////////// //////////////// //////////////// //////////////// ////////////////
//////////////// //////////////// //////////////// //////////////// ////////////////

// constexpr inline ll MOD = 1'000'000'007;

int main()
{
    // 入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int a,b,c,k; cin>>a>>b>>c>>k;
    int res = 0;
    if (a >= k)
    {
        cout << k << endl;
        return 0;
    }
    res += a;
    k -= a;
    if (b >= k)
    {
        cout << res << endl;
        return 0;
    }
    k -= b;
    res -= k;
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3656
# include <iostream>
# include <cmath>
using namespace std;

int main() {
  int n, d; cin >> n >> d;
  double coordinate[n][d] = {};
  
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < d; ++j) {
      cin >> coordinate[i][j];
    }
  }
  
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      double distance = 0;
      for (int k = 0; k < d; ++k) {
        double diff = coordinate[i][k] - coordinate[j][k];
        distance += pow(diff, 2);
      }
      // 距離が整数
      if (fmod(sqrt(distance), 1) == 0) ++ans;
    }
    
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 512
#include"bits/stdc++.h"
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;

bool dfs(vector<vector<ll>>& node,vector<ll> &color, ll v, ll cor) {
	color[v] = cor;
	for (auto next_v : node[v]) {
		if ((color[next_v] != -1)) {
			if (color[next_v] == cor)return false;
			continue;
		}

		if (!dfs(node, color, next_v, !cor))return false;
	}
	return true;
}

int main() {
	ll n, m, a, b;;
	map<ll, ll>mp;
	a = b = n = m = 0;
	cin >> n >> m;
	vector<vector<ll>>node(n);
	vector<ll>color(n, -1);
	rep(i, m) {
		cin >> a >> b;
		a--, b--;
		node[a].push_back(b);
		node[b].push_back(a);
	}

	if (!dfs(node,color, 0LL, 0LL)) cout << ((n * (n - 1)) / 2) - m << endl;
	else {
		for (int c : color) {
			mp[c]++;
		}
		cout << mp[0] * mp[1] - m << endl;
	}
	return 0;
}


Measured memory_bytes: 7424
l,n = map(int,input().split())

ll = l % 2019
ans = 2018
if l-n >= 672:
    ans = 0
elif n-l > 2:
    for i in range(ll,ll + n-l +1):
        if i % 673 == 0:
            ans = 0
            break
        else:
            for j in range(ll,ll + n-l +1):
                if i != j:
                    ansss = i*j%2019
                    if ansss == 0:
                        ans = 0
                        break
                    elif ansss < ans:
                        ans = ansss
else:
    ans = l*n%2019

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=(x<<3)+(x<<1)+k-'0';
	x*=f;
}
template<class T>il print(T x){
	if(x/10) print(x/10);
	putchar(x%10+'0');
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int m,int mod){
	int res=1,bas=x%mod;
	while(m){
		if(m&1) res=(1ll*res*bas)%mod;
		bas=(1ll*bas*bas)%mod,m>>=1;
	}
	return res%mod;
}
const int MAXN = 25;
int n,a[MAXN],b[MAXN],c[MAXN],dp[MAXN],ans;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n);
	for(ri i=1;i<=n;++i) read(a[i]);
	for(ri i=1;i<=n;++i) read(b[i]),ans+=b[i];
	for(ri i=1;i<n;++i) read(c[i]);
	for(ri i=2;i<=n;++i) if(a[i-1]+1==a[i]) ans+=c[a[i-1]];
	print(ans);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <stdio.h>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,D,Q,K,R,W,H,P,L,G;
ll ans;
string S,T;
ll y[101010];
ll a[101010];
ll k[101010];
ll b[101010];
ll d[101010];
ll t[101010];
ll p[101010];
ll n[101010];
ll l[101010];
ll r[101010];
ll v[101010];
ll s[101010];
ll x[101010];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
struct Edge{
	ll to,cost;
	 Edge(ll to, ll cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;

struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
	vector<ll> size;
    UnionFind(ll N) : par(N),size(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
		for(ll i = 0; i < N; i++) size[i] = 1;
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
	ll GetSize(ll x){
		return size[root(x)];
	}

    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
		size[ry]+=size[rx];

    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

int main() {
    cin>>X>>A;
    if(X<A){
        cout<<0<<endl;
    }else{
        cout<<10<<endl;
    }
    return 0;
}


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

int main()
{
	int a,b,c;
	cin >> a;
	cin >> b;
	cin >> c;
	int h[5];
	int min=0; 
	h[1] = 10*a+b+c;
	h[2] = 10*b+a+c;
	h[3] = 10*c+a+b;
	for(int i = 1;i<4;i++)
	{
		if(h[i]>min)
		{
			min = h[i];
		}
	}
	cout << min << endl;

}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);

int n;
ll m;

ll a[MAX_N];

ll acc[MAX_N];

bool check(ll x) {
  ll count = 0LL;

  for (int i = 0; i < n; ++i) {
    int idx = lower_bound(a, a + n, x - a[i]) - a;
    count += (ll)(n - idx);
  }

  return count >= m;
}

int main(void) {
  // Here your code !

  scanf("%d %lld", &n, &m);

  for (int i = 0; i < n; ++i) {
    scanf("%lld", &(a[i]));
  }

  sort(a, a + n);

  for (int i = 1; i <= n; ++i) {
    acc[i] = acc[i - 1] + a[i - 1];
  }

  ll ok = 0;
  ll ng = 2LL * (ll)(1e5 + 3);

  while (abs(ok - ng) > 1) {
    ll next = (ok + ng) / 2;

    if (check(next)) {
      ok = next;
    } else {
      ng = next;
    }
  }

  ll ans = 0LL;
  ll count = 0LL;

  for (int i = 0; i < n; ++i) {
    int idx = lower_bound(a, a + n, ok - a[i]) - a;

    ll length = (ll)(n - idx);

    ans += a[i] * length + acc[n] - acc[idx + 1 - 1];
    count += length;
  }

  ans -= abs(m - count) * ok;

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

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;

int main()
{
    int n;
    string s;
    cin >> n >> s;
    for(int i = 0; i< s.size(); i++){
        int x = s[i] - 'A';
        x = (x + n) % 26;
        s[i] = x + 'A';
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace __gnu_pbds;
using namespace std;
#define testing 1
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << endl
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<endl
#define dbv(v) cerr << #v << ":"; for (auto it : v) cerr << it << ' '; cerr << endl
#define dbvp(v) cerr << #v << ":"; for (auto it : v) cerr << "{"  << it.f << ',' << it.s << "} "; cerr << endl
#define dba(a,ss,ee) cerr << #a << ":"; FOR(i,ss,ee) cerr << a[i] << ' '; cerr << endl
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define inf (int)1e9+500
#define oo (ll)1e18+500
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "LINE: " << __LINE__ << "\n";
typedef pair <int, int> pi;
typedef pair <ll,ll> pl;
typedef pair <pi, int> pii;
typedef tuple<int,int,int> ti3;
string cts(char x) {string t(1,x); return t;}
ll rand(ll a, ll b) { return a + rand() % (b-a+1); }
const int MOD = 1e9 + 7;
template <typename T> void maxself(T& a, T b) {
	a = max(a, b);
}
template <typename T> void minself(T& a, T b) {
	a = min(a, b);
}
#define MAXN 500005
#if !testing
#define cerr if(0)cout
#endif
struct fenv {
	int fw[MAXN];
	void update(int x, int nval) {
		for(;x<=MAXN;x+=x&(-x))fw[x]+=nval;
	}
	int sum(int x) {
		int res = 0;
		for(;x;x-=x&(-x))res+=fw[x];
		return res;
	}
	int query(int st, int en) {
		return this->sum(en)-this->sum(st-1);
	}
} fw[26];

int32_t main() {
	IAMSPEED
	int n, Q;
	string str;
	cin>>n>>str>>Q;
	str = "A" + str;
	FOR(i,1,n) {
		fw[str[i]-'a'].update(i,1);
	}
	while(Q--) {
		int op;cin>>op;
		if(op==1) {
			int idx; char ch; cin >> idx >> ch;
			fw[str[idx]-'a'].update(idx,-1);
			str[idx]=ch;
			fw[ch-'a'].update(idx,1);
			
		} else {
			int l,r; cin >> l >> r;
			int res = 0;
			FOR(i,0,25){
				res += bool(fw[i].query(l,r));
			}
			cout<<res<<'\n';
		}
	}
}


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

using namespace std;

string d2b(int x, int M)
{
    string s;
    while (x > 0) {
        s += (x % 2 == 0 ? "0" : "1");
        x /= 2;
    }
    while ((int)s.size() < M) {
        s += "0";
    }
    reverse(s.begin(), s.end());
    return s;
}

int main()
{
    int N, M;
    while (cin >> N >> M, N) {
        vector<int> L(N);
        for (int i = 0; i < N; i++) {
            cin >> L[i];
        }

        vector<string> bits;
        for (int i = 0; i < (1<<M); i++) {
            if (L[0] == __builtin_popcount(i)) {
                bits.push_back(d2b(i, M));
            }
        }
        
        for (int i = 1; i < N; i++) {
            vector<string> nbits;
            for (int j = 0; j < (int)bits.size(); j++) {
                int cnt = 0;
                for (int k = i; k < i + M; k++) {
                    if (bits[j][k] == '1') {
                        cnt++;
                    }
                }
                int bit_cnt = L[i];
                if (cnt == bit_cnt) {
                    nbits.push_back(bits[j] + "0");
                } else if (cnt + 1 == bit_cnt) {
                    nbits.push_back(bits[j] + "1");
                }
            }
            bits = nbits;
        }

        if (bits.size() == 0) {
            cout << "Goofy" << endl;
        } else {
            cout << bits[0] << endl;
        }
    }
    return 0;
}

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

int main()
{
    int x, y;
    cin >> x >> y;
    if(y % 2 == 1 || x * 2 > y || x * 4 < y){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  int N;
  cin>>N;
  string S,T;
  cin>>S>>T;
  int ans=0;
  rep(i,N+1){
    int F=1;
    rep(j,i){
      if(S[N-i+j]!=T[j]) F=0;
    }
    if(F) ans=max(ans,i);
  }
  cout<<N*2-ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int c1, c5, c10, c50, c100, c500;
	cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500;

	int sum = c1
			+ c5 * 5
			+ c10 * 10
			+ c50 * 50
			+ c100 * 100
			+ c500 * 500;

		cout << (sum >= 1000) << endl;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    ll n,m;cin>>n>>m;
    vl x(m);rep(i,m)cin>>x[i];
    sort(all(x));
    vl d(m-1);
    ll sum=0;
    rep(i,m-1){
        d[i]=x[i+1]-x[i];
        sum+=d[i];
    }
    sort(all(d));
    reverse(all(d));
    rep(i,min(n,m)-1){
        sum-=d[i];
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 1792
#include<cstdio>
int n;
int a[60];
int main(){
    int ans=0;
    scanf("%d",&n);
    for(int i=0;i<n;++i) scanf("%d",&a[i]);
    for(int i=0;i<n-1;++i){
        for(int j=i+1;j<n;++j){
            ans+=a[i]*a[j];
        }
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 256
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def putsd(str)
  puts str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

nn = inputs[0][0]

# body
if $debugFlag
end

if nn <= 999
  puts "ABC"
else
  puts "ABD"
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
// #include<boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define mod 1000000007
#define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n) for(int i=0;i<n;i++)
#define fp(i,k,n) for(int i=k;i<=n;i++)
#define fr(i,k,n) for(int i=k;i>=n;i--)
#define pb push_back
#define F first
#define S second
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

double maxvolume(double s) 
{ 
    // finding length 
    double length = s / 3; 
  
    s -= length; 
  
    // finding breadth 
    double breadth = s / 2; 
  
    // finding height 
    double height = s - breadth; 
  
    return length * breadth * height; 
} 

void solve()
{
  double l;
  cin >> l;
  printf("%0.12f\n",maxvolume(l)); 
  return;
}

signed main()
{
   FAST;
	int T=1;
	// cin >> T;
	while(T--)
	{
		solve();
	}
    return 0;
}

Measured memory_bytes: 256
#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 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; }
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; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

	ll x;
	cin >> x;
	bool ok = false;
	if(x==1){
		cout << 0 << " "<< -1 << endl;
		return 0;
	}
	repk(i,-1000,1000){
		if(ok) break;
		repk(j,-1000,1000){
			if(i*i*i*i*i - j*j*j*j*j == x){
				cout << i <<" "<< j << endl;
				ok = true;
				break;
			}
		}
	}


    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>
 
#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif
 
int main(){
	double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
 
#if INPUT_FROM_FILE
    //std::ifstream ifs("test.txt");
    FILE *fp = fopen("test.txt", "r");
#endif
 
#if INPUT_FROM_FILE
	while(fscanf(fp, "%lf %lf %lf %lf %lf %lf %lf %lf", &xa1, &ya1, &xa2, &ya2, &xb1, &yb1, &xb2, &yb2) != EOF){
#else
	while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &xa1, &ya1, &xa2, &ya2, &xb1, &yb1, &xb2, &yb2) != EOF){
#endif
		if(((xa1 <= xb2 && xb2 <= xa2) || (xa1 <= xb1 && xb1 <= xa2) ||
			(xb1 <= xa2 && xa2 <= xb2) || (xb1 <= xa1 && xa1 <= xb2)) &&
			((ya1 <= yb2 && yb2 <= ya2) || (ya1 <= yb1 && yb1 <= ya2) ||
			(yb1 <= ya2 && ya2 <= yb2) || (yb1 <= ya1 && ya1 <= yb2))){
			std::cout << "YES" << std::endl;
		}
		else{
			std::cout << "NO" << std::endl;
		}
	}
 
#if INPUT_FROM_FILE
#else
#endif
 
#if INPUT_FROM_FILE
	fclose(fp);
#endif
    return 0;
}


Measured memory_bytes: 3128
# 2019/06/22
# AtCoder Beginner Contest 131 - D

from operator import itemgetter

# Input
n = int(input())
tlist = list()

for i in range(n):
    a, b = map(int, input().split())
    tlist.append([a, b])

tlist.sort(key=itemgetter(1))

etime = 0
ans = "Yes"
for i in range(n):
    etime += tlist[i][0]
    if etime > tlist[i][1]:
        ans = "No"

# Output
print(ans)


Measured memory_bytes: 38080
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
 
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
int bsr(int x) { return 31 - __builtin_clz(x); }
int bsr(ll x) { return 63 - __builtin_clzll(x); }
int bsf(int x) { return __builtin_ctz(x); }
int bsf(ll x) { return __builtin_ctzll(x); }

const int MN = 100100;
int n;
ll a[MN];
V<int> g[MN];
bool ok = true;
ll dfs(int p, int r) {
    if (g[p].size() == 1) {
        return a[p];
    }
    ll sm = 0;
    ll ma = -1;
    for (int d: g[p]) {
        if (d == r) continue;
        ll u = dfs(d, p);
        sm += u; ma = max(ma, u);
    }
    ll rem = a[p]*2-sm;
    ma = max(ma, rem);
    if (rem < 0) {
        ok = false;
        return 0;
    }
    if (a[p]*2-ma < ma) {
        ok = false;
        return 0;
    }
    return rem;
}

bool solve() {
    if (n == 2) return a[0] == a[1];
    int r = -1;
    for (int i = 0; i < n; i++) {
        if (g[i].size() >= 2) {
            r = i;
            break;
        }
    }
    //root = r
    if (dfs(r, -1)) ok = false;
    return ok;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n-1; i++) {
        int x, y;
        cin >> x >> y; x--; y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    if (solve()) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 13184
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define ll long long
int n,k;
vector<ll> pos,neg,res;
ll ans=1,cons=1000000007;

signed main(){
	cin>>n>>k;
	for(int i=0;i<n;i++){
	   ll v;cin>>v;
	   if(v>=0){pos.push_back(v);
	   }
	   else neg.push_back(v*(-1));
	   ans=(ans*v)%cons;
	}
	if(k==n){cout<<(ans+cons)%cons<<endl; return 0;
	}
	ans=1;
	sort(neg.begin(),neg.end());
	sort(pos.begin(),pos.end());
	if(pos.empty()){
		ans=1;
		if(k%2){
			for(int i=0;i<k;i++)ans=(ans*neg[i]+cons)%cons;
			ans*=-1;
		}
		else{
			for(int i=neg.size()-1;i>=neg.size()-k;i--){
				ans=(ans*neg[i]+cons)%cons;
			}
		}
		cout<<(ans+cons)%cons;return 0;
	}
	else{
		if(k%2==1){
		    res.push_back(pos.back());
		    pos.pop_back();
		}
		while(res.size()<k){
			bool ppos=0,pneg=0;ll pos1,neg1,pos2,neg2;
			if(pos.size()>=2){ppos=1;pos1=pos.back();
			pos2=pos[pos.size()-2];
			}
			if(neg.size()>=2){pneg=1;neg1=neg.back();
			neg2=neg[neg.size()-2];
			}
			if(ppos&&pneg){
				if(pos1*pos2>neg1*neg2){
					pos.pop_back();
					pos.pop_back();
					res.push_back(pos1);res.push_back(pos2);
				}
				else{
					neg.pop_back();neg.pop_back();
					res.push_back(neg1);res.push_back(neg2);
				}
			}
			if(pneg&&!ppos){
				neg.pop_back();neg.pop_back();
					res.push_back(neg1);res.push_back(neg2);
			}
			if(ppos&&!pneg){
				pos.pop_back();
					pos.pop_back();
					res.push_back(pos1);res.push_back(pos2);
			}
			if(!ppos&&!pneg){
				res.push_back(pos.back());pos.pop_back();
				res.push_back(neg.back());neg.pop_back();
			}		
	}
	}
	for(int i=0;i<k;i++)ans=(ans*res[i]+cons)%cons;
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 7904
#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++)

int main() {
  string Ans = "No";  // 回答：

  string N;cin >> N;  //
  if ( N.at(0) == '7' ) { Ans = "Yes";}
  if ( N.at(1) == '7' ) { Ans = "Yes";}
  if ( N.at(2) == '7' ) { Ans = "Yes";}

  cout << Ans << endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 200001

using namespace std;

struct Can{ ll A; ll B; };
vector<Can> vec;

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    ll N, M; cin >> N >> M;
    for(int i = 0; i < N; i++)
    {
        ll a, b; cin >> a >> b;
        vec.push_back(Can{a, b});
    }
    
    sort(vec.begin(), vec.end(), [](Can a, Can b) { return a.A > b.A; });
    ll ret = 0;
    ll cnt = 0;
    while(cnt < M)
    {
        auto cur = vec.back(); vec.pop_back();
        if(cnt + cur.B <= M)
        {
            cnt += cur.B;
            ret += cur.A * cur.B;
        }
        else
        {
            while(cur.B-- && cnt < M)
            {
                cnt += 1;
                ret += cur.A;
            }
        }
    }
    cout << ret << endl;
    return 0;
}


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

int Sibling(int);
int degree(int);
int Depth(int);
int height(int);

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

tree *TREE;

int N;

#define fr -1

int main(){
  int id,i,j,de,depth;

  scanf("%d",&N);
  TREE = (tree *)malloc(sizeof(tree)*N);

  for(i=0;i<N;i++){
    TREE[i].parent = fr;
    TREE[i].left = fr;
    TREE[i].right = fr;
  }

for(i=0;i<N;i++){
  scanf("%d",&id);
  scanf("%d",&TREE[id].left);
  scanf("%d",&TREE[id].right);

if(TREE[id].left != -1){
  TREE[TREE[id].left].parent = id;
}
if(TREE[id].right != -1){
  TREE[TREE[id].right].parent = id;
}
}

for(i=0;i<N;i++){
//if(TREE[i].parent == -1){
//printf("node %d: parent = -1",i);
//}

//else{
  printf("node %d: parent = %d, ",i,TREE[i].parent);
//}


printf("sibling = %d, ",Sibling(i));
de = degree(i);
printf("degree = %d, ",de);

printf("depth = %d, ",Depth(i));
depth = Depth(i);

printf("height = %d, ",height(i));

if(TREE[i].parent == -1){
  printf("root\n");
}
else if(TREE[i].left == fr && TREE[i].right == fr){
  printf("leaf\n");
}
else printf("internal node\n");

}

return 0;
}

//Sibling Function!<f>
int Sibling(int id){
  int i;
  for(i=0;i<N;i++){
    if(TREE[id].parent == TREE[i].parent && id != i){
      return i;
    }
  }
  return -1;
}

//degree Function!<f>
int degree(int id){
  int i;
if(TREE[id].left != -1 && TREE[id].right != -1){
  return 2;
}
  else if(TREE[id].left != -1 || TREE[id].right != -1){
    return 1;
  }
  else return 0;
}

//depth Function!<f>
int Depth(int id){
  int i = TREE[id].parent;
  int depth = 0;
  while(i!=fr){
    i = TREE[i].parent;
    depth++;
  }
return depth;
}

//height Function
int height(int id){
  int lheight=0,rheight=0;
  if(TREE[id].left != fr){
    lheight = height(TREE[id].left) + 1;
  }
  if(TREE[id].right != fr){
  rheight = height(TREE[id].right) + 1;
}
if(lheight > rheight){
  return lheight;
}
else{
  return rheight;
}
}

Measured memory_bytes: 612
#include <stdio.h>

int main(void){
    int s;

    scanf("%d",&s);

    if(s < 1200) printf("ABC");
    else if(s < 2800) printf("ARC");
    else printf("AGC");

    /*
    switch(s){
        case int n when n < 1200:
        printf("ABC");
        break;
        case s < 2800:
        printf("ARC");
        break;
        default:
        printf("AGC");
        break;
    }
    */
   return 0;
}

Measured memory_bytes: 128
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N, P := nextInt(), nextInt()
	var sum int
	var includeodd bool
	for i := 0; i < N; i++ {
		A := nextInt()
		sum += A
		if A%2 == 1 {
			includeodd = true
		}
	}
	if includeodd {
		fmt.Println(pow(2, N-1))
	} else {
		if P == 1 {
			fmt.Println(0)
		} else {
			fmt.Println(pow(2, N))
		}
	}
}

func nextLine() 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 abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


Measured memory_bytes: 1800
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include <string>

using namespace std;

void solve();

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

void solve() {
    while(1) {
        int n,m;
        cin >> n >> m;
        if(n == 0 && m == 0) break;
        int a[n];
        for(int i = 0; i < n; i++) {
            cin >> a[i];
        }
        int ans = -1;
        for(int i = 0; i< n; i++) {
            for(int j = i + 1; j < n; j++) {
                if(a[i] + a[j] <= m) {
                    ans = max(a[i] + a[j],ans);
                }
            }
        }
        if(ans == -1) cout << "NONE" << endl;
        else cout << ans << endl;
    }
}

Measured memory_bytes: 3112
n = int(input())
a = list(map(int, input().split()))

count4 = 0
count2_except4 = 0
for i in range(n):
    if a[i] % 4 == 0:
        count4 += 1
    elif a[i] % 2 == 0:
        count2_except4 += 1
if count4 * 2 + 1 >= n:
    print('Yes')
elif count2_except4 >= n - 2 * count4:
    print('Yes')
else:
    print('No')


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

int main(){
    int n;
    cin >> n;
    int digit = 0;
    int tmp = n;
    while(tmp > 0){
        digit += tmp % 10;
        tmp = tmp / 10;
    } 
    if(n % digit == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

int main() {
  int s;
  cin>>s;
  
  if(s%100>0 && s%100<13){
    if (s/100 >12 || s/100 ==0){
      cout << "YYMM" << endl;
    }
    else if (s/100>0 && s/100<13){
      cout <<"AMBIGUOUS" << endl;
    }
    else{
      cout << "NA" <<endl;
    }
  }
  else {
    if(s/100 >0 && s/100<13){
      cout << "MMYY" << endl;
    }
    else {
      cout << "NA" << endl;
    }
  }
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

  int n; cin >> n;
  map<int,int> s;
  REP(i,n){
	int x; cin >> x;
	s[x]++;
  }

  int q, ans = 0; cin >> q;
  REP(i,q){
	int x; cin >> x;
	if(s[x] > 0) ++ans;
  }

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

Measured memory_bytes: 3540
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MOD=1e9+7;
static const ll MAX=101010;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/


int main(void) {
  ll i, j, k, l;
  
  ll N;
  cin >> N;
  ll s=0;
  ll a[MAX];
  memset(a, 999, sizeof(a));
  for(i=0; i<N; i++) {
    cin >> a[i];
    s+=abs(a[i]);
  }
  sort(a, a+N);
  
  if((a[0]<0 && a[N-1]>0)) {
    pt(s);
    for(k=0; a[k]<=0; k++);
    
    for(i=k; i<N-1; i++) {
      pt(a[0]<<" "<<a[i]);
      a[0]-=a[i];
    }
      
    for(i=0; i<k; i++) {
      pt(a[N-1]<<" "<<a[i]);
      a[N-1]-=a[i];
    }
    
  }else if(a[0]>=0) {
    pt(s-a[0]*2);
    for(i=1; i<N-1; i++) {
      pt(a[0]<<" "<<a[i]);
      a[0]-=a[i];
    }
    pt(a[N-1]<<" "<<a[0]);
    
  }else {
    pt(s-abs(a[N-1])*2);
    for(i=0; i<N-1; i++) {
      pt(a[N-1]<<" "<<a[i]);
      a[N-1]-=a[i];
    }
      
  }
  
  
}




Measured memory_bytes: 2688