akhauriyash/Code-Regression huggingface dataset:
/*    ####################  */
/*   # I_LOVE_THUY_LINH #  */
/*  ####################  */
#include <bits/stdc++.h>
#define ll long long
#define db double
#define ld long double
#define ii pair<int,int>
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define matrix vector<vector<ll>>
#define fir first
#define sec second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
#define uni(a) (a).erase(unique(all(a)),(a).end())
#define sz(a) int((a).size())
#define ms(s,val) memset(s,val,sizeof(s))
#define bitcount(n) __builtin_popcountll((ll)n)
#define getbit(s,k) ((s >> k)&1)
#define turnbit(s,k) (s | (1<<k))
#define offbit(s,k) (s & ~(1<<k))
#define flipbit(s,k) (s ^ (1<<k))
#define prec(n) fixed<<setprecision(n)
#define sqr(x) (ll)(x)*(ll)(x)
#define lcm(a,b) ((ll)a/__gcd((ll)a,(ll)b)*(ll)(b))
#define gcd(a,b) __gcd(a,b)
using namespace std;
const int INF = int(1e9);
vector<vector<ii>> g;
vector<ll> wedge;

int n, m;

// Inclusion-Exclusion

bool dfs(int u,int to,int id,int par = -1){
    if (u == to) return true;

    for (auto ev: g[u]){
        if (ev.fir == par) continue;
        if (dfs(ev.fir,to,id,u)){
            wedge[id] |= (1LL << ev.sec);
            return true;
        }
    }

    return false;
}

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    g.resize(n);
    for (int i = 0; i < n - 1; i++){
        int u, v;
        cin >> u >> v;
        u--, v--;
        g[u].emplace_back(v,i);
        g[v].emplace_back(u,i);
    }
    
    cin >> m;
    wedge.resize(m);
    for (int i = 0; i < m; i++){
        int u, v;
        cin >> u >> v;
        u--, v--;
        dfs(u,v,i);
    }

    ll ans = (1LL << (n - 1));
    for (int mask = 1; mask < (1 << m); mask++){
        ll edge = 0;
        for (int i = 0; i < m; i++)
            if (getbit(mask,i)) edge |= wedge[i];
        int flip = (bitcount((ll)mask) & 1);
        if (flip) ans -= (ll)(1LL << (n - 1 - bitcount((ll)edge)));
        else ans += (ll)(1LL << (n - 1 - bitcount((ll)edge)));
    }
    cout << ans;
    return 0;
}

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

int main(){
    string integer;
    while(1){
        cin>>integer;
        if(integer=="0")break;
        int sum=0;
        for(int i=0; i<integer.size();i++){
            sum+=integer[i]-'0';
        }
        cout<<sum<<endl;
        
    }
        
}



Measured memory_bytes: 3156
# -*- coding:utf-8 -*-
import copy
from math import factorial

def solve2():
    N = int(input())
    cities = [[None, None]]
    for i in range(N):
        x, y = list(map(int, input().split()))
        cities.append([x,y])

    def calc_distance(a, b):
        return ((a[0]-b[0])**2+(a[1]-b[1])**2)**(1/2)

    memo = {}  # 距離の事前計算
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            memo[(i,j)] = calc_distance(cities[i], cities[j])

    degree = N-1  # 頂点の次数
    coef = factorial(degree)

    ans = 0
    for key, value in memo.items():
        ans += value * coef * 2  # 経路(1,2)と経路(2,1)で倍にする必要がある
    ans = ans / factorial(N)
    print(ans)


def solve():
    N = int(input())
    cities = [[None, None]]
    for i in range(N):
        x, y = list(map(int, input().split()))
        cities.append([x,y])

    def calc_distance(a, b):
        return ((a[0]-b[0])**2+(a[1]-b[1])**2)**(1/2)

    memo = {}  # 距離の事前計算
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            memo[(i,j)] = calc_distance(cities[i], cities[j])

    def dfs(will_visit, visited, now_i, total_d):
        if now_i is None:
            ans = 0
            for i in will_visit:
                new_will_visit = copy.deepcopy(will_visit)
                new_visited = copy.deepcopy(visited)
                new_will_visit.remove(i)
                new_visited.add(i)
                ans += dfs(new_will_visit, new_visited, i, 0)
            return ans

        if will_visit == []:
            return total_d

        ans = 0
        for i in will_visit:
            if i in visited: continue
            new_will_visit = copy.deepcopy(will_visit)
            new_visited = copy.deepcopy(visited)
            new_will_visit.remove(i)
            new_visited.add(i)
            ans += dfs(new_will_visit, new_visited, i, total_d+memo[min(now_i, i), max(now_i, i)])
        return ans

    will_visit = [i for i in range(1, N+1)]
    visited = set()
    ans = dfs(will_visit, visited, None, 0)
    print(ans/factorial(N))


if __name__ == "__main__":
    solve2()


Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ll n;
vector<unordered_map<int, int> >edges;
vector<int>colors;

void dfs(int n){
    DEBUG{
        cout << n << endl;
    }
    for(auto x:edges[n]){
      if(colors[x.first]!=-1){
          continue;
      } 
      if(x.second%2==1)colors[x.first]=1-colors[n];
      else colors[x.first]=colors[n];
      dfs(x.first);
    }
    // for(auto x:edges[n]){
    //     if(colors[x.first]==-1)dfs(x.first);
    // }
}

int main(void) {
    cin >> n;
    colors = vector<int>(n+1,-1);
    edges = vector<unordered_map<int, int> >(n+1, unordered_map<int,int>());
    int start=n+1;
    rep(i,n-1){
        int tu,tv,tw;
        cin >> tu >> tv >> tw;
        start = min(start, min(tu,tv));
        edges[tu][tv]=tw;
        edges[tv][tu]=tw; 
    }
    DEBUG{
        cout << "start " << start << endl;
    }
    colors[start]=0;
    dfs(start);
    rep(i,n){
        cout << colors[i+1] << endl;
    }

    return 0;
}


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

using ll = long long;
using Pl = pair<ll, ll>;

ll N, X, D;
map<ll, vector<Pl>> mp;
ll offset = 1ll << 61;
int main() {
    cin >> N >> X >> D;
    if (D < 0) {
        X = -X;
        D = -D;
    }
    if (D == 0) {
        if (X != 0) cout << N + 1 << endl;
        else cout << 1 << endl;
        return (0);
    }
    for (ll i = 0; i <= N; i++) {
        ll left  = i*X + D*i*(i-1)/2;
        ll right = i*(X+(N-i)*D) + D*i*(i-1)/2;
        mp[(left%D+D)%D].emplace_back((left+offset)/D, 1);
        mp[(left%D+D)%D].emplace_back((right+offset)/D + 1, -1);
    }
    ll sum = 0;
    for (auto &m : mp) {
        auto &v = m.second;
        sort(begin(v), end(v));
        ll cnt = 0;
        ll i = 0;
        while (i < v.size()) {
            ll pos = v[i].first;
            if (i > 0 && cnt > 0) sum += pos - v[i - 1].first;
            while (pos == v[i].first) cnt += v[i].second, i++;
        }
    }
    cout << sum << endl;
    return (0);
}


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

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

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

int main(){
  int N;
  cin >> N;
  vector<long long> A(N);
  vector<long long> G(N,0);
  vector<long long> H(N,0);
  for (int i=0;i<N;i++) cin >> A[i];
  G[0] = A[0];
  for (int i=1;i<N;i++){
    G[i] = gcd(A[i],G[i-1]);
  }
  H[N-1] = A[N-1];
  for(int i=N-2;i>=0;i--){
    H[i] = gcd(A[i],H[i+1]);
  }
  
  long long ans = 0;
  ans = chmax(H[0],H[1]);
  for(int i=1;i<N-1;i++){
    ans = chmax(ans, gcd(G[i-1],H[i+1]));
  }
  ans = chmax(ans, G[N-2]);
  ans = chmax(ans, G[N-1]);
  
  cout << ans << endl;
  return 0;
}








Measured memory_bytes: 2560
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
using namespace std;

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <stack>
#include <bitset>

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

	int ans = 1;

	rep(i, N) {
		if (ans < K) {
			ans *= 2;		
		}
		else {
			ans += K;		
		}	
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
a=[0]+a+[0]
cnt=0
for i in range(1,n+2):
  cnt+=abs(a[i]-a[i-1])

for i in range(1,n+1):
  print(cnt-abs(a[i-1]-a[i])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]))
  


Measured memory_bytes: 86780
/*************************************************************************
	> File Name: 1.cpp
	> Author: Knowledge_llz
	> Mail: 925538513@qq.com 
	> Blog: https://blog.csdn.net/Pig_cfbsl 
	> Created Time: 2020/6/14 20:01:11
 ************************************************************************/

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define LL long long
using namespace std;
int read(){
	char x=getchar(); int u=0,fg=0;
	while(!isdigit(x)){ if(x=='-') fg=1; x=getchar(); }
	while(isdigit(x)){ u=(u<<3)+(u<<1)+(x^48); x=getchar(); }
	return fg?-u:u;
}
int a[10];
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
	For(i,1,5){
		a[i]=read();
		if(!a[i]){
			cout<<i;
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
using namespace std;
int n,q;
int a[1000];
main()
{
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	cin>>q;
	for(int i=0;i<q;i++)
	{
		int b,e,t;cin>>b>>e>>t;
		swap_ranges(a+b,a+e,a+t);
	}
	for(int i=0;i<n;i++)cout<<(i?" ":"")<<a[i];
	cout<<endl;
}


Measured memory_bytes: 3096
from collections import Counter

n = int(input())
v = [int(_) for _ in input().split()]

# 最終的な2値をx, yとしたとき書き換える要素が最小の場合は、
# xは、書き換えが最も少ない数。つまり、もともと最も多い数
# yも同様。
# ただ、xとyがかぶる場合があるので、それに対処。
if len(Counter(v)) > 1:
    v1 = v[0:n+1:2]
    # print(v)
    # print(v1)
    v2 = v[1:n+2:2]
    # print(v2)
    v1_count = Counter(v1)
    v2_count = Counter(v2)

    v1_1st_common = v1_count.most_common(1)
    v2_1st_common = v2_count.most_common(1)
    sols = []
    # print(v1_1st_common[0][1], v2_1st_common[0][1])
    # v1を基準として多い方を考える場合。
    n1 = v1_1st_common[0][1]
    # v1の1位とv2の1位がかぶる場合
    if v1_1st_common[0][0] == v2_1st_common[0][0]:
        if len(v2_count) >= 2:
            v2_2nd_common = v2_count.most_common(2)
            n2 = v2_2nd_common[1][1]
        else:
            print(n//2)
    else:
        n2 = v2_1st_common[0][1]
    sols.append(n-n1-n2)

    # v2を基準として多い方を考える場合。
    n2 = v2_1st_common[0][1]
    # v1の1位とv2の1位がかぶる場合
    if v1_1st_common[0][0] == v2_1st_common[0][0]:
         if len(v1_count) >= 2:
            v1_2nd_common = v1_count.most_common(2)
            n1 = v1_2nd_common[1][1]
         else:
            print(n//2)
    else:
        n1 = v1_1st_common[0][1]
    sols.append(n-n1-n2)
    print(min(sols))
else:
    print(n//2)

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

vector<P> g[100010];
vector<int> dif;
bool vis[100010];
vector<int> res;

bool dfs(int v,int pre,int preidx){
  vis[v]=true;
  bool crt=dif[v];
  for(P e : g[v]){
    if(e.fi==pre||vis[e.fi])continue;
    crt^=dfs(e.fi,v,e.se);
  }
  if(crt){
    res.push_back(preidx);
  }
  return crt;
}

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

  int n,m;
  cin>>n>>m;
  vector<int> xs;
  vector<int> a(n),b(n),c(n);
  rep(i,n){
  	cin>>a[i]>>b[i];
  	xs.push_back(a[i]);
  }
  sort(all(xs));
  uni(xs);
  rep(i,n){
  	ll idx=lower_bound(all(xs),a[i])-xs.begin();
  	c[idx]=b[i];
  }
  dif.resize(n+1);
  dif[0]=c[0]; dif[n]=c[n-1];
  repl(i,1,n)dif[i]=c[i-1]^c[i];

  vector<P> ps;
  rep(i,m){
  	int l,r;
  	cin>>l>>r;
  	int lidx=lower_bound(all(xs),l)-xs.begin();
  	int ridx=upper_bound(all(xs),r)-xs.begin();
    if(lidx>=ridx)continue;
    g[lidx].push_back(P(ridx,i));
    g[ridx].push_back(P(lidx,i));
  }

  rep(i,n+1){
    if(vis[i])continue;
    if(dfs(i,-1,-1)){
      cout<<-1<<endl;
      return 0;
    }
  }
  cout<<res.size()<<endl;
  sort(all(res));
  rep(i,res.size())cout<<res[i]+1<<" ";
  cout<<endl;

  return 0;
}


Measured memory_bytes: 16120
#include <bits/stdc++.h>
using namespace std;
const long long OO = (long long) 1e18+7;
#define lp(i,a,n) for(long long i = a ; i < n ; ++i)
#define rep(i,vec) for(ll i = 0 ; i < vec.size() ; ++i)
#define reprv(i,vec) for(ll i = vec.size()-1; i >=0 ; --i)
#define eps (1e-5)
#define pb(i) push_back(i)
#define PI acos(-1.0)
#define vec(a,b)                ((b)-(a))
#define length(a)               (hypot((a).imag(), (a).real()))
#define EPS 1e-9

#define cp(a,b)                 ( (conj(a)*(b)).imag() )	// a*b sin(T), if zero -> parllel
#define ff first
#define ss second
typedef vector<int> vi ;
typedef   long long ll;
typedef vector<ll> vll ;
typedef pair<int,int> pii ;
typedef vector< pair<int,int> >  vpii;
typedef vector<vector<int> > vvi ;
typedef complex<double> point;
typedef pair<ll,ll> pll;


using namespace std;
ll  inv(ll a, ll b) {return 1 < a ? b - inv(b % a, a) * b / a : 1;}
ll  Pow(ll  B,ll  P){ll  R=1; while(P>0)  {if(P&1) R=(R*B);P/=2;B=(B*B);}return R;} //compute b^p
ll  GCD(ll  a,ll  b){ while(b){b ^= a ^=b ^= a %=b;}  return a;}
ll  LCM(ll  a,ll  b) { return (a / GCD(a,b)*b); }
ll  BigMod(ll  B,ll  P,ll  M){ ll  R=1; while(P>0)  {if(P&1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return (ll )R;} //compute b^p%m



const int MOD = 1000000007;

const int MX = 100001; //check the limits, dummy

ll modExp(ll base, ll power) {
    if (power == 0) {
        return 1;
    } else {
        ll cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
        if (power % 2 == 1) cur = cur * base;
        cur = cur % MOD;
        return cur;
    }
}

ll inv(ll base) {
    int g = MOD, r = base, x = 0, y = 1;
    while (r != 0) {
        int q = g / r;
        g %= r; swap(g, r);
        x -= q * y; swap(x, y);
    }
    return x < 0 ? x+MOD : x;
}

ll mul(ll A, ll B) {
	return (A*B)%MOD;
}

ll add(ll A, ll B) {
	return (A+B)%MOD;
}

ll dvd(ll A, ll B) {
    return mul(A, inv(B));
}

ll sub(ll A, ll B) {
    return (A-B+MOD)%MOD;
}
ll* facs = new ll[MX];
ll* facInvs = new ll[MX];

ll choose(ll a, ll b) {
	if (b > a) return 0;
	if (a < 0) return 0;
	if (b < 0) return 0;
    ll cur = facs[a];
    cur = mul(cur, facInvs[b]);
    cur = mul(cur, facInvs[a-b]);
    return cur;
}

void initFacs() {
	facs[0] = 1;
	facInvs[0] = 1;
	lp(i, 1, MX) {
		facs[i] = (facs[i-1] * i) % MOD;
		facInvs[i] = inv(facs[i]);
	}
}


int main()
{
    ios::sync_with_stdio(0);
   cin.tie(0);
  //   freopen( "output.txt" , "w" , stdout ) ;
  //  freopen( "input.txt" , "r" , stdin ) ;
   ll n ,k;

   cin>>n>>k;
    vll nm(n);
    initFacs();
    lp(i,0,n){
        cin >> nm[i];
    }
    sort(nm.begin(),nm.end());
    ll ans =0;
    lp(i,0,n-k+1){
        ll tm = choose(n-i-1,k-1) ;
        tm *= nm[i]; tm %= MOD;
        ans += MOD - tm; ans %= MOD;

    }
    lp(i,k-1,n){
        ll tm = choose(i,k-1);
        tm *= nm[i]; tm %= MOD;
        ans += tm; ans %= MOD;

    }
    cout << ans<<endl;



    return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;

#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;

const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int n,m;
vs in;
vvi d,dp;
bool dfs(int a,int b,int c){
	if(dp[a][b]<c)return 0;
	rep(i,4){
		int x=a+dx[i];
		int y=b+dy[i];
		if(x<0||y<0||x>=n||y>=m||in[x][y]=='#'||d[x][y]<=c+1||c+1>=dp[x][y])continue;
		if(in[x][y]=='%'){
			cout<<"Yes"<<endl;
			return 1;
		}
		d[x][y]=c+1;
		if(dfs(x,y,c+1))return 1;
	}
	return 0;
}
int main(){
	cin>>n>>m;
	in=vs(n);
	rep(i,n)cin>>in[i];
	dp=vvi(n,vi(m,inf));
	priority_queue<tp>que;
	rep(i,n)rep(j,m)if(in[i][j]=='$'){
		que.push(tp(i,j,0));
		dp[i][j]=0;
	}
	while(!que.empty()){
		int x,y,co;
		tie(x,y,co)=que.top();
		que.pop();
		if(dp[x][y]<co)continue;
		rep(i,4){
			int nx=x+dx[i];
			int ny=y+dy[i];
			if(nx<0||ny<0||nx>=n||ny>=m||in[nx][ny]=='#'||dp[nx][ny]<=co+1)continue;
			dp[nx][ny]=co+1;
			que.push(tp(nx,ny,co+1));
		}
	}
	d=vvi(n,vi(m,inf));
	rep(i,n)rep(j,m)if(in[i][j]=='@'){
		d[i][j]=0;
		if(!dfs(i,j,0))cout<<"No"<<endl;
	}
}

Measured memory_bytes: 3940
#                         author:  kagemeka 
#                         created: 2019-11-09 11:51:37(JST)
### modules
## from standard library
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## from external libraries
# import scipy.special   
# import scipy.misc      
# import numpy as np 


def baseConvert(n, base):
    if n == 0:
        return ''
    else:
        for i in range(abs(base)):
            if n % abs(base) == i:
                return baseConvert((n - i) // base, base) + str(i)
 
def main():
    n = int(sys.stdin.readline().rstrip())
    base = -2
    
    if n == 0:
        ans = '0'
    else:
        ans = baseConvert(n, base)
    print(ans)

if __name__ == "__main__":
    # execute only if run as a script
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <tuple>
#include <utility>
#include <functional>
#include <set>
#include <map>
#include <bitset>
#include <list>

using namespace std;


#define INF pow(10, 9)
// typedef priority_queue<tuple<int,int,int>, vector< tuple<int, int, int> >, greater< tuple<int, int, int> > > PQ;

typedef long long int ll;



int search_parent(vector< pair<int, int> > &parent_size, int i)
{
    if(parent_size[i].first != i)
    {
        parent_size[i].first = search_parent(parent_size, parent_size[i].first);
    }
    return parent_size[i].first;
}

int main(void)
{

    int tmp_d, M;
    cin >> tmp_d >> M;
    const int N = tmp_d;
    vector< vector<int> > friends(M, vector<int>(2) ); // friend pair information
    vector< pair<int, int> > parent_size(N); // parent, N_friends
    for(int i=0; i<N; i++)
    {
        parent_size[i] = make_pair(i, 1);
    }

    int friends_max=1;

    for(int i=0; i<M; i++)
    {
        cin >> friends[i][0] >> friends[i][1];

        friends[i][0] --;
        friends[i][1] --;

    }

    for(int i=0; i<M; i++)
    {
        int friend1 =  friends[i][0], friend2= friends[i][1];
        int parent1 = search_parent(parent_size, friend1 );
        int parent2 = search_parent(parent_size, friend2 );
        if( parent1 != parent2 )
        {
            if(parent_size[parent1].second > parent_size[parent2].second)
            {
                parent_size[parent2].first = parent_size[parent1].first;
                int tmp_i = parent_size[parent2].second;
                parent_size[parent2].second += parent_size[parent1].second;
                parent_size[parent1].second += tmp_i;
                if(friends_max < parent_size[parent1].second) friends_max = parent_size[parent1].second;

            }
            else
            {
                parent_size[parent1].first = parent_size[parent2].first;
                int tmp_i = parent_size[parent2].second;
                parent_size[parent2].second += parent_size[parent1].second;
                parent_size[parent1].second += tmp_i;
                if(friends_max < parent_size[parent2].second) friends_max = parent_size[parent2].second;
            }

            // if(friends_max < parent_size[].second) friends_max = parent_size[friend2].second;

        }
    }

    cout << friends_max << endl;







    return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define int long long
#define pb push_back
#define m_p make_pair
#define m_t meke_tuple
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define debg(a) cout<<#a<<" "<<a<<endl;
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define out(a) cout<<(a)<<endl;
typedef long long ll;
typedef string str;
typedef vector<int> V;
typedef pair<int,int> P;
typedef vector<P> VP;
const int INF = 1LL<<60;
const int MOD = 1e9+7;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
int lcm(int a,int b){return a/gcd(a,b)*b;}

signed main(){
  int n;
  cin>>n;
  V a(n);
  rep(i,n)cin>>a[i];
  int cnt=0;
  rep(i,n)if(a[i]%2!=0)cnt++;
  cout<<(cnt%2==0?"YES":"NO")<<endl;  
  
  
  return 0;
}


Measured memory_bytes: 1024
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_chars() -> Vec<char> {
    read::<String>().chars().collect()
}

fn main() {
    let chars = read_chars();

    let mut prev = '\0';
    for c in chars.iter() {
        if prev == *c {
            println!("Bad");
            return;
        }
        prev = *c;
    }
    println!("Good");
}


Measured memory_bytes: 4352
N,M = [int(i) for i in input().split()]
if N%2 == 1:
    for i in range(1,M+1):
        print(i, end=" ")
        print(N+1-i)
    exit()
L = min(M,N//4)
for i in range(1,L+1):
    print(i,end=" ")
    print(N+1-i)
if L < M:
    for i in range(L+1,M+1):
        print(i,end=" ")
        print(N-i)

Measured memory_bytes: 9292
#include <iostream>

using namespace std;

int main()
{
    string s;
    int n=0;
    cin>>s;
    for(int i=0; i<4; i++)
    {
        if(s[i]=='+')
        {
            n++;
        }
        else
        {
            n--;
        }
    }
    cout<<n;
}

Measured memory_bytes: 3592
import sys
import math
import collections
import decimal
import itertools
from collections import deque
from functools import reduce
import heapq
import copy
#n = int(input())
n, x, t = map(int, sys.stdin.readline().split())
#s = input()
#p = list(map(int, sys.stdin.readline().split()))


a = math.ceil(n / x)
print(a * t)
        

    






Measured memory_bytes: 10136
#include<bits/stdc++.h>
using namespace std;
int main(){
  int X, Y;
  cin >> X >> Y;
  bool flag = false;
  for(int i=0; i<=X; i++){
    for(int j=0; j<=X; j++){
      if(i*2 + j*4 == Y && i + j == X){
        flag = true;
      }
    }
  }
  
  if(flag){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3492
#include <iostream>
#include <string.h>
#include <algorithm>

using namespace std;

int main(){
    string str_in;

    cin >> str_in;

    if(str_in[0] == 'S')
    {
       cout <<"Cloudy"<< endl;

    }

    if(str_in[0] == 'C')
    {
       cout <<"Rainy"<< endl;
    }

    if(str_in[0] == 'R')
    {
        cout <<"Sunny"<< endl;
    }



    


   
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a, b, n, x, sum;
int main() {
	while (cin >> a >> b >> n) {
		x = (a%b) * 10; sum = 0;
		for (int i = 0; i < n; i++) {
			sum += x / b;
			x = (x%b) * 10;
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 1156
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, K: int, l: "List[int]"):
    l.sort(reverse=True)
    print(sum(l[:K]))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    l = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, l)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC037A
{
	class Program
	{
		static void Main(string[] args)
		{
			int a, b, c;
			var word = Console.ReadLine().Split(' ');
			 a = int.Parse(word[0]);
			 b = int.Parse(word[1]);
			 c = int.Parse(word[2]);

			if (a == (b + c))
				Console.WriteLine("Yes");

			else if (b == (a + c))
				Console.WriteLine("Yes");

			else if (c == (a + b))
				Console.WriteLine("Yes");

			else
				Console.WriteLine("No");
		}
	}
}

Measured memory_bytes: 13140
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<deque>
using namespace std;

using ll = long long;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001;

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

set<ll> t;
set<ll> s;

ll NearTemple(ll p)
{
  auto t1 = t.lower_bound(p);
  auto t2 = t1 == t.begin() ? t1 : prev(t1);
  ll nearTempleDistance = min(abs(*t1-p), abs(*t2-p));
  return nearTempleDistance;
}

ll NearShrine(ll p)
{
  auto s1 = s.lower_bound(p);
  auto s2 = s1 == s.begin() ? s1 : prev(s1);
  ll nearShrineDistance = min(abs(*s1-p), abs(*s2-p));
  return nearShrineDistance;
}

int main()
{
  ll a, b, q;
  cin >> a >> b >> q;
  rep(i,a) {
    ll tmp;
    cin >> tmp;
    s.insert(tmp);
  }
  rep(i,b) {
    ll tmp;
    cin >> tmp;
    t.insert(tmp);
  }
  rep(i,q) {
    ll x;
    cin >> x;
    ll ts = 0; /*先に寺*/
    ll st = 0; /*先に神社*/

    /*1.先に寺へ行く*/
    auto t1 = t.lower_bound(x);
    auto t2 = t1 == t.begin() ? t1 : prev(t1);
    ll dt1 = NearShrine(*t1) + abs(*t1-x);
    ll dt2 = NearShrine(*t2) + abs(*t2-x);
    ts = min(dt1, dt2);

    /*2.先に神社へ行く*/
    auto s1 = s.lower_bound(x);
    auto s2 = s1 == s.begin() ? s1 : prev(s1);
    ll ds1 = NearTemple(*s1) + abs(*s1-x);
    ll ds2 = NearTemple(*s2) + abs(*s2-x);
    st = min(ds1, ds2);

    cout << min(st, ts) << endl;
  }
}


Measured memory_bytes: 12288
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <math.h>
#include <cmath>
#include <ctime>
#include <stdlib.h>

using namespace std;

#define int long long

#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define m_p make_pair
#define m_t make_tuple
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
typedef pair<int, int> P;
typedef long double ld;

const double pai = 3.1415926535897;
const int mod = 1000000007;
const int INF = 1000000021;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];


//x未満の要素数を返す二分探索関数
int b_s(vector<int>& vec, int xx) {
	return lower_bound(all(vec), xx) - vec.begin();
}
template<typename T>void vecout(vector<T>& vec) { for (T t : vec) cout << t << " "; cout << endl; }
template<typename TT>void vecin(vector<TT>& vec) {
	for (int i = 0; i < vec.size(); i++) {
		cin >> vec[i];
	}
}

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

//n個を1個以上のx組のグループに分ける重複組み合わせはcom(n-1,x-1)
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
long long modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

bool chmax(int& xx, int yy) {
	if (xx < yy) {
		xx = yy;
		return true;
	}
	return false;
}
bool chmin(int& xx, int yy) {
	if (xx > yy) {
		xx = yy;
		return true;
	}
	return false;
}
double dist(int x, int y) {
	return sqrt(x * x + y * y);
}
double dist(int xx1, int xx2, int yy1, int yy2) {
	return sqrt(abs(xx1 - xx2) * abs(xx1 - xx2) + abs(yy1 - yy2) * abs(yy1 - yy2));
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	if (xx <= 1) {
		return 0;
	}
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	int n,t=0,a,ans=0;
	cin >> n;
	map<int, int>ma;
	ma[0] = 1;
	rep(i, n) {
		cin >> a;
		t += a;
		if (!ma.count(t)) {
			ma[t] = 1;
		}
		else {
			ma[t]++;
		}
	}
	for (auto p : ma) {
		ans += p.second * (p.second - 1) / 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 16088
while True:
    s=raw_input()
    if s=="#":break
    cnt=0
    pre=s[0] in "qwertasdfgzxcvb"
    for c in s[1:]:
        now=c in "qwertasdfgzxcvb"
        if now<>pre:
            cnt+=1
            pre=now
    print cnt

Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll k, x;
    cin >> k >> x;

    ll l = max(x - k + 1, -1000000LL), r = min(x + k - 1, 1000000LL);
    for(ll i = l; i <= r; i++){
        cout << i << " ";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int n;
string s;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> s;
  n = s.size();

  bool no = false;
  no |= (s[n-1] == '1');
  no |= !(s[0] == '1' && s[n-2] == '1');
  for (int i = 1; i < (n-1)/2; i++) {
    no |= (s[i] != s[n-2-i]);
  }  
  if (no) {
    cout << -1 << endl;
    return 0;
  }
  int a = n, b = n-1;
  for (int i = 0; i < n-1; i++) {
    cout << a << " " << b << endl;
    if (s[i] == '1') {
      a = b--;
    } else {
      b--;
    }
  }

  return 0;
}

Measured memory_bytes: 1616
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}


int main()
{
  string s ;
  cin >> s ;
  int n = SZ(s) ;
  
  REP(i,n-1){
    if(s.substr(i,2)=="AC"){
      cout <<"Yes"<<endl ;
      return 0 ;
    }
  }
  
  cout <<"No"<<endl ;
  
   


  return 0 ;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rrep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define maxe(x) *max_element(all(x))
#define mine(x) *min_element(all(x))
#define Size(x) ((int)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
long long MOD = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo,gyakugen
//mint,dijkstra

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll h1,h2,m1,m2,k;
        cin>>h1>>m1>>h2>>m2>>k;
        ll H=h2-h1;
        ll M=m2-m1;
        H*=60;
        H+=M;
        H-=k;
        cout<<H<<endl;
    }

Measured memory_bytes: 3636
H = int(input())
L = [H]
for i in range(1, 10 ** 2 + 1):
    L.append(2**i)
A = sorted(L)
i = A.index(H)

if (A.count(H) == 1):
    print(2 * 2**(i) - 1)
else:
    print(2 * 2**(i + 1) - 1)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define REP(i,n) for (long long i=0;i<(n);i++)
#define FOR(i,a,b) for (long long i=(a);i<(b);i++)
#define RREP(i,n) for(long long i=n;i>=0;i--)
#define RFOR(i,a,b) for(long long i=(a);i>(b);i--)
#define dump1d_arr(array) REP(i,array.size()) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl
#define dump2d_arr(array) REP(i,array.size()) REP(j,array[i].size()) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl
#define dump(x)  cerr << #x << " => " << (x) << endl
#define dumpP(p) cerr << "( " << p.first << " , " << p.second << " )" << ends
#define SORT(c) sort((c).begin(),(c).end())
#define MIN(vec) *min_element(vec.begin(), vec.end())
#define MAX(vec) *max_element(vec.begin(), vec.end())
#define UNIQ(vec) vec.erase(unique(vec.begin(), vec.end()),vec.end()) //ソートの必要あり
#define IN(n,m)  (!(m.find(n) == m.end()))
#define ENUM(m) for (auto itr = m.begin(); itr != m.end(); ++itr)
#define dump_MAP(m) for(auto itr = m.begin(); itr != m.end(); ++itr) { cerr << itr->first << " --> "  << itr->second << endl; }
#define FINDL(vec,x) (lower_bound(vec.begin(),vec.end(),x) - vec.begin())
#define FINDU(vec,x) (upper_bound(vec.begin(),vec.end(),x) - vec.begin())
#define ROUND(N) setprecision(N)
#define ROUND_PRINT(N,val) cout << fixed;cout << setprecision(N) << val << endl
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

using namespace std;
constexpr long double pi = M_PI;
constexpr double eps = 1e-10;
constexpr long mod = 1000000007;
constexpr short shINF = 32767;
constexpr long loINF = 2147483647;
constexpr long long llINF = 9223372036854775807;
typedef long long LL;
typedef vector<LL> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<LL,LL> pr;
typedef vector<pr> VP;
struct Order {
	bool operator() (pr const& a,pr const& b) const {
		return a.first > b.first || ((a.first == b.first) && (a.second > b.second));
	}
};

int main(void) {
	long N,W;
	cin >> N >> W;
	VI v(N),w(N);
	REP(i,N) cin >> v[i] >> w[i];
	VI dp(W+1,0); // 重さwで実現できる最大の価値

	dp[0] = 0;

	REP(i,W+1) {
		REP(j,N) {
			if (i - w[j] >= 0) dp[i] = max(dp[i-w[j]]+v[j],dp[i]);
		}
	}
	cout << MAX(dp) << endl;
}




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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;

const ll mod = 1e9+7;
const ll inf = 1e16;

#define loop(i,m,n) for(ll i=m;i<n;i++)
#define vloop(it,x) for(auto it=x.begin(); it!=x.begin(); it++)
#define all(x) x.begin(),x.end()
#define debug(x) cout << #x <<":"<< x <<endl	
#define showll(x) printf("%lld\n",x)
#define test(t) ll t;cin >> t;while(t--)
#define showc(x) printf("%c\n",x)
#define read(x) cin >> x
#define yes printf("YES\n")
#define no printf("NO\n")
#define pb push_back

void fast(){
ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
}

//////////////////////////////// - _ - \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

int main()
{
	fast();
	// debug(n);
	// showll(a);
	ll n,i,j,k,tmp;
	read(n);read(k);
	ll arr[n];
	ll mini[n];
	loop(i,0,n)
	{
		cin >> arr[i];
		mini[i] = inf;
	}

	
	mini[0] = 0;
	if(k<=n)
	{
		tmp = k;
	}
	else
	{
		tmp = n;
	}
	for(i=1;i<n;i++)
	{
		for(j=max(i-k,(ll)0);j<i;j++)
		{
			mini[i] = min(mini[i],abs(arr[i]-arr[j])+mini[j]);	 
		}
		
	}
	showll(mini[n-1]);
}	


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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int m, n;
	cin >> n >> m;
	int a[1000], b[1000], c[1000];
	for (int i = 0; i < m; i++) {
		cin >> a[i] >> b[i] >> c[i];
		a[i]--;
		b[i]--;
	}
	// Bellman-Ford
	int d[100][100];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) d[i][j] = 1001;
		d[i][i] = 0;
		bool update = true;
		while (update) {
			update = false;
			for (int j = 0; j < m; j++) {
				if (d[i][a[j]] > d[i][b[j]] + c[j]) {
					d[i][a[j]] = d[i][b[j]] + c[j];
					update = true;
				}
				else if (d[i][b[j]] > d[i][a[j]] + c[j]) {
					d[i][b[j]] = d[i][a[j]] + c[j];
					update = true;
				}
			}
		}
	}
	int ans = 0;
	for (int j = 0; j < m; j++) {
		if (d[a[j]][b[j]] < c[j]) ans++;
	}
	cout << ans << endl;

	return 0;
}

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

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  map<ll, bool> check;
  ll i = 1;
  while (i*i < 100000000) {
    check[i * i] = true;
    i++;
  }

  ll n,d;
  cin >> n >> d;
  vector<vector<ll>> x(n, vector<ll>(d));
  rep(i, n) {
    rep(j, d) {
      cin >> x[i][j];
    }
  }
  int ans = 0;
  rep(i, n) {
    rep_r(j, n, i+1) {
      ll total = 0;
      rep (k, d) {
        total += abs(x[i][k] - x[j][k]) * abs(x[i][k] - x[j][k]);
      }
      if (check[total]) ans += 1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 896
#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 FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
ll LCM(ll a,ll b){return (a*b)/GCD(a,b);}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	string s;
	int c[26] = {};
	cin >> s;
	REP(i, 4){
		c[s[i]-'A']++;
	}
	REP(i, 26){
		if (c[i] != 0 and c[i] != 2){
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define all(a) (a).begin(), (a).end()


int main () {
  int N;
  cin >> N;
  int pt = 0, px = 0, py = 0;
  rep(i,N) {
    int t, x, y;
    cin >> t >> x >> y;
    int dt = t - pt;
    int d = abs(x-px) + abs(y-py);
    if(d > dt || (dt % 2 != d %2)) {
      cout << "No" << endl;
      return 0;
    }
    pt = t, px = x, py = y;
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    #define int long long int
    #define pb push_back
    #define vi vector<int>
    #define loop(i,a,b) for(int i=a;i<b;i++)
    int32_t main()
    {
       
        #ifndef ONLINE_JUDGE
  freopen("input.txt" , "r" , stdin);
  freopen("output.txt" , "w" , stdout);
  #endif
           char ch;
           cin>>ch;
           if(ch>='A' && ch<='Z')
           	cout<<"A\n";
           else
           	cout<<"a\n";
    return 0;
}

Measured memory_bytes: 3560
l=list(input())
count=0
s=set()
arr=[]
val=0
while True:
    for i in range(len(l)):
        if(l[i]=='0'):
            val+=1
        if(len(arr)>0 and i not in s and((arr[-1]=='1' and l[i]=='0') or (arr[-1]=='0' and l[i]=='1'))):
            del arr[-1]
            count+=2
        else:
            arr.append(l[i])
            s.add(i)
    if(val==l.count('0')):
        break
    #print(count)
print(count)

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

int SUM(vector<int> v,int n){
int sum=0;
for(int i=0;i<n;i++){
  sum+=v[i];
}
return sum;
}

int main(){
int n;
cin>>n;
vector<int> v(n);
for(int i=0;i<v.size();i++){
  cin>>v[i];
}
sort(v.begin(),v.end());
if(SUM(v,n)>2*v.back()){
  cout<<"Yes"<<endl;
}
else cout<<"No"<<endl;
return 0;
}

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

int main(){
	int n,k;
	cin >> n >> k;
	vector<ll> a(n);
	ll s(0);
	rep(i,n){
		cin >> a[i];
		s+=a[i];
	}
	vector<ll> div;
	for(ll i(1);i*i<=s;++i){
		if(s%i == 0){
			div.push_back(i);
			if(i * i != s) div.push_back(s / i);
		}
	}
	sort(div.begin(),div.end());
	ll ans(0);
	rep(i,div.size()){
		ll d = div[i];
		auto b = a;
		ll s1(0),s2(0);
		rep(j,n){
			b[j] %= d;
			s1 += d-b[j];
		}
		sort(b.begin(),b.end());
		rep(j,n){
			s2 += b[j];
			s1 -= d-b[j];
			if(s1 == s2) break;
		}
		if(s2 <= k && ans < d) ans = d;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#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, X, T; cin >> N >> X >> T;
  cout << (N+X-1)/X * T << endl;
  return 0;
}

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

int main()
{
  int n; cin >> n;
  string s,t; cin >> s >> t;
  int hit = 0;
  for (int i = 0; i < n; i++)
  {
    int tmp = 0;
    for (int j = 0; j < n - i; j++)
    {
      int a = i + j;
      int b = n - i + j;
      if (s[a] == t[j])
      {
        tmp++;
        continue;
      }
      else 
      {
        tmp = 0;
        break;   
      }
    }
    hit = max(tmp, hit);
  }
  cout << 2 * n - hit << endl;
}

Measured memory_bytes: 3628
/*
* Welcome to my code!
*---------------------------------------------*
* author : lynmisakura(twitter : @andoreiji11)
*/
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <chrono>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define repn for(int i = 0;i < n;i++)
#define ain(a) for(auto& i : a)cin >> i;
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x.size()) 
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define cont continue

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using pi = pair<int,int>;
using vpi = vector<pi>;
using pl = pair<ll,ll>;
using vpl = vector<pl>;

template<class T> bool chmin(T& a,T b){if(a > b){a = b;return true;}else return false;}
template<class T> bool chmax(T& a,T b){if(a < b){a = b;return true;}else return false;}
template<class T> void print(std::vector<T> a){ int sz = a.size();
for(int i=0;i<a.size();i++)cout << a[i] << (i < sz-1 ? ' ' : '\n'); }
void ioboost(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}
///////////////////////////////////////////////////////////

int main(void){
  ioboost();

  int k;cin >> k;
  string s;cin >> s;
  if(s.size() <= k)cout << s << '\n';
  else cout << s.substr(0,k) << "..." << '\n';
}


Measured memory_bytes: 3652
cards=[""]*10

cnt=0
while True:
  tmp_cards = str(input())
  if tmp_cards == "-":
    break
    
  m = int(input())
  h = [0]*m
  
  for num in range(m):
    h[num] = int(input())
  
  for n in h:
    tmp_cards = tmp_cards[n:len(tmp_cards)]+tmp_cards[0:n]
  
  cards[cnt] = tmp_cards
  cnt=cnt+1
    
    
for ans in cards:
  if ans != "":
    print(ans)


Measured memory_bytes: 5596
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		int a = 0;
		int b = 0;
		java.util.Scanner stdIn = new Scanner(System.in);
		for(int i=0;i<4;i++){
			int p = stdIn.nextInt();
			a += p;
		}
		for(int i=0;i<4;i++){
			int p = stdIn.nextInt();
			b += p;
		}
		System.out.println(Math.max(a,b));
	}

}

Measured memory_bytes: 17232
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   double h, a;
   cin >> h >> a;
   cout << (int)ceil(h / a) << endl;
   return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int prime[1000000];

int main(void)
{
    int n;
    int cnt;
    int i, j;

    prime[2] = 1;
    for (i = 3; i < 1000000; i += 2){
        prime[i] = 1;
    }

    for (i = 3; i * i < 1000000; i += 2){
        if (prime[i] == 0){
            continue;
        }
        for (j = i * i; j < 1000000; j += i){
            prime[j] = 0;
        }
    }

    while (scanf("%d", &n) == 1){
        cnt = 0;
        for (i = 2; i <= n; i++){
            cnt += prime[i];
        }
        printf("%d\n", cnt);
    }

    return (0);
}

Measured memory_bytes: 4500
N = int(input())
l = 1
r = 1

for k in range(N):
	T, A = map(int, input().split())
	if l % T != 0:
		l += (T - l % T)
	if r % A != 0:
		r += (A - r % A)

	if l//T == r//A:
		()
	elif l//T > r//A:
		r = (l//T) * A
	else:
		l = (r//A) * T
print(l+r)


Measured memory_bytes: 42480
#include<bits/stdc++.h>
using namespace std;
int n,st[300010][30];
void work(){
	for(register int i=1;i<=n;++i)
	    for(register int j=1;j+(1<<i)-1<=(1<<n);j+=(1<<i)){
	    	int x=st[j][i-1],y=st[j+(1<<(i-1))][i-1];
	    	x==y?st[j][i]=y:st[j][i]=abs(x-y);
	    }
	return;
}
int main(){
	scanf("%d",&n);
	for(register int i=1;i<=1<<n;++i) scanf("%d",&st[i][0]);
	work();
	printf("%d\n",st[1][n]);
	return 0;
}

Measured memory_bytes: 33024