akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

ll a[100010],s[100010];

int main(void){
	          int i;

	          int N;
	          cin >> N;
	          for(i=0;i<N;i++) cin >> a[i];
	          sort(a,a+N);

	          s[0]=a[0];
	          for(i=1;i<N;i++) s[i]=s[i-1]+a[i];
	          int p=0;
	          for(i=1;i<N;i++) if(a[i]>2*s[i-1]) p=i;

	          cout << N-p << endl;

	          return 0;
}


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

int main(void) {
    int K, A, B;
    cin >> K >> A >> B;
    for (int i = A; i <= B; i++) {
        if (i % K == 0) {
            printf("OK\n");
            return 0;
        }
    }
    printf("NG\n");
    return 0;
}

Measured memory_bytes: 3620
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

const int N=2e5+5;
char s[N];
int n,ans;

signed main(){
	scanf("%s",s+1);n=strlen(s+1);
	for(int i=2,last=1;i<=n;i++){
		ans++;
		if(last==1){
			if(s[i]==s[i-1]){
				if(i<n) i++,last=2;
				else ans--;
			}
		}
		else last=1;
	}
	write(ans+1);
}

Measured memory_bytes: 3940
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
typedef long long ll;
int main(){

	int n,m,c;
	cin >> n>>m>>c;
	int bs[25] = {};
	int as[25][25] = {};

	rep(i,m) {
		cin >> bs[i];
	}

	rep(i,n) {
		rep(j,m) {
			cin >> as[i][j];
		}
	}
	ll cnt = 0;

	rep(i,n) {
		int key = c;
		rep(j,m) {
			key += as[i][j]*bs[j];
		}
		if (key>0) {
			cnt++;
		}
 	}

 	cout << cnt << endl;
 }

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

int main() {
  ll N, A, B; cin>>N>>A>>B;
  if(A>B) cout<<0<<endl;
  else if(N==1 && A!=B) cout<<0<<endl;
  else{
    cout<<(B*(N-1)+A)-(A*(N-1)+B)+1<<endl;
  }
}


Measured memory_bytes: 256
n,a,b=map(int,input().split())
if a == 0:
    print(0)
    exit()
if a > n:
    print(n)
    exit()
if b > n:
    print(a)
    exit()
if n%(a+b) > a:
    print((n//(a+b))*a + a)
    exit()
print((n//(a+b))*a + (n%(a+b)))

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

int main(){
    int w,a,b;
    cin>>w>>a>>b;
    if(a<b){
        if(0<(b-a-w)){cout<<(b-a-w);}
        else{cout<<0;}
    }
    else{
       if(0<(a-b-w)){cout<<(a-b-w);}
        else{cout<<0;} 
    }
    return 0;
}

Measured memory_bytes: 764
using System;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(ReadLine());
        int[] A = ReadLine().Split(' ').Select(int.Parse).ToArray();
        bool t = true;
        int ans = 0;
        while (t)
        {
            for(int i = 0; i < N; i++)
            {
                if(A[i] % 2 == 0)
                {
                    A[i] /= 2;
                }
                else
                {
                    t = false;
                    break;
                }
            }
            if (t)
            {
                ans++;
            }
        }
        WriteLine(ans);
    }
}

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

int main(){
	long long int S; 
	cin >> S;
	long long int k = 1000000000;
	long long int n = (S + k - 1) / k;
	long long int m = k * n - S;
	cout << 0 << " " << 0 << " " << k << " " << 1 << " " << m << " " << n <<endl;
}

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

int main()
{
    long r,c;
    cin>>r>>c;
    if(r == 1 || c == 1)
        cout<<1<<"\n";
    else cout<<(r*c+1)/2<<endl;
    return 0;
}

Measured memory_bytes: 3580
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
        	int tmp = sc.nextInt();
        	map.put(tmp, i+1);
        }
		sc.close();
		for (int i = 0; i < n; i++){
			System.out.print(map.get(i+1));
			if(i+1 != n){
				System.out.print(" ");
			}
		}
	}
}

Measured memory_bytes: 71244
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);

    for(ll i = 0;i < N;i++)
        cin >> A.at(i);

    sort(A.begin(),A.end());
    
    ll hako=0;

    ll i = 0,rs=0,ans=0;

    while(i < A.size()){
        hako = A.at(i);
        while(i < A.size()){
            if(hako == A.at(i)){
                rs++;
                i++;
            }else{
            break;
            }
        }

        if(rs % 2 == 1)
            ans++;

        rs = 0;

    }

    cout << ans << endl;

}

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

using namespace std;

typedef long long ll;

ll N[1001][1001];
int H, W, Ch, Cw, Dh, Dw;
char  S[1001][1001];
deque <pair<int, int>> q;

void visit(int h, int w, int n, bool front) {
    if (h <= 0 || h > H || w <= 0 || w > W) { return; }
    if (S[h][w] == '#') { return; }

    if (N[h][w] <= n) {
        return;
    }
    N[h][w] = n;
    
    //printf("  %d, %d: %ld\n", h, w, n);

    if (h == Dh && w == Dw) { return; }

    if (front) {
        q.push_front(pair<int, int>(h, w));
    }
    q.push_back(pair<int, int>(h, w));
}

int main() {
    cin >> H >> W;
    cin >> Ch >> Cw;
    cin >> Dh >> Dw;

    for (int h = 1; h <= H; h++) {
        for (int w = 1; w <= W; w++) {
            char s;
            cin >> s;
            S[h][w] = s;
            N[h][w] = 99999999999999;
        }
    }

    N[Ch][Cw] = 0;

    q.push_back(pair<int, int>(Ch, Cw));
    while (q.size() > 0) {
        pair<int, int> nxt = q.front();
        q.pop_front();
        int h = nxt.first;
        int w = nxt.second;
        int n = N[h][w];

        //printf("at %d, %d\n", h, w);

        if (h == Dh && w == Dw) {
            continue;
        }

        visit(h-1, w, n, true);
        visit(h+1, w, n, true);
        visit(h, w-1, n, true);
        visit(h, w+1, n, true);

        for (int nh = h - 2; nh <= h + 2; nh++) {
            for (int nw = w - 2; nw <= w + 2; nw++) {
                visit(nh, nw, n+1, false);
            }
        }

        //cout << "-----" << endl;
    }

    if (N[Dh][Dw] == 99999999999999) {
        cout << -1 << endl;
    }else {
        cout << N[Dh][Dw] << endl;
    }
}

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

using namespace std;
using ll = long long;

int main() {
  string S;
  cin >> S;
  for (int i = 1; i < 4; ++i) {
    if(S[i-1]==S[i]){
      cout<<"Bad"<<endl;
      return 0;
    }
  }
  cout << "Good" << endl;
}


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

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

template <typename T>
class FenwickTree
{
    int n;
    std::vector<T> bit;

  public:
    FenwickTree(int _n) : n(_n), bit(_n, 0) {}

    void add(int pos, const T &w)
    {
        assert(0 <= pos && pos < n);
        for (int i = pos; i < n; i |= i + 1)
            bit[i] += w;
    }
    // v[0] + ... + v[pos-1]
    T sum(int pos)
    {
        assert(0 <= pos && pos <= n);
        T res = 0;
        for (int i = pos - 1; i >= 0; i = (i & (i + 1)) - 1)
        {
            res += bit[i];
        }
        return res;
    }
    T sum(int l, int r)
    {
        assert(0 <= l && l <= r && r <= n);
        return sum(r) + (-sum(l));
    }
};

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

    ll n;
    cin >> n;
    int ret = 0;
    while (n > 1)
    {
        ret++;
        n = (n - 1) / 3 + 1;
    }
    cout << ret << endl;
}


Measured memory_bytes: 3152
function Main(input) {
    const [n, k] = input.split(" ").map(str => Number(str));
    let result = 0;
    for (let i = 1; i <= n; i++) {
        let requiredCnt = 0;
        let score = i;
        while (true) {
            if (k <= score) break;
            score *= 2;
            requiredCnt++;
        }
        result += (1 / n) * (0.5 ** requiredCnt);
    }
    console.log(result);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
n, m = map(int, input().split())
s = [0] * (n+1)
cnt = 0
for i, x in enumerate(input()):
    if x == "1":
        cnt += 1
        if cnt >= m: print(-1); exit()
        s[i] = 1
    else: cnt = 0

c = n
res = []

while True:
    nc = c - m
    if nc <= 0:
        res.append(c)
        break
    while s[nc]: nc += 1
    res.append(c - nc)
    c = nc

print(*reversed(res))

Measured memory_bytes: 49532
<?php
	fscanf(STDIN, "%d %d %d", $A, $B, $K);

	if ($K <= $A) {
      $A = $A - $K;
    } else if (($K > $A) && (($K - $A) < $B)) {
      $B = $B - ($K - $A);
      $A = 0;
    } else {
      $A = 0;
      $B = 0;
    }

	echo ($A.' '.$B);
?>

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#include <bitset>
#define M 1000000007
#define M1 998244353

#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define fast                        \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

ll power(ll x, ll n)
{
    ll result = 1;
    while (n)
    {
        if (n % 2 == 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}

ll gcd(ll a, ll b)
{
    if (!b)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
    return (a * b) / gcd(a, b);
}

inline ll mul(ll x, ll y, ll m)
{
    ll z = 1LL * x * y;
    if (z >= m)
    {
        z %= m;
    }
    return z;
}

ll powmod(ll x, ll y, ll m)
{
    ll r = 1;
    while (y)
    {
        if (y & 1)
        {
            r = mul(r, x, m);
        }
        y >>= 1;
        x = mul(x, x, m);
    }
    return r;
}



void start()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
/***********************************************************************************************************/

int main()
{
    start();
    int n;
    cin>>n;
    int a[n];
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a, a+n);
    double b=a[0];
    for (int i=1;i<n;i++)
    {
        b=(b+a[i])/2.0;
    }
    cout<<b;
    return 0;
}

Measured memory_bytes: 3752
#include<bits/stdc++.h>
#include<functional>
#define ll long long
using namespace std;

int main() 
{
    int r,d,x;
    cin >> r >> d >> x;
    for (int i=0; i<10; i++)
    {
        x = x*r-d;
        cout << x << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
                                                                                                
  
int main(void){
                                                                                                
   
    int n, p, i;
   
    int a[51];

    int s = 0;

    int k = 0;
   
      
    scanf("%d %d", &n, &p);
   
    for( i = 0 ; i < n ; i = i + 1 ){

         scanf("%d", &a[i]);

         s += a[i];

         if( a[i] % 2 != 0 ){

             k += 1;

             }

         }
   
   
    if( k == 0 ){

        if( p == 0 ){

            printf("%.0f\n", pow( (double)2, (double)n) );

            return 0;

            }

            else{

                printf("0\n");

                return 0;

                }

        }

    
    else printf("%.0f\n", pow( (double)2, (double)( n - 1 )) );


    return 0;
                                                          
}

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

using namespace std;

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

    int v[N];
    int tmp;
    for (int i = 0; i < N; i++) {
        cin >> v[i];
    }

    sort(&v[0], &v[N]);
    double res = v[0];
    for (int i = 1; i < N; i++) {
        res = (res + v[i]) / 2;
    }

    cout << res << "\n";
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		for(int i = 0; i < h.length; i++) {
			h[i] = sc.nextInt();
		}
		
		int count = 0;
		int view = 0;
		for(int i = 0; i < h.length; i++) {
			int max = h[i];			
			for(int j = i; j >= 0; j--) {
				if(h[j] > h[i])	max = h[j]; 
			}
			if(max == h[i]) view++;
		}
		System.out.println(view);
		
	}

}

Measured memory_bytes: 23124
#include<stdio.h>
int main(){
    int H,W;
    for(;;){
        scanf("%d%d",&H,&W);
        if(H == 0 && W == 0){
            break;
        }
        int a[H][W];
        for(int i = 0;i < H;i++){
            for(int j = 0;j < W;j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
        
    }
    return 0;
}


Measured memory_bytes: 2680
import java.util.Scanner;

public class Main {

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

	public static void main(String[] args) {
		System.out.println(solve() ? "Possible" : "Impossible");
	}

	static boolean solve() {
		int N = sc.nextInt();
		int[] A = new int[N];
		int[] hist = new int[N];
		int max = 0;
		for (int i = 0; i < N; ++i) {
			A[i] = sc.nextInt();
			hist[A[i]]++;
			max = Math.max(max, A[i]);
		}
		if (hist[max] == 1) return false;
		if (max == 1) {
			return N == 2;
		}
		if (max == 2) {
			return hist[1] == 1;
		}
		for (int i = max; i > max / 2; --i) {
			if (hist[i] <= 1) return false;
		}
		if (max % 2 == 0) {
			if (hist[max / 2] != 1) return false;
		} else {
			if (hist[(max + 1) / 2] != 2) return false;
		}
		for (int i = 1; i <= (max - 1) / 2; ++i) {
			if (hist[i] != 0) return false;
		}
		return true;
	}

}


Measured memory_bytes: 10316
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s, p;
  cin >> s >> p;
  s += s;
  bool ans = false;
  for (int i = 0; i < s.size() - p.size(); i++){
    bool flg = true;
    for (int j = 0; j < p.size(); j++){
      if (s[i + j] != p[j]){
        flg = false;
      }
    }
    if (flg){
      ans = true;
    }
  }
  if (ans){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3204
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int a,b,x;
	scan(a>>b>>x);
	if(a*a*b<=2*x){
		double rad=atan((double)(2*a*a*b-2*x)/(a*a*a));
		double ans=rad*180/M_PI;
		prin(setprecision(11)<<ans);
	}
	else{
		double rad=atan((double)a*b*b/(2*x));
		double ans=rad*180/M_PI;
		prin(setprecision(11)<<ans);
	}
	return 0;
}


Measured memory_bytes: 384
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n):
    res = [None] * n
    for i in range(n):
        res[i] = II()
    return res
def LIR(n):
    res = [None] * n
    for i in range(n):
        res[i] = LI()
    return res
def FR(n):
    res = [None] * n
    for i in range(n):
        res[i] = IF()
    return res
def LIR(n):
    res = [None] * n
    for i in range(n):
        res[i] = IF()
    return res
def LIR_(n):
    res = [None] * n
    for i in range(n):
        res[i] = LI_()
    return res
def SR(n):
    res = [None] * n
    for i in range(n):
        res[i] = S()
    return res
def LSR(n):
    res = [None] * n
    for i in range(n):
        res[i] = LS()
    return res
mod = 1000000007
inf = float('INF')

#solve
def solve():
    a, b, c = LI()
    k = II()
    tmp = 0
    while a >= b:
        b *= 2
        tmp += 1
    while b >= c:
        c *= 2
        tmp += 1
    print("Yes" if tmp <= k else "No")
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 65724
#include<stdio.h>
int main(void){
  long L,R;
  scanf("%ld",&L);
  scanf("%ld",&R);
  long min;
  long first = R - L;
  long l=L%2019;
  long r=R%2019;
  while (l>r){
    long tmp=l;
  	l=r;
  	r=tmp;
  }
    for(long i=l;i<=2018;i++){
      for(long j=i+1;j<=r;j++){
        if( min > ((i%2019)*(j%2019)) % 2019){
          min = ((i%2019)*(j%2019))%2019;
        }
      }
    }
  if(first > 2018){
    min=0;
  }
    
  
  printf("%ld",min);
  return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main{
  public static void main(String args[]){
  Scanner sc = new Scanner(System.in);
  int n = sc.nextInt();
  String str = sc.next();
  if(n%2==1){
    System.out.println("No");
    System.exit(0);
  }else{}
  String str1 = str.substring(0,n/2);
  String str2 = str.substring(n/2);
  if(str1.equals(str2)){
    System.out.println("Yes");
  }else{
    System.out.println("No");
  }


}
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>

using namespace std;

int main()
{
    int D;
    cin >> D;
    string ans("Christmas");
    if(D == 22) ans += " Eve Eve Eve";
    else if(D == 23) ans += " Eve Eve";
    else if(D == 24) ans += " Eve";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n,m=[int(i) for i in input().split()]

#都市nがキー
keys=[i for i in range(1,n+1)]
#print(keys)
values=[0]*n
#print(values)
a_dic=dict(zip(keys,values))
#print(a_dic)

for i in range(m):
    a,b=[int(i) for i in input().split()]
    #print(a,b)
    a_dic[a]+=1
    a_dic[b]+=1


#print(a_dic)

#都市n個のvalueを出力していく    
for i in range(1,n+1):
    print(a_dic[i])

   

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

int main(){
    int H,W;
    while(1){
        cin >> H >> W;
        if(H==0&&W==0)break;
        for(int i = 0;i < H;i++){
            for(int j = 0;j < W;j++){
                if (j==0||j==W-1||i==0||i==H-1){
                    cout << "#";
                }
                else{
                    cout << ".";
                }
            }cout << endl;
        }cout << endl;
    }    
    return 0;
}


Measured memory_bytes: 3080
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#include<functional>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define printfdouble(x) printf("%.20f\n",(x))
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define cotu cout
#define Endl endl
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b){if(b<a){a=b; return 1;} return 0;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    string s; cin >> s;
    if(s[SZ(s)-1] == 's') s += "es";
    else s += "s";

    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>

#define REP(i, n) for (int i = 0; i < n; i++)
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 // 1e9+7(prime number)
#define INF 1000000000 // 1e9

using namespace std;
typedef long long ll;

int main() {
	int n, k;
	ll ans = 0, count = 0;

	cin >> n >> k;

	for (int i = k; i <= n; i += k) {
		count++;
	}

	ans += (count - 2) * (count - 1) * count + (count - 1) * count * 3 + count;
	
	// debug(count)
	// debug(ans)

	if (k % 2 == 0) {
		count = 0;

		for (int i = k / 2; i <= n; i += k) {
			count++;
		}
		
		// debug(count)

		ans += (count - 2) * (count - 1) * count + (count - 1) * count * 3 + count;
	}
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	
	int a, i[1000]={}, b, c;
	char mozi[1001]={};
	for(a=0;a<10000;a++){
	scanf("%s", mozi);
		if(mozi[0]=='0'){break;}
		for(b=0;b<1001;b++){
			
			i[a]+=mozi[b]-'0';
			if(mozi[b+1]=='\0')break;
			
		}
	}
	for(c=0;c<a;c++){
		printf("%d\n",i[c]);
	}
	return 0;
}

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

using Cost = ll; // time
struct Edge{
    Cost cost;
    int to;
    int fee;
    bool operator>(const Edge &right)const{
        return cost > right.cost;
    }
};

#define MAX_N 50
#define MAX_C 10000
#define INF ((ll)1e16)

int main(void){
    int n, m, s;
    cin >> n >> m >> s;
    s = min(s,MAX_C);
    vector<vector<Edge>> g(n);
    rep(i,m) {
        int u, v, fee;
        Cost cost;
        cin >> u >> v >> fee >> cost;
        u--, v--;
        g[u].push_back({cost, v, fee});
        g[v].push_back({cost, u, fee});
    }
    rep(i,n) {
        int c;
        Cost d;
        cin >> c >> d;
        g[i].push_back({d, i, -c});
    }

    // 運賃 Ai <= 50, M = 100 -> 必要最高枚数 = 10000
    // dp[頂点][残り枚数] = かかった時間
    vector<vector<Cost>> dp(n);
    rep(i,n) dp[i] = vector<Cost>(MAX_C+1, INF);

    dp[0][s] = 0;
    priority_queue<Edge,vector<Edge>,greater<Edge>> qu;
    qu.push(Edge{dp[0][s], 0, s});
    while (qu.size()) {
        Edge cur = qu.top(); qu.pop();
        int v = cur.to;
        int rem = cur.fee;
        if (dp[v][rem] < cur.cost) continue;
        for (Edge e : g[v]) {
            Cost next_cost = cur.cost + e.cost;
            int next_rem = min(MAX_C, rem - e.fee);
            if (rem - e.fee >= 0 && dp[e.to][next_rem] > next_cost){
                dp[e.to][next_rem] = next_cost;
                qu.push({next_cost, e.to, next_rem});
            }
        }
    }

    vector<Cost> res(n, INF);
    rep1(i,n-1)rep(j,MAX_C+1){
        res[i] = min(res[i], dp[i][j]);
    }
    rep1(i,n-1){
        cout << res[i] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 15572
#include <iostream>
using namespace std;
using ll = long long;
int main() {
	long long N, P;
	cin >> N >> P;
	bool all_even = true;
	for (long long i = 0, A; i < N; i++) {
		cin >> A;
		if (A % 2) all_even = false;
	}
	cout << (all_even ? (1LL << N) * (P == 0) : (1LL << (N - 1))) << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
//#define int ll
typedef long long ll;

const int md = 1000000007;
const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "YES" : "NO";
}

int main(){
    int c[5];
    rep(i,5) c[i] = 0;

    rep(i,6){
        int x; cin >> x;
        c[x]++;
    }

    bool ans = false;

    rep1(i,4){
        if(c[i]%2 == 0) ans = true;
    }

    cout << yn(ans) << endl;

}

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

using namespace std;

#define REP(i,x) for(int i=0; i<(int)(x); i++)       // 0 <= i < x
#define REPS(i,x) for(int i=1; i<=(int)(x); i++)     // 0 < i <= x
#define RREP(i,x) for(int i=((int)(x)-1); i>=0; i--) // x > i >= 0
#define RREPS(i,x) for(int i=((int)(x)); i>0; i--)   // x >= i > 0
#define INF 1000000000

typedef long long ll;
typedef pair<int, int> P;

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

int main(void){
    int N;
    cin >> N;
    int F[N][10], P[N][11];
    REP(i, N){
        REP(j, 10){
            cin >> F[i][j];
        }
    }
    REP(i, N){
        REP(j, 11){
            cin >> P[i][j];
        }
    }
    
	int res = -INF;
    int c;
    int profit = 0;
    for(int i = 1; i < (1 << 10); i++){
        profit = 0;
        REP(j, N){ //shop j
            c = 0;
            REP(k, 10){ //time k
                c += F[j][k] & (i >> k);
            }
            profit += P[j][c];
        }

        res = max(res, profit);
    }

    cout << res << endl;
    return 0;
}


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

#define MAX(a,b) (a > b) ? a : b
#define MIN(a,b) (a < b) ? a : b
const int inf = 1000000000; // 10^9

int main(){
   char a[101],b[101],c[101];scanf("%s %s %s",a,b,c);
   char table = 'a';
   int ta=0,tb=0,tc=0;
   for(int i = 0;i < 300;i++){
      if(table == 'a'){
         //printf("aきたよ\n");
         //printf("table:%c\na[ta]:%c\nta:%d\n",table,a[ta],ta);
         table = a[ta];
         ta++;
         if(ta-1 == strlen(a)){
            printf("A\n");
            break;
         }
      }else if(table == 'b'){
         //printf("bきたよ\n");
         //printf("table:%c\nb[tb]:%c\n",table,b[tb]);
         table = b[tb];
         tb++;
         if(tb-1 == strlen(b)){
            printf("B\n");
            break;
         }
      }else if(table == 'c'){
         //printf("cきたよ\n");
         //printf("table:%c\nc[tc]:%c\n",table,c[tc]);
         table = c[tc];
         tc++;
         if(tc-1 == strlen(c)){
            printf("C\n");
            break;
         }
      }
   }
   //printf("何もない");
   return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <iomanip>
using ll = long long;
using namespace std;
//#define int long long

#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = 0; i <= (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int i = n; i >= 0; i--)
int factorical(int n) {
	int sum = 1;
	for (int i = 1; i <= n; ++i)
	{
		sum *= i;
	}
	return sum;
}

vector<int> divisors(int n) {
	vector<int> res;
	for (int i = 1; i * i <= n; ++i) {
		if (n % i != 0) continue;
		res.push_back(i);
		if (n / i == i) continue; // 上の行で追加済み。
		res.push_back(n / i);
	}
	return res;
}
vector<ll> divisors_ll(ll n) {
	vector<ll> res;
	for (ll i = 1; i * i <= n; ++i) {
		if (n % i != 0) continue;
		res.push_back(i);
		if (n / i == i) continue; // 上の行で追加済み。
		res.push_back(n / i);
	}
	return res;
}


void printVector(const vector<int>& vec) {
	for (int value : vec) {
		cout << value << " ";
	}
	cout << endl;
}

bool pal(string s) {
	int n = s.length() / 2;
			rep(i, n) {
			if (s[i] != s[s.length() - 1 - i]) return false;
		}
			return true;
}

int main() {
	int x, y_500, y_5;
	cin >> x;
	y_500 = x / 500;
	y_5 = (x % 500) / 5;
	cout << y_500 * 1000 + y_5 * 5;

	return 0;
}




Measured memory_bytes: 256
use std::io;


fn main() {
    let s = read::<String>()[1].chars().collect::<Vec<char>>()[0];
    println!("A{}C", s);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

#define BUF_SIZE 30

int get_int3(int *a1, int *a2, int *a3) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return -1;
  sscanf(line, "%d %d %d", a1, a2, a3);
#else
#error
#endif
  return 0;
}

int main(void) {
    int bottom, height, water;
    get_int3(&bottom, &height, &water);
    double volume = bottom*bottom*height;
    double barea = bottom*bottom;
    double half = volume/2;
    double ans; // [rad]
    if(water >= half) {
        double rem = (volume-water)*2/barea;
        ans = atan(rem/bottom);
    } else {
        double c = (double)water*2/(bottom*height);
        ans = atan(height/c);
    }
#ifdef DEBUG
    printf("%lf\n", ans);
#endif
    printf("%.7lf\n", ans*180/M_PI);
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main () {
    int N;
    int A,B;

    scanf("%d",&N);

    if (N == 1) {
        printf("Hello World\n");
    } else {
        scanf("%d",&A);
        scanf("%d",&B);
        printf("%d",A+B);
    };

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define r(i, n) for (ll i=2;i<n;i++)
#define ll long long
#define llc(n) ll n; cin >> n;
using namespace std;
int main() {
  ll a,b,c;
  cin >> a >> b >> c;
  string s="bust";
  if (a+b+c<22) s="win";
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include<bits/stdc++.h>
using namespace std;
int main(){
    char c;
    cin >> c;
    c++ ;
    cout << c; 
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws NumberFormatException, IOException {
        // TODO 自動生成されたメソッド・スタブ
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[] input = br.readLine().split(" ");
        int m = Integer.parseInt(input[0]);
        int n = Integer.parseInt(input[1]);
        int[][] matrix = new int[m][n];
        int[] num = new int[n];


        for(int i = 0;i < m;i++){
            String[] line = br.readLine().split(" ");
            for(int j = 0;j < n;j++){
                matrix[i][j] = Integer.parseInt(line[j]);
            }
        }
        for(int i = 0;i < n;i++){
            num[i] = Integer.parseInt(br.readLine());            ;
        }

        for(int i = 0;i < m;i++){
            int result = 0;
            for(int j = 0;j < n;j++){
            result += matrix[i][j] * num[j];
            }
            System.out.println(result);
        }

    }

}


Measured memory_bytes: 27492
#include <stdio.h>
#include <string.h>


int main(){
	int A,B;
	int Ia,Ib;
	double i;
	int a=0,b=0;
	char s[110];
	
	scanf("%d%d",&A,&B);
	
	for(i=1;i<1300;i++){
		if((int)(i*0.08)==A && (int)(i*0.1)==B){
			printf("%d\n",(int)i);
			return 0;
		}
	}
	#if 0
	Ia = (int)(A/0.08);
	//Ib = (int)(B/0.1);
	//printf("%d %d\n",Ia,Ib);
	if((int)B==(int)(Ia*0.1)){
		printf("%d\n",Ia);
	}
	else{
		printf("-1\n");
	}
	#endif
	
		printf("-1\n");
	
 return 0;
 }

Measured memory_bytes: 128
program main
    implicit none
    integer n,i
    integer,allocatable :: D(:,:)

    read(*,*)n
    allocate(D(1:n,1:2))
    do i=1,n
        read(*,*)D(i,1:2)
    enddo
    do i=1,n-2
        if(D(i,1)==D(i,2) .and. D(i+1,1)==D(i+1,2).and.D(i+2,1)==D(i+2,2))then
            write(*,*)"Yes"
            RETURN
        endif
    enddo
    write(*,*)"No"
end program main

Measured memory_bytes: 2824
def main():
    R, G, B, N = map(int, input().split())
    ans = 0

    for r in range(N//R + 1):
        for g in range(N//G + 1):
            
            res = (N - (R*r + G*g)) 
            if res >= 0 and res % B == 0:
                ans += 1

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
//typedef pair<double, double> P;
#define X real()
#define Y imag()
#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]
#define prev(P, i) P[(i+P.size()-1) % P.size()]
#define diff(P, i) (next(P, i) - curr(P, i))
const double EPS = 1e-8;
const double INF = 1e12;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}

typedef vector<P> G;

double compare_x(const P &a, const P &b){
  return a.X != b.X ? a.X < b.X : a.Y < b.Y;
}

double compare_y(const P &a, const P &b){
  return a.Y != b.Y ? a.Y < b.Y : a.X < b.X;
}

double length_of_the_nearest_point_to(P a[100000], int n){
    if(n<=1)return 999999999.9;
    int m=n/2;
    double x=a[m].X;
    double d=min(length_of_the_nearest_point_to(a, m), length_of_the_nearest_point_to(a+m, n-m));
    sort(a, a+n, compare_y);
    vector<P> b;
    for(int i=0; i<n; i++){
        if(fabs(a[i].X-x)>=d)continue;
        for(int j=0; j<b.size(); j++){
            double dx=a[i].X-b[b.size()-j-1].X;
            double dy=a[i].Y-b[b.size()-j-1].Y;
            if(dy>=d)break;
            d=min(d,sqrt(dx*dx+dy*dy));
             
        }
        b.push_back(a[i]);
    }
    return d;
}

int main() {
  int N; cin >>N;
  G g(N);
  REP(i, N){
    double x, y; cin >>x >>y;
    g[i] = P(x, y);
  }
  sort(g.begin(), g.end(), compare_x);
  printf("%.10lf\n", length_of_the_nearest_point_to(&g[0], N));
  return 0;
}

Measured memory_bytes: 5616
A, B = map(int, input().split())
S = input()

res = 'Yes'
if S[A] != '-' or len(S) != A+B+1:
    res = 'No'
#     print('0')
else:
    for i in range(A):
        if not S[i] in '1234567890':
#             print('1')
            res = 'No'
            break
    for i in range(B):
        if not S[A+i+1] in '1234567890':
#             print('2')
            res = 'No'
            break
print(res)

Measured memory_bytes: 3064
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

ll n, m, q;
bool s[2000][2000];

ll sn[2001][2001];
ll seh[2001][2001];
ll sev[2001][2001];

ll sumn(int x, int y, int xx, int yy) {
	return sn[xx][yy] - sn[x][yy] - sn[xx][y] + sn[x][y];
}
ll sumeh(int x, int y, int xx, int yy) {
	return seh[xx][yy] - seh[x][yy] - seh[xx][y] + seh[x][y];
}
ll sumev(int x, int y, int xx, int yy) {
	return sev[xx][yy] - sev[x][yy] - sev[xx][y] + sev[x][y];
}

int main(int argc, char **argv) {
	cin >> n >> m >> q;
	REP(y, n) {
		string l;
		cin >> l;
		REP(x, m) s[x][y] = (l[x] == '1');
	}

	REP(y, n + 1) sn[0][y] = seh[0][y] = sev[0][y] = 0;
	REP(x, m + 1) sn[x][0] = seh[x][0] = sev[x][0] = 0;
	REP(y, n) REP(x, m) sn[x + 1][y + 1] = sn[x][y + 1] + (s[x][y] ? 1 : 0);
	REP(x, m) REP(y, n) sn[x + 1][y + 1] += sn[x + 1][y];
	REP(y, n) REP(x, m - 1) seh[x + 1][y + 1] = seh[x][y + 1] + (s[x][y] && s[x + 1][y] ? 1 : 0);
	REP(x, m - 1) REP(y, n) seh[x + 1][y + 1] += seh[x + 1][y];
	REP(y, n - 1) REP(x, m) sev[x + 1][y + 1] = sev[x][y + 1] + (s[x][y] && s[x][y + 1] ? 1 : 0);
	REP(x, m) REP(y, n - 1) sev[x + 1][y + 1] += sev[x + 1][y];

	REP(i, q) {
		ll x, y, xx, yy;
		cin >> y >> x >> yy >> xx;
		--x; --y;
		cout << (sumn(x, y, xx, yy) - sumev(x, y, xx, yy - 1) - sumeh(x, y, xx - 1, yy)) << endl;
	}

	return 0;
}


Measured memory_bytes: 99584
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define all(x) x.begin(), x.end()
#define MOD 1000000007
#define vi vector < int >
#define pii pair < ll, ll >
#define INF (int)1e9
#define pb push_back
#define fastIO ios::sync_with_stdio(0); cin.tie(0);

int n;
vi arr;

pii cache[410][410];

pii dpSol(int l, int r)
{
    if(l == r)
        return {0, arr[l]};
    
    if(r == l + 1)
        return {arr[l] + arr[r], arr[l] + arr[r]};
        
    pii &res = cache[l][r];
    if(res.first != -1 && res.second != -1)
        return res;
        
    int len = r - l + 1;
    ll minele = LONG_MAX, sum = 0;
    for(int i = 1; i <= len - 1; ++i)
    {
        pii left = dpSol(l, l + (i - 1));
        pii right = dpSol(l + i, r);
        
        ll temp = left.first + left.second + right.first + right.second;
        if(minele > temp)
        {
            minele = temp;
            sum = left.second + right.second;
        }
    }
    return res = {minele, sum};
}

int main()
{
    fastIO
    cin >> n;
    
    arr = vi(n);
    for(int i = 0; i < n; ++i)
        cin >> arr[i];
        
    for(int i = 0; i < 410; ++i)
        for(int j = 0; j < 410; ++j)
            cache[i][j] = {-1, -1};
        
    cout << dpSol(0, n - 1).first;

    return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <utility>
#include <cstring>
typedef long long ll;
using namespace std;
long long MOD = 1e9 +7;
ll fct[500000];
ll rfct[500000];
class Combination{
  public:
    Combination(){
      memset(fct,-1,sizeof(fct));
      memset(rfct,-1,sizeof(rfct));
    }
    long long Repeat(long long a,long long cnt){
      if(cnt==0)return 1LL;
      if(cnt%2==1){
        long long x = Repeat(a,cnt/2);
        return (((a*x)%MOD)*x)%MOD;
      }
      else {
        long long x = Repeat(a,cnt/2);
        return (x*x)%MOD;
      }
    }

    long long fact(long long a){
      return fct[a];
    }

    long long conb(long long a, long long b){
      long long fa,fb,fab;
      fa = fact(a);
      fb = fact(b);
      fab = fact(a-b);
      /*if(rfct[fb]==-1)rfct[fb] = Repeat(fb,MOD-2);
      fb = rfct[fb];
      if(rfct[fab]==-1)rfct[fab] = Repeat(fab,MOD-2);
      fab = rfct[fab];*/
      fb = Repeat(fb,MOD-2);
      fab = Repeat(fab,MOD-2);
      return (((fa*fb)%MOD)*fab)%MOD;
    }
};

int main(){
  ll h,w,a,b,i,j;
  cin >> h >> w >> a >> b;
  ll ret = 0;
  Combination cn;
  ll f = 1ll;
  fct[0]=1;
  for(i=1;i<=h+w+7;i++)fct[i]=f=(f*i)%MOD;
  for(i=b;i<w;i++){
    ret=(ret+(cn.conb(h-a-1+i,i)*cn.conb(a-1+w-1-i,a-1))%MOD)%MOD;
  }
  cout << ret << endl;
  return 0;
}


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

using namespace std;

long long N, M, a[100009][3], maxn = -(1LL << 60);

int main(void) {
  cin >> N >> M;
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < 3; j++) {
      cin >> a[i][j];
    }
  }

  for(int i = 0; i < 8; i++) {
    vector <long long> vec;
    for(int j = 0; j < N; j++) {
      long long S = 0;
      for(int k = 0; k < 3; k++) {
	if((i / (1 << k)) % 2 == 0) {
	  S += a[j][k];
	}
	else {
	  S -= a[j][k];
	}
      }
      vec.push_back(S);
    }
    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());
    long long ans = 0;
    for(int j = 0; j < M; j++) {
      ans += vec[j];
    }
    maxn = max(maxn, ans);
  }

  cout << maxn << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo LLONG_MAX
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*
sum ^= A[1]-x
sum ^= A[2]+x
をした結果sum=0になればいい

sum == (A[1]-x) ^ (A[2]+x)

A[1] + A[2]=100010とか
        sum=000101とかだったばあい
       A[1]=010000
       A[2]=010101とかじゃないといけない。
       
            010010
            010111とか。0の場所は00か11
                       1の場所は01か10

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll N, ans = oo; cin >> N;
  vector<ll> A(N+1, 0);
  rep(i, N) cin >> A[i+1];
  ll sum = 0;
  rep(i, N) sum ^= A[i+1];
  if (sum == 0){
    cout << 0 << endl;
    return 0;
  }
  sum ^= A[1];
  sum ^= A[2];
  ll mix = A[1] + A[2];
  ll keep = mix;
  ll a=0;
  vector<ll> stock(41, 0);
  rep(i, 41){
    if ((sum >> (40-i)) & 1){
      if ((1LL << (40-i)) > mix){
        cout << -1 << endl;
        return 0;
      }
      stock[40-i] = 1;
      mix -= (1LL << (40-i));
    }
    else{
      if ((1LL << (41-i)) <= mix){
        mix -= (1LL << (41-i));
        a += 1LL << (40-i);
      }
    }
  }
  //stockをもとに候補の値出す
  if (mix){
    cout << -1 << endl;
    return 0;
  }
  vector<ll> cand;
  cand.push_back(a);
  rep(i, 41){
    if (stock[i]){
      vector<ll> task;
      task = cand;
      for(auto v: task){
        ll next = v + (1LL << i);
        cand.push_back(next);
      }
    }
  }
  sort(all(cand));
  for(auto v: cand){
    if (v == 0)
      continue;
    if (v > A[1])
      break;
    ll test = v^(keep - v);
    if (sum == test)
      chmin(ans, A[1] - v);
  }
  if (ans == oo)
    ans = -1;
  cout << ans << endl;
}


Measured memory_bytes: 396620
#include<stdio.h>
int main(void){
	int x[10000],y[10000];
	int t,m=0;
	for(t=0;t<10000;t++){
		scanf("%d%d",&x[t],&y[t]);
		if(x[t]==0&&y[t]==0){
			break;
		}
		m++;
	}
	for(t=0;t<m;t++){
	    if(x[t]>y[t]){
	        printf("%d %d\n",y[t],x[t]);
	    }else{
	        printf("%d %d\n",x[t],y[t]);
	    }
	}
	return 0;
}


Measured memory_bytes: 2044
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int A = reader.nextInt();
		int B = reader.nextInt();
		int C = reader.nextInt();
		int X = reader.nextInt();
		int Y = reader.nextInt();
		int ans = 0;
		boolean isCheaperThanAB = A + B > C * 2;
		boolean isCheaperThanA = A > C * 2;
		boolean isCheaperThanB = B > C * 2;

		if (isCheaperThanAB) {
			int num = Math.min(X, Y);
			ans += num * 2 * C;
			X -= num;
			Y -= num;
		}
		if (isCheaperThanA) {
			ans += X * C * 2;
			X = 0;
		}
		if (isCheaperThanB) {
			ans += Y * C * 2;
			Y = 0;
		}
		ans += X * A;
		ans += Y * B;

		reader.close();
		System.out.print(ans);
	}
}



Measured memory_bytes: 21716
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String s = sc.next();

		for (int i = 0; i< s.length() -1; i++){
			if (s.charAt(i) != s.charAt(i+1)){
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}

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

using namespace std;
vector<long long>v;
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};

bool comp(pair<int,int>a,pair<int,int>b){
    if(a.first==b.first)
        return a.second<b.second;
    return a.first<b.first;
}

unordered_map<pair<int,int>,int, hash_pair>vis;
vector<pair<int,int> >vps;
long long n,h,w;
int cnt(int dlx,int dly,int urx,int ury,pair<int,int>center){

    if(urx>h||dlx<1||ury>w||dly<1)
        return 0;
    int cntb=0;
    for(int x=dlx;x<=urx;x++){
        for(int y=dly;y<=ury;y++){
            if(*(lower_bound(vps.begin(),vps.end(),make_pair(x,y),comp))==make_pair(x,y)){
                if(x<center.first)
                    return 0;
                if(x==center.first&&y<center.second)
                    return 0;
                cntb++;
            }
        }
    }
    return cntb;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);      cout.tie(0);
    v.resize(10);
    cin>>h>>w>>n;
    vps.resize(n);
    for(int i=0;i<n;i++){
        cin>>vps[i].first>>vps[i].second;
    }
    sort(vps.begin(),vps.end(),comp);
    for(int i=0;i<n;i++){
        for(int x=-2;x<=0;x++){
            for(int y=-2;y<=0;y++){
                v[cnt(vps[i].first+x,vps[i].second+y,vps[i].first+x+2,vps[i].second+y+2,vps[i])]++;
                ///cout << vps[i].first+x << ' '<< vps[i].second+y << ' '<< vps[i].first << ' '<< vps[i].second<< ' '<< cnt(vps[i].first+x,vps[i].second+y,vps[i].first+x+2,vps[i].second+y+2,vps[i]) << '\n';
            }
        }
    }
    int cnttl=0;
    for(int i=1;i<10;i++){
        cnttl+=v[i];
    }
    v[0]=(h-2)*(w-2)-cnttl;
    for(int i=0;i<10;i++)
        cout << v[i] << '\n';
    return 0;
}
/**
4 5 8
1 1
1 4
1 5
2 3
3 1
3 2
3 4
4 4
*/


Measured memory_bytes: 3936