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

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,m,a; cin>>n>>m;
	while (m--) {
		cin>>a, n-=a;
	} 
	if (n<0) cout<<-1;
	else cout<<n;
	cout<<endl;
	return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>
 
 
#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s
 
typedef long long ll;
 
using namespace std;

ll modd = 1000*1000*1000+7;

ll binary_search(function<bool(ll)> func, ll start, ll end) {
    /*      func:int ->bool
            returns smallest int x where func(x) evaluates to true, searches in [start,end), it is assumed the values are false, .. , false, true ...
             */
    if (end <= start) {   return end;  }   // has to be here, otherwise func(end-1) in next line could be a problem
    if (!func(end-1)) {  return end;  }
    while (end-start>1) {
        ll mid = (start+end)/2;
        if (func(mid)) {  end = mid;  } else { start = mid;   }
    }
    if (func(start)) {  return start;  } else {  return end;   }
}; 

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


int main()   {

    ios_base::sync_with_stdio(false);

    cout.precision(17);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no
 
//    auto start = chrono::steady_clock::now();
  
//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readll(n); readll(m);
        n = gcd(n,m);

        ll d = 2;
        set<ll> primes; primes.insert(1);
        while (d*d<=n) {
            if (n%d==0) {
                n/=d; primes.insert(d);
            } else {
                d++;
            }
        }
        primes.insert(n);

        cout << primes.size() << endl;

    }
 
//    auto end = chrono::steady_clock::now();
//    cout << chrono::duration_cast<chrono::milliseconds>(end - start).count() << endl;
 
    return 0;
}

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

const int MAXN=5e5+10;
const int mod=1e9;
typedef long long LL;

int n,m,c1,c2,v,t;
int x[MAXN],y[MAXN];
int f[MAXN],g[MAXN];

int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&x[i]);
    for(int i=1;i<=n;i++) scanf("%d",&y[i]);
    int ans=0;
    for(int k=1;k<=29;k++){
        int bas=1<<(k-1);
        for(int i=1;i<=n;i++) f[i]=x[i]%(2*bas);
        for(int i=1;i<=n;i++) g[i]=y[i]%(2*bas);
        sort(f+1,f+n+1);
        sort(g+1,g+n+1);
        int l1,l2,r1,r2;
        l1=l2=r1=r2=n;
        int num=0;
        for(int i=1;i<=n;i++){
            /*for(int j=1;j<=n;j++){
                if (3*bas<=f[i]+g[j] && f[i]+g[j]<4*bas) num++;
                if (bas<=f[i]+g[j] && f[i]+g[j]<2*bas) num++;
            }*/
            while(l1>=1 && g[l1]+f[i]>=bas) l1--;
            while(l2>=1 && g[l2]+f[i]>=3*bas) l2--;
            while(r1>=1 && g[r1]+f[i]>=2*bas) r1--;
            while(r2>=1 && g[r2]+f[i]>=4*bas) r2--;
            int tmp=max(0,r1-l1)+max(0,r2-l2);
            num=(num+tmp)%2;
        }
        num%=2;
        if (num==1) ans+=bas;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 5760
import sys
from collections import defaultdict

input = sys.stdin.readline


def calc_prime_factors(n, count=False):
    """Trial division"""
    factors = []
    # factor: 2
    while n % 2 == 0:
        factors.append(2)
        n //= 2
    # factor: 3, 5, 7, 11, ...
    f = 3
    root_n = int(n ** 0.5) + 1
    while f <= root_n:
        if n % f == 0:
            factors.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        factors.append(n)
    return factors


def main():
    N = int(input())

    n_factor = defaultdict(int)
    for n in range(1, N + 1):
        factors = calc_prime_factors(n)
        for f in factors:
            n_factor[f] += 1

    n_factor = list(n_factor.values())
    n_factor.sort()
    ans = 0

    # 75 = 3 x 3 x 5 : (2, 4, 4)
    A, B = 0, 0
    for n in n_factor:
        if 2 <= n <= 3:
            A += 1
        elif 4 <= n:
            B += 1
    ans += A * B * (B - 1) // 2 + B * (B - 1) * (B - 2) // 6 * 3

    # 75 = 3 x 25 : (2, 24)
    A, B = 0, 0
    for n in n_factor:
        if 2 <= n <= 23:
            A += 1
        elif 24 <= n:
            B += 1
    ans += A * B + B * (B - 1)

    # 75 = 5 x 15 : (4, 14)
    A, B = 0, 0
    for n in n_factor:
        if 4 <= n <= 13:
            A += 1
        elif 14 <= n:
            B += 1
    ans += A * B + B * (B - 1)

    # 75 = 75 : (74,)
    A = 0
    for n in n_factor:
        if 74 <= n:
            A += 1
    ans += A

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 65820
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
	double T,A;
	int n;
	scanf("%d",&n);
	scanf("%lf%lf",&T,&A);
	int pos=0;
	double now=1000000000000000.0;
	for(int i=1;i<=n;i++)
	{
		double xx;
		scanf("%lf",&xx);
		double tmp=T-xx*0.006;
		if(abs(tmp-A)<=now)
		{
			pos=i;
			now=abs(tmp-A);
		}
	}
	cout<<pos<<endl;
	return 0;
}

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

int main(){
	int D, N, a;
	scanf("%d%d", &D, &N);
	if(D == 0){
		a = 1;
	}
	else if(D == 1){
		a = 100;
	}
	else{
		a = 10000;
	}
	if(N == 100){
		printf("%d\n", 101 * a);
	}
	else{
		printf("%d\n", N * a);
	}
	return 0;
}

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

int main() {
	int h, w;
	cin >> h >> w;
	vector<vector<int>> m(h, vector<int>(w));
	rep(i, h) {
		rep(j, w) {
			cin >> m[i][j];
		}
	}
	vector<pair<pair<int, int>, pair<int, int>>> ans;
	int cnt = 0;
	rep(i, w) {
		rep(j, h - 1) {
			if (m[j][i] % 2 == 1) {
				cnt++;
				ans.push_back(make_pair(make_pair(j + 1, i + 1), make_pair(j + 2, i + 1)));
				m[j][i]--;
				m[j + 1][i]++;
			}
		}
	}
	rep(i, w - 1) {
		if (m[h - 1][i] % 2 == 1) {
			cnt++;
            m[h-1][i+1]++;
			ans.push_back(make_pair(make_pair(h, i + 1), make_pair(h, i + 2)));
		}
	}
	cout << cnt << endl;
	rep(i, ans.size()) {
		cout << ans[i].first.first << " " << ans[i].first.second << " " << ans[i].second.first << " " << ans[i].second.second << endl;
	}
}


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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 100007;

int n;
LL l;
char s[MAXN];
int ch[MAXN][2], kc;



void init ();
void input ();
void work ();

LL sg ( LL x )
{
	return ( x & -x );
}

void addtrie ( char s[] )
{
	int now = 0, len = strlen ( s ), nc;
	lp ( i, 0, len ) {
		nc = s[i] - '0';
		if ( ch[now][nc] ) now = ch[now][nc];
		else now = ch[now][nc] = ++kc;
	}
}

LL dfs ( int now, int nl )
{
	if ( !now ) return sg ( l - nl + 1 );
	else return ( dfs ( ch[now][0], nl+1 ) ^ dfs ( ch[now][1], nl+1 ) );
}



int main ()
{
	init ();
	input ();
	work ();
}



void init ()
{
	// Init Everything Here

	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method

	scanf ( "%d%lld", &n, &l );
	lpi ( i, 1, n ) {
		scanf ( "%s", s );
		addtrie ( s );
	}
}

void work ()
{
	// main work

	cout << ( ( dfs ( ch[0][0], 1 ) ^ dfs ( ch[0][1], 1 ) ) ? "Alice" : "Bob" ) << endl;
}

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

int main() {
    int c[3][3];
    
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            cin>>c[i][j];
        }
    }
    
    int temp;
    for(int i=0; i<3; i++){
        temp = min(min(c[i][0],c[i][1]),c[i][2]);
        c[i][0] -= temp;
        c[i][1] -= temp;
        c[i][2] -= temp;
    }
    
    for(int i=0; i<3; i++){
        temp = min(min(c[0][i],c[0][i]),c[0][i]);
        c[0][i] -= temp;
        c[0][i] -= temp;
        c[0][i] -= temp;
    }
    int sum=0;
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            sum += c[i][j];
        }
    }
    
    if(sum==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}
    



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>
#include <cmath>
using namespace std;
typedef complex<double> P;

const double eps = 1e-8;

bool equals(double a, double b) {
  return abs(a-b) < eps;
}

double dot(P a, P b) {
  return a.real()*b.real() + a.imag()*b.imag();
}

double cross(P a, P b) {
  return a.real()*b.imag() - a.imag()*b.real();
}

int ccw(P p, P a, P b) {
  a -= p;
  b -= p;
  if(cross(a, b) > eps) return 1;
  if(cross(a, b) < -eps) return -1;
  if(dot(a,b) < -eps) return 2;
  if(norm(b)-norm(a) > eps) return -2;
  return 0;
}

bool isIntersect(P a1, P a2, P b1, P b2) {
  return ( ccw(a1, a2, b1) * ccw(a1, a2, b2) <= 0 &&
	   ccw(b1, b2, a1) * ccw(b1, b2, a2) <= 0 );
}

P getCrossP(P a1, P a2, P b1, P b2) {
  P a = a2 - a1;
  P b = b2 - b1;
  return a1 + a * cross(b, b1 - a1)/cross(b, a);
}

P A, B;
int N;
vector<P> S, T;
vector<int> Own, Pos;

int main() {
  int Tc;
  cin >> Tc;
  while(Tc--) {
    cin >> A.real() >> A.imag() >> B.real() >> B.imag();
    cin >> N;
    S.resize(N);
    T.resize(N);
    Own.resize(N);
    Pos.resize(N);
    for(int i = 0; i < N; ++i) {
      cin >> S[i].real() >> S[i].imag() >> T[i].real() >> T[i].imag()
	  >> Own[i] >> Pos[i];
    }

    vector<pair<double, int> > v;
    for(int i = 0; i < N; ++i) {
      if(isIntersect(A,B,S[i],T[i])) {
	P p = getCrossP(A,B,S[i],T[i]);
	v.push_back(make_pair(norm(p-A), i));
      }
    }
    int cnt = 0;
    if(v.size()) {
      sort(v.begin(), v.end());
      int pos = (Pos[v[0].second] ^ ~Own[v[0].second]);
      
      for(int i = 1; i < v.size(); ++i) {
	int npos = Pos[v[i].second] ^ ~Own[v[i].second];
	if(npos != pos) ++cnt;
	pos = npos;
      }
    }
    cout << cnt << endl;
  }
  return 0;
}

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

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

ll pow_mod(ll a, ll n, ll p)
{
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res*a%p;
        a = a*a%p;
        n >>= 1;
    }
    return res;
}

int main()
{
    ll i,j;
    ll h,w,k;
    cin >> h >> w >> k;
    vector<vector<ll>> c(h,vector<ll>(w));
    for(i = 0;i < h;++i){
        string s;
        cin >> s;
        rep(j,w){
            c.at(i).at(j) = s.at(j) - '0';
        }
    }
    ll ans = 0;
    for(i = 0;i < h;++i){
        rep(j,w){
            vector<vector<ll>> cc = c;
            cc.at(i).at(j) = 0;
            ll tmp = 0;
            ll stage = 0;
            while(true){
                ll ii,jj;
                rep(jj,w){
                    vector<ll> notzero;
                    for(ii = h-1;ii >= 0;--ii){
                        if(cc.at(ii).at(jj) != 0) notzero.push_back(cc.at(ii).at(jj));
                    }
                    for(ii = 0;ii < notzero.size();++ii){
                        cc.at(h-1-ii).at(jj) = notzero.at(ii);
                    }
                    for(ii = ii;ii < h;++ii){
                        cc.at(h-1-ii).at(jj) = 0;
                    }
                }
                bool flag = true;
                for(ii = h-1;ii >= 0;--ii){
                    rep(jj,w){
                        if(cc.at(ii).at(jj) == 0) continue;
                        if(jj + k-1 >= w) continue;
                        ll kk;
                        ll tmp_number = cc.at(ii).at(jj);
                        ll conlen = 0;
                        for(kk = jj;kk < w;++kk){
                            if(cc.at(ii).at(kk) == tmp_number){
                                ++conlen;
                            }else{
                                break;
                            }
                        }
                        if(conlen >= k){
                            flag = false;
                            tmp += tmp_number*conlen*pow_mod(2ll, stage, 1e12+7);
                            for(kk = jj;kk < jj+conlen;++kk){
                                cc.at(ii).at(kk) = 0;
                            }
                        }
                    }
                }
                if(flag) break;
                ++stage;
            }
            ans = max(tmp,ans);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string a;
int g,p,w;
int main()
{
    cin>>a;
    for(int i=0;i<a.length();i++)
    {
        if(a[i]=='g')
        {
            if(g>=(p+1))
            {
                w++;
                p++;
            }
            else g++;
        }
        else if(g>=(p+1))p++;
            else
            {
                g++;
                w--;
            }
    }
    cout<<w<<endl;
    return 0;
}

Measured memory_bytes: 512
#pragma GCC optimize(3)
#include<iostream>
#include<map>
#include<algorithm>
using namespace std;
string s;
int n;
map<string,int>m;
long long ans,tmp;
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	for(register int i=1;i<=n;i++){
		cin>>s;
		sort(s.begin(),s.end());
		m[s]++;
	}
	for(register map<string,int>::iterator iter=m.begin();iter!=m.end();iter++){
		tmp=iter->second;
		ans+=(tmp*(tmp-1))>>1;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
#define mem(a, b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 100000 + 50;
int n, k, t;
int gcd(int a, int b){
	return b==0?a:gcd(b,a%b);
}
int a[maxn];
bool check(){
	int d = 1e9+7;
	for(int i = 1; i < n; i++)
	{
		d = min(d, gcd(a[i], a[i-1]));
	}
	if(k % d == 0) return true;
	return false;
}
int main(){
	//freopen("input.txt", "r", stdin);
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin >> n >> k;
	for(int i = 0; i < n; i++){
			cin >> a[i];
		 	if(k == a[i]){
		 		cout << "POSSIBLE" << endl;
		 		return 0;
			}
		}
	sort(a,a+n);
	if(k > a[n-1]) {cout << "IMPOSSIBLE" << endl; return 0;}
	bool fg1 = false, fg2 = false;
	for(int i = 0; i < n && !fg1 && !fg2; i++){
		if(a[i] % 2 == 0) fg1 = true;
		if(a[i] % 2 != 0) fg2 = true;
	}
	if(fg1 && fg2){
		 		cout << "POSSIBLE" << endl;
		 		return 0;
	}
	else {
		if(check()) 	cout << "POSSIBLE" << endl;
		else 	cout << "IMPOSSIBLE" << endl;

	}
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main(){
	double a, b, c, d, p, q;
	double x, y;
	while(cin >> a >> b >> p >> c >> d >> q){
		x = (d*p - b*q)/(a*d - b*c);
		y = (c*(-p) + a*q)/(a*d - b*c); //条件より?≠0
		x = floor(100*(x + 0.005)) / 100; 
		y = floor(100*(y + 0.005)) / 100; //四捨五入
		cout << setprecision(3) << fixed << x << " " << y << endl;
	}
	return(0);
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
  ll n,l,c=0;
  cin>>n>>l;
  while(n--){
	ll x,y;
    cin>>x>>y;
    if(l*l>=x*x+y*y)c++;
  }
  cout<<c;
  return 0;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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 A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;

const ll MOD = 1e9+7;

// n^m%MOD を求める。O( log(m) )
ll modpow(ll n, int m){
	ll ret=1;
	for(int i=1; i<=m; i<<=1, (n*=n)%=MOD){
		if( m&i ) (ret *= n) %= MOD;
	}
	return ret;
}

// 逆元を求める
ll modinv(ll n){
	return modpow( n, MOD-2 );
}

// 階乗を求める。O(1)  準備O( n*log(n) )
// fact[n]     : nの階乗
// fact.inv[n] : nの階乗の逆元
class FACTORIAL{
public:
	vector<ll> fact, inv;
	FACTORIAL(int MAX_NUM): fact(MAX_NUM), inv(MAX_NUM) {
		fact[0] = inv[0] = 1;
		for(ll i=1; i<MAX_NUM; i++){
			fact[i] = (fact[i-1] * i) % MOD;
			inv[i] = modinv( fact[i] );
		}
	}
	const ll& operator [ ] ( const int i ) const {
		return fact[i];
	}
} fact(200006); // nの最大値を指定


// 組み合わせ(Combinationを求める) O(1)
ll cmb(unsigned int n, unsigned int r){
	if( n < r ) return 0;
	return fact[n] * fact.inv[r] % MOD * fact.inv[n-r] % MOD;
}


vector<int> edge[200005];
map<int,pll> memo[200005];
map<int,pll> memoL[200005];
map<int,pll> memoR[200005];
pll solve(int n, int b){
	if(memo[n].count(b)) return memo[n][b];

	auto merge = [&](pll cur, pll pre){
		ll cnt = pre.Y + cur.Y;
		ll sum = pre.X;
		sum = sum * cmb(cnt, cur.Y) % MOD;
		sum = sum * cur.X % MOD;
		return pll(sum, cnt);
	};

	if(b >= 0 && memo[b].count(n)){
		// b -> n が存在するとき、nが根のときの結果を使って高速化する
		solve(n, -1);
		auto ret = merge(memoL[n][b], memoR[n][b]);
		ret.Y += 1;
		return memo[n][b] = ret;
	}

	pll ret = pll(1, 0);
	for(auto t: edge[n]) if(t != b){
		ret = merge(solve(t, n), ret);
	}
	ret.Y += 1;

	if(b == -1){
		pll nex = pll(1, 0);
		rep(i,edge[n].size()){
			int t = edge[n][i];
			memoL[n][t] = nex;
			nex = merge(solve(t,n), nex);
		}
		nex = pll(1, 0);
		rrep(i,edge[n].size()){
			int t = edge[n][i];
			memoR[n][t] = nex;
			nex = merge(solve(t,n), nex);
		}
	}

	return memo[n][b] = ret;
}

int main(){
	ios_base::sync_with_stdio(false);
	int N;

	cin >> N;
	rep(i,N-1){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}

	vector<ll> ans;
	rep(i,N) ans.push_back(solve(i,-1).X);
	for(auto t: ans) cout << t << "\n";

	return 0;
}

Measured memory_bytes: 134256
n=int(input())-1
A=list(map(int,input().split()))
i=0
for j in range(n):
 if A[j]<=A[-1]:A[i],A[j]=A[j],A[i];i+=1
A[i],A[n]='['+str(A[n])+']',A[i]
print(*A)


Measured memory_bytes: 16388
#include <stdio.h>
#include <string.h>
int main(void)
{
	char S[100010];
	scanf("%s",S);
	int i,N;
	N = strlen(S);
	//printf("N = %d\n",N);
	int c[N],k[N];
	
	for(i = 0; i < N; i++)
	{
		if(S[i] == 'R') c[i] = 1;
		else c[i] = 2;
		k[i] = 0;
	}
	
	int count = 0,j = 0,r = 0, l = 0;
	/*
	for(i = 0; i < N; i++)
	{
		printf("%d ",c[i]);
	}
	*/
	while(j != N)
	{
		r = 0; l = 0;
		while(c[r+j] != 2){
			r++;
		}
		while(c[j+r+l] != 1 && j+r+l != N)
		{
			l++;
		}
		k[j+r]+=r/2;
		k[j+r-1] += r - r/2;
		k[j+r-1]+=l/2;
		k[j+r] += l - l/2;
		j+=r+l;
	}
	//printf("r = %d, l = %d\n",r,l);
	for(i = 0; i < N; i++)
	{
		printf("%d ",k[i]);
	}
	//*/
	return 0;
}


Measured memory_bytes: 1280
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static final PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    private static StringTokenizer st;

    private static long readLong() throws IOException {
        while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
        return Long.parseLong(st.nextToken());
    }

    public static void main(String[] args) throws IOException {
        pw.println(solve());
        pw.close();
    }

    private static long solve() throws IOException {
        long OrigX = readLong();
        long K = readLong();
        long D = readLong();

        if (OrigX == 0) return D * (K % 2);

        return solve(Math.abs(OrigX), K, D);
    }

    private static long solve(long X, long K, long D) {
        if (X / D >= K) return (X - K * D);
            // Now X < D * K

        else {
            K -= X/D;
            X -= X / D * D;

            if ( K % 2 == 0) {
                return X;
            } else {
                return D - X;
            }
        }
    }
}


Measured memory_bytes: 32864
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

#include <fstream>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

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

	//カードの枚数を数える
	map<int, int> counts;

	rep(i, N)
	{
		int tmp;
		cin >> tmp;
		counts[tmp]++;
	}

	//カードが1種類の場合は1枚しか残せない。
	if (counts.size() == 1)
	{
		cout << 1 << endl;
		return 0;
	}

	//2枚以上ある数字だけ別管理
	map<int, int> dup;
	for (auto c : counts)
	{
		if (c.second >= 2) dup[c.first] = c.second;
	}

	//全部1枚の時はN
	if (dup.size() == 0)
	{
		cout << N << endl;
		return 0;
	}

	int total = N;

	auto l = dup.begin();
	auto r = dup.rbegin();

	while (true)
	{
		if (l->first > r->first) break;

		if (l->first == r->first)
		{
			if (l->second%2 == 0)
			{
				total -= l->second;
			}
			else
			{
				total -= l->second - 1;
			}
			
			break;
		}

		int cnt = min(l->second, r->second) - 1;
		l->second -= cnt;
		r->second -= cnt;
		total -= 2 * cnt;

		if (l->second == 1) ++l;
		if (r->second == 1) ++r;
	}

	cout << total << endl;

	return 0;
}

Measured memory_bytes: 4992
#include <iostream>

int main()
{
	char c;
	int n[26] {};
	while (std::cin >> c) {
		if ('A'<=c && c<='Z') ++n[c-'A'];
		else if ('a'<=c && c<='z') ++n[c-'a'];
	}
	for (int i=0; i!=26; ++i)
		std::cout << char('a'+i) << " : " << n[i] << '\n';
}

Measured memory_bytes: 3096
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		String s = sc.next();
        int b = 0;
        for(int i=0;i<a-2;i++){if(s.substring(i,i+3).equals("ABC")){b++;                                                                                                  
                                                                   }                            
                              }
		System.out.println(b);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    int n, k;
    cin >> n >> k;
    ll ans = k;
    rep(i, n-1) {
        ans *= k - 1;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3600
#include<stdio.h>
int main()
{
    int n, a[20], i, j = 0, k;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(i=1; i<n-1; i++)
    {
        if((a[i-1]<a[i] && a[i]<a[i+1]) || (a[i-1]>a[i] && a[i]>a[i+1]))
            j++;
    }
    printf("%d\n",j);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int N;
    cin >> N;
    int res = 0;
    rep(i, N) {
        int l, r;
        cin >> l >> r;
        res += r-(l-1);
    }
    
    cout << res << endl;
    return 0;
}

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

int main() { 
	char b;
  cin >> b;
  if(b== 'A'){
  cout << "T" << endl;
  }else if(b== 'T'){
   cout << "A" << endl;
  }else if(b=='G'){
   cout << "C" << endl;
  }else if(b=='C'){
   cout << "G" << endl;
  }
}

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

int main() {
  int N;
  cin>>N;
  vector<int> p(N);
  for(int i=0;i<N-1;i++){
    int a;
    cin>>a;
    p.at(a-1)=p.at(a-1)+1;
  }
  for(int i=0;i<N;i++){
    cout<<p.at(i)<<endl;
  }
}

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

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		var l = Input().ToInt();
		int n = l[0];
		int k = l[1];
		var h = new long[n];
		for(int i = 0; i < n; i++)
			h[i] = Console.ReadLine().ToInt();
		Array.Sort(h);
		long r = 9999999999;
		for(int i = 0; i <= n - k; i++)
		{
			r = Math.Min(h[k-1 + i] - h[i], r);
		}
		Console.WriteLine(r);
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		int[] r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
	
}

Measured memory_bytes: 16092
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	int count1=-1,count2=-1;
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='C'&&count1==-1)count1=i;
		if(s[i]=='F')count2=i;
	}
	if(count1<count2&&count1!=-1&&count2!=-1)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


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

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

long long lcm(long long a, long long b)
{
   return a * b / gcd(a, b);
}


long long nsolver(long long n,long long x, long long y){
        return n - (n/x + n/y - n/(lcm(x,y)));
}


int main(){
	long long a,b,c,d;
    cin >> a >> b >> c >> d;

    cout << nsolver(b,c,d) - nsolver(a-1,c,d) << endl;


}

Measured memory_bytes: 3588
import java.util.*;
import java.util.stream.*;

public class Main{

	static Scanner s=new Scanner(System.in);
	public static void main(String[] $){
		IntSummaryStatistics o=IntStream.range(0,s.nextInt()).map(i->s.nextInt()).summaryStatistics();
		System.out.println(o.getMax()-o.getMin());
	}
}

Measured memory_bytes: 27092
#include<stdio.h>
#include<string.h>
#include<stdlib.h>


typedef struct moji{
  char key[13];
  struct moji *r;
  struct moji *l;
}moji;



moji *mk_moji(char *x){
  moji *p;
  p=malloc(sizeof(moji));
  strcpy(p->key,x);
  p->r=NULL;
  p->l=NULL;
  return p;
}
  

void insert(moji **tree,moji *p){
  moji *q;
  if(*tree==NULL) *tree=p;
  else{
  q=*tree;
  while(1){
    if(strcmp(q->key , p->key) <0){
      if(q->r!=NULL) q=q->r;
      else{
        q->r=p;
        break;
      }
    }
    else{
      if(q->l!=NULL) q=q->l;
      else{
        q->l=p;
        break;
       
      }
    }
  }
  }
}

int search(moji *tree,char *x){
  if(tree==NULL) return 0;
  if(strcmp(tree->key,x) <0) return search(tree->r,x);
  if(strcmp(tree->key,x) ==0) return 1;
  return search(tree->l,x);
}


int main(){
  int n;
  int i;
  char x[13];
  char inst[8];
  moji **tree;
  moji *p;
  tree=malloc(sizeof(moji *));
  *tree=malloc(sizeof(moji));
  *tree=NULL;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%*[ \n]%s",inst);
    if(inst[0]=='i'){
      scanf("%*[ \n]%s",x);
      p=mk_moji(x);
      insert(tree,p);
      if(p==NULL) printf("WWW");
    }
    
    if(inst[0]=='f'){
      scanf("%*[ \n]%s",x);
      if(search(*tree,x)==1) printf("yes\n");
      else printf("no\n");
    }
  }
  return 0;
}


Measured memory_bytes: 28476
#include <cstdio>

int main(){
  char str[20];
  int i = 0;

  scanf("%s", str);

  while (str[i] != '\0'){
    i++;
  }
  for (i--; i >= 0; i--){
    printf("%c", str[i]);
  }
  printf ("\n");
  return 0;
}

Measured memory_bytes: 932
#include<bits/stdc++.h>
#define Mod 2019
using namespace std;
int l,r,a[2050];
int main() {
	int sz=0;
	scanf("%d%d",&l,&r);
	for(int i=l; i<=r; i++) {
		a[++sz]=i%Mod;
		if(sz==2019)break;
	}
	int ans=1e9;
	for(int i=1; i<=sz; i++) 
		for(int j=i+1; j<=sz; j++) 
			ans=min(ans,a[i]*a[j]%Mod);
	printf("%d\n",ans);
	return 0;
}

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

int insertionSort( int a[], int N, int g){
	int cnt = 0;
	for ( int i = g; i < N; i++ ){
		int v = a[i];
		int j = i - g;
		while ( j >= 0 && a[j] > v){
			a[j+g] = a[j];
			j -= g;
			cnt++;
		}
		a[j+g] = v;
	}
	return cnt;
}

void shellSort(int a[], int N){
	int cnt = 0;
	int G[100];
	int m = 0;
	int num = N;
	if (num < 3){
		G[0] = 1;
		m++;
	}
	else{
	    while ( num > 1 ){
		    num = num/3+1;
		    G[m] = num;
		    m++;
    	}
	}
	cout << m << endl;
	for ( int i = 0; i < m; i++){
		cout << G[i] << " ";
		cnt += insertionSort(a, N, G[i]);
	}
	cout << endl;
	cout << cnt << endl;
	for ( int i = 0; i < N; i++) cout << a[i] << endl;
}

int main(){
	int N;
	int a[1000000];
	cin >> N;
	for ( int i = 0; i < N; i++) cin >> a[i];

	shellSort(a, N);

	return 0;
}


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

using namespace std;

int main(){
	int x[1002];
	int y[1002];
	int r[1002];
	r[0] = r[1] = 0;
	
	scanf("%d %d %d %d",&x[0],&y[0],&x[1],&y[1]);
	
	int n;
	scanf("%d",&n);
	n+=2;
	for(int i=2;i<n;i++){
		scanf("%d %d %d",x+i,y+i,r+i);
	}
	
	priority_queue<pair<double,int>, vector<pair<double,int>>, greater<pair<double,int>>> pq;
	
	vector<int> trace;
	
	double d[1002];
	for(int i=0;i<1002;i++) d[i] = DBL_MAX;
	pq.push(make_pair(0.0,0));
	while(!pq.empty()){
		double di = pq.top().first;
		int j = pq.top().second;
		pq.pop();
		//printf("%f %d\n",di,j);
		//if(find(trace.begin(),trace.end(),j) != trace.end()) continue;
		trace.emplace_back(j);
		if(d[j] > di){
			d[j] = di;
		} else {
			continue;
		}
		d[j] = min(d[j],di);
		for(int i=1;i<n;i++){
			//cout << x[j] << " " << x[i] << " " << y[j] << " " << y[i] << " " << r[i] << " " << r[j] << endl;
			double distance = di + max(hypot(x[j] - x[i],y[j] - y[i]) - r[i] - r[j],0.0);
			//cout << j << " - " << i << " " << distance << endl;
			pq.push(make_pair(distance,i));
		}
	}
	printf("%.10f\n",d[1]);
	return 0;
}

Measured memory_bytes: 23780
#include <iostream>
#include <fstream>
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <string.h>
#include <string>
#include <math.h>
#include <iomanip>
using namespace std;

#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define pb push_back

typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

const int mod = 1e9 + 7;
const int mod2 = 998244353;

void fact_init(int n);
ll exp(ll taban, ll us, ll md);
ll ebob(ll a, ll b);
ll ekok(ll a, ll b);
ll komb(ll a, ll b);

vector<ll> fact;
vector<ll> inv_fact;
void fact_init(int n){
    fact.resize(n+5);
    inv_fact.resize(n+5);
    fact[0] = inv_fact[0] = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = (fact[i-1] * i) % mod;
        inv_fact[i] = exp(fact[i], mod-2, mod);
    }
}
ll exp(ll taban, ll us, ll md) {
    ll carpan = taban % md;
    if(carpan == 0) return 0;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % md;
        temp /= 2;
        carpan = (carpan*carpan) % md;
    }
    return res;
}
 
ll ebob(ll a, ll b){
    if(!a)return b;
    return ebob(b%a, a);
}

ll ekok(ll a, ll b){
    return (a*b)/ebob(a, b);
}

ll komb(ll a, ll b){
    if(a < b) return 0;
    return fact[a] * (inv_fact[a-b] * inv_fact[b] % mod) % mod;
}

const int N = 2e5 + 5;

int main(){
    ios::sync_with_stdio(false); cin.tie(NULL);
	int x; cin>>x;
	x /= 200;
	cout<<(10 - x)<<endl;
}

Measured memory_bytes: 3520
//135 B - 0 or 1 Swap 2019/07/27
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

int main(){
    int n; cin >> n;
    vector<int> p(n);
    rep(i ,n) cin >> p.at(i);
    int counter=0;
    rep(i ,n){
        if(p[i]!=i+1) ++counter;
    }
    cout << ((counter<=2) ? "YES" : "NO" ) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

int main() {
  int N;
  cin >> N;
  int a[200000] = {0};
  rep(i, N-1) {
    int temp;
    cin >> temp;
    temp--;
    a[temp]++;
  }
  rep(i, N) {
    cout << a[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 4372
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};
 

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if (A + B < C) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

class Test {
	static void Main(string[] args) {
      var inputs = System.Console.ReadLine()
    	.Split(' ')
    	.Select(s => int.Parse(s))
    	.ToArray();
      int H = inputs[0];
      int W = inputs[1];
      int K = inputs[2];
      int[,] c = new int[H,W];
      int[,] tmp = new int[H,W];
      int result = 0;
      for(int i = 0; i < H; i++){
        string A = System.Console.ReadLine();
        for(int j = 0; j < A.Length; j++){
          if(A[j].Equals('.')){
            c[i,j] = 0;
            tmp[i,j] = 0;
          }else if(A[j].Equals('#')){
            c[i,j] = 1;
            tmp[i,j] = 1;
          }
        }
      }
      
      
      for(int i = 0; i < Math.Pow(2, H + W) - 1; i++){
        string str = Convert.ToString(i,2).PadLeft(H + W, '0');
        for(int j = 0; j < H + W; j++){
          if(str[j] == '1'){
            if(H > j){
              for(int k = 0; k < W; k++){
                tmp[j,k] = 0;
              }
              
            }else{
              for(int k = 0; k < H; k++){
                tmp[k,j - H] = 0;
              }
            }
            
          }
        }
        
        int cnt = 0;
      	for(int j = 0; j < H; j++){
          for(int k = 0; k < W; k++){
          	if(tmp[j,k] == 1){
              cnt++;
            }
            tmp[j,k] = c[j,k];
          }
        }
        if(cnt == K){
          result++;
        }
      }
      Console.WriteLine(result);
	}
}

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

namespace program
{
    class Program
    {
        static void Main()
        {
          int a = Input.ScanInt();
          
          Console.WriteLine(a<1000 ? "ABC" : "ABD");
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public double[] ScanDoubleArray() { return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


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

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

	for(int i=0;i<n;++i){
		double a,b,c;
		cin >> a >> b >> c;
		double _a = pow(a,2),_b = pow(b,2),_c = pow(c,2);

		if(_a == _b + _c || _b == _a + _c || _c == _a + _b)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}

	return 0;
}

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

int n;
int b1[200005];
int range(int x, int y){
	int s, e;

	s = 0; e = n-1;
	while(s < e){
		int mid = (s+e)/2;
		if(b1[mid] < x){
			s = mid+1;
		}
		else{
			e = mid;
		}
	}
	int st = s;
	s = 0; e = n-1;
	while(s < e){
		int mid = (s+e)/2;
		mid = s+e-mid;
		if(b1[mid] >= y){
			e = mid-1;
		}
		else{
			s = mid;
		}
	}
	int en = s;
	if(st > en) return 0;
	if(st == en){
		if(b1[st] >= y || b1[st] < x) return 0;
		else return 1;
	}
	else{
		return en-st+1;
	}
}

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	int a[n];
	int b[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int i = 0; i < n; i++){
		cin >> b[i];	
	}
	long long int power = 1;
	long long int temp = 2;
	long long int ans = 0;
	for(int i = 0; i < 31; i++){
		for(int j = 0; j < n; j++){
			b1[j] = b[j]%temp;
		}
		sort(b1, b1+n);
		int ans1 = 0;
		for(int j = 0; j < n; j++){
			int x = a[j]%temp;
			int a1 = range(power-x, temp-x);
			a1 += range(3*power-x, temp*2-x);
			a1 %= 2;
			ans1 += a1;
		}
		ans1 %= 2;
		ans += ans1*(power);
		power *= 2;
		temp *= 2;	
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int main () {
  int n;
  cin >> n;
  int a[2][n];
  rep(i,2)rep(j,n) cin >> a[i][j];

  int ans = 0;
  rep(i,n) {
    int s = 0;
    for (int j = 0; j <= i; ++j) {
      s += a[0][j];
    }
    for (int j = i; j < n; ++j) {
      s += a[1][j];
    }
    ans = max(ans, s);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
def d(K):
    res=0
    for i in range(1,K+1):
        if K%i==0:
            res+=1
    return res

N=int(input())
ans=0
for i in range(1,N+1):
    if i%2==0:
        continue
    if d(i)==8:
        ans+=1
print(ans)


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
    long L,R,d,n=0;
    cin >> L>>R>>d;
    for(int i=L;i<R+1;i++){
        if(i%d==0){
            n++;
        }
    }
    cout <<n;
}

Measured memory_bytes: 3580
/*
edit : Le Duy Dat
team : THree Wolves
Task:
Link:
*/
#include <bits/stdc++.h>

#define f0(i,a,b) for(int i= a; i<= b; ++i)
#define f1(i,a,b) for(int i= a; i>= b; --i)
#define DEBUG(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("XAUCON.INP", "r", stdin)
#define OUTPUT      freopen("XAUCON.OUT", "w", stdout)
using namespace std;
const int base=1e9+7;
typedef pair<int, int> ii;
typedef long long ll;
/*

 End of Template

*/

/* Action  */
ll s[5];
void Solves(){
	ll n,m,k;
	cin>>n>>m>>k;
	for(int i = 1 ;i <= n ; i ++){
		for(int j = 1 ; j <= m ; j ++){
			 s[1] = i*j;
			 s[2] = (n-i) * j;
			 s[3] = i * (m-j);
			 s[4] = (n-i) * (m-j);
			for(int q = 1 ;q <= 4 ; q++){
				for(int p = q + 1 ; p <= 4 ; p ++){
					if(s[q] + s[p] == k){
						cout<<"Yes";
//						DEBUG(i);
//						DEBUG(j);
//						DEBUG(p);
//						DEBUG(q);
						return;
					}
				}
			}
			
		}
	}
	
	cout<<"No";
}
int main(){
	#ifdef LOCAL
    	INPUT;
        OUTPUT;
    #endif
	Solves();    
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		int L=sc.nextInt();
      int sum=0;
      for(int i=1;i<N+1;i++){
        sum+=i+L-1;
      }
      if(L>=0){
      sum-=L;
      }else if(N>Math.abs(L)){
        sum=sum;
      }else{
      sum+=Math.abs(N+L-1);
      }
      System.out.println(sum);
	}
}

Measured memory_bytes: 20820
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cmath>

using namespace std;

unsigned long long pow(int a, int n, int m)
{
    if (n == 0)
    {
        return 1;
    }
    if (n % 2 == 0)
    {
        unsigned long long t = pow(a, n / 2, m);
        return (t * t) % m;
    }
    return (a * pow(a, n - 1, m)) % m;
}

int comb(int n, int k, int m)
{
    unsigned long long num = 1;
    for (int i = 0; i < k; i++)
    {
        num = (num * (n - i)) % m;
    }
    unsigned long long deno = 1;
    for (int i = 1; i <= k; i++)
    {
        deno = (deno * i) % m;
    }
    return (num * pow(deno, m - 2, m)) % m;
}

int main()
{
    int n, a, b;
    int m = 1e9 + 7;
    cin >> n >> a >> b;

    int ans = pow(2, n, m);
    ans = (ans + m - 1) % m;
    ans = (ans + m - comb(n, a, m)) % m;
    ans = (ans + m - comb(n, b, m)) % m;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <queue>
#include <map>
using namespace std;

#define max_n 10000
#define max_m 1000
#define max_w 10000
#define max_h 1000
#define INF 1000000000

typedef long long lint;


    
    
int main()
{
    char n;
    cin>>n;
    if(n=='a'||n=='i'||n=='u'||n=='e'||n=='o'){
        cout<<"vowel"<<endl;
    }else{
        cout<<"consonant"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    int r, g, b, n;
    cin >> r >> g >> b >> n;
    vector<int> v;
    v.push_back(r);
    v.push_back(g);
    v.push_back(b);
    sort(v.begin(), v.end(), greater<int>());
    long long cnt = 0;
    for (int i=n/v[0]; i>=0; i--) {
        for (int j=(n-i*v[0])/v[1]; j>=0; j--) {
            if ((n-i*v[0]-j*v[1])%v[2] == 0) cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int N;
    cin >> N;

    vector<int> A(N);
    set<int> S;

    for(int i = 0; i < N ; i++)
    {
        cin >> A.at(i);
        S.insert(A.at(i));
    }

    if(S.size() == N)
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }

    return 0;
}

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

using namespace std;

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

    int n;
    list<int> l;
    cin >> n;

    while (n--) {
        int tmp;
        cin >> tmp;
        n & 1 ? l.push_back(tmp) : l.push_front(tmp);
    }

    for (int x : l)
        cout << x << " ";
    cout << "\n";

    return 0;
}

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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, init, n) for(int i = init; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define fi first
#define se second

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

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

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

    int a, b;
    cin >> a >> b;

    cout << (a + b) / 2 << endl;
    
    return 0;
}


Measured memory_bytes: 3144