akhauriyash/Code-Regression huggingface dataset:
inputs = int(input())
line = raw_input().split()

nums = [int(i) for i in line]

map_ = {}

for num in nums:
    if num not in map_:
        map_[num] = 0
    map_[num] += 1

count = 0
for key, item, in map_.iteritems():
    if item < key:
        count += item
    else:
        count += (item - key)

print count


Measured memory_bytes: 21596
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	
	public static void main(String [] args) {
		Scanner scanner = new Scanner(System.in);
		int k = scanner.nextInt();
		int n = scanner.nextInt();
		int[] d = new int[n];
		List<Integer> a[] = new ArrayList[k];
		for (int i = 0 ; i < n ; i ++) {
			int di = scanner.nextInt();
			d[i] = di;
			for (int j = 0 ; j < di ; j ++) {
				int aj = scanner.nextInt();
				List<Integer> ajtemp = a[aj - 1];
				if (ajtemp == null ) {
					ajtemp = new ArrayList<>();
				}
				ajtemp.add(ajtemp.size() + 1);
				a[aj - 1] = ajtemp;
			}
		}
		int ans = 0;
		for (List<Integer> temp : a) {
			if (temp == null || temp.size() == 0) {
				ans ++;
			}
		}
		System.out.println(ans);
		scanner.close();
	}
}

Measured memory_bytes: 37708
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

n,m=map(int,input().split())
p=[int(i) for i in input().split()]

uf=UnionFind(n)
for i in range(m):
    x,y=map(int,input().split())
    uf.union(x,y)
ans=0
for i in range(n):
    if uf.same_check(p[i],i+1):
        ans+=1
print(ans)


Measured memory_bytes: 14452
# https://atcoder.jp/contests/abc166/tasks/abc166_b
# at_coder_friends test-all B.rb
# require 'pry'

input_lines = readlines.map(&:chomp)
N, K = input_lines.shift.split.map(&:to_i)
Ass = Array.new(K)
K.times do |ki|
 d = input_lines.shift.to_i
 Ass[ki] = input_lines.shift.split.map(&:to_i)
end

mark_as = Array.new(N)

Ass.each do |as|
  as.each do |a|
    mark_as[a - 1] = true
  end
end

#p mark_as

ans = mark_as.count do |m|
  m.nil?
end

puts ans


Measured memory_bytes: 14280
K,N=map(int,input().split())
A=list(map(int,input().split()))
m=K
for i in range(N):
  if i==0:
    m=min(m,A[N-1]-A[0])
  else:
    b=A[N-1]-A[i]+K-A[N-1]+A[i-1]
    m=min(m,b)
print(m)
             

Measured memory_bytes: 26420
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int H = sc.nextInt();
        int W = sc.nextInt();
        String[] S = new String[H];
        for(int i = 0; i < H; i++)
            S[i] = sc.next();
        sc.close();

        int[][] L = new int[H+2][W+2];
        int[][] R = new int[H+2][W+2];
        int[][] U = new int[H+2][W+2];
        int[][] D = new int[H+2][W+2];
        for(int i = 1; i <= H; i++){
            for(int j = 1; j <= W; j++){
                if(S[i-1].charAt(j-1) == '#'){
                    L[i][j] = 0;
                } else {
                    L[i][j] = L[i][j-1]+1;
                }
            }
        }
        for(int i = 1; i <= H; i++){
            for(int j = W; j >= 1; j--){
                if(S[i-1].charAt(j-1) == '#'){
                    R[i][j] = 0;
                } else {
                    R[i][j] = R[i][j+1]+1;
                }
            }
        }

        for(int j = 1; j <= W; j++){
            for(int i = 1; i <= H; i++){
                if(S[i-1].charAt(j-1) == '#'){
                    U[i][j] = 0;
                } else {
                    U[i][j] = U[i-1][j]+1;
                }
            }
        }
        for(int j = 1; j <= W; j++){
            for(int i = H; i >= 1; i--){
                if(S[i-1].charAt(j-1) == '#'){
                    D[i][j] = 0;
                } else {
                    D[i][j] = D[i+1][j]+1;
                }
            }
        }
        int ans = 0;
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                if(S[i].charAt(j) == '.'){
                    ans = Math.max(ans, L[i+1][j+1]+R[i+1][j+1]+U[i+1][j+1]+D[i+1][j+1]-3);
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 117940
#include <bits/stdc++.h>
using namespace std;
const double pi=acos(-1.0);
int a,b,x;
int main(){
	scanf("%d%d%d",&a,&b,&x);
	if (a*a*b>=x*2){
		double y=x*2.0/b/a;
		printf("%.9lf\n",90-atan(y/b)*180/pi);
	}else{
		double y=1.0*x/a;
		y=y*2/a;
		double t=y-b;
		printf("%.9lf\n",90-atan(a/(b-t))*180/pi);
	}
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    ll n;
    cin >> n;
    if (n <= 999) {
        cout << "ABC\n";
    } else {
        cout << "ABD\n";
    }
    return 0;
}

Measured memory_bytes: 3592
# -*- coding: utf-8 -*-

N, M = map(int, input().split())

A = list(map(int,input().split()))

count = 0

ans = 'No'
k = 0
sum = 0


for i in range(N):
    k = A[i]
    sum += k




for j in range(N):
    k = A[j]

    if  k * 4 * M >= sum:
        count += 1

if count  >= M:
    ans = 'Yes'

print(ans)


Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<=n;i++)
#define rep2(i,k,n) for(int i=k;i>=n;i--)
using namespace std;
typedef long long ll;
typedef double db;
const int N=2e5+7;
ll s[N];
ll ans=0x7f7f7f7f7f7f7f7full;
int n,a[N];
int main(){
	scanf("%d",&n);
	rep(i,1,n)scanf("%d",&a[i]),s[i]=s[i-1] + a[i];
	rep(i,1,n-1){
		ans=min(1.0*ans,fabs(2*s[i] - s[n]));
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 2560
R,G,B,N = list(map(int,input().split()))
count = 0
for r in range(N//R+1):
    for g in range((N-R*r)//G+1):
        if (N-(R*r+G*g))%B == 0 and N-(R*r+G*g) >= 0:
            count += 1
print(count)

Measured memory_bytes: 40556
#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() {
    double n, d, ans = 0;
    cin >> n >> d;

    cout << ceil(n / (2 * d + 1)) << endl;
    return 0;
}


Measured memory_bytes: 3776
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        ss: chars,
    }
    let mut ret = 0;
    let mut b = false;
    let mut no_w = true;
    for i in 0..ss.len() {
        if ss[i] == 'B' {
            if b {
            } else {
                b = true;
                ret+=1;
            }
        } else {
            no_w = false;
            b = false;
        }
    }
    let mut si = 0;
    let len = ss.len();
    if ret > 1 {
        if ss[0] == 'B' {
            si += 1;
        }
        if ss[(len - 1) as usize] == 'B' {
            si += 1;
        }
    } else {
        if ss[0] == 'B' || ss[(len - 1) as usize] == 'B' {
            si += 1;
        }
    }
    if no_w {
        println!("{}", 0);
        return;
    }
    if ret == 0 {
        println!("0");
        return;
    }
    println!("{}", ret * 2 - si);
}

Measured memory_bytes: 4352
// B - Varied
// https://atcoder.jp/contests/abc063/tasks/abc063_b
#include <bits/stdc++.h>
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const long double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
#define pb push_back
#define eb emplace_back
#pragma GCC optimize("Ofast")
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using P = pair<lli, lli>;
// vector<P> vp;
// vp.emplace_back(a[i], b[i]);
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, k, n, w, ans = 0, count = 0;
  string s, t;
  cin >> s;
  rep(i, 0, s.size())
  {
    rep(j, i + 1, s.size())
    {
      if (s[i] == s[j])
      {
        cout << "no"
             << "\n";
        return 0;
      }
    }
  }
  cout << "yes"
       << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ll a,b,i,j,k,m,n,t;
	cin>>n;
	string s;
	cin>>s;
	ll ctr=0;
	for(i=0;i<n;)
	{
		ctr++;
		char ch=s[i];
		while(i<n&&ch==s[i])
		i++;
	}
	cout<<ctr;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <limits.h>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <string>
#define ll long long
#define ull unsigned long long
#define ms(a) memset(a,0,sizeof(a))
#define pi acos(-1.0)
#define INF 0x7f7f7f7f
#define lson o<<1
#define rson o<<1|1
const double E=exp(1);
const int maxn=1e3+10;
const int mod=1e9+7;
using namespace std;
int main(int argc, char const *argv[])
{
	int n,m;
	cin>>n>>m;
	string ch[maxn];
	for(int i=0;i<n;i++)
	{
		cin>>ch[i];
		// a[i]=ch[i][0];
	}
	sort(ch+0,ch+n);
	for(int i=0;i<n;i++)
		cout<<ch[i];
	cout<<endl;
	// n=unique(a,a+n)-a;
	// for(int i=0;i<n;i++)
	// {
	// 	cout<<a[i];
	// 	for(int j=1;j<m;j++)
	// 		cout<<"x";
	// }
	// cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000LL;
constexpr auto MOD = 1000000007;

int main() {
	
	string s;
	cin >> s;
	int k = 0, ans = 0;
	string pre = "", now = "";
	while (k < s.size()) {
		now = "";
		now += s[k];
		k++;
		if (k < s.size() && now == pre) {
			now += s[k];
			k++;
		}
		if (pre == now)break;
		pre = now;
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 644
N=int(input())
X,Y=map(int,input().split())
T,A=0,0
b,c=0,0
for i in range(N-1):
  T,A=map(int,input().split())
  b=((X+T-1)//T)*T
  c=(b//T)*A
  if c>=Y:
    X,Y=b,c
  else:
    Y=((Y+A-1)//A)*A
    X=(Y//A)*T
print(X+Y)

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

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

    if (s.size() <= k) {
        cout << s << endl;
    }

    else {
        string sk;
        sk = s.substr(0, k);
        cout << sk << "..." << endl;
    }
}

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

typedef long long ll;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a%2==0&&a==b&&b==c){
        cout << -1 << endl;
        return 0;
    }
 
    if(a%2!=0||b%2!=0||c%2!=0){
        cout << 0 << endl;
        return 0;
    }
    
    int ans = 0;
 
    while(true){
        int aa = a,bb= b,cc=c;
        a = bb/2 + cc/2;
        b = aa/2 + cc/2;
        c = aa/2 + bb/2;
        ans++;
        if(a%2!=0||b%2!=0||c%2!=0){
            break;
        }
    }
 
 
    cout << ans << endl;
}

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

int main()
{
    map<string,int> memo;
    int N;
    cin >> N;
    for(int i = 0; i < N; ++i)
    {
        string S;
        cin >> S;
        memo[S] += 1;
    }

    int maxv = 0;
    for (const auto& x : memo)
    {
        int v = x.second;
        if (v > maxv)
        {
            maxv = v;
        }
    }
    for (auto it = memo.begin(); it != memo.end(); ++it)
    {
        if (it->second == maxv)
        {
            cout << it->first << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 25216
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
using Graph_weighted = vector<vector<pair<int,int>>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
int main(){
  ll x;
  cin >> x;
  ll ans = 0,now = 100;
  while(now < x){
    now += (now / 100);
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3608
package main

import (
	"fmt"
	"sort"
)

func main() {
	// Code for C - Christmas Eve
	var N, K int
	fmt.Scanf("%d %d", &N, &K)
	h := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &h[i])
	}

	sort.Sort(sort.IntSlice(h))

	var min int = 10000000000
	var temp int
	for i := 0; i < N-K+1; i++ {
		temp = h[i+K-1] - h[i]
		if min > temp {
			min = temp
		}
	}

	fmt.Println(min)
}


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

int main() {
	int n;
	cin >> n;
	int A[111];
	for (int i = 0; i < n; i++) cin >> A[i];
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		int minj = i;
		for (int j = i; j < n; j++) {
			if (A[j] < A[minj]) {
				minj = j;
			}
		}
		if (i != minj) {
			swap(A[i], A[minj]);
			cnt++;
		}
	}
	for (int i = 0; i < n; i++) cout << A[i] << " \n"[i == n - 1];
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3100
#include <stdio.h>
int main(void) {
    int i, a, b, c,e=0;

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

    for (i = a; i <= b; i++) {
        if (i % c == 0) {
            e++;
        }
    }
    printf("%d", e);

    return 0;
}


Measured memory_bytes: 2152
char s[9];x,l;
int P(a){
	sprintf(s,"%d",a),l=strlen(s);
	for(x=0;x<l;x++)if(s[x]!=s[l-x-1])return 0;
	return 1;
}
main(){
	int n,i;
	scanf("%d",&n);
	for(i=0;;i++){
		if(P(n-i)){printf("%d\n",n-i);return 0;}
		if(P(n+i)){printf("%d\n",n+i);return 0;}
	}
	exit(0);
}

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

typedef long long ll;
ll N;
vector<ll> InvP;
set<ll> Seen;
ll R;

int main() {
  cin >> N;
  InvP.resize(N);
  for (ll i = 0; i < N; ++i) {
    ll p;
    cin >> p;
    --p;
    InvP[p] = i;
  }
  for (ll p = N - 1; p >= 0; --p) {
    ll i = InvP[p];
    auto it = Seen.insert(i).first;
    if (it != Seen.begin()) {
      auto left = prev(it);
      ll l_max = *left;
      ll l_min = left != Seen.begin() ? *prev(left) + 1 : 0;
      ll r_min = *it;
      ll r_max = next(it) != Seen.end() ? *next(it) - 1 : N - 1;
      R += (p + 1) * (l_max - l_min + 1) * (r_max - r_min + 1);
    }
    if (next(it) != Seen.end()) {
      auto right = next(it);
      ll r_min = *right;
      ll r_max = next(right) != Seen.end() ? *next(right) - 1 : N - 1;
      ll l_max = *it;
      ll l_min = it != Seen.begin() ? *prev(it) + 1 : 0;
      R += (p + 1) * (l_max - l_min + 1) * (r_max - r_min + 1);
    }
  }
  cout << R << endl;
  return 0;
}


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

public class Main {
    BufferedReader rd;

    Main() throws IOException {
        rd = new BufferedReader(new InputStreamReader(System.in));
        compute();
    }

    private void compute() throws IOException {
        rd.readLine();
        int[] a = intarr();
        int res = 0;

        int last = -1;
        int start = 0;
        for(int i=0;i<a.length;i++) {
            if(a[i] != last) {
                res += (i - start) / 2;
                start = i;
            }
            last = a[i];
        }
        res += (a.length - start) / 2;
        out(res);
    }

    private int[] intarr() throws IOException {
        return intarr(rd.readLine());
    }

    private int[] intarr(String s) {
        String[] q = split(s);
        int n = q.length;
        int[] a = new int[n];
        for(int i=0;i<n;i++) {
            a[i] = Integer.parseInt(q[i]);
        }
        return a;
    }

    private String[] split(String s) {
        if(s == null) {
            return new String[0];
        }
        int n = s.length();
        int start = -1;
        int end = 0;
        int sp = 0;
        boolean lastWhitespace = true;
        for(int i=0;i<n;i++) {
            char c = s.charAt(i);
            if(isWhitespace(c)) {
                lastWhitespace = true;
            } else {
                if(lastWhitespace) {
                    sp++;
                }
                if(start == -1) {
                    start = i;
                }
                end = i;
                lastWhitespace = false;
            }
        }
        if(start == -1) {
            return new String[0];
        }
        String[] res = new String[sp];
        int last = start;
        int x = 0;
        lastWhitespace = true;
        for(int i=start;i<=end;i++) {
            char c = s.charAt(i);
            boolean w = isWhitespace(c);
            if(w && !lastWhitespace) {
                res[x++] = s.substring(last,i);
            } else if(!w && lastWhitespace) {
                last = i;
            }
            lastWhitespace = w;
        }
        res[x] = s.substring(last,end+1);
        return res;
    }

    private boolean isWhitespace(char c) {
        return c==' ' || c=='\t';
    }

    private static void out(Object x) {
        System.out.println(x);
    }

    public static void main(String[] args) throws IOException {
        new Main();
    }
}


Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define int ll
#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int n, k;
int a[N];
bool dp[N];

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    cin>>n>>k;
    f(i, N) dp[i] = false;
    f(i, n) cin>>a[i], dp[a[i]] = true;
    rep(i, 1, k + 2) {
    	if(dp[i]) continue;
    	bool ok = false;
    	f(j, n) {
    		if(i - a[j] > 0) {
    			if(!dp[i - a[j]]) {
    				ok = true;
    				break;
    			}
    		} 
    		else break;
    	}
    	dp[i] = ok;
    }
    if(dp[k]) cout<<"First\n";
    else cout<<"Second\n";
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define MOD 1000000007

ll N, K;
vi G[100005];
vi seen(100005);
vi num(100005);

void dfs(int v) {
    seen[v] = true;
    int j;
    j = ( v == 0 ? 1 : 2);
    for (auto next : G[v]) {
        if (seen[next]) continue;
        else {
            num[next] = K - j;
            j++;
            dfs(next);
        }
    }
}

int main() {
    cin >> N >> K;

    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b); //0-origin
        G[b].push_back(a);
    }

    seen.assign(N, false);
    num.assign(N, K);
    dfs(0);

    ll ans = 1;

    rep(i, N) {
        ans = (ans * (ll)num[i]) % MOD;
    }

    cout << ans << endl;
}



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

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

  int x[110];
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += min(x[i], abs(k-x[i])) * 2;
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
  char c;
  char res;
  cin >> c;

  res = c + 1;

  cout << res << endl;
}


Measured memory_bytes: 256
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>

int main()
{ 
    int a, b, c;
    std::cin >> a >> b >> c;
    if(a+b+c > 21) {
     std::cout << "bust" << std::endl;
    } else {
     std::cout << "win" << std::endl;
    }
    return 0;
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF = 1e9 + 5; 
int main()
{
    int n; cin>>n;
    vector<int> h(n);
    REP(i,n) cin>>h[i];
    vector<int> dp(n,INF);
    dp[0]=0;
    REP(i,n){
        for(int j : {i+1,i+2}){
            if (j<n)
                dp[j] = min(dp[j],dp[i]+abs(h[i]-h[j]));
        }
    }// _ _ _ _ _ _ _ _ _ _ _ _
    cout<<dp[n-1]<<"\n";
    return 0;
}


Measured memory_bytes: 3996
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    static Node root;

    public static void main(String[] args) {
        new Main().run();
    }

    public void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        IntStream.range(0, N).forEach(i -> {
            String cmd = sc.next();
            if (cmd.equals("insert")) {
                int id = sc.nextInt();
                insert(new Node(id));
            } else if(cmd.equals("print")) {
                print();
            }
        });
    }


    class Node {
        int id;
        Node parent = null, left = null, right = null;

        Node(int id) {
            this.id = id;
        }
    }

    private void insert(Node node) {
        Node parent = null;
        Node position = root;

        while(position != null) {
            parent = position;
            if(node.id < position.id) {
                position = position.left;
            } else {
                position = position.right;
            }
        }

        node.parent = parent;

        if (parent == null) {
            root = node;
        } else {
           if(node.id < parent.id) {
               parent.left = node;
           } else {
               parent.right = node;
           }
        }
    }

    private void print() {
        inOrder(root);
        System.out.println();
        preOrder(root);
        System.out.println();
    }

    private void preOrder(Node node) {
        if(node == null) {
            return;
        }
        System.out.print(" "  + node.id);
        preOrder(node.left);
        preOrder(node.right);
    }

    private void inOrder(Node node) {
        if(node == null) {
            return;
        }
        inOrder(node.left);
        System.out.print(" " + node.id);
        inOrder(node.right);
    }
}


Measured memory_bytes: 205524
package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

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

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var N, D, X int

func main() {
	sc.Split(bufio.ScanWords)

	N, D, X = nextInt(), nextInt(), nextInt()

	var ans int
	for i := 0; i < N; i++ {
		ans++
		A := nextInt()
		ans += (D - 1) / A
	}

	fmt.Println(ans + X)
}


Measured memory_bytes: 640
import java.io.*;
import java.util.*;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
	 	Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		long[] A=new long[N];
		for(int i=0;i<N;++i){
			A[i]=sc.nextLong();
		}
		Arrays.sort(A);
		long ans=0;
		int p0=N-1;
		while(p0>0&&A[p0]!=A[p0-1])--p0; //A[p0]==A[p0-1]
		int p1=p0-2;
		while(p1>0&&A[p1]!=A[p1-1])--p1;
		if(p0>0&&p1>0&&A[p0]==A[p0-1]&&A[p1]==A[p1-1])ans=A[p0]*A[p1];
		System.out.println(ans);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


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

long long N;
long long A[100005];
vector<long long> tree[100005];

//上に流れる分
long long dfs(long long pa, long long cur){

	//leaf
	if(tree[cur].size() == 1 && tree[cur][0] == pa){
		return A[cur];
	}

	long long child = 0;
	vector<long long>chs;
	for(long long i = 0; i < tree[cur].size(); i++){
		if(pa == tree[cur][i]){
			continue;
		}
		long long tmp = dfs(cur, tree[cur][i]);
		chs.push_back(tmp);
		if(tmp < 0){
			return -1;
		}
		child += tmp;
	}

	long long up = (2 * A[cur] - child);
	long long down = (child - A[cur]);
	if(up < 0 || down < 0){
		return -1;
	}

	sort(chs.begin(), chs.end());
	long long num = 0;
	for(long long i = 0; i < chs.size(); i++){
		num += min(chs[i], down);
	}
	if(num < 2 * down){
		return -1;
	}
	return up;
}

int main(){
	cin >> N;
	for(long long i = 0; i < N; i++){
		cin >> A[i];
	}
	for(long long i = 0; i < N - 1; i++){
		long long a,b;
		cin >> a >> b;
		a--;b--;
		tree[a].push_back(b);
		tree[b].push_back(a);
	}

	long long ret = dfs(-1, 0);
	if(ret < 0){
		cout << "NO" << endl;
		return 0;
	}

	if(tree[0].size() == 1){
		if(A[0] == ret){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}else{
		if(0 == ret){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
}



Measured memory_bytes: 15872
using System;
// using System.Collections.Generic;
// using System.Linq;

class Program
{
    static void Main()
    {
        String[] arr = Console.ReadLine().Split();
        int A, B, C, D;
        A = int.Parse(arr[0]);
        B = int.Parse(arr[1]);
        C = int.Parse(arr[2]);
        D = int.Parse(arr[3]);
        Console.WriteLine((B + C - 1) / B <= (A + D - 1) / D ? "Yes" : "No");
        return;
    }
}

Measured memory_bytes: 27444
import bisect,collections,copy,heapq,itertools,math,operator,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def LS(): return list(input().split())
##################################################
N = I()
H = LI()
if N==1:
    print('Yes')
    exit()
if N==2:
    print('Yes' if H[0]-1<=H[1] else 'No')
    exit()
for i in range(N-1):
    if i==0:
        H[i] -= 1
        continue
    if H[i-1]<=H[i]-1<=H[i+1]:
        H[i] -= 1
        continue
    if H[i-1]<=H[i]<=H[i+1]:
        continue
    print('No')
    break
else:
    print('Yes')


Measured memory_bytes: 15288
program AGC38_A
  integer(8)::H,W,A,B
  integer(8),allocatable::S(:,:)
  read(*,*)H,W,A,B
  allocate(S(H,W))
  S=0
  S(B+1:H,1:A)=1
  S(1:B,A+1:W)=1
  do i=1,H
     write(*,"(1000I1)")S(i,:)
  end do
end program AGC38_A

Measured memory_bytes: 8960
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=5e5+10;
bool prime (int x){
    for (int i=2;i<=sqrtl(x);i++){
        if (x%i==0)
            return false;
    }
    return true;
}
int main()
{
    FASTINOUT;
    int x;
    cin>>x;
    vector<int>v;
    for (int i=11;i<=55555;i++){
        if (prime(i)&&i%5==1)
            v.push_back(i);
    }
    for (int i=0;i<x;i++)
        cout<<v[i]<<" ";
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    P = list(map(int, input().split()))
    bubbleSort(N, P)


def bubbleSort(N, P):
    change_count = 0
    i = 0
    while True:
        for j in range(N - 1, i, -1):
            if P[j] < P[j - 1]:
                tmp = P[j]
                P[j] = P[j - 1]
                P[j - 1] = tmp
                change_count += 1
        i += 1
        # print("i:{}".format(i))
        if i == N:
            break

    print(' '.join(map(str, P)))
    print(change_count)


if __name__ == '__main__':
    main()



Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#  define DEBUG(x) cerr << "D: " <<  x << endl
#else
#  define DEBUG(x) do {} while (0)
#endif
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define mp make_pair
#define each(x, v) for (auto &x : v)
#define all(v) (v).begin(), (v).end()
#define sz(v) ((int)(v).size())
#define mem(a, val) memset(a, val, sizeof(a))
#define rep(i, N) for (int i = 0; i < N; i++)
#define repr(i, N) for (long long i = (long long)(N)-1; i >= 0; i--)
#define rep1(i, N) for (long long i = 1; i <= (long long)(N); i++)
#define repr1(i, N) for (long long i = (N); (long long)(i) > 0; i--)
using ii = pair<int, int>;
using ll = long long;
const int inf = 0x3f3f3f3f;
const long long linf = 0x3f3f3f3f3f3f3f3fll;
template<typename T> T abs (T x) { return x < 0 ? -x : x; }
template<typename T> T gcd (T a, T b) { return a ? gcd (b % a, a) : b; }
template<typename T> void max_self(T &a, T b) {  a = max(a, b); }
template<typename T> void min_self(T &a, T b) {  a = min(a, b); }

void solve(int tc) {
  string a, b;
  cin >> a >> b;
  vector< vector< pair<int, ii > > > dp(sz(a) + 1,
  vector< pair<int, ii> >(sz(b) + 1, mp(-inf, mp(0,0))));
  dp[0][0] = mp(0, mp(0, 0));


  rep(i, sz(a)) {
    rep(j, sz(b)) {
      if(a[i] == b[j]) {
        max_self(dp[i+1][j+1], mp(1 + dp[i][j].fi, mp(i, j)));
      }
      max_self(dp[i+1][j], mp(dp[i][j].fi, mp(i, j)));
      max_self(dp[i][j+1], mp(dp[i][j].fi, mp(i, j)));
    }
  }
  string ans;
  pair<int, ii> pp = {0, {0, 0}};
  rep(i, sz(a)+1)rep(j, sz(b)+1) {
    max_self(pp, mp(dp[i][j].fi, mp(i, j)));
  }
  DEBUG("pp: " << pp.fi);
  auto cur = pp.se;
  while(cur.fi != 0 && cur.se != 0) {
      int i = cur.fi;
      int j = cur.se;
      DEBUG(i << " " << j);
      auto prev = dp[i][j].se;
      if(prev == mp(i-1, j-1)){
        ans += a[i-1];
      }
      cur = prev;
  }
  reverse(all(ans));
  cout << ans << endl;
}

int main() {
  int tc = 1;
  // scanf("%d", &tc);
  for(int i = 1; i <= tc; ++i)solve(i);
  return 0;
}

Measured memory_bytes: 105984
#include <stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
  char suit;
  int value;
};

struct Card L[MAX/2+2], R[MAX/2+2];

void merge(struct Card A[], int n, int left, int mid, int right) {
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  for(i=0;i<n1;i++) L[i] = A[left + i];
  for(i=0;i<n2;i++) R[i] = A[mid  + i];
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  for(k=left; k<right; k++) {
    if(L[i].value <= R[j].value) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(struct Card A[], int n, int left, int right) {
  if(left+1 < right) {
    int mid = (left+right) / 2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid, right);
    merge(A,n,left,mid,right);
  }
}

int partition(struct Card A[], int n, int p, int r) {
  int i, j;
  struct Card t, x;
  x = A[r];
  i = p-1;
  for(j=p; j<r; j++) {
    if(A[j].value <= x.value) {
      i++;
      t=A[i]; A[i]=A[j]; A[j]=t;
    }
  }
  t=A[i+1]; A[i+1]=A[r]; A[r]=t;
  return i+1;
}

void quickSort(struct Card A[], int n, int p, int r) {
  int q;
  if(p<r) {
    q = partition(A,n,p,r);
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);
  }
}

int main() {
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;

  scanf("%d", &n);

  for(i=0;i<n;i++) {
    scanf("%s %d",S,&v);
    A[i].suit =  B[i].suit  = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);

  for(i=0;i<n;i++) {
    // マージソートとクイックソートの結果を比べる
    if(A[i].suit != B[i].suit) stable = 0;
  }

  if(stable==1) printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++) {
    printf("%c %d\n",B[i].suit,B[i].value);
  }

  return 0;
}


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

using namespace std;

int main(){
	long long int A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;
	long long int ansA = 100*A, ansB = 0;
	for(long long int i = 0; i <= F / 100 / A; i++){
		long long int F_ = F - i*A * 100;
		for(long long int j = 0; j <= F_ / 100 / B; j++){
			long long int F__ = F_ - j*B * 100;
			for(long long int k = 0; k <= F__ / C; k++){
				long long int F___ = F__ - C*k;
				for(long long int l = 0; l <= F___ / D; l++){

					long long int W = ( i*A + j*B ) * 100;
					long long int S = k*C + l *D;

					//cout << W << " " << S << endl;
					//cout << ansB*( S + W ) << " " << S * ( ansA + ansB ) << endl;
					if(W*E >= S * 100){
						if(ansB*( S + W ) < S * ( ansA + ansB )){
							ansA = W;
							ansB = S;
						}
					}
				}
			}
		}
	}
	cout << ansA+ansB << " " << ansB << endl;
}


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

signed main() {
  vector<int> A(4);
  for( int i = 0; i < 4; i++ ) cin >> A.at(i);
  if( count(A.begin(), A.end(), 1) == 1 && count(A.begin(), A.end(), 9) == 1 && count(A.begin(), A.end(), 7) == 1 && count(A.begin(), A.end(), 4) == 1 ){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<utility>
#include<algorithm>

typedef long long ll;

int main(){
	int h, w, k;
	std::cin >> h >> w >> k;
	ll black;

	std::vector<std::vector<char>> c(h, std::vector<char>(w));
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			std::cin >> c[i][j];
			if(c[i][j] == '.'){
				black++;
			}
		}
	}

	ll res = 0;
	for(int hbit=0; hbit < 1<<h; hbit++){
		for(int wbit=0; wbit < 1<<w; wbit++){
			int tmp = 0;
			for(int i=0; i<h; i++){
				for(int j=0; j<w; j++){
					if(c[i][j] == '#'){
						if(!(hbit>>i & 1) && !(wbit>>j & 1)){
							tmp++;
						}
					}
				}
			}
			if(tmp == k){
				res++;
			}
		}
	}
	std::cout << res << std::endl;
	return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define ll long long
#define loop(n) for(ll i = 0; i<n; i++)
#define sort(a) sort(a.begin(), a.end())
using namespace std;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int a, b; cin>>a>>b;
    if(a==b) loop(a)cout<<a;
    else if(a>b) loop(a)cout<<b;
    else loop(b)cout<<a;
    return 0;
}

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

int main(){
  int n,ans;
  cin >> n;
  ans = 0;
  vector<int> a(n);
  for(int i = 0;i < n;i++){
    cin >> a.at(i);
    if(a.at(i) % 2 != 0){
      cout << 0 << endl;
      return 0;
    }
  }
  while(ans < 30){
    for(int i = 0;i < n;i++){
      if(a.at(i)%2 == 0){
        a.at(i) /= 2;
      }else{
          cout << ans << endl;
        return 0;
      }
    }
    ans++;
  }
  cout << ans << endl;
    
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    string S;
    cin >> S;
    ll n = S.size();
    string T = S;
    reverse(T.begin(), T.end());
    if (S == T) {
        string a = S.substr(0, n/2);
        string b = a;
        reverse(b.begin(), b.end());
        if (b == a) {
            string c = S.substr(n/2+1);
            string d = c;
            reverse(d.begin(), d.end());
            if (d == c) {
                cout << "Yes\n";
                return 0;
            }
        }
    }

    cout << "No\n";
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    long long n, sum=0;
    scanf("%lld", &n);
    for(int i=1;i<=n;i++){
        if(i%3!=0 && i%5!=0)
            sum=sum+i;
        else
        {
            if(i%3==0 && i%5==0)
                sum=sum+0;
            else if(i%3==0 && i%5!=0)
                sum=sum+0;
            else if(i%5==0 && i%3!=0)
                sum=sum+0;
        }
    }
    printf("%lld", sum);

}





Measured memory_bytes: 1720
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

//#define int long long
//using ll = boost::multiprecision::cpp_int;
using ll = long long;
//constexpr int INF = 1e9;//INT_MAX=1<<31-1=2147483647
constexpr ll INF = (ll)1e18;//1<<63-1=9223372036854775807
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-9;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define pb push_back
inline bool isnatural(double a) { return a>=0 && ceil(a)==floor(a); }
template<typename T> inline T power(T x, T n){ return n ? power(x*x%MOD,n/2)*(n%2?x:1)%MOD : 1; }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

constexpr ll W_MAX = 20;

ll H, W;
ll h, w;

void input() {
	scanf("%lld%lld", &H, &W);
	scanf("%lld%lld", &h, &w);
}

void solve() {

	printf("%lld\n", (H-h)*(W-w));
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	input();
	solve();
	return 0;
}


Measured memory_bytes: 256
function Main(s){
  s = s.split("\n");
  var n = +s[0];
  s = s[1];
  var a = [0];
  for(var i = 0; i < n; i++){
    if(s[i] === "E")a[i+1] = a[i] + 1;
    else a[i+1] = a[i];
  }
  ans = 9e9;
  for(i = 0; i < n; i++){
    ans = Math.min(ans, a[n] - a[i+1] + i - a[i] + a[0]);
  }
  console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin","utf8").trim());

Measured memory_bytes: 16700
#include<bits/stdc++.h>
using namespace std;
int main()
{
 long long int a;
 cin>>a;
 if(a%2==0 && a%a==0)
 {
     cout<<a<<endl;
 }
 else
 {
     a=a*2;
     cout<<a<<endl;
 }

}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>

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

using namespace std;

bool is_valid(const char *a,const char *b,int hit,int blow){
	rep(i,4) rep(j,4) if(a[i]==b[j]) {
		if(i==j) hit--;
		else     blow--;
	}
	return hit==0 && blow==0;
}

int main(){
	vector<int> cand0; // どの桁の数字も異なるような 4 桁の数
	rep(i,10000){
		char s[5]; sprintf(s,"%04d",i);
		if(!(s[0]==s[1] || s[0]==s[2] || s[0]==s[3] || s[1]==s[2] || s[1]==s[3] || s[2]==s[3]))
			cand0.push_back(i);
	}

	for(int n;scanf("%d",&n),n;){
		vector<int> in(n),hit(n),blow(n);
		rep(i,n) scanf("%d%d%d",&in[i],&hit[i],&blow[i]);

		// 入力された質問に矛盾しない数全体
		vector<int> cand;
		rep(j,cand0.size()){
			char s[5]; sprintf(s,"%04d",cand0[j]);
			bool ok=true;
			rep(i,n){
				char t[5]; sprintf(t,"%04d",in[i]);
				if(!is_valid(s,t,hit[i],blow[i])){ ok=false; break; }
			}
			if(ok) cand.push_back(cand0[j]);
		}

		if(cand.size()==1){
			printf("%04d\n",cand[0]);
			continue;
		}

		if(cand.size()>15){ // 最後の一回の発言でどうやっても特定できない ( 15 通りの返答しか得られない, 鳩ノ巣原理 )
			puts("????");
			continue;
		}

		int ans=-1;
		rep(i,cand0.size()){
			char s[5]; sprintf(s,"%04d",cand0[i]); // 最後の 1 回に発言するべき数

			bool ok=true;
			vector<int> reply(cand.size());
			rep(j,cand.size()){
				char t[5]; sprintf(t,"%04d",cand[j]);
				int hit=0,blow=0;
				rep(k,4) rep(l,4) if(s[k]==t[l]) {
					if(k==l) hit++;
					else     blow++;
				}
				reply[j]=hit*10+blow;
				rep(k,j) if(reply[k]==reply[j]) { ok=false; break; }
			}

			if(ok){ // 真の解がどれであったとしても特定できるとき
				if(ans==-1){ ans=cand0[i]; break; }
			}
		}

		if(ans!=-1) printf("%04d\n",ans);
		else        puts("????");
	}

	return 0;
}

Measured memory_bytes: 876