akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,int> pdi;
typedef pair<double,double> pdd;
typedef pair<double,ll> pdl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<pdd> vdd;
typedef vector<pdi> vdi;
typedef vector<pdl> vdl;
typedef vector<string> vs;
#define fi first
#define se second
const ll INFLL=LLONG_MAX;
const int INF=INT_MAX;
const ll MAXLL=0x3f3f3f3f3f3f3f3f;
const int MAX=0x3f3f3f3f;
const ll MOD=1000000007;
const ll mod=998244353;
#define eb emplace_back
#define emp emplace
#define mp(a,b) make_pair(a,b)
template<class T> using min_heap=priority_queue<T,vector<T>,greater<T> >;
template<class T>
void sort(vector<T>& v){
	sort(v.begin(),v.end());
}
template <class T, class U>
void sort(vector<T>& v,U func){
	sort(v.begin(),v.end(),func);
}
template<class T>
void rsort(vector<T>& v){
	sort(v.rbegin(),v.rend());
}
template <class T>
int lb_index(vector<T>& v,T k){
	return lower_bound(v.begin(),v.end(),k)-v.begin();
}
template <class T>
int ub_index(vector<T>& v,T k){
	return upper_bound(v.begin(),v.end(),k)-v.begin();
}
template<class T>
bool is_sorted(vector<T>& v){
	return is_sorted(v.begin(),v.end());
}
template<class T>
bool sorted(vector<T>& v){
	return is_sorted(v);
}
void precompute(){

	return;
}
void solve(){
	int p=0;
	int n;
	cin>>n;
	vl v(n);
	for(int i=0;i<n;i++)cin>>v[i];
	p=v[0];
	ll ans=0;
	for(int i=1;i<n;i++){
		if(v[i]>=p)p=v[i];
		else{
			ans+=p-v[i];
		}
	}
	cout<<ans;
	return;
}

int main(){
	ios::sync_with_stdio(0);
	int numberofsubtestcases=1;
//	cin>>numberofsubtestcases;
	precompute();
	for(int looping=1;looping<=numberofsubtestcases;looping++){
//		cout<<"Case #"<<looping<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 4772
#include<bits/stdc++.h>
#define int long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
int a[10],b[10],p[10];
int cnt1,cnt2;
bool f1,f2;
int n;
signed main(){
	ios_base::sync_with_stdio(0);
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<n;i++) cin>>b[i];
	for(int i=0;i<n;i++) p[i]=i+1;
	do{
		if(f1&&f2) break;
		if(!f1) cnt1++;
		if(!f2) cnt2++;
		bool check=1;
		for(int i=0;i<n;i++){
			if(a[i]!=p[i]){
				check=0;
				break;
			}
		}
		if(check) f1=1;
		check=1;
		for(int i=0;i<n;i++){
			if(b[i]!=p[i]){
				check=0;
				break;
			}
		}
		if(check) f2=1;
	}while(next_permutation(p,p+n));
	cout<<abs(cnt1-cnt2);
	re 0;
}

Measured memory_bytes: 3512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;
 
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;
}

const int MOD = 1000000007;
const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int 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;
    }
}

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

ll nmod(ll a) {
    return ((a % MOD < 0) ? a % MOD + MOD : a % MOD);
}

int main(void)
{
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    REP(i,n){
        cin >> a[i];
    }

    ll ans = 0;
    sort(all(a));
    COMinit();

    for (int i = k - 1; i < n;i++)
    {
        ans = nmod(ans + nmod(a[i] * COM(i, k - 1)));
    }

    for (int i = 0; i <= n - k;i++){
        ans = nmod(ans - nmod(a[i] * COM(n-i-1,k-1)));
    }

    cout << ans << endl;

    return 0;
}

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

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

static const int INF = 1E8;
int n, m, s, g1, g2;
int v, w, c;
int d[111][111];

int main()
{
  while(cin >> n >> m >> s >> g1 >> g2, n){
    rep(i, n) rep(j, n) d[i][j] = INF;
    rep(i, n) d[i][i] = 0;
    rep(i, m){
      cin >> v >> w >> c;
      d[v - 1][w - 1] = c;
    }
    rep(k, n) rep(i, n) rep(j, n) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    int res = INF;
    rep(i, n) res = min(res, d[s - 1][i] + d[i][g1 - 1] + d[i][g2 - 1]);
    cout << res << endl;
  }

  return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;

int r, c;
int a[11][10001];

int main(int argc, char const* argv[])
{
	while(true){
			cin >> r >> c;
			if(r == 0)return 0;
			for(int i = 0; i < r; i++){
					for(int j = 0; j < c; j++)cin >> a[i][j];
			}
			int ans = -1;
			for(int i = 0; i < (1 << r); i++){
					int res = 0;
					for(int j = 0; j < c; j++){
							int thres = 0;
							for(int k = 0; k < r; k++){
									if((i >> k) % 2 == 0 && a[k][j] == 0)thres++;
									else if((i >> k) % 2 == 1 && a[k][j] == 1)thres++;
							}
							res += max(thres, r - thres);
					}
					ans = max(ans, res);
			}
			cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 3480
import Data.List
import Data.List.Split
import System.Environment (getArgs)

takePairs ls | ((length ls) `rem` 2) == 1 = f (0:ls) 0
             | otherwise = f ls 1
  where f l@(x:y:xs) i | (x == i) && (y == i) = f xs (i + 2)
                       | otherwise = l
        f [] _ = []

solve ls = if (null $ takePairs $ sort ls) == True then (f ((length ls) `div` 2)) else 0
  where f 0 = 1
        f n = (2 * (f (n - 1))) `rem` 1000000007

main = do
  lx <- getLine
  ln <- getLine
  let ls = map (read::String->Int) $ splitOn " " ln
  putStrLn $ show $ solve ls


Measured memory_bytes: 40316
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

vector <int> v[100010];
int t[100010], down[100010], ans = 0, n, k;

void dfs (int nod)
{
    for (auto &it : v[nod])
    {
        dfs (it);

        bool OK = true;

        if (nod == 1)
        {
            if (down[it] > k) OK = false;
        }

        else if (down[it] >= k) OK = false;

        if (!OK) ++ans;
        else down[nod] = max (down[nod], down[it]);
    }

    ++down[nod];
}

int main ()
{
  //  freopen ("file.in", "r", stdin);

    scanf ("%d %d", &n, &k);

    for (int i = 1; i <= n; ++i)
    {
        scanf ("%d", &t[i]);
        if (i > 1) v[t[i]].push_back (i);
    }

    if (t[1] != 1) ++ans;

    dfs (1);

    printf ("%d\n", ans);

    return 0;
}


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

int main() {
    int a, b, c, x; // a...500yen, b...100yen, c...50yen
    int cnt = 0;

    cin >> a >> b >> c >> x;
    for (int i=0; i<=a; i++) {
        for (int j=0; j<=b; j++) {
            for (int k=0; k<=c; k++) {
                if (500*i + 100*j + 50*k == x) {
                    cnt++;
                    continue;
                }
            }
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
import math
from collections import deque
from collections import defaultdict

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq
def get_sieve_of_eratosthenes(n):
	#data = [2]
	data = [0,0,0]
	for i in range(3,n+1,2):
		data.append(i)
		data.append(0)
	for i in range(len(data)):
		interval = data[i]
		if interval!=0:
			for j in range(i+interval,n-1,interval):
				data[j] = 0
	#ans = [x for x in data if x!=0]
	ans = data[:]
	return ans

ryuka = [-1]*87
ryuka[0] = 2
ryuka[1] = 1
for i in range(2,87):
	ryuka[i] = ryuka[i-1]+ryuka[i-2]



print(ryuka[readInt()])

Measured memory_bytes: 3444
S = list(input())

goal = [str(i%2) for i in range(len(S))]    #完成形１'01010101...'
diff1 = 0 #完成形1'01010101...'と比較したとき、異なる文字の数
diff2 = 0 #完成形2'10101010...'と比較したとき、異なる文字の数

for i in range(len(S)):
    if S[i] != goal[i]:
        diff1 += 1
    else:
        diff2 += 1
        
print(min(diff1,diff2))

Measured memory_bytes: 16840
N = int(input())
alist = list(map(int, input().split()))
alen = len(alist) 
nkei = 0
for i in range(0,alen-1):
    if alist[i] > alist[i+1]:
        n = alist[i]-alist[i+1]
        alist[i+1] = alist[i]
        nkei = nkei + n
print(nkei)

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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define debug if(true)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

bool cmp(int a, int b){
	return a > b;
}

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

	sort(a,a+n, cmp);

	int sisa = n-1;
	vi avail;
	avail.pb(a[0]);
	ll ans = 0;
	for(i=1;i<n;i++){
		if(avail.size() >= sisa){
			int idx = 0;
			for(j=i;j<n;j++){
				ans += avail[idx++];
				// printf("j: %d idx; %d\n",j, idx-1);
			}
			break;
		}else{
			int back = avail.back();
			ans += back;
			avail.pop_back();
			avail.pb(a[i]); avail.pb(a[i]);
			// printf("ans: %lld\n",ans);
			// for(j=0;j<avail.size();j++){
			// 	printf("%d ", avail[j]);
			// }
			// printf("\n");
			sisa--;
		}
	}
	printf("%lld\n",ans);
	
	return 0;
};

Measured memory_bytes: 4684
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
#include <iomanip>

int main()
{
	double r;
	std::cin >> r;	
	
	std::cout << std::fixed << std::setprecision(6) << r * r * M_PI << " ";
	std::cout << std::fixed << std::setprecision(6) << r * 2 * M_PI << std::endl;

}

Measured memory_bytes: 1288
#include <iostream>
using namespace std;
int main()
{
    int a,b,c,y;
    cin>>a>>b>>c;
    y=(a*100)+(b*10)+c;
    if(y%4==0)
    {
        cout<<"YES";
    }
    else
    {
        cout<<"NO";
    }





    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){

    
    int a,b,ans[100],i,j;
    char op;
    i=0;
    
    while(op != '?'){     
 	  scanf("%d %c %d",&a,&op,&b);
 	  
 	  if (op=='+'){
		  ans[i]=a+b;
	  }else if(op=='-'){
		  ans[i]=a-b;
	  }else if(op=='*'){
		  ans[i]=a*b;
	  }else if(op=='/'){
		  ans[i]=a/b;
	  }
 	  i++;
    }
 	  
    for (j=0;j<i-1;j++){
		printf("%d\n",ans[j]);
    }
    
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;

#define MAX 100000
#define INFTY 1 << 30
int v,r;
vector<pair<int,int> > adj[MAX];

void dijkstra(){
    priority_queue<pair<int,int> > PQ;
    int d[MAX];
    for(int i = 0; i < v; i++){
        d[i] = INFTY;
    }    
    d[r] = 0;
    PQ.push(make_pair(0,r));
    
    while(!PQ.empty()){
        pair<int,int> m = PQ.top(); PQ.pop();
        int u = m.second;

        if(d[u] < m.first*(-1)) continue;

        for(int i = 0; i < adj[u].size(); i++){
            int v = adj[u][i].first;
            if(d[u]+adj[u][i].second < d[v]){
                d[v] = d[u]+adj[u][i].second;
                PQ.push(make_pair(d[v]*(-1),v));
            }
        }
    }
        for(int i = 0; i < v; i++){
        if(d[i] < INFTY) printf("%d\n",d[i]);
        else printf("INF\n");
    }
}

int main(){
    int e,s,t,d;
    scanf("%d %d %d", &v, &e, &r);
    for(int i = 0; i < e; i++){
        scanf("%d %d %d", &s, &t, &d);
        adj[s].push_back(make_pair(t,d));
    }
    dijkstra();

    return 0;
}



Measured memory_bytes: 13040
t=int(input())
ct=0
ct1=0
for i in range(0,t):
  a,b=map(int,input().split())
  if(a==b):
    ct+=1
  else:
    ct=0
  if(ct==3):
    ct1+=1
if(ct1==0):
  print("No")
else:
  print("Yes")
    
  

Measured memory_bytes: 9136
from itertools import accumulate
n,k = map(int,input().split())
l = [0] + list(map(int,input().split()))
for i in range(n):
    l[i+1] = (l[i+1]+1)/2
acc = list(accumulate(l))
# print(acc)
maxi = 0
for i in range(n-k+1):
    maxi = max(maxi,acc[i+k]-acc[i])
print(maxi)

Measured memory_bytes: 102992
///in the name of Allah the most beneficent the most merciful.
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define MAX 1e18
#define MIN -1e18
#define MOD 1000000007
//#define mod2 20071027
//#define MOD 998244353
#define base 139
//#define mod 1000074259
#define base2 31
#define memz(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define in1(a) scanf("%lld", &a)
#define in2(a, b) scanf("%lld%lld", &a, &b)
#define TC(c) printf("Case #%lld: ", ++c)
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FILE   freopen("input.txt", "r", stdin);  freopen("out.txt", "w", stdout);
#define out(x) cout << #x << " -> " << x << endl;
using namespace std;
const ll N = 200010, M = 2000005;
string s;
int solve()
{
    cin>>s;
    if(s[0]>='A' && s[0]<='Z')
        printf("A\n");
    else printf("a\n");
    return 0;
}
int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int ret = solve();
    return 0;
}
/*

*/


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


#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()


using namespace std;
using namespace __gnu_pbds;

template<class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
using ll  = long long;

using point = complex<double>;


void err(istream_iterator<string> it) {cerr << endl;}
template<typename T, typename... Args>void err(istream_iterator<string> it, T a, Args... args) {cerr << *it << " = " << a << endl;err(++it, args...);}


const double EPS = 1e-8;
const long long mod = 1e9 + 7;

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

const int N = 1e6 + 5;
const long long inf = 1e18;


int h , w , k;
int acc[20][1020];
vector<int>ans;
char arr[20][1002];
int getSegment(int lstr,int lstc, int r,int c){
        return acc[r][c] - acc[lstr - 1][c] - acc[r][lstc - 1] + acc[lstr - 1][lstc - 1];
}
int solve(int lc, int msk){

    int ret = 1e9;
    int lstr = 1;
    for(int i = 0; i < h; ++i){
        if(!(msk & (1 << i)))continue;
        int lo = lc,hi = w, mid ,out = -1;
        while(lo <= hi){
            mid = lo + hi >> 1;
            int cnt = getSegment(lstr,lc,i+1,mid);

            if(cnt <= k){
                lo = mid + 1;
                out = mid;
            }else{
                hi = mid - 1;
            }
        }
        if(out == -1)
                return 1e9;
        lstr = i + 2;
        ret = min(ret, out);
    }
    return ret;
}
void get_mask(int msk,int i){
    if(i == h - 1){
        int ret = 0;
        int r = 0;
        while(r<w){
            r = solve(r + 1,msk);
            if(r == 1e9){
                ans.push_back(r);
                return ;
            }
            if(r == w)break;
            ret++;
        }
        ret += __builtin_popcount(msk);
        ret--;
        ans.push_back(ret );
        return ;
    }

    get_mask(msk,i + 1);
    get_mask(msk | (1 << i) ,i + 1);

}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> h >> w >> k;

    for(int i = 1; i <= h; ++i)
            for(int j = 1; j <= w; ++j)
                cin >> arr[i][j];

    for(int i = 1; i <= h; ++i){
        for(int j = 1; j <= w; ++j){
            acc[i][j] = (arr[i][j] == '1');
        }
    }
    for(int i = 1; i <= h; ++i)
        for(int j = 1; j <= w; ++j)
            acc[i][j] += acc[i][j - 1];
    for(int i = 1; i <= w; ++i)
            for(int j = 1; j <= h; ++j)
                acc[j][i] += acc[j - 1][i];
    get_mask(1 << (h - 1) ,0);
    sort(all(ans));
    cout << ans[0] << '\n';
    return 0;
}


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

typedef vector<int> vi;
typedef pair<int,int> pii;
#define For(i,n) for(int i = 0; i < (int) n; ++i)
#define Rep(i,n) for(int i = 1; i <= (int) n; ++i)
#define ll long long
#define lld long double
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define ar array
#define INF 1e18;
#define all(v) (v).begin(),(v).end()
const int N=2e5+5,mod=1e9+7;

void solve(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;

    ll val=max({a*c,b*d,a*d,b*c});
    cout<<val<<endl;

}


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        //cout<<"Case #"<<a<<": ";
        solve();
        //a+=1;
    }
}


Measured memory_bytes: 3648
#include<iostream>

#include<cmath>
#include<string>
#include <algorithm> 

using namespace std;

# define p(s) cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) cout << (j ? "Yes" : "No") << endl;

string lpad(string l,int s,int n){
    string temp = to_string(n);
    string res = "";
    int loop = s - temp.size();
    while(loop--) res+=l;

    return res+temp;
}

int main()
{
    int x,y;
    cin >> x >> y ;

    cout << x+y/2 << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char* argv[]) {
  long long N, A, B;
  cin >> N >> A >> B;

  if (A == 0 && B == 0) {
    cout << 0 << endl;
    return 0;
  }

  long long n = N / (A + B);
  long long e = min(N - n * (A + B), A);

  cout << n * A + e << endl;

  return 0;
}

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

int main() {  
  char num[6];
  for (int i = 0; i < 6; ++i) {
  	cin >> num[i];
  }
  sort(num, num+6);
  int array = atoi(num);
  if (array == 112234 ||
      array == 112334 ||
      array == 112344 ||
      array == 122334 ||
      array == 122344 ||
      array == 123344) {
  	cout << "YES" << endl;
  } else {
  	cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define ld long double
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
void solve(){
    int n;
    cin>>n;
    vi v(n);
    int s = 0;
    for(int i = 0; i < n; i++)cin>>v[i]; 
    int mx = v[0];
    for(int i = 0; i < n; i++){
        mx=max(mx, v[i]);
        s+=mx-v[i];
    }  
    cout<<s;
}
signed main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)solve();
}

Measured memory_bytes: 4776
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <cctype>
#include <bits/stdc++.h>
#include <queue>

using namespace std;
// for loop
#define F(i, L, R) for(long i = L; i < R; i++)
#define FE(i, L, R) for(long i = L; i <= R; i++)
// for (reversed)
#define FR(i, L, R) for(long i = L; i > R; i--)
#define FRE(i, L, R) for(long i = L; i >= R; i--)

// data types
#define Int long
#define ul unsigned long
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned shoft

// vectors
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> ii;
#define ALL(c) (c).begin(),(c).end()
#define last(vec) vec.size()-1
#define lastEle(vec) vec[last(vec)]
#define pb push_back
#define InputV(a, n) F(i,0,n){long l; cin >> l; a.pb(l);}

// debug
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define printA(a, L, R) FE(i, L, R) cout << a[i] << (i==R?'\n':' ')
#define printAF(a, L) printA(a, 0, L-1)
#define printV(a) printA(a, 0, a.size()-1)

// utils
#define char2int(c) (c-'0')
#define bit(x, i) (x&(1<<i))
#define space ' '
#define PI 3.14159265358979323


#define TST 0

int main() {
#if TST==1
    ifstream in ("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int N;
    unsigned long long D;
    cin >> N >> D;
    int ans = 0;
    unsigned long long goal = D * D;
    //cout << "goal is " << goal << endl;
    for(int i = 0;i < N;i++){
        int x,y;
        cin >> x >> y;
        unsigned long long x_sq = pow(x, 2);
        unsigned long long y_sq = pow(y, 2);
        unsigned long long dist = x_sq + y_sq;
        //cout << "dist is " <<  dist << endl;
        if( dist <= goal){
            //cout << "inside D" << endl;
            ans ++;
        }
    }
    cout << ans << endl;

#if TST==1

#endif
}



Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

int main(){
    int n,k;
    cin >> n >> k;
    if(2*k-1 <= n) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

#define loop(i,n) for(int i=0;i<(n);i++)
#define pool(i,n) for(int i=(n)-1;i>=0;i--)
#define cont(i,n) for(int i=1;i<=(n);i++)
#define tnoc(i,n) for(int i=(n);i>=1;i--)
#define circ(i,a,b) for(int i=(a);i<=(b);i++)
#define cric(i,a,b) for(int i=(b);i>=(a);i--)
#define sub(i,a) for(int i=a;i;i=((i-1)&(a)))
#define subs(i,a) for(int i=a;i>=0;i=(!i?-1:((i-1)&(a))))
#define subt(i,a) for(int i=((a-1)&a);i;i=((i-1)&(a)))
#define subst(i,a) for(int i=((a-1)&a);i>=0;i=(!i?-1:((i-1)&(a))))
#define range(i,a,b,c) for(int i=(a);((c)>0?i<=(b):i>=(b));i+=(c))
#define foreach(it,v) for(__typeof((v).begin()) it=(v).begin(),_e_D_=(v).end();it!=_e_D_;it++)
#define parse(i,s) for(int i=0;s[i];i++)

#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mak make_pair

#define y0 y0O0OO00OO0OO0OO0OOO00OO0OO0O0O000OO0
#define y1 y1II11II11III11I1III11II111IIII1II1I1
#define ws WSrAkIoi2333wSraKIoIWSraKiOi
#define left left_jTjTJtJtIoiiOiioIAuaU66666jtIOIau
#define hash whYusEthiSnamE_caNyoUusEothERnaMesliKeHSH

#define Mask(a) (1ll<<(a))
#define Maskx(a,x) ((a)<<(x))
#define Full(a) ((1ll<<(a))-1)
#define Bit(a,x) (((a)>>(x))&1)
#define all(a) (a).begin(),(a).end()
#define SZ(a) ((int)((a).size()))

typedef long long ll;
typedef long double lf;

const int Inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3fll;
const lf inF=11451419198101145141919810.1145141919810;
const lf pi=acosl(-1);
/* Source code starts here */

const int jt=1000000007;
int n,m,k;
int a[29][29];
int dp[2][1<<20];
int btz[1<<20];

int main(){
	scanf("%d%d%d",&n,&m,&k);n--;
	memset(a,-1,sizeof(a));
	loop(i,k){
		int u,v,w;
		scanf("%d%d%d",&u,&v,&w);
		a[--u][--v]=w;
	}
	dp[0][0]=1;
	int now=1,lst=0;
	cont(msk,(1<<n)-1)btz[msk]=(1<<__builtin_ctz(msk));
	loop(i,m)loop(j,n){
		loop(msk,1<<n)dp[now][msk]=0;
		loop(msk,1<<n){
			if(!dp[lst][msk])continue;
			if(a[i][j]!=1&&!Bit(msk,j))(dp[now][msk]+=dp[lst][msk])%=jt;
			if(a[i][j]){
				int nmsk=msk^btz[msk&((1<<n)-(1<<j))]^(1<<j);
				(dp[now][nmsk]+=dp[lst][msk])%=jt;
			}
		}
		swap(now,lst);
	}
	int ans=0;
	loop(msk,1<<n)ans=(ans+dp[lst][msk])%jt;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 12544
#define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>    // 10????????? cout << setprecision(10) << double;
#include <queue>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
//for gcc (???test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// ??\??????push_back(d)???array[d]???????????????1??????§?????????
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// ??????§????¢??´????°???Greatest Common Divisor???
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// ?????°?????¢??????°???Least Common Multiple???
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y???´???????????????´?????????
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

// vector???¨???
// vec[i][j]?????????????\????????\?????????¨??????vec???????????????????????????????????????.

#define INF 1000000

// ------------------- include, typedef, define END. -------------------


int n;
LL patternNum = 0;

inline void nextStep(LL nowStep) {

	if (nowStep == n) {
		// GOAL
		patternNum++;
	}
	else if (nowStep>n) {
		// ?????°????????????
		
	}
	else {
		nextStep(nowStep + 1);
		nextStep(nowStep + 2);
		nextStep(nowStep + 3);
	}
}

int main() {

	while (cin >> n, n) {
		nextStep(0);
		int days = ceil(patternNum / 10.0);
		int years = ceil(days / 365.0);
		cout << years << endl;
		patternNum = 0;
	}

	return 0;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09 + 7;

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

  ll n, m;
  cin >> n >> m;
  if(abs(n - m) >= 2){
    cout << 0 << endl;
    return 0;
  }

  ll ans = 1;
  
  REP(i, n) ans = ans * (i + 1) % mod;
  REP(i, m) ans = ans * (i + 1) % mod;

  if(abs(n - m) == 1) cout << ans << endl;
  else{
    ans = (2 * ans) % mod;
    cout << ans << endl;
  }
}


Measured memory_bytes: 764
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		var rn = 1/X + 1/Y;
		Console.WriteLine(1/rn);
		
		
	}
	double X,Y;
	public Sol(){
		var d = rda();
		X = d[0]; Y = d[1];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 2648
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const int INF=1000100010;
int main(){
ll n;cin>>n;
ll ans=0;
rep(i,n){
    if((i+1)%3!=0&&(i+1)%5!=0)ans+=(i+1);
}
cout<<ans<<endl;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k); i > (n); i--)
#define FORre(i, k, n) for(int i = (k); i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;
const int mod = 1000000007;



int main(void){
  int n, m;
  cin >> n >> m;
  vector<vector<int>> to(n);
  REP(i, m){
    int u, v;
    cin >> u >> v;
    u--; v--;
    to[u].emplace_back(v);
  }
  int s, t;
  cin >> s >> t;
  s--; t--;

  vector<vector<int>> dist(n, vector<int>(3, INF));

  queue<P> q;
  q.push(P(s, 0));
  dist[s][0] = 0;
  while(!q.empty()){
    int v = q.front().first;
    int l = q.front().second;
    q.pop();
    int nl = (l+1)%3;
    for(int u : to[v]){
      if(dist[u][nl] != INF) continue;
      dist[u][nl] = dist[v][l]+1;
      q.push(P(u, nl));
    }
  }
  int ans = (dist[t][0] == INF) ? -1 : dist[t][0] / 3;
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 11136
#include<iostream>

using namespace std;

int main()
{
	int a,b,c,x,y;

	cin >> a >> b >> c >> x >> y;

	int i,min;
	if(a+b > c*2) min=c*2;
	else min=a+b;


	int co,am,ad;
	if(x > y){
		co = y*min;
		am = x-y;
		if(a+b > c*2){
			if(min < a)
				ad = co + (min*am);
			else
				ad = co + a*am;
		}
		else
			ad = co + a*am;	
	}
	else if(x < y){
		co = x*min;
		am = y-x;
		if(a+b > c*2){
			if(min < b)
				ad = co + (min*am);
			else
				ad = co + b*am;
		}
		else
			ad = co + b*am;
	}
	else{
		cout << min*x << endl;
		return 0;
	}

	cout << ad << endl;

	return 0;
}








Measured memory_bytes: 256
import collections
n = int(input())
a_lst = list(map(int, input().split()))

c = collections.Counter(a_lst)
cand = [k for k, v in c.items() if v >= 2]
cand = sorted(cand)

if len(cand) >= 2:
  if c[cand[-1]] >= 4:
    print(cand[-1] ** 2)
  else:
    print(cand[-2] * cand[-1])
else:
  print(0)

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

#define ll long long

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a;
    vector<int> b;
    vector<int> c;

    for(int i=0;i<n;i++){
        int an;
        cin >> an;
        a.emplace_back(an);
    }
    for(int i=0;i<n;i++){
        int bn;
        cin >> bn;
        b.emplace_back(bn);
    }
    for(int i=0;i<n-1;i++){
        int cn;
        cin >> cn;
        c.emplace_back(cn);
    }

    /*判別*/
    int ans=0;
    for(int i=0;i<n;i++){
        int gene=a[i]-1;
        ans+=b[gene];
        if(i<n-1){
            int afte=a[i+1]-1;;
            if(afte-gene==1){
                ans+=c[afte-1];
            }
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def unite(x,y):
    x, y = find(x), find(y)
    if x == y:
        return False
    
    if par[x] > par[y]:
        x,y = y,x
    par[x] += par[y]
    par[y] = x
    return True

def same(x,y): #xとyが同じ集合に属するかの判定
    return find(x) == find(y)

def size(x): #xが属する集合の個数
    return -par[find(x)]
n, m = map(int, input().split())
par = [-1]*n

for _ in range(m):
    a, b = map(int, input().split())
    unite(a-1, b-1)
par = [-i for i in par]
print(max(par))

Measured memory_bytes: 22512
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007

//qsort用、昇順
int compare_int(const void *a, const void *b)
{
	return *(int*)a-*(int*)b;
}
//qsort(data, 10, sizeof(int), compare_int)

long int a[1000000];
long int d[1000000];

int main(){
	long int k, n;
	scanf("%ld%ld", &k, &n);
	scanf("%ld", &a[0]);
	for(int i=1; i<n; i++){
		scanf("%ld", &a[i]);
		d[i] = a[i]-a[i-1];
	}
	d[0] = k-a[n-1] + a[0];

	long int max=0;
	for(int i=0; i<n; i++){
		if(max<d[i]) max = d[i];
	}

	printf("%ld\n", k-max);
	
	return 0;
}

Measured memory_bytes: 5760
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;
long long int MOD = 1000000007;

using namespace std;

int main(){
	
	int V, E;
	cin >> V >> E;
	
	long long int d[V][V];
	
	for(int i = 0; i < V; i++){
		for(int j = 0; j < V; j++){
			d[i][j] = INF;
		}
		d[i][i] = 0;
	}
	
	for(int i = 0; i < E; i++){
		int u, v, cost;
		cin >> u >> v >> cost;
		d[u][v] = cost;
	}
	
	for(int k = 0; k < V; k++){
		for(int i = 0; i < V; i++){
			for(int j = 0; j < V; j++){
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	
	bool flag = false;
	for(int k = 0; k < V; k++){
		for(int i = 0; i < V; i++){
			for(int j = 0; j < V; j++){
				if(d[i][j] > d[i][k] + d[k][j]){
					flag = true;
				}
			}
		}
	}
	
	if(flag){
		cout << "NEGATIVE CYCLE" << endl;
		return 0;
	}
	
	for(int i = 0; i < V; i++){
		for(int j = 0; j < V; j++){
			if(d[i][j] > 1e11){
				cout << "INF";
			}else{
				cout << d[i][j];
			}
			printf("%c", j == V - 1 ? '\n' : ' ');
		}
	}
	
	return 0;
}


Measured memory_bytes: 3184
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------ 
long A[100000];
void Calc(){
	int N = rei();
	for(int i=0;i<N;i++){
		A[i] = rel();
	}
	sort(A,A+N);
	long ans = 0;
	if(N % 2 == 0){
		for(int i=0;i<N/2;i++){
			ans -= A[i]*2;
		}
		ans += A[N/2-1];
		for(int i=N/2;i<N;i++){
			ans += A[i]*2;
		}
		ans -= A[N/2];
	}
	else{
		long ans1 = 0;
		for(int i=0;i<N/2;i++){
			ans1 -= 2*A[i];
		}
		ans1 += A[N/2] + A[N/2+1];
		for(int i=N/2+2;i<N;i++){
			ans1 += A[i]*2;
		}
		long ans2 = 0;
		for(int i=0;i<N/2-1;i++){
			ans2 -= 2*A[i];
		}
		ans2 -= A[N/2-1] + A[N/2];
		for(int i=N/2+1;i<N;i++){
			ans2 += A[i]*2;
		}
		ans = max(ans1,ans2);
	}
	cout << ans << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

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

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

    int p[256] = {};
    for (char c : s) {
        p[c] = 1;
    }

    for (char c = 'a'; c <= 'z'; c++) {
        if (p[c] == 0) {
            cout << c << endl;
            quick_exit(0);
        }
    }

    cout << "None" << endl;

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define all(x) x.begin(),x.end()
#define FIO ios_base::sync_with_stdio(false), cin.tie(NULL);
#define N

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

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define srt(i) sort(i.begin(), i.end())
#define rvt(i) sort(i.begin(), i.end(), greater<int>())

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

  if(s.at(2)==s.at(3) && s.at(4)==s.at(5)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1000000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
#define ll long long int

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int 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;
    }
}

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

int main() {
    int x,y; cin >> x >> y;
    COMinit();
    if((x+y)%3!=0){
        cout << 0 << endl;
        return 0;
    }else{
    ll r = (2*y-x)/3;
    cout << COM((x+y)/3,r) << endl;
    }
}

Measured memory_bytes: 23680
N=int(input())
S=input()
A=[0]*N
for i in range(N):
 A[i]=int(S[i])
b=0
for i in range(1000):
 i1=int(i/100)
 i2=int((i-i1*100)/10)
 i3=i%10
 a=0
 for j in range(N):
  if a==0:
   if A[j]==i1:
    a+=1
  elif a==1:
   if A[j]==i2:
    a+=1
  else:
   if A[j]==i3:
    b+=1
    break
print(b)


Measured memory_bytes: 43996
object Main {

  def main(args: Array[String]): Unit = {
    import scala.io.StdIn._
    val Sd = readLine()
    val T = readLine()

    // Tが含まれていない場合には、満たさない
    // Tが含まれている場合には、含まれている箇所

    // わからない箇所は、aを埋めれば、辞書順最小になる。
    // Tが含まれる場所は、含まれるとすれば、一番後ろがいい。
    // 'a'で|T|と同じ長さの文字列を作ると、常に'a'だけで作った文字列のほうが辞書順最小になる。

    // 後ろから見ていって、一回マッチしたら、そこは置き換えて
    // 一回もマッチしなかったら, UNRESTORABLE.
    // それ以降の?は'a'に変換する.

    val reversedT = T.reverse
    val tSize = T.length

    def isMatch(ambiguous: String, t: String): Boolean =
      ambiguous.zip(t).forall {
        case ('?', _) => true
        case (a, b) => a == b
      }

    def solve(reversedS: String, checked: String): String =
      if (reversedS.length < tSize)
        // Tにマッチするケースが発見できないので,
        "UNRESTORABLE"
      else {
        // マッチするケースを発見できる可能性がある.
        if (isMatch(reversedS.take(tSize), reversedT))
          // マッチしたなら, マッチした部分を置き換えて, 残りの後ろの?を全て'a'にする.
          (checked.replace('?', 'a') + reversedT + reversedS.drop(tSize).replace('?', 'a')).reverse
        else
          solve(reversedS.tail, checked + reversedS.head)
      }

    println(solve(Sd.reverse, ""))
  }

}

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

int main()
{
    ll N; cin >> N;
    ll m = sqrt(N);
    
    ll ans = 0;
    for (int i = 1; i <= N; ++i) {
        for (int j = 1; j <= N; ++j) {
            if (i * j < N) ans++;
            else break;
        }
    }
    cout << ans << endl;



}


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

signed main(){
  int N;
  cin>>N;
  int ll=N;
  int hh=0;
  int out=0;
  while(ll>=10){
    if(ll%10!=9)out++;
    ll/=10;
    hh++;
  }
  int ans=hh*9+ll-1;
  if(out==0)ans++;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

struct Info{
	Info(int arg_row,int arg_col){
		row = arg_row;
		col = arg_col;
	}
	int row,col;
};

int H,W;
int table[500][500],calc[500][500],adj_count[500][500];
int diff_row[8] = {-1,-1,-1,0,0,1,1,1},diff_col[8] = {-1,0,1,-1,1,-1,0,1};


bool rangeCheck(int row,int col){
	if(row >= 0 && row <= H-1 && col >= 0 && col <= W-1)return true;
	else{
		return false;
	}
}

int main(){

	scanf("%d %d",&H,&W);
	for(int row = 0; row < H; row++){
		for(int col = 0; col < W; col++)scanf("%d",&table[row][col]);
	}

	for(int row = 0; row < H; row++){
		for(int col = 0; col < W; col++){
			calc[row][col] = 0;
		}
	}

	int adj_sum,adj_row,adj_col;

	for(int row = 0; row <= H-2; row++){
		for(int col = 0; col <= W-2; col++){

			adj_sum = 0;
			for(int i = 0; i < 8; i++){
				adj_row = row+diff_row[i];
				adj_col = col+diff_col[i];
				if(rangeCheck(adj_row,adj_col) == false)continue;

				adj_sum += calc[adj_row][adj_col];
			}

			calc[row+1][col+1] = table[row][col]-(calc[row][col]+adj_sum);
		}
	}

	for(int row = 0; row < H; row++){
		for(int col = 0; col < W; col++)adj_count[row][col] = 0;
	}

	vector<Info> ANS;
	int count;

	for(int row = 0; row < H; row++){
		for(int col = 0; col < W; col++){
			if(calc[row][col] == 0)continue;

			count = 0;
			for(int i = 0; i < 8; i++){
				adj_row = row+diff_row[i];
				adj_col = col+diff_col[i];

				if(rangeCheck(adj_row,adj_col) == false || calc[adj_row][adj_col] == 0)continue;

				count++;
				if(count >= 2)break;
			}
			if(count <= 1)ANS.push_back(Info(row,col));
		}
	}

	if(ANS.size() == 1){
		printf("%d %d %d %d\n",ANS[0].row,ANS[0].col,ANS[0].row,ANS[0].col);
		return 0;
	}

	if(10000*ANS[1].row+ANS[1].col > 10000*ANS[0].row+ANS[0].col)swap(ANS[0],ANS[1]);

	printf("%d %d %d %d\n",ANS[0].row,ANS[0].col,ANS[1].row,ANS[1].col);

	return 0;
}



Measured memory_bytes: 6156
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }

        static int Search(Stack<char> digits, int i, int I, int N)
        {
            if (i < I)
            {
                int sum = 0;
                foreach (char c in new[] { '7', '5', '3' })
                {
                    digits.Push(c);
                    sum += Search(digits, i + 1, I, N);
                    digits.Pop();
                }
                return sum;
            }
            else
            {
                if (digits.Contains('7')
                 && digits.Contains('5')
                 && digits.Contains('3'))
                {
                    int n = int.Parse(new string(digits.ToArray()));
                    return (n <= N) ? 1 : 0;
                }
                else
                {
                    return 0;
                }
            }
        }

        static int Solve(int N)
        {
            int count = 0;
            for (int i = 3; i <= 9; ++i)
            {
                count += Search(new Stack<char>(), 0, i, N);
            }
            return count;
        }

        static void Main(string[] args)
        {
            int N = ReadInt();
            Console.WriteLine(Solve(N));
        }
    }
}


Measured memory_bytes: 15316
/// @file

#include <iostream>
#include <limits>
#include <string>

namespace {

bool run(std::istream& is, std::ostream& os);
}  // unnamed namespace

/// @brief エントリポイント
#ifdef _TEST
static int run()
#else
int main()
#endif
{
  try {
    if (run(std::cin, std::cout) == false) {
      std::cerr << "main funciton error.\n";
      return EXIT_FAILURE;
    }
  } catch (const std::exception& e) {
    std::cerr << "catch exception\n";
    std::cerr << e.what() << "\n";
    return EXIT_FAILURE;
  }

  return EXIT_SUCCESS;
}

namespace {

/// @brief 実行処理
bool run(std::istream& is, std::ostream& os)
{
  using Numeric_t = unsigned long;
  const Numeric_t MAX_VALUE = 1e+12;
  Numeric_t a;
  Numeric_t b;
  is >> a >> b;

  auto f = [](Numeric_t num) -> Numeric_t {
    Numeric_t fxor (0);

    if (((num - 1) / 2) % 2 == 0) fxor |= 0x01;

    for (Numeric_t i = 1, N = sizeof(Numeric_t) * 8, v = 2; i < N; ++i, v = v << 1) {
      if (num < (v - 1)) break;

      const Numeric_t REST = num - (v - 1);
      const Numeric_t DIV_NUM = REST / v;
      const Numeric_t MOD_NUM = REST % v;
      if (DIV_NUM % 2 == 1) continue;
      if (MOD_NUM % 2 == 0) continue;
      fxor |= v;
    }

    return fxor;
  };

  const Numeric_t A_XOR = f(a - 1);
  const Numeric_t B_XOR = f(b);
  const Numeric_t F_XOR = B_XOR ^ A_XOR;

  os << F_XOR << "\n";

  return true;
}
}  // unnamed namespace


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using P = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
int INF = 1e9+7;


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

    sort(d,d+N);

    int ave = N/2;
    cout << d[ave]-d[ave-1] << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define ll long long
int main()
{
	ll n,a,b;
	cin>>n>>a>>b;
	ll i=0,k=0,ans=0;
	ll q= n/(a+b);
	ll r=n%(a+b);
	ans=q*a;
	if(r>a)
	r=a;
	ans+=r;
	cout<<ans;
	
}

Measured memory_bytes: 256