akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
int cmp(const void *a, const void *b);
//your code here!

int main(void){
    ll x, y, gx, gy;
    scanf("%lld %lld", &x, &y);
    if(x==2) gx=0;
    else if(x==4||x==6||x==9||x==11) gx=1;
    else gx=2;
    if(y==2) gy=0;
    else if(y==4||y==6||y==9||y==11) gy=1;
    else gy=2;
    printf("%s\n", (gx==gy)?"Yes":"No");
    return 0;
}

int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート
}


Measured memory_bytes: 128
#include <iostream>

int main() {
  int N;
  std::cin >> N;
  double sum=0;
  for(int i=0;i<N;i++){
    double m;
    std::string t;
    std::cin >> m >> t;
    sum += t=="JPY"?m:380000.0*m;
  }
  std::cout << sum << std::endl;
  return 0;
}

Measured memory_bytes: 256
X,K,D = map(int,input().split())
if X < 0:
  X = -X
A = X // D
if A > K:
  print(X - (K*D))
else:
  B = X % D
  KK = K - A
  if KK % 2 == 1:
    print(abs(B-D))
  elif KK % 2 == 0:
    print(abs(B))

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

using namespace std;


void solve() {
    int n; cin >> n;
    vector<int> a(n),b(n);
    for (auto& x: a) {
        cin >> x;
    }
    for (auto& x: b) {
        cin >> x;
    }
    const int L = 30;
    int res = 0;
    for (int j = 0; j < L; j++) {
        int k = 1<<j;
        int z = 0;
        for (auto& x: a) {
            if (!(x&k))z++;
        }int p = n-z;
        int u = 0;
        for (auto& x: b) {
            if (!(x&k))u++;
        }int v = n-u;
        z&=1, p&=1;
        u&=1, v&=1;
        int ans = z*v + u*p;
        vector<int> c(n);
        for (int i = 0; i < n; i++) {
            c[i] = b[i]%k;
        }
        sort(c.begin(), c.end());
        int carry = 0;
        for (auto& x: a) {
            int y = k - (x%k);
            int i = lower_bound(c.begin(), c.end(), y) - c.begin();
            carry ^= ((n-i)&1);
        }
        ans&=1;
        ans^=carry;
        if (ans) res |= k;
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 2672
# -*- coding: utf-8 -*-
N, M = map(int, input().split())
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
if N != 0:
  if N != 1:
    N_sum = combinations_count(N, 2)
  else:
    N_sum = 0
else:
  N_sum = 0
if M != 0:
  if M != 1:
    M_sum = combinations_count(M, 2)
  else:
    M_sum = 0
else:
  M_sum = 0
print(N_sum + M_sum)

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

using namespace std;

struct amida {
	int h, p, q;
};

bool cmp(const amida& x, const amida& y) {
	return x.h > y.h;
}

int main() {
	int n, m, a;
	while (cin >> n >> m >> a && (n || m || a)) {
		vector<amida> b(m);
		for (int i = 0; i < m; ++i) cin >> b[i].h >> b[i].p >> b[i].q;
		sort(b.begin(), b.end(), cmp);
		for (int i = 0; i < m; ++i) {
			if (a == b[i].p) a = b[i].q;
			else if (a == b[i].q) a = b[i].p;
		}
		cout << a << endl;
	}

	return 0;
}


Measured memory_bytes: 3136
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<queue>

using namespace std;


int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int tmp =  min(b,d)- max(a,c);
  cout<<max(0,tmp)<<endl;
  return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		long N = nl();

		l: for (long h = 1; h <= 3150; h++) {
			for (long n = 1; n <= 3150; n++) {

				long w = 1;
				if (4 * h * n - n * N - N * h > 0)
					w = N * h * n / (4 * h * n - n * N - N * h);

				if (4l * n * h * w == n * w * N + N * h * w + N * h * n) {
					out(n + " " + h + " " + w);
					break l;
				}

			}
		}

	}

	/*
	 * 以下メソッド集
	 */

	static int abcount(String str) {
		int count = 0;
		int len = str.length();
		for (int i = 0; i < len - 1; i++) {
			if ("AB".equals(str.substring(i, i + 2))) {
				count++;
			}
		}
		return count;
	}

	static int ni() {
		return sc.nextInt();
	}

	static long nl() {
		return sc.nextLong();
	}

	static double nd() {
		return sc.nextDouble();
	}

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

	static char[] nc() {
		return sc.next().toCharArray();
	}

	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

	static void out(char info) {
		System.out.println(info);
	}

	static void out(Object obj) {
		System.out.println(obj.toString());
	}

	static void outn(String info) {
		System.out.print(info);
	}

	static void outn(int info) {
		System.out.print(info);
	}

	static void outn(double info) {
		System.out.print(info);
	}

	static void outn(long info) {
		System.out.print(info);
	}

	static void outn(char info) {
		System.out.print(info);
	}

	static double max(double d, double e) {
		return Math.max(d, e);
	}

	static long max(long a, long b) {
		return Math.max(a, b);
	}

	static double min(double d, double e) {
		return Math.min(d, e);
	}

	static long min(long a, long b) {
		return Math.min(a, b);
	}
}

class XY {
	int h;
	int c;

	XY(int h, int c) {
		this.h = h;
		this.c = c;
	}
}


Measured memory_bytes: 23892
import java.util.*;
 
public class Main { 
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		Map<Integer, List<Integer>> map = new HashMap<>();

		for(int i=0; i<m; i++){
			int a = sc.nextInt();
			int b = sc.nextInt();
			List<Integer> value = map.get(a);
			if(value == null) value = new ArrayList<>();
			value.add(b);
			map.put(a, value);
			List<Integer> value2 = map.get(b);
			if(value2 == null) value2 = new ArrayList<>();
			value2.add(a);
			map.put(b, value2);
		}
		int[] ans = new int[n+1];
		ArrayDeque<Integer> dq = new ArrayDeque<>();
		dq.add(1);
		while(dq.size() > 0){
			Integer i = dq.removeFirst();
			List<Integer> value = map.get(i);
			for(Integer j: value){
				if(ans[j] == 0){
					ans[j] = i;
					dq.add(j);
				}
			}
		}
		System.out.println("Yes");
		for(int i=2; i<=n; i++){
			System.out.println(ans[i]);
		}
	}
}


Measured memory_bytes: 72584
/*author - Ashutosh Chitranshi*/
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp> 
#include<ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define pow2(x) ((x)*(x))
#define ll long long
#define ld long double
#define eb emplace_back
#define pb push_back
#define pf push_front
#define mod 1000000007
#define ordered_set tree<pair<ll,ll>,null_type,less<pair<ll,ll>>,rb_tree_tag,tree_order_statistics_node_update>
#define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
#define mp make_pair
#define ff first
#define ss second
#define null NULL
#define all(c) (c).begin(),(c).end()
#define nl "\n"
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vi > vvi;
typedef vector< vl > vvl;
typedef pair< int,int > ii;
typedef pair< ll,ll> pll;
typedef map< ll,ll> mll;
typedef map< int,int> mii;
ll dp[2005];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll s;
    cin >> s;
    dp[3] = 1ll;
    for(int i=4;i<=s;i++)
    {
        dp[i] = 1ll;
        for(int j=3;j<=i;j++)
        {
            ll rem = i-j;
            dp[i] = (dp[i] + (dp[rem])%mod)%mod;
        }
    }
    cout << dp[s] << nl;
    return 0;
}

Measured memory_bytes: 3636
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T>
inline bool chmin(T &a, const T b) { return a > b && (a = b, true); }

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, M, X;
	cin >> N >> M >> X;

	vector<int> C(N);
	vector<vector<int>> alg(N, vector<int>(M));
	for (int i = 0; i < N; i++) {
		cin >> C[i];
		for (int j = 0; j < M; j++) {
			cin >> alg[i][j];
		}
	}

	int ans = INF;
	for (int bit = 0; bit < (1 << N); bit++) {
		int sum = 0;
		vector<int> m(M);
		for (int i = 0; i < N; i++) {
			if (bit & (1 << i)) {
				for (int j = 0; j < M; j++) {
					m[j] += alg[i][j];
				}
				sum += C[i];
			}
		}
		if (all_of(m.begin(), m.end(), [&](auto &p) {return p >= X; })) chmin(ans, sum);
	}

	if(ans != INF) cout << ans << "\n";
	else cout << -1 << "\n";

	return 0;
}

Measured memory_bytes: 3616
#include <iostream>

int main(){
	int N, X, T; std::cin >> N >> X >> T;
	if ((N / X) < 1) std::cout << T << std::endl;
	else if (N % X == 0) std::cout << T * (N / X) << std::endl;
	else std::cout << ((N / X) + 1) * T << std::endl;
	return 0;
}

Measured memory_bytes: 3644
# 初期入力
import sys
#input = sys.stdin.readline  #文字列では使わない

S =input().strip()
ans =0
if S =="RRR":
    ans =3
elif S[:2]=="RR" or S[1:]=="RR":
    ans =2
elif S[0] =="R" or S[1] =="R" or S[2] =="R":
    ans =1
else:
    ans =0
print(ans)

Measured memory_bytes: 9112
#include<iostream>
using std::cout;
using std::cin;
using std::endl;

void calc (int a, char op, int b); 

int main(void) {
    int a;
    int b;
    char op;
    while (op != '?') {
        cin >> a >> op >> b;
        calc(a, op, b);
    }

    return 0;
}

void calc (int a, char op, int b) {
    if (op == '+') {
       cout << a + b << endl; 
    } else if (op == '-') {
       cout << a - b << endl; 
    } else if (op == '*') {
       cout << a * b << endl; 
    } else if (op == '/') {
       cout << a / b << endl; 
    } else {
    }
    return;    
}

Measured memory_bytes: 3112
#include<stdio.h>
int main(void){
  int a;
  int b;
  int c;
  scanf("%d",&a);
  scanf("%d",&b);
  if(a +b == 3){
    c = 3;
  }else if(a + b == 4){
	c = 2;
  }else{
	c = 1;
  }
  printf("%d",c);  
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
/*
*****************code written By**********************
..................Marajul islam.......................
...................BSMRSTU,CSE........................
*/ 
 
int sc1() {int x; scanf("%d", &x); return x;}
 
long long sc2() {long long x; scanf("%lld", &x); return x;}
 
 
 
#define  gcd(a,b)         __gcd(a,b)
#define  lcm(a,b)         (a*b)/gcd(a,b)
#define  Int              sc1()
#define  LL               sc2()
#define  For(n)           for(int i=0;i<n;i++)
#define  Forj(n)          for(int j=0;j<n;j++)
#define  Fork(n)          for(int k=0;k<n;k++)
#define  For1(n)          for(int i=1;i<=n;i++)
#define  ll               long long
#define  vi               std::vector<int>
#define  vll              std::vector<ll>
#define  qui              qu
#define  pb               push_back
#define  mpsi             std::map<string, int>
 
 
const int mod           = 1e9 + 7;
const int inf           = (int)2e9 + 5;
const ll  Inf           = (ll)1e18 + 5;
const int N             = 5e6 + 5;
 
inline int add(int a, int b) {a += b; return a >= mod ? a - mod : a;}
inline int sub(int a, int b) {a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b) {return (ll)a * b % mod;}
 

 
 
int solve() {
 
	int n=Int;
	cout<<n/2+n%2<<endl;
 
	return 0;
}
 
 
 
 
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
 
	int test = 1, tc = 0;
	//scanf("%d", &test);
	//cin >> test;
	while (test--) {
		//printf("Case %d: ", ++tc);
		solve();
	}
 
	return 0;
 
 
 
 
}




Measured memory_bytes: 256
import numpy as np

m = list(map(int, input().split()))
m2 = list(map(int, input().split()))
n = m[0]
l = m2

lnp = np.asarray(l)
lmax = np.max(lnp)
lsum = np.sum(lnp) - lmax

if(lsum > lmax):
    print('Yes')
else:
    print('No')


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

int main(){
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    cout << x2-y2+y1 << " " << y2+x2-x1 << " " << x1-y2+y1 << " " << y1+x2-x1 << endl;
}

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

int input[100001];

int main(void)
{
    int a, b, i, j, n, length, ans = 0;

    scanf("%d", &n);

    for (i = 1; i <= n; i++) {
        scanf("%d", &input[i]);
    }
    for (i = 1; i <= n; i++) {
        if (input[input[i]] == i) {
            ans++;
        }
    }

    printf("%d\n", ans/2);

    return 0;
}


Measured memory_bytes: 512
# ABC141-D
import heapq
n, m = [int(x) for x in input().split()]
h = [-int(x) for x in input().split()]
heapq.heapify(h)
for i in range(m):
    x = heapq.heappop(h)
    heapq.heappush(h, -(-x//2))
z = 0
print(-sum(h))

Measured memory_bytes: 14180
N = gets.chomp.to_i

t0, x0, y0 = 0, 0, 0

N.times do
  t, x, y = gets.chomp.split.map(&:to_i)
  d = (x0 - x).abs + (y0 - y).abs
  dt = t - t0
  if d > dt || (d % 2 != dt % 2)
    puts 'No'
    exit
  end

  t0, x0, y0 = t, x, y
end

puts 'Yes'


Measured memory_bytes: 1788
import sys

sys.setrecursionlimit(10**7)
h,w = map(int,input().split())
s = [list(input()) for i in range(h)]

dp = [[-1]*w for i in range(h)]

co = [0]
dx = [0,0,1,-1]
dy = [1,-1,0,0]
def dfs(x,y,c):
    count = 0
    dp[x][y] = 1
    if s[x][y] == "#":
        for i in range(4):
            nx = x+dx[i]
            ny = y+dy[i]
            if 0 <= nx < h and 0 <= ny < w and s[nx][ny] == "." and dp[nx][ny] == -1:
                count += 1
                count += dfs(nx,ny,c+1)
    elif s[x][y] == ".":
        for i in range(4):
            nx = x+dx[i]
            ny = y+dy[i]
            if 0 <= nx < h and 0 <= ny < w and s[nx][ny] == "#" and dp[nx][ny] == -1:
                l.append((nx,ny))
                count += dfs(nx,ny,c+1)
    return count
            
ans = 0
for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            l = []
            count = dfs(i,j,0)
            ans += count*(len(l)+1)
            s[i][j] = "x"
            for x,y in l:
                s[x][y] = "x"
print(ans)
            
        
    
    


Measured memory_bytes: 168200
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
constexpr double BIGP = 1000000007L;
constexpr double INF_I = std::numeric_limits<double>::max();
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll ans = 10000000000000;
    for(ll i=1;i*i<=N;++i)
        if (N % i == 0)
            chmin(ans, i + N / i - 2);
    cout << ans;
    return 0;
}

Measured memory_bytes: 3172
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;

int main(void) {

  string s; cin >> s;
  bool a = false;
  if ('0' == s[0] && '1' <= s[1] && s[1] <= '9') {
    a = true;
  }else if('1' == s[0] && '0' <= s[1] && s[1] <= '2') {
    a = true;
  }
  bool b = false;
  if ('0' == s[2] && '1' <= s[3] && s[3] <= '9') {
    b = true;
  }else if('1' == s[2] && '0' <= s[3] && s[3] <= '2') {
    b = true;
  }

  if(a & !b) {
    cout << "MMYY" << endl;
  }else if(!a & b) {
    cout << "YYMM" << endl;
  }else if(a && b) {
    cout << "AMBIGUOUS" << endl;
  }else {
    cout << "NA" << endl;
  }


  return 0;
}



// EOF


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

using namespace std;

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

    int N, K;
    string S;
    cin >> N >> K >> S;
    string T;
    T += S[0];
    for (int i = 1; i < N; ++i) {
        if (S[i] != S[i - 1]) {
            T += S[i];
        }
    }
    int res = 0;
    for (int i = 0; i < N; ++i) {
        res += (i > 0 && S[i] == 'L' && S[i - 1] == 'L');
        res += (i < N - 1 && S[i] == 'R' && S[i + 1] == 'R');
    }
    int m = T.size();
    int cnt = (m - 1) / 2;
    cnt = min(cnt, K);
    K -= cnt;
    res += cnt * 2;

    if (K > 0) {
        res = N - 1;
    }

    cout << res << "\n";

    return 0;
}

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

int main() {
    int n, x;
    cin >> n >> x;
    int ans = n;
    int minm = 1e9;
    for (int i=0; i<n; ++i) {
        int num;
        cin >> num;
        minm = min(minm, num);
        x -= num;
    }
    ans += x / minm;
    cout << ans << endl;
}

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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define F first
#define S second
#define INF 1 << 30

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

int main(){
  double a, l, x;
  while(~scanf("%lf%lf%lf", &a, &l, &x)){
    double res = 0;
    double s = (a+l+l)/2;
    res += sqrt(s*(s-a)*(s-l)*(s-l));

    double e = (l+x)/2;
    s = (l+e+e)/2;
    res += 2*sqrt(s*(s-l)*(s-e)*(s-e));

    printf("%lf\n", res);
  }
  return 0;
}

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

int main(void){
    string s;
    cin >> s;
    int checka = 1;
    int checkb = 1;
    for(int i = 1; i < 3; i++){
        if(s[0] == s[i])
            checka++;
    }
    for(int i = 2; i < 4; i++){
        if(s[1] == s[i])
            checkb++;
    }
    if(checka >= 3 || checkb >= 3)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
     return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<class T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
    ll a = in(), b = in(), c = in();
    cout << (a < c && c < b || b < c && c < a ? "Yes" : "No") << endl;
}

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

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define BUFF ios::sync_with_stdio(false);

typedef long long int ll;
typedef long double ld;
typedef vector < int > vi;
typedef vector < vi > vvi;
typedef pair < int, int > ii;
typedef vector < ii > vii;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const int MOD = 1e9+7;
const ld pi = acos(-1);

int n, k, x, y;
int main() { BUFF
  cin >> n >> k >> x >> y;
  cout << x*min(n, k) + (n > k ? y*(n-k) : 0) << endl;
  return 0;
}


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

using namespace std;

int magic[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main() {
    int k;
    cin >> k;
    cout << magic[k-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(10000000)

N = input()
E = [[] for i in range(N)]

for i in range(N - 1):
    x, y = map(int, raw_input().split())
    x, y = x - 1, y - 1
    E[x].append(y)
    E[y].append(x)

def func(pos, pre):
    ret = 0
    for to in E[pos]:
        if to != pre:
            ret ^= func(to, pos)
    return ret + 1

if func(0, -1) != 1:
    print "Alice"
else:
    print "Bob"

Measured memory_bytes: 110824
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e,i,sum;
	sum=0;
	scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
	if(a>0){
		sum=sum-e;
	}
	for(i=a;i<=b;i++){
		if(i<0){
		   sum+=c;
		}
		if(i==0){
			sum+=d;
		}
		if(i>0){
			sum+=e;
		}
	}
	printf("%d\n",sum);
	return 0;
}


Measured memory_bytes: 2148
K = int(input())

def sunuke(n) :
    sumN = sum(map(int, list(str(n))))
    return n / sumN

digit = 0
now = 1

for i in range(K) :
    print(now)
    if sunuke(now + 10**digit) > sunuke(now + 10**(digit + 1)) :
        digit += 1
    now += 10**digit

Measured memory_bytes: 3188
n, m = map(int, raw_input().split())

m /= 2

# convert x pairs of c to S
# new c = c - 2x
# new S = S + x
# amount = min(c/2 - x, S + x)

x = max((m - n) / 2, 0)
n += x
m -= x

print min(m, n)


Measured memory_bytes: 28012
///*Bismillahir Rahmanir Rahim***///
/***Stay_Home_Stay_Safe***/
///**Author Thasin Sheikh**///
#include<bits/stdc++.h>
using namespace std;
#define MAX 1e6+10
#define MOD 1000000007
#define PI 3.14159265359
#define makefast__  ios_base::sync_with_stdio(false);
using ll=long long int  ;
using dl =double;
const int N = 2e5 + 10;
ll aarray[200000+10];
ll magic[101][101];
vector<ll>primes;
bool prime[1000001];
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    makefast__
    string str;
    ll i,j,n,m,t,k;
    cin>>n>>m>>k;
    n=abs(n);
    if(n/k>=m)
    {
        cout<<n-(m*k)<<endl;
        return 0;
    }
    m=m-(n/k);
    n-=(n/k)*k;
    //cout<<m<<" "<<n<<endl;
    if(m%2==0)
    {
        cout<<n<<endl;
        return 0;
    }
    cout<<abs(n-k)<<endl;

    return 0;
}




Measured memory_bytes: 3592
//  IT'S NEVER TOO LATE...

		    #include <bits/stdc++.h>
			#include <complex>
		    #define ll long long

			#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
			#define forn(i, n) fore(i, 0, n)
			#define fori(i, l, r) fore(i, l, (r) + 1)
			#define sz(v) int((v).size())
			#define all(v) (v).begin(), (v).end()
			#define pb push_back
			#define mp make_pair
		    #define ff first
		    #define ss second
			#define inf 1e9
		    
			#define C complex<int>
			#define X real()
			#define Y imag()

		    using namespace std; 

		    const double PI = atan(1)*4;


		    bool isprime(int n)
		    {
		        for(int i=2;i*i<=n;i++)
		            if(n%i==0)
		                return false;
		        return true;
		    }
		     
		    bool comp(pair<double,int> a, pair<double,int> b)
		    {
		    	if( b.ff == a.ff )
		    		return a.ss < b.ss ;
		    	return b.ff < a.ff ;
		    }

		    int modpow(int b,int p,int m)
		    {
		    	if(p==0) return 1%m;
		    	if(p%2) return (b*modpow(b,p-1,m))%m;
		    	int u=modpow(b,p/2,m);
		    	return (u*u)%m;
		    }

		    vector<int> ar[100005];
		    int vis[100005],from[100005];
		    double dis[100005];
		    
		     
		/*    void dikstra(int s,int n)
		    {
		    	forn(i,n+3)
		    	{
		    		dis[i]=inf;
		    		vis[i]=0;
		    		from[i]=-1;
		    	}

		    	dis[s]=0;
		    	priority_queue<pair<int,int>> q;
		    	q.push({0,s});
		    	from[s]=s;

		    	while(!q.empty())
		    	{
		    		pair<int,int> a;
		    		a=q.top();
		    		q.pop();
		    		//cout<<a.ss<<" ";

		    		if(vis[a.ss]) continue;
		    		vis[a.ss]=1;

		    		for(pair<int,int> b:ar[a.ss])
		    		{
		    			if(dis[b.ff]>dis[a.ss] + b.ss)
		    			{
		    				dis[b.ff]=dis[a.ss] + b.ss;
		    				from[b.ff]=a.ss;
		    				q.push({-dis[b.ff],b.ff});
		    			}
		    		}
		    	}
		    }*/

		    int main()
		    {
		    	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
		     
		     
		    	int tt=1;
		    	//cin>>t;
		    	
		    	while(tt--)
		    	{
					int n;
					cin>>n;

					set<int> hon={2,4,5,7,9} , pon={0,1,6,8} , bon={3};

					if(hon.count(n%10))
						cout<<"hon";
					else
						if(bon.count(n%10))
							cout<<"bon";
						else
							cout<<"pon";
				}

		    	cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";

		    	return 0;
		    }
		    				//              NOW IT'S TIME TO WAKE UP...

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

template<typename integer>
integer __lcm(integer a, integer b) {
  return (a * b) / __gcd(a, b);
}

int main() {
  long long a, b, c, k;
  cin >> a >> b >> c >> k;

  int na = 0;
  int nb = 0;
  int nc = 0;
  long long ans = 0;

  rep (i, k+1) {
    rep (j, k+1) {
      rep (h, k+1) {
        if (i + j + h == k) {
          // cout << i << j << h << endl;

          long long a_ = a;
          long long b_ = b;
          long long c_ = c;

          rep (i_, i) a_ *= 2;
          rep (j_, j) b_ *= 2;
          rep (h_, h) c_ *= 2;

          ans = max(ans, a_ + b_ + c_);
        }
      }
    }
  }

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

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

H, W = map(int, input().split())
if H == 1 or W == 1:
    print(1)
else:
    if H * W % 2 == 0:
        print(H * W // 2)
    else:
        print(H * W // 2 + 1)

Measured memory_bytes: 2940
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    LL A,B;R(A,B);
    LL g=__gcd(A,B);
    int an=1;
    for(LL i=2;i*i<=g;i++){
        if(g%i==0){
            an++;
            while(g%i==0){
                g/=i;
            }
        }
    }
    if(g!=1)an++;
    W(an);
    return 0;
}


Measured memory_bytes: 256
import math
import fractions
n,m=map(int, input().split())
a=list(map(int, input().split()))
b=[]
s=math.floor(math.log2(max(a)))
buf=0
for i in range(n): #aは偶数なので、1/2した値の配列を作った
    b.append(int(a[i]//2))

for i in range(s+1): #2のi乗ですべての数が割れるかどうか
    for j in b:
        if j%(2**i)==0:
            buf+=1
        else:
            continue
    if buf==n:
        buf=0
        continue
    else:
        break

def lcm(x,y): #最小公倍数を求める関数の定義
    return (x*y)//fractions.gcd(x,y)

if buf!=0 and buf!=n: #偶奇が入り混じってるとき
    print(0)
elif n==1: #配列の要素が1つしかないとき
    d=int(m//b[0])
    print(int((d+1)//2))
else:
    c=[lcm(b[0],b[1])] #以下のサイクルで求めた最小公倍数を入れる配列
    for i in range(1,n):
        x=lcm(c[i-1],b[i])
        c.append(x)
        if x<m:
            continue
        else:
            break
    d=int(m//c[len(c)-1]) #最後の値(c[len(c)-1])が配列bの最小公倍数
    ans=int((d+1)//2)
    print(ans)


Measured memory_bytes: 17040
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int H, W;
vector<vector<char>> Maze(0, vector<char>(0));
v1 move_h = {1, 0, -1, 0};
v1 move_w = {0, 1, 0, -1};

int search(int s1, int s2, int g1, int g2){
	v2 dist(H, v1(W, -1));
	queue<pair<int, int>> Q;
	int m = 1e8;
	if(Maze[s1][s2] == '#' || Maze[g1][g2] == '#') return 0;
	else{
		dist[s1][s2] = 0;
		Q.push(make_pair(s1, s2));
		while(!Q.empty()){
			int h = Q.front().first;
			int w = Q.front().second;
			if(h == g1 && w == g2){
				m = min(m, dist[h][w]);
			}else{
				rep(i, 4){
					int n_h = h + move_h.at(i);
					int n_w = w + move_w.at(i);
					if(n_h < 0 || n_h>=H || n_w <0 || n_w >= W) continue;
					if(dist[n_h][n_w] == -1 && Maze[n_h][n_w] == '.'){
						dist[n_h][n_w] = dist[h][w]+1;
						Q.push(make_pair(n_h, n_w));
					}
				}
			}
			Q.pop();
		}
	}
	return m;
}

int main(){
	cin >> H >> W;
	rep(i, H){
		vector<char> a(0);
		Maze.push_back(a);
		rep(j, W){
			char s;
			cin >> s;
			Maze.at(i).push_back(s);
		}
	}
	int M = 0;
	rep(s1, H){
		rep(s2, W){
			rep(g1, H){
				rep(g2, W){
					int m = search(s1, s2, g1, g2);
					M = max(M, m);
				}
			}
		}
	}
 cout << M << endl;
}


Measured memory_bytes: 3488
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


import numpy as np
from numba import njit, b1, i4, i8, f8
from heapq import heappop as hpp, heappush as hp

@njit((b1[:, :],i8,i8,i8,i8), cache=True)
def main(ss,ch,cw,dh,dw):
    inf = 1<<30
    h,w = ss.shape
    start = ch*w+cw
    goal = dh*w+dw
    n = h*w
    seen = np.full(n, inf, np.int64)
    seen[start] = 0
    q = [(0, start)] # ワープ回数, 現在位置, 最後の道の位置
    while q:
        pnum,pu = hpp(q)
        ux,uy = divmod(pu,w)
        if pu==goal:
            break
        for xx in range(-2, 3):
            for yy in range(-2, 3):
                if xx==yy==0:
                    continue
                if abs(xx)+abs(yy)<=1:
                    vv = 0
                else:
                    vv = 1
                x,y = ux+xx, uy+yy
                u = x*w + y
                num = pnum+vv
                if x<0 or y<0 or x>=h or y>=w or ss[x][y]:
                    continue
        #         print(x,y)
                if seen[u]>num:
                    seen[u] = num
                    hp(q,(num, u))
                
    val = seen[goal]
    if val==inf:
        return -1
    else:
        return val
h,w = map(int, input().split())
ch,cw = map(int, input().split())
dh,dw = map(int, input().split())
ch -= 1
cw -= 1
dh -= 1
dw -= 1
rows,cols = h,w

OK = "."
NG = "#"

ss = np.array([[c=="#" for c in input()] for _ in range(h)])

print(main(ss,ch,cw,dh,dw))

Measured memory_bytes: 117740
//Weighted-Union-Find木
//参考 https://qiita.com/drken/items/cce6fc5c579051e64fab
// verify https://onlinejudge.u-aizu.ac.jp/courses/library/3/DSL/1/DSL_1_B

#include<iostream>
#include<vector>

using namespace std;

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

template <typename T>
struct Weighted_Union_Find {

  vector<T> par;//親の番号
  vector<T> urank;//集合のランク
  vector<T> usize;//集合の要素数
  vector<T> diff_weight;//親との距離
  T num;//集合の数

  Weighted_Union_Find() {
    init(100000);
  }

  Weighted_Union_Find(T n) {
    init(n);
  }

  void init(T n) {//0〜n-1までの要素を初期化 最初はバラバラ
    par.clear();urank.clear();usize.clear();diff_weight.clear();
    par.resize(n);urank.resize(n);usize.resize(n);diff_weight.resize(n);
    num = n;
    rep(i,n) {
      par[i] = i;
      urank[i] = (T)0;
      usize[i] = (T)1;
      diff_weight[i] = (T)0;
    }
  }

  T find(T x) {//根の添字を返すと同時に経路圧縮をする
    if(par[x] == x) {
      return x;
    } else {
      T r = find(par[x]);
      diff_weight[x] += diff_weight[par[x]];//累積和
      return par[x] = r;
    }
  }

  T get_usize(T x) {//xが属する集合の要素数を返す。
    return usize[find(x)];
  }

  bool unite(T x,T y,T w) {//weight(y) = weight(x) + w (diff(x,y) = w) となるようにxの属する集合とyの属する集合をマージ
    if(urank[x] < urank[y]) {swap(x,y);w*=-1;}//x(のroot)の下にy(のroot)をつけるので反転

    w += weight(x);w -= weight(y);
    //x(のroot)の下にy(のroot)をつけるので、w=diff(xのroot,yのroot)となるように

    x = find(x);//xの親
    y = find(y);//yの親
    if(x == y) { 
      return diff(x,y) == w;//falseの時矛盾が生じている
    }

    //x(のroot)の下にy(のroot)をつける。
    usize[x] = usize[x] + usize[y];
    num--;
    if(urank[x] == urank[y]) urank[x]++;
    par[y] = x;

    diff_weight[y] = w;

    return true;
  }

  bool same(T x,T y) {//同じ集合に属するかを判定する
    return find(x) == find(y);
  }

  T weight(T x) {//親との距離を求める
    find(x);
    return diff_weight[x];
  }

  T diff(T x,T y) {//xからyに行くときのポテンシャルの増加分 same関数で一緒かどうか調べてから使う
    return weight(y) - weight(x);
  }

  T num_set() {//集合の数(木の数)を返す。
    return num;
  }
};

using ll = long long;

ll n,q;

int main() {
    cin >> n >> q;
    Weighted_Union_Find<ll> wuf(n);

    rep(i,q) {
      ll com,x,y,z;
      cin >> com;
      if(com) {
        cin >> x >> y;
          if(wuf.same(x,y))cout << wuf.diff(x,y) << endl;
          else cout << "?" << endl;
      }else {
        cin >> x >> y >> z;;
        wuf.unite(x,y,z);
      }
  }
    return 0;
}



Measured memory_bytes: 6012
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

string Sd, T;

int main() {
  cin >> Sd >> T;

  if (T.size() > Sd.size()) {
    cout << "UNRESTORABLE";
    return 0;
  }

  int tstart;
  for (int i = Sd.size() - T.size(); i >= 0; --i) {
    bool can = true;
    for (int j = 0; j < T.size(); ++j) {
      if (Sd[i + j] != T[j] && Sd[i + j] != '?') {
        can = false;
        break;
      }
    }
    if (can) {
      tstart = i;
      break;
    }

    if (i == 0) {
      cout << "UNRESTORABLE";
      return 0;
    }
  }

  for (int i = 0; i < Sd.size(); ++i) {
    if (tstart <= i && i < tstart + T.size()) {
      cout << T[i - tstart];
      continue;
    }

    if (Sd[i] == '?') {
      cout << "a";
    } else {
      cout << Sd[i];
    }
  }
}


Measured memory_bytes: 3604
gets;
t=Hash.new 0;
$<.map{a,b=_1.split.map &:to_r;t[a==0?b==0?0:1:b==0?-1:a/b]+=1};
M=10**9+7;
p (t[0]-1+t.map{
_1==0?1:(w=t[-1/_1];w>0&&_1<0?1:2.pow(_2,M)+2.pow(w,M)-1)
}.reduce{_1*_2%M})%M

####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################


Measured memory_bytes: 38508
#include <bits/stdc++.h>
#define For(i, l, r) for(ll i = (l), _end_ = (int)(r); i <= _end_; ++i)
#define Fordown(i, r, l) for(ll i = (r), _end_ = (int)(l); i >= _end_; --i)
#define Set(a, v) memset(a, v, sizeof(a))
using namespace std;

bool chkmin(int &a, int b) {return b < a ? a = b, 1 : 0;}
bool chkmax(int &a, int b) {return b > a ? a = b, 1 : 0;}

typedef long long ll;
inline ll read() {
    ll x = 0, fh = 1; char ch = getchar();
    for (; !isdigit(ch); ch = getchar() ) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar() ) x = (x<<1) + (x<<3) + (ch ^ '0');
    return x * fh;
}

void file() {
#ifdef zjp_shadow
	freopen ("D.in", "r", stdin);
	freopen ("D.out", "w", stdout);
#endif
}

const ll mod = 1e9 + 7;
ll fpm(ll x, int power) {
	ll res = 1;
	for (; power; power >>= 1, (x *= x) %= mod)
		if (power & 1) (res *= x) %= mod;
	return res ;
}

const int N = 1001000;
ll fac[N], inv[N];
ll C(ll m, ll n) {
	return fac[n] * inv[m] % mod * inv[n - m] % mod;
}

void init() {
	fac[0] = 1;
	fac[1] = 1;
	For (i, 2, 1000000)
		fac[i] = fac[i - 1] * i % mod;
	inv[1000000] = fpm(fac[1000000], mod - 2);
	Fordown (i, 1000000 - 1, 1)
		inv[i] = inv[i + 1] * (i + 1) % mod;
	inv[0] = 1;
}

ll h, w, a, b;
void input() {
	h = read();
	w = read();
	a = read();
	b = read();
}

ll ans = 0;
void solve() {
	For (i, 1, h - a) 
		(ans += C(i - 1, b + i - 2) * C(h - i, h - i - 1 + w - b)) %= mod;
}

void output() {
	printf ("%lld\n", ans);
}

int main () {
	file() ;
	init() ;
	input() ;
	solve() ;
	output() ;
    return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
int main() {


	int a,b,c,k;
	cin>>a>>b>>c>>k;
if(b<=a)
     {
        while(k>0&&b<=a)
       {
           b*=2;k--;
       }
     }
     if(c<=b)
     {
       while(k>0&&c<=b)
       {
           c*=2;k--;
       }
     }

     if(c>b&&b>a){cout<<"Yes"<<endl;return 0;}
     else
        cout<<"No";
	return 0;
}


Measured memory_bytes: 3596
import sys
sys.setrecursionlimit(1234567890)
from collections import deque

n, *L = map(int, open(0).read().split())
mod = 10 ** 9 + 7


def prepare(m, mod=10 ** 9 + 7):
	fac = [1] * (m + 1)
	inv = [1] * (m + 1)
	for i in range(1, m + 1):
		fac[i] = fac[i - 1] * i % mod
	inv[-1] = pow(fac[-1], mod - 2, mod)
	for i in range(m - 1, -1, -1):
		inv[i] = inv[i + 1] * (i + 1) % mod
	return fac, inv


fac, inv = prepare(n)

con = [[] for _ in range(n)]
for s, t in zip(*[iter(L)] * 2):
	con[s - 1] += t - 1,
	con[t - 1] += s - 1,

par = [-1] * n
q = deque([0])
odr = []
while q:
	cur = q.popleft()
	odr += cur,
	for nxt in con[cur]:
		if nxt != par[cur]:
			par[nxt] = cur
			q.append(nxt)

sz = [1] * (n + 1)
st = 1
for i in odr[::-1]:
	sz[par[i]] += sz[i]
	st *= pow(sz[i], mod - 2, mod)
	st %= mod

# inv[n-1]*fac[sz[i]]*inv[sz[i]-1]*inv[n-sz[i]]*fac[n-sz[i]-1]*fac[n-1]=sz[i]*(n-sz[i])^-1
ans = [st * fac[n] % mod] + [0] * (n - 1)
for i in odr[1:]:
	ans[i] = ans[par[i]] * sz[i] % mod * pow(n - sz[i], mod - 2, mod) % mod
print(*ans)


Measured memory_bytes: 93780
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	int ans=0;
	for(int i=0; i<N; ++i){
	    int h;
	    cin >> h;
	    if(K<=h) ++ans;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int N, M, R;
vector<int> rs;
vector<vector<int>> A;
int dfs(int k, int s){
	debug(k, s);
	s += 1<<k;
	if(s==(1<<R)-1) return 0;
	int ret = 1e9;
	for(int i=0; i<R; i++){
		if((s>>i)&1) continue;
		ret = min(ret, dfs(i, s)+A[rs[i]][rs[k]]);
	}
	debug(k, s, ret);
	return ret;
}

int main(){
	cin >> N >> M >> R;
	rs.assign(R, 0);
	for(int i=0; i<R; i++){
		cin >> rs[i];
		rs[i]--;
	}
	A.assign(N, vector<int>(N, 1e9));
	for(int i=0; i<M; i++){
		int a, b, c;
		cin >> a >> b >> c;
		A[a-1][b-1] = c;
		A[b-1][a-1] = c;
	}

	for(int k=0; k<N; k++) for(int i=0; i<N; i++) for(int j=0; j<N; j++){
		A[i][j] = min(A[i][j], A[i][k]+A[k][j]);
	}

	int ans = 1e9;
	int s=0;
	for(int i=0; i<R; i++) ans = min(ans, dfs(i, s));
	cout << ans << endl;

	return 0;
}


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

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define EACH(begin, end) for(auto itr = (begin); itr != (end); itr++)

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;



ll N = 0;
ll ret = 0;
vector<ll> p;
void input() {
  IN(N);
  REP(i, N) {
    ll temp;
    IN(temp);
    p.push_back(temp);
  }
}

void solve() {
  int cnt = 0;
  FOR(i, 1, N-1) {
    ll a, b, c;
    a = p[i-1];
    b = p[i];
    c = p[i+1];
    if(a < b && b < c) {
      cnt++;
    } else if(a > b && b > c) {
      cnt++;
    }
  }
  PRINT(cnt);
}

int main(void){
  input();
  solve();
}


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

typedef long long ll;

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

int main() {
  int W,N;
  cin >> W >> N;
  vector<ll> dp(W+1,100000000000);
  dp[0] = 0;
  int w,v;
  rep(i,N) {
    cin >> w >> v;
    rep(j,W+1) dp[j] = min(dp[j], dp[max(0,j-w)]+v);
  }
  cout << dp[W] << endl;
  return 0;
}

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

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if (s[0] == s[1] && s[2] == s[3] && s[1] != s[2]) cout << "Yes" << '\n';
    else cout << "No" << '\n';
    return 0;
}

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

int main()
{
	int n;
	char str[100000], out[100000];
	char tmp[10];

	while (cin >> n, n){
		cin >> str;
		for (int i = 0; i < n; i++){
			int cnt = 1;
			out[0] = '\0'; // clean
			for (int j = 0; j < strlen(str); j++){
				if (str[j] == str[j + 1]){
					cnt++;
				}
				else {
					sprintf(tmp, "%d%c", cnt, str[j]); // tmp <- cnt + str[j]
					strcat(out, tmp);
					cnt = 1;
				}
			}
			strcpy(str, out);
		}
		cout << out << endl;
	}

	return (0);
}

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

#define IOS                               \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0);                      \
	cout.precision(20);               \
	cout << fixed;
#define int long long int
#define pb push_back
#define endl "\n"
#define all(a) a.begin(), a.end()
#define N 1500009
#define M 1000009
#define mod 1000000007
int powi(int a,int b){if (b == 0)return 1;int see = powi(a, b / 2);see *= see;see %= mod;if (b % 2)see *= a;see %= mod;return see;}

int a,b;
int mp1[N];
int mp2[N];
int ans = 0;

void pre()
{
	memset(mp2,0,sizeof(mp2));
	memset(mp1,0,sizeof(mp1));	
	for(int i=2;i<=(sqrt(a)+4);i++)
	{
		if((a%i)==0)
		{
			mp1[i] = 1;
			while((a%i)==0)
			{
				a/=i;
			}
		}
	}
	for(int i=2;i<=(sqrt(b)+4);i++)
	{
		if((b%i)==0)
		{
			mp2[i] = mp1[i];
			while((b%i)==0)
			{
				b/=i;
			}
		}
	}
	if(a!=1 && a == b)
		ans++;
	mp2[1] = 1;
	for(int i=0;i<N;i++)
	{
		if(mp2[i]==1)
		{
			ans++;
		}
	}

	cout<<ans<<endl;
	
}

int32_t main()
{
	IOS;
	cin>>a>>b;
	pre();	
}

Measured memory_bytes: 23808