akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<set>
#include<list>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<limits>
#include<cctype>
#include<unordered_map>
#include<complex>
#pragma warning(disable:4996)
using namespace std;

#define debug(i) cout<<"<debug> "<<#i<<" "<<i<<" <\\debug>"<<endl
#define mfor(i,a,b) for(int i=(a);i<=(b);i++)
#define mrep(i,a,b) for(int i=(a);i>=(b);i--)
#define lll __int128
#define Re register
#define mem(a,b) memset(a,(b),sizeof(a))
#define Design ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define endl '\n'
typedef pair<int, int> intpair;
typedef pair<long long int, long long int> llpair;
typedef long long int ll;
const double pi = acos(-1);
const double eps = 1e-5;
const int INF = 0x3f3f3f3f;
const long long int INFLL = 0x3f3f3f3f3f3f3f3f;

const int maxn = 2000010;
ll fac[maxn];
ll inv[maxn];

long long fpow(long long a, long long n, long long mod)
{
    if (n == 0)        return 1;
    else if (n & 1) return a * fpow(a, n - 1, mod) % mod;
    else
    {
        long long num = fpow(a, n / 2, mod) % mod;
        return num * num % mod;
    }
}

void getfacinv(int n, ll mod)
{//初始化fac和inv数组，获取1!-n!和相应的逆元
    fac[0] = inv[0] = 1;
    for (int i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % mod;
    inv[n] = fpow(fac[n], mod - 2, mod);
    for (int i = n - 1; i >= 1; i--) inv[i] = inv[i + 1] * (i + 1LL) % mod;
}

ll com(ll a, ll b, ll mod)
{
    //计算组合数
    if (a < b) return 0;
    return fac[a] * fpow(fac[b], mod - 2, mod) % mod * fpow(fac[a - b], mod - 2, mod) % mod;
}

const ll mod = 1e9 + 7;

ll decm(ll a, ll b)
{
    return ((a - b) % mod + mod) % mod;
}

int main()
{
	Design;
    getfacinv(1e6,mod);
    ll n;
    cin >> n;
    ll ans = 0;
    ans = decm(fpow(10, n, mod), fpow(9, n, mod) * 2 % mod) + fpow(8, n, mod);
    cout << ans % mod;
}

Measured memory_bytes: 19244
//Code by ASIM FOIZE AIMON
//CSE'19;CUET
//avoid copy paste//Hit the frined button
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define precise cout.precision(10); cout << fixed;
#define endl "\n"
#define int int64_t
#define ll long long
#define yes printf("YES\n")
#define no printf("NO\n")

int32_t main()
{
    /*#ifndef ONLINE_JUDGE
        freopen("/media/AIMON/SSDVol/Progs/CodeForces/input.txt", "r", stdin);
        freopen("/media/AIMON/SSDVol/Progs/CodeForces/output.txt", "w", stdout);
    #endif*/
    int a,b,c,d,e,f,m,n,p,x,y,z,t,i,j,k;
    string s;
    cin>>s;
    if(s[s.size()-1]=='s')
    {
        cout<<s;
        cout<<"es"<<endl;
    }
    else
    {
       cout<<s;
        cout<<"s"<<endl;
    }
}


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

using ll =  long long;
using pint =  pair<int,int>;

#define rep(i,n) for(int (i)=0,temp=(int)(n);(i)<temp;++(i))
#define repi(i,start,end) for(int (i)=(start),temp=(int)(end);i<(end);++(i))
#define rfor(x,v) for(const auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort((v), (v)+(n))
#define vsort(v) sort((v).begin(), (v).end())
#define vfsort(v,lambda) sort(all((v)),(lambda))
#define vint vector<int>
#define vvint vector<vector<int>> //vvint v(n,vint(n))
#define vin(v) rep(i,(v).size()) {cin >> (v)[i];}
//最終奥義 #define int long long
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; }
//lambda: [&](int x, int y){return x<y;}

signed main(void){
    int n;cin>>n;
    vector<pint> red(n),blue(n);
    rep(i,n)cin>>red[i].first>>red[i].second;
    rep(i,n)cin>>blue[i].first>>blue[i].second;

    vsort(blue);
    vfsort(red,[](pint x,pint y){return x.second>y.second;});

    int ans=0;
    vint used(n,0);
    rep(i,n){
        rep(j,n){
            if(used[j]>0)continue;
            if(red[j].first<blue[i].first&&red[j].second<blue[i].second){
                used[j]++;
                ans++;
                break;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(),v.end()
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define pi 3.1415926535897932384626433832
#define mod 1000000007
#define inf 1000000000
#define pr1(a) cout << a << endl
#define pr2(a,b)cout << a <<  " " <<b<< endl
#define pr3(a,b,c) cout << a <<" " << b << " " << c << endl

const long double PI = acos(-1);

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

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


void solve(){
    int n, b,r;
    cin >> n>> b >> r;

    int ans = 0;

    if(n<=b){
        cout << n << endl;
        return;
    }
    else if(n>b && n<=b+r){
        cout << b << endl;
        return;
    }
    else{

        int x = n/(b+r);
        n%=(b+r);

        ans = x*b + min(n,b);
        cout << ans << endl;
    }


 
} 

signed main() 
{   
    IOS;
    int t = 1;
    //cin >> t;

    for(int i = 1;i<=t;i++){
        solve();
    }
    return 0;
} 

 


Measured memory_bytes: 256
#define _LIBCPP_DEBUG 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef vector<int> vi;
typedef long long ll;



int main(){
    string s;cin>>s;
    if(s=="zyxwvutsrqponmlkjihgfedcba"){
        cout<<-1<<endl;
        return 0;
    }
    int N=s.size();
    if(N!=26){
        cout<<s;
        map<char,int> m;
        for(char i='a';i<='z';i++){
            m[i]=0;
        }
        rep(i,0,N){
            m[s.at(i)]++;
        }
        for(auto it:m){
            if(it.second==0){
                cout<<it.first;
                return 0;
            }
        }
    }
    else{
        map<char,int> m;
        rep(i,0,N){
            m[s.at(i)]=i;
        }
        for(int i=25;i>=0;i--){
            char tmp=s.at(i);
            while(tmp<='z'){
                tmp++;
                if(m[tmp]>=i){
                    rep(j,0,i){
                        cout<<s.at(j);
                    }
                    cout<<tmp;
                    return 0;
                }
            }
        }
    }

    
}






Measured memory_bytes: 256
//競技プログラミング　テンプレ
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

using namespace std;

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

const int max_v = 300;
const int INF = 1000000;



int main() {
	int n, ans=0 ,k ,ii=0;
	int mp_size ,min,s,m,ban;
	cin >> n >> k;
	vector <int> A(n);
	
	//string str;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	map<int ,int> mp;

	REP(i,n){
		mp[A[i]] ++ ;
	}
	mp_size = mp.size();
	vector <int> B (mp_size);
		for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
		 	m= itr ->second; //値
			B[ii] = m;
			ii++;
		 }
		 sort(B.begin(), B.end());
	ii = 0;
	while (mp_size > k){
		ans += B[ii];
		ii++;
		mp_size--;
	}

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


Measured memory_bytes: 11136
#include <iostream>

using namespace std;

int sum(int i){
	int res=0;
	while(i>0){
		res+=i%10;
		i /= 10;
	}
	return res;
}

int main(){
	int N,A,B;
	cin >> N >> A >> B;
	
	int ans=0;
	for(int i=1;i<=N;i++){
		if(sum(i)>=A && sum(i)<=B) ans+=i;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3608
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int N;
  cin >> N;
  int a[N] = {0};
  int b[N][11];
  rep(i, N){
    rep(j, 10){
      int p;
      cin >> p;
      a[i] |= p<<j;
    }
  }
  rep(i, N){
    rep(j, 11){
      cin >> b[i][j];
    }
  }
  int ans = -(inf);
  for(int j=1; j<(1<<10); j++){
    int tmp = 0;
    int cnt[N] = {0};
    rep(i, N){
      rep(k, 10){
        if(j & a[i] & 1<<k) cnt[i]++;
      }
      tmp += b[i][cnt[i]];
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
 
}
 

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

std::vector<std::pair<long long,long long>> convex_hull(std::vector<std::pair<long long,long long>> P){
    if(P.size()<=2){
        return P;
    }
    std::vector<std::pair<long long,long long>> H,L,R;
    sort(P.begin(),P.end());
    
    //下半分
    for(int i=0;i<P.size();i++){
        int j=L.size();
        while(j>=2 && (L[j-1].first-L[j-2].first)*(P[i].second-L[j-2].second)<=(L[j-1].second-L[j-2].second)*(P[i].first-L[j-2].first)){
            L.pop_back();
            j--;
        }
        L.push_back(P[i]);
    }
    
    //上半分
    for(int i=P.size()-1;i>=0;i--){
        int j=H.size();
        while(j>=2 && (H[j-1].first-H[j-2].first)*(P[i].second-H[j-2].second)<=(H[j-1].second-H[j-2].second)*(P[i].first-H[j-2].first)){
            H.pop_back();
            j--;
        }
        H.push_back(P[i]);
    }
    
    
    R=L;
    for(int i=1;i<H.size()-1;i++){
        R.push_back(H[i]);
    }
    
    return R;
}


signed main(void){
    int N;
    const double PI = 3.14159265358979;
    std::vector<std::pair<long long,long long>> P;
    std::map<std::pair<int,int>,int> M;
    double Ans[114]={};
    int x,y;
    std::cin >> N;
    for(int i=0;i<N;i++){
        std::cin >> x >> y;
        P.push_back({x,y});
        M[{x,y}]=i;
    }
    P=convex_hull(P);
    //REP(i,P.size()){cout << P[i].first <<" "<< P[i].second << endl;}
    
    P.push_back(P[0]);
    double angle[114]={};
    for(int i=0;i<P.size()-1;i++){
        double t=atan2(-(P[i+1].first-P[i].first),(P[i+1].second-P[i].second));
        angle[i]=t;
    }
    angle[P.size()-1]=angle[0];
    for(int i=0;i<P.size()-1;i++){
        double k=angle[i+1]-angle[i];
        if(k<-PI)k+=2*PI;
        Ans[M[P[i+1]]]+=k;
    }
    
    //REP(i,P.size()-1){printf("%.8f\n",angle[i]);}
    
    double sum=0;
    for(int i=0;i<N;i++){
        sum+=Ans[i];
    }
    
    for(int i=0;i<N;i++){
        Ans[i]/=sum;
    }
    //printf("%.8f\n\n\n\n",sum/PI);
    for(int i=0;i<N;i++){
        printf("%.8f\n",Ans[i]);
    }
    
    return 0;
}


Measured memory_bytes: 512
class Balance:
    def __init__(self):
        self.N = int(input())
        self.W = [int(n) for n in input().split()]

    def minAbs(self):
        total = 0
        for n in self.W:
            total += n

        S1 = 0
        diffs = []
        for n in self.W:
            S1 += n
            S2 = total - S1
            diffs.append(abs(S1 - S2))

        print(min(diffs))


balance = Balance()
balance.minAbs()


Measured memory_bytes: 3060
int main(void) {
   int n, m;
   int i;
   int sum = 0;
   int cnt = 0;
   int com;
   scanf("%d %d",&n, &m);

   int an[n];
   for(i = 0; i < n; i++) {
      scanf("%d",&an[i]);
      sum += an[i];
   }

   com = sum/(4*m);

   for(i = 0; i < n; i++) {
      if(sum <= an[i]*4*m) {
         cnt++;
      }
   }
   if(cnt >= m) {
      printf("Yes");
   } else {
      printf("No");
   }

   return 0;
}



Measured memory_bytes: 1628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 1e9+7


int main() {
    int n;
    cin >> n;
    set<string> st;
    for (int i = 0; i < n; i ++) {
        string s;
        cin >> s;
        st.emplace(s);
    }
    int ans = 0;
    for (string s : st) {
        ans++;
    }
    cout << ans << endl;
}


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

int main(void){
    int n; cin >> n;
    string s = to_string(n);
    int fn;
    for(int i=0;i<s.length();i++) fn += s[i]-'0';
    if(n%fn==0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define mp make_pair
#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

//#####################
//Dijkstra
//#####################
struct edge
{
    ll from, to, cost;
};

int n, m, a, b, c;
edge g[112345];
ll dis[112345];

void bellmanFord(int s, int t)
{
    ll inf = LLONG_MAX;

    fill(dis, dis + n + 1, inf);

    dis[s] = 0;

    for (int j = 0; j < t; j++)
    {
        for (int i = 0; i < m; i++)
        {
            edge e = g[i];
            if (dis[e.from] != inf && dis[e.to] > dis[e.from] + e.cost)
            {
                dis[e.to] = dis[e.from] + e.cost;
            }
        }
    }
}

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

    cin >> n >> m;

    REP(i, m)
    {
        cin >> a >> b >> c;

        g[i] = {a, b, -c};
    }

    bellmanFord(1, n - 1);
    ll res = -dis[n];
    bellmanFord(1, n);

    if (res != -dis[n])
    {
        cout << "inf" << endl;
    }
    else
    {
        cout << res << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    ll N;
    cin >> N;
    if (N <= 9) {
        cout << 0 << endl;
    } else {
        ll N2 = N;
        ll total = 0;
        while (N2 > 0) {
            total += N2 / 5;
            N2 /= 5;
        }
        ll tens = 0;
        N2 = N;
        while (N2 > 0) {
            tens += N2 / 10;
            N2 /= 5;
        }
        // cout << tens << endl << total << endl;
        // cout << total/2 << endl;
        if (N % 2 == 0) {
            cout << tens << endl;
        } else {
            cout << 0 << endl;
        }
    }
    return 0;
}




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

int main(){
	int n,k;
	cin >> n >> k;
	vector<int> a(200001,0);
	bool flag[200001] = {};

	int buf;
	for(int i = 0; i < n; ++i){
		cin >> buf;
		a[buf]++;
		flag[buf] = true;
	}

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

	int count = 0;
	for(; a[count] == 0; ++count){}
	a.erase(a.begin(),a.begin() + count);

	int var = 0;
	for(int i = 0; i < 200001; ++i){
		if(flag[i]){
			var++;
		}
	}

	int out = 0;
	for(int i = 0; i < var - k; ++i){
		out += a[i];
	}

	cout << out << endl;

	return 0;
}


Measured memory_bytes: 1280
#include<stdio.h>


int main()
{
  int cnt;
  int n[4];
  int f[10] = {0,};
  int i;

  cnt = scanf("%d %d %d %d", &n[0], &n[1], &n[2], &n[3]);

  for (i=0; i<4; i++){
    f[n[i]] = 1;
  }

  if (f[1] && f[9] && f[7] && f[4]) {
    printf ("YES");
  } else {
    printf ("NO");
  }
  
  return 0;
}

Measured memory_bytes: 128
import sys 
 
S = int(sys.stdin.readline().strip())
mod = 10**9 + 7

fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

for i in range(2, 2*S+1):
    fact.append((fact[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod // i)) % mod)
    factinv.append((factinv[-1] * inv[-1]) % mod)

def nCr(n, r, mod=10**9+7):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % mod

ans = 0
n = 1
n_max = S // 3
while n <= n_max:
    res = S - 3 * n
    tmp = nCr(res + n - 1, n - 1)
    # print(n, res, tmp)
    ans += tmp
    ans %= mod
    n += 1

print(ans)

Measured memory_bytes: 65868
#include <cmath>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <numeric>
#include <map>   
#include <stdio.h>

#define FOR(i,a,b) for(i=(a);i<(b);++i) 
#define FORR(i,a,b) for(i=(a);i>(b);--i)
#define REP(i,n) for(i=0;i<(n);++i)
#define REPR(i,n) for(i=(n);i>0;--i)
#define PB push_back
#define ll long long
#define INT_MAX 2147483647
#define LL_MAX 9223372036854775807
#define sortR(a,b) sort(a, b, greater<int>())

using namespace std;

	long long GCD(long long a, long long b) {
		if (a < b)
			swap(a, b);
		if (b == 0) return a;
		else return GCD(b, a % b);
	}
	bool sosuu_check(int num) {
		int i;
		for (i = 2; i <= sqrt(num); ++i) {
			if (num%i == 0)
				return false;
		}
		return (num < 2) ? false : true;
	}



int main() {
	int A,B;
	cin >> A>>B;
	if (B%A == 0)
		cout << A + B << endl;
	else
		cout << B - A << endl;
}

Measured memory_bytes: 256
#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[i];a[i]-=i+1;}
	sort(a.begin(),a.end());
	int mid=(a[(n-1)/2]+a[n/2])/2;
	long long ret=0;
	for(int i=0;i<n;i++)ret+=abs(a[i]-mid);
	cout<<ret<<endl;
	return 0;
}

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

int main(int argc, char const *argv[]) {
  string str;
  int ans[26] = {0};

  while (getline(cin, str)) {
    for (int i = 0; i < str.size(); i++) {
      if ('a' <= str[i] && str[i] <= 'z') {
        ans[str[i] - 'a']++;
      } else if ('A' <= str[i] && str[i] <= 'Z') {
        ans[str[i] - 'A']++;
      }
    }
  }
  for (int i = 0; i < 26; i++) {
    cout << (char)('a' + i) << " : " << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 3180
N = int(input())
A = list(map(int, input().split()))
A.sort()
maxv1 = A[-1]
maxv2 = A[-2]
if maxv1 != maxv2:
    print("Impossible")
    exit()

K = maxv1
if K % 2 == 0:
    for i in range(K // 2):
        for j in range(2):
            if K - i in A:
                A.remove(K - i)
            else:
                print("Impossible")
                exit()
    if K // 2 in A:
        A.remove(K // 2)
    else:
        print("Impossible")
        exit()
else:
    for i in range(K // 2 + 1):
        for j in range(2):
            if K - i in A:
                A.remove(K - i)
            else:
                print("Impossible")
                exit()
if len(A) == 0:
    print("Possible")
    exit()
else:
    for a in A:
        if K % 2 == 0:
            if a < K // 2 + 1:
                print("Impossible")
                exit()
        else:
            if a < (K + 1) // 2 + 1:
                print("Impossible")
                exit()
    print("Possible")


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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
int main() {
  int n,k;cin>>n>>k;
  cout << (n%k==0?0:1) << endl;
}


Measured memory_bytes: 256
import java.util.*;


public class Main {
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		boolean X = true;
		for(int i = 0; i < N; i++) {
			int A = sc.nextInt();
			if(A % 2 == 0 && A % 3 != 0 && A % 5 != 0) {
				X = false;
				break;
			}
		}
		if(X == true) {
			System.out.println("APPROVED");
		}
		else {
			System.out.println("DENIED");
		}
	}
}

Measured memory_bytes: 23124
#include <iostream>
#include <complex>
#include <utility>
#include <algorithm>
using namespace std;

typedef complex<double> Point, Vector;
typedef pair<Point, Point> Segment, Line;

#define X real()
#define Y imag()
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

double dot(Vector a, Vector b){
    return a.X * b.X + a.Y * b.Y;
}

double cross(Vector a, Vector b){
    return a.X * b.Y - a.Y * b.X;
}

double norm(Vector a){
    return a.X * a.X + a.Y * a.Y;
}

double abs(Vector a){
    return sqrt(norm(a));
}

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;

int ccw(Point p0, Point p1, Point p2){
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    if(cross(a, b) > EPS) return COUNTER_CLOCKWISE;
    if(cross(a, b) < -EPS) return CLOCKWISE;
    if(dot(a, b) < -EPS) return ONLINE_BACK;
    if(norm(a) < norm(b)) return ONLINE_FRONT;

    return ON_SEGMENT;
}

// 線分の交差判定
bool intersect(Point p1, Point p2, Point p3, Point p4){
    return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 && ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0);
}

bool intersect(Segment s1, Segment s2){
    return intersect(s1.first, s1.second, s2.first, s2.second);
}

double getDistanceLP(Line l, Point p){
    return abs(cross(l.second - l.first, p - l.first) / abs(l.first - l.second));
}

double getDistanceSP(Segment s, Point p){
    if(dot(s.second - s.first, p - s.first) < 0.0) return abs(p - s.first);
    if(dot(s.first - s.second, p - s.second) < 0.0) return abs(p - s.second);
    return getDistanceLP(s, p);
}

double getDistanceSS(Segment s1, Segment s2){
    if(intersect(s1, s2)) return 0.0;
    return min({getDistanceSP(s1, s2.first), getDistanceSP(s1, s2.second), getDistanceSP(s2, s1.first), getDistanceSP(s2, s1.second)});
}

int main(){
    int q; cin>>q;
    while(q--){
        double x0, y0, x1, y1, x2, y2, x3, y3;
        cin>>x0>>y0>>x1>>y1>>x2>>y2>>x3>>y3;
        Segment s1 = {Point(x0, y0), Point(x1, y1)};
        Segment s2 = {Point(x2, y2), Point(x3, y3)};
        
        printf("%.10f\n", getDistanceSS(s1, s2));
    }
}


Measured memory_bytes: 3204
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    if (A > B) {
      System.out.println(A * 2 - 1);
    } else if (A < B) {
      System.out.println(B * 2 - 1);
    } else {
      System.out.println(A + B);
    }
  }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N; cin >> N;
    map<int,int> MA, MB;
    vector<int> A(N), B(N);
    rep(i,N) {
        cin >> A[i];
        MA[A[i]]++;
    }
    rep(i,N) {
        cin >> B[i];
        MB[B[i]]++;
    }
    for (auto [k,v] : MA) {
        if (MB.count(k) > 0) {
            if (N - MB[k] < v) {
                cout << "No" << endl;
                return 0;
            } 
        }
    }

    for (auto [k,v] : MB) {
        if (MA.count(k) > 0) {
            if (N - MA[k] < v) {
                cout << "No" << endl;
                return 0;
            } 
        }
    }

    int j = 0;
    reverse(B.begin(), B.end());
    rep(i,N) {
        if (A[i] == B[i]) {
            while(A[j] == B[i] || B[j] == B[i]) j++;
            swap(B[j], B[i]);
        }
    }


    cout << "Yes" << endl;
    rep(i,N) {
        if (i) cout << " ";
        cout << B[i];
    }
    cout << endl;
}


Measured memory_bytes: 23420
mod = 10**9+7
MAX_N = 10 ** 6
fact = [1]
fact_inv = [0] * (MAX_N + 4)
for i in range(MAX_N + 3):
  fact.append(fact[-1] * (i + 1) % mod)
fact_inv[-1] = pow(fact[-1], mod - 2, mod)
for i in range(MAX_N + 2, -1, -1):
  fact_inv[i] = fact_inv[i + 1] * (i + 1) % mod
def mod_comb_k(n, k, mod):
  return fact[n] * fact_inv[k] % mod * fact_inv[n - k] % mod
x,y=map(int,input().split())
if (2*x-y)>=0 and (2*y-x)>=0 and (x+y)%3==0:
  print(mod_comb_k((x+y)//3,(2*y-x)//3,mod))
else:print(0)

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

double a[50 + 5];

int main() { // claudio van
  int n; scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%lf", &a[i]);
  }
  sort(a, a + n);
  double mx = a[0];
  for (int i = 1; i < n; ++i) {
    mx = (mx + a[i]) / 2;
  }
  printf("%.10lf\n", mx);
  return 0;
}

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

vector<vector<int>> graph(111111);
vector<int> color(111111,0);
vector<int> color_of_parent(111111,0);
map<pair<int,int>,int> edge;
vector<bool> visited(111111,false);

void BFS(int x){
	queue<int> que;
	que.push(x);
	visited[x]=true;
	while(!que.empty()){
		int f=que.front();
		que.pop();
		int c=1;
		for(auto t:graph[f]){
			if(visited[t])continue;
			if(color_of_parent[f]==c)c++;
			color[edge[make_pair(f,t)]]=color_of_parent[t]=c;
			c++;
			visited[t]=true;
			que.push(t);
		}
	}
}

int main(){
	int N;
	cin >> N;
	for(int i=0;i<N-1;i++){
		int a,b;
		cin >> a >> b;
		a--;
		b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
		edge.insert(make_pair(make_pair(a,b),i));
		edge.insert(make_pair(make_pair(b,a),i));
	}
	
	int m=0,mi;
	for(int i=0;i<N;i++){
		if(graph[i].size()>m){
			m=graph[i].size();
			mi=i;
		}
	}
	
	BFS(mi);
	
	cout << *max_element(color.begin(),color.end()) << endl;
	for(int i=0;i<N-1;i++)cout << color[i] << endl;
	return 0;
}

Measured memory_bytes: 19712
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
using P = pair<ll, ll>;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const ll INF = 1LL << 62;
const int inf = 1<<30;
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; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, pair<T,T> const&P){
    os << P.first;
    os << " ";
    os << P.second;
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
     os<<endl;
    return os;
}
vector<pair<int,int>> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)};
//fixed<<setprecision(10)<<ans<<endl;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,H;
    cin >> N >> H;
    vi A(N),B(N);
    REP(i,N){
        cin >> A[i] >> B[i];
    }
    sort(ALL(A));
    sort(ALL(B));
    int idx = N-1;

    int ans=0;
    while(idx>=0 && H>0){
        if (B[idx]>A.back()) H-=B[idx];
        else break;
        ans++;
        idx--;
    }
    if(H>0) ans+=ceil((double)H/A.back());

    cout << ans << endl;
}

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

const int s=1001;

using namespace std;

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

	int q;
	static unsigned int dp[s][s] = {0};
	
	dp[0][0] = 0; dp[0][1] = 0; dp[1][0] = 0;

	cin >> q;
	for(int k=0; k < q; k++){
		string X,Y;
		cin >> X >> Y;
		int i,j;
		for(i=0;i<X.size();i++){
			for(j=0;j<Y.size();j++){
				if(X[i] == Y[j]) dp[i+1][j+1] = dp[i][j] + 1;
				else dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j]);
			}
		}
		cout << dp[i][j] << "\n";
	}
	return 0;
}


Measured memory_bytes: 7016
def main():
    # 下、右、上、左
    dyx = [(1, 0), (0, 1), (-1, 0), (0, -1)]
    H, W = map(int, input().split())
    s = ["." * (W + 2)]
    s.extend(["." + input() + "." for i in range(H)])
    s.append("." * (W + 2))
    for y in range(1, H + 1):
        for x in range(1, W + 1):
            if "." == s[y][x]:
                continue
            for dy, dx in dyx:
                if "#" == s[y + dy][x + dx]:
                    break
            else:
                print("No")
                return
    print("Yes")
    return


main()


Measured memory_bytes: 3064
import scala.io.StdIn

object Main extends App {

  val s = StdIn.readLine()
  val sc = s.tail.slice(1, s.length - 2)
  val rep = s.tail.replace("C", "")
  val r = (s.head == 'A' &&
    sc.count(c => c == 'C') == 1 &&
    rep.forall(c => 'a' <= c && c <= 'z'))


  println(if (r) "AC" else "WA")
}


Measured memory_bytes: 25420
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <array>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <utility>
#include <iomanip>
#include <numeric>
#include <climits>
#include <algorithm>
#include <cstdint>
using namespace std;

int main()
{
    int h, n;
    cin >> h >> n;

    vector<int> niz(n);
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        niz[i] = x;
    }
    for (auto x : niz)
    {
        h -= x;
        if (h <= 0)
        {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
}

Measured memory_bytes: 3776
n,k,*l=map(int,open(0).read().split())
for _ in range(min(k,41)):
  s=[0]*-~n
  for i in range(n):
    s[max(i-l[i],0)]+=1
    s[min(i+l[i]+1,n)]-=1
  for i in range(n): s[i+1]+=s[i]
  l=s
print(*l[:n])

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

namespace ConsoleApp44 {
    class Program {
        static void Main(string[] args) {
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            int h = int.Parse(Console.ReadLine());

            Console.WriteLine((a + b) * h / 2);

        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n,k;
	int *h;
	long long int sum = 0;
	cin >> n >> k;
	h = new int[n];
	for(int i = 0;i < n;i++){
		cin >> h[i];
	}
	sort(h,h + n);
	for(int i = 0;i < n - k;i++){
		sum += h[i];
	}
	cout << sum;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

int main()
{
  long long N,W,ans=0,w1;
  cin>>N>>W;
  vector <long long> v1,v2,v3,v4;
  for(int i=0;i<N;i++){
    long long wtmp,vtmp;
    cin>>wtmp>>vtmp;
    if(i==0){
      w1=wtmp;
      v1.push_back(vtmp);
    }else{
      if(wtmp==w1){
        v1.push_back(vtmp);
      }
      if(wtmp==w1+1){
        v2.push_back(vtmp);
      }
      if(wtmp==w1+2){
        v3.push_back(vtmp);
      }
      if(wtmp==w1+3){
        v4.push_back(vtmp);
      }
    }
  }
  sort(v1.rbegin(),v1.rend());
  sort(v2.rbegin(),v2.rend());
  sort(v3.rbegin(),v3.rend());
  sort(v4.rbegin(),v4.rend());
  for(int i=0;i<=min(W/w1,(long long)v1.size());i++){
    for(int j=0;j<=min((W-w1*i)/(w1+1),(long long)v2.size());j++){
      for(int k=0;k<=min((W-w1*i-(w1+1)*j)/(w1+2),(long long)v3.size());k++){
        long long tmp=0;
        for(int l=0;l<i;l++){
          tmp+=v1[l];
        }
        for(int l=0;l<j;l++){
          tmp+=v2[l];
        }
        for(int l=0;l<k;l++){
          tmp+=v3[l];
        }
        for(int l=0;l<min((W-w1*i-(w1+1)*j-(w1+2)*k)/(w1+3),(long long)v4.size());l++){
          tmp+=v4[l];
        }
        ans=max(ans,tmp);
      }
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    bool isok = false;
    for(int i=1; i<100000; i++){
        if(a*i % b == c){
            isok = true;
            break;
        }
    }
    if(isok){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import math
# 町kと町jとの距離を算出する関数
def distance(k,j):
    return math.sqrt((x[k]-x[j])**2 + (y[k]-y[j])**2)

x,y=[],[]
N = int(input())
for i in range(N):
    a, b = map(int, input().split())
    x.append(a)
    y.append(b)

sum = 0.00
for k in range(N):
    for j in range(N):
        if k != j:
            sum += distance(k,j)
print(sum/N)

Measured memory_bytes: 3064
#include <iostream>	//cin, cout
#include <vector>	//vector
#include <algorithm> //sort,min,max
#include <string>	//string
#include <ios>		//fixed
#include <iomanip>	//setprecision
#include <utility> //swap
#include <cstdlib>	//abs(int)
#include <cmath>	//sqrt
#include <sstream>	//stringstream,getline
#include <cmath>	//ceil

using namespace std;

int main() {

	int x;

	for (int i = 1; i <= 5; i++) {
		cin >> x;
		if (x == 0) {
			cout << i << endl;
		}
	}

	return 0;

}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
#define double long double
using namespace std;
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vl>;
using vs=vector<string>;
using vd=vector<double>;
using vvd=vector<vd>;
using vb=vector<bool>;
using pll=pair<ll,ll>;
#define all(a) a.begin(),a.end()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(ll i=(a);i<n;i++)
#define LINF ((ll)1ll<<60)
#define fcout(a) cout<<setprecision(a)<<fixed
#define EPS (1e-10)

int sgn(const double&r){return (r>EPS)-(r<-EPS);}
int sgn(const double&a, const double&b){return sgn(a-b);}


int main(){
    int n,m,k;
    cin>>n>>m>>k;
    vl d(m);
    vb isdark(n,false);
    map<ll,ll> assm;
    rep(i,m){cin>>d[i];d[i]--;isdark[d[i]]=true;assm[d[i]]=i;}

    vvl v(n,vl(k));
    rep(i,n)rep(j,k){cin>>v[i][j];v[i][j]--;}
    vb memo(1<<m, false);
    queue<pll> q;
    q.emplace((1<<m)-1, 0);
    while(!q.empty()){
        ll s,c;
        tie(s,c)=q.front();
        q.pop();
        if(memo[s])continue;
        memo[s]=true;
        rep(i,k){
            ll nxt=0;
            rep(j,m){
                if( s & (1<<j)){
                    if(isdark[v[d[j]][i]]){
                        nxt|=(1<<(assm[v[d[j]][i]]));
                    }
                }
            }
            if(!nxt){
                cout<<c+1<<endl;
                return 0;
            }
            if(memo[nxt])continue;
            q.emplace(nxt, c+1);
        }
    }
}


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

#define IOS             ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define watch(x);       cout << "\n" <<  #x << " is: " << x << "\n";
#define ll              long long int
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define pb              push_back
#define nl              cout<<"\n"
#define gcd(a,b)        __gcd(a,b)
#define sq(a)           (a)*(a)
#define loop(i,a,b)     for (ll i = a; i <= b; i++)
#define rloop(i,a,b)    for (int i = a; i >= b; i--)
#define sz(a)           a.size()
#define mod             1000000007
#define PI              2*acos(0.0)


int main()
{
    IOS
    int T=1;
    //cin>>T;
    while(T--)
    {
        ll n,k;
        cin>>n>>k;
        ll ans=0;
        for(ll i=k;i<=n+1;i++)
        {
            ll mn=(i-1)*i/2;
            ll mx=(2*n-i+1)*i/2;
            ans+=mx-mn+1;
            ans%=mod;
        }
        cout<<ans;

    }
    return 0;
}


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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i,N) for(int i=0; i<N; i++)
#define cinv(v,N) vector<int> v(N); for(int i=0; i<N; i++){ cin >> v[i]; }
#define mt make_tuple
const ll MOD2 = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
  //input
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int N; cin >> N;
  string S; cin >> S;
  
  //main
  set<int> st1,st2,st3;
  for(int i=0; i<N; i++){ 
    //cout << S[i]-'0' << endl;
    for(auto tmp : st2){
      st3.insert(tmp*10+(S[i]-'0')); 
    }
    for(auto tmp : st1){
      st2.insert(tmp*10+(S[i]-'0')); 
    }
    st1.insert(S[i]-'0');
  }
  
  // output
  cout << st3.size() << endl;

  return 0;
}

Measured memory_bytes: 512
/*ex6_2
    takafumi_ueki*/
#include <stdio.h>
#include <string.h>
#define LIMIT 101
int main(void){
    int i;
    char str[LIMIT];
    //文字列を受け取る
    scanf("%s",str);
    //最初の文字、挟まれている文字数(文字列の文字数-2)、最後の文字((文字列の文字数-1)番目の文字)を出力する
    printf("%c%d%c\n",str[0],(int)strlen(str)-2,str[(int)strlen(str)-1]);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int H, W;
int cnt[26] = {};

int main() {
	cin >> H >> W;
	REP(i, H) {
		string S;
		cin >> S;
		REP(j, S.size()) cnt[S[j] - 'a']++;
	}
	
	int cnto = 0, cnt4 = 0;
	REP(i, 26) {
		if (cnt[i] & 1) { cnto++; cnt[i]--; }
		cnt4 += cnt[i] / 4;
	}
	
	bool ans = true;
	
	if (H % 2 == 1 && W % 2 == 1) {
		if (cnto > 1) ans = false;
		int dif = cnt4 - (H-1)*(W-1)/4;
		if (dif < 0) ans = false;
	}
	else {
		if (H % 2 == 1) swap(H, W);
		if (cnto > 0) ans = false;
		
		int dif = cnt4;
		if (W % 2 == 1) dif -= H*(W-1)/4;
		else dif -= H*W/4;
		
		if (dif < 0) ans = false;
	}
	
	puts(ans ? "Yes" : "No");
	
	return 0;
}


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

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

    string ans;
    if (s[0] == s[1] and s[1] == s[2]){
        ans = "No";
    }
    else{
        ans = "Yes";
    }

    cout << ans << endl;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x"=" << x <<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3

#define MAX_N 1000000001
#define MOD 1000000007

void factrial();
ll factInv(ll);

ll fact[200001];

int main(){
	cin.sync_with_stdio(false);
	ll h, w, a, b;
	cin >> h >> w >> a >> b;

	factrial();

	ll all = fact[h + w - 2] * factInv(fact[w - 1] * fact[h - 1]) % MOD;
	ll out = 0;
	rep(i, b) {
		out = (out + (((fact[h - a - 1 + i] * factInv(fact[h - a - 1] * fact[i])) % MOD)
			* ((fact[a + w - i - 2] * factInv(fact[a - 1] * fact[w - i - 1])) % MOD))) % MOD;
	}
	ll ans = (all - out) % MOD;
	if (ans < 0) ans = MOD + ans;

	cout << ans << endl;

	return 0;
}

void factrial(){
	fact[0] = 1;
	fact[1] = 1;
	repl(i, 2, 200001) {
		fact[i] = fact[i - 1] * i % MOD;
	}
}

ll factInv(ll x){
	x %= MOD;
	ll res = 1;
	ll n = MOD - 2;
	while (n > 0) {
		if (n & 1) res = res * x % MOD;
		x = x * x % MOD;
		n >>= 1;
	}
	return res;
}

Measured memory_bytes: 1792
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
//10の1/2乗（ルート）pow(10, 0.5)
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#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 < (int)(n); i++)
int main(){
  int n,s;
  cin >> n >> s;
  for(int x=0;x<=n;x++){
    for(int y=0;x+y<=n;y++){
      int z = n - x - y;
      if(0 <= z && z <=n){
        if(10000*x+5000*y+1000*z == s){
        cout<< x <<" " << y <<" "<< z <<endl;
        return 0;
        }
      }
    }
  }
  cout << "-1"<< " " <<"-1"<< " "<<"-1"<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    vector<char> c(4); for(int i = 0; i < 4; i++) cin >> c[i];

    int d[] = {0, 0, 0, 1, 1, 2};
    int e[]  ={1, 2, 3, 2, 3, 3};
    int f[]  ={2, 1, 1, 3, 2, 1};
    int g[]  ={3, 3, 2, 0, 0, 0};

    bool flag = false;
    for(int i  = 0; i < 6; i++) {
        if(c[d[i]] == c[e[i]] && c[f[i]] == c[g[i]]) flag = true;
    }

    if(c[0] == c[1] && c[1] == c[2] && c[2] == c[3]) {
        cout << "No" << endl;
        return 0;
    }

    cout << (flag ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()

import string
alf = string.ascii_uppercase

ans =''
for i in s:
    #print(i)
    for index,j in enumerate(alf):
        #print(j)
        if i == j:
            num = (index+n)%26
            ans += alf[num]

print(ans)

Measured memory_bytes: 4084
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<queue>
#include<stack>
#include<algorithm>
#include<vector>
int s=0;
using namespace std;
inline int ggg(int x,int y)
{
	return y?ggg(y,x%y):x;
}
inline int gcd(int x,int y,int z)
{
	return ggg(ggg(x,y),z);
}
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			for(int k=1;k<=n;k++)
				s+=gcd(i,j,k);
	cout<<s;
}




Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf pop_front()
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define inf 100000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define vll vector<lli>
#define eps 0.000001
#define endl '\n'
#define mo 998244353
 
using namespace std ;

const lli MAXN = 100005 ;

typedef tree<lli,null_type,less<lli>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

bool cmp(pair<pair<string,lli>,lli> p1 , pair<pair<string,lli>,lli> p2)
{
    if(p1.ff.ff < p2.ff.ff)
        return true;

    else if(p1.ff.ff > p2.ff.ff)
        return false;

    else
    {
        if(p1.ff.ss > p2.ff.ss) return true;
        else return false;
    }
}

int main()
{  
 
//////////////////////////////////////////////
    fastio;
//////////////////////////////////////////////

    lli n;
    cin>>n;

    pair<pair<string,lli>,lli> p[n+1];

    loopl(i,1,n+1)
    {
        cin>>p[i].ff.ff>>p[i].ff.ss;
        p[i].ss = i;
    }

    sort(p+1,p+n+1,cmp);

    loopl(i,1,n+1)
    cout<<p[i].ss<<endl;


}

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

int main(){
	int a,b;
	cin >> a >> b;
	
	int res = 0;

	rep(i,2){
		if(a>b){
			res += a;
			a--;
		}
		else{
			res += b;
			b--;
		}
	}
	
	cout << res << endl;

	return 0;
}

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

#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define debug(x) cerr << #x << " = " << x << endl;
#define SET(c, v) memset(c, v, sizeof c)
#define pi 3.14159265358979323846264338
#define all(S) (S).begin(), (S).end()
#define INF 0x3f3f3f3f
#define mod 1000000007
#define pf push_front
#define pb push_back
#define mk make_pair
#define MAX 3010
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
typedef unsigned long long int ull;
double v[MAX], pd[MAX][MAX];
int N;

double solve(int m) {
	REP(i, 0, N) REP(j, 0, N) pd[i][j] = 1.0;
	REP(i, 1, N) {
		REP(j, 0, m) {
			pd[i][j] = pd[i-1][j] * v[i];
			if(j > 0) pd[i][j] += pd[i-1][j-1] * (1.0 - v[i]);
		}
	}
	return pd[N][m];
}

int main(int argc, char** argv) {
	scanf("%d", &N);
	REP(i, 1, N) scanf("%lf", &v[i]);
	printf("%.10lf\n", solve(N/2));
	return 0;
}


Measured memory_bytes: 70784
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
using namespace std;
// using namespace _gnu_pbds;
#define vb __int128
#define ll long long
#define ld long double
#define full(a) a.begin(),a.end()
#define fr(i,a,b) for(ll i = a ; i < b ; i++)
#define stoink stack<ll>
#define quu queue<ll>
#define quee queue<pair<ll,ll>>
#define vec vector <ll>
#define vg vector<vector<ll> >
#define eg vector<pair<ll,ll>>
#define vgw vector<vector<pair<ll,ll> > >
#define pa pair<ll,ll>
#define pb push_back
#define ff first
#define ss second
#define pre 0.00000000000000000001
#define inf 100000000000000000
#define mod (ll)(1e9 + 7)
#define endl '\n'
int main()
{	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    ll n;
    cin >> n;
    vec dp(1 << n);
    ll mask = 0;
    ll arr[30][30];
    fr(i,0,n) fr(j,0,n) cin >> arr[i][j];
    dp[0] = 1;
    for(mask = 0 ; mask < ((1 << n) - 1) ; mask++) {
        ll cnt = __builtin_popcount(mask);
        fr(i,0,n) {
            if(arr[cnt][i] == 0 || (1 << i) & mask)
                continue;
            dp[mask | 1 << i] = (dp[mask | 1 << i] + dp[mask]) % mod;
        }
    }
    cout << dp[(1 << n) - 1];
	return 0;
}

Measured memory_bytes: 19576