akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	_ = sc.nextInt()
	S := sc.nextStr()
	x := 0
	max := 0
	for _, r := range S {
		if r == 'I' {
			x++
			if max < x {
				max = x
			}
		} else {
			x--
		}
	}

	fmt.Fprintln(wtr, max)
	wtr.Flush()
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
const int N = 21;
int n, v[N], c[N], ans;
int main(){
	scanf("%d", &n);
	for(Rint i = 1;i <= n;i ++) scanf("%d", v + i);
	for(Rint i = 1;i <= n;i ++){
		scanf("%d", c + i);
		ans += max(0, v[i] - c[i]);
	}
	printf("%d", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

int r; cin >> r;


cout << pow(r, 2) << endl;
}

// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 256
//基本は任意のところに置いて分割すれば良いだけ
//同じものが連続するときのみ別にしたい

#include<iostream>
#include<string>
#include<set>
#include<algorithm>
//algorithmincludeしないミス毎回のようにやってる、猛省
using namespace std;
//何もむずくなかった
//多分setに入れてくだけ


int main(){
  int m,l;
  string s;
  string a,b;
  cin >> m;
  for(int i=0;i<m;i++){
    cin >> s;
    l=s.length();
    set<string> strs;
    for(int i=0;i<l-1;i++){
      a=s.substr(0,i+1);
      b=s.substr(i+1,l-i-1);
      strs.insert(a+b);
      strs.insert(b+a);
      reverse(a.begin(),a.end());
      strs.insert(a+b);
      strs.insert(b+a);
      reverse(b.begin(),b.end());
      strs.insert(a+b);
      strs.insert(b+a);
      reverse(a.begin(),a.end());
      strs.insert(a+b);
      strs.insert(b+a);
    }
    cout << strs.size() << endl;
  }
}



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

int main() {
	int n;
	int p;
	cin >> n;
	int ans = 0;
	for(int i=1; i<=n; i++){
		cin >> p;
		if(p != i){
			ans += 1;
		}
	}
	if(ans == 0 || ans == 2){
		cout << "YES\n";
	}else{
		cout << "NO\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

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

int main() {
	int n, k; scanf("%d%d", &n, &k);
	
	if((n - 1) * (n - 2) / 2 < k) {
		printf("-1\n");
		return 0;
	}
	
	std::vector<std::pair<int, int>> edges;
	for(int i = 1; i < n; i++) edges.push_back({0, i});
	
	int now = (n - 1) * (n - 2) / 2;
	for(int i = 1; i < n and k < now; i++) {
		for(int j = i + 1; j < n and k < now; j++) {
			edges.push_back({i, j});
			now--;
		}
	}
	
	printf("%d\n", edges.size());
	for(auto v: edges) printf("%d %d\n", v.first + 1, v.second + 1);
	return 0;
}


Measured memory_bytes: 384
function main(input) {
  input=input.trim();
  const a = parseInt(input.split(" ")[0], 10);
  const b = parseInt(input.split(" ")[1], 10);
  c=a+b;
  if(c%2==1){
    console.log(Math.floor((a+b)/2)+1)
  }else{
    console.log(c/2);
  }

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));



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

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split("\\s+");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		System.out.println((N - 2) * 180);
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 20692
#include<bits/stdc++.h>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  int ans=0,tmp=0;
  cin>>s;
  REP(i,s.size()){
    int j=i;
    tmp=0;
    while(s[j]=='A'||s[j]=='C'||s[j]=='G'||s[j]=='T'){
      tmp++;
      j++;
    }
    ans = max(tmp,ans);
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
H = []
H = input().split(" ")
for i in range(N):
    H[i] = int(H[i])-1

ochinchin = True
for i in range(1, N):
    if H[i] < H[i-1]:
        H[i] += 1
        if H[i] < H[i-1]:
            ochinchin = False
            break
            

if ochinchin:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 11152
import sys

def input():
    return sys.stdin.readline()[:-1]

N,M = map(int,input().split(' '))
L = []
for i in range(M):
    L.append(list(map(str, input().split())))
VISITED = [0]*N
AC = 0
p = 0
for i in range(M):
    n,s = L[i]
    n = int(n) - 1
    if VISITED[n]==-1:
        continue
    if s=='AC':
        p += VISITED[n]
        VISITED[n] = -1
        AC += 1
    else:
        VISITED[n] += 1
print(AC,p)

Measured memory_bytes: 32908
#include<bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define vl vector<long long>
#define pll pair<long long,long long>
#define sl set<long long>
#define uset unordered_set<long long>
#define umap unordered_map
#define hell 1000000007
#define mod 998244353
#define pb push_back
#define mp make_pair
#define N 10001
#define inf 1e16
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define D1(x) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<endl
#define D2(x,y) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define D3(x,y,z) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
using namespace std;
ll power(ll x, ll y)
{
  if (y == 0)
    return 1;
  else if (y % 2 == 0)
    return (power(x, y / 2) * power(x, y / 2)) % mod;
  else
    return ((x * power(x, y / 2)) % mod * power(x, y / 2)) % mod;
}
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;  
    x = x % p;  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
  
// Returns n^(-1) mod p 
ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
} 
  
// Returns nCr % p using Fermat's little theorem. 
ll nCrModPFermat(ll n, ll r, ll p) 
{ 
   if (r==0) 
      return 1; 
    ll fac[n+1]; 
    fac[0] = 1; 
    for (ll i=1 ; i<=n; i++) 
        fac[i] = (fac[i-1]*i)%p; 
  
    return (fac[n]* modInverse(fac[r], p) % p * modInverse(fac[n-r], p) % p) % p; 
}
int main(){
  #ifndef ONLINE_JUDGE
  freopen("input.txt.txt","r",stdin);
  freopen("output.txt.txt","w",stdout);
  freopen("error.txt","w",stderr);
  #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    char c;
    cin>>c;
    if(isupper(c))
      cout<<"A";
    else cout<<"a";
    cerr<<(1000*clock())/CLOCKS_PER_SEC<<"ms";
    return 0;
}


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

int main(){
    string X;
    cin >> X;
    int ans = 0;
    int cnt = 0;
    for (char c : X) {
        if (c == 'T') cnt++;
        else cnt--;
        ans = max(ans, cnt*2);
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int ans;
  if(a<b){
    ans=a;
  }else{
    ans=b;
  }
  if(c<d){
    ans+=c;
  }else{
    ans+=d;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for (long long i = 0; i < N; i++)
using ll = long long;

void solve(long long N, std::vector<long long> A) {
    sort(A.begin(), A.end(), greater<ll>());
    queue<ll> q;
    q.push(A[0]);
    ll ans = 0;
    for (ll i = 1; i < N; i++) {
        ll front = q.front();
        q.pop();
        ans += front;
        ll addnum = min(front, A[i]);
        q.push(addnum);
        q.push(addnum);
    }
    cout << ans << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


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

#include <climits>

#define DEBUG if(false)

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<long long> A(N);
  bool ZERO = false;
  for(int i = 0; i < N; i++){
    cin >> A[i];
    if(A[i] == 0){
      ZERO = true;
    }
  }
  if(ZERO){
    cout << 0 << endl;
  }else{
    long long ANS = A[0];
    for(int i = 1; i < N; i++){
      long long tmp = ANS;

      ANS = ANS * A[i];
      if(ANS < 0 || ANS < tmp || ANS < A[i] || ANS > 1000000000000000000){
        ANS = -1;
        break;
      }
    }
    cout << ANS << endl;
  }


  return 0;
}


Measured memory_bytes: 4052
/*
    Created by Tejas Chaudhari
    link:
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef bool bl;
typedef vector<ll> vl;
typedef vector<bl> vb;
typedef string st;
typedef pair<ll,ll> pll;

#define INF LONG_LONG_MAX / 4;
#define SORT(x) sort(x.begin(), x.end());
#define Mod % 1000000007
#define HERE cout<<"HERE"<<endl;

void re_curse() {
        ll s,w;
        cin>>s>>w;
        if (s > w) {
            cout<<"safe"<<endl;
        } else {
            cout<<"unsafe"<<endl;
        }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin>>t;
    for (int i = 1; i <= t; ++i) {
        re_curse();
    }
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h> 
using namespace std;
int q,w,e,r,t,c[100010];
struct qqq{
	int l,r;
}a[300010];
int read(){
	int sum=0;
	char st=getchar();
	while(st<'0'||'9'<st)st=getchar();
	while('0'<=st&&st<='9'){
		sum=(sum<<3)+(sum<<1)+st-'0';
		st=getchar();
	}
	return sum;
}
void add(int x,int y){
	while(x<=w){
		c[x]+=y;
		x+=x&(-x);
	}
}
int get(int x){
	int sum=0;
	while(x>0){
		sum+=c[x];
		x-=x&(-x);
	}
	return sum;
}
bool paix(qqq s1,qqq s2){
	return s1.r-s1.l<s2.r-s2.l;
}
int main(){
	cin>>q>>w;
	for(int i=1;i<=q;i++){
		a[i].l=read(),a[i].r=read();
	}
	sort(a+1,a+1+q,paix);
	int ans,st=0;
	for(int i=1;i<=w;i++){
		ans=0;
		for(;st<q&&a[st+1].r-a[st+1].l+1<i;st++){
			add(a[st+1].l,1),add(a[st+1].r+1,-1);
		}
		for(int j=i;j<=w;j+=i){
			ans+=get(j);
		}
		printf("%d\n",ans+q-st);
	}
	return 0;
}

Measured memory_bytes: 3712
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            double m = 100000;
            for (int i = 0; i < n; i++)
            {
                m = m * 1.05;
                if (m % 1000 != 0)
                {
                    m = (int)m / 1000 * 1000 + 1000;
                }
            }
            Console.WriteLine(m);
        }
    }
}

Measured memory_bytes: 19932
#include <iostream>
#include <math.h>
#include <string>
#include <sstream>

using namespace std;
istringstream iss;
long long sum, num, c;
string S;

int summary(string s, int x){
    //cout << s << " " << s.size() << " " << x << endl;
    if(x == s.size()){
        iss = istringstream(s.substr(0,1));
        iss >> num;
        //cout << "num = "  << num << endl;
        //cout << x;
        for(int i=1;i<s.size();i++){
            if(s.substr(i,1)=="+"){
                //printf("%s \n", s.substr(i,1));
                sum += num;
                num = 0;
            }
            else{
                iss = istringstream(s.substr(i,1));
                iss >> c;
                num *= 10;
                num += c;
                //if(s == "3141592653")cout << "num = "  << num << "c = "  << c << endl;
            }
            //cout << "num = "  << num << endl;
        }
        //cout << "num = "  << num << endl;
        sum += num;
        //cout << "sum=" << sum << endl;
    }
    
    else {
        string s2 = s;
        summary(s.insert(x,"+"), x+2);
        s = s2;
        summary(s, x+1);
    }

}

int main(){
    
    cin >> S;
    if(S.size()==1){
        iss = istringstream(S.substr(0,1));
        iss >> sum;
    }
    else if(S.size()==2){
        int x, y, z;
        iss = istringstream(S.substr(0,1));
        iss >> x;
        iss = istringstream(S.substr(1,1));
        iss >> y;
        iss = istringstream(S.substr(0,2));
        iss >> z;
        sum = x + y + z;
    }
    else{
        sum = 0;
        summary(S, 1);
    }
    cout << sum;
    //S.insert(1,"+");
    //cout << S;

    cout << endl;
}

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

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

#ifdef _DEBUG
#include "../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

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

template <class T>
class CuSum {
private:
	vector<T> cusum;

public:
	CuSum(vector<T> const& vec) : cusum(vec.size() + 1) {
		for (int i = 0; i < (int)vec.size(); i++) cusum[i + 1] = cusum[i] + vec[i];
	}
	CuSum(const int N) : cusum(N + 1) {}
	void add(const int i, const T& x) { cusum[i + 1] += x; }
	void build() { for (int i = 0; i < (int)cusum.size() - 1; i++) cusum[i + 1] += cusum[i]; }

	// partial sum of 0-indexed [l, r)
	T operator()(int l, int r) {
		if (r < l || r < 0) {
			assert(0);
			return T(0);
		}
		else return cusum[r] - cusum[l];
	}
	// 0-indexed
	const T& operator[](int i) { return cusum[i]; }
	T back() { return cusum.back(); }
};

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

int main() {

	lint N, M, K;
	cin >> N >> M >> K;

	vector<lint> A(N), B(M);
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < M; i++) cin >> B[i];
	B.emplace_back(INF); // 番兵

	CuSum sumA(A), sumB(B);
	int idx_b = 0, ans = 0;
	for (int i = N; i >= 0; i--) {
		while (sumA[i] + sumB[idx_b + 1] <= K) idx_b++;
		if (sumA[i] + sumB[idx_b] <= K) chmax(ans, i + idx_b);
	}

	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 9312
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, M, V, P;
    cin >> N >> M >> V >> P;
    vector<int> A(N);
    for (auto & a : A) cin >> a;
    sort(A.rbegin(), A.rend());
    if (V <= P) {
        for (int i = N-1; i > P-2; --i) {
            if (A[P-1] <= A[i]+M) {
                printf("%d\n", i+1);
                return 0;
            }
        }
    }
    vector<long long> cs(N+1);
    for (int i = P-1; i < N; ++i) {
        cs[i+1] = cs[i]+A[i];
    }
    int beforeH = 0;
    long long tmpS = 0;
    for (int i = N-1; i > P-1; --i) {
        tmpS += (long long)(i-P+2)*(A[i]+M-beforeH);
        beforeH = A[i]+M;
        if (A[i]+M >= A[P-1] && tmpS >= (long long)(V-P+1)*M+cs[N]) {
            printf("%d\n", i+1);
            return 0;
        }
    }
    printf("%d\n", P);
    return 0;
}

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

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

bool dp[5001][5001];
int n,k;
vector<ll> a;

int dpxy(ll y,ll x){    // cant use a[x] to make sum y
    for(int i=0;i<=n;i++){
        for(int j=0;j<=k;j++){
            dp[i][j]=0;
        }
    }
    for(int i=0;i<n;i++){
        dp[i][0]=1;
    }
    if(x!=0){
        dp[0][a[0]]=1;
    }
    else{
        dp[1][a[1]]=1;
    }
    for(int i=1;i<n;i++){
        for(int j=0;j<k;j++){
            if(dp[i-1][j]==1){
                dp[i][j]=1;
                if(j+a[i]<k && i!=x){
                    dp[i][j+a[i]]=1;
                }
            }
        }
    }
    int ans=0;
    for(int i=y;i<k;i++){
        if(dp[n-1][i]==1){
            ans=1;
            break;
        }
    }
    return ans;
}

// hitsuyou (dp=1) ;hitsuyoudenai (dp=0)   max unnecessary
int binarysearch(int p,int q){
    int lo=p,hi=q;
    int med=lo+hi;
    med>>=1;
    if(hi>lo+1){
        ll y=k-a[med];
        if(y>=0){
            if(dpxy(y,med)==0){  // unnecessary
                binarysearch(med,hi);
            }
            else{
                binarysearch(lo,med);
            }
        }
        else{
            binarysearch(lo,med);
        }
    }
    else{
        ll y=k-a[med];
        if(y>=0){
            if(dpxy(y,med)==0){  // unnecessary
                return med;
            }
            else{
                return med-1;
            }
        }
        else{
            return med-1;
        }
    }
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n>>k;
    ll sum=0;
    for(ll i=0;i<n;i++){
        ll c;
        cin>>c;
        sum+=c;
        a.pb(c);
    }
    sort(a.begin(),a.end());
    ll count=0;
    if(sum>=k && n>1){
        count=binarysearch(0,n-1);
        count+=1;
    }
    else if(n==1){
        count=0;
    }
    else{
        count=n;
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 24832
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

int main() {
  string S; cin >> S;
  int total = 0;
  for (int i = 0; i < S.length(); ++i) {
    int d = S[i] - '0';
    total += d;
  }
  if (total % 9 == 0) cout << "Yes" << endl;
  else               cout << "No" << endl;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1 << 21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
    int N, W;
    cin >> N >> W;
    vector<pair<ll, ll>> wv(N);
    // i番目までの品物で、重さの総和がw以下での価値の総和の最大
    // dp[i][j] := i番目までの品物、重さがj以下のものの価値
    ll dp[105][100500];
    dp[0][0] = 0;

    rep(i, N){
        ll w, v;
        cin >> w >> v;
        wv[i] = make_pair(w, v);
    }
    rep(i, N)rep(j, W+1){
        pair<ll, ll> tmp = wv[i];
        if (j-tmp.first>=0) chmax(dp[i+1][j], dp[i][j-tmp.first] + tmp.second);
        
        chmax(dp[i+1][j], dp[i][j]);
    }

    cout << dp[N][W] << endl;

    return 0;
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

const int N = 200001;

int n, k;
int a[N];

bool check(int x)
{
	int reqd = 0;
	for(int i = 0; i + 1 <= n; i++)
	{
		int diff = a[i];
		reqd += (diff - 1) / x;
		if(reqd > k)
			return 0;
	}
	return 1;
}

int binsearch(int lo, int hi)
{
	while(lo < hi)
	{
		int mid = (lo + hi) / 2;
		if(mid==0){
			return 0;
		}
		if(check(mid))
			hi = mid;
		else
			lo = mid + 1;
	}
	return lo;
}

int main()
{
	IOS;
	int t=1;
	int tc = 0; 
	while(t--)
	{
		tc++;
		cin >> n >> k;
		for(int i = 0; i < n; i++)
			cin >> a[i];
		int ans = binsearch(1, 1e9);
		cout<<ans;
 	}	
	return 0;
}

Measured memory_bytes: 4424
#include <bits/stdc++.h>
using namespace std;
#define lld long long int
int main()
{
    lld num,result=0,i;
    cin>>num;
    for(i=1;i<=num;i++)
    {
        if(i%3==0||i%5==0)
        {
            continue;
        }
        result+=i;
    }
    cout<<result<<endl;
    return 0;
}


Measured memory_bytes: 3560
local mfl, mce = math.floor, math.ceil
local n, k = io.read("*n", "*n")
assert(-1000000000 <= k and k <= 1000000000)
local p, c = {}, {}
for i = 1, n do
  p[i] = io.read("*n")
end
for i = 1, n do
  c[i] = io.read("*n")
  assert(-1000000000 <= c[i] and c[i] <= 1000000000)
end
local asked = {}
for i = 1, n do
  asked[i] = false
end
local zpos = 1
local function findstart()
  for i = zpos, n do
    if not asked[i] then zpos = i + 1 return i end
  end
  return false
end
local ret = -1000000007LL
local function mma_l(a, b) return a < b and b or a end
while true do
  local spos = findstart()
  if not spos then break end
  local route = {spos}
  local sum = 0LL + c[spos]
  local src = spos
  asked[spos] = true
  while true do
    local dst = p[src]
    if asked[dst] then break end
    asked[dst] = true
    table.insert(route, dst)
    sum = sum + c[dst]
    src = dst
  end
  local len = #route
  if 0LL < sum then
    local lp = mfl(k / len)
    local rem = k
    if 1 <= lp then
      lp = lp - 1
      rem = k - lp * len
    end
    sum = sum * lp
    ret = mma_l(ret, sum)
    for i = 1, len do
      local v = 0LL
      local src = route[i]
      for j = 1, rem do
        local dst = p[src]
        v = v + c[dst]
        ret = mma_l(ret, sum + v)
        src = dst
      end
    end
  else
    for i = 1, len do
      local v = 0LL
      local src = route[i]
      local lim = math.min(len, k)
      for j = 1, lim do
        local dst = p[src]
        v = v + c[dst]
        ret = mma_l(ret, v)
        src = dst
      end
    end
  end
end
ret = tostring(ret):gsub("LL", "")
print(ret)


Measured memory_bytes: 3420
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string str;
    cin>>str;
    int i,j;
    set<char>s;
    for(i = 0;i < str.size();i++)
    {
        s.insert(str[i]);
    }
    if(s.size()==2)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef pair<Int,Int> Pl;
const int mod = 1e9+7;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define Pr(type) priority_queue<type>
#define gPr(type) priority_queue<type,vector<type>,greater<type>>
#define V(type) vector<type>
#define rep(i,n) for(int i=0; i<n; i++)
#define rer(i,st,en) for(int i=st; i<en; i++)
#define gnr(i,l,r) for(int i=int(r)-1; i>=int(l); i--)
#define eb emplace_back
#define pri1(a) cout<<(a)<<'\n'
#define pri2(a,n) rep(i,n-1)cout<<a[i]<<' '; cout<<a[n-1]<<'\n'
#define prip(p) cout<<p.first<<' '<<p.second<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n,m,_,x,y,q;
string s,sb;
bool ok;
char ch;



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

  cin>>n; Int c[n-1],s[n-1],f[n-1];
  rep(i,n-1)cin>>c[i]>>s[i]>>f[i];
  rep(i,n){
    Int t=0;
    rer(j,i,n-1){
      if(t>s[j])t=(t%f[j]?(t+f[j]-t%f[j]):t);
      else t=s[j];
      t+=c[j];
    }
    pri1(t);
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
int main(){
    int n,sum=0;
    cin >> n;
    vector<int> v(n+2),p(n+1);
    for(int i=1;i < n+1;i++)
    {
        cin >> v.at(i);
    }
    v.at(0)=0;v.at(n+1)=0;
    for(int i=0;i < n+1;i++)
    {
        p.at(i)=abs(v.at(i+1)-v.at(i));
        sum+=p.at(i);
    }

    for(int i=1;i <= n;i++)
    {
        cout << sum-p.at(i)-p.at(i-1)+abs(v.at(i+1)-v.at(i-1)) << endl;
    }
}


Measured memory_bytes: 2048
#include<iostream>
#include<fstream>
#include<string>
#include<algorithm>
using namespace std;
string s;
int c,f;
int main()
{
 cin>>s;
 for(int i=0;i<s.size();i++)
 {
   if (s[i]=='C') 
   {
   	  for (int j=i+1;j<s.size();j++)
      if (s[j]=='F') {cout<<"Yes";return 0;}
   }
 }
 cout<<"No";
 return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const double PI = acos(-1);
using namespace std;
using Graph = vector<vector<lli>>;
using P = pair<int, int>;
// }}} End Header

int main(){
	int a, b;
	cin >> a >> b;
	if((a+b)%3 == 0 || a%3 == 0 || b%3 == 0)puts("Possible");
	else puts("Impossible");
	return 0;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <ctime>
#include <cmath>
#include <queue>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define PII pair<int,int>
#define FOR(i,a,b) for (int i=(a);i<=(b);++i)
#define ROF(i,b,a) for (int i=(b);i>=(a);--i)
typedef long long LL;
inline int read(){
	int x=0,f=1; char ch=getchar();
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	while (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	return x*f;
}

const int MAXN=300005;
const double eps=1e-8,INF=1e20,PI=3.141592653589793238462;
int n,m,a[MAXN];
LL s[MAXN];
struct list{
	int l,lt[MAXN],nt[MAXN],x[MAXN];
	void clear(){ l=0; memset(lt,0,sizeof(lt)); }
	void addedge(int a,int b){ l++; nt[l]=lt[a]; lt[a]=l; x[l]=b; }
}E;
int main(){
	n=read();
	FOR(i,1,n) a[i]=read();
	FOR(i,1,n) s[i]=s[i-1]+a[i];
	LL ans=(s[n]-s[1]*2>0?s[n]-s[1]*2:s[1]*2-s[n]);
	FOR(i,1,n-1) ans=min(ans,(s[n]-s[i]*2>0?s[n]-s[i]*2:s[i]*2-s[n]));
	cout<<ans<<endl;
	return 0;
}

/*
*/


Measured memory_bytes: 4864
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
from collections import Counter

n = int(input())
a = [int(item) for item in input().split()]
comb = [0] * (n + 1)
cnt = Counter(a)

for key in cnt.keys():
    comb[key] = cnt[key] * (cnt[key] - 1) // 2
total = sum(comb)

for item in a:
    if comb[item] <= 1:
        diff = comb[item]
    else:
        diff = comb[item] - (comb[item] * (cnt[item] - 2)) // cnt[item]
    print(total - diff)

Measured memory_bytes: 86348
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 1e5+100;
bool vis[maxn];
int num[maxn];
int main()
{
    memset(vis,0,sizeof(vis));
    memset(num,0,sizeof(vis));
    int n,m;
    cin >> n >> m;
    int id;
    string s;
    int res= 0;
    for(int i =0; i<m; ++i)
    {
        cin >> id >> s;
        if(vis[id])
            continue;
        if(s[0]=='A')
        {
            ++res;
            vis[id] =1;
        }
        else
        {
            ++num[id];
        }

    }
    LL sum = 0;
    for(int i = 1; i<=n; ++i)
    {
        if(vis[i])sum+=num[i];
    }
        
    cout << res << " " <<sum <<"\n";
    return 0;
}


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

int main() {
    while(true){
        int h;cin >> h;
        if(h == 0) break;
        int c[15][5];
        for(int i=h-1;i>=0;i--){
            for(int j=0;j<5;j++){
                cin >> c[i][j];
            }
        }

        int ans = 0;
        while(true){
            // erase
            // cout << "hoge" << endl;
            bool flag = false;
            for(int i=0;i<h;i++){
                int bb = c[i][0];
                int l = 0, r = 1;
                // int cc = c[i][0];
                for(int j=1;j<5;j++){
                    if(c[i][j] == bb && c[i][j] != 0){
                        // cc = c[i][j];
                        r++;
                    }else{
                        if(j >= 3){
                            break;
                        }
                        l = j;
                        r = j+1;
                        // cc = c[i][j];
                        bb = c[i][j];
                    }
                }
                // cout << count << "count" << endl;
                if(r-l >= 3){
                    flag = true;
                    for(int j=l;j<r;j++){
                        ans += c[i][j];
                        c[i][j] = 0;
                    }
                }
            }

            // cout << "before" << endl;
            // for(int i=0;i<h;i++){
            //     for(int j=0;j<5;j++){
            //         cout << c[i][j];
            //     }
            //     cout << endl;
            // }
            // fall
            for(int j=0;j<5;j++){
                int i=0;
                for(int k=0;k<h;k++){
                    if(c[k][j] != 0){
                        c[i][j] = c[k][j];
                        i++;
                    }
                }
                for(int k=i;k<h;k++){
                    c[k][j] = 0;
                }
            }
            // cout << "after" << endl;
            // for(int i=0;i<h;i++){
            //     for(int j=0;j<5;j++){
            //         cout << c[i][j];
            //     }
            //     cout << endl;
            // }
            // cout << endl;
            if(!flag) break;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3044
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll N, M;
  cin >> N >> M;
  vector<ll> H(N);
  for (ll i = 0; i < N; ++i) {
    cin >> H.at(i);
  }
  vector<vector<ll>> connect(N);
  for (ll i = 0; i < M; ++i) {
    ll a, b;
    cin >> a >> b;
    connect.at(a - 1).push_back(b - 1);
    connect.at(b - 1).push_back(a - 1);
  }
  ll ans = 0;
  for (ll i = 0; i < N; ++i) {
    ll now_h = H.at(i);
    ll good = 1;
    for (ll j = 0; j < connect.at(i).size(); ++j) {
      if (H.at(connect.at(i).at(j)) >= now_h) {
        good = 0;
        break;
      }
    }
    ans += good;
  }
  cout << ans << "\n";
}


Measured memory_bytes: 9856
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
using namespace std;

/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long ll;

#define fi first
#define se second

using Graph = vector<vector<int>>;

int main()
{
    ll r, d, x;
    cin >> r >> d >> x;
    for (int i = 0; i < 10; i++)
    {
        x = r * x - d;
        cout << x << endl;
    }

    return 0;
}

Measured memory_bytes: 256
ol = '#.' * 150
el = '.#' * 150

while s = gets.chomp
  h, w = s.split.map(&:to_i)
  break if h.zero? && w.zero?
  (1..h).each do |n|
    puts ol[0..(w-1)] if n.odd?
    puts el[0..(w-1)] if n.even?
  end
  puts
end

Measured memory_bytes: 6100
#include <bits/stdc++.h>
#define For( i, j, k ) for( int i = j; i <= k; ++i )
using std::cin;
using std::cout;
using std::vector;
using std::pair;
using std::string;
std::map < pair < int, int >, int > mp, mp1;
int h, w, n;
int dx[ 9 ] = { -1, 0, 1, 1, 1, 0, -1, -1, 0 },
				dy[ 9 ] = { 1, 1, 1, 0, -1, -1, -1, 0, 0 };
long long cnt[ 10 ];
int main( )
{
	std::ios::sync_with_stdio( false );
	cin >> h >> w >> n;
	cnt[ 0 ] = ( long long ) ( h - 2 ) * ( w - 2 );
	vector < pair<int, int > > a;
	int u, v;
	For( i, 1, n )
	{
		cin >> u >> v;
		std::pair < int, int > I;
		mp[ I = std::make_pair( u, v ) ] = 1; 
		For( k, 0, 8 ) if( I.first + dx[ k ] >= 2 && I.second + dy[ k ] >= 2 && I.first + dx[ k ] <= h - 1 && I.second + dy[ k ] <= w - 1 )
			a.push_back( std::make_pair( u + dx[ k ], v + dy[ k ] ) );
	}
	for( auto &i : a )
	{
		if( mp1[ i ] == 1 )
			continue;
		mp1[ i ] = 1;
		int o = 0;
		For( k, 0, 8 ) if( i.first + dx[ k ] >= 1 && i.second + dy[ k ] >= 1 && i.first + dx[ k ] <= h && i.second + dy[ k ] <= w )
			o += mp.count( std::make_pair( i.first + dx[ k ], i.second + dy[ k ] ) );
		cnt[ o ]++;
		cnt[ 0 ]--;
	}
	For( i, 0, 9 )
		cout << cnt[ i ] << '\n';
	return 0;
}

Measured memory_bytes: 72872
X, Y, A, B, C = map(int, input().split())

P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))

P.sort(reverse = True)
Q.sort(reverse = True)
R.sort(reverse = True)

L = P[0: X] + Q[0 : Y]
L.sort(reverse = True)

# replace するリンゴの数に関する二分探索
# リンゴを n 個 replace するとすると，
# (L の下から数えて n 番目の値) < (R の上から数えて n 番目の値)
# が成り立つ最大の n を求めたい

def f(n):
    if n == 0: return True
    return L[-n] < R[n - 1]

ok = 0
ng = min(X + Y, C) + 1
mid = (ok + ng) // 2

while ng - ok > 1:
    mid = (ok + ng) // 2
    # print("ok, ng, mid", end = "")
    # print(ok, ng, mid)
    if f(mid):
        ok = mid
    else:
        ng = mid

n = ok
# print(n)
# print(*L)

ans = sum(L[0 : X + Y - n])
if n > 0:
    ans += sum(R[0 : n])

print(ans)

Measured memory_bytes: 106604
#pragma GCC optimize "-O3"
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

const int MAXN = 2000;

int n;
string stmp[MAXN];
int a[MAXN][MAXN];
ll go[MAXN][MAXN];
int gd[MAXN][MAXN];
int gr[MAXN][MAXN];

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> stmp[i];
		for (int j = 0; j < n; ++j) {
			if (stmp[i][j] == '#')
				a[i][j] = 0;
			else
				a[i][j] = stmp[i][j] - '0';
		}
	}
	ll ans = 0;
	for (int i = n - 1; i >= 0; --i)
		for (int j = n - 1; j >= 0; --j) {
			if (a[i][j] == 0)
				continue;
			if (i + 1 < n && j + 1 < n && a[i + 1][j] != 0 && a[i][j + 1] != 0) {
				go[i][j] += go[i + 1][j];
				go[i][j] += go[i][j + 1];
				//TODO: optimize
				for (int k = i + 1; k < n && gd[j + 1][k] != -1; ++k) {
					if (gr[j][gd[j + 1][k]] == k)
						go[i][j] -= go[k][gd[j + 1][k]];
				}
				gd[j][i] = j;
				for (int x = j + 1; x < n && gr[j + 1][x] != -1; ++x)
					gr[j][x] = gr[j + 1][x];
				int st = i + 1;
				while (st < n && gd[j][st] != -1)
					++st;
				while (st < n && gd[j + 1][st] != -1)
					gd[j][st] = gd[j + 1][st], ++st;
				gr[j][j] = i;
			}
			else if (i + 1 < n && a[i + 1][j] != 0) {
				go[i][j] += go[i + 1][j];
				gd[j][i] = j;
				gr[j][j] = i;
			}
			else if (j + 1 < n && a[i][j + 1] != 0) {
				go[i][j] += go[i][j + 1];
				memcpy(gr[j] + j + 1, gr[j + 1] + j + 1, sizeof(gr[0][0]) * (n - j - 1));
				memcpy(gd[j] + i + 1, gd[j + 1] + i + 1, sizeof(gr[0][0]) * (n - i - 1));
				gd[j][i] = j;
				gr[j][j] = i;
			}
			else {
				memset(gr[j] + j + 1, -1, sizeof(gr[0][0]) * (n - j - 1));
				memset(gd[j] + i + 1, -1, sizeof(gr[0][0]) * (n - i - 1));
				gd[j][i] = j;
				gr[j][j] = i;
			}
			ans += go[i][j] * a[i][j];
			go[i][j] += a[i][j];
		}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 68224
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
 
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define len(x) int((x).size())
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define randint(n) uniform_int_distribution<int>(1, (n))(rng)

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif

	int n;
	cin>>n;

	vector<int> divs(n+1);

	for(int i=1; i<n; i++)
	{
		int ii=i;

		while(ii<n)
		{
			divs[ii]++;
			ii+=i;
		}
	}

	int ans=0;
	for(auto t:divs) ans+=t;
	cout << ans << endl;
}

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

using namespace std;

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

const int MAX_N = (int)2e5 + 5;
const ll MOD = (ll)1e9 + 7LL;

ll fact[MAX_N];

ll mod_pow(ll n, ll p, ll M){
	ll res = 1LL;
	while(p > 0LL){
		if (p % 2LL == 1LL){
			res = (res * n) % M;
		} // end if
		n = (n * n) % M;
		p >>= 1;
	} // end while
	return res;
}

ll comb(ll n, ll r){
	if (n < r) return 0LL;
	if (r == 0LL || n == r) return 1LL;

	ll deno = (fact[r] * fact[n-r]) % MOD;
	ll res = (fact[n] * mod_pow(deno, MOD - 2LL, MOD)) % MOD;

	return res;
}

void init_fact(void){
	memset(fact, 0LL, sizeof(fact));
	fact[0] = 1LL;
	fact[1] = 1LL;
	for (int i = 2; i < MAX_N; ++i){
		fact[i] = (fact[i-1] * (ll)i) % MOD;
	} // end for
}

int main()
{
	init_fact();
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll H, W, A, B; cin >> H >> W >> A >> B;

	ll res = 0LL;
	for (int i = B; i < W; ++i){
		ll curr = comb(H - A - 1LL + (ll)i, (ll)i);
//		cerr << "curr: " << curr << endl;
		curr *= comb(A - 2LL + W - (ll)i, W - 1LL - (ll)i);
//		cerr << "curr: " << curr << endl;
		curr %= MOD;
		res = (res + curr) % MOD;
	} // end for
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 1792
def solve():
	X, Y = map(int, input().split())
	if Y % 2 != 0:
		return "No"
	turtle = (Y // 2) - X
	if turtle < 0:
		return "No"
	crane = X - turtle
	if crane < 0:
		return "No"
	if crane + turtle == X and 2 * crane + 4 * turtle == Y:
		return "Yes"
	return "No"


def main():
	print(solve())


if __name__ == '__main__':
	main()

Measured memory_bytes: 9168
#include <bits/stdc++.h>
 
typedef long long ll;
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define REP(i,n) for (int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
 
using namespace std;
 
int main(){
    
    int n,m,l;
    cin >> n >> m>> l;
    int a = max({n,m,l}) - min({n,m,l}) ;
 
 
    cout << a << endl;
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)
#define debug(var) cout << "[" << #var << "] " << var << endl

const int INF = 1<<29;
const double EPS=1e-9;
const int MOD=998244353;

signed main() {
    ll A, V, B, W, T;
    cin >> A >> V;
    cin >> B >> W;
    cin >> T;

    ll dis = abs(B-A);
    while(T > 0) {
        dis -= (V-W);
        if (dis <= 0) { 
            YES();
            exit(0);
        }
        T--;
    }
    NO();
}

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

using namespace std;

#define pb push_back
#define F first
#define S second
#define INF ll(1e18)
#define MOD 1000000007

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

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
    int a;cin>>a;
    ld b[a];
    for(int i=0;i<a;i++)cin>>b[i];
    sort(b,b+a);
    ld sum=b[0];
    for(int i=1;i<a;i++){
        sum=(sum+b[i])/2;
    }
    cout << sum;
}


Measured memory_bytes: 384
/* 	* In the name of GOD 
 	* Thanks God */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define int long long
const int N = 88;
int a[N];

int32_t main(){
	int n, ans = 1000;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++){
		int j;
		for (j = i + 1; j < n; j++) {
			if (a[j] != a[i]){
				break;
			}
		}
		if (j == n)
			break;
		if (a[j] > a[i]) {
			int x = ans / a[i];
			ans += (x * (a[j] - a[i]));
		}
		i = j - 1;
	}
	cout << ans << endl;
}



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


int main(){
    int k;
    cin >> k;
    queue<ll> Q;
    
    rep(i,9){
        Q.push(ll(i+1));
    }

    int count=9;
    if(k<=9){
        cout << k << endl;
        return 0;
    }
    ll ans = 0;
    while(true){
        ll p;
        p = Q.front();
        Q.pop();
        //cout << "p" << p << endl;

        int matubi = p%10;
        if(matubi-1>=0){
            ll temp;
            temp = 10*p+matubi-1;
            //cout << temp << endl;
            Q.push(temp);
            count++;
            if(count==k){
                ans = temp;
                break;
            }
        }

        ll temp;
        temp = 10*p + matubi;
        //cout << temp << endl;
        Q.push(temp);
        count++;
        if(count==k){
            ans = temp;
            break;
        }

        if(matubi+1<=9){
            ll temp;
            temp = 10*p+matubi+1;
            Q.push(temp);
            count++;
            //cout << temp << endl;
            if(count==k){
                ans = temp;
                break;
            }
        }
        
    }
    //cout << "ans" << endl;
    cout << ans << endl;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define INF 1e18
using namespace std;
typedef struct ee{
  long long cost,to;
}edge;
int main(){
  int v,e;
  cin>>v>>e;
  vector<vector<ee> >E(v);
  long long dp[v+1][v+1]={};
  for(int i=0;i<v;i++){
    for(int j=0;j<v;j++){
      dp[i][j]=INF;
      if(i==j)
	dp[i][j]=0;
    }
  }
  for(int i=0;i<e;i++){
    int a,b,c;
    cin>>a>>b>>c;
    dp[a][b]=c;
  }
  for(int k=0;k<v;k++){
    for(int i=0;i<v;i++){
      for(int j=0;j<v;j++){
	dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
      }
    }
  }
  int flag=1;
  for(int i=0;i<v;i++){
    if(dp[i][i]<0){
      flag=0;
      cout<<"NEGATIVE CYCLE"<<endl;
      break;
    }
  }
  if(flag){
    for(int i=0;i<v;i++){
      for(int j=0;j<v;j++){
	if(dp[i][j]>=INF-1e10)
	  cout<<"INF";
	else
	  cout<<dp[i][j];
	if(j!=v-1)
	  cout<<" ";
      }
      cout<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3188
n = gets.to_i
plan = n.times.map{ gets.split.map &:to_i }

dp = Array.new(n).map{Array.new(3).map{0}}
dp[0] = plan[0]

1.upto(n-1).each{|i|
    0.upto(2).each{|j|
        maxval = 0
        0.upto(2).each{|k|
            if j != k
                maxval = dp[i-1][k] if dp[i-1][k] > maxval
            end
        }
        dp[i][j] = maxval + plan[i][j]
    }
}

puts dp.last.max

Measured memory_bytes: 20984
//package atcoder;

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in  = new Scanner(System.in);
	        int a = in.nextInt();
	        int b = in.nextInt();
	        
	        if( a>9 || a<1 || b>9 || b<1){
	        		System.out.println(-1);
	        		return;
	        } 
	        
	        System.out.println(a*b);
	        
	}

}


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

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> vec(W);
    
    string x;
    
    for (int i = -1; i < H+1; ++i)
    {
        cout << "#";

        if (i == -1 || i == H){
            for (int j = 0; j < W; ++j){
                vec.at(j) = '#';
            }
        }
        else
        {
            cin >> x;
            for (int j = 0; j < W; ++j){
                vec.at(j) = x.at(j);
            }
        }

        for (int j = 0; j < W; ++j){
            cout << vec.at(j);
        }
        cout << "#" << endl;
    }
    
}


Measured memory_bytes: 256