akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<char>> hw(h, vector<char>(w));
    int black_num = 0;
    rep(i, h) rep(j, w) {
        cin >> hw[i][j];
        if (hw[i][j] == '#') ++black_num;
    }
    queue<pair<int, int>> que;
    que.push(make_pair(0, 0));
    int dx[4] = {1, -1, 0, 0};
    int dy[4] = {0, 0, 1, -1};
    vector<vector<int>> cnt(h, vector<int>(w, -1));
    cnt[0][0] = 0;
    while(!que.empty()) {
        pair<int, int> now = que.front(); que.pop();
        if (now.first == h-1 && now.second == w-1) {
            break;
        }
        rep(ri, 4) {
            int y = now.first + dy[ri];
            int x = now.second + dx[ri];
            if (x < 0 || x >= w || y < 0 || y >= h) continue;
            if (hw[y][x] == '#') continue;
            if (cnt[y][x] != -1) continue;
            que.push(make_pair(y, x));
            cnt[y][x] = cnt[now.first][now.second] + 1;
        }
    }
    if (cnt[h-1][w-1] == -1) {
        cout << -1 << endl;
    }
    else {
        cout << h * w - black_num - cnt[h-1][w-1] - 1 << endl; 
    }
    return 0;
}


Measured memory_bytes: 3676
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
 
public class Main {

  public static void main(String[] args) throws IOException {
    try ( BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) ) {

      String[] lines = br.readLine().split(" ");
      int n = Integer.parseInt(lines[0]);
      int m = Integer.parseInt(lines[1]);
      int l = Integer.parseInt(lines[2]);
      long[][] mA ; // = new long[n][m];
      long[][] mB ; // = new long[m][l];
      long[][] mC = new long[n][l];

      Function<String,long[]> lineSplitThenArray =
        s -> Stream.of(s.split(" "))
          .mapToLong(Long::parseLong)
          .toArray();
      
      mA =
        br.lines()
          .limit(n)
          .map( lineSplitThenArray )
          .toArray(long[][]::new);

      mB =
        br.lines()
          .limit(m)
          .map( lineSplitThenArray )
          .toArray(long[][]::new);

      for( int i = 0; i < n; i++ ) {
        for( int j = 0; j < l; j++ ){
          for( int k = 0; k < m; k++ )
          mC[i][j] += mA[i][k] * mB[k][j];
        }
      }

      System.out.println(
        Stream.of(mC)
              .map( a -> ArrayToString(a) )
              .collect(Collectors.joining("\n"))
      );
    }
  }

  public static String ArrayToString(long[] a) {
      if (a == null)
          return "null";
      int iMax = a.length - 1;
      if (iMax == -1)
          return "[]";

      StringBuilder b = new StringBuilder();
      for (int i = 0; ; i++) {
          b.append(a[i]);
          if (i == iMax)
              return b.toString();
          b.append(" ");
      }
  }
}


Measured memory_bytes: 36752
#include <stack>
#include <queue>
#include <cstdio>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
#define INF (1<<29)
#define test cout << "test" << endl;

int abs(int a,int b){
	if(a>b) return a-b;
	else return b-a;
}	

int main (){
	int a,b,c,d;
	cin >> a>> b>>c>>d;
	if(abs(a,c)<=d){
		cout << "Yes" << endl;
		return 0;
	}
	else if (abs(a,b)<=d && abs(b,c)<=d){
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll int64_t
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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


int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int A[2020202],B[2020202],C[10101];
int n;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n;
    REP(i,n) cin>>A[i+1];
    REP(i,10101) C[i]=0;

    for(int j=1;j<=n;j++) C[A[j]]++;
    for(int i=1;i<10101;i++) C[i]+=C[i-1];
    for(int j=n;j>=1;j--){
        B[C[A[j]]]=A[j];
        C[A[j]]--;
    }
    REP(i,n){
        if(i) cout<<" ";
        cout<<B[i+1];
    }
    cout<<endl;
}


Measured memory_bytes: 18852
#include <bits/stdc++.h>
using namespace std;
const int inf = 100000000;
int ad_matrix[1000][1000], a[1000], b[1000], c[1000];

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

    for (auto i = 0; i < n; i++)
    {
        for (auto j = 0; j < n; j++)
        {
            if (i == j)
            {
                ad_matrix[i][j] = 0;
            }
            else
            {
                ad_matrix[i][j] = inf;
            }
        }
    }

    for (auto i = 0; i < m; i++)
    {
        int a_i, b_i, c_i;
        cin >> a_i >> b_i >> c_i;
        a_i -= 1;
        b_i -= 1;
        a[i] = a_i;
        b[i] = b_i;
        c[i] = c_i;
        ad_matrix[a_i][b_i] = min(ad_matrix[a_i][b_i], c_i);
        ad_matrix[b_i][a_i] = min(ad_matrix[b_i][a_i], c_i);
    }

    for (auto k = 0; k < n; k++)
    {
        for (auto i = 0; i < n; i++)
        {
            for (auto j = 0; j < n; j++)
            {
                ad_matrix[i][j] = min(ad_matrix[i][j], ad_matrix[i][k] + ad_matrix[k][j]);
            }
        }
    }

    int ans = m;

    for (auto i = 0; i < m; i++)
    {
        bool shortest = false;
        for (auto j = 0; j < n; j++)
        {
            if (ad_matrix[j][a[i]] + c[i] == ad_matrix[j][b[i]])
            {
                shortest = true;
            }
        }
        if (shortest)
        {
            ans -= 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long A = scanner.nextLong();
        long B = scanner.nextLong();
        long C = scanner.nextLong();

        long K = scanner.nextLong();

        long result;

        if (A >= K) {
            result = K;
        }
        else if (B >= K - A) {
            result = A;
        } else {
            result = -1 * (K - A - B) + A;
        }

        System.out.println(result);
    }
}


Measured memory_bytes: 26996
#include<stdio.h>
int N, A, maxi = 0;
long ans = 0;
int main(){
	scanf("%d", &N);
	while(N--){
		scanf("%d", &A);
		if(maxi > A){
			ans += maxi - A;
		}else {
			maxi = A;
		}
	}
	printf("%ld\n", ans);
	return 0;
}

Measured memory_bytes: 1732
using System;
using System.Linq;
using System.Collections.Generic;

class P
{
    static void Main()
    {
        int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine((s[0] * 100 + s[1] * 10 + s[2]) % 4 == 0 ? "YES" : "NO");
    }
}

Measured memory_bytes: 13268
#include "bits/stdc++.h"
using namespace std;
const int N = 1e5 + 5;
int n;
int a , b;
vector < int > v[N];
int ans;
int dfs(int node , int parent){
	int res = 0;
	for(int next : v[node]){
		if(next != parent){
			res ^= dfs(next , node) + 1;
		}
	}
	return res;
}
int main(){
	scanf("%d" , &n);
	for(int i = 1 ; i < n ; ++i){
		scanf("%d %d" , &a , &b);
		v[a].emplace_back(b);
		v[b].emplace_back(a);
	}
	ans = 0;
	for(int x : v[1]){
		ans ^= dfs(x , 1) + 1;
	}
	if(ans){
		printf("Alice\n");
	}
	else{
		printf("Bob\n");
	}
}

Measured memory_bytes: 10368
#include <iostream>
#include<bits/stdc++.h>
#include<vector>
#define ll long long
using namespace std;
int main(){
    ll n;
    cin>>n;
    vector<ll>v(n);
    for(ll i=0;i<n;i++)
     cin>>v[i];
     sort(v.rbegin(),v.rend());
     ll sum=0;
     if(n==2)
    {
        cout<<v[0]<<endl;
    }
    else
    {
        ll r=n-2;
        sum+=v[0];
        if(r%2==0)
        {
            ll t=r/2;
            for(ll i=1;i<=t;i++)
            sum+=v[i]*2;
            cout<<sum<<endl;
        }
        else
        {
            ll t1=r/2;
            for(ll i=1;i<=t1;i++)
            sum+=v[i]*2;
            sum+=v[t1+1];
            cout<<sum<<endl;
        }
    }
   return 0; 
}


Measured memory_bytes: 4852
// organize and work - Abhinav IIITA
#include <bits/stdc++.h>
using namespace std;
#define int long long 
vector<int> adj[100005];
bool vis1[100005],vis2[100005];
int l1[100005],l2[100005];
void dfs1(int s,int d){
	vis1[s]=true;
	l1[s]=d;
	for(int i=0;i<(int)adj[s].size();++i){
		if(!vis1[adj[s][i]])
		dfs1(adj[s][i],d+1);
	}
}
void dfs2(int s,int d){
	vis2[s]=true;
	l2[s]=d;
	for(int i=0;i<(int)adj[s].size();++i){
		if(!vis2[adj[s][i]])
		dfs2(adj[s][i],d+1);
	}
}
void solve(){
	int n,u,v;
	cin>>n>>u>>v;
	u--;v--;
	for(int i=1;i<n;++i){
		int a,b;
		cin>>a>>b;
		a--;b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	dfs1(u,0);
	dfs2(v,0);
	int ans=-1;
	for(int i=0;i<n;++i)
	if(l1[i]<l2[i])
	ans=max(ans,l2[i]);
	cout<<ans-1;
	

}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;//cin>>t;
	t=1;
	while(t--)//
	solve();
	return 0;
}


Measured memory_bytes: 11520
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int INF = 100000000;
ll i,j,k;
ll mod=1000000007;

ll mypow(ll num1,ll num2){
    ll number=1;
    for(i=0;i<num2;i++){
        number*=num1;
    }
    return number;
}

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

    vector<ll> B(60,0);//2進数表示の時の、i桁目の1の個数

    for(i=0;i<n;i++){
        for(j=0;j<60;j++){
            if((a[i]>>j)&1){B[j]++;}//x桁目が1なら加算
        }
    }

    ll ans=0;
    for(i=0;i<60;i++){
        ans+=((mypow(2,i)%mod)*(B[i]*(n-B[i])%mod));//mypowをbitshiftにするとoverflow
        ans%=mod;
    }
    ans%=mod;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2560
/**
**	author : Raghav
**	codechef:raghav_456
**	codeforces:raghavramola7
**/
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void Raghav()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
struct comp {
	template <typename T>

	// Comparator function
	bool operator()(const T& l,
	                const T& r) const
	{
		if (l.second != r.second) {
			return l.second > r.second;
		}
		return l.first < r.first;
	}
};
bool compare(pair<int, int>&a, pair<int, int>&b)
{
	if (a.second == b.second)
		return a.first < b.first;
	else
		return a.second > b.second;
}
int32_t main()
{
	Raghav();
	string s;
	cin >> s;
	int ans = 0;
	int i = 0;
	while (i < 3)
	{
		if (s[i] == 'R')
			ans++;
		i++;

	}
	if (ans == 0)
		cout << 0;
	else if (ans == 3)
		cout << 3;
	else if (ans == 1)
		cout << 1;
	else
	{
		if (s[0] == s[1] || s[1] == s[2])
			cout << 2;
		else
			cout << 1;
	}
	cout << endl;
	return 0;
}

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

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vi p(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  int fail_cnt = 0;
  for (int i = 0; i < n; i++) {
    if (p[i] != (i + 1)) {
      fail_cnt++;
    }
  }
  if (fail_cnt == 2 || fail_cnt == 0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int K,A,B,i,x=0;
cin >> K;
cin >> A >> B;
for(i=A;i<=B;i++){
if(i%K==0){x++;}
}
if(x>0){cout << "OK" << endl;}else{cout << "NG" << endl;} 
return 0;
}

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

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

    int x = 0;
    std::vector<int> rain(n); // その山の降水量 - x
    for(int i=2;i<n;i+=2){
        rain[i] = (2*(a[i-1] - a[i-2]) + rain[i-2]);
        //std::cerr << rain[i] << std::endl;
    }
    x = (a[n - 1] - rain[n - 1] / 2);

    std::vector<int> ans(n);
    ans[0] = x;
    for(int i=1;i<n;i++){
        ans[i] = (a[i-1] - (ans[i-1] / 2)) * 2;
    }
    for(int i=0;i<n;i++){
        std::cout<<ans[i]<<" ";
    }
}

Measured memory_bytes: 2432
#include <string>
#include <iostream>
#include <algorithm>
#include <array>
#include <math.h>
#include <vector>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    string s;
    bool check = true;
    cin >> s;
    int len = s.size();
    for(int i = 0; i<len; i++){
        if(i%2 == 1 && s[i] == 'R'){
            check = false;
        }
        else if(i%2 == 0 && s[i] == 'L')
            check = false;
    }
    
    if(check){
        cout << "Yes" << '\n';
    }
    else
        cout << "No" << '\n';
}


Measured memory_bytes: 256
n, k = map(int, input().split())
mod = 10**9+7

def power(a, n, mod):
    bi=str(format(n,"b"))
    res=1
    for i in range(len(bi)):
        res=(res*res) %mod
        if bi[i]=="1":
            res=(res*a) %mod
    return res

X = [0]*(k+1)
ans = 0
for i in reversed(range(1, k+1)):
    temp = power(k//i, n, mod)
    j = i
    while j <= k:
        temp -= X[j]
        j += i
    ans += temp*i
    ans %= mod
    X[i] = temp
print(ans%mod)


Measured memory_bytes: 74792
<?php
fscanf(STDIN, "%d", $n);
$a = explode(' ', trim(fgets(STDIN)));
fscanf(STDIN, "%d", $q);
$sum = array_sum($a);

$cnt_array = [];
foreach ($a as $val) {
  @$cnt_array[$val] += 1;
}

for ($i = 0; $i < $q; $i++) {
  fscanf(STDIN, "%d %d", $b, $c);
  $sum -= $b * @$cnt_array[$b];
  $sum += $c * @$cnt_array[$b];
  @$cnt_array[$c] += $cnt_array[$b];
  $cnt_array[$b] = 0;
  echo $sum . PHP_EOL;
}

Measured memory_bytes: 28204
Scanf.scanf "%d %d" (fun n m ->
    let module S = Set.Make (struct type t = int let compare = compare end) in
    let mat = Array.make_matrix n n (max_int / 1000, S.empty) in
    for i = 0 to n - 1 do mat.(i).(i) <- 0,S.empty done;
    for i = 0 to m - 1 do
        Scanf.scanf " %d %d %d" (fun a b c ->
            let a = a - 1 in let b = b - 1 in
            mat.(a).(b) <- c, S.singleton i;
            mat.(b).(a) <- c, S.singleton i;
        )
    done;
    for k = 0 to n - 1 do
        for i = 0 to n - 1 do
            for j = 0 to n - 1 do
                let d1, s1 = mat.(i).(j) in
                let d2, s2 = mat.(i).(k) in
                let d3, s3 = mat.(k).(j) in
                if d1 > d2 + d3 then mat.(i).(j) <- d2 + d3, S.union s2 s3
            done
        done
    done;
    let edge = Array.make m false in
    for i = 0 to n - 1 do
        for j = 0 to n - 1 do
            let _, s = mat.(i).(j) in
            S.iter (fun v -> edge.(v) <- true) s
        done
    done;
    Array.fold_left (fun acc v -> if v then acc else acc + 1) 0 edge |> Printf.printf "%d\n"
)


Measured memory_bytes: 7040
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　 |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/



int N;
string W[101010];
int dp[101010], opt[101];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> W[i];

    rep(i, 0, N + 1) dp[i] = inf;
    dp[0] = 0;
    rep(i, 0, 26) opt[i] = inf;

    rep(i, 1, N + 1) {
        int c = W[i - 1].front() - 'a';
        chmin(opt[c], dp[i - 1]);
        
        dp[i] = opt[c] + 1;
    }

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



Measured memory_bytes: 9276
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    ll A,B,C; cin >> A >> B >> C;
    if(A+B >= C) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

S = list(input())
T = list(input())

if len(T) == len(S) + 1:
    flag = True
    for i in range(len(S)):
        if S[i] != T[i]:
            flag = False
    if flag:
        print('Yes')
    else:
        print('No')
else:
    print('No')


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b + c >= 22) cout << "bust" << endl;
	else cout << "win" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef double db; 
typedef string str; 
 
typedef pair<int,int> pi;
typedef pair<ll,ll> pl; 
typedef pair<db,db> pd; 
 
typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<db> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 
typedef vector<pd> vpd;
typedef vector<vi> vvi; 
 
typedef set<int> si;
 
#define mp make_pair
#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend() 
#define rsz resize
#define ins insert 
#define ft front() 
#define bk back()
#define pf push_front 
#define pb push_back
#define eb emplace_back 
#define lb lower_bound 
#define ub upper_bound
#define ts to_string 
 
int cdiv(int a, int b) { return a/b+!(a<0||a%b == 0); }
str tb(int x) {str ans; int c = x; for(int i = log2(x); i >= 0; --i){if(pow(2,i) <= c){ ans += "1"; c-=pow(2,i); } else { ans += "0"; } } return ans;}
bool ispr(int x){ for(int i = 2; i <= x/2; ++i){ if(x%i == 0){ return false; } }return true; } 
 
const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5; 
const ll INF = 1e18; 
 
void solve(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	d-=a;
	int ans = a-abs(min(0,d));
	d-=b;
	if(d > 0){
		ans-=d;
	}
	cout << ans;
			
}
 
int main(){
	std::ios::sync_with_stdio(0); std::cin.tie(0);
	
	bool isT = 0;
	if(isT){
		int t; cin >> t; while(t--){
			solve();
			cout << "\n";
		}
		return 0;
	}
	solve();
	cout << "\n";		
	return 0;
}


Measured memory_bytes: 3672
//g++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

ll keisan(int x){
  if(x == 0) return 2;
  if(x == 1) return 1;
  ll ans = 0;
  ans = keisan(x-1) + keisan(x-2);
  return ans;
}

int main(){
  ll N;
  cin >> N;
  vector<ll> ryuka(100, 0);
  ryuka[0] = 2;
  ryuka[1] = 1;
  for(int i = 2; i < 87; i++){
    ryuka[i] = ryuka[i-1] + ryuka[i-2];
  }


  cout << ryuka[N] <<endl;



}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n;
	cin >> n;
	int ok = 1;
	while (n--) {
		int x;
		cin >> x;
		if (x % 2 == 0) {
			ok &= (x % 3 == 0) || (x % 5 == 0);
		}
	}
	if (ok) cout << "APPROVED";
	else cout << "DENIED";
}


Measured memory_bytes: 888
#include<iostream>

using namespace std;
/*
 * 冒泡排序思路：
 * 1. 进行n-1轮冒泡
 * 2. 每一轮冒泡排序，通过相邻元素比较和交换将排序后的最后一个元素归位
 * */

int bubbleSort(int a[], int n){
    int count = 0;
    for (int i = 0; i < n-1; i++){
        for (int j = 0; j < n-i-1; j++){
            if (a[j] > a[j+1]){
                swap(a[j], a[j+1]);
                count++;
            }
        }
    }
    return count;
}

int main(){
    int n, count;
    int a[100];
    cin>>n;
    for (int i = 0; i < n; i++){
        cin>>a[i];
    }
    count = bubbleSort(a, n);
    for (int i = 0; i < n; i++){
        if (i != n-1){
            cout<<a[i]<<" ";
        }else{
            cout<<a[i]<<endl;
        }
    }
    cout<<count<<endl;
    return 0;
}


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

/*int l[100001];
int r[100001];
int templ[100001];
int tempr[100001];
void margesort(int a[], int a_len, int left, int right);
*/
long long modpow(long long a, long long n, long long mod);
long long modinv(long long a, long long mod);


int main(){
	//C
	long long int n;
	long long int p = 998244353;
	cin >> n;
	n = n / 2;
	long long int counter = 0;
	long long int comb = 1;
	int i;
	for (i = 0; i < n; i++) {
		counter = (counter + 2 * comb) % p;
		comb = (comb * 2 * (2 * n - i)) % p;
		comb = (comb * modinv(i + 1, p)) % p;
	}
	long long int absum = 1;
	for (i = 0; i < 2 * n; i++) {
		absum = (absum * 3) % p;
	}
	absum = (absum - counter + p) % p;
	cout << absum;
	return 0;
	/*int n;

	int i;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> l[i];
		cin >> r[i];
	}
	margesort(l, n, 0, n - 1);
	int minR, min2R, maxL, max2L;
	minR = 1000000001;
	min2R = 1000000001;
	maxL = 0;
	max2L = 0;
	int maxwidth = 0;
	for (i = 0; i < n; i++) {
		if (r[i] <= minR) {
			min2R = minR;
			minR = r[i];
		}
		else if (r[i] < min2R) {
			min2R = r[i];
		}
		if (l[i] >= maxL) {
			max2L = maxL;
			maxL = l[i];
		}
		else if (l[i] > max2L) {
			max2L = l[i];
		}
	}

	int ll, rr;
	for (i = 0; i < n; i++) {
		if (r[i] == minR) {
			rr = min2R;
		}
		else {
			rr = minR;
		}
		if (l[i] == maxL) {
			ll = max2L;
		}
		else {
			ll = maxL;
		}
		if (rr - ll >= 0) {
			if (rr - ll + r[i] - l[i] + 2 > maxwidth) {
				maxwidth = rr - ll + r[i] - l[i] + 2;
			}
		}
		else {
			if (r[i] - l[i] + 1 > maxwidth) {
				maxwidth = r[i] - l[i] + 1;
			}
		}
	}
	
	min2R = r[n - 1];
	max2L = l[n - 1];
	int j,w1,w2;
	for (i = n-2; i > 0; i--) {
		if (r[i] < min2R) {
			min2R = r[i];
		}
		if (l[i] > max2L) {
			max2L = l[i];
		}
		maxL = l[i - 1];
		if (r[i] == minR) {
			minR = 1000000001;
			for (j = 0; j < i; j++) {
				if (r[j] < minR) {
					minR = r[j];
				}
			}
		}
		if (min2R - max2L >= 0) {
			w2 = min2R - max2L + 1;
		}
		else {
			w2 = 0;
		}
		if (minR - maxL >= 0) {
			w1 = minR - maxL + 1;
		}
		else {
			w1 = 0;
		}
		if (w1 + w2 > maxwidth) {
			maxwidth = w1 + w2;
		}
	}
	cout << maxwidth;
	return 0;
	*/
}
/*
void margesort(int a[], int a_len, int left, int right){
	int i, j, mid, L, R;

	if (right <= left)
		return;

	mid = (left + right) / 2;
	margesort(a, mid, left, mid);
	margesort(a, a_len - mid, mid + 1, right);

	for (i = left; i <= mid; i++) {
		templ[i] = a[i];
		tempr[i] = r[i];
	}
	for (i = mid + 1, j = right; i <= right; i++, j--) {
		templ[i] = a[j];
		tempr[i] = r[j];
	}
	L = left;
	R = right;

	for (i = left; i <= right; i++)
	{
		if (templ[L] <= templ[R])
		{
			a[i] = templ[L];
			r[i] = tempr[L];
			L++;
		}
		else
		{
			a[i] = templ[R];
			r[i] = tempr[R];
			R--;
		}
	}*/
	// a^n mod を計算する

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

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
	return modpow(a, mod - 2, mod);
}



Measured memory_bytes: 256
import sys
import math

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

n = ini()
T = [ini() for _ in range(n)]


def solve():
    a = T[0]
    for t in T[1:]:
        g = math.gcd(a, t)
        a = g * (a // g) * (t // g)
    return a


print(solve())


Measured memory_bytes: 9052
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
//V<ll>fac,rfac;void setFac(int n,int mod){fac=rfac=V<ll>(++n);fac[0]=1;FOR(i,1,n)fac[i]=fac[i-1]*i%mod;rfac[n-1]=modInv(fac[n-1],mod);FORR(i,n-1,1)rfac[i-1]=rfac[i]*i%mod;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int n, l;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> l;
  int s = l*n + n*(n-1)/2;
  int d;
  if(l>=0){
    d = l;
  }else if(l+n > 0){
    d = 0;
  }else{
    d = l+n-1;
  }
  cout << s-d << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
#define double long double
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main(){
    int n; lint K;
    scanf("%d%lld", &n, &K);
    int to[61][n];
    rep(i, n){
        scanf("%d", &to[0][i]);
        --to[0][i];
    }
    For(k, 1, 61)rep(i, n) to[k][i] = to[k-1][to[k-1][i]];
    int ans = 0;
    rep(k, 61)if(K>>(lint)k & 1) ans = to[k][ans];
    printf("%d\n", ans + 1);
}

Measured memory_bytes: 51484
/*
https://emtubasa.hateblo.jp/entry/2019/03/14/000000_1
勉強させていただいた記事
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()

int main(){
    int N;
    cin>>N;
    vector<int> A(N),T(N);
    rep(i,N)cin>>T[i]>>A[i];

    ll Ta=1,Ao=1;
    rep(i,N){
        ll n=max((Ta+T[i]-1)/T[i],(Ao+A[i]-1)/A[i]);//割る数を足しておくことで繰り上げをすることができる
        //1をマイナスしておかないと1で割るときに二つ繰り上げとなってしまうので引いておく
        Ta=T[i]*n;
        Ao=A[i]*n;
    }
    cout<<Ta+Ao<<endl;
    return 0;
}

//a=97,z=122

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

int main(){
	char mas[3][3];
	while(cin >> mas[0][0]){
		cin >> mas[0][1] >> mas[0][2];
		for(int i=1;i<3;i++){
			for(int j=0;j<3;j++){
				cin >> mas[i][j];
			}
		}
		bool flg = true;
		for(int i=0;i<3;i++){
			if(mas[i][0]=='o' && mas[i][1]=='o' && mas[i][2]=='o'){
				cout << "o" << endl;
				flg = false;
			}
			else if(mas[i][0]=='x' && mas[i][1]=='x' && mas[i][2]=='x'){
				cout << "x" << endl;
				flg = false;
			}
		}
		for(int i=0;i<3;i++){
			if(mas[0][i]=='o' && mas[1][i]=='o' && mas[2][i]=='o'){
				cout << "o" << endl;
				flg = false;
			}
			else if(mas[0][i]=='x' && mas[1][i]=='x' && mas[2][i]=='x'){
				cout << "x" << endl;
				flg = false;
			}
		}
		if(mas[0][0]=='o' && mas[1][1]=='o' && mas[2][2]=='o'){
			cout << "o" << endl;
			flg = false;
		}
		if(mas[0][0]=='x' && mas[1][1]=='x' && mas[2][2]=='x'){
			cout << "x" << endl;
			flg = false;
		}
		if(mas[0][2]=='o' && mas[1][1]=='o' && mas[2][0]=='o'){
			cout << "o" << endl;
			flg = false;
		}
		if(mas[0][2]=='x' && mas[1][1]=='x' && mas[2][0]=='x'){
			cout << "x" << endl;
			flg = false;
		}
		if(flg) cout << "d" << endl;
	}
}

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

//===


const int INF = int(1e9 + 7);


int main() {
	int N;
	cin >> N;
	Vi A(N);
	ll sum = 0;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		sum += A[i];
	}
	Vl ans(N);
	ans[0] = sum;
	for (int i = 1; i <= N - 2; i += 2) {
		ans[0] -= 2*A[i];
	}
	for (int i = 0; i < N - 1; ++i) {
		ans[i + 1] = 2 * A[i] - ans[i];
	}
	for (int i = 0; i < N - 1; ++i) {
		cout << ans[i] << " ";
	}
	cout << ans[N - 1] << endl;
}


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

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

    int a; cin >> a;
    string s; cin >> s;

    if(a >= 3200)
        cout << s;
    else if(a < 3200)
        cout << "red";

    return 0;
}

Measured memory_bytes: 256
M = 1000000007
def nCr(n, r, M):
    return fact[n] * inv[n-r] % M * inv[r] % M


n = int(input())

fact = [1] * (n + 1)
inv = [1] * (n + 1)

for i in range(1, n + 1):
    fact[i] = fact[i-1] * i % M

inv[n] = pow(fact[n], M - 2, M)
for i in range(n-1, -1, -1):
    inv[i] = inv[i + 1] * (i + 1) % M
pw2 = [1]
for _ in range(n+1):
    pw2.append((pw2[-1]*2)%M)
pw8 = [1]
for _ in range(n+1):
    pw8.append((pw8[-1]*8)%M)
    
mod = 10**9+7
ans = 0
for i in range(2,n+1):
    if pw2[i]-2==-1:
        t = 10**9+6
    elif pw2[i]-2==-2:
        t = 10**9+5
    else:
        t = pw2[i]-2
    #print(n-i,len(pw8))
    temp = nCr(n, i, M) * t * pw8[n-i]
    temp %= M
    ans += temp
    ans %= M
print(ans)

Measured memory_bytes: 166768
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;

int main(void)
{
    int n;
    int p[21];

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

    int ctr = 0;
    for (int i = 1; i < n - 1; i++)
    {
        if (((p[i] > p[i - 1]) &&
             (p[i] < p[i + 1])) ||
            ((p[i] < p[i - 1]) &&
             (p[i] > p[i + 1])))
        {
            ctr++;
        }
    }

    cout << ctr;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int a,b[110000],d[110000],cnt=0;
string s;
char c;
pair<int,int> p[110000];
signed main()
{
	cin>>a;
	d[0]=1000000;
	rep(i,a-1){
		cin>>b[i];
		d[i]=min(d[i],b[i]);
		d[i+1]=b[i];
	}
	rep(i,a){
		cnt+=d[i];
	}
	cout<<cnt;
}

Measured memory_bytes: 256
// E.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <numeric>

using namespace std;
typedef long long LL;

const LL MOD = 1000000007;

struct modll {
	long long x;
	modll() { }
	modll(int _x) : x(_x) { }
	operator int() const { return (int)x; }
	modll operator+(int y) { return (x + y + MOD) % MOD; }
	modll operator+=(int y) { x = (x + y + MOD) % MOD; return *this; }
	modll operator-(int y) { return (x - y + MOD) % MOD; }
	modll operator-=(int y) { x = (x - y + MOD) % MOD; return *this; }
	modll operator*(int y) { return (x * y) % MOD; }
	modll operator*=(int y) { x = (x * y) % MOD; return *this; }
	modll operator/(int y) { return (x * modpow(y, MOD - 2)) % MOD; }
	modll operator/=(int y) { x = (x * modpow(y, MOD - 2)) % MOD; return *this; }
	static modll modinv(int a) { return modpow(a, MOD - 2); }
	static modll modpow(int a, int b) {
		modll x = a, r = 1;
		for (; b; b >>= 1, x *= x) if (b & 1) r *= x;
		return r;
	}
};

LL solve(LL n, LL k, vector<LL> a) {
	modll ans = 0;
	LL zc = 0, r = k;
	vector<LL> pos, neg;
	for (LL i = 0; i < n; ++i) {
		if (a[i] > 0) {
			pos.emplace_back(a[i]);
		} else if (a[i] == 0) {
			++zc;
		} else {
			neg.emplace_back(-a[i]);
		}
	}
	LL nc = min(LL(neg.size() & ~1), k & ~1);
	if (nc + pos.size() >= k) {
		sort(pos.rbegin(), pos.rend());
		sort(neg.rbegin(), neg.rend());
		LL pi = 0, ni = 0;
		ans = 1;
		while (r > 0) {
			LL pp = pi + 2 <= pos.size() ? pos[pi] * pos[pi + 1] : 0;
			LL nn = ni + 2 <= neg.size() ? neg[ni] * neg[ni + 1] : 0;
			if (r >= 2 && (nn > pp || pi >= pos.size() - 1)) {
				r -= 2;
				ans *= int(MOD - neg[ni++]);
				ans *= int(MOD - neg[ni++]);
			} else {
				--r;
				ans *= int(pos[pi++]);
			}
		}
	} else if (!zc) {
		sort(neg.begin(), neg.end());
		ans = 1;
		for (auto x : neg) {
			if (r-- <= 0) break;
			ans *= int(MOD - x);
		}
		for (auto x : pos) {
			if (r-- <= 0) break;
			ans *= int(x);
		}
	}

	return ans;
}

int main(int argc, char* argv[]) {
	cout.precision(20);
#ifdef _MSC_VER
	while (true)
#endif
	{
		LL n = -1, k = -1;
		cin >> n >> k;
		if (n < 0) return 0;
		vector<LL> a(n);
		for (LL i = 0; i < n; ++i) {
			cin >> a[i];
		}
		LL ans = solve(n, k, a);
		cout << ans << endl;
	}
	return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int a,b,h;
  cin>>a>>b>>h;
  cout<<(a+b)*h/2<<endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int maxn = 5050;
bool good(int a, int b, int c){
    int tm = min({a, b, c});
    a -= tm;
    b -= tm;
    c -= tm;
    if(a == 0 && b == 0 && c == 0) return true;
    if(a == 1 && b == 0 && c == 0) return true;
    if(a == 1 && b == 1 && c == 0) return true;
    return false;
}
int main(){
    string s;
    cin >> s;
    int a = 0, b = 0, c = 0;
    for(auto it : s){
        a += it == 'a';
        b += it == 'b';
        c += it == 'c';
    }
    bool ok = false;
    ok |= good(a, b, c);
    ok |= good(a, c, b);
    ok |= good(b, a, c);
    ok |= good(b, c, a);
    ok |= good(c, a, b);
    ok |= good(c, b, a);
    if(ok) printf("YES\n");
    else printf("NO\n");
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;

int main(){
  int n,a,b;
  cin>>n>>a>>b;
  int p[n];
  for(int i=0;i<n;++i){
    cin>>p[i];
  }
  sort(p,p+n);
  int p1=0,p2=0,p3=0;
  for(int i=0;i<n;++i){
    if(p[i] <= a){
      ++p1;
    }
    else if(p[i] <= b){
      ++p2;
    }
    else{
      ++p3;
    }
  }
  int MIN=114514;
  MIN = min(MIN,p1);
  MIN = min(MIN,p2);
  MIN = min(MIN,p3);

  cout<<MIN;
}

Measured memory_bytes: 256
#include<cstdio>
int main()
{
	long long n,m,ans=0;
	scanf("%lld%lld",&n,&m);
	if(m==0)
	{
		printf("0\n");
		return 0; 
	}
	ans=m-n*2;
	if(ans<0)
	{
		printf("%lld\n",m/2);
		return 0;
	} 
	printf("%lld\n",n+ans/4);
	return 0;
}

Measured memory_bytes: 128
N, K = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]

A.sort(key=lambda x: x[0])

cnt = 0

for ab in A:
    a = ab[0]
    b = ab[1]

    cnt += b
    if cnt >= K:
        print(a)
        exit()

Measured memory_bytes: 28656
def f_distinct_numbers():
    # 参考: http://drken1215.hatenablog.com/entry/2019/10/20/003400
    from collections import Counter
    N = int(input())
    A = [int(i) for i in input().split()]

    c = [0] * (N + 1)  # c[k]: A の中に k が何回現れたか
    d = [0] * (N + 1)  # d[x]: c の中に x 以上の要素が何個あるか (0番は使わない)
    for a in A:
        c[a] += 1
        d[c[a]] += 1

    cumsum = [0] * (N + 1)  # リスト d の累積和
    judge = [0] * (N + 1)
    for i in range(1, N + 1):
        cumsum[i] = cumsum[i - 1] + d[i]
        judge[i] = cumsum[i] // i

    # 各 k ごとに k <= cumsum[x] // x (judge[x]) を満たす最大の x を求める
    ans = []
    x = N
    for k in range(1, N + 1):
        while x > 0 and k > judge[x]:  # 条件を満たさなくなるまで x を減らす
            x -= 1
        ans.append(x)
    return ' '.join(map(str, ans))

print(f_distinct_numbers())

Measured memory_bytes: 57428
s = list(input())
min = 200000
max = 0

for i in range(len(s)):
    if s[i] == 'A':
        if min > i:
            min = i
    if s[-i] == 'Z' and i != 0:
        if max < len(s) - i:
            max = len(s) - i

print(max-min+1)


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

bool isPrime(int num){
    if(num == 2){
        return true;
    }

    if(num < 2 || num%2 == 0){ //1の時と偶数の時を排除する
        return false;
    }

    int i = 3;
    while(i <= sqrt(num)){
        if(num%i == 0){
            return false;
        }
        i += 2; //偶数はすべて素数ではないので、iが奇数になるようにする
    }

    return true;
}

int main(){
    int n, num, count=0;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> num;
        if(isPrime(num) == true){
            count++;
        }
    }

    cout << count << endl;
}


Measured memory_bytes: 3040
a,b,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

cost = []
for i in range(m):
  x,y,c = map(int,input().split())
  cost.append(a[x-1]+b[y-1]-c)
a.sort()
b.sort()
res = a[0] + b[0]
for i in cost:
  res = min(i,res)
print(res)


Measured memory_bytes: 18736
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds; 
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define T pair<int, int>
#define ordered_set tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>
#define int long long
#define MOD 1000000007
#define pb push_back 
#define ins insert
#define fast(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ld long double
#define endl '\n'
int m(int a) {
    return ((a%MOD)+MOD)%MOD;
}
int p(int a, int b) {
    if (b==0) return (int)1;
    int x = p(a, b>>1);
    if (b & 1) return m(x*m(a*x));
    return m(x*x);
}
signed main(){
    fast();
    int n, k;
    cin >> n >> k;
    vector<int> dp(k+1, 0);
    for(int i=k; i>=1; i--){
        int facts = k/i;
        dp[i] = p(facts, n);
        for(int j=i*2; j<=k; j+=i){
            dp[i] -= dp[j];
        }
    }
    // for(int i=k; i>=1; i--){
    //     cerr << dp[i] << " ";
    // }
    // cerr << endl;
    int ans = 0;
    for(int i=1; i<=k; i++){
        ans = m(m(ans)+m(m(dp[i])*m(i)));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3988
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

 
int main(){
  int a,b,k;
  cin >> a >> b >> k;
  if(b-a+1<=k*2){
    for(int i=a; i<=b; i++) cout << i << endl;
    return 0;
  }
  for(int i=a; i<a+k; i++) cout << i << endl;
  for(int i=b-k+1; i<=b; i++) cout << i << endl;
  return 0;
}


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

using namespace std;

void solve(void)
{
	int n, ans = 0;
	string s;
	cin >> n >> s;
	for (char x : s)
	{
		if (x == 'R') ans++;
		else ans--;
	}
	cout << (ans > 0 ? "Yes" : "No") << endl;
}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


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

const int maxn(2e5 + 5);

int n, x[maxn], y[maxn], bmx, bmn, rmx, rmn;
int premn[maxn], premx[maxn];
ll ans;
pair <int, int> vxy[maxn];

int main() {
	int i, p1, p2;
	scanf("%d", &n), rmn = bmn = 1e9;
	for (i = 1; i <= n; ++i) {
		scanf("%d%d", &x[i], &y[i]);
		if (x[i] > y[i]) swap(x[i], y[i]);
		bmx = max(bmx, y[i]), rmn = min(rmn, x[i]);
		rmx = max(rmx, x[i]), bmn = min(bmn, y[i]);
	}
	ans = (ll)(bmx - bmn) * (rmx - rmn);
	for (i = 1; i <= n; ++i) vxy[i] = make_pair(x[i], y[i]);
	bmn = rmn, sort(vxy + 1, vxy + n + 1);
	premn[1] = premx[1] = vxy[1].second;
	for (i = 2; i <= n; ++i) {
		premx[i] = max(premx[i - 1], vxy[i].second);
		premn[i] = min(premn[i - 1], vxy[i].second);
		if (i ^ n) ans = min(ans, (ll)(bmx - bmn) * (max(premx[i], vxy[n].first) - min(premn[i], vxy[i + 1].first)));
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main() {

	int N,ans=0;
  string lS,rS;
	cin>>N>>lS;
 
  
  for(int i=0; i<N; i++){
    rS.push_back(lS.at(0));
    lS.erase(lS.begin());
    int cnt=0;
    map<char,int> m;
    for(int j=0; j<rS.size(); j++){  
      if(!m.count(rS.at(j)))m[rS.at(j)]=1;
      else{continue;}
      for(int k=0;k<lS.size(); k++){
       if(rS.at(j)==lS.at(k)){cnt++;break;}
      }
    if(cnt>ans)ans=cnt;
    }  
  }
	
	cout<<ans<<endl;
}



Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
MOD = 10**9+7

#以下が an mod p を求めるソースコードです.
def power_func(a,n,p):
  bi=str(format(n,"b"))#2進表現に
  res=1
  for i in range(len(bi)):
    res=(res*res) %p
    if bi[i]=="1":
      res=(res*a) %p
  return res


A.sort()
if N % 2 == 0 and A == [2*(i // 2)+1 for i in range(N)] or\
        N % 2 == 1 and A == [2*((i+1) // 2) for i in range(N)]:
    #print(2**(N // 2))
    print(power_func(2,N//2,MOD))
else:
    print(0)

Measured memory_bytes: 14008
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, k, ans;
	cin >> n >> k;
	ans = (n - 1 + k - 2) / (k - 1);
	cout << ans << "\n";


	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	static Scanner sc;
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x[] = new int[n];
		int y[] = new int[n];
		for (int i=0; i<n; i++){
			x[i] = sc.nextInt()-x[0];
			y[i] = sc.nextInt()-y[0];
		}
		double area = 0;
		for (int k = 1; k<n-1; k++){
			area += x[k]*y[k+1]-x[k+1]*y[k];
		}
		System.out.printf("%.1f\n", Math.abs(area*0.5));
	}
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  ll m;cin>>m;
  ll result = 0;
  ll digits_counter=-1;
  ll sum=0;
  rep(i, m){
    ll d,c;cin>>d>>c;
    digits_counter+=c;
    sum+= d*c;
  }

  cout << (sum-1)/9+digits_counter << endl;

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <cstdlib>
#define PI acos(-1.0)
#define ll long long int
#define db double
#define ull unsigned long long int
#define Fill(x,y) memset(x,y,sizeof(x))
#define bug printf("!!!!!!\n");
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
using namespace std;
const db eps = 1e-6;
const int inf = 0x3f3f3f3f; //用这个可以直接mem
const ll INF = 1e18;
const int mod = 1e9+7;
const int maxn = 1e5+5;
int cas=1;
ll a[maxn], b[maxn];
void solve()
{
    ll n, h;
    cin >> n >> h;
    ll sum = 0; ll mx = 0;
    for (int i = 1 ; i <= n ; i++) {
        cin >> a[i] >> b[i];
        mx = max(mx, a[i]);
    }
    sort(b+1, b+1+n); int cnt = 0;
    int flag = 0;
    for (int i = n ; i >= 1 ; i--) {
        if (b[i] >= mx) {
            cnt++;
            sum += b[i];
        }
        if (sum >= h) {
            flag = 1;
            break;
        }
    }
    //cout << sum << endl;
    if (flag) cout << cnt << endl;
    else {
        cout << cnt + ((h - sum) + mx - 1)/ mx << endl;
    }
}
int main()
{
    // freopen("in.txt","r",stdin);
    //  freopen("out.txt","w",stdout);
    int t = 1 ;
    //scanf("%d",&t);
    while(t--){
       // printf("Case %d: ", cas++);
        solve();
        //printf("\n");
    }
}









Measured memory_bytes: 1920