akhauriyash/Code-Regression huggingface dataset:
n = int(input())
dicti = {}
boss = list(map(int, input().split()))
for i in boss:
    if i in dicti:
        dicti[i] += 1
    else:
        dicti[i] = 1
#print(dicti)
for j in range(1,n+1):
    try:
        print(dicti[j])
    except:
        print(0)

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

using ll = long long;
using ld  = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

// #define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
// int lcm(int a, int b){return a / gcd(a, b) * b;}
#define begin_end(a) a.begin(),a.end() //sort(begin_end(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll)(n) ; i++ )
#define DREP(i,m,n) for(ll i=(ll)(m) ; i > (ll)(n) ; i-- )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define p_b push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに


// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// -------- template end - //


// - library ------------- //



// --------- library end - //


int main(){

  ll N = il();

  // dp[i] := i という数字を末尾として作れる、連続インクリメント部分列（？）の長さ
  vector<ll> dp(N+1, 0);

  ll ans = 0;
  rep(i, N){
    ll p = il();
    dp[p] = dp[p-1] + 1;
    chmax(ans, dp[p]);
  }

  cout << N - ans << endl;


}

Measured memory_bytes: 4784
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007LL;
const int INF = LLONG_MAX;

signed main(){
    
    int n, q; cin >> n >> q;
    string s; cin >> s;
    vector<char> t(q);
    vector<char> d(q);
    for(int i = 0; i < q; i++) cin >> t[i] >> d[i];

    int l = 0;
    int r = n;
    for(int i = q - 1; i >= 0; i--){

        //cout << l << " " << r << endl;
        if(d[i] == 'R'){
            if(s[r - 1] == t[i]) r--;
            if(l != 0 && s[l - 1] == t[i]) l--;
        }else{
            if(s[l] == t[i]) l++;
            if(r != n && s[r] == t[i]) r++;
        }
    }

    //cout << l << " " << r << endl;
    cout << max(0LL, r - l) << endl;
    return 0;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; 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 INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  ll n;
  cin >> n;
  vector<ll> t(n), a(n);
  REP(i, n) { cin >> t[i] >> a[i]; }
  ll x = t[0], y = a[0];
  FOR(i, 1, n) {
    ll c = max((x + t[i] - 1) / t[i], (y + a[i] - 1) / a[i]);
    x = c * t[i];
    y = c * a[i];
  }
  cout << x + y << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define read(n) scanf("%lld",&n)
#define write(x) printf("%lld",x)
#define F(i,n) for(int i = 0;i < n;i++)
#define ll long long
#define MX 3005
#define MOD 1000000007
#define INF 1000000009
#define set_dp(dp) memset(dp,-1,sizeof(dp))
using namespace std;
ll n, dp[MX][MX];
string s;
ll solve(ll i, ll j){
	if(i == 0) return j == 0;
	if(j < 0 || j > i) return 0;
	if(dp[i][j] == -1){
		ll ans = 0;
		if(s[i - 1] == '<')
			ans = (solve(i, j - 1) + solve(i - 1, j - 1)) % MOD;
		else
			ans = (solve(i, j + 1) + solve(i - 1, j)) % MOD;
		dp[i][j] = ans;
	}
	return dp[i][j];
}
int main(){

	cin>>n>>s;

	set_dp(dp);

	ll ans = 0;

	F(j, n){
		ans += solve(n - 1, j);
		ans %= MOD;
	}

	write(ans);

	return 0;
}


Measured memory_bytes: 281600
def lcs():
    x, y = raw_input(), raw_input()
    b1 = [0 for k in range(len(y)+1)]
    for i in xrange(len(x)):
        a = x[i]
        b2 = b1 + []
        for j in xrange(len(y)):
            if a == y[j]:
                b1[j+1] = b2[j] + 1
            elif b1[j+1] < b1[j]:
                b1[j+1] = b1[j]
    print max(b1)
 
n = input()
for i in xrange(n):
    lcs()

Measured memory_bytes: 6492
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)
#define rrep(i, j, n) for (int i = (int)n - 1; j <= i; --i)

constexpr ll MOD = 1000000007;
constexpr int INF = 0x3f3f3f3f;
constexpr ll INFL = 0x3f3f3f3f3f3f3f3fLL;

vector<int> g[200000];
ll sub_size[200000];
ll finv[200010];
ll fact[200010];
ll ans[200000];
ll final_ans[200000];

ll inv(ll x) {
  ll e = MOD - 2;
  ll res = 1;
  while (e) {
    if (e & 1) res = res * x % MOD;
    x = x * x % MOD;
    e >>= 1;
  }
  return res;
}

ll dfs(int v, int p) {
  sub_size[v] = 1;
  for (int nv : g[v]) {
    if (nv == p) continue;
    sub_size[v] += dfs(nv, v);
  }
  return sub_size[v];
}

ll solve1(int v, int p) {
  ans[v] = fact[sub_size[v] - 1];
  for (int nv : g[v]) {
    if (nv == p) continue;
    ans[v] = ans[v] * solve1(nv, v) % MOD * finv[sub_size[nv]] % MOD;
  }
  return ans[v];
}

void solve2(int v, int p) {
  final_ans[v] = fact[sub_size[v] - 1];
  for (int nv : g[v])
    final_ans[v] = final_ans[v] * ans[nv] % MOD * finv[sub_size[nv]] % MOD;

  for (int nv : g[v]) {
    if (nv == p) continue;
    // nvを根とした状態にする
    ans[v] = ans[v] * inv(ans[nv]) % MOD * fact[sub_size[nv]] % MOD *
             inv(fact[sub_size[v] - 1]) % MOD *
             fact[sub_size[v] - 1 - sub_size[nv]] % MOD;
    ans[nv] = ans[nv] * inv(fact[sub_size[nv] - 1]) % MOD;
    sub_size[v] -= sub_size[nv];
    sub_size[nv] += sub_size[v];
    ans[nv] = ans[nv] * fact[sub_size[nv] - 1] % MOD * ans[v] % MOD *
              finv[sub_size[v]] % MOD;

    solve2(nv, v);
    ans[nv] = ans[nv] *
              inv(fact[sub_size[nv] - 1] % MOD * ans[v] % MOD *
                  finv[sub_size[v]] % MOD) %
              MOD;
    sub_size[nv] -= sub_size[v];
    sub_size[v] += sub_size[nv];
    ans[nv] = ans[nv] * fact[sub_size[nv] - 1] % MOD;
    ans[v] = ans[v] * ans[nv] % MOD * inv(fact[sub_size[nv]]) % MOD *
             fact[sub_size[v] - 1] % MOD *
             inv(fact[sub_size[v] - 1 - sub_size[nv]]) % MOD;
  }
}

int main() {
  int n, a, b;
  cin >> n;
  rep(i, 0, n - 1) {
    cin >> a >> b;
    --a, --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  fact[0] = finv[0] = 1;
  rep(i, 1, n + 5) {
    fact[i] = fact[i - 1] * i % MOD;
    finv[i] = finv[i - 1] * inv(i) % MOD;
  }

  dfs(0, 0);
  solve1(0, 0);
  solve2(0, 0);
  rep(i, 0, n) cout << final_ans[i] << '\n';

  return 0;
}

Measured memory_bytes: 22540
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi A(n);
  for(auto &a:A)cin>>a;
  sort(ALL(A));
  if(n%2 == 0){
    ll ans = 0;
    for(int i=0;i<n/2-1;i++){
      ans -= 2*A[i];
    }
    ans -= A[n/2-1];
    ans += A[n/2];
    for(int i=n/2+1;i<n;i++){
      ans += 2*A[i];
    }
    cout<<ans<<endl;
  }else{
    ll sum = 0,sum2 = 0;
    for(int i=0;i<n/2-1;i++){
      sum -= 2*A[i];
    }
    sum -= A[n/2-1]+A[n/2];
    for(int i=n/2+1;i<n;i++){
      sum += 2*A[i];
    }

    for(int i=0;i<n/2;i++){
      sum2 -= 2*A[i];
    }

    sum2 += A[n/2]+A[n/2+1];
    for(int i=n/2+2;i<n;i++){
      sum2 += 2*A[i];
    }
    //  cout<<sum<<" "<<sum2<<endl;
    cout<<max(sum,sum2)<<endl;
  }
  return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int x = sc.nextInt();
        if (x >= a && x <= a + b) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }

}

Measured memory_bytes: 20820
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <stack>
#include <utility>
#include <array>
#include <random>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
using namespace std;
typedef long long ll;
#define dump(x) cerr << #x << " = " << (x) << " [" << __LINE__ << ":" << __FUNCTION__ << "] " << endl;
// vector出力
template < typename T >
ostream& operator<<(ostream& os, vector< T >& v) {
    os << "{";
    for (int i = 0; i < (int)v.size(); i++) {
        os << v[i] << (i < v.size() - 1 ? ", " : "");
    }
    os << "}";
    return os;
}
// pair出力
template < typename T, typename U >
ostream& operator<<(ostream& os, pair< T, U >& p) {
    return os << "(" << p.first << ", " << p.second << ")";
}
// map出力
template < typename T, typename U >
ostream& operator<<(ostream& os, map< T, U >& map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set 出力
template < typename T >
ostream& operator<<(ostream& os, set< T >& set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
#pragma endregion

/////////////////////////////////////////

int main() {
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != t[i]) {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}

/////////////////////////////////////////

Measured memory_bytes: 3636
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <deque>
using namespace std;

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


int main() {
	int n;
	cin >> n;
	ll A[n];
	rep(i, n) cin >> A[i];
	sort(A, A+n, greater<ll>());

	int cnt = 1;
	ll first = 0;
	ll ans = 0;
	for (int i=0; i<n-1; i++) {
		if (A[i]==A[i+1]) {
			cnt++;
			if (cnt== 4) {
				ans = A[i]*A[i];
				cout << ans << endl;
				return 0;
			}
			else if (cnt==2) {
				if (first==0) first = A[i];
				else {
					ans = first * A[i];
					cout << ans << endl;
					return 0;
				}
			}
		}
		else cnt = 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
/*
  Id: ak260901
  Task: a
  Lang: C++
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

#define foru(i, l, r) for(register int i = l; i <= r; i++)
#define ford(i, r, l) for(register int i = r; i >= l; i--)

typedef long long ll;

ll read() {
  ll res = 0; char c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)) res = res * 10 + c - '0', c = getchar();
  return res;
}

int main() {
  ll n = read(), m = read();
  ll x = read(), y = read();
  printf("%.6lf ", (double)n * (double)m * (double)0.5);
  if(x * 2 == n && y * 2 == m) puts("1");
  else puts("0");
  return 0;
}


Measured memory_bytes: 256
n=int(input())
l=[0,0,0,0]
while(n):
  r=input()
  if(r=="AC"):
    l[0]=l[0]+1
  elif(r=="WA"):
    l[1]=l[1]+1
  elif(r=="TLE"):
    l[2]=l[2]+1
  elif(r=="RE"):
    l[3]=l[3]+1
  n=n-1  
print("AC x {}".format(l[0]))
print("WA x {}".format(l[1]))
print("TLE x {}".format(l[2]))
print("RE x {}".format(l[3]))

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

int arr[200200];
int srt[200200];

int main(){
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d", &arr[i]);
        srt[i] = arr[i];
    }
    sort(srt, srt+n);
    int l = n/2;
    int an1 = srt[l-1];
    int an2 = srt[l];

    for(int i = 0; i < n; i++){
        if (arr[i] <= an1) printf("%d\n", an2);
        else printf("%d\n", an1);
    }

    return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#define FOR(i, a, b)  for(int i=a; i<b; ++i)
#define rFOR(i, a, b) for(int i=a-1; i>=b; --i)
#define REP(i, n) for(int i=0; i<n; ++i)
#define rREP(i, n) for(int i=n-1; i>=0; --i)
#define all(a)  a.begin(), a.end()
using namespace std;

int main(){
  int n;  cin >> n;
  vector<int> vec;
  FOR(i, 1, n/2+1){
    int sum = 0;
    string a, b;
    a = to_string(i);
    b = to_string(n-i);
    for(auto&& c : a){
      sum += (c - '0');
    }
    for(auto&& c : b){
      sum += (c - '0');
    }
    vec.emplace_back(sum);
  }
  cout << *min_element(all(vec)) << endl;
  return 0;
}

Measured memory_bytes: 640
import java.util.*;
public class Main{
public static void main (String [] args){	
Scanner scanner = new Scanner (System.in); 
    String a = scanner.next();
    String b = "";
    if (a.charAt(0) == 48){
      for (int i = 0; i < a.length()/2 + 1; i++){
        b = b + "01";
      }
    }
    else{
      for (int i = 0; i < a.length()/2+1; i++){
        b = b + "10";
      }
    }
    int counter = 0;
    for (int i = 0; i < a.length(); i++){
      if (a.charAt(i) != b.charAt(i))
        counter++;
    }
    System.out.println(counter);
}
}

Measured memory_bytes: 58156
#include <stdio.h>

int main(){
  int N;
  int A[100];
  scanf("%d", &N);
  for(int i=0; i<N; i++){
	scanf("%d", &A[i]);
  }

  int min=A[0], max = A[0];
  for(int i=1; i<N; i++){
	if (min > A[i]) min = A[i];
	if (max < A[i]) max = A[i];
  }

  printf("%d\n", max-min);

  return 0;
}

Measured memory_bytes: 128
n,m,k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))


a = [0]
b = [0]

for i in range(n):
    a.append(a[i]+ A[i])
for i in range(m):
    b.append(b[i] + B[i])
# print(a)
# print(b)
# print(a[3])
ans=0
j = m
for i in range(n+1):
    if a[i] > k:
        break
    while b[j] > k - a[i]:
        j -= 1
    ans = max(ans,i+j)
print(ans)

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

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

int main() {
	int n;
	cin >> n;
	int p[25];
	rep(i, n) cin >> p[i];
	int ans=0;
	for(int i=1; i<n-1; i++)
	{
		if(p[i-1]<p[i] && p[i]<p[i+1]) ans++;
		if(p[i-1]>p[i] && p[i]>p[i+1]) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        k: usize,
        a: usize,
        b: usize,
    }
    let flag = (a..=b).any(|i| i % k == 0);
    if flag {
        println!("OK");
    } else {
        println!("NG");
    }
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
#define    fio     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define    eps     1e-9
#define    pi      acos(-1.0)
#define    mod     1e9+7

using namespace std;
typedef long long ll;

void solve()
{
    ll l,r,d;
    cin>>l>>r>>d;
    l--;
    cout<<(r/d)-(l/d)<<endl;
}

int main()
{
    fio;
///    freopen ("output.txt","w",stdout);
///    freopen ("input.txt","r",stdin);
    int tc=1;
///    cin>>tc;
///    int i=0;
    while(tc--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<string>

using namespace std;

#define ll long long

int main(){
    string S;
    cin >> S;
    if(S <= "2019/04/30"){
        cout << "Heisei" << endl;
    }else{
        cout << "TBD" << endl;
    }
}

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


int main(){
  int day;
  cin >> day;
  int sa = 25 - day;
  string s = "Christmas";
  if (sa > 0){
    for (int i = 0; i < sa; i++){
      s += " Eve";
    }
  }
  cout << s << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    long long t,a,k;
    cin>>t>>a>>k;
    
    if(t<=k){
        k-=t;
        t=0;
    }else{
        long long hoge=k;
        k=0;
        t-=hoge;
    }
    
    if(a<=k){
        a=0;
    }else{
        a-=k;
    }
    
    cout<<t<<" "<<a<<endl;
    
    return 0;
}

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

int main(){
  int a, b, C;
  double c, PI, rad, S, L, h;
  PI = acos(-1);

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

  rad = C * PI / 180;
  S = a*b*sin(rad)/2;
  c = sqrt( a*a+b*b-2*a*b*cos(rad) );
  L = a + b + c;
  h = 2*S/a;

  printf("%lf\n", S);
  printf("%lf\n", L);
  printf("%lf\n", h);

}

Measured memory_bytes: 2916
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <deque>
#include <stack>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define DEBUG(x) cout << (#x) << ": " << (x) << endl
#define DEBUG_VEC(v)            \
    cerr << #v << ": ";         \
    REP(__i, (v).size())        \
    cerr << ((v)[__i]) << ", "; \
    cerr << endl

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main()
{
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    int h, w;
    cin >> h >> w;

    cout << (H - h) * (W - w) << endl;
    return 0;
}


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

using namespace std;

#define V vector
typedef long long ll;
typedef unsigned long long ull;

typedef V<int> vi;
typedef V<ll> vll;
typedef V<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef V<pll> vpll;

#define f(i,a) for(int i = 0 ; i < a ; i++)
#define fll(i,a) for(ll i = 0 ; i < a ;i++)
#define forab(i,a,b) for(int i = a ; i < b ; i++)
#define prec(x) cout<<fixed<<setprecision(x)
#define ff first
#define ss second

#define pb push_back
#define mp make_pair
#define numberofdigits(x) floor(log10(x)) + 1
#define MAXN 100001

ll binpow(ll a, long long b) {
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a);
		a = (a * a);
		b >>= 1;
	}
	return res;
}

void solve()
{
	ll n , sum = 0;
	cin >> n;

	unordered_map<ll , ll> mp;

	ll a;
	fll(i, n) {
		cin >> a;
		mp[a]++;
		sum += a;
	}

	int q;
	cin >> q;

	while (q--) {

		ll l , r;
		cin >> l >> r;

	    if(mp[l] > 0)
	    {
	        mp[r] += mp[l];
	        sum += ( r - l ) *mp[l];
	        mp[l] = 0;
	    }
		cout << sum << "\n";
	}
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int t = 1;
	//cin >> t;

	while (t--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 6976
#include<stdio.h>
int main(){
	int t;
	int a;
	int b=0;
	scanf("%d",&t);
	a=t;
	
	while(t>0){
		b+=t%10;
		t/=10;
	}
	
	
		if(a%b==0) printf("Yes");
		else printf("No");
		
	
	
	return 0;
} 

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;



#define INF 2000000000
#define MAX_V 10



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

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

ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

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

ll lcm(ll a,ll b){
   return a/gcd(a,b)*b;
}
const ll MAX = 5100000;
const ll MOD = 1000000007;
 
ll fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

using graph = vector<vector<ll>>;
pair<pair<ll,ll>,ll> p[100010];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,h;
    cin>>n>>h;
    vector<ll> a(n),b(n);
    rep(i,n) cin>>a[i]>>b[i];
    sort(ALL(a));
    sort(ALL(b),greater<>());
    ll sum=0;
    rep(i,n){
        if(a[n-1]<=b[i]) {
            h-=b[i];
            sum++;
        }
        if(h<=0){
            cout<<sum<<endl;
            return 0;
        }
    }
    if(h%a[n-1]==0) sum+=h/a[n-1];
    else sum+=h/a[n-1] + 1;
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 1792
from collections import defaultdict

n = int(input())
x, y = [0] * n, [0] * n
data = defaultdict(int)
for i in range(n):
    x[i], y[i] = map(int, input().split())

if n == 1:
    print(1)
    exit()
for i in range(n):
    for j in range(n):
        if i != j:
            data[x[j] - x[i], y[j] - y[i]] += 1

print(n - max(data.values()))

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
using namespace std;
ll powmod(ll base,ll exponent,ll mod){
	ll ans=1;base%=mod;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 2e5+1;
const int mod = 1e9+7;
ll dp[upperlimit];
int col[upperlimit];
int main(){
	dp[0]=1;
	int n;
	sd(n);
	int inp;
	for(int i = 1; i <= n; i++){
		sd(inp);
		dp[i]=dp[i-1];
		if((col[inp]>0)&&(col[inp]!=i-1)) dp[i]+=dp[col[inp]];
		col[inp]=i;
		dp[i]%=mod;
	}
	plld(dp[n]);
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>

using namespace std;

void digit();

int a, b;

int main() {


	while(cin >> a >> b) {
		digit();
	}

	return 0;

}

void digit() {
	
	int i=0;
	a+=b;

	while(a!=0) {
		a/=10;
		i++;
	}

	cout << i << endl;

}

Measured memory_bytes: 0
def resolve():
  N = int(input())
 
  table = [1]*(N+1)
  for i in range(2, N+1):
    n = i
    while n <= N:
      table[n] += 1
      n += i
 
  ans = 0
  for i in range(1, N+1):
    ans += i*table[i]
 
  print(ans)
 

if __name__ == "__main__":
  resolve()

Measured memory_bytes: 151316
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
char notes[110][10];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n, k;
	cin >> n >> k;
	vector<ll>p(n), c(n);
	rep(i, n) {
		cin >> p[i];
		p[i]--;
	}
	rep(i, n) {
		cin >> c[i];
	}
	ll ans = -1 * INF;
	rep(si, n) {
		ll x = si;
		vector<ll>s;
		ll total = 0;
		while (1) {
			x = p[x];
			s.push_back(c[x]);
			total += c[x];
			if (x == si)break;
		}
		ll l = s.size();
		ll now = 0;
		rep(i, l) {
			now += s[i];
			if (i + 1 > k)break;
			ll now2 = now;
			if (total > 0) {
				ll e = (k - 1 - i) / l;
				now2 += total * e;
			}
			ans = max(ans, now2);
		}
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

#define int long long

void solve() {
    int a, b;
    string s, t, u;
    cin >> s >> t >> a >> b >> u;
    if (s == u) {
        cout << a - 1 << ' ' << b;
    }
    else cout << a << ' ' << b - 1;
}

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


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

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		solver.readRSP(in.readLine());
		solver.readT(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split("\\s+");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		K = Integer.parseInt(strArr[1]);
	}

	public void readRSP(String str) {
		String[] strArr = str.split("\\s+");
		R = Integer.parseInt(strArr[0]);
		S = Integer.parseInt(strArr[1]);
		P = Integer.parseInt(strArr[2]);
	}

	int K;
	int R;
	int S;
	int P;

	public void readT(String str) {
		int ans = 0;
		char[] arr = str.toCharArray();
		for (int i = 0; i < N; i++) {
			if (i >= K && arr[i] == arr[i - K]) {
				arr[i] = 'x';
				continue;
			}
			if (arr[i] == 'r')
				ans += P;
			else if (arr[i] == 's')
				ans += R;
			else if (arr[i] == 'p')
				ans += S;
		}
		System.out.println(ans);
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 26452
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s;
	cin>>s;
	if((s[0]==s[1]&&s[1]==s[2])||(s[1]==s[2]&&s[2]==s[3]))
	    cout<<"Yes";
	else
	    cout<<"No";
    return 0;
}

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

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define fr(i,k,n) for (int i = k; i < n; ++i)
#define fri(i,k,n) for (int i = k; i >= n; --i)
#define INF (int)1e9
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define all(arr) arr.begin(),arr.end()

void boost(){
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const int N=102,K=1e5+5;
int arr[N],pre[K];
ll dp[N][K];

void solve(){
  int n,k;
  cin>>n>>k;
  fr(i,1,n+1){
    cin>>arr[i];
  }
  dp[0][0]=1;
  fr(i,0,k+1)
  pre[i]=1;
  fr(i,1,n+1){
    int t=arr[i];
    fr(j,0,k+1){
      dp[i][j]=pre[j];
      if(j-t>0)
        dp[i][j]=(dp[i][j]-pre[j-t-1]+MOD)%MOD;
    }
    pre[0]=dp[i][0];
    fr(j,1,k+1){
      pre[j]=(dp[i][j]+pre[j-1])%MOD;
    }
  }
  cout<<dp[n][k]<<endl;
  return;
}

int main()
{
  boost();
  
  int tc=1;
  //cin>>tc;
  while(tc--)
    solve();
  return 0;
}

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

int main() {
  double d, e;
  int a[4] = {0}, b[4] = {0};
  while(cin >> d >> e) {
    if(d >= 1.1) ++a[0];
    else if(d >= 0.6) ++a[1];
    else if(d >= 0.2) ++a[2];
    else ++a[3];
    if(e >= 1.1) ++b[0];
    else if(e >= 0.6) ++b[1];
    else if(e >= 0.2) ++b[2];
    else ++b[3];
  }
  for(int i = 0; i < 4; ++i) cout << a[i] << " " << b[i] << endl;
  return 0;
}

Measured memory_bytes: 1224
n,m = map(int,input().split())
if m == 0:
    if n == 1:
        print(0)
        exit()
    if n == 2:
        print(10)
        exit()
    if n == 3:
        print(100)
        exit()

a = [-1]*n
for _ in range(m):
    s,c = map(int,input().split())
    if s == 1 and c == 0 and n == 3:
        print(-1)
        exit()
    if s == 1 and c == 0 and n == 2:
        print(-1)
        exit()
    if a[s-1] == -1:
        a[s-1] = c
    else:
        if a[s-1] != c:
            print(-1)
            exit()

ans = ""
for i in range(n):
    if a[i] == -1:
        if i == 0:
            ans += "1"
        else:
            ans += "0"
    else:
        ans += str(a[i])
print(ans)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
int main() {
	long long N, W; cin >> N >> W;
	vector<pair<long long, long long>>A(N);
	for (long long i = 0; i < N; i++) {
		cin >> A.at(i).first >> A.at(i).second;
	}
	vector<vector<long long>>DP(110, vector<long long>(11000));
	for (long long i = 0; i < N; i++) {
		DP.at(i).at(0) = 0;
	}
	for (long long i = 0; i < W; i++) {
		DP.at(0).at(i) = 0;
	}
	for (long long i = 0; i < N; i++) {
		for (long long j = 0; j <= W; j++) {
			if (j < A.at(i).second) {
				DP.at(i + 1).at(j) = DP.at(i).at(j);
			}
			else {
				DP.at(i + 1).at(j) = max(DP.at(i).at(j), DP.at(i + 1).at(j - A.at(i).second) + A.at(i).first);
			}
		}
	}
	cout << DP.at(N).at(W) << endl;
}




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

using namespace std;
static const int INF = 999999999;
typedef pair<int, int> P;


void solve()
{
	int N;
	while(cin >> N, N)
	{
		vector< vector<P> > field(N, vector<P>(N));
		vector< vector<int> > data(N, vector<int>(N));
		for(int i = 0; i < N; ++i)
		{
			for(int j = 0; j < N; ++j)
			{
				cin >> field[i][j].first >> field[i][j].second;
				data[i][j] = INF;
			}
		}
		int ans = 0;
		int count = 0;
		for(int i = 0; i < N; ++i)
		{
			for(int j = 0; j < N; ++j)
			{
				if(data[i][j] == INF)
				{
					int x = j;
					int y = i;
					while(data[y][x] == INF)
					{
						data[y][x] = count;
						int ny = field[y][x].second;
						int nx = field[y][x].first;
						y = ny;
						x = nx;
					}
					if(data[y][x] == count)
					{
						++ans;
					}
					++count;
				}
			}
		}
		cout << ans << endl;
	}
}

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

Measured memory_bytes: 1344
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL

struct node{
  struct node *p;
  struct node *r;
  struct node *l;
  int key;
};

typedef struct node * binary;

binary root;

void insert(int k){
  binary y=NIL;
  binary x=root;
  binary z;

  z=malloc(sizeof(struct node));
  z->key=k;
  z->l=NIL;
  z->r=NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key)
      x=x->l;
    else
      x=x->r;
  }

  z->p=y;

  if(y==NIL)
    root=z;
  else if(z->key<y->key)
    y->l=z;
  else
    y->r=z;
}


void inorder(binary p){

  if(p->l!=NIL)
    inorder(p->l);

  printf(" %d",p->key);

  if(p->r!=NIL)
    inorder(p->r);

}
void preorder(binary p){

  printf(" %d",p->key);

  if(p->l!=NIL)
    preorder(p->l);

  if(p->r!=NIL)
    preorder(p->r);

}


int main(){
  int n,i,k;
  char a[10];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",a);

    if(a[0]=='i'){
      scanf("%d",&k);
      insert(k);
    }
    else if(a[0]=='p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 24040
import scala.io.StdIn

object Main {
  def main(args: Array[String]){
    val input = StdIn.readLine().split(" ").map(_.toInt)
    println(gcd(input.max,input.min))
  }

  def gcd(x: Int, y: Int):Int = {
    if(1 < y && y < x) { gcd(y, x % y) } 
    else if(x == 1 || y == 1) { 1 }
    else { x }
  }
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    string S;
    cin>>S;
    if(S.size()%2 == 1){
        cout<<"No"<<endl;
        return 0;
    }
    rep(i, (int)S.size()-1){
        if(S[i] == 'h' && S[i+1] == 'i'){
            i++;
        }
        else{
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-9;

int hoge(vector< vector<int> >& a, int i, int j) {
	return i < a[j].size() ? a[j][i] : 0;
}

int main() {
	for (;;) {
		int H; cin >> H;
		if (H == 0) break;
		vector< vector<int> > a(5, vector<int>(H));
		for (int i = H - 1; i >= 0; i--)
			for (int j = 0; j < 5; j++)
				cin >> a[j][i];
		int ans = 0;
		for (;;) {
			bool flag = false;
			vector< vector<bool> > b(5, vector<bool>(H));
			for (int i = 0; i < H; i++)
				for (int j = 0; j < 3; j++) {
					int x = hoge(a, i, j);
					if (x && hoge(a, i, j + 1) == x && hoge(a, i, j + 2) == x) {
						b[j][i] = b[j + 1][i] = b[j + 2][i] = true;
						flag = true;
					}
				}
			for (int i = H - 1; i >= 0; i--)
				for (int j = 0; j < 5; j++)
					if (b[j][i]) {
						ans += a[j][i];
						a[j].erase(a[j].begin() + i);
					}
			if (!flag) break;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define at(x,i) get<i>(x);
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll x,y;cin >> x >>y;
    ll k=x+y;
    if(k%3!=0){cout <<0 <<endl;return 0;}
    k/=3;
    x-=k;y-=k;
    if(x<0||y<0){cout <<0 <<endl;return 0;}
    ll a=min(x,y);
    ll ans=1;
    rep(i,a){
        ans*=(x+y-i);
        ans%=MOD;
    }
    rep(i,a){
        ans*=modinv(i+1,MOD);
        ans%=MOD;
    }
    cout <<ans <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> ans(n + 1);
	for (int i = 1; i <= 100; i++) {
		for (int j = 1; j <= 100; j++) {
			for (int k = 1; k <= 100; k++) {
				int val = i * i + j * j + k * k + i * j + j * k + i * k;
				if (val <= n)
					ans[val]++;
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		cout << ans[i] << "\n";
	}
}


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

using namespace std;

template <typename T>
T cin2var()
{
    T val;
    cin >> val;
    return val;
}

int main()
{
    const auto N(cin2var<size_t>());
    size_t     sum = 0;
    for (size_t i = 1; i < N; ++i) {
        sum += i;
    }
    cout << sum << endl;
}

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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);



int n , m;


void solve(int testCase){
    string s , t;
    cin >> s >> t;
    int a , b;
    cin >> a >> b;

    string u;
    cin >> u;

    if(u == s)a --;
    else if(u == t)b --;

    printf("%d %d\n" , a , b);

}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  char c;
  cin >> c;
  if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
    cout << "vowel" << endl;
  } else{
    cout << "consonant" << endl;
  }

  return 0;
}


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

typedef long long int llint;

int main(){
	int N,A,B;
	cin >> N >> A >> B;
	int sum=0;
	for(int i=1;i<=N;i++){
		int digitSum=0;
		for(int k=i;k;k/=10){
			digitSum+=k%10;
		}
		if(A<=digitSum && digitSum<=B){
			sum+=i;
		}
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    #define INF 2000000000
    typedef long long int ll;
    typedef pair<ll,ll> ii;
    typedef pair<ii,ll> iii;
    typedef vector<ll> vi;
    typedef vector<ii> vii;
    #define getbit(n,i) (((n)&(1<<(i)))!=0)
    #define setbit0(n,i) ((n)&(~(1<<(i))))
    #define setbit1(n,i) ((n)|(1<<(i)))
    #define togglebit(n,i) ((n)^(1<<(i)))
    #define lastone(n) ((n)&(-(n)))
    #define read freopen("debug\\in.txt","r",stdin)
    #define write freopen("debug\\out.txt","w",stdout)
    #define fi first
    #define se second
    #define getI(a) scanf("%d",&a)
    #define getII(a,b) scanf("%d%d",&a,&b)
    #define PI (acos(-1))
    #define fastread ios_base::sync_with_stdio(false);cin.tie(NULL)
    #define mod (1000000007)
    #define asz 500005
    #define pb push_back
    #define ppf pop_front
    #define ppb pop_back
    #define pf push_front
    ll a[200005];
    int main()
    {
        fastread;
        ll n,i,j,k,l,m;
        cin>>n>>k;
        ll sum=0;
        for(i=1;i<=k;i++){
        	cin>>m;
        	sum+=m;
		}
		if(sum>=n)
		cout<<"Yes";
		else
		cout<<"No";
    	return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

#define int ll

int n,a,b,c,d;


signed main(){
    cin>>n>>a>>b>>c>>d;
    rep(i,0,n){
        int k=i,l=n-i-1;
        int lb=c*l-d*k,ub=-c*k+d*l;
        if(lb<=b-a && b-a<=ub){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    puts("NO");
    
    return 0;
}

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

signed main(){
  lint N, K; cin >> N >> K;
  lint r, s, p; cin >> r >> s >> p;
  string t; cin >> t;
  lint ans = 0;
  for(lint i = 0; i < K; i++){
    if(t[i] == 'r') ans += p;
    if(t[i] == 's') ans += r;
    if(t[i] == 'p') ans += s;
  }
  for(lint i = K; i < N; i++){
    if(t[i] == 'r'){
      if(t[i - K] == 'r'){
        t[i] = 'm';
      }
      else ans += p;
    }
    if(t[i] == 's'){
      if(t[i - K] == 's'){
        t[i] = 'm';
      }
      else ans += r;
    }
    if(t[i] == 'p'){
      if(t[i - K] == 'p'){
        t[i] = 'm';
      }
      else ans += s;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using psi = pair<string, int>;
int val[5000];

int N, M;

struct UnionFind {
	vector<int> data;
	int Val(int a) {
		return val[root(a)];
	}
	int root(int a) {
		return data[a] < 0 ? a : data[a] = root(data[a]);
	}
	UnionFind(int n) : data(n, -1) {}
	bool Find(int a, int b) {
		return root(a) == root(b);
	}
	void Union(int a, int b) {
		int ra = root(a), rb = root(b);
		if (ra == rb) return;
		if (data[ra] < data[rb]) {
			data[ra] += data[rb];
			data[rb] = a;
			val[ra] = min(val[ra], val[rb]);
		}
		else {
			data[rb] += data[ra];
			data[ra] = b;
			val[rb] = min(val[ra], val[rb]);
		}
	}
	int size(int a) {
		return -data[root(a)];
	}
};

int main()
{
	string s, t;
	cin >> N;
	vector<psi> ax(N);
	vector<string> a; a.reserve(N);
	for (int i = 0; i < N; i++) {
		cin >> ax[i].first >> ax[i].second;
	}
	sort(ax.begin(), ax.end());
	for (int i = 0; i < N; i++) {
		a.push_back(ax[i].first);
		val[i] = ax[i].second;
	}
	UnionFind uf(N);
	cin >> M;
	for (int i = 0; i < M; i++) {
		cin >> s >> t;
		uf.Union(lower_bound(a.begin(), a.end(), s) - a.begin(), lower_bound(a.begin(), a.end(), t) - a.begin());
	}
	int res = 0;
	for (int i = 0; i < N; i++) {
		res += uf.Val(i);
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;

#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <climits>
using Graph = vector<vector<int>>;
const double PI = 3.14159265358979323846;
#define int long long


signed main() {

	const int SIZE = 200020;
	const int IX = 1000000007;

	int N;
	int A[SIZE];

	cin >> N;
	
	int sum = 0;

	for (int i = 0; i < N; i++) {
		cin >> A[i];
		sum += A[i];
	}

	int ans = 0;

	for (int i = 0; i < N; i++) {
		sum -= A[i];
		ans = (ans + (sum%IX)*(A[i]%IX)) % IX;
	}




	cout << ans << endl;

	cin >> ans;

	return 0;


}



Measured memory_bytes: 5184
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

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


signed main(void) {
    string s;
    int n,a,b,c;
    cin >> n;
    cout << n*n*n << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    vector<int> temp (10, 0);
    temp[a] = 1;
    temp[b] = 1;
    temp[c] = 1;
    int sum = 0;
    for(auto i: temp) sum += i;
    if(sum == 2) {
        cout << "Yes" << endl;
    } else cout <<"No" << endl;
    return 0;
}

Measured memory_bytes: 888