akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
using namespace std;
 
int A[500000], S = 0;
 
int merge(int l, int m, int r){
    int n1 = m - l, n2 = r - m, i, j;
    int L[n1 + 1], R[n2 + 1];
    for(i = 0;i < n1;i++)L[i] = A[i + l];
    for(i = 0;i < n2;i++)R[i] = A[i + m];
    i = j = 0;
    for(int k = 0;k < r - l;k++, S++){
        if(j == n2 || (i < n1 && L[i] <= R[j]))A[k + l] = L[i++];
        else A[k + l] = R[j++];
    }
}

int mergeSort(int l, int r){
    if(l + 1 < r){
        int m = (l + r) / 2;
        mergeSort(l, m);
        mergeSort(m, r);
        merge(l, m, r);
    }
}
 
int main(){
    int n;
    scanf("%d", &n);
    for(int i = 0;i < n;i++)scanf("%d", &A[i]);
    mergeSort(0, n);
    for(int i = 0;i < n;i++){
        if(i)printf(" ");
        printf("%d", A[i]);
    }
    printf("\n%d\n", S);
     
    return 0;
}

Measured memory_bytes: 7080
#include<algorithm>
#include<iostream>
#include<string>

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)

using namespace std;

int n;
string a,b;

int main(void){
	cin>>n;
	while(n--){
		cin>>a>>b;
		int siz = max(a.size(),b.size());
		if(a.size()>80||b.size()>80){
			cout<<"overflow"<<endl;
			continue;
		}
		reverse(a.begin(),a.end());
		reverse(b.begin(),b.end());		
		a.resize(80);
		b.resize(80);
		
		string ans="";
		int c = 0;
		rep(i,siz){
			if(i>=a.size()||a[i]=='\0')
				a[i] = '0';
			if(i>=b.size()||b[i]=='\0')
				b[i] = '0';
			int t = int(a[i]) - '0' + b[i] - '0' + c;
			c = 0;
			if(t>=10){
				c = 1 , t %= 10;
			}
			ans += char(t+'0');				
		}
		
		if(c)
			ans += '1';
			
		if(ans.size()>80)
			cout<<"overflow"<<endl;
		else {
			rep(i,ans.size()){
				cout<<ans[ans.size()-1-i];
			}
			cout<<endl;
		}
	}
}

Measured memory_bytes: 1220
#include<vector>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>

using std::max;
using std::min;
using std::sort;

typedef long long LL;
typedef double Doub;

const int sta(0), deb(0);

struct Read
{
    inline int operator ~()
    {
        int c, s(0);
        for(; !isdigit(c = getchar());)
            s = c == '-';
        int r(c & 15);
        for(; isdigit(c = getchar());)
            r = r * 10 + (c & 15);
        return s? -r: r;
    }

    inline Read &operator >>(int& a)
    {return a = ~*this, *this;}
} read;

typedef std::vector<int> VI;

const int mxN(100233);

int n, m, a[mxN], b[mxN], val[mxN], no[mxN];
VI vs[mxN];

inline void init()
{
    if(sta == 1 || sta == 2)
        freopen("rescue.in", "r", stdin);
    if(sta == 1)
        freopen("rescue.out", "w", stdout);

    read >> n >> m;
    for(int i(1); i <= n; ++i)
    {
        read >> a[i] >> b[i];
        val[i] = max(0, a[i]-b[i]);
        no[i] = i;
    }
    for(int _(m); _--;)
    {
        int u, v;
        read >> u >> v;
        vs[u].push_back(v);
        vs[v].push_back(u);
    }
}

inline bool cmp(int i, int j)
{   return val[i] < val[j];}

int fat[mxN];

int getF(int x) {return fat[x]!=x? fat[x] = getF(fat[x]): x;}

int main()
{
    init();

    sort(no+1, no+n+1, cmp);
    static LL sB[mxN], g[mxN];
    for(int _(1); _<=n; ++_)
    {
        int u(no[_]);
        fat[u] = u;
        VI sons;
        for(unsigned i(0); i<vs[u].size(); ++i)
            if(fat[vs[u][i]])
                sons.push_back(getF(vs[u][i]));
        sort(sons.begin(), sons.end());
        sons.resize(unique(sons.begin(), sons.end())-sons.begin());
        if(deb)
            for(unsigned i(0); i<sons.size(); ++i)
                printf("%d--%d\n", u, sons[i]);
        LL d(b[u]+val[u]);
        for(unsigned i(0); i<sons.size(); ++i)
        {
            int v(sons[i]);
            sB[u] += sB[v];
            if(deb && max((LL)a[u], b[u] + g[v])-sB[v] < d)
                printf("%d->%d %lld\n", u, v,  max((LL)a[u], b[u] + g[v])-sB[v]);
            d = min(d, max((LL)a[u], b[u] + g[v])-sB[v]);
            fat[v] = u;
        }
        g[u] = sB[u] + d;
        sB[u] += b[u];
        if(deb)
            printf("%lld ; %lld\n", sB[u], g[u]);
    }

    printf("%lld\n", g[no[n]]);
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<ll> l(86);
  l[0] = 2;
  l[1] = 1;
  for(int i = 2; i <= n; ++i){
    l[i] = l[i-1] + l[i-2];
  }
  cout << l[n];
}

Measured memory_bytes: 3604
n = int(input())
s=input()
r=g=b=0
for index,value in enumerate(s):
    if value=="R":
        r+=1
    elif value=="G":
        g+=1
    else:
        b+=1
ans=r*g*b
for i in range((n-3)//2+1):
    for j in range(n-2-i*2):
        f1=s[j]
        f2=s[j+i+1]
        f3=s[j+2*i+2]
        if f1!=f2!=f3!=f1:
            ans-=1
print(ans)

Measured memory_bytes: 9144
N,P=map(int,input().split())

def prime_factorization(n):
    arr=[]
    temp=n

    for i in range(2,int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp//=i
            arr.append([i,cnt])

    if temp!=1:
        arr.append([temp,1])
    
    if arr==[]:
        arr.append([n,1])
    
    return arr

res=prime_factorization(P)

ans=1
for i in range(len(res)):
    prime=res[i][0]
    index=res[i][1]

    while index >=N:
        ans*=prime
        index-=N

print(ans)

Measured memory_bytes: 9492
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b % mod; if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12); // debuged
    int T;
    T = 1;
    while (T--) solve();
}

// https://betrue12.hateblo.jp/entry/2019/11/30/184748
// https://atcoder.jp/contests/abc145/submissions/15344203
ll dp[305][305][305];
void solve() {
    int n, k_;
    cin >> n >> k_;
    vector<int> h(n + 1);
    h[0] = 0;
    rep3(i, 1, n + 1) cin >> h[i];
    
    rep(i, 305) rep(j, 305) rep(k, 305) dp[i][j][k] = INF;
    dp[0][0][0] = 0;
    rep(i, n + 1) rep(j, n + 1) rep(k, k_ + 1) {
        if (dp[i][j][k] == INF) continue;
        // 手前に合わせる
        if (k != k_) chmin(dp[i + 1][j][k + 1], dp[i][j][k]);
        // 変えない
        chmin(dp[i + 1][i][k], dp[i][j][k] + max(0, h[i] - h[j]));
    }
    ll ans = INF;
    rep(j, n + 1) rep(k, k_ + 1) chmin(ans, dp[n + 1][j][k]);
    cout << ans << endl;
}


Measured memory_bytes: 225220
#include <algorithm>
#include <iostream>
#include<cstring>
#include<vector>
#include<cstdio>
using namespace std;

int main()
{
    int d, t, s;
    cin >> d >> t >> s;
    if(t*s>=d)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

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

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> pint;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;


int n;
int bit[26][500010];
void add(int i, int a, int w){
    for (int x = a; x <= n; x += x & -x) bit[i][x] += w;
}

int sum(int i, int a){
    int ret = 0;
    for (int x = a; x > 0; x -= x & -x) ret += bit[i][x];
    return ret;
}

int main() {
    cin >> n;
    string s; cin >> s;
    vector<char> sv(n);
    rep(i, n) sv[i] = s[i];
    rep(i, n) {
        add(sv[i]-'a', i+1, 1);
    }

    int q; cin >> q;
    rep(_, q) {
        int type; cin >> type;
        if (type == 1) {
            int i;
            char c;
            cin >> i >> c;
            i--;
            if (sv[i] == c) continue;
            add(sv[i]-'a', i+1, -1);
            sv[i] = c;
            add(sv[i]-'a', i+1, 1);
        } else {
            int l, r; cin >> l >> r;
            l--;
            int cnt = 0;
            rep(j, 26) {
                if (sum(j, r) - sum(j, l) > 0) {
                    cnt++;
                }
            }
            cout << cnt << endl;
        }
    }

    return 0;
}


    


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



int main(){

	int X;
	scanf("%d",&X);

	if(X >= 30){

		printf("Yes\n");

	}else{

		printf("No\n");
	}

	return 0;
}


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

#define MAXN 100005
typedef long long lint;

using namespace std;

int n, m, b;
lint a[MAXN], times[MAXN], remain[MAXN], sum[MAXN];

lint read() {
//    return rand() % 30 + 1;
    char c = getchar();
    lint x = 0;
    while (!isdigit(c))
        c = getchar();
    while (isdigit(c)) {
        x = (x << 3) + (x << 1) + c - '0';
        c = getchar();
    }
    return x;
}

void find(lint p, lint val) {
    while (p) {
        if (p <= a[1]) {
            sum[p] += val;
            return ;
        }
        int x = int(upper_bound(a + 1, a + n + 1, p) - a - 1);
        lint np = p % a[x];
        times[x] += val * int(p / a[x]);
        p = np;
    }
}

int main() {
//    freopen("01.txt", "r", stdin);
//    freopen("02.txt", "w", stdout);
    a[n = 1] = b = (int)read() ;
    m = (int)read();
    for (int i = 1; i <= m; ++i) {
        lint x = read();
        while (n >= 1 && a[n] >= x)
            --n;
        a[++n] = x;
    }
    for (int i = 2; i <= n; ++i)
        remain[i] = a[i] - a[i - 1] * (a[i] / a[i - 1]);
    times[n] = 1;
    for (int i = n; i >= 2; --i) {
        find(remain[i], times[i]);
        times[i - 1] += times[i] * (a[i] / a[i - 1]);
    }
    for (int i = (int)a[1] - 1; i >= 1; --i)
        sum[i] += sum[i + 1];
    for (int i = 1; i <= a[1]; ++i)
        sum[i] += times[1];
    for (int i = 1; i <= b; ++i)
        printf("%lld\n", sum[i]);
}
/*
 
 3 3
 986 1090 23478
 
 3 3
 78 105 207
 3 3
 15 30 45
 */


Measured memory_bytes: 4864
#include <cstdio>
#include <cstring>

using namespace std;

char s[101];
char t[8] = "keyence";

int main() {
    int n, i, j;
    
    scanf("%s", s);
    
    n = strlen(s);
    
    for (i = 0; i <= 7; i++) {
        for (j = 0; j < i; j++) {
            if (s[j] != t[j]) break;
        }
        
        if (j < i) continue;
        
        for (; j < 7; j++) {
            if (s[n - 7 + j] != t[j]) break;
        }
        
        if (j < 7) continue;
        
        puts("YES");
        
        return 0;
    }
    
    puts("NO");
    
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(int argc, char **argv)
{
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    if (K <= A) {
        cout << K << endl;
    }
    else if (K <= A + B) {
        cout << A << endl;
    }
    else {
        cout << A - (K - A - B) << endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>

using namespace std;

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

	if(input.size() == 3) {
		cout << input[2] << input[1] << input[0] << endl;
	}
	else {
		cout << input << endl;
	}

	return 0;
}


Measured memory_bytes: 256
const main = function(input){
  var lines = input.split("\n");
  var s = lines[0];
  var t = lines[1];
  var can = false;
  
  for(var i=0;i<s.length;i++){
    if(s ===t){
      can = true;
      break;
    }
    var last = s.slice(s.length-1,s.length);
    s = last + s.slice(0,-1);
  }
  if(can){
  	console.log("Yes");
  }else{
  	console.log("No");
  }
  
  
}


main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int>d(N);
        for(int i = 0; i < N; i++){
        cin >> d[i];
        }
    sort(d.begin(), d.end());
    int X = N/2;
    int Y = X-1;
    cout<<d[X]-d[Y]<<endl;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define ll long long int
#define du double

using namespace std;

int main(){
    ll N;
    cin>>N;
    vector<du> vec(N);
    for(int i=0;i<N;i++){
        cin>>vec[i];
    }
    vector<vector<double>> dp(N+1,vector<double>(N+1,0));
    dp[0][0]=1;
    for(int i=1;i<N+1;i++){
        dp[i][0] = dp[i-1][0]*(1-vec[i-1]);
    }
    for(int i=1;i<N+1;i++){
        for(int j=1;j<N+1;j++){
            dp[i][j] +=(vec[i-1]*dp[i-1][j-1]);
            dp[i][j]+=((1-vec[i-1])*dp[i-1][j]);
        }
    }
    double ans = 0;
    for(int i=(N+1)/2;i<=N;i++){
        ans += dp[N][i];
    }
    cout<<setprecision(10)<<ans;
    return 0;
    
}

Measured memory_bytes: 70656
N, M = map(int,input().split())
KS_lis = [list(map(int, input().split())) for _ in range(M)]
P = list(map(int, input().split()))

KS = []
ans = 0

for i in range(2**N):

    for j in range(M):
        Z = [0]*N
        bin_s = 0
        KS = KS_lis[j]
        K = KS[0]
        S = KS[1:]

        for l in range(K):
            bin_s += 2**(int(S[l])-1)

        if bin(i & bin_s).count("1") % 2 != P[j]:
            break
    else:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>

using namespace std;

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

long long int INF = 3e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pd(x) cerr<<"//"<<(x)<<endl;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl


ll mod = 1000000007;
ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

ll n,m,num,sum,ans,a,b,c,d,e,f,g,h,i,j,k,w,ok,ng,l,q;
ll x[500005],y[500005],z[500005];
ll dp[3005][3005];
char s[500005],t[500005];
bool flag,dame;

int main(){
    cin >> n >> k;
	for(i=0;i<n;i++){
		cin >> x[i];
	}
	ans = INF;
	for(i=0;i<(1ll<<n);i++){
		sum = 0;
		num = 0;
		for(j=0;j<n;j++){
			if(i & (1ll << j)){
				num++;
			}
		}
		if(num != k)continue;
		//p(i);
		num = 0;
		for(j=0;j<n;j++){
			if(i & (1ll << j)){
				if(x[j] < num){
					sum += num - x[j];
					num += 1;
				}else{
					num = x[j] + 1;
				}
			}else{
				num = max(x[j] + 1,num);
			}
			//pe(sum);
		}
		//el;
		ans = min(ans,sum);
	}
	p(ans);
	

	
	return 0;
}

Measured memory_bytes: 27008
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll inf =1LL << 62;

#define MAX 1299709+10
bool primes[MAX];

int main(void){
	rep(i,MAX+1)
		primes[i]=true;
	primes[0]=primes[1]=false;
	for(int i=2;i*i<=MAX;i++){
		if(primes[i])
			for(int j=2*i;j<=MAX;j+=i)
				primes[j]=false;

	}
	int n;
	while(cin >> n,n){
		int l=n;
		int r=n;
		while(!primes[l])
			l--;
		while(!primes[r])
			r++;
		cout << r-l << endl;
	}
	return 0;
}

Measured memory_bytes: 2428
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
void log(A...)(A arg) { stderr.writeln(arg); }
int size(T)(in T s) { return cast(int)s.length; }

void main() {
    auto s = readln.chomp;
    long n = s.size;
    long ans = 0;
    foreach (i, c; s) {
        if (i < (n + 1) / 2) { // choose 'g'
            ans += (c == 'g' ? 0 : -1);
        } else {
            ans += (c == 'g' ? 1 : 0);
        }
    }
    writeln(ans);
}


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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cerr<<(#v)<<":";for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;
#define printVS(vs) cerr<<(#vs)<<":"<<endl;for(auto(s):(vs)){cerr<<(s)<< endl;}
#define printVV(vv) cerr<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;}
#define printP(p) cerr<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cerr<<(#vp)<<":"<<endl;for(auto(p):(vp)){cerr<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cerr << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cerr << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1ll << 60;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

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

    int n;
    cin >> n;
    vi a(3 * n);
    rep(i, 3 * n) cin >> a[i];

    sort(rall(a));

    int ans = 0;
    rep(i, n) {
        ans += a[2 * i + 1];
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
typedef long long ll;
const ll mod = 1e9+7;
int pos[maxn];

int main()
{
    string s;
    while(cin>>s){
        int n=s.length();
        memset(pos, 0, sizeof(pos));
        int temp = 0;
        for(int i=0;i<n;i++){
            if(s[i] == 'R'){
                temp++;
                if(s[i+1] == 'L'){
                    pos[i] = temp;
                    temp = 0;
                }
            }
        }
        for(int i=n-1;i>=0;i--){
            if(s[i] == 'L'){
                temp++;
                if(s[i-1] == 'R'){
                    pos[i] = temp;
                    temp = 0;
                }
            }
        }
//        for(int i=0;i<n;i++){
//            printf("%d%c", pos[i], i==n-1?'\n':' ');
//        }
//        cout<<123<<endl;
        for(int i=0;i<n;i++){
            if(pos[i] && pos[i+1]){
                int temp1 = 0, temp2 = 0;
                while(pos[i]){
                    if(pos[i]&1){
                        temp1++;
                    }
                    else{
                        temp2++;
                    }
                    pos[i]--;
                }
                while(pos[i+1]){
                    if(pos[i+1]&1){
                        temp2++;
                    }
                    else{
                        temp1++;
                    }
                    pos[i+1]--;
                }
                pos[i] = temp1;
                pos[i+1] = temp2;
                i++;
            }
        }
        for(int i=0;i<n;i++){
            printf("%d%c", pos[i], i==n-1?'\n':' ');
        }
    }
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int l=s.length();
	if(s[l-1]=='s')
	{
		cout<<s<<"e"<<"s"<<endl;
	}
	else
	{
		cout<<s<<"s"<<endl;

	}
	return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;


int main(){
  int S;cin >> S;
  int a = S % 100;
  int b = S / 100;
  string ans;
  if((a >= 1 && a <= 12) && (b == 0 || b > 12)) ans = "YYMM";
  if((b >= 1 && b <= 12) && (a == 0 || a > 12)) ans ="MMYY";
  if((a >= 1 && a <= 12) && (b >= 1 && b <= 12)) ans = "AMBIGUOUS";
  if((a == 0 || a > 12) && (b == 0 || b > 12)) ans ="NA";
  cout << ans << endl;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::{i32, i64, u32, u64, usize, f64};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{VecDeque, HashMap, BTreeMap, HashSet, BTreeSet};
#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::mem::{swap};

const DXDY4: [(usize, usize); 4] = [(1, 0), (0, 1), (!0, 0), (0, !0)];

fn main() {
    input! {
        h: usize,
        w: usize,
        grid: [String; h],
    }
    let grid: Vec<_> = grid.iter().map(|r| r.chars().collect::<Vec<char>>()).collect();
    for i in 0..h {
        for j in 0..w {
            if grid[i][j] == '#' {
                for (m, &(di, dj)) in DXDY4.iter().enumerate() {
                    let (k, l) = (i.wrapping_add(di), j.wrapping_add(dj));
                    if k < h && l < w && grid[k][l] == '#' { break; }
                    if m == 3 {
                        println!("No");
                        return;
                    }
                }
            }
        }
    }
    println!("Yes")
}


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

typedef long long ll;
typedef pair<int, int> ii;

const int N = 1e5 + 5;
int a[N];
ii p[N];
int n, m;
ll sum;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int j = 0; j < m; ++j) {
        cin >> p[j].second >> p[j].first;
    }
    sort(a, a + n);
    sort(p, p + m, greater<ii>());
    int j = 0;
    for (int i = 0; i < n; ++i) {
        while (p[j].second == 0) ++j;
        while (a[i] >= p[j].first && j < m) ++j;
        if (j < m) {
            sum += p[j].first;
            --p[j].second;
        } else {
            sum += a[i];
        }
    }
    cout << sum << endl;

    return 0;
}



Measured memory_bytes: 4800
n = int(input())
num_list = sorted([ int(v) for v in input().split() ])


judge_list = []
count_list = []

for i in num_list:
    if judge_list == []:
        judge_list.append(i)
        count_list.append(1)
    else:
        if i != judge_list[-1] or judge_list ==[]:
            judge_list.append(i)
            count_list.append(1)
        else:
            count_list[-1] += 1
ans = 0
for i in range(len(judge_list)):
    if judge_list[i] > count_list[i]:
        ans += count_list[i]
    elif judge_list[i] < count_list[i]:
        ans += count_list[i] - judge_list[i]

print(ans)

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

#define ALL(obj) (obj).begin(),(obj).end()
template<class T> using priority_queue_reverse = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = 1'000'000'000LL + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
vector<string> split(const string &str, const char delemiter) {vector<string> res;stringstream ss(str);string buffer; while( getline(ss, buffer, delemiter) ) res.push_back(buffer); return res;}
int msb(int x) {return x?31-__builtin_clz(x):-1;}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    string S; cin >> S;
    corner(S=="RRR",3);
    corner(S=="RRS" || S=="SRR",2);
    corner(S=="SSS",0);
    cout << 1 << endl;
    return 0;
}


Measured memory_bytes: 3644
#include <stdio.h>
#include <string.h>
int main() {
	char s[27];
	int alCnt[26] = {0};
	scanf("%s", s);
	int len = strlen(s);
	for (int i = 0; i < len; i++) {
		alCnt[s[i] - 'a']++;
	}
	for (int i = 0; i < 26; i++) {
		if (alCnt[i] > 1) {
			printf("no\n");
			return 0;
		}
	}
	printf("yes\n");
	return 0;
}

Measured memory_bytes: 128
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.ListIterator;
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 N = nextInt();
		int M = nextInt();

		int[][] AB = new int[N][2];
		for(int i=0;i<N;i++) {
			AB[i] = nextIntArray(2);
		}
		//Arrays.sort(AB,(a1,a2)->Integer.compare(a2[1],a1[1]));
		//Arrays.sort(AB,(a1,a2)->Integer.compare(a1[0],a2[0]));
		Arrays.sort(AB,(a1,a2)->hikaku(a2[1],a1[1],a1[0],a2[0]));

		List<Integer> list = new ArrayList<Integer>(N);
		long sum = 0;
		int AB_i = 0;
		for(int l=1;l<=M;l++) {
			int Search_l = -1;
			while(AB_i<N&&AB[AB_i][0]==l) {
				int Insert_i = Search(list ,AB[AB_i][1],Search_l);
				if(M<Insert_i)break;// 候補外となるため挿入する必要なし
				list.add(Insert_i,AB[AB_i][1]);
				AB_i++;
				Search_l = Insert_i;
			}

			if(list.size()>0) {
				sum+=list.get(0);
				list.remove(0);
			}

			if(list.size()>M*2) {
				ListIterator<Integer> removeList = list.listIterator(M);
				while (removeList.hasNext()) {
					removeList.next();
					removeList.remove();
				}
			}
		}

		out.println(sum);
	}

	private int hikaku(int a, int b, int c, int d) {
		if(c > d)return 1;
		if(c < d)return -1;
		if(a > b)return 1;
		if(a < b)return -1;
		return 0;
	}

	//二部探索
	static int Search(List<Integer> list, int k, int Search_l) {
		int l = Search_l;
		int r = list.size();
		while(r - l > 1) {
			int mid = (r + l) / 2;
			if(list.get(mid) <= k) r = mid;
			else l = mid;
		}
		return r;
	}


	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

}

Measured memory_bytes: 63448
import java.util.*;
import java.io.*;

class Main{
    public static void main(String[] args){
        FastScanner fs = new FastScanner();
        int n = fs.nextInt();
        int k = fs.nextInt();
        int[] a = new int[n];
        for(int i=0;i<n;i++)a[i] = fs.nextInt();

        boolean[] dp = new boolean[k+1];//石がi個ある状態で勝てるかどうか

        for(int i=1;i<=k;i++){
            for(int j=0;j<n;j++){
                if(i-a[j]>=0){
                    dp[i] |=!dp[i-a[j]];
                }
            }
        }
        if(dp[k]){
            System.out.println("First");
        }else{
            System.out.println("Second");
        }
    }
    static class FastScanner{
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        private boolean hasNextByte(){
            if(ptr < buflen){
                return true;
            }else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen <= 0){
                    return false;
                }
            }
            return true;
        }

        private int readByte(){
            if(hasNextByte())return buffer[ptr++];
            else return -1;
        }

        private boolean isPrintableChar(int c){
            return 33<=c && c<=126;
        }

        public boolean hasNext(){
            while(hasNextByte() && !isPrintableChar(buffer[ptr]))ptr++;
            return hasNextByte();
        }

        public String next(){
            if(!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)){
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public long nextLong(){
            if(!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if(b == '-'){
                minus = true;
                b = readByte();
            }
            if(b < '0' || '9' < b){
                throw new NumberFormatException();
            }
            while(true){
                if('0' <= b && b<='9'){
                    n*=10;
                    n+=b-'0';
                }else if(b==-1 || !isPrintableChar(b)){
                    return minus ? -n : n;
                }else{
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
        public int nextInt(){
            long nl = nextLong();
            if(nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)throw new NumberFormatException();
            return (int)nl;
        }
        public double nextDouble(){return Double.parseDouble(next());}
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n, p;
    std::string s;
    std::cin >> n >> p >> s;

    std::reverse(s.begin(), s.end());

    if (p == 2) {
        i64 ret = 0;
        for (int i = 0; i < n; i++) {
            int d = s[i] - '0';
            if (d % 2 == 0) ret += n - i;
        }
        std::cout << ret << std::endl;
        return 0;
    } else if (p == 5) {
        i64 ret = 0;
        for (int i = 0; i < n; i++) {
            if (s[i] == '5' || s[i] == '0') ret += n - i;
        }
        std::cout << ret << std::endl;
        return 0;
    }

    std::vector<i64> cnt(p);
    cnt[0] = 1;
    int r = 0, t = 1;
    for (int i = 0; i < n; i++) {
        int d = s[i] - '0';
        r = (r + d * t) % p;
        cnt[r]++;
        t = t * 10 % p;
    }

    i64 ret = 0;
    for (auto e : cnt) ret += e * (e - 1) / 2;
    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
typedef long long int lli;

using namespace std;

int main(){
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
	int t=1;
	//cin>>t;
	while(t--){
		//logic_start
        int n,l;
        cin>>n>>l;
        vector<string> s;
        for(int i=0;i<n;i++){
            string cs;cin>>cs;
            s.push_back(cs);
        }
        sort(s.begin(),s.end());
        string ns="";
        for(string ls:s)
            ns+=ls;
        cout<<ns<<endl;
		//logic_end

	} 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fr(i1,m) for(int i1=0;i1<m;i1++)
using namespace std;
int main()
{
    long n,m;
    while(cin>>n>>m)
    {
        string s[100100],s1[100100];
        long tt=0,pp=0,x,y,p,q,k,l;
        fr(i,n)
        cin>>s[i];


        fr(i,m)
        {
            cin>>s1[i];
        }

        fr(i,n)
        {
            fr(j,n)
            {
                x=i+m;
                y=j+m;
                p=0;
                tt=0;
                for(k=i;k<x;k++)
                {

                    q=0;
                    for(l=j;l<y;l++)
                    {
                       if(s[k][l]!=s1[p][q])
                       {
                           tt=1;

                       }
                       q++;
                    }
                    p++;
                }
                if(tt==0)
                {
                    pp=1;
                }

            }
        }
        if(pp==1)
        {
            cout<<"Yes\n";
        }
        else
            cout<<"No\n";
    }
    return 0;

}




Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <iomanip>
//#include <unordered_map>
//#include <unordered_set>
using namespace std;
#define ls ro<<1
#define fi first
#define se second
#define rs ro<<1|1
#define ll long long
#define pb push_back
#define vi vector<int>
#define lowbit(x) x&(-x)
#define pii pair<int,int>
#define lson ro<<1,l,mid
#define rson ro<<1|1,mid+1,r
#define mem(a,b) memset(a,b,sizeof(a))
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
const int INF = 0x3f3f3f3f;



int main() {
	IOS;
	double n,m,k;
	cin>>n>>m>>k;
	double s=max(n,m);
	
	cout<<ceil(k/s)<<endl;







	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(int)(a); i!=(int)(b); i++)
#define RFOR(i, a, b) for(int i=(int)(a); i!=(int)(b); i--)
#define REP(i, n) FOR(i, 0, n)
using namespace std;
using ll = long long;
 
constexpr int lim = 1e5;
ll a[lim+1], l[lim+1], r[lim+1];
ll k;
 
int main(){
  cin >> k;
  FOR(i, 1, k+1) cin >> a[i];
 
  l[k] = r[k] = 2;
 
  RFOR(i, k, 0){
    r[i-1] = r[i]/a[i]*a[i] + a[i] - 1;
    l[i-1] = (ll)ceil(l[i]*1.0/a[i]) * a[i];
    if(r[i-1] < l[i-1]){
      cout << -1 << endl;
      return 0;
    }
  }
 
  cout << l[0] << " " << r[0] << endl;
 
  return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)
#define vec1(V,T,a) vector<T> V (a)
#define vec2(V,T,a,b) vector<vector<T>> V (a, vector<T>(b))
#define vec3(V,T,a,b,c) vector<vector<vector<T>>> V (a, vector<vector<T>>(b, vector<T>(c)))

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool>::reference b) { return to_string(bool(b)); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; }

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "[L" << to_string(__LINE__) << ":" <<#__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  priority_queue<ll,vector<ll>,greater<ll>> q;
  int N;
  cin >> N;
  REP(i,N) {
    ll A;
    cin >> A;
    q.push(A);
  }
  ll m = q.top(); q.pop();
  while (q.size() > 0) {
    ll v = q.top(); q.pop();
    v %= m;
    if (v == 0) continue;
    else if (v == 1) {m=v;break;}

    q.push(m);
    m = v;
  }
  cout << m << endl;
  return 0;
}

Measured memory_bytes: 1400
import java.io.*;
import java.util.*;

public class Main {
    FastScanner in;
    PrintWriter out;

    void solve() {
        String s = in.next();
        if (s.length() == 1) {
            out.println(s);
            return;
        }
        int res = (s.charAt(0) - '1') + (s.length() - 1) * 9;
        int cur = 0;
        for (char c : s.toCharArray()) {
            cur += c - '0';
        }
        out.println(Math.max(cur, res));
    }

    void run() {
        try {
            in = new FastScanner(new File("Main.in"));
            out = new PrintWriter(new File("Main.out"));

            solve();

            out.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

    void runIO() {

        in = new FastScanner(System.in);
        out = new PrintWriter(System.out);

        solve();

        out.close();
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        boolean hasMoreTokens() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return false;
                st = new StringTokenizer(s);
            }
            return true;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }

    public static void main(String[] args) {
        new Main().runIO();
    }
}

Measured memory_bytes: 21204
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<ll, P> E;
#define cost first
#define from second.first
#define to second.second
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

int main(void){
	int a,b,c;
	cin >> a >> b >> c;
	cout << ((a+b+c)-max(a,max(b,c))) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int A, B, C, D;
	int hazime, owari;
	if (scanf("%d%d%d%d", &A, &B, &C, &D) != 4) return 1;
	hazime = A < C ? C : A;
	owari = B <= D ? B : D;
	printf("%d\n", hazime <= owari ? owari - hazime : 0);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cmath>
using namespace std;
int main() {
	int X;
	cin >> X;
	for (int i = 1; i <= (int)sqrt(X); i++) { //i=A-B
		if (X % i != 0) continue;
		int j = X / i - i * i * i * i;
		if (j % 5 != 0) continue;
		int k = i * i * i * i + j / 5 * 4;
		if (k < 0) continue;
		int sqrtk = sqrt(k);
		if (sqrtk * sqrtk != k) continue;
		int AB = (sqrtk - i * i) / 2;
		if (AB == 0) {
			cout << i << " " << 0 << endl;
			return 0;
		}
		for (int A = 1; A < abs(AB); A++) {
			if (AB % A != 0) continue;
			int B = AB / A;
			if (A - B != i) continue;
			else {
				cout << A << " " << B << endl;
				return 0;
			}
		}
	}
	return -1;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define p3i pair<pii, int>
#define pll pair<ll, ll>
#define p3l pair<pll, ll>
#define lseg L, (L+R)/2, N*2+1
#define rseg (L+R)/2+1, R, N*2+2
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define MN 1000000007
#define fox(k, x) for (int k=0; k<x; ++k)
#define fox1(k, x) for (int k=1; k<=x; ++k)
#define foxr(k, x) for (int k=x-1; k>=0; --k)
#define fox1r(k, x) for (int k=x; k>0; --k)
#define ms multiset
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)
#define rng() (rand() >> 3)*rand()
#define scan(X) do{while((X=getchar())<'0'); for(X-='0'; '0'<=(_=getchar()); X=(X<<3)+(X<<1)+_-'0');}while(0)
char _;
#define pi 3.14159265358979323846

int n, ans, t, a, k;
int getkth(int a){
    int gen=a/k, place=a%k;
    if (gen<=0) return 0;
    if (place==0) return gen;
    return getkth(a-gen-1);
}
int main(){
    cin >> n;
    fox(l, n){
        cin >> a >> k;
        /*if (a>=1LL*k*(k+1)/2){
            a=k*(k+1)/2+(a-(k*(k+1)/2))%(k+1);
        }*/
        t=getkth(a);
        ans^=t;
        //cout << t << endl;
    }
    if (ans==0) cout << "Aoki";
    else cout << "Takahashi";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <bitset>
using namespace std;
typedef long long ll;
inline int read()
{
	int x = 0, f = 1; char c = getchar();
	while (!isdigit(c)) {if (c == '-') f = -1; c = getchar();}
	while (isdigit(c)) {x = x * 10 + c - '0', c = getchar();}
	return x * f;
}

const int maxn = 405;
typedef bitset<maxn> mybitset;
int n, m, u[maxn * maxn], v[maxn * maxn];
mybitset bit[maxn]; bool mark[maxn];

int main()
{
	n = read(), m = read();
	for (int i = 1; i <= m; i ++) u[i] = read(), v[i] = read();
	for (int i = 1; i <= n; i ++) bit[i].set(i);
	for (int i = m; i >= 1; i --)
		for (int x = 1; x <= n; x ++) if (!mark[x])
		{
			if (!bit[x].test(u[i]) && !bit[x].test(v[i])) continue;
			if (bit[x].test(u[i]) && bit[x].test(v[i])) {mark[x] = 1; continue;}
			if (bit[x].test(u[i])) bit[x].set(v[i]);
			else bit[x].set(u[i]);
		}
	int ans = 0;
	for (int i = 1; i <= n; i ++) if (!mark[i])
		for (int j = i + 1; j <= n; j ++) if (!mark[j])
			ans += (bit[i] & bit[j]).none();
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#define ll long long
#define INF 1e+18
#define MOD 998244353
using namespace std;

int main(){
    int N;
    cin >> N;
    ll A[N];
    for(int i=0; i<N; i++){
        cin >> A[i];
        A[i]-=i;
    }
    
    sort(A,A+N);
    
    ll ans=0;
    for(int i=0; i<N; i++){
        ans+=abs(A[i]-A[N/2]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792