akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int ll;

ll n;
// ll dp[101][100000];
// ll find(ll arr[][2], ll curr, ll w, ll i) {
// 	if (i >= n)
// 		return 0;

// 	if (curr > w)
// 		return 0;

// 	if (dp[i][curr] != -1)
// 		return dp[i][curr];

// 	ll ans = find(arr, curr, w, i + 1);
// 	if (curr + arr[i][0] <= w)
// 		ans = max(ans, find(arr, curr + arr[i][0], w, i + 1) + arr[i][1]);

// 	dp[i][curr] = ans;
// 	return ans;
// }


int main() {
	ll w;
	cin >> n >> w;
	// memset(dp, -1, sizeof(dp));
	// vector<vector<ll>> arr(n, vector<ll>(2));
	ll arr[n][2];
	for (ll i = 0; i < n; i++)
		cin >> arr[i][0] >> arr[i][1];
	// cout << find(arr, 0, w, 0);
	ll dp[n + 1][w + 1];
	memset(dp, 0, sizeof(dp));
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= w; j++) {
			if (arr[i - 1][0] <= j)
				dp[i][j] = max(arr[i - 1][1] + dp[i - 1][j - arr[i - 1][0]], dp[i - 1][j]);
			else
				dp[i][j] = dp[i - 1][j];
		}
	}
	cout << dp[n][w];
	return 0;
}

Measured memory_bytes: 82436
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#include <cassert>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using namespace std;
int cake[300][300];
int main() {
    int H, W, K;
    char tmp;
    cin >> H >> W >> K;
    rep(i, H) {
        rep(j, W) {
            cin >> tmp;
            cake[i][j] = tmp == '#' ? 1 : 0;
        }

    }

    int color = 0;
    int first_berry_h = -1;
    rep(i, H) {
        int num_berry_w = 0;
        rep(j, W) {
//            cout << cake[i][j] << " ";
            if(cake[i][j] == 1) {
                num_berry_w++;
                if(color == 0) {
                    first_berry_h = i;
                }
            }
        }

        if(num_berry_w == 0) {
            if(first_berry_h == -1)
                continue;
            rep(j, W) {
                cake[i][j] = cake[i-1][j];
            }
        } else {
            bool first_berry = true;
            color++;
            rep(j, W) {
                if(cake[i][j] == 1) {
                    if(first_berry) {
                        first_berry = false;
                    } else {
                        color++;
                    }
                }
                cake[i][j] = color;
            }
        }
//        cout << endl;
    }
    if(first_berry_h != 0) {
        rep(i, first_berry_h) {
            rep(j, W) {
                cake[i][j] = cake[first_berry_h][j];
            }
        }
    }

    rep(i, H) {
        rep(j, W) {
//            printf("%03d ", cake[i][j]);
            cout << cake[i][j] << " ";
        }
        cout << endl;
    }

    return 0;
}




Measured memory_bytes: 3496
/*
If you want to shine like a sun, first burn like a sun.
*/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define vpi vector<ppi>
#define ppl pair<ll,ll>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf LONG_MAX
#define minf LONG_MIN
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793
const ll infinity = 9e18;

/*
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/

int main()
{
    fast

/*
    #ifndef ONLINE_JUDGE
        freopen("in.txt",  "r",  stdin);
        freopen("out.txt", "w", stdout);
    #endif
//*/

        
    int n;

    cin>>n;

    ll sum = 0,total = 0;
        
    ll k;
    forn(i,0,n)
    {
        cin>>k;
        sum += k;
        total += k*k;
    }    

    cout<<((sum*sum-total)/2);










    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int [] Ai = new int[N];
    double [] Gi = new double[N];
    double sum = 0;
    for(int i=0;i<N;i++){
      Ai[i] = scan.nextInt();
      Gi[i] = 1.0/Ai[i];
      sum += Gi[i];
    }
    //System.out.println(sum);
    double sum2 = 1.0/sum;
    System.out.println(sum2);
  }
}


Measured memory_bytes: 21716
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
using namespace std;


//#define debugger
#define rep int kase; scanf("%d", &kase); while(kase--)
typedef long long LL;
const int maxn = 150;
LL gcd(LL a, LL b){
  LL t;
  if(a < b) swap(a,b);
  while(b % a) {
    t = b % a;
    b = a;
    a = t;
  }
  return a;
}
int main(){
  #ifdef debugger
  freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
  #endif // debugger
  int n; scanf("%d", &n);
  LL a, ans = 1, t;
  for(int i = 0; i < n; i++) {
    scanf("%lld", &a);
    t = gcd(a,ans);
    ans /= t;
    ans *= a;
  }
  printf("%lld\n", ans);
  return 0;
}


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

using namespace std;

struct I{I(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(10);
}}init;

const int M=2*114514;
const double INF=M*100;
typedef vector<double> V;
typedef vector<V> VV;
double diff(double a,double b){
    return abs(a-b)/a;
}
int main(){
    int N;cin>>N;
    V a(N);for(auto &it:a)cin>>it;
    VV dp(N,V(M,INF));
    for(int i=1;i<M;i++)dp[0][i]=diff(a[0],i);
    for(int i=1;i<N;i++){
        for(int j=1;j<M;j++){
            for(int k=j;k<M;k+=j)
                dp[i][k]=min(dp[i][k],max(dp[i-1][j],diff(a[i],k)));
        }
    }
    double res=INF;
    for(auto &it:dp.back())res=min(res,it);
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 40588
#include <iostream>
#include <math.h>
#include <vector>
#include <cstdlib>

using namespace std;

int main(int argc, const char * argv[]) {
	int A, B;
	int C;

	cin >> A >> B;
	C = A - B * 2;

	if(C <= 0){
		cout << 0 << endl;
	}else{
		cout << abs(C * (-1)) << endl;
	}

	return 0;
}


Measured memory_bytes: 384
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func add(a, b int) int {
	return a + b
}

func del(a, b int) int {
	return a - b
}

func stringToInt(s string) int {
	i, _ := strconv.Atoi(s)
	return i
}

func intToOpe(i int) string {
	if i == 0 {
		return "+"
	} else {
		return "-"
	}
}

func main() {
	var ops1 []func(int, int) int
	ops1 = append(ops1, add)
	ops1 = append(ops1, del)
	s := ""
	fmt.Scan(&s)
	inputs := make([]int, 0, 4)
	for _, tmpS := range strings.Split(s, "") {
		inputs = append(inputs, stringToInt(tmpS))
	}

	for i := 0; i < 2; i++ {
		for j := 0; j < 2; j++ {
			for k := 0; k < 2; k++ {
				if 7 == ops1[k](ops1[j](ops1[i](inputs[0], inputs[1]), inputs[2]), inputs[3]) {
					fmt.Printf("%d%s%d%s%d%s%d=7\n", inputs[0], intToOpe(i), inputs[1], intToOpe(j), inputs[2], intToOpe(k), inputs[3])
					return
				}
			}
		}
	}

}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        n = ni();
        int m = ni();
        graph= new ArrayList<>();
        for (int i = 0; i < n; i++){
            graph.add(new ArrayList<>());
        }
        for (int i = 0; i < m; i++) {
            int a = ni()-1;
            int b = ni()-1;
            graph.get(a).add(b);
            graph.get(b).add(a);
        }
        dfs(0,1);
        
        out.println(ans);
    }
    
    int n;
    ArrayList<ArrayList<Integer>> graph;
    int ans=0;

    void dfs(int next, int state){
        state = state | 1<<next;
        if(state == (1<<n)-1){
            ans++;
            return;
        }
        for (Integer n : graph.get(next)) {
            if((1<<n & state) ==0){
                dfs(n,state);
            }
        }
    }
 
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 21716
N = int(input())    #テストケースの個数
#SはAC, WA, TLE, RE のいずれか

C = [0,0,0,0]
for i in range(N):
    s = input()
    if s == "AC":
        C[0] += 1
    elif s == "WA":
        C[1] += 1
    elif s == "TLE":
        C[2] += 1
    else:
        C[3] += 1

print("AC x " + str(C[0]))
print("WA x " + str(C[1]))
print("TLE x " + str(C[2]))
print("RE x " + str(C[3]))

Measured memory_bytes: 9224
#define __mode_debug__
/*   ξ
     ll
   ＿ll＿
 ／  ∞  ＼
│*  Ａ  *│
│*  Ｃ  *│
│*  祈  *│
│*  願  *│
│*      *│
 ￣￣￣￣￣    */
//C++14 (GCC 5.4.1)
#include <bits/stdc++.h>
using namespace std;
#ifdef __mode_debug__
    #define DBG
#else
    #define DBG if(false)
#endif

#define LLINF (1LL<<60)
using ll = long long;
#define mod  1000000007

#define whole(a) (a).begin(),(a).end()
#define rwhole(a) (a).rbegin(),(a).rend()

#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(ll i=(a);i>=(b);i--)
#define each(itr,ds) for(auto itr=(ds).begin();itr!=(ds).end();itr++)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

//DUMP
//  ostream vector<T> , vector<vector<T>> , set<T> ,queue<T> , priority_queue<T> , pair<T,U> , map<T,U>
template<class T> ostream& operator<<(ostream&os,vector<T>&vec){os<<"{ ";rep(i,vec.size()) os<<((i==0)?"":", ")<<i<<":"<<vec[i];os<<" }";return os;}
template<class T> ostream& operator<<(ostream&os,vector<vector<T>>&vec){os<<"{"<<endl;rep(i,vec.size())os<<"\t   "<<i<<":"<<vec[i]<<((i==vec.size()-1)? "":",")<<endl;os<<"\t }";return os;}
template<class T> ostream& operator<<(ostream&os,set<T>&p){os<<"{ ";each(itr,p)  os<<((itr==p.begin())?"":", ")<<*itr;os<<" }";return os;}
template<class T> ostream& operator<<(ostream&os,queue<T>&p){queue<T> q(p);os<<"[< "<<(q.empty()?" <]":"");while(!q.empty()){os<<q.front();q.pop();os<< (q.empty() ? " <]" : ", ");}return os;}
template<class T> ostream& operator<<(ostream&os,priority_queue<T>&p){priority_queue<T> q(p);os<<"[< "<<(q.empty()?" <]":"");while(!q.empty()){os<<q.top();q.pop();os<< (q.empty() ? " <]" : ", ");}return os;}
template<class T,class U> ostream& operator<<(ostream&os,pair<T,U>&p){os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T,class U> ostream& operator<<(ostream&os,map<T,U>&p){os<<"{ ";each(itr,p)os<<((itr==p.begin())?"":", ")<<itr->first<<":"<<itr->second;os<<" }";return os;}
void dump_f(string &nm,char t){cerr<<endl;}
template<class T,class... Ts> void dump_f(string &nm,char t,T &&x,Ts&&... ts){int l=nm.find_first_of(',');string name(nm,0,l),nx(nm,l+1,-1);if(t=='\n') cerr<<"  "<<name<<"\t: "<<x<<t;else cerr << name<<": "<<x<<","<<t;dump_f(nx,t,forward<Ts>(ts)...);}
template<class... Ts> void dump_m(int &&ln,string &&nm,char t,Ts&&... ts){cerr<<"[ln: "<<ln<<"]"<<t;dump_f(nm,t,forward<Ts>(ts)...);}
#define dump(...) DBG dump_m(__LINE__,#__VA_ARGS__,'\n',__VA_ARGS__)
#define dl(...) DBG dump_m(__LINE__,#__VA_ARGS__,'\t',__VA_ARGS__)

#define lower_bound_idx(V,c) distance(V.begin(),lower_bound(whole(V),c))

int main() {
    ios::sync_with_stdio(false);//printf<=>cout
    cin.tie(nullptr);//cin<=>cout


    ll A;
    string x;
    cin >>A>>x;
    ll B= (x[0]-'0')*100+(x[2]-'0')*10+(x[3]-'0');
    cout << A*B/100 <<'\n';


    return (0);
}

Measured memory_bytes: 3680
import java.util.Scanner;
public class Main {
public static void main(String[]srgs) {
	Scanner scan=new Scanner(System.in);
	int a=scan.nextInt();
	int b=scan.nextInt();
	if(a<=0&&b>=0) {
		System.out.println("Zero");
	}
	else if(a<0&&Math.abs((a-b+1))%2==1){
		System.out.println("Negative");
	}
	else {
		System.out.println("Positive");
	}
	scan.close();
	}
}


Measured memory_bytes: 23124
#include <stdio.h>
int dp[1010][1010];
typedef long long ll;
ll M = 1000000007;
int f(int n, int k)
{
	if (dp[n][k]) return dp[n][k];
	if (n == k) return 1;
	if (k == 0) return 1;
	if(n<=1000&&k<=1000) return dp[n][k]=f(n - 1, k - 1) + f(n - 1, k);
	else return f(n - 1, k - 1) + f(n - 1, k);
}
ll pow2(long long base, int index, int mod) {
	if (index == 1) return base;
	if (index % 2 == 0) {
		long long r = pow2(base, index / 2, mod);
		return (r * r) % mod;
	}
	else {
		return (base * pow2(base, index - 1, mod)) % mod;
	}
}

int main()
{
	int x, y;
	scanf("%d %d", &x, &y);
	int a, b;
	a = (2 * y - x) / 3;
	b = (2 * x - y) / 3;
	ll A=1;
	ll B = 1;
	if ((2 * x - y) % 3 == 0 && (2 * y - x) % 3 == 0 && (2 * y - x) >= 0 && (2 * x - y) >= 0)
	{
		for (ll i = a + b; i >= 1; i--)
		{
			A *= i;
			A %= M;
		}
		for (ll i = a; i >= 1; i--)
		{
			B *= i;
			B %= M;
		}
		for (ll i = b; i >= 1; i--)
		{
			B *= i;
			B %= M;
		}
		B=pow2(B, M - 2, M);
		printf("%lld", (A*B)%M);
	}
	else
	{
		printf("0");
	}
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();
	
	string s; cin >> s;
	bool is = false;
	if (s[2] == s[3] && s[4] == s[5])is = true;
	else is = false;
	cout << (is ? "Yes" : "No") << "\n";
	
	return 0;
}

Measured memory_bytes: 256
import fractions
N=int(input())
l1=list(map(int,input().split()))
l2=[0]*(N+1)
l3=[0]*(N+1)
for i in range(N):
  l2[i+1]=fractions.gcd(l2[i],l1[i])
for j in range(N-1,0,-1):
  l3[j-1]=fractions.gcd(l3[j],l1[j])
ans=1
for k in range(N):
  ans=max(ans,fractions.gcd(l2[k],l3[k]))
print(ans)

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

int N;
string S;

int main(){
    cin>>N>>S;

    for(int i=0;i<S.size();i++){
        if(S[i]+N<='Z'){
            S[i]+=N;
        }else{
            S[i]='A'+S[i]+N-'Z'-1;
        }
    }

    cout<<S<<endl;
}

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

int main() {
  string N;
  cin >> N;
  if (N.at(0)=='7'||N.at(1)=='7'||N.at(2)=='7') {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3632
#include<stdio.h>

int main(){
    int A,B,C,N[101]={},i,j,k;
    scanf("%d%d%d",&A,&B,&C);
    for(i=1;i<=100;i++){
        N[i]=A*i%B;
        if(i>=2 && N[i]==N[1]){
            break;
        }
    }
    for(j=1;j<=i;j++){
        if(N[j]==C){
            k=1;
            break;
        }else{
            k=0;
        }
    }
    if(k==1){
        puts("YES");
    }else{
        puts("NO");
    }
    return 0;

}

Measured memory_bytes: 128
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define LL long long
#define M 200020
#define MAXN 8004
#define bas 2002
#define mod 1000000007
#define inv2 500000004 
using namespace std;
int read(){
	int nm=0,fh=1; char cw=getchar();
	for(;!isdigit(cw);cw=getchar()) if(cw=='-') fh=-fh;
	for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
	return nm*fh;
}
int add(int x,int y){return (x+y)>=mod?x+y-mod:x+y;}
int mus(int x,int y){return (x-y)<0?x-y+mod:x-y;}
int mul(int x,int y){return (LL)x*(LL)y%mod;}
void upd(int &x,int y){x=add(x,y);}
int qpow(int x,int sq){
	int res=1; x%=mod;
	while(sq){if(sq&1) res=mul(res,x);x=mul(x,x),sq>>=1;}
	return res;
}
int n,m,fac[MAXN],ifac[MAXN],F[bas<<1][bas<<1],A[M],B[M],ans;
int C(int tot,int tk){return mul(mul(fac[tot],ifac[tk]),ifac[tot-tk]);}
int main(){
	n=read(),fac[0]=1;
	for(int i=1;i<MAXN;i++) fac[i]=mul(fac[i-1],i),ifac[i]=qpow(fac[i],mod-2);
	for(int i=1;i<=n;i++) A[i]=read(),B[i]=read(),F[bas-A[i]][bas-B[i]]++;
	for(int i=1;i<(bas<<1);i++){
		for(int j=1;j<(bas<<1);j++) upd(F[i][j],add(F[i-1][j],F[i][j-1]));
	}
	for(int i=1;i<=n;i++){
		upd(ans,F[bas+A[i]][bas+B[i]]);
		upd(ans,mod-C((A[i]+B[i])<<1,A[i]<<1));
	}
	printf("%d\n",mul(ans,inv2)); return 0;
}

Measured memory_bytes: 64512
#include<iostream>
using namespace std;
int a[200005],tmp[200005],n;
long long ans;
long long merge(int a[],int l,int m,int r,int tmp[])
{
    int p1=l,p2=m+1,p3=0;
    long long cnt=0;
    while(p1<=m&&p2<=r)
    {
        if(a[p1]<=a[p2]) tmp[p3++]=a[p1++];
        else {tmp[p3++]=a[p2++];cnt+=m-p1+1;}
    }
    while(p1<=m) tmp[p3++]=a[p1++];
    while(p2<=r) tmp[p3++]=a[p2++];
    for(int i=0;i<=r-l;i++) a[i+l]=tmp[i];
    return cnt;
}
long long mergesort(int a[],int l,int r,int tmp[])
{
    long long v1,v2,v3;
    if(l<r)
    {
        int m=l+(r-l)/2;
        v1=mergesort(a,l,m,tmp);
        v2=mergesort(a,m+1,r,tmp);
        v3=merge(a,l,m,r,tmp);
        return v1+v2+v3;
    }
    return 0;
}
int main()
{
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    ans=mergesort(a,0,n-1,tmp);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
#define debug(x) cerr << x << endl
#define Complex complex<double>
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

/*
テストケース全てに目を通す
テストケースが2個以下だったらなんかある
N最小のコーナーケースがないか調べる
制約をしっかりと確認する（1からNまでの順列、全て異なる値などの制約も含め）
制約のn*mとn,mを読み違えない
操作の逆順を考える
オーバーフローしないか確かめる
Codeforcesではscanfを使う
modの引き算には+modをする
エラー出力は消す
エラー出力を消せ！！！！！
数値の区切り位置を誤読しない
木はn-1ノード
関数単位で調べる
cout << fixed;
cout << setprecision(n) << ans;
 */

int main() {
    int n;
    cin >> n;
    int x[n]={};
    rep(i,n-1){
        int a;
        cin >> a;
        a--;
        x[a]++;
    }
    rep(i,n)cout << x[i] << endl;


    
}

/*
*/


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

#define fi first
#define se second
#define pb push_back
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define FOR(i, a, b) for (int i = a; i <= (b); i++)
#define ROF(i, a, b) for (int i = a; i >= (b); i--)

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<ll>; using vvll = vector<vll>;

pii ch[4] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};

int main() {
    int h, w; cin >> h >> w;
    vector <vector <char> > c(h + 1, vector <char> (w + 1));
    FOR(i, 1, h) FOR(j, 1, w)
        cin >> c[i][j];
    bool ok = 1;
    FOR(i, 1, h) FOR(j, 1, w) if (c[i][j] == '#') {
        bool hv = 0;
        FOR(k, 0, 3) {
            int tx = i + ch[k].fi, ty = j + ch[k].se;
            if (tx > h || tx < 1 || ty > w || ty < 1) continue;
            if (c[tx][ty] == '#') hv = 1;
        }
        if (!hv) ok = 0;
    }
    if (ok) cout << "Yes\n";
    else cout << "No\n";
}

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

#define whole(f, x, ...)                                 \
  ([&](decltype((x)) whole) {                            \
    return (f)(begin(whole), end(whole), ##__VA_ARGS__); \
  })(x)

using namespace std;
using ll = long long;

void solve() {
  int k;
  string s;
  cin >> k >> s;
  if (s.size() <= k) {
    cout << s << endl;
    ;
  } else {
    cout << s.substr(0, k) << "..." << endl;
  }
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


Measured memory_bytes: 3652
from fractions import gcd

def lcm(x, y):
    return (x*y) // gcd(x, y)

def getN():
    return int(input())
# print(lcm(10, 20))

n = getN()
ans = 1
for i in range(n):
    t = getN()
    ans = lcm(ans, t)

print(ans)


Measured memory_bytes: 63980
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  ll N, K, C, cur = 0, br = 2000000000; cin >> N >> K >> C;
  string S; cin >> S;
  vecll work(K), work2(K);
  REP(i, N) if (cur < K) {
    if (br >= C && S[i] == 'o') {
      work[cur] = i;
      cur++;
      br = 0;
    } else br++;
  } else break;

  cur = 0;
  br = 2000000000;
  REP(i, N) {
    ll j = N-i-1;
    if (cur < K) {
      if (br >= C && S[j] == 'o') {
        work2[K-cur-1] = j;
        cur++;
        br = 0;
      } else br++;
    } else break;
  }
  REP(i, K) if (work[i] == work2[i]) cout << work[i]+1 << endl;
  return 0;
}


Measured memory_bytes: 4996
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

int main() {
    ll A, B, N;
    cin >> A >> B >> N;
    ll x = min(B - 1, N);
    cout << (A * x) / B << endl;
}

Measured memory_bytes: 3568
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<cmath>
using namespace std;
int kaisuu(int n){
  int num =0;
  while(n>0){
    if(n%2==0) num++;
    else break;
    n/=2;
  }
  return num;
}
int main(){
  int n;
  cin>>n;
  int max=0;
  int ans=1;
  for(int i=1; i<=n;i++){
    int k=kaisuu(i);
    if(k>max) {max=k; ans =i;}
  }
  cout <<ans<<endl;



}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;


int main(){
  int N, K; cin >> N >> K;
  ll A[N]; rep(i,N) cin >> A[i];

  for (int i=K;i<N;i++){
    if (A[i-K]<A[i]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }


  // cout << fixed << setprecision(10);
  
  return 0;
}


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

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

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

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

    string S; cin >> S;
    bool A = true;
    if (S[2] >= '2') {
        A = false;
    } else if (S[2] >= '1') {
        A = S[3] <= '2';
    } else if (S[2] == '0' && S[3] == '0') {
        A = false;
    }

    bool X = A;
    string S2(S); S2[0] = S[2]; S2[1] = S[3]; S2[2] = S[0]; S2[3] = S[1];

     A = true;
    if (S2[2] >= '2') {
        A = false;
    } else if (S2[2] >= '1') {
        A = S2[3] <= '2';
    } else if (S2[2] == '0' && S2[3] == '0') {
        A = false;
    }



    bool Y = A;

    if (X && Y) {
        cout << "AMBIGUOUS";
    } else if (X) {
        cout << "YYMM";
    } else if (Y) {
        cout << "MMYY";
    } else {
        cout << "NA";
    }
    cout << endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a[3],i,k;
  for(i=0;i<3;i++)
  {
    cin>>a[i];
  }
  sort(a,a+3);
  k=a[0]*a[1]/2;
  cout<<k<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define f first
#define s second
using namespace std;

void fast(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
}

int main(){
	fast();
	ll n,cnt=0,ans=0;
	cin>>n;
	while(n){
		n=n/2;
		cnt++;
	}
	for(ll i=0;i<cnt;i++){
		ans+=pow(2.0,i);
	}
	cout<<ans;
}

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

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  deque<char> s;
  int rev = 0;
  string tmp;
  cin >> tmp;
  for(auto c : tmp) s.push_back(c);
  int Q;
  cin >> Q;
  while(Q--) {
    int t;
    cin >> t;
    if(t == 1) rev ^= 1;
    else {
      int f;
      char c;
      cin >> f >> c;
      --f;
      if(f ^ rev) s.push_back(c);
      else s.push_front(c);
    }
  }
  if(rev) reverse(s.begin(), s.end());
  string ans(s.begin(), s.end());
  cout << ans << '\n';
}

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

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int a = sc.nextInt();
		String s = sc.next();
		String ans = "red";
		if (a >= 3200) {
			ans = s;
		}
		System.out.println(ans);
	}

}

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

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

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

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

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

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

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

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


Measured memory_bytes: 21332
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define modulo 1000000007
typedef long long int ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int main(int argc, char const *argv[])
{
	string s;
	cin >> s;

	int ans(1);
	int length = 1;
	vector<char> v;
	v.push_back(s[0]);

	for(int i=1; i<s.size(); i++){
		if(length==1){
			if(v[0] != s[i]){
				ans ++;
				v[0] = s[i];
				continue;
			}else{
				length = 2;
				v[0] = s[i];
				continue;
			}
		}
		if(length==2){
			if(v.size()==1){
				v.push_back(s[i]);
				ans ++;
				continue;
			}else{
				v.clear();
				v.push_back(s[i]);
				ans ++;
				length = 1;
				continue;
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 640
a, b, c, x, y = map(int, input().split())
if a+b < 2*c:
    print(x*a+y*b)
elif a > 2*c:
    print(x*2*c+max(0, y-x)*min(b, 2*c))
elif b > 2*c:
    print(y*2*c+max(0, x-y)*min(a, 2*c))
elif x >= y:
    print(y*2*c+(x-y)*a)
else:
    print(x*2*c+(y-x)*b)


Measured memory_bytes: 3060
(* O(n log n) *)
Scanf.scanf "%d" @@ fun n ->
  let a_s = Array.init (3 * n) @@ fun _ -> Scanf.scanf " %d" @@ (+) 0 in
  Array.sort (fun x y -> y - x) a_s;
  let a2s = Array.init n @@ fun i -> a_s.(i * 2 + 1) in
  Array.fold_left (+) 0 a2s |> Printf.printf "%d\n"

Measured memory_bytes: 6144
#include "bits/stdc++.h"
using namespace std;

int main(){
  int n;
  cin>>n;
  int ans=0;
  vector<int> a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n-1;i++){
    if(a[i]==a[i+1]){
      ans++;
      a[i+1]=-1;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define Max 100000
using namespace std;

int n,A[Max+1],L[Max];
//A[]:数列,L[i]:長さがi+1であるような増加部分列の最後の要素の最小値とする配列

int lis(){
    L[0] = A[0];
    int length = 1; //length:i番目の要素までを使った最長増加部分列の長さを表す整数

    for(int i=1;i<n;i++){
        if(L[length-1] < A[i]){
            L[length++] = A[i]; //LISの最後の要素より大きかったらLISに追加
        }else{
            *lower_bound(L,L+length,A[i]) = A[i];
            //lower_bound(first,last,key)
            //L[lower_bound(L,L+length,A[i])]にA[i]を代入
            
        }
    }
    return length;
}

int main(){
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> A[i];
    }

    cout << lis() << endl;
}


/*
in
5
5
1
3
2
4

out
3
*/


Measured memory_bytes: 3768
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include<functional>

using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int N;
ll res,H,t=0,mxs=0;
vector<ll>S;


int main()
{
	cin>>N>>H;
	for(int i=0;i<N;i++)
	{
		ll a,b;
		cin>>a>>b;
		mxs=max(a,mxs);
		S.push_back(b);
	}
	sort(S.begin(),S.end(),greater<ll>());
	res=H/mxs+(H%mxs?1:0);
	for(int i=1;i<=N;i++)
	{
		t+=S[i-1];
		if(H<=t)res=min(res,0LL+i);
		else res=min(res,(H-t)/mxs+((H-t)%mxs?1:0)+i);
	}
	cout<<res<<endl;
}


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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int a,b,c;
	cin>>a>>b>>c;
	if(c>=a && c<=b) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
input = sys.stdin.buffer.readline


def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))

# mod=10**9+7
# rstrip().decode('utf-8')

#import numpy as np
from itertools import combinations

def main():
	n,k=MI()
	ans=10**18

	A=LI()
	A=[A[0]-1]+A

	for t in combinations(range(n),k):
		B=A.copy()
		tmp=0
		for i in t:
			i+=1
			B[i]=max(max(B[:i])+1,A[i])
			tmp+=B[i]-A[i]
		ans=min(ans,tmp)
	print(ans)

if __name__ == "__main__":
	main()


Measured memory_bytes: 3064
n,x = map(int,input().split())
kids = list(map(int,input().split()))

kids.sort()
i=0
while i<n and x>=kids[i]:
  x-=kids[i]
  i+=1

if x!=0 and i==n:
  i-=1
if i<0:
  i=0
  
print(i)

Measured memory_bytes: 3060
import heapq
k,t = map(int,input().split())
a = list(map(int,input().split()))
mx = max(a)
others = k - mx
if t == 1:
    print(k - 1)
    exit()

if others >= mx - 1:
    print(0)
else:
    print(mx - others - 1)


Measured memory_bytes: 3064
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

def less_than(array, x):
    # arrayの中のx未満のものの個数
    # arrayの中のx未満のもののうちの最大値
    index = bisect_left(array, x)
    if index == 0:
        less_than_int = -float('inf')
    else:
        less_than_int = array[index - 1]
    return [index, less_than_int]

N = getN()
up = getList()
up.sort()
mid = getList()
mid.sort()
low = getList()
low.sort()

# 中段のパーツに載せられる上段のパーツの数
mid_imos = [0] * N
for i in range(N):
    mid_imos[i] = less_than(up, mid[i])[0]

for i in range(N - 1):
    mid_imos[i + 1] += mid_imos[i]

low_imos = [0] * N
for i in range(N):
    ind = less_than(mid, low[i])[0]
    if ind > 0:
        low_imos[i] = mid_imos[ind - 1]
print(sum(low_imos))

Measured memory_bytes: 116156
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
#define rep(i, s, n)      for(int i(s); i < int(n); ++i)
#define endl '\n'
#ifndef YDK
#define eprintf(...)
#endif
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr const int INF  = 0x3f3f3f3f;
constexpr const i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr const int MOD  = int(1e9) + 7;
// }}}

// Library {{{
constexpr i64 modPow(i64 n, i64 p, const int mod = int(1e9)+7)
{
    i64 ret = 1;
    while(p) {
        if (p & 1) ret = (ret * n) % mod;
        n = (n * n) % mod;
        p >>= 1;
    }
    return ret;
}

template<int MOD> class ModInt {
private:
    long long n;
    using T = ModInt<MOD>;
public:
    static constexpr const int mod = MOD;
    constexpr inline ModInt(long long n_) : n(n_ % MOD) {}
    template<class Int> constexpr explicit inline operator Int() const { return n; }
    friend ostream& operator<<(ostream &os, T m) { os << m.n; return os; }
    constexpr inline T operator~() const { return modPow(n, MOD-2, MOD); }
    constexpr inline T& operator+=(T o) { n = (n + o.n) % MOD; return *this; }
    constexpr inline T& operator-=(T o) { n = (n - o.n + MOD) % MOD; return *this; }
    constexpr inline T& operator*=(T o) { n = (n * o.n) % MOD; return *this; }
    constexpr inline T& operator/=(T o) { n = (n * (~o).n) % MOD; return *this; }
};
using Mint = ModInt<int(1e9)+7>;
Mint operator+(Mint a, Mint b) { return Mint(a) += b; }
Mint operator-(Mint a, Mint b) { return Mint(a) -= b; }
Mint operator*(Mint a, Mint b) { return Mint(a) *= b; }
Mint operator/(Mint a, Mint b) { return Mint(a) /= b; }

template<size_t N, int MOD=int(1e9)+7> struct Factrial {
    using Mint = ModInt<MOD>;
    i64 a[N];
    constexpr inline Factrial() : a{1} { for (int i = 1; i < N; ++i) a[i] = (a[i-1] * i) % MOD; }
    constexpr inline Mint operator[] (size_t i) const { return a[i]; }
};

Factrial<200010> fact;

Mint nCr(i64 n, i64 r) { return (r < 0 || n < r) ? 0 : (fact[n] / (fact[r] * fact[n-r])); }

Mint nPr(i64 n, i64 r) { return (r < 0 || n < r) ? 0 : (fact[n] / fact[r]); }

Mint nHr(i64 n, i64 r) { return nCr(n+r-1, r); }
// }}}


signed main()
{
    int H, W, A, B;
    cin >> H >> W >> A >> B;

    auto f = [&](int sx, int sy, int gx, int gy) -> Mint {
        int h = abs(gy - sy + 1);
        int w = abs(gx - sx + 1);
        return fact[h+w-2] / (fact[w-1] * fact[h-1]);
    };

    Mint ans = 0;
    for (int x = B+1; x <= W; ++x) {
        ans += f(1, 1, x, H-A) * f(x, H-A+1, W, H);
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast {ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
typedef long long int ll;
typedef string S;
#define M 1e18
#define AS 1000005
#define in(x)  cin>>x
#define in4(w,x,y,z) cin>>w>>x>>y>>z
#define in3(x,y,z) cin>>x>>y>>z
#define o(x)  cout<<x
#define o2(x,y) cout<<x<<' '<<y;
#define o3(x,y,z) cout<<x<<' '<<y<<' '<<z
#define o4(w,x,y,z)cout<<w<<' '<<x<<' '<<y<<' '<<z
#define sp cout<<' '
#define nw cout<<endl
#define rt return
#define fr(i,a,n) for(ll i=a;i<=n;i++)
#define frm(i,a,n) for(ll i=n;i>=a;i--)
#define P pair<ll,ll>
#define vc vector<ll>
#define pb push_back
#define MP map<ll,ll>
bool sortin(const pair<ll,ll> &e,const pair<ll,ll> &f){return (e.first<f.first);}
bool POT(ll x){return x && (!(x&(x-1)));}
ll i,j,k,l,m,n,p,q,r,a,b,c,x,y,z,ts,mn=1e18,mod=1e9+7;
ll ar[AS],br[AS],xr[AS],tem[AS];
void sieve()
{
    fr(i,2,AS-5)
    {
        if(xr[i]==0)
        {
            for(j=i;j<=AS-5;j+=i)
            {
                if(xr[j]==0)
                xr[j]=i;
            }
        }
    }
}
int main()
{
    fast;
   in(n);
   fr(i,1,n)in(ar[i]),c=__gcd(c,ar[i]);
   if(c>1){o("not coprime");rt 0;}
   sieve();
   fr(i,1,n)
   {
       while(ar[i]>1)
       {
           br[ar[i]]++;
           if(br[ar[i]]>1){o("setwise coprime");rt 0;}
           ar[i]/=xr[ar[i]];
       }
   }
   o("pairwise coprime");
}


Measured memory_bytes: 19920
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x,n;cin>>x>>n;
  	if(n==0)cout<<x;
  else{
    vector<int >b(101,0);
    for(int i=0,a;i<n;i++){cin>>a;b[a]=1;}
  	int mini = 1000000000;
    int index = -1;
    for(int i=0;i<=101;i++){
    	if(b[i]==0){
        	if(abs(x-i)<mini){mini = abs(x-i);index = i;}
        }
    }
    cout<<index;
  }
}

Measured memory_bytes: 3620
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}
import Data.Char (isSpace)
import Data.Int (Int64)
import Data.List (unfoldr)
import Control.Monad
import Control.Monad.ST
import Control.Monad.Trans.Maybe
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS

topologicalSort :: V.Vector [Int] -> Maybe (U.Vector Int)
topologicalSort edges_from = runST $ runMaybeT $ do
  let !n = V.length edges_from -- 頂点の個数
  vec <- UM.new n
  seen <- UM.replicate n False
  iref <- UM.replicate 1 (n - 1)
  seen <- UM.replicate n (0 :: Int) -- 0: new, 1: active, 2: finished
  let dfs x = do
        UM.write seen x 1
        forM_ (edges_from V.! x) $ \y -> do
          -- 辺 (x,y) が存在
          s <- UM.read seen y
          case s of
            0 -> dfs y
            1 -> mzero
            _ -> return ()
        UM.write seen x 2
        i <- UM.read iref 0
        UM.write vec i x
        UM.write iref 0 (i - 1)
  forM_ [0..n-1] $ \x -> do
    s <- UM.read seen x
    when (s == 0) $ dfs x
  U.unsafeFreeze vec

longest :: Int -> V.Vector [Int] -> Int
longest !n edges = U.maximum $ U.create $ do
  vec <- UM.replicate n (-1 :: Int)
  let dfs x = do
        v <- UM.read vec x
        if v == -1
          then do ys <- mapM dfs (edges V.! x)
                  let !v = 1 + maximum (0 : ys)
                  UM.write vec x v
                  return v
          else return v
  forM_ [0..n-1] $ \i -> dfs i
  return vec

main = do
  n <- readLn
  xs <- V.replicateM n $ do
    U.map (subtract 1) . U.unfoldrN (n-1) (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let makePair i j | i < j = n * i - (i + 1) * i `quot` 2 + j - i - 1
                   | otherwise = undefined
  let edges :: V.Vector [Int]
      edges = V.create $ do
        e <- VM.replicate (n * (n - 1) `quot` 2) []
        V.forM_ (V.indexed xs) $ \(i,ys) -> do
          U.forM_ (U.zip ys (U.tail ys)) $ \(a,b) -> do
            -- (i,a) -> (i,b)
            let !b' = makePair (min i b) (max i b)
            VM.modify e (b' :) (makePair (min i a) (max i a))
        return e

  let p :: U.Vector (Int, Int)
      p = U.create $ do
        vec <- UM.new (n * (n - 1) `quot` 2)
        forM_ [0..n-1] $ \i -> do
          forM_ [i+1..n-1] $ \j -> do
            UM.write vec (makePair i j) (i,j)
        return vec

  let sorted = topologicalSort edges
  case sorted of
    Nothing -> putStrLn "-1"
    Just sorted -> do
      print $ longest (n * (n - 1) `quot` 2) edges


Measured memory_bytes: 103676