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

long long n;

int solve() {
  scanf("%lld", &n);
  --n;

  int cnt = 1;
  long long cur = 26;
  while (cur <= n) {
    n -= cur;
    cur *= 26;
    ++cnt;
  }

  string ans;
  for (int i = 0; i < cnt; ++i) {
    ans += 'a' + n % 26;
    n /= 26;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
  return 0;
}

int main() {
  int t = 1;
  // scanf("%d", &t);
  while (t--) solve();
  return 0;
}


Measured memory_bytes: 3688
#include<stdio.h>
int main(void){
	int y1,m1,d1,y2,m2,d2;
	int i;
	int y1day,y2day;
	while(1){
		scanf("%d %d %d %d %d %d",&y1,&m1,&d1,&y2,&m2,&d2);
		y1day=y2day=0;
		if(y1==-1 || m1==-1 || d1==-1 || y2==-1 || m2==-1  || d2==-1) break;
		y1day=y2day=0;
		for(i=1;i<y1;i++){
			y1day+=365;
			if((i%4==0 && i%100!=0) || i%400==0) y1day++;
		}
		for(i=1;i<m1;i++){
			y1day+=31;
			if(i==4 || i==6 || i==9 || i==11) y1day-=1;
			if(i==2){
				y1day-=3;
				if((y1%4==0 && y1%100!=0) || y1%400==0) y1day++;
			}
		}
		y1day+=d1;
		for(i=1;i<y2;i++){
			y2day+=365;
			if((i%4==0 && i%100!=0) || i%400==0) y2day++;
		}
		for(i=1;i<m2;i++)	{
			y2day+=31;
			if(i==4 || i==6 || i==9 || i==11) y2day--;
			if(i==2){
				y2day-=3;
				if((y2%4==0 && y2%100!=0) || y2%400==0) y2day++;
			}
	//		printf("y2d==%d\n",y2day);
		}
		y2day+=d2;
	//	printf("%d %d\n",y1day,y2day);
		printf("%d\n",y2day-y1day);
	}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  string s, t;
  cin >> s >> t;
  
  for (int i=0; i<N; i++) {
    cout << s.at(i);
    cout << t.at(i);
  }
  
  cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
//#define int ll

const int md = 1000000007;
const int INF = 1<<30;


class UnionFind{
private:
    vi par,rank,min;
public:
    explicit UnionFind(int n){
        par.resize(n);
        rank.resize(n);
        rep(i,n) par[i] = i;
    }

    explicit UnionFind(vector<int> x){
        int n = x.size();
        par.resize(n);
        rank.resize(n);
        min.resize(n);
        rep(i,n) par[i] = i;
        rep(i,n) min[i] = x[i];
    }

    int root(int x){
        return x == par[x] ? x : par[x] = root(par[x]);
    }

    void unite(int x, int y){
        x = root(x);
        y = root(y);

        if(x == y) return;
        if(rank[x] > rank[y]) swap(x,y);

        par[x] = y;
        if(rank[x] == rank[y]) rank[x]++;
    }

    void minUnite(int x,int y){
        int px = root(x);
        int py = root(y);

        if(px == py) return;
        if(min[px] < min[py]) swap(px,py);
        par[px] = py;
    }

    bool same(int x, int y){
        return root(x) == root(y);
    }

    int minValue(int x){
        return min[x];
    }
};

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    vi x(n);
    rep(i, n) cin >> s[i] >> x[i];
    map<string, int> a;
    rep(i,n){
        a[s[i]] = i;
    }


    UnionFind u(x);
    int m; cin >> m;
    rep(i,m){
        string x, y;
        cin >> x >> y;
        int tmpx = a[x];
        int tmpy = a[y];

        u.minUnite(tmpx,tmpy);
    }

    int ans = 0;
    rep(i,n){
        ans += u.minValue(u.root(i));
    }

    cout << ans << endl;
}



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

int n;
int a[20];
int x[20][20];
int y[20][20];

int counter(int x) {
    if (x == 0) return 0;
    return counter(x >> 1) + (x & 1);
}

void solve() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        for (int j = 1; j <= a[i]; j++) {
            cin >> x[i][j] >> y[i][j];
        }
    }

    int ans = 0;

    for (int bit = 0; bit < (1 << n); bit++) {
        bool ok = true;
        for (int i = 1; i <= n; i++) {
            if (!(bit & (1 << (i-1)))) continue;
            for (int j = 1; j <= a[i]; j++) {
                if (((bit >> (x[i][j]-1)) & 1) ^ y[i][j]) ok = false;
            }
        }
        if(ok) ans = max(ans, counter(bit));
    }

    cout << ans << endl;
    return;
}

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

Measured memory_bytes: 3624
#include<stdio.h>
#include<math.h>
int main(void)
{
	double amount, x1, x2, y1, y2;
	scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2);
	amount = ((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1));
	printf("%f\n",sqrt(amount));
	return 0;
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
using namespace std;
void swap(int *x,int *y){
    int temp = *x;
    *x = *y;
    *y = temp;
}
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a > b){
       swap(&a,&b);
    }
    if(b > c){
       swap(&b,&c);
    }
    if(a > b){
       swap(&a,&b);
    }
   cout << a << " " << b << " " << c << endl;
   return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    int N, L;
    cin >> N >> L;
    vector<string> s(N);
    rep(i, N) cin >> s[i];
    sort(s.begin(), s.end());
    string ans;
    rep(i, s.size()) ans += s[i];
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
   
   for(;;){
   int h,w;
   
   cin>>h>>w;
   
   if(!h) break;
   
   for(int i=0;i<h;i++){
     
     for(int j=0;j<w;j++){
       
       if(i==0 || i==h-1 || j==0 || j==w-1) cout<<"#";
       else cout<<".";
       
     }
     cout<<endl;
   }
   
   cout<<endl;
   
}
   
}



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


int main() {
  string S;
  cin >> S;
  long long ans = 0;
  for(int i = 0; i < S.size(); i++) {
    ans += S.at(i) - '0';
  }
  if(ans%9 == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

//#define DEBUG
#define INF 1000000000
#define REP(i,n) for(int i=1;i<=n;i++)
struct E {int to,cost;};
int n,m,k;
vector<E> G[3002];
vector<int> S;
int D[3002];

int main(){
  cin>>n>>m>>k;
  REP(i,m){
    int a,b,l;
    cin>>a>>b>>l;
    G[a].push_back({b,l});
    G[b].push_back({a,l});
  }
  REP(i,n)D[i]=INF;
  REP(i,k){
    int s;
    cin>>s;
    S.push_back(s);
    D[s]=0;
  }
  for(int s : S){
    queue<int> que;
    que.push(s);
    while(!que.empty()){
      int t=que.front();que.pop();
      for(E e : G[t]){
        if(D[e.to]>D[t]+e.cost){
          D[e.to]=D[t]+e.cost;
          que.push(e.to);
        }
      }
    }
  }
  int ans=0;
  REP(i,n){
    for(E e : G[i]){
      int d=D[i]+D[e.to]+e.cost;
      d-=d/2;
      ans=max(ans,d);
    }
  }
  cout<<ans<<endl;
  #ifdef DEBUG
  REP(i,n){
    cout<<D[i]<<" ";
  }
  #endif
  return 0;
}

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

int main() {
  
  char c;
  cin >> c;
  
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') cout << "vowel\n";
  else cout << "consonant\n";

}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef std::pair<int,int> pair2;
typedef std::pair<int,pair2> pair3;
const ll INF = 1LL<<60;

int main(){
    ll N,K;
  cin >>N>>K;
  ll h[N];
  for(ll i=0;i<N;i++){
  cin >>h[i];
  }
ll dp[N];
  for(ll i=1;i<N;i++){dp[i]=INF;}
  dp[0]=0;

  for(ll i=0;i<N;i++){
    for(ll j=1;j<K+1;j++){
	dp[min(i+j,N)]=min(dp[min(i+j,N)],dp[i]+abs(h[min(i+j,N)]-h[min(i,N)]));
    }
 // cout<<i<<";"<<dp[i]<<endl;
  }
  //  cout<<dp[i]<<endl;
    
  
  cout<<dp[N-1]<<endl;
  
}


Measured memory_bytes: 1792
## subroutines

def fact(n)
  f = 1
  for k in (2..n)
    f *= k
  end
  f
end

### main

n, m, r = gets.strip.split(' ').map{|s| s.to_i}

# n+r-mn-1 C r-mn = (n-1+r-mn)! / (r-mn)! / (n-1)!

ans = fact(n + r - m * n - 1) / fact(n - 1) / fact(r - m * n)
puts ans

Measured memory_bytes: 10276
import collections

S = []
while True:
    try:
        s = int(input())
        S.append(s)
    except EOFError:
        break

c = collections.Counter(S)
k = 0
a = []

if len(S) == 0:
    pass
else:
    for i in range(len(c)):
        if c.most_common()[i][1] == c.most_common()[i+1][1]:
            k += 1
        else:
            break
    for i in range(k+1):
        a.append(c.most_common()[i][0])
        a.sort()

    for i in range(len(a)):
        print(a[i])


Measured memory_bytes: 6008
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll a, b;
  cin >> a >> b;
  rep2(i, 1, 1e5) {
    ll s8 = i * 8 / 100;
    ll s10 = i * 10 / 100;
    if(s8 != a || s10 != b) continue;
    cout << i << endl;
    return 0;
  }
  cout << -1 << endl;
}

Measured memory_bytes: 256
N=int(input())
S=[input() for i in range(N)]
c=[0,0,0,0,0]
for i in S:
    if i[0]=='M':
        c[0]+=1
    elif i[0]=='A':
        c[1]+=1
    elif i[0]=='R':
        c[2]+=1
    elif i[0]=='C':
        c[3]+=1
    elif i[0]=='H':
        c[4]+=1
ans=0
ans+=c[0]*(c[1]*(c[2]+c[3]+c[4])+c[2]*(c[3]+c[4])+c[3]*c[4])
ans+=c[1]*(c[2]*(c[3]+c[4])+c[3]*c[4])
ans+=c[2]*c[3]*c[4]
print(ans)

Measured memory_bytes: 56024
#include<bits/stdc++.h>
using namespace std;
long long n;
const long long mod=26;
int ans[10005]; 
int main()
{
	int len=10001;
	cin>>n;
	if(n%mod==0){
		
	}
	while(n!=0){
		len--;
		if(n%mod==0){
			ans[len]=26;
			n/=mod;
			n--;
			continue;
		}
		ans[len]=n%mod;
		n/=mod;
	}
	for(int i=len;i<=10000;i++)
		cout<<char(ans[i]+'a'-1);
	cout<<endl;
	return 0;
}

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

#define MAX 1000000
#define MIN -1000000

int main() {
    
    long n, min = MAX, max = MIN, sum = 0, v;
    cin>>n;
    for(int i = 0; i < n; i++) {
        cin>>v;
        if(v < min) min = v;
        if(v > max) max = v;
        sum += v;
    }

    cout<<min<<' '<<max<<' '<<sum<<endl;
    return 0;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
    using namespace std ;
    vector<int>vc;
    int k,counter=0;
    int main ( ) {
    int n ;
    cin>>n;
    int a[10000];
    for(int i = 1 ; i <= n ; i ++ ){
        cin>>a[i];
    }
    for(int i =1 ; i <=n ; i ++ ){
        if(a[i] != i ){
            counter++;
        }
    }
    if(counter == 0 || counter == 2){
        cout<<"YES";
    }
    else {
        cout<<"NO";
    }
    }

Measured memory_bytes: 256
from collections import deque

s = list(input())
Q = int(input())
r = False

q = deque(s)
for _ in range(Q):
    query = list(map(str, input().split()))
    if query[0] == '1':
        r = not r
    else:
        f,c = query[1],query[2]
        if f == '1':
            if not r:
                q.appendleft(c)
            else:
                q.append(c)
        else:
            if not r:
                q.append(c)
            else:
                q.appendleft(c)

ans = list(q)
if r: ans = ans[::-1]
print(''.join(ans))


Measured memory_bytes: 101516
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		int num1 = scan.nextInt();
		int num2 = scan.nextInt();
		int num3 = scan.nextInt();
		
		int num4 = num1-num2;
		int ans = num3-num4;
		
		if(ans<0){
			ans = 0;
		}
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 22612
using namespace std;
typedef long long ll;
#include <string>
#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>

#define out(S) cout<<(S)<<endl;
#define mod(i) ((i)%(ll)(1000000000 + 7))
ll modpow(ll i, ll j) { ll tmp = 1; while (j) { if (j % 2)tmp = mod(tmp*i); i = mod(i*i); j /= 2; }return tmp; }
#define divmod(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define For(i,a,b) for(size_t i=(a);i<(b);i++)
#define rFor(i,a,b) for(size_t i=(a)-1;i>=(b);i--)
#define Rep(i,a) for(size_t i=0;i<(a);i++)
#define rRep(i,a) for(size_t i=(a)-1;i>=0;i--)
#define pb(i) push_back(i);
#define Foreach(item,collection) for(auto item:collection)
using vi = vector<int>;


int main(){
	string S;
	cin >> S;
	while (true)
	{
		S.erase(S.size()-1, 1);
		if (S.size() % 2 == 1)continue;
		string up = S.substr(0, S.size() / 2);
		string down = S.substr(S.size() / 2, S.size() / 2);
		if (up == down) break;
	}
	out(S.size());
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = Integer.parseInt(sc.next());
		int x = Integer.parseInt(sc.next());

		int[] a = new int[n];
		int sum = 0;
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
			sum += a[i];
		}
		int left = 1;
		int right = sum;
		int ans = 1;
		while (right - left > 0) {
			ans = (left + right) / 2;
			boolean clear = false;
			clear = isClear(ans, a, x);

			if (clear) {
				right = ans;

			}

			else {
				left = ans + 1;
			}

		}
		if (isClear(ans, a, x) && !isClear(ans - 1, a, x)) {
			System.out.println(ans);
		}
		if (!isClear(ans, a, x) && isClear(ans + 1, a, x)) {
			System.out.println(ans + 1);
		}

	}

	private static boolean isClear(int ans, int[] a, int x) {

		int sum = 0;
		int cnt = 0;
		for (int i = 0; i < x; i++) {
			sum = 0;
			while (true) {
				sum += a[cnt];
				if (sum > ans) {
					break;
				}
				if (cnt == a.length - 1) {
					return true;
				}
				cnt++;
			}
		}

		return false;
	}
}

Measured memory_bytes: 70616
#include "bits/stdc++.h"

using namespace std;

int main() {
    int N;
    cin >> N;
    int K;
    cin >> K;
    vector<int> tall(N);
    for(int i = 0; i < N; i++) cin >> tall.at(i);

    int sum = 0;
    for(int i = 0; i < N; i++){
        if(tall.at(i) >= K) sum++;
    }

    cout << sum << endl;
}

Measured memory_bytes: 768
import scala.io.StdIn.{readInt,readLine}
import scala.collection.mutable.HashMap
import scala.collection.mutable.ArrayBuffer

object Main {

  def move(m:Int, d1:Int, d2:Int) = {
    val x = m/d2 % 10
    m-9*d1-x*d2+9*d2+x*d1
  }
  def end(m:Int) = m == 123456789

  def main(args:Array[String]) = {
    val hist = new ArrayBuffer[Int]
    val phist = new ArrayBuffer[Int]
    val map = new HashMap[Int,Int]
    var pointer = 0
    var found = false
    var count = 0

    val s = { for(i<-1 to 3) yield readLine.split(" ").reduce(_+_) }.reduce(_+_)
    val idx = 8-s.indexWhere(_=='0')
    phist += idx

    val n = s.map{ c => if(c=='0') '9' else c }.toInt
    hist += n
    map += (n->1)

    if(end(n)) found = true
    while(!found) {
      val len = hist.length
      for(i<-pointer until len if !found) {
        val pos = phist(i)
        val data = hist(i)
        val p = Math.pow(10,pos).toInt
        if((8-pos)%3 != 2) {
          val r = move(data, p, p/10)
          if(end(r)) found = true
          else if(!map.contains(r)) {
            hist += r
            map += (r->1)
            phist += pos-1
          }
        }
        if(!found && (8-pos) % 3 != 0) {
          val r = move(data, p, p*10)
          if(end(r)) found = true
          else if(!map.contains(r)) {
            hist += r
            map += (r->1)
            phist += pos+1
          }
        }
        if(!found && (8-pos) / 3 != 0) {
          val r = move(data, p, p*1000)
          if(end(r)) found = true
          else if(!map.contains(r)) {
            hist += r
            map += (r->1)
            phist += pos+3
          }
        }
        if(!found && (8-pos) / 3 != 2) {
          val r = move(data, p, p/1000)
          if(end(r)) found = true
          else if(!map.contains(r)) {
            hist += r
            map += (r->1)
            phist += pos-3
          }
        }
      }
      pointer = (len-pointer)
      count += 1
    }
    println(count)
  }

}

Measured memory_bytes: 122024
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
vector<int> nex[114514];
int deg[114514];
int ans[114514];
signed main(){
	int n;
	cin>>n;
	for(int i=0;i<n-1;i++){
		int x,y;
		cin>>x>>y;
		nex[x].pb(y);
		nex[y].pb(x);
		deg[x]++;
		deg[y]++;
	}
	vector<int> c;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		c.pb(x);
	}
	sort( c.begin(), c.end() );
	queue<int> que;
	for(int i=1;i<=n;i++){
		if( deg[i] == 1 )que.push(i);
	}
	int idx = 0;
	int res = 0;
	while( !que.empty() ){
		int cur = que.front(); que.pop();
		ans[cur] = c[idx];
		res += c[idx];
		idx++;
		for(int i=0;i<nex[cur].size();i++){
			int nx = nex[cur][i];
			deg[nx]--;
			if( deg[nx] == 1 ){
				que.push(nx);
			}
		}
	}
	cout<<res-c[c.size()-1]<<endl;
	for(int i=1;i<=n;i++){
		cout<<ans[i]<<" ";
	}
	cout<<endl;
	return 0;
}

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

int main(){
    string X;
    cin>>X;
    int len = X.size();
    string ans = "x";
    for(int i = 1; i < len; i++){
        ans += "x";
    }
    cout<<ans<<endl;
    return 0;
}

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

#define chmax(x, y) x = max(x, y)

int main(void){
    int N;
    cin >> N;
    vector<int> A(1 << N);
    for(int i = 0; i < (1 << N); ++i)   cin >> A[i];
    
    int res = 0;
    for(int K = 1; K < (1 << N); ++K){
        int firstmax = max(A[K], A[0]), secondmax = min(A[K], A[0]);
        int subset = (K - 1) & K;
        while(subset){  // 部分集合列挙
            int hoge = A[subset];
            if(hoge > firstmax)     swap(hoge, firstmax);
            if(hoge > secondmax)    swap(hoge, secondmax);
            subset = (subset - 1) & K;
        }
        chmax(res, firstmax + secondmax);
        cout << res << "\n";
    }
}

Measured memory_bytes: 4224
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x.size())
#define pb push_back
#define mp make_pair
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define int long long
#define endl "\n"

using namespace std;

const int N = 500510;
const int inf = (int)(1e18) + 123;
const int mod = 998244353;
const double eps = 1e-9;


int n, k, cnt;

signed main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k;
    for(int i = 1; i <= n; ++i) {
        int x; cin >> x;
        cnt += (x >= k);
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct P
{
    //string r;
    int x,y,z;

    bool operator<(const P &a)const{
       // if(y!=a.y)
       // return y>a.y;
       return x<a.x;
//        return z>a.z;
    }
};

vector<int> v[5555];
//bitset<4001000> b;
int a,c,i,b,k,d,n,m,e[10][10][10];//dy[15]={0,1,0,-1,-1,1,-1,1},dx[15]={1,0,-1,0,1,1,-1,-1};//
int l[555][555];
int o[2400];
int dx[10]={0,1,0,-1},dy[10]={1,0,-1,0},dz[10]={0,0,0,0,1,-1};

long long x,y,z,mod=1000000007;
P u[1111];
int j[555][555];

stack<int> s;
queue<int> q;
priority_queue<int> q1;
priority_queue<P> q2;
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
map<int,int > p;
//list<int> l;
string r[555],r1[555],r2;
//char r[333];


bool as(P a,P b)
{
    if(a.x!=b.x) return a.x<b.x;
    return a.y>b.y;
}

long long f(long long a,long long b)
{
    if(b==0) return 1;
    if(b==1) return a;
    long long k=f(a,b>>1);
    k*=k,k%=mod;
    if(b&1) k*=a,k%=mod;
    return k;
}

int main()
{
    scanf("%d %d",&a,&b);
    for(int t=1;t<a;t++)
    {
        scanf("%d %d",&n,&m);
        v[n].push_back(m);
        v[m].push_back(n);
    }
    //b++;
    k=987654321;
    if((b)%2==0)
    for(int t=1;t<=a;t++)
    {
        memset(o,0,sizeof(o));
        i=0;
        o[t]=1;
        q.push(t);
        for(;q.size();q.pop())
        for(int h=0;h<v[q.front()].size();h++)
        if(!o[v[q.front()][h]])
        {
            o[v[q.front()][h]]=o[q.front()]+1;
            //printf("%d\n",o[v[q.front()][h]]);
            q.push(v[q.front()][h]);
            if(o[q.front()]>b/2) i++;
        }
        //printf("@@@%d %d\n",i,t);
        k=min(k,i);
    }
    else
    for(int t=1;t<=a;t++)
    for(int w=0;w<v[t].size();w++)
    {
        memset(o,0,sizeof(o));
        i=0;
        o[t]=1;
        o[v[t][w]]=1;
        //if(b>1) i++;
        q.push(t);
        q.push(v[t][w]);
        for(;q.size();q.pop())
        for(int h=0;h<v[q.front()].size();h++)
        if(!o[v[q.front()][h]])
        {
            o[v[q.front()][h]]=o[q.front()]+1;
            q.push(v[q.front()][h]);
            if(o[q.front()]>b/2) i++;
        }
        k=min(k,i);
    }
    printf("%d",k);
}


Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func zoro(n int) bool {
	return (n/100)%10 == (n/10)%10 && (n/10)%10 == n%10
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	for ; !zoro(n); n++ {
	}
	fmt.Println(n)
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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; }
////////////////////////////////////////////////////////////////////////////////////////////////////////

ll gcd(ll X, ll Y) {
    return (X ? gcd(Y%X,X) : Y);
}
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int T; cin >> T;
    while (T--) {
        ll A,B,C,D; cin >> A >> B >> C >> D;

        if (B > A || B > D) {
            cout << "No" << endl;
            continue;
        }
        if (C+1LL >= B) {
            cout << "Yes" << endl;
            continue;
        }
        ll E = A%B, F = D-B;
        bool ok = true;
        if (D == B) {
            if (C < E) ok = false;
        }
        else if (C-E < 0) ok = false;
        else {
            ll G = gcd(B,D);
            if ((C-E)/G+1LL <= (B-E-1LL)/G) ok = false; 
            //if((C-E)/F+1LL <= (B-E-1LL)/F) ok = false;
        }
        cout << (ok ? "Yes" : "No") << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<queue>
#include<set>
#include<utility>
using namespace std;
char C(char a,char b)
{
	if(a!='r'&&b!='r')return'r';
	if(a!='g'&&b!='g')return'g';
	return'b';
}
int F(string s)
{
	int i,b;
	string n;
	set<string> h;
	typedef pair<string,int>T;
	queue<T> q;	
	T p;
	q.push(make_pair(s,0));
	while(!q.empty())
	{
		p=q.front();q.pop();
		s=p.first;
		if(!h.insert(s).second)continue;
		for(b=1,i=0;i+1<s.size();++i)
			if(s[i]!=s[i+1])b=0;
		if(b) return p.second;

		for(i=0;i+1<s.size();++i)
		{
			if(s[i]!=s[i+1])
			{
				n=s;
				n[i]=n[i+1]=C(n[i],n[i+1]);
				q.push(make_pair(n,p.second+1));
			}
		}
	}
	return -1;
}
int main()
{
	string s;
	int n;
	while(cin>>s,s[0]-'0')
		if((n=F(s))<0) cout<<"NA\n";
		else cout<<n<<endl;
	return 0;
}

Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define degreeToRadian(deg) (((deg)/360)*2*M_PI)
#define radianTodegree(rad) (((rad)/2/M_PI)*360)
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; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const int MOD = 1e9 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//cin.tie(0);ios::sync_with_stdio(false);
//cout << fixed << setprecision(15) << y << endl;
int main() {
  ll k, a, b;
  cin >> k >> a >> b;

  if (k < 3 || k <= (a - 1) || a >= b || (b - a) <= 2) {
    cout << k + 1 << endl;
  } else {
    ll bis = 0;
    k -= (a - 1);
    bis += a;
    bis += (b - a) * (k / 2);
    if (k % 2 == 1) bis += 1;
    cout << bis << endl;
  }
  return 0;
}


Measured memory_bytes: 3568
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);

		int N = scanner.nextInt();
		int K = scanner.nextInt();

		int ans = 0;

		for (int i = 0; i < N; i++) {
			int h = scanner.nextInt();
			if (K <= h)
				ans++;
		}

		System.out.println(ans);
	}
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef complex<double> cd;

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define pb push_back
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

signed main()
{
    srand(time(NULL));
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int L = 0;
    for (int i = 1; i < n; i += 2)
    {
        s[i] = 'A' + 'B' - s[i];
    }
    if (k > 2 * n)
    {
        k = 2 * n + (k % 2);
    }
    for (int i = 0; i < k; i++)
    {
        if (s[L] == 'A')
        {
            s[L] = 'B';
        }
        else
        {
            L++;
            if (n % 2) s += "A";
            else s += "B";
        }
    }
    for (int i = L; i < s.size(); i++)
    {
        if ((i - L) % 2) cout << (char)('A' + 'B' - s[i]);
        else cout << s[i];
    }
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


Measured memory_bytes: 3876
using System;

class Program
    {
        static void Main(string[] args)
        {
            int num = int.Parse(Console.ReadLine());
            string[] data = Console.ReadLine().Split();
            for(int i = num - 1; i >= 0; i--)
            {
                if (i == 0)
                {
                    Console.WriteLine(data[i]);
                }
                else
                {
                    Console.Write("{0} ", data[i]);
                }
            }
        }
    }

Measured memory_bytes: 8912
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
use proconio::{fastout, input};
#[fastout]
fn main() {
    input! {
        n: usize,
        a: [usize; n]
    }
    let mut prev = false;
    let mut next = false;
    let mut count = 1;
    let mut skip = true;
    for i in 0..n - 1 {
        if a[i] == a[i + 1] {
            continue;
        } else if a[i] < a[i + 1] {
            next = true;
        } else {
            next = false;
        }
        if skip {
            skip = false;
            prev = next;
            continue;
        }
        if prev == next {
            continue;
        } else {
            count += 1;
            prev = next;
            skip = true;
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 3612
#include <iostream>
#include <map>
#include <string>

int main()
{
	bool flag = true;
	std::string s;
	std::map<char, int> m;
	std::cin >> s;
	for (int i = 0; i < s.size();i++) {
		m[s[i]] = 0;
	}
	for (int i = 0; i < s.size();i++) {
		m[s[i]]++;
	}
	for (int i = 0; i < s.size(); i++)
	{
		flag = flag && (m[s[i]] % 2 == 0);
	}
	if (flag) std::cout << "Yes" << std::endl;
	else std::cout << "No" << std::endl;
} 

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    Integer a = Integer.valueOf(sc.next());
    Integer b = Integer.valueOf(sc.next());
    Integer c = Integer.valueOf(sc.next());
    Set<Integer> set = new HashSet<>();
    set.add(a);
    set.add(b);
    set.add(c);
    if (set.size() == 2) {
      pw.println("Yes");
    } else {
      pw.println("No");
    }
  }
}


Measured memory_bytes: 21844
s = input()
n = len(s)
a = int((n-1)/2)
b = int((n+3)/2)-1
def ispalindrome(str): return 1 if str == str[::-1] else 0

if ispalindrome(s) == 1 and ispalindrome(s[:a]) == 1 and ispalindrome(s[b:]) == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_range(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep_rev(i, s, e) for (int i = (s)-1; i >= (int)(e); i--)
#define sort_vec(v) sort((v).begin(),(v).end())
typedef int64_t lint;
// lint mod = 998244353;
template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

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

  vector<int> a(n),b(n);
  rep(i,n){
    cin>>a[i]>>b[i];
  }

  sort(a.begin(),a.end());
  int ma=a[(n-1)/2]+a[n/2];

  sort(b.begin(),b.end());
  int mb=b[(n-1)/2]+b[n/2];
  
  return (mb-ma)/(1+n%2)+1;
}

int main(){cout<<app()<<endl;return 0;}


Measured memory_bytes: 4780
// 
import java.math.*;
import java.util.*;
import java.io.*;
  
public class Main { 
  
    static BufferedReader in;
    static String file = "../in";

    static int test = 10;  // 0 for local testing, 1 for std input

    public static void main(String[] args) throws Exception
    {
        int _k = Integer.valueOf("1");
        if(test > 0) in = new BufferedReader(new InputStreamReader(System.in));
        else in = new BufferedReader(new FileReader(file));
        if(test < 0) {String[] str = in.readLine().split(" ");}
        
        /****************************************************/
        /****************************************************/
        /****************************************************/
        /****************************************************/

        String[] sp = in.readLine().split(" ");
        
        int a = Integer.valueOf(sp[0]);
        int b = Integer.valueOf(sp[1]);
        if(a * 500 >= b) System.out.println("Yes");
        else System.out.println("No");

    }
}

Measured memory_bytes: 21076
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
INF = 10**18

S=input()

ans = INF
for i in range(len(S)-2):
    rst = abs(753 - int(S[i:i+3]))
    if ans > rst:
        ans = rst

print(ans)

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

using pii = pair<int, int>;

constexpr int inf = 1e9;

int eval_impl(string const& s, int& p, const int S) {
    if(s[p] == '0' || s[p] == '1') {
        return s[p++] == '1';
    }
    if(isalpha(s[p])) {
        return (S >> (s[p++] - 'a')) & 1;
    }
    if(s[p] == '-') {
        return !eval_impl(s, ++p, S);
    }
    if(s[p] == '(') {
        const bool t1 = eval_impl(s, ++p, S);
        const char op = s[p++];
        const bool t2 = eval_impl(s, p, S);
        p++; // )
        if(op == '^') return t1 ^ t2;
        else          return t1 & t2;
    }
    assert(false);
    return -1;
}

int eval(string const& s) {
    int truth = 0;
    for(int S = 0; S < 1 << 4; ++S) {
        int p = 0;
        truth |= (eval_impl(s, p, S) << S);
    }
    return truth;
}

int main() {
    constexpr int all_mask = (1 << 16) - 1;
    vector<int> ans(1 << 16, inf);
    ans[0] = ans[(1 << 16) - 1] = 1;
    ans[eval("a")] = ans[eval("b")] = ans[eval("c")] = ans[eval("d")] = 1;
    vector<int> ts = {0, (1 << 16) - 1, eval("a"), eval("b"), eval("c"), eval("d")};
    vector<int> len = {1, 1, 1, 1, 1, 1};
    priority_queue<pii, vector<pii>, greater<>> que;
    for(int i = 0; i < (int)ts.size(); ++i) {
        que.emplace(len[i], ts[i]);
    }
    while(!que.empty()) {
        const auto l = que.top().first;
        const auto t = que.top().second;
        que.pop();
        if(ans[t ^ all_mask] > l + 1) {
            ans[t ^ all_mask] = l + 1;
            que.emplace(l + 1, t ^ all_mask);
            ts.push_back(t ^ all_mask), len.push_back(l + 1);
        }
        const int m = ts.size();
        for(int i = 0; i < m; ++i) {
            if(len[i] + l + 3 > 16) continue;
            if(ans[t & ts[i]] > len[i] + l + 3) {
                ans[t & ts[i]] = len[i] + l + 3;
                ts.push_back(t & ts[i]), len.push_back(len[i] + l + 3);
                que.emplace(len[i] + l + 3, t & ts[i]);
            }
            if(ans[t ^ ts[i]] > len[i] + l + 3) {
                ans[t ^ ts[i]] = len[i] + l + 3;
                ts.push_back(t ^ ts[i]), len.push_back(len[i] + l + 3);
                que.emplace(len[i] + l + 3, t ^ ts[i]);
            }
        }
    }

    string exp;
    while(cin >> exp, exp != ".") {
        const auto t = eval(exp);
        cout << ans[t] << endl;
    }
}



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

typedef long long ll;

using namespace std;

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

template<class T>
using vt = vector<T>;
template<class T>
using vvt = vector<vector<T>>;

int main(){
    string o,e,re="";
    int len;
    cin >> o >> e;
    len = o.size()+e.size();
    re = re + o[0];
    reps(i,1,len-1){
        if(i%2){
            re = re + e[i/2];
        }
        else re = re + o[i/2];
    }
    cout << re << endl;
    return 0;
}


Measured memory_bytes: 256
n,k,c = map(int, input().split())
s = input()
L = []
L.append(-c)
workday = 1
for i in range(1, n+1):
    if i <= L[workday-1] + c:
        continue
    if s[i-1] == 'x':
        continue
    L.append(i)
    workday += 1
    if workday == k + 1:
        break
R = [0] * (k+2)
R[k+1] = n + c + 1
workday = k
for i in range(n, 0, -1):
    if i >= R[workday+1] - c:
        continue
    if s[i-1] == 'x':
        continue
    R[workday] = i
    workday -= 1
    if workday == 0:
        break
for i in range(1, k+1):
    if L[i] == R[i]:
        print(L[i])

Measured memory_bytes: 20708
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    int ary[n];
    rep(i, n) cin >> ary[i];
    int ans[n];
    int sum_num = 0;

    for (int i = n-1;i >= 0; i--) {
        int repeat_count = n / (i+1);
        int tmp_sum = 0;
        REP(j, 1, repeat_count) {
            tmp_sum += ans[(i + 1) * (j + 1) - 1];
        }
        // cout << tmp_sum << endl;
        if (tmp_sum%2 != ary[i]) {
            ans[i] = 1;
            sum_num ++;
        }
        else
        {
            ans[i] = 0;
        }
    }

    cout << sum_num << endl;
    int tmp_m = 0;
    rep(i,n) {
        if (ans[i] == 1) {
            cout << i+1;
            tmp_m++;
            if (tmp_m != sum_num) {
                cout << " ";
            }
        }
    }
}


Measured memory_bytes: 2560
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<stack>
#include<queue>
using namespace std;

typedef long long i64;
#define put(n) cout<<(n)<<"\n"
#define FOR(i,num,N) for(int(i)=(num);(i)<(N);(i)++)
#define RFOR(i,num,N) for(int (i)=(num);(i)>(N);(i)--)
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()

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

    vector<int> A(N);
    FOR(i,0,N){
        cin>>A[i];
        A[i] -= (i+1);
    }
    sort(all(A));
    
    int b = A[N/2];
    i64 ans = 0;
    FOR(i,0,N) ans += abs(A[i]-b);
    put(ans);
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 200010;
 
// aのn乗を求める。計算量はO(logn)
ll modpow(ll a, ll n) {
    if(n == 0) {
        return 1;
    }
    if(n%2 == 1) {
        return (a * modpow(a, n-1))%mod;
    }
    return (modpow(a, n/2) * modpow(a, n/2))%mod;
}
 
ll inverse(ll a) {
    return modpow(a, mod-2);
}
 
ll inv[MAX_N];  // inv[i] : iの逆数のmod
ll fact[MAX_N];  // fact[i] : iの階乗のmod
ll invfact[MAX_N];
 
void init() {
    inv[0] = fact[0] = invfact[0] = 1;
    inv[1] = 1;
    for(ll i = 1; i < MAX_N; i++) {
        if(i >= 2) {
            inv[i] = mod - inv[mod%i]*(mod/i)%mod;
        }
        fact[i] = (i*fact[i-1])%mod;
        invfact[i] = inverse(fact[i]);
    }
}
 
ll Comb(ll n, ll r) {
    if(r < 0 || n < 0 || n < r) {
        return 0;
    }
    ll res = fact[n];
    res = (res * invfact[r])%mod;
    res = (res * invfact[n-r])%mod;
    return res;
}
 
//--- main関数でinit()を呼び出すのを忘れるな ---//
int main() {
    ll n, k;
    cin >> n >> k;
 
    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }
    sort(all(a));
 
    init();
    
    ll x = 0;
    exrep(i, 0, n-k) {
        x += (3*mod + a[(n-1)-i]*Comb((n-1)-i, k-1))%mod;
        x %= mod;
    }
    
    ll y = 0;
    exrep(i, 0, n-k) {
        y += (3*mod + a[i]*Comb((n-1)-i, k-1))%mod;
        y %= mod;
    }
    
    ll ans = (x + 3*mod - y)%mod;
    
    out(ans);
    re0;
}

Measured memory_bytes: 5760
from collections import Counter

N = int(input())
A = [int(i) for i in input().split()]
zz = Counter(A)

if N%2 == 0:
    for i in range(1,N,2):
        if zz[i] != 2:
            print(0)
            exit()
else:
    if zz[0] != 1:
        print(0)
        exit()
    for i in range(2,N,2):
        if zz[i] != 2:
            print(0)
            exit()

p = N//2
print(2**p%(10**9+7))


Measured memory_bytes: 55532
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) &= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double PI = (double)acos(-1);
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  double n, m, d;
  cin >> n >> m >> d;

  if (d == 0) {
    cout << fixed << setprecision(13) << (1 / n) * (m - 1) << endl;
  } else {
    cout << fixed << setprecision(13) << (2.0 * (n - d) / (n * n)) * (m - 1) << endl;
  }

  return 0;
}


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

typedef long long ll;
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> tree(n + 1);
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        tree[u].emplace_back(v);
    }
    int s, t;
    cin >> s >> t;
    queue<pair<int, int>> q;
    q.emplace(pair<int, int>{s, 0});
    vector<vector<bool>> reached(3, vector<bool>(n + 1, false));
    reached[0][s] = true;
    while (!q.empty()) {
        auto front = q.front();
        q.pop();
        int cur = front.first;
        int count = front.second;
        if (cur == t && count % 3 == 0) {
            cout << count / 3 << endl;
            return 0;
        }
        for (auto e: tree[cur]) {
            if (!reached[(count + 1) % 3][e]) {
                q.emplace(pair<int, int>{e, count + 1});
                reached[(count + 1) % 3][e] = true;
            }
        }
    }
    cout << -1 << endl;
    return 0;
}


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

long long ndivide(long long A, long long B, long long C){
    long long upper = B / C;
    long long lower = A / C;
    if(A % C == 0){
        // cout << upper - lower + 1 << endl;
        return upper - lower + 1;
    }
    else{
        // cout << upper - lower << endl;
        return upper - lower;
    }
}

long long gcd(long long A, long long B){
    if(A < B){
        long long tmp = A;
        A = B;
        B = tmp;
    }
    if(B == 0) return A;
    return gcd(B, A%B);
}

int main(){
    long long A, B;
    long long C, D;

    cin >> A >> B >> C >> D;

    cout << (B-A+1) - (ndivide(A, B, C)+ndivide(A, B, D)-ndivide(A, B, C*D/gcd(C, D))) << "\n";
    return 0;
}

Measured memory_bytes: 256
def resolve():
    a,b=map(int, input().split())
    if a==1 and b!=1:
        print('Alice')
    elif b==1 and a!=1:
        print('Bob')
    else:
        if a<b:
            print('Bob')
        elif a==b:
            print('Draw')
        else:
            print('Alice')

resolve()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define INF  (1<<30)
#define INFL (1LL<<60)
#define EPS ((ld)(1e-9))
 
#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define rep(i, e) for (int i = 0, _##i = (e); i < _##i; i++)
#define repp(i, s, e) for (int i = (s), _##i = (e); i < _##i; i++)
#define repr(i, s, e) for (int i = (s)-1, _##i = (e); i >= _##i; i--)
#define repi(i, x) for (auto &i : (x))
#define ARR(...) vector<int>({__VA_ARGS__})
#define ARS(...) vector<string>({__VA_ARGS__})
 
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef complex<double> base;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    return os << '(' << pai.first << ' ' << pai.second << ')';
}
 
template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    cout << '[';
    for (auto p : v) cout << p << ",";
    cout << "]";
    return os;
}
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const set<T, V> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const map<T, V> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}
 
#ifndef __DJKIM613
#define debug(...) 0
#define endl '\n'
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif
 
template<typename T> void get_max(T &a, T b) {a = max(a, b);}
template<typename T> void get_min(T &a, T b) {a = min(a, b);}

ld a, b, x;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    
    cin >> a >> b >> x;

    ld rad = 0;
    if(a * a * b / 2 >= x) rad = atan(a * b * b / (2 * x));
    else rad = atan((2 * b - 2 * x / (a * a)) / a);

    ld PI = acos(-1);
    cout << fixed << setprecision(10);
    cout << rad / PI * 180;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    string s, t;
    cin>>s>>t;
    int ans = 0;
    rep(i, s.size()){
        if(s[i] != t[i]) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3864