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

int main() {
  int N, K, count = 0;
  cin >> N >> K;
  
  for (int i = 0; i < N; i++) {
    int h;
    cin >> h;
    if (h >= K) {
      count++;
    }
  }
  
  cout << count << endl;
  

}


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

typedef long long ll;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
    return arg1.first > arg2.first;
}

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

    if(s.at(0)=='A') cout << 'T' << endl;
    else if(s.at(0)=='T') cout << 'A' << endl;
    else if(s.at(0)=='G') cout << 'C' << endl;
    else cout << 'G' << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<string>
#include<iostream>
#include<sstream>

using namespace std;

int n;

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		string str,str2;
		cin >> str >> str2;
		int c=0;
		int f=1;
		for(int i=0;i<str.size();i++){
			if(str[i]>='2' && str[i]<='9'){
				f=str[i]-'0';
			}
			if(str[i]=='m'){
				c+=1000*f;
				f=1;
			}
			if(str[i]=='c'){
				c+=100*f;
				f=1;	
			}
			if(str[i]=='x'){
				c+=10*f;
				f=1;	
			}
			if(str[i]=='i'){
				c+=f;
				f=1;	
			}
		}
		f=1;
		for(int i=0;i<str2.size();i++){
			if(str2[i]>='2' && str2[i]<='9'){
				f=str2[i]-'0';
			}
			if(str2[i]=='m'){
				c+=1000*f;
				f=1;
			}
			if(str2[i]=='c'){
				c+=100*f;
				f=1;	
			}
			if(str2[i]=='x'){
				c+=10*f;
				f=1;	
			}
			if(str2[i]=='i'){
				c+=f;
				f=1;
			}
		}
		int k=1000;
		while(k>0){
			int d=c/k;
			if(d>=1){
				if(d>=2)printf("%d",d);
				if(k==1000)printf("m");
				if(k==100)printf("c");
				if(k==10)printf("x");
				if(k==1)printf("i");
			}
			c%=k;
			k/=10;
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1236
import java.util.Scanner;

public class Main {

    private static class Point {
        double x = 0;
        double y = 0;
        public Point(double x, double y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public String toString() {
            return String.format("%.5f %.5f", x, y);
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        Point min = new Point(0, 0);
        Point max = new Point(100, 0);

        System.out.println(min);
        koch(min, max, n);
        System.out.println(max);
    }

    private static void koch(Point min, Point max, int n) {
        if (n == 0) return;
        double sx = (2*min.x+1*max.x) / 3;
        double sy = (2*min.y+1*max.y) / 3;
        Point s = new Point(sx, sy);

        double tx = (1*min.x+2*max.x) / 3;
        double ty = (1*min.y+2*max.y) / 3;
        Point t = new Point(tx, ty);

        double ux = (tx-sx)*Math.cos(Math.toRadians(60)) - (ty-sy)*Math.sin(Math.toRadians(60))+sx;
        double uy = (tx-sx)*Math.sin(Math.toRadians(60)) + (ty-sy)*Math.cos(Math.toRadians(60))+sy;
        Point u = new Point(ux, uy);

        koch(min, s, n-1);
        System.out.println(s);
        koch(s, u, n-1);
        System.out.println(u);
        koch(u, t, n-1);
        System.out.println(t);
        koch(t, max, n-1);
    }
}



Measured memory_bytes: 42316
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define ALL(x)    (x).begin(),(x).end()
#define UNIQ(c)   (c).erase(unique(ALL((c))), end((c)))
#define mp        make_pair
#define eb        emplace_back
#define REP(i, a) for (int i = 0; i < (a); i++)


string s;
int main() {
	cin >> s;
	int a = 0, b = 0, c = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'a')a++;
		if (s[i] == 'b')b++;
		if (s[i] == 'c')c++;
	}
	cout << ((max({ a,b,c }) - min({ a,b,c }) <= 1) ? "YES" : "NO") << endl;
}

Measured memory_bytes: 512
#!/usr/bin/env python
# -*- coding: utf-8 -*-

ABCDE = [int(input()) for i in range(5)]

e = min(map(lambda x: (x - 1) % 10 + 1, ABCDE))
s = list(map(lambda x: int((x - 1) / 10) * 10 + 10, ABCDE))
print(sum(s) - (10 - e))


Measured memory_bytes: 2940
N, T = map(int, input().split())
t = list(map(int, input().split()))
ans = 0 

for i in range(N-1):
    if (t[i+1] - t[i]) < T:
        ans = ans +  (t[i+1] - t[i])
    else:
        ans = ans + T

print(ans + T)

Measured memory_bytes: 25196
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll,ll>;
using vpl = vector<pll>;
using vvpl = vector<vpl>;
using vb = vector<bool>;
using vs = vector<string>;

const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;

#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define has(c,i) (c.find() != end(c))
#define FOR(i,a,b) for (ll i=(a); i<(b); i++)
#define FORD(i,a,b) for (ll i=ll(b)-1; i>=(a); i--)

#define DBG 1
#define TR(X) ({ if(DBG) cerr << "TR: " << (#X) << " = " << (X) << endl; })

template<class T, class U>
ostream& operator<<(ostream& os, pair<T,U> obj){
	os << "(" << obj.xx << ", " << obj.yy << ")";
	return os;
}

template<class T, class U>
ostream& operator<<(ostream& os, map<T,U> obj){
	os << "{";
	for(const auto &it : obj)
		os << " " << it;
	os << "}";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> obj){
	os << "[";
	FOR(i,0,sz(obj)-1)
		os << obj[i] << ", ";
	os << obj[sz(obj)-1] << "]";
	return os;
}


vvpl adj;
map<ll,vl> colors;

void dfs(ll cur, ll last, ll col){
	ll c = 0;
	for(auto &it : adj[cur]){
		if(it.xx == last)
			continue;

		if(c == col)
			c++;

		dfs(it.xx, cur, c);
		colors[c].pb(it.yy);

		c++;
	}
}

int main(void){
	cin.sync_with_stdio(false);
	cin.tie(NULL);

	ll N;
	cin >> N;
	adj.assign(N, vpl());
	FOR(i,1,N){
		ll a, b;
		cin >> a >> b;
		a--;
		b--;

		adj[a].eb(b,i);
		adj[b].eb(a,i);
	}

	dfs(0,-1,-1);

	vl res(N-1);

	for(auto it : colors) {
		for(auto cur : it.yy) {
			res[cur-1] = it.xx;
		}
	}

	TR(res);

	cout << sz(colors) << '\n';
	FOR(i,0,sz(res))
		cout << res[i] + 1 << '\n';
	cout << flush;
}


Measured memory_bytes: 12652
n, m = map(int, input().split())
a = []
flag = True
for i in range(m):
    l, r = map(int, input().split())
    if i == 0: 
        l1 = l
        r1 = r
    else:
        if r < l1 or r1 < l:
            flag = False
        elif l1 < l:
            l1 = l
        elif r1 > r:
            r1 = r
if flag: print(r1-l1+1)
else: print(0)

Measured memory_bytes: 3064
n,k = map(int, input().split())
r,s,p = map(int, input().split())
t = input()
dic = {}
dic['r'] = p
dic['s'] = r
dic['p'] = s
ans = sum([dic[s] for s in t])
for i in range(k,len(t)):
    if t[i-k] == t[i]:
        ans -= dic[t[i]]
        t = t[:i] + 'a' + t[(i+1):]
print(ans)

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

struct Edge {
  int to, id;
};

vector<vector<Edge>> g;
vector<int> ans;

int main() {
  int n;
  cin >> n;
  g.resize(n);
  ans.resize(n - 1);
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    g[a].emplace_back((Edge){b, i});
    g[b].emplace_back((Edge){a, i});
  }
  queue<int> q;
  q.push(0);
  vector<int> used(n);
  used[0] = 1;
  while (q.size()) {
    int v = q.front();
    q.pop();
    int c = -1;

    rep(i, g[v].size()) {
      int u = g[v][i].to, ei = g[v][i].id;
      if (used[u]) c = ans[ei];
    }

    int k = 1;
    rep(i, g[v].size()) {
      int u = g[v][i].to, ei = g[v][i].id;
      if (used[u]) continue;
      if (k == c) k++;
      ans[ei] = k;
      k++;
      q.push(u);
      used[u] = 1;
    }
  }

  int mx = 0;
  rep(i, n) mx = max(mx, int(g[i].size()));
  cout << mx << endl;
  rep(i, n - 1) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5 + 10;

int main() {
    int n, m;
    cin >> n >> m;
    typedef pair<int, int> pa;
    multiset<pa> st;
    for(int i = 0, x; i < n; i++) {
        cin >> x;
        st.insert(pa(x, 1));
    }
    for(int i = 0, a, b; i < m; i++) {
        cin >> a >> b;
        st.insert(pa(b, a));
    }
    ll ans = 0;
    while(n--) {
        auto it = prev(st.end());
        pa p = *it;
        ans += p.first;
        p.second--;
        st.erase(it);
        if(p.second != 0) {
            st.insert(p);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9600
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Int (Int64)
import Data.Coerce
import qualified Data.ByteString.Char8 as BS
import Control.Exception (assert)

main = do
  n <- readLn
  s <- BS.getLine
  assert (BS.length s == 2 * n) $ return ()
  let loop :: N -> Int -> Int -> N
      loop !acc !k !i | BS.length s == i = if k == 0 then acc else 0
                      | BS.index s i == 'W' = if even k
                                              then loop (acc * fromIntegral k) (k-1) (i+1)
                                              else loop acc (k+1) (i+1)
                      | otherwise = if even k
                                    then loop acc (k+1) (i+1)
                                    else loop (acc * fromIntegral k) (k-1) (i+1)
  print $ loop (product $ map fromIntegral [1..n]) 0 0

--
-- Modular Arithmetic
--

modulo :: Int64
modulo = 10^9+7
addMod, subMod, mulMod :: Int64 -> Int64 -> Int64
addMod !x !y | x + y >= modulo = x + y - modulo
             | otherwise = x + y
subMod !x !y | x >= y = x - y
             | otherwise = x - y + modulo
mulMod !x !y = (x * y) `rem` modulo

newtype N = N { unwrapN :: Int64 } deriving (Eq)
instance Show N where
  show (N x) = show x
instance Num N where
  (+) = coerce addMod
  (-) = coerce subMod
  (*) = coerce mulMod
  fromInteger n = N (fromInteger (n `mod` fromIntegral modulo))
  abs = undefined; signum = undefined

{-# RULES
"^9/Int" forall x. x ^ (9 :: Int) = let u = x; v = u * u * u in v * v * v
"^9/Integer" forall x. x ^ (9 :: Integer) = let u = x; v = u * u * u in v * v * v
 #-}


Measured memory_bytes: 1404
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main()
{
	int N;
	long long value = 1;
	long long ans = 1;
	int num = 1000000007;
	vector<int> p;

	p.push_back(2);
	for (int i = 3; i <= 1000; i += 2)
	{
		bool k = false;
		for (int j = 3; j <= sqrt(i); j += 2)
		{
			if (i % j == 0)
			{
				k = true;
				break;
			}
		}

		if (!k)
			p.push_back(i);
	}
	vector<int> Pc(p.size());
	for (int i = 0; i < Pc.size(); i++)
		Pc[i] = 0;

	cin >> N;

	//N!
	for (int i = 0; i < N; i++)
	{
		value = i + 1;

		for (int j = 0; j < p.size(); j++)
		{
			int v = 0;
			while (value % p[j] == 0)
			{
				value /= p[j];
				v++;
			}
			Pc[j] += v;
		}
	}

	for (int i = 0; i < Pc.size(); i++)
	{
		ans = (ans % num) * (Pc[i] + 1 % num);
	}
	ans %= num;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 998244353
#define in(x, a, b) (a <= x && x < b)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

void solve() {
	int n, s;
	cin >> n >> s;
	
	vi a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	
	int ans = 0;
	vvi dp(n + 1, vi(s + 1));
	dp[0][0] = 1;
	for(int i = 1; i <= n; i++) {
		for(int j = 0; j <= s; j++) dp[i][j] = (dp[i][j] + dp[i - 1][j]) % P;
		for(int j = 0; j < s; j++) if(j + a[i - 1] <= s) dp[i][j + a[i - 1]] = (dp[i][j + a[i - 1]] + (dp[i - 1][j] * (j == 0 ? i : 1)) % P) % P;
		
		ans = (ans + dp[i][s]) % P; 
	}
	
	cout << ans << endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	solve();
    return 0;
}

Measured memory_bytes: 38632
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	n := io.NextInt()
	count := map[string]int{}
	for i := 0; i < n; i++ {
		count[io.Next()]++
	}
	io.Println(len(count))
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 20708
/*
Author-> Codie_1(Akash)
*/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(n) for(int i=0;i<n;i++)
#define repi(n) for(int i=0;i<n;i++)
#define repj(n) for(int j=0;j<n;j++)
#define repp(n) for(int i=0;i<=n;i++)
#define repab(a,b) for(int i=a;i<b;i++)
#define w(t) int t; cin>>t; while(t--)
#define endl '\n'
#define pi pair<int, int> p
#define pis pair<int, string> p
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define vi vector<int> v
#define vl vector<long long> v;
typedef long long ll;



int main()
{
	int ac = 0, wa = 0, tle = 0, re = 0;
	w(t)
	{
		string s;
		cin >> s;
		if (s == "AC")
			ac++;
		else if (s == "WA")
			wa++;
		else if (s == "TLE")
			tle++;
		else
			re++;
	}
	cout << "AC x " << ac << endl;
	cout << "WA x " << wa << endl;
	cout << "TLE x " << tle << endl;
	cout << "RE x " << re << endl;

	return 0;
}

Measured memory_bytes: 3628
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
aa = [a[0]]
bb = [b[0]]
for i in range(1,n):
  aa.append(aa[-1]+a[i])
for i in range(1,m):
  bb.append(bb[-1]+b[i])
import bisect
#print(aa)
#print(bb)
ans = bisect.bisect_right(bb,k)
#print(ans)
for i in range(n):
  if aa[i] > k:
    #print(aa[i])
    break
  tmp = bisect.bisect_right(bb,k-aa[i])+i+1
  ans = max(ans,tmp)
  #print(tmp)
print(ans)

Measured memory_bytes: 126952
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/math/common_factor_rt.hpp>

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T>
    inline std::vector<T> read(std::size_t n)
    {
        std::vector<T> res;
        res.reserve(n);

        for (std::size_t i = 0; i < n; ++i) {
            T tmp;
            cin >> tmp;
            res.emplace_back(tmp);
        }
        return res;
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

    template <class T, class... Args>
    void impl(T&& v, Args&&... args)
    {
        cout << std::forward<T>(v) << ' ';
        impl(std::forward<Args>(args)...);
    }
    template <class T>
    void impl(T&& v)
    {
        cout << std::forward<T>(v);
    }

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class... Args>
    void operator()(Args&&... args)
    {
        impl(std::forward<Args>(args)...);
        cout << '\n';
    }
    template <class... Args>
    void noreturn(Args&&... args)
    {
        impl(std::forward<Args>(args)...);
    }

    template <class T>
    void print(const T& container)
    {
        bool first = true;
        for (auto&& x : container) {
            if (!first) {
                cout << ' ';
            }
            cout << x;
            first = false;
        }
    }
};

void prog()
{
    input in;
    output out;

    uint64_t n, a, b;
    in >> n, a, b;
    if ((b - a) % 2 == 0) {
        out((b - a) / 2);
        return;
    }

    auto d = std::min(a - 1, n - b);
    out(d + 1 + (b - a) / 2);
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline long long int read()
{
    char c=getchar();
    long long int x=0,f=1;
    while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
    while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x*f;
}
int main()
{
    int A = read(), B = read(), C = read();
    if(A == B && A != C) cout<<"Yes"<<endl;
    else if(A == C && A != B) cout<<"Yes"<<endl;
    else if(B == C && B != A) cout<<"Yes"<<endl;
    else cout<<"No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
typedef long long ll;
int n;
int a[300009];
int s[300009];

bool judge(ll mid,ll k){
  int idx=upper_bound(a,a+n,mid)-a;
  ll sum=s[idx]+mid*(n-idx);
  if(sum>=mid*k)return 1;
  else return 0;
}

int main(){
  cin>>n;
  rep(i,n){
    int x;
    cin>>x;
    a[x-1]++;
  }
  sort(a,a+n);
  for(int i=0;i<n;i++){
    s[i+1]=s[i]+a[i];
  }

  for(int i=1;i<=n;i++){
    int left=-1,right=n+1;
    while(right-left>1){
      ll mid=(left+right)/2;
      if(judge(mid,i)){
        left=mid;
      }
      else{
        right=mid;
      }
    }
    cout<<left<<endl;
  }

  return(0);

}


Measured memory_bytes: 3200
#include <iostream>
#include <map>
#include <vector>
#include <algorithm> 
int main() {
  int N,K;
  std::cin >> N >> K;
  std::map<int,int> baket;
  for(int i=0; i<N; i++){
    int n;
    std::cin >> n;
    if(baket.count(n))
      baket[n]++;
    else
      baket[n] = 1;
  }
  std::vector<int> cnt;
  for(auto &b:baket)
    cnt.push_back(b.second);
  std::sort(cnt.begin(),cnt.end());
  int sum=0;
  int M = static_cast<int>(cnt.size()) - K;
  if (M < 0) M = 0;
  for(int i=0; i< M ;i++)
    sum+=cnt[i];
  std::cout << sum << std::endl;
  return 0;
}

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
// #define SORT(v, n) stable_sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const int N     = 100;
int       white = 0;
int       gray  = 1;
int       black = 2;

int n, m[N][N];
int color[N], d[N], f[N], tt;

// 再帰による深さ優先探索
void dfs_visit(int u) {
    color[u] = gray;
    d[u]     = ++tt;  //最初の訪問
    rep(v, n) {
        if (m[u][v] == 0) continue;
        if (color[v] == white) {
            dfs_visit(v);
        }
    }
    color[u] = black;
    f[u]     = ++tt;  // 訪問の完了
}

void dfs() {
    //初期化
    rep(u, n) color[u] = white;
    tt                 = 0;
    rep(u, n) {
        // 未訪問のuを始点として深さ優先探索
        if (color[u] == white) dfs_visit(u);
    }
    rep(u, n) { cout << u + 1 << " " << d[u] << " " << f[u] << endl; }
}

// 再帰による深さ優先探索
int main() {
    int u, v, k;
    cin >> n;
    rep(i, n) rep(j, n) m[i][j] = 0;

    rep(i, n) {
        cin >> u >> k;
        u--;
        rep(j, k) {
            cin >> v;
            v--;
            m[u][v] = 1;
        }
    }
    dfs();

    return 0;
}



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

int ball[10];

bool dfs(int i = 0, int l = 0, int r = 0) {
	if(i == 10)
		return true;

	if(l < ball[i] && dfs(i + 1, ball[i], r))
		return true;

	if(r < ball[i] && dfs(i + 1, l, ball[i]))
		return true;

	return false;
}


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

	int n;
	cin >> n;

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

		cout << (dfs() ? "YES" : "NO") << endl;
	}

	return EXIT_SUCCESS;
}

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

int main() {
  string s;
  cin >> s;
  rep(i,s.size()-1) {
    if (s.substr(i,2) == "AC") {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3608
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))
n = ii()
A = iil()

odd = 0
even = 0
mulof4 = 0
for i in A:
    if i%2 == 1:
        odd += 1
    elif i%4 == 2:
        even += 1
    else:
        mulof4 += 1

if odd > mulof4+1:
    print('No')
else:
    if odd < mulof4+1:
        print('Yes')
    else:
        print("Yes" if even == 0 else 'No')

Measured memory_bytes: 14480
#include <bits/stdc++.h>
using namespace std;
void read (int &x) {
	char ch = getchar(); x = 0;
	while (!isdigit(ch)) ch = getchar(); x = 0;
	while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
} const int N = (1 << 18) + 100, M = 1e5 + 10;
int m, mx, V[N], W[N], lg[N], d[(1 << 9) + 100][M];
void dfs (int u, int la, int dep) {
	if (dep > m) return;
	for (int i = mx; i >= W[u]; --i) {
		d[u][i] = max (d[la][i], d[la][i - W[u]] + V[u]);
	} for (int i = 1; i < W[u]; ++i) d[u][i] = d[la][i];
	for (int i = 1; i <= mx; ++i) d[u][i] = max (d[u][i], d[u][i - 1]);
	dfs (u << 1, u, dep + 1), dfs ((u << 1 | 1), u, dep + 1);
} int res, t, v[N], l[N];
void work (int u, int _v, int _w) {
	if (_w > l[t]) return;
	if (lg[u] <= m) { res = max (res, d[u][l[t] - _w] + _v); return; }
	work (u >> 1, _v + V[u], _w + W[u]), work (u >> 1, _v, _w);
}
signed main() {
	int n; read (n); 
	for (int i = 1; i <= n; ++i) read (V[i]), read (W[i]);
	int q; read (q);
	for (int i = 1; i <= q; ++i) 
		read (v[i]), read (l[i]), mx = max (mx, l[i]);
	m = 9; while ((1 << m) * (1 << m) > n + 1) --m;
	dfs (1, 0, 1); lg[1] = 1;
	for (int i = 2; i <= n; ++i) lg[i] = lg[i >> 1] + 1;
	for (t = 1; t <= q; ++t) {
		res = 0, work (v[t], 0, 0), printf ("%d\n", res); 
	} return 0;
}

Measured memory_bytes: 207156
import java.util.Scanner;
class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = x-a;
		int d = c/b*b;
		int remaining = c-d;
		System.out.println(remaining);
	}
}

Measured memory_bytes: 22868
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long a = long.Parse(str[0]);
		long b = long.Parse(str[1]);
		Console.WriteLine(Lcm(a,b));
	}
	
	public static long Gcd(long a, long b) {
		if (a < b)
			return Gcd(b, a);
		while (b != 0) {
			var r = a % b;
			a = b;
			b = r;
		}
		return a;
	}
	public static long Lcm(long a, long b) {
        return a * b / Gcd(a, b);
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <map>
#include <fstream>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define INF 1e9 
typedef long long ll;
typedef long double ld;
int main(){
    int n,m;
    cin>>n>>m;
    vector<vector<int>> edges(n+1);
    int a,b;
    REP(i,m){
        cin>>a>>b;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    vector<int> nodes(n-1);
    REP(i,n-1)nodes[i]=i+2;
    int cnt=0;
    if(SIZE(nodes)==1){
        cnt=1;
    }else{
        do{
            bool can=true;
            int from=1;
            REP(i,n-1){
                int to=nodes[i];
                if(find(ALL(edges[from]),to)!=edges[from].end()){
                    from=to;
                }else{
                    can=false;
                    break;
                }
            }
            if(can)cnt++;
        }while(next_permutation(ALL(nodes)));
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(x) x.begin(), x.end()

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef long long ll;

template <typename T> void max_self(T& a, T b){
  a = max(a,b);
}

template <typename T> void min_self(T& a, T b){
  a = min(a,b);
}

void solve(){	
  ll a; cin>>a;
  string str;
  cin>>str;
  int k = str[0]-'0';
  k = k*10 + str[2]-'0';
  k = k*10 + str[3]-'0';
  a*=k;
  cout<<a/100<<endl;
}

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


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	bool ok = true;
	string s;cin>>s;
	int n = s.size();
	int l = 0, r = n -1;
	while(l <= r && s[l]==s[r]){
		l++; --r;
	}
	ok &= (l > r);
	l = 0, r = n / 2 - 1;
	while(l <= r && s[l]==s[r]){
		l++; --r;
	}
	ok &= (l > r);
	l = (n+3)/2 - 1, r = n - 1;
	while(l <= r && s[l]==s[r]){
		l++; --r;
	}
	ok &= (l > r);
	cout<<(ok?"Yes":"No")<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstring>

using namespace std;
int n,i,j,a,b,fr[30],l,ok;
char s[100001];

int main()
{
    cin>>s;
    l=strlen(s);
    ok=1;
    for(i=0;i<l;i++)
    {
        fr[s[i]-'a']++;
        if(fr[s[i]-'a']>1) ok=0;
    }
    if(ok) cout<<"yes\n";
    else cout<<"no\n";
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 2000001
#define M 10001

int main(){
  short A[N], B[N];
  int C[M], n;
      int i, k = 0;

  scanf("%d", &n);

  for(i = 1; i <= n; i++){
    scanf("%d", &A[i]);
    if(A[i] > k) k = A[i];
  }
  
  for(i = 0; i <= k; i++){
    C[i] = 0;
  }

  for(i = 1; i <= n; i++){
    C[A[i]]++;
  }

  for(i = 1; i <= k; i++){
    C[i] += C[i - 1];
  }
  
  
    for(i = n; i > 0; i--){ 
    B[C[A[i]]] = A[i];
    C[A[i]] = C[A[i]]-1;
  }
    
    for(i=1; i <= n ;i++){
      if(i > 1){
	printf(" ");
      }
      printf("%d",B[i]);
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 8452
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  string s, t; cin >> s >> t;
  int ans = 0;
  REP(i, 3) ans += (s[i] == t[i]);
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
adeck = raw_input()
bdeck = raw_input()
cdeck = raw_input()






next = "a"
card = "a"
ahead =0
bhead=0
chead =0

while (1):
    if next == "a":
        if ahead == len(adeck):
            print "A"
            break    
        
        card =adeck[ahead]
        ahead+=1
        


    elif next == "b":
        if bhead == len(bdeck):
            print "B"
            break        
       
        card =bdeck[bhead]

        bhead+=1

    elif next == "c":
        if chead == len(cdeck):
            print "C"
            break        
        
        card =cdeck[chead]

        chead+=1
    
    next = card
        
    


Measured memory_bytes: 2692
// #pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define N 1000000007
#define N2 998244353
#define Nmax 1000005
#define INF (ll)1e18
#define pll pair<ll,ll>
#define mp make_pair
#define fi first
#define se second
#define vv vector
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(ll i=m;i<(n);i++)
#define repr(i,n) repr2(i,n,0)
#define repr2(i,m,n) for(ll i=m;i>=(n);i--)
#define get(n) ll (n); scanf("%lld",&(n));
#define get2(n,k) ll (n),(k); scanf("%lld%lld",&(n),&(k));
#define get3(n,m,k) ll (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k));
#define gets(s) string (s); cin >> (s);
#define ALL(c) (c).begin(),(c).end()
#define fill_nums(A,n) vector<ll> A((n)); for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1); adj[b-1].pb(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1);}
#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); //cout.tie(0);
#define pi 3.1415926535897L
#define db long double  /* print with %Lf */
#define EPS 1e-9
#define flu fflush(stdout)
#define imp {cout<<"No\n"; return 0;}
#define yup {cout<<"Yes\n"; return 0;}
#define debug_vec(vec,n) {rep(idxi,n) cout<<vec[idxi]<<" "; cout<<"\n";}
#define debug_pvec(vec,n) {rep(idxi,n) cout<<vec[idxi].fi<<"-"<<vec[idxi].se<<"  "; cout<<"\n";}
#define debug_set(seta) {cout<<seta.size()<<"\n"; for(auto idxi:seta) cout<<idxi<<" "; cout<<"\n";}
#define debug_map(mappa) {cout<<mappa.size()<<"\n";for(auto idxi:mappa) cout<<idxi.fi<<"-"<<idxi.se<<"  "; cout<<"\n";}
#define debug_vecvec(vec,n) {rep(idxi,n) {for(auto idxi2:vec[idxi]) cout<<idxi2<<" "; cout<<"\n";}}
 
// LOOK AT THESE BEFORE SUBMISSION
// LOOK AT THESE BEFORE SUBMISSION
// ============================================================
// Nmax value and is index access offset taking it beyond Nmax.
// Precision error in case of real numbers.
// N vs N2 chosen correctly.
// Modulo applied everywhere.
// Flush in case of interactive.
// Don't erase value in multiset.
// Check for array indices out of bound (in pre or suff sums).
// Correct return value for functions.
// Confirm the letter case of yes and no.
// Dont paste code two times in the text file.
// ============================================================

int main() {
    
    vector<vector<ll>> A(3, vector<ll>(3,0));
    rep(i,3) {
        rep(j,3) {
            scanf("%lld",&A[i][j]);
        }
    }

    get(n);
    rep(i,n) {
        get(a);
        rep(i,3) rep(j,3) if(A[i][j]==a) A[i][j] = 0;
    }

    rep(i,3) {
        int c = 0; 
        rep(j,3) if(A[i][j]==0) c++;
        if(c==3) yup;
    }
    rep(j,3) {
        int c = 0; 
        rep(i,3) if(A[i][j]==0) c++;
        if(c==3) yup;
    }
    int c = 0;
    rep(i,3) 
        if(A[i][i]==0) c++; 
    if(c==3) yup;

    if(!A[0][2] && !A[1][1] && !A[2][0])
        yup;

    imp;
    return 0;  
}   


Measured memory_bytes: 256
N = int(input())
A = [int(input()) for i in range(N)]

firstVal = max(A)
firstInd = A.index(firstVal)
secondVal = max(A[0:firstInd] + A[firstInd+1:])

for i in range(firstInd):
    print(firstVal)

print(secondVal)

for i in range(N-firstInd-1):
    print(firstVal)


Measured memory_bytes: 20004
N = int(input())

A = list(map(int, input().split()))

cnt = 0

M = 1000

min_ind = 0

def kau(M, a, cnt):
    result_cnt = M // a
    result_kingaku = M - (result_cnt * a)
    return result_kingaku, result_cnt
    
def uru(M, a, cnt):
    result_cnt = 0
    result_kingaku = M + a * cnt
    return result_kingaku, result_cnt

operation = "kau"

for i in range(N - 1):
    eval(operation)(M, A[i], cnt)
    
    if operation == "kau":
        if A[i] < A[i + 1]:
            # print(f"day : {i}, M : {M}, cnt : {cnt}, operation : 買う")
            M, cnt = eval(operation)(M, A[i], cnt)
            operation = "uru"
    else:
        if A[i] > A[i + 1]:
            # print(f"day : {i}, M : {M}, cnt : {cnt}, operation : 売る")
            M, cnt = eval(operation)(M, A[i], cnt)
            operation = "kau"
if cnt:
    M, cnt = uru(M, A[-1], cnt)
    # print(f"day : {N-1}, M : {M}, cnt : {cnt}, operation : 売る")
print(M)

Measured memory_bytes: 9220
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=min(a)+min(b)
for i in range(M):
    x,y,c=map(int,input().split())
    ans=min(ans,a[x-1]+b[y-1]-c)
print(ans)

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


/*
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <ctype.h>
*/



using namespace std;

typedef pair<int , int > pii;
typedef pair<long , long> pll;
typedef pair<pii , int > piii;
typedef pair<pll , long > plll;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector <pii> vii;
typedef vector<pll> vll;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef unsigned long long int ulli;
typedef long long int lli;
typedef float f;
typedef char ch;
typedef pair<int,ll> pill;

#define loop(n) for(int i = 0; i < (n); i++)
#define lp(x , s , e) for(int x = (s); x < (e); x++)
#define lpe(x , s , e) for(int x = (s); x <= (e); x++)
#define readline(s) getline(cin,s)
#define NumofDigits(n) ((int)log10(n)+1)
#define CountofNumber(array,n,x)  (upper_bound(array, array+n, x)-lower_bound(array, array+n, x))
#define F first
#define S second
#define EPS 1e-7
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;
#define MP make_pair
#define PB push_back
#define all(a) a.begin(),a.end()
#define clr(x , val) memset((x) , (val) , sizeof(x))
#define Unique(n)   (n).erase(unique(all(n)), (n).end())
#define endl '\n'

ll power(ll a, ll b)
{
    ll res = 1;
    for(int i = 0; i<b; i++)
       res *= a;

    return res;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    cout << (1000 - (n % 1000)) % 1000;
	return 0;
}


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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

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

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}

//char->int
int ctoi(char c){
    return c-'0';
}



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

    ll ans = 0;

    if(d==0){
        ans = 1*n;
        if(n==100){
            ans = 101;
        }
    }else if(d==1){
        ans = 100*n;
        if(n==100){
            ans = 101*100;
        }
    }else{
        ans = 10000*n;
        if(n==100){
            ans = 101*10000;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
from bisect import bisect_left as bl
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
cs = [0] * (N + 1)
for i in range(N): cs[i + 1] = cs[i] + a[i]

res = sum(a)
for m in range(1, N - 1):
  lsm = cs[m]
  rsm = cs[-1] - cs[m]
  l = bl(cs, lsm / 2)
  l -= l == m
  for i in range(l - 1, l + 2):
    if i == 0: continue
    if i == m: break
    if abs(cs[l] - (cs[m] - cs[l])) > abs(cs[i] - (cs[m] - cs[i])): l = i
  r = bl(cs, rsm // 2 + lsm)
  r -= r == N
  for i in range(r - 1, r + 2):
    if i == m: continue
    if i == N: break
    if abs(cs[-1] - cs[r] - (cs[r] - cs[m])) > abs(cs[-1] - cs[i] - (cs[i] - cs[m])): r = i
  mx = max(cs[l], cs[m] - cs[l], cs[r] - cs[m], cs[-1] - cs[r])
  mn = min(cs[l], cs[m] - cs[l], cs[r] - cs[m], cs[-1] - cs[r])
  res = min(res, mx - mn)
  #print(l, m, r, res)
print(res)

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

#define fst() ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define f(i,a,b) for(i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define endl '\n'
typedef long long ll;

int main()
{
  fst();
  int n,a[100],i;
  cin>>n;
  f(i,0,n) cin>>a[i];
  sort(a,a+n);
  int s1=0,s2=0;
  for(i=n-1;i>=0;i-=2)
  {
    s1+=a[i];
  }
  for(i=n-2;i>=0;i-=2) s2+=a[i];
  cout<<s1-s2;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

const ll N=50;
ll dp[N][2];

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vector<ll> a(n);
	ll x=0,sum=0;
	rep(i,n){
		cin>>a[i];
		if(i>=2){
			x^=a[i];
		}else{
			sum+=a[i];
		}
	}
	if((sum-x)%2){
		cout<<-1<<endl;
		return 0;
	}
	ll d=(sum-x)/2;
	rep(i,N)rep(j,2) dp[i][j]=-1;
	dp[0][0]=0;
	rep(i,N-1)rep(j,2){
		ll cx=((x>>i) & 1);
		ll cd=((d>>i) & 1);
		ll ca=((a[0]>>i) & 1);
		rep(na,2)rep(nb,2){
			if((na^nb)!=cx) continue;
			if((na & nb)!=cd) continue;
			ll ni=i+1,nj=j;
			if(ca<na) nj=1;
			else if(ca==na) nj=j;
			else nj=0;
			chmax(dp[ni][nj],dp[i][j]|((1ll<<i)*na));
		}
	}
	ll ans=dp[N-1][0];
	if(ans==-1 || ans==0){
		cout<<-1<<endl;
	}else{
		cout<<a[0]-ans<<endl;
	}
}

Measured memory_bytes: 3632
/*
    In the name of
        "ALLAH"
    And say "AL-HAM-DU-LILLAH"
*/

#include<bits/stdc++.h>
#define ll long long
#define llu unsigned long long

int take() {
    int n;
    scanf("%d",&n);
    return n;

}
double ttake() {
    double n;
    scanf("%lf",&n);
    return n;
}
ll takes() {
    ll n;
    scanf("%lld",&n);
    return n;

}

#define Int take()
#define Dnt ttake()
#define LL takes()
#define done {return 0;}
#define fr(n) for(int i=1;i<=n;i++)
#define FR(a,b,x) for(int i=(a);i<=(b);i+=(x))
#define rfr(n) for(int i=n;i>=1;i--)
int cas;
#define print printf("Case %d:",++cas)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define pii pair<int,int>
#define vii vector<pii>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mk  make_pair
#define fill(x,v) memset(x,v,sizeof x)

using namespace std;

bool approximatelyEqual(float a, float b, float epsilon) {
    return fabs(a - b) <= ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool essentiallyEqual(float a, float b, float epsilon) {
    return fabs(a - b) <= ( (fabs(a) > fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool definitelyGreaterThan(float a, float b, float epsilon) {
    return (a - b) > ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool definitelyLessThan(float a, float b, float epsilon) {
    return (b - a) > ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}
#define STR {struct info}
#define dbg(x) {cout<<"ekhane"<<x<<endl;}
#define  SS second
#define  FF first
#define PQ priority_queue
#define great greatest
#define less lesser
#define mii map<int,int>
#define mil map<int,ll>
#define mll map<ll,ll>
#define msb map<string,bool>
#define M 100005
//////////////////////////////////////////


int main(){

    int x=Int,a=Int,b=Int;
    x-=a;
    x-=((x/b)*b);
    printf("%d\n",x);
    done;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=2e5+5;
const int mod=1e9+7;
int a[maxn];
int sum[maxn];
signed  main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    sum[n+1]=0;
    for(int i=n;i>=2;i--){
        sum[i]=(sum[i+1]+a[i])%mod;
    }
    int ans=0;
    for(int i=1;i<=n-1;i++){
            //cout<<sum[i+1]<<endl;
        ans=(ans+a[i]*sum[i+1])%mod;
    }
    cout<<ans<<endl;

    return 0;
}




Measured memory_bytes: 6736
object Main {
  def main(args:Array[String]) {
    val nk = readLine().split(' ').map(_.toInt)
    val h = readLine().split(' ').map(_.toInt)
    var count = 0
    for(i <- 0 until nk(0)) {
      if(nk(1) <= h(i)) count += 1
    }
    println(count)
  }
}


Measured memory_bytes: 42096
// -*- coding:utf-8-unix -*-

use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        s: String,
        t: String,
    }
    let s = s.as_bytes();
    let t = t.as_bytes();
    let mut ans = 10000;
    for i in 0..=s.len() - t.len() {
        let mut count = 0;
        for j in 0..t.len() {
            if t[j] != s[i + j] {
                count += 1;
            }
        }
        ans = ans.min(count);
    }
    println!("{}", ans);
}


Measured memory_bytes: 2160
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
  int x,a,b,n;
  cin >> x >> a >> b >> n;
  string s;
  for(int i=0; i<n; i++) {
    cin >> s;
    if(s=="nobiro") {
      x=max(0,x+a);
    }
    else if(s=="tidime") {
      x=max(0,x+b);
    }
    else {
      x=0;
    }
  }
  cout << x << endl;
}


Measured memory_bytes: 3208
#include <stdio.h>
#include <iostream>

using namespace std;
int main(void){
    int A = 0,B = 0,ans = 0;
    cin >> A >> B;
    ans = A * B;
    if(A > 9 || B > 9) ans = -1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

const ll mod = 1e9 + 7;


map<pair<int,int>, int> mp;


int main()
{
    FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
   // cin >> T;
    T = 1;
    for(int cs = 1; cs <= T; cs++)
    {
        int n;
        cin >> n;
        int a[n+2];
        for(int i = 1; i <= n; i++) cin >> a[i];
            sort(a+1, a+n+1);
        int m = (n+1)/2;
        ll ans = 0;
        for(int i = m+1; i <=  n; i++){
            ans += 2 * (a[i] - a[i - m]);
        }

        if(n & 1) ans += max(a[m] - a[m - 1], a[m + 1] - a[m]) - a[m+1] + a[m- 1];
        else ans -= a[m + 1] - a[m];
        cout << ans << endl;

    }

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);

    return 0;
}


Measured memory_bytes: 640