akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static PrintWriter out;
	static InputReader ir;

	static void solve() {
		int[] g=new int[13];
		g[4]=g[6]=g[9]=g[11]=1;
		g[2]=2;
		out.println(g[ir.nextInt()]==g[ir.nextInt()]?"Yes":"No");
	}

	public static void main(String[] args) throws Exception {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

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

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

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

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

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

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}


Measured memory_bytes: 21076
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#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 repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define setp(x) fixed << setprecision(x)
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const ll INF = ll(1e16);
const int mod = 998244353;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
} 
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r; 
}
template<typename T_vector> // neal
void output_vector(const T_vector &v, bool add_one = false, int start = -1, int end = -1) {
    if (start < 0) start = 0;
    if (end < 0) end = int(v.size());
 
    for (int i = start; i < end; i++)
        cout << v[i] + (add_one ? 1 : 0) << (i < end - 1 ? ' ' : '\n');
}

vector<int> g[N];
void make(vector<pair<int, pii> > &p){
	sort(all(p));
	int j = 0, id = 0;
	rep(i, sz(p)){
		while(j < sz(p) and p[i].F > p[j].F){
			if(p[j].S.F < p[id].S.F) id = j;
			j++;
		}
		if(p[id].S.F < p[i].S.F and p[id].F != p[i].F){
			g[p[i].S.S].pb(p[id].S.S);
			g[p[id].S.S].pb(p[i].S.S);
		}
	}
	j = 0;
	id = 0;
	reverse(all(p));
	rep(i, sz(p)){
		while(j < sz(p) and p[i].F < p[j].F){
			if(p[j].S.F > p[id].S.F) id = j;
			j++;
		}
		if(p[id].S.F > p[i].S.F and p[id].F > p[i].F){
			g[p[i].S.S].pb(p[id].S.S);
			g[p[id].S.S].pb(p[i].S.S);
		}
	}
}
vector<int> vv;
int used[N], cnt = 0;
int ans[N];
void dfs(int v){
	used[v] = 1;
	++cnt;
	vv.pb(v);
	for(int to : g[v]) if(!used[to]) dfs(to);
}
void solve()
{ 
	int n;
	cin >> n;
	vector<pair<int, pii> > p(n), q(n);
	rep(i, n) cin >> p[i].F >> p[i].S.F, p[i].S.S = i;
	q = p;
	rep(i, n) swap(q[i].F, q[i].S.F);
	make(p);
	make(q);
	rep(i, n){
		if(!used[i]){
			vv.clear();
			cnt = 0;
			dfs(i);
			for(int j : vv) ans[j] = cnt;
		}
	}
	rep(i, n) cout << ans[i] << '\n';

	// for(ll i = 1; i <= sqrt(n) * 2; ++i){
	// 	x * (x + 1) / 2 & n
	// 	n * p = x * (x + 1) / 2
	// }
}
	


int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
    // Red;
  	int T = 1;
  	// cin >> T;
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
  	return 0;

}

Measured memory_bytes: 44608
#include<cstdio>
#include<algorithm>
int main(){
	char s[1000000]={};
	scanf("%s",s);
	long long int n;
	for(int i=0;true;i++){
		if(s[i]==0){
			n=i;
			break;
		}
	}
	long long int x=0;
	long long int y=0;//個数
	for(int i=0;i<n;i++){
		if(s[i]=='B'){
			y++;
			x+=i;
		}
	}
	y=(n-y+n-1)*y/2;
	printf("%lld\n",y-x);
	return 0;
}

Measured memory_bytes: 1152
#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
using namespace std;
#define maxn 200010
#define ll long long
#define mod 1000000007
 
int n,m,S,T;
struct edge{int x,y,z,next;}e[maxn<<1];
int first[maxn],len=0;
void buildroad(int x,int y,int z){e[++len]=(edge){x,y,z,first[x]};first[x]=len;}
struct node{
	int x;ll d;node(int xx=0,ll yy=0):x(xx),d(yy){}
	bool operator<(const node &ANO)const{return d>ANO.d;}
};
void add(int &x,int y){x=(x+y>=mod?x+y-mod:x+y);}
priority_queue<node>q;
int v[maxn],f[maxn],g[maxn];
ll dis1[maxn],dis2[maxn];
void dij(int S,ll *dis,int *F)
{
	memset(dis,63,sizeof(dis1));
	memset(v,false,sizeof(v));
	q.push(node(S,0));dis[S]=0;F[S]=1;
	while(!q.empty())
	{
		int x=q.top().x;q.pop();if(v[x])continue;v[x]=true;
		for(int i=first[x];i;i=e[i].next)
		{
			int y=e[i].y;
			if(dis[y]>dis[x]+e[i].z)dis[y]=dis[x]+e[i].z,F[y]=F[x],q.push(node(y,dis[y]));
			else if(dis[y]==dis[x]+e[i].z)add(F[y],F[x]),q.push(node(y,dis[y]));
		}
	}
}
int ans=0;
void work()
{
	ll L=dis1[T];
	for(int i=1;i<=n;i++)if(dis1[i]+dis2[i]==L&&dis1[i]*2ll==L)
	add(ans,1ll*f[i]*g[i]%mod*(f[T]-1ll*f[i]*g[i]%mod+mod)%mod);
	for(int i=1;i<=len;i++)if(dis1[e[i].x]*2<L&&dis1[e[i].y]*2>L&&dis1[e[i].x]+e[i].z+dis2[e[i].y]==L)
	add(ans,1ll*f[e[i].x]*g[e[i].y]%mod*(f[T]-1ll*f[e[i].x]*g[e[i].y]%mod+mod)%mod);
}
 
int main()
{
	scanf("%d %d %d %d",&n,&m,&S,&T);for(int i=1,x,y,z;i<=m;i++)
	scanf("%d %d %d",&x,&y,&z),buildroad(x,y,z),buildroad(y,x,z);
	dij(S,dis1,f);dij(T,dis2,g);work();printf("%d",ans);
}

Measured memory_bytes: 14448
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>//小数点以下表示
#include<map>
using namespace std;
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 long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


int main(){
    int n;
    cin>>n;
    double Sum=0.0;
    rep(i,n){
        double x;
        string u;
        cin>>x>>u;
        if(u=="BTC"){
            Sum+=x*380000.0;
        }
        else{
            Sum+=x;
        }
    }
    cout<<Sum<<endl;
}

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

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

int dy[] = {0,1,0,-1};
int dx[] = {1,0,-1,0};
int dy8[] = {0,1,1,1,0,-1,-1,-1};
int dx8[] = {1,1,0,-1,-1,-1,0,1};

/*==================================================*/
/*variable*/
int X, A, B;

/*==================================================*/
/*function*/

/*==================================================*/

int main() {
    cin>>X>>A>>B;
    cout<<(X-A)%B<<endl;


    return 0;
}


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

using namespace std;

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

constexpr int I_INF = (1 << 30);
constexpr ll L_INF = (1ll << 62);

//==================================

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

    int A, B;
    cin >> A >> B;

    if (max(A, B) > 9) {
        cout << -1 << endl;
    }
    else {
        cout << A * B << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;



int main() {
	int n, m, c;
	cin >> n >> m >> c;
	vector<int>b(m);
	for (int i = 0; i < m; i++) {
		cin >> b[i];
	}

	vector<vector<int>> a(n, vector<int>(m));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}

	int cnt = 0;
	for (int i = 0; i < n; i++) {
		int s = c;
		for (int j = 0; j < m; j++) {
			s += a[i][j] * b[j];
		}

		if (s > 0) {
			cnt++;
		}
	}

	cout << cnt << endl;
}


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

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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

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

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  ll n, k; cin >> n >> k;
  if (k == 0) {
    cout << n*n << endl;
    return 0;
  }
  ll ans = 0;
  for(auto i=k+1; i<=n; i++) {
    auto r = n/i;
    ans += r*(i-k);
    r = n-(n/i)*i;
    ans += max(r-k+1, 0LL);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int a[105],b[105];
int main(){
	int n;
	scanf("%d",&n);
	int x;
	for(int i=1;i<=n;i++){
		scanf("%d",&x);
		a[i]=x+a[i-1];
	}
	for(int i=1;i<=n;i++){
		scanf("%d",&x);
		b[i]=x+b[i-1];
	}
	int maxv=0,sum;
	for(int i=1;i<=n;i++){
		sum=a[i]+b[n]-b[i-1];
		maxv=max(sum,maxv);
	}
	printf("%d\n",maxv);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>

typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()
using namespace std;

int par[100001];

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;
    par[x] = y;
}

int main() {
    int N, M, p[100001], x, y;
    vector<int> vi[100001];
    cin >> N >> M;
    REP(i, N) cin >> p[i + 1];
    REP(i, N) par[i + 1] = i + 1;
    REP(i, M) {
        cin >> x >> y;
        unite(x, y);
    }

    int ans = 0;
    FOR(i, 1, N + 1) {
        if (p[i] == i || find(i) == find(p[i]))
            ans++;
    }

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

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

int main() {
	int h, w;
	char s[100][100];

	cin >> h >> w;

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> s[i][j];
		}
	}
	
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cout << s[i][j];
			
		}cout << endl;
		for (int j = 0; j < w; j++) {
			cout << s[i][j];

		}cout << endl;
	}

	
	

	return 0;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define repll(i,n) for(ll i = 0; i < n; i++)
#define REPll(i,n) for(ll i = 1; i < n; i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define yesorno(a) printf(a ? "yes\n" : "no\n")
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define YESorNO(a) printf(a ? "YES\n" : "NO\n") 
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

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

bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}


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

  ll a, b;
  cin >> a >> b;
  ll g = gcd(a, b);
  vl gcds;
  for(ll i = 1; i*i <= g; i++){
    if(g % i == 0){
      gcds.push_back(i);
      gcds.push_back(g/i);
    }
  }
  ll ans = 0;
  for(ll &x : gcds){
    ans += isprime(x);
  }
  cout << ans+1 << endl;
}

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

template <class T>
inline bool read(T &ret)
{
    char c;
    int sgn;
    if (c = getchar(), c == EOF)
    {
        return 0;
    }
    while (c != '-' && (c < '0' || c > '9'))
    {
        c = getchar();
    }
    sgn = (c == '-') ? -1 : 1;
    ret = (c == '-') ? 0 : (c - '0');
    while (c = getchar(), c >= '0' && c <= '9')
    {
        ret = ret * 10 + (c - '0');
    }
    ret *= sgn;
    return 1;
}

template <class T>
inline void write(T x)
{
    if (x > 9)
    {
        write(x / 10);
    }
    putchar(x % 10 + '0');
}

const int MAXN=110;
const double PI=acos(-1.0);

int n;
struct point
{
    double x,y;
};
point points[MAXN];
double ans;

double dfs()
{
    double r=rand();
    r/=RAND_MAX,r*=2*PI;
    double ansx=0,ansy=0;
    for(int i=1;i<=n;i++)
    {
        double ccx=cos(r)*points[i].x-sin(r)*points[i].y;
        double ccy=sin(r)*points[i].x+cos(r)*points[i].y;
        if(ccx>=0)
        {
            ansx+=ccx,ansy+=ccy;
        }
    }
    return sqrt(ansx*ansx+ansy*ansy);
}

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>points[i].x>>points[i].y;
    for(int i=1;i<=1000;i++)
        ans=max(ans,dfs());
    cout<<fixed<<setprecision(13)<<ans<<endl;
}

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

int pt(int n, int m){  
  int i; 
  for(i = m-1 ; i < (m-1)*n ; i = (m*i) / (m-1)+1);
  return (m*n-i); 
  }   

int main(){     
  int n,m;  
  
  while( cin >> n >> m , n || m ) cout << pt(n,m) << endl;    
   
  return 0;
 }

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0; i<N; i++)
  {
    cin >> vec[i];
  }
  sort(vec.begin(), vec.end());
  bool equal = false;
  for(int i=0; i<N-1; i++)
  {
    if(vec[i]==vec[i+1])
    {
    equal = true;
    }
  }
  if(equal==true)
  {
    cout << "NO" <<endl;
  }
  else
  {
    cout << "YES" <<endl;
  }
  return 0;
}


Measured memory_bytes: 1024
N = int(input())
A = list(map(int, input().split()))
s = [str(a) for a in A]
s = ' '.join(s)
print(s)

for i in range(1, N):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j + 1] = A[j]
        j -= 1
    A[j + 1] = v
    s = [str(a) for a in A]
    s = ' '.join(s)
    print(s)



Measured memory_bytes: 5604
#include <iostream>
using namespace std;
int main(){
  int n;
  while(true){
    cin >> n;
    if(n == 0){
      break;
    }
    int table[n+4];
    fill(table, table+(n+4), 0);
    table[0] = 1;
    for(int i = 0; i < n; ++i){
      table[i+1] += table[i];
      table[i+2] += table[i];
      table[i+3] += table[i];
    }
    cout << (table[n] / 10 / 365) + 1<< endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>                        
#define pb push_back                            
#define mp make_pair                            
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)((x).size())
#define endl "\n"
#define jonathan ios_base::sync_with_stdio(0)
#define livingston cin.tie(0)
using namespace std;                            
                                                
void yes() {cout << "YES" << endl;}                                               
void no() {cout << "NO" << endl;}                                                        
                                                
int dx[] = {1, 0, -1, 0, -1, -1, 1, 1};         
int dy[] = {0, 1, 0, -1, -1, 1, -1, 1}; 

const long long INF = 8e18 + 8;
const double EPS = 1e-9;
const long long MOD = 1e9 + 7;

long long fact[200010];
 
long long binpow(long long a, long long p) {
    if (p == 0) return 1;
    else if (p & 1) return a * binpow(a, p - 1) % MOD;
    else {
        long long res = binpow(a, p / 2);
        return res * res % MOD;
    }
}
 
long long mul(long long a, long long b) {
    return a * b % MOD;
}
 
long long sub(long long a, long long b) {
    return (a - b + MOD) % MOD;
}
 
long long inv(long long a) {
    return binpow(a, MOD - 2);
}
 
long long cnk(long long n, long long k) {
    if (n < 0 or k < 0 or n < k) return 0;
    return mul(fact[n], inv(mul(fact[n - k], fact[k])));
}
 
long long f(long long a, long long b) {
    a--; b--;
    return cnk(a + b, b);
}
 
void precalc() {
    fact[0] = 1;
    for (long long i = 1; i < 200010; i++) {
        fact[i] = mul(fact[i - 1], i);
    }
}

void solve() {
    long long h, w, a, b;
    cin >> h >> w >> a >> b;
    long long j = h - a;
    long long k = w - b; 
    long long ans = 0;
    for (int i = b + 1; i <= w; i++) {
        long long temp = f(i, j);
        long long d = f(a, k);
        ans += mul(temp, d);
        ans %= MOD;
        k--;
    }
    cout << ans << endl;
}

int main() {
    jonathan; 
    livingston;
    precalc();
    bool tests = 0;
    int t = 1;
    if (tests) cin >> t;
    for (int i = 1; i <= t; i++) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 5212
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rep(i,a,b) for( ll i = a ; i < b ; i+=1 )
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
ll t = 1,tt;
const ll nax=2e18;
set<pair<ll,string> > nums;
void dfs(string x,ll len){
	if(sz(x)==len){
		nums.insert({len,x});
		//cout<<x<<" ";
		return;
	}
	for(char c='0';c<='9';c++)
		if(abs(c-x.back())<=1)
			dfs(x+c,len);
}
void solve(){
	rep(i,1,10){
		string x = "";
		rep(j,1,10){
			x='0'+j;
			dfs(x,i);
		}
	}
	dfs("1",10);
	dfs("2",10);
	dfs("3",10);
	vector<pair<ll,string> > v;
	for(auto u : nums)v.pb(u);
	ll n;
	cin>>n;
	cout<<v[n-1].se;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	//cin>>t;
    while(t--){
        solve();
        //if(t!=0)cout<<"\n";
    }
    return 0 ;
}


Measured memory_bytes: 16120
#include <iostream>
#include <cmath>
using namespace std;
int y[101],r,n;

bool check(double cy){
  double x=sqrt(r*r-cy*cy);
  if(cy>=0)x=r;
  int L=(-x-0.9999),R=(x+0.9999),hb[101]={};

  for(int i=L+50;i<R+50;i++){
    int x1=i-49-i/50;
    double y1=y[i]-cy;
    if(sqrt(x1*x1+y1*y1)>=r)hb[i]++;
  }
  for(int i=L+50;i<R+50;i++)if(!hb[i])return 0;
  return 1;
}

int main(){
  while(1){
    cin>>r>>n;
    if(!r&&!n)break;
    for(int i=0;i<100;i++)y[i]=0;

    for(int i=0;i<n;i++){
      int x1,x2,h;
      cin>>x1>>x2>>h;
      for(int j=x1;j<x2;j++) y[j+50]=max(y[j+50],h);
    }
    double ans=0;
    while(check(ans-r))ans+=0.0005;
    cout << ans-0.0005<<endl;
  }
  return 0;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    vint a(n);
    rep(i,n) cin >> a[i];
    a.erase(unique(all(a)),a.end());
    n = a.size();
    int ans = 1;
    int id = 1;
    while (id < n-1) {
        if ((ll)(a[id]-a[id-1])*(a[id+1]-a[id]) < 0) {
            id += 2;
            ans++; 
        } else {
            id++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3712
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Integer n = Integer.valueOf(br.readLine());
		int i;
		Integer[] d = new Integer[n];
		for(i=0;i<n;i++) d[i] = Integer.valueOf(br.readLine());
		Arrays.sort(d);
		int cnt = 0,temp = 101;
		for(i=n-1;i>=0;i--) {
			if(temp > d[i]) {
				temp = d[i];
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}

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

using namespace std;

#define int long long

struct moj {
    int u, v, c;
    bool operator < ( const moj & other ) const {
        return c < other.c;
    }
};

vector<moj> drogi;
int ojciec[1000];

int f( int where ) {
    if( where == ojciec[where] ) return where;
    return ojciec[where] = f( ojciec[where] );
}

int u( int a, int b ) {
    ojciec[ f(a) ] = f(b);
}

int tab[1000][1000];
int dist[1000][1000];

int32_t main() {
    ios_base::sync_with_stdio( 0 );
    cin.tie( 0 );

    int n;
    cin >> n;
    for( int i=1; i<=n; i++ ) {
        ojciec[i] = i;
        for( int j=1; j<=n; j++ ) {
            cin >> tab[i][j];
            drogi.push_back( {i, j, tab[i][j]} );
            dist[i][j] = 1000000000000000ll;
            if( i == j ) dist[i][j] = 0;
        }
    }
    int wy=0;
    sort( drogi.begin(), drogi.end() );
    for( moj & x : drogi ) {
        if( dist[x.u][x.v] > x.c ) {
            dist[x.u][x.v] = dist[x.v][x.u] = x.c;
            wy += x.c;
            for( int i=1; i<=n; i++ ) {
            for( int j=1; j<=n; j++ ) {
                    dist[i][j] = min( dist[i][j], dist[i][x.u]+dist[x.u][j] );
                }
            }
            for( int i=1; i<=n; i++ ) {
                for( int j=1; j<=n; j++ ) {
                    dist[i][j] = min( dist[i][j], dist[i][x.v]+dist[x.v][j] );
                }
            }
        }
    }

    /*for( int k=1; k<=n; k++ ) {
        for( int i=1; i<=n; i++ ) {
            for( int j=1; j<=n; j++ ) {
                dist[i][j] = min( dist[i][j], dist[i][k]+dist[k][j] );
            }
        }
    }*/
    for( int i=1; i<=n; i++ ) {
        for( int j=1; j<=n; j++ ) {
            if( dist[i][j] != tab[i][j] ) {
                cout << -1;
                return 0;
            }
        }
    }
    cout << wy;


    return 0;
}



Measured memory_bytes: 11120
#include <stdio.h>

int main()
{
  int a,b,c,i,cnt=0;
  scanf("%d%d%d",&a,&b,&c);
  for(i=a;i<=b;i++)
  {
    if(c%i==0)cnt++;
  }
  printf("%d\n",cnt);
  return 0;
}



Measured memory_bytes: 2120
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int>v(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
    }
    int sum=0;
    int prev=0;
    for(int i=0;i<n;i++)
    {
        if(prev<v[i]){
            sum+=v[i]-prev;
        }
        prev=v[i];
    }
    cout<<sum<<endl;
}

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

int main(){
  string S;
  int N;
  cin >> N;
  cin >> S;
  long r = count(S.begin(),S.end(), 'R');
  long g = count(S.begin(),S.end(), 'G');
  long b = count(S.begin(),S.end(), 'B');
  long x=0;
  for(int i=0; i<N; i++){
    for(int j=i+1;j<N;j++){
      int k = j + (j-i);
      if(k>=N)break;
      if(S[i]!=S[j] && S[j]!=S[k] && S[k]!=S[i])x--; 
    }
  }
  cout << x+(r*g*b) << endl;
  return 0;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <iostream>
#include <vector>
#include <iomanip>
#define lsb(x) ((x) & -(x))
using namespace std;

#define mod 1000000007
typedef long long i64;
int n;

struct Mat {
    int v[50][50];
    Mat() {
        fill(v[0], v[50], 0);
    }
    int * operator[](int a) { return v[a]; }
};

Mat operator* (Mat & a, Mat & b)
{
    Mat ans;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            for (int k = 0; k < n; k++)
                ans[i][j] = (ans[i][j] + 1LL * a[i][k] * b[k][j]) % mod;
    return ans;
}

Mat put(Mat a, i64 p)
{
    Mat ans = a;
    p--;

    while (p) {
        if (p & 1LL)
            ans = ans * a;
        p /= 2;
        if (p)
            a = a * a;
    }

    return ans;
}

int main()
{
    Mat a;
    i64 k;
    scanf("%d%lld", &n, &k);

    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            scanf("%d", a[i] + j);

    a = put(a, k);


    int ans = 0;

    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            ans = (ans + a[i][j]) % mod;

    printf("%d\n", ans);
    return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    ll N, M;
    map<string, ll> mp;
    cin >> N;
    REP(i, N){
    	string s;
    	cin >> s;
    	mp[s]++;
    }
    cin >> M;
    REP(i, M){
    	string s;
    	cin >> s;
    	mp[s]--;
    }
    ll ma = 0;
    for(auto x: mp){
    	chmax(ma, x.second);
    }
    cout << ma << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	int ans=0,x;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		ans+=min(x,k-x);
	}
	cout<<ans*2;
}

Measured memory_bytes: 256
from __future__ import print_function
import sys
import os.path
import math
import collections
if os.path.isfile("test.inp"):
    sys.stdin = open("test.inp", "r")
    sys.stdout = open("test.out", "w")
elif os.path.isfile("panasonic2020.inp"):
    sys.stdin = open("panasonic2020.inp", "r")
    sys.stdin = open("panasonic2020.out", "w")
def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
def erange (a, b, x = 1):
    return range (a, b + 1, x)
ntest = 1
#ntest = int(input())
for itest in erange(1, ntest):
    a, b, c = map(int, input().split())
    if (c - a - b < 0):
        print ("No")
        sys.exit()
    if (4 * a * b < c * c + a * a + b * b - 2 * a * c - 2 * b * c + 2 * a * b):
        print ("Yes")
    else :
        print ("No")


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

int main() {
    ll a,b,c;
    string k;
    std::cin >> a>>b>>c>>k;
    if((k[k.length()-1]-'0') %2 == 0){
        std::cout << a-b << std::endl;
    }else{
        std::cout << b-a << std::endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int N, K;
  int i;
  int count = 0;

  scanf("%d %d",&N,&K);

  for(i=0;i<N;i++){
    int a;
    scanf("%d",&a);
    if(a>=K)count++;
  }
  printf("%d",count);

  return 0;
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(System.Console.ReadLine());
            int[] ary = System.Console.ReadLine().Trim().Split(' ').Select(x => int.Parse(x)).ToArray();
            Array.Sort(ary);
            int a = 0, b = 0;
            for(int i = 0; i <n;i++)
            {
                if (i % 2 == 0) a += ary[n - 1 - i];
                else b += ary[n - 1 - i];
            }
            System.Console.WriteLine(a - b);
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) {
        cin >> a[i];
    }
    int g = a[0];
    rep(i, n) g = gcd(g, a[i]);
    cout << g << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAXN 1e9+7
#include <math.h>

int main()
{
    int N,R;
    scanf("%d%d",&N,&R);
    int end;
    if(N<10)
     end=R+100*(10-N);
     else end=R;
     printf("%d\n",end);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector<ll> a;
int n;

bool isok(ll m) {
  ll cnt = 0;
  for (int i = 0; i < n && cnt <= m; i++) {
    ll t = a[i] + m - (n - 1);
    ll d = n+1;
    cnt += (t+d-1) / d;
  }
  return cnt <= m;
}

ll f() {
  cin >> n;
  a.resize(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i <= 1e7; i++) {
    if (isok(i)) return i;
  }
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    sum += a[i];
  }
  sum -= n*(n-1);
  for(;;sum++) if (isok(sum)) return sum;
}

int main() {
  cout << f() << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
#define mod 1000000007
#define pb push_back
#define pf push_front
#define ulli unsigned long long int
#define what_is(x) cerr << #x << " is " << x << endl;
#define pi 2*acos(0.0)
#define F  first
#define S  second
//#define endl '\n'
#define all(x) x.begin(),x.end()
using namespace std;
const int INF = 1e18L+5;
/*
int power(int x,int y)
{
	int res=1;
	while(y>0)
	{
		if(y%2==1)
			res=(res*x)%mod;
		x=(x*x)%mod;
		y=y/2;
	}
	return res;
}
*/
int csr(int A[], int len) 
{ 
    set<int> s; 
    int countSmaller[len]; 
    for (int i = len - 1; i >= 0; i--) { 
        s.insert(A[i]); 
        auto it = s.lower_bound(A[i]); 
        countSmaller[i] = distance(s.begin(), it); 
    } 
  int z=0;
    for (int i = 0; i < len; i++) 
        z+=countSmaller[i]; 
    return z;
} 
int32_t main()
{
	//cout.precision(10);
	//cout.setf(ios::fixed,ios::floatfield);
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int T=1;
	//cin>>T;
	while(T--)
	{
		int a,b;
		cin>>a>>b;
		if(max(a,b)>=10)
		cout<<"-1"<<endl;
		else
		cout<<a*b<<endl;
	}
}


Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
 
#include<bits/stdc++.h>
 
using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0); 
#define nl "\n"
#define sz(a) (int)(a).size() 
#define all(a) (a).begin(),(a).end()
#define fl(a,x) memset(a,x,sizeof(a));
#define pt(a,x) cout << get<x>(a) << " " ;  
#define mt make_tuple 
#define vec vector
 
#define int long long 
 
const int mod = (int) 1e9 + 7 ;
const int MOD = (int) 998244353 ;
const int INF = (int) 1e18 ;
 
typedef vector<int> vii;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef vector<vector<int> > vv;
 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
 
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

const int N = 2e5 + 5;
int dp[N][2] ;
vii g[N] ;

void dfs(int node,int par) {
	for(auto i : g[node]) {
		if(i != par) {
			dfs(i,node) ;
			dp[node][0] = (dp[node][0] * ((dp[i][0]+ dp[i][1]) % mod)) % mod ;
			dp[node][1] = (dp[node][1] * dp[i][0]) % mod ;
		}
	}
}

void solve(int test) {
	int n; cin >> n ;
	
	rep(i,0,n-1) {
		int u,v; cin >> u >> v;
		g[u].eb(v);
		g[v].eb(u);
	}

	for(int i = 0 ; i < N ; ++i) dp[i][0] = dp[i][1] = 1;
	dfs(1,-1);
	cout << ( dp[1][0] + dp[1][1] ) % mod; 
}
 
int32_t main() {
 
 
    fast;
	int t=1;
	// cin>>t;
	rep(i,0,t) {
		solve(i) ;
	}
 
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 21428
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
 
const int INF = 1145141919;
 
vector<int> g[100005];
vector<int> color;
 
bool dfs(int cur) {
    for (int nex : g[cur]) {
        if (color[nex] == color[cur]) {
            return false;
        }
        if (color[nex] != INF) continue;
        color[nex] = !color[cur];
        if (!dfs(nex)) return false;
    }
    return true;
}
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    ll ans = 0;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    color.resize(n, INF);
    color[0] = 0;
    if (dfs(0)) {
        ll cnt = 0;
        for (int i = 0; i < n; i++) cnt += color[i];
        cout << cnt * (n - cnt) - m << endl;
    } else {
        cout << (ll)n * (n - 1) / 2 - m << endl;
    }
    return 0;
}

Measured memory_bytes: 6400
import java.util.*;
import java.io.*;
import java.math.*;
public class Main
{
    static class Reader 
    { 
        private InputStream mIs;private byte[] buf = new byte[1024];private int curChar,numChars;public Reader() { this(System.in); }public Reader(InputStream is) { mIs = is;} 
        public int read() {if (numChars == -1) throw new InputMismatchException();if (curChar >= numChars) {curChar = 0;try { numChars = mIs.read(buf);} catch (IOException e) { throw new InputMismatchException();}if (numChars <= 0) return -1; }return buf[curChar++];} 
        public String nextLine(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isEndOfLine(c));return res.toString() ;} 
        public String s(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isSpaceChar(c));return res.toString();} 
        public long l(){int c = read();while (isSpaceChar(c)) c = read();int sgn = 1;if (c == '-') { sgn = -1 ; c = read() ; }long res = 0; do{ if (c < '0' || c > '9') throw new InputMismatchException();res *= 10 ; res += c - '0' ; c = read();}while(!isSpaceChar(c));return res * sgn;} 
        public int i(){int c = read() ;while (isSpaceChar(c)) c = read();int sgn = 1;if (c == '-') { sgn = -1 ; c = read() ; }int res = 0;do{if (c < '0' || c > '9') throw new InputMismatchException();res *= 10 ; res += c - '0' ; c = read() ;}while(!isSpaceChar(c));return res * sgn;} 
        public double d() throws IOException {return Double.parseDouble(s()) ;}
        public boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } 
        public boolean isEndOfLine(int c) { return c == '\n' || c == '\r' || c == -1; } 
        public int[] arr(int n){int[] ret = new int[n];for (int i = 0; i < n; i++) {ret[i] = i();}return ret;}
    }
  
    public static void main(String[] args)throws IOException
    {
        PrintWriter out= new PrintWriter(System.out);
        Reader sc=new Reader();
        int n=sc.i();
        int x=sc.i();
        int arr[]=sc.arr(n);
        Arrays.sort(arr);
        int count=0;
        for(int i=0;i<n;i++)
        {
            if(arr[i]<=x)
            {
                x-=arr[i];
                count++;
            }
            else
            break;
        }
        if(x!=0&&count==n)
        out.println(count-1);
        else
        out.println(count);
        out.flush();
    }
}

Measured memory_bytes: 21204
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();	//price of ABpizza
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int ans1 = A*X + B*Y;
		int ans2 = 0;
		if( X < Y ){
			ans2 = 2*C*X + B*(Y-X);
		}else{
			ans2 = 2*C*Y + A*(X-Y);
		}
		int ans3 = 2*C*Math.max(X,Y);
		System.out.println( Math.min(ans1,Math.min(ans2,ans3)) );
	}
}


Measured memory_bytes: 23508
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int gcd(int a, int b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
int digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}


int main() {
	IOS;
	int a, b;
	cin >> a >> b;
	cout << ceil((a + b) / 2.0) << endl;
}



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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, k;
    cin >> n >> k;
    int ans = 0;
    for(int i = 0; i < n; ++i){
        int h;
        cin >> h;
        if(h >= k)  ++ans;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<map>
using namespace std;
inline char tc(void){
	static char fl[10000],*A=fl,*B=fl;
	return A==B&&(B=(A=fl)+fread(fl,1,10000,stdin),A==B)?EOF:*A++;
}
inline int read(void){
	int a=0;char c;
	while((c=tc())<'0'||c>'9');
	while(c>='0'&&c<='9')a=a*10+c-'0',c=tc();
	return a;
}
int n,ans;
map<int,int>a;
int main(void){
	register int i,x;
	ans=n=read();
	for(i=1;i<=n;++i)
		x=read(),(++a[x]==x)?ans-=x:0;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4736
def main():
    N = int(input())
    A = list(map(int, input().split()))
    if N <= 2: return 1

    i = 0
    count = 0
    while i < N:
        ref = A[i]
        count += 1
        i += 1
        while i < N and A[i] == ref:
            i += 1
        if i < N:
            diff = A[i] - ref
            i += 1
            if diff > 0:
                while i < N and A[i-1] <= A[i]:
                    i += 1
            else:
                while i < N and A[i-1] >= A[i]:
                    i += 1
    return count

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 14436
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    i64 N, D;
    cin >> N >> D;
    i32 sum = 0;
    for (i32 i = 0; i < N; i++) {
        i64 X, Y;
        cin >> X >> Y;
        if (X * X + Y * Y <= D * D) sum++;
    }
    cout << sum << endl;
}


Measured memory_bytes: 3660
mod=10**9+7
N=int(input())

Factorial=[1]*(N+1)
for i in range(1,N+1):
  Factorial[i]=Factorial[i-1]*(i)%mod
def power(x,y):
  if y==0:
    return 1
  elif y==1:
    return x%mod
  elif y%2==0:
    return power(x,y//2)**2%mod
  else:
    return (power(x,y//2)**2)*x%mod

inverseFactorial=[1]*(N+1)
inverseFactorial[N]=power(Factorial[N],mod-2)
for i in range(0,N)[::-1]:
  inverseFactorial[i]=(inverseFactorial[i+1]*(i+1))%mod
  
def comb(x,y):
  if x<y or y<0:
    return 0
  else:
    return (Factorial[x]*inverseFactorial[y]*inverseFactorial[x-y])%mod

P=[0]*(N)
for k in range(N):
  P[k]=(comb(k-1,2*k-N)*Factorial[k]*Factorial[N-1-k])%mod
ans=0
for k in range(1,N):
  ans=(ans+k*(P[k]-P[k-1]))%mod
print(ans)

  
  


Measured memory_bytes: 178816
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll X, t;
    cin >> X >> t;

    cout << max((ll)0, X - t) << endl;
    
    return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner stdIn = new Scanner(System.in);
		
		int N = stdIn.nextInt();
		int sum = 0;
		int max = 0;
		
		for(int p = 1 ,i = 0; p <= N ; sum += i,p++) {
		i = stdIn.nextInt();
			if (max < i) 
				max = i;
		}
		 
		int X = sum - (max / 2);
		System.out.println(X);
		
	}

	}




Measured memory_bytes: 21844
#include<cstdio>
#include<iostream>
#include<algorithm>
#define N 1000000
using namespace std;
int A[N], T[4*N];
void build(int l, int r, int k) {
    if (l == r) {
        T[k] = A[l];
        return;
    }
    int mid = (l + r) / 2;
    build(l, mid, k * 2);
    build(mid + 1, r, k * 2 + 1);
    T[k] = min(T[2 * k], T[2 * k + 1]);
}
int find(int L, int R, int l, int r, int k) {
    if (L <= l && r <= R) return T[k];
    int mid = (l + r) / 2;
    int ans = 1e10;
    if (mid >= L) ans = min(ans, find(L, R, l, mid, k * 2));
    if (mid < R) ans = min(ans, find(L, R, mid + 1, r, k * 2 + 1));
    return ans;
}
int main() {
    int n, q;
    scanf("%d%d", &n, &q);
	for (int i=0; i<n; i++) scanf("%d", &A[i]);
    build(0, n-1, 1);
    bool first = 1;
    for(int i=0; i+q-1<n; i++)
			if(first) {
				printf("%d", find(i,i+q-1,0,n-1,1));
				first = 0;
			}
			else printf(" %d", find(i,i+q-1,0,n-1,1));
	puts("");
    return 0;
}


Measured memory_bytes: 15304