akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);	
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
int n,a[25],b[25],c[25];
void solve(){
	int ans = 0;
	rep(i,1,n){
		ans += b[a[i]];
	}
	rep(i,2,n){
		if(a[i] - a[i-1] == 1) ans += c[a[i-1]];
	}
	cout << ans << endl;
}
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	rep(i,1,n) cin >> a[i];
	rep(i,1,n) cin >> b[i];
	rep(i,1,n-1) cin >> c[i];
	solve();	
	return 0;
}
//do smt instead of nothing! never give up!


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

const int MAX_N = 500000;

ll fact[MAX_N+100];
ll frev[MAX_N+100];

ll rev(ll a, ll p){
    if(p == 0) return 1;
    ll tmp = rev(a, p/2);
    tmp = tmp * tmp % MOD;
    if(p % 2 == 1) tmp = tmp * a % MOD;
    return tmp;
}


void calc_fact(){
    fact[0] = frev[0] = 1;
    for(int i = 1; i <= MAX_N; i++){
        fact[i] = (fact[i-1] * i) % MOD;
        frev[i] = rev(fact[i], MOD-2);
    }
}


ll comb(int n, int k){
    if(n < 0 || k < 0 || n < k) return 0;
    if(n == 0 || k == 0) return 1;
    return fact[n] * frev[k] % MOD * frev[n-k] % MOD;
}

int main(){
    ll N, K;
    cin >> N >> K;

    //in main function
    fact[0] = frev[0] = 1;
    for(int i = 1; i <= MAX_N; i++){
        fact[i] = (fact[i-1] * i) % MOD;
        frev[i] = rev(fact[i], MOD-2);
    }

    ll ans = 0;
    if(K >= N-1){
        ans = comb(2*N-1, N);
    }
    else{
        REPi(k,0,K+1){
            ans += comb(N, k) * comb(N-1, k);
            ans %= MOD;
        }
    }

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


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int main()
{
    int p[5];
    int k;
    REP(i,5) cin>>p[i];
    cin>>k;
    REP(i,5) REP(j,5) {
        if (abs(p[i] - p[j]) > k) {
            cout<<":("<<endl;
            return 0;
        }
    }
    cout<<"Yay!"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long  l[1000000];
long long r[1000000];
long long cnt = 0;
long long  merge(int n,long long t[],int left,int mid,int right){
	long long n1 = mid-left;
	long long n2 = right -mid;
	for(long long i = 0;i<n1;i++) l[i] = t[left+i];
	for(long long i = 0;i<n2;i++) r[i] = t[mid+i];
	l[n1] = r[n2] = 9999999999999999;
	long long i = 0,j = 0;
	for(long long k = left;k<right;k++){
		if(l[i] <=r[j]){
			t[k] = l[i];
			i++;
		}else{
			t[k] = r[j];
			j++;
			cnt += n1-i;
		}
	}
}
long long  mergesort(long long t[],int n,int left,int right){
	if(left +1<right){
	long long mid = (left + right)/2;
	long long v1 = mergesort(t,n,left,mid);
	 long long v2 = mergesort(t,n,mid,right);
	long long v3 = merge(n,t,left,mid,right);
	return v1 + v2 + v3;
	}else return 0;
}
int main(){
	long n;
	cin>>n;
	long long  t[n];
	for(int  i = 0;i<n;i++){
		cin>>t[i];
	}
	mergesort(t,n,0,n);
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 6188
import math
BINGO = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
NUMS = [int(input()) for _ in range(N)]

for n in NUMS:
    for i in range(3):
        for j in range(3):
            if BINGO[i][j] == n:
                BINGO[i][j] = 0
    
res = 1000000
for i in range(3):
    res = min(res, sum(BINGO[i]))

for j in range(3):
    col = 0
    for i in range(3):
        col += BINGO[i][j] 
    res = min(res, col)

res = min(res, BINGO[0][0]+ BINGO[1][1]+ BINGO[2][2])
res = min(res, BINGO[0][2]+BINGO[1][1]+BINGO[2][0])

print("Yes" if res == 0 else "No")
    

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include <bitset>
using namespace std;
const int mod=1e9+7;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,x,n) for (int i= x;i<n;i++)
#define all(v) v.begin(), v.end()
#define nepe(v) next_permutation(all(v))
#define F first 
#define S second
#define PB push_back 
#define MP make_pair
using ll = long long;
using vi = vector<int>; 
using vvi = vector<vi>;
using vl=vector<long long>;
using vp =vector<pair<int,int>>;

typedef pair<int,int> P;
string s;
int k;
ll INF = 10000000000000000;


bool judge(int N,vi D){
    int n = log10(N)+1;
    rep(i,n){
        if(D[N%10]==1) return false;
        N /=10;
    }
    return true;
}


int main(){
    int N,K;
    cin >>N>>K;
    vi D(10,0);
    rep(i,K){
        int k;
        cin >>k;
        D[k] =1;
    }
    while(true){
        if(judge(N,D)) {
            cout<<N<<endl;
            return 0;
        }
        N++;
    }
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void anss(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  ll l,r;
  bool judge = true;
  ll a,b,c;cin>>a>>b>>c;
  ans2(b-a==c-b);

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef vector< vector<int> > vvi;
typedef vector< vector<bool> > vvb;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef long long ll;

void dfs(const vvi &graphf, vb &found, int s, vi &connection){
    found[s]=true;
    connection.push_back(s);
    for(auto next:graphf[s]){
        if(found[next]) continue;
        dfs(graphf,found,next,connection);        
    }
    return;
}

int main(){
    int n,m,k;
    cin >> n >> m >> k;
    //隣接リスト
    vvi graphf(n+1);
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        graphf[a].push_back(b);
        graphf[b].push_back(a);
    }
    vvi graphb(n+1);
    for(int i=0;i<k;i++){
        int a,b;
        cin >> a >> b;
        graphb[a].push_back(b);
        graphb[b].push_back(a);
    }
    //連結成分
    vvi connection(n+1,vi());
    vi grouped(n+1,0);
    //連結成分を求める
    for(int i=1;i<=n;i++){
        if(grouped[i]!=0) continue;
        vb found(n+1,false);
        dfs(graphf,found,i,connection[i]);
        for(auto x:connection[i]){
            grouped[x]=i;
        }
    }

    /*
    for(int i=1;i<=n;i++){
        cout << i << " : "; 
        for(int x:connection[i]){
            cout << x << " ";
        }
        puts("");
    }
    */

    int ans;
    for(int i=1;i<=n;i++){
        ans=connection[grouped[i]].size()-1;
        for(int x:graphf[i]){
            if(grouped[i]==grouped[x]) ans--;
        }
        for(int x:graphb[i]){
            if(grouped[i]==grouped[x]) ans--;
        }
        cout << ans << " ";
    }
    puts("");
    return 0;
}

Measured memory_bytes: 18952
import sys
readline = sys.stdin.readline
n = int(readline())
a = list(map(int, readline().split()))
a.sort()

zero_count = 0
curr = 0
i = 0

while n - zero_count > 1:
    # print(i,curr,zero_count,a)
    if i != curr and a[i] != 0:
        if a[i] % a[curr] == 0:
            a[i] = 0
        elif a[curr] <= a[i]:
            a[i] = a[i] % a[curr]
            if a[i] < a[curr]:
                curr = i
        if a[i] == 0:
            zero_count += 1
    if i == n - 1:
      i = 0
    else:
      i += 1

print(max(a))

Measured memory_bytes: 15020
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef unsigned long long int ull;
int main() {
	//cout<<"GfG!";
	ull a, b, n, res, x, m = 0;
	cin>>a>>b>>n;
	if (n < b)
	{
	    cout<<(floor((a*n)/b));
	}
	else
	{
	    cout<<(floor((a*(b-1))/b));
	}
	return 0;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
int main() {
    string s;
    cin>>s;
    if(s[0]=='A'){
        int cnt=0;
        for(int i=2; i<s.size()-1; i++){
            if(s[i]=='C'){
                cnt++;
            }
        }
        if(s[1]-'a'<0){
            cout<<"WA";
            return 0;
        }
        for(int i=2; i<s.size(); i++){
            if(s[i]!='C'&&s[i]-'a'<0){
                cout<<"WA";
                return 0;
            }
        }
        if(cnt==1){
            cout<<"AC";
            return 0;
        }
    }
    cout<<"WA";
}


Measured memory_bytes: 256
class Main{
    public static void main(String[] a){
    	
    	int[] x = new int[9];
    	
    	for(int i = 0;i < 9;i++) {
    		x[i] = i + 1;
    	}
    	
    	for(int X1 : x) {
    		for(int X2 : x) {
    			System.out.println(X1+"x"+X2+"="+X1*X2);
    		}
    	}
    }
}


Measured memory_bytes: 23972
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {
          
          var inputArray = retreiveLongArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = inputArray[0];
			var Aarray  = retreiveLongArray();
			//nCrが最大となるのは、nが最大でかつrが(n+1)/2に一番近い時
			var max = Aarray.Max();

			long r=0;
			
			var compare2 = (max + 1) ;
			var dif =long.MaxValue;
			for (int i = 0; i < N; i++) {

				if (Aarray[i]==max) {
					continue;
				}

				if (Math.Abs(Aarray[i]*2-compare2) <= dif) {
					r = Aarray[i];
					dif = Math.Abs(Aarray[i]*2 - compare2);
				}
			}


			//答えの出力
			var ans = max + " " + r;
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}

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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, M;
  cin >> N >> M;
  vector<int> K(M);
  vector<vector<int>> S(M);
  vector<int> p(M);
  for (int i = 0; i < M; i++)
  {
    cin >> K[i];
    for (int j = 0; j < K[i]; j++)
    {
      int s;
      cin >> s;
      s--;
      S[i].push_back(s);
    }
  }
  for (int i = 0; i < M; i++)
    cin >> p[i];

  int ans = 0;

  for (int bit = 0; bit < (1 << N); bit++)
  {
    bool ok = true;
    vector<bool> included(N, false);
    for (int i = 0; i < N; i++)
    {
      if (bit & (1 << i)) // iがbitに入るかどうか
      {
        included[i] = true;
      }
    }
    for (int i = 0; i < M; i++)
    {
      int num = 0;
      for (int j = 0; j < S[i].size(); j++)
      {
        if (included[S[i][j]])
          num++;
      }
      if (num % 2 != p[i])
        ok = false;
    }
    if (ok)
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 705
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int N,M;
bool E[SIZE][SIZE]; //falseなら逆グラフに辺あり
vector<int> G[SIZE];
int C[SIZE]; //色は1か-1
bool T = true; //falseなら答えは-1
int D[2];

void dfs(int v,int c){
	if(C[v] == -c){
		T = false;
	}
	else if(C[v] == 0){
		C[v] = c;
		int d = (c==1?0:1);
		D[d]++;
		rep(i,0,G[v].size()){
			dfs(G[v][i],-c);
		}
	}
}


int main()
{
	cin >> N >> M;
	rep(i,0,M){
		int a,b;
		cin >> a >> b;
		a--;b--;
		E[a][b] = true;
		E[b][a] = true;
	}
	T = true;
	rep(i,0,N) rep(j,0,N) {
		if(i==j)continue;
		if(!E[i][j]){
			G[i].push_back(j);
		}
	}
	int cnt = 0;
	vector<P> ps;
	rep(i,0,N) if(C[i]==0) {
		D[0] = D[1] = 0;
		dfs(i,1);
		cnt++;
		ps.push_back(make_pair(D[0],D[1]));
	}
	if(!T){
		cout << -1 << endl;
		return 0;
	}
	//dp
	set<int> dp;
	dp.insert(0);
	for(auto p : ps){
		vector<int> vs;
		for(int j : dp){
			vs.push_back(j);
		}
		dp.clear();
		for(int j : vs){
			dp.insert(j+p.first);
			dp.insert(j+p.second);
		}
	}
	int n = 0;
	int h = N/2;
	for(int i : dp){
		int j = i;
		if(i>h)j = N-i;
		if(abs(h-n) >= abs(h-j)){
			n = j;
		}
	}
	cout << n*(n-1)/2 + (N-n)*(N-n-1)/2 << endl;

	return 0;
}


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

typedef long long ll;
#define MOD = 1000000007;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
template<class T> inline bool is_overlap(const T& as, const T& ae, const T& bs, const T& be)
{ return bs <=ae && as <= be; }
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
#define ANS(a) cout<<a<<endl
void yes(bool f){cout<<(f?"yes":"no")<<endl;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
void YES(bool f){cout<<(f?"YES":"NO")<<endl;}

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int N, M; cin >>N>> M;
    vector<int> counter(M, 0);
    
    int ans = 0;

    rep(i, N) {
        int K; cin >> K;
        rep(j, K) {
            int A; cin >> A;
            counter[A - 1]++;
        }
    }
    ans = count_if(ALL(counter), [&](const int x){return x==N;});

    cout << ans << endl;
}


Measured memory_bytes: 256
h, w = map(int, input().split())

grid = [list(input()) for _ in range(h)]
left = [[0] * w for _ in range(h)]
right = [[0] * w for _ in range(h)]
up = [[0] * w for _ in range(h)]
down = [[0] * w for _ in range(h)]

for i in range(h):
    current = 0
    for j in range(w):
        if grid[i][j] == '#':
            current = 0
        else:
            current += 1
        left[i][j] = current
    
for i in range(h):
    current = 0
    for j in range(w - 1, -1, -1):
        if grid[i][j] == '#':
            current = 0
        else:
            current += 1
        right[i][j] = current

for i in range(w):
    current = 0
    for j in range(h):
        if grid[j][i] == '#':
            current = 0
        else:
            current += 1
        up[j][i] = current

for i in range(w):
    current = 0
    for j in range(h - 1, -1, -1):
        if grid[j][i] == '#':
            current = 0
        else:
            current += 1
        down[j][i] = current

ans = 0
for i in range(h):
    for j in range(w):
        if grid[i][j] == '#':
            continue
        ans = max(ans, left[i][j] + right[i][j] + up[i][j] + down[i][j] - 3)

print(ans)

Measured memory_bytes: 309256
fun main(args : Array<String>) {
    val n = readLine()!!.toLong()
    val max = Math.sqrt(n.toDouble()).toInt()

    var min = Int.MAX_VALUE

    for (i in 1..max) {
        if (n % i != 0L) continue

        val ans = n / i
        val f = Math.max(i.toString().length, ans.toString().length)
        min = Math.min(min, f)
    }

    println(min)
}

Measured memory_bytes: 31708
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int count = 0;
  if(s[0] == 'o') count++;
  if(s[1] == 'o') count++;
  if(s[2] == 'o') count++;
  cout << 700 + 100 * count << endl;
}

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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'
#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
#define int long long
#define pow mypow

typedef pair<int,int> pii;
const int N = 2e5+5;
const int INF = 1e9+5;
const int MOD = 1e9+7;

int n, k;
int fact[N];
void precompute(){
	fact[0] = 1;
	for(int i=1; i<N; i++) fact[i] = fact[i-1]*i % MOD;
}
int pow(int a, int b){
	int res = 1;
	while(b){
		if (b&1) res = (res*a) % MOD;
		a = (a*a) % MOD;
		b /= 2; 
	}
	return res;
}
int C(int n, int k){
	if (k>n || k<0 || n<0) return 0;
	return fact[n]*pow(fact[n-k], MOD-2) % MOD * pow(fact[k], MOD-2) % MOD;
}
int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	precompute();
	cin >> n >> k;
	int ans = 0;
	for(int i=max(1LL, n-k); i<=n; i++){
		ans = (ans + C(n, i)*C(n-1, i-1) % MOD) % MOD;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1920
from itertools import accumulate

while 1:
    n = int(input())
    if n == 0:
        exit()
    ans = [0]*(24*60*60+1)
    for _ in range(n):
        s, t = input().split()
        sl = s.split(':')
        tl = t.split(':')
        ans[int(sl[0])*3600+int(sl[1])*60+int(sl[2])] += 1
        ans[int(tl[0])*3600+int(tl[1])*60+int(tl[2])] -= 1
    print(max(list(accumulate(ans))))


Measured memory_bytes: 10212
#include<stdio.h>
int main(void){
  int w,h,n,p[100][4],i,xmin=0,xmax,ymin=0,ymax;
  scanf("%d%d%d",&w,&h,&n);
  for(i=0;i<n;i++)scanf("%d%d%d",&p[i][0],&p[i][1],&p[i][2]);
  xmax=w;
  ymax=h;
  for(i=0;i<n;i++){
    switch(p[i][2]){
      case 1:
        if(p[i][0]>xmin){
         if(p[i][0]<xmax)xmin=p[i][0];
          else xmin=xmax;
        }
        break;
      case 2:
        if(p[i][0]<xmax){
         if(p[i][0]>xmin)xmax=p[i][0];
          else xmax=xmin;
        }
        break;
      case 3:
        if(p[i][1]>ymin){
          if(p[i][1]<ymax)ymin=p[i][1];
          else ymin=ymax;
        }
        break;
      case 4:
        if(p[i][1]<ymax){
          if(p[i][1]>ymin)ymax=p[i][1];
          else ymax=ymin;
        }
        break;
    }
  }
  printf("%d",(xmax-xmin)*(ymax-ymin));
  return 0;
}

Measured memory_bytes: 128
def examA():
    L = LI(); L.sort()
    ans = L[0]*L[1]//2
    print(ans)
    return

def examB():
    return

def examC():
    return

def examD():
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,ALPHABET, _ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 1e-9
alphabet = [chr(ord('a') + i) for i in range(26)]
ALPHABET = [chr(ord('A') + i) for i in range(26)]

if __name__ == '__main__':
    examA()


Measured memory_bytes: 3436
<?PHP

$single_line_input = trim(fgets(STDIN));
$array = explode(" ", $single_line_input);
$array_fruit=array(1,2,3,4,5,6,7,8,9);
if (in_array($array[0], $array_fruit)and in_array($array[1], $array_fruit) ){
  echo  $array[0]*$array[1];
}
else{
echo -1;
}

Measured memory_bytes: 4728
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 100005

const int INF = 1e9+7;


int main(){

    int a,b,c;
    cin >> a >> b >> c;
    int cnt = 0;
    for(int i = 100;i >= 0;i--){
        if(a%i == 0 && b%i == 0){
            cnt++;
        }
        if(cnt == c){
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
a1 = gets.split.map(&:to_i);
a2 = gets.split.map(&:to_i);
k = 0
ans = []

n.times do
    s1,s2 = 0,0
    s1 = a1[0..k].inject(:+)
    s2 = a2[k..n].inject(:+)
    ans << (s1 + s2)
    k += 1
end
    
puts ans.max
    

Measured memory_bytes: 1788
n,m = gets.split.map(&:to_i)
shop = n.times.map{gets.split.map(&:to_i)}.sort{|a,b| a[0] <=> b[0]}

ans = 0
drink = 0
shop.each do |s|
  a,b = s[0],s[1]
  if drink+b <= m
    ans += a * b
    drink += b
  else
    ans += a * (m-drink)
    drink = m
  end
  if drink == m
    break
  end
end

puts ans

Measured memory_bytes: 11128
#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define FORD(i,a,b) for(int i = (a); i >= (b); i--)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define M_PI 3.14159265358979323846
template<class C> void mini(C& _a4, C _b4) { _a4 = min(_a4, _b4); }
template<class C> void maxi(C& _a4, C _b4) { _a4 = max(_a4, _b4); }

template<class TH> void _dbg(const char *sdbg, TH h) { cerr << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
	while (*sdbg != ',')cerr << *sdbg++; cerr << '=' << h << ','; _dbg(sdbg + 1, a...);
}

template<class T> ostream& operator<<(ostream& os, vector<T> V) {
	os << "["; for (auto& vv : V) os << vv << ","; os << "]";
	return os;
}

template<class L, class R> ostream &operator<<(ostream &os, pair<L, R> P) {
	return os << "(" << P.st << "," << P.nd << ")";
}


#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#endif
const int mx = (int)1e6;

int32_t main(int32_t argc, char ** argv) {
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	VI inp(n);
	REP(i, n) {
		cin >> inp[i];
	}
	PII r = { -1, -1 };
	int idx = 0;
	REP(i, n){
		maxi(r, {abs(inp[i]), i});
	}
	if (inp[r.second] == 0) {
		cout << 0;
		return 0;
	} 
	vector<PII> oper;
	if (inp[r.second] < 0) {
		REP(i, 2) {
			oper.push_back({ r.second, n - 1 });
		}
		FORD(i, n - 2, 0) {
			REP(j, 2)
				oper.push_back({ i + 1, i });
		}
	}
	else {
		REP(i, 2) {
			oper.push_back({r.second, 0});
		}
		FOR(i, 1, n - 1) {
			REP(j, 2) {
				oper.push_back({i - 1, i});
			}
		}
	}
	cout << SZ(oper) << "\n";
	for (PII p : oper) {
		p.first++;
		p.second++;
		cout << p.first << " " << p.second << "\n";
	}
	return 0;
}

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

int main() {
   long long int A, B, K;
   cin >> A >> B >> K;
   A -= K;
   if (A <= 0)
      B += A;
   A = 0 > A ? 0 : A;
   B = 0 > B ? 0 : B;
   cout << A << " " << B << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>    
#include <vector>       
#include <set>
#include <utility>  
#include <cstring>
#include <stdio.h>
#include <limits.h>
#include <queue>
#include <algorithm> 
#define MAX_DOUBLE  40000000000.0 
#include <math.h> 
#include <unistd.h>

using namespace std;


int min(int a, int b){
	if( a > b ) return b;
	return a; 
}


int main(){
	int n;
	cin>>n;
	
	vector<int> vec(n);
	
	for(int i = 0; i<n; i++){
		
		cin>>vec[i];
		
	}
	
	vector<int> res(n);
	
	res[0] = 0;
	res[1] = abs(vec[0] - vec[1]);
	
	for(int i = 2; i < n; i++){
		res[i] = min(abs(vec[i] - vec[i-2]) + res[i-2] , abs(vec[i] - vec[i-1]) +res[i-1]);

	}
	
	cout<<res[n-1];
}





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

#define rep(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
const ll inf = 100100100100100;

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

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

    
    int h,w;
    cin >> h >> w;
    int arr[h][w];
    rep(i,0,h){
        rep(j,0,w){
            cin >> arr[i][j];
        }
    }
    
    vector<string> out;
    rep(i,0,h){
        rep(j,1,w){
            if(arr[i][j-1] % 2 == 1){
                arr[i][j-1]--;
                arr[i][j]++;
                string t = "";
                t += to_string(i+1) + " " + to_string(j) + " " + to_string(i+1) + " " + to_string(j+1);
                out.push_back(t);
            }
        }
    }

 
    rep(i,1,h){
        if(arr[i-1][w-1] %2 == 1){
            arr[i-1][w-1]--;
            arr[i][w-1]++;
            string t = "";
            t += to_string(i) + " " + to_string(w) + " " + to_string(i+1) + " " + to_string(w);
            out.push_back(t);
        }
    }
 
    cout << out.size() << endl;
    rep(i,0,out.size()) cout << out[i] << endl;

}

Measured memory_bytes: 9972
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int main(){
	int A,B,X;
	cin>>A>>B>>X;
	rep(i,A+1) rep(j,B+1){
		int x = i*j+(A-i)*(B-j);
		if(x==X){
			puts("Yes");
			return 0;
		}
	}
	puts("No");
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int a, x = 1;
        
        while(true){
            a = sc.nextInt();
            if(a == 0) break;
            
            System.out.println("Case "+ x +": "+ a); 
            x++;
        }
        
    }
}


Measured memory_bytes: 42644
#include <iostream>
#include <string>
#include <set>


using namespace std;


int main()
{
    int N, L;
    cin >> N >> L;
    
    multiset<string> S;
    for( int i = 0; i < N; ++i ){
        string tmp;
        cin >> tmp;
        S.insert(tmp);
    }


    for( auto itr = S.begin(); itr != S.end(); ++itr ){
        cout << *itr;
    }
    cout << endl;


    return 0;
}

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

int main()
{
    int n;
    cin>>n;
    int ar[n];
    int i,j;
    for(i=0;i<n;++i) scanf("%d",&ar[i]);
    int sum=0;
    for(i=0;i<n-1;++i){
        for(j=i+1;j<n;++j) sum+=ar[i]*ar[j];
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 256
s=input()
l=len(s)

n=[0]*l
p='R'
c=0

for i in range(l):
  if (p!=s[i]):
    if (p=='R'):
      n[i]     += c//2 
      n[i-1]   += c//2 + c%2
    else:
      n[i-c]   += c//2 + c%2
      n[i-c-1] += c//2
    p=s[i]
    c=1
  else:
    c+=1

n[l-c]    += c//2 + c%2
n[l-c-1]  += c//2
print(*n)


Measured memory_bytes: 6400
A,B = map(int,input().split())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

#最大公約数
def my_gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
    
gcd_n = my_gcd(max(A,B),min(A,B))

if A==1 or B==1:
    print(1)
else:
    print(len(factorization(gcd_n))+1)

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

typedef long long ll;

int main() {
    int N, K;
    ll MOD = 1e9 + 7;
    cin >> N >> K;
    vector<int> a(N);    
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    //dp[i][j] i番目までの子供たちでj個を分け合う方法
    vector<vector<int>> dp(N + 1, vector<int>(K + 1, 0));
    //cs[i][j] = sum(dp[i][k] for k < j)
    vector<vector<int>> cs(N + 1, vector<int>(K + 2, 1));
    dp[0][0] = 1;
    cs[0][0] = 0;
    for (int i = 0; i < N; i++) {
        dp[i + 1][0] = 1;
        cs[i + 1][0] = 0;
        for (int j = 1; j <= K; j++) {
            dp[i + 1][j] = (cs[i][j + 1] - cs[i][max(0, j - a[i])] + MOD) % MOD;
            cs[i + 1][j + 1] = (cs[i + 1][j] + dp[i + 1][j] + MOD) % MOD;
            //cout << "dp[" << i + 1 << "][" << j << "]=" << dp[i+1][j] << " cs[" << i + 1 << "][" << j + 1 << "]=" << cs[i + 1][j + 1] << endl;
        }
    }
    cout << dp[N][K] << endl;
}

Measured memory_bytes: 79736
#include<stdio.h>
int main(){
  int n,flag = 0;
  scanf("%d",&n);
  for(int i = 0;i<=n/4;i++){
    for(int j = 0;j<=n/7;j++){
      if(n == 4*i + 7*j) flag = 1;
    }
  }
  if(flag == 1) printf("Yes");
  else printf("No");
  return 0;
}



Measured memory_bytes: 128
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x[] = new int[n];
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
        }
        int sort[] = Arrays.copyOf(x, n);
        Arrays.sort(sort);
        int mid1 = sort[n / 2 - 1];
        int mid2 = sort[n / 2];
        for (int i = 0; i < n; i++) {
            if (x[i] <= mid1) {
                System.out.println(mid2);
            } else {
                System.out.println(mid1);
            }
        }
    }
}

Measured memory_bytes: 91052
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <climits>
#include <assert.h>
#include <cstring>
#include <set>
using namespace std;

typedef long long ll;

int main()
{
    int N;
    cin >> N;
    cout << (1000 - (N%1000))%1000 << "\n";
}

Measured memory_bytes: 3576
object Main extends App {
  val in = new StdinReader
  val a, b, q = in.nextInt
  val Max = 10000000000L
  val ss = (-2 * Max) +: Array.fill(a)(in.nextLong) :+ (3 * Max)
  val ts = (-2 * Max) +: Array.fill(b)(in.nextLong) :+ (3 * Max)
  val xs = Array.fill(q)(in.nextLong)

  def search(a: Array[Long], l: Int, r: Int, x: Long): (Long, Long) = {
    val m = (l + r) / 2
    if (x < a(m)) search(a, l, m, x)
    else if (x >= a(m + 1)) search(a, m, r, x)
    else (x - a(m), a(m + 1) - x)
  }

  println(xs.map{x =>
    val (sl, sr) = search(ss, 0, ss.size, x)
    val (tl, tr) = search(ts, 0, ts.size, x)
    Array(
      sl max tl,
      sr max tr,
      sl * 2 + tr,
      tl * 2 + sr,
      sl + tr * 2,
      tl + sr * 2).min
  }.mkString("\n"))
}




class StdinReader {
  val is = System.in
  val buffer = new Array[Byte](1024 * 1024)
  var size = 0
  var pos = 0

  private def readByte: Byte = {
    if (pos >= size) {
      pos = 0;
      size = is.read(buffer);
    }
    if (size < 0) -1
    else {
      val ret = buffer(pos)
      pos += 1
      ret
    }
  }

  def nextInt: Int = {
    @scala.annotation.tailrec
    def r(i: Int, reading: Boolean): Int = {
      readByte match {
        case '-' => r(i * -1, true)
        case b if '0' <= b && b <= '9' => r(i * 10 + (b - '0'), true)
        case _ => if (reading) i else r(i, false)
      }
    }
    r(0, false)
  }

  def nextLong: Long = {
    @scala.annotation.tailrec
    def r(i: Long, reading: Boolean): Long = {
      readByte match {
        case '-' => r(i * -1, true)
        case b if '0' <= b && b <= '9' => r(i * 10 + (b - '0'), true)
        case _ => if (reading) i else r(i, false)
      }
    }
    r(0L, false)
  }
}

Measured memory_bytes: 57972
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static MyUtil;

class MyUtil
{
    public static long[] ReadLongArray()
    {
	return ReadLine().Split().Select(x => long.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	int n = int.Parse(ReadLine());
	var a = ReadLongArray();

	int nn = 0; // number of negative numbers.
	for (int i = 0; i < n; i++)
	{
	    if (a[i] < 0)
	    {
		nn++;
		a[i] = -a[i];
	    }
	}

	Array.Sort(a);
	
	if ((nn&1) == 1)
	{
	    a[0] = -a[0];
	}

	WriteLine(a.Sum());
    }
}


Measured memory_bytes: 31580
#include<bits/stdc++.h>
using namespace std;
const int N=500005,M=998244353;
int n,a[105],i,j;
long long dfs(int l,int r,int sl,int sr)
{
	if(r==l+1)
		return 0;
	int i;
	long long ans=1e18;
	for(i=l+1;i<r;++i)
		ans=min(ans,dfs(l,i,sl,sl+sr)+dfs(i,r,sl+sr,sr)+1ll*a[i]*(sl+sr));
	return ans;
}
int main()
{
	scanf("%d",&n);
	for(i=1;i<=n;++i)
		scanf("%d",&a[i]);
	cout<<dfs(1,n,1,1)+a[1]+a[n];
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<unordered_map>
#include<stack>
#include<string>
#include<algorithm>
#include<functional>
#include<cstring>
#include<complex>
#include<bitset>
#include<iostream>
using namespace std;

/**** Type Define ****/

typedef long long ll;
typedef long long unsigned ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> Q;
char S[64],ans[64]="No";
/**** main function ****/
int main(){
  scanf("%s",S);
  if(S[0] ==S[1] && S[2] ==S[3] &&S[0] != S[2]) strcpy(ans,"Yes");
  if(S[0] ==S[2] && S[1] ==S[3] &&S[0] != S[1]) strcpy(ans,"Yes");
  if(S[0] ==S[3] && S[1] ==S[2] &&S[0] != S[1]) strcpy(ans,"Yes");

  printf("%s",ans);
}


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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define all(x) x.begin(), x.end()
#define PB push_back
#define F first
#define S second

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

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

	int a, b, m; cin >> a >> b >> m;
	vi aa(a), bb(b);
	int ma = 1e7, mb = 1e7;
	for(auto& p: aa){
		cin >> p;
		ma = min(ma, p);
	} 
	for(auto& p: bb){
		cin >> p;
		mb = min(mb, p);
	}

	int ans = ma+mb;
	FOR(i, m){
		int x, y, c; cin >> x >> y >> c;
		ans = min(ans, aa[x-1]+bb[y-1] - c);
	}

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("O3")
#include<stdint.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/rope>
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define VIS(it,con) for(auto it=con.begin();it!=con.end();++it)
#define pob pop_back
#define pf push_front
#define pof pop_front
#define MIN(x,y) (x=min(x,(y)))
#define MAX(x,y) (x=max(x,(y)))
#define mid (l+r>>1)
#define lch (idx*2+1)
#define rch (idx*2+2)
/*****************************************************************************/
#include<bits/stdc++.h>
#define int int_fast64_t
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> VI;
#define REP(i,j,k) for(register int i=(j);i<(k);++i)
#define RREP(i,j,k) for(register int i=(j)-1;i>=(k);--i)
#define ALL(a) a.begin(),a.end()
#define MST(a,v) memset(a,(v),sizeof a)
#define pb push_back
#define F first
#define S second
#define endl '\n'
//																#define __debug
#ifdef __debug
	#define IOS (void)0
	#define de(...) cerr<<__VA_ARGS__
	#define ar(a,s,t) {REP(__i,s,t)de(a[__i]<<' ');de(endl);}
#else
	#define IOS cin.tie(0),cout.tie(0),ios_base::sync_with_stdio(false)
	#define de(...) (void)0
	#define ar(...) (void)0
#endif
/***********************************default***********************************/
const int maxn=20,inf=1ll<<60;
int n,a[maxn];

int sol(int l,int r,int xl,int xr){
	if(l>r)return 0;
	int ret=inf;
	for(int i=l;i<=r;++i){
		MIN(ret,sol(l,i-1,xl,xl+xr)+sol(i+1,r,xl+xr,xr)+(xl+xr)*a[i]);
	}
	return ret;
}

main(){
	IOS;
	cin>>n;
	REP(i,0,n)cin>>a[i];
	cout<<sol(1,n-2,1,1)+a[0]+a[n-1]<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int MOD = 1e9 + 7;

struct Combination{
  const int MOD = 1e9+7;

  vector<int> fact; //　fact[i] = iの階乗
  void init(int n){
    fact.resize(n+1);
    fact[0] = fact[1] = 1;
    for(int i = 2; i <= n; i++){
      fact[i] = i * fact[i-1] % MOD;
    }
  }

  int nCr(int n, int r){ // nCr = n!/r!(n-r)!
    if(n < r) return 0;
    return fact[n] * mod_pow(fact[r]*fact[n-r]%MOD, MOD-2) % MOD;
  }

  int mod_pow(int n, int p){ // a/n ≡ a*n^(p-2) nとpは互いに素
    int r = 1;
    for(; p > 0; p >>= 1){
      if(p & 1LL) r = (r * n) % MOD;
      n = (n * n) % MOD;
    }
    return r; // r = n^p % MOD
  }

}comb;

signed main(){

  int H, W, A, B; cin >> H >> W >> A >> B;

  int ans = 0;
  comb.init(1e7);
  for(int i = B; i < W; i++){
    ans += comb.nCr(H-1-A + i, i) * comb.nCr(H-1 - (H-A) + W-1 - i, W-1 - i);
    ans %= MOD;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 78336
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#define REP(i,n) for(int i=0;i<(int)(n);i++)
 
 
int main()
{
    long int n,k;
    scanf("%ld %ld\n",&n,&k);
    long long int ans=0;
    long int x1=0;
    long int x2=0;
    x1=n/k;
    if(k%2==0)
    {
        x2=x1+((n-x1*k)>=k/2);
    }
    ans=x1*x1*x1+x2*x2*x2;
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main() {
    string tmp, str;
    while (cin >> tmp) str += tmp;
    FOR(i, 'a', 'z'+1) {
        int s = 0;
        REP(j, str.size()) if (tolower(str[j]) == i) s++;
        cout << (char)i << " : " << s << endl;}
}

Measured memory_bytes: 3196
#include<bits/stdc++.h> 
#define mod 1000000007
using namespace std;
int s[4100][4100],t[4100][4100],fac[10100],inv[10100],ans,n;
int qpow(int a,int b){
	int ans=1,tmp=a;
	for(;b;b>>=1,tmp=1ll*tmp*tmp%mod)
		if(b&1)ans=1ll*ans*tmp%mod;
	return ans;
}
int C(int x,int y){
	return 1ll*fac[y]*inv[x]%mod*inv[y-x]%mod;
}
int main(){
	scanf("%d",&n),fac[0]=inv[0]=1;
	for(int i=1;i<=10010;++i)fac[i]=1ll*fac[i-1]*i%mod;
	inv[10010]=qpow(fac[10010],mod-2);
	for(int i=10009;i>=1;--i)inv[i]=1ll*inv[i+1]*(i+1)%mod;
	for(int i=1,a,b;i<=n;++i)
		scanf("%d%d",&a,&b),
		s[2001-a][2001-b]++,t[2001+a][2001+b]++,
		ans=(ans-C(a*2,(a+b)*2))%mod;
	for(int i=1;i<=4010;++i)
		for(int j=1;j<=4010;++j){
			s[i][j]=(1ll*s[i][j]+s[i-1][j]+s[i][j-1])%mod;
			if(t[i][j])ans=(ans+1ll*t[i][j]*s[i][j])%mod;
		}
	printf("%d",(1ll*ans*(mod+1)/2%mod+mod)%mod);
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	if(n >= 400 && n <= 599)
		cout <<  8 << endl;

	else if(n >= 600 && n <= 799)
		cout <<  7 << endl;


	else if(n >= 800 && n <= 999)
		cout <<  6 << endl;

	else if(n >= 1000 && n <= 1199)
		cout <<  5 << endl;


	else if(n >= 1200 && n <= 1399)
		cout <<  4 << endl;

	else if(n >= 1400 && n <= 1599)
		cout <<  3 << endl;

	else if(n >= 1600 && n <= 1799)
		cout <<  2 << endl;

	else if(n >= 1800 && n <= 1999)
		cout <<  1 << endl;


}




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

int main() {
    int h, w;
    cin >> h >> w;
    rep(i, 0, h) {
        rep(j, 0, w) {
            string s;
            cin >> s;
            if (s == "snuke") {
                cout << char('A' + j) << i + 1 << endl;
            }
        }
    }
}

Measured memory_bytes: 256
X, K, D = map(int,input().split())
X = abs(X)

if X > K*D:
    print( X - K*D )
else:
    a = X//D
    K -= a
    X -= D*a
    if K%2 == 0:
        print(X)
    else:
        print(abs(X-D))

Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
const int M = 1000000007;
struct ban
{
    long long x;
    ban()
    {
        x = 0;
    }
    ban(long long x)
    {
        this->x = (x % M);
    }
};
ban operator+(const ban& a, const ban& b)
{
    return ban(a.x + b.x);
}
ban operator-(const ban& a, const ban& b)
{
    return ban(a.x - b.x + M);
}
ban operator*(const ban& a, const ban& b)
{
    return ban(a.x * b.x);
}
ban ast(ban x, long long n)
{
    ban ans(1);
    while (n)
    {
        if (n % 2 == 1)
            ans = ans * x;
        x = x * x;
        n /= 2;
    }
    return ans;
}
ban operator/(const ban& a, const ban& b)
{
    return a * ast(b, M - 2);
}

ban ans;

int n;
vector<int> a[N];

int pp[N];
int q[N];
void dfs(int x, int p)
{
    pp[x] = p;
    q[x] = 1;
    for (int i = 0; i < a[x].size(); ++i)
    {
        int h = a[x][i];
        if (h == p)
            continue;
        dfs(h, x);
        q[x] += q[h];
    }
}

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n - 1; ++i)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        a[x].push_back(y);
        a[y].push_back(x);
    }
    dfs(1, 1);
    ans = ban(n) / ban(2);
    for (int x = 1; x <= n; ++x)
    {
        for (int i = 0; i < a[x].size(); ++i)
        {
            int h = a[x][i];
            int qq;
            if (h == pp[x])
                qq = n - q[x];
            else
                qq = q[h];
            ans = ans - (ban(1) - ast(ban(1) / ban(2), qq)) * ast(ban(1) / ban(2), n - qq);
        }
        ans = ans - ast(ban(1) / ban(2), n);
    }
    printf("%lld\n", ans.x);
    return 0;
}


Measured memory_bytes: 23936
#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 = 1e9 + 7;
const int INF = 1 << 30;

struct Edge{
    int src,dst,weight;
    Edge(): src(0),dst(0),weight(0) {}
    Edge(int src,int dst, int weight): src(src),dst(dst) ,weight(weight){}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

class UnionFind{
private:
    vector<int> par,rank,sizes;
    int tree;

public:
    explicit UnionFind(const int n) : tree(n){
        par.resize(n+1);
        rank.resize(n+1);
        sizes.resize(n+1);
        rep(i,n){
            par[i] = i;
            sizes[i] = 1;
        }
    }

    ~UnionFind() = default;

    int root(int x){
        if(par[x] == x) return x;
        else return par[x] = root(par[x]);
    }

    int find(int x){ return root(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[y] = x;
        tree--;
        sizes[x] += sizes[y];
        if (rank[x] == rank[y]) rank[x]++;
    }

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

    int size(int x){
        return sizes[x];
    }

    int sumTree(){
        return tree;
    }
};

bool operator < (const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight < f.weight : //辺は重さが重いものを"小さい"と定義する
           e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

int main(){
    int n,m; cin >> n >> m;
    UnionFind uf(n);

    ll ans = 0;

    Edges e(m);
    rep(i,m){
        int a,b,c;
        cin >> a >> b >> c;

        e[i].src = a;
        e[i].dst = b;
        e[i].weight = c;
    }

    sort(e.begin(),e.end());

    rep(i,m){
        int ts = e[i].src;
        int td = e[i].dst;
        int cost = e[i].weight;

        if(!uf.same(ts,td)){
            ans += cost;
        }

        uf.unite(ts,td);
    }

    cout << ans << endl;
}



Measured memory_bytes: 4072