akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define mod 1000000007
using datas=pair<ll,ll>;
using tdata=pair<datas,ll>;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncrlistp[200000],modncrlistm[200000];

ll modncrs(ll n,ll r){
  ll i,j;
  if(modncrlistp[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistp[i])break;
    }
    if(i<0){
      modncrlistp[0]=1;
      rep1(i,n+1){
        modncrlistp[i]=(modncrlistp[i-1]*i)%mod;
      }
    }else{
      For(j,i+1,n+1){
        modncrlistp[j]=(modncrlistp[j-1]*j)%mod;
      }
    }
  }
  if(modncrlistm[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistm[i])break;
    }
    if(i<0){
      modncrlistm[0]=1;
      rep1(i,n+1){
        modncrlistm[i]=(modncrlistm[i-1]*modinv(i))%mod;
      }
    }else{
      For(j,i+1,n+1)modncrlistm[j]=(modncrlistm[j-1]*modinv(j))%mod;
    }
  }
  return (((modncrlistp[n]*modncrlistm[r])%mod)*modncrlistm[n-r])%mod;
}

ll modncr(ll n,ll r){
  if(r*2>n)return modncr(n,n-r);
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll euclidean_gcd(ll a, ll b) {
  if(a<b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

void printmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  For(i,0,H+2){
    For(j,0,W+2){cout<<a[i*(W+2)+j];}
    cout<<endl;
  }
}
void inputmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        a[i*(W+2)+j]=1;
      }else{
        a[i*(W+2)+j]=0;
      }
    }
  }
}

int main(){
  ll i,N,ans,x;
  cin>>N;
  set<ll> se;
  vec v;
  rep(i,N){
    cin>>x;
    auto p=se.insert(x);
    if(!p.second)v.push_back(x);
  }
  if(N-se.size()>1||v.size()>2){
    vrsort(v);
    if(v[0]==v[1]){
      cout<<v[0]*v[2]<<endl;
    }else{
      cout<<v[0]*v[1]<<endl;
    }
    ans=0;
  }else{
    cout<<0<<endl;
  }
  return 0;
}

Measured memory_bytes: 4992
#include <iostream>

using namespace std;

const int MAX_N = 305;

int n;
long long c[MAX_N][MAX_N], cc[MAX_N][MAX_N];
const long long INF = (1LL << 60);

void warshall_floyd(long long d[MAX_N][MAX_N]){
    for(int i = 0; i < n; ++i) d[i][i] = 0;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){
            for(int k = 0; k < n; ++k){
                d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
            }
        }
    }
}

int main()
{
    int m, L;
    cin >> n >> m >> L;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){
            c[i][j] = cc[i][j] = INF;
        }
    }
    for(int i = 0; i < m; ++i){
        int a, b, _c;
        cin >> a >> b >> _c;
        c[a-1][b-1] = c[b-1][a-1] = _c;
    }
    warshall_floyd(c);
    for(int i = 0; i < n; ++i){
        for(int j = i + 1; j < n; ++j){
            if(c[i][j] <= L) cc[i][j] = cc[j][i] = 1;
        }
    }
    warshall_floyd(cc);
    int q;
    cin >> q;
    for(int i = 0; i < q; ++i){
        int s, t;
        cin >> s >> t;
        if(cc[s-1][t-1] == INF){
            cout << "-1\n";
        }else{
            cout << cc[s-1][t-1] - 1 << "\n";
        }
    }
}

Measured memory_bytes: 1920
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>

using namespace std;

typedef long long ll;
typedef std::pair<int, int> ipair;
const int MAX_V = 100010;
const int MAX_LOG_V = 17;
vector<ipair> G[MAX_V];
int parent[MAX_LOG_V][MAX_V];
int depth[MAX_V];
vector<int> eulerT;

template<class T> class TREE {

   public:
      int k = 0;
      T distance[MAX_V];
      int begin[MAX_V * 2];
      int end[MAX_V * 2];

      // vertex, parent, depth, distance
      void dfs(int v, int p, int d, T l) {
         parent[0][v] = p;
         depth[v] = d;
         distance[v] = l;
         begin[v] = k;
         eulerT.push_back(v);
         k++;
         for (auto& g : G[v]) {
            if (g.first != p) {
               dfs(g.first, v, d + 1, l + g.second);
               eulerT.push_back(v);
               k++;
            }
         }
         end[v] = k;
      }

      void init(int V, int root) {
         dfs(root, -1, 0, 0);
         for (int k = 0; k + 1 < MAX_LOG_V; k++) {
            for (int v = 0; v < V; v++) {
               if (parent[k][v] < 0) parent[k + 1][v] = -1;
               else parent[k + 1][v] = parent[k][parent[k][v]];
            }
         }
      }

      int lca(int u, int v) {
         if (depth[u] > depth[v]) swap(u, v);
         for (int k = 0; k < MAX_LOG_V; k++) {
            // if k th digit of depth[v] - depth[u] is 1
            if ((depth[v] - depth[u]) >> k & 1) {
               v = parent[k][v];
            }
         }
         if (u == v) return u;
         for (int k = MAX_LOG_V - 1; k >= 0; k--) {
            if (parent[k][u] != parent[k][v]) {
               u = parent[k][u];
               v = parent[k][v];
            }
         }
         return parent[0][u];
      }
};

int main() {
   int N;
   cin >> N;
   int a, b, c;
   for (int i = 0; i < N - 1; i++) {
      cin >> a >> b >> c;
      a--;
      b--;
      G[a].push_back(ipair(b, c));
      G[b].push_back(ipair(a, c));
   }
   int Q, K;
   cin >> Q >> K;
   K--; 
   TREE<ll> tree;
   tree.init(N, K);
   
   int u, v;
   for (int q = 0; q < Q; q++) {
      cin >> u >> v;
      u--;
      v--;
      ll ans = 0;
      ans += tree.distance[u] + tree.distance[v];
      cout << ans << endl;
   }
   
   return 0;
}


Measured memory_bytes: 21236
#include<bits/stdc++.h>
using namespace std;
struct PrimalDual{
  const int INF = 1<<28;
  typedef pair<int,int> P;
  struct edge{
    int to,cap,cost,rev;
    edge(){}
    edge(int to,int cap,int cost,int rev):to(to),cap(cap),cost(cost),rev(rev){}
  };

  int V;
  vector<vector<edge> > G;
  vector<int> h,dist,prevv,preve;

  PrimalDual(){}
  PrimalDual(int V):V(V){init();}

  void init(){
    for(int i=0;i<(int)G.size();i++) G[i].clear();
    G.clear();
    h.clear();
    dist.clear();
    prevv.clear();
    preve.clear();
    G.resize(V);
    h.resize(V);
    dist.resize(V);
    prevv.resize(V);
    preve.resize(V);
  }
  
  void add_edge(int from,int to,int cap,int cost){
    G[from].push_back(edge(to,cap,cost,G[to].size()));
    G[to].push_back(edge(from,0,-cost,G[from].size()-1));
  }

  int min_cost_flow(int s,int t,int f){
    int res=0;
    fill(h.begin(),h.begin()+V,0);
    while(f>0){
      priority_queue<P,vector<P>,greater<P> > que;
      fill(dist.begin(),dist.begin()+V,INF);
      dist[s]=0;
      que.push(P(0,s));
      while(!que.empty()){
	P p=que.top();que.pop();
	int v=p.second;
	if(dist[v]<p.first) continue;
	for(int i=0;i<(int)G[v].size();i++){
	  edge &e=G[v][i];
	  if(e.cap>0&&dist[e.to]>dist[v]+e.cost+h[v]-h[e.to]){
	    dist[e.to]=dist[v]+e.cost+h[v]-h[e.to];
	    prevv[e.to]=v;
	    preve[e.to]=i;
	    que.push(P(dist[e.to],e.to));
	  }
	}
      }
      if(dist[t]==INF){
	return -1;
      }
      for(int v=0;v<V;v++) h[v]+=dist[v];

      int d=f;
      for(int v=t;v!=s;v=prevv[v]){
	d=min(d,G[prevv[v]][preve[v]].cap);
      }
      f-=d;
      res+=d*h[t];
      for(int v=t;v!=s;v=prevv[v]){
	edge &e=G[prevv[v]][preve[v]];
	e.cap-=d;
	G[v][e.rev].cap+=d;
      }
    }
    return res;
  }
};
int main(){
  int v,e,f;
  cin>>v>>e>>f;
  PrimalDual pd(v);
  for(int i=0;i<e;i++){
    int u,v,c,d;
    cin>>u>>v>>c>>d;
    pd.add_edge(u,v,c,d);
  }
  cout<<pd.min_cost_flow(0,v-1,f)<<endl;
  return 0;
}
/*
verified on 2017/06/29
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_6_B
*/

Measured memory_bytes: 3152
int G(x,y){return y?G(y,x%y):x;}
#define L(x,y)((long long)x/G(x,y)*y)
n[3],a[3],m[3];main(i,x){
	for(;scanf("%d%d%d%d%d%d",a,m,a+1,m+1,a+2,m+2),*m;printf("%lld\n",L(n[0],L(n[1],n[2])))){
		for(i=3;i--;)for(x=n[i]=1;(x=a[i]*x%m[i])>1;n[i]++);
	}
}

Measured memory_bytes: 600
// Created by sz
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    set<char> ss;
    for (auto i : s) {
        ss.insert(i);
    }
    
    if(ss.size()>1)cout << "Yes" << "\n";
    else cout << "No" << "\n";
    
    return 0;
}


Measured memory_bytes: 256
lst = input().split()
stack = []

for s in lst:
    if s == "+":
        stack += [stack.pop() + stack.pop()]
    elif s == "-":
        stack += [-stack.pop() + stack.pop()]
    elif s == "*":
        stack += [stack.pop() * stack.pop()]
    else:
        stack += [int(s)]

print(stack.pop())



Measured memory_bytes: 5596
import java.io.{BufferedReader, InputStream, InputStreamReader}
import java.util.{Comparator, StringTokenizer}

import scala.collection.mutable
import scala.util.Sorting
import math.{abs, max, min}
import scala.collection.mutable.{ArrayBuffer, ListBuffer}

object Main {
  val MOD = 1000000007
  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val N, M = sc.nextInt()
    type Edge = ((Int, Int), Int)
    val E = Array.ofDim[Edge](M)
    (0 until M) foreach { i =>
      val a, b = sc.nextInt() - 1
      val c = sc.nextInt()
      E(i) = ((a, b), c)
    }

    val INF = Long.MinValue + 1000000000
    val d = Array.fill[Long](N)(INF)
    d(0) = 0

    def BF(): Boolean = {
      var updated = false
      (0 until N - 1) foreach { _ =>
        (0 until M) foreach { i =>
          val ((a, b), c) = E(i)
          if (d(a) + c > d(b)) {
            d(b) = d(a) + c
            if (b == N - 1) updated = true
          }
        }
      }
      updated
    }

    BF()
    val updated = BF()

    val ans = if (updated) "inf" else d(N - 1).toString
    println(ans)
  }


  def main(args: Array[String]): Unit = {
    solve()
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = null

    def next: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next.toInt
    def nextLong(): Long = next.toLong
    def nextChar(): Char = next.charAt(0)
  }

}


Measured memory_bytes: 68048
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
int x=0,y=0,z=0;
cin >> x>>y>>z;
if((z-y)%2==0)cout<<(z-y)/2<<'\n';
else cout<<min(min(z-1,x-y),min((y+z-1)/2,(2*x+1-z-y)/2))<<'\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define re register
using namespace std;
int n,val[52],vis[52],lena,lenb,len[52];
char s[52][52],t[52][52],a[1000002],b[1000002],c[1000002];
long long ans,sum;
inline int read(){
	re int t=0,f=0;re char v=getchar();
	while(v<'0')f|=(v=='-'),v=getchar();
	while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
	return f?-t:t;
}
inline void dfs(){
	if(sum>ans)return;
	if(lena&&lenb&&abs(lena-lenb)<=1){
		ans=sum;
		return;
	}
	re bool iaa=1;
	re int ttt=0;
	for(re int i=1;i<=lena;++i)c[++ttt]=a[i];
	for(re int i=lenb;i;--i)c[++ttt]=b[i];
	for(re int i=1;i<=ttt/2;++i)if(c[i]!=c[ttt-i+1]){
		iaa=0;
		break;
	}
	if(ttt&&iaa){
		ans=sum;
		return;
	}
	if(lena<=lenb){
		for(re int i=1;i<=n;++i){
			re bool ia=1;
			for(re int j=lena+1;j<=min(lenb,lena+len[i]);++j){
			if(b[j]!=s[i][j-lena]){
				ia=0;
				break;
			}}
			if(ia){
				if(vis[i]>100)continue;
				++vis[i];
				re int pp=lena;sum+=val[i];
				for(re int j=lena+1;j<=lena+len[i];++j)a[j]=s[i][j-lena];
				lena+=len[i];
				dfs();
				lena=pp;
				--vis[i];sum-=val[i];
			}
		}
	}
	else{
		for(re int i=1;i<=n;++i){
			re bool ia=1;
			for(re int j=lenb+1;j<=min(lena,lenb+len[i]);++j){
			if(a[j]!=t[i][j-lenb]){
				ia=0;
				break;
			}}
			if(ia){
				if(vis[i]>100)continue;
				++vis[i];
				re int pp=lenb;sum+=val[i];
				for(re int j=lenb+1;j<=lenb+len[i];++j)b[j]=t[i][j-lenb];
				lenb+=len[i];
				dfs();
				lenb=pp;
				--vis[i];sum-=val[i];
			}
		}
	}
}
signed main(){
	ans=1e18;
	n=read();
	for(re int i=1;i<=n;++i){
		scanf("%s",s[i]+1);
		re bool ia=1;
		len[i]=strlen(s[i]+1);
		for(re int j=1;j<=len[i];++j){
		t[i][j]=s[i][len[i]-j+1];if(t[i][j]!=s[i][j]){
			ia=0;
		}}
		val[i]=read();
		if(ia)ans=min(ans,1ll*val[i]);
	}
	dfs();
	if(ans<1e18)printf("%lld\n",ans);
	else puts("-1");
}


Measured memory_bytes: 3808
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

typedef long long LL; 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int N; cin >> N;
    int cnt[int(1e5+10)] = {0};
    REP(i,N)
    {
        int tmp; cin >> tmp;
        cnt[tmp]++;
    }
    int ans = 0;
    FOR(i,1,1e5+10)
    {
        int tmp;
        tmp = cnt[i-1] + cnt[i] + cnt[i+1];
        if(tmp > ans) ans = tmp;
    }
    cout << ans << endl;

}


Measured memory_bytes: 640
#include <iostream>
#include <queue>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <math.h>
#include <stdlib.h>
#include <numeric>
#include <functional>
int main(){
	long int n;
	std::cin >> n;
	std::cout << (n * (n-1)) / 2 << std::endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
L = list(map(int,input().split()))
counter = 0
for i in range(len(L)-2):
    for j in range(i+1,len(L)-1):
        if L[i] == L[j]:
            continue
        for k in range(j+1,len(L)):
            if L[i] == L[k]:
                continue
            elif L[j] == L[k]:
                continue
            if L[i]+L[j]>L[k] and L[j]+L[k]>L[i] and L[i]+L[k]>L[j]:
                counter += 1
print(counter)

Measured memory_bytes: 9192
using System;
using System.Text.RegularExpressions;

namespace ConsoleApp1
{
    class Program
    {
  
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            Boolean ok = false;
            int cnt = 0;
            int len = S.Length;
            if (S.Substring(0, 1) == "A"
             && S.Substring(1, 1) == S.Substring(1, 1).ToLower()
             && S.Substring(len - 1, 1) == S.Substring(len - 1, 1).ToLower())
            {
                for (int i = 2; i < len - 1; i++)
                {
                    if (S.Substring(i, 1) != S.Substring(i, 1).ToLower())
                    {
                        if (S.Substring(i, 1) != "C")
                        {
                            ok = false;
                            break;
                        }
                        else
                        {
                            cnt++;
                            ok = true;
                        }
                    }
                    else
                    {
                        ok = true;
                    }
                }
                if (cnt != 1)
                    ok = false;
            }
            if(ok)
            {
                Console.WriteLine("AC");
            }
            else
            {
                Console.WriteLine("WA");
            }
        }
    }
}

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

int main(){
  int A,B;
  cin >> A >> B;
  int c= 0;
  
  for (int i = A; i <=B; i++){
    int s = i %10 , t = i/ 10000 % 10;
    int u = i / 10 % 10, v = i / 1000 % 10;
    if (s == t && u == v) c++;
  }
  cout << c << endl;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
const ll MOD = 1e9 + 7;

void mainsolve(){

	string s;
	cin >> s;
	ll q;
	cin >> q;

	deque<char> deq;
	for(char c : s) deq.push_back(c);

	ll revcnt = 0;

	rep(i,q){
		ll t;
		cin >> t;
		if(t==1){
			revcnt++;
		}
		else{
			ll f;
			char c;
			cin >> f;
			cin >> c;
			if(f==1){
				if(revcnt % 2 == 1) deq.push_back(c);
				else deq.push_front(c);
			}
			else{
				if(revcnt % 2 == 1) deq.push_front(c);
				else deq.push_back(c);
			}
		}
	}

	if(revcnt % 2 == 1) reverse(deq.begin(),deq.end());

	rep(i,deq.size()) cout << deq[i];

	cout << endl;
	return;
}

int main(){
	
  	//ll TC;cin>>TC;rep(I,TC){cout<<"case:"<<I+1<<"---"<<endl; // comment out!
		mainsolve();
	//} // comment out!
	return 0;
}


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

using namespace std;

int main()
{
    int n, x;
    cin >> n;
    int flag = -1;
    for (int i = 0; i < n; i++)
    {
        cin >> x;
        if (x % 2 == 0)
        {
            if (!(x % 3 == 0 || x % 5 == 0))
            {
                flag = 1;
            }
        }
    }
    if (flag == -1)
        cout << "APPROVED" << endl;
    else
        cout << "DENIED" << endl;

    return 0;
}

Measured memory_bytes: 256
/*
 *
 *   Author     : Amit Kumar
 *   Date    	: June 11 2019
 * 
 */

#include <bits/stdc++.h>

#define FAST_INPUT_OUTPUT
//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(x) for(auto i=0 ; i<(x); ++i)
#define _rep(a,b) for(auto i=(a); i<(b); ++i)
#define ef else if
#define wh while
#define el else
#define ivv(x) int x; cin>>x
#define lv(x) bint x; cin>>x
#define sv(x) string x; cin>>x
#define cv(x) char x; cin>>x
#define fv(x) float x; cin>>x
#define dv(x) double x; cin>>x
#define endl '\n'
using namespace std;




auto SOLUTION_FUNCTION( void ) ->void {

    // your solution goes here 


    lv(n);
    lv(k);
    vl v(n);
    iv(v);
    bint ans=0;

    for(int i=50; i>=0; --i){
        int counter = 0;

        for(auto j:v){
            if((j>>i)&1)
                counter++;
        }
        if(counter < (n+1)/2){
            if(ans + (1LL<<i)<=k)
                ans+=(1LL<<i);
        }
    }
    for(auto &i:v){
        i^=ans;
    }
    cout<<accumulate(all(v),0LL)<<endl;
    return ;
}




int main(void){
#ifdef FAST_INPUT_OUTPUT
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#endif
#ifdef MY_LOCAL_PROJECT
    freopen("input","r",stdin);
    freopen("output","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}

Measured memory_bytes: 1024
# 入力
a1,a2,a3 = 3.times.map { gets.chomp.split.map(&:to_i) } 
n = gets.to_i
b = n.times.map { gets.to_i } 

# よこ
c1 = a1[0],a2[0],a3[0]
c2 = a1[1],a2[1],a3[1]
c3 = a1[2],a2[2],a3[2]

# ななめ
d1 = a1[0],a2[1],a3[2]
d2 = a1[2],a2[1],a3[0]

# おきかえ
a1 = (a1 & b)
a1 = a1.size
a2 = (a2 & b)
a2 = a2.size
a3 = (a3 & b)
a3 = a3.size
c1 = (c1 & b)
c1 = c1.size
c2 = (c2 & b)
c2 = c2.size
c3 = (c3 & b)
c3 = c3.size
d1 = (d1 & b)
d1 = d1.size
d2 = (d2 & b)
d2 = d2.size

a = [a1,a2,a3,c1,c2,c3,d1,d2]

# こたえ
if a.include?(3)
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 3836
/*************************************************
       Author       :   NIYOUDUOGAO
       Last modified:   2018-08-01 09:00
       Email        :   pjm000@163.com
       Filename     :   t2.cpp
 *************************************************/
#include <bits/stdc++.h>
#define mset(a, x) memset(a, x, sizeof(a))
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int N = 1e5 + 5;
int a[N];
int vis[N];
ll fac[100005]={1,1};
ll inv[100005]={1,1};
ll fi[100005]={1,1}; 
void init()
{
    for(int i=2; i<=100005; ++i)
    {
        fac[i] = fac[i-1]*i%mod;
        inv[i] = (mod-mod/i)*inv[mod%i]%mod;
        fi[i] = fi[i-1]*inv[i]%mod;
    }
}
ll C(ll n, ll m) {
    return fac[n]*fi[n-m]%mod*fi[m]%mod;
}
int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    init();
    int n;
    cin >> n;
    int Index1, Index2;
    for (int i = 1; i <= n + 1; i++) {
        cin >> a[i];
        if (vis[a[i]]) {
            Index1 = vis[a[i]] - 1;
            Index2 = i;
        }
        vis[a[i]] = i;
    }
    ll t1, t2;
    for (int i = 1; i <= n + 1; i++) {
        t1= C(n + 1, i) % mod;
        if (n + 1 - Index2 + Index1 >= i - 1) {
            t2 = C(n + 1 - Index2 + Index1, i - 1) % mod;
        } else {
            t2 = 0;
        }
        cout << (t1 - t2 + mod) % mod << "\n";
    }
    return 0;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
using namespace std;
typedef long long LL;
const int N = 505;
const int P = 8005;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

int n, pr[P], pcnt, vis[P];
LL a[N][N], mx;
//set<LL> S;

LL gcd(LL x, LL y) {
	return (!y)? x : gcd(y, x % y);
}

inline LL lcm(LL x, LL y) {
	if (!x || !y) return x + y;
	return x / gcd(x, y) * y;
}

void init() {
	read(n);
	if (n == 2) {
		printf("4 7\n23 10\n");
		exit(0);
	}
	for (int i = 2; i <= 8000; ++i) {
		if (!vis[i]) {
			pr[++pcnt] = i;
		}
		for (int j = 1; j <= pcnt && i * pr[j] <= 8000; ++j) {
			vis[i * pr[j]] = 1;
			if (i % pr[j]) continue;
		}
	}
}

void solve() {
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) {
			if (!((i + j) & 1)) {
				a[i][j] = pr[(i + j) / 2] * pr[(n - i + 1 + j) / 2 + n / 2];
			}
		}
	}
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) {
			if ((i + j) & 1) {
				a[i][j] = lcm(lcm(a[i - 1][j], a[i + 1][j]), lcm(a[i][j - 1], a[i][j + 1])) + 1;
			}
			printf("%lld ", a[i][j]);
/*mx = max(mx, a[i][j]);
if (S.find(a[i][j]) != S.end()) {
	printf("error\n");
}
S.insert(a[i][j]);*/
		}
		printf("\n");
	}
//printf("%lld\n", mx);
}

int main() {
	init();
	solve();
	return 0;
}


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

void solve()
{
	string S,T;
	cin>>S;
	cin>>T;

	int c = 0;

	for(int i = 0;i<S.length();i++)
	{
		if(S[i] != T[i])
			c++;
	}	

	cout<<c<<endl;
}

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


	solve();

	return 0;
} 

Measured memory_bytes: 3804
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int n, m;
  cin >> n >> m;
  vi cnt(m);
  rep(i,n) {
    int k = in();
    rep(j,k) {
      int a;
      cin >> a;
      a--;
      cnt[a]++;
    }
  }
  int ans = 0;
  rep(i,m) {
    if (cnt[i] == n) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>

#define CK(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)
#define F first
#define S second
#define ll long long;

const int INF = 1e9;
const long long  LLINF = 1e15;

using namespace std;

int H, W, S, U[35][35];
int sum[35][35][35][35];
pair<int, int> dp[35][35][35][35];
//dp[y1][x1][y2][x2]: [(y1,x1),(y2,x2)]??? ????????¢??? <?????§??°???????????°, ?????????>
//dp[0][0][H-1][W-1]??????????????????

pair<int, int> dfs(int y1, int x1, int y2, int x2){
  if(dp[y1][x1][y2][x2].F != -INF){
     return dp[y1][x1][y2][x2];
  }

  //first: ?????????????????¨????????????????????°??????????????¨??????????????°??????????????????????????¨??????????????????1?????\??????
  //second: ????????????????????°??????????????£?????´??????????????????????????\????????????
  pair<int, int> ret = make_pair(1, S-(sum[0][0][H-1][W-1]-sum[y1][x1][y2][x2]));

  //?????´??????
  for(int cutx=x1; cutx<x2; cutx++){
    int suml = sum[y1][x1][y2][cutx];
    int sumr = sum[y1][cutx+1][y2][x2];
    if(sum[0][0][H-1][W-1]-suml > S || sum[0][0][H-1][W-1]-sumr > S) continue;
    pair<int, int>  l = dfs(y1,x1,y2,cutx);
    pair<int, int>  r = dfs(y1,cutx+1,y2,x2);
    pair<int, int> tmp = make_pair(l.F+r.F, min(l.S,r.S));  //???????????????????????§?¨?????????????
    ret = max(ret, tmp);  //F->S????????§????????????????????§????????§OK
  }

  //?°´?????????
  for(int cuty=y1; cuty<y2; cuty++){
    int suml = sum[y1][x1][cuty][x2];
    int sumr = sum[cuty+1][x1][y2][x2];
    if(sum[0][0][H-1][W-1]-suml > S || sum[0][0][H-1][W-1]-sumr > S) continue;
    pair<int, int>  l = dfs(y1,x1,cuty,x2);
    pair<int, int>  r = dfs(cuty+1,x1,y2,x2);
    pair<int, int> tmp = make_pair(l.F+r.F, min(l.S,r.S));  //???????????????????????§?¨?????????????
    ret = max(ret, tmp);  //F->S????????§????????????????????§????????§OK
  }

  //???????????§??\???????????§?????????????????????????????????????????????????±???????????????§???
  //????????§dp?????\??????????????????????????????????????????????????????????????????????????????????????¢?´¢?????????dp?????????????????§?????????
  return dp[y1][x1][y2][x2] = ret;
}


int main() {
  while(1){
    cin>>H>>W>>S;
    if(H==0&&W==0&&S==0) break;
    REP(i,0,H){
      REP(j,0,W){
        cin>>U[i][j];
      }
    }
    //????????????????¨?????????????????????????
    REP(i,0,H){
      REP(j,0,W){
        REP(ranH,0,H-i)REP(ranW,0,W-j){
          int tmp = 0;
          REP(k,i,i+ranH+1){
            REP(l,j,j+ranW+1){
              tmp += U[k][l];
            }
          }
          sum[i][j][i+ranH][j+ranW] = tmp;
        }
      }
    }
    //?????????
    REP(i,0,H){
      REP(j,0,W){
        REP(k,0,H){
          REP(l,0,W){
            dp[i][j][k][l] = make_pair(-INF,-INF);
          }
        }
      }
    }

    pair<int, int> ans = dfs(0,0,H-1,W-1);
    cout<<ans.F<<" "<<ans.S<<endl;
  }

  return 0;
}

Measured memory_bytes: 17848
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
int n,k,ans;
string S;
cin >> S;
n = S.size();
	vector<int> num,i(n);
	for(k=0;k<n;k++){
		num.push_back(S[k]-'0');
	}
	for(k=1;k<n;k++){
		if(num[k-1] != num[k]){
			i[k] = max(k,n-k);
		}else{
			i[k] = n;
		}
	}
	ans = i[1];
	for(k=1;k<n;k++){
		ans = min(ans,i[k]);
	}
  if(n==1){
    cout << 1 << endl;
  }else{
	cout << ans << endl;
}
}
	

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

struct Node { // 構造体でNodeを作る
  int key; // データ本体
  Node *prev, *next; // 前の要素、次の要素をもつ構造体変数
};

Node *nil;

Node* listSearch(int key){
  Node *cur = nil->next; // 番兵の次の要素から巡る
  while(cur != nil && cur->key != key) { // keyを発見するか、番兵に戻ると探索が終了
   cur = cur->next;
  }
  return cur;
}

// リストの初期化
// nextとprevをnilにして空のリストを作成
// リストの先頭を表す番兵というらしい・・？
void init(){
  nil = (Node *)malloc(sizeof(Node)); // mallocは指定したサイズだけメモリを動的に確保する
  nil->next = nil; // ->はアロー演算子。ポインタ変数からメンバにアクセスする
  nil->prev = nil;
}


void printList(){
  Node *cur = nil->next;
  int isf = 0;
  while(1){
    if ( cur == nil ) break;
    if ( isf++ > 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t){
  if (t == nil) return; // tが番兵の時は処理しない。
  t->prev->next = t->next; // tの前の要素のnextをtのnextの指定に変更
  t->next->prev = t->prev; // tの次の要素のprevをtのprevの指定に変更
  free(t); // メモリ解放
}

void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast(){
  deleteNode(nil->prev);
}

void deleteKey(int key){
  // 検索したノードを削除
  deleteNode(listSearch(key));
}


void insert(int key){
  Node *x;
  x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next; // nilのprevをxのnextと繋いでいるらしい？
  // 番兵の直後に要素を追加
  nil->next->prev = x; 
  nil->next = x;
  x->prev = nil;
}

int main() {
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) { insert(key); np++; size++; }
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	      if ( com[6] == 'F' ) deleteFirst();
	      else if ( com[6] == 'L' ) deleteLast();
      } else {
	      deleteKey(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}



Measured memory_bytes: 34400
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int d = sc.nextInt();
      if(d == 22)System.out.println("Christmas Eve Eve Eve");
      if(d == 23)System.out.println("Christmas Eve Eve");
      if(d == 24)System.out.println("Christmas Eve");
      if(d == 25)System.out.println("Christmas");
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <iomanip>
#define MOD 1000000007
#define pb push_back
#define ll long long
using namespace std;

struct Point {
	double x, y;
};

struct Line {
	ll a, b;

	static Point intersect(const Line& l1, const Line& l2) {
		double x, y;
		
		x = 1.0  * (l2.b - l1.b) / (l1.a - l2.a);
		y = l1.a * x + l1.b;
		
		return { x, y };
	}

	ll eval(ll x) {
		return a * x + b;
	}
};

struct CHT {
	vector<Line> lines;
	
	void addLine(const Line& l) {
		while (lines.size() >= 2 && Line::intersect(l, lines.end()[-1]).x < Line::intersect(l, lines.end()[-2]).x) {
			lines.pop_back();
		}
		lines.pb(l);
	}

	ll query(ll x) {
		int l = 0, r = lines.size() - 1;
		
		while (l != r) {
			//cout << "L, R: " << l << " " << r << endl;
			int mid = (l + r) / 2;
			if (lines[mid].eval(x) < lines[mid + 1].eval(x)) r = mid;
			else l = mid + 1;
		}

		return lines[l].eval(x);
	}
};

int main() {
	ll n, c;
	cin >> n >> c;
	
	vector<ll> h(n + 1);
	vector<ll> dp(n + 1);
	vector<int> last(n + 1);
	for (int i = 0; i < n; i++) cin >> h[i];

	CHT cht;
	cht.addLine({ 0, (ll)1e17 });
	cht.addLine({ -2 * h[0], h[0] * h[0] });

	dp[0] = 0;
	for (int i = 1; i < n; i++) {
		dp[i] = h[i] * h[i] + c + cht.query(h[i]);
		cht.addLine({ -2 * h[i],  dp[i] + h[i] * h[i]});
	}

	//cout << endl;
	//for (int i = 0; i < n; i++) {
	//	cout << dp[i] << " ";
	//}
	//cout << endl;
	cout << dp[n - 1];
	
	return 0;
}

Measured memory_bytes: 10096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
// #ifdef DEBUG 
// #define
int judge(int a){
    for(int i=2; i*i<=a; i+=(i==2)?1:((i%2)?2:4)){
        if(!(a%i)) return 0;
    }
    return 1;
}
int main(){
    int n,sum=0;
    cin >> n;
    int A[n];
    REP(i,n) cin >> A[i];
    REP(i,n) sum+=judge(A[i]);
    cout << sum << endl;
}


Measured memory_bytes: 3116
h, w = gets.split.map(&:to_i)
a = []
rh, rw = [], []

h.times do |y|
  a[y] = gets.chomp

  if a[y].count('.') == w
    rh[y] = true
  end
end

w.times do |x|
  cnt = 0

  h.times do |y|
    if a[y][x] == '.'
      cnt += 1
    end
  end

  if cnt == h
    rw[x] = true
  end
end

h.times do |y|
  if rh[y].nil?
    w.times do |x|
      if rw[x].nil?
        print a[y][x]
      end
    end

    puts
  end
end


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

#define _GLIBCXX_DEBUG

//vector<int> A(M), B(M);
//vector<vector<char>> answer(N, vector<char>(N, '-'));

int main() {
  int r;
  int ans;
  
  cin >> r;
  
  ans = r * r;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main () {
	int N;
	long long num[] = {0,0,0,0,0};
	char name[11];
	scanf ("%d", &N);
	for (int i=0; i<N; i++) {
		scanf ("%s", name);
		switch (name[0]) {
			case 'M':
				num[0] ++;
				break;
			case 'A':
				num[1] ++;
				break;
			case 'R':
				num[2] ++;
				break;
			case 'C':
				num[3] ++;
				break;
			case 'H':
				num[4] ++;
				break;
		}
	}
	long long sum = 0;
	for (int i=0; i<5; i++)
		for (int j=i+1; j<5; j++)
			for (int k=j+1; k<5; k++)
				sum += num[i] * num[j] * num[k];
	printf ("%lld\n", sum);
	return 0;
}


Measured memory_bytes: 128
#include<algorithm>
#include<string>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<utility>
#include<functional>
#include<cassert>
#include<cmath>
#include<math.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<vint> vvint;
#define PI 3.1415926535;
#define MOD 1000000007;
#define rep(i, n) for(int i=0;i<(n);i++)


int main(void) {
	int n,ans=0; cin >> n;
	vector<vector<P>> a(n);
	rep(i, n) {
		int x; cin >>x;
		rep(j, x) {
			int k, l;
			cin >> k>>l;
			k--;
			a[i].push_back(P(k,l));
		}
	}

	rep(i, 1 << n) {
		vector<int> b(n);
		int bit = i;
		int j = 0, res = 0;
		while (bit != 0) {
			b[j] = bit % 2;
			if (bit % 2 == 1)res++;
			bit /= 2;
			j++;
		}

		rep(k, n) {
			if (b[k] == 1) {
				rep(l, a[k].size()) {
					if (b[a[k][l].first] != a[k][l].second) {
					goto A;
					}
				}
			}
		}

		ans = max(ans, res);
	A:;
	}
	cout << ans << endl;

	return 0;
}

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


int main()
{
    string s;

    cin >> s;


    int len = s.length();


    for(int i=0; i<len; i++)
    {
        if(i%2)
        {
            if(s[i]=='L' || s[i]=='U' || s[i]=='D')
                continue;
                else
                {
                    cout << "No" << "\n";
                    return 0;
                }
        }
        else if(i%2==0)
        {
             if(s[i]=='R' || s[i]=='U' || s[i]=='D')
                continue;
             else
             {
                 cout << "No" << "\n";
                 return 0;
             }

        }
    }


    cout << "Yes" << "\n";

    return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> height(N);
  for (int &e : height) {
    cin >> e;
  }
  
  sort(height.begin(), height.end(), greater<int>());
  int delt = 1000000000;
  for (int i = 0; i < N-K+1; i++) {
    delt = min(delt, height[i]-height[i-1+K]);
  }
  
  cout << delt << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;
 public class Main { 
     public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
       while(true){
            int a = sc.nextInt();
            int b = sc.nextInt();
            if(a == 0 && b == 0){
                break;
             } 
            for(int i = 0;i<a;i++){
                 for(int j = 0;j<b;j++) {
                      System.out.printf("#"); 
                    } System.out.printf("\n");
                 } System.out.printf("\n"); 
                }
             }
             }


Measured memory_bytes: 60992
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

i64 H, W;

i64 sep(i64 cur, i64 h, i64 w)
{
	i64 mx, lo;
	if (h % 2 == 0 || w % 2 == 0) {
		mx = lo = h * w / 2;
	} else {
		mx = (h * w + min(h, w)) / 2;
		lo = h * w - mx;
	}
	return max({ 0LL, mx - cur, cur - lo, mx - lo });
}

int main()
{
	scanf("%lld%lld", &H, &W);

	i64 ret = H * W;
	for (int i = 0; i <= H; ++i) {
		ret = min(ret, sep(i * W, H - i, W));
	}
	for (int i = 0; i <= W; ++i) {
		ret = min(ret, sep(i * H, W - i, H));
	}
	printf("%lld\n", ret);
	return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include <iostream>
#include <math.h>
#include <cstdio>
#include <string.h>
using namespace std;
int main(void){
	long long int n,t,i,x=0,c,j=0;
	cin>>n>>t;
	long long int td[n];
	for(i=0;i<n;i++)cin>>td[i];
	for(i=0;i<=td[n-1];i++){
		if(i==td[j]){
			c=t;
			j++;
		}
		if(c>0){
			x++;
			c--;
		}
	}
	x+=t;
	cout<<x-1<<endl;
	return 0;
}

Measured memory_bytes: 1792
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-01-19 20:38:44
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#ifdef LOCAL
#define debug(_) cerr << #_ << ": " << (_) << '\n'
#else
#define debug(_) 1728
#endif

template <class T>
class FenwickTree {
 public:
  FenwickTree(const std::vector<T>& data) : n_(data.size() + 1), data_(data) {
    Initialize();
  }

  void Add(size_t pos, T value) {
    ++pos;
    while (pos < n_) {
      node_[pos] += value;
      pos += pos & -pos;
    }
  }

  // return sum of [0, i]
  T GetSum(size_t pos) {
    ++pos;
    T sum = 0;
    while (pos > 0) {
      sum += node_[pos];
      pos -= pos & -pos;
    }
    return sum;
  }

  // return sum of [left, rihgt]
  T GetRangeSum(int left, int right) {
    return GetSum(right) - GetSum(left - 1);
  }

  // for range add query
  class RAQ {
   public:
    RAQ(const std::vector<T>& data)
        : n_(data.size()),
          ft1_(FenwickTree<T>(data)),
          ft2_(FenwickTree<T>(data)) {}

    // add value range [left, right)
    void RangeAdd(int left, int right, T value) {
      Add(ft1_, left, right, value);
      Add(ft2_, left, right, -value * static_cast<T>(left - 1));
      Add(ft2_, right, n_, value * static_cast<T>(right - left));
    }

    // get sum of [0, i]
    T GetSum(size_t pos) {
      return ft1_.GetSum(pos) * static_cast<T>(pos) + ft2_.GetSum(pos);
    }

    // get sum of [left, right]
    T GetRangeSum(int left, int right) {
      return GetSum(right) - GetSum(left - 1);
    }

   private:
    size_t n_;
    FenwickTree<T> ft1_;
    FenwickTree<T> ft2_;
    void Add(FenwickTree<T>& ft, int left, int right, T value) {
      ft.Add(left, value);
      ft.Add(right, -value);
    }
  };

 private:
  size_t n_;
  std::vector<T> data_;
  std::vector<T> node_;
  void Initialize() {
    node_.assign(n_ + 1, 0);
    for (size_t i = 0; i < n_ - 1; ++i) Add(i, data_[i]);
  }
};

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

  int n; cin >> n;
  vector<int> p(n); cin >> p;

  FenwickTree<int> ft(vector<int>(n + 1, 0));

  int ans = 0;

  for (int i = 0; i < n; ++i) {
    if (ft.GetRangeSum(1, p[i] - 1) == 0) ++ans;
    ft.Add(p[i], 1);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int main() {
  int x;
  cin >> x;
  for (int a = 1; a < 1000; a++) {
      ll a5 = 1;
      rep(i,5) a5 *= a;
      for (int b = -1000; b < 1000; b++) {
          ll b5 = 1;
          rep(i,5) b5 *= b;
          if (a5 - b5 == x) {
              printf("%d %d\n", a, b);
              return 0;
          }
      }
  }
  return 0;
} 


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

int N;
vector<long long> x,y;

int main(){
  cin >> N;
  x.resize(N);
  y.resize(N);
  
  for(int i =0; i < N; i++){
    cin >> x[i] >> y[i]; 
  }
  
  int res =N; //最大コストはN - 1(0-index)  + 必ずかかる1でN
  if(N == 1) cout << "1" << endl;
  else{
    for(int i =0; i < N; i++){ //1つ目の点xi,yiを見る。N通り繰り返す。
      for(int j = 0; j < N; j++){ //1つ目の点に対し、残るすべての点xj,yjを見る。ここまででO(N^2)
        if( i == j ) continue; //i==jのときは制約によりないので除外する
        long long dx = x[j] - x[i];
        long long dy = y[j] - y[i]; //2点から移動ベクトルを算出
        
        int count =0; //コストが0で済む数を数え上げる
        
        //dx,dyは(p,q)。よってそれぞれの点(p,q)においてさらに
        for(int i2 = 0; i2 <N; i2++){ //ひとつめの点がxi,yiのとき
          for(int j2 =0; j2 < N; j2++){ //残りの点xj,yj の組み合わせを全て調べる
            if(i == j )continue;
            if(dx == x[j2]- x[i2] && dy == y[j2]- y[i2])count++; //j2,i2の差がdx,dyに等しければ0コスト
          }
        }
        res = min(res, N - count); //コストが0で済んだ回数をNから引く。すべてのパターンで調べ、一番小さかったものを残す
        
      }
    }
      cout << res << endl;
    
  }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
int main(){
	int n, cnt = 1; 
	string s;
	cin >> n >> s;
	for(int i = 0; i < n-1; i++)
    {
		if(s[i] != s[i+1])
          cnt++;
	}
	cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 512
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

K,X = IL()

l = max(-1000000,X-K+1)
r = min( 1000000,X+K-1)

ans = []
for i in range(l,r+1):
  ans.append(i)

print(" ".join(map(str,ans)))

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  string vowel = "aiueo";
  if (vowel.find(s)!=-1){
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }
}


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

int main() {

    int n;

    while(1) {

        cin >> n;

        if(n==0){
            break;
        }

        long long int h[n + 1];

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

        long long int dif;

        if (h[1] - h[0] == h[2] - h[1] && h[2] - h[1] == h[3] - h[2]) {
            dif = h[1] - h[0];
            for (int i = 1; i < n; i++) {
                if (h[i + 1] - h[i] != dif) {
                    cout << h[i + 1] << endl;
                    break;
                }
            }
        } else {
            if(n>4){
                dif = h[5] - h[4];
                if(h[3] - h[2] != dif && h[2] - h[1] == dif){
                    cout << h[3] << endl;
                }
                else if(h[3] - h[2] != dif && h[2] - h[1] != dif){
                    cout << h[2] << endl;
                }
                else if (h[3] - h[2] == dif && h[2] - h[1] != dif) {
                    cout << h[1] << endl;
                } else {
                    cout << h[0] << endl;
                }
            }
            else{
                int dif1=h[1]-h[0],dif2=h[2]-h[1];
                if(dif1==dif2){
                    cout << h[3] << endl;
                }
                else{
                    if(h[4]-h[3]!=dif1){
                        cout << h[0] << endl;
                    }
                    else{
                        cout << h[2] << endl;
                    }
                }
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3084