akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

bool is_prime[100005];
int sum[100005];

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

    for(int i = 2; i < 100000; ++i) is_prime[i] = true;
    for(int i = 2; i < 100000; ++i){
        if(!is_prime[i])    continue;
        for(int j = i + i; j <= 100000; j += i) is_prime[j] = false;
    }
    for(int i = 1; i < 100000; i += 2){
        int foo = (i + 1) / 2;
        if(is_prime[i] && is_prime[foo])    sum[i] = 1;
    }
    for(int i = 1; i < 100000; ++i) sum[i + 1] += sum[i];
    int q;
    cin >> q;
    for(int i = 0; i < q; ++i){
        int l, r;
        cin >> l >> r;
        cout << sum[r] - sum[l - 1] << "\n";
    }
}

Measured memory_bytes: 1152
#include <iostream>
#include <set>
using namespace std;
int main(void) {
	int a, b, c;
	cin >> a >> b >> c;
	set<int> st;
	st.insert(a), st.insert(b), st.insert(c);
	cout << (st.size() == 2 ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)

n,k = map(int, input().split())
h = list(map(int, input().split()))

h.sort()

l = -1; r = n # 二分探索時は探索範囲は取り得る値+-1しておく

while l+1 < r:
    c = (l+r)//2
    if h[c] < k:
        l = c
    else:
        r = c

print(n-(l+1))

Measured memory_bytes: 51440
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func main() {
	var N int
	fmt.Scan(&N)
	d := make([]int, N)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < N; i++ {
		d[i] = nextInt(sc)
	}
	ans := 0
	for i := 0; i < len(d); i++ {
		for j := i; j < len(d); j++ {
			if i != j {
				ans += d[i] * d[j]
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int x,y,z,e;
main(){
while(true){
cin >> e;
if(!e)
break;
int ans = e;
for(z=0;z*z*z<=e;z++){for(y=0;y*y+z*z*z<=e;y++){int b=e-(y*y+z*z*z);ans = min(ans,b+y+z);
}
}
cout << ans <<endl;
}
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
using ll = long long;
#define ull unsigned ll
#define endl "\n"
#define vi vector<int>
#define vl vector<ll>
#define all(v) (v).begin(),(v).end()
#define mst(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ppi pair<int, pii>
#define mt make_tuple
#define eb emplace_back
#define pcii pair<char, pair<int, int>>
using namespace std;

const ll N = 1e5, mod = 1e9 + 7;
const ll inf = 1e18 + 5;

void solve(){
    string s, t;
    cin >> s >> t;
    int n = s.length();
    int m = t.length();
    vector<vi> dp(n + 1, vi(m + 1));
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            if(s[i - 1] == t[j - 1]){
                dp[i][j] = 1 + dp[i - 1][j - 1];
            }
            else{
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }
    //cout << dp[n][m] << endl;
    int i = n, j = m;
    string ans;
    while(i > 0 && j > 0){
        if(s[i - 1] == t[j - 1]){
            ans += s[i - 1];
            i--;
            j--;
        }
        else if(dp[i - 1][j] > dp[i][j - 1]){
            i--;
        }
        else{
            j--;
        }
    }
    reverse(all(ans));
    cout << ans << endl;
}

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

    ll t,p;
    t=1;
    //cin>>t;
    for(p=1;p<=t;p++){
        solve();
    }
    return 0;
}


Measured memory_bytes: 38516
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define str string
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
int main(){
  int A,B,C,D;
  str S;
  cin>>A>>B>>C>>D;
  if(min(B,D)-max(A,C)<0)cout<<0<<endl;
  else cout<<min(B,D)-max(A,C)<<endl;
}


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

using namespace std;

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

	bool flag[3]{};

	if (a == 5) flag[0] = true;
	else if (a == 7) flag[1] = true;

	if (b == 5) {
		if (flag[0]) {
			flag[2] = true;
		}
		else {
			flag[0] = true;
		}
	}
	else if (b == 7) flag[1] = true;

	if (c == 5) {
		if (flag[0]) {
			flag[2] = true;
		}
		else {
			flag[0] = true;
		}
	}
	else if (c == 7) flag[1] = true;

	if (flag[0] == true && flag[1] == true && flag[2] == true)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

typedef pair<int, pair<int, int>> STATE;

const int INF = INT_MAX / 4;

int main(void) {
	int c, n, m, s, d;

	while (cin >> c >> n >> m >> s >> d, c) {
		s--; d--;

		VVI es(n, VI(n, INF));
		for (int i = 0; i < m; i++) {
			int a, b, f;
			cin >> a >> b >> f;
			es[a - 1][b - 1] = f;
			es[b - 1][a - 1] = f;
		}

		VVI distance(n, VI(c + 1, INF));	// node, ticket
		distance[s][c] = 0;
		priority_queue<STATE, vector<STATE>, greater<STATE>> q; // cost, node, ticket
		q.push(STATE(0, make_pair(s, c)));

		while (q.size()) {
			int cost = q.top().first;
			int node = q.top().second.first;
			int ticket = q.top().second.second;
			q.pop();

			if (cost > distance[node][ticket]) {
				continue;
			}

			for (int i = 0; i < n; i++) if (es[node][i] != INF) {
				int next_cost;

				// not use ticket
				next_cost = distance[node][ticket] + es[node][i];
				if (distance[i][ticket] > next_cost) {
					distance[i][ticket] = next_cost;
					q.push(STATE(next_cost, make_pair(i, ticket)));
				}

				// ticket - 1
				if (ticket) {
					next_cost = distance[node][ticket] + es[node][i] / 2;
					if (distance[i][ticket - 1] > next_cost) {
						distance[i][ticket - 1] = next_cost;
						q.push(STATE(next_cost, make_pair(i, ticket - 1)));
					}
				}
			}
		}

		cout << *min_element(distance[d].begin(), distance[d].end()) << endl;
	}

	return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = 10000000000;
/****** define constant end ********/

/****** define variable start ******/
ll n, k, s;
/******* define variable end *******/
ll solve(){
    cin >> n >> k >> s;
    REP(i, k){
        cout << s << " ";
    }
    for(ll i = k; i < n; i++){
        if(s == 1000000000){
            cout << s - 1 << " ";
        }
        else{
            cout << s + 1 << " ";
        }
    }
    cout << endl;
    return 0;
}
int main(){
    //clock_t start = clock();
    cout << std::fixed << std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll end_solve = solve();
    /*
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    printf("time %lf[ms]\n", time);
    */
    return (int)end_solve;
}


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

int main(){
    int a, b;
    cin >> a >> b;
    if (a < b){
        cout << "a < b" << endl;
    } else if (a > b){
        cout << "a > b" << endl;
    } else{
        cout << "a == b" << endl;
    }
    return 0;
}


Measured memory_bytes: 3108
/*
 * a.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 30;

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  int mmnt = 0;
  for (int i = 0; i < n; i++) {
    int xi, wi;
    cin >> xi >> wi;
    mmnt += xi * wi;
  }
  //printf("moment=%d\n", mmnt);

  if (mmnt == 0) puts("0");
  else {
    puts("1");
    printf("%d %d\n", (mmnt > 0) ? -1 : 1, abs(mmnt));
  }
  return 0;
}

Measured memory_bytes: 1148
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
#define pvec(vec) {for (auto v: vec) cout << v << ' '; cout << endl;}
#define pivec(vec) {rep(i, 0, vec.size()) cout << i << ':' << vec[i] << ' '; cout << endl;}

using namespace std;
using ll = long long;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<vector<int>> snuke(n, vector<int>(100, 0));
    rep(i, 0, k)
    {
        int d;
        cin >> d;
        rep(j, 0, d)
        {
            int a;
            cin >> a;
            --a;
            snuke[a][i] = 1;
        }
    }
    int res = 0;
    rep(i, 0, n)
    {
        int cnt = 0;
        rep(j, 0, 100)
            cnt += snuke[i][j];
        if (cnt == 0) ++res;
    }
    cout << res << endl;
    return 0;
}


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

using namespace std; 

int main(){ 
  string s,a;
  cin>>s;
  a="CODEFESTIVAL2016";
  int ans=0;
  for(int i=0;i<16;i++){
    if(s[i]!=a[i]){
      ans+=1;
    }
  }
  cout<<ans;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
X = list(map(int, input().split()))

k = []
# print(X)

k0 = abs(X[0])
for n in range(0+1, K):
    k0 += X[n] - X[n-1]
k.append(k0)
for i in range(1, len(X)-K+1):
    ki = k[i-1] - (X[i] - X[i-1]) + (X[i+K-1] - X[i+K-2]) - abs(X[i-1]) + abs(X[i])
    k.append(ki)
# print(min(k))

l = []
l0 = abs(X[N-1])
for n in range(N-1, N-K, -1):
    l0 += X[n] - X[n-1]
# print(l0)
l.append(l0)
for i in range(1, len(X)-K+1):
    # print(i, i-1, i+K, i+K-1)
    li = l[i-1] - (X[N-i] - X[N-i-1]) + (X[N-K-i+1] - X[N-K-i]) - abs(X[N-i]) + abs(X[N-i-1])
    # print(li)
    l.append(li)
print(min(min(k), min(l)))


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

using namespace std;

int dp[110][2][10];

int main()
{
    string s;
    cin >> s;
    int n = (int)s.size();
    int k;
    cin >> k;

    dp[0][0][0] = 1;

    for(int i = 0; i < n; ++i)
    {
        for(int j = 0; j < 2; ++j)
        {
            for(int l = 0; l <= k; ++l)
            {
                int granica = j ? 9 : (s[i]-'0');
                for(int d = 0; d <= granica; ++d)
                {
                    dp[i+1][j || d < granica][l + (d!=0)] += dp[i][j][l];
                }
            }
        }
    }

    cout << dp[n][0][k] + dp[n][1][k] << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//vector<vector<要素の型>> 変数名(要素数1, vector<要素の型>(要素数2, 初期値));
//vector<vector<要素の型>> 変数名(要素数1, vector<要素の型>(要素数2));  // 初期値を省略


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string ts="test";
	
	int n,m; cin >> n >> m;
	
	vector<int> a(m),c(n,0); vector<string> b(m); rep(i,m) cin >>a[i] >>b[i];

	rep(i,m){
		if(c[a[i]-1]<100001){ //注目番号のACが出てないなら
			if(b[i]=="AC"){
				c[a[i]-1]+=100001;
				
				//cout << i <<  ts << 1 << endl;
			}
			if(b[i]=="WA") {
				c[a[i]-1]++; //WAの数を増やす
				//cout << i <<  ts << 2 <<  endl;
			}
		}
	}
	
	
	int c1=0,c2=0;
	
	
	//rep(i,n) cout << c[i] << endl;
	
	
	///////////あとは数えるだけ
	
	rep(i,n){
		
		if(c[i]>100000){
			c1++; // ACの数
			c2+=c[i]-100001;
		}
	
	}
		
	
	
	
	cout << c1 << " " << c2 << endl;
	
	return 0;
}



Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
typedef long long l;
typedef string ss;
typedef char cc;
typedef long double dd;
int main(){
   l n,b=0,c=10000000000;
   cin>>n;
   l a[n];
   for(l i=0;i<n;i++) {cin>>a[i];
     if(b<a[i]) b=a[i];
     if(c>a[i]) c=a[i];
   }
   cout<<b-c<<endl;
   return 0;
}


Measured memory_bytes: 256
from collections import deque

h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]

def bfs():
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]
    que = deque()
    for i in range(h):
        for j in range(w):
            if a[i][j] == '#':
                que.append((i, j))
                a[i][j] = 0

    while que:
        p = que.popleft()
        for i in range(4):
            ny = p[0] + dy[i]
            nx = p[1] + dx[i]

            if 0 <= nx < w and 0 <= ny < h and a[ny][nx] == '.':
                que.append((ny,nx))
                a[ny][nx] = a[p[0]][p[1]] + 1
    ans = 0
    for i in range(h):
        ans = max(ans, *a[i])
    return ans

print(bfs())

Measured memory_bytes: 136156
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int n,d; cin >> n >> d;
  double ans = n * 1.0 / (2*d + 1);
  cout << ceil(ans) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1LL << 60;

void solve(){
    int N;
    scanf("%d", &N);
    vector<long long> A(N);
    for(int i = 0; i < N; i++)scanf("%lld", &A[i]);
    
    int Status = 0;//0...junction, 1...increase, 2...decrease
    int ans = 1;
    
    for(int i = 1; i < N; i++){
        if(Status == 0){
            if(A[i - 1] < A[i])Status = 1;
            if(A[i - 1] > A[i])Status = 2;
        }
        else if(Status == 1 && A[i - 1] > A[i]){
            ans++;
            Status = 0;
        }
        else if(Status == 2 && A[i - 1] < A[i]){
            ans++;
            Status = 0;
        }
    }
    printf("%d\n", ans);
    return;
}
   
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    solve();
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >>n;
  int identifier=0;
  int i;
  for(i=0;i<n;i++){int v;cin >>v;
                   if(v%2==0){if(v%3==0 || v%5==0) identifier=identifier; else identifier=1;}}
  if (identifier==0) cout<<"APPROVED";
  else cout<<"DENIED";}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

struct D {
    ll pit, fuel, x;
};

struct comp {
    bool operator() (const D& d1, const D& d2) {
        if(d1.pit == d2.pit) return d1.fuel < d2.fuel;
        return d1.pit > d2.pit;
    }
};

bool check(const D& d1, const D& d2) {
    if(d1.pit == d2.pit) return d1.fuel > d2.fuel;
    return d1.pit < d2.pit;
}

struct Edge{
    ll to, cost;
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
const ll inf = 1e18;
// 隣接リストのdijkstra
// s -> all の最短距離 O(ElogV)

const ll p = 1e10;
// x 回の補給を行って燃料 y を持って next に到達できるという情報を持ちながら計算
// x が小さい方が良くて, x が等しいならば y が大きい方が良い
vll dijkstra(const Graph &g, int s, ll L){
    ll N = g.size();
    vector<D> d(N, D{inf, 0, -1});
    d[s] = D{0, L, -1};
    priority_queue<D, vector<D>, comp> que;
    que.push(D{0, L, s});
    while(!que.empty()){
        D dist = que.top();
        int v = que.top().x;
        que.pop();
        if(check(d[v], dist)) continue;
        for(const auto &e: g[v]){
            if(e.cost > L) continue;
            D tmp = d[v];
            tmp.fuel -= e.cost;
            if(tmp.fuel < 0){
                tmp.fuel = L - e.cost;
                tmp.pit++;
            }
            if(check(d[e.to], tmp)) continue;
            d[e.to] = tmp;
            que.push(D{tmp.pit, tmp.fuel, e.to});
        }
    }
    vll res(N);
    REP(i, N){
        res[i] = (d[i].pit == inf) ? -1 : d[i].pit;
    }
    return res;
}

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

    ll n, m, l;
    cin >> n >> m >> l;

    Graph g(n);

    ll a, b, c;
    REP(i, m){
        cin >> a >> b >> c;
        a--;
        b--;
        g[a].push_back(Edge{b, c});
        g[b].push_back(Edge{a, c});
    }
    vvll d(n, vll(n));
    REP(i, n){
        d[i] = dijkstra(g, i, l);
    }
    ll q;
    cin >> q;
    ll s, t;
    while (q) {
        cin >> s >> t;
        s--;
        t--;
        ll res = d[s][t];
        cout << res << endl;
        q--;
    }
    return 0;
}

Measured memory_bytes: 4944
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        h_max: usize,
        w_max: usize,
        h: usize,
        w: usize,
    }
    println!("{}", (h_max - h) * (w_max - w));
}


Measured memory_bytes: 4352
#include<stdio.h>
int main(void){
   int N, K, P;
   scanf("%d", &N);
   while ( N ) {
      scanf("%d %d", &K, &P);
      if ( K % P == 0 ) printf("%d\n", P);
      else printf("%d\n", K % P);
      N--;
   }
   return 0;
}

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

public class Main {
  private static int solve(int n, int[] as) {
    Arrays.sort(as);
    return as[n - 1] - as[0];
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    int[] as = reader.nextInt(n);
    out.println(solve(n, as));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


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

typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SZ(x) (int)(x).size()
#define ZERO(a) memset(a,0,sizeof(a))
#define dbg(x) cout<<#x<<": "<<(x)<<"\n"
#define pb push_back
#define eb emplace_back
#define mp make_pair

const int mod = 1e9 + 7;
int n;
int x[114514], y[114514];

void solve() {
    vector<int> t(n), a(n);
    for(auto& i : t) scanf("%d",&i);
    for(auto& i : a) scanf("%d",&i);
    if(t.back() != a[0]) {
        puts("0");
        return ;
    }
    x[0] = x[n-1] = 1;
    FOR(i,1,n-1) {
        if(t[i-1] != t[i]) {
            x[i] = 1;
            y[i] = t[i];
        } else {
            x[i] = t[i];
            y[i] = -1;
        }
    }

    for(int i=n-2; i>=0; i--) {
        if(y[i]!=-1 and a[i] < y[i]) {
            puts("0");
            return ;
        }
        if(a[i] > a[i+1])
            x[i] = 1;
        else
            x[i] = min(x[i], a[i]);
    }

    ll ans = 1;
    rep(i,n) {
        ans = (ans * x[i]) % mod;
    }

    cout << ans << "\n";
}


int main() {
    while(cin>>n) {
        ZERO(x); ZERO(y);
        solve();
    }
    return 0;
}


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

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

Measured memory_bytes: 3636
/*---------------------------*\
____________Mari000____________         
________Mostafa  Shehab________    
\*---------------------------*/

#include <bits/stdc++.h>
using namespace std;
 
#define PI  3.14159265  // PI = acos(-1)
#define EPS (1e-10)
#define endl "\n"
typedef long long ll;
typedef long double ld;
//template <class Type>

ll power(ll x,ll y,ll p);
int Bit(ll x);
 
inline int D(){
	int t;
	scanf("%d",&t);
	return t;
}
inline ll llD(){
	ll t;
	scanf("%lld",&t);
	return t;
}

const int N=1e5 + 5;
char arr[N];

int n,m;
int i,j;

int main(){
	scanf("%s",arr);
	for(i=1,j=1;arr[i];++i)
		if(!(i&1))
			arr[j++]=arr[i];
	arr[j]='\0';
	printf("%s",arr);


	

}










ll power(ll x,ll y,ll p){ 
    ll res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or  
                // equal to p 
    while (y > 0){ 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p;
    }
    return res; 
}


int Bit(ll x){
	if(!x)
		return 0;
	return 1+Bit(x>>1);
}


















Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
long long inf = 100000000000000;

int main() {
	ll n;
	cin >> n;
	ll ans = 0;
	if (n % 2 == 1 || n <= 9) {
		cout << 0;
		return(0);
	}
	while (n) {
		ans += (n / 5) / 2;
		n /= 5;
	}
	cout << ans;
	return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
 
int main(){
  int a,b,c,x;
  cin >> a>> b >> c >> x;
  int count=0;
 rep(i,a+1){
   rep(j,b+1){
     rep(k,c+1){
      int y=500*i+100*j+50*k;
      if(y==x) count++;
     }
   }
 }
  cout << count << endl;
  
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


int main(void){
	int ans[1000],cnt=0;
	while(1){
		int n,r;
		cin>>n>>r;
		if(n==0)break;
		int p[50],c[50];
		irep(i,r)cin>>p[i]>>c[i];//?????????????????????
		int pos=0;
		rep(i,r){
			if(pos<c[i]){
				pos+=p[i]-1;
			}else if(pos<c[i]+p[i]-1){
				pos-=c[i];
			}
		}
		ans[cnt]=n-pos;
		cnt++;
	}
	rep(i,cnt)cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 2988
N = int(input().strip())
A = list(map(int,input().strip().split(' ')))
B = [0]+A+[0]
sums=0
for i in range(N+1):
    sums = sums+abs(B[i]-B[i+1])

for i in range(1,N+1):
    if min(B[i-1],B[i+1]) <= B[i] and B[i] <= max(B[i-1],B[i+1]):
        print(sums)
    else:
        print(sums-2*min(abs(B[i]-B[i-1]),abs(B[i]-B[i+1])))
    

Measured memory_bytes: 14048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
#define REP(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for(ll (i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for(ll (i) = (m); (i) < (n); (i)++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

template <uint MD> struct ModInt {
    using M = ModInt;
    const static M G;
    uint v;
    ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt<1000000007>;

const double PI = 3.14159265358979323846;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main()
{	
    string s;
	cin >> s;
    if(s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
}


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

int main()
{
	int A,B;
	cin >> A >> B;
	cout << (A-1) * (B-1) << endl;
	return 0;
}

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

int main()
{
	string s;
	cin >> s;
	int a = -1;
	int z = -1;
	for (int i = 0; i < s.size(); i++) {
		if (a == -1 && s.at(i) == 'A') a = i;
		if (s.at(i) == 'Z') z = i;
	}
	cout << z - a + 1 << endl;
}

Measured memory_bytes: 640
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#define forn(i, n) for (long long i = 0; i < (long long) (n); ++i)
#define pb emplace_back
#define endl '\n'

template<typename T> void _dbg(const char*_s,T _h) { cerr<<_s<<" = "<<_h<<"\n"; }

template<typename T, typename... Ts> void _dbg(const char*_s,T _h,Ts... _t) {
    for(int _b=0;((_b+=*_s=='(')-=*_s==')')!=0||*_s!=',';)cerr<<*_s++;
    cerr<<" = "<<_h<<",";_dbg(_s+1,_t...);
}

#define int long long

#ifdef LOCAL
    #define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
    #define dbg(...)
#endif

const int N = 2 * 1000 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int k;
string s;
int F[N];

bool read() {
    if (!(cin >> k >> s))
        return false;

    return true;
}

int bpow(int a, int n, int mod = MOD) {
    int res = 1;

    for (; n > 0; n /= 2, (a *= a) %= mod)
        if (n & 1)
            (res *= a) %= mod;

    return res;
}

int rev(int x) {
    return bpow(x, MOD - 2, MOD);
}

int binomial(int n, int k) {
    return k < 0 || n - k < 0 ? 0 : F[n] * rev(F[k] * F[n - k] % MOD) % MOD;
}

void solve(int id = 0) {
    F[0] = 1;

    forn (i, N - 1)
        F[i + 1] = F[i] * (i + 1) % MOD;

    int res = 0;
    int n = s.size();

    for (int i = 0; i <= k; ++i)
        (res += bpow(26, i) * bpow(25, k - i) % MOD * binomial(k - i + n - 1, n - 1) % MOD) %= MOD;

    cout << res << endl;
}

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

    int T;
    //cin >> T;
    T = 1;

    while (read())
        solve(T++);

    return 0;
}


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

#define F first
#define FF first.first
#define FS first.second
#define S second
#define SF second.first
#define SS second.second
#define ii pair<int,int>
#define iii pair<ii, int>
#define iiii pair<ii, ii>
#define viiii vector< iiii >
#define viii vector< iii >
#define vii vector< ii >
#define vi vector< int >
#define vvi vector<vector< int > >
#define int long long

#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define pb push_back
#define FOR(v, i, l) for(int v = i; v < (int)l; ++v)
#define REP(v, l) FOR(v, 0, l)

#define EPS 1e-6
#define oo (1LL<<60)
#define MAX 1000000000000000000LL
#define MOD 1000000007LL
#define debug(x) cout << #x << " is " << x << "\n";

const int dx[8] = {1, 1, -1, -1, 2, 2, -2, -2};
const int dy[8] = {2, -2, 2, -2, 1, -1, 1, -2};

int PAsum(int in, int fi, int s){
   if(fi<in)return 0;
   return ((in+fi)*(1+(fi-in)/s))/2LL;
}

int modPow(int x, int y, int mod = MOD){
   int ans = 1;
   while( y ){
      if(y%2){
         ans = (ans*x)%mod;
      }
      x = (x*x)%mod;
      y /= 2;
   }
   return ans;
}

int countBit(int x){
   int ans  = 0;
   while(x){
      ans += (x%1);
      x /= 2;
   }
   return ans;
}

int N, M, K, L, R, J, P, CASES;
int A,B,C,D;

main(){
   int ans = 0;
   for(int i = 1; i <= 5; i++){
      scanf("%lld", &N);
      if(!N)ans = i;
   }
   printf("%lld\n", ans);
}

/*

*/


Measured memory_bytes: 3760
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

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

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

//-----------------------ここから-----------


int main(void){
	ld a, b;
	cin >> a >> b;
	cout << ceil((a + b) / 2) << endl;
}

Measured memory_bytes: 256
n, y = map(int, input().split())

for a in range(n + 1):
   for b in range(n - a + 1):
           if a * 10000 + b * 5000 + (n - a - b) * 1000 == y:
               print(a, b, n - a - b)
               exit()

print("-1 -1 -1")    

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

int main()
{
	vector<int> nums(3);
	int k;
	cin >> nums[0] >> nums[1] >> nums[2] >> k;
	sort(nums.begin(), nums.end());
	for(int i = 0; i < k; i++)
		nums[2] = nums[2] * 2;
	cout << nums[0] + nums[1] + nums[2] << "\n";
	

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define FORR(i, m, n) for (ll i = m; i >= n; i--)
#define REPO(i, n) for (ll i = 1; i <= n; i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(), n.end()
#define MOD 1000000007
#define P pair<ll, ll>


int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    cout << b / c - (a - 1) / c << endl;
}

Measured memory_bytes: 3580
N = int(input())
a = [int(i) for i in input().split()]
l = [{a[0]:1}]
ans = 0
for i in a[1:]:
    k = l[-1]
    if k.get(i):
        k[i] += 1
        a[-1] = k
    else:
        k = {i:1}
        l.append(k)
for d in l:
    for i in d.values():
        ans += i // 2
print(ans)

Measured memory_bytes: 3064
list1 = list(map(int, input().split()))
if list1[3] <= list1[0]:
    print(list1[3])
else:
    a = list1[3] - list1[0]
    if a <= list1[1]:
        print(list1[0])
    else:
        b = a - list1[1]
        c = (-1)*b + list1[0]
        print(c)

Measured memory_bytes: 9048
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

int N;

bool check(int n)
{
    int m = n % 10;
    while (n > 0)
    {
        if (n % 10 != m)
        {
            return false;
        }
        n /= 10;
    }
    return true;
}

int main()
{
    cin >> N;
    for (int i = N; i <= 2000; i++)
    {
        if (check(i))
        {
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <utility>
#include <vector>
#include <set>

using namespace std;

int n;
int a[222222];
int b[222222];
const int N = 222222;

int main(void) {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", a+i);
    b[a[i]] = i;
  }

  long long res = 0;
  set<int> p, q;
  for (int i = 1; i <= n; i++) {
    long long rb, lb;
    auto rit = p.lower_bound(b[i]);
    // printf("%d: %d\n", i, b[i]);
    if (rit == p.end() ||
        *rit < b[i]) {
      rb = n;
    } else {
      rb = *rit;
    }
    auto lit = q.lower_bound(-b[i]);
    if (lit == q.end() ||
        -*lit > b[i]) {
      lb = 0;
    } else {
      lb = -*lit+1;
    }
    // printf("%d %d\n", lb, rb);
    long long v = rb-lb;
    // res += i * v*(v+1)/2;
    res += i*(v+1-(b[i]-lb+1))*(b[i]-lb+1);
    /*
    printf("%lld\n", v);
    printf("l:%lld\n", b[i]-lb+1);
    */
    p.insert(b[i]);
    q.insert(-b[i]);
  }
  
  printf("%lld\n", res);
  return 0;
}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
#define reps(i,n) for(ll i=1;i<=(n);++i)
#define out(a) cout<<(a)<<endl;
using ll = long long;
using str = string;
constexpr long long INF = (1LL<<60);
constexpr long long MOD = (1e9+7);
constexpr long long LMAX = LLONG_MAX;
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
inline void dump(){cout<<endl;}
template<class Head,class... Tail>inline void dump(Head&& head, Tail&&... tail){cout<<head<<", ";dump(forward<Tail>(tail)...);} // output
template<typename T>inline istream &operator>>(istream&input,vector<T>&v){for(auto &elemnt:v)input>>elemnt;return input;} // input,vector<>

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(10);
  
  ll h,w;
  cin>>h>>w;
  vector<str> s(h);
  cin>>s;

  constexpr ll dx[]={1,0,-1,0};
  constexpr ll dy[]={0,1,0,-1};
  vector<vector<bool>> visited (h,vector<bool>(w,false));
  using pos = struct position{ll y,x;position(ll y,ll x):y(y),x(x){}};
  queue<pos> que;
  ll ans=0;
  rep(i,h){
    rep(j,w){
      if(visited[i][j])continue;
      que.emplace(i,j);
      ll white=0,black=0;
      while(!que.empty()){
        auto now = que.front();
        que.pop();
        if(visited[now.y][now.x])continue;
        visited[now.y][now.x]=true;
        (s[now.y][now.x]=='#'?black:white)++;
        visited[now.y][now.x]=true;
        rep(k,4){
          ll ny=now.y+dy[k],nx=now.x+dx[k];
          if(ny==-1||ny==h||nx==-1||nx==w)continue;
          if(visited[ny][nx])continue;
          if(s[now.y][now.x]!=s[ny][nx]){
            que.emplace(ny,nx);
          }
        }
      }
      ans+=black*white;
    }
  }
  cout<<(ans)<<endl;
  
  
  
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<cctype>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long INF = 1LL << 60;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	char n,a,b;
	int nd,ad,bd;
	scanf("%c %c %c",&n,&a,&b);
	ad=a-'0';
	bd=b-'0';
	nd=n-'0';
	cout<<nd+ad+bd<<endl;
	
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]

answer = 0
for i in range(N):
  limit = B[i]
  if limit > A[i]:
    answer += A[i]
    limit -= A[i]
    A[i] = 0
  else:
    A[i] -= limit
    answer += limit
    limit = 0
    
  if limit == 0:
    continue

  if limit > A[i+1]:
    answer += A[i+1]
    limit -= A[i+1]
    A[i+1] = 0
  else:
    A[i+1] -= limit
    answer += limit
    limit = 0

print(answer)
    

Measured memory_bytes: 18624
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;


int main() {
int A,P;
cin>>A>>P;
P+=A*3;
cout<<P/2<<endl;
return 0;
}

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

int main() {
	int x1, x2, x3, x4, x5;
	cin >> x1 >> x2 >> x3 >> x4 >> x5;

	if(x1 == 0)
		cout << 1 << endl;
	else if(x2 == 0)
		cout << 2 << endl;
	else if(x3 == 0)
		cout << 3 << endl;
	else if(x4 == 0)
		cout << 4 << endl;
	else if(x5 == 0)
		cout << 5 << endl;

	return 0;
}

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

int main() {
  int n;
  double t, a;
  cin >> n >> t >> a;
  double sa = 1e6;
  int ans = 0;
  rep(i, n) {
    double h;
    cin >> h;
    double x = t - (h*0.006);
    if(abs(a - x) < sa) {
      sa = abs(a - x);
      ans = i + 1;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3760
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

// disjoin set
public class Main {
    static class UnionFindTree {

        private int parent[];
        private int rank[];
        private int weight[];

        public UnionFindTree(int Num_element) {
            parent = new int[Num_element];
            rank = new int[Num_element];
            weight = new int[Num_element];
            for (int i = 0; i < Num_element; i++)
                makeSet(i);
        }

        public void makeSet(int x) {
            parent[x] = x;
            rank[x] = 0;
            weight[x] = 0;
        }

        public void union(int x, int y, int cost) {
            link(findSet(x), findSet(y), cost - weight[x] + weight[y]);
        }

        public int findSet(int x) {
            if (x != parent[x]) {
                int tmp = findSet(parent[x]);;
                weight[x] += weight[parent[x]];
                parent[x] = tmp;
            }
            return parent[x];
        }
        public boolean same(int x,int y){
            return findSet(x) == findSet(y);
        }

        public void link(int x, int y, int cost) {
            if (rank[x] > rank[y]) {
                parent[y] = x;
                weight[y] -= cost;
            } else {
                parent[x] = y;
                weight[x] += cost;
                if (rank[x] == rank[y]) {
                    rank[y]++;
                }
            }
        }

        public int sum(int x) {
            int sum = 0;
            int now = x;
            while ((now != parent[now])) {
                sum += weight[now];
                now = parent[now];
            }
            return sum;
        }

    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // Disjoin set element number
        int Num_element;

        //Query times
        int Num_query;


        Num_element = sc.nextInt();
        Num_query = sc.nextInt();
        UnionFindTree Disjoin_set = new UnionFindTree(Num_element);
        for (int i = 0; i < Num_query; i++) {
            // '0' denotes unite and '1' denotes same operation.
            int com = sc.nextInt();
            int x = sc.nextInt();
            int y = sc.nextInt();
            if (com == 0) {
                int z = sc.nextInt();
                Disjoin_set.union(x, y, z);
            } else {
                if(!Disjoin_set.same(x,y)){
                    System.out.println("?");
                }else
                    System.out.println(Disjoin_set.sum(x) - Disjoin_set.sum(y));
            }
        }

    }
}


Measured memory_bytes: 176268
def main():
  import math
  N = int(input())
  gcd={}
  ans=0
  for i in range(1,N+1):
    for j in range(1, N+1):
      key=i*N+j
      gcd[key]=math.gcd(i,j)
  
  for k, i in gcd.items():
    for j in range(1, N+1):
      key=j*N+i
      ans+=gcd[key]
        
  print(ans)
 
if __name__=='__main__':
  main()

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

int main() {
  int n,ans = 0;
  cin >> n;
  vector<int>a(n);
  rep(i,0,n) cin >> a[i];
  sort(a.begin(),a.end());
  int back = a[n-1];
  vector<bool>banned(back+1,false);
  vector<bool>data(back,true);
  rep(i,0,n-1) if(a[i] == a[i+1]) banned[a[i]] = true;
  rep(i,0,n){
    if(data[a[i]]){
      if(!banned[a[i]]) ans++;
      for(int j = a[i];j <= back;j += a[i]){
        data[j] = false;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4300
n,m = map(int,input().split())
list = [list(map(int,input().split())) for i in range(m)]

num = [1]*n
red = [0]*n
red[0] = 1

for i in range(m):
    x = list[i][0]-1
    y = list[i][1]-1
    if red[x] == 1:
        if num[x] == 1:
            red[x] = 0
        red[y] = 1
    num[x] -= 1
    num[y] += 1

print(sum(red))    

Measured memory_bytes: 28836