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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using llu = long long unsigned int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int H,W,ch,cw,dh,dw;
    Scd2(H,W);
    Scd2(ch,cw);
    Scd2(dh,dw);
    ch--,cw--,dh--,dw--;

    static char s[1020][1020];

    Rep(i,H) Scs(s[i]);

    vector<vi> di(H,vi(W,INF));
    deque<pii> q;
    q.push_back({ch,cw});
    di[ch][cw] = 0;

    while( q.size() ){
        int h = q.front().first;
        int w = q.front().second;
        q.pop_front();
        int d = di[h][w];

        Repe(y,3,-2) Repe(x,3,-2){
            int hh = h+y, ww = w+x;
            if( hh >= H || hh < 0 ) continue;
            if( ww >= W || ww < 0 ) continue;
            if( s[hh][ww] == '#' ) continue;
            if( abs(y)+abs(x) == 1 ) {
                if( d < di[hh][ww] ){
                    di[hh][ww] = d;
                    q.push_front({hh,ww});
                }
            }else{
                if( d+1 < di[hh][ww] ){
                    di[hh][ww] = d+1;
                    q.push_back({hh,ww});
                }
            }
        }

    }

    printf ("%d\n", di[dh][dw]==INF?-1:di[dh][dw] );

    return 0;
}




Measured memory_bytes: 8756
#include <iostream>
#include <algorithm>
#include <array>
#include <math.h>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define INT_MAX 2000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(i = (a); i < (b); i++)
#define bitget(a,b) (((a) >> (b)) & 1)

using namespace std;

int i, j, k;

int main() {
	ll int k;
	cin >> k;
	ll int a[50];
	rep(i, 0, 50) {
		a[i] = k / 50 + 50;
	}
	int b;
	b = 50 - k % 50;
	rep(i, 0, k % 50) {
		a[i] += b;
	}
	rep(i, k%50, 50) {
		a[i] = a[i] - 50 + b - 1;;
	}
	cout << "50" << endl;
	rep(i, 0, 50) {
		cout << a[i];
		if (i != 49)
			cout << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
type Scanner() = class
    let mutable hold = [||]
    let mutable index = 0
    member public this.Next() =
        if hold.Length > index
        then 
            index <- index + 1
            hold.[index - 1]
        else
            let mutable st = stdin.ReadLine()
            while st = "" do st <- stdin.ReadLine()
            hold <- st.Split(' ')
            if hold.Length = 0
            then
                this.Next()
            else
                index <- 1
                hold.[index - 1]
            
    member public this.NextI32() =
        this.Next() |> int

    member public this.ArrayI32(n: int) =
        [for _ in 0 .. n - 1 -> this.NextI32()]

    member public this.NextI64() =
        this.Next() |> int64
    
    member public this.ArrayI64(n: int) =
        [for _ in 0 .. n - 1 -> this.NextI64()]

    member public this.NextF32() =
        this.Next() |> float32
    
    member public this.ArrayF32(n: int) =
        [for _ in 0 .. n - 1 -> this.NextF32()]

    member public this.NextF64() =
        this.Next() |> double
    
    member public this.ArrayF64(n: int) =
        [for _ in 0 .. n - 1 -> this.NextF64()]
end

[<EntryPoint>]
let main _ =
    // answer = int -> int -> int
    let rec answer ind en eqnum count = 
        match ind with
        | a when a > en -> count
        | x -> List.fold(fun acc p -> acc + if (fun a b -> a >= 0 && a <= b) (eqnum - (p + x)) en then 1 else 0) 0 [0..en] + count
            |> answer (ind + 1) en eqnum 
    let sc = Scanner()
    let k = sc.NextI32()
    let s = sc.NextI32()
    answer 0 k s 0 |> printfn "%i"
    0


Measured memory_bytes: 24932
#include <iostream>
#include <vector>
#include <sstream>

using namespace std;

void print(vector<int>& arr) {
	int n = arr.size();
	for (int i = 0; i < n; ++i) {
		cout << arr[i];
		if (i != n - 1) cout << " ";
	}
	cout << endl;
}

void insert_sort(vector<int> &arr) {
	int n = arr.size();
	for (int i = 0; i < n; ++i) {
		for (int j = i; j > 0; --j) {
			if (arr[j - 1] > arr[j])
				swap(arr[j - 1], arr[j]);
		}
		print(arr);
	}
}

void bubble_sort(vector<int>& arr) {
	int n = arr.size();
	int cnt = 0;
	for (int i = 0; i < arr.size(); ++i) {
		for (int j = n - 1; j > i; --j) {
			if (arr[j] < arr[j - 1]) {
				swap(arr[j - 1], arr[j]);
				cnt++;
			}
		}
	}
	print(arr);
	cout << cnt << endl;
}


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

	vector<int> arr(n, 0);
	for (int i = 0; i < n; ++i)
		cin >> arr[i];
	bubble_sort(arr);

	return 0;
}



Measured memory_bytes: 3104
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)

int d[10][10];
int main(){
	rep(i,10)rep(j,10)d[i][j] = INF;
	int v,e;
	cin>>v>>e;
	rep(i,e){
		int a,b;
		cin>>a>>b;
		a--,b--;
		d[a][b] = d[b][a] = 1;
	}
	
	vector<int> w(v);
	rep(i,v)w[i] = i;
	sort(all(w));
	int c=0;
	do{
		bool f = true;
		if(w[0]!=0)continue;
		rep(i,v-1){
			if(d[w[i]][w[i+1]]!=1)f=false;
		}
		if(f)c++;
	}while(next_permutation(all(w)));
	cout<<c<<endl;
}

Measured memory_bytes: 256
while(n=gets.to_i)>0
a=[b=[x=0,0]]
p=a*n
n.times{|i|w=0;m=gets
n.times{|j|h,w=p[j][0]+1,w+1;m[j]==?*&&h=w=0
a[j]=[h,s=[h,w,p[j-1][1]+1].min]
x<s&&x=s}
p,a=a,[b]}
p x
end

Measured memory_bytes: 6116
#include <bits/stdc++.h>
#define fr(i,n) for (int i=0;i<n;i++)
#define ll long long int
using namespace std;
stack<ll> st;
vector< vector<ll> >adj;
vector <ll> dp;
vector <int> visited;
ll ans = 0LL;
void dfs(ll s)
{
    dp[s]=1;
    fr(i,adj[s].size())
    {
        if(!visited[adj[s][i]])
        {
            visited[adj[s][i]]=1;
            dfs(adj[s][i]);
        }
    }
    fr(i,adj[s].size())
    {
        dp[s]=max(dp[s],dp[adj[s][i]] + 1);
    }
}
int main()
{
    ll n,m;cin>>n>>m;
    adj.resize(n);
    visited.resize(n);
    dp.resize(n);
    fr(i,n)visited[i]=0;
    fr(i,m)
    {   
        ll u,v;cin>>u>>v;
        adj[u-1].push_back(v-1);
    }
    fr(i,n)
    {
        if(!visited[i])
        {
            visited[i]=1;
            dfs(i);
        }
    }
    fr(i,n)ans = max(ans,dp[i]);
    cout<<ans-1<<endl;
}

Measured memory_bytes: 8192
#include <iostream>
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define F first
#define S second
#define ll long long
const int MOD = 1e9 + 7;
const float epsilon = 0.0005f;
const float PI = 3.1415926535897932384626433f;
 
vector<pair<int,int>> dire{{0,1},{0,-1},{1,0},{-1,0}};
 
// std::cout << std::fixed;
// std::cout << std::setprecision(9);

void solve(){
    int d, t, s;
    cin >> d >> t >> s;
    double ttake = (double)d / (double)s;
    if(ttake>t){
        cout << "No\n";
        return;
    }
    cout << "Yes\n";
}
    
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    // int t;cin>>t;
    // for(int i = 0;i<t;++i){
    //     solve();
    // }
    solve();
    return(0);
}

Measured memory_bytes: 3580
import std.algorithm,
       std.string,
       std.range,
       std.stdio,
       std.conv;

void main() {
  long[] nab = readln.chomp.split.to!(long[]);
  long N = nab[0],
       A = nab[1],
       B = nab[2];
  long[] hs = N.iota.map!(_ => readln.chomp.to!long).array;
  long b, e = 10^^9;

  while (e - b > 1) {
    long t = (b + e) / 2;

    long sum;

    foreach (hi; hs) {
      if (hi - (t * B) > 0) {
        sum += (hi - (t * B) + (A - B - 1))/(A-B);
      }

      if (sum > t) {
        break;
      }
    }

    if (sum > t) {
      b = t;
    } else {
      e = t;
    }
  }

  writeln(e);
}


Measured memory_bytes: 4092
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007

int main() {
    ll n, m, v, p;
    cin >> n >> m >> v >> p;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(all(a), greater<ll>());
    int l = p - 1, r = n;
    while(l + 1 < r) {
        int i = (l + r) / 2;
        if(a[i] + m < a[p - 1]) {
            r = i;
            continue;
        }
        ll res = max(0LL, v - (n - i) - (p - 1));
        ll sum = 0;
        for(int j = p - 1; j < i; j++) {
            sum += (a[i] + m) - a[j];
        }
        if(sum >= res * m) {
            l = i;
        } else {
            r = i;
        }
    }
    cout << l + 1 << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<tuple>
#include<cmath>


#define MOD 1000000007
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back

typedef long long ll;

using namespace std;

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

struct UnionFind{
    vector<ll> par;
    vector<ll> rank;

    UnionFind(ll N): par(N,-1), rank(N, 1){
    }

    ll root(ll x){
        if(par[x] < 0) return x;
        else return root(par[x]);
    }

    void unite(ll x, ll y){
        x = root(x);
        y = root(y);
        if(x == y) return;
        if(rank[x] < rank[y]) swap(x,y);
        if(rank[x] == rank[y])rank[x]++;
        par[x] += par[y];
        par[y] = x;
        return;
    }

    bool is_same(ll x, ll y){
        return root(x) == root(y);
    }

    ll size(ll x){
        return -1 * par[root(x)];
    }
};


int main(){
    ll N,M,K;
    cin>>N>>M>>K;
    UnionFind tree(N);

    vector<vector<ll>> block(N),fri(N);
    rep(i,0,M){
        ll a,b;
        cin>>a>>b;
        tree.unite(a-1,b-1);
        fri[a-1].PB(b-1);
        fri[b-1].PB(a-1);
    }
    rep(i,0,K){
        ll a,b;
        cin>>a>>b;
        block[a-1].PB(b-1);
        block[b-1].PB(a-1);
    }
    rep(i,0,N){
        ll sum=tree.size(i)-1;
        rep(j,0,block[i].size()){
            if(tree.is_same(i,block[i][j])){
                sum--;
            }
        }
        rep(j,0,fri[i].size()){
            if(tree.is_same(i,fri[i][j])){
                sum--;
            }
        }
        cout<<sum<<" ";
    }
    return 0;
}

Measured memory_bytes: 14452
import heapq

I = input().split()
N = int(I[0])
M = int(I[1])
# N: 品物の数
# M: 割引券の数
# A: 品物の値段行列
A = list(map(int , input().split()))

A = list(map(lambda x: x*(-1), A))

heapq.heapify(A)
for i in range(M):
    M -= 1
    pri = heapq.heappop(A)

    pri *= -1
    pri //= 2
    pri *= -1

    heapq.heappush( A , pri )

Fi_pri = 0
for i in range(N):
    Fi_pri += A[i]

print( -1 * Fi_pri )

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



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

    int n, m;
    cin >> n >> m;

    map<pair<int, int>, bool> mp;
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        mp[make_pair(a, b)] = true;
    }

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

    int ans = 0;
    do{
        int now = A[0];
        if(now != 0) continue;
        bool f = false;
        for(int i = 1; i < n; i++){
            int to = A[i];
            int mi = min(now, to);
            int ma = max(now, to);
            if(mp[make_pair(mi, ma)]);
            else{
                f = true;
                break;
            }
            now = to;
        }
        if(!f) ans++;
    } while (next_permutation(A.begin(), A.end()));
    
    cout << ans << endl;

    return 0;
}

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

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

  return 0;
}


Measured memory_bytes: 256
/**
*   @Author : MeGA
*   @InitTime :01/24/20 12:32:13
*   @Idea : 
*
*
*
*
*
*
*
**/
#include <bits/stdc++.h>
using namespace std;
int main(){
#ifndef ONLINE_JUDGE
  // freopen("in","r",stdin);
  // freopen("out","w",stdout);
#endif
       int n,k,q;
       scanf("%d %d %d",&n,&k,&q);
       vector<int>v(n+1);
       long long maxx=0;
       for(int i=0;i<q;i++){
           int a;
           scanf("%d",&a);
           v[a]++;
       }
       for(int i=1;i<=n;i++){
            if(1ll*k-q+v[i] <= 0){
                printf("No\n");
            }else{
               printf("Yes\n");
            }
            
       }



}

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

int main() {
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll res = a*c;
  res = max(res,a*d);
  res = max(res,b*c);
  res = max(res,b*d);
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3664
#include<iostream>
int R,C,s[10000][10],f[10],N,i,j,n,m;void rec(int k){if(k<R){f[k]=0;rec(k+1);f[k]=1;rec(k+1);}else for(n=i=0;i<C;i++,n+=m>R-m?m:R-m,N=N>n?N:n)for(m=j=0;j<R;j++)m+=s[i][j]^f[j];}main(){for(;std::cin>>R>>C,R|C;rec(0),printf("%d\n",N))for(j=R;j-->0;)for(i=C;i-->0;)scanf("%d",s[i]+j);scanf("%d",s[i]+j);}

Measured memory_bytes: 1308
#include <math.h>
#include <ctype.h>
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)

int main(){
    int n;
    cin >> n;
    cout << n / 3 << endl;


    return 0;
}

Measured memory_bytes: 256
/*
*/

//#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>т мом
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd

#define eps 1e-8
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 400031;

string st;
int k;

int dp[331][331][331];

int get(int lev, int i,int j){
	if (i>j)
		return 0;
	return dp[lev][i][j];
}

int main(){
//	freopen("apache.in","r",stdin);
//	freopen("apache.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
//	cin.tie(0);

	cin>>st>>k;

	for (int i=0;i<=k;i++){
		for (int j=0;j<=st.size();j++){
			for (int q=0;q<=st.size();q++)
			{
					dp[i][j][q]=1e9;
			}
		}
	}

	for (int i=0;i<st.size();i++){
		dp[0][i][i]=0;

	}
	for (int lev=0;lev<=k;lev++){
		for (int j=0;j<st.size();j++){
			for (int i=j-1;i>=0;--i){
				if (st[i]==st[j]){ // match
					int here=get(lev,i+1,j-1);
					dp[lev][i][j]=min(dp[lev][i][j],here);
				}
				// remove left
				int here=get(lev,i+1,j);
				dp[lev][i][j]=min(dp[lev][i][j],here+1);
				// remove right
				here=get(lev,i,j-1);
				dp[lev][i][j]=min(dp[lev][i][j],here+1);
				// change some
				if (lev>0)
				{
					int here=get(lev-1,i+1,j-1);
					dp[lev][i][j]=min(dp[lev][i][j],here);
				}
			}
		}
	}

	int res=1e9;
	for (int i=0;i<=k;i++){
		res=min(res,dp[i][0][st.size()-1]);
	}
	cout<<st.size()-res<<endl;

//	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 129152
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,a,b,c;
  cin >> N;
  a = N/100;
  b = N%100/10;
  c = N%10;
  if(a==7||b==7||c==7){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define LOCAL
using std::to_string;
auto to_string(std::string s) -> std::string {
  return '"' + s + '"';
}
auto to_string(char c) -> std::string {
  return "'" + std::string{c} + "'";
}
auto to_string(const char* s) -> std::string {
  return to_string((std::string) s);
}
auto to_string(bool b) -> std::string {
  return (b ? "true" : "false");
}
template <typename T, typename U>
auto to_string(std::pair<T, U> p) -> std::string {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <size_t N>
auto to_string(std::bitset<N> bs) -> std::string {
  std::string res{};
  for (size_t i = 0; i < N; i++)
    res.insert(res.begin(), bs.test(i) ? '1' : '0');
  return res;
}
template <typename T>
auto to_string(T v) -> std::string {
  bool flg = false;
  std::string res = "{";
  for (auto const&x : v) {
    if (flg) res += ", ";
    else flg = true;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  std::cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  std::string s; std::cin >> s;
  long long now = 0, ret = 0;
  for (auto c : std::string(s.rbegin(), s.rend())) {
    switch(c) {
      case 'A' : {
        if (now % 2 == 0) ret += now / 2;
        else now = 0;
        break;
      }
      case 'B' : {
        if (now % 2 == 1) now++;
        else now = 0;
        break;
      }
      case 'C' : {
        if (now % 2 == 0) now++;
        else now = 1;
        break;
      }
    }
    debug(c, now);
  }
  std::cout << ret << std::endl;
  return 0;
}

Measured memory_bytes: 788
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
 
using namespace std;
 
 int main(void){
     int N,M;
     cin >> N >> M;
     char A[N+10][N+10],B[M+10][M+10];
     for(int i=0; i<N; i++){
         for(int j=0; j<N; j++){
             cin >> A[i][j];
         }
     }for(int i=0; i<M; i++){
         for(int j=0; j<M; j++){
             cin >> B[i][j];
         }
     }
     bool ex=false;
     for(int i=0; i<N; i++){
         for(int j=0; j<N; j++){
             if(i+M-1>=N || j+M-1>=N) continue;

             bool ma=true;
             for(int y=0; y<M; y++){
                 for(int x=0; x<M; x++){
                     if(A[i+y][j+x]!=B[x][y]){
                         ma = false;
                     }
                 }
             }
             if(ma) ex=true;
         }
     }
    if(ex) cout << "Yes" << endl;
    else cout << "No" << endl;
 }

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;


// a^n mod を計算する
long int modpow(long int a, long int n) {
    long int res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = (a * a) % mod;
        n >>= 1;
    }
    return res;
}

int main(){
    ll n, k;
    cin >> n >> k;
    ll num1, num2;
    num1 = n - k + 1;
    num2 = 1;
    ll ans = num1 * num2;
    cout << ans << endl;
    for (int i = 2; i <= k; i++){
        num1 *= (n - k + 1 - i + 1);
        num1 %= mod;
        num1 *= modpow(i, mod - 2);
        num1 %= mod;
        num2 *= (k - 1 - i + 2);
        num2 %= mod;
        num2 *= modpow(i - 1, mod - 2);
        num2 %= mod;
        ans = (num1 * num2) % mod;
        // cout << num1 << " " << num2 << endl;
        cout << ans << endl;
    }
}

Measured memory_bytes: 3596
#include<stdio.h>
int main(){
  int n;
  scanf("%d", &n);
  
  int max = 0, cnt = 0;
  int cell_now, cell_next;
  scanf("%d", &cell_now);
  
  int i;
  
  for(i=1; i<n; i++){
    scanf("%d", &cell_next);
    if(cell_next <= cell_now){
      cnt++;
    }else{
      if(cnt > max){
        max = cnt;
      }
      cnt = 0;
    }
    cell_now = cell_next;
  }
  
  if(cnt > max){
    max = cnt;
  }
  
  printf("%d", max);
}


Measured memory_bytes: 128
n, q = map(int, input().split())
s = input()
t = [0] * (n+1)

for i in range(n):
    t[i+1] = t[i] + (1 if s[i:i+2] == 'AC' else 0)

for i in range(q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])

Measured memory_bytes: 7748
#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()
static const int INF (1<<30);

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i, N) cin >> a[i];

  int ans = 0;
  rep(i, N) {
    for (int j = i + 1; j < N; j++) {
      ans = max(ans, abs(a[i] - a[j]));
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), count = 0;
        int[] a = new int[n];
        for(int i=0; i<n; i++){ a[i] = sc.nextInt(); }
        
        while(true){
            
            if(isOdd(a)){
                break;
            }
            
            
            for(int i=0;i<a.length;i++){
                a[i] /= 2;
            }
            count++;
            
        }
        System.out.println(count);
    }
    
    public static boolean isOdd(int[] a){
        boolean isOddFlag = false;
        for(int i=0;i<a.length; i++){
            if(a[i] % 2 != 0){
                isOddFlag = true;
            }
        }
        return isOddFlag;
    }
}


Measured memory_bytes: 25172
s = input()
t = ''
result = 'YES'

scripts = ['dream', 'dreamer', 'erase', 'eraser']

while len(s) > len(t) and result == 'YES':
    restmp = False
    for script in scripts:
        tmp = t + script
        if tmp == s[:len(tmp)]:
            if tmp == s:
                t = tmp
                restmp = True
                break
            for script2 in scripts:
                tmp2 = tmp + script2
                if tmp2 == s[:len(tmp2)]:
                    t = tmp
                    restmp = True
                    break
            else:
                continue
            break

    if restmp is False:
        result = 'NO'

print(result)

Measured memory_bytes: 3832
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<cmath>
#include<iomanip>

using namespace std;

const double pi = 3.141592653589793238;

int main() {
	int N;
	cin >> N;
	vector<vector<double>> x(N, vector<double>(2));
	for (int i = 0; i < N; i++) cin >> x[i][0] >> x[i][1];
	vector<vector<vector<double>>> normal(N, vector<vector<double>>(0, vector<double>(2)));
	for (int i = 0; i < N - 1; i++) {
		for (int j = i + 1; j < N; j++) {
			vector<double> dx(2);
			dx[0] = x[i][0] - x[j][0];
			dx[1] = x[i][1] - x[j][1];
			normal[j].push_back(dx);
			dx[0] *= -1;
			dx[1] *= -1;
			normal[i].push_back(dx);
		}
	}
	vector<vector<double>> dead_r(N, vector<double>(2, 0.0));
	vector<vector<double>> dead_l(N, vector<double>(2, pi));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < normal[i].size(); j++) {
			double theta;
			theta = atan2(normal[i][j][0], normal[i][j][1]);
			if (fabs(theta) > pi / 2.0) {
				theta = fmod(theta + 2.0 * pi, 2.0 * pi);
				dead_l[i][0] = min(dead_l[i][0], theta - pi / 2.0);
				dead_l[i][1] = max(dead_l[i][1], theta + pi / 2.0);
			}
			else {
				dead_r[i][0] = min(dead_r[i][0], theta - pi / 2.0);
				dead_r[i][1] = max(dead_r[i][1], theta + pi / 2.0);
			}
		}
		if (dead_r[i][1] >= dead_l[i][0]) {
			dead_r[i][1] = pi / 2.0;
			dead_l[i][0] = pi / 2.0;
		}
		if (dead_l[i][1] >= dead_r[i][0] + 2.0 * pi) {
			dead_l[i][1] = 3.0 * pi / 2.0;
			dead_r[i][0] = -pi / 2.0;
		}
		cout << setprecision(15) << (2.0 * pi - (dead_r[i][1] - dead_r[i][0] + dead_l[i][1] - dead_l[i][0])) / (2.0 * pi) << endl;
	}

	system("pause");
	return 0;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using pii = pair<int, int>; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>;
#define rep(CNT, GOAL) for (int CNT = 0; CNT < (int)(GOAL); CNT++)
#define rep2(CNT, START, GOAL) for (int CNT = (int)(START); CNT < (int)(GOAL); CNT++)
#define rep3(CNT, START, GOAL) for (int CNT = (int)(START); CNT > (int)(GOAL); CNT--)
#define all(CONT) begin(CONT), end(CONT)

#include <atcoder/all>
using namespace atcoder;

template <typename T> void CERR(const T &ELEM) { cerr << ELEM; }
#define dbl(OBJ) cerr << #OBJ << ": "; CERR(OBJ); cerr << "\n"

template <typename T, typename ...Ts> void CERR(const T &FIRST, const Ts &...REST) { CERR(FIRST); cerr << ", "; CERR(REST...); }
#define dbs(...) cerr << "(" << #__VA_ARGS__ << "): ("; CERR(__VA_ARGS__); cerr << ")\n"

// i:0~N-1を0~N-1,j:0~N-1をN~2*N-1,sを2*N,tを2*N+1と表す。
// s->(i)->(j)->t というフローネットワークを考える。
// capは，s->(i)がK,(i)->(j)が1，(j)->tがK
// costは，s->(i)が0,(i)->(j)がINF-Aij,(j)->tが0
// ※Aijの総和を最大にするために(i)->(j)のcostを-Aijとし，この総和を最小にしたいが，制約0<=costに反する。
// そこで，-Aijに代えてINF-Aij>=0を用いる。
// s->tという特別な有向辺を考え，capを最大流量K*N,costをINF(=INF-0)とする。

int main() {
	const ll INF = 1'000'000'000; // 1'000'000'007;
	int N, K; cin >> N >> K;
	mcf_graph<int, ll> g(2 * N + 2);
	rep(v, N) g.add_edge(2 * N, v, K, 0);
	rep2(v, N, 2 * N) g.add_edge(v, 2 * N + 1, K, 0);
	rep(i, N) rep(j, N) {
		ll A; cin >> A;
		g.add_edge(i, N + j, 1, INF - A);
	}
	g.add_edge(2 * N, 2 * N + 1, K * N, INF);

	/*
	for (mcf_graph<int, ll>::edge e : g.edges()) {
		dbs(e.from, e.to, e.cap, e.flow, e.cost);
	}
	*/
	
	pair<int, ll> p = g.flow(2 * N, 2 * N + 1, K * N);
	// dbs(p.first, p.second);

	cout << K * N * INF - p.second << endl;

	vector<vector<bool>> S(N, vector<bool>(N));

	for (mcf_graph<int, ll>::edge e : g.edges()) {
		// dbs(e.from, e.to, e.cap, e.flow, e.cost);
		if (e.from == 2 * N or e.to == 2 * N + 1) continue;
		if (e.flow == 0) continue;
		S[e.from][e.to - N] = true;
	}
	rep(i, N) {
		rep(j, N) {
			cout << (S[i][j] ? 'X' : '.');
		}
		cout << endl;
	}
}

Measured memory_bytes: 3884
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    ll N, K, S;
    cin >> N >> K >> S;
    VLL A(N);
    rep(i,K){
        A[i]=S;
    }
    rept(i,K,N){
        if(S==1000000000){
            A[i]=S-1;
        }
        else{
            A[i]=S+1;
        }
    }
    rep(i,N){
        cout << A[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 2176
# coding: utf-8

m, d = map(int,input().split())

ans = 0
for i in range(1,m+1):#月
    for j in range(1,d+1):#日
        if len(str(j)) == 2:
            d1 = int(str(j)[0])
            d10 = int(str(j)[1])
            if i >= 2 and d1 >= 2 and d10 >= 2 and int(str(j)[0]) * int(str(j)[1]) == i:
                ans += 1

print(ans)

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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s[i];
  map<string, int> cnt;
  rep(i, n) { cnt[s[i]]++; }
  printf("AC x %d\n", cnt["AC"]);
  printf("WA x %d\n", cnt["WA"]);
  printf("TLE x %d\n", cnt["TLE"]);
  printf("RE x %d\n", cnt["RE"]);
  return 0;
}

Measured memory_bytes: 6376
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define SIZE_OF_ARRAY(a) (sizeof(a)/sizeof(a[0]))

unsigned GetDigit(unsigned num){
    return std::to_string(num).length();
}



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int ans = 0;
    string ans2;
    int A,B,C;
    cin >> A >> B >> C;
    int K;
    cin >> K;
    cout << A+B+C-max({A, B, C})+(max({A, B, C}) << K) << endl;
}

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

int main()
{
  int h,w;
  cin >> h >> w;
  
  string s[h+2][w+2];
  rep(i,h+2){
    rep(j,w+2){
      if(i == 0 || i == h+1){
        s[i][j] = '#';
      }else if(j == 0 || j == w+1){
        s[i][j] = '#';
      }else{
        cin >> s[i][j];
        j += w-1;
      }
    }
  }
    
  rep(i,h+2){
    rep(j,w+2){
      cout << s[i][j];
    }
    cout << endl;
  }
    
}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n;
    long long m;
    cin >> n >> m;
    vector<int> a(n);
    int MX = 2e5 + 9;
    vector<int> aCnt(MX);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        aCnt[a[i]]++;
    }
    sort(a.begin(), a.end());
    vector<long long> pref(n+1);
    for (int i = 0; i < n; i++) {
        pref[i+1] = pref[i] + a[i];
    }
    auto getSum = [&] (int l, int r) {
        return pref[r+1] - pref[l];
    };
    auto calc = [&](int mn) -> pair<bool, long long> {
        auto tot = 0ll;
        auto cnt = 0ll;
        auto exact = 0ll;
        for (int i = 0; i < n; i++) {
            int needExact = mn - a[i];
            if (needExact >= 0) {
                exact += aCnt[needExact];
            }
            auto target = mn - a[i];
            auto it = upper_bound(a.begin(), a.end(), target);
            if (it != a.end()) {
                int j = it - a.begin();
                long long c = n-j;
                tot += c*a[i] + getSum(j, n-1);
                cnt += c;
            }
        }
        if (cnt > m) {
            return {false, tot};
        }
        auto take = min(exact, m-cnt);
        tot += take*mn;
        return {true, tot};
    };
    int l = 0, r = MX - 1;
    auto ans = 0ll;
    while (l < r) {
        auto mid = (l+r)/2;
        auto pr = calc(mid);
        if (pr.first) {
            r = mid;
            ans = pr.second;
        } else {
            l = mid+1;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 5288
import numpy as np 
A=[]
A.extend(list(map(int,input().split())))
A.extend(list(map(int,input().split())))
A.extend(list(map(int,input().split())))
N = int(input())
check = [False]*9
for i in range(N):
    b=int(input())
    if(b in A):
        check[A.index(b)]=True
posi_list=[[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]]
np_check=np.array(check)
for i in range(len(posi_list)):
    if (False not in np_check[posi_list[i]]):
        print('Yes')
        exit()
print('No')


Measured memory_bytes: 27156
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

template<class T> inline bool chmin(T &a, T b) {
    if (a > b) a = b; return true;
    return false;
}

void solve(long long N, long long T, std::vector<long long> c, std::vector<long long> t){
    long long ans = 1001;
    REP(i, N) {
        long long tmp;
        if (T >= t[i]) tmp = c[i];
        chmin(ans, tmp);
    }
    if (ans == 1001) cout << "TLE" << '\n';
    else cout << ans << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    long long T;
    scanf("%lld",&T);
    std::vector<long long> c(N);
    std::vector<long long> t(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&c[i]);
        scanf("%lld",&t[i]);
    }
    solve(N, T, std::move(c), std::move(t));
    return 0;
}


Measured memory_bytes: 256
n, p = map(int, input().split())
x = p
so = []
for i in range(2, int(p**(1/2))+1):
    c = 0
    while x%i==0:
        c += 1
        x //= i
    if c:
        so.append([c, i])
if x:
    so.append([1, x])
result = 1
for s, t in so:
    result *= t**(s//n)
print(result)

Measured memory_bytes: 40044
#include<iostream>
#include<vector>

using namespace std;

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


Measured memory_bytes: 2944
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
//#define scanf scanf_s
#define fir first
#define sec second
#define mp make_pair
#define mt make_tuple
#define pub push_back
using namespace std;
typedef long long int llint;
const llint one = 1;
const llint big = (one<<30);
const llint mod=1000000007;
int main(void){
	llint N,K,i,j,a,b,ans=big*15,gen,jam;
	vector<llint> taka;
	scanf("%lld %lld ",&N,&K);
	for(i=0;i<N;i++){
		scanf("%lld",&a);
		taka.pub(a);
	}
	for(i=0;i<(1<<N);i++){
		gen=0;jam=0;
		for(j=0;j<N;j++){
			if((i&(1<<j))!=0){gen++;}
		}
		if(gen!=K){continue;}
		gen=0;
		for(j=0;j<N;j++){
			if((i&(1<<j))==0){jam=max(jam,taka[j]);continue;}
			jam=max(jam+1,taka[j]);
			gen+=jam-taka[j];
		}
		ans=min(ans,gen);
	}
	printf("%lld\n",ans);
	return 0;

}


Measured memory_bytes: 256
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];


int main()
{
    ll n,i,j,cc=0,mn=100000000000LL;
    cin>>n;
    ll ara[n];
    for(i=0;i<n;i++)cin>>ara[i];
    sort(ara,ara+n);
    for(i=ara[0];i<=ara[n-1];i++){
        cc=0;
        for(j=0;j<n;j++){
            ll x=abs(i-ara[j]);
            cc+=x*x;
        }
        mn=min(cc,mn);
    }
    cout<<mn<<endl;
return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char const *argv[])
{
    string S;
    cin >> S;
    int ans = 0;
    for (string::iterator itr = S.begin() + 1; itr != S.end(); itr++)
    {
        if (*itr != *(itr - 1)) ans++;
    }

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

Measured memory_bytes: 512
#include <stdio.h>

#define SIZE_MAX 101

struct dice {
int central;
int under;
int right;
int left;
int on;
int rear;
} dice_1;

char str[SIZE_MAX];

int i, j,work;

int main(void) {
    fscanf(stdin, "%d %d %d %d %d %d", &dice_1.central,
                                       &dice_1.under,
                                       &dice_1.right,
                                       &dice_1.left,
                                       &dice_1.on,
                                       &dice_1.rear);

    fscanf(stdin, "%100s", str);

    for (i = 0; str[i]; i++) {
        if (str[i] == 'W') {
            work = dice_1.rear;
            dice_1.rear = dice_1.left;
            dice_1.left = dice_1.central;
            dice_1.central = dice_1.right;
            dice_1.right = work;
        } else if (str[i] == 'E') {
            work = dice_1.rear;
            dice_1.rear = dice_1.right;
            dice_1.right = dice_1.central;
            dice_1.central = dice_1.left;
            dice_1.left = work;
        } else if (str[i] == 'N') {
            work = dice_1.rear;
            dice_1.rear = dice_1.on;
            dice_1.on = dice_1.central;
            dice_1.central = dice_1.under;
            dice_1.under = work;
        } else {
            work = dice_1.rear;
            dice_1.rear = dice_1.under;
            dice_1.under = dice_1.central;
            dice_1.central = dice_1.on;
            dice_1.on = work;
        }
    }
        
    fprintf(stdout, "%d\n", dice_1.central);
    
    return 0;
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int a, b, c;
  while (cin >> a >> b >> c) {
    map<int, int> cnt;
    ++cnt[a];
    ++cnt[b];
    ++cnt[c];
    each (i, cnt) if (i.second == 1) cout << i.first << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
	int H, W;
	int h, w;
	cin >> H >> W >> h >> w;
	H -= h;
	W -= w;
	cout << H * W << endl;


	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    string S;
    cin >> S;
    int64_t sum=0;
    for(int i=0; i<S.size(); i++)
    {
        sum=sum+int(S.at(i)-48);
    }
    if(sum%9==0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 3744
#pragma comment(linker, "/STACK:10240000")
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

int main ()
{
    int n;
    scanf ("%d", &n);
    int a = n % 10;
    int b = n / 10;
    if ((a == 9) || (b == 9))
    {
        printf ("Yes\n");
    }
    else
    {
        printf ("No\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,m,s,g1,g2;
  while(cin>>n>>m>>s>>g1>>g2,n||m||s||g1||g2){
    int i,j,k;
    int b1,b2,c;
    int d[105][105];
    int inf = 1<<20;
    for(i=1;i<=n;i++){
      for(j=1;j<=n;j++){
    if(i==j) d[i][j]=0;
    else d[i][j]=inf;
      }
    }
    for(i=0;i<m;i++) {
      cin >> b1 >> b2 >> c;
      d[b1][b2]=c;
    }
    for(k=1;k<=n;k++){
      for(i=1;i<=n;i++){
    if(d[i][k]==inf) continue;
    for(j=1;j<=n;j++){
      if(d[k][j]==inf) continue;
      d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    } 
      } 
    }
    int o=inf;
    for(i=1;i<=n;i++){
      o=min(o,d[s][i]+d[i][g1]+d[i][g2]);
    }
    cout << o << endl;
  }
 
}

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

#define mp              make_pair
#define pb              push_back

#define ff              first
#define ss              second

typedef long long ll;

int main()
{
    int a, b;
    cin >> a >> b;
    
    cout << max(0, a-(2*b)) << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	string s;
	cin>>n>>s;
	ll a=0,b=0,c=0,ans=0;
	rep(i,n){
		if(s[i]=='R')a++;
		if(s[i]=='G')b++;
		if(s[i]=='B')c++;
	}
	ans=a*b*c;
	rep(i,n){
		range(j,1,n){
			if(i-j<0||i+j>=n)break;
			if(s[i-j]!=s[i]&&s[i]!=s[i+j]&&s[i+j]!=s[i-j])ans--;
		}
	}
	puta(ans);
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i = x; i < n; i++)
#define MAX 100
#define INF 1000000001

int n;
vector<int> adj[114514];
int d[2][114514];

// char X[100][100];
// int dp[1000000001];

void dfs(int peek, int current, int depth, int w) {
    // int i;
    
    d[w][peek] = depth;
    
    REP(i,0,adj[peek].size()) {
        if (adj[peek][i] == current) continue;
        
        dfs(adj[peek][i],peek,depth+1,w);
    }
}

bool processed[2][114514];

void bfs(int s,int w) {
    queue<int> q;
    q.push(s);
    // int dist = 0;
    d[w][s] = 0;
    
    processed[w][s] = true;
    
    while(!q.empty()) {
        int a = q.front(); q.pop();
        
        for (auto u: adj[a]) {
            if (processed[w][u]) continue;
            processed[w][u] = true;
            
            d[w][u] = d[w][a] + 1;
            q.push(u);
            // if (d[w][a] + 1 < d[w][u]) {
            //     d[w][u] = d[w][a] + 1;
            //     q.push(u);
            // }
        }
        
        // dist++;
    }
}

int main(void){
    cin >> n;
    REP(i,0,n-1) {
        int a,b;
        cin >> a >> b;
        
        a--; 
        b--;
        
        // cout << a << b << endl;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    
    
    REP(i,0,n-1) {
        d[0][i] = INF;
        d[1][i] = INF;
    }
    
    bfs(0,0);
    bfs(n-1,1);


    int c1 = 0;
    int c2 = 0;
    for (int i = 0; i < n; i++) {
        if (d[0][i] <= d[1][i]) {
            c1++;
        } else {
            c2++;
        }
    }
    
    if (c1 > c2) {
        puts("Fennec");
    } else {
        puts("Snuke");
    }
    
    return 0;

}

Measured memory_bytes: 7168
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using mii = map<int, int>;
using mll = map<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vpi = vector<pii>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpl = vector<pll>;
using vs = vector<string>;

int main()
{
    ll n, m;
    cin >> n >> m;
    vl as;
    as.resize(m);
    for(ll i=0; i<m; i++) cin >> as.at(i);
    ll sun = 0;
    for(auto a : as)
    {
        sun += a;
    }
    if(n >= sun) cout << n - sun << endl;
    else cout << -1 << endl;
    return 0;
}


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

using namespace std;

#define il inline
#define re register
#define Rep(i, s, e) for (re int i = s; i <= e; ++i)
#define Dep(i, s, e) for (re int i = s; i >= e; --i)
#define file(a) freopen(#a".in", "r", stdin), freopen(#a".out", "w", stdout)

il int read() {
    int x = 0; bool f = true; char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = false; c = getchar();}
    while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
    return f ? x : -x;
}

map <string, bool> M;

int n, ans;

int main() {
    n = read();
    while (n--) {
        string s;
        cin >> s;
        if (!M[s]) ++ans, M[s] = true;
    }
    printf("%d", ans);
    return 0;
}

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

bool f(int x)
{
    int fact = 1;
    for (int i = 2; i * i <= x; i++)
    {
        int count = 0;
        while (x % i == 0)
        {
            count++;
            x /= i;
        }
        fact *= count + 1;
    }
    if (x != 1)
    {
        fact *= 2;
    }
    return fact == 8;
}

int main()
{
    int N;
    cin >> N;
    int ans = 0;
    for (int i = 1; i <= N; i += 2)
    {
        if (f(i))
        {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256