akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	int n, x;
	vector<int> a;
	cin >> n >> x;

	for(int i=0; i<n; i++){
		int t;
		cin >> t;
		a.push_back(t);
	}

	long long ans = 0;
	for(int i=0; i<n-1; i++){
		if(a[i] + a[i+1] > x){
			int diff = abs(x-(a[i] + a[i+1]));
			ans += min(a[i+1], diff);
			a[i+1] -= min(a[i+1], diff);

			if(a[i] + a[i+1] > x){
				int diff = abs(x-(a[i] + a[i+1]));
				ans += min(a[i], diff);
				a[i] -= min(a[i], diff);
			}
		}
	}
	/*
	for(int i=0; i<n; i++){
		printf("%d ", a[i]);
	}
	puts("");
	*/

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 892
a,b=map(int,input().split())

cnt=0
for i in range(1,10):
  for j in range(0,10):
    for k in range(0,10):
      num=int(str(i)+str(j)+str(k)+str(j)+str(i))
      if a<=num<=b:
        cnt+=1
        
print(cnt)

Measured memory_bytes: 9112
import sys
import numpy as np
import numba

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

i4 = numba.int32

def get_input():
    D = int(readline())
    C = np.array(readline().split(), np.int32)
    S = np.array([readline().split() for _ in range(D)], np.int32)
    T = np.array([readline() for _ in range(D)], np.int32)
    T -= 1
    Q = int(readline())
    query = np.array(read().split(), np.int32).reshape(-1, 2)
    query -= 1
    return D, C, S, T, query

@numba.njit((i4, i4[:], i4[:, :], i4[:]), cache=True)
def first_computation(D, C, S, T):
    x = 0
    last = np.zeros((26, D), np.int32)
    for d in range(D):
        if d:
            last[:, d] = last[:, d - 1]
        i = T[d]
        x += S[d, i]
        last[i, d] = d + 1
        for i in range(26):
            x -= C[i] * (d + 1 - last[i, d])
    return last, x

@numba.njit((i4, i4[:], i4[:, :], i4[:], i4[:, :], i4, i4), cache=True)
def difference_update(D, C, S, T, last_day, d, q):
    p = T[d]
    T[d] = q
    x = S[d, q] - S[d, p]

    i = np.searchsorted(last_day[p], d + 1)
    d_p = last_day[p, i - 1] if i >= 1 else 0
    coef = 0
    for k in range(d, D):
        if last_day[p, k] == d + 1:
            # k 日目に入るスコアの変更
            coef += d_p - d - 1
            last_day[p, k] = d_p
        else:
            break
    x += coef * C[p]

    coef = 0
    for k in range(d, D):
        if last_day[q, k] < d + 1:
            coef += (d + 1 - last_day[q, k])
            last_day[q, k] = d + 1
        else:
            break
    x += coef * C[q]
    return x

@numba.njit((i4, i4[:], i4[:, :], i4[:], i4[:, :], i4[:, :], i4), cache=True)
def main(D, C, S, T, query, last_day, score):
    for i in range(len(query)):
        d, q = query[i]
        score += difference_update(D, C, S, T, last_day, d, q)
        print(score)

D, C, S, T, query = get_input()
last_day, score = first_computation(D, C, S, T)

main(D,C,S,T,query,last_day,score)

Measured memory_bytes: 117836
using System;

namespace _085_Joseph_sPotato
{
	class Program
	{
		static void Main ( string[] args )
		{
			string inputStr;

			while ((inputStr = Console.ReadLine ()) != "0 0")
			{
				int[] inputNum = Array.ConvertAll (inputStr.Split (' '), int.Parse);

				int joinCount = inputNum[0];
				int interval = inputNum[1];

				bool[] isHit = new bool[joinCount];

				int index = 0;

				for (int lp = 0; lp < isHit.Length; lp++)
				{
					int rest = interval;

					while (0 < rest)
					{
						index++;
						index %= isHit.Length;

						if (!isHit[index])
						{
							rest--;
						}
					}

					isHit[index] = true;
				}

				index = index == 0 ? isHit.Length : index;
				Console.WriteLine (index);
			}
		}
	}
}

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

using namespace std;
using ll = long long;


int main(){
    int n,m,x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int> > a(n, vector<int>(m));
    for(int i = 0; i < n; i++){
        cin >> c[i];
        for(int j = 0; j < m; j++){
            cin >> a[i][j];
        }
    }
    int ans = 1e7;
    for(int bit = 1; bit < (1 << n); bit++){
        int temp = 0;
        vector<int> v(m, 0);
        for(int i = 0; i < n; i++){
            if(bit & (1 << i)){
                temp += c[i];
                for(int j = 0; j < m; j++){
                    v[j] += a[i][j];
                }
            }
        }

        bool f = true;
        for(int j = 0; j < m; j++){
            if(v[j] < x) f = false;
        }
        if(f) ans = min(ans, temp);
    }

    if(ans >= 1e7){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }
}

Measured memory_bytes: 3632
program main
  implicit none
  character(len=10) ::  S
  character(len=11) ::  T
  integer :: N,i 
  read(*,*) S
  read(*,*) T

  N = len(trim(S))
  do i = 1,N
     if (S(i:i) /= T(i:i)) then
        write(*,'(a)') 'No'
        stop
     end if
  end do
  write(*,'(a)') 'Yes'
end program main


Measured memory_bytes: 2948
n, k = gets().split.map{ |p|
	p.to_i
}
a = gets().chomp!.split.sort!

arr = []
kosuu = 1 # a[0]のぶん
1.upto(a.length){ |i|
	if a[i] != a[i-1] then
		arr << kosuu
		kosuu = 0
	end
	kosuu+= 1

}
arr.sort!

if arr.length <= k then
	puts 0
	exit
else
	# 最初(n-k)個の和
	ans = 0
	0.upto(arr.length - k - 1){|i|
		ans += arr[i]
	}
	puts ans
end


Measured memory_bytes: 18148
package main

import "fmt"

func main() {
	// Code for B - Chocolate
	var N int
	fmt.Scanf("%d", &N)

	var D, X int
	fmt.Scanf("%d %d", &D, &X)

	A := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &A[i])
	}

	var answer int = N
	for i := 0; i < N; i++ {
		answer += (D - 1) / A[i]
	}
	fmt.Println(answer + X)
}


Measured memory_bytes: 1844
def parallel? u, v
  (u.conj * v).imag.zero?
end

gets.to_i.times do
  p0, p1, p2, p3 = gets.split.map(&:to_i).each_slice(2).map {|a, b| a + b * 1i }
  u, v = p1 - p0, p3 - p2
  p [u, -u].any? {|z| parallel? z, v } ? 2 : [u * 1i, u * -1i].any? {|z| parallel? z, v } ? 1 : 0
end

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



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



Measured memory_bytes: 3092
n, x = map(int, input().split())
a = list(map(int, input().split()))

ans = 0
b = 0
for i in range(n):
    c = b + a[i]
    if c > x:
        ans += c - x
        b = a[i] + x - c
    else:
        b = a[i]

print(ans)

Measured memory_bytes: 14540
n = gets.to_i
as = gets.split.map(&:to_i).sort!

ans = 100 * (200) ** 2
-100.upto(100) do |i|
  sum = as.inject(0) { |r, a| (r + (i - a) ** 2) }
  ans = sum if sum <= ans
end

puts ans


Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
#include <cctype>
#include <cstdio>
#include <math.h>
using f32 = float;
using f64 = double;
using f80 = __float80;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using vi = vector<int>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vs = vector<string>;
using vl = vector<LL>;
using vvl = vector<vl>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
#define REP(i, n) for (LL i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (LL i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
#define fst first
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define sw swap
#define UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper);
#define LOW(x) transform(x.begin(), x.end(), x.begin(), ::tolower);
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
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;
}
int main()
{
    int K,J;
    string S,SAVE;
    vector<string> a;
  
    cin >> S >> K;
    J=S.size();
   if(1<J){
  for(int i=0;i<J;i++)
    {
       SAVE=S[i];
      a.pb(SAVE);
        for(int j = i+1;j<min(i+6,J);j++)
        {
            SAVE += S[j];
            a.pb(SAVE);
        }
    }
    SORT(a);
a.erase(std::unique(a.begin(), a.end()), a.end());
cout << a[K-1];
   }else{
   cout <<S;
   }
}

Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(17) << res << endl;
 
int main() {
    string s;
    cin >> s;
    auto n = s.size();

    bool ok = true;
    

    int countc = 0;
    int countUpper = 0;
    for (size_t i = 0; i < n; ++i) {
        if (i >= 2 && (n-i)>1 && s[i] == 'C') ++countc;
        if (isupper(s[i])) {
            countUpper++;
        }
    }

    if (s[0] != 'A') {
        //cerr << "X has $A" << endl;
        ok = false;
    }

    if (countc != 1) {
        //cerr << "X has one C" << endl;
        ok = false;
    }

    if (countUpper != 2) {
        //cerr << "X has 2 upper letter" << endl;
        ok = false;
    }

    if (ok) {
        cout << "AC" << endl;
    } else {
        cout << "WA" << endl;
    }
}


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

#define      ll      long long int

int main( )
{
    ll n, i, j, k, l;
    ll g = 0;
    ll x;
    cin >> n >> x;
    for (i = 1; i <= n; i++) {
        cin >> j;
        g = __gcd(abs(j - x), g);
    }
    cout << g << '\n';
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100

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

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

  flag = 1;
  while(flag){
    flag = 0;
    for(i=N-1; i>=1; i--){
      if(A[i] < A[i-1]){
	swap = A[i];
	A[i] = A[i-1];
	A[i-1] = swap;
	count++;
	flag = 1;
      }
    }
  }

  for(i=0; i<N; i++){
    printf("%d",A[i]);
    if(i==N-1) break;
    printf(" ");
  }
  printf("\n");
  printf("%d\n",count);

  return 0;
}



Measured memory_bytes: 2084
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
int main()
{
    int h,n;
    cin>>h>>n;
    ll sum=0;
    for(int i=0,tmp;i<n;i++)
    {
        cin>>tmp;
        sum+=tmp;
    } 
    if(sum>=h) cout<<"Yes\n";
    else cout<<"No\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;




int main(){

	ll N;
	scanf("%lld",&N);

	ll ans = 0;

	for(ll i = 1; i <= N; i++){
		if(i%3 != 0 && i%5 != 0){

			ans += i;
		}
	}

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

	return 0;
}


Measured memory_bytes: 3788
-- Question B

import Data.List
import Control.Applicative
import Control.Monad

main = do
  [a, b] <- map read . words <$> getLine
  xs <- (map read . words) <$> getLine 
  putStrLn $ show ( check (nara xs) b)

nara :: [Int] -> [Int]
nara xs = reverse ( sort xs )   

check :: [Int] -> Int -> Int
check xs b = sum ( take b xs)


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

#define ll long long
#define ld long double
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
//#define int long long

using namespace std;
const int INF = 1e15;
const int MB = 30;
const int MOD = 1e9 + 7;

void solve() {
	int k;
	cin >> k;
	int now = 7 % k;
	for (int i = 1; i <= 5e6; i++) {
		if (!now) {
			cout << i;
			return;
		}
		now = (now * 10 + 7) % k;
	}
	cout << -1;
}


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	srand(time(0));
	int t = 1;
	//int t;
	//cin >> t;
	while (t--) solve();
}

Measured memory_bytes: 3636
#define ONLINE_JUDGE
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
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;}

void solve();

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

void solve(){
    ll n,k,l,r;cin>>n>>k>>l>>r;
    vl a(n);rep(i,n)cin>>a[i];

    ll h=n/2;
    vvl c(h+1);
    rep(i,1<<h){
        ll sum=0;
        rep(j,h){
            if(i>>j&1)sum+=a[j];
        }
        c[__builtin_popcount(i)].push_back(sum);
    }
    repe(i,h)sort(all(c[i]));

    ll ans=0;
    ll h2=n-h;
    rep(i,1<<h2){
        ll cnt=__builtin_popcount(i);
        if(cnt>k||cnt+h<k)continue;
        ll sum=0;
        rep(j,h2){
            if(i>>j&1)sum+=a[h+j];
        }
        ans+=upper_bound(all(c[k-cnt]),r-sum)-lower_bound(all(c[k-cnt]),l-sum);
    }
    cout<<ans<<endl;
}


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

int main()
{
	int n, k, ans = 0;
	cin >> n >> k;
	while(n--)
	{
		int h;
		cin >> h;
		if(h >= k)
			ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int start = 0, end = 1;
    int max = 0;

    while (end < n) {
        string ss = s.substr(start, (end - start));
        bool flag = false;
        for (int j = end; j < n; j++) {
            string sss = s.substr(j, end - start);
            if (ss == sss) {
                max = end - start;
                flag = true;
                break;
            }
        }
        if (flag) {
            end++;
        } else {
            start++;
            end++;
        }
    }

    cout << max << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int maxn=2e5+5;
int a[maxn];
int pf[maxn];
int ans=1e18;
signed main() {
	int n;
	cin>>n;
	pf[0]=0;
	for(int i=1 ; i<=n ; i++) {
		cin>>a[i];
		pf[i]=pf[i-1]+a[i];
	}
	for(int i=2; i<=n-2; i++) {
		int lef=1;
		int rig=i-1;
		vii f,s;
		while(lef<rig)  {
			int mid=(lef+rig+1)/2;
			if(2*pf[mid]>pf[i]) rig=mid-1;
			else lef=mid; 
		}
		int tl=lef;
		lef=i+1, rig=n-1;
		while(lef<rig) {
			int mid=(lef+rig+1)/2;
			if(2*(pf[mid]-pf[i])>pf[n]-pf[i]) rig=mid-1;
			else lef=mid;
		}
		int tr=lef;
		for(int j=tl-10; j<=tl+10; j++) {
			for(int k=tr-10; k<=tr+10; k++) {
				if(j && j<i && k>i && k<n) {
					int t1=pf[j];
					int t2=pf[i]-pf[j];
					int t3=pf[k]-pf[i];
					int t4=pf[n]-pf[k];
					int mn=min({t1, t2, t3, t4});
					int mx=max({t1, t2, t3, t4});
					ans=min(ans, mx-mn);
				}
			}
		}		
	}
	cout<<ans;
}

Measured memory_bytes: 6712
import Data.List
import Data.List.Split
solve q k a x
  | length ys < q = 10^9
  | otherwise = sort ys !! (q-1) - x
  where
    ys = concatMap (drop (k-1) . reverse . sort) $ wordsBy (x >) a
main = do
  [n,k,q] <- map read . words <$> getLine
  a <- map read . words <$> getLine
  print $ minimum $ map (solve q k a) a

Measured memory_bytes: 2428
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

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

using namespace std;

const int mod = 1000000007;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, m, x;
    cin >>n >>m;
    // usable stairs...
    vector<bool> stairs(n+1, true);
    for(int i = 0; i < m; i++){
        cin >>x;
        // this stair is not usable
        stairs[x] = false;
    }
    vector<long long> dp(n+1);
    // base case
    dp[0] = 1;
    for(int now = 0; now < n; now++){
        for(int next = now + 1; next <= min(n, now + 2); next++){
            if(stairs[next]){
                dp[next] += dp[now];
                dp[next] %= mod;
            }
        }
    }
    cout <<dp[n] <<"\n";
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <cmath>
#include <queue>
typedef long long ll;
using namespace std;

int main(void){
    ll N;
    ll A, B;
    cin >> N >> A >> B;
    
    ll cnt = 0;
    
    cnt += (N / (A+B)) * A;
    if(N%(A+B) <= A) cnt += N%(A+B);
    else cnt += A;
    
    cout << cnt << endl;
}



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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

int main(){
    ll a,b,n;
    cin>>a>>b>>n;
    ll x=min(n, b-1);
    ll ans = (ll)x*a/b;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;


bool check_eq(vector<int>& u, vector<int>& v) {
	for (int i = 0; i < u.size(); ++i) {
		if (u[i] != v[i]) {
			return false;
		}
	}
	return true;
}

int main(void) {
	int N;
	cin >> N;
	vector<int> P(N),Q(N),perm(N);
	for (int i = 0; i < N; ++i) {
		cin >> P[i];
		perm[i] = i+1;
	}
	for (int i = 0; i < N; ++i) {
		cin >> Q[i];
	}
	int a,b,ind = 1;
	a = b = -1;
	while (a < 0 || b < 0) {
		if (a < 0 && check_eq(P,perm)) {
			a = ind;
		}
		if (b < 0 && check_eq(Q,perm)) {
			b = ind;
		}
		++ind;
		next_permutation(perm.begin(),perm.end());
	}
	cout << abs(a-b) << endl;
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, fas string
	var an int
	fmt.Scan(&a)
	for num, key := range a {
		word := string(key)
		if num == 0 {
			fas = word
		}
		if num != 0 && fas == word {
			an = 1
			fas = word
		} else {
			fas = word
		}

	}
	if an == 1 {
		fmt.Println("Bad")
	} else {
		fmt.Println("Good")
	}
}


Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
const int maxn = 1e4;
struct point{
	int x,y;
}u,v;
queue<int>que;
map<string,int>mp;
map<string,int>::iterator it;
#define m(a,b) memset(a,b,sizeof(a));
LL ans = 0;
int main(){
	LL a,b,c;
	cin >> a >> b >> c;
	if(a+b>=c)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 764
#include <stdio.h>
   
   
   int main(void) {
    int a,b,c;

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

      
     if(b-a==c-b) {
                  printf("YES");
              } else {
                  printf("NO");
              }
   
   
   
   return 0;
   
   }

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr ll INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// ----------------------------------------------------------------------------

int main(){
  int x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int x3,y3,x4,y4;
  x3 = x2 - (y2-y1);
  y3 = y2 + (x2-x1);
  x4 = x3 - (x2-x1);
  y4 = y3 - (y2-y1);
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl; 
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define display(v) for (auto x : v) cout << x << ", "
#define print(x) cout << (#x) << " = [ ";display(x); cout << "]\n"
#define endl '\n'
#define pb push_back
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
 
// DEBUG TEMPLATE by livw
void __print(int x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifdef INCLUDEWHENOFFLINE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
 
int main()
{
    fastio;
    
    string s, t;
    cin >> s >> t;
    int count = 0;
    for (int i = 0; i < 3; i++)
    {
        if (s[i] == t[i]) count++;
    }
    cout << count;
    return 0;
}


Measured memory_bytes: 256
import sys
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

MOD = int(1e+9) + 7

def comb(n, k):
    r = 1
    for i in range(n, max(n-k, k), -1):
        r *= i
    for i in range(1, min(n-k, k) + 1, 1):
        r //= i
    return r

class Comb:
    def __init__(self, MAX, MOD):
        MAX += 1
        fac = [0] * MAX
        finv = [0] * MAX
        inv = [0] * MAX
        fac[0] = fac[1] = 1
        finv[0] = finv[1] = 1
        inv[1] = 1
        for i in range(2, MAX):
            fac[i] = fac[i - 1] * i % MOD
            inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
            finv[i] = finv[i - 1] * inv[i] % MOD
        self.fac = fac
        self.finv = finv
        self.MOD = MOD
    
    def comb(self, n, k):
        fac = self.fac
        finv = self.finv
        MOD = self.MOD
        if (n < k):
            return 0
        if (n < 0 or k < 0):
            return 0
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD

def main():
    # 行数, 列数, 駒数
    N, M, K = i2nn()
    # 配置コストの総和 % MOD

    # 例）N, M, K = 2, 2, 2
    # 駒が置ける場所は4箇所: N * M
    # 駒の配置は6通り: comb(4, 2) = comb(N*M, K)
    # K=2 の場合のコスト
    xcost = 0
    for i in range(1, M):
        # iをx座標の差とする
        # x座標のみに注目した場合、差がiとなるのは(M-i)通り
        #   M=4, i=1, => (1,2), (2,3), (3,4) = 3通り
        #   M=4, i=2, => (1,3), (2,4) = 2通り
        #   M=4, i=3, => (1,4) = 1通り
        # さらにy座標の組み合わせは, 左側がN通り, 右側がN通り
        #   (1,2) について M=2 の場合 ((1,1), (2,1)), ((1,1), (2,2)), ((1,2), (2,1)), ((1,2), (2,2))
        xcost = (xcost + i * (M-i) * (N*N)) % MOD
    ycost = 0
    for i in range(1, N):
        ycost = (ycost + i * (N-i) * (M*M)) % MOD
    cost = (xcost + ycost) % MOD
    # K=3 の場合、K=2 の場合のコストを NM-2 倍すればよい
    # 汎用的に考えると、 K=2 の場合のコストを comb(MN-2, K-2) 倍すればよい
    #cost = (cost * comb(M*N-2, K-2)) % MOD
    cost = (cost * Comb(N*M-2, MOD).comb(N*M-2, K-2)) % MOD
    print(cost)

main()


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

int main(){
    string T;
    cin >> T;
    for(int i = 0; i< T.size(); i++){
      if(T[i] == '?') T[i] = 'D';
      cout << T[i];
    }
  cout << endl;
    return 0;
}

Measured memory_bytes: 3388
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    string s;
    cin >> s;
    int x, y;
    cin >> x >> y;
    
    int fcnt = 0;
    int tcnt = 0;
    vector<int> f, t;
    f.emplace_back(0);
    t.emplace_back(0);

    bool state = true; 
    for(int i=0; i<s.size(); i++){
        if(s.at(i)=='T'){
            tcnt++;
        }
        else{
            if(tcnt!=0){
                if(state){
                    f.emplace_back(fcnt);
                    if(tcnt%2!=0){
                        state = !state;
                    }
                    tcnt = 0;
                    fcnt = 0;
                }
                else if(!state){
                    t.emplace_back(fcnt);
                    if(tcnt%2!=0){
                        state = !state;
                    }
                    tcnt = 0;
                    fcnt = 0;
                }
            }
            fcnt++;
        }
    }

    if(fcnt!=0){
        if(state){
            f.emplace_back(fcnt);
        }
        else{
            t.emplace_back(fcnt);
        }
    }
    rep(i, f.size()){
        dump(f.at(i));
    }
    
    rep(i, t.size()){
        dump(t.at(i));
    }


    vector<vector<int>> dpx(f.size()+1, vector<int>(16020, 0));
    vector<vector<int>> dpy(t.size()+1, vector<int>(16020, 0));
    dpx.at(0).at(8000) = 1;
    dpy.at(0).at(8000) = 1;
    for(int i=1; i<f.size(); i++){
        for(int j=0; j<16020; j++){
            if(s.at(0)=='F' && i==1){
                dpx.at(i).at(8000+f.at(i)) = 1;
                continue;
            }
            if(dpx.at(i-1).at(j)==1){
                if(j+f.at(i)<16020) dpx.at(i).at(j+f.at(i)) = 1; 
                if(j-f.at(i)>=0) dpx.at(i).at(j-f.at(i)) = 1; 
            }
        }
    }

    for(int i=1; i<t.size(); i++){
        for(int j=0; j<16020; j++){
            if(dpy.at(i-1).at(j)==1){
                if(j+t.at(i)<16020) dpy.at(i).at(j+t.at(i)) = 1; 
                if(j-t.at(i)>=0) dpy.at(i).at(j-t.at(i)) = 1; 
            }
        }
    }

    if(dpx.at(f.size()-1).at(x+8000)==1 && dpy.at(t.size()-1).at(y+8000)==1){
        cout << "Yes" << endl;
    } 
    else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 251008
#include<stdio.h>
int main(void){
  int a,b,c,d;
  
  scanf("%d %d %d %d",&a,&b,&c,&d);
  
  while(1){
    
    c = c-b;
    if(c<=0){
      printf("Yes");
      break;
    }
    a = a-d;
    if(a<=0){
      printf("No");
      break;
    }
    
  }
  return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int N;
    string S;
    cin>>N>>S;
    int x=0;
    int ans=0;
    rep(i,N){
        if(S.at(i)=='I'){
            x++;
            ans=max(ans,x);
        }else{
            x--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int K = nextInt();
		int S = nextInt();

		int cnt = 0;
		for(int i=0;i<=K;i++) {
			for(int j=0;j<=K;j++) {
				int num = i+j;
				if(num + K >= S && num <= S) {
					cnt++;
				}else if(num > S) {
					break;
				}
			}
		}

		out.println(cnt);
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

}

Measured memory_bytes: 21712
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int, int >
#define F first
#define S second
#define int  long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
using namespace std;
const int N=2e5+100,mod=1e9+7;
vector <int> g[N];
ll h[N];
ll in[N],ts=0;
ll C[N][2];
ll power(ll n,ll k){
    if (k==0){
        return 1;
    }
    if (k%2==1){
        ll x=power(n,k/2);
        return x*x%mod*n%mod;
    }
    ll x=power(n,k/2);
    return x*x%mod;
}
void Add(string x) {
    ll hi=0;
	int now = 0;
	for (char ch : x) {
		if (!C[now][ch - '0']) {
            C[now][ch - '0'] = ++ts;
            in[now]++;
        }
		h[now]=hi;
		now = C[now][ch - '0'];
		hi++;
	}
	h[now]=hi;
	//ras[id]=now;

}

int32_t main(){
    ll n;
    ll l;

    cin >> n;
    cin >> l;
    vector <int> a;
    for (int i=0;i<n;i++){
        string y;
        cin >> y;
        Add(y);
    }
    for (int i=0;i<=ts;i++){
        if (in[i]==1){
            ll z=l-h[i];
            ll p=1;
            while(z%2==0){
                p++;
                z/=2;
            }
            a.pb(p);
        }
    }
    ll x=0;
    for (int i=0;i<a.size();i++){
        x ^= a[i];
    }
    if (x==0)
        cout << "Bob" << endl;
    else
        cout << "Alice";
}




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

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

Measured memory_bytes: 256
#include<iostream>
int main()
{
	int data[10000][2];
	int number;
	for(int i = 0;; i++)
	{
		for(int j = 0; j < 2; j++)
		{
			std::cin >> data[i][j];
		}
		if(data[i][0] == 0 && data[i][1] == 0)
		{
			number = i;
			break;
		}
	}
	for(int i = 0; i < number; i++)
	{
		std::cout << (data[i][0] > data[i][1] ? data[i][1] : data[i][0]) << ' ' <<  (data[i][0] > data[i][1] ? data[i][0] : data[i][1]) << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3080
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const int max_abs = 100001;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	vector<int> cl(max_abs * 2 + 1), cr(max_abs * 2 + 1);
	int N;
	cin >> N;
	long long sl = 0, sr = 0;
	for (int i = 0; i < N; ++i) {
		int L, R;
		cin >> L >> R;
		++cl[L + max_abs];
		++cr[R + max_abs];
		sr += L + max_abs;
	}
	++N;
	++cl[max_abs];
	++cr[max_abs];
	sr += max_abs;
	int pl = 0, pr = N;
	long long ret = (1LL << 62);
	for (int i = 0; i <= max_abs * 2; ++i) {
		pr -= cl[i];
		sr -= (long long)cl[i] * i;
		if (pl <= N / 2 && pr <= N / 2) {
			ret = min(ret, -2 * sl - 2LL * i * (N / 2 - pl) + 2LL * i * (N / 2 - pr) + 2 * sr);
		}
		pl += cr[i];
		sl += (long long)cr[i] * i;
	}
	cout << ret << '\n';
	return 0;
}

Measured memory_bytes: 1792
#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 ALL(v) v.begin(), v.end()
using namespace std;
using P = pair<int, int>;
typedef long long ll;
const int MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> cn(n + 1, 0);
  rep(i, n) cin >> a[i];
  cn[0] = 3;
  ll ans = 1;
  rep(i, n){
    if(cn[a[i]] <= 0){
      cout << 0 << endl;
      return 0;
    }
    ans *= cn[a[i]];
    ans %= MOD;
    cn[a[i]]--;
    cn[a[i] + 1]++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4012
//04
#include<iostream>
#include<algorithm>
#include<functional>

using namespace std;

int main(){
  int a[5];
  for(int i=0;i<5;i++){
    cin>>a[i];
  }
  sort(a,a+5,greater<int>());
  for(int i=0;i<5;i++){
    cout<<a[i]<<((i!=4)?' ':'\n');
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int a[1005],n,cnt,ans,ans2,ans3;
int main()
{
    cin >> n;
    for(int i = 1;i <= n;i++)
    {
        cin >> a[i];
        cnt += a[i];
    }
    int t = cnt / n;
    for(int i = 1;i <= n;i++)
    {
        ans += (a[i] - t) * (a[i] - t);
        ans2 += (a[i] - t - 1) * (a[i] - t - 1);
        ans3 += (a[i] - t + 1) * (a[i] - t + 1);
    }
    int tt = ans < ans2 ? ans : ans2;
    tt = tt > ans3 ? ans3 : tt;
    cout << tt;
    return 0;
}

Measured memory_bytes: 256
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast int x = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
ll ans;
void solve()
{
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ans+=min(a,k);k-=min(a,k);
    k-=min(b,k);
    ans-=min(c,k);k-=min(c,k);
    cout<<ans<<endl;
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3636
let a = read_int()
let b = read_int()
let c = read_int()
let x = read_int()

let rec count i j k n =
  if i > a then n
  else if j > b then (count (i+1) 0 0 n)
  else if k > c then (count i (j+1) 0 n)
  else if 500*i + 100*j + 50*k = x then (count i j (k+1) n+1)
  else (count i j (k+1) n)

let answer = string_of_int (count 0 0 0 0)

let () = print_endline answer

Measured memory_bytes: 384
import itertools
N = int(input())
NL = [str(i) for i in range(1,N+1)]
P = input().replace(' ', '')
Q = input().replace(' ', '')
NLL = sorted(list(itertools.permutations(NL,N)))
a = 0
b = 0
for i in range(len(NLL)):
    if ''.join(list(NLL[i])) == P:
        a = i+1
    if ''.join(list(NLL[i])) == Q:
        b = i+1
print(abs(a-b))

Measured memory_bytes: 8308
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <set>
using namespace std;

int main()
{
	string S;
	int32_t K;
	cin >> S >> K;

	int32_t one_index = -1;
	int32_t res = 1;
	for (size_t i = 0; i < S.size(); i++) {
		if (S[i] == '1') {
			one_index = i;
		} else {
			res = S[i] - '0';
			break;
		}
	}
	if (one_index >= K - 1)
		res = 1;
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
ll a,b,v,w, T;
int main()
{
    IO
    cin>>a>>v>>b>>w>>T;
    if(a>b)
        swap(a,b);
    if(v==w)
    {
        if(a==b)
            cout<<"YES\n";
        else
            cout<<"NO\n";
        return 0;
    }
    if(T*(w-v)<=a-b && (w-v<=0))
        cout<<"YES\n";
    else
        cout<<"NO\n";
}


Measured memory_bytes: 3692
#include<bits/stdc++.h>
//#include<windows.h>
using namespace std;
int main()
{
	long long a,b,c,d;
	cin >> a >> b >> c >> d;
	long long s1=a*c,s2=b*c,s3=a*d,s4=b*d;
	cout << max(s1,max(s2,max(s3,s4)));
	return 0;
}


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

using namespace std;

class Solution {
public:
	void solve() {
		int M = 2019;
		string s;
		cin >> s;
		int n = s.length();
		vector<int> t(n + 1), cnt(M);
		cnt[0] = 1;
		int m = 1;
		int ans = 0;
		for (int i = n - 1; i >= 0; i--) {
			t[i] = (t[i + 1] + m * (s[i] - '0')) % M;
			ans += cnt[t[i]]++;
			m = (m * 10) % M;
		}
		cout << ans << "\n";

		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 4352
#include<stdio.h>

int main()
{
  int n,k;
  int i;
  long long a[200001];
  scanf("%d%d",&n,&k);
  for(i=0;i<n;i++){
    scanf("%lld",&a[i]);
  }
  for(i=k;i<n;i++){
    if(a[i]>a[i-k]) printf("Yes\n");
    else printf("No\n");
  }
  return 0;
} 


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

int main() {
  char s[0];
  int a[4];
  for (int i = 0; i < 4; i++) {
    cin >> s[0];
    a[i] = atoi(s);
  }

  char op[2];
  op[0] = '+';
  op[1] = '-';
  for (int i = 0; i < 2; i++) {
    int AB = a[0];
    if (i == 0)
      AB += a[1];
    else
      AB -= a[1];
    for (int j = 0; j < 2; j++) {
      int ABC = AB;
      if (j == 0)
        ABC += a[2];
      else
        ABC -= a[2];
      for (int k = 0; k < 2; k++) {
        int ABCD = ABC;
        if (k == 0)
          ABCD += a[3];
        else
          ABCD -= a[3];
        if (ABCD == 7) {
          cout << a[0] << op[i] << a[1] << op[j] << a[2] << op[k] << a[3]
               << "=7" << endl;
          return 0;
        }
      }
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

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

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

int main() {
    ll X,Y;
    cin >> X >> Y;

    ll result = X;
    ll ans = 0;
    while(result <= Y){
        result *= 2;
        ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

// RangeMinimumQuery
template<typename T> struct SegTree {
	T init_val;
	int n;
	vector<T> dat;
	
	SegTree(int _n, T init_val) : init_val(init_val) {
		n = 1;
		while (n < _n) n *= 2;
		dat.resize(2 * n - 1, init_val);
	}
	
	void set(int k, T a) {
		dat[k + n - 1] = a;
		update(k, dat[k + n - 1]);
	}
	
	void update(int k, T a) {
		k += n - 1;
		dat[k] = min(dat[k], a);
		
		while (k > 0) {
			k = (k - 1) / 2;
			dat[k] = min(dat[2 * k + 1], dat[2 * k + 2]);
		}
	}
	
	T query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return init_val;
		if (a <= l && r <= b) return dat[k];
		return min(query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (l + r) / 2, r));
	}
	
	T query(int a, int b) {
		return query(a, b, 0, 0, n);
	}
};

int main() {
	int n, q; cin >> n >> q;
	
	SegTree<ll> sg(n, (1ll<<31) - 1);
	
	while (q--) {
		int com, x, y;
		scanf("%d %d %d", &com, &x, &y);
		if (com == 0) sg.set(x, y);
		else printf("%lld\n", sg.query(x, y + 1));
	}
	return 0;
}

Measured memory_bytes: 4972
#include<bits/stdc++.h>
#define int long long
using namespace std;
main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i=0;i<n;i++) cin >> v[i];
    if (n % 3 != 0){
        sort(v.begin(), v.end());
        if (v.back() == 0){
            cout << "Yes";
            return 0;
        }
        cout << "No" << endl;
        return 0;
    }
    map<int, int> tet;
    for (int i=0;i<n;i++) tet[v[i]]++;
    vector<int> kek;
    for (auto it = tet.begin(); it != tet.end(); it++){
        pair<int, int> p = *it;
        if (p.second % (n/3) != 0){
            cout << "No" << endl;
            return 0;
        }
        for (int i=0; i < p.second/(n/3); i++) kek.push_back(p.first);
    }
    if ((kek[0]^kek[1]^kek[2]) == 0){
        cout << "Yes";
    }
    else cout << "No";
    return 0;
}

Measured memory_bytes: 5632
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using ull=unsigned long long int;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
while(1){
  ll n;
  cin>>n;
  if(n==0)return 0;
  ll ans=inf;
  for(ll i=0;i*i*i<=n;i++){
    for(ll j=0;i*i*i+j*j<=n;j++){
      chmin(ans,n-i*i*i-j*j+i+j);
    }
  }
  cout<<ans<<"\n";
}
}


Measured memory_bytes: 3040
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include <sstream>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include <iomanip>
#include <numeric>
#include <math.h>
using namespace std;


int main(void){
    vector<double> rl;
    long N,K;
    cin >> N >> K;
    map <int,int> balls;
    for(int i =0; i < N; i++){
        int tmp ;
        cin >> tmp;
        balls[tmp]++;
    }

    vector<int> nums;
    for(auto it = balls.begin(); it != balls.end(); ++it){
        int first,second;
        second = it->second;
        nums.push_back(second);
    }

    int rewrite = 0;
    int del = balls.size() - K;

    //cout << balls.size() << endl;

    sort(nums.begin(), nums.end());
    for(int i =0; i < del; i++){
        rewrite += nums[i];
    }

    cout << rewrite << endl;
    return 0;
}

Measured memory_bytes: 13504
#include "bits/stdc++.h"
using namespace std;
#define MODULO 1000000007
#define PI 3.14159265359
typedef long long int ll;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
	int t;
	cin>>t;
	if(t==0)
	cout<<"1";
	else
	cout<<"0";
	    return 0;
}


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

int main(){
	long double a,b,c;

	cin >> a >> b >> c;

	 if(c - a - b > 0 && 4 * a * b < (c - a - b) * (c - a - b)){
		cout << "Yes";
	 }else{
		 cout << "No";
	 }
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

A = list(map(lambda x:ord(x)-63, readline().strip()))
B = list(map(lambda x:ord(x)-63, readline().strip()))
C = list(map(lambda x:ord(x)-63, readline().strip()))

LA = len(A)
LB = len(B)
LC = len(C)
geta = 4002

tAB = [True]*(2*geta + 4)
for i in range(-geta//2, geta//2+1):
    for j in range(LB):
        if 0 <= j+i < LA and A[i+j] and B[j] and A[i+j] != B[j]:
            tAB[i] = False
            break

tAC = [True]*(2*geta + 4)
for i in range(-geta//2, geta//2+1):
    for j in range(LC):
        if 0 <= j+i < LA and A[i+j] and C[j] and A[i+j] != C[j]:
            tAC[i] = False
            break


tBC = [True]*(2*geta + 4)
for i in range(-geta, geta+1):
    for j in range(LC):
        if 0 <= j+i < LB and B[i+j] and C[j] and B[i+j] != C[j]:
            tBC[i] = False
            break

ans = 3*geta
for ib in range(-geta, geta+1):
    if tAB[ib]:
        for ic in range(min(0, ib)-LC, 1+max(LA-1, ib+LB-1)):
            if tAC[ic]:
                if -geta <= ic-ib <= geta and not tBC[ic-ib]:
                    continue
                l = min(0, ib, ic)
                r = max(LA-1, ib+LB-1, ic+LC-1)
                ans = min(ans, r-l+1)
print(ans)

Measured memory_bytes: 56284
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) {
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }
int f(string S) {
  int a = (S[0] - '0') * 10 + S[1] - '0';
  int b = (S[2] - '0') * 10 + S[3] - '0';
  //  cout << a << "," << b << endl;                                                         
  bool aism = (a >= 1 && a <= 12);
  bool bism = (b >= 1 && b <= 12);
  if(aism) {
    if(bism) return 3;
    else return	2;
  } else {
    if(bism) return 1;
    else return	4;
  }

}
int main() {
  string S; cin>>S;
  int tmp = f(S);
  string ans = "";
  switch (tmp) {
  case 1: ans = "YYMM"; break;
  case 2: ans = "MMYY"; break;
  case 3: ans = "AMBIGUOUS"; break;
  case 4: ans = "NA"; break;
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
    ll m, k;
    cin >> m >> k;

    if (k >= (1LL << m)) {
        cout << -1 << endl;
    } else if (m == 0) {
        cout << 0 << " " << 0 << endl;
    } else if (m == 1) {
        if (k == 0) {
            cout << 0 << " " << 0 << " " << 1 << " " << 1 << endl;
        } else {
            cout << -1 << endl;
        }
    } else {
        for (int i = 0; i < (1 << m); ++i) {
            if (i != k) cout << i << " ";
        }
        cout << k << " ";
        for (int i = (1 << m) - 1; i >= 0; --i) {
            if (i != k) cout << i << " ";
        }
        cout << k << endl;
    }

    return 0;
}

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

int main(){
    int N;
    string S;
    cin >> N >> S;
    int black = 0;
    int white = 0;
    for (int i = 0; i < N; i++){
        if(S[i] == '#') black++;
        else white++;
    }
    int mincount = white;
    int nowcount = mincount;
    for (int i = 0; i < N; i++){
        if (S[i] == '.') {
            nowcount--;
        }
        else nowcount++;
        if (nowcount < mincount) mincount = nowcount;
    }
    cout << mincount << endl;
    return 0;
}

Measured memory_bytes: 640