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

const int N = (int) 1e6 + 7;

int n;
vector<vector<int> > g;
vector<char> cl;
vector<int> p;
int cycle_st, cycle_end;
vector<int> cycle;

bool dfs(int v) {
    cl[v] = 1;
    for (size_t i = 0; i < g[v].size(); ++i) {
        int to = g[v][i];
        if (cl[to] == 0) {
            p[to] = v;
            if (dfs(to)) return true;
        } else if (cl[to] == 1) {
            cycle_end = v;
            cycle_st = to;
            return true;
        }
    }
    cl[v] = 2;
    return false;
}
bool funk(){
    vector <int> vis(n, -1);
    for(int i=0;i<cycle.size();i++){
        vis[cycle[i]] = i;
    }
    for(int i=0;i<cycle.size();i++){
        int ths = cycle[i];
        for(int ver : g[ths]){
            int j=vis[ver];
            if(j != -1 && j!=(i+1)%cycle.size()){
                vector<int> new_cycle;
                if(i<j){
                    for(int k=0;k<=i;k++){
                        new_cycle.push_back(cycle[k]);
                    }
                    for(int k=j;k<cycle.size();k++){
                        new_cycle.push_back(cycle[k]);
                    }
                }
                else{
                    for(int k=j;k<=i;k++){
                        new_cycle.push_back(cycle[k]);
                    }
                }
                cycle= new_cycle;
                cycle.resize(new_cycle.size());
                return true;
            }
        }
    }
    return false;
}

int main() {
    //ios_base::sync_with_stdio(false);
    //cin.tie(nullptr), cout.tie(nullptr);
    int m;
    cin>>n>>m;
    g.resize(n);
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        g[x-1].push_back(y-1);
    }
    p.assign(n, -1);
    cl.assign(n, 0);
    cycle_st = -1;
    for (int i = 0; i < n; ++i)
        if (dfs(i))
            break;
    if (cycle_st == -1) {
        cout << "-1";
    } else {
        cycle.push_back(cycle_st);
        for (int v = cycle_end; v != cycle_st; v = p[v])
            cycle.push_back(v);
       // cycle.push_back(cycle_st);
        reverse(cycle.begin(), cycle.end());
      //  cycle.pop_back();
      //  for (size_t i = 0; i < cycle.size(); ++i)
      //      printf("%d ", cycle[i] + 1);
       // cout<<"kek";
        //return 0;
        while(funk() == 1){
        }
        //cout<<"kek";
        cout<<cycle.size()<<'\n';
        for(int ver :cycle){
            cout<<ver+1<<'\n';
        }
    }
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)

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

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

  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n);

  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  rep(i, n - 1) cin >> c[i];

  int ans = 0;
  int before = 0;
  for (int i = 0; i < n; i++) {
    ans += b[a[i]-1];
//    cout << "b:" << b[a[i]-1] << endl;
    if (a[i] - a[i - 1] == 1 && i != 0) {
      ans += c[a[i]-2];
//      cout << "c:" << c[a[i]-2] << endl;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		String s = "IMPOSSIBLE";
		if((b - a) % 2 == 0){
			s = String.valueOf(((b - a) / 2) + a);
		}
		System.out.println(s);
	}
}


Measured memory_bytes: 23892
#include<stdio.h>
#define SIZE10 100000

typedef long long int ll;
typedef unsigned char u8;

int main(void){
    char S[1000];
    int i = 0;

    fgets(S, 200, stdin);

    while(S[i] != '\n'){
        if((i+1) % 2 == 0){
            if(S[i] == 'R'){
                printf("No");
                return 0;
            }
        }else{
            if(S[i] == 'L'){
                printf("No");
                return 0;
            }
        }
        i++;
    }

    printf("Yes");

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<vector>
#include<math.h>
using namespace std;

int main(){
   int n, d, sum = 0;
   float temp;
   cin >> n >> d;
   float x[n][d];
   for(int i = 0; i<n; i++){
       for(int j = 0; j < d; j++){
           cin >> x[i][j];
       }
   }
   for(int i = n-1; i>=1; i--){
       for(int j = i-1; j>=0; j--){
           temp = 0;
           for(int k = 0; k<d; k++){
               temp += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
           }
           temp = sqrt(temp);
           if(ceil(temp) == floor(temp))sum++;
       }
   }
   cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include<vector>
#include <algorithm>
#include<cstdlib>
#include<set>
#include<math.h>
#include<map>
#include<iomanip>

using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;i++)


int main()
{
	ll n;
	cin >> n;
	vector<ll> x(n);
	vector<ll> y(n);
	rep(i, n) cin >> x[i] >> y[i];
	double sum = 0;
	rep(i, n) for (ll j = i + 1; j < n; j++)
	{
		sum += sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
	}
	double ans = 2 * sum / n;
	cout << fixed << setprecision(8) << ans << "\n";
	return 0;
}

Measured memory_bytes: 3816
import java.util.*;

public class Main
{
	public static void main (String[] args)
	{
		Scanner sc = new Scanner (System.in);
		String str = sc.nextLine();
		int n = str.length();
		int red = 0;
		int blue = 0;

		//0=red	1=blue

			for (int i = 0; i < n; i++)
			{
				if (str.substring (i,i+1).equals ("0"))
					red++;
				else
					blue++;
			}

		int ans = 0;
		if (red>blue)
			ans = n-(red-blue);
		else
			ans = n-(blue-red);
		System.out.println (ans);
	}
}

Measured memory_bytes: 30580
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int n;cin>>n;
    vin alpha(26,inf);
    rep(i,n){
        string s;cin>>s;
        vin tmp(26);
        rep(j,s.size())tmp[s[j]-'a']++;
        rep(j,26)alpha[j]=min(alpha[j],tmp[j]);
    }
    string ans;
    string ntoa="abcdefghijklmnopqrstuvwxyz";
    rep(i,26)rep(j,alpha[i])ans+=ntoa[i];
    cout<<ans<<endl;
}

Measured memory_bytes: 384
import java.util.*;

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

        long minus = Math.min(A, K);
        A -= minus;
        K -= minus;
        B -= Math.min(B, K);
        System.out.println(A+" "+B);
    }
}

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

int main(){
    int64_t N;
    int64_t a[2][3], A[2][3];

    cin >> N;
    for(int i=0; i<2; i++) for(int j=0; j<3; j++) cin >> a[i][j];
    vector<int64_t> vs[3];
    for(int j=0; j<3; j++) vs[j] = {a[1][j]-a[0][j], a[0][j], a[1][j]};
    sort(vs, vs+3);
    for(int i=0; i<2; i++) for(int j=0; j<3; j++){
        A[i][j] = vs[j][i+1];
        cerr << A[i][j] << " \n"[j==2];
    }

    for(int t=0; t<2; t++){
        int64_t mid = N;
        if(A[t][2] < A[1-t][2]){
            for(int i=0; i<=N; i++) for(int j=0; j<=N; j++){
                int64_t use = A[t][0]*i + A[t][1]*j;
                if(use > N) continue;
                int64_t k = (N-use)/A[t][2];
                use += k*A[t][2];

                int64_t res = N - use + i*A[1-t][0] + j*A[1-t][1] + k*A[1-t][2];
                mid = max(res, mid);
            }
        }else{
            for(int i=0; i<=A[t][1]; i++) for(int j=0; j<=A[t][0]; j++){
                int64_t use = A[t][0]*i + A[t][1]*j;
                if(use > N) continue;
                int64_t rem = N - use;
                int64_t gain = 0;
                for(int k=0; k<2; k++){
                    int64_t num = rem / A[t][k];
                    gain = max(gain, num*(A[1-t][k] - A[t][k]));
                }
                int64_t res = N - use + i*A[1-t][0] + j*A[1-t][1] + gain;
                mid = max(res, mid);
            }
        }
        N = mid;
    }
    cout << N << endl;
    return 0;
}


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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

class UnionFind {
public:
    vector<int> par;
    vector<ll> white;
    UnionFind(int n) {
        par.resize(n);
        white.resize(n, 0);
        REP(i, 0, n) {
            par[i] = i;
        }
    }
    int Find(int n) {
        return (n == par[n] ? n : par[n] = Find(par[n]));
    }
    bool Union(int a, int b, bool at, bool bt) {
        a = Find(a);
        b = Find(b);
        if (a == b) return false;
        par[a] = b;
        if (at && white[a] == 0) {
            white[a]++;
        }
        if (bt && white[b] == 0) {
            white[b]++;
        }
        white[a] += white[b];
        white[b] = white[a];
        return true;
    }
    ll getWhite(int n) {
        return white[Find(n)];
    }
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    auto mp = make_v(H, W, ' ');
    REP(i, 0, H) {
        REP(j, 0, W) {
            cin >> mp[i][j];
        }
    }
    UnionFind uf(H * W);
    int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
    REP(i, 0, H) {
        REP(j, 0, W) {
            REP(k, 0, 4) {
                int nx = j + dx[k], ny = i + dy[k];
                if (nx < 0 || nx >= W || ny < 0 || ny >= H || mp[ny][nx] == mp[i][j]) continue;
                uf.Union(i * W + j, ny * W + nx, mp[i][j] == '.', mp[ny][nx] == '.');
            }
        }
    }

    ll ans = 0;
    REP(i, 0, H) {
        REP(j, 0, W) {
            if (mp[i][j] == '#') {
                ans += uf.getWhite(i * W + j);
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2304
#include <stdio.h>

int main()
{
	int a, b, c;
	
	scanf("%d %d %d", &a, &b, &c);
	
    if (a < b && b < c)
    {
    	printf("Yes\n");
    }
	else 
	{
		printf("No\n");
	}
		
	return 0;
	
} 


Measured memory_bytes: 2604
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int sLength = in.nextInt();
        if(sLength <= 100 && sLength >= 0) {
            String stri = in.next();
            if(sLength == stri.length()) {
                boolean allAcceptable = true;
                for (int i = 0; i < sLength; i++) {
                    char c = stri.charAt(i);
                    if(Character.isUpperCase(c) || !Character.isLetter(c)) {
                        allAcceptable = false;
                    }
                }
                if(allAcceptable) {
                    String first = stri.substring(0,sLength/2);
                    String second = stri.substring(sLength/2);
                    if(first.equals(second)) {
                        System.out.println("Yes");
                    } else {
                        System.out.println("No");
                    }
                }
            }
        }

    }
}


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

#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=1;i<=n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>

const int N = 105;
const int W = 1e5+10;
const int inf = 1e13;

int dp[N][W],w[N],v[N],we,n;

void solve()
{
  cin >> n >> we;
     
  f(i,n) cin >> w[i] >> v[i];
  
  f(i,n)
  {  
   f(j,we) dp[i][j] = dp[i-1][j];   
      
   f(j,we)   
     if(j-w[i] >= 0) dp[i][j-w[i]] = max(dp[i][j-w[i]],dp[i][j] + v[i]); 
  }
    
  int ans = dp[n][0];
    
  f(j,we) ans=max(ans,dp[n][j]);
    
  cout << ans;
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

Measured memory_bytes: 79360
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main() {

    int n;
    cin >> n;

    string ans = "";
    while(n != 0){
        if(n % 2 != 0){
            n--;
            ans = "1" + ans;
        }
        else{
            ans = "0" + ans;
        }
        n /= -2;
    }
    if(ans == ""){
        ans = "0";
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
s = input()

N = len(s)
i = 0
a = ""
while i<N:
	#print( s[i] )
	if s[i]=="A" or s[i]=="T" or s[i]=="C" or s[i]=="G":
		a = a + "A"
	else:
		a = a + ","
	i += 1

#print(a)
l=a.split(",")

#print(l)

ans=0
for b in l:
	ans = max(len(b),ans)

print(ans)




Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int main() {
	int n;
	cin >> n;
	char s[300][300];
	char S;
	int i, j,k;
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			cin >> S; s[i][j] = S;
		}
	}
	int out = 0;
	for (i = 0; i < n; i++) {
		bool f = true;
		for (j = 0; j < n; j++) {
			for (k = 0; k < n; k++) {
				if (s[(j + i) % n][k] != s[(k + i) % n][j])f = false;
			}
		}
		if (f)out += n;
	}
	cout << out << endl;
	return 0;
}

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

int main() {
  const string list[10] = {"0111111","0000110","1011011","1001111","1100110","1101101","1111101","0100111","1111111","1101111"};
  int M[10] = {};
  for(int i=0; i<10; i++)
    for(int j=0; j<7; j++)
      M[i] += (list[i][j]-'0') << j;
  
  int N;
  while(cin >> N && (N!=-1)) {
    int S = 0;
    for(int i=0; i<N; i++) {
      int x; cin >> x;
      S ^= M[x];
      for(int j=0; j<7; j++) {
        cout << (S >> j & 1);
      }
      S = M[x];
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1204
#include <stdio.h>
int main(){
    int h, w;
    int i = 0;
    int j, k, l;
    while(i<1){
        scanf("%d %d", &h, &w);
        if(h==0 && w==0){
            break;
        }else{
            for(j=0; j<h; j++){
                if(j%2==0){
                    for(k=0; k<w; k++){
                        if(k%2==0){
                            printf("#");
                        }else if(k%2==1){
                            printf(".");
                        }
                    }
                    printf("\n");
                }else if(j%2==1){
                    for(l=0; l<w; l++){
                        if(l%2==0){
                            printf(".");
                        }else if(l%2==1){
                            printf("#");
                        }
                    }
                    printf("\n");
                }
            }
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2092
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m,d;
    scanf("%d%d%d",&n,&m,&d);
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            int x=(i+j)/d%2;
            int y=(1000+i-j)/d%2;
            char c="RGBY"[2*x+y];
            printf("%c",c);
        }
        printf("\n");
    }    
    return 0;
}

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

int h[100005];
int dp[100005];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    for(int i = 0;i < N;i++){
        cin >> h[i];
    }
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for(int i = 2;i < N;i++){
        dp[i] = min( abs(h[i] - h[i-1]) + dp[i-1], abs(h[i] - h[i-2]) + dp[i-2] );
    }
    cout << dp[N - 1] << '\n';
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  int n = 3;
  vector<string> vs(n);
  for (auto& e : vs) cin >> e;
  for (auto& e : vs) reverse(all(e));

  int turn = 0;
  for (;;) {
    if (sz(vs[turn]) == 0) break;
    int next = vs[turn].back() - 'a';
    vs[turn].pop_back();
    turn = next;
  }

  char ans = 'A' + turn;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int h[100000];

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

Measured memory_bytes: 640
import java.util.Scanner;

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

        long count = 0;
        long constraintA = 0;

        int i = 0;
        while (i < s.length()) {
            final char c = s.charAt(i);
            if (c == 'A') {
                long tmp = i;
                while (i < s.length() && s.charAt(i) == 'A') {
                    i++;
                }
                final long aCount = i - tmp + constraintA;

                tmp = i;
                while (i < s.length() - 1 && s.charAt(i) == 'B' && s.charAt(i + 1) == 'C') {
                    i += 2;
                }
                final long bcCount = (i - tmp) / 2;
                count += aCount * bcCount;
                constraintA = aCount;
            } else {
                constraintA = 0;
                i++;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 28160
#include <iostream>
#include <string>

using namespace std;

int main()
{
  while (1) {
    string r, a;

    cin >> r >> a;
    if (r == "0" && a == "0") break;
    int hit = 0, blow = 0;
    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 4; j++) {
        if (r[i] == a[j] && i == j) hit++;
        if (r[i] == a[j] && i != j) blow++;
      }
    }
    cout << hit << " " << blow << endl;
  }
}
    



Measured memory_bytes: 3040
#include <cstdio>
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main(void){
    int K,x;

    cin >> K>> x;

    cout << x-K+1;
    for (int i = x-K+2; i <x+K ; ++i) {
        cout <<" "<< i;
    }


    return 0;
}


Measured memory_bytes: 256
// Created by: WeirdBugsButOkay

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define ff first
#define ss second
#define PI 3.14159265358979323846
#define endl '\n'

using namespace std;

void solve()
{
	int n, x;
	cin >> x >> n;
	int p[n];
	set <int> s;
	for(int i = 0; i < 201; i++)
		s.insert(i);
	for(int i = 0; i < n; i++)
		cin >> p[i];
	for(int i = 0; i < n; i++)
		s.erase(p[i]);
	int cdiff = x, ans = 0;
	for(auto i : s)
		if(abs(x - i) < cdiff)
		{
			cdiff = abs(x - i);
			ans = i;
		}
	cout << ans;
}

int main()
{
	int q = 1;
	//scanf("%d", &q);
	for(int i = 1; i <= q; i++)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3644
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, j, k = 100000, n, m, a, cnt[k], now, ans = 1, max = 0;
  bool p[k];
  scanf("%lld%lld", &n, &m);
  for(i = 0; i < k; ++i) p[i] = true, cnt[i] = 0;;
  for(i = 2; i * i < k; ++i) if(p[i]) for(j = 2; i * j < k; ++j) p[i * j] = false;
  for(i = 0; i < n; ++i) {
    scanf("%lld", &a);
    a /= 2;
    for(j = 2; j * j <= a; ++j) if(p[j]) {
      now = 0;
      while(!(a % j)) now++, a /= j;
      if(j == 2) {
        if(!i) cnt[2] = now;
        else if(cnt[2] != now) {
          printf("0");
          return 0;
        }
      } else if(cnt[j] < now) cnt[j] = now;
      if(a == max) break;
    }
    if(a < k) {
      if(!cnt[a]) cnt[a]++;
    } else {
      if(a != max) ans *= a;
      max = a;
      if(ans > m) {
        printf("0");
        return 0;
      }
    }
  }
  for(i = 2; i < k; ++i) {
    a = 1;
    for(j = 0; j < cnt[i]; ++j) a *= i;
    ans *= a;
    if(ans > m) {
      printf("0");
      return 0;
    }
  }
  printf("%lld", (m / ans + 1) / 2);
  return 0;
}

Measured memory_bytes: 1024
n = gets.chomp.to_i
a = gets.chomp.to_i
b = gets.chomp.to_i
c = gets.chomp.to_i
d = gets.chomp.to_i
e = gets.chomp.to_i

min = [a, b, c, d, e].min

p (n.to_f/min).ceil + 4


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
const int dx[4]={-1,1,0,0};
const int dy[4]={0,0,-1,1};
signed main()
{
	int n;
	cin>>n;
	int d=1;
	int cou=1e18,ok=1,ookk=1;
	int mx=1;
	vector<int>h(n+1);
	for (int i=0;i<n;i++){
		cin>>h[i];
		if (h[i]==0)  ookk=0;
	}
	if (!ookk){
		cout<<0;
		re 0;
	}
	for (int i=0;i<n;i++){
		if (h[i]>cou){
			ok=0;
		}
		if (ok){
			mx*=h[i];
			cou/=h[i];
		}
	}
	if (ok)  cout<<mx;
	else  cout<<-1; 
	re 0;
}

Measured memory_bytes: 4048
# -*- coding: utf-8 -*-
#a,b,c,d,e,k = 2,4,7,8,15,1
#box = [a,b,c,d,e]
import itertools
box = []
for i in range(0,5):
    box.append(int(input()))
k = int(input())
c = 0
for two in list(itertools.combinations(box,2)):
    if (two[1]- two[0] > k):
        c +=1
    else:
        pass
if c == 0:
    print("Yay!")
else:
    print(":(")

Measured memory_bytes: 3316
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, i321) => {
        read_value!($next, i32) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

//
// # Examples
//
// # integers
// input! { n: i32, m: i32, ... }
//
// # array
// input! { n: i32, v: [i32; n], }
//
// # matrix
// input! { n: i32, m: i32, mat: [[]] }
//
// # string
// input! { s: chars }
//
// 3 4
// ####
// #..#
// .#.#
//
// input!{
//     h: i32,
//     w: i32,
//     board: [chars; h],
// }

// https://practice.contest.atcoder.jp/tasks/practice_1
//fn main() {
//    input!{
//        a: i32, b: i32, c: i32,
//        foo: chars,
//    }
//    let s: String = foo.into_iter().collect();
//    println!("{} {}", a+b+c, s);
//}
fn main() {
    input! { n: usize, m: usize }
    println!("{}", (n-1)*(m-1));
}

Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <queue>
using namespace std;
deque<int> Q;
int n;
int main(){
	scanf("%d", &n);
	bool rev=0; int a;
	for(int i=0;i<n;i++){
		scanf("%d", &a);
		if(!rev) Q.push_back(a);
		else Q.push_front(a);
		rev^=1;
	}
	if(rev)
		for(deque<int>::reverse_iterator it=Q.rbegin();it!=Q.rend();it++)
			printf("%d ", *it);
	else
		for(deque<int>::iterator it=Q.begin();it!=Q.end();it++)
			printf("%d ", *it);
	puts("");
	return 0;
}

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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(){
    int n,k; cin>>n>>k;
    vector<int> a(n);
    vector<int> s,t;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]<0) t.push_back(a[i]);
        else s.push_back(a[i]);
    }

    int S = s.size(), T = t.size();
    bool ok = false;
    if(S>0){
        if(n==k) ok = (T%2==0);
        else ok = true;
    }else{
        ok = (k%2==0);
    }

    mint ans = 1;
    if(!ok){
        sort(a.begin(),a.end(),[](int x,int y){
            return abs(x) < abs(y);
        });
        for(int i=0;i<k;i++) ans *= a[i];
    }else{
        sort(s.begin(),s.end());
        sort(t.rbegin(),t.rend());
        if(k%2==1){
            ans *= s.back();
            s.pop_back();
        }

        vector<ll> p;
        while(s.size()>=2){
            ll x = s.back(); s.pop_back();
            x *= s.back(); s.pop_back();
            p.push_back(x);
        }
        while(t.size()>=2){
            ll x = t.back(); t.pop_back();
            x *= t.back(); t.pop_back();
            p.push_back(x);
        }
        sort(p.rbegin(),p.rend());
        for(int i=0;i<k/2;i++) ans *= p[i];
    }

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

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

int main() {
	// your code goes here
	ll n;
	cin >> n;
	map<ll,ll> mp;
	ll temp;
	ll sum=0;
	for(ll i=0;i<n;i++){
	    cin >> temp;
	    sum+=temp;
	    if(mp.find(temp)==mp.end())
	        mp[temp]=0;
	    mp[temp]++;
	}
	ll q;
	cin >> q;
	while(q--){
	    ll b,c;
	    cin >> b >> c;
	    sum = sum - b*mp[b];
	    sum = sum + c*mp[b];
	    if(mp.find(c)==mp.end())
	        mp[c]=0;
	    mp[c]+=mp[b];
	    mp[b]=0;
	    cout << sum << endl;
	}
	return 0;
}


Measured memory_bytes: 9540
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
 
int main() {
	int x;
	cin >> x;
	int ans = 1;
	for (int b = 2; b <= x; b++) {
		int power = b*b;
		for (int p = 2;; p++) {
			if (power > x) break;
			ans = max(ans, power);
			power *= b;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef uint64_t ULL;
using namespace std;
ULL GCD(ULL x,ULL y){return y==0?x:GCD(y,x%y);}
int main()
{
  ULL A,B,greatest,index=2;
  vector<ULL> p;
  set<ULL> q;
  cin>>A>>B;
  greatest=GCD(A,B);
  while(greatest>=index*index)
  {
    if(greatest%index==0){q.insert(index);while(greatest%index==0){greatest/=index;}}
    else if(index==2)index++;
    else index+=2;
  }
  q.insert(greatest);
  q.insert(1);
  cout<<q.size()<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b;
  in2(a, b);
  if(b % a == 0)
    out(a + b);
  else
    out(b - a);
  memi;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;
vector<int> y;
int main() {
   int N,n;
    cin >> N;
    n = 1000;

    vector<int> prime;
    prime.push_back(2);
    for(int i = 2;i<=n;i++){
        for(int j=0;j<prime.size();j++){
            if(i%prime[j]==0){
                break;
            }
            if(j==prime.size()-1){
                prime.push_back(i);
            }
        }

    }
    int num[1001]={};
    for(int i=1;i<=N;i++) {
        n=i;
        for (int j = 0; j < prime.size(); j++) {
            while(n%prime[j]==0){
                n /= prime[j];
                num[j]++;
            }
        }
    }
    long long int l = 1;
    for(int i=0;i<prime.size();i++){
        l *= (num[i]+1);
        if(l > 1000000007){
            l = l%1000000007;
        }
    }

    cout << l <<endl ;
    return 0;

}


















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

int main() {
	bool judge = false;
	int n, sum = 0, num;
	cin >> n;

	vector<long long> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] % 2 == 0) {
			judge = true;
		}
	}

	if (judge) {
		for (int i = 0; i < n; i++) {
			if (a[i] % 2 == 0) {
				for (;;) {
					if (a[i] % 2 != 0) {
						break;
					}
					else {
						sum++;
						a[i] = a[i] / 2;
					}
				}
			}
		}
		cout << sum << endl;
	}
	else {
		cout << 0 << endl;
	}
	

	return 0;
}

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

using usize = ::std::size_t;
using u64 = ::std::uint_least64_t;

int main(int argc, char *argv[])
{
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    u64 N;
    cin >> N;
    
    map<string, u64> cnt;
    string cases[4] = {"AC", "WA", "TLE", "RE"};
    
    while (N--) {
        string a;
        cin >> a;
        cnt[a]++;
    }
    
    for (auto e : cases) {
        cout << e << " x " << cnt[e] << endl;
    }
    
    
    
    return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
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 int64_t INF = 1LL << 60;


int main() {
  int N;
  int64_t a[1000100][3];
  int64_t dp[1000100][3];
  
   cin >> N;
    for (int i = 0; i < N; ++i) for (int j = 0; j < 3; ++j) cin >> a[i][j];


  for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (j == k) continue;
                chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }

  cout<<max({dp[N][0],dp[N][1],dp[N][2]})<<endl;

  return 0;
  }

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

#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define out(x) cout << x << endl;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;

int main(){
    int N;
    cin >> N;
    int a[N];
    rep(i, N){
        cin >> a[i];
    }
    int anss[100003];
    rep(i, 100003){
        anss[i] = 0;
    }
    rep(i, N){
        int tmp = a[i];
        anss[tmp]++; tmp++;
        anss[tmp]++; tmp++;
        anss[tmp]++;
    }
    int ans = 0;
    rep(i, 100003){
        ans = max(ans, anss[i]);
    }
    out(ans);
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main()
{
    string s,a,b,c;
    a="Sunny";
    b="Cloudy";
    c="Rainy";
    cin>>s;
    if(s==a) cout<<b;
    if(s==b) cout<<c;
    if(s==c) cout<<a;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, K;

int main() {
	cin >> N >> K;
	if (K == 1) {
		cout << 0 << endl;
	}
	else {
		cout << N - K << endl;
	}
}

Measured memory_bytes: 764
n = int(input())
x = list(map(int,input().split()))
x = [0]+x+[0]
cost = 0
for i in range(n+1):
    cost+=abs(x[i]-x[i+1])
for i in range(1,n+1):
    cost2 = cost - abs(x[i]-x[i-1]) - abs(x[i]-x[i+1]) + abs(x[i-1]-x[i+1])
    print(cost2)


Measured memory_bytes: 14048
/* Look for:
* the exact constraints (multiple sets are too slow for n=10^6 :( ) 
* special cases (n=1?)
* overflow (ll vs int?)
* array bounds
* if you have no idea just guess the appropriate well-known algo instead of doing nothing :/
*/

// Author:: Subash Singha Roy
// Institution:: Jalpaiguri Government Engineering College

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod (int)(1e9+7)
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define frr(i,a,b) for(ll i=a-1;i>=b;i--)
#define tc(t) int t;cin >>t;while(t--)
#define pb(i) push_back(i)
#define rr return 0
#define mp make_pair
#define pr  pair <ll,ll> 
#define ff first
#define ss second
#define inf 999999999999999999
ll mult(ll a,ll b, ll p=mod){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=mod){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = mod) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n%p; n = n * n%p;} return r;}
ll inv(ll a, ll p = mod) {return fpow(a, p - 2, p);}
bool sa(const pair<int,int> &a,const pair<int,int> &b){return (a.second<b.second);}
bool fd(const pair<int,int> &a,const pair<int,int> &b){return (a.first>b.first);}
bool sd(const pair<int,int> &a,const pair<int,int> &b){return (a.second>b.second);}

int main(){
fio
ll n,k;
cin>>n>>k;
ll h[n+5],mini[n+5];
fr(i,0,n){
    cin>>h[i];
    mini[i]=inf;
}
ll dp[n+5][k+1];
fr(i,0,k){
    dp[0][i]=0;
}
mini[0]=0;
fr(i,1,n){
    fr(j,0,k){
        dp[i][j]=inf;
        if(j<i){
        dp[i][j]=mini[i-(j+1)]+abs(h[i]-h[i-(j+1)]);
        mini[i]=min(mini[i],dp[i][j]);
        }
}
}

cout<<mini[n-1]<<"\n";
rr;}

Measured memory_bytes: 80768
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

int main()
{
    IOS;
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll n1=b/c-ceil((ld)a/c)+1;
    ll n2=b/d-ceil((ld)a/d)+1;
    ll e=(c*d)/__gcd(c,d);
    ll n3=b/e-ceil((ld)a/e)+1;
    //cout<<n1<<" "<<n2<<" "<<n3<<endl;
    cout<<(b-a+1)-(n1+n2-n3)<<endl;
}
 

Measured memory_bytes: 256
//
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
//
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// solution 
use std::cmp;
#[allow(unused_mut)]
#[allow(non_snake_case)]
fn main() {
    input!{
        N: usize,
        stations: [(usize, usize, usize); N-1],
    }

    let mut dp = vec![0; N];

    for first in 0..N {
        dp[first] = 0;
        for s in first..N-1 {
            dp[s+1] = if dp[s] < stations[s].1 {
                stations[s].0 + stations[s].1
            } else {
                stations[s].0 + stations[s].1 + stations[s].2 * ((dp[s] - stations[s].1 + stations[s].2 - 1) / stations[s].2)
            }
        }
        println!("{}", dp[N-1]);
    }

}


Measured memory_bytes: 4352
#include <cstdio>
#include <algorithm>
using namespace std;

int main(){
	int a[3];
	int x=0,y=0,z=0;
	while(true){
		scanf("%d%d%d",&a[0],&a[1],&a[2]);
		sort(a,a+3);
		if(a[0]+a[1] <= a[2]){
			break;
		}
		int tmp = a[0]*a[0]+a[1]*a[1];
		int tmp2 = a[2]*a[2];
		if(tmp == tmp2){
			x++;
		}
		else if(tmp < tmp2){
			z++;
		}
		else{
			y++;
		}
	}
	printf("%d %d %d %d\n",x+y+z,x,y,z);
	return 0;
}



Measured memory_bytes: 2744
n=int(input())
a=list(map(int, input().split()))
b=list(map(int, input().split()))

a_sum=sum(a)
b_sum=sum(b)

if a_sum<b_sum:
    ans=-1
else:
    dif=[0]*n
    dif_sum=a_sum-b_sum
    ans=n
    for i in range(n):
        dif[i]=a[i]-b[i]
    dif.sort()
    for d in dif:
        if d>=0:
            dif_sum-=d
            if dif_sum<0:
                break
            ans-=1
    
print(ans)

Measured memory_bytes: 24140
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
   ll p,r,q;
   cin>>p>>q>>r;
   cout<<min(p+q,min(q+r,r+p))<<endl; 
}
return 0;
}

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

using namespace std;

int main() {
    int a, b;

    cin >> a >> b;

    if ( (a % 3 == 0) || (b % 3 == 0) || ( (a+b) % 3 == 0) ) {
        cout << "Possible" << endl;
    } else {
        cout << "Impossible" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
MOD=10**9+7
fact=[1]
temp=1
for i in range(1,3*10**5+1):
    temp*=i
    temp%=MOD
    fact+=[temp]

def bino(a,b):
    if a<b:
        return 0
    up=fact[a]
    down=fact[a-b]*fact[b]
    return (up*pow(down,MOD-2,MOD))%MOD

def find(H,W,A,B):
    temp=0
    for x in range(1,H-A+1):
        temp+=bino(x+B-2,x-1)*bino(W-B-1+H-x,H-x)
        temp%=MOD
    return temp

H,W,A,B=list(map(int,input().strip().split(" ")))
print(find(H,W,A,B))



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

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

llint n,m;
vector<llint>a;
void solve(){
  cin >> n >> m;
  a.resize(n);
  vector<pair<llint,llint>>vp;
  for(int i=0;i<n;i++)cin >> a[i];
  for(int i=0;i<m;i++){
    llint b,c;
    cin >> b >> c;
    vp.emplace_back(c,b);

  }
  sort(a.begin(),a.end());
  sort(vp.begin(),vp.end());
  llint ans=0;
  for(llint i=0;i<n;i++){
    if(vp.empty()||vp.back().first<=a[i]){
      ans+=a[i];
      continue;
    }
    ans+=vp.back().first;
    vp.back().second--;
    if(vp.back().second==0)vp.pop_back();
  }
  cout << ans << endl;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 3188
#include<iostream>
#include<vector>
using namespace std;
#define int long long int
int count=0;
int answer=0;
void function(vector<int> &v,int initial,int final,int prev,int m,int arr[][4],int q)
{
	if(initial>final)
	{
		count++;
		int here=0;
		int j;
		for(j=0;j<q;j++)
		{
			int a=arr[j][0]-1;
			int b=arr[j][1]-1;
			int c=arr[j][2];
			int d=arr[j][3];
			if(v[b]-v[a]==c)
			{
				here+=d;
			}
		}
		answer=max(answer,here);
	}
	else
	{
		int j;
		for(j=prev;j<=m;j++)
		{
			v.push_back(j);
			function(v,initial+1,final,j,m,arr,q);
			v.pop_back();
		}
	}
}
int32_t main()
{
	int n,m,q;
	cin>>n>>m>>q;
	int arr[q][4];
	int j;
	for(j=0;j<q;j++)
	{
		cin>>arr[j][0]>>arr[j][1]>>arr[j][2]>>arr[j][3];
	}
	for(j=1;j<=m;j++)
	{
		vector<int> v;
		v.push_back(j);
		function(v,1,n-1,j,m,arr,q);
	}
	cout<<answer<<endl;
}


Measured memory_bytes: 3632
def solve():
	ar=input()
	a=0
	b=0
	for i in ar:
		if(i=='A'):
			a+=1
		else:
			b+=1;
	if(a==0 or b==0):
		print("No");
	else:
		print("Yes");			
t=1
#t=int(input())
while(t>0):
	solve()
	t-=1
		
	


Measured memory_bytes: 2940
from collections import deque
from bisect import bisect_left
from collections import deque
import sys

sys.setrecursionlimit(10**9)

INF = 10**9 + 1
N = int(input())
A = list(map(int, input().split()))
G = [[] for i in range(N)]
for i in range(N-1):
    u, v = list(map(int, input().split()))
    G[u-1].append(v-1)
    G[v-1].append(u-1)

LIS = deque()
LIS.append(A[0])
ans = [0] * N

def dfs(v, p=-1):
    a = A[v]
    if a > LIS[-1]:
        idx = len(LIS) - 1
        old_val = -1
        LIS.append(a)
    else:
        idx = bisect_left(LIS, a)
        old_val = LIS[idx]
        LIS[idx] = a

    ans[v] = len(LIS)

    for u in G[v]:
        if u == p:
            continue
        dfs(u, v)
    
    if old_val == -1:
        LIS.pop()
    else:
        LIS[idx] = old_val

dfs(0)

print(*ans, sep='\n')

Measured memory_bytes: 343280
/**
 * Author: Behradm
 * Created: 14-04-2020 19:36:10
**/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;

#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define LOCAL

#ifdef LOCAL
	#define debugi(x) cerr << "{" << #x << "}: " << (x) << '\n'
	#define debug(v, begin, end) cerr << "{ | "; for(auto i = begin; i < end; i++){cerr << #v << "[" << i << "]: " << v[i] << " | ";} cerr << " }\n"
	#define debugp(a, b) cerr << "\n{ " << a << " " << b << " }\n"
#else
	#define debugi(x) 42
	#define debug(v, begin, end) 42
	#define debugp(a, b) 42 
#endif

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cout.precision(6);
	cout << fixed;
	int n;
	cin >> n;
	cout << n/2 + (n%2) << '\n';
	return 0;
}



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

#define rep(i,n) for(int i=0;i<n;i++)
///1<<3シフト演算子 とは　0001の1を三つずらして1000にする, これは8を表しておりつまりbitは0から7まで
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define CST(x) cout<<fixed<<setprecision(x)
#define PI 3.14159265359
#define MOD 1000000007
using namespace std;
using ll = long long;
using ld = long double;

//条件式 ? 真の場合の文 : 偽の場合の文
//string S  S,at(i),S += T,S += c,S.size(),S.substr(l)l文字目から最後まで,
///S.substr(l, r)l文字目からl+r-1文字目 n文字目から0個で空列を返せる
//*min_element(all(x)) *max_element(all(x))
//vi x; x.back(),x.front(),x.push_back(),x.pop_back()
//gcd(a, b)最大公約数
//sort(all(x)),reverse(all(x)),sort(x.begin()+l,a.begin()+r)lからrまで
//stack<int> a; a.push(x),a.pop(),a.top(),a.empty()bool
//queue<int> b; b.push(x),b.pop(),b.front(),b.empty()bool,b.size() 要素が小さい順
//priority_queue<int, vector<int>, greater<int>> c,c.top()
//map<int, int> M1; 変数[key] = value; 変数.erase(key); 変数.at(key); 変数.count(key)所属判定　変数.size()
//find(all(x), key)boolソート済みのベクトル
//*lower_bound(all(x),k)以上の最小の要素,*uppper_bound(all(x),k)より大きい最小の要素
//char('0'+cnt) 数字cntからcharへの変換
//int(char-'0') charからintへの変換
//binary_search(all(p),x) bool型

int main(){

    int x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    vector<ll> p(a),q(b),r(c);
    rep(i,a) cin >> p.at(i);
    rep(i,b) cin >> q.at(i);
    rep(i,c) cin >> r.at(i);

    sort(all(p));
    sort(all(q));
    sort(all(r));

   

    priority_queue<ll, vector<ll>, greater<ll> > p_new;
    priority_queue<ll, vector<ll>, greater<ll> > q_new;
    rep(i,x){
        ll temp = p.back();
        p_new.push(temp);
        p.pop_back();
    } 
    rep(i,y){
        ll temp = q.back();
        q_new.push(temp);
        q.pop_back();
    } 

    
    while(r.size() != 0 && max(r.back()-p_new.top(),r.back()-q_new.top()) > 0LL){
        if(p_new.top() < q_new.top()){
            p_new.pop();
            p_new.push(r.back());
            r.pop_back();
        }
        else{
            q_new.pop();
            q_new.push(r.back());
            r.pop_back();
        }
    }

    
    ll sum = 0;
    while(!p_new.empty()){
        sum += p_new.top();
        p_new.pop();
    }
    while(!q_new.empty()){
        sum += q_new.top();
        q_new.pop();
    }
    cout << sum << endl;


    return 0;     
}

Measured memory_bytes: 4852
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

A, B, C, K = map(int, input().split())

if K < A:
    print(K)
elif A <= K < A+B:
    print(A)
elif A+B <= K < A+B+C:
    print(A - (K - (A+B)))
else:
    print(A-C)



Measured memory_bytes: 9484
n = gets.to_i
x,y = n.times.map{gets.split.map &:to_i}.transpose

pi = Math.atan(1)*4

n.times{|i|
  d = []
  n.times{|j|
    if i!=j
      dx = x[j] - x[i]
      dy = y[j] - y[i]
      d << Math.atan2(dx,dy)
    end
  }
  d.sort!
  d << d[0]+2*pi
  
  ret = 0
  (d.size-1).times{|j|
    if d[j+1] - d[j]>=pi
      ret = (d[j+1] - d[j]) - pi
    end
  }
  puts sprintf("%.8G", ret/(2*pi))
}

Measured memory_bytes: 2044