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

inline void upmax(short &x,const short &y){if(y>x) x=y;}

const int N=105;
short f[N][N][N][N];
short sum1[N][N],sum2[N][N];
int n,m,tx,ty;

void gao()
{
    int limu=tx-1,limd=n-tx,liml=ty-1,limr=m-ty;
    for(int u=0;u<=limu;u++)
        for(int d=0;d<=limd;d++)
            for(int l=0;l<=liml;l++)
                for(int r=0;r<=limr;r++)
                {
                    int L=max(ty-l,r+1),R=min(ty+r,m-l);
                    if(L<=R)
                    {
                        upmax(f[u+1][d][l][r],f[u][d][l][r]+(tx-u-1>=d+1?sum1[tx-u-1][R]-sum1[tx-u-1][L-1]:0));
                        upmax(f[u][d+1][l][r],f[u][d][l][r]+(tx+d+1<=n-u?sum1[tx+d+1][R]-sum1[tx+d+1][L-1]:0));
                    }
                    L=max(tx-u,d+1),R=min(tx+d,n-u);
                    if(L<=R)
                    {
                        upmax(f[u][d][l+1][r],f[u][d][l][r]+(ty-l-1>=r+1?sum2[R][ty-l-1]-sum2[L-1][ty-l-1]:0));
                        upmax(f[u][d][l][r+1],f[u][d][l][r]+(ty+r+1<=m-l?sum2[R][ty+r+1]-sum2[L-1][ty+r+1]:0));
                    }
                }
    printf("%d\n",f[limu][limd][liml][limr]);
}

int main()
{
    static char s[105];
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
    {
        scanf("%s",s+1);
        for(int j=1;j<=m;j++)
        {
            if(s[j]=='E') tx=i,ty=j;
            sum1[i][j]=sum1[i][j-1]+(s[j]=='o');
            sum2[i][j]=sum2[i-1][j]+(s[j]=='o');
        }
    }
    gao();
}

Measured memory_bytes: 207232
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N,K;
LL V[50];
 
LL ans = 0;

void solve(){
	//まず取り出して、その後に詰めることを考える
	for(int left=0;left<=N;left++){//左からleft個取る
		for(int right=0;right<=N-left;right++){//右からright個とる
			if(left+right>K) continue;
			LL sum = 0;//とった価値の合計
			priority_queue<LL> low_gem;//とった宝石を価値の低いものほど優先度が高くなるよう格納
			for(int l=0;l<left;l++){
				sum += V[l];
				low_gem.push(-V[l]);
			}
			for(int r=0;r<right;r++){
				sum += V[N-1-r];
				low_gem.push(-V[N-1-r]);
			}
			//すでに(left+right)回取り出しているので
			//宝石を詰める操作はK-(left+right)回できる
			for(int i=0;i<K-(left+right);i++){
				if(low_gem.empty() || low_gem.top()<=0) break;
				sum += low_gem.top();low_gem.pop();
			}
			ans = max(ans,sum);
		}
	}
}

int main(){
    cin >> N >> K;
    for(int i=0;i<N;i++) cin >> V[i];
 
    solve();
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MOD = pow(10, 9) + 7;
using ll = long long;

int main(){
    ll n;
    ll ans = 0;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i]; 
    }
    
    vector<ll> sum(n);
    ll pre = 0;
    for(int i = 0; i < n; i++){
        sum[i] = (pre%MOD + a[i]%MOD)%MOD;
        pre = sum[i];
    }
    for(int i = 0; i < n - 1; i++){
        ans += (sum[i] * a[i + 1]%MOD)%MOD;
        ans %= MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 6364
import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		String t=sc.next();
		char[] s1=s.toCharArray();
		char[] t1=t.toCharArray();
		int cnt=0;
		for(int i=0;i<s1.length;i++)
		{
			if(s1[i]!=t1[i])
			{
				cnt++;
			}
		}
		System.out.println(cnt);
		sc.close();
	}
}


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

//#define int long long
#define fi first
#define se second
#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 rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if ((a+b+c>=22) ? cout<<"bust"<<endl : cout<<"win"<<endl) ;
}

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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_N 100000

int par[MAX_N]; // 親
int depth[MAX_N]; // 木の深さ

struct UnionFind {
    vector<int> par;
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    // 木の根を求める
    int root(int x) {
        if(par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    // xとyの属する集合を併合
    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if(x == y) return;

        if(par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;

    }

    // xとyが同じ集合に属するか否か
    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int size(int x) {
        return -par[root(x)];
    }
};

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

    int N, M;
    cin >> N >> M;
    UnionFind uf(N + M);
    rep(i, 0, N) {
        int K;
        cin >> K;
        rep(j, 0, K) {
            int l;
            cin >> l;
            l += (N - 1);
            if(!uf.same(i, l)) uf.unite(i, l);
        }
    }

    rep(i, 0, N - 1) {
        if(!uf.same(i, i + 1)) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;


}


Measured memory_bytes: 1024
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    token.parse().ok().unwrap()
}

fn main() {
    let a = input::<i64>();
    let b = input::<i64>();
    let c = input::<i64>();

    let ans = if (a < c && c < b) || (b < c && c < a) {
        "Yes"
    } else {
        "No"
    };
    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.Scanner;

class Main {

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

		int n = sc.nextInt();
		int[] a = new int[n];

		for(int i = 0; i < a.length; i++){
			a[i] =sc.nextInt();
		}

		int[] b = new int[n];

		boolean isTop = true;
		int topCnt = 0;
		int tailCnt = n - 1;
		for(int i = n - 1; i >= 0 ; i--){
			if(isTop){
				b[topCnt++] = a[i];
				isTop = false;
			}else{
				b[tailCnt--] = a[i];
				isTop = true;
			}
		}

		for(int i = 0; i < n - 1; i++){
			System.out.print(b[i] + " ");	
		}
		System.out.print(b[n - 1]);			
	}

}


Measured memory_bytes: 92836
def main():
    s = input()
    t = input()

    ok = True
    dic = {}
    dic2 = {}
    for i in range(len(s)):
        if t[i] in dic:
            if dic[t[i]] != s[i]:
                ok = False
                break
        else:
            dic[t[i]] = s[i]
        if s[i] in dic2:
            if dic2[s[i]] != t[i]:
                ok = False
                break
        else:
            dic2[s[i]] = t[i]
    if ok:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

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

struct str {
    string s;
    int counts;
};

vector<vector<str>> anss(11, vector<str>());

void f(int n) {
    vector<string> als = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j"};
    for (auto e : anss[n - 1]) {
        string s = e.s;
        int c    = e.counts;
        for (int i = 0; i <= c + 1; i++) {
            anss[n].push_back({s + als[i], max(c, i)});
        }
    }
}

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

    anss[0].push_back({"", -1});
    for (int i = 1; i <= N; i++)
        f(i);
    vector<string> ans;
    for (auto e : anss[N])
        ans.push_back(e.s);
    sort(all(ans));
    for (auto e : ans)
        cout << e << endl;
}

Measured memory_bytes: 12656
n,k=map(int,input().split())
# 1以上k以下の整数がn個
mod=int(1e+9 + 7)
d=[0]*(k+1)
ans=0
for i in range(k,0,-1):
      m=k//i
      d[i]=pow(m,n, mod) 
      d[i]-=sum([d[j*i]for j in range(2,m+1)])
      ans+=(d[i]*i)%mod
print((ans)%mod)
#print(d)



Measured memory_bytes: 80832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=(ll)(1e9+7);
ll run();
int main() {
#ifdef home
    freopen("i", "r", stdin);
    freopen("d", "w", stderr);
#endif
    cout.precision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    run();
    return 0;
}
const ll inf = (1e18+5);

void max_self(int &a, int b){
    a= max(a,b);
}

void min_self(ll &a, ll b){
    a=min(a,b);
}

int a[3005];
ll dp[3005][3005];

ll f(int i, int j){
    if(j==i)
        return a[i];
    if((j-i)==1)
        return max(a[i],a[j]);
    if(dp[i][j]!=-1)
        return dp[i][j];
    return dp[i][j]=max(a[i]+min(f(i+2,j),f(i+1,j-1)), a[j] + min(f(i+1,j-1),f(i,j-2)));
}

ll run() {
    int n;
    cin>>n;
    ll sum =0;
    for(int i=1;i<=n;i++) {
        cin >> a[i];
        sum+=a[i];
    }
    memset(dp,-1,sizeof(dp));

    ll ans = f(1,n);
    ans=ans-(sum-ans);
    cout<<ans;
}


Measured memory_bytes: 70912
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n);i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
  ll x,y;
  cin >> x >> y;
  int ans = 1;
  y /= x;

  while(y!=1){
    y /= 2;
    ans++;
  }
  cout << ans << endl;
}

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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int N = S.Length - 1;
		if(S.Length == 1){
			Console.WriteLine(S);
			return;
		}
		
		long sum = 0;
		for(int i=0;i<(1<<N);i++){
			sum += cal(i);
		}
		Console.WriteLine(sum);
		
		
	}
	
	long cal(int t){
		List<char> L = new List<char>();
		int n = S.Length;
		L.Add(S[0]);
		for(int k=1;k<n;k++){
			if( (t & (1<<(k-1)))>0){
				L.Add(',');
			}
			L.Add(S[k]);
		}
//Console.WriteLine(new String(L.ToArray()));
		var ss = new String(L.ToArray()).Split(',').Select(str => long.Parse(str));
		
		return ss.Sum();
	}
	
	
	
	
	String S;
	public Sol(){
		S = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 3416
#include <iostream>
#include <algorithm>
#define int long long
using namespace std;

int n;
int a[100000];

signed main() {
	int i;
	
	cin >> n;
	for (i = 0; i < n; i++) cin >> a[i];
	sort(a, a + n);
	
	int asum = 0, ngMax = -1;
	for (i = 0; i < n - 1; i++) {
		asum += a[i];
		if (asum * 2 < a[i + 1]) ngMax = i;
	}
	cout << n - ngMax - 1 << endl;
	return 0;
}

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

long long x;

long long f(long long n){
  if(n==-1) return 0;
  else if(n>=0) return n/x+1;
}

int main(){
  
  long long a, b, cnt=0;

  cin>>a>>b>>x;

  cout<<f(b)-f(a-1)<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int main() {
    int n; cin >> n;
    int k; cin >> k;
    int sum = 0;
    rep(i, n) {
        int x; cin >> x;
        sum += min(x, abs(x - k)) * 2;
    }
    out(sum);
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}

int w,h;
int c[55][55];

void dfs(int x,int y) {
    for(int dx = -1;dx<=1;dx++) {
        for(int dy = -1;dy<=1;dy++) {
            int nx = x + dx;
            int ny = y + dy;
            if(nx<0 || nx>=h || ny<0 || ny>=w) continue;
            if(c[nx][ny] == 0) continue;
            if(c[nx][ny] == 1) c[nx][ny] = 0;
            dfs(nx,ny);
        }
    }
}

int main() {
    while(true) {
        cin >> w >> h;
        if(w == 0 && h == 0) break;
        rep(i,h) rep(j,w) {
            cin >> c[i][j];
        }
        int ans = 0;
        rep(i,h) rep(j,w) {
            if(c[i][j] == 1) {
                ans++;
                dfs(i,j);
            }
        }
        cout << ans << endl;
    }    
}


Measured memory_bytes: 3260
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    sort(All(A));
    reverse(All(A));
    vector<ll> res;
    res.pb(A[0]);
    int c = 1;
    while(res.size() < N - 1) {
        res.pb(A[c]);
        if(res.size() == N - 1)
            break;
        res.pb(A[c]);
        c++;
    }
    ll sum = 0;
    rep(i, res.size()) { sum += res[i]; }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 6932
#include <bits/stdc++.h>
using namespace std;
const int INF = 2100100100;

int main() {
    int N,T,A;
    cin >> N ;
    cin >> T >> A;
    vector<int> high = vector<int>(N);
    for (int i=0;i<N;i++){
        cin >> high.at(i);
    }
    float nin = float(INF);
    int num = -1;
    for (int i=0;i<N;i++){
        float diff =  A - T + high.at(i)*0.006;
        if (nin > abs(diff)){
            num = i;
            nin = abs(diff);
        }
    }    
    cout << num+1 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int a = sc.nextInt();
        char op = sc.next().charAt(0);
        int b = sc.nextInt();

        while(op != '?')
        {
            if(op == '+')
                System.out.println(a + b);
            if(op == '-')
                System.out.println(a - b);
            if(op == '*')
                System.out.println(a * b);
            if(op == '/')
                System.out.println(a / b);

            a = sc.nextInt();
            op = sc.next().charAt(0);
            b = sc.nextInt();
        }
    }
}


Measured memory_bytes: 26208
import java.util.*;

//update 2020/1/1 23:01

public class Main{

  static Scanner sc = new Scanner(System.in);
  static StringBuilder sb = new StringBuilder();

  public static void main(String[] args) {

    int n = nextInt();
    int m = nextInt();

    int ans = 0;

    ans += n*(n-1)/2;
    ans += m*(m-1)/2;

    System.out.println(ans);

  }

  static int lcm(int a,int b){
    return a*b*gcd(a,b);
  }

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

  /*
    static String toSmall(String s){
      char c = s.charAt(0);
      //if(Character.isUpperCase(c)){
      if(c<=90){
        c += 32;
      }
      return String.valueOf(c);
    }
    static String toBig(String s){
      char c = s.charAt(0);
      //if(Character.isLowerCase(c)){
      if(c>=97){
        c -= 32;
      }
      return String.valueOf(c);
    }
  */

  static String toSmall(String s){
    return s.toLowerCase();
  }

  static String toBig(String s){
    return s.toUpperCase();
  }

  static String next(){
    return sc.next();
  }

  static int nextInt(){
    return Integer.parseInt(sc.next());
  }

  static long nextLong(){
    return Long.parseLong(sc.next());
  }

  static double nextDouble(){
    return Double.parseDouble(sc.next());
  }

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char a){
    return a - 48;
  }

////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////

////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////

}


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

using namespace std;

typedef long long int ll;

const ll mod = 1e9 + 7;
const ll MAXN = 1e5 + 5;

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

  string s, t;
  cin >> s >> t;
  ll n = s.length(), m = t.length();
  vector < vector < ll > > dp(n, vector < ll > (m, 0));

  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      if(s[i] == t[j]){
        if(i >= 1 && j >= 1) dp[i][j] = 1 + dp[i - 1][j - 1];
        else dp[i][j] = 1;
      }else{
        if(i >= 1) dp[i][j] = max(dp[i][j], dp[i - 1][j]);
        if(j >= 1) dp[i][j] = max(dp[i][j], dp[i][j - 1]);
      }
    }
  }

  string res = "";
  for(int i = n - 1, j = m - 1; i >= 0 && j >= 0; ){
    if(s[i] == t[j]){
      res += s[i];
      i--; j--;
    }
    else{
      if(i == 0 && j == 0) break;
      else if(i == 0) j--;
      else if(j == 0) i--;
      else if(dp[i - 1][j] >= dp[i][j - 1]) i--;
      else j--;
    }
  }
  reverse(res.begin(), res.end());

  cout << res << '\n';
}


Measured memory_bytes: 70784
#include <stdio.h>


int main () {
	int a, b, c, d, e;
	scanf("%d %d %d", &a, &b, &c) ;
	d= a-b ;
	e= a-c ;
	if(d < 0){
		d*= -1 ;
	}
	if(e < 0) {
		e*= -1 ;
	}
	
	
	if(d < e){
	
		printf("A");
	}
	else if(e < d){

		printf("B") ;
	}
	
	
	
	
	
	return 0 ;
}

Measured memory_bytes: 1616
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()


void solve(){
 ll a,b,c,x,y,k;
  cin >> a >> x >> y >> k;
  
  
  
  rep(i,0,k+1){ 
    b=x;
    c=y;
    rep(l,0,i) b*=2;
    rep(j,0,k-i) c*=2;
    
    if(a<b&&b<c) {
      cout << "Yes" << endl;
     return; 
    }
  }
  cout << "No" << endl;
}
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}

Measured memory_bytes: 3648
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int N;
  ll dp[100];
  cin >> N;
  dp[0] = 2;
  dp[1] = 1;
  for(int i=2;i<87;i++){
    dp[i] = dp[i-1] + dp[i-2];
  }
  cout << dp[N] << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

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



Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    // get value from StandardIn
    int n = Integer.parseInt(sc.next());
    int k = Integer.parseInt(sc.next());
    int ans = 1;
    while(n/k>0){
      ans++;
      n=n/k;
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 21844
import numpy as np
from numba import njit, int32, int64
i4 = np.int32
i8 = np.int64

INF = 1000000000


@njit((int32[:,:], int64, int64), cache=True)
def solve(s, ch, cw):
    H = s.shape[0]
    W = s.shape[1] - 1
    ah = H + 4
    aw = W + 4

    a = np.full((ah, aw), -1, i4)
    for i in range(H):
        for j in range(W):
            if s[i, j] == 46:
                a[i + 2, j + 2] = INF

    sh1 = np.empty(1000000, i4)
    sw1 = np.empty(1000000, i4)
    p1 = 0
    sh2 = np.empty(1000000, i4)
    sw2 = np.empty(1000000, i4)
    p2 = 0

    dis = 0
    a[ch + 1, cw + 1] = dis
    sh1[p1] = ch + 1
    sw1[p1] = cw + 1
    p1 += 1

    while True:
        while p1 > 0:
            p1 -= 1
            h = sh1[p1]
            w = sw1[p1]
            for i in range(-2, 3):
                for j in range(-2, 3):
                    if ((i == 1 or i == -1) and j == 0) or (i == 0 and (j == 1 or j == -1)):
                        if a[h + i, w + j] > dis:
                            a[h + i, w + j] = dis
                            sh1[p1] = h + i
                            sw1[p1] = w + j
                            p1 += 1
                    else:
                        if a[h + i, w + j] > dis + 1:
                            a[h + i, w + j] = dis + 1
                            sh2[p2] = h + i
                            sw2[p2] = w + j
                            p2 += 1

        dis += 1
        for i in range(p2):
            if a[sh2[i], sw2[i]] == dis:
                sh1[p1] = sh2[i]
                sw1[p1] = sw2[i]
                p1 += 1
        p2 = 0

        if p1 == 0:
            break

    return a


def main(in_file):
    stdin = open(in_file)
    H, W = [int(x) for x in stdin.readline().split()]
    ch, cw = [int(x) for x in stdin.readline().split()]
    dh, dw = [int(x) for x in stdin.readline().split()]
    s = np.frombuffer(np.array(stdin.read()), i4).reshape((H, W + 1))
    a = solve(s, ch, cw)
    ans = a[dh + 1, dw + 1]
    if ans == INF:
        print(-1)
    else:
        print(ans)


main('/dev/stdin')


Measured memory_bytes: 114476
#include <bits/stdc++.h>
 using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 int main(){
  int n;
   cin>>n;
   if(n%100==0&&n/100==0)cout<<"NA"<<endl;
   else if(n%100>0&&n%100<=12){
     if(n/100>0&&n/100<=12)cout<<"AMBIGUOUS"<<endl;
     else cout<<"YYMM"<<endl;
   }
  else{
    if(n/100>0&&n/100<=12)cout<<"MMYY"<<endl;
    else cout<<"NA"<<endl;
  }
}


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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

ll N, u, v;
vector<vector<ll>> G;
vector<ll> dv, du;

int main(int argc, char **argv)
{
	cin >> N >> u >> v;
	--u, --v;
	G.resize(N);
	dv.assign(N, -1);
	du.assign(N, -1);
	
	REP(i, N-1)
	{
		ll a, b; cin >> a >> b;
		--a, --b;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	du[u] = 0;
	queue<ll> que;
	que.push(u);
	while (!que.empty())
	{
		ll now = que.front();
		que.pop();

		for (auto &e : G[now])
		{
			if (du[e] != -1) continue;
			du[e] = du[now] + 1;
			que.push(e);
		}
	}

	if (du[v] == 1)
	{
		std::cout << 0 << std::endl;
		return 0;
	}
	
	dv[v] = 0;
	que.push(v);
	while (!que.empty())
	{
		ll now = que.front();
		que.pop();

		for (auto &e : G[now])
		{
			if (dv[e] != -1) continue;
			dv[e] = dv[now] + 1;
			que.push(e);
		}
	}

	ll res{0};
	REP(n, N)
	{
		if (du[n] < dv[n])
			res = max(res, dv[n]);
	}

	std::cout << res - 1 << std::endl;
}


Measured memory_bytes: 8064
#include<iostream>
#include<algorithm>

struct edge{int u,v,cost;};

int par[101],rank[101];
edge es[10001];
int V,E;

void init_union_find(int);
int find(int);
void unite(int,int);
bool same(int,int);
bool comp(const edge& e1,const edge& e2);
int kruskal(void);

using namespace std;

int main(void){
  int i,a,b,c;

  while(cin >> V >> E && V){
    for(i=0;i<E;i++){
      cin >> a >> b >> c;
      es[i].u=a;
      es[i].v=b;
      es[i].cost=c;
    }
    printf("%d\n",kruskal());
  }
  return 0;
}

void init_union_find(int n){
  for(int i=0;i<n;i++){
    par[i]=i;
    rank[i]=0;
  }
}

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

void unite(int x,int y){
  x=find(x);
  y=find(y);
  if(x==y)return;
  
  if(rank[x] < rank[y]){
    par[x]=y;
  }
  else {
    par[y]=x;
    if(rank[x]==rank[y])rank[x]++;
  }
}

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

bool comp(const edge& e1,const edge& e2){
  return e1.cost < e2.cost;
}

int kruskal(){
  sort(es,es+E,comp);
  init_union_find(V);
  int res=0;
  for(int i=0;i<E;i++){
    edge e=es[i];
    if(!same(e.u,e.v)){
      unite(e.u,e.v);
      res+=e.cost;
    }
  }
  return res;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

class UnionFind {
    public:
    int n;
    vector<int> par, rank;

    UnionFind(int n): n(n) {
        for(int i=0;i<n;++i) {
            par.push_back(i);
            rank.push_back(0);
        }
    }

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

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

        if(x == y) return;

        if(rank[x] < rank[y]){
            par[x] = y;
        }else{
            par[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
        }
        return;
    }

    bool is_same(int x, int y) {
        return find(x) == find(y);
    }
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, m, k, l;
    cin >> n >> m;
    vector<int> langs[m];
    for(int i=0;i<n;++i) {
        cin >> k;
        for(int j=0;j<k;++j) {
            cin >> l;
            --l;
            langs[l].push_back(i);
        }
    }

    UnionFind uf = UnionFind(n);
    for(int i=0;i<m;++i) {
        int ln = langs[i].size();
        for(int j=0;j<ln-1;++j) {
            uf.unite(langs[i][j], langs[i][j+1]);
        }
    }

    int root = uf.find(0);
    for(int i=1;i<n;++i) {
        if(root != uf.find(i)) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 4608
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using ll = long long;

const int INF = 1 << 29;

int main() {
    int N, t[105], v[105];
    cin >> N;
    int sumt[105];
    for (int j = 0; j < N; ++j) {
        cin >> t[j];
        sumt[j] = t[j] + (j == 0 ? 0 : sumt[j-1]);
    }
    for (int j = 0; j < N; ++j) {
        cin >> v[j];
    }
    v[N] = 0;

    double ans = 0;
    int st = 0, vc = 0;
    for (int j = 0; j < N; ++j) {
        for (int tc = st; tc < st + t[j]; ++tc) {
            int offset = INF;
            for (int k = j; k < N; ++k) {
                offset = min(offset, - (tc - sumt[k]) + v[k+1] - vc);
            }
            if (offset <= 0) {
                ans += vc - 0.5;
                --vc;
            } else {
                if (vc == v[j]) {
                    ans += vc;
                } else if (offset == 1) {
                    ans += vc + 0.25;
                } else {
                    ans += vc + 0.5;
                    ++vc;
                }
            }
        }
        st += t[j];
    }
    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
bool cmp1(char a, char b)
{
    return a < b;
}
bool cmp2(char a, char b)
{
    return a > b;
}
int main()
{
    char ch1[100010] = {}, ch2[100010] = {};
    gets(ch1);
    gets(ch2);
    std::sort(ch1, ch1 + strlen(ch1), cmp1);
    std::sort(ch2, ch2 + strlen(ch2), cmp2);
    if(strcmp(ch1, ch2) < 0)printf("Yes\n");
    else printf("No\n");
    return 0;
}

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

int main(){
    ll x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    if(x/d-k>=0)cout<<x-(k*d)<<endl;
    else{
        k-=x/d;
        x%=d;
        if(k%2==0)cout<<x<<endl;
        else cout<<abs(x-d)<<endl;
    }
}

Measured memory_bytes: 3620
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($r :tt ) *) =>{let stdin =std ::io ::stdin () ;let mut bytes =std ::io ::Read ::bytes (std ::io ::BufReader ::new (stdin .lock () ) ) ;let mut next =move ||->String {bytes .by_ref () .map (|r |r .unwrap () as char ) .skip_while (|c |c .is_whitespace () ) .take_while (|c |!c .is_whitespace () ) .collect () } ;input_inner !{next ,$($r ) *} } ;}
macro_rules !input_inner {($next :expr ) =>{} ;($next :expr ,) =>{} ;($next :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($next ,$t ) ;input_inner !{$next $($r ) *} } ;}
macro_rules !read_value {($next :expr ,($($t :tt ) ,*) ) =>{($(read_value !($next ,$t ) ) ,*) } ;($next :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($next ,$t ) ) .collect ::<Vec <_ >>() } ;($next :expr ,chars ) =>{read_value !($next ,String ) .chars () .collect ::<Vec <char >>() } ;($next :expr ,usize1 ) =>{read_value !($next ,usize ) -1 } ;($next :expr ,$t :ty ) =>{$next () .parse ::<$t >() .expect ("Parse error" ) } ;}

const MOD: usize = 1000000007;

fn main() {
   input! {
      _k: String,
      d: usize,
   }

   let k: Vec<usize> = _k.as_bytes().iter().map(|&b| (b - b'0') as usize).collect();
   let n = k.len();

   let mut dp = vec![vec![vec![0; 2]; d]; n];
   for i in 0..k[0] {
      dp[0][i % d][0] += 1;
   }
   dp[0][k[0] % d][1] = 1;
   for i in 1..n {
      for j in 0..d {
         for l in 0..10 {
            dp[i][(j + l) % d][0] += dp[i - 1][j % d][0];
            if l < k[i] {
               dp[i][(j + l) % d][0] += dp[i - 1][j][1];
            } else if l == k[i] {
               dp[i][(j + l) % d][1] += dp[i - 1][j][1];
            }
            dp[i][(j + l) % d][0] %= MOD;
            dp[i][(j + l) % d][1] %= MOD;
         }
      }
   }
   let mut ans = dp[n - 1][0][0] + dp[n - 1][0][1] + MOD - 1;
   ans %= MOD;
   println!("{}", ans);
}


Measured memory_bytes: 45308
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
map<in,in> st;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in h,w,n;
  cin>>h>>w>>n;
  in a,b;
  forn(z,n){
    cin>>a>>b;
    for(in i=max(1LL,a-2);i<=min(h-2,a);++i){
      for(in j=max(1LL,b-2);j<=min(w-2,b);++j)
	++st[i*(w+2)+j];
    }
  }
  VI r(10,0);
  fors(i,st)
    ++r[i->second];
  for(in i=1;i<=9;++i)
    r[0]-=r[i];
  r[0]+=(h-2)*(w-2);
  forn(i,10)
    cout<<r[i]<<endl;
  return 0;
}


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

#define ll long long int
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define INF 0x3f3f3f3f
#define show(x) cerr<<#x<<" : "<<x<<'\n';
#define yogeshk972() cerr<<"\nTime Taken : "<<(float)(clock()-time_p)/CLOCKS_PER_SEC<<"\n";
clock_t time_p=clock();
 
using namespace std;
const int N=1e5+1, mod=998244353;
vector<int> g[N];
map<pair<int,int>,int> e;
int res[N],mx=0;

void dfs(int u,int p,int pc){
	int c=1;
	for(auto v:g[u]){
		if( v!=p ){
			if( c==pc ) c++;
			res[ e[{u,v}] ]=c;
			dfs(v,u,c);
			c++;
		}
	}
}

int main(){
	ios_base::sync_with_stdio(0);	cin.tie(0);
	int n;
	cin>>n;
	
	for(int i=0;i<n-1;i++){
		int u,v;
		cin>>u>>v;
		g[u].pb(v);
		g[v].pb(u);
		e[{u,v}]=i;
		e[{v,u}]=i;
	}
	
	for(int i=1;i<=n;i++) mx=max(mx,(int)g[i].size());
	
	for(int i=1;i<=n;i++){
		if( (int)g[i].size()==mx ){
			dfs(i,0,0);
			break;
		}
	}
	cout<<mx<<"\n";
	for(int i=0;i<n-1;i++)cout<<res[i]<<"\n";
	
		
    yogeshk972();
}


Measured memory_bytes: 19328
import bisect

N = int(input())

An = map(int, input().split())
Bn = map(int, input().split())
Cn = map(int, input().split())


def main():
    A = sorted(An)
    C = sorted(Cn)

    ans = 0

    for Bi in Bn:
        # 以上
        lx = bisect.bisect_left(A, Bi)

        # より大きい
        ux = bisect.bisect(C, Bi)

        ans += lx * (N - ux)

    print(ans)
    return


main()


Measured memory_bytes: 29708
#!/usr/bin/env ruby

while line = gets
  xa, ya, xb, yb, xc, yc, xd, yd = line.chomp!.split.map(&:to_f)

  puts ((xb-xa) * (xd-xc) + (yb-ya) * (yd-yc)).abs < 1e-12 ? "YES" : "NO"
end

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

int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	for(int i=1;;i++)
	{
		if(a>0&&c>0)
		{
			if(i%2)
				c-=b;
			else
				a-=d;
		}
		else
		{
			if(a<=0)
			{
				cout<<"No";
				break;
			}
			else
			{
				cout<<"Yes";
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
const ll inf=1e9+7;
ll gcd(ll a, ll b) { return (b ? gcd(b, a % b) : a); }
ll lcm(ll a, ll b) { return a / (gcd(a, b)) * b; }

int main(){
    ll n;
    cin>>n;

    ll ans=0,tmp=10;
    ll cnt=0;
    if(n%2) ans=0;
    else{
      while(n/tmp>0){
        ans+=n/tmp;
        tmp*=5;
      }
    }

    cout<<ans<<endl;
    //cout<<cnt<<endl;
    //cout<<tmp<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main (void) {
    int n, m;

    scanf("%d%d", &n, &m);

    int a[m];

    int i;
    int sum_day = 0;
    for ( i=0; i<m; i++ ) {
        scanf("%d", &a[i]);
        sum_day += a[i];
    }

    if ( sum_day > n )
        printf("-1\n");
    else
        printf("%d\n", n - sum_day);

    return EXIT_SUCCESS;
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define ll long long
#define pp pair<int,int> 
//int 2×10の9乗

//vector<vector<int>> a(n, vector<int>(m));
  //rep(i,n){
    //rep(j,m) cin >> a[i][j]; 
  //}
 
int main() {
  int n, m, c;
  cin >> n >> m >> c;
  vector<int> b(m);
  rep(i,m) cin >> b[i];
  vector<vector<int>> a(n, vector<int>(m));
  rep(i,n){
    rep(j,m) cin >> a[i][j]; 
  }
  int ans = 0;
  rep(i,n){
    int sum = 0;
    rep(j,m) sum += a[i][j]*b[j];
    sum += c;
    if(sum > 0) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 764
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int ans = -1;
		if (A < 10 && B < 10) {
			ans = A*B;
		}
		System.out.println(ans);
	}
	
	public static long gcd(long a, long b) {
		long remainder = a % b;
		if (remainder == 0) {
			return b;
		} else {
			return gcd(b, remainder);
		}
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define MAX 510000
#define rrep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);

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


//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}


////////////////////////////////////////////////////////////////////
int ex[1003][1003];
char gr[1003][1003];
int cnt;
int h,w;
void bfs(int x,int y){
	ex[x][y]=1;
int dx[8]={1,1,1,0,0,-1,-1,-1};
int dy[8]={1,0,-1,1,-1,1,0,-1};
cnt++;

rrep(i,8){
if(x+dx[i]<=h-1 && x+dx[i]>=0 && y+dy[i]<=w-1 &&y+dy[i]>=0){
if(ex[x+dx[i]][y+dy[i]]==0 &&gr[x+dx[i]][y+dy[i]]=='o'){
	ex[x+dx[i]][y+dy[i]]=1;
	bfs(x+dx[i], y+dy[i]);
}
}


}
return;
}




int main() {
	COMinit();
ll h,w;
cin>>h>>w;
ll a,b;
cin>>a>>b;

ll ans=0;
for(ll i=b;i<=w-1;i++){
	ll val=COM(h-a+i-(ll)1,i);
	val%=MOD;
	val*=COM(a+w-i-(ll)2,w-i-(ll)1);
	val%=MOD;
	ans+=val;
	ans%=MOD;
}

cout<<ans<<endl;
return 0;



}




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

#define int long long

#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;

int H,W,K;
int ans=1;
bool can;
int dp[101][10];

signed main(){
    cin.tie(0);
	ios::sync_with_stdio(false);
    cin>>H>>W>>K;
    
    if(W==1){
        cout<<1<<endl;
        return 0;
    }
    
    dp[0][0]=1;
    rep(i,0,H){
        rep(j,0,W){
            rep(k,0,1<<(W-1)){
                can=true;
                rep(l,0,W-2){
                    if((k&(1<<l))&&(k&(1<<(l+1)))){
                        can=false;
                    }
                }
                if(!can)continue;
            if(k&(1<<j)){
                dp[i+1][j+1]+=dp[i][j];
                dp[i+1][j+1]%=MOD;
            }else if(k&(1<<(j-1))){
                dp[i+1][j-1]+=dp[i][j];
                dp[i+1][j-1]%=MOD;
            }else{
                dp[i+1][j]+=dp[i][j];
                dp[i+1][j]%=MOD;
            }
            }
        }
    }
    cout<<dp[H][K-1]<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include<fstream>

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
using namespace std;

const LL MOD = 1000000007;// 10^9+7
const int INF = (1 << 30);
const LL INFL = (LL)INF*INF;
const int MAXN = 51;
const int MAXA = 51;

//変数
int N;
vector<int> a, b;


//サブ関数
//入力
void input()
{
	cin >> N;
	a.resize(N);
	b.resize(N);
	REP(i, N)cin >> a[i];
	REP(i, N)cin >> b[i];
}


//テーブル作成
//cost[from][to]は、a[to]←b[from]の経路に必要なコスト
//値INFLは、繋がっていないことを意味する
void create_cost_table(vector<vector<LL>>& cost)
{
	//init
	cost = vector<vector<LL>>(MAXA, vector<LL>(MAXA, INFL));

	//table(greedy)
	REP(from, MAXA)
		FOR(to, from + 1, MAXA)
			FOR(div, 1, to + 1)
				if (from == (to % div)) {
					cost[from][to] = (1ll << div);
					break;
				}

	//same will be ignored
	REP(i, MAXA)cost[i][i] = 0;
}

//現在のcostグラフの状況で、a[i]とb[i]の最短経路を結んでみる。
//その時の、一番大きいdivision(問題文におけるk)を探す
int largest_division_search(vector<vector<LL>> cost)
{
	//ダイクストラ
	REP(from, MAXA)REP(to, MAXA)REP(mid, MAXA) 
		cost[from][to] =
			min(
				cost[from][to],
				cost[from][mid] + cost[mid][to]
			);
			
	//最短経路を全て結んでみる
	LL tmp = 0;
	REP(i, N) {
		tmp |= cost[b[i]][a[i]];
	}
	//最短経路がINFLだったら、つまり不可能なので終了
	if (tmp == INFL)return -2;

	//あれば、一番コスト多いやつをとりあえず選ばざるを得ない
	for (int i = MAXA; i >= 0; i--) {
		if (tmp&(1ll << i))return i;
	}
	return -1;
}

//コスト　2^divisionの辺は無条件に使えることにする（使うとは言ってない）
void delete_concerning_edge(int division, vector<vector<LL>>& cost)
{
	//table(greedy)
	REP(from, MAXA)FOR(to, from + 1, MAXA){
		if (from == (to % division)) {
			cost[from][to] = 0;
		}
	}
}


//計算
void calc()
{
	LL ans = 0;
	vector<vector<LL>> cost;
	create_cost_table(cost);

	REP(i, N) {
		int must_edge = largest_division_search(cost);
		if (must_edge == -2) {
			cout << -1 << endl;
			return;
		}
		if (must_edge == -1)break;

		ans += (1ll << must_edge);
		delete_concerning_edge(must_edge, cost);
	}
	

	cout << ans << endl;
}


//出力
void output()
{
	
}


//デバッグ
void debug()
{
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	input();
	calc();
	output();
	debug();
	
	return 0;
}


Measured memory_bytes: 256