akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
 #include <cstdlib>
 #include <iostream>
 #include <fstream>
 #include <sstream>
 #include <set>
 #include <map>
 #include <vector>
 #include <list>
 #include <algorithm>
 #include <cstring>
 #include <cmath>
 #include <string>
 #include <stack>
 #include <queue>
 #include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
 #include <cassert>
 #include <iomanip>        //do setprecision
 #include <ctime>
 #include <complex>
 using namespace std;

 #define FOR(i,b,e) for(int i=(b);i<(e);++i)
 #define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
 #define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
 #define REP(x, n) for(int x = 0; x < (n); ++x)

 #define ST first
 #define ND second
 #define PB push_back
 #define PF push_front
 #define MP make_pair
 #define LL long long
 #define ULL unsigned LL
 #define LD long double
 #define pii pair<int,int>
 #define pll pair<LL,LL>

 const double pi = 3.14159265358979323846264;
 const int mod=1000000007;

 vector<int> i2g;          // i2g[i] := アイテム i の所属するグループの番号(find)
 vector<vector<int>> g2i;  // g2i[g] := グループ g に所属するアイテムたち

 void union_init(int n) {
   i2g.resize(n);
   g2i.resize(n);
   for (int i = 0; i < n; ++i) {
     // 最初はアイテム i はグループ i に所属
     i2g[i] = i;
     g2i[i].assign(1, i);
   }
 }

 int find(int i){
   return i2g[i];
 }

 // アイテム ia の所属するグループとアイテム ib の所属するグループを 1 つにする
 void merge(int ia, int ib) {
   if(i2g[ia]==i2g[ib])return;
   // ia の所属するグループが ib の所属するグループより小さくならないようにする
   if (g2i[i2g[ia]].size() < g2i[i2g[ib]].size()) {
     swap(ia, ib);
   }
   int ga = i2g[ia], gb = i2g[ib];
   // グループ gb に所属する全てのアイテムをグループ ga に移す
   for (int j : g2i[gb]) i2g[j] = ga;
   g2i[ga].insert(g2i[ga].end(), g2i[gb].begin(), g2i[gb].end());
   g2i[gb].clear();
 }

 // アイテム ia とアイテム ib は同じグループに所属しているか？
 bool is_same_group(int ia, int ib) {
   return i2g[ia] == i2g[ib];
 }


int main(){
	int n,m;
	cin>>n>>m;
	int ans=n;
	union_init(n);
	FOR(i,0,m){
		int a,b,c;
		cin>>a>>b>>c;
		a--;
		b--;
		if(!is_same_group(a,b)){
			merge(a,b);
			n--;
		}
	}
	cout<<n<<endl;
	return 0;
}


Measured memory_bytes: 9696
#include <stdio.h>

int main(void)
{
        int N,T,i,s=0,index,min=1001;
        scanf("%d%d",&N,&T);
        int c[N],t[N];
        for(i=0;i<N;i++)
                scanf("%d%d",&c[i],&t[i]);

        for(i=0;i<N;i++){
                if(t[i]<=T && min>c[i]){
                        min=c[i]; s++;
                }
        }
        if(s!=0) printf("%d\n",min);
        else printf("TLE\n");
        return 0;
}


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

static class MargeSort
{
    public static int mgc;
    public static IEnumerable<T> Sort<T>(IEnumerable<T> items, Comparison<T> compare)
    {
        if (items.Count() > 1)
        {
            int m = items.Count() / 2;
            var a1 = items.Take(m).ToArray();
            var a2 = items.Skip(m).ToArray();
            return Merge(Sort(a1, compare), Sort(a2, compare), compare);
        }
        return items;
    }

    private static IEnumerable<T> Merge<T>(IEnumerable<T> a1, IEnumerable<T> a2, Comparison<T> compare)
    {
        var ite1 = a1.GetEnumerator();
        var ite2 = a2.GetEnumerator();
        var exists1 = ite1.MoveNext();
        var exists2 = ite2.MoveNext();
        while (exists1 == true && exists2 == true)
        {
            T x1 = ite1.Current;
            T x2 = ite2.Current;
            if (compare(x1, x2) < 0)
            {
                yield return x1;
                exists1 = ite1.MoveNext();
            }
            else
            {
                yield return x2;
                exists2 = ite2.MoveNext();
            }
            mgc++;
        }
        while (exists1)
        {
            mgc++;
            yield return ite1.Current;
            exists1 = ite1.MoveNext();
        }
        while (exists2)
        {
            mgc++;
            yield return ite2.Current;
            exists2 = ite2.MoveNext();
        }
    }
}

public class hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        Console.WriteLine(string.Join(" ", MargeSort.Sort<int>(a, (x, y) => x - y)));
        Console.WriteLine(MargeSort.mgc);
    }
}



Measured memory_bytes: 132608
(defun answer-word (YYMM MMYY)
  (cond ((and YYMM MMYY) "AMBIGUOUS")
        ((and (not YYMM) MMYY) "MMYY")
        ((and YYMM (not MMYY)) "YYMM")
        (t "NA")))

(defun is-MM (n)
  (and (< 0 n)
       (< n 13)))

;(defun is-YY (n) t)

(defun can-YYMM (str)
  (is-MM (parse-integer (subseq str 2))))
(defun can-MMYY (str)
  (is-MM (parse-integer (subseq str 0 2))))

(let ((str (read-line)))
  (princ (answer-word (can-YYMM str) (can-MMYY str))))

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

int main() {
    string s;
    cin >> s;

    cout << s;
    if (s[s.size() - 1] == 's')
        cout << "es\n";
    else
        cout << "s\n";

    return 0;
}

Measured memory_bytes: 3588
#include<iostream>
#include<iomanip>

int main()
{
	double a, b, c, d, e, f, x, y;
	std::cout << std::fixed << std::setprecision(3);
	while (std::cin >> a >> b >> c >> d >> e >> f)
	{
		x = (c * e - b * f) / (a * e - b * d);
		y = (c * d - a * f) / (b * d - a * e);
		if (-0.001 < x && x < 0.001)
			x = 0;
		if (-0.001 < y && y < 0.001)
			y = 0;
		std::cout << x << " " << y << std::endl;
	}

	return 0;
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD = 1000000007;
const ll INF = 1061109567;
const double EPS = 1e-10;
int main(){
    int x,y;
    string s;
    cin>>x>>y;
    bool flag=false;
    int foot=0;
    for(int i=0;i<=x;i++){
        foot=2*i+4*(x-i);
        if(foot==y){
            flag=true;
        }
    }
    if(flag){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool prime(ll n) {
  if (n == 1) {
    return false;
  } else {
    for (ll i = 2; i <= (ll)pow(n, 0.5); i++) {
      if (n%i == 0) return false;
    }
  }
  return true;
}

int main() {
  ll n, m;
  cin >> n;
  vector <ll> a(n);
  rep(i, n) cin >> a.at(i);
  cin >> m;
  ll tmp = 0;
  rep(i, m) {
    ll b;
    cin >> b;
    ll left = 0, right = n;
    while (left < right) {
      ll mid = (left+right)/2;
      if (b == a.at(mid)) {
        tmp++;
        break;
      } else if (b < a.at(mid)) {
        right = mid;
      } else {
        left = mid + 1;
      }
    }
  }
  if (tmp == m) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }
}


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

typedef struct node {int key;  struct node *right,*left,*pr;} node;
node *root,*NIL;

node * treemin(node *x){
  while(x->left == NIL) x = x->left;
  return x;
}

node * find(node *u,int k){
  while(u != NIL && k != u->key)//uがNILまたはkeyが見つかったら抜ける。//
  { if(k < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}

node * treesuccessor(node *x){
  node *y = x->pr;
  if(x->right != NIL) return treemin(x->right);
  while(y != NIL && x == y->right){
    x = y;
    y = y->pr;
  }
  return y;
}

void treedelete(node *z){
  node *y; node *x;

  if(z->left == NIL || z->right == NIL) y = z;
  else y = treesuccessor(z);
  if(y->left != NIL) x = y->left;
  else x = y->right;

  if(x != NIL) x->pr = y->pr;
  if(y->pr == NIL) root = x;
  else{
    if(y == y->pr->left) y->pr->left = x;
    else y->pr->right = x;
  }

  if(y != z) z->key = y->key;
  free(y);
}

void insert(int k){
  node *y = NIL,*x = root,*z;
  z = (node *)malloc(sizeof(node));
  z->key = k; z->left = z->right = NIL;
  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->pr = y;
  if(y == NIL) root = z;
  else{
    if(z->key < y->key) y->left = z;
    else y->right = z;
  }
}
//中間順巡回//
void inP(node *u){
  if(u == NIL) return;
  inP(u->left);
  printf(" %d",u->key);
  inP(u->right);
}
//先行準巡回//
void preP(node *u){
  if(u == NIL) return;
  printf(" %d",u->key);
  preP(u->left);
  preP(u->right);
}

int main(){
  int n,i,key;
  node *t;
  char cmd[10];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",cmd);

    if(cmd[0] == 'f'){
      scanf("%d",&key);
      t = find(root,key);
      if(t != NIL) printf("yes\n");
      else printf("no\n");
    }else if(cmd[0] == 'i'){
      scanf("%d",&key);
      insert(key);
    }else if(cmd[0] == 'p'){
      inP(root);
      printf("\n");
      preP(root);
      printf("\n");
    }else if(cmd[0] == 'd'){
      scanf("%d",&key);
      treedelete(find(root,key));
    }
  }
  return 0;
}



Measured memory_bytes: 25124
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)(x).size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 102000;
int n,k;
void print(Vi a){
	assert(SZ(a)==n);
	rep(i,0,n-1)printf("%d ",a[i]+1);puts("");
}
Vi inv(Vi a){
//	puts("QaQ");print(a);
	Vi b(n,0);//rep(i,0,n-1)assert(a[i]<n);
	rep(i,0,n-1)b[a[i]]=i;
	return b;
}
Vi operator *(const Vi &p, const Vi &q){
//	puts("OwO");print(q);print(q);
	Vi a(n,0);
	rep(i,0,n-1)a[i]=q[p[i]];
	return a;
}
Vi mul(Vi p, Vi q){return p*q;}
Vi power(Vi a, int t){
	assert(SZ(a)==n);//t & n!!
	Vi res(n,0);rep(i,0,n-1)res[i]=i;
	while(t){
		if(t&1)res=res*a;a=a*a;t>>=1;
	}
	assert(SZ(res)==n);
	return res;
}
char flip(char c){return c>='a'&&c<='z'?c+'A'-'a':c+'a'-'A';}
int main() {
	read(n);read(k);Vi p(n,0),q(n,0);
	rep(i,0,n-1)read(p[i]),p[i]--;
	rep(i,0,n-1)read(q[i]),q[i]--;
	
	/*string a[N];
	a[1]="p";a[2]="q";
	rep(i,3,k){
		per(j,SZ(a[i-2])-1,0)a[i]+=flip(a[i-2][j]);
		rep(j,0,SZ(a[i-1])-1)
			if(!a[i].empty()&&a[i].back()==flip(a[i-1][j]))a[i].pop_back();
			else a[i]+=a[i-1][j];
	}
	
	rep(i,1,k){
		printf("%d(%d):",i,SZ(a[i])-SZ(a[i-1]));cout<<a[i]<<endl;
	}*/
	
	if(k<=6){
		Vi a[8];a[1]=p;a[2]=q;
		rep(i,3,k)a[i]=mul(inv(a[i-2]),a[i-1]);
		print(a[k]);return 0;
	}
	int c=k/6;//Q+(pqPQ)*(c-1)+???+(pQPq)*c
	Vi P=inv(p),Q=inv(q);//,tt=p*q*P*Q;
//	printf("done1 %d %d %d %d %d\n",SZ(p),SZ(q),SZ(P),SZ(Q),SZ(p*q*P*Q));
	Vi q233=power(p*q*P*Q,c-1);
	Vi res=mul(Q,q233);
//	puts("done1 yzr");
	int tmp=k%6;
	if(tmp==0)res=mul(res,p);
	if(tmp==1)res=mul(res,mul(p,q));
	if(tmp==2)res=mul(res,mul(mul(mul(p,q),P),q));
	if(tmp==3)res=mul(res,mul(mul(mul(mul(p,q),P),P),q));
	if(tmp==4)res=res*p*q*P*Q*P*q;
	if(tmp==5)res=res*p*q*P*Q*p*Q*P*q;
//	puts("done2");
	res=res*power(p*Q*P*q,c);
	print(res);
	/*print(p);print(q);
	rep(t,3,k){
		Vi w=mul(inv(p),q);p=q;q=w;print(w);
	}*/
	return 0;
}


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

#define ll long long
namespace flow{
	const ll __ = 1e6 + 7 , _ = 1e5 + 7;
	struct Edge{ll end , upEd , f , c;}Ed[__];
	ll head[_] , cntEd , S , T;
	void clear(){memset(head , 0 , sizeof(head)); cntEd = 1; S = T = 0;}
	void addEd(ll a , ll b , ll c , ll d){Ed[++cntEd] = (Edge){b , head[a] , c , d}; head[a] = cntEd;}
	void addE(ll a , ll b , ll c , ll d){addEd(a , b , c , d); addEd(b , a , 0 , -d);}

	bool vis[_]; queue < ll > q; ll dis[_] , pre[_];
	bool bfs(){
		q.push(S); memset(dis , -0x3f , sizeof(ll) * (T + 2)); dis[S] = 0;
		while(!q.empty()){
			ll t = q.front(); q.pop(); vis[t] = 0;
			for(ll i = head[t] ; i ; i = Ed[i].upEd)
				if(Ed[i].f && dis[Ed[i].end] < dis[t] + Ed[i].c){
					dis[Ed[i].end] = dis[t] + Ed[i].c; pre[Ed[i].end] = i;
					if(!vis[Ed[i].end]){vis[Ed[i].end] = 1; q.push(Ed[i].end);}
				}
		}
		return dis[T] != dis[T + 1];
	}
	
	ll EK(ll s , ll t , ll tarf , ll tarc){
		S = s; T = t; ll sum = 0;
		while(bfs()){
			ll cur = T; --tarf;
			while(cur != S){
				ll t = pre[cur]; cur = Ed[t ^ 1].end; --Ed[t].f; ++Ed[t ^ 1].f;
				if(Ed[t].c == 1e16) --tarc; else if(Ed[t].c == -1e16) ++tarc; else sum += Ed[t].c;
			}
		}
		return !tarf && !tarc ? sum : -1;
	}
}

ll bound[2][2][103] , N , M , X[83] , Y[83]; ll v[83];

signed main(){
	cin >> N; for(ll i = 1 ; i <= N ; ++i) cin >> X[i] >> Y[i] >> v[i];
	cin >> M; memset(bound , 0x3f , sizeof(bound));
	for(ll i = 1 ; i <= M ; ++i){
		char c; ll p , q; cin >> c >> p >> q;
		switch(c){
		case 'L': bound[0][0][p] = min(bound[0][0][p] , q); break;
		case 'R': bound[0][1][p] = min(bound[0][1][p] , q); break;
		case 'U': bound[1][0][p] = min(bound[1][0][p] , q); break;
		case 'D': bound[1][1][p] = min(bound[1][1][p] , q); break;
		}
	}
	ll ans = 0;
	for(ll i = 1 ; i <= N ; ++i){
		flow::clear(); bool flg = bound[0][0][100] >= i && bound[1][1][100] >= i; ll cnt = 0;
		for(ll j = 1 ; j <= 100 ; ++j){
			ll dwn = max(0ll , i - bound[0][0][j - 1]) , up = bound[0][1][j]; flg &= dwn <= up;
			cnt += dwn; flow::addE(j , j + 1 , dwn , (ll)1e16); flow::addE(j , j + 1 , up - dwn , 0);
		}
		for(ll j = 100 ; j ; --j){
			ll dwn = max(0ll , i - bound[1][1][j - 1]) , up = bound[1][0][j]; flg &= dwn <= up;
			cnt += dwn; flow::addE(202 - j , 203 - j , dwn , (ll)1e16); flow::addE(202 - j , 203 - j , up - dwn , 0);
		}
		for(ll j = 1 ; j <= N ; ++j) flow::addE(X[j] + 1 , 202 - Y[j] , 1 , v[j]);
		flow::addE(0 , 1 , i , 0); if(flg) ans = max(ans , flow::EK(0 , 202 , i , cnt));
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 2688
n, x = list(map(int, input().split()))

a = [1]
p = [1]
for i in range(1,n):
    a.append(a[i - 1] * 2 + 3)
    p.append(2 * p[i - 1] + 1)

def f(n, x):
    if n == 0:
        return 0 if x <= 0 else 1
    elif x <= 1 + a[n-1]:
        return f(n-1, x-1)
    else:
        return p[n-1] + 1 + f(n-1, x-2-a[n-1])
print(f(n,x))


Measured memory_bytes: 3064
using System;
using System.Collections;
using System.Collections.Generic;

class Program {
    static void Main (string[] args) {
        long N = long.Parse (Console.ReadLine ());
        long ans = 0;
        for (long k = 1; k <= N; k++) {
            ans += (k + (N - N % k)) * (long) Math.Floor ((double) N / (double) k) / 2;
        }

        Console.WriteLine (ans);
    }

}

//dotnet run --project test

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


struct store
{
    ll can;
    ll price;
};
bool compare( struct store a , struct store b)
{
    return a.price< b.price;
}
int main()
{
    ll n;
    cin>>n;
    ll m;
    cin>>m;

    store* shop = new store[n];
    for(ll i=0; i < n; i++)
    {
        cin>>shop[i].price>>shop[i].can;
    }
    sort( shop , shop +n , compare);
//    for(int i=0;i<n;i++)
//    {
//        cout<<shop[i].price <<" "<<shop[i].can<<endl;
//    }
    ll index =0;
    ll ans =0;
    while( m>0)
    {
        if( m> shop[index].can )
        {
            m = m-shop[index].can;
            ans += shop[index].can*shop[index].price;
        } else
        {

            ans += m*shop[index].price;
            m =0;
        }
        index++;
    }
    cout<<ans;
}

Measured memory_bytes: 5160
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define nmax_def 110000
#define Cmax_def 2200
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main() {
	int N;
	cin >> N;
	int ans = -1;
	rep(i, 100000) {
		int Ntmp = i * 1.08;
		if (N == Ntmp)
			ans = i;
	}
	if (ans == -1)
		cout << ":(" << endl;
	else
		cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> v(N);
  vector<int> tmp(N);
  int b = 0;
  long long  result = 0;
  
  for(int i = 0; i < N; i++){
  	cin >> v[i];
    tmp[i] = v[i] - i - 1;
  }
  //bを求める
  sort(tmp.begin(), tmp.end());
  b = tmp[N/2];
  
  for(int i = 0; i < N; i++){
  	tmp[i] -= b;
  }
  for(int i = 0; i < N; i++){
  	result += abs(tmp[i]);
  }
  cout << result << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

void change(int *x, int *y);

int a,b,x;

int main(void){
	scanf("%d %d %d", &a, &b, &x);

	if(x >= a && x <= a+b)	printf("YES");
	else	printf("NO");

	return 0;
}

void change(int *x, int *y){
	int z;
	z = *x;
	*x = *y;
	*y = z;
}

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

const int INF = 2e9;

template <typename T>
vector<vector<T>> warshall_floyd(int n, vector<vector<T>> d) {

  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) 
      for (int j = 0; j < n; j++) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
  }
  return d;
}
int main(){
  int n;
  cin >> n;

  vector<vector<int> > a(n,vector<int>(n));
  ll res = 0;
  rep(i,n) rep(j,n) cin >> a[i][j];
  rep(i,n) rep(j,n) {
    if (a[i][j] == 0) continue;
    res += a[i][j];
  }
  res /= 2;
  auto dist = warshall_floyd<int>(n,a);
  vector<vector<bool>> memo(n,vector<bool>(n,false));
  for (int k = 0; k < n ; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = i+1; j < n; j++) {
        if (a[i][j] != dist[i][j]) {
          puts("-1");
          return 0;
        }
        if (i == j || j == k || k == i) continue;
        if (dist[i][j] == dist[i][k] + dist[k][j] && !memo[i][j]) {
          memo[i][j] = true;
          res -= dist[i][j];
        }
      }
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

int main(void) {

  while (true) {
    int m, min, max;
    cin >> m >> min >> max;
    if (m == 0 && min == 0 && max == 0) break;

    int p[m];
    for (int i = 0; i < m; i++)
      cin >> p[i];
    vector<pair<int,int> > g;

    for (int i = min; i <= max; i++) {
      pair<int,int> tmp = make_pair(i,p[i-1]-p[i]);
      //cout << tmp.first << " " << tmp.second << endl;
      
      g.push_back(tmp);
    }

    int gmax = -1;
    int n;
    for (int i = 0; i < g.size(); i++) {
      pair<int,int> tmp = g[i];
      if (gmax <= tmp.second) {
	n = tmp.first;
	gmax = tmp.second;
      }
    }
    cout << n << endl;
    
  }

  return 0;
  
}

Measured memory_bytes: 3060
def is_same_as_ptypes(j, ptypes):
  for x,y in A[j]:
    if ptypes[x] != str(y):
      return False
  return True  
  

N = int(input())
A = {i:[] for i in range(N)}
for i in range(N):
  for _ in range(int(input())):
    x,y = map(int,input().split())
    A[i].append([x-1,y])

ans = 0
for i in range(2**N):
  ptypes = bin(i)[2:].zfill(N)
  flag = True
  for j in range(len(ptypes)):
    if ptypes[j] == '0':continue
    if is_same_as_ptypes(j,ptypes) is False:
      flag = False
  if flag is True: ans = max(ptypes.count('1'), ans)
print(ans)

Measured memory_bytes: 45020
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define rep(i,n) for(int i=0;i<n;i++)
int gcd(int a, int b){
    int r=1;
    while(r!=0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
void revStr(char* str){
    int size = strlen(str);
    int i,j;
    char tmp = {0};
    for(i = 0, j = size - 1; i < size / 2; i++, j--){
        tmp = str[i];
        str[i] = str[j];
        str[j] = tmp;
    }return;
}
struct data{
    int a,b,c;
};

//降順
int compare_int(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}
#define MAXSIZE 200000
int list[MAXSIZE];
int tail;

void Init(void){
    tail=0;
}
int Top(void){
    return 0;
}

int Next(int pos){
    if(pos<tail-1){
        return pos+1;
    }else{
        return -1;
    }
}
int Count(void){
    return tail;
}

int Item(int pos){
    if((pos>=0)&&(pos<tail)){
        return list[pos];
    }else{
        return 0;
    }
}
void Add(int value){
    if(tail<MAXSIZE){
        list[tail]=value;
        tail++;
    }
}
void Delete(int pos){
    if((pos>=0)&&(pos<tail)){
        int i;
        for(i=pos;i<tail-1;i++){
            list[i]=list[i+1];
        }
        tail--;
    }
}

int main(){
    int a,b;
    int sum=1;
    int i=0;
    scanf("%d%d",&a,&b);
    while(sum<b){
        sum--;
        sum+=a;
        i++;
    }
    printf("%d",i);
}


Measured memory_bytes: 1700
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++) 

using namespace std;

int main() {
  int n;cin>>n;
  int ans=0;
  for(int i=1;i<=n;i++){
    int cnt=0;
    if(i%2==1){
      for(int j=1;j<=i;j++){
        if(i%j==0)cnt++;
      }
      if(cnt==8)ans++;
    }
  }
  cout<<ans<<endl;
}

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}  
vector<ll>z_algorithm(string s){
  ll n = s.size();
  vector<ll>ret(n,0);
  ret[0] = n;
  ll p = 1,len = 0;
  while(p < n){
    while(p+len < n && s[len] == s[p+len])len++;
    ret[p] = len;
    if(len == 0){p++; continue;}
    ll k = 1;
    while(p+k < n && k+ret[k] < len)ret[p+k] = ret[k], k++;
    p += k, len -= k;
  }
  return ret;
}
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  string s;cin>>s;
  ll n=s.size();
  rep(i,0,n-1)if(s[i]!=s[i+1])judge=false;
  if(judge){
    cout<<n<<endl;
    cout<<1<<endl;
    return 0;
  }
  auto v=z_algorithm(s);
  auto vr=z_algorithm(string(ALLR(s)));
  vector<bool>t(n),tr(n);
  rep(i,1,n+1){
    for(ll j=i;j<n;j+=i){
      if(v[j]>=i)t[j+i-1]=true;
      else break;
    }
    for(ll j=i;j<n;j+=i){
      if(vr[j]>=i)tr[n-(j+i)]=true;
      else break;
    }
  }
  if(!t[n-1]){
    cout<<1<<endl;
    cout<<1<<endl;
    return 0;
  }
  rep(i,0,n-1){
    if(!t[i]&&!tr[i+1])res++;
  }
  cout<<2<<endl;
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 9012
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	string S;
	cin >> S;
	if( S.at(0) != 'A' ){
		cout << "WA" << endl;
		return 0;
	}
	int cdex = 0;
	for( int i = 2; i < S.l_ength()-1; ++i ){
		if( S.at(i) == 'C' ){
			if( cdex != 0 ){
				cout << "WA" << endl;
				return 0;
			}
			cdex = i;
		}
	}
	if( cdex == 0 ){
		cout << "WA" << endl;
		return 0;
	}
	for( int i = 1; i < S.l_ength(); ++i ){
		if( i != cdex && S.at(i) < 'a' || S.at(i) > 'z' ){
			cout << "WA" << endl;
			return 0;
		}
	}
	cout << "AC" << endl;
	return 0;
}

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

typedef long long ll;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint dp[61][2][2][2];
/*
the first dimension is about the bit position
the second dimension is whether x >= l
the third dimension is whether y <= r
ther last dimension is whether the first "1"bit is placed 
*/


int main()
{
    ll l, r;
    cin >> l >> r;
    // 59<log(10^18)<60
    dp[60][0][0][0] = 1;
    //process from the high bit position to low bit position
    for (int i = 59; i >= 0; i--)
    {
        //take out the ith bit of l and r
        int lb = l >> i & 1;
        int rb = r >> i & 1;
        for (int j = 0; j < 2; j++)
        for (int k = 0; k < 2; k++)
        for (int s = 0; s < 2; s++)
        {
            //the previous state
            mint pre = dp[i + 1][j][k][s];
            /*
            there are 3 possibilities for next state
            they are all about the ith bit position
            1. x = 1, y = 1
            2. x = 0, y = 0
            3. x = 0, y = 1
            */
            for (int x = 0; x < 2; x++)
            for (int y = 0; y < 2; y++)
            {
                // x = 1, y = 0 is impossible
                if (x && !y) continue;
                // for next state
                int nj = j, nk = k, ns = s; 
                //s = 0, which means the first 1bit is not placed. Under this condition, x = y = 0
                if (!s && x != y) continue; 
                // if the first 1bit is set
                if (x && y) ns = 1;
                // if x < l
                if (!j && !x && lb) continue;
                if (x && !lb) nj = 1;
                // if y > r
                if (!k && y && !rb) continue;
                if (!y && rb) nk = 1;
                // the ans of next state += previous state
                dp[i][nj][nk][ns] += pre;
            }
        }
    }
    mint ans;
    // add up the ans
    for (int j = 0; j < 2; j++)
    for (int k = 0; k < 2; k++)
    for (int s = 0; s < 2; s++)
    ans += dp[0][j][k][s];
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
e_list = [[] for i in range(N)]
for i in range(N-1):
    u,v,w = map(int,input().split())
    w %= 2
    e_list[u-1].append([v-1,w])
    e_list[v-1].append([u-1,w])

stack = [0]
ans = [-1]*N
ans[0] = 0
while stack:
    x = stack.pop()
    for v,w in e_list[x]:
        if ans[v] != -1:
            continue
        else:
            ans[v] = ans[x]^w
            stack.append(v)
print(*ans,sep='\n')

Measured memory_bytes: 80288
n = int(input())
xys = [[] for _ in range(n)]
for i in range(n):
    a = int(input())
    for j in range(a):
        x, y = map(int, input().split())
        xys[i].append((x-1, y))

def digitsum(x, base=2):
    ret = 0
    while x>0:
        ret += x % base
        x = x // base
    return ret

ans = 0
for i in range(1<<n):
    ok = True
    for j in range(n):
        # if jth person may be honest, verify testimony of him.
        if (i>>j) & 1 == 1:
            for xy in xys[j]:
                x, y = xy
                if (i>>x) & 1 != y:
                    ok = False
                    break
        if not ok:
            break
    if ok:
        ans = max(ans, digitsum(i))
print(ans)

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

using namespace std;

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

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

int N;
vector<string> S;
void solve() {
    int cnt = 0;
    string ans = "YES";
    rep(i, N) {
        if (S[i] == "A")
            cnt++;
        else
            cnt--;
        if (cnt < 0) {
            ans = "NO";
            break;
        }
    }
    if (cnt != 0) ans = "NO";
    cout << ans << endl;
}
int main() {
    while (cin >> N) {
        S.resize(N);
        rep(i, N) cin >> S[i];
        solve();
    }

    return 0;
}

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

void bye() { std::cout << "NO" << std::endl; exit(0); }
int ind[410], oud[410], fa[410], idx;
int p[210][2], hav[410];
int n, H;
int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
int newnode() { ++idx; fa[idx] = idx; return idx; }
int get(int x, int b) { return p[x][b] ? p[x][b] : p[x][b] = newnode(); }
void adde(int b, int e) { ++ind[e], ++oud[b]; fa[find(b)] = find(e); }
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n >> H;
	for (int i = 1; i <= n; ++i) {
		int a, b, c, d;
		std::cin >> a >> b >> c >> d;
		adde(c ? get(c, 1) : get(a, 0), d ? get(d, 0) : get(b, 1));
	}
	for (int i = 1; i <= H; ++i) {
		if (int t = p[i][0]) {
			if (ind[t] > oud[t]) bye(); hav[find(t)] |= ind[t] != oud[t];
		}
		if (int t = p[i][1]) {
			if (ind[t] < oud[t]) bye(); hav[find(t)] |= ind[t] != oud[t];
		}
	}
	for (int i = 1; i <= idx; ++i) if (fa[i] == i && !hav[i]) bye();
	std::cout << "YES" << std::endl;
	return 0;
}


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

using namespace std;

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

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


signed main() {

	int V,E; cin2(V,E);

	vvi edge(V,vi(V,INF));

	rep(i,0,E) {
		int s,t; cin2(s,t);
		int d; cin >> d;
		edge[s][t] = d;
	}
	vvi dp((1 << V),vi(V, INF));
	dp[0][0]=0;

	rep(i,0,(1 << V)) {
		rep(j,0,V) {
			rep(k,0,V) {
				if ((i & (1 << k)) != 0) continue;

				int cost = dp[i][j] + edge[j][k];
				if (cost < dp[i | (1 << k)][k]) {
					dp[i | (1 << k)][k] = cost;
				}
			}
		}
	}

	if(dp[(1 << V)-1][0] == INF){
		cout << -1 << endl;
	}else {
		cout << dp[(1 << V)-1][0] << endl;
	}
	return 0;
}

Measured memory_bytes: 7584
/*input
1
1

*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
#include <fstream>
#include <stack>

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int n;
  cin >> n;
  vector<int> vec;
  int v;
  map<int, int> mp;
  for (int i = 0; i < n; i++) {
    cin >> v;
    vec.pb(v);
    mp[v]++;
  }  
  int ans = 0;
  for (auto it : mp) {
    if (it.S != it.F) {
      if (it.S > it.F)
        ans += it.S - it.F;
      else
        ans += it.S;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 8064
data = list(map(str,input().split()))
stack = []
op1 = 0
op2 = 0
k = 0
for i in data:
# print(i,type(i))
  if(i == "+" or i == "-" or i == "*" or i == "/"):
    op1 = stack.pop()
    op2 = stack.pop()
    if(i == "+"): stack.append(op2+op1)
    elif(i == "-"): stack.append(op2-op1)
    elif(i == "*"): stack.append(op2*op1)
    elif(i == "/"): stack.append(int(op2/op1))
  else:
    stack.append(int(i))


print(stack.pop())



Measured memory_bytes: 5596
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

ll C(ll n, ll k) {
  if (k == 0) return 1;
  return (C(n, k-1) * (n+1-k)) / k;
}

int N, A, B;
ll v[60];
ll maxi, mini;

int cnt(ll x) {
  int ans = 0;
  for (auto i = 0; i < N; ++i) {
    if (v[i] == x) ++ans;
  }
  return ans;
}

int gre(ll x) {
  int ans = 0;
  for (auto i = 0; i < N; ++i) {
    if (v[i] > x) ++ans;
  }
  return ans;  
}

void solve1() {
  int c = cnt(maxi);
  // cerr << c << endl;
  ll ans = 0;
  for (ll i = A; i <= min(c, B); ++i) {
    ans += C(c, i);
  }
  cout << ans << endl;
}

void solve2() {
  int c = cnt(mini);
  int d = gre(mini);
  cout << C(c, A-d) << endl;
}

int main() {
  cin >> N >> A >> B;
  for (auto i = 0; i < N; ++i) {
    cin >> v[i];
  }
  sort(v, v+N);
  reverse(v, v+N);
  maxi = v[0];
  mini = v[A-1];
  if (maxi == mini) {
    cout << maxi << endl;
    solve1();
  } else {
    double sum = 0;
    for (auto i = 0; i < A; ++i) {
      sum += v[i];
    }
    cout << fixed << setprecision(10) << sum/A << endl;
    solve2();
  }
}


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

#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<long long,long long>
#define FOR(i,a,b)  for(long long i=a;i<b;++i)
#define RFOR(i,a,b) for(long long i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        400005
#define all(v)      v.begin(),v.end()
#define sz(x)       (long long)x.size()
//#define mod         1000000007
#define pqueue      priority_queue<long long>
#define pdqueue     priority_queue< long long,vector<long long> ,greater< long long >>
 
typedef long long ll;
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//const long long md = 998244353;
 
/*const long long mod = 998244353;
long long power(long long a,long long n)
{
	if(n == 1)return a%mod;
	if(n == 0)return 1;
	if(n&1)return ((a%mod)*(power((a*a)%mod,n/2))%mod)%mod;
	return power((a*a)%mod,n/2)%mod;
}
*/

int c[40];
vector<ll> x;

ll calc(ll z)
{
	ll ans = 0;
	FOR (i,0,x.size()) {
		ans += z ^ x[i];
	}

	return ans;
}

int main()
{
	ll n,k;
	cin >> n >> k;

	x.resize(n);
	FOR (i,0,40)
		c[i] = 0;

	ll m;
	FOR (i,0,n) {
		cin >> x[i];
		m = 1;
		FOR (j,0,40) {
			if ((x[i] & m)!= 0) c[j]++;
			m <<= 1;
		}
	}

	ll y = 0;
	m = 1LL << 39;
	// cerr << "n= " << n << ", c[3]=" << c[3] << ", c[2]=" << c[2] << ", c[1]=" << c[1] << ", c[0]=" << c[0] << endl;
	RFOR (i, 39, -1) {
		if (n - c[i] > c[i])
			y |= m;
		m >>= 1;
	}

	// cerr << "y= " << std::bitset<40>(y) << endl;
	// cerr << "k= " << std::bitset<40>(k) << endl;
	ll ans = calc(0);
	ll z = 0;
	m = 1LL << 39;
	RFOR (i, 39, -1) {
		if ((k & m) == 0) {
			y &= (~m);
		} else {
			ans = max(calc(y & ~m), ans);
			// cerr << "x= " << std::bitset<40>(y & ~m) << endl;
			y |= m;
		}
		m >>= 1;
	}
	ans = max(calc(k), ans);

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


Measured memory_bytes: 1152
#include <algorithm>
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main()
{
    int N;
    cin >> N;
    int person = 0;
    for (int i = 0; i < N; ++i)
    {
        int Li, Ri;
        cin >> Li >> Ri;
        person += Ri - Li + 1;
    }
    cout << person << endl;

    return 0;
}

Measured memory_bytes: 256
#[doc = " https://github.com/hatoo/competitive-rust-snippets"]
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
mod util {
    use std::fmt::Debug;
    use std::io::{stdin, stdout, BufWriter, StdoutLock};
    use std::str::FromStr;
    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    #[allow(dead_code)]
    pub fn chars() -> Vec<char> {
        line().chars().collect()
    }
    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
    #[allow(dead_code)]
    pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
        let out = stdout();
        let writer = BufWriter::new(out.lock());
        f(writer)
    }
}
#[allow(unused_macros)]
macro_rules ! get { ( [ $ t : ty ] ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . split_whitespace ( ) . map ( | t | t . parse ::<$ t > ( ) . unwrap ( ) ) . collect ::< Vec < _ >> ( ) } } ; ( [ $ t : ty ] ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( [ $ t ] ) ) . collect ::< Vec < _ >> ( ) } ; ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; let mut iter = line . split_whitespace ( ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; ( $ t : ty ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ ( $ t : ty ) ,*; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ ( $ t ) ,* ) ) . collect ::< Vec < _ >> ( ) } ; }
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }
const BIG_STACK_SIZE: bool = true;
#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}
fn solve() {
    let (a, b) = get!(usize, usize);
    if b % a == 0 {
        println!("{}", a + b);
    } else {
        println!("{}", b - a);
    }
}


Measured memory_bytes: 8572
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s; cin >> s; int N = (int) s.size();
  string t = "";
  for(int i = 0; i < N; i++){
    if(i%2){ t += "p";} else{ t += "g";}}
  long long ans = 0;
  for(int i = 0; i < N; i++){
    if(t[i]=='g'){ if(s[i]=='p'){  ans--;}} else{ if(s[i]=='g'){ ans++;}}
  }
  cout << ans << endl; 
 return 0;}

Measured memory_bytes: 640
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools


#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]

x = list(map(int,input().split()))
ans = 0

print(x.index(0)+1)




Measured memory_bytes: 68704
#include<bits/stdc++.h>
#define maxn 100005
using namespace std;

int n,k,a[maxn],s=0;
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&a[i]);
		s+=(a[i]>=k);
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 640
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: i32,
        b: i32,
        c: i32,
        d: i32,
    }
    use std::cmp::min;
    println!("{}", min(a,b) + min(c,d));
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)

using namespace std;
typedef long long int ll;

int N, K;
int P[100];
int C[100];
int main(void){
    cin >> N >> K;
    int d, e;
    REP(i,K){
        cin >> d;
        REP(j,d){
            cin >> e;
            C[e-1]++;
        }
    }
    int ans = 0;
    REP(i,N){
        if(C[i] == 0) ans++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3672
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ll n;
	cin>>n;
	string s;
	cin>>s;

	ll er[n],ge[n],be[n];
	for(ll i=0; i<n; i++)
	{
		er[i]=0;ge[i]=0;be[i]=0;
	}
	if(s[0]=='R') er[0]++;
	else if(s[0]=='G') ge[0]++;
	else be[0]++;
	for(ll i=1; i<n; i++)
	{
		er[i]=er[i-1];
		ge[i]=ge[i-1];
		be[i]=be[i-1];
		if(s[i]=='R') er[i]++;
		else if(s[i]=='G') ge[i]++;
		else be[i]++;
	}
	ll res=0;
	for(ll i=0; i<n; i++)
	{
		for(ll k=i+3; k<n; k++)
		{
			if(s[i]!=s[k])
			{
				ll za=i;

				ll r=er[k-1]-er[za];
				ll g=ge[k-1]-ge[za];
				ll b=be[k-1]-be[za];
				if(s[k]=='R') r=1;
				else if(s[k]=='G') g=1;
				else b=1;
				if(s[i]=='R') r=1;
				else if(s[i]=='G') g=1;
				else b=1;
				if((i+k)%2==0)
				{
					ll mid=(i+k)/2;
					if((r>1 || (max(r,(max(g,b)))==1)) && s[mid]=='R')
					{
						r--;
					}else if((g>1 || (max(r,(max(g,b)))==1)) && s[mid]=='G'){
						g--;
					}
					else if((b>1||(max(r,(max(g,b)))==1)) && s[mid]=='B'){
						b--;
					}
				}
				if(s[k]=='R') r=1;
				else if(s[k]=='G') g=1;
				else b=1;
				if(s[i]=='R') r=1;
				else if(s[i]=='G') g=1;
				else b=1;
				//cout<<i<<" "<<k<<endl;
				//cout<<r<<" "<<g<<" "<<b<<endl;

				//cout<<r*g*b<<endl;
				//if(max(r,(max(g,b)))>1)
				res+=r*g*b;
			}
		}
	}
	cout<<res<<endl;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

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

    int ans = 0;
    while(x < 2000){
        ans++;
        x += 200;
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3632