akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<queue>
using namespace std;

int main() {
	int N, u, v;
	cin>>N>>u>>v;
	vector< vector<int> >list;
	vector<int>tmplist;
	for(int i=0;i<N;++i){
		list.push_back(tmplist);
	}
	int A, B;
	for(int i=0;i<N-1;++i){
		cin>>A>>B;
		list[A-1].push_back(B-1);
		list[B-1].push_back(A-1);
	}
	/**
	// 隣接リストは完成
	for(int i=0;i<N;++i){
		for(int j=0;j<list[i].size();++j){
			cout<<list[i][j]<<' ';
		}
		cout<<endl;
	}
	**/
	
	// 端点チェック
	int endlist[N];
	for(int i=0;i<N;++i){
		if(list[i].size() == 1){
			endlist[i] = 1;
		} else {
			endlist[i] = 0;
		}
	}

	int Adist[N];
	int Bdist[N];
	for(int i=0;i<N;++i){
		Adist[i] = -1;
		Bdist[i] = -1;
	}

	// u, vから各点への最短距離を求めたい
	queue<int> que1, que2, distque1, distque2;
	que1.push(u-1);
	que2.push(v-1);
	distque1.push(0);
	distque2.push(0);
	int dist1, dist2;
	Adist[u-1] = distque1.front();
	Bdist[v-1] = distque2.front();
	int state1, state2;
	while(!que1.empty()){
		state1 = que1.front();
		que1.pop();
		dist1 = distque1.front();
		distque1.pop();
		for(int i=0;i<list[state1].size();++i){
			if(Adist[list[state1][i]] == -1){
				que1.push(list[state1][i]);
				distque1.push(dist1 + 1);
				Adist[list[state1][i]] = dist1 + 1;
			}
		}
	}
	while(!que2.empty()){
		state2 = que2.front();
		que2.pop();
		dist2 = distque2.front();
		distque2.pop();
		for(int i=0;i<list[state2].size();++i){
			if(Bdist[list[state2][i]] == -1){
				que2.push(list[state2][i]);
				distque2.push(dist2 + 1);
				Bdist[list[state2][i]] = dist2 + 1;
			}
		}
	}
	/**
	for(int i=0;i<N;++i){
		cout<<Adist[i]<<' ';
	}
	cout<<endl;
	for(int i=0;i<N;++i){
		cout<<Bdist[i]<<' ';
	}
	cout<<endl;
	**/
	int ans = 0;
	for(int i=0;i<N;++i){
		if(endlist[i] == 1){
			continue;
		} else {
			if(Adist[i] > Bdist[i]){
				continue;
			} else if((Adist[i] == Bdist[i]) && (ans == 0)) {
				ans = 1;
			} else {
				if(Bdist[i] > ans) {
					ans = Bdist[i];
				}
			}
		}
	}
	cout<<ans<<endl;
}


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

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = long.Parse(line[0]);
        var b = long.Parse(line[1]);
        var c = long.Parse(line[2]);
        Console.WriteLine((a % 2 == 0) || (b % 2 == 0) || (c % 2 == 0) ? 0 : getMin(a, b, c));
    }
    public static long getMin(long a, long b, long c)
    {
        var w = new long[3];
        w[0] = a * b;
        w[1] = b * c;
        w[2] = c * a;
        return w.Min();
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

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

const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};

const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

vector< vector<int> > Graph;
vector< int > value;





int main(int argc, const char * argv[]) {
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string a = "abcdefghijklmnopqrstuvwxyz";
    map<char,int> abc{};
    rep(i,26) abc.insert(make_pair(a[i],0));
    
    string s; cin >> s;
    
    rep(i,s.size()) abc[s[i]]++;
    
    rep(i,26){
        if(abc[ a[i] ] == 0){
            cout << a[i] << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
    
    
    
    
    
    
    
    
    
    
}



Measured memory_bytes: 512
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n,m=LI()
  l=LI()

  l.sort()
  l2=[]
  for i in range(len(l)-1):
    l2.append(l[i+1]-l[i])

  l2.sort()

  if n==1:
    return sum(l2)
  return sum(l2[:-n+1])

print(main())


Measured memory_bytes: 16636
#include <stdio.h>

int main(){
  int a, b, c, d;
  scanf("%d%d%d%d",&a, &b, &c,&d);
  if(a + b > c + d) printf("Left");
  else if (a + b == c + d) printf("Balanced");
  else printf("Right");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)

const ll MOD = 10007;
const ll HIGHINF = (ll)1e18;

int main() {
  ll a, b; cin >> a >> b;
  while (b!=0) {
    ll tmp = b;
    b = a % b;
    a = tmp;
  }
  cout << a << endl;
  return 0;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

const int MAX_N = 100005;

bool check(int s, int t, vector<bool> u, vector<int> v[MAX_N]){
	for(auto i : v[s]){
		if(u[i] == false){
			return true;
		}
	}
	for(auto i : v[t]){
		if(u[i] == false){
			return true;
		}
	}
	return false;
}

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

    vector<int> v[MAX_N];
    rep(i,m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        v[a].emplace_back(b);
        v[b].emplace_back(a);
    }

	list<int> ans;
	vector<bool> used(n,0);
	int s = 0, t = 0;
	used[0] = true;
	ans.emplace_back(0);
	while(check(s,t, used, v)){
		bool f = false;
		for(auto i : v[t]){
			if(not used[i]){
				t = i;
				used[i] = true;
				f = true;
				ans.emplace_back(i);
				break;
			}
		}
		if(f) continue;
		for(auto i : v[s]){
			if(not used[i]){
				s = i;
				used[i] = true;
				ans.emplace_front(i);
				break;
			}
		}
	}

	cout << ans.size() << endl;
	for(auto i = ans.begin(); i != ans.end(); i++){
		if(i != ans.begin()) cout << ' ';
		cout << *i + 1;
	}
	cout << endl;
}


Measured memory_bytes: 9472
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 1000000007 // //100000000 998244353 //
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll lx[4] = {0, 0, 1, -1};
ll ly[4] = {1, -1, 0, 0};
ll dx[8] = {0, 0, 1, -1, 1, -1, 1, -1};
ll dy[8] = {1, -1, 0, 0, 1, 1, -1, -1};
void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}
ll lcm(ll a, ll b) {return (a*b)/__gcd(a, b); }

void solve()
{
    vector<string> v(3);
    rep(i, 3) cin >> v[i];
    map<char, ll> mp;
    mp['a'] = 0, mp['b'] = 1, mp['c'] = 2;
    ll t = 0;
    while(true){
        if(v[t].empty()) ANS((char) (t+'A'));
        char x = v[t].front();
        v[t].erase(v[t].begin());
        t = mp[x]; //cout << x << " ";
    }
}
int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
lis1 = []
lis2 = []
lis3 = []
count = 0
for num in input().split():
    lis1.append(int(num))
for num in input().split():
    lis2.append(int(num))
for num in input().split():
    lis3.append(int(num))
if lis1[0]-lis2[0]==lis1[1]-lis2[1]==lis1[2]-lis2[2]:
    count += 1
if lis1[0]-lis3[0]==lis1[1]-lis3[1]==lis1[2]-lis3[2]:
    count += 1
if lis1[0]-lis1[1]==lis2[0]-lis2[1]==lis3[0]-lis3[1]:
    count += 1
if lis1[0]-lis1[2]==lis2[0]-lis2[2]==lis3[0]-lis3[2]:
    count += 1
if count == 4:
    print("Yes")
else:
    print("No")

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

using namespace std;
using ll = long long;

const long long INF = 1LL << 60;

ll dp[101][1000001] = {};

int main() {
    #ifdef MYLOCAL
        ifstream in("input.txt");
        cin.rdbuf(in.rdbuf());
    #endif

    int n, w; cin >> n >> w;
    vector<int> ws(n);
    vector<int> vs(n);
    for (int i = 0; i < n; ++i) {
        cin >> ws[i] >> vs[i];
    }

    for (int i = 0; i < n; ++i) {
        for(int j = 0; j <= w; ++j) {
            if (j - ws[i] >= 0) {
                dp[i+1][j] = max(dp[i + 1][j], dp[i][j - ws[i]] + vs[i]);
            }
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
        }
    }
    cout << dp[n][w] << endl;
    return 0;
}

Measured memory_bytes: 286976
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a = na()

x = 0 #+-+-
y = 0 #-+-+
xx,yy = 0,0

for i in range(n):
    xx += a[i]
    yy += a[i]
    if not i%2:
        p = 0 if xx > 0 else 1-xx
        q = 0 if yy < 0 else 1+yy
        x += p
        y += q
        xx += p
        yy -= q
    else:
        p = 0 if yy > 0 else 1-yy
        q = 0 if xx < 0 else 1+xx
        y += p
        x += q
        yy += p
        xx -= q

print(min(x,y))

Measured memory_bytes: 14340
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  int N = 0;
  cin >> N;
  vector<int>A(N);
  rep(i,N){
    cin >> A[i];
  }
  if(N % 2 == 0){
    rep(i,N/2){
      cout << A[N-1-2*i] << " ";
    }
    rep(i,N/2){
      cout << A[2*i] << " ";
    }
  }
  else{
    rep(i,N/2+1){
      cout << A[N-1-2*i] << " ";
    }
    rep(i,N/2){
      cout << A[2*i+1] << " ";
    }
  }
}

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

# define C continue;
# define D double
# define ll long long
# define ld long double
# define ull unsigned long long

# define pb push_back
# define vi vector < int >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()

# define pii pair < int , int >
# define vii vector < pii >
# define F first
# define S second
# define mp make_pair

# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
# define mod 1000000007

# define pp(n) printf("%.10f",n);
# define line cout<<"\n";

const D pie = acos(-1);
const D hpie = asin(1);
const D qpie = atan2(-1,1);
const D tpie = 2*pie;

void solve ( int test_case )
{
    int n;
    cin>>n;

    vi a ( n );


    int ans = 0;
    int temp;
    for ( int i=0 ; i<n ; i++ ) cin>>a[i];
    for ( int i=0 ; i<n ; i++ )
    {
        cin>>temp;
        ans+= max(0,a[i]-temp);
    }

    cout<<ans<<"\n";

}

int main()
{
    fast
    int t = 1;
    //cin>>t;

    for ( int i=0 ; i<t ; i++ ) solve(i);
    return 0;
}



Measured memory_bytes: 256
S=input()
S=S[::-1]

pointer=0
while 1:
  if pointer == len(S):
    print('YES')
    exit()
  if pointer >= len(S)-4:
    print('NO')
    exit()
  if S[pointer:pointer+5] in {'dream'[::-1],'erase'[::-1]}:
    pointer += 5
    continue
  elif S[pointer:pointer+6] == 'eraser'[::-1]:
    pointer += 6
    continue
  elif S[pointer:pointer+7] == 'dreamer'[::-1]:
    pointer += 7
    continue
  else:
    print('NO')
    exit()

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

using namespace std;

template <typename T>
T num_div(T x) {
  T res = 0;
  for (T i = 1; i * i <= x; i++) {
    if (x % i == 0) {
      res++;
      if (i * i != x) res++;
    }
  }
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int ans = 0;
  for (int x = 1; x <= n; x += 2) {
    if (num_div(x) == 8) ans++;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

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


int main() {
	
	ll A, B, C, D;
	cin >> A >> B >> C >> D;

	ll t = (C - 1) / B + 1;
	ll a = (A - 1) / D + 1;

	if (t <= a) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }

	system("PAUSE");
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

ll gcd(ll a, ll b);
ll power(ll n, ll k);
ll inv(ll n);
ll genfact(ll n, ll k);
ll fact(ll n);
ll nck(ll n, ll k);
#define N 100001

int parent[N];
int visited[N];
int num[N];
vector<vector<int>> edge(N, vector<int>(0));
vector<vector<int>> dame(N, vector<int>(0));
int findroot(int a){
  if (parent[a] == a)
    return a;

  int newparent = findroot(parent[a]);
  parent[a] = newparent;
  return newparent;
}


void dfs(int cur){
  if (visited[cur])
    return;

  visited[cur] = 1;
  for (int i = 0; i < edge[cur].size(); i++){
    int u = findroot(cur);
    int v = findroot(edge[cur][i]);
    if (u != v){
      parent[v] = u;
      num[u] = num[u] + num[v];
    }
    dfs(edge[cur][i]);
  }
}

int main(void){
  int n, m, k;
  cin >> n >> m >> k;
  int a, b;
  for (int i = 0; i < m; i++){
    cin >> a >> b;
    a--; b--;
    edge[a].emplace_back(b);
    edge[b].emplace_back(a);
  }
  for (int i = 0; i < k; i++){
    cin >> a >> b;
    a--; b--;
    dame[a].emplace_back(b);
    dame[b].emplace_back(a);
  }

  for (int i = 0; i < n; i++){
    parent[i] = i;
    num[i] = 1;
  }
  for (int i = 0; i < n; i++){
    dfs(i);
  }

  
  for (int i = 0; i < n; i++){
    int ret = num[findroot(i)] - 1;
    for (int j = 0; j < edge[i].size(); j++){
      if (findroot(i) == findroot(edge[i][j])){
        ret--;
      }
    }
    for (int j = 0; j < dame[i].size(); j++){
      if (findroot(i) == findroot(dame[i][j])){
        ret--;
      }
    }
    cout << ret << " ";
  }

  return 0;
}

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

ll power(ll n, ll k){
  ll res = 1;
  while(k > 0){
    if (k & 1) 
      res = res * n % MOD;
    n = n * n % MOD;
    k >>= 1;
  }
  return res;
}

ll genfact(ll n, ll k){

  ll res = 1;
  while (k >= 0){
    res = (res * (n - k)) % MOD;
    k--;
  }

  return res;
}

ll inv(ll n){
  return power(n, MOD - 2);
}

ll fact(ll n){
  return genfact(n, n - 1);
}

ll nck(ll n, ll k){
  if (k == 0)
    return 1;
  if (n <= 0)
    return 0;

  return ((genfact(n, k) % MOD) * inv(fact(k))) % MOD;
}


Measured memory_bytes: 13440
#include<bits/stdc++.h>
using namespace std;
int MAXN = 1000;
int main(){
  int N;
  int a[MAXN];
  cin >> N;
  for (int i = 0; i < N; i++){
    cin >> a[i];
  }
  int maxa = a[0];
  int mina = a[0];
  for (int i = 0; i< N; i++){
    if (maxa < a[i]) maxa = a[i];
    if (a[i] < mina) mina = a[i];
  }
  int dist;
  dist = maxa - mina;
  cout << dist << endl;
  return 0;
}

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



int c = 0;


void insertS(int *A,int n,int g){
  int i,j;
  int k;
  for( i = g ; i < n ; i++){
    j = i;
    k = A[i];
    while( 0 <= j - g){
      if( A[j-g] <= k) break;
      A[j] = A[j-g];
      j -= g;
      c++;
    }
   A[j] = k;
 }
}


int main(){
  int n;
  int i,j;
  int *A;
  int G[20];



  scanf("%d", &n);
  A = malloc(n * sizeof(int));
  for( i = 0 ; i < n ; i++ ) scanf("%d", &A[i]);

  int m = 0;
  G[0] = 0;
  while(1){
    if( n < 3*G[m]+1) break;
    G[m+1] = 3*G[m] + 1;
    m++;
 }

 for( i = m ; i > 0 ; i--) insertS(A,n,G[i]);

  printf("%d\n", m);
  for( i = m ; i >= 1 ; i-- ) printf("%d ", G[i]);
  printf("\n");
  printf("%d\n", c);

  for( i = 0 ; i < n ; i++ ) printf("%d\n", A[i]);

  return 0;
}



Measured memory_bytes: 5660
import math

n, d = map(int, input().split(" "))
x = [list(map(int, input().split(" "))) for i in range(n)]

ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        distance = 0
        for k in range(d):
            distance += (x[i][k] - x[j][k]) ** 2 
        if math.sqrt(distance).is_integer():
            ans += 1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
vector<vector<int>> adj;
int dp[100001];
int n, m;
int ans[100001];
int calc(int u, int p, int subs){
//  cout << u << ' ' << subs << endl;
  bool cc = 0;
  vector<int> chres;
  for(auto el : adj[u]){
    if(el != p){

      chres.push_back(dp[el] + 1);
      cc = 1;
    }
  }
  ans[u] = 1ll * (1 + subs) * dp[u] % m;
  if(!cc)
    return 0;
  vector<int> lsum(chres);
  vector<int> rsum(chres);
  for(int i = 1;i < lsum.size();i++){
    lsum[i] = (1ll * lsum[i] * lsum[i - 1]) % m;
  }
  for(int i = (int)rsum.size() - 2;i >= 0;i--){
    rsum[i] = (1ll * rsum[i] * rsum[i + 1]) % m;
  }
  int pp = 0;
  for(int i = 0;i < adj[u].size();i++){
    if(adj[u][i] == p){
      pp = 1;
      continue;
    }
    calc(adj[u][i], u, 1ll * (subs + 1) * (i - pp - 1 >= 0 ? lsum[i - pp - 1] : 1) % m * (i - pp + 1 < rsum.size() ? rsum[i - pp + 1] : 1) % m);
  }

}
void dfs(int u, int p = -1){
  dp[u] = 1;
  for(auto el : adj[u]){
    if(el == p)continue;
    dfs(el, u);
    dp[u] = 1ll * (1 + dp[el]) * dp[u] % m;
  }
}
int main()
{
//  freopen("lcm.in", "r", stdin);
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  cin >> n >> m;
  adj.resize(n);
  for(int i = 0;i < n - 1;i++){
    int u, v;
    scanf("%d %d", &u, &v);
    u--, v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs(0);
  calc(0, -1, 0);

  for(int i = 0;i < n;i++){
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 24448
#include <iostream>

using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	int A[n][m], b[m];
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cin >> A[i][j];
		}
	}
	for(int i = 0; i < m; i++){
		cin >> b[i];
	}

	for(int i = 0; i < n; i++){
		int sum = 0;
		for(int j = 0; j < m; j++){
			sum += A[i][j] * b[j];
		}
		cout << sum << endl;
	}

	return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
 
using namespace std;
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<long long , long long>
#define pb push_back
#define ll long long
#define ld long double
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define fill(a,b) memset((a),(b),sizeof((a)))
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
ll power(ll x,ll y,ll m){ll r=1;for(;y;y>>=1){if(y&1)r=r*x%m;x=x*x%m;}return r;}
const ll mod = 1e9 + 7;
const ld pi = 3.14159265358979;
 
int run_test(){
      string s;
      cin >> s;
      int l = s.length();
      int i = 0;
      int ans = 0;
      int visited[l + 1];
      fill(visited, 0);
      while(i < l){
            if(visited[i]){
                  i++;
                  continue;
            }
            int j = i, k = 0, sum = 0;;
            while(j < l){
                  k = (10*k + (s[j] - '0'))%2019;
                  if(k == 0){
                        j++; sum++;
                        visited[j] = 1;
                        continue;
                  }
                  else{
                        j++;
                  }
            }
            ans += (sum*(sum + 1))/2; i++;
      }
      cout << ans;
      return 0;
}
 
int main(){
    FAST;
    ll t;
    t = 1;
 
    while(t--){
        run_test();
    }
}

Measured memory_bytes: 4484
module.exports=function(r){var t={};function n(e){if(t[e])return t[e].exports;var o=t[e]={i:e,l:!1,exports:{}};return r[e].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=r,n.c=t,n.d=function(r,t,e){n.o(r,t)||Object.defineProperty(r,t,{enumerable:!0,get:e})},n.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},n.t=function(r,t){if(1&t&&(r=n(r)),8&t)return r;if(4&t&&"object"==typeof r&&r&&r.__esModule)return r;var e=Object.create(null);if(n.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:r}),2&t&&"string"!=typeof r)for(var o in r)n.d(e,o,function(t){return r[t]}.bind(null,o));return e},n.n=function(r){var t=r&&r.__esModule?function(){return r.default}:function(){return r};return n.d(t,"a",t),t},n.o=function(r,t){return Object.prototype.hasOwnProperty.call(r,t)},n.p="",n(n.s=0)}([function(r,t,n){n(1)(n(3).readFileSync("/dev/stdin","UTF-8").split("\n"))},function(r,t,n){"use strict";function e(r,t){return function(r){if(Array.isArray(r))return r}(r)||function(r,t){var n=[],e=!0,o=!1,u=void 0;try{for(var i,l=r[Symbol.iterator]();!(e=(i=l.next()).done)&&(n.push(i.value),!t||n.length!==t);e=!0);}catch(r){o=!0,u=r}finally{try{e||null==l.return||l.return()}finally{if(o)throw u}}return n}(r,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var o=n(2);r.exports=function(r){for(var t=e(r[0].split(" ").map(function(r){return Number(r)}),2),n=t[0],u=t[1],i=[],l=0;l<n;l++)i.push([]);for(var f=0;f<u;f++){var a=e(r[f+1].split(" ").map(function(r){return Number(r)-1}),2),c=a[0],s=a[1];i[c].push(s),i[s].push(c)}var p=o(i);console.log(p.length)}},function(r,t,n){"use strict";r.exports=function(r){var t=r.length,n=new Array(t).fill(-1),e=new Array(t).fill(-1),o=[];return function t(u,i,l){n[u]=l++,e[u]=n[u];var f=!0,a=!1,c=void 0;try{for(var s,p=r[u][Symbol.iterator]();!(f=(s=p.next()).done);f=!0){var y=s.value;if(-1==n[y])e[u]=Math.min(e[u],t(y,u,l)),e[y]==n[y]&&o.push({from:u,to:y});else{if(i==y)continue;e[u]=Math.min(e[u],e[y])}}}catch(r){a=!0,c=r}finally{try{f||null==p.return||p.return()}finally{if(a)throw c}}return e[u]}(0,0,0),o}},function(r,t){r.exports=require("fs")}]);

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

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

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

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

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

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

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

int n,k;
vector<int> as(17);
ll res = 20 * 1000'000'000LL;

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

    // 15:32
    cin>>n>>k;
    rep(i, n){
        cin>>as[i];
    }

    rep(visibl, 1<<n){
        bitset<32> visibl_set = bitset<32>(visibl);
        if (visibl_set.count() < k) { continue; } // continue と break 間違えない
        // 経費を求める
        ll tmpres = 0;
        int nec_ht = 1;
        rep(i, n){
            if (visibl_set[i])
            {
                tmpres += max(0, nec_ht - as[i] + 1);
                nec_ht = max(as[i], nec_ht + 1);
            }
            else
            {
                nec_ht = max(nec_ht, as[i]);
            }
        }
        res = min(res, tmpres);
    }
    cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

void solve()
{
	int n;
	cin >> n;
	int cnt = 1;
	vector<string> now;
	string s = "";
	rep(i, n) s.push_back('a');
	now.push_back(s);
	int ite[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
	while (cnt < n)
	{
		vector<string> next;

		rep(i, now.size())
		{
			rep(j, ite[cnt])
			{
				string t=now[i];
				t[cnt]+=j;
				next.push_back(t);
			}
		}
		now=next;
		cnt++;
	}
	map<string,int>used;
	vector<string>ans;
	set<string>as;
	rep(i,now.size()){
		char mc='a';
		rep(j,n){
			if(now[i][j]>mc){
				char prev=now[i][j];
				FOR(k,j,n){
					if(prev==now[i][k]){
						now[i][k]=mc+1;
					}
				}
				mc++;
			}
		}
		as.insert(now[i]);

	}
	for(auto itr = as.begin(); itr != as.end(); ++itr) {
        std::cout << *itr << "\n";
	}      // イテレータの指す先のデータを表示
    
}

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


Measured memory_bytes: 247136
function Main(input) {
  var line = input.split(' ');
  var N = Number(line[0]);
  var R = Number(line[1]);
  if (10 <= N) {
    console.log(R);
  } else {
    var internalRating = R + 100 * (10 - N);
    console.log(internalRating);
  }
}

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


Measured memory_bytes: 21064
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;
#ifdef DEBUGRUN
#define log(a) (cerr<<#a"="<<a<<endl)
#else
#define log(a) ((void)0)
#endif
#define rep(i, n) for(int i=0; i<(int)(n); i++)

const int tbl_n[3] = {2, 1, 0};
const int tbl_m[3][3] = { {0, 0, 0}, {0, 1, 1}, {0, 1, 2} };
const int tbl_p[3][3] = { {0, 1, 2}, {1, 1, 2}, {2, 2, 2} };

int v[3];
string s;
unsigned ix;

int expr();
int parse(int p, int q, int r) {
    v[0]=p, v[1]=q, v[2]=r;
    ix = 0;
    return expr();
}

int expr() {
    const char ch = s[ix++];
    if('0'<=ch && ch<='2') return ch-'0';
    else if('P'<=ch && ch<='R') return v[ch-'P'];
    else if(ch=='-') return tbl_n[expr()];
    else {
        const int l = expr();
        const char op = s[ix++];
        const int r = expr();
        ix++;
        if(op=='+') return tbl_p[l][r];
        if(op=='*') return tbl_m[l][r];
    }
    log(false);
}

int main() {
    for(;;) {
        getline(cin, s);
        log(s);
        if(s[0]=='.') return 0;
        int ans = 0;
        rep(p, 3) rep(q, 3) rep(r, 3) {
            if(parse(p, q, r)==2) ans++;
        }
        printf("%d\n", ans);
    }
}

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

int main(int argc, const char * argv[]) {
    // insert code here...
    int a,b,c;
    std::cin >> a >> b >> c;
    if (a+b==c||a+c==b||a==b+c)
        std::cout<<"Yes";
    else
        std::cout<<"No";
    std::cout<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

const int N=2e5+100;

int a[N],b[N];

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

    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i]>>b[i];
    sort(a+1,a+n+1);
    sort(b+1,b+n+1);
    int l=(n%2?a[(n+1)/2]:a[n/2]+a[n/2+1]);
    int r=(n%2?b[(n+1)/2]:b[n/2]+b[n/2+1]);
    cout<<r-l+1;
}


Measured memory_bytes: 6784
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(c) (c).begin(), (c).end()
#define pb push_back
#define eb emplace_back
using namespace std;
const long long INF = 1LL<<60; // 仮想的な無限大の値;
using ll = long long;
using P  = pair<int, int>;
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main()
{
    int n;
    cin >> n;
    vi h(n);
    rep(i, n) cin >> h[i];
    reverse(ALL(h));
    rep2(i, 1, n){
        if(h[i-1] >= h[i] ) continue;
        h[i] -=1;
        if(h[i-1] >= h[i] ) continue;
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;


    return 0;
}

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

int main(void){
  string S;
  cin >> S;
  int len = S.length();
  
  if(S[len-1]=='s'){
    S += "es";
  }else{
    S += "s";
  }
  
  cout<< S << endl;
  return 0;
}

Measured memory_bytes: 3604
// atcoder/abc176/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int n, x, t;
  while (cin >> n >> x >> t) {
    int y = 0;
    int z = 0;
    while (y < n) {
      y += x;
      z += t;
    }
    cout << z << endl;
  }

  return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <cmath>

typedef long long ll;

using namespace std;

vector<pair<ll, int> > factorization(ll num){
  vector<pair<ll, int> > res;
  for(ll i=2; i*i<=num; i++){
    if(  num%i ) continue;
    res.push_back( make_pair(i, 0) );
    while( 0 == num%i ){
      res.back().second += 1;
      num /= i;
    }
  }
  if( 1 != num ) res.push_back(make_pair(num, 1)); // numがこの時点で１でなければ、numが素数であるので、その分を追加している
  return res;
}


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

int main(){
  ll a, b;
  cin >> a >> b;

  ll gcdOfAB = gcd(a, b);

  auto primeFactors = factorization(gcdOfAB);
  cout << primeFactors.size() + 1 << endl;

  return 0;
}


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

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
	cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__);
#else
#define dbg(...) 
#endif

int main() {
	ios_base::sync_with_stdio(false);
	int N, M, Q;
	cin >> N >> M >> Q;
	vector<int> A(Q), B(Q), C(Q), D(Q);
	for(int i=0; i<Q; i++){
		cin >> A[i] >> B[i] >> C[i] >> D[i];
		A[i]--; 
		B[i]--;
	}

	int ans = 0;
	vector<int> a(N, 1);
	while(true){
		int x = 0;
		dbg(a[0], a[1], a[2]);
		for(int i=0; i<Q; i++){
			if(a[B[i]]-a[A[i]]==C[i]) x += D[i];
		}
		ans = max(ans, x);

		if(a[0]==M) break;
		int i=0;
		while(i<N&&a[i]!=M) i++;
		i--;
		a[i]++;
		int b = a[i];
		i++;
		while(i<N) {
			a[i]=b;
			i++;
		}
	}

	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 3656
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 50
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on

int N, M;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> M;
  vector<vector<int>> G(N);

  REP(i, M)
  {
    int x, y;
    cin >> x >> y;
    G[x - 1].push_back(y - 1);
    G[y - 1].push_back(x - 1);
  }

  for (int i = 0; i < N; i++) {
    cout << G[i].size() << endl;
  }

  return 0;
}


Measured memory_bytes: 632
#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()
{
    vector<int> a(3);
    rep(i, 3) cin >> a[i];
    sort(a.begin(), a.end());
    rep(i, a.size())
    {
        cout << a[i];
        if (i < a.size() - 1)
            cout << " ";
        else
            cout << endl;
    }

    return 0;
}


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

int main()
{
	int K;
    cin >> K;
    if(K%7==0) {
       K /= 7;
    }
    ll x = 1;
    int ans = 0;
    while(x%K!=0&&ans<10000000) {
         ans++;
         x = 10*x+1;
         x %= K;
    }
    if(ans==10000000) {
        cout << -1 << endl;
        return 0;
    }
    cout << ans+1 << endl;
	return 0;
}

Measured memory_bytes: 3632
N = int(input())
from collections import deque
L = deque([])
R = deque([])

for i in range(N):
  S = input()
  l = [0]*len(S)
  if S[0]=='(':
    l[0]=1
  else:
    l[0]=-1
  for j in range(1,len(S)):
    if S[j]=='(':
      l[j] = l[j-1] + 1
    else:
      l[j] = l[j-1] - 1
  if l[-1] < 0:
    R.append([min(l)-l[-1], -l[-1], min(l), l[-1]])
  else:
    L.append([min(0,min(l)),l[-1]])
    
R = sorted(R, key = lambda x:x[0])
L = sorted(L, key = lambda x:x[0], reverse = True)
now = 0
judge = True
    
for l in L:
  if now + l[0]<0:
    judge = False
    break
  else:
    now += l[1]
    
for r in R:
  if now+r[2]<0:
    judge = False
    break
  else:
    now += r[3]
    
if now!=0:
  judge = False
  
if judge:
  print('Yes')
else:
  print('No')
    

Measured memory_bytes: 218328
#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 REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////

//verify by https://atcoder.jp/contests/nikkei2019-final/tasks/nikkei2019_final_d
//RSQ and RUQ
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    int N;
    cin >> N;
    int odd = 0;
    int even = 0;

    REP(i,N){
        int A;
        cin >> A;
        if (A % 2 == 0) even++;
        else odd++;
    }

    //cout << even << " " << odd << "\n";

    even = even + (odd/2) * 2;
    odd = odd % 2;

    if (odd == 0){
        printf("YES\n");
    }else{
        printf("NO\n");
    }
    

}


Measured memory_bytes: 256
#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;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int ans = 0;
    int cnt = 1;
    rep(i,n) {
        if (a[i] != cnt) ans++;
        if (a[i] == cnt) cnt++;
    }
    if (cnt == 1) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007

vector<ll> len(60,1),p(60,1);

ll dfs(ll n,ll x){
  if(n == 0)return x ? 1 : 0;
  if(x == 1)return 0;
  else if(x <= len[n-1]+1)return dfs(n-1,x-1);
  else if(x == len[n-1]+2)return p[n-1]+1;
  else if(x <= 2*len[n-1]+2)return p[n-1]+1+dfs(n-1,x-len[n-1]-2);
  else return p[n-1]*2+1;
}

int main(){
  
  rep(i,55)len[i+1] = 2*len[i]+3;
  rep(i,55)p[i+1] = 2*p[i]+1;
  ll n,x;
  cin >> n >> x;
  cout << dfs(n,x) << "\n";
  





  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 100000
#define MO 1000000007
using namespace std;
int a[MAXN+5],pre[MAXN+5],n;
int d[MAXN+5],cnt[MAXN+5],f[MAXN+5];
bool vis[MAXN+5];
int main()
{
//	freopen("test.in","r",stdin);
//	freopen("test.out","w",stdout);
	int ans=1;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]),d[a[i]]++;
	for(int i=1;i<=n;i++)
	{
		if(d[i]>=3)
		{
			printf("0\n");
			return 0;
		}
		if(d[i]<=1||vis[i]==true)
			continue;
		int p=i;
		do
		{
			if(vis[p]==true)
			{
				printf("0\n");
				return 0;
			}
			vis[p]=true;
			pre[a[p]]=p;
			p=a[p];
		}while(p!=i);
	}
	for(int i=1;i<=n;i++)
	{
		if(d[i]==0)
		{
			int p=i,len1=0,len2=0;
			while(vis[p]==false)
				vis[p]=true,len1++,p=a[p];
			do
			{
				p=pre[p];
				len2++;
			}while(d[p]!=2);
			if(len1<len2)
				ans=2LL*ans%MO;
			else if(len1>len2)
			{
				printf("0\n");
				return 0;
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(vis[i]==false)
		{
			int p=i,len=0;
			do
			{
				p=a[p];
				len++;
				vis[p]=true;
			}while(p!=i);
			cnt[len]++;
		}
	}
	for(int i=1;i<=n;i++)
	{
		int mul=1;
		if(i!=1&&(i%2==1))
			mul++;
		f[0]=1,f[1]=mul;
		for(int j=2;j<=cnt[i];j++)
			f[j]=(1LL*f[j-2]*(1LL*j-1LL)%MO*i%MO+1LL*f[j-1]*mul%MO)%MO;
		ans=(1LL*ans*f[cnt[i]])%MO;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
template<class itr, class itr2> bool next_sequence2(itr first, itr last, itr2 first2, itr2 last2){ itr now = last; itr2 now2 = last2; while(now != first){ now--, now2--; (*now)++; if((*now) == (*now2)){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    lint N;
    lint A, B;
    cin >> N >> A >> B;
    N %= 12;
    for(int i = 0; i < N; i++){
        if(i % 2 == 0){
            A = A - B;
        }else{
            B = A + B;
        }
    }
    cout << A << " " << B << endl;
}



Measured memory_bytes: 3116
l = [input() for i in range(5)]
k = int(input())

for x in range(4):
  for y in range(4):
    s = 0
    s = int(l[x]) - int(l[y+1])
    if(s<0):
      s = -s
    if(k < s):
      print(":(")
      break
    if(x==3 & y==3):
      print("Yay!")
  else:
    continue
  break

Measured memory_bytes: 3060