akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int N, K;
    cin >> N >> K;
    int N2 = N - 2;
    if (K > ((N2+1)*N2 / 2))
        cout << -1 << endl;
    else {
        int rem = ((N2+1)*N2 / 2) - K;
        set<pair<int, int>> s;
        for(int i = 2; i <= N; i++) {
            s.insert({1, i});
        }
        if (rem == 0) {
            cout << s.size() << endl;
            for(auto& p: s) {
                cout << p.first << " " << p.second << endl;
            }
            return 0;
        }
        for(int i = 2; i <= N; i++)
            for(int j = i+1; j <= N; j++) {
                s.insert({i, j});
                rem--;
                if (rem == 0) {
                    cout << s.size() << endl;
                    for(auto& p: s) {
                        cout << p.first << " " << p.second << endl;
                    }
                    return 0;
                }
            }
    }
    return 0;
}



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

using namespace std;

typedef long long ll;
typedef long double ld;

#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(),v.end()

const int maxn = 1e5 + 100;
const ll inf = 2e18, mod = 1e9 + 7;

int n, m, color[maxn], ql, qr, q[maxn];
vector<int> graph[maxn], rgraph[maxn], pool, order;
bool mark[maxn], visited[maxn];
ll ans, cnt[3];

void getPool(int u)
{
	mark[u] = true;
	for (int i : graph[u])
		if (!mark[i])
			getPool(i);
	for (int i : rgraph[u])
		if (!mark[i])
			getPool(i);
	pool.pb(u);
}

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

	memset(color, -1, sizeof(color));

	cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		int u, v;
		cin >> u >> v;
		graph[--u].pb(--v);
		rgraph[v].pb(u);
	}

	for (int vert = 0; vert < n; vert++)
		if (!mark[vert])
		{
			pool.clear();

			getPool(vert);

			ql = qr = 0;
			q[qr++] = pool[0];
			color[pool[0]] = 0;
			while (qr - ql)
			{
				int now = q[ql++];
				for (int i : graph[now])
					if (color[i] == -1)
						q[qr++] = i, color[i] = (color[now] + 1) % 3;
				for (int i : rgraph[now])
					if (color[i] == -1)
						q[qr++] = i, color[i] = (color[now] + 2) % 3;
			}

			bool okay = true;
			for (int i : pool)
				for (int j : graph[i])
					okay &= (color[j] == (color[i] + 1) % 3);

			memset(cnt, 0, sizeof(cnt));
			for (int i : pool)
				cnt[color[i]]++;

			if (okay)
			{
				if (*min_element(cnt, cnt + 3))
					ans += cnt[0] * cnt[1] + cnt[1] * cnt[2] + cnt[2] * cnt[0];
				else
					for (int i : pool)
						ans += graph[i].size();
			}
			else
				ans += (ll)pool.size() * pool.size();
		}
	cout << ans << endl;
}



Measured memory_bytes: 17276
#include<bits/stdc++.h>
#define INF 2000000000
#define int long long int
#define MOD 1000000007
#define pb push_back
#define cin1(n) (cin >> n)
#define cin2(a,b) (cin >> a >> b)
#define cin3(a,b,c) (cin >> a >> b >> c)
#define cout(n) (cout << n << endl)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define fr first 
#define sc second 
#define EPS (1e-10)

using namespace std;

typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef vector<pair<int,int>> vpii;
typedef vector<string> vs;
typedef vector<vector<string>> vss;
typedef pair<int,int> pii;

int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
int n,m;
int a,b;
int p,q;


signed main() {
	
	int n,k; cin2(n,k);

	vpii num(n);

	int cnt = 0;
	for (int i = 0; i < n; i++) {
		cin >> num[i].fr >> num[i].sc;
	}

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

	for (int i = 0; i < n; i++) {
		cnt += num[i].sc;
		if (cnt >= k) {
			cout(num[i].fr);
			return 0;
		}
	}

	return 0;
}





Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(begin, end) for (i=begin;i<end;i++)
#define repj(begin, end) for (j=begin;j<end;j++)
#define init(arr, end, val) for (i=0;i<end;i++) arr[i] = val;
#define printint(i0, i1) printf("%d %d\n", i0, i1)

using namespace std;
typedef long long int ll;
const int inf = 1000000000;
const int mod = 1000000007;
const int nil = -1;
int i, n, x, y, ans;
int a[1000];

int main() {
    scanf(" %d %d", &x, &y);
    if (y%2 != 0) {
        printf("No\n");
        exit(0);
    }
    int b = y / 2 - x;
    if (b < 0 || b > x) {
        printf("No\n");
    } else {
        printf("Yes\n");
    }
}

Measured memory_bytes: 3756
#include<iostream>
#include<cmath>
#include<string.h>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
using namespace std;

int n;
int a[311][311];
int b[311][311];
int INF=0x3f3f3f3f;
bool ok;
long long ans;


int main()
{
    int i,j,k;
    
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            scanf("%d",&a[i][j]);
        }
    }
    
    ok=1;
    
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            if(a[i][j]!=a[j][i])
            {
                ok=0;
            }
        }
    }
    
    memset(b,0,sizeof(b));
    for(k=1;k<=n;k++)
    {
        for(i=1;i<=n;i++)
        {
            for(j=1;j<=n;j++)
            {
                if(a[i][k]+a[k][j]>a[i][j])
                {
                    
                }
                else if(a[i][k]+a[k][j]==a[i][j])
                {
                    if(i!=k && j!=k)
                    {
                        b[i][j]=INF;
                    }
                }
                else
                {
                    ok=0;
                }
            }
        }
    }
    
    
    if(ok==0)
    {
        cout<<-1<<endl;
    }
    else
    {
        ans=0;
        for(i=1;i<=n;i++)
        {
            for(j=i+1;j<=n;j++)
            {
                if(b[i][j]!=INF)
                {
                    ans+=a[i][j];
                }
            }
        }
        cout<<ans<<endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#define size 100
#define p (int)(1e9 + 7)

int main(){
	int i;
	long long int K[size], L1[size], L2[size], L3[size];
	long long int n;
	scanf("%lld", &n);

	for(i = 0; n != 0; i++){
		K[i] = n;
		n = (n-1)/2;
	}
	K[i]  = 1;
	L1[i] = 1;
	L2[i] = 1;
	L3[i] = 0;
	i--;

	for(; i >= 0; i--){
		if(K[i] % 2 == 0){
			K[i] = (3*K[i + 1] + L1[i + 1])%p;
			L1[i] = L1[i + 1];
			L2[i] = (L1[i + 1] + L2[i + 1])%p;
			L3[i] = L2[i + 1];
		}
		else{
			K[i] = (3*K[i + 1] - L2[i + 1] + p)%p;
			L1[i] = (L1[i + 1] + L2[i + 1])%p;
			L2[i] = L2[i + 1];
			L3[i] = (L2[i + 1] + L3[i + 1])%p;
		}
	}
	printf("%lld\n", K[0]);
	return 0;
}

Measured memory_bytes: 128
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let w = read::<i64>();
  let a = read::<i64>();
  let b = read::<i64>();

  println!("{}", max(max(0, b - (w + a)), max(0, a - (w + b))));
}



Measured memory_bytes: 4352
N, M = map(int, input().split())
A = list(map(int, input().split())) 

sortedA = sorted(A, reverse=True)

AA = sum(A)
de = AA/(4*M)
picA = sortedA[0:M]


if (picA[-1] < de):
  print("No")
  
else:
  print("Yes")

Measured memory_bytes: 3064
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n = i()
k = i()
x = i()
y = i()

if k <= n:
	print(k*x + (n-k)*y)
else:
	print(n*x) 

Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
	double a, b, h, m;
	double PI = acos(-1.0);
	cin >> a >> b >> h >> m;
	double t = h * 30.0 + 0.5 * m - 6.0 * m;
	double ans = sqrt(a * a + b * b - 2.0 * a * b * cos(t / 180.0 * PI));
	printf("%.15f\n", ans);
}

Measured memory_bytes: 4216
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define for1(i, m, n) for(int i = m;i < n;i++)
#define ll long long
#define endl '\n'
using namespace std;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int move[4] = {};
    rep(i, s.size()) {
        if (s[i] == 'N') {
            move[0]++;
        }
        if (s[i] == 'S') {
            move[1]++;
        }
        if (s[i] == 'E') {
            move[2]++;
        }
        if (s[i] == 'W') {
            move[3]++;
        }
    }
    bool is_x0 = false, is_y0 = false;
    if ((move[0] > 0 && move[1] > 0) || (move[0] == 0 && move[1] == 0)) {
        is_y0 = true;
    }
    if ((move[2] > 0 && move[3] > 0) || (move[2] == 0 && move[3] == 0)) {
        is_x0 = true;
    }
    if (is_x0 && is_y0) {
        puts("Yes");
    } else {
        puts("No");
    }
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
char s1[3],s2[3];
scanf("%s",s1);
scanf("%s",s2);
if(s1[0] == s2[2] && s1[1] == s2[1] && s1[2] == s2[0]) printf("YES");
else printf("NO");
return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
int main() {
	vector<long long>Fib(45);
	Fib.at(0) = 1;
	Fib.at(1) = 1;
	for (int i = 2; i < 45; i++) {
		Fib.at(i) = Fib.at(i - 2) + Fib.at(i - 1);
	}
	int N;
	cin >> N;
	cout << Fib.at(N) << endl;
}



Measured memory_bytes: 3116
#include<iostream>
#include<cstdio>
#include<iomanip>

#define PI 3.14159265359
using namespace std;
int main(){
double a;
cin >> a;

cout << fixed << setprecision(6) << a*a*PI ;
cout << " ";
cout << fixed << setprecision(6) << a*PI*2.0 <<endl;
return 0;
}




Measured memory_bytes: 3288
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <numeric>
using namespace std;
using llong = long long;

const llong INF = 1ll << 60ll;
llong n;
llong x, y;
llong ta[45];
llong tb[45];
llong tc[45];
llong dp[45][405][405];

int main() {
    for (int i = 0; i < 45; i++) {
        for (int j = 0; j < 405; j++) {
            for (int k = 0; k < 405; k++) {
                if (j == 0 && k == 0) dp[i][j][k] = 0;
                else dp[i][j][k] = INF;
            }
        }
    }

    cin >> n >> x >> y;
    for (int i = 1; i <= n; i++) {
        cin >> ta[i] >> tb[i] >> tc[i];
    }

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= 400; j++) {
            for (int k = 1; k <= 400; k++) {
                dp[i][j][k] = dp[i - 1][j][k];
                if (j >= ta[i] && k >= tb[i] && dp[i - 1][j - ta[i]][k - tb[i]] != INF) {
                    dp[i][j][k] = min(dp[i][j][k], dp[i - 1][j - ta[i]][k - tb[i]] + tc[i]);
                }
            }
        }
    }

    llong ans = INF;
    llong tmpx = x;
    llong tmpy = y;
    while (tmpx <= 400 && tmpy <= 400) {
        ans = min(ans, dp[n][tmpx][tmpy]);
        tmpx += x;
        tmpy += y;
    }

    if (ans == INF) {
        cout << -1 << endl;
    }
    else {
        cout << ans << endl;
    }
    
    return 0;
}


Measured memory_bytes: 57984
# -*- coding: utf-8 -*-
"""
Created on Sun Sep 13 19:51:37 2020

@author: liang
"""

import math

key = 10**9 + 7

n, a, b = map(int,input().split())

ans = 1
tmp = 2
N = math.ceil(math.log2(n))

#繰り返し二乗法
for i in range(N+1):
    if n>>i&1 == 1:
        #print(i,tmp)
        ans *= tmp
    tmp *= tmp
    tmp %= key
    ans %= key
ans -= 1
#print("1",ans)

def comb(r):
    #permutation
    perm = 1
    for i in range(0,r):
        perm *= n - i
        perm %= key
    
    #factorial
    fact = 1
    for i in range(1,r+1):
        fact *= i
        fact %= key
    
    ans = 1
    tmp = fact
    p = key -2
    N = math.ceil(math.log2(p))
    #繰り返し二乗法
    for i in range(N):
        if  p >>i&1 == 1:
            #print(i,tmp)
            ans *= tmp
        tmp *= tmp
        tmp %= key
        ans %= key
    ans *= perm
    ans %= key
    return ans

ans -= comb(a)
ans -= comb(b)
ans %= key
#print("2",comb(a))
#print("3",comb(b))
print(ans)

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

int main(){
  int n;
  cin >> n;
  vector<long long> a(n+1);
  a.at(0)=0;
  for(int i=1;i<n+1;i++){
    int q;
    cin >> q;
    a.at(i)=a.at(i-1)+q;
  }
  
  sort(a.begin(),a.end());
  
  long long ans=0;
  long long e=1;
  for(int i=1;i<n+1;i++){
    if(a.at(i-1)==a.at(i)){e++;}
    if(a.at(i-1)!=a.at(i) && e>=2){ans+=e*(e-1)/2;
                                  e=1;}
    if(e>=2 && i==n){ans+=e*(e-1)/2;}
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
from collections import defaultdict

import sys
sys.setrecursionlimit(10**6)
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    n,m=mis()
    h=lmis()
    cnt=0
    tlis=defaultdict(list)
    for _ in range(m):
        a,b=mis()
        tlis[a].append(b)
        tlis[b].append(a)
    lis=sorted(tlis.items())
    high=0
    for i in range(1,n+1):
        cnt+=1
        if len(tlis[i])==0:
            continue
        high=h[i-1]
        for j in tlis[i]:
            if h[j-1]>=high:
                cnt-=1
                break

    print(cnt)




if __name__ == "__main__":
    main()

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

int main(){
   int n,m; cin>>n>>m;
   vector<int> l(m);
   vector<int> r(m);
   rep(i,m) cin>>l[i]>>r[i];
   int maxl=l[0];
   int minr=r[0];
   rep(i,m){
      if(l[i]>maxl) maxl=l[i];
      if(r[i]<minr) minr=r[i];
   }
   if(maxl<=minr) cout<<minr-maxl+1<<endl;
   else cout<<0<<endl;
   return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <stack>
#include <map>
using namespace std;
using ll=long long;

#include <list>

template<class T>
class union_find {
  public:
    struct node {
      node *parent = nullptr;
      T data;
    };
    union_find() : _nodes() {}
    node *add(T a) {
      node tmp; tmp.data = a;
      _nodes.push_back(tmp);
      node *ret = &_nodes.back();
      return ret;
    }
    void union_(node *a, node *b) {
      node *ra=a,*rb=b;
      std::list<node *> na,nb;
      while(ra->parent!=nullptr) na.push_back(ra), ra = ra->parent;
      while(rb->parent!=nullptr) nb.push_back(rb), rb = rb->parent;
      for(auto *p: na) p->parent=ra;
      for(auto *p: nb) p->parent=rb;
      if(ra!=rb) {
        rb->parent = ra;
      }
    }
    bool find(node *a, node *b) {
      node *ra=a,*rb=b;
      std::list<node *> na,nb;
      while(ra->parent!=nullptr) na.push_back(ra), ra = ra->parent;
      while(rb->parent!=nullptr) nb.push_back(rb), rb = rb->parent;
      for(auto *p: na) p->parent=ra;
      for(auto *p: nb) p->parent=rb;
      return ra==rb;
    }
    std::list<node *> roots() {
      std::list<node *> rts;
      for(auto p: _nodes) {
        if (p.parent == nullptr) rts.push_back(&p);
      }
      return rts;
    }
  private:
    std::list<node> _nodes;
};

int main() {
  int N,M;cin>>N>>M;
  vector<int> X(M),Y(M),Z(M);
  union_find<int> tree;
  map<int, union_find<int>::node *> tnode;
  for(int i=0;i<N;++i) {
    tnode[i] = tree.add(i);
  }
  for(int i=0;i<M;++i) {
    cin>>X[i]>>Y[i]>>Z[i];
    X[i]--;Y[i]--;
    tree.union_(tnode[X[i]],tnode[Y[i]]);
  }
  auto roots = tree.roots();
  int max_group = roots.size();
  cout << max_group << endl;
}



Measured memory_bytes: 15488
#include<iostream>
using namespace std;
int main(){
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    if(A+B>C+D){
        cout<<"Left"<<endl;
    }
    if(A+B==C+D){
        cout<<"Balanced"<<endl;
    }
    if(A+B<C+D){
        cout<<"Right"<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define chmin(x,y) if(x>y)x=y
#define chmax(x,y) if(x<y)x=y
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const ll inf=100100100100;
const int Inf=1001001001;
const int mod=1000000007;
const double pi=3.141592653589793;

vvi from;
vi dis;
vector<bool> visited,calc;
int dfs(int i){
    if(visited[i]){
        if(!calc[i])return -1; //閉路がある
        return dis[i];
    }
    visited[i]=true;
    dis[i]=0;
    for(int x:from[i]){
        int res=dfs(x);
        if(res==-1)return -1;
        chmax(dis[i],res+1);
    }
    calc[i]=true;
    return dis[i];
}

int main(){
    ll n;cin>>n;
    ll m=n*(n-1)/2;
    vvi v(n,vi(n-1));
  	rep(i,n)rep(j,n-1)cin>>v[i][j];
    from=vvi(m);
    dis=vi(m);
    visited=vector<bool>(m);
    calc=vector<bool>(m);
  	vvi id(n,vi(n-1));
  	int k=0;
  	rep(i,n)rep(j,i)id[i][j]=k++;
    rep(i,n){
        rep(j,n-2){
            ll b=v[i][j+1]-1,c=v[i][j]-1;
            from[id[max(i,b)][min(i,b)]].pb(id[max(i,c)][min(i,c)]);
        }
    }
  	ll ans=0;
    rep(i,m){
        int ret=dfs(i);
        if(ret==-1){
            cout<<-1<<endl;
            return 0;
        }
        chmax(ans,ret);
    }
    cout<<ans+1<<endl;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll D, N;
    cin >> D >> N;

    if(D == 0) {
        if(N < 100) PR(N);
        else PR(101);
    }
    else if(D == 1) {
        if(N < 100) PR(100*N);
        else PR(10100);
    }
    else {
        if(N < 100) PR(10000*N);
        else PR(1010000);
    }

    return 0;
}

/*

*/

Measured memory_bytes: 3636
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<array>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

#ifdef ONLINE_JUDGE
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#define int128 __int128
#else
#define int128 long long
#endif

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(nullptr));

ll mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}
	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}
	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

int const maxn = 3e5 + 5;

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll a, b, c; cin >> a >> b >> c;
	swap(a, b);
	swap(a, c);
	cout << a << " " << b << " " << c << endl;

	return 0;
}

/*


*/

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <type_traits>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int h, w; cin >> h >> w;
    vector<vector<char>> a(h, vector<char> (w));
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            cin >> a[i][j];
        }
    }

    int right = 0;
    for(int i = 0; i < h; i++) {
        bool flag = true;
        for(int j = 0; j < w; j++) {
            if(a[i][j] == '#') {
                if(flag && j != right) {
                    cout << "Impossible" << endl;
                    return 0;
                } else if(!flag && j < right){
                  cout << "Impossible" << endl;
                  return 0;
                } else {
                    right = j;
                    flag = false;
                }
            }
        }
    }

    cout << "Possible" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val A, B, C, D = Integer.parseInt(sc.next())

    println(if (A + B == C + D) {"Balanced"} else if (A + B > C + D) {"Left"} else if (A + B < C + D) {"Right"})
  }
}

Measured memory_bytes: 25428
#include <iostream>
#include <string>

std::string solve(int a, int b) {
	if (a > 0) return "Positive";
	if (a <= 0 && b >= 0) return "Zero";
	return (b - a + 1) % 2 == 0 ? "Positive" : "Negative";
}

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

	int a, b;
	std::cin >> a >> b;
	std::cout << solve(a, b) << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


ll a[101010];
struct UnionFind{
   vector<int> par;
   vector<ll> sum;
   UnionFind(int n):par(n,-1),sum(n){
       rep(i,n)sum[i]=a[i];
   }
   int find(int x){
       if(par[x]<0)return x;
       return par[x]=find(par[x]);
   }
   bool unite(int x,int y){
       x=find(x);
       y=find(y);
       if(x==y)return false;
       if(par[x]>par[y]){
           par[y]+=par[x];
           sum[y]+=sum[x];
           par[x]=y;
       }
       else{
           par[x]+=par[y];
           sum[x]+=sum[y];
           par[y]=x;
       }
       return true;
   }

   bool same(int x,int y){
       return find(x)==find(y);
   }
   ll get(int x){
       return sum[find(x)];
   }
};

vector<pint> v[101010];
bool used[101010];
int ans;

void dfs(int x, int M){
    if(used[x])return;
    used[x]=true;
    for(auto to:v[x]){
        if(to.second>M)continue;
        ++ans;
        if(used[to.first])continue;
        dfs(to.first,M);
    }
}
int main(){
    int n,m;
    cin>>n>>m;
    rep(i,n)cin>>a[i];
    int l[m],r[m],w[m];
    rep(i,m){
        cin>>l[i]>>r[i]>>w[i];
        --l[i];--r[i];
        v[l[i]].emplace_back(r[i],w[i]);
        v[r[i]].emplace_back(l[i],w[i]);
    }
    vector<int> ord(m);
    iota(ord.begin(),ord.end(),0);
    sort(ord.begin(),ord.end(),[&](int x,int y){
        return w[x]<w[y];
    });
    UnionFind uf(n);
    vector<int> ok;
    for(auto idx:ord){
        uf.unite(l[idx],r[idx]);
        if(uf.get(l[idx])>=w[idx])ok.push_back(idx);
    }
    reverse(ok.begin(),ok.end());
    for(auto idx : ok){
        dfs(l[idx],w[idx]);
    }
    cout<<m-ans/2<<endl;
    return 0;
}

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

int main(void) {
	int N; cin >> N;
	int i, a[N], b[N], sum = 0;
	
	for (i = 0; i < N; i++) {
		cin >> a[i];
		cin >> b[i];
		sum =sum + b[i] - a[i] + 1;
	}

	cout << sum << endl;

	return 0;
}

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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int idx = -1;
		for(int i=0;i<N;i++) if(A[i] == 1) idx = i;
		
		int min = N;
		for(int i=0;i<K;i++){
			int r = idx + i;
			int l = r - K + 1;
			if(!InRange(l,0,N) || !InRange(r,0,N)) continue;
			int cnt = 1;
//Console.WriteLine("{0} {1}",l,r);
			cnt += (l + (K - 2))/ (K - 1);
			cnt += ((N - 1 - r) +(K - 2)) / (K - 1);
//Console.WriteLine(cnt);
			min = Math.Min(cnt, min);
			
		}
		Console.WriteLine(min);
		
	}
	
	bool InRange(int t, int l, int r){
		return l <= t && t < r;
	}
	
	int N,K;
	int[] A;
	public Sol(){
		var d = ria();
		N = d[0]; K = d[1];
		A = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 18016
object Main {
  def main(args: Array[String]): Unit = {
    val in =  new java.util.Scanner(System.in)
    rec(in)
  }
  def rec(in:java.util.Scanner):Unit ={
    val a = in.nextInt
    val b = in.nextInt
    if(a ==0 && b == 0) return
    for(i <- 1 to a){
      for(j <- 1 to b){
        print("#")
      }
      println("")
    }
    println("")
    return rec(in)
  }
}

Measured memory_bytes: 53140
#include<iostream>
using namespace std;
int main()
{
	int n;
	int a, b, c;
	int ans = 0;
	bool flag = true;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a >> b >> c;
		ans = 0;
		while (flag){
			if (a > 0 && b > 0 && c > 0){
				ans++;
				a--;;
				b--;
				c--;
				flag = false;
			}
			else if (a > 1 && b > 0){
				a -= 2;
				b--;
				ans++;
				flag = false;
			}
			else if (a >=3){
				a -= 3;
				ans++;
				flag = false;
			}
			if (!flag){
				flag = true;
			}
			else{
				break;
			}
		}
		cout << ans << endl;
	}
}

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

int main()
{
    int N;
    cin >> N;
    std::vector<int> v(N,0);
    for(int i=1; i<N; i++){
        int A;  cin >> A;
        v[A-1]++;
    }
    for(int i=0; i<=N-1; i++){
        cout << v[i] << '\n';
    }
}

Measured memory_bytes: 4056
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	while(true){
		vector<pair<char,int>> P(5);
		P[0].first='A';
		P[0].second=in();
		P[0].second+=in();
		if(!P[0].second) break;

		P[1].first='B';
		P[1].second=in();
		P[1].second+=in();
		P[2].first='C';
		P[2].second=in();
		P[2].second+=in();
		P[3].first='D';
		P[3].second=in();
		P[3].second+=in();
		P[4].first='E';
		P[4].second=in();
		P[4].second+=in();

		sort(ALL(P),PAIRCOMP(second,>));
		out(P[0].first,P[0].second);
	}
	return 0;
}



Measured memory_bytes: 3056
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int A = 0;
        for(int i = 0; i < 3; i++){
            A  += sc.nextInt();
        }
        if(A <= 21){
            System.out.println("win");
        }else{
            System.out.println("bust");
        }
    }
}

Measured memory_bytes: 23892
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.valueOf(sc.next());
		String op = sc.next();
		int b = Integer.valueOf(sc.next());
		int ans = 0;
		if (op.equals("+"))
			ans = a + b;
		if (op.equals("-"))
			ans = a - b;
		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 21844
io = STDIN
hash=Hash.new{|h,k|h[k]=0}
n,m=io.gets.chomp.split.map(&:to_i)
m.times do
  a,b=io.gets.chomp.split.map(&:to_i)
  hash[a]+=1
  hash[b]+=1
end
(1..n).each {|n|puts hash[n]}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)

using namespace std;

typedef long long ll;
#define Fizz 4
#define Buzz 4
#define FizzBuzz 8

inline string lltos(ll v) { stringstream ss; ss << v; return ss.str(); }
ll pw10[20];

ll calcLength(ll n) {
  ll p3 = 0, p5 = 0, p15 = 0, sum = 0;
  string ns = lltos(n);
  REP(i,1,(int)ns.size()+1) {
    ll maxi = pw10[i] - 1LL;
    if( maxi > n ) maxi = n;
    ll n3 = maxi / 3LL - p3;
    ll n5 = maxi / 5LL - p5;
    ll n15 = maxi / 15LL - p15;
    ll other = maxi - pw10[i-1] + 1LL;
    ll cost = ( other - n3 - n5 + n15 ) * (ll)i;
    cost += ( n3 - n15 ) * Fizz;
    cost += ( n5 - n15 ) * Buzz;
    cost += n15 * FizzBuzz;
    sum += cost;
    p3 += n3, p5 += n5, p15 += n15;
  }
  return sum;
}

int main() {
  pw10[0] = 1;
  REP(i,1,20) pw10[i] = pw10[i-1] * 10LL;
  ll s;
  cin >> s;
  ll L = 0, R = 1000000000000000000LL;
  while( R - L ) {
    ll M = ( L + R ) / 2LL;
    if( calcLength(M) <= s ) L = M + 1LL;
    else                     R = M;
  }
  ll lower = L - 1LL;
  string answer = "";
  for(ll i=lower;i<lower+20LL;++i) {
    string tmp = "";
    if( i % 3LL == 0LL && i % 5LL == 0LL ) tmp = "FizzBuzz";
    else if( i % 3LL == 0LL )              tmp = "Fizz";
    else if( i % 5LL == 0LL )              tmp = "Buzz";
    else                                   tmp = lltos(i);
    if( i == lower ) tmp = tmp[(int)tmp.size()-1];
    answer += tmp;
  }
  ll ptr = calcLength(lower);
  rep(i,(int)answer.size()) {
    if( s <= ptr+(ll)i && ptr+(ll)i < s + 20LL ) printf("%c",answer[i]);
  } puts("");
  return 0;
}

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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    vector<string> s(3);
    REP(i, 3) {
        cin >> s[i];
    }
    REP(i, 3) {
        cout << s[i][i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val aList = (1..m).map { readLine()!!.toInt() }

    val isSafeSteps = (0..n).map { true }.toMutableList().toTypedArray()
    aList.forEach { i: Int -> isSafeSteps[i] = false }

    val sumList = (0..n + 1).map { 0.toLong() }.toMutableList()
    sumList[0] = 1

    for (i in 0..n) {
        if (isSafeSteps[i]) {
            if (i + 1 < n + 1) {
                sumList[i + 1] += sumList[i]
                sumList[i + 1] = sumList[i + 1] % 1000000007
            }
            if (i + 2 < n + 1) {
                sumList[i + 2] += sumList[i]
                sumList[i + 2] = sumList[i + 2] % 1000000007
            }
        }
    }

    println(sumList[n])
}


Measured memory_bytes: 45884
n = int(input())
A = list(map(int, input().split()))
if n % 2 == 0:
    l = n ** 2
else:
    l = (n - 1) * (n + 1)
if sum(A) == l // 2:
    print(2 ** (n // 2) % (10 ** 9 + 7))
else:
    print(0)


Measured memory_bytes: 13880
#include <cstdio>
typedef long long int64;
static const int MAXN = 52;

int n, p;
int a[MAXN];

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

    bool has_odd = false;
    for (int i = 0; i < n; ++i) if (a[i] % 2 == 1) has_odd = true;
    if (has_odd) {
        printf("%lld\n", 1LL << (n - 1));
    } else {
        if (p == 0) printf("%lld\n", 1LL << n);
        else puts("0");
    }

    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<set>
using namespace std;
typedef long long ll;
int maxn = 1e8;
int T;
set<int> s;
int main() {
   int T;
   int ans=0;
   int a,b;
   cin>>T;

   while(T--)
   {
       cin>>a;
       if(s.count(a)==0)
       s.insert(a);
       else
       s.erase(s.find(a));
   }
   cout<<s.size()<<endl;
   return 0;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
#include <algorithm>
#include <queue>
using namespace std;
int main(){
	int N, K; 
	cin >> N >> K; 
	int H[100010] = {}; 
	for(int i = 1; i <= N; i++){
		cin >> H[i]; 
	}
	int dp[100010] = {}; 
	for(int i = 2; i <= N; i++){
		dp[i] = 1145141919; 
		for(int j = 1; j <= min(K, i-1); j++){
			dp[i] = min(dp[i], dp[i - j] + abs(H[i] - H[i - j])); 		
		}
	}
	cout << dp[N] << endl; 
}

Measured memory_bytes: 1024
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + end + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw "ArrayIndexOutOfBoundsException ‚There is no more input";}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var one = nextIntArray();
  var N = one[0];
  var K = one[1];
  var output = 0;
  for(var i = 1; i <= N; i++){
    output += Math.max(0, i - K) * Math.floor(N / i) + Math.max(0, N % i - K + 1);
  }
  if(K == 0){
    output -= N;
  }
  myout(output);
}


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

int main(){
  int N;
  cin>>N;
map<string,int> data{};
  
  for(int i=0;i<N;i++){
   string c;
    cin>>c;
    data[c]++;
  }
cout<<data.size()<<endl;
}

Measured memory_bytes: 19232
#include <iostream> // includes cin to read from stdin and cout to write to stdout
using namespace std; // since cin and cout are both in namespace std, this saves some text

int main()
{
    int A, B;
    cin >> A >> B;
    
    int pre = 0;
    for (int i = 1; i <= 999; ++i)
    {
        int diffA = pre - A;
        int cur = i * (i + 1) * 0.5;
        int diffB = cur - B;
        
        if (diffA == diffB)
        {
            cout << diffA << endl;
            break;
        }
        pre = cur;
    }
    
    return 0;
}

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


signed main(){
    ll n;
    string ans = "";
    cin>>n;

    while(n>0){
        n-=1;
        ans += (n%26)+'a';
        n /= 26;
    }

    reverse(ans.begin(), ans.end());
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
import java.util.*;


public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		long T[] = new long[n];
		long A[] = new long[n];
		
		for(int i=0;i<n;i++){
		    T[i] = sc.nextInt();
		    A[i] = sc.nextInt();
		}
		
		for(int i=0;i<n-1;i++){
		    long t = T[i+1];
		    long a = A[i+1];
		    if(T[i]>T[i+1]||A[i]>A[i+1]){
		        long j = Math.max((T[i]-1)/T[i+1],(A[i]-1)/A[i+1])+1;
		        T[i+1]=t*j;
		        A[i+1]=a*j;
		    }
		}
		// 出力
		System.out.println(T[n-1] + A[n-1]);
    }
}


Measured memory_bytes: 13152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007


int main()
{
    int t=1;
    //cin>>t;
    while( t-- )
    {
        int a;

        cin>>a;
        int ans= a + a*a + a*a*a;

        cout<<ans;
    }
    return 0;
}


Measured memory_bytes: 3552
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

  int n;
  cin >> n;
  std::vector<int> w(n);
  int left = 0, right = 0;
  for (int i = 0; i < n; i++) {
    cin >> w[i];
    right += w[i];
  }
  int diff = right;

  for (int i = 0; i < n; i++) {
    left += w[i];
    right -= w[i];
    int temp = std::abs(left - right);
    diff     = std::min(diff, temp);
  }
  cout << diff << endl;

  return 0;
}


Measured memory_bytes: 888
#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 <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        Int N;
        cin >> N;
        vector<Int> X(N);
        for (int i = 0; i < N; ++i) cin >> X[i];

        Int ans = INFl;
        for (int p = 0; p <= 100; ++p) {
            Int tmp = 0;
            for (int i = 0; i < N; ++i) {
                tmp += (X[i] - p) * (X[i] - p);
            }
            chmin(ans, tmp);
        }

        cout << ans << endl;
    }

};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;
int n,vis[100005]={0};
int x,y,ans[100005]={0};
int main(){ 
    for(int i=2;i<=100000;i++){
    	if(vis[i]==0){
    		for(int j=2*i;j<=100000;j+=i){
    			vis[j]=1;
			}
		}
	}
	for(int i=2;i<=100000;i++){
		ans[i]=ans[i-1];
		if(i%2==1&&vis[i]==0&&vis[(i+1)/2]==0){
			ans[i]++;
		}
	}
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
    	scanf("%d%d",&x,&y);
    	printf("%d\n",ans[y]-ans[x-1]);
	}
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e9;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll n; cin >> n;
    vector<long long> vec(n);
    for(long long i = 0; i < n; i ++){
        cin >> vec[i];
    }
    ll flag = 1;
    ll ans = 0;
    while(flag){
        flag = 0;
        for(ll j = n-1; j > 0; j--){
            if(vec[j] < vec[j-1]){
                swap(vec[j], vec[j-1]);
                ans++;
                flag = 1;
            }
            
        }
    }
    rep(i, n){
        cout << vec[i];
        (i == n-1) ? cout << "" : cout << " ";
    }
    cout << endl;
    cout << ans << endl;
    

}


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

using namespace std;

const int INF = 0x0fffffff;

int N;
int K;

typedef pair<int, int> ii;

vector< vector<int> > M;
vector<bool> V; // visited

vector<ii> R; // range

const ii inf = make_pair(-INF, INF);
const ii fail = make_pair(INF, -INF);

ii dfs(int i) {
    if (V[i]) {
        return inf;
    }

    V[i] = true;

    for (size_t j = 0; j < M[i].size(); ++j) {
        int ni = M[i][j]; // next i

        ii rv = dfs(ni);

        if (rv == make_pair(-INF-1, INF+1)) {
            rv = inf;
        }

        if (rv == fail) {
            return fail;
        } else if (R[i] == inf){
            R[i] = rv;
        } else if (rv == inf) {
            continue;
        } else if (R[i].first % 2 != rv.first % 2) {
            return fail;
        } else if (R[i].second < rv.first) {
            return fail;
        } else if (rv.second < R[i].first) {
            return fail;
        } else {
            R[i].second = min(R[i].second, rv.second);
            R[i].first  = max(R[i].first, rv.first);
        }
    }

    if (R[i].second < R[i].first) {
        return fail;
    }

    return make_pair(R[i].first-1, R[i].second+1);
}

void dfs2(int i) {
    if (V[i]) {
        return;
    } 

    V[i] = true;

    R[i] = make_pair(R[i].first, R[i].first);
    
    for (size_t j = 0; j < M[i].size(); ++j) {
        int ni = M[i][j]; // next i
        
        if (V[ni]) {
            continue;
        }

        R[ni] = make_pair(max(R[ni].first, R[i].first-1), min(R[ni].second, R[i].second+1));

        dfs2(ni);
    }
}

int main(int argc, char* argv[]) {
    // for cin
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> N;

    M.resize(N);

    for (int i = 0; i < N; ++i) {
        M[i].clear();
    }

    for (int i = 0; i < N-1; ++i) {
        int a;
        int b;

        cin >> a >> b;
        a--;
        b--;

        M[a].push_back(b);
        M[b].push_back(a);
    }

    V.resize(N);
    fill(V.begin(), V.end(), false);

    R.resize(N);
    fill(R.begin(), R.end(), inf);

    cin >> K;

    for (int i = 0; i < K; ++i) {
        int v;
        int p;

        cin >> v >> p;
        v--;

        R[v] = make_pair(p, p);
    }

    ii rv = dfs(0);

    if (rv == fail) {
        printf("No\n");
        return 0;
    }

    printf("Yes\n");
    fill(V.begin(), V.end(), false);

    dfs2(0);

    for (int i = 0; i < N; ++i) {
        printf("%d\n", R[i].first);
    }

    return 0;
}


Measured memory_bytes: 11904
#include<bits/stdc++.h>
using namespace std;
#define RI register int
int read() {
	int q=0;char ch=' ';
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') q=q*10+ch-'0',ch=getchar();
	return q;
}
int n,js;
int main()
{
	n=read();
	for(RI i=1;i<=n;++i) js+=read()&1;
	if(js&1) puts("NO");
	else puts("YES");
	return 0;
}

Measured memory_bytes: 256