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

#define ff              first
#define ss              second
#define ll            long long

#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
//mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void sb()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
unordered_map<int, vector<int> > graph;
void insert_graph(int vertex1,int vertex2,bool bidirectional = 1){
    if(bidirectional){
        graph[vertex2].push_back(vertex1);
    }
    graph[vertex1].push_back(vertex2);

}
////////

int parent[200009];
////////////
void BFS(int root,int n){
    for(int i=1;i<=n;i++){
        
        parent[i]=-1;
    }
queue<int> q;
q.push(root);

parent[root] = -3;
while(!q.empty()){
    int curr = q.front();
    //cout<<parent<<"--"<<visited[parent]<<" ";
    //cout<<endl;
    q.pop();
    for(auto child: graph[curr]){
        if(parent[child] == -1 )
        {
            q.push(child);
            parent[child] = curr;
            
        }
    }

}

}
int main()
{
	//sb();
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        insert_graph(a,b);
    }
    BFS(1,n);
    int flag =0;
    for(int i=2;i<=n;i++){
        if(parent[i]==-1){
        flag = 1;
        break;
        }
    }
    if(flag)
    cout<<"No";
    else{
        cout<<"Yes"<<endl;
    for(int i=2;i<=n;i++)
    cout<<parent[i]<<endl;
    }




return 0;
}



Measured memory_bytes: 13660
#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 , m , x , y ;
    cin >> n >> m >> x >> y ;
    int ans_x = -105 ;
    int ans_y =  105 ;
    rep(i,n){
        int a ;
        cin >> a ;
        ans_x = max(ans_x,a) ;
    } 
    rep(i,m){
        int b ;
        cin >> b ;
        ans_y = min(ans_y,b) ;
    } 
    for(int z = x+1 ;z <= y ;z++ ){
        if(z > ans_x && z <= ans_y ){
            cout << "No War" << endl;
            return 0 ;
        }
    }
    cout << "War" << endl;
}

Measured memory_bytes: 3600
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
using namespace std;
typedef long long ll;
const int maxn = 1000 + 10;
const int N = 200000 + 10;
const int E = 1000000 + 10;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int DEBUG = 0;

ll flow, cost;
int S, T, n, h[N], ecnt;
struct enode{
	int v, n;
	ll w, c;
	int op;
	enode() {}
	enode(int _v, int _n, ll _w, ll _c, int _op):v(_v), n(_n), w(_w), c(_c), op(_op) {}
}e[E << 1];

inline void addedge(int u, int v, ll w, ll c) {
	c = - c;
	if(DEBUG) printf("%d %d %lld %lld\n", u, v, w, c);
	ecnt ++; e[ecnt] = enode(v,h[u],w,c,ecnt + 1); h[u] = ecnt;
	ecnt ++; e[ecnt] = enode(u,h[v],0,-c,ecnt - 1); h[v] = ecnt;
}

ll d[N];
int pre[N];
bool inq[N];
queue<int> q;

inline bool spfa() {
	for(int i = S;i <= T;i ++) d[i] = - INF;
	memset(inq,false,sizeof(inq));
	memset(pre,-1,sizeof(pre));
	while(!q.empty()) q.pop();
	q.push(S); d[S] = 0; inq[S] = 1; pre[S] = -1;
	while(!q.empty()) {
		int u = q.front(); q.pop();
		for(int i = h[u];~ i;i = e[i].n) {
			int v = e[i].v;
			if(e[i].w > 0 && d[v] < d[u] + e[i].c) {
				d[v] = d[u] + e[i].c;
				pre[v] = i;
				if(!inq[v]) {
					inq[v] = 1;
					q.push(v);
				}
			}
		}
		inq[u] = 0;
	}
	if(d[T] == - INF) return 0;
	ll tmp = INF, now = 0;
	for(int i = pre[T];~ i;i = pre[e[e[i].op].v]) {
		tmp = min(tmp,(ll)e[i].w);
	}
	for(int i = pre[T];~ i;i = pre[e[e[i].op].v]) {
		e[i].w -= tmp;
		e[e[i].op].w += tmp;
		now += (ll)tmp * e[i].c;
	}
	flow += tmp; cost += now;
	return 1;
}

inline void mcmf() {
	flow = cost = 0;
	while(spfa());
}

struct anode{
	int x, y, w;
	anode() {}
	anode(int _x, int _y, int _w):x(_x), y(_y), w(_w) {}
}a[maxn], b[maxn];
int Tmp[5];

int main() {
	scanf("%d", &n); ecnt = 0;
	memset(h,-1,sizeof(h)); 
	for(int i = 1;i <= n;i ++) {
		int x, y, w;
		scanf("%d%d%d", &x, &y, &w);
		a[i] = anode(x,y,w);
	}
	for(int i = 1;i <= n;i ++) {
		int x, y, w;
		scanf("%d%d%d", &x, &y, &w);
		b[i] = anode(x,y,w);
	}
	S = 0, T = n + n + 4 + 1;
	for(int i = 1;i <= 4;i ++) Tmp[i] = n + n + i;
	for(int i = 1;i <= n;i ++) {
		addedge(S,i,a[i].w,0);
		addedge(i,Tmp[1],INF,(ll)+ a[i].x + a[i].y);
		addedge(i,Tmp[2],INF,(ll)+ a[i].x - a[i].y);
		addedge(i,Tmp[3],INF,(ll)- a[i].x + a[i].y);
		addedge(i,Tmp[4],INF,(ll)- a[i].x - a[i].y);
	}
	for(int i = 1;i <= n;i ++) {
		addedge(i + n,T,b[i].w,0);
		addedge(Tmp[1],i + n,INF,(ll)- b[i].x - b[i].y);
		addedge(Tmp[2],i + n,INF,(ll)- b[i].x + b[i].y);
		addedge(Tmp[3],i + n,INF,(ll)+ b[i].x - b[i].y);
		addedge(Tmp[4],i + n,INF,(ll)+ b[i].x + b[i].y);
	}
	mcmf();
	printf("%lld\n", cost);
	return 0;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll; ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);
ll fac(ll x){if(x==0) return 1;  return x*fac(x-1);}

int main(){
    ll n;
    string s;
    cin>>n>>s;
    rep(i,s.size()){
        char a='A';
        a+=(s[i]-'A'+n)%26;
        cout<<a;
    }
    cout<<endl;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            total = 500 * i + 100 * j + 50 * k
            if total == x:
                count = count + 1

print(count)


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

int main() {
	int n,k;
  	string s;
  	cin >> n >> k;
  	cin >> s;
  	
  	if(s.at(k-1) == 'A') s.at(k-1) = 'a';
  	else if(s.at(k-1) == 'B') s.at(k-1) = 'b';
  	else if(s.at(k-1) == 'C') s.at(k-1) = 'c';
  
  	cout << s;
  
  	return 0;
}


Measured memory_bytes: 256
/*
ID: wangjun30
TASK:
LANG: C++
*/
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int num[26],num1[26];
int main(){
	vector<int> v1,v2;
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)
		num[s[i]-97]++;
	cin>>s;
	for(int i=0;i<s.size();i++)
		num1[s[i]-97]++;
	for(int i=0;i<26;i++){
		if(num[i])
			v1.push_back(num[i]);
		if(num1[i])
			v2.push_back(num1[i]);
	}
	sort(v1.begin(),v1.end());
	sort(v2.begin(),v2.end());
	if(v1.size()!=v2.size()){
		cout<<"No";
		return 0;
	}
	for(int i=0;i<v1.size();i++)
		if(v1[i]!=v2[i]){
			cout<<"No";
			return 0;
		}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 644
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        long H = scan.nextLong();
        int N = scan.nextInt();
        int A[] = new int[N];
        for(int i = 0; i < N; i++)
            A[i] = scan.nextInt();

        Arrays.sort(A);
        for(int i = N-1; i >= 0; i--){
            H -= A[i];
            if(H <= 0) break;
        }

        if(H <= 0)
            os.println("Yes");
        else
            os.println("No");
    }
}

Measured memory_bytes: 50408
N, W = map(int, input().split())
wv = [[0 for i in range(2)] for j in range(N)]

for i in range(N):
    w, v = map(int, input().split())
    wv[i] = [w, v]

dp = [[0 for i in range(2*W)] for j in range(2*N)]

for i in range(N):
    for j in range(W+1):
        if (j - wv[i][0] >= 0):
            dp[i+1][j] = max(dp[i+1][j], dp[i][j-wv[i][0]] + wv[i][1])
        dp[i+1][j] = max(dp[i+1][j], dp[i][j])

print(dp[N][W])

Measured memory_bytes: 488976
import math
n, m = [int(el) for el in input().split(' ')]
prime = 10**9 + 7

def f(x):
    return(math.factorial(x) % prime)

if  n == m:
    print((2 * f(n) * f(m)) % prime)
elif abs(n - m) == 1:
    print((f(n) * f(m)) % prime)
else:
    print(0)


Measured memory_bytes: 4092
#include <bits/stdc++.h>
#define PI 3.1415926535897932
#define _GLIBCXX_DEBUG
using namespace std;
long long GCD(long long A,long long B){
  if(B==0){
    return A;
  }
  else{
    return GCD(B,A%B);
  }
}
int main() {
  
  int K;
  cin>>K;
  
  long long ans=0;
  
  
  for(int i=1;i<=K;i++){
    for(int j=1;j<=K;j++){
      for(int l=1;l<=K;l++){
        ans+=GCD(GCD(i,j),l);
      }
    }
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int co[4] = { 0 };
int main(){
	for (int i = 0; i < 3; i++) {
		int a, b;
		cin >> a >> b;
		co[a - 1]++;
		co[b - 1]++;
	}
	sort(co, co + 4);
	if (co[0] == 1 && co[1] == 1 && co[2] == 2 && co[3] == 2) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	vector<vector<int>> c(3, vector <int> (3, 0));
	for (int ii = 0; ii < 3; ++ii){
		cin >> c[ii][0] >> c[ii][1] >> c[ii][2];
	}

	bool OK = true;
	for (int ii = 0; ii < 2; ++ii){
		for (int jj = ii + 1; jj < 3; ++jj){
			if ( (c[ii][1] - c[ii][0]) != (c[jj][1] - c[jj][0]) ){
				OK = false;
			}
			if ( (c[ii][2] - c[ii][0]) != (c[jj][2] - c[jj][0]) ){
				OK = false;
			}
			if ( (c[ii][2] - c[ii][1]) != (c[jj][2] - c[jj][1]) ){
				OK = false;
			}
		}
	}

	if (OK){
		cout << "Yes" << "\n";
	} else {
		cout << "No" << "\n";

	}

	

	return 0;
}


Measured memory_bytes: 256
n=int(input())
arr=list(map(int,input().split()))
for i in range(n-1):
  arr[i+1]+=arr[i]
ans=10**18
for i in range(n-1):
  x=arr[i]
  y=arr[n-1]-x
  tmp=abs(x-y)
  ans=min(ans,tmp)
print(ans)


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

using namespace std;
constexpr int64_t MOD = 1'000'000'007;
constexpr int     MAX =       2000'005;

int64_t fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
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;
    }
}

// 二項係数計算
int64_t 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;
}

template< typename T >
T mod_pow(T x, T n) {
    T ret = 1;
    while(n > 0) {
        if(n & 1) (ret *= x) %= MOD;
        (x *= x) %= MOD;
        n >>= 1;
    }
    return ret;
}

int main(void) {
    int K;
    string S;
    cin >> K >> S;
    // cout << mod_pow(26L, (int64_t)(K+S.size())) << endl;;

    // vector<int64_t> dp(S.size()+2);
    // vector<int64_t> dp2(S.size()+2);
    // dp[0] = 1;
    // while(K--) {
    //     for(int i=0; i<=S.size(); i++) {
    //         if(i == S.size()) {
    //             dp2[i] += dp[i] * 26;
    //             dp2[i] %= MOD;
    //         } else {
    //             dp2[i] += dp[i]*25;
    //             dp2[i] %= MOD;
    //             dp2[i+1] += dp[i];
    //             dp2[i+1] %= MOD;
    //         }
    //     }
    //     swap(dp, dp2);
    //     fill(dp2.begin(), dp2.end(), 0);
    // }

    // cout << dp[S.size()] << endl;

    COMinit();
    int N = S.size();
    int T = K + S.size();
    int64_t ans = 0;
    for(int i=N; i<=T; i++) {
        ans += COM(T, i) * mod_pow(25L, (int64_t)(T-i));
        ans %= MOD;
    }

    // int64_t ans = mod_pow(26, T);
    // for(int i=0; i<N; i++) {
    //     ans -= COM(T, i) * mod_pow(25, T-i);
    // }


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


Measured memory_bytes: 51220
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int s1[100100],s2[100100];
int cal(char a){
	if(a=='A') return 1;return 2;
}
int main()
{
	string s,t;int a,b,c,d,q;
	cin>>s;cin>>t;
	s1[0]=0;s2[0]=0;
	rep(i,s.size()) s1[i+1]=s1[i]+cal(s[i]);
	rep(i,t.size()) s2[i+1]=s2[i]+cal(t[i]);
	cin>>q;
	rep(i,q){
		cin>>a>>b>>c>>d;
		int x=s1[b]-s1[a-1],y=s2[d]-s2[c-1];
		if(x%3==y%3) cout<<"YES"<<endl;else cout<<"NO"<<endl;
	}
}


Measured memory_bytes: 1792
function Main(s) {
  s = s.split("\n");
  const q = +s[0];
  for(var i = 0; i < q; i++){
    var a = s[i+1].split(" ").map(a => +a);
    var b = Math.max(a[0], a[1]);
    a = Math.min(a[0], a[1]);
    var c = sqrt64(kakeru32(a,b));
    var d = c[1];
    c = c[0];
    var ans = c * 2;
    if(a === b)ans -= 2;
    else if(d === 0)ans -= 3;
    else if(c * (c + 1) < a * b)ans--;
    else ans -= 2;
    console.log(ans);
  }
}
function sqrt64(a){
  const al = a.length;
  var b, c;
  if(al & 1)b = +a[0];else b = +(a[0]+a[1]);
  c = Math.sqrt(b)|0;
  b -= c * c;
  var d = c;
  for(var i = 2 - (al & 1); i < al ; i += 2){
    d = (d + d % 10) * 10;
    b = +(b + a[i] + a[i+1]);
    for(var j = 1; j <= 9; j++){
      if(b - (d + j) * j < 0) break;
    }
    c = c * 10 + --j;
    b -= (d + j) * j;
    d += j;
  }
  return [c,b];
}
function kakeru32(a,b){
	var c = a % 1e5 * b;
	var d = Math.floor(a / 1e5) * b + Math.floor(c / 1e5);
	c %= 1e5;
	if(d > 0)c = ("00000" + c).slice(-5);
	else d = "";
	return d + c;
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 21448
H, W = map(int,input().split())
S = [list(input()) for i in range(H)]

Ans = []
for i in range(H+2) :
    Ansi = ["#" for x in range(W+2)]
    if i != 0 and i != H+1 :
        for j in range(W) :
            Ansi[j+1] = S[i-1][j]
    Ans.append(Ansi)

for i in range(H+2) :
    print("".join(Ans[i]))


Measured memory_bytes: 3188
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "{ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "}";

    return os;
}

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

    return res;
}


ll mod_inv(ll a, ll m) {
    ll b = m, u = 0, v = 1;
    while(a) {
        ll t = b / a;
        swap(b -= t * a, a);
        swap(u -= t * v, v);
    }

    return (u % m + m) % m;
}

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

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}





#ifdef LOCAL
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif


struct UnionFind{
        vector<int> par;

        UnionFind(int n): par(n, -1) {}
        void init(int n) { par.assign(n, -1); }

        int root(int x) {
            if (par[x] < 0) return x;
            return par[x] = root(par[x]); // path compression
        }

        bool issame(int a, int b) {
            return root(a) == root(b);
        }

        bool merge(int a, int b) {
            a = root(a); b = root(b);
            if (a == b) return false;

            // merge by size
            if(par[a] > par[b]) swap(a, b);
            par[a] += par[b];
            par[b] = a;
            return true;
        }

        int size(int x) {
            return -par[root(x)];
        }

    };


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    ll N, M; cin >> N >> M;

    int a[M], b[M];
    REP(i, M) {
        cin >> a[i] >> b[i], --a[i], --b[i];
    }

    UnionFind uf(N);
    vector<ll> ans;
    ll cur = N * (N - 1) / 2;
    REP(i, M) {
        ans.pb(cur);

        int ca = a[M-i-1], cb = b[M-i-1];

        if (uf.issame(ca, cb)) continue;

        ll as = uf.size(ca), bs = uf.size(cb);

        cur -= as * bs;

        uf.merge(ca, cb);
    }

    reverse(ans.begin(), ans.end());
    cout << fixed << setprecision(20);
    REP(i, M) cout << ans[i] << endl;

}


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
#define LIMIT 1000000007 //10^9+7
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define all(v) (v).begin(), (v).end()

namespace /* debug */{
  #define DEBUG(...) do{cout<<#__VA_ARGS__<<" = ";debug(__VA_ARGS__);}while(0) //変数
  #define ldebug(...) do{cout<<"["<<setw(3)<<__LINE__<<"] ";debug(__VA_ARGS__);}while(0) //行数
  #define lDEBUG(...) do{cout<<"["<<setw(3)<<__LINE__<<"] "<<#__VA_ARGS__<<" = ";debug(__VA_ARGS__);}while(0) //変数, 行数
  template<class T>void show(T&x){cout<<x<<" ";} //出力
  template<class T>void showendl(T&x){cout<<x<<endl;} //出力改行
  template<class P,class Q>void show(pair<P,Q>&x){cout<<"("<<x.first<<", "<<x.second<<") ";} //pair出力
  template<class P,class Q>void showendl(pair<P,Q>&x){cout<<"("<<x.first<<", "<<x.second<<")"<<endl;} //pair出力改行
  template<class H>void debug(H&&h){showendl(h);} //引数1つ
  template<class H,class...Ts>void debug(H&&h,Ts&&...ts){show(h);debug(forward<Ts>(ts)...);} //可変引数
  template<class T>void debug(vector<T>&vt){int i=0;for(auto x:vt)++i!=vt.size()?show(x):showendl(x);} //vector出力
  template<class T>void debug(initializer_list<T>init){int i=0;for(auto x:init)++i!=init.size()?show(x):showendl(x);} //初期化子リスト出力
}

ll f(ll n){
  if(n%2==0){
    return n ^ f(n-1);
  }else{
    return (n+1)/2%2;
  }
}

int main(){
	ll A,B;cin>>A>>B;
  ll ans =  f(A-1) ^ f(B);
  cout<<ans<<endl;
}

Measured memory_bytes: 3584
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('f1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


M = 10 ** 9 + 7
f = [1] * (2*10**6+4)
for i in range(1, 2*10**6+3):
  f[i] = f[i-1] * i
  f[i] %= M


def g(r, s):
  res = 1
  frs = f[r+s+2]
  fs = f[s+1]
  fr = f[r+1]

  res *= pow(fr, M-2, M)
  res *= pow(fs, M-2, M)

  res *= frs
  res %= M
  return res


def main():
    r1, c1, r2, c2 = read_int_list()
    res = 0
    res += g(r2, c2) - g(r2, c1-1) - g(r1-1, c2) + g(r1-1, c1-1)
    res %= M
    print(res)


main()


Measured memory_bytes: 83660
import sys
from math import factorial
from collections import Counter
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

n, m, x = MAP()
bene = [[0]*(m+1) for i in range(n)]
for i in range(n):
    a = LIST()
    bene[i] = a

def add(in1, in2):
    return [a + b for a, b in zip(in1, in2)]

bene = sorted(bene)
result = []
for n in range(1,len(bene)+1):
    for conb in itertools.combinations(bene, n):
        conb = list(conb)
        res = conb[0]
        for i in range(len(conb)-1):
            res = add(res, conb[i+1])
        result.append(res) 
result = sorted(result)

for i in range(len(result)):
    flag = True
    for j in range(m):
        if result[i][j+1] <x:
            flag = False
    if flag:
        print(result[i][0])
        sys.exit()
print(-1)

Measured memory_bytes: 74252
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_GRP_MAX		200000									// 最大グループ数

// 内部構造体 - グループ情報
typedef struct Grp {
	int miNo;													// グループ番号
	int miCnt;													// 人数
} Grp;

// 内部変数
static FILE *szpFpI;											// 入力
static Grp sz1Grp[D_GRP_MAX];									// グループ

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 最大値 - 取得
int
fGetMaxI(
	int piVal1					// <I> 値１
	, int piVal2				// <I> 値２
)
{
	if (piVal1 > piVal2) {
		return piVal1;
	}
	else {
		return piVal2;
	}
}

// グループ番号 - 取得
int
fGNoGet(
	int piNo					// <I> 配列番号 0～
)
{
	// グループ番号 - チェック
	if (piNo == sz1Grp[piNo].miNo) {
		return piNo;
	}

	// グループ番号 - 取得
	sz1Grp[piNo].miNo = fGNoGet(sz1Grp[piNo].miNo);

	return sz1Grp[piNo].miNo;
}

// 同一グループ化
int
fGrpConv(
	int piNo1					// <I> 配列番号１ 0～
	, int piNo2					// <I> 配列番号２ 0～
)
{
	// グループ番号 - 取得
	int liGNo1 = fGNoGet(piNo1);
	int liGNo2 = fGNoGet(piNo2);
	if (liGNo1 == liGNo2) {
		return 0;
	}

	// 同一グループ化
	sz1Grp[liGNo2].miNo = liGNo1;
	sz1Grp[liGNo1].miCnt += sz1Grp[liGNo2].miCnt;

	return sz1Grp[liGNo1].miCnt;
}

// 実行メイン
int
fMain(
)
{
	int i;
	char lc1Buf[1024];

	// 人数・関係数 - 取得
	int liHCnt, liRCnt;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d%d", &liHCnt, &liRCnt);

	// グループ番号 - 初期化
	for (i = 0; i < liHCnt; i++) {
		sz1Grp[i].miNo = i;
		sz1Grp[i].miCnt = 1;
	}

	// 関係 - 取得
	int liMax = 1;
	for (i = 0; i < liRCnt; i++) {
		int liNo1, liNo2;
		fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
		sscanf(lc1Buf, "%d%d", &liNo1, &liNo2);
		int liCnt = fGrpConv(liNo1 - 1, liNo2 - 1);
		liMax = fGetMaxI(liMax, liCnt);
	}

	return liMax;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 出力
	sprintf(lc1Buf, "%d\n", liRet);
	fOutLine(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 3332
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		
		long[] h = new long[N];
		
		for(int i = 0; i < N; i++) {
			h[i] = sc.nextLong();
		}
		
		Arrays.sort(h);
		long min = 1000000000;
		
		for(int i = K - 1; i < N; i++) {
			min = Math.min(h[i] - h[i - (K - 1)], min);
		}
		System.out.println(min);
		
	}
}


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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}
template <typename T>
T modinv(T a, const T m) {
  T b = m, u = 1, v = 0;
  while (b != 0) {
    const auto t = a / b;
    a -= t * b;
    std::swap(a, b);
    u -= t * v;
    std::swap(u, v);
  }
  u %= m;
  if (u < 0) {
    u += m;
  }
  return u;
}

int main() {
  int64_t n, a, b;
  std::cin >> n >> a >> b;

  constexpr int64_t mod = 1000000007;

  int64_t ans = 1;

  {
    int64_t i = 1;
    int64_t v = 2;

    while (i <= n) {
      if ((n & i) != 0) {
        ans *= v;
        ans %= mod;
      }
      i *= 2;
      v *= v;
      v %= mod;
    }
  }
  ans += mod - 1;
  ans %= mod;

  const auto comb = [n](const auto v) {
    int64_t ans = 1;
    for (int64_t i = 0; i < v; i++) {
      ans *= n - i;
      ans %= mod;
      ans *= modinv(i + 1, mod);
      ans %= mod;
    }
    return ans;
  };

  ans += mod - comb(a);
  ans %= mod;
  ans += mod - comb(b);
  ans %= mod;
  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1e09+7;



#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back






int main(){



  ll h;
  cin>>h;
  
  ll count=0;
  
  while (h>0){
    h/=2;
    count++;
  }
  
  ll answer=pow(2,count)-1;
  
  cout<<answer<<endl;
  

}




















Measured memory_bytes: 256
import string
from collections import Counter

alphabet_list = string.ascii_lowercase

sentences = []
while True:
    try:
        sentence = input().lower()
        sentences.append(sentence)
    except EOFError:
        break

sentence_flatten = ''.join(sentences)

count_list = Counter(sentence_flatten)

for alphabet in alphabet_list:
    print(f'{alphabet} : {count_list[alphabet]}')



Measured memory_bytes: 6696
#include<iostream>
#include<stdio.h>
#include<math.h>

#define PI 3.14159265f

using namespace std;


int main() {
	int a, b, C;
	double S, L, h;

	cin >> a >> b >> C;

	S = a*b*0.5*sin(C*PI / 180);
	L = a + b + sqrt(a*a + b*b - 2 * a*b*cos(C*PI / 180));
	h = b*sin(C*PI / 180);

	printf("%f %f %f\n", S, L, h);

	return 0;
}

Measured memory_bytes: 1212
#include <stdio.h>
#include <string.h>

int N;
char S[100] = {};

int isrev(char s[]){
    int i;char r[100] = {};
    for(i=0; i<strlen(s); i++){
        r[i] = s[strlen(s)-i-1];
    }
    if(strcmp(s, r)==0){
        return 1;
    }else{
        return 0;
    }
}

int main(){
    scanf("%s", S);
    N = strlen(S);
    int tuyo = isrev(S);
    int i;

    char s1[100] = {};
    for(i=0; i<(N-1)/2; i++){
        s1[i] = S[i];
    }
    tuyo += isrev(s1);
    
    char s2[100] = {};
    for(i=0; i<((N+5)/2); i++){
        s2[i] = S[(N+1)/2 +i];
    }
    tuyo += isrev(s2);
    if(tuyo == 3){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    string s;cin>>s;
    int ans=0;
    for(int i=1;i<=s.length()-1;i++){
        if(s[i]!=s[i-1])
            ans++;
        //cout<<s[i]<<ans<<endl;
    }
    cout<<ans<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------







Measured memory_bytes: 512
N,M = map(int,input().split())
A = list(map(int,input().split()))
sortedA = sorted(A)
CB = []
for i in range(M):
    B,C = map(int,input().split())
    CB.append([C,B])

CB.sort(reverse=True)

cnt = 0
goukei = 0
flag = True
flag2 = False
for i in range(M):
    Bi,Ci = CB[i][1],CB[i][0]
    # Bi = min(Bi,N-cnt-1)
    if Bi+cnt >= N:
        Bi = N-cnt-1
        flag2 = True

    if sortedA[cnt+Bi] <= Ci:
        if flag2:
            cnt += Bi
            goukei += (Bi+1)*Ci
            flag = False
            break
        else:
            cnt += Bi
            goukei += Bi*Ci
    elif sortedA[cnt] >= Ci:
        goukei += sum(sortedA[cnt:])
        flag = False
        break
    else:
        for x in sortedA[cnt:cnt+Bi+1]:
            if x <= Ci:
                goukei += Ci
            else:
                goukei += x
        goukei += sum(sortedA[cnt+Bi+1:])
        flag = False
        break
if flag:
  goukei += sum(sortedA[cnt:])

print(goukei)



Measured memory_bytes: 24876
import sys

sys.setrecursionlimit(10 ** 8)
n = int(input())

graph = [[] for _ in range(n)]
for i in range(n):
    graph[i] = list(map(lambda x: x - 1, list(map(int, input().split()))[2:]))

timestamp = [[] for _ in range(n)]
visited = [False] * n
cnt = 0


def dfs(v):
    global visited
    global cnt
    global timestamp
    cnt += 1
    timestamp[v].append(cnt)
    visited[v] = True
    for to in graph[v]:
        if visited[to]:
            continue
        else:
            dfs(to)
    cnt += 1
    timestamp[v].append(cnt)


dfs(0)

while False in visited:
    nxt = visited.index(False)
    dfs(nxt)


for i, (d, f) in enumerate(timestamp, 1):
    print(i, d, f)



Measured memory_bytes: 5668
#include<bits/stdc++.h>
using namespace std;
const int N =2e5+100;
int main()
{
    int n;
    char s[N];
    scanf("%d%s",&n,s);

    int sum =0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
            sum++;
    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
#define ll long long int
#define fab(a,b,i) for(int i=a;i<b;i++)
#define pb push_back
#define db double
#define mp make_pair
#define endl "\n"
#define f first
#define se second
#define all(x) x.begin(),x.end()
#define MOD 1000000007
#define quick ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
int n;
ll a[3005];
ll dp[3005][3005][2];
int turn;
ll recurse(int i,int j, int k)
{
    if(i>j)
        return 0;
    if(dp[i][j][k]!=-1)
        return dp[i][j][k];
    if(k==0) 
        dp[i][j][k]=max(recurse(i+1,j,1-k)+a[i],recurse(i,j-1,1-k)+a[j]);
        
    
    else
        dp[i][j][k]=min(recurse(i+1,j,1-k)-a[i],recurse(i,j-1,1-k)-a[j]);
    return dp[i][j][k];


}
int main()
{ quick;

    cin>>n;
    fab(0,n,i)
    cin>>a[i];
    memset(dp,-1,sizeof(dp));
    cout<<recurse(0,n-1,0);

 cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
    return 0;
}

Measured memory_bytes: 145052
#include<bits/stdc++.h>
using namespace std;
#define nn 800
int able[nn][nn];

int n,d1,d2;
void work(int x,int y){
	if(x%4==1){
		for(int i=0;i<n*2;i++) for(int j=0;j<n*2;j++) if((i/y+j/y)&1) able[i][j]=1;
	}
	if(x%4==2){
		for(int i=0;i<n*2;i++) for(int j=0;j<n*2;j++) if((i/y)&1) able[i][j]=1;
	}
	if(x%4==0){
		x/=4;
		work(x,y<<1);
	}
}
signed main(){
	cin>>n>>d1>>d2;
	work(d1,1);work(d2,1);
	
	
	int cnt=0;
	for(int i=0;i<n*2;i++) for(int j=0;j<n*2;j++) if(!able[i][j]){
		printf("%d %d\n",i,j);
		++cnt;if(cnt==n*n) return 0;
	}
	return 0;
}

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

int main()
{
  vector<int> vec(3);
  int count = 3;
  cin >> vec.at(0) >> vec.at(1) >> vec.at(2);

  sort(vec.begin(), vec.end());
  for(int i = 0; i < 2; i++)
  {
    if(vec.at(i) == vec.at(i + 1))
      count--;
  }
  
  cout << count << endl;
}

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

int main(){
    int h, w;
    cin >> h >> w;
    vector<vector<int>> distance(10, vector<int>(10));
    for (int i = 0; i < 10; i++){
        for (int j = 0; j < 10; j++){
            cin >> distance[i][j];
        }
    }
    for (int k = 0; k < 10; k++){
        for (int i = 0; i < 10; i++){
            for (int j = 0; j < 10; j++){
                distance[i][j] = min(distance[i][j], distance[i][k] + distance[k][j]);
            }
        }
    }
    vector<int> num(10, 0);
    int tmp;
    for (int i = 0; i < h*w; i++){
        cin >> tmp;
        if (tmp != - 1) num[tmp]++;
    }
    int ans = 0;
    for (int i = 0; i < 10; i++){
        ans += num[i] * distance[i][1];
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
while True:
    L = []
    H = []
    for _ in range(5):
        c = int(input())
        if c == 0:
            exit()
        L.append(c)

    h = set(L)

    if len(h) in [1, 3]:
        for _ in range(5):
            H.append(3)
    else:
        r = list(set([1,2,3])-h)[0]
        if r == 1:
            w = 2
        elif r == 2:
            w = 3
        else:
            w = 1
        for i in L:
            if i == w:
                H.append(1)
            else:
                H.append(2)
    for i in H:
        print(i)



Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
#define lson l, m, rt << 1
#define rson m + 1, r, rt << 1 | 1
const int MAX_N = 2e5 + 5;
const int INF = 1e6;
struct Segment_Tree
{
    struct Node{
        int seg, lazy;
    } T[MAX_N << 2];
    void push_up(int rt) {
        // 将 T[rt].seg 用 T[rt << 1].seg 和 T[rt << 1 | 1].seg 更新
        T[rt].seg = min(T[rt << 1].seg, T[rt << 1 | 1].seg);
    }
    void Build(int l, int r, int rt)
    {
        // 将 T[rt].seg 初始化为合适的值
        if (l == r) {
            // 将 T[rt].seg 初始化为合适的值
            T[rt].seg = INF;
            return;
        }
        int m = (l + r) >> 1;
        Build(lson);
        Build(rson);
        push_up(rt);
    }
    void Update(int L, int R, int c, int l, int r, int rt)
    {
        if (L <= l && r <= R) {
            // 用 c 更新 T[rt].lazy 和 T[rt].seg
            T[rt].seg = c;
            return;
        }
        int m = (l + r) >> 1;
        if (L <= m) Update(L, R, c, lson);
        if (R > m) Update(L, R, c, rson);
        push_up(rt);
    }
    int Query(int L, int R, int l, int r, int rt)
    {
        if (L <= l && r <= R) return T[rt].seg;
        int m = (l + r) >> 1;
        int ret = INF; // 将 ret 初始化为合适的值
        if (L <= m) ret = min(ret, Query(L, R, lson)); // 用 Query(L, R, lson) 更新 ret
        if (m < R) ret = min(ret, Query(L, R, rson)); // 用 Query(L, R, rson) 更新 ret
        return ret;
    }
} ST[2];
int n, a[MAX_N], pos[MAX_N];
struct cmp
{
    bool operator () (pair<int, int> &a, pair<int, int> &b) {
        int al = a.first, ar = a.second, bl = b.first, br = b.second;
        return ST[bl & 1].Query(bl, br, 1, n, 1) < ST[al & 1].Query(al, ar, 1, n, 1);
    }
};
priority_queue<pair<int, int>, vector<pair<int, int> >, cmp> pq;
int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        pos[a[i]] = i;
    }
    ST[0].Build(1, n, 1);
    ST[1].Build(1, n, 1);
    for (int i = 1; i <= n; i++) {
        if (i & 1) ST[1].Update(i, i, a[i], 1, n, 1);
        else ST[0].Update(i, i, a[i], 1, n, 1);
    }
    pq.push(make_pair(1, n));
    pair<int, int> t;
    int p, q, l, r, cnt = 0;
    while (!pq.empty()) {
        t = pq.top(); pq.pop();
        l = t.first, r = t.second;
        //printf("!%d %d\n", l, r);
        p = ST[l & 1].Query(l, r, 1, n, 1);
        q = ST[(l + 1) &1].Query(pos[p] + 1, r, 1, n, 1);
        cnt += 2;
        printf("%d %d%c", p, q, cnt == n ? '\n' : ' ');
        if (cnt == n) break;
        if (l < pos[p] - 1) pq.push(make_pair(l, pos[p] - 1));
        if (pos[p] + 1 < pos[q] - 1) pq.push(make_pair(pos[p] + 1, pos[q] - 1));
        if (pos[q] + 1 < r) pq.push(make_pair(pos[q] + 1, r));
    }
    return 0;
}


Measured memory_bytes: 14200
import numpy as np
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, d = map(int, readline().split())
x = np.array(read().split(), np.int64).reshape(n, d)

z = []
ans = 0

for i in range(400):
    z.append(pow(i, 2))

for i in range(n-1):
    for j in range(i+1, n):
        t = 0
        for k in range(d):
            t += pow(x[j][k] - x[i][k], 2)

        if t in z:
            ans += 1

print(ans)


Measured memory_bytes: 12424
/**
 * Author : RDP
 * There are no two words in the English language more harmful than "good job".
 * 1729 ;)
**/
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <numeric>
using namespace std;
using ll = long long;
#define endl '\n'
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) 
{
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define FAST_IO ios::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);
#define bp(x) __builtin_popcount(x)
#define zf(x) __builtin_clz(x)
#define zl(x) __builtin_ctz(x)
#define par(x) __bultin_parity(x)
#define all(x) (x).begin(), (x).end()
/* **************************************************************************************** */
int diff(string s, string t)
{
    int diff =0;
    for(int i = 0; i < s.length(); i ++)
    {
        if(s[i]!=t[i])
            diff++;
    }
    return diff;
}
void test_case()
{
    string s, t;
    cin >> s >> t;
    int ans = 1001;
    for(int i = 0; i <= s.length() - t.length(); i ++)
    {
        ans = min(ans, diff(s.substr(i, t.length()), t));
    }
    cout << ans << endl;
}
int main()
{
	FAST_IO
    int t = 1;
    //cin >> t;
    while(t--)
        test_case();
	return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    
           int n;
           cin >>n;
int cnt=0;
    vector<int> vec(n+1);
  
  vec[0]=0;
    for (int i = 1; i < n+1; i++) {
        cin>> vec.at(i);
      if(i%2==1 && vec[i]%2==1)cnt++;
    }
  
  cout << cnt <<endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<bits/stdc++.h>
#include<cctype>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include <string> 
#define ll long long
#define charToInt(c) (c-'0')
using namespace std;

bool pal(string s){
	ll n=s.length();
	ll i=0;ll j=n-1;
    if(i==j)
    return 1;
    ll f=0;
    while(i<j){
        if(s[i++]!=s[j--]){
            f=1;break;
        }
    }
    if(f==0)    return 1;
    else    return 0;
}


int main(){
string s;
cin>>s;
ll n=s.length();

if(pal(s.substr(0,(n-1)/2))&&pal(s)&&pal(s.substr((n+1)/2)))
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
return 0;
}


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


vector<int> prime_div(ll x)
{
	vector<int> ret;
	for(ll i=2;i<=(ll)sqrt(x);i++)
	{
		while(x%i==0)
		{
			x/=i;
			ret.push_back((int)i);
		}
	}
	if(x!=1) ret.push_back((int)x);
	return ret;
}
int main()
{
	ll N;
	cin>>N;
	vector<int> primes=prime_div(N);
	map<int,int> m;
	for(int x : primes)
	{
		m[x]++;
	}
	int ans=0;
	for(auto p : m)
	{
		int i=1;
		while(p.second-i>=0)
		{
			p.second-=i;
			i++;
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3728
#include<stdio.h>

int main(){

	int n,i;	
	scanf("%d\n",&n);

	for(i=3; i<=n; i++){
		if(i%3==0)	
			printf(" %d",i);
		else if(i%10==3 || (i/10)%10==3 || (i/100)%10==3 || (i/1000)%10==3 || (i/10000)%10==3)		
			printf(" %d",i);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 604
N, K = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
MOD = 10**9 + 7
dp = Array.new(N+1) {Array.new(N+1) {Array.new(256, 0)}}
dp[0][0][0] = 1
N.times do |i|
    (i+1).times do |j|
        256.times do |l|
            dp[i+1][j][l] += dp[i][j][l]
            dp[i+1][j][l] %= MOD
            dp[i+1][j+1][l^a[i]] += dp[i][j][l]
            dp[i+1][j+1][l^a[i]] %= MOD
        end
    end
end
ans = 0
c = 1
1.upto(N) do |i|
    c *= i
    ans += dp[N][i][K] * c % MOD
    ans %= MOD
end
puts ans


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

using namespace std;

int top, S[1000];

void push(int x){
    top++;
    S[top] = x;
}

int pop(){
    top--;
    return S[top+1];
}

int main(){
    top = 0;
    char s[100];
    int a, b;
    
    while(scanf("%s", s) != EOF){
        if(s[0] == '+'){
            a = pop();
            b = pop();
            push(a + b);
        }
        else if(s[0] == '-'){
            b = pop();
            a = pop();
            push(a - b);
        }
        else if(s[0] == '*'){
            a = pop();
            b = pop();
            push(a * b);
        }
        else{
            push(atoi(s));
        }
    }
    
    cout << pop() << endl;
}


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

int main()
{
    int n, m;
    cin >> n >> m ;
    int sum = 0 ;
    int a ;
    rep(i,m)
    {
        cin >> a ;
        sum+=a ;
    }
    if(sum>n)
    {
        cout << -1 << endl ;
    }    
    else
    {
        cout << n-sum << endl ;
    }
    
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

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

    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    sort(a.rbegin(), a.rend());

    int alice = 0, bob = 0;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) {
            alice += a[i];
        } else {
            bob += a[i];
        }
    }

    cout << alice - bob << endl;

    return 0;
}

Measured memory_bytes: 504
import std.conv, std.stdio, std.algorithm, std.string, std.range, std.math;

void main() {
  readln;
  const tako = readln.split.map!(to!int).array;
  const N    = tako.length;
    
  int z;
  foreach (x; 0..N) foreach (y; x+1..N) {
    z += tako[x]*tako[y];
  }
  z.writeln;
}

Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = (int) 1e5 + 5;
int n;
vector<int> g[maxn];

int read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    g[i].clear();
  }
  for (int i = 0; i < n - 1; i++) {
    int v, u;
    scanf("%d%d", &v, &u);
    v--;
    u--;
    g[v].push_back(u);
    g[u].push_back(v);
  }
  return true;
}

int dp[maxn];
int rdp[maxn];

void dfs(int v, int p) {
  dp[v] = false;
  for (int i = 0; i < sz(g[v]); i++) {
    int u = g[v][i];
    if (u == p) {
      continue;
    }
    dfs(u, v);
    if (!dp[u]) {
      dp[v] = true;
    }
  }
}

bool res;

void dfs1(int v, int p, int up) {
  int cnt = !up;
  for (int i = 0; i < sz(g[v]); i++) {
    int u = g[v][i];
    if (u == p) {
      continue;
    }
    if (!dp[u]) {
      cnt++;
    }
  }
  for (int i = 0; i < sz(g[v]); i++) {
    int u = g[v][i];
    if (u == p) {
      continue;
    }
    if (cnt - (!dp[u])) {
      rdp[u] = true;
    } else {
      rdp[u] = false;
    }
    dfs1(u, v, rdp[u]);
  }
  if (sz(g[v]) == 1) {
    int cur;
    if (p == -1) {
      cur = dp[g[v][0]];
    } else {
      cur = rdp[v];
    }
    if (cur) {
      res = true;
    }
  }
}

void solve() {
  res = false;
  dfs(0, -1);
  dfs1(0, -1, true);
  if (res) {
    printf("First\n");
  } else {
    printf("Second\n");
  }
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


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

int main() {
    int N, M, Q;
    cin >> N >> M >> Q;
    vector<int> L(M), R(M);
    vector<vector<int>> X(N + 1, vector<int>(N + 1));
    for (int i = 0; i < M; i++) {
        cin >> L[i] >> R[i];
        X[L[i]][R[i]]++;
    }
    vector<vector<int>> C(N + 1, vector<int>(N + 1));
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            C[i][j] = C[i][j - 1] + X[i][j];
        }
    }

    for (int i = 0; i < Q; i++) {
        int p, q;
        cin >> p >> q;
        int sum = 0;
        for (int j = p; j <= q; j++) {
            sum += C[j][q] - C[j][p - 1];
        }
        cout << sum << endl;
    }

    return 0;
}

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

int main() {
  int N, a, b, c, d;
  cin >> N;
  a = N/1000;
  b = N/100 - 10*a;
  c = N/10 - 100*a - 10*b;
  d = N - 1000*a - 100*b - 10*c;
  if (a == b&&b== c || b == c&&c== d) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3620