akhauriyash/Code-Regression huggingface dataset:
# python3.4.2用
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def lprint(l): print(*l, sep='\n')
def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

# ABC044-C
# N枚のカードがあり、i番目(1<i<N)番目のカードには整数x(i)が書かれている
# カードを一枚以上選び、選んだカードの平均をAとしたい
# このような選び方は何通りあるか
# 三次元配列を用いたdpを行う。計算量はO(N^3*X)

N,A=imn()
x = iln()
# 数値の最大値
X = 50

# dp[i][j][k]とする
# xの中からj枚を選んで、x(i)の合計をkにするような選び方の総数
dp = [[[0 for _ in range(N*X+1)] for _ in range(N+1)] for _ in range(N+1)]
dp[0][0][0] = 1

for j in range(N):
    for k in range(N):
        for s in range(N*X+1):
            # 選択したカードの数値がS未満の場合
            if s-x[j] < 0:
                # 選択できないので、前回値をそのまま移行
                dp[j+1][k][s] = dp[j][k][s]
            else:
                # 選択した場合の値は下記の2値を加算
                # 1.dp[j][k+1][s]は今回選択してないが、既に合計がsのなる場合の数
                # 2.dp[j][k][s-x[j]]は今回選択することにより、合計がsとなる場合の数 
                dp[j+1][k+1][s] = dp[j][k+1][s] + dp[j][k][s-x[j]]


ans = 0
for i in range(1, N+1):
    # 合計が選んだカード数*平均値となっている場合の数を加算
    ans += dp[N][i][i*A]
print(ans)

                


Measured memory_bytes: 120280
#include <stdio.h>

int main()
{
    int  m, f, r;
    char grade;

    for (;;) {
        scanf("%d %d %d", &m, &f, &r);

        if ((m == -1)&&(f == -1)&&(r == -1)) {
            break;
        } else if ((m == -1)||(f == -1)) {
            grade = 'F';
        } else if (80 <= (m + f)) {
            grade = 'A';
        } else if ((65 <= (m + f))&&((m + f) < 80)) {
            grade = 'B';
        } else if ((50 <= (m + f))&&((m + f) < 65)) {
            grade = 'C';
        } else if ((30 <= (m + f))&&((m + f) < 50)) {
            if (50 <= r) {
                grade = 'C';
            } else {
                grade = 'D';
            }
        } else if ((m + f) < 30) {
            grade = 'F';
        }
        printf("%c\n", grade);
    }

    return 0;
}




Measured memory_bytes: 2044
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE BangPatterns #-}

-- Default Imports

import Control.Monad
import Control.Monad.ST
import Control.Monad.Trans.Class

import qualified Control.Monad.Reader as Reader
import Control.Monad.Reader (Reader, ReaderT, runReader, runReaderT)

import qualified Data.Array.MArray as MArray
import qualified Data.Array.ST as STArray
import Data.Array.ST (STArray, STUArray, runSTArray, runSTUArray)
import Data.Ix (Ix)

import qualified Data.Bits as Bits
import Data.Bits ((.&.), (.|.))

import qualified Data.ByteString.Char8 as BS
import Data.ByteString.Char8 (ByteString)

import qualified Data.Char as Char
import qualified Data.List as List
import qualified Data.Map.Strict as Map
import Data.Map.Strict (Map)
import qualified Data.Maybe as Maybe
import qualified Data.Set as Set
import Data.Set (Set)

import qualified Data.Vector as Vector
import qualified Data.Vector.Generic as GVector
import qualified Data.Vector.Mutable as MVector
import Data.Vector.Mutable (STVector)
import qualified Data.Vector.Unboxed as UVector

import Numeric

import Debug.Trace
-- ----------

-- Custom Import Here


-- ----------

-- Default Definitions

type Vector = Vector.Vector
-- type GVector = GVector.Vector
type UVector = UVector.Vector

readIntToList :: ByteString -> [Int]
readIntToList = List.unfoldr (fmap (second $ BS.dropWhile Char.isSpace) . BS.readInt)

readToList :: Read a => ByteString -> [a]
readToList = List.unfoldr $ fmap (mapTaken . mapRemain) . span' (not . Char.isSpace)
	where
		mapTaken  = first $ read . BS.unpack
		mapRemain = second $ BS.dropWhile Char.isSpace
		span' pred s
			| BS.null taken = Nothing
			| otherwise     = Just (taken, remain')
			where
				(taken, remain) = BS.span pred s
				remain' = BS.dropWhile Char.isSpace remain

readToListN :: Read a => Int -> ByteString -> [a]
readToListN n = take n . readToList

readIntToVector :: ByteString -> Vector Int
readIntToVector = Vector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVector :: ByteString -> UVector.Vector Int
readIntToUVector = UVector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToVectorN :: Int -> ByteString -> Vector.Vector Int
readIntToVectorN n = Vector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVectorN :: Int -> ByteString -> UVector.Vector Int
readIntToUVectorN n = UVector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace


first :: (a -> a') -> (a, b) -> (a', b)
first f (a, b) = (f a, b)

second :: (b -> b') -> (a, b) -> (a, b')
second f (a, b) = (a, f b)

average :: Fractional a => [a] -> a
average xs = sum xs / (fromIntegral . length) xs

-- ----------

main :: IO ()
main = do
	[n, m] <- readIntToList <$> BS.getLine
	as <- readIntToList <$> BS.getLine
	print $ max (n - sum as) (-1)


Measured memory_bytes: 4828
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

void Init() {
	std::cin.tie(0); std::ios::sync_with_stdio(false);
	struct Init_caller { Init_caller() { Init(); } }caller;
}

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define ei else if
#define all(a) a.begin(),a.end()
#define size(s) ((LL)s.size())
#define F first
#define S second
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define int_INF 1<<29
#define ll_INF 1LL<<60
#define MOD 1000000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<LL>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<LL>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using ppi = pair<pi, LL>;
using mll = map<LL, LL>;
using mcl = map<char, LL>;
using vpi = vector<pi>;
using vppi = vector<ppi>;

#pragma endregion

struct edge {
	int from, to, cost;
};

void y_n(bool p) {
	p ? _y() : _n();
}

void Y_N(bool p) {
	p ? _Y() : _N();
}

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		ret %= MOD;
	}
	return ret;
}


#pragma endregion 


/*****************************************************************************/
signed main(void) {
	int n; st s;
	cin >> n >> s;
	vi d(n+2, 0);
	f(i, 0, n+1) {
		if (s[i] == '(') {
			d[i + 1] = d[i] + 1;
		}
		else {
			d[i + 1] = d[i] - 1;
		}
	}
	int x = ll_INF;
	f(i, 0, n+1) {
		x = min(x, d[i]);
	}
	int c = x;
	while (-x > 0) {
		cout << '(';
		x++;
	}
	cout << s;
	while (d[n] - c > 0) {
		cout << ')';
		c++;
	}
	return 0;
}

Measured memory_bytes: 256
p="0123456789543210"
for i in range(input()):
	sp,ep=raw_input().split()
	if sp<ep:
		sp=p.find(sp)
		ep=p.find(ep)+1
	else:
		sp=p.rfind(sp)
		ep=p.rfind(ep)+1
	print " ".join(list(p[sp:ep])) if sp<ep else " ".join(list(p[sp:]+p[1:ep]))

Measured memory_bytes: 4212
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        A: i64,
        B: i64,
        C: i64,
    }
    println!("{}", if C>=A && C<=B {"Yes"}else{"No"});
}

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

using namespace std;

const int max_n = 202222, inf = 1000111222;

int h, w, n, x[2][max_n], y[2][max_n];
int sx, sy;
char s1[max_n], s2[max_n];

void proc(char s[max_n], int x[max_n], int y[max_n]) {
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'L') {
            y[i] = -1;
        } else if (s[i] == 'R') {
            y[i] = 1;
        } else if (s[i] == 'U') {
            x[i] = -1;
        } else {
            x[i] = 1;
        }
    }
}

bool solve(int mx, int st, int a[], int b[]) {
    int l = 0, r = mx - 1;
    for (int i = n - 1; i >= 0; --i) {
        if (b[i] == 1) {
            --l;
        } else if (b[i] == -1) {
            ++r;
        }
        l = max(l, 0);
        r = min(r, mx - 1);
        if (a[i] == 1) {
            --r;
        } else if (a[i] == -1) {
            ++l;
        }
        //cout << l << " " << r << endl;
        if (l > r) {
            return true;
        }
    }
    //cout << l << " " << r << ", " << st << endl;
    if (l <= st && st <= r) {
        return false;
    }
    return true;
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d%d%d", &h, &w, &n);
    scanf("%d%d", &sx, &sy);
    --sx;
    --sy;
    scanf("%s%s", s1, s2);
    proc(s1, x[0], y[0]);
    proc(s2, x[1], y[1]);
    if (solve(h, sx, x[0], x[1]) || solve(w, sy, y[0], y[1])) {
        puts("NO");
    } else {
        puts("YES");
    }
    return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7



int main()
{
    int N;
    cin>>N;
    map<int,int> mp;
    REP(i,N){
        int tmp;
        cin>>tmp;
        mp[tmp]++;
    }

    priority_queue<int> pq;
    for(auto itr=mp.begin();itr!=mp.end();++itr){
        if(itr->second>=4)pq.push(itr->first);
        if(itr->second>=2)pq.push(itr->first);
    }

    if(pq.size()<2)cout<<0<<endl;
    else{
        ll res = pq.top();pq.pop();
        res*=pq.top();
        cout<<res<<endl;
    }
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
typedef int64_t ll;
typedef long double ld;
using namespace std;
const ll mod=1000000007;
const ll INF=(1LL<<62);
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}

int main(){
  init();
  ll a,b,c,d;cin>>a>>b>>c>>d;
  cout<<min(a,b)+min(c,d)<<endl;
}

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

using namespace std;


int32_t main() {

    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);

    int a,b;
    cin>>a>>b;
    int k = a+b;
    if(k&1) cout<<"IMPOSSIBLE"<<endl;
    else cout<<k/2<<endl;

    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> num(n + 1, 0);
    for (int i = 1; i <= n; i++) num[i] = (int)(i * 1.08);
    for (int i = 0; i <= n; i++){
        if (num[i] == n){
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
}

Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const double eps=1e-10;
bool vis[200100];
int main()
{
	int i,j,k,l,n,m,a,b;
	scanf("%d%d",&n,&m);
	k=0;
	bool flag=false;
    for(i=0;i<n;i++)
        vis[i]=false;
	for(i=0;i<m;i++)
	{
		scanf("%d%d",&a,&b);
		if(flag)
		continue;
		if(a==1)
		{
			if(vis[b])
			{
				flag=true;
			}
			vis[b]=true;
		}
		else if(b==n)
		{
			if(vis[a])
			{
				flag=true;
			}
			vis[a]=true;
		}
	}
	if(flag)
		printf("POSSIBLE\n");
	else
		printf("IMPOSSIBLE\n");
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7;

int main(){
 string s; cin>>s;
  int b;
  b=(s[5]-'0')*10+s[6]-'0';
    
  if(b>4){cout<<"TBD"<<endl; return 0;}
    else {cout<<"Heisei"<<endl; return 0;}

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <complex>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <stack>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <cassert>

using namespace std;

typedef long long ll;
typedef ll li;
typedef pair<ll,ll> PI;
#define EPS (1e-10L)
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define REP(i,m,n) for(int i=m; i<=(int)(n); ++i)
#define F first
#define S second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(),a.end()
#define FOR(it,a) for(__typeof(a.begin())it=a.begin();it!=a.end();++it)
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,-1,1,1,-1};

double pro[11][200];

typedef vector<vector<double> > mat;


mat matmul(const mat& a,const mat& b){
  int n = SZ(a);
  mat c(n,vector<double>(n));

  rep(i,n)rep(j,n)rep(k,n)
    c[i][j] += a[i][k] * b[k][j];
  return c;
}

mat powmat(mat a, int p){
  int n=SZ(a);
  mat ret(n,vector<double>(n));
  rep(i,n) ret[i][i] = 1;
  while(p){
    if(p&1) ret=matmul(ret,a);
    a=matmul(a,a);
    p >>= 1;
  }
  return ret;
}

vector<double> gausu(mat A, vector<double> b){
  int n=SZ(A);
  vector<double> ret(n);

  rep(i,n){
    double maxv=abs(A[i][i]);
    int idx = i;
    for(int j=i+1;j<n;++j){
      if(maxv<abs(A[j][i])){
        maxv = abs(A[j][i]);
        idx = j;
      }
    }
    swap(A[i],A[idx]);
    swap(b[i],b[idx]);
    maxv = A[i][i];
    for(int j=0;j<n;++j){
      if(j==i) continue;
      double mul = A[j][i]/maxv;
      b[j] -= mul * b[i];
      for(int k=i;k<n;++k)
        A[j][k] -= mul * A[i][k];
    }
  }
  rep(i,n) ret[i] = b[i]/A[i][i];
  return ret;
}

int main(){
  int s,n,k;
  cin >> s >> n >> k;
  s=abs(s);
  if(n==1){
    if(s%k) cout << -1 << endl;
    else cout << s/k << endl;
    return 0;
  }

  pro[0][0] = 1;
  for(int i=0;i<k;++i)
    for(int j=1;j<=n;++j)
      for(int idx=0;idx<=n*k;++idx)
        pro[i+1][idx+j] += pro[i][idx]/n;

  mat E(n*k+1,vector<double>(n*k+1));
  vector<double> eb(n*k+1,-1);
  eb[0] = 0;

  rep(x,n*k+1){
    if(x==0){
      E[0][0]=1;
      continue;
    }
    E[x][x] -= 1;
    rep(i,n*k){
      int idx=abs((x)-(i+1));
      E[x][idx] += pro[k][i+1];
    }
  }
  vector<double> ex(gausu(E,eb));

  if(n*k>=s){
    printf("%.8f\n",ex[s]);
    return 0;
  }

  mat A(n*k+1,vector<double>(n*k+1));
  rep(i,n*k) A[0][i] = pro[k][i+1];
  rep(i,n*k-1) A[i+1][i] = 1;
  A[0][n*k]=1;
  A[n*k][n*k]=1;

  vector<double> b(n*k+1);
  b[0] = b[n*k] = 1;

  A=powmat(A,s-n*k);

  double ans = 0;
  ex[0] = 1;
  rep(i,n*k+1)
    ans += ex[n*k-i] * A[0][i];
  printf("%.8f\n",ans);

}

Measured memory_bytes: 1592
def main():
    N = int(input())
    T, A = map( int, input().split())
    H = list (map( int, input().split()))
    pos = -1
    best = 1 << 64
    for i in range(0, N):
        avg = T - H[i] * 0.006
        if best > abs(A - avg):
            best = abs(A - avg)
            pos = i + 1
    print(pos)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string> //文字列
#include <iomanip> //doubleの桁数指定 setprecision()
#include <list> //前後に数値を入れれる配列
#include <map> //map
#include <vector> //vecror

#define REP(i,m,n) for(ll i = (ll) (m);i < (ll) (n);i++) //forの短縮
#define rep(i,n) REP(i,0,n) //REPが0の時
#define ll long long int

using namespace std;

double PI = acos(-1); //円周率
ll mod = 1e9 + 7;


//提出コード↓

ll n,sum;

int main() {
	cin >> n;
	REP(i, 1, n + 1) {
		if (i % 3 != 0 && i % 5 != 0) sum += i;
	}
	cout << sum << endl;

	
	return 0;
}



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

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

using Graph = vector<vector<int>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}

typedef pair<int,int> P;

bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int factorial(int a){
  int res = 1;
  while(a){
    res *= a;
    a--;
  }
  return res;
}

int main(){
  int a,b,h;
  cin >> a >> b >> h;
  cout << (a+b)*h/2 << endl;
}


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

#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

/*
Arguments:
- G   : 隣接リスト {destination edge, cost}
- d   : srtからの距離 <- これを変更する
- srt : 始点
*/

void dijkstra(vector<vector<pair<ll,ll>>> G, vector<ll> &d, ll srt){
    priority_queue<pair<ll,ll>, vector<pair<ll,ll>>, greater<pair<ll,ll>>> que;
    que.push({0, srt});
    d[srt] = 0;
    while(!que.empty()){
        auto q = que.top();
        que.pop();
        if(q.first > d[q.second]) continue;
        for(auto g : G[q.second]){
            if(d[g.first] <= q.first + g.second) continue;
            d[g.first] = q.first + g.second;
            que.push({d[g.first], g.first});
        }
    }
}

int main(){

    ll n, x, y;
    cin >> n >> x >> y;
    x--; y--;
    VVP G(n);
    rep(i, 0, n-1){
        G[i].push_back({i+1, 1});
        G[i+1].push_back({i, 1});
    } 
    G[x].push_back({y, 1});
    G[y].push_back({x, 1});
    VL d(n), ans(n, 0);
    rep(i, 0, n) {
        rep(j, 0, n) d[j] = 1e18;
        dijkstra(G, d, i);
        rep(j, i+1, n) ans[d[j]]++;
    }
    rep(i, 1, n) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 3916
import java.util.Scanner;
import java.util.Arrays;

class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
    
        int[] sort = {a , b, c};
        Arrays.sort(sort);
        System.out.println(sort[0] + " " + sort[1] + " " + sort[2]);

    }
}

Measured memory_bytes: 26188
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  int N,M;
  cin >> N >> M;
  for(int i=0;i<M;i++){
    int a;
    cin >> a;
    N-=a;
  }

  if(N<0) cout << -1 << endl;
  else cout << N << endl;
  
  return 0;
}


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

int main(){
  int n, x;
  cin >> n;
  vector<int> fv(200000);
  for (int i=1; i<n; ++i){
    cin >> x;
    fv[x]++;
  }
  for (int i=1; i<=n; ++i)
    cout << fv[i] << " \n";
  return 0;
}
  

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int N;
vector<int> E[202020];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	ll ret=0;
	FOR(i,N) ret+=1LL*(i+1)*(N-i);
	FOR(i,N-1) {
		cin>>x>>y;
		x--;
		y--;
		if(x>y) swap(x,y);
		ret-=1LL*(x+1)*(N-y);
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 8364
// 72 72 72 72 72 72 72 72 72 72 72
#include <bits/stdc++.h> 
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef double ld;
typedef string st;
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;
const ll MOD = 1e9 + 7 ;
const ll INF=1e17;                                                                                                  
ll mpow(ll a,ll b){a=a%MOD;ll res=1;while(b>0){if(b&1)res=(res*a)%MOD;a=(a*a)%MOD;b=b>>1;}return res%MOD;}             

int main()
{ 
ios_base::sync_with_stdio(false);
cin.tie(NULL);
///freopen("input.txt", "r", stdin);
//freopen("output.txt","w",stdout);
ll k=0;
st s;
cin>>s;
forn(i,s.length())
{
    if(s[i]=='+') k++;
    else k--;
}
cout<<k;
return 0;    
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<queue>
using namespace std;
int n,ans=0;
string sh;

int main() {
	cin >> n >> sh;
	for (int i = 0; i < n; i++) {
		string old;
		cin >> old;
		bool jud = false;

		for (int j = 0; j < old.size(); j++) {//first
			if (old[j] == sh[0]) {
				for (int k = j+1; k < old.size(); k++) {//second,dis diside
					if (old[k] == sh[1]) {
						int dis = k - j;
						for (int l = 2; l < sh.size(); l++) {//check
							if (old[k + (dis*(l - 1))] == sh[l] && k+(dis*(l-1)) <= old.size()){
								if (l + 1 == sh.size()) jud = true;//success
							}
							else break;//error
						}
					}
					if (jud) break;
				}
			}
			if (jud) break;
		}
		//judge end
		if (jud) ans++;
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3156
#include<iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include<unordered_map>
using namespace std;
const long long int mod1=1000000007;
const long long int mod2 = -1;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define pp pop_back                                       
#define ff first
#define ss second
#define ll long long int
#define ull unsigned long long int
#define ordered_set tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define ordered1 tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define inf mod1
#define all(x) x.begin(),x.end()
ll gcd(ll a, ll b){
    ll c;
     while(b){
        c = b;
        b = a % b;
        a = c;
     }
     return a;
}
ll power1(ll a, ll b){
     if(b == 0) return 1;
     else if(b % 2) return a * power1(a, b - 1);
     else {
        ll temp = power1(a, b / 2);
        return temp * temp;
     }
}
ll power2(ll a, ll b, ll m){
     a %= m;
     if(b == 0) return 1;
     else if(b % 2) return (a * power2(a, b - 1, m)) % m;
     else{
        ll temp = power2(a, b / 2, m);
        return (temp * temp) % m;
     }
}
ll mod(ll x, ll p){
return (x % p + p) % p;
}
ll lcm(ll x, ll y){
return (x * y)/gcd(x, y);
}
int main(){
    fast;
    ll tt = 1;
    //cin >> tt;
    while(tt--){
        ll k, a, b;
        cin >> k >> a >> b;
        for(int i = a; i <= b; i++){
            if(i % k == 0){
                cout << "OK" << endl;
                return 0;
            }
        }
        cout << "NG" << endl;
    }
}

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

int main() {
   int n,m;
   cin >> n >> m;
   string a[60],b[60];
   rep(i,n)
   cin >> a[i];
   rep(i,m)
   cin >> b[i];

   string ans="No";
   for(int i=0;i<=n-m;i++){
      for(int j=0;j<=n-m;j++){
         bool found=true;
         rep(y,m){
            rep(x,m){
               if(a[i+y][j+x]!=b[y][x])
               found=false;
            }
         }
         if(found)
         ans="Yes";
      }
   }
   cout << ans << endl;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
    .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn main() {
    let v1: Vec<u32> = read_vec();
    let (r,c) = (v1[0], v1[1]);
    let v2: Vec<Vec<i32>> = read_vec2(r);
    for v in &v2 {
        let sum: i32 = v.iter().sum();
        for i in v {
            print!("{} ", i);
        }
        println!("{}", sum);
    }
    let mut sum = 0;
    for i in 0..c {
        let s: i32 = v2.iter().map(|v| v[i as usize]).sum();
        print!("{} ", s);
        sum += s;
    }
    println!("{}", sum);
}



Measured memory_bytes: 5048
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define sz(a) (int)a.size()
#define de(a) cout<<#a<<" = "<<a<<endl
#define dd(a) cout<<#a<<" = "<<a<<" "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int P = 1e9 + 7;
inline int add(int a, int b) {if((a += b) >= P) a -= P; return a;}
inline int sub(int a, int b) {if((a -= b) < 0) a += P; return a;}
inline int mul(int a, int b) {return 1ll * a * b % P;}
inline int kpow(int a, int b) {int r=1;for(;b;b>>=1,a=mul(a,a)) {if(b&1)r=mul(r,a);}return r;}
//----
const int N = 202020;
int n;
int a[N];
int main(){
	scanf("%d", &n);
	rep(i, 0, n) scanf("%d", a + i);
	sort(a, a + n);
	int mid = a[n - 1] / 2;
	int st = lower_bound(a, a + n, mid) - a;
	int l = mid, r = a[n - 1] % 2 + mid;
	pii a1 = {2e9, 2e9}, a2 = {2e9, 2e9};
	rep(i, max(0, st - 50), min(n - 1, st + 50)) {
		pii t1 = {abs(a[i] - l), a[i]}, t2 = {abs(a[i] - r), a[i]};
		a1 = min(a1, t1);
		a2 = min(a2, t2);
	}
	a1 = min(a1, a2);
	printf("%d %d\n", a[n - 1], a1.se);
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int X, Y;
    cin >> X >> Y;

    rep(x, X + 1) {
        int y = X - x;
        if (2 * x + 4 * y == Y) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <queue>
#include <array>

const int kSize = 20 + 2;

std::array<int, 4> ways = {-1, -kSize, +1, +kSize};

inline int xy2pos(const int x, const int y){
    return x + y * kSize;
}

std::array<bool, kSize*kSize> Bfs(const std::array<bool, kSize*kSize> &tiles, int pos){
    std::array<bool, kSize*kSize> arrived;
    std::queue<int> q;
    q.push(pos);
    std::fill(arrived.begin(), arrived.end(), false);
    while(!q.empty()){
        pos = q.front();
        q.pop();
        arrived[pos] = true;
        for(int way : ways)
            if(tiles.at(pos + way) && !arrived.at(pos + way))
                q.push(pos + way);
    }
    return arrived;
}

int main(){
    int w,h;
    std::array<bool,kSize*kSize> tiles; ///< true if black
    while((std::cin >> w >> h) && w != 0){
        std::fill(tiles.begin(), tiles.end(), false);
        int pos;
        for(int y=1; y<=h; ++y){
            for(int x=1; x<=w; ++x){
                char c;
                std::cin >> c;
                tiles[xy2pos(x,y)] = (c == '.');
                if(c == '@'){
                    pos = xy2pos(x,y);
                    tiles[pos] = true;
                }
            }
        }
        auto arrived = Bfs(tiles, pos);
        int sum = 0;
        for(bool v : arrived)
            sum += (v) ? 1 : 0;
        std::cout << sum << std::endl;
    }
}


Measured memory_bytes: 4668
#include<iostream>
using namespace std;
typedef long long ll;
const int maxn=1e6+5;
const int mod=1e9+7;
ll  n,k;
ll a[maxn];

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


Measured memory_bytes: 888
# coding: utf-8
A,B = list(map(int, input().split()))
S = input()

A_ = A+1
value = list(map(str ,list(range(10))))
count = 1
flag = True
count_ = 0
for i in S:
    if count==A_:
        if i == '-':
            flag = False
    else:
        for j in value:
            if i==j:
                count_ += 1
    count+=1


if count_==len(S)-1 and flag==False:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3316
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#include <set>
#include <tuple>
#include <cassert>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;

int main()
{
    ll H, W;
    ll CH, CW;
    ll DH, DW;
    scanf("%lld", &H);
    scanf("%lld", &W);
    scanf("%lld", &CH);
    scanf("%lld", &CW);
    scanf("%lld", &DH);
    scanf("%lld", &DW);
    CH--;
    CW--;
    DH--;
    DW--;

    vector<vector<bool>> mazemap(H, vector<bool>(W));
    char c;
    scanf("%c", &c);
    for (ll i = 0; i < H; i++)
    {
        char c;
        for (ll j = 0; j < W; j++)
        {
            scanf("%c", &c);
            mazemap[i][j] = (c == '.');
        }
        scanf("%c", &c);
    }

    ll ans = 127;
    if (!mazemap[CH][CW])
    {
        ans = -1;
        printf("%lld\n", ans);
        return 0;
    }

    priority_queue<pair<ll, pair<ll, ll>>, vector<pair<ll, pair<ll, ll>>>, greater<pair<ll, pair<ll, ll>>>> nexts;
    nexts.push({0, {CH, CW}});
    vector<vector<ll>> depthmap(H, vector<ll>(W, __LONG_LONG_MAX__));
    while (!nexts.empty())
    {
        auto current = nexts.top();
        nexts.pop();
        for (ll l = -2; l < 3; l++)
        {
            for (ll m = -2; m < 3; m++)
            {
                pair<ll, ll> currentpos = current.second;
                currentpos.first += l;
                currentpos.second += m;
                ll depth = current.first;
                if (currentpos.first < 0 || currentpos.second < 0 || currentpos.first >= H || currentpos.second >= W)
                    continue;

                if (!mazemap[currentpos.first][currentpos.second])
                    continue;

                if (!(abs(l) <= 1 && abs(m) <= 1 && abs(l) != abs(m)))
                    depth++;

                if (depthmap[currentpos.first][currentpos.second] > depth)
                {
                    depthmap[currentpos.first][currentpos.second] = depth;
                    nexts.push({depth, {currentpos.first, currentpos.second}});
                }
            }
        }
    }

    ans = depthmap[DH][DW];
    if (ans == __LONG_LONG_MAX__)
        ans = -1;
    printf("%lld\n", ans);
}


Measured memory_bytes: 11940
import java.util.Arrays;
import java.util.Scanner;

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

		long a[] = new long[n];


		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();

		}
		Arrays.sort(a);
		long ans = 1;
		int cd = 0;
		for (long i = a[1]; i >=0; i=i-1) {
			for (int j = 0; j < n; j++) {
				if (a[j] % i != 0) {
					cd++;
					
				}
				if(cd>=2){
					break;
				}
			}


				if (cd <=1) {
					ans = i ;
					break;
				}
			cd = 0;
		}
		System.out.println(ans);
	}
}


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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    vector<ll> P[4];
    ll w1;
    int N; ll W; cin >> N >> W;
    rep(i, N){
        ll weight, value; cin >> weight >> value;
        if(i == 0){
            w1 = weight;
            P[0].push_back(value);
        }
        else{
            int idx = weight-w1;
            P[idx].push_back(value);
        }
    }
    rep(i, 4) sort(P[i].rbegin(), P[i].rend());
    ll ruiseki[4][101];
    rep(i, 4) ruiseki[i][0] = 0;
    rep(i, 4){
        rep(j, P[i].size()){
            ruiseki[i][j+1] = ruiseki[i][j] + P[i][j];
        }
    }
    /*
    rep(i, 4){
        rep(j, P[i].size()+1) cout << ruiseki[i][j] << " ";
        cout << endl;
    }
    */

    ll ans = 0;
    for(int i = 0; i <= P[0].size(); i++){
        ll wi = w1*i;
        for(int j = 0; j <= P[1].size(); j++){
            ll wj = (w1+1)*j;
            for(int k = 0; k <= P[2].size(); k++){
                ll wk = (w1+2)*k;
                for(int l = 0; l <= P[3].size(); l++){
                    ll wl = (w1+3)*l;
                    if(wi+wj+wk+wl <= W){
                        //cout << "i: " << i << ",j: " << j << ", k: " << k << ",l: " << l << endl;
                        ans = max(ans, ruiseki[0][i]+ruiseki[1][j]+ruiseki[2][k]+ruiseki[3][l]);
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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();
		String s = sc.next();
		String s1 ="1";
		String s2 ="2";
		
		if(N%2 == 0) {
			s1 = s.substring(0, N/2);
			s2 = s.substring(N/2,N);
		}
		
		if(s1.equals(s2)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		sc.close();
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
main(){
  int q,b,c1,c2,q2;
  while(cin>>q,q){
    cin>>b>>c2>>c1>>q2;
    int a1=0,a2=0;
    r(i,q2+1)if((b-i*c2)>=0){
      int f=(b-i*c2)/c1;
      if(i+f>=q){
        if(a1<i){
          a1=i;
          a2=f;
        }
      }
    }
    if(a1==0)cout<<"NA"<<endl;
    else cout<<a1<<' '<<a2<<endl;
  }
}

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

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

signed main(){

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

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <numeric>
#include <functional>
#include <cmath>
#include <cassert>
#include <string>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll MOD = 1000000007;
const ll INF = 1LL << 60;
#define PI (acos(-1))

ll lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}
vector<ll> divisor(ll n)
{
    vector<ll> ret;
    for (ll i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push_back(i);
            if (i * i != n)
                ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

const ll MAX = 510000;
// const ll MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll solve()
{
    ll h, w, a, b;
    cin >> h >> w >> a >> b;
    COMinit();

    ll ans = 0;
    for (int i = 0; i < w - b; i++)
    {
        ll hh = h - a - 1;
        ll ww = b + i;
        ll hh2 = a - 1;
        ll ww2 = w - b - i - 1;
        ans += COM(hh + ww, hh) * COM(hh2 + ww2, hh2);

        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}

int main()
{
    //cout.precision(10);
    ios::sync_with_stdio(false);
    cin.tie(0);

    solve();
}


Measured memory_bytes: 12160
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REP1(i,n) for(int i=1;i<=(int)(n);i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;

int main(){
  int a;
  cin >> a;
  cout << a+a*a+a*a*a << endl;
}


Measured memory_bytes: 3620
import numpy as np

X, Y, Z, K = map(int, input().split())
A = np.array([int(i) for i in input().split()])
B = np.array([int(i) for i in input().split()])
C =np.array([int(i) for i in input().split()])
A = -np.sort(-A) #要チェックや
B = -np.sort(-B)
C = -np.sort(-C)
D = []
for i in range(min(K, X)):
    for j in range(min(K, Y)):
        if (i + 1) * (j + 1) > K:
            break
        for k in range(min(K, Z)):
            if (i + 1) * (j + 1) * (k + 1) > K:
                break
            else:

                D.append(A[i] + B[j] + C[k])

X = np.array(D)
X = -np.sort(-X)
for i in range(K):
    print(X[i])

Measured memory_bytes: 19068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<int ,P> P3;
typedef pair<P ,P> PP;
const ll MOD = ll(1e9+7);
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int n, a[10005], sum, ans;
    while(cin >> n, n){
        sum = 0;
        ans = 0;
        REP(i,n){
            cin >> a[i];
            sum += a[i];
        }
        sum /= n;
        REP(i,n){
            if(a[i]<=sum)ans++;
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3144
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;

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

	for (int i = 0; i < n; i++) {
		int a = 0, b = 0;

		int f = 0;
		for (int i = 0; i < 10; i++) {
			int x;
			cin >> x;

			if (!i) {
				a = x;
			}
			else {
				if (x > a) {
					a = x;
				}
				else {
					if (!b) {
						b = x;
					}
					else if (x>b) {
						b = x;
					}
					else {
						f = 1;
					}
				}
			}
		}

		if (f) {
			cout << "NO" << endl;
		}
		else {
			cout << "YES" << endl;
		}
	}
}


Measured memory_bytes: 3084
#include <stdio.h>
#include <math.h>
 
int        main()
{
    int        N, K;
    long long     sum = 0;
 
    scanf("%d %d\n", &N, &K);
    long long min = 0;
    // printf("%d %d\n", N, K);
    for(int i = 0; i<=(K-1); i++){
         min += i;
         min %= 1000000007;
    }
    long long max = 0;
    for(int i = (N-(K-1)); i<=N; i++){
         max += i;
         max %= 1000000007;
    }
    int n = 0;
    int i = K;
    while(i<=N+1)
    {
        if (n != 0)
        {
            min += (K - 1 + n);
            max += (N - (K - 1) - n);
        }
        sum += max - min + 1;
        sum %= 1000000007;
        // printf("%d %d\n", min, max);
        n++;
        i++;
    }
  if(sum<0)
    sum+=1000000007;
     printf("%lld\n", sum);
    return (0);
}

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

static const int MAX = 100;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

int prim() {
    int u, minv;
    int d[MAX], p[MAX], color[MAX];

    // init
    for (int i = 0; i < n; i++) {
        d[i] = INFTY; // ノードごとの最小エッジスコア
        p[i] = -1; // Minimum spanning treeでの親
        color[i] = WHITE;
    }

    d[0] = 0; // node 0からスタート

    while (true) {
        minv = INFTY;
        u = -1;

        // MSTに入っていない点の中で、最小エッジスコアが最小のものを選択 -> u
        for (int i = 0; i < n; i++) {
            if (minv > d[i] && color[i] != BLACK) {
                u = i;
                minv = d[i];
            }
        }

        // 行ける範囲にいった場合終わり
        if (u == -1)
            break;
        
        // uに到達
        color[u] = BLACK;

        // uの近傍の最小エッジスコアを更新
        for (int v = 0; v < n; v++) {
            if (color[v] != BLACK && M[u][v] != INFTY) {
                if ( d[v] > M[u][v] ) {
                    d[v] = M[u][v];
                    p[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }

    // back pointerから重みの和を計算
    int sum = 0;
    for (int i = 0; i < n; i++) {
        if ( p[i] != -1 )
            sum += M[i][p[i]];
    }
    return sum;
}

int main() {
    cin >> n;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            int e;
            cin >> e;
            M[i][j] = (e == -1) ? INFTY : e;
        }
    }

    cout << prim() << endl;
}


Measured memory_bytes: 3124
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	string O,E;
	cin>>O>>E;
	for(int i=0;O.length()>i;i++)
	{
		putchar(O[i]);
		if(E.length()>i)putchar(E[i]);
	}
	puts("");
	return 0;
}


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

int main() {
  int a,b;
  cin >> a>>b;

  if (a==b) {
    cout << a+b<< endl;
  }
  if(a>b)

  cout << 2*a-1<< endl;
if(a<b)
  cout<<2*b-1<<endl;
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    bool ans = true;
    map <int, int> m;
    int a[n];
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        m[a[i]]++;
        if(m[a[i]] > 1)
        {
            ans = false;
        }
    }
    if(ans)
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
    return 0;
}


Measured memory_bytes: 10368
using System;

namespace ITP1_5_B
{
    class Program
    {
        static void Main(string[] args)
        {
            while(true)
            {
                string[] str = Console.ReadLine().Split(' ');
                int H = int.Parse(str[0]);
                int W = int.Parse(str[1]);

                if(W!=0 && H!=0)
                {
                    for(int i=0; i<H; i++)
                    {
                        for(int j=0; j<W; j++)
                        {
                            if(j==W-1)
                            {
                                Console.WriteLine('#');
                            }
                            else if(i==0 || i==H-1 || j==0) 
                            {
                                Console.Write('#');
                            }
                            else
                            {
                                Console.Write('.');
                            }
                        }
                    }

                    Console.WriteLine();
                }
                else
                {
                    break;
                }
            }
        }
    }
}



Measured memory_bytes: 15920