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

int main(){
    int a, b, k;
    cin >> a >> b >> k;
    for (int i = a; i <= min(b, a+k-1); i++){
        cout << i << endl;
    }
    for (int i = max(b-k+1, a+k); i<=b; i++){
        cout << i << endl;
    }
    return 0;
}

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

int main(){
  int N,a,b,j;
  cin >> N;  
  vector<int> p(N),q(N),v(N);
  rep(i,N) cin >> p.at(i);
  rep(i,N) cin >> q.at(i);
  rep(i,N) v.at(i)=i+1;
  do{
    if(p == v) a = j;
    if(q == v) b = j;
    j ++;
  }while (next_permutation(v.begin(), v.end()));
  
  cout << abs(a-b);
}
          


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define INPUT()              freopen("input.txt", "r", stdin)
    #define OUTPUT()             freopen("output.txt", "w", stdout)
    #define F                    first
    #define S                    second
//Templatefunctions
    template<typename T>T gcd(T x, T y) { if (y == 0)return x; else return gcd(y, x%y);}
    template <class T> T euclideanDistance(T x1 , T x2 , T y1 , T y2){return sqrt(( x1 - x2 ) * ( x1 - x2 ) + ( y1 - y2 ) * ( y1 - y2 ));}
    template <class T> T digitSum(T n){T sum = 0;while(n > 0)sum += n % 10,n /= 10;return sum;}
//datatypes
    typedef long long int ll;
    typedef unsigned long long int ull;
    typedef long double ld;
//constants
    const double INF = 1e+9;
    const double INFLL = 1e+18;
    const double EPS = 1e-9;
    const double PI = acos(-1);
    const int knightDir[8][2] = {{-2,-1},{-2,1},{-1,2},{1,2},{2,-1},{2,1},{-1,-2},{1,-2}};
           //const int dx[]={0,0,0,1,1,1,-1,-1,-1};
           //const int dy[]={-1,0,1,-1,0,1,-1,0,1};
    const int dx[] = {0 , 1 , 0 , -1};
    const int dy[] = {1 , 0 , -1 , 0};
//helpers
    //#define MOD         1000000007LL
    #define MAX         2000005
    const ll MOD = 1000000000 + 7;
    //int arr[10000005];
    char str[MAX+10];
    int dp[MAX],bad[MAX];
//Global Variables
    //int dp[MAX],n;
    std::map<int,int>::iterator it;
     signed main()
    {
//        int t;
//        scanf("%d",&t);
//        int x = 2;
//        while(t--)
//        {
//        }
        int n , m;
        scanf("%d%d",&n,&m);

        for(int i = 0 ; i < m ; i++)
        {
            int x;
            scanf("%d",&x);
            bad[x] = 1;
        }

        dp[0] = 1;
        for(int i = 1 ; i <= n ; i++)
        {
            if(!bad[i])
            {
                if(i > 0)dp[i] = (dp[i-1] + dp[i]) % MOD;
                if(i > 1)dp[i] = (dp[i-2] + dp[i]) % MOD;
            }
        }
        printf("%d\n",dp[n]);
    }
//


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n, m;
  cin >> n >> m;
  int l = 1;
  int r = n;
  for(int i = 0; i < m; i++)
  {
    int a, b;
    cin >> a >> b;
    l = max(a, l);
    r = min(b, r);
  }
  if(l > r)
  {
    cout << 0 << endl;
  }
  else
  {
  cout << r - l + 1 << endl;
  }
}
    

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int N=2e5;
int n,cnt,hd[N],v[N],nxt[N],w[N];
long long d[N];
void dfs(int u,int fa){
    for(int i=hd[u];i;i=nxt[i]){
	    if(v[i]!=fa){
	        d[v[i]]=d[u]+w[i];
	        dfs(v[i],u);
	    }
	}
}
int main(){
    cin>>n;
    for(int i=1,x,y,z;i<n;i++){
		cin>>x>>y>>z;
		v[++cnt]=y;
		nxt[cnt]=hd[x];
		w[cnt]=z;
		hd[x]=cnt;
		v[++cnt]=x;
		nxt[cnt]=hd[y];
		w[cnt]=z;
		hd[y]=cnt;
	}
    dfs(1,0);
    for(int i=1;i<=n;i++){
        int op=d[i]&1;
        cout<<op<<endl;
    }
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define vi vector<int>
#define vii vector<int, int>
#define po pop_back
#define hell 1000000007
using namespace std;

int a[201][201];

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

void filla(){
	for(int i=1;i<201;i++){
		for(int j=1;j<201;j++){
			if(a[i][j]!=0) continue;
			else{
				a[i][j] = gcd(i,j);
				a[j][i] = a[i][j];
			}
		}
	}
}

void solve(){
	memset(a,0,sizeof(a));
	filla();
	int k;
	cin>>k;
	ll ans = 0;
	for(int i=1;i<k+1;i++){
		for(int j=1;j<k+1;j++){
			for(int l=1;l<k+1;l++){
				ans+=a[i][a[j][l]];
			}
		}
	}
	cout<<ans;
}

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

Measured memory_bytes: 3804
import itertools
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, m = map(int, readline().split())
k = [list(map(int, readline().split())) for _ in range(m)]
p = list(map(int, readline().split()))

ans = 0
for t in itertools.product([0, 1], repeat=n):
    t = list(t)
    bl = True
    for i in range(m):
        cnt = 0
        for j in k[i][1::]:
            cnt += t[j - 1]
        if cnt % 2 != p[i]:
            bl = False
    if bl:
        ans += 1
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc= new Scanner(System.in);
		int N=sc.nextInt();
		int M=sc.nextInt();
		int A[]=new int[N];//競技コスト
		int B[]=new int[M];//審査基準
		int kyougi[]=new int[N];//入った票数を管理する。
		int top=0,max=0;
		for(int i=0;i<N;i++){
			A[i]=sc.nextInt();
		}
		for(int i=0;i<M;i++){
			B[i]=sc.nextInt();
		}
		for(int i=0;i<M;i++){
			for(int j=0;j<N;j++){
				if(A[j]<=B[i]){//審査基準より費用が小さい競技
					kyougi[j]++;
					if(max<kyougi[j]){
						max=kyougi[j];
						top =j+1;
					}
					break;
				}
			}
		}
		System.out.println(top);
		}
}

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

int main() {
	int n; cin >> n;
	vector<int> S(n);
    for (int i = 0; i < n; i++) cin >> S[i];
    int q; cin >> q;
    int cnt = 0;
    while (q--) {
        int tgt; cin >> tgt;
		auto it = lower_bound(S.begin(), S.end(), tgt);
		auto jt = upper_bound(S.begin(), S.end(), tgt);
		cnt += min(1, int(jt - it));
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define adj_list vector<vi>
#define endl "\n"
#define INF_INT 2e9
#define INF_LL 2e18
#define matmax 25
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define pi pair<int, int>
#define pii pair<int, pair<int, int> >
#define pl pair<ll, ll>
#define pll pair<ll, pair<ll, ll> >
#define vi vector<int>
#define vl vector<ll>
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long int ll;

int lsone(int n)
{
	return (n&-n);
}

ll pow1(ll a, ll b)
{
	if (b == 0)
		return 1ll;
	else if (b == 1)
		return a;
	else
	{
		ll x = pow1(a, b/2);
		x *= x;
		x %= mod;
		if (b%2)
		{
			x *= a;
			x %= mod;
		}
		return x;
	}
}

int n, h[110000], dp[110000];

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

	for (int i = 1; i <= n; i++)
		cin>>h[i];

	dp[1] = 0;
	dp[2] = abs(h[2]-h[1]);
	for (int i = 3; i <= n; i++)
	{
		dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
	}

	cout<<dp[n]<<endl;

	return 0;
}


Measured memory_bytes: 1024
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List
import Test.HUnit

main :: IO ()
-- main = runTestTT (TestList tests) >> return ()
main = do
  xs <- getc $ solve . split toDbl
  mapM_ putStrLn xs

solve :: [Double] -> String
solve [t1,t2] = judge t1 t2

judge :: Double -> Double -> String
judge t1 t2
  | t1 < 35.5 && t2 < 71.0 = "AAA"
  | t1 < 37.5 && t2 < 77.0 = "AA"
  | t1 < 40.0 && t2 < 83.0 = "A"
  | t1 < 43.0 && t2 < 89.0 = "B"
  | t1 < 50.0 && t2 < 105.0 = "C"
  | t1 < 55.0 && t2 < 116.0 = "D"
  | t1 < 70.0 && t2 < 148.0 = "E"
  | otherwise = "NA"

toDbl :: String -> Double
toDbl s = read s

split :: (String -> a) -> String -> [a]
split f = map f . words

getc :: (String -> a) -> IO [a]
getc f = map f . lines <$> getContents

Measured memory_bytes: 4288
import sys
sys.setrecursionlimit(2**20)

class Node:
    def __init__(self, parent,
                left, right) -> None:
        self.parent = parent
        self.left = left
        self.right = right

def pre_parse(T: dict, u: int, pre_ls: list):
    if u is None:
        return
    pre_ls.append(u)
    pre_parse(T, T[u].left, pre_ls)
    pre_parse(T, T[u].right, pre_ls)

def in_parse(T: dict, u: int, in_ls: list):
    if u is None:
        return
    in_parse(T, T[u].left, in_ls)
    in_ls.append(u)
    in_parse(T, T[u].right, in_ls)

def post_parse(T: dict, u: int, post_ls: list):
    if u is None:
        return
    post_parse(T, T[u].left, post_ls)
    post_parse(T, T[u].right, post_ls)
    post_ls.append(u)

# input
n = int(input())
T = {key: Node(None, None, None) for key in range(n)}
for _ in range(n):
    tmp = list(map(int, input().split()))
    T[tmp[0]].left = tmp[1] if tmp[1] != -1 else None
    T[tmp[0]].right = tmp[2] if tmp[2] != -1 else None
    if tmp[1] != -1:
        T[tmp[1]].parent = tmp[0]
    if tmp[2] != -1:
        T[tmp[2]].parent = tmp[0]
ROOT = 0
for id, node in T.items():
    if node.parent is None:
        ROOT = id
        break

pre_ls, in_ls, post_ls = [], [], []
pre_parse(T, ROOT, pre_ls)
in_parse(T, ROOT, in_ls)
post_parse(T, ROOT, post_ls)

print("Preorder")
print("", *pre_ls)
print("Inorder")
print("", *in_ls)
print("Postorder")
print("", *post_ls)


Measured memory_bytes: 5624
import java.util.*;
class Main
{
  public static void main(String args[])
  {
    Scanner sc=new Scanner(System.in);
    for(int j=0;j<5;j++)
    {
      int val=sc.nextInt();
      if(val==0)
      {
        System.out.println(j+1);
        break;
      }
    }
  }
}

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

#define pb push_back
#define fi first
#define se second
typedef long long ll;

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

	int n;
	cin >> n;

	int next = 1, ans = 0;
	for (int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		if (a == next) {
			next++;
			ans++;
		}
	}
	cout << (ans == 0 ? -1 : n - ans) << '\n';
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <cctype>
#include <algorithm>
#include <functional>
#include <utility>
#include <vector>
using ll = long long;
const ll ha = 1000000007LL;
const int maxn = 5005;
std::vector<int> G[maxn];
inline void ins_edge(int u, int v) {
  G[u].push_back(v);
  G[v].push_back(u);
}

ll g[maxn];
ll f[maxn][maxn]; int siz[maxn];
void dp(int x, int fa = 0) {
  siz[x] = 1;
  for(int v : G[x]) {
    if(v != fa) {
      dp(v, x); siz[x] += siz[v];
    }
  }
  int lim = 1;
  f[x][1] = 1;
  static ll tmp[maxn];
  for(int v : G[x]) {
    if(v != fa) {
      ll val = 0;
      for(int i = 1; i <= siz[v]; i ++) {
        ll cb = f[v][i];
        val = (val + ha - cb * g[i] % ha) % ha;
      }
      std::fill(tmp, tmp + lim + siz[v] + 1, 0);
      for(int i = 1; i <= lim; i ++) {
        tmp[i] = (tmp[i] + f[x][i] * val) % ha;
        for(int j = 1; j <= siz[v]; j ++) {
          ll &p = tmp[i + j];
          p = (p + f[x][i] * f[v][j]) % ha;
        }
      }
      std::copy(tmp, tmp + lim + siz[v] + 1, f[x]);
      lim += siz[v];
    }
  }
#ifdef LOCAL
  for(int i = 1; i <= lim; i ++) {
    printf("f[%d][%d] : %lld\n", x, i, f[x][i]);
  }
#endif
}

int main() {
  int n; scanf("%d", &n);
  g[2] = 1;
  for(int i = 3; i <= n; i ++) {
    if(1 & i) g[i] = 0;
    else g[i] = g[i - 2] * (i - 1) % ha;
  }
  for(int i = 1; i <= n - 1; i ++) {
    int u, v; scanf("%d%d", &u, &v);
    ins_edge(u, v);
  }
  dp(1);
  ll ans = 0;
  for(int i = 1; i <= n; i ++) {
    ans = (ans + f[1][i] * g[i]) % ha;
  }
  printf("%lld\n", ans);
  return 0;
}

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

int main(){
  int N,K,A,B,x,sum = 0;
  cin >> N >>K;
  
  for(int i = 0; i<N; i++){
    cin >> x;
    A =2*x;
    B =2*(x-K);
    
    if(B<0)
      B *=-1;
    
    if(A<B)
      sum +=A;
    
    else
      sum +=B;
  }
  cout << sum <<endl;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    a: i64,
    b: i64,
    c: i64,
    k: i64,
    }
    let mut ans = 0;
    let mut k = k;
    if a <= k {
        ans += a;
        k -= a;
    } else {
        println!("{}", k);
        return
    }
    if b > k {
        println!("{}", ans);
        return
    } else {
        k -= b;
    }
    if c > k {
        ans -= k;
    } else {
        ans -= c;
    }
    println!("{}", ans);



}


Measured memory_bytes: 2144
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
LL A[501][501];
LL B[501];

void solve(){
	REP(i,N){
		for(int j=i+1;j<N;j++){
			cout<<A[i][j];
			if(j!=N-1)cout<<" "; 
		}
		if(i!=N-1){
			cout<<endl;
		}
	}
}

void solve2(){
	REP(i,N){
		REP(j,N){
			cout<<A[i][j]<<" ";
		}
		cout<<endl;
	}
}
int main(){
	cin>>N;
	REP(i,N){
		REP(j,N){
			A[i][j]=-1;
		}
		B[i]=0;
	}
	A[0][1]=1;
	A[0][2]=1;
	A[1][0]=1;
	A[2][0]=1;
	A[1][2]=2;
	A[2][1]=2;
	B[0]=1;
	B[1]=2;
	B[2]=2;
	for(int i=3;i<N;i++){
		int x=0;
		int now=1000;
		REP(k,i){
			if(now>B[k]){
				now=B[k];
				x=k;
			}
		}
		B[x]++;
		//cout<<x<<" "<<B[x]<<endl;
		REP(j,i){
			A[i][j]=A[x][j];
			A[j][i]=A[j][x];
		}
		A[i][x]=B[x];
		A[x][i]=B[x];
		B[i]=B[x];
	}
	//solve2();
	solve();
	return 0;
}

Measured memory_bytes: 2432
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 5;
int n;
ll l, r, ans = 1e18 + 1;
ll a[maxn], s[maxn], t[4];
ll f(ll x) { return x > 0 ? x : -x; }
int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n; l = 1, r = 3;
	for (int i = 1; i <= n; i++)cin >> a[i], s[i] = s[i - 1] + a[i];
	for (int i = 2; i <= n - 2; i++) {
		while (l + 1 < i && f(2 * s[l] - s[i])
			>= f(2 * s[l + 1] - s[i])) l++;
		while (r + 1 < n && f(2 * s[r] - s[i] - s[n])
			>= f(2 * s[r + 1] - s[i] - s[n])) r++;
		t[0] = s[l];
		t[1] = s[i] - s[l];
		t[2] = s[r] - s[i];
		t[3] = s[n] - s[r];
		sort(t, t + 4);
		ans = min(ans, t[3] - t[0]);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

// const int maxn = 
const int mo = 1e9 + 7;

int n;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int x, y, z;
	cin >> x >> y >> z >> n;

	int a = 0, ans = 0;
	for (int i = 0; a <= n; ++i) {
		int b = 0;
		for (int j = 0; a + b <= n; ++j) {
			int c = n - a - b;
			if (c % z == 0)
				++ans;
			b += y;
		}
		a += x;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
typedef long long ll;
const int INF = 1e9+1;
const int MOD = 2e9 + 9;
const ll LINF = 1e18;
using namespace std;


int main() {
	int n;
	int x = 0, maxi = 0;
	string s;
	cin >> n >> s;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'I')x++;
		else if (s[i] == 'D')x--;

		if (x > maxi)maxi = x;
	}
	cout << maxi << endl;
	return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>

int main(void)
{
	int N, M;
	scanf("%d%d",&N, &M);
	int num[30];
	int K[30][30];
	int i = 0;
	int j,k;
	while (i < N)
	{
		if (scanf("%d", &num[i]) == 1)
		{
			j = 0;
			while (j < num[i])
			{
				if (scanf("%d", &K[i][j]) == 1)
				{
				}
				else
					break;
				j++;
			}
		}
		else
			break;
		i++;
	}
	// i = 0;
	// while (i < N)
	// {
	// 	j = 0;
	// 	while (j <= num[i])
	// 	{
	// 		printf("%d ", K[i][j]);
	// 		j++;
	// 	}
	// 	printf("\n");
	// 	i++;
	// }
	i = 1;
	int count;
	int ans = 0;
	while (i <= M)
	{
		j = 0;
		count = 0;
		while (j < N)
		{
			k = 0;
			while (k < num[j])
			{
				if (i == K[j][k])
				{
					count++;
					break;
				}
				k++;
			}
			j++;
		}
		if (count == N)
			ans++;
		i++;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
package main
import (
   "fmt"
   "os"
   "bufio"
   "strconv"
)
var sc = bufio.NewScanner(os.Stdin)

func main() {
  sc.Split(bufio.ScanWords)
  a := nextInt()
  b := nextInt()
  mul := a * b

  if mul % 2 == 0{
	  fmt.Println("Even")
  }else if mul % 2 == 1{
	  fmt.Println("Odd")
  }
}

func nextString() (string) {
	sc.Scan()
	v := sc.Text()
	return v
}

func nextInt() (int) {
	sc.Scan()
	v, e := strconv.Atoi(sc.Text())
    if e != nil { panic(e) }
    return v
}

func nextFloat() (float64) {
	sc.Scan()
	v, e := strconv.ParseFloat(sc.Text(), 64)
    if e != nil { panic(e) }
    return v
}


Measured memory_bytes: 640
use input::Input;
use std::collections::HashMap;

const MOD: i64 = 2019;

fn main() {
    let mut input = Input::new();

    let mut x = 1;
    let v = input
        .read_line()
        .trim_end()
        .chars()
        .rev()
        .map(|z| {
            let y = (z as u8 - b'0') as i64 * x % MOD;
            x *= 10;
            x %= MOD;
            y
        })
        .collect::<Vec<_>>();

    let mut sum = 0;
    let mut map: HashMap<i64, i64> = HashMap::new();
    map.insert(0, 1);
    for i in 0..v.len() {
        sum = (sum + v[i]) % MOD;
        let count = map.entry(sum).or_insert(0);
        *count += 1;
    }

    let mut ans = 0;
    for (_, v) in map {
        ans += v * (v - 1) / 2;
    }
    println!("{}", ans);
}

#[allow(dead_code)]
mod input {
    use std::io::{stdin, BufRead, StdinLock};

    pub struct Input<'a> {
        memory: Vec<String>,
        reader: StdinLock<'a>,
    }

    impl<'a> Input<'a> {
        pub fn new() -> Self {
            Self {
                memory: Vec::new(),
                reader: Box::leak(Box::new(stdin())).lock(),
            }
        }
        pub fn read_line(&mut self) -> String {
            let mut s = String::new();
            self.reader.read_line(&mut s).expect("read_line failed.");
            s
        }
        pub fn parse<T: std::str::FromStr>(&mut self) -> T {
            if self.memory.len() == 0 {
                let s = self.read_line();
                self.memory = s.split_whitespace().map(String::from).rev().collect();
            }
            self.memory.pop().unwrap().parse().ok().unwrap()
        }
    }
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  int from = max(A, C);
  int to = min(B, D);

  string ans = std::to_string(max(to - from, 0));
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {


        Scanner sc = new Scanner(System.in);

        int i = 0, j = 0;
        double[] a;
        a = new double[1000];

        while (i < 1000) {

            int n = sc.nextInt();

            if (n == 0) {
                break ;
            }

            double[] A;
            double m = 0;
            A = new double[n];

            for (j = 0; j < n; ++j) {
                A[j] = sc.nextInt();
                m += A[j];
            }

            m = m / n;

            for (j = 0; j < n; ++j) {
                a[i] += Math.pow((A[j] - m), 2);
            }

            a[i] = a[i] / n;
            a[i] = Math.pow(a[i], 0.5);

            ++i;
        }

        for(j=0;j<i;++j){

            System.out.println(a[j]);

        }
    }


}



Measured memory_bytes: 31604
/*
memo for solution
*/
#include <cstdlib> 
#include <numeric>
#include <cstring>
#include <cstdio> 
#include <cfloat> 
#include <map> 
#include <cassert>
#include <cmath> 
#include <climits> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <iomanip>
#include<sys/time.h>
using namespace std; 
double e_time(void){static struct timeval now;gettimeofday(&now, NULL);return (double)(now.tv_sec  + now.tv_usec/1000000.0);}
#define REP(i,b,n) for(int i=b;i<n;i++) 
#define rep(i,n)      REP(i,0,n) 
#define pb push_back  
#define mp make_pair 
#define ALL(C)   (C).begin(),(C).end() 
#define fe(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr != (c).end();itr++)
#define BITSHIFT(X)     ( (1<<(X)) )
#define CONTAIN(S,X) ( ((S)&BITSHIFT(X)) != 0)
typedef complex<double>P; 
typedef long long ll; 
typedef unsigned long long ull; 
typedef pair<int,int> pii; 
typedef vector<int> vint;
template<class T> void vp(T &a,int p){rep(i,p)cout << a[i]<<" ";cout << endl;}  
template<class T> T ceilUp(const T& a,const T& b){return (a+b-1)/b;}
const ll mod =   1000000009;
inline ll modadd(ll a,ll b){a %= mod;b %= mod;return (a+b)%mod;}
inline ll modsub(ll a,ll b){a %= mod;b %= mod;a-=b;a%=mod;if (a<0)a+=mod;return a;}
inline ll modmul(ll a,ll b){a %= mod;b %= mod;return (a*b)%mod;}
inline ll modeq(ll a,ll b,ll m){a = (a%m+m)%m; b = (b%m+m)%m;return a == b;}
//ll modpow(ll n,ll p){if (p == 0)return 1;if (p == 1)return n;ll ret=mypow(n,p/2);ret=ret*ret%mod;if (p&1)ret=ret*n%mod;return ret;}
//ll getinv(ll a){return mypow(a,mod-2);}
ll mypow(ll n,ll p){
  if (p == 0)return 1;
  if (p == 1)return n;
  ll ret=mypow(n,p/2);
  ret=ret*ret;
  if (p&1)ret=ret*n;
  return ret;
}

const int N = 400;
bool vis[N][N] = {false};
int dy[4] = {0, 0, 1, -1};
int dx[4] = {1, -1, 0, 0};

void solve(int h, int w, int y, int x, int  & cnt_b, int & cnt_h, const vector<string> & in){
  if (vis[y][x])return;
  if (in[y][x] == '#')cnt_b++;
  else cnt_h++;
  vis[y][x] = true;
  rep(i,4){
    int nex = x + dx[i], ney = y + dy[i];
    if (0 <= ney && ney < h &&
	0 <= nex && nex < w && in[y][x] != in[ney][nex]){
      solve(h, w, ney, nex, cnt_b, cnt_h, in);
    }
  }
}
 
int main(){
  int h, w;
  cin >> h >> w;
  vector<string> in(h);
  rep(i,h)cin>>in[i];
  long long ans = 0;
  rep(i,h){
    rep(j,w){
      if (!vis[i][j]){
	int cnt_b = 0, cnt_h = 0;
	solve(h, w, i, j, cnt_b, cnt_h, in);
	ans += (long long)cnt_b * cnt_h;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
 
 


Measured memory_bytes: 18176
n, x = map(int, input().split())
X = list(map(int, input().split()))

X.sort()
l = []
for i in range(n):
    l.append(abs(X[i]-x))

import fractions
#import math
from functools import reduce

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)
    #return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
    #return reduce(math.gcd, numbers)

print(gcd_list(l))


Measured memory_bytes: 84244
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	seg := newSegment(n)
	for i := 0; i < n; i++ {
		a := getNextInt(scanner)
		seg.update(i, a, seg.gcd)
	}
	var ans cint
	ans.maxAs(cint(seg.query(0, n-1, seg[0][0], seg.gcd)))
	ans.maxAs(cint(seg.query(1, n, seg[0][1], seg.gcd)))
	for i := 1; i < n-1; i++ {
		g := seg.gcd(seg.query(0, i, seg[0][0], seg.gcd), seg.query(i+1, n, seg[0][i+1], seg.gcd))
		ans.maxAs(cint(g))
	}
	fmt.Fprintln(writer, ans)
}

type cint int64

func (ct *cint) minAs(x cint) *cint {
	*ct = ct.min(x)
	return ct
}
func (ct *cint) maxAs(x cint) *cint {
	*ct = ct.max(x)
	return ct
}
func (ct cint) min(x cint) cint {
	if ct > x {
		return x
	}
	return ct
}
func (ct cint) max(x cint) cint {
	if ct < x {
		return x
	}
	return ct
}

type segment [][]int

func newSegment(n int) segment {
	seg := make(segment, 0)
	for n > 1 {
		seg = append(seg, make([]int, n))
		n = (n + 1) >> 1
	}
	seg = append(seg, make([]int, 1))
	return seg
}
func (seg segment) update(i int, v int, f func(x, y int) int) {
	seg[0][i] = v
	for h := 1; h < len(seg); h++ {
		i >>= 1
		if i<<1+1 < len(seg[h-1]) {
			seg[h][i] = f(seg[h-1][i<<1], seg[h-1][i<<1+1])
		} else {
			seg[h][i] = seg[h-1][i<<1]
		}
	}
}
func (seg segment) query(l, r int, s int, f func(x, y int) int) int {
	for h := 0; h < len(seg) && l < r; h++ {
		if l&1 == 1 {
			s = f(s, seg[h][l])
			l++
		}
		l >>= 1
		if r&1 == 1 {
			s = f(s, seg[h][r-1])
		}
		r >>= 1
	}
	return s
}
func (seg segment) gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return seg.gcd(y, x%y)
}


Measured memory_bytes: 5716
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define P 1000000007
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;

void solve() {
	int h, a;
	cin >> h >> a;
	
	int num = 0;
	while(h > 0) {
		h -= a;
		num++;	
	}
	
	cout << num << endl;
}

int main(){
#define MULTITEST 0
#if MULTITEST   
 
    CASET {
        solve();
    }
    
#else

    solve();
    
#endif

    return 0;
}

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

const int  maxn = 100002;

int par[maxn];
int ranks[maxn];
int club[maxn];

void init(){
    for(int i=0;i<maxn;i++){
        par[i] = i;
        ranks[i] = 0;
    }
}

int find(int x){
    if(par[x] == x){
        return x;
    } else{
      return par[x] = find(par[x]);
    }
}

void unite(int x,int y){
    x = find(x);
    y = find(y);
    if(x == y ) return;

    if(ranks[x] < ranks[y]){
        par[x] = y;
        if(club[y] == 0 && club[x] != 0){
            club[y] = club[x];
        }
    }
    else{
        par[y] = x;
        if(club[x] == 0 && club[y] != 0){
            club[x] = club[y];
        }
        if(ranks[x] == ranks[y])
            ranks[x]++;
    }
}



int main() {

    int n,m,k;

    cin >> n >> m >> k;

    int r,a,b;

    init();

    for(int i=1;i<=k;i++) {

        scanf(" %d %d %d", &r, &a, &b);

        if(r==1){

            int ra = find(a);
            int rb = find(b);

            if(club[ra] != 0 && club[rb] != 0 && club[ra] != club[rb]){
                cout << i << endl;
                return 0;
            }
            unite(a,b);
        }
        else{
            int rute = find(a);

            if(club[rute] != 0 && club[rute] != b){
                cout << i << endl;
                return 0;
            }

            club[rute] = b;
        }

    }

    cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 4392
#include<cstdio>
    #include<cmath>
    #include<cstdlib>
    #include<cstring>
    #include<algorithm>
    #include<iostream>
    using namespace std;
    int main(){
    	char a,b;
    	while (~scanf ("%c %c",&a,&b)){
    		getchar();
    		if (a-b>0){
    			printf (">\n");
    		}
    		if (a-b<0){
    			printf ("<\n");
    		}
    		if (a-b==0){
    			printf ("=\n");
    		}
    	}
    	return 0;
    }

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
	int N;
	int i;
	int anyC=0;
	int rate;
	int c1=0;
	int c2=0;
	int c3=0;
	int c4=0;
	int c5=0;
	int c6=0;
	int c7=0;
	int c8=0;
	cin>>N;
	for (i=0;i<N;i++){
		cin>>rate;
		if (1<=rate && rate<=399){
			c1=1;
		}else if (400<=rate && rate<=799){
			c2=1;
		}else if (800<=rate && rate<=1199){
			c3=1;
		}else if (1200<=rate && rate<=1599){
			c4=1;
		}else if (1600<=rate && rate<=1999){
			c5=1;
		}else if (2000<=rate && rate<=2399){
			c6=1;
		}else if (2400<=rate && rate<=2799){
			c7=1;
		}else if (2800<=rate && rate<=3199){
			c8=1;
		}else{
			anyC++;
		}
	}
	int minC,maxC;
	minC=c1+c2+c3+c4+c5+c6+c7+c8;
	maxC=anyC+minC;
	/*
	int rem=8-minC;
	if (anyC>=rem){
		maxC=8;
	}else{
		maxC=anyC+minC;
	}*/
	if (minC==0){
		minC=1;
	}
	cout<<minC<<" "<<maxC<<endl;
	return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define MAX 200000

int n, bit[MAX+2], bit_size;

int sum(int i){
	int s=0;
	while(i>0){
		s+=bit[i];
		i-=(i&-i);
	}
	return s;
}

void add(int i, int x){
	while(i<=bit_size){
		bit[i]+=x;
		i+=(i&-i);
	}
	return;
}

int main(){
	ll k;
	cin >> n >> k;
	vector<ll> s(n+1, 0);
	for(int i=1; i<=n; i++){
		ll a;
		cin >> a;
		s[i]=s[i-1]+a-k;
	}

	vector<ll> v=s;
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
	for(int i=0; i<=n; i++){
		s[i]=lower_bound(v.begin(), v.end(), s[i])-v.begin()+1;
	}

	bit_size=v.size();
	ll ans=0;
	for(int i=0; i<=n; i++){
		ans+=sum(s[i]);
		add(s[i], 1);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define INF 10000000000

ll b, n, x, y, z, w, ans = 0, cnt = 0, mx = 0, mn = INF;
string s;

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

    cin >> n;
    ll m = 0, a = 0, r = 0, c = 0, h = 0;
    rep(i, n){
        cin >> s;
        if(s[0] == 'M'){
            m++;
        }else if(s[0] == 'A'){
            a++;
        }else if(s[0] == 'R'){
            r++;
        }else if(s[0] == 'C'){
            c++;
        }else if(s[0] == 'H'){
            h++;
        }
    }
    ll d[5];
    d[0] = m, d[1] = a, d[2] = r, d[3] = c, d[4] = h;
    rep(i, 3){
        rep(j, i + 1, 4){
            rep(k, j + 1, 5){
                ans += d[i] * d[j] * d[k];
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[1000000];
map<string,int> hash_m;
int main()
{
    int n;
    string s;
    int br=0;
    cin>>n;
   for(int i=0;i<n;i++) {cin>>s;hash_m[s]++; if(hash_m[s]==1) br++;}
    cout<<br<<endl;

    return 0;
}


Measured memory_bytes: 19228
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
class Program
{       
    static IEnumerable<string> GenerateChain(int start, int count)
    {
        foreach(int i in Enumerable.Range(1, count))
        {
            yield return $"{start} {start + i}";
        }
    }
    public void Slove()
    {
        var input = Console.ReadLine();
        bool[] canCreate = input.Select(x => x == '1').ToArray();
        if(
            !canCreate[0] || canCreate.Last() ||
            Enumerable.Range(0, (input.Length + 1) / 2)
                .Any(x => canCreate[x] != canCreate[input.Length - x - 2])
            )
        {
            Console.WriteLine(-1);
        }
        else
        {
            int idGen = 1;
            int main = 1;
            var result = new List<string>();
            for(int i = 0; i < input.Length - 1; i++)
            {
                result.Add($"{main} {++idGen}");
                if(canCreate[i])
                {
                    main = idGen;
                }
            }
            System.Console.WriteLine(string.Join("\n", result));
        }
    }
    
    static void Main(string[] args)
    {
        new Program().Slove();
    }
}


Measured memory_bytes: 31700
#include <bits/stdc++.h>
#define MOD 1000000007

using namespace std;


int main(){
    long long x,y;
    cin >> x >> y;
    long long g=__gcd(x,y);
    x/=g;y/=g;
    if(y==1){
        cout << "-1" << endl;
    }
    else{
        if(y>2)
            x=x*g*(y-1);
        else
            x=x*g*(y+1);
        if(x>1000000000000000000){
            cout << "-1" << endl;
        }
        else{
            cout << x << endl;
        }

    }
    return 0;
}


Measured memory_bytes: 256
// This file is a "Hello, world!" in Java language by OpenJDK for wandbox.
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;

class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		sc.close();
        int ans=0;
        int aind=-1;
        int zind=-1;
        
        for (int i=0;i<s.length;i++){
            if (s[i]=='A' && aind==-1){
                aind=i;
            }    
            if (s[i]=='Z'){
                zind=i;
            }
        }
		System.out.println(zind-aind+1);        
    
    }
}



Measured memory_bytes: 26800
import sys
N,M = map(int,input().split())
As = [int(input()) for e in range(M)]

if N == 1:
    if 1 in As:
        print(0)
    else:
        print(1)
    sys.exit()

 
if 1 in As and 2 in As:
    print(0)
    sys.exit()
 
if 1 in As and 2 not in As:
    patterns = [0,1]
 
if 1 not in As and 2 in As:
    patterns = [1,0]
 
if 1 not in As and 2 not in As:
    patterns = [1,2]
 
flags = [0 for _ in range(N)]
for e in As:
    flags[e] = 1
for i in range(3,N+1):
    value = 0
    if not flags[i-2]:
        value += patterns[i-3]
    if not flags[i-1]:
        value += patterns[i-2]
    patterns.append(value%1000000007)
print(patterns[-1]%1000000007)

Measured memory_bytes: 9628
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
using namespace std;

typedef unsigned int uint;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vint;
typedef vector<uint> vuint;
typedef vector<ull> vull;
typedef vector<ll> vll;

#define init(type,var) type var;cin>>var;
#define vinit(type,var,n) vector<type> var((uint)n);loop(i,0,n)cin>>var[i];
#define linit(type,var,n) list<type> var;loop(i,0,n){type _v;cin>>_v;var.push_back(_v);}
#define range(container) container.begin(),container.end()
#define loop(i,first,end) for(ull i=(first);i<(end);i++)
#define outl(out) cout<<(out)<<endl;

const ull INF = (ull)(-1LL);

typedef ull dint;

typedef vector<dint> vdint;

int main(void){
	init(dint, n);

	bool ans = false;
	loop(i, 1, 10){
		ans |= (n % i == 0 && n / i < 10);
	}

	outl(ans ? "Yes" : "No");

	return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
m = [list(input()) for _ in range(h)]

for i in range(h):
    for j in range(w):
        if m[i][j] == '#':
            cnt = sum([0 <= i-1, i+1 < h, 0 <= j-1, j+1 < w])

            # up
            if 0 <= i-1:
                if m[i-1][j] != '#':
                    cnt -= 1

            # down
            if i+1 < h:
                if m[i+1][j] != '#':
                    cnt -= 1
            # left
            if 0 <= j-1:
                if m[i][j-1] != '#':
                    cnt -= 1

            # right
            if j+1 < w:
                if m[i][j+1] != '#':
                    cnt -= 1

            if cnt == 0:
                print('No')
                exit(0)
else:
    print('Yes')


Measured memory_bytes: 3064
/**
*    author:  boutarou
*    created: 27.06.2020 21:01:52
**/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define fcout cout << fixed << setprecision(15)
using lint = long long;
using P = pair<int, int>;

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

const double PI = 3.1415926535897932;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    lint n, m;
    lint k;
    lint ans = 0;
    cin >> n >> m >> k;
    vector<lint>a(n), b(m);
    vector<lint>asum(n + 1), bsum(m + 1);
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];
    asum[0] = 0, bsum[0] = 0;
    rep(i, n) asum[i + 1] = asum[i] + a[i];
    rep(i, m) bsum[i + 1] = bsum[i] + b[i];
    rep(i, n + 1) {
        if (asum[i] > k) break;
        lint res = k - asum[i];
        lint readi = upper_bound(bsum.begin(), bsum.end(), res) - bsum.begin() - 1;
        //cout << readi << " ";
        chmax(ans, readi + i);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 9536
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int N = sc.nextInt();
		int Q = sc.nextInt();
		String S = sc.next();
		int [] l = new int [Q];
		int [] r = new int [N];
		int sum = 0;
		for (int i = 0; i < N-1; i++) {
			
			if (S.charAt(i) == 'A' && S.charAt(i+1) == 'C') {
			
				sum++;
				r[i+1] += sum;
			
			} 
			
			else {
				r[i+1] += sum;
			}
		
		}
		
		for (int i = 0; i < Q; i++) {
		
			int start = sc.nextInt() - 1;
			int fin = sc.nextInt() - 1;
			l[i] = r[fin] - r[start];
			
		}
		
		for (int T = 0; T < Q; T++) {
			System.out.println(l[T]);
		}

	}	

}

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

int main() {
  string s; cin >> s;
  int ans = 1 << 31 - 1;
  for (int i = 0; i < s.size() - 2; ++i) {
    string x = s.substr(i, 3);
    ans = min(abs(753 - stoi(x)), ans);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    int main(){
        long long sum=0;
    long long n,t[100000],m,p,x,a,b;
    cin>>n;
    for(int i=0;i<n;i++){
        scanf("%lld",&t[i]);
    }
   scanf("%lld",&m);
    for(int j=0;j<m;j++)
    {
        sum=0;
        scanf("%lld %lld",&a,&b);
        int temp=t[a-1];
          t[a-1]=b;
        for(int k=0;k<n;k++){

            sum+=t[k];
        }
        printf("%lld\n",sum);
        t[a-1]=temp;
    }
    return 0;

    }




Measured memory_bytes: 256
#include <cstdio>
    #include <cstring>
    #include <cstdlib>
    #include <vector>
    #include <algorithm>
    #include <cstdlib>
    #include <cmath>
    #include <map>
    #pragma comment(linker, "/STACK:336777216")  
     
    using namespace std;
     
    const int MOD = 1000000007;
     
    int H, W, A, B;
     
    const int MAXCOMB = 200000 + 10; // NEED TO CHECK
    long long Fac[MAXCOMB], InvFac[MAXCOMB];
    long long CombMod(long long A, long long B)
    {
    	long long Ans = Fac[A];
    	(Ans *= InvFac[B]) %= MOD;
    	(Ans *= InvFac[A - B]) %= MOD;
    	return Ans;
    }
    long long PowerMod(long long Base, long long Exp, long long Mod)
    {
    	Base %= Mod;
    	long long Ret = 1;
    	while (Exp)
    	{
    		if (Exp & 1)
    			(Ret *= Base) %= Mod;
    		(Base *= Base) %= Mod;
    		Exp >>= 1;
    	}
    	return Ret;
    }
    void GenFactorial()
    {
    	Fac[0] = 1;
    	for (int i = 1; i < MAXCOMB; i ++)
    		Fac[i] = ((long long) Fac[i - 1] * (long long) i) % MOD;
    	InvFac[MAXCOMB - 1] = PowerMod(Fac[MAXCOMB - 1], MOD - 2, MOD);
    	for (int i = MAXCOMB - 1; i >= 1; i --)
    		InvFac[i - 1] = ((long long) InvFac[i] * (long long) i) % MOD;
    }
     
    void Work()
    {
    	GenFactorial();
    	scanf("%d%d%d%d", &H, &W, &A, &B);
    	long long Ans = 0;
    	for (int i = B; i < W; i ++)
    	{
    		Ans += CombMod(H - A - 1 + i, H - A - 1) * CombMod((H + W - 2) - (H - A - 1 + i) - 1, A - 1) % MOD;
    		Ans %= MOD;
    	}
    	printf("%d\n", (int) Ans);
    }
     
    int main()
    {
    	Work();
    	return 0;
    }

Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		int X = Integer.parseInt(sc.next());
		sc.close();
		if(A <= X && X <= A + B) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}

	}
}


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

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

string SD, T;
vector<string> sv;

/*==================================================*/

/*==================================================*/

int main() {
    cin>>SD>>T;
    for(int i = SD.size()-T.size(); i >= 0; i--){
        bool flag = false;
        REP(j,0,T.size()){
            if(SD[i+j] != T[j] && SD[i+j] != '?'){
                flag = true;
                break;
            }
        }
        if(!flag){
            string tmp = "";
            REP(j,0,SD.size()){
                if(i <= j && j < i + T.size()){
                    tmp += T[j - i];
                }else if(SD[j] == '?'){
                    tmp += "a";
                }else{
                    tmp += SD[j];
                }
            }
            sv.push_back(tmp);
            continue;
        }
    }

    if(sv.size() == 0){
        cout<<"UNRESTORABLE"<<endl;
    }else{
        sort(sv.begin(), sv.end());
        cout<<sv[0]<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
import heapq

N = int(input())
h = list(map(int, input().split()))

s = 0
Q = []
heapq.heappush(Q, h)
while Q:
	a = heapq.heappop(Q)
	x = min(a)
	s += x
	for i in range(len(a)):
		a[i] -= x
	L = []
	for i in range(len(a)):
		if a[i] == 0:
			if L!= []:
				heapq.heappush(Q, L)
				L = []
		else:
			L.append(a[i])
	if L != []:
		heapq.heappush(Q, L)

print(s)

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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;

		while ((str = br.readLine()) != null) {
			String[] num = str.split(" ", 0);

			double a = Double.parseDouble(num[0]);
			double b = Double.parseDouble(num[1]);
			double c = Double.parseDouble(num[2]);
			double d = Double.parseDouble(num[3]);
			double e = Double.parseDouble(num[4]);
			double f = Double.parseDouble(num[5]);

			double x = (c * e - b * f) / (a * e - b * d);
			double y = (a * f - c * d) / (a * e - b * d);

			if (x == -0) {
				x = 0;
			}
			if (y == -0) {
				y = 0;
			}

			System.out.printf("%4.3f %4.3f\n", x, y);
		}
	}
}

Measured memory_bytes: 24772
#include <iostream>
//#include<cmath>
//#include<algorithm>
//#include<vector>
using namespace std;

int main() {
	int N;
	float ans;
	cin >> N;
	ans = N;
	if (N % 2 == 1)N = N / 2 + 1;
	else N /= 2;
	ans = N / ans;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(),v.end()
ll INF = 10010001010;

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

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

int main(){
    ll A, B, K;
    cin >> A >> B >> K;
    for (int i = A; i <= B;i++)
    {
        if (i <= A + K - 1 || i >= B - K + 1)
        {
            cout << i << endl;
        }
    }
}


Measured memory_bytes: 256
# coding=utf-8

N = int(input())
a = []

for x in input().split(" "):
    a.append(int(x))

a.sort(reverse=True)

alice = 0
bob = 0

for i in range(N):
    if i%2==0:
        alice += a[i]
    else:
        bob += a[i]

print(alice-bob)


Measured memory_bytes: 3060
use proconio::input;

fn main() {
    input! {
        n: String,
    }
    let s = n.chars().map(|c| c.to_digit(10).unwrap()).sum::<u32>();
    if s % 9 == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

typedef long long ll;

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

	int num;
	cin >> num;
	ll cnt = 0;
	for (int i = 1; i < num; ++i)
	{
		cnt += ((num / i) * i == num) ? num / i - 1 : num / i;
	}
	cout << cnt << "\n";
	return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>

int search(int A[],int n,int key){
	int i=0;
	A[n]=key;
	while(A[i]!=key)i++;
	return i!=n;
}

int main(){
	int i,n,A[10000+1],q,key,sum=0;
	
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%d",&A[i]);
	
	scanf("%d",&q);
	for(i=0;i<q;i++){
		scanf("%d",&key);
		if(search(A,n,key))sum++;
	}
	printf("%d\n",sum);
	
	return 0;
}

Measured memory_bytes: 636
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<deque>
#include<iomanip>
#include<set>
#include<unordered_set>
#include<tuple>
#include<map>
#include<memory>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<double> VD;
typedef pair<int, int> P1;
typedef long long int ll;

//number
#define INF 1e9
#define NUM 1000000007

//itr
#define all(x) begin(x),end(x)

//repeat
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define RREPS(i,x) for(int i=((int)(x));i>=0;i--)

//max,min
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

//function

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

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

/*int dig(int a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}*/

//grid template
int x[] = { -1, 0, 1, 0 };
int y[] = { 0,-1,0,1 };
int xx[] = { -1,-1,1,1 };
int yy[] = { 1,-1,1,-1 };

int main() {
	string s;
	cin >> s;

	s[3] = '8';
	cout << s << endl;

}


 

Measured memory_bytes: 256