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

using namespace std;

struct Node {
    int key;
    Node *parent, *left, *right;
};
Node *root, *NIL;

void insert(int key) {
    Node *parent = NIL;
    Node *node = root;
    Node *target;

    target = (Node *)malloc(sizeof(Node));
    target->key = key;
    target->left = NIL;
    target->right = NIL;

    while(node != NIL) {
        parent = node;
        if(target->key < node->key) {
            node = node->left;
        } else {
            node = node->right;
        }
    }
    target->parent = parent;

    if(parent == NIL) {
        root = target;
    } else {
        if(target->key < parent->key) {
            parent->left = target;
        } else {
            parent->right = target;
        }
    }
}

void preorder(Node *node) {
    if(node->left != NIL) {
        preorder(node->left);
    }
    printf(" %d", node->key);
    if(node->right != NIL) {
        preorder(node->right);
    }
}

void inorder(Node *node) {
    printf(" %d", node->key);
    if(node->left != NIL) {
        inorder(node->left);
    }
    if(node->right != NIL) {
        inorder(node->right);
    }
}

int main() {
    int n, key;
    string code;
    cin >> n;
    root = (Node *)malloc(sizeof(Node));
    NIL = (Node *)malloc(sizeof(Node));
	root = NIL;
    for(int i = 0; i < n; i++) {
        cin >> code;
        if(code == "print") {
            preorder(root);
            printf("\n");
            inorder(root);
            printf("\n");
            continue;
        }
        scanf("%d", &key);
        if(code == "insert"){
            insert(key);
		}
    }
}


Measured memory_bytes: 26756
#include <bits/stdc++.h>
using namespace std;
int n, a[100009];
int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);
	int r = 1; long long ret = 0;
	for(int i = 0; i < n; i++) {
		if((a[i] - 1) >= r) ret += (a[i] - 1) / r, a[i] = 1;
		r = max(r, a[i] + 1);
	}
	printf("%lld\n", ret);
	return 0;
}

Measured memory_bytes: 768
#define DEBUG 0

/**
 * File    : D2.cpp
 * Author  : Kazune Takahashi
 * Created : 3/10/2019, 11:00:46 PM
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(10101010));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef long long ll;

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

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

int L;
ll A[200010];
ll DP[200010][5];

ll near_even(ll x)
{
  if (x == 0)
  {
    return 2;
  }
  return x % 2;
}

ll near_odd(ll x)
{
  if (x % 2 == 0)
  {
    return 1;
  }
  else
  {
    return 0;
  }
}

int main()
{
  cin >> L;
  for (auto i = 0; i < L; i++)
  {
    cin >> A[i];
  }
  fill(&DP[0][0], &DP[0][0] + 200010 * 5, 0);
  for (auto i = 0; i < L; i++)
  {
    ll mini = DP[i][0];
    DP[i + 1][0] = mini + A[i];
    mini = min(DP[i][1], mini);
    DP[i + 1][1] = mini + near_even(A[i]);
    mini = min(DP[i][2], mini);
    DP[i + 1][2] = mini + near_odd(A[i]);
    mini = min(DP[i][3], mini);
    DP[i + 1][3] = mini + near_even(A[i]);
    mini = min(DP[i][4], mini);
    DP[i + 1][4] = mini + A[i];
  }
  ll ans = DP[L][0];
  for (auto i = 1; i < 5; i++)
  {
    ans = min(ans, DP[L][i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 9728
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int n[4];
    REP(i,4){
        cin >> n[i];
    }
    sort(n, n + 4);
    if(n[0] == 1 && n[1] == 4 && n[2] == 7 && n[3] == 9){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define int long long
using namespace std;
typedef vector<int> vi;
#define y1 abacaba
#define left sefude
typedef long long ll;
typedef pair<int,int> pii;
inline ll mod(ll n, ll m ){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}

const int M = 1e9 + 7;

const int N = 2e6 + 10;
ll inv[N],fat[N];
ll C(int n,int k){
  if(k>n)return 0;
  return mod(fat[n]*mod(inv[k]*inv[n-k],M),M);
}
ll invi(int x){
  return exp(x,M-2,M);
}


int32_t main(){
  fastio;
  int k;
  string s;
  cin>>k;
  cin>>s;
  fat[0] = inv[0] = 1;
  for(int i=1;i<N;i++){
    fat[i]= (i*fat[i-1])%M;
  }
  inv[N-1] = exp(fat[N-1],M-2,M);
  for(int i=N-2;i>=0;i--){
    inv[i] = (inv[i+1]*(i+1))%M;
  }
  int n = sz(s);
  ll ans = 0;
  for(int i = n;i<=n + k ;i++){
    
    ll put = mod(exp(25,i-n,M) * C(i-n + n - 1, n -1),M);
    ans= mod(ans + exp(26,n+k-i,M) * put,M);
    //cout << i<<" "<<put << endl;
  }

  cout << ans << endl;

  // Math -> gcd it all
  // Did u check N=1? Did you switch N,M?
}

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

int Ordinary(int n){
    int P[n]={};
    for(int i=0;i<n;i++){
        cin >> P[i];
    }
    int cnt=0;
    for(int i=0;i<n-2;i++){
        if(P[i]<P[i+1]&&P[i+1]<P[i+2]){
            cnt++;
        }
        else if(P[i]>P[i+1]&&P[i+1]>P[i+2]){
            cnt++;
        }
    }
    return cnt;
}

int main(){
    int n; cin >> n;
    cout << Ordinary(n) << endl;
    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        var line = Console.ReadLine();
        var Ws = new int[N];
        var Es = new int[N];
        var leftW = new int[N];
        var rightE = new int[N];
        leftW[0] = 0;
        rightE[N-1] = 0;
        for (int i = 1; i < N; i++)
        {
            if (line[i-1] == 'W')
            {
                leftW[i] = leftW[i-1]+1;
            }
            else
            {
                leftW[i] = leftW[i - 1];
            }
        }
        for (int i = N-2; i >= 0; i--)
        {
            if (line[i+1] == 'W')
            {
                rightE[i] = rightE[i + 1];
            }
            else
            {
                rightE[i] = rightE[i + 1]+1;
            }
        }
        var min = int.MaxValue;
        for (int i = 0; i < N; i++)
        {
            var val = leftW[i] + rightE[i];
            if (val < min)
            {
                min = val;
            }
        }
        Console.WriteLine(min);
    }
}

Measured memory_bytes: 16480
#include <iostream>
#include<queue>
#include <string>
#include <cstdlib>
#include<algorithm>
#include<vector>
using namespace std;

int main(int argc, const char * argv[]) {
    string sa,sb,sc;
    queue<char> qa,qb,qc;
    cin>>sa>>sb>>sc;
    //cout<<sa<<sb<<sc;
    for(int i=0;i<sa.size();i++) qa.push(sa[i]);
    for(int i=0;i<sb.size();i++) qb.push(sb[i]);
    for(int i=0;i<sc.size();i++) qc.push(sc[i]);
    qa.push(1);
    qb.push(1);
    qc.push(1);
    
    
    bool ba=true;
    bool bb=false;
    bool bc=false;
    
    //for(int i=0;i<2*(sa.size()+sa.size()+sa.size());i++){
    while(!qa.empty() && !qb.empty() && !qc.empty()){
        if(ba==true ){
            //if(qa.front()=='a') { ba=true;}
             if(qa.front()=='b') {ba=false; bb=true;}
            else if(qa.front()=='c') {ba=false; bc=true;}
            //cout<<qa.front();
            qa.pop();
        }
        else if(bb==true ){
            if(qb.front()=='a') {bb=false; ba=true;}
            //else if(qb.front()=='b') {bb=true;}
            else if(qb.front()=='c') {bb=false; bc=true;}
            //cout<<qb.front();
            qb.pop();
        }
        else if(bc==true ){
            if(qc.front()=='a') {bc=false; ba=true;}
            else if(qc.front()=='b') {bc=false; bb=true;}
            //else if(qc.front()=='c') { bc=true;}
            //cout<<qc.front();
            qc.pop();
        }
        //if(qa.pop()==1 || qb.empty() || qc.empty()) break;
    }
    //cout<<qa.front()<<qb.front()<<qc.front();
    
    if(qa.empty())cout<<'A'<<endl;
    else if(qb.empty())cout<<'B'<<endl;
    else if(qc.empty())cout<<'C'<<endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		BigDecimal A = new BigDecimal(tokens[0]);
		BigDecimal B = new BigDecimal(tokens[1]);
		A = A.multiply(B);
		BigInteger result = A.toBigInteger();
		System.out.println(result);

	}

	void calc() {
	}

	void showResult() {
	}
}


Measured memory_bytes: 33240
import math 
 
side, height, volume = list(map(int, input().split()))
 
fullvolume = side * side * height
space = fullvolume - volume
 
if fullvolume/2 > volume:
  n = (2 * volume) / (side * height)
  
  angle = 90 - math.degrees(math.atan(n/height))
else:
  n = (2 * space) / (side * side)
  angle = math.degrees(math.atan(n/side))
print(angle)

Measured memory_bytes: 3060
#include<iostream>
#include<set>

using namespace std;

int main(){
    int n, idx = 0;
    cin >> n;

    set<int> s;

    int tmp;
    for(int i = 0; i< n; i++){
        cin >> tmp;
        s.insert(tmp);
        idx++;
    }

    if(s.size() == idx)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 9600
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
#include<cmath>
using namespace std;

typedef long long int llint;

int main(){
	llint N,K;
	cin >> N >> K;
	int A[N];
	bool visited[N];
	for(int i=0;i<N;i++){
		cin >> A[i];
		A[i]--;
		visited[i]=false;
	}

	vector<int> route;
	int pos=0;
	while(!visited[pos]){
		route.push_back(pos);
		visited[pos]=true;
		pos=A[pos];
	}
	int backI=pos;
	for(int i=0;i<route.size();i++){
		if(route[i]==pos){
			backI=i;
		}
	}
	if(K<route.size()){
		cout << route[K]+1 << endl;
	}else{
		cout << route[(K-backI)%(route.size()-backI)+backI]+1 << endl;
	}
	return 0;
}


Measured memory_bytes: 5264
S = input()
flip_points = [0]
values = [0 for i in range(len(S))]
for i,e in enumerate(S):
    if i != 0 and S[i] != S[i-1]:
        flip_points.append(i)
        if len(flip_points)%2 == 1 and len(flip_points) != 1:
            first_count = flip_points[-2] - flip_points[-3]
            second_count = flip_points[-1] - flip_points[-2]
            values[flip_points[-2]-1] += first_count//2 + second_count//2 
            values[flip_points[-2]] += first_count//2 + second_count//2
            if first_count % 2 == 1:
                values[flip_points[-2]-1] += 1
            if second_count % 2 == 1:
                values[flip_points[-2]] += 1

first_count = flip_points[-1] - flip_points[-2]
second_count = len(S) - flip_points[-1]
values[flip_points[-1]-1] += first_count//2 + second_count//2 
values[flip_points[-1]] += first_count//2 + second_count//2
if first_count % 2 == 1:
    values[flip_points[-1]-1] += 1
if second_count % 2 == 1:
    values[flip_points[-1]] += 1

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


Measured memory_bytes: 14472
def main():
    N, K = map(int, input().split())

    c = [[0] * 4000 for _ in range(4000)]
    c[0][0] = 1
    for i in range(1, 4000):
        ci = c[i]
        ci1 = c[i - 1]
        ci[0] = 1
        for j in range(1, i + 1):
            ci[j] = (ci1[j - 1] + ci1[j]) % 1000000007

    for i in range(1, K + 1):
        print((c[K-1][i-1] * c[N-K+1][i]) % 1000000007)


main()

Measured memory_bytes: 382452
def init_load(ipt):
    return "".join(sorted([x for x in ipt]))
 
# load
n = int(input())
s = [init_load(input()) for _ in range(n)]
 
 
dictS = {}
for new_st in s:
    if new_st in dictS:
        dictS[new_st] += 1
    else:
        dictS[new_st] = 1
 
ans = sum([int(x * (x - 1) / 2) for x in dictS.values()])
print(ans)

Measured memory_bytes: 19500
#include <algorithm>
#include <iostream>
#include <cstdio>

using namespace std ;

int n , t ;
int res ;

int main ()
{
	int i , a , b ;
	scanf("%d%d",&n,&t);
	res=1926;
	for ( i=1 ; i<=n ; i++ )
	{
		scanf("%d%d",&a,&b);
		if ( b<=t ) res=min(res,a);
	}
	if ( res==1926 ) puts("TLE");
	else printf("%d\n",res);
	return 0 ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int n;
ll m;
vector<ll> a;

bool judge( int x ){
	ll sum = 0;
	for( auto k : a ){
		sum += (ll)(a.end() - lower_bound( a.begin(), a.end(), x-k ));
	}
	return sum >= m;
}

int main(){
	cin >> n >> m;
	a.resize(n);
	for( auto &k : a ) cin >> k;
	sort( a.begin(), a.end() );
	int ok = -1;
	int ng = 2*a.back()+1;
	while( abs(ok-ng) > 1 ){
		int mid = (ok+ng)/2;
		( judge(mid) ? ok : ng ) = mid;
	}
	vector<ll> sum(n+1, 0);
	for( int i = 0; i < n; ++i ) sum[i+1] = sum[i] + a[i];
	ll cnt = 0;
	ll ans = 0;
	for( auto x : a ){
		int t = lower_bound( a.begin(), a.end(), ok-x ) - a.begin();
		ans += sum[n]-sum[t]+((n-t)*x);
		cnt += n-t;
	}
	ans -= ok*(cnt-m);
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <set>
using namespace std;

static int get_group(int32_t val)
{
	switch (val) {
	case 1:
	case 3:
	case 5:
	case 7:
	case 8:
	case 10:
	case 12:
		return 0;
	case 4:
	case 6:
	case 9:
	case 11:
		return 1;
	case 2:
		return 2;
	default:
		return -1;
	}
}

int main()
{
	int32_t x, y;
	cin >> x >> y;

	cout << (get_group(x) == get_group(y) ? "Yes" : "No") << endl;

	return 0;
}

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

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

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

  int arr[N];
  for(int i = 0; i < N; i++) {
    cin >> arr[i];
  }
  
  sort(arr, arr + SIZE_OF_ARRAY(arr), greater<>());
  int alice_point = 0;
  int bob_point = 0;
  for(int i = 0; i < N; i++) {
    if(i % 2 == 0) {
      alice_point += arr[i];
    } else {
      bob_point += arr[i];
    }
  }
  cout << alice_point - bob_point << endl;
  
  return 0;
}


Measured memory_bytes: 3168
#include <stdio.h>

int main(void)
{
	int i,j,k,a,b,c,H[300],W[300];
	i = 0;

	scanf("%d %d",&a,&b);
	
	while((a!=0) || (b!=0))
	{
		H[i] = a;
		W[i] = b;
		i++;
		scanf("%d %d",&a,&b);
	}

	for(c=0;c<i;c++)
	{
		for(j=0;j<H[c];j++)
		{
			for(k=0;k<W[c];k++)
			{
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 572
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    private static Scanner sc;

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

    private void solve() {
        int n = sc.nextInt();
        Set<String> s = new HashSet<String>();
        for (int i = 0; i < n; i++) {
            s.add(sc.next());
        }

        if (s.size() == 3) {
            System.out.println("Three");
        } else {
            System.out.println("Four");
        }

    }
}

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

int main() {
  int N,T;
  cin>>N>>T;
  vector<pair<int,int>> p(N);
  for(int i=0;i<N;i++){
    int a,b;
    cin>>a>>b;
    p.at(i)=make_pair(a,b);
  }
  sort(p.begin(),p.end());
  vector<vector<int>> dp(N,vector<int>(T));
  for(int i=1;i<N;i++){
    for(int j=0;j<T;j++){
      if(j>=p.at(i-1).first){
        dp.at(i).at(j)=max(dp.at(i-1).at(j),p.at(i-1).second+dp.at(i-1).at(j-p.at(i-1).first));
      }
      else{
        dp.at(i).at(j)=dp.at(i-1).at(j);
      }
    }
  }
  int Z=0;
  for(int i=0;i<N;i++){
    Z=max(Z,p.at(i).second+dp.at(i).at(T-1));
  }
  cout<<Z<<endl;
                           
              
}

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    //(1,1)から(100,100)までで矛盾が生じないものが1つある
    int x[N],y[N],h[N];
    int taller_zero = -1;
    rep(i, N){
        cin >> x[i] >> y[i] >> h[i];
        if(h[i] > 0) taller_zero = i;
    }
    assert(taller_zero != -1);
    int must_height[N];
    for(int i = 0; i <= 100; i++){
        for(int j = 0; j <= 100; j++){
            bool ok = true;
            int ch = h[taller_zero] + abs(i-x[taller_zero]) + abs(j-y[taller_zero]);
            rep(k, N){
                must_height[k] = max(0, ch - abs(i-x[k]) - abs(j-y[k]));
                if(h[k] != must_height[k]) ok = false;
            }
            if(ok){
                cout << i << " " << j << " " << ch << endl;
                return 0;
            }  
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 100000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;
string A;
char* color;
int Pnum=0;
int Qnum=0;

signed main(void) {

    string str;
    cin >> str;
    char* cstr = new char[str.size() + 1]; // メモリ確保

    char_traits<char>::copy(cstr, str.c_str(), str.size() + 1);

    rep(i, str.size()){
        int p = i%2;
        int q = (i+1)%2;
        if(cstr[i]=='1'){
            if(p==1){
                Qnum++;
            }else{
                Pnum++;
            }
        }
        if(cstr[i]=='0'){
            if(p==0){
                Qnum++;
            }else{
                Pnum++;
            }
        }


    }
    cout << min(Pnum,Qnum) << endl;



    return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define R cin>>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    int a, b, x;
    cin>>a>>b>>x;
    int res=x-a;
    if (0<=res && res<=b) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std;

int a[4], n, m, i, j;

int main()
{
	while(cin >> a[0])
	{
		cin >> a[1] >> a[2] >> a[3];
		n = min(a[0], a[1]) + min(a[2], a[3]);
		cout << n << endl;
	}
	return 0;
}

Measured memory_bytes: 256
from math import factorial
MOD = int(1e9+7)


def comb(n, r):
    return (factorial(n) * pow(factorial(n - r), MOD - 2, MOD) * pow(factorial(r), MOD - 2, MOD)) % MOD


N, K = map(int, input().split())
for i in range(1, K+1):
    if i > N-K+1:
        print(0)
    else:
        print(comb(N-K+1, i)*comb(K-1, i-1) % MOD)


Measured memory_bytes: 3316
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;

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

    sort(d, d+n);

    int ans = d[n/2] - d[n/2-1];
    cout << ans;
    
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <math.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
 
int main(){
  int n;
  cin >> n;
  int p[n], check_id=-1;
  cin >> p[0];
  if(p[0]!=1) {check_id = p[0]-1;}
  for(int i=1;i<n;i++){
    cin >> p[i];
    if(p[i]!=i+1){
      if(check_id==-1){
        check_id = p[i]-1;
      }
      else if(p[p[i]-1]!=i+1){
        printf("NO\n");
        return 0;
      }
    }
  }
  printf("YES\n");
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

const int INF = 1001001001;

int dist(pii a, pii b)
{
	int dy = a.first - b.first;
	int dx = a.second - b.second;
	if(0 <= dy*dx){
		dy = abs(dy);
		dx = abs(dx);
		return dy + max(0, dx - (dy+1-min(a.first,b.first)%2)/2);
	}
	else{
		dy = abs(dy);
		dx = abs(dx);
		return dy + max(0, dx - (dy + min(a.first, b.first)%2)/2);
	}
}

int main()
{
	int m, n;
	while(scanf("%d%d", &m, &n), m){
		int s;
		scanf("%d", &s);
		pii conv[10];
		rep(i, s)
			scanf("%d%d", &conv[i].second, &conv[i].first);
		
		int d[101][101];
		rep(i, n) rep(j, m){
			d[i+1][j+1] = INF;
			rep(k, s)
				d[i+1][j+1] = min(d[i+1][j+1], dist(pii(i+1, j+1), conv[k]));
		}
		
		int t, ans = 0;
		scanf("%d", &t);
		rep(i, t){
			int x, y;
			scanf("%d%d", &x, &y);
			
			int cnt = 0;
			rep(j, n) rep(k, m)
				cnt += dist(pii(j+1, k+1), pii(y, x)) < d[j+1][k+1];
			ans = max(ans, cnt);
		}
		printf("%d\n", ans);
	}
	return 0;
}

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

int main(){
	cin >> n;
	vector<pair<int, int>> red(n);
	vector<pair<int, int>> blue(n);
	for (int i = 0;i < n;i++) {
		int k1,k2; cin >> k1 >> k2;
		red.at(i) = make_pair(k1,k2);
	}
	for (int i = 0;i < n;i++) {
		int k1,k2; cin >> k1 >> k2;
		blue.at(i) = make_pair(k1,k2);
	}
	sort(red.begin(), red.end());
	vector<bool> red_used(n,false);
	sort(blue.begin(),blue.end());
	int red_c = 0;
	for (int i = 0;i< n;i++){
		int b1, b2;
		b1 = blue.at(i).first; b2 = blue.at(i).second;
		for (int j = red_c;j < n; j++){
			if (b1 >= red.at(red_c).first){
				red_c++;
			} else {
				break;
			}
		}
		int min_diff = 100000;
		int min_i = -1;
		for (int j = 0;j < red_c;j++){
			if (red_used.at(j) == true) continue;
            if (b2 - red.at(j).second < 0) continue;
			min_diff = min(min_diff, b2 - red.at(j).second);
			if (min_diff == b2 - red.at(j).second){
				min_i = j;
			}
		}
		if (min_i == -1) continue;
		else {
			red_used.at(min_i) = true;
		}
	}
	int ans_c = 0;
	for (int i = 0;i < n;i++){
		if (red_used.at(i) == true) ans_c++;
	}
	cout << ans_c << endl;
}

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

int main(){
	char chs[]=" ',-.?ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	string codes[32]={
		"101","000000","000011","10010001","010001","000001","100101","10011010"
		,"0101","0001","110","01001","10011011","010000","0111","10011000"
		,"0110","00100","10011001","10011110","00101","111","10011111","1000"
		,"00110","00111","10011100","10011101","000010","10010010","10010011","10010000"};

	string s;
	while(getline(cin,s)){
		string t;
		for(int i=0;i<s.size();i++){
			t += codes[find(chs,chs+32,s[i])-chs];
		}
		if(t.size()%5)t.append(5-t.size()%5,'0');
		for(int i=0;i<t.size();i+=5){
			int n=0;
			for(int j=0;j<5;j++)n = n<<1|t[i+j]-'0';
			if(n<26)cout<<(char)('A'+n);
			else cout<<" .,-'?"[n-26];
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main(){
    

    ll k;
    cin >> k;
    vector <ll> v;
    for (ll i=0;i<k;i++){
        ll p;
        cin >> p;
        v.push_back(p);
    }
    reverse(v.begin(), v.end());
    ll vmin, vmax;
    vmin = vmax = 2;
    int flag = 0;
    for (ll i=0;i<k;i++){
        ll tmp = v[i];
        if(vmin % tmp == 0){
            ;
        }else{
            vmin = (vmin/tmp + 1)*tmp;
        }
        vmax = (vmax/tmp)*tmp + (tmp-1);
        if(vmin > vmax){
            cout << -1 << endl;
            flag = 1;
            break;
        }
//        cout << i << " " << vmin << " " << vmax << endl;
    }
    if(flag == 0){
        cout << vmin << " " << vmax << endl;
    }
}

Measured memory_bytes: 1400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static readonly int border = 1000000;

        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            while (true)
            {
                int n = int.Parse(Console.ReadLine());

                if (n == 0) break;

                List<int> idList = new List<int>();
                long[] sales = new long[4001];

                for (int i = 0; i < n; i++)
                {
                    string[] input = Console.ReadLine().Split(' ');

                    int e = int.Parse(input[0]);
                    int p = int.Parse(input[1]);
                    int q = int.Parse(input[2]);

                    if (sales[e] == 0) idList.Add(e);

                    sales[e] += p * q;
                }

                bool isNA = true;

                foreach (var id in idList)
                {
                    if (sales[id] >= border)
                    {
                        sb.AppendLine(id.ToString());
                        isNA = false;
                    }
                }

                if (isNA) sb.AppendLine("NA");
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9468
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

ll f(ll n)
{
  switch(n % 4){
    case 0: return n;
    case 1: return 1;
    case 2: return n + 1;
    case 3: return 0;
  }
}

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


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <sstream>
#include <vector>
#include <string>
#include <iomanip>
#include <bitset>
#define INF	100000000
#define pb	push_back
#define fi first
#define sec second
#define SS stringstream
using namespace std;
typedef pair<int, int> P;
typedef long long int	ll;

int n;

int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		vector<int> vec;
		ll m = 0, l = 0;
		for(int j = 0; j < 8; j++){
			SS ss;
			char temp;
			int kari;
			cin >> temp;
			ss << temp;
			ss >> kari;
			vec.pb(kari);
		}
		sort(vec.begin(), vec.end());
		for(int j = 0; j < 8; j++){
			l += vec[j]*pow(10,j);
		}
		sort(vec.begin(), vec.end(), greater<int>());
		for(int j = 0; j < 8; j++){
			m += vec[j]*pow(10,j);
		}
		cout << l-m << endl;
	}
}

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

int main() {
  int n,a,b ;
  cin>>n>>a>>b;
  int A,B;
  A=n*a;
  B=b;
  if(A>=B){
    cout<<B<<endl;
  }
  else{
    cout<<A<<endl;
  }
 
  
 
}


Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

using namespace std;

void print(const vector<int> &data){
	for (int i = 0; i < data.size(); ++i){
		cout << data[i];
		if (i == data.size() - 1) cout << endl;
		else cout << " ";
	}
}

void bubS(vector<int> &data){
	int count = 0;
	for (int i = 0; i < data.size(); ++i){
		for (int j = data.size() - 1; j > i; --j){
			if (data[j] < data[j-1]){
				swap(data[j], data[j - 1]);
				count++;
			}
		}
	}
	print(data);
	cout << count << endl;
}

void selS(vector<int> &data){
	int count = 0;
	for (int i = 0; i < data.size(); ++i) {
		int pos = i;
		for (int j = i; j < data.size(); ++j){
			if (data[j] < data[pos])
				pos = j;
		}
		if (pos != i){
			swap(data[i], data[pos]);
			count++;
		}
	}
	print(data);
	cout << count << endl;
}


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

	selS(data);
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
#include <math.h>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int x,y,z;
	cin >> x;
    string ans;
    if(x<1000)ans="ABC";
    else ans = "ABD";
      cout << ans << endl;
}

Measured memory_bytes: 256
from collections import deque, defaultdict
from itertools import chain, combinations
import json


def main():
    # N = int(input())
    N, M = [int(a) for a in input().split()]
    # A = [int(a) for a in input().split()]
    pS = [
        [a for a in input().split()]
        for _ in range(M)
    ]

    seitou = 0
    pen = 0
    mem = [0] * (N + 1)

    for p, S in pS:
        p = int(p)
        if mem[p] < 0:  # 正答済み
            continue
        if S == 'AC':
            seitou += 1
            pen += mem[p]
            mem[p] = -1
        else:
            mem[p] = mem[p] + 1
    print(seitou, pen)


if __name__ == "__main__":
    main()



Measured memory_bytes: 27260
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author amotoma3
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long x = in.nextLong();
            long y = in.nextLong();

            int cnt = 0;
            while (x <= y) {
                cnt++;
                x *= 2;
            }

            out.println(cnt);
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(nextString());
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 23252
#include <iostream>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  if (a > b) {
    cout << "a > b" << endl;
  } else if (a < b) {
    cout << "a < b" << endl;
  } else {
    cout << "a == b" << endl;
  }
}



Measured memory_bytes: 3100
//abc177_d.cpp
    //Sat Aug 29 20:53:41 2020
     
    #include <iostream>
    #include <string>
    #include <queue>
    #include <map>
    #include <unordered_map>
    #include <vector>
    #include <algorithm>
    #include <math.h>
    #include <set>
    #define INTINF 2147483647
    #define LLINF 9223372036854775807
    #define MOD 1000000007
    #define rep(i,n) for (int i=0;i<(n);++i)
     
    using namespace std;
    using ll=long long;
    typedef pair<int,int> P;
     
    //Union-Find木
    int par[300000]; //親
    int treerank[300000]; //木の深さ
     
    //n要素で初期化
    void init(int n){
    	for (int i=0;i<n;i++){
    		par[i] = i;
    		treerank[i] = 0;
    	}
    }
     
    //木の根（親）を見つける
    int find (int x){
    	if (par[x] == x){
    		return x;
    	} else {
    		return par[x] = find(par[x]);
    	}
    }
     
    //xとyの属する集合の併合
    void unite(int x, int y){
    	x = find(x);
    	y = find(y);
    	if (x == y) {
    		return;
    	} 
     
    	if (treerank[x] < treerank[y]){
    		par[x] = y;
    	} else {
    		par[y] = x;
    		if (treerank[x] == treerank[y]){
    			treerank[x]++;
    		}
    	}
    }
     
    //xとyが同じグループに属するか判定
    bool same(int x, int y){
    	return find(x) == find(y);
    }
     
    int main(){
    	int n,m;
    	cin >> n >> m;
     
    	init(n);
     
    	rep(i,m){
    		int a,b;
    		cin >> a >> b;
    		a--;b--;
    		unite(a,b);
    	}
     
    	vector<int> member(n);
    	rep(i,n){
    		member[find(i)]++;
    	}
    	int ans = 0;
    	rep(i,n){
    		ans = max(ans,member[i]);
    	}
    	cout << ans << endl;
    //	printf("%.4f\n",ans);
    }

Measured memory_bytes: 5504
import java.util.Scanner;

public class Main {

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

		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int ans = 0;

		if ( A == B ) {
			ans = C;
		} else if ( A == C ) {
			ans = B;
		} else {
			ans = A;
		}

		System.out.println( ans );
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<fstream>
#include<math.h>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<sstream>
#include<set>

using namespace std;

#define forn(i,n) for(int i=0;i<(int)(n); i++)
#define forsn(i,s,n) for(int i=(s);i<(int)(n); i++)
#define esta(x,v) (find((v).begin(),(v).end(),(x)) !=  (v).end())
#define index(x,v) (find((v).begin(),(v).end(),(x)) - (v).begin())
#define debug(x) cout << #x << " = "  << x << endl
#define pb push_back
#define mp make_pair

typedef long long tint;
typedef unsigned long long utint;
typedef long double ldouble;

typedef vector<int> vint;

int toNumber (string s)
{
	int Number;
	if ( ! (istringstream(s) >> Number) ) Number = 0; // el string vacio lo manda al cero
	return Number;
}

string toString (int number)
{
    ostringstream ostr;
    ostr << number;
    return  ostr.str();
}

bool isP(int a){
	if(a==2)return true;
	if(a%2==0)return false;
	for(int i=3; i*i<=a; i++){
		if(a%i==0)return false;
	}
	return true;
}

int main(){
	int n, a, b;
	while(cin>>n>>a>>b){
		tint ar[n];
		vector<tint> dist;
		forn(i, n){
			cin>>ar[i];
			if(i>0)dist.pb(ar[i]-ar[i-1]);
		}
		sort(dist.begin(), dist.end());
		tint cant=b/a;
		tint fat=0;
		forn(i, n){
			if(dist[i]<=cant){
				fat+=dist[i]*a;
			}else{
				fat+=b;
			}
		}
		cout<<fat<<endl;
	}
}


Measured memory_bytes: 1912
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.HCPC200420
{
    class B
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            bool[] vals = new bool[30];
            for(int i = 0; i < 28; i++)
            {
                int val = ReadInt();
                vals[val - 1] = true;
            }
            for(int i = 0; i < 30; i++)
            {
                if (vals[i])
                {
                    continue;
                }
                WriteLine(i + 1);
            }
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



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

int main(){
  int N;
  cin>>N;
  
  vector<int> A(N);
  for(int i=0; i<N; i++) cin >> A.at(i);
  
  int min = A.at(0), max = A.at(0);
  
  for(int x : A){
    min > x ? min = x : 0;
    max < x ? max = x : 0;
  }
  cout << max-min << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600

// Dinic Maximum Flow algorithm O(E V^2)
template<typename T>
class MaximumFlow{
private:
  struct edge{int to; T cap; int rev;};
  vector<vector<edge> > Graph;
  vector<int> level, iter; //sからの距離,どこまで調べたか
  void bfs(int s){
    fill(all(level), -1);
    queue<int> q;
    level[s]=0;
    q.push(s);
    while(!q.empty()){
      int v=q.front(); q.pop();
      for(auto e : Graph[v]){
        if(e.cap>0 && level[e.to]<0){
          level[e.to] = level[v]+1;
          q.push(e.to);
        }
      }
    }
  }
  T dfs(int v, int t, T f){
    if(v==t) return f;
    for(int &i=iter[v]; i<(int)Graph[v].size(); i++){
      auto &e = Graph[v][i];
      if(e.cap>0 && level[v]<level[e.to]){
        T d = dfs(e.to, t, min(f, e.cap));
        if(d>0){
          e.cap -= d;
          Graph[e.to][e.rev].cap += d;
          return d;
        }
      }
    }
    return 0;
  }
public:
  MaximumFlow(int n){
    Graph = vector<vector<edge> >(n, vector<edge>());
    level = vector<int>(n);
    iter = vector<int>(n);
  }
  T max_flow(int s, int t){
    T flow=0;
    while(true){
      bfs(s);
      if(level[t] < 0) break;
      fill(all(iter), 0);
      T f;
      while( (f=dfs(s,t,INF)) > 0){
        flow += f;
      }
    }
    return flow;
  }
  void add_edge(int from, int to, T cap){
    int tos = Graph[to].size(), froms = Graph[from].size();
    Graph[from].pb(((edge){to, cap, tos}));
    Graph[to].pb(((edge){from, 0, froms}));
  }
}; // END class MaximumFlow


int main(){
  int h,w;
  cin>>h>>w;
  vector<string> vec(h);
  rep(i,h) cin>>vec[i];

  int cnt=2;
  vector<vector<int>> nums(h,vector<int>(w));

  int sx,sy,tx,ty;
  rep(i,h) rep(j,w){
    if(vec[i][j]=='o') nums[i][j] = cnt++;
    if(vec[i][j]=='S') sx=i, sy=j, nums[i][j]=0;
    if(vec[i][j]=='T') tx=i, ty=j, nums[i][j]=1;
  }

  if(sx==tx || sy==ty){
    cout << -1 << endl;
    return 0;
  }

  MaximumFlow<long> mf(cnt*2+10);

  rep(i,cnt) mf.add_edge(i*2, i*2+1, 1);

  rep(i,h) rep(j,w) if(vec[i][j]!='.'){
    int from = nums[i][j]*2+1;
    rep(k,h) if(i!=k && vec[k][j]!='.') mf.add_edge(from, nums[k][j]*2, INF);
    rep(k,w) if(j!=k && vec[i][k]!='.') mf.add_edge(from, nums[i][k]*2, INF);
  }

  long f = mf.max_flow(1, 2);

  if(f>=INF) cout << -1 << endl;
  else cout << f << endl;

  return 0;
}


Measured memory_bytes: 124160
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

ll kai[200001];

ll extgcd(ll a,ll b,ll &x,ll &y)
{
	ll d=a;
	if(b!=0)
	{
		d=extgcd(b,a%b,y,x);
		y-=(a/b)*x;
	}else{
		x=1;
		y=0;
	}
	return d;
}

ll inver(ll a)
{
	ll x,y;
	extgcd(a,MOD,x,y);
	return (MOD+x%MOD)%MOD;
}

ll combi(ll a,ll b)
{
	ll ret=kai[a];
	ret*=inver(kai[b]);
	ret%=MOD;
	ret*=inver(kai[a-b]);
	ret%=MOD;
	if(ret<0)
		ret+=MOD;
	return ret;
}

int main()
{
	ll h,w,a,b;
	ll ans=0;
	
	cin>>h>>w>>a>>b;
	kai[0]=1;
	for(int i=1;i<200001;i++)
	{
		kai[i]=kai[i-1]*i;
		kai[i]%=MOD;
		if(kai[i]<0)
			kai[i]+=MOD;
	}
	
	for(ll i=0;i<h-a;i++)
	{
		ll temp=combi(b-1+i,i)*combi(w-b-1+h-i-1,w-b-1);
		temp%=MOD;
		if(temp<0)
			temp+=MOD;
		ans+=temp;
		ans%=MOD;
		if(ans<0)
			ans+=MOD;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>

int main(void){
	long long int x,y;
	int count = 1;

	scanf("%lld %lld",&x,&y);

	x *= 2;

	while( x <= y){
		count++;
		x *=2;
	}
	printf("%d\n",count);
	return 0;
}


Measured memory_bytes: 128
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-5;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;

class UnionFind {
	vector<int>parent;
	vector<int>rank;
public:
	UnionFind(int num) {
		num++;
		parent.resize(num);
		rank.resize(num);
		for (int i = 0; i < num; i++) {
			parent[i] = i;
			rank[i] = 0;
		}
	}
	int Find(int node) {
		if (parent[node] == node)return node;
		else return parent[node] = Find(parent[node]);
	}
	void Unite(int u, int v) {
		u = Find(u);
		v = Find(v);
		if (u == v)return;
		if (rank[u] < rank[v])parent[u] = v;
		else {
			parent[v] = u;
			if (rank[u] == rank[v])rank[u]++;
		}
	}
	bool Check_Same(int u, int v) {
		return Find(u) == Find(v);
	}
};

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

	cin >> N >> M;
	UnionFind uf(N);
	int ans = N - 1;
	for (int i = 0; i < M; i++) {
		cin >> L >> R;
		L--, R--;
		if (uf.Check_Same(L, R))continue;
		ans--;
		uf.Unite(L, R);
	}
	cout << ans << endl;
}

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

int main() {
    int n;
    cin >> n;
    map<int, int> a;
    for (int i = 0; i < n; i++) {
        int ai;
        cin >> ai;
        a[ai]++;
    }

    int ans = 0;
    for (auto& e : a) ans += (e.second >= e.first ? e.second - e.first : e.second);
    
    cout << ans << endl;
}


Measured memory_bytes: 4736
// In the name of Allah the Lord of the Worlds.

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int Set(int n , int pos)
{
    return n|(1<<pos);
}
bool Check(int n , int pos)
{
    return n&(1<<pos);
}
ll dp[1005][(1<<12)+5];
int n , m;
vector<pair<ll , ll > > v;

ll f(int i , int mask)
{
    if(i==m){
        if(mask==(1<<n)-1)return 0;
        return 1e15;
    }
    if(dp[i][mask]!=-1)return dp[i][mask];
    ll value = f(i+1 , mask);
    value = min(value , f(i+1 , mask|v[i].second)+v[i].first);
    return dp[i][mask] = value;
}

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

    cin >> n >> m;
    for(int i=0;i<m;i++){
        ll cost , lim;
        cin >> cost >> lim;
        int mask = 0;
        for(int j=0;j<lim;j++){
            ll in;
            cin >> in;
            mask = Set(mask , in-1);
        }
        v.push_back({cost , mask});
    }
    memset(dp , -1 , sizeof(dp));
    ll ans = f(0 , 0);
    if(ans>=1e15)ans = -1;
    cout << ans << endl;

    return 0;
}


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

#define int long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (long long)1000000007
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 0x3f3f3f3f
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back
#define mxn 500005

int32_t main(){
sp;
    int bit[61] = {0};
    int n;
    cin>>n;
    for(int i = 1; i <= n; ++i){
        int x;
        cin>>x;
        for(int j = 0; j < 61; ++j){
            if(x&(1LL<<j))
                ++bit[j];
        }
    }
    int ans = 0;
    for(int i = 0; i < 61; ++i){
        int in = bit[i];
        int out = n - bit[i];
        int val = (1LL<<i);
        val %= mod;
        ans += (1LL *(1LL * in * out) % mod * val) % mod;
        ans %= mod;
    }
    cout<<ans;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const int INTMAX = 2147483647;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    int n;cin >> n;
    cout << (n/500)*1000 + ((n%500)/5) * 5 << endl;
}

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

int op(int a,int b){
  return max(a,b);
}

int e(){
  return -1;
}

int v;

bool f(int k){
  return k < v;
}

int main(){
  int n, q;
  cin >> n >> q;
  vector<int> A(n);
  for(int i=0;i<n;i++){
    cin >> A[i];
  }
  segtree<int,op,e> seg(A);
  for(int i=0;i<q;i++){
    int t;
    cin >> t;
    if(t == 1){
      int x;
      cin >> x >> v;
      x--;
      seg.set(x,v);
    }
    else if(t == 2){
      int l,r;
      cin >> l >> r;
      l--;
      cout << seg.prod(l,r) << endl;
    }
    else if(t == 3){
      int x;
      cin >> x >> v;
      x--;
      cout << seg.max_right<f>(x)+1 << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 6200