akhauriyash/Code-Regression huggingface dataset:
#include<iostream>

using namespace std;

const int MAX = 1000001;
bool data[MAX];
int n,a,b;


void solve(){
  data[a] = data[b] = true;

  for(int i = 1; i < MAX; i++){
    if(i-a>0) data[i] = (data[i] || data[i-a]);
    if(i-b>0) data[i] = (data[i] || data[i-b]);
  }

  int ans = 0;
  for(int i = 1; i <= n; i++)
    if(!data[i]) ans++;

  cout << ans << endl;
}

int main(){
  while(cin >> n >> a >> b && n+a+b){
    fill(data,data+MAX,false);
    solve();
  }
  return 0;
}

Measured memory_bytes: 2136
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    ll n, k;
    cin >> n >> k;
    vl a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 1; i < n; ++i) {
        a[i] += a[i - 1];
    }
    vl b;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            ll sum = a[j];
            if (i)
                sum -= a[i - 1];
            b.push_back(sum);
        }
    }
    ll m = n * (n + 1) / 2;
    vector<bool> use(m, true);
    ll ret = 0;
    for (int i = 50; i >= 0; --i) {
        ll bit  = 1LL << i;
        int cnt = 0;
        for (int j = 0; j < m; ++j) {
            if (use[j] && (bit & b[j]))
                cnt++;
        }
        if (cnt >= k)
            ret += bit;
        else
            continue;
        for (int j = 0; j < m; ++j) {
            if (!(bit & b[j]))
                use[j] = false;
        }
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 6260
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
int in() {int x; cin>>x; return x;}
string stin() {string s; cin>>s; return s;}
/***** MAIN *****/
signed main() {
  int n = in();
  int m = in();
  if(n == 1 && m == 1) {
    cout << 1 << endl;
    return 0;
  }
  if(n == 1 || m == 1) {
    int ans = max(0LL, n*m-2);
    cout << ans << endl;
    return 0;
  }
  int h = max(0LL, n-2);
  int w = max(0LL, m-2);
  cout << h*w << endl;
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder1_A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            string[] name = new string[n];

            for (int i = 0; i < n; i++)
            {
                name[i] = Console.ReadLine();
            }
            long M = 0;
            long A = 0;
            long R = 0;
            long C = 0;
            long H = 0;

            foreach (string item in name)
            {
                switch (item[0])
                {
                    case 'M':
                        M++;
                        break;
                    case 'A':
                        A++;
                        break;
                    case 'R':
                        R++;
                        break;
                    case 'C':
                        C++;
                        break;
                    case 'H':
                        H++;
                        break;
                }
            }
            long ans = (M * A * R) + (M * A * C) + (M * A * H) + (M * R * C) + (M * R * H) + (M * C * H) + (A * R * C) + (A * R * H) + (A * C * H) + (R * C * H);
            Console.WriteLine(ans);
        }
    }
}

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

int main(){
    //input
    long long N,A,B;
    cin >> N >> A >> B;
    //calculate
    long long answer;
    if(A>B)
        answer = 0;
    else if(N==1){
        if(A==B)
            answer = 1;
        else
            answer = 0;
    }
    else
        answer = (B-A)*(N-2)+1;
    //output
    cout << answer << endl;
}

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

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string S, T; cin >> S >> T;

	int n = (int)S.length();
	bool ok = false;
	rep (i, n){
		string U = "";
		U += S[n-1];
		U += S.substr(0,n-1);
		S = U;
		if (S == T){
			ok |= true;
		} // end if
	} // end rep

	cout << (ok ? "Yes" : "No") << endl;

	return 0;
}

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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 10000000000000000;
double PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;
Graph G(100010);

bool table[100010];

void dfs(ll x){
  int n = G[x].size();
  for(int i = 0;i < n;i++){
    if(!table[G[x][i]]){
      table[G[x][i]] = 1;
      dfs(G[x][i]);
    }
  }
  return ;
}

int main(){
 int N,M;cin >> N >> M;
 for(int i = 0;i < M;i++){
   int x,y,z;cin >> x >> y >> z;
   x--;y--;
   G[x].push_back(y);
   G[y].push_back(x);
 }
 ll cnt = 0;
 for(int i = 0;i < N;i++){
   if(!table[i]){
     cnt++;
     dfs(i);
   }
 }
 cout << cnt << endl;
}

Measured memory_bytes: 8960
#include<bits/stdc++.h>
using namespace std;
#define f(x,i,n) for(int i = x;i<=n;i++)
#define test int t;cin >> t;while(t--)


void solve(){
    int k,a,b;
    cin >> k >> a >> b;
    f(a,i,b){
        if(i%k==0){
            cout << "OK\n";
            return;
        }
    }
    cout << "NG\n";
    return;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define big 998244353
#define ff first
#define se second
#define pb push_back
#define pii pair<int,int>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define mp make_pair
#define pi 3.141592653589
int power(int x,int y){
    int r=1,z=x;
    while(y){
        if(y & 1)r*=z;
        z*=z;y=y>>1;}
    return r;}
int powerm(int x,int y,int p){
    int r=1;
    while(y){
        if(y & 1)r=(r*x)%p;
        y=y>>1;
        x=(x*x)%p;}
    return r%p;}
int modinv(int x,int m){
    return powerm(x,m-2,m);}
int logarithm(int a,int b){
    int x=0;
    while(a>1){
        x++;
        a/=b;}
    return x;}
int32_t main(){
    fast;
    int a,b,n;
    cin>>a>>b>>n;
    int x=min(b-1,n);
    int p=a/b;
    int q=a%b;
    cout<<p*x+q*x/b;
    return 0;
}

Measured memory_bytes: 3608
import java.util.*;

public class Main {

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

		while(true){
			int n = sc.nextInt();
			int s = sc.nextInt();
			if(n==0 && s==0) break;
			int[] a = new int[101];
			for(int i=0;i<n;i++) a[sc.nextInt()]++;
			
			int cnt = 0;
			for(int i=1;i<=100;i++){
				for(int j=i;j<=100;j++){
					if(s<i+j){
						if(i==j) cnt += a[i]*(a[i]-1)/2;
						else cnt += a[i]*a[j];
					}
				}
			}
			
			System.out.println(cnt);
		}
	}

}

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

int main(void) {

  char str[1000];
  int i;

  fgets(str,sizeof(str),stdin);

  str[strlen(str)-1]='\0';

  for(i=0;i<strlen(str);i++) {

    if(str[i]>=97 && str[i]<=122) str[i]=str[i]-32;
     
  }

  printf("%s\n",str);

  return 0;

}

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

main() {
  int N, M, K; cin >> N >> M >> K;
  bool ans = false;
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= M; j++) {
      if ((N - i) * j + (M - j) * i == K) ans = true;
    }
  }
  cout << ( (ans) ? "Yes" : "No" ) << endl;
}


Measured memory_bytes: 256
N = int(input())

primes = []
for n in range(2, 55556):
    i = 2
    prime = True
    while i**2 <= n:
        if n % i == 0:
            prime = False
            break
        i += 1
    if prime and n % 5 == 1:
        primes.append(n)

for i in range(N):
    print(primes[i], end=' ')
print()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n, a[100005];
multiset<int> S;
int main()
{
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i)
        scanf("%d", &a[i]);
    for(int i = 1; i <= n; ++i){
        auto it = S.lower_bound(a[i]);
        if(it != S.begin()) S.erase(--it);
        S.insert(a[i]);
    }
    cout << S.size() << '\n';
    return 0;
}

Measured memory_bytes: 8716
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  cin >> n;
  vector<int> a(n),b(n);
  rep(i,n) R a[i];
  rep(i,n) R b[i];
  if(a>b) swap(a,b);
  int ans=0;
  while(a!=b&&next_permutation(all(a))) ans++;
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
//"I'll live the focused life, because it's the best kind there is" - Winifred Gallagher
#include<bits/stdc++.h>
using namespace std;
#define debug(a) cout << #a << ": " << a << endl

int32_t main(){
	//freopen("input.txt","r",stdin);
	int n, m; cin>>n>>m;
	if(n == m) cout<<"Yes"; else cout<<"No";
	return 0;
}



Measured memory_bytes: 256
import bisect

while True:
  N,M = map(int,input().split())
  if N == 0 and M == 0: break
  targets = [0]+[ int(input()) for _ in range(N) ]
  targets.sort()

  cans = [targets[i]+targets[j] for i in range(N+1) for j in range(i,N+1) if targets[i]+targets[j] <= M]
  cans.sort()

  res = 0

  for l in cans:
    y = cans[bisect.bisect_right(cans, M-l)-1]
    res = max(res, l+y)

  print(res)


Measured memory_bytes: 47216
N, K = list(map(int, input().split()))
p = 10**9+7
size = 2*2*10**5

def binom(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2, size + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

res = 0

for i in range(min(K, N)+1):
        res += (binom(N, i, p) * binom(N-1, N-i-1, p)) % p

print(res % p)

Measured memory_bytes: 162884
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MAXN = 1e5 + 7;

ll dp[3][MAXN];

int main()
{
#ifdef LOCAL
    freopen("data.txt", "r", stdin);
#endif
    int n;
    ll a, b, c;
    scanf("%d", &n);
    scanf("%lld%lld%lld", &dp[0][0], &dp[1][0], &dp[2][0]);
    for (int i = 1; i != n; ++i) {
        scanf("%lld%lld%lld", &a, &b, &c);
        dp[0][i] = max(dp[1][i - 1], dp[2][i - 1]) + a;
        dp[1][i] = max(dp[0][i - 1], dp[2][i - 1]) + b;
        dp[2][i] = max(dp[0][i - 1], dp[1][i - 1]) + c;
    }
    printf("%lld\n", max({ dp[0][n - 1], dp[1][n - 1], dp[2][n - 1] }));
}

Measured memory_bytes: 2560
from collections import deque

K = int(input())

queue = deque(range(1, 10))

for _ in range(K):
    x = queue.popleft()
    if x % 10 != 0:
        queue.append(10 * x + x % 10 - 1)
    queue.append(10 * x + x % 10)
    if x % 10 != 9:
        queue.append(10 * x + x % 10 + 1)

print(x)


Measured memory_bytes: 18832
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define PI acos(-1)
int main(){
int a,b;
while(cin>>a>>b,a||b){
rep(i,a){
rep(j,b){
if(i==0||i==a-1||j==0||j==b-1)cout<<"#";
else cout<<".";
}
cout<<endl;
}
cout<<endl;
}
}

Measured memory_bytes: 1152
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cinttypes>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

using ll = long long;

void Dfs(int v, const vector<vector<char>>& G, vector<char>& use) {
  use[v] = true;
  for (int u = 0; u < G[v].size(); ++u) {
    if (G[v][u] && !use[u]) {
      Dfs(u, G, use);
    }
  }
}

bool Check(const vector<vector<char>>& G) {
  vector<char> use(G.size(), false);
  Dfs(0, G, use);

  for (int i = 0; i < G.size(); ++i) {
    if (!use[i]) {
      return false;
    }
  }

  int sum = -1;
  for (int i = 0; i < G.size(); ++i) {
    int cand_sum = 0;
    for (int j = 0; j < G.size(); ++j) {
      if (G[i][j]) {
        cand_sum += (j + 1);
      }
    }

    if (sum == -1) {
      sum = cand_sum;
    } else {
      if (cand_sum != sum) {
        return false;
      }
    }
  }

//  cout << "Answer sum: " << sum << '\n';
//  for (int i = 0; i < G.size(); ++i) {
//    assert(!G[i][i]);
//    for (int j = i + 1; j < G.size(); ++j) {
//      if (G[i][j]) {
//        cout << i + 1 << ", " << j + 1 << '\n';
//      }
//    }
//  }
//  for (int i = 0; i < G.size(); ++i) {
//    for (int j = 0; j < G.size(); ++j) {
//      if (G[i][j]) {
//        cout << "1 ";
//      } else {
//        cout << "0 ";
//      }
//    }
//    cout << '\n';
//  }
  return true;
}

void Go(int idx, const vector<pair<int, int>>& E, vector<vector<char>>& G) {
  if (idx == E.size()) {
    Check(G);
    return;
  }

  G[E[idx].first][E[idx].second] = true;
  G[E[idx].second][E[idx].first] = true;
  Go(idx + 1, E, G);
  G[E[idx].first][E[idx].second] = false;
  G[E[idx].second][E[idx].first] = false;
  Go(idx + 1, E, G);
}

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

//  int N = 3;
//  vector<vector<char>> G(N, vector<char>(N, false));
//
//  vector<pair<int, int>> E;
//  for (int i = 0; i < N; ++i) {
//    for (int j = i + 1; j < N; ++j) {
//      E.push_back({i, j});
//    }
//  }
//
//  Go(0, E, G);
//
//  return 0;

  int N;
  cin >> N;

  vector<vector<char>> A(N, vector<char>(N, true));
  for (int i = 0; i < N; ++i) {
    A[i][i] = false;
  }

  if (N % 2 != 0) {
    for (int i = N - 2, j = 0; i >= 0; --i, ++j) {
      A[i][j] = false;
    }
  } else {
    for (int i = N - 1, j = 0; i >= 0; --i, ++j) {
      A[i][j] = false;
    }
  }

  assert(Check(A));

  vector<pair<int, int>> result;
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      if (A[i][j]) {
        result.push_back({i, j});
      }
    }
  }

  cout << result.size() << '\n';
  for (const auto& r : result) {
    cout << r.first + 1 << " " << r.second + 1 << '\n';
  }

  return 0;
}


Measured memory_bytes: 384
/***
*	5-1 ?????????
****/

#include <iostream>
#include <vector>
using namespace std;

//--------------------------------------------
vector<int> input()
{
	int n;
	cin >> n ;
	vector<int> str;
	str.resize(n);
	
	for(int i=0; i< n; i++){
		cin >> str[i];
	}
	return str;
}
//--------------------------------------------
void judge(bool result)
{
	if (result){
		cout << "yes" << endl;
	} else {
		cout << "no" << endl;
	}
}
//--------------------------------------------

//--------------------------------------------
bool solve(int i, int m, vector<int> &A)
{
	if(m==0){
		return true;
	}
	if(i >= (A.size())){
		return false;
	}
	bool res ;
	bool res1 = solve( (i+1), m, A);
	bool res2 = solve((i+1), m- A[i], A);
	if(res1 || res2){
		res = true;
	}
	else{
		res = false;
	}
	
	return res;
}
//--------------------------------------------
int main()
{
	//??°????????\???
	vector<int> strA = input();
	
	//?????????q?????\???
	int q;
	cin >> q;
	
	//q????????°??????????????????
	for	(int i=0; i< q; i++){
		int integM;
		cin >> integM;
		
		//i ????????\??????????´?????????£??? m ??????????????´??? true ???????????¢??°
		bool result = solve(0, integM, strA);
		
		//?????????q????????????
		judge(result);
	}
	
	return 0;
}

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

int main() {
  int n;
  long long s = 0;
  cin >> n;
  for (int i = 0; i <= n; i++){
    if (i%3 == 0 || i%5 == 0) continue;
    s += i;
  }
  cout << s << endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;
#define endl '\n'

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

template<typename T>
inline bool chmax(T& x, T a) {
	if (x <= a) { x = a; return true; }
	return false;
}

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

	int N, M; cin >> N >> M;
	vector<int> a(N);
	int sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		sum += a[i];
	}
	int c = 0;
	for (int i = 0; i < N; i++) {
		if (a[i] * 4 * M >= sum) { c++; }
	}
	if (c >= M) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <queue>
#include <utility>
typedef long long ll;
using namespace std;

int main(void) {
  ll i, j, k, n;
  scanf("%lld%lld", &n, &k);
  ll dp[k + 1], a[n];
  for(i = 0; i <= k; ++i) dp[i] = 0;
  for(i = 0; i < n; ++i) scanf("%lld", &a[i]);
  for(i = 1; i <= k; ++i) {
    for(j = 0; j < n; ++j) if(i - a[j] >= 0) {
      if(!dp[i - a[j]]) dp[i] = 1;
    }
  }
  printf("%s", dp[k] ? "First" : "Second");
  return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI=acos(-1);
const int INF = numeric_limits<int>::max();
 
int main(){
    int n, m;
    cin >> n >> m;

    int h[n];
 
    rep(i,n) cin >> h[i];

    vector<set<int>> v(n);
 
    rep(i,m){
        int a, b;
        cin >> a >> b;
        v[a-1].insert(b-1);
        v[b-1].insert(a-1);
    }

    int count = 0;

    rep(i,n){
        bool flag = true;
        set<int>::iterator itr;
        for(itr = v[i].begin(); itr != v[i].end(); ++itr){
            if (h[i] <= h[*itr]) flag = false;
        }
        if(flag) count++;
    }
 
    cout << count << endl;
 
}

Measured memory_bytes: 17724
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#include <array>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__)
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
template <typename T>
vector<T> divisor(T n) {
    vector<T> res;
    for (T i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i * i != n) {
                res.push_back(n / i);
            }
        }
    }
    sort(res.begin(), res.end());
    return res;
}
template <typename T>
map<T, int> prime_factor(T n) {
    map<T, int> res;
    for (T i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            res[i]++;
            n /= i;
        }
    }
    if (n != 1) {
        res[n]++;
    }
    return res;
}
template <typename T>
T gcd(T a, T b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

int main(){
    ll n;
    cin >> n;
    auto d = divisor(n);
    ll ans = 0;
    show(d);
    for(auto x : d){
        if(x==1)continue;
        ll N = n;
        while(N%x==0)N/=x;
        if(N%x==1)ans++;
    }
    auto dd = divisor(n-1);
    ans += dd.size()-1;
    cout << ans << endl;
}


Measured memory_bytes: 384
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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 DEBUG_VLL(vec) REP(sz, vec.size()) cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vvll edges(n);
    vll a(n - 1), b(n - 1);
    ll k = 0, maxi = -1;
    REP(i, n - 1) {
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
        edges[a[i]].push_back(b[i]);
        if (k < edges[a[i]].size()) {
            k = edges[a[i]].size();
            maxi = a[i];
        }

        edges[b[i]].push_back(a[i]);
        if (k < edges[b[i]].size()) {
            k = edges[b[i]].size();
            maxi = b[i];
        }
    }

    cout << k << '\n';

    map<P<ll, ll>, ll> color;
    V< set<ll> > col(n);
    vll coled(n, 0);
    queue<ll> que; que.push(maxi);
    while (!que.empty()) {
        ll q = que.front(); que.pop();
        if (coled[q] == 1) continue;
        coled[q] = 1;

        ll tmpc = 1;
        for (ll e: edges[q]) {
            if (coled[e] == 1) continue;
            while (col[e].find(tmpc) != col[e].end() || col[q].find(tmpc) != col[q].end()) tmpc++;
            col[e].insert(tmpc);
            col[q].insert(tmpc);
            color[make_pair(e, q)] = tmpc;
            color[make_pair(q, e)] = tmpc;
            tmpc++;
            que.push(e);
        }
    }

    REP(i, n - 1) {
        cout << color[make_pair(a[i],b[i])] << '\n';
    }
    return 0;
}


Measured memory_bytes: 35456
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <cmath>

#include <fstream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void)
{


    int k;
    string s;
    
    cin >> k >> s;
    
    if(s.size() <= k)
    {
        cout << s;
    }
    else
    {
        for(int i = 0; i < k; i++)
        {
            cout << s[i];
        }
        cout << "...";
    }
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long ll;
typedef pair<int,int> pii;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

// graph //
int V,E,r,from,to,weight;
string A[50],B[50];

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cin >> V >> E;
    REP(i,V) cin >> A[i];
    REP(i,E) cin >> B[i];
    REP(i,V-E+1){
        REP(j,V-E+1){
            if(A[i][j]==B[0][0]){
                bool isok = true;
                REP(k,E){
                    REP(l,E){
                        if(A[i+k][j+l]!=B[k][l]) isok = false;
                    }
                }
                if(isok){
                    cout << "Yes" << '\n';
                    return 0;
                }
            }
        }
    }
    cout << "No" << '\n';


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
double s(long long n)
{
    long long x=n,y=0;
    
    while (x)
    {
        y+=x%10;
        x/=10;
    }
    return (double)n/y;
}
int main()
{
    long long K;
    long long n=1;
    long long x=1;
    cin>>K;
    for (int i = 0; i < K; i++)
    {
        cout<<n<<endl;
        if (s(n+x)>s(n+x*10))
            x*=10;
        n+=x;
    }
    return 0;
}


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

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

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

	
	if (N > 1 && M > 1) {
		cout << (N * (N - 1) + M * (M - 1)) / 2;
	}
	else if (N > 1) {
		cout << (N * (N - 1) ) / 2;
	}
	else if (M > 1) {
		cout << ( M * (M - 1)) / 2;
	}
	else cout << 0;
}

Measured memory_bytes: 256
#include<cctype>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
#include<bitset>
#include<cstdio>
#include<queue>
#include<ctime>
#define pprint(x) print(x),putchar(' ')
#define fprint(x) print(x),putchar('\n')
using namespace std;
//#define getchar() (SS == TT && (TT = (SS = BB) + fread(BB,1,1 << 15,stdin),TT == SS) ? EOF : *SS++)
char BB[1 << 15],*SS = BB,*TT = BB;
inline long long read()
{
	long long x = 0;int f = 1;
	char ch = getchar();
	for(;!isdigit(ch);ch = getchar())
		if(ch == '-')
			f = -1;
	for(;isdigit(ch);ch = getchar())
		x = x * 10 + (ch ^ 48);
	return x * f;
}
inline void print(long long x)
{
	if(x < 0)
	{
		putchar('-');
		x = -x;
	}
	char ch = x % 10 + '0';
	if(x > 9)
		print(x / 10);
	putchar(ch);
}
const int N = 5110,mod = 1000000007;
struct edge
{
	int to,nxt;
}e[N << 1];
int head[N],cnt;
void add(int u,int v)
{
	e[++cnt].nxt = head[u],e[cnt].to = v;
	head[u] = cnt;
}
void add_edge(int u,int v)
{
	add(u,v),add(v,u);
}

int n;
int siz[N];
long long g[N],f[N][N],tmp[N];

void dfs(int u,int fa)
{
	siz[u] = f[u][1] = 1;
	for(int i = head[u];i;i = e[i].nxt)
	{
		int v = e[i].to;
		if(v == fa)
			continue;
		dfs(v,u);
		for(int j = 1;j <= siz[u] + siz[v];j++)
			tmp[j] = 0;
		
		for(int j = 1;j <= siz[u];j++)
			for(int k = 0;k <= siz[v];k++)
				tmp[k + j] = (tmp[k + j] + f[u][j] * f[v][k]) % mod;
		for(int j = 1;j <= siz[u] + siz[v];j++)
			f[u][j] = tmp[j];
		siz[u] += siz[v];
	}
	for(int i = 2;i <= siz[u];i += 2)
		f[u][0] = (f[u][0] - f[u][i] * g[i] % mod + mod) % mod;
}

int main()
{
	n = read();
	for(int i = 1;i < n;i++)
		add_edge(read(),read());
	g[0] = 1;
	for(int i = 2;i <= n;i += 2)
		g[i] = g[i - 2] * (i - 1) % mod;
	dfs(1,0);
	fprint(mod - f[1][0]);
}

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

#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f){cout<<(f?"YES":"NO")<<endl;}

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

    string S; cin >> S;
    S.replace(0, 4, "2018");
    cout << S << endl;
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void anss(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  ll n;cin>>n;
  deque<ll>a;
  for(i=0;i<n;i++){
    cin>>buf;
    if(i%2==0)a.push_back(buf);
    else a.push_front(buf);
  }
  if(n%2==1)reverse(ALL(a));
  for(i=0;i<n;i++){
    cout<<a.front()<<" ";
    a.pop_front();

  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 3840
n = int(input())
a = list(map(int , input().split()))

from collections import defaultdict
c = defaultdict(int)
for ai in a:
    c[ai] += 1

class Combination:
    def __init__(self, N=2*10**5, mod=67280421310721):
        self.mod = mod
        self.N = N
        self.fact = [1, 1]  # fact[n] = (n! mod p)
        self.factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
        self.inv = [0, 1]  # factinv 計算用
        for i in range(2, N + 1):
            self.fact.append((self.fact[-1] * i) % mod)
            self.inv.append((-self.inv[mod % i] * (mod // i)) % mod)
            self.factinv.append((self.factinv[-1] * self.inv[-1]) % mod)

    def nCr(self, n, r):
        if (r < 0) or (n < r):
            return 0
        r = min(r, n - r)
        return self.fact[n] * self.factinv[r] * self.factinv[n-r] % self.mod

comb = Combination()

t = 0
for ci in c:
    t += comb.nCr(c[ci],2)

for ai in a:
    print(t - comb.nCr(c[ai],2) + comb.nCr(c[ai]-1,2))


Measured memory_bytes: 46544
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 2100000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

ll n;
vl a(3005);
ll dp[3005][3005];
bool calc[3005][3005];

ll rec(ll l, ll r){
	if(l==r) return a[l];
	if(calc[l][r]) return dp[l][r];
	dp[l][r] = max(a[l] - rec(l+1,r), a[r] - rec(l,r-1));
	calc[l][r] = true;
	return dp[l][r];
}

int main(){
	cin >> n;
	rep(i,n) cin >> a[i];
	cout << rec(0,n-1) << endl;
}

Measured memory_bytes: 78592
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int compare_int(const void *a, const void *b)
{
//    return *(int*)a - *(int*)b;
    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

int main()
{
  int a ,b, c, d, e, X, Y;
//  long long  b, c, d, e, X, Y;
  //  double  c;
  long long  A[100003]={};
  int  B[100003]={};
  int  C[100003]={};

  int  flag[103]={};

//  long long  a, b, c, d, X, Y;
  char s[101]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
//  int flag=0;
  int tmp=0;
//  int min=1000000;
  long long min=100000001;
  int len=0;
  double cnt=0;
  int num=0;
  double ans=0;
  int max=0;
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
//  scanf("%lld %lld", &a, &b);
//  scanf("%d%d", &a,&c);
//  cnt = strlen(t);
// printf("%d\n",a);
    scanf("%d%d%d", &a,&b, &c);
  for(i=0;i<10;i++){
    c=a*c-b;
    printf("%d\n",c);
  }
  
  
//  printf("%d %d\n", a,b);
  
//  printf("%lf\n",ans);
  //  //  if(flag==0)   printf("TLE\n");
//    if(max < cnt - max)  printf("Yes\n");
//    else  printf("No\n");
  
return 0;
}


Measured memory_bytes: 128
//
//  main.cpp
//  temp
//
//  Created by tolemy on 2019/08/04.
//  Copyright © 2019 tolemy. All rights reserved.
//

#include <iostream>

using namespace std;

int main(int argc, const char * argv[]) {
    
    string s;
    cin >> s;
    
    string t;
    cin >> t;
    
    int count = 0;
    for(int i=0;i<3;i++)
    {
        if(s[i] == t[i]) count++;
    }
    
    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def main():
    A, B = map(int, input().split())
    ans = 0
    for a in range(A, B + 1):
        s = str(a)
        ans += (s == s[::-1])
    print(ans)

if __name__ == '__main__':
    main()


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

typedef long long LL;
LL n, x, ans;

int main()
{
	cin >> n >> x;
	ans = n;
	
	LL a = x, b = n - x, t; //a存长边,b存短边 
	while(true)
	{
		if(a < b) swap(a,b);
		//cout << a << " " << b << endl;
		
		if(b == 0) break;
		
		ans += 2 * b * (a / b);
		if(a % b == 0) ans -= b;
		
		t = a % b; a = b; b = t;
	}
	
	cout << ans << endl;
	
	return 0;
}


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

int main(){
    string s;
    int k;
    cin>>s>>k;
    int n=s.size();
    rep(i,n-1){
        if(s[i]=='a')continue;
        if(s[i]-'a'+k<26)continue;
        k-=26-(s[i]-'a');
        s[i]='a';
    }
    int x=s[n-1]-'a'+k%26;
    if(x>=26)x-=26;
    s[n-1]=x+'a';
    cout<<s<<endl;
}

Measured memory_bytes: 512
//Minesweeper

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) int n;cin>>n;vector<int>a(n);rep(i,0,n)cin>>a[i]
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
#define cout15(a) printf("%.15f\n",a)
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<int,string> p;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int main (){
    int h,w;cin>>h>>w;
    char s[h+2][w+2],a[h][w];
    rep(i,0,h+2)rep(j,0,w+2)s[i][j]='.';
    rep(i,1,h+1){
        string u;cin>>u;
        rep(j,1,w+1){
            s[i][j]=u[j-1];
        }
    }
    rep(i,1,h+1)rep(j,1,w+1){
        if(s[i][j]=='#')a[i-1][j-1]='#';
        else{
            int ans = 0;
            rep(k,-1,2)rep(l,-1,2){
                if(s[i+k][j+l]=='#')ans++;
            }
            a[i-1][j-1]=ans+'0';
        }
    }
    rep(i,0,h){
        rep(j,0,w){
            cout << a[i][j];
        }
        cout<<nnn;
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<queue>
using namespace std;
int n,r,l;
int d,t,x;
int tt[1000001]={0},ten[1000001]={0};
typedef pair<int,int> P;
priority_queue<P> qu;
int main(void)
{
	int i,j,flg,max,min,n1,nn,ten1;
	P ppp;
	
	scanf("%d %d %d",&n,&r,&l);
	
	n1=1;
	ten1=0;
	
	for(i=0;i<r;i++){
		scanf("%d %d %d",&d,&t,&x);
		
		tt[n1]+=t-ten1;
		ten[d]+=x;
		
		qu.push(P(ten[d],d*-1));
		ten1=t;
		
		while(1){
			ppp=qu.top();
			nn=ppp.second*-1;
			if(ten[nn]==ppp.first){
				n1=nn;
				break;
			}
			qu.pop();
		}	
	}
	tt[n1]+=l-ten1;
	max=-1;
	for(i=1;i<=n;i++){
		if(max<tt[i]){
			max=tt[i];
			min=i;
		}	
	}	
	printf("%d\n",min);	
}		


Measured memory_bytes: 11172
from collections import deque

H,W = list(map(int,input().split()))
Ch,Cw = list(map(int,input().split()))
Dh,Dw = list(map(int,input().split()))

maze = [["#"]*(W+4)]
maze.append(["#"]*(W+4))
for i in range(H):
    row = ["#","#"]
    row.extend(list(input()))
    row.append("#")
    row.append("#")
    maze.append(row)
maze.append(["#"]*(W+4))
maze.append(["#"]*(W+4))
warp = [[114514]*(W+4) for i in range(H+4)]

queue = deque()
queue.append((Ch+1,Cw+1))
warp[Ch+1][Cw+1] = 0
move_one = set(((1,0),(0,1),(-1,0),(0,-1)))
while queue:
    y,x = queue.popleft()
    for i in range(-2,3):
        for j in range(-2,3):
            if i == 0 and j == 0:
                maze[ny][nx] = "#"
                continue
            ny,nx = y+i,x+j
            if maze[ny][nx] == "#":
                continue
            if (i,j) in move_one:
                warp[ny][nx] = warp[y][x]
                queue.appendleft((ny,nx))
                maze[ny][nx] = "#"
            else:
                if warp[ny][nx] == 114514:
                    warp[ny][nx] = warp[y][x]+1
                    queue.append((ny,nx))

if warp[Dh+1][Dw+1] == 114514:
    print(-1)
else:
    print(warp[Dh+1][Dw+1])

Measured memory_bytes: 132076
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << (x) << endl

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define INF 0x7FFFFFFF//or 0x3f3f3f3f ? -Wall
using namespace std;

template<class T> inline
void read(T& x) {
	int f = 1; x = 0;
	char ch = getchar();

	while (ch < '0' || ch > '9')   {if (ch == '-') f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}

/*============ Header Template ============*/

int n, d, x;
double ans;

void solve(int n, double d, double x) {
	if (n == 0) return;
	//printf("%d %lf %lf\n", n, d, x);
	ans += ((d + d + (2.0 * n - 1.0) * x) * n) / (2.0 * n);
	d = ((2.0 * n + 2.0) * d + 5.0 * x) / (2.0 * n);
	x = (2.0 * n + 4.0) * x / (2.0 * n);
	solve(n - 1, d, x);
}

int main() {
	read(n), read(d), read(x);
	solve(n, d, x);
	printf("%.9lf\n", ans);
	return 0;
}

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


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        var n = int.Parse(Console.ReadLine());
        var s = new HashSet<String>();

        for (int i = 0; i < n; i++)
        {
            var t = Console.ReadLine();
            if (!s.Contains(t))
            {
                 s.Add(t);
            }
           
        }

        // 出力
        var ans = s.Count();
        Console.WriteLine(ans);
    }
}

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

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

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

    a.erase(unique(a.begin(), a.end()), a.end());

    for(int i = 0; i < a.size(); i++)  cout << a[i] << " \n"[i == a.size()-1];

    return 0;
}


Measured memory_bytes: 3080
a,b,c =map(int,input().split())
flag1 = 0
flag2 = 0
flag3 = 0
if a == b:
  flag1 = 1
if b == c:
  flag2 =1
if a == c:
  flag3 =1
if flag1 ==1 and flag2 ==1:
  print("No")
elif flag1 ==0 and flag2 ==0 and flag3 == 0:
  print("No")
else:
  print("Yes")

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

using namespace std;

int main(){
  int N;
  int ans=1;
  int P[200010];
  cin >> N;
  for(int i=0; i<N; i++) cin >> P[i];
  int M[200010];
  M[0]=P[0];
  for(int i=1; i<N; i++) M[i]=min(M[i-1],P[i]);
  for(int i=1; i<N; i++){
    if(P[i]<=M[i-1]) ans++;
  }
  cout << ans << endl;
  
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef long long ld;


#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))

int main(){
    FAST
    int n;
    ld d;
    cin >> n >> d;
    int ans = 0;
    for(int i = 0; i < n; i++){
        ld x, y; cin >> x >> y;
        ld res = x*x + y*y;
        if(sqrt(res) <= d)ans++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3664
H, W = map(int, input().split())
T = list(map(str, input()))
dic = {}
M = []
M.append(T)
for i in range(W):
    if T[i] == '.':
        dic[i] = 1
for i in range(H-1):
    T = list(map(str, input()))
    for j in range(W):
        if T[j] == '.' and j in dic:
            dic[j] += 1
    M.append(T)

for i in range(H):
    t = 0
    for j in range(W):
        if M[i][j] == '.':
            t += 1
        if j in dic and dic[j] == H:
            M[i][j] = ''
    if not t == W:
        print(''.join(M[i]))

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

typedef struct Node{
  int key;
  struct Node *next;
  struct Node *prev;
}Node;

void insert(int);
void delete(Node *);
Node *search(int);

Node *nil;

void insert(int key){
    Node *a;

    a = (Node *)malloc(sizeof(Node));
    a->key = key;
    a->next = nil->next;
    a->prev = nil;
    nil->next = a;
    a->next->prev = a;
}

void delete(Node *d){
    if (d == NULL){
        return;
    }
    d->prev->next = d->next;
    d->next->prev = d->prev;
    free(d);
}

Node *search(int key){
    Node *search;
    for(search=nil->next ; search!=nil ; search=search->next){
        if(search->key == key){
          return search;
        }
    }
    return NULL;
}

int main(){
  int i, n, rekey;
  char tstr[20];
  Node *p;

  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil->prev = nil;

  scanf("%d", &n);

  //入力
  for(i=0 ; i<n ; i++){
    scanf("%s", tstr);

    //挿入
    if(strcmp(tstr, "insert") == 0){
        scanf("%d", &rekey);
        insert(rekey);
    }
    //削除
    else if(strcmp(tstr, "delete") == 0){
      scanf("%d", &rekey);
      delete(search(rekey));
    }
    //先頭を削除
    else if(strcmp(tstr, "deleteFirst") == 0){
      delete(nil -> next);
    }
    //末尾を削除
    else if(strcmp(tstr, "deleteLast") == 0){
      delete(nil -> prev);
    }
  }

  for(p=nil->next ; p->next!=nil ; p=p->next){
    printf("%d ", p->key);
  }
  printf("%d\n", p->key);

  return 0;
}



Measured memory_bytes: 33004
#include <cstdio>
#include <cstring>
#include <algorithm>

typedef long long LL;
const int Mod = 1000000007;
const int MN = 25005, MK = 405;

inline int qPow(int b, int e) {
	int a = 1;
	for (; e; e >>= 1, b = (LL)b * b % Mod)
		if (e & 1) a = (LL)a * b % Mod;
	return a;
}

int N, K, M, A[MN];
int Ans, B1[MN], B2[MN];

inline int check() {
	static int lst[MK];
	int ok = 0, len = 0;
	for (int i = 1; i <= K; ++i) lst[i] = 0;
	for (int i = 1; i <= M; ++i) {
		len = std::min(len + 1, i - lst[A[i]]);
		lst[A[i]] = i;
		if (len == K) ok = 1;
	} return ok ? 0 : len;
}

inline void DP(int *B, int len) {
	static int f[MK], g[MK];
	for (int i = 1; i < K; ++i) f[i] = 0;
	f[len] = B[0] = 1;
	for (int i = 1; i <= N - M; ++i) {
		int Sum = 0;
		for (int j = K - 1; j >= 1; --j) {
			Sum -= (Sum += f[j]) >= Mod ? Mod : 0;
			g[j] = (Sum + (LL)(K - j + 1) * f[j - 1]) % Mod;
		}
		std::swap(f, g);
		Sum = 0;
		for (int j = 1; j < K; ++j) Sum -= (Sum += f[j]) >= Mod ? Mod : 0;
		B[i] = Sum;
	}
}

int main() {
	scanf("%d%d%d", &N, &K, &M);
	for (int i = 1; i <= M; ++i) scanf("%d", &A[i]);
	Ans = (LL)(N - M + 1) * qPow(K, N - M) % Mod;
	int chk = check();
	if (chk) {
		if (chk == M) {
			static int f[2][MK], g[2][MK];
			f[0][1] = K, f[1][1] = M > 1 ? 0 : K;
			for (int i = 2; i <= N; ++i) {
				int S0 = 0, S1 = 0;
				for (int j = K - 1; j >= 1; --j) {
					S0 -= (S0 += f[0][j]) >= Mod ? Mod : 0;
					S1 -= (S1 += f[1][j]) >= Mod ? Mod : 0;
					g[0][j] = (S0 + (LL)(K - j + 1) * f[0][j - 1]) % Mod;
					g[1][j] = (S1 + (LL)(K - j + 1) * f[1][j - 1] + (j >= M ? g[0][j] : 0)) % Mod;
				}
				std::swap(f, g);
			}
			int S1 = 0, C = 1;
			for (int j = 1; j < K; ++j) S1 -= (S1 += f[1][j]) >= Mod ? Mod : 0;
			for (int i = 0; i < M; ++i) C = (LL)C * (K - i) % Mod;
			Ans = (Ans - (LL)S1 * qPow(C, Mod - 2)) % Mod;
		} else {
			std::reverse(A + 1, A + M + 1);
			int lb = check(), rb = chk;
			DP(B1, lb), DP(B2, rb);
			for (int i = 0; i <= N - M; ++i)
				Ans = (Ans - (LL)B1[i] * B2[N - M - i]) % Mod;
		}
	}
	printf("%d\n", (Ans + Mod) % Mod);
	return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
using namespace std;

int a, b, c, d;

int main()
{
	cin >> a >> b >> c >> d;
	int A = max(a, c), B = min(b, d);
	if (A > B) printf("0\n");
	else printf("%d\n", B - A);
	return 0;
}

Measured memory_bytes: 256