akhauriyash/Code-Regression huggingface dataset:
//verma_ankit484

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

typedef long long ll;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
const ll mod = (ll) 1e9+7;

using namespace std;
//using namespace __gnu_pbds;

//#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>

//This is the template for sum of a range and updating a particular range using lazy propagation
//Remember to keep size of seg tree array and lazy prop array as 4*n+1
//If you just want to do range query then just remove lazypush implementation

vector<ll> arr, seg, lazy;

void init(ll v, ll l , ll r)
{
  if (l == r)
  {
    seg[v] = arr[l];
    lazy[v] = 0;
    return;
  }
  ll mid = (l+r)/2;
  init(2*v,l , mid);
  init(2*v+1, mid+1, r);
  seg[v] = seg[2*v]+seg[2*v+1];
}

void lazypush(ll v, ll l, ll r)
{
  if (lazy[v] != 0)
  {
    seg[v] += (r-l+1)*lazy[v];//because sum fill be reflected at every child
    if (l != r)
    {
      lazy[2*v] += lazy[v];
      lazy[2*v+1] += lazy[v];
    }
    lazy[v] = 0;
  }
}

ll query(ll v, ll l, ll r, ll s, ll e)
{
  lazypush(v, s, e);
  if(l>r||s>e||r<s||l>e)
    return 0;      //if not in range we returned 0 so that it doesn't make any change
  if (s >= l && e <= r)
    return seg[v];
  ll mid = (s+e)/2;
  return query(2*v, l, r, s, mid)+query(2*v+1, l ,r, mid+1, e);
}

void update(ll v, ll l, ll r, ll s, ll e, ll val)
{
  lazypush(v,s,e);
  if(l>r||s>e||r<s||l>e)
    return;
  if (s >= l && e <= r)
  {
    seg[v] += (e-s+1)*val;
    if (s != e)
    {
      lazy[2*v] += val;
      lazy[2*v+1] += val;
    }
    return;
  }
  ll mid = (s+e)/2;
  update(2*v, l , r, s, mid, val);
  update(2*v+1, l ,r, mid+1, e, val);
  seg[v] = seg[2*v]+seg[2*v+1];
}


int main() {
  IOS
  #ifdef AV
  freopen("input.txt", "r", stdin);
  #endif
  ll n, d, a;
  cin >> n >> d >> a;
  vector<pair<ll, ll>> vc(n);
  for (ll i = 0; i < n; i++) {
    cin >> vc[i].first >> vc[i].second;
  }
  arr.resize(n);
  seg.resize(4*n+1);
  lazy.resize(4*n+1);
  map<ll, ll> mp;
  vector<ll> varr(n);
  sort(vc.begin(), vc.end());
  for (ll i = 0; i < n; i++) {
    mp[vc[i].first] = i;
  }
  for (ll i = 0; i < n; i++) {
    arr[i] = vc[i].second;
    varr[i] = vc[i].first;
  }
  init(1, 0, n-1);
  ll ans = 0;
  for (ll i = 0; i < n; i++) {
    ll val = query(1, i, i, 0, n-1);
    if (val <= 0) continue;
    ll l, r;
    l = i;
    r = upper_bound(varr.begin(), varr.end(), vc[i].first + 2*d) - varr.begin();
    r--;
    ll p = ceil((double)val / (double)a);
    update(1, l, r, 0, n-1, -(p*a));
    ans += p;
    // cout << varr[i] << ' ';
    // cout << vc[i].first + 2*a << ' ' << r << endl;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 31488
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
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; }
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define DEBUG(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(int argc, const char * argv[]) {
  std::cout << std::fixed << std::setprecision(15);

  int N; cin >> N;
  vector<int> v;
  int dp[MAX];
  fill(dp, dp+MAX, INTINF);
  v.push_back(1);
  rep(i, 10){
    // DEBUG(pow(6, i+1));
    // DEBUG(pow(9, i+1));
    if(pow(6, i+1) < INTINF)
    v.push_back(pow(6, i+1));
    if(pow(9, i+1) < INTINF)
    v.push_back(pow(9, i+1));
  }
  sort(ALL(v));

  dp[0] = 0;
  rep(j, v.size()){
    rep(i, MAX){
      // DEBUG(i + v[j]);
      if(i+v[j] < MAX)
        chmin(dp[i+v[j]], dp[i] + 1);
    }
  }

  cout << dp[N] << endl;
}  


Measured memory_bytes: 640
#include <iostream>
#include <string>
using namespace std;
 
int main()
{
    double v;
    while(cin >> v){
        double t = v / 9.8;
        double y = 4.9 * t * t;
        int n = 1;
        while(true){
        if (5 * n - 5 >= y){
            cout << n << endl;
            break;
        } else {
            n++;
        }
        }
    }
 
    return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define initdp(a, b)  for (int i = 0; i <= a; i++)   for (int j = 0; j <= b; j++) dp[i][j] = -1;
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define ll long long
#define pll pair<ll, ll>
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repd(i, n) for (int i = n - 1; i >= 0; i--)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 1000005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define endl "\n"
using namespace std;

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

 
 
void solve(){
 
    long double a,b,n;
    cin>>a>>b>>n;

    long double temp = b-1;

    if( b-1 > n) {
        temp = n;
    }

    long double ans = (a *  temp) / b;

    cout<<(ll)floor(ans)<<endl;

    // ll x = b/g;

    // long double p = (a * x) / b;

    // long double q =  x/b;

    // ll ans = floor(p) - a * floor(q);

    // cout<<ans<<endl;



}
 
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(20);
    int t = 1;
   //  cin >> t;
    while (t--)
    {
        solve();
    }
}

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

int main() {
  int A, B, sum = 0;
  cin >> A >> B;
  
  for (int i = 0; i < B - A + 1; i++) {
    int x_all = A + i;
    int x_1 = x_all / 10000;
    int x_2 = x_all / 1000 % 10;
    int x_4 = x_all % 100 / 10;
    int x_5 = x_all % 10;
    
    if (x_1 == x_5 && x_2 == x_4)
      sum ++;
  }
  cout << sum << endl;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using pll=pair<ll,ll>;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i,l,r) for(ll i = (l); i <= (ll)(r); i++)
#define rep3(i,l,r) for(ll i = (l); i >= (ll)(r); i--)
#define dup(x,y) (((x)+(y)-1)/(y)) //a/bの除算の切り上げ
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 = 1001001001;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const ld pi = acos(-1);
 
// union by size + path having
class UnionFind {
public:
   vector <ll> par; // 各元の親を表す配列
   vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)
 
   // Constructor
   UnionFind(ll sz_): par(sz_),siz(sz_, 1LL){
       for (ll i=0; i<sz_; i++) par[i]=i; // 初期では親は自分自身
   }
   void init(ll sz_){
       par.resize(sz_);
       siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
       for (ll i=0; i<sz_; i++) par[i]=i; // 初期では親は自分自身
  }
 
   // Member Function
   // Find
   ll root(ll x){ // 根の検索
      while (par[x]!=x){
           x=par[x]=par[par[x]]; // x の親の親を x の親とする
       }
       return x;
  }
 
   // Union(Unite, Merge)
   bool unite(ll x, ll y){
       x=root(x);
       y=root(y);
       if (x==y) return false;
       // merge technique（データ構造をマージするテク．小を大にくっつける)
       if (siz[x]<siz[y]) swap(x, y);
       siz[x]+=siz[y];
       par[y]=x;
       return true;
  }
 
  bool same(ll x, ll y){ // 連結判定
       return root(x)==root(y);
  }
 
  ll size(ll x){ // 素集合のサイズ
      return siz[root(x)];
  }
};
 
ll modpow(ll x, ll n){
   x=x%mod;
   if(n==0) return 1;  //再帰の終了条件
 
   else if(n%2==1){
       return (x*modpow(x, n-1))%mod;  //nが奇数ならnを1ずらす
   }
   else return modpow((x*x)%mod, n/2)%mod;  //nが偶数ならnが半分になる
}
 
ll com(ll n, ll k){
   ll x=1;
   for(int i=n-k+1; i<=n; i++){
      x=x*i%mod;
   }
 
   ll y=1;
   for(int i=1; i<=k; i++){
       y=y*i%mod;
   }
   y=modpow(y, mod-2);
 
   return x*y%mod;
}
 
bool is_prime(const unsigned n){
   switch(n){
       case 0: // fall-through
       case 1: return false;
       case 2: // fall-through
       case 3: return true;
  } // n>3 が保証された
 
   if(n%2==0 || n%3==0) return false;
   // nは2と3のいずれの倍数でもないことが保証された
   // これよりnは(6の倍数)-1か(6の倍数)+1である
 
   // 6の倍数前後の数を使って試し割りをする
   for(unsigned i = 5; i*i<=n; i+=6) {
       if(n%i==0) return false; // (6の倍数)-1
       if(n%(i+2)==0) return false; // (6の倍数)+1
   }
 
   return true;
}
 
int digsum(int n){
   int res=0;
   while(n > 0) {
       res+=n%10; //ここをres++;に変えたら桁数を求める関数になる,res+=n%10;なら格桁の和
       n/=10;
   }
   return res;
}
vector<ll> divisor(ll n){
   vector<ll> ret;
   for(ll i=1; i*i<=n; i++){
       if(n%i==0){
           ret.push_back(i);
           if(i*i!=n) ret.push_back(n/i);
       }
   }
   sort(ret.begin(),ret.end());
   return ret;
}
 
int main(){

    ll n,k,ans=0;
    cin >> n >> k;
    vector<ll> data(n);
    rep(i,n){
        cin >> data[i];
    }
    sort(all(data));
    rep(i,k){
        ans+=data[i];

    }
    cout << ans << endl;


 
}

Measured memory_bytes: 3600
n=int(input())
itv=[]
for _ in range(n):
    x,l=map(int,input().split())
    itv.append((x+l,x-l))
itv.sort()
ass = 0
tt = -float("inf")
for i in range(n):
    if tt <= itv[i][1]:
        ass += 1
        tt = itv[i][0]
print(ass)

Measured memory_bytes: 53392
#include<bits/stdc++.h>
using namespace std;
bool check(vector<int> a, vector<int> b){
	int res = 0;
	int n = a.size();
	for(int i =0; i < n; i++){
		res += (a[i] - b[i]) * (a[i] - b[i]);
	}
	return pow((trunc(sqrt(res))), 2) == res;
}
int32_t main() {
	int ans = 0, n, d; cin>>n>>d;
	vector<vector<int>> a(n);
	for(int i = 0; i < n; i++){
		for(int j = 0; j < d; j++){
			int x; cin>>x;
			a[i].push_back(x);
		}
	}
	for(int i = 0; i < n - 1; i++){
		for(int j = i + 1; j < n; j++){
			if(check(a[i], a[j])){
				ans++;
			}
		}
	}
	cout<<ans<<endl;
}


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

int main() {
  int A,B,M;
  cin>>A>>B>>M;
  vector<int>a(A);
  vector<int>b(B);
  for(int i=0;i<A;i++) cin>>a[i];
  for(int i=0;i<B;i++) cin>>b[i];
  vector<vector<int>>data(M,vector<int>(3));
  for(int i=0;i<M;i++) cin>>data[i][0]>>data[i][1]>>data[i][2];
  int ans=a[0]+b[0];
  for(int i=0;i<M;i++){
    int x=a[data[i][0]-1]+b[data[i][1]-1]-data[i][2];
      ans=min(ans,x);
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  ans=min(ans,a[0]+b[0]);
  cout<<ans<<endl;
}

Measured memory_bytes: 6528
#include <iostream>
using namespace std;
int main(void){
	string s;
	while(cin>>s,s!="0"){
		for(int i=0;i<3;++i){
			if(i)cin>>s;
			int a=0,b=0;
			for(int j=1;j<s.size();++j){
				if(s[j]=='A') ++a;else ++b;
			}
			if(a>b) ++a;else ++b;
			cout<<a<<" "<<b<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1184
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 998244353 /*1e9 + 7*/ ;

#define REP(i, n) for(ll i = 0; i < n; i++)



int main() {
    string s;
    cin >> s;
    ll n = s.size();
    
    vector<vector<ll>> dp(2 * n + 1, vector<ll>(2 * n + 1));
    ll r = 0;
    dp[0][0] = 1;
    for(ll i = 0; i < 2 * n; i++){
        if(i < n){
            r += 2 - (s[i] - '0');
        }
        for(ll j = 0; j <= min(i, r); j++){
            if(j < r){
                dp[i + 1][j + 1] += dp[i][j];
                dp[i + 1][j + 1] %= MOD;
            }
            if(i - j < min(i + 1, n) * 2 - r){
                dp[i + 1][j] += dp[i][j];
                dp[i + 1][j] %= MOD;
            }
            
        }
    }
    cout << dp[2 * n][r] << endl;
}

Measured memory_bytes: 125440
#Postal Code
a,b=parse.(Int,split(readline()))
c=a+1
d=c+b
s = readline()
x = zeros(Int64,(1,d))
Ans=zeros(Int64,(1,d))
check=zeros(Int64,(1,d))
if s[c] == '-' 
    str = "Yes"
else 
    str="No"
end
for i=1:d
    if i != c && s[i] != '-' 
    x[i]=parse.(Int,string(s[i]))
    [(i != c && typeof(x[i])==Int64) ? Ans[i]=0 : Ans[i]=1] 
    Ans[c] = 0
    elseif i!=c && s[i] =='-' 
    Ans[d]=1
    break
    end
end
if str=="Yes" && Ans == check
    println("Yes")
else
    println("No")
end

Measured memory_bytes: 175368
#include <bits/stdc++.h>      
#define pb push_back 
#define fr first 
#define sc second
#define MOD 1000000007
#define len(s) s.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define f(i,a,n) for(int i=a;i<n;i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef map<int,int> mii; 

int main() {

    /* #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif */
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;

    //int t; cin>>t; while(t--) { 
	int n; cin>>n;
	vi dp(3,0);
	
	f(days,0,n) {
		vi c(3);
		vi new_dp(3,0);
		f(i,0,3) cin>>c[i];
		//f(i,0,3) cout<<dp[0]<<" "<<dp[1]<<" "<<dp[2]<<endl;
		f(i,0,3) {
			f(j,0,3) {
				if(i!=j) new_dp[j]=max(new_dp[j],dp[i]+c[j]);
			}	
		}
		dp=new_dp;
	}
	cout<<max3(dp[0],dp[1],dp[2]);
    return 0;
} 	

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
X = int(input())
if X >= 30:
    print("Yes")
else:
    print("No")

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

int main() {
    string s;
    cin>>s;
    int minv=1000000005;
    size_t l=s.length();
    rep(i,l-2){
        string ss=s.substr(i,3);
        int num=stoi(ss);
        minv=min(minv,abs(num-753));
    }
    cout<<minv<<"\n";
    return 0;
}

Measured memory_bytes: 3568
N, X = map(int, input().split())
A = list(map(int, input().split()))

B = []
for i in range(N):
    b = abs(A[i] - X)
    B.append(b)

#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

B.sort()

ans = B[0]
for i in range(1, N):
    ans = gcd(ans, B[i])

print(ans)

Measured memory_bytes: 14224
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 100005;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(3*n);
    cins(all(a));
    RSORT(a);
    ll cnt = 0;
    rep(i,n){
        cnt += a[i*2+1];
    }
    PRINT(cnt);
}


Measured memory_bytes: 2560
N, K = map(int, input().split())
A = list(map(int, input().split()))
import collections
C = collections.Counter(A)
D = sorted(C.items(), key=lambda x: x[1])
B = len(set(A)) -K
result = 0
for a in range(B):
    result += D[a][1]

print(result)

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	string o,e;
	cin>>o>>e;
	for(int i=0,j=0,k=0;i<o.size()+e.size();++i){
		if((i+1)%2==1)cout<<o.at(j),++j;
		else cout<<e.at(k),++k;
	}
	cout<<"\n"s;
}

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

int main() {
    ll N,sum = 0;
    cin >> N;
    vector<ll> V(N);
    for(int i=0; i<N; i++) {
        cin >> V[i];
        sum += V[i];
    }
    ll min_div = INF;
    ll X=0, Y=sum;
    for(int i=0; i<N-1; i++) {
        X += V[i];
        Y -= V[i];
        min_div = min(min_div, (ll)abs(X-Y));
    }
    cout << min_div << endl;

}

Measured memory_bytes: 4776
a = int(input())
b = int(input())
c = int(input())
d = int(input())
ans = 0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if d == 500*i + 100*j + 50*k:
        ans += 1
print(ans)

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

int main() {
    int H, W, h, w;
    cin >> H >> W >> h >> w;

    cout << (H * W - ((h * W) + (H * w) - (h * w))) << 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,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;

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

    while(1) {
        int n; cin >> n;
        if (n==0) break;

        vector<int> vec(n);
        rep(i, n) cin >> vec[i];

        int ans = accumulate(all(vec), 0);
        sort(all(vec));
        ans -= vec.front();
        ans -= vec.back();

        ans /= n-2;
        cout << ans << endl;
    }
}


Measured memory_bytes: 3108
#-*- coding: utf-8 -*-
"""
https://yahoo-procon2019-qual.contest.atcoder.jp/tasks/yahoo_procon2019_qual_a
"""


def sol(a, b):
    if b % a == 0: return a+b
    else: return b-a


test = False
#test = True
if test:
    n, k = 4, 12
    #S =list( map(int, "1 6 3".split()))
    print(sol(n, k))

    n, k = 8, 20
    #S =list( map(int, "7 4 0 3".split()))
    print(sol(n, k))
    #
    n, k = 31, 10
    #S =list( map(int, "1000000000000".split()))
    print(sol(n, k))

    n, k = 10, 90
    #S =list( map(int, "1000000000000".split()))
    print(sol(n, k))

else:
    a, b = map(int, input().split())
    #S =list( map(int, input().split()))
    print(sol(a, b))




Measured memory_bytes: 3064
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif

struct Stuple {
    int s; int t; int c;
    using type = tuple<int, int, int>;
    Stuple(int s, int t, int c): s(s), t(t), c(c){ }
    operator tuple<int, int, int> () const { return make_tuple(s, t, c); }
    // bool operator < (const Stuple& e) const { return type(*this) < type(e); }
    // ostream& operator >> (ostream& out) const { prints(type(*this)); return out; }
    bool operator < (const Stuple& e) const { return tie(s, t, c) < tie(e.s, e.t, e.c); }
    ostream& operator >> (ostream& out) const { prints(tie(s, t, c)); return out; }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, c;
    cin >> n >> c;
    // set<tuple<int, int, int>> stcs;
    set<Stuple> stcs;
    for(int i = 0; i < n; i++){
        int s, t, c;
        cin >> s >> t >> c;
        stcs.emplace(s, t, c);
    }
    int ans = 0;
    prints(stcs);
    while(stcs.size()){
        ans++;
        auto next = stcs;
        int time = -1, channel = -1;
        for(auto& stc : stcs){
            // if(time + (channel != get<2>(stc)) <= get<0>(stc)){
            //     time = get<1>(stc);
            //     channel = get<2>(stc);
            //     next.erase(stc);
            // }
            // get<0>(stc.data) = 1;
            // decltype(auto) a = get<0>(stc.data);
            // a = 1;
            // stc.t = 1;
            if(time + (channel != stc.c) <= stc.s){
                time = stc.t;
                channel = stc.c;
                next.erase(stc);
            }
        }
        next.swap(stcs);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 9728
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
string a;
int main()
{
    long long N,ans=0,i;
    map<string,long long> mp;
    cin>>N;
    for( i=0;i<N;i++)
    {
        cin>>a;
        sort(a.begin(),a.end());
        ans+=mp[a];
        mp[a]++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 11136
let solve () =
    let a, b = Scanf.scanf "%d %d" (fun a b -> a, b)
    in (float_of_int a +. float_of_int b) /. 2.0 +. 0.999999999
    |> int_of_float
    |> print_int
    |> print_newline

let _ = solve ()

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX
typedef pair<long long, long long> P;
int main(){
    long long n;
    cin>>n;
    vector<string> w(n);
    rep(i,n){
        cin>>w[i];
    }
    set<string> p;
    p.insert(w[0]);
    char g=w[0][w[0].size()-1];
    rep11(i,n){
        if(g!=w[i][0]){
            cout<<"No"<<endl;
            return 0;
        }
        g=w[i][w[i].size()-1];
        if(p.find(w[i])!=p.end()){
            cout<<"No"<<endl;
            return 0;
        }
        p.insert(w[i]);
    }
    cout<<"Yes"<<endl;
    return 0;
}

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

using namespace std;

int main() {
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  long long x;
  cin >> x;
  long long now = 100;
  int ans = 0;
  while (now < x) {
    now = now + now / 100;
    ans++;
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1000000007;

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------

int main(void) {
  int d;
  cin >> d;
  arrll(c,26);
  vecll2(s, d, 26);
  rep(i,d){
    rep(j,26){
      cin >> s[i][j];
    }
  }

  srand(time(NULL));

  vecll human(26);
  vecll last(26);

  vecll ans;

  rep(i,d){
    ans.pb(rand()%26+1);
  }

  rep(i,d){
    prt(ans[i]);
  }
}


Measured memory_bytes: 3740
#include "math.h"
#include "stdio.h"
#include <algorithm>
#include <string>
#include <map>
#include <iostream>

using namespace std;

/** Problem0035 : It is Convex? **/
double calcS(double x1, double y1, double x2, double y2, double x3, double y3)
{
	double S, s, ab, bc, ca;
	ab = sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
	bc = sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));
	ca = sqrt((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1));
	s = 0.5*(ab+bc+ca);
	S=sqrt(s*(s-ab)*(s-bc)*(s-ca));
	return S;
}

int main()
{
	double x1, y1, x2, y2, x3, y3, x4, y4;
	char c;
	
	while (1) {
		cin >> x1 >> c >> y1 >> c >> x2 >> c >> y2 >> c >> x3 >> c >> y3 >> c >> x4 >> c >> y4;
		if (cin.eof()) break;
		
		if (fabs((calcS(x1,y1,x2,y2,x3,y3)+calcS(x1,y1,x4,y4,x3,y3)) - (calcS(x2,y2,x3,y3,x4,y4)+calcS(x2,y2,x1,y1,x4,y4))) <= 0.01)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}

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

using namespace std;

int main() {
  int x[6];
  for (int i = 0; i < 5; i++) {
    cin >> x[i];
  }
  for (int i = 0; i < 5; i++) {
    if (x[i] == 0) {
      cout << i + 1 << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"
using namespace std;
int main()
{
    int n, mx;
    scanf("%d", &n);
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
    {
        scanf("%d", &a[i]);
    }
    sort(a.begin(), a.end());
    mx = a[n - 1];
    a.pop_back();
    auto md = lower_bound(a.begin(), a.end(), a[n - 1] / 2);
    if (mx - *md <= *(md - 1) || md == a.end())
    {
        printf("%d %d\n", a[n - 1], *(md - 1));
    }
    else
    {
        printf("%d %d\n", a[n - 1], *md);
    }
}



Measured memory_bytes: 640
N, M = gets.split(' ').map(&:to_i)
MOD = 10 ** 9 + 7
 
a = [-1]
M.times do
  a.push(gets.to_i)
end
a.push(N+1)
 
@memo = {}
 
def com(n)
  return @memo[n] if @memo[n]
  return 0 if n == 0
  return 1 if n == 1
  
  c = (com(n-1) + com(n-2))%MOD
  @memo[n] = c
  return c
end
 
b = Array.new
0.upto(M) do |i|
  d = a[i+1] - a[i] -1
  if @memo[d] == nil
    2.upto(d) do |i|
      com(i)
    end
  end
  
  b.push(com(d))
end
 
p b.inject{|p, n| (p*n)%MOD}

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

int main()
{
ll n ;
cin >> n ;
vector<string> s(n);
rep(i, n){
  cin >> s[i];
}
map<string,ll> m;
rep(i,n)m[s[i]]++;
ll mx=0;
for (auto i = m.begin(); i != m.end(); ++i) {
  mx=max(mx,i->second);
}
vector<string> v;
for (auto i = m.begin(); i != m.end(); ++i) {
  mx=max(mx,i->second);
}
for (auto i = m.begin(); i != m.end(); ++i) {
  if(mx==i->second)v.push_back(i->first);
}
sort(v.begin(),v.end());
rep(i,v.size())cout << v[i] << endl;
return 0;
}

Measured memory_bytes: 30068
#include <iostream>
using namespace std;
int main() {
    int N,M;
    int count[60]={0};
    cin>>N>>M;
    int tmp;
    for(int i=0;i<(M*2);++i){
        cin>>tmp;
        count[tmp]++;
    }
    for(int i=1;i<N+1;++i){
        cout<<count[i]<<endl;
    }
}

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

int main() {
  int N;
  
  cin >> N;
  
  signed long long A[200000]={};
  
  signed long long Ans = 0;
  signed long long kakekioku = 0;
  signed long long Anstmp = 0;
  
  for (int i=1;i<=N;i++) {
    cin >> A[i];
  }
  
  for (int i=N-1;i>=1;i--) {
    kakekioku+=A[i+1];
    Ans+=(A[i]%1000000007)*(kakekioku%1000000007);
    Ans%=1000000007;
  }
  cout << (Ans%1000000007) <<endl;
  
}

Measured memory_bytes: 5176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long INF = 1LL << 60;

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

int lcm(int a, int b) { return a * b / gcd(a, b); }

int main() { 
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    ll g = lcm(C, D);
    ll cnt_B = B / C + B / D - B / g;
    ll cnt_A = (A-1) / C + (A-1) / D - (A-1) / g;
    cout << B-A+1-cnt_B + cnt_A << endl;
    return 0;
}

Measured memory_bytes: 3536
n = int(input())
s_lsit = {}
cnt = 0
for i in range(n):
    s = list(input())
    s.sort()
    s = "".join(s)
    if s in s_lsit:
        cnt += s_lsit[s]
        s_lsit[s] += 1
    else:
        s_lsit[s] = 1
print(cnt)

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

#define rep(i, a, n) for (int i = a; i < n; i++)
#define asc(v) sort(v.begin(), v.end())
#define desc(v) sort(v.begin(), v.end(), greater<int>())

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> arr(N, 0);
  rep(i, 0, N) { cin >> arr[i]; }
  desc(arr);
  int alice = 0;
  int bob = 0;
  rep(i, 0, N) {
    if (i % 2 == 0) {
      alice += arr[i];
    } else {
      bob += arr[i];
    }
  }
  cout << alice - bob;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int N,count=0,flag=0;
  int A[N];

  scanf("%d",&N);
  if(N!=0){
    for(int i=0;i<N;i++){
      scanf("%d",&A[i]);
    }
  while(flag==0){
    for(int i=0;i<N;i++){
      if(A[i]%2==0 && i != N-1){
        A[i] /= 2;
      }
      else if(A[i]%2 != 0){
        flag++;
        break;
      }
      else if(i == N-1 && A[i]%2 == 0){
        A[i] /= 2;
        count++;
      }
    }
  }
}
else{
  printf("%d\n",count);

}
  printf("%d\n",count);

}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime>
#include <cstring>
#include <iterator>

using namespace std;
int countDivisors(int n)
{
    int cnt = 0;
    for (int i = 1; i <= sqrt(n); i++) {
        if (n % i == 0) {
            // If divisors are equal, 
            // count only one 
            if (n / i == i)
                cnt++;

            else // Otherwise count both 
                cnt = cnt + 2;
        }
    }
    return cnt;
}

int main()
{
    int n; cin >> n;
    int cnt = 0;
    for (int i = 1; i < n; ++i) {
        cnt += countDivisors(n - i);
    }
    cout << cnt;
}



Measured memory_bytes: 3700
#include <iostream>
#include <vector>
#include <string>

using namespace std;

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

int main()
{
  string s;
  
  cin >> s;
/*  
  AAAA|ABCBC
  AAAA|BCABC
  AAAB|CAABC
  AABC|AAABC
  ABCA|AAABC
  BCAA|AAABC
  BCAA|AABCA
  BCAA|ABCAA
  BCAA|BCAAA
  BCABCAAAA
  BCBCAAAAA
*/    
  string s2;
  long int ans = 0;
  int len = s.size();
  int repeat_A = 0;
  for (int i=0;i<len-2;++i) {
    if (s[i] == 'A') {
      repeat_A++;
      
      if (s[i+1] == 'B' && s[i+2] == 'C') {
        ans += repeat_A;
        repeat_A--;
        i += 1;
        s[i+1] = 'A';
      }
    } else {
      repeat_A = 0;
    }

  //cout << s << ":" << repeat_A << ":" << ans << ":" << i << endl;
  }
  
  cout << ans << endl;
  //cout << s << endl;

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;
int cnt[10000005];
int main() {
    int n,x;
    cin >> n;
    for(int i = 0; i < n-1; i++){
        cin >> x;
        cnt[x]++;
    }
    for(int i = 1; i <= n; i++){
        cout << cnt[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 4360
use std::io::stdin;
use std::str::FromStr;
#[allow(dead_code, unused_mut)]
fn read<T: FromStr>() -> T {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().expect("1")
}
#[allow(dead_code, unused_mut)]
fn read_vec<T: FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().expect("2"))
        .collect()
}
#[allow(dead_code, unused_mut)]
fn read_two<T: FromStr>() -> (T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code, unused_mut)]
fn read_three<T: FromStr>() -> (T, T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code)]
fn remove_whitespace(s: &str) -> String {
    s.chars().filter(|c| !c.is_whitespace()).collect()
}

#[allow(unused_imports)]
use std::io::{stdout, Write};
#[allow(unused_imports)]
use std::collections::HashMap;
fn gcd(mut x: u64, mut y: u64) -> u64 {
    let mut z = x;
    let mut gcd_num = x;
    while z != 0 {
        gcd_num = z;
        z = y % x;
        y = x;
        x = z;
    }
    gcd_num
}
fn main() {
    let n = read::<i32>();
    if n % 1000 == 0 {
        println!("0");
    } else {
        println!("{}", 1000 - n % 1000);
    }
}

Measured memory_bytes: 2172
#include<stdio.h>

int main(void){
  int a,b,i;
  bool ans=true;
  char s[200];

  scanf("%d %d",&a,&b);
  scanf("%s",s);
  for(i=0;i<a;i++){
    if(s[i]<'0'||s[i]>'9'){
      ans=false;
      break;
    }
  }
  if(ans==false||s[i]!='-')
    ans=false;
  if(ans==true){
    for(i++;s[i]!=0;i++){
      if(s[i]<'0'||s[i]>'9'){
        ans=false;
        break;
      }
    }
  }

  if(ans==true)
    printf("Yes\n");
  else
    printf("No\n");

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
#define reg register
#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
#define input(a){a=0;char c=gc();int f=1;while(c<'0'||c>'9'){if(c=='-')f=-1;c=gc();}while(c>='0'&&c<='9'){a=(a<<3)+(a<<1)+(c&15);c=gc();}a*=f;}
static char buf[1<<21],*p1=buf,*p2=buf;
char bu[1<<21],cha[20];int p,pp=-1;
#define flush(){fwrite(bu,1,pp+1,stdout),pp=-1;}
#define output(x){if(pp>1<<20)flush();if(x<0)bu[++pp]=45,x=-x;do{cha[++p]=x%10+48;}while(x/=10);do{bu[++pp]=cha[p];}while(--p);}
#define Endl bu[++pp]='\n'
#define Space bu[++pp]=' '
#define pc(c) bu[++pp]=c
const int N=100010;
int a,b,c,x,ans;
int main()
{
    //input(a);input(b);input(c);input(x);
	scanf("%d%d%d%d",&a,&b,&c,&x);
    for(int i=0;i<=a;++i)
        for(int j=0;j<=b;++j)
            for(int k=0;k<=c;++k)
                if(500*i+100*j+50*k==x)++ans;
    output(ans);
    Endl;
	flush();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
int bsr(int x) { return 31 - __builtin_clz(x); }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20);
    int h, w;
    cin >> h >> w;
    int sm = 0;
    for (int y = 0; y < h; y++) {
        string s;
        cin >> s;
        for (auto c: s) {
            if (c == '#') sm++;
        }
    }
    if (sm == h+w-1) {
        cout << "Possible" << endl;
    } else {
        cout << "Impossible" << endl;
    }
    return 0;
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    string s;
    cin>>s;
    int ls[26];
    int cnt=0;
    for (int i = 0; i < 26; i++)
    {
        ls[i]=0;
    }
    
    for (int i = 0; i < 4; i++)
    {
        ls[s[i]-'A']++;
    }
    for (int i = 0; i < 26; i++)
    {
        if(ls[i]==2) cnt++;
    }
    
    if(cnt==2) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 256
//  Created by conan1024hao in 2020.
//  Copyright © 2020 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao Twitter/QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef long long int LL;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

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

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????统一类型        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    string s,t,u;
    int a,b;
    cin>>s>>t>>a>>b>>u;
    if(u==s){
        cout<<a-1<<" "<<b<<endl;
    }
    else{
        cout<<a<<" "<<b-1<<endl;
    }
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------








Measured memory_bytes: 256
import bisect
n,m,k=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
RA=[0]*(n+1)
RB=[0]*(m+1)
for i in range(n):
    RA[i+1]=RA[i]+A[i]
for i in range(m):
    RB[i+1]=RB[i]+B[i]
#print(RA)
#print(RB)

r=0
for i in range(n+1):
    a=RA[i]
    if k-a>=0:
        j=bisect.bisect_right(RB,k-a)-1
        r=max(r,i+j)
for i in range(m+1):
    b=RB[i]
    if k-b>=0:
        j=bisect.bisect_right(RA,k-b)-1
        r=max(r,i+j)
print(r)

Measured memory_bytes: 118272
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long int n;
	cin>>n;
	long int i,a[n],s=0,d=0;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	for(i=n-1;i>=0;i=i-2)
	{
		s=s+a[i];
	}
	for(i=n-2;i>=0;i=i-2)
	{
		d=d+a[i];
	}
	cout<<abs(s-d)<<endl;
	
	
}

Measured memory_bytes: 3552
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

N = int(input())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))
Cs = list(map(int, input().split()))

ans = sum(Bs)
for n in range(N-1):
    if As[n+1] - As[n] == 1:
        ans += Cs[As[n] - 1]
print(ans)



Measured memory_bytes: 6576
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define repm(i, a, n) for (ll i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vd vector<double>
#define vb vector<bool>
#define vs vector<string>
#define vii vector<vector<int>>
#define vll vector<ll>
#define vllll vector<vector<ll>>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define reverse_v(a) reverse(a.begin(), a.end())

void print(bool c)
{
    (c) ? (cout << "Yes" << endl) : (cout << "No" << endl);
}

void Print(bool c)
{
    (c) ? (cout << "YES" << endl) : (cout << "NO" << endl);
}

//最小公倍数
template <typename T>
T gcd(T a, T b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

//最大公約数
template <typename T>
T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}
//セカンドキー->ファーストキーの順ソート
bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

//右下左上
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};

int eve(int x)
{
    if (x % 400 == 0)
        return 1;
    if (x % 100 == 0)
        return 0;
    if (x % 4 == 0)
        return 1;
    return 0;
}

int main(void)
{
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if (a + b >= k)
        cout << min(a, k) << endl;
    else
        cout << a - (k - a - b) << endl;
}


Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;

struct node
{
    int mp;
    int n;
    node(int tmp, int tn)
    {
        n = tn;
        mp = tmp;
    }
    friend bool operator < (node A, node B)
    {
        return A.mp > B.mp;
    }
};

vector<int> vec_empty;
int h, w;
int spend[10][10];
int pic[205][205];
int save[10];
int res;

int bfs(int ori)
{
    int j;
    bool chkre[10];
    priority_queue<node> que, q_empty;

    memset(chkre, 0, sizeof(chkre));
    que.push(node(0, ori));
    while(que.size())
    {
        node start = que.top();
        que.pop();
        if(start.n == 1)
        {
            res += start.mp;
            //printf("\nres = %d add = %d\n\n", res, start.mp);
            //printf("ori=%d the path:\n", ori);
            //vector<int>::iterator si;
            //for(si = start.path.begin();si != start.path.end();si++) printf("%d\n", *si);
            return 0;
        }
        if(chkre[start.n] == 1) continue;
        chkre[start.n] = 1;

        for(j = 0;j <= 9;j++)
        {
            if(chkre[j] == 1) continue;
            if(start.n == j) continue;

            //printf("convert %d to %d mp=%d\n", start.n, j, start.mp + spend[start.n][j]);

            que.push(node(start.mp + spend[start.n][j], j));
        }
    }
    return 0;
}

int main()
{
    while(scanf("%d%d", &h, &w) != EOF)
    {
        int hh,ww;

        res = 0;
        memset(save, -1, sizeof(save));

        for(hh = 0;hh < 10;hh++)
        {
            for(ww = 0;ww < 10;ww++)
            {
                scanf("%d", &spend[hh][ww]);
            }
        }

        for(hh = 0;hh < h;hh++)
        {
            for(ww = 0;ww < w;ww++)
            {
                scanf("%d", &pic[hh][ww]);
                if(pic[hh][ww] != -1 && pic[hh][ww] != 1)
                {
                    if(save[pic[hh][ww]] > 0) res += save[pic[hh][ww]];
                    else bfs(pic[hh][ww]);
                }
            }
        }

        printf("%d\n", res);
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
#include <map>
using namespace std;

const double PI=acos(-1);

int main(){
    long h, w;
    cin >> h >> w;
    long wh = 0, bl = 0;
    vector<string> ss;
    for(int i = 0; i < h; i++){
        string s;
        cin >> s;
        ss.push_back(s);
    }
    vector<long> he, we;
    for(int i = 0; i < ss.size(); i++){
        for(int j = 0; j < w; j++){
            if(ss[i][j] == '.') wh++;
            else bl++;
        }
        if(bl == 0) we.push_back(i);
        wh = bl = 0;
    }
    for(int i = 0; i < w; i++){
        for(int j = 0; j < ss.size(); j++){
            if(ss[j][i] == '.') wh++;
            else bl++;
        }
        if(bl == 0) he.push_back(i);
        wh = bl = 0;
    }
    for(int j = 0; j < ss.size(); j++){
        bool z = false;
        for(int i = 0; i < w; i++){
            if(find(we.begin(), we.end(), j) == we.end() && find(he.begin(), he.end(), i) == he.end()){
                cout << ss[j][i];
                z = true;
            }
        }
        if(z) cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <utility>
#include <numeric>
#include <iomanip>

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

using namespace std;

int main()
{
    long int a;
    long int b;
    long int k;
    cin >> a >> b >> k;

    long int ans1;
    long int ans2;

    if (a-k < 0)
    {
        if (b - (k - a) < 0)
        {
            cout << 0 << " " << 0 << endl;
        }
        else
        {
            cout << 0 << " " << b - (k - a) << endl;
        }
    }
    else
    {
        cout << a-k << " " << b << endl;
    }
    
    
}

Measured memory_bytes: 256