akhauriyash/Code-Regression huggingface dataset:
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
#define min(x,y) (x < y ? x : y)
#define max(x,y) (x < y ? y : x)
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << "(" << p.first << ", " << p.second << ")"; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

void solve() {
  string s; cin >> s;
  const ll n = s.size();
  rep(l, n) rep(r, l, n+1) {
    if (s.substr(0, l) + s.substr(r, n) == "keyence") {
      cout << "YES" << endl;
      return;
    }
  }
  cout << "NO" << endl;
}


Measured memory_bytes: 256
# coding: utf-8
rank = [0,0,0]
for i in range(10):
    t = input()
    if t > rank[0]:
        rank.insert(0, t)
        rank.pop()
    elif t > rank[1]:
        rank.insert(1, t)
        rank.pop()
    elif t > rank[2]:
        rank.insert(2, t)
        rank.pop()
print "{}\n{}\n{}".format(rank[0], rank[1], rank[2])

Measured memory_bytes: 4664
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const int mod=1e9+7;
const int seed=233;
const double PI=acos(-1.0);
const double eps=1e-7;
const int inf=0x3f3f3f3f;
const int max_n=100005;
ll ceil(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?(x+y-1)/y:-x/y;}
ll floor(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?x/y:-(x+y-1)/y;}
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
    inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){if(y==0)return 1;int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
/**********************head************************/
int n,m;
int main(){
    scanf("%d%d",&n,&m);
    if(m==n)printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

void solve(int n){
    vector<char> c(n);
    map<char, int> mI;
    map<int, char> mC;
    int id = 0;
    rep(i, n) {
        cin >> c[i];

        if(mI.find(c[i]) == mI.end()){
            mI.emplace(c[i], id);
            mC.emplace(id++, c[i]);
        }
    }

    int num = mI.size();

    if(num == 1){
        cout << mC[0] << " " << n / 2 + 1 << endl;
        return;
    }

    vector<int> v(num);
    rep(i, n){
        v[mI[c[i]]]++;

        rep(s, num){

            bool win = true;
            rep(t, num){
                if(s == t){
                    continue;
                }

                if(v[s] <= v[t] + n - i - 1){
                    win = false;
                }
            }
            if(win){
                cout << mC[s] << " " << i+1 << endl;
                return;
            }
        }
    }
    cout << "TIE" << endl;
}

signed main(){
    while(true){
        int n;
        cin >> n;

        if(n == 0){
            break;
        }
        solve(n);
    }

    return 0;
}



Measured memory_bytes: 3012
#include <stdio.h>
#define FREE 1
#define NOT_FREE -1
#define N 8

void putQueen(int);
void Printboard();

int row[N], col[N], dpos[2*N], dneg[2*N], n, tate[N], yoko[N], x[N];


int main() {
  int i = 0, p = 0, q = 0;

  scanf("%d",&n);

  for(i = 0 ; i< N ; i++) x[i] = -1;

  for(i = 0 ; i < n ; i++) {
    scanf("%d %d",&p,&q);

    tate[i] = p;
    yoko[i] = q;

    x[p] = q;
      
    /*row[p] = q;
    col[q] = NOT_FREE;
    dpos[p+q] = NOT_FREE;
    dneg[p-q+N-1] = NOT_FREE;*/
  }
  

  putQueen(0);
  
  return 0;
}


void putQueen(int i) {
  int j = 0, k = 0;

  /*if(i == 0) {
    for(k = 0 ; k < n ; k++) {
      row[tate[k]] = yoko[k];
      col[yoko[k]] = NOT_FREE;
      dpos[tate[k]+yoko[k]] = NOT_FREE;
      dneg[tate[k]-yoko[k]+N-1] = NOT_FREE;
    }
    }*/

  
  if(i == N) {
    Printboard();
    return;
  }

  /*for(k = 0; k< n ; k++) {
    if(yoko[k] == i) {
      printf("tate: %d yoko: %d\n",tate[k],yoko[k]);
      putQueen(i+1);
      return;
    }
    }*/

  for(j = 0 ; j < N ; j++) {

    if(x[i] != -1 && x[i] != j) {
      continue;
    }
    /* for(k = 0 ; k < n ; k++) {
      row[tate[k]] = yoko[k];
      col[yoko[k]] = NOT_FREE;
      dpos[tate[k]+yoko[k]] = NOT_FREE;
      dneg[tate[k]-yoko[k]+N-1] = NOT_FREE;
      }*/


    
    
    if(col[j] == NOT_FREE || dpos[i+j] == NOT_FREE || dneg[i-j+N-1] == NOT_FREE) {
      //printf("donot j: %d i: %d\n",j,i);
      continue;
      
    }



    row[i] = j;
    col[j] = NOT_FREE;
    dpos[i+j] = NOT_FREE;
    dneg[i-j+N-1] = NOT_FREE;

    putQueen(i+1);

    col[j] = FREE;
    dpos[i+j] = FREE;
    dneg[i-j+N-1] = FREE;
    
  }

}


void Printboard() {
  int i = 0, j = 0, ban[N][N];
  
  for(i = 0 ; i < N ; i++) {
    for(j = 0 ; j < N ; j++) {
      ban[i][j] = 0;
    }
  }
  
  for(i = 0 ; i < N ; i++) {
    ban[i][row[i]] = 1;
  }

  for(i = 0 ; i < N ; i++) {
    for(j = 0 ; j < N ; j++) {
      if(ban[i][j] == 1) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}



Measured memory_bytes: 2104
#include <iostream>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
using namespace __gnu_pbds;

typedef tree<pair<long long int,long long int>,null_type,less<pair<long long int,long long int> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

void go()
{
    string a,b;
    cin>>a>>b;
    int ans=0;
    for(int i=0;i<a.size();i++)
    {
        if(a[i] != b[i])
            ans++;
    }
    cout<<ans;
}
int main()
{
    //FIO;
//    int t;
//    cin>>t;
//    while(t--)
        go();
    return 0;
}



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

ans = True

for i in range(len(s)):
    if i == a:
        if s[i] != '-':
            ans = False
    else:
        if s[i] < '0' or '9' < s[i]:
            ans = False

if ans:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
n, k = map(int, input().split())
a = list(map(int, input().split()))

if k <= n:
    takahashi = 0
    for _ in range(k):
        takahashi = a[takahashi] - 1
    print(takahashi + 1)
else:
    start = 0
    takahashi = start
    trajectory = [takahashi]
    loop_start = -1
    loop_end = -1
    visited = [False] * n
    visited[0] = True
    for i in range(n):
        takahashi = a[takahashi] - 1
        if visited[takahashi]:
            loop_start = trajectory.index(takahashi)
            break
        visited[takahashi] = True
        trajectory.append(takahashi)
    print(trajectory[loop_start:][(k - loop_start) % (i + 1 - loop_start)] + 1)


Measured memory_bytes: 32380
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define mt make_tuple
#define ldb double
#define pii pair<int,int>
#define pll pair<ll,ll>
template<typename T>void ckmn(T &a,T b){a=min(a,b);}
template<typename T>void ckmx(T &a,T b){a=max(a,b);}
int ri(){int x;scanf("%i",&x);return x;}
void rd(){}
template<typename...T>void rd(int &x,T&...args){scanf("%i",&x);rd(args...);}
template<typename...T>void rd(ll &x,T&...args){scanf("%lld",&x);rd(args...);}
template<typename...T>void rd(ldb &x,T&...args){scanf("%lf",&x);rd(args...);}
template<typename...T>void rd(pii &x,T&...args){scanf("%i %i",&x.first,&x.second);rd(args...);}
template<typename T>void rd(vector<T>&v){for(T&i:v)rd(i);}

const int mod=998244353;
int add(int a, int b){ a+=b;return a>=mod?a-mod:a;}
void ckadd(int &a, int b){ a=add(a,b);}
int sub(int a, int b){ a-=b;return a<0?a+mod:a;}
void cksub(int &a, int b){ a=sub(a,b);}
int mul(int a, int b){ return (ll)a*b%mod;}
void ckmul(int &a, int b){ a=mul(a,b);}
int powmod(int x, int k){ int ans=1;for(;k;k>>=1,ckmul(x,x)) if(k&1) ckmul(ans,x);return ans;}
int inv(int x){ return powmod(x,mod-2);}

const int N=3005;
int dp[N][N],ans;
int main(){
	int a,b,c,d;rd(a,b,c,d);
	dp[a][b]=1;
	if(a==c)ans=powmod(a,d-b);
	for(int i=a+1;i<=c;i++){
		int sum=0;
		for(int j=b;j<=d;j++){
			ckadd(dp[i][j],mul(dp[i-1][j],j));
			ckadd(sum,dp[i-1][j-1]);
			ckmul(sum,i-1);
			ckadd(dp[i][j],sum);
			//for(int las=b;las<j;las++){
			//	ckadd(dp[i][j],mul(dp[i-1][las],powmod(i-1,j-las)));
			//}
			if(i==c){
				ckadd(ans,mul(dp[i][j],powmod(c,d-j)));
			}
		}
	}
	printf("%i\n",ans);
	return 0;
}

Measured memory_bytes: 39080
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
	cout << fixed << setprecision(10);
	int h,w,d;
	cin >> h >> w >> d;
	map<int,pair<int,int>> mpi;
	rep(i,h) rep(j,w){
		int x;
		cin >> x;
		mpi[x] = {i+1,j+1};
	}
	int mp[h*w+1];
	for(int i=1;i<=h*w;i++){
		if(i<=d){
			mp[i] = 0;
		}else{
			mp[i] = mp[i-d] + abs(mpi[i].first-mpi[i-d].first) + abs(mpi[i].second-mpi[i-d].second);
		}
	}
	int q;
	cin >> q;
	vector<int> ans;
	rep(i,q){
		int l,r;
		cin >> l >> r;
		ans.push_back(mp[r]-mp[l]);
	}
	for(auto u : ans){
		cout << u << endl;
	}
	return 0;
}

Measured memory_bytes: 7672
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define iii tuple<int, int, int>
#define ii pair<int, int>
#define fi first
#define se second

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void solve() {
    int n, M = 1e9 + 7;
    cin >> n;

    vector<vector<int>> a(n, vector<int>(n));
    for (auto& i : a)
        for (auto& j : i) cin >> j;

    vector<int> dp(1 << n), p2(n + 1);
    for (int i = 0; i <= n; ++i) p2[i] = 1 << i;
    dp[0] = 1;

    queue<ii> q;
    q.push({0, 0});
    while (!q.empty()) {
        int msk = q.front().fi, i = q.front().se;
        q.pop();

        // cout << msk << ' ' << i << '\n';
        if (dp[msk] == -1) continue;
        if (msk == p2[n] - 1) break;

        for (int j = 0; j < n; ++j) {
            if (a[i][j] && !(msk & p2[j])) {
                int nmask = msk | p2[j];
                dp[nmask] = (dp[nmask] + dp[msk]) % M;
                q.push({nmask, i + 1});
            }
        }
        dp[msk] = -1;
    }
    cout << dp[p2[n] - 1] << '\n';
}

int main() {
    // ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    // freopen("in", "r", stdin);

    int t = 1;
    // cin >> t;
    while (t--) solve();

    return 0;
}

Measured memory_bytes: 41676
#include <stdio.h>

typedef struct {
    int flip;
    long long rotate;
} Query;

long long n, k, q;

Query tree[(1 << 20) * 2];

void  build(long long _n);
Query merge(Query a, Query b);
void  update(Query data, long long i);
Query sum(void);

int main()
{
    long long _n;
    long long a;

    scanf("%lld %lld %lld", &k, &_n, &q);

    build(_n);

    for (long long i = 0; i < _n; i++) {
        scanf("%lld", &a);

        Query data = {0, 0};

        if (a == 0) data.flip = 1;
        else data.rotate = -a;

        update(data, i);
    }

    for (long long i = 0; i < q; i++) {
        long long left, right;
        Query l, r;
        scanf("%lld %lld", &left, &right);
        left--;
        right--;

        l = tree[left + n - 1];
        r = tree[right + n - 1];

        update(l, right);
        update(r, left);


        Query total = sum();

        long long num;
        if (total.rotate < 0) total.rotate = k + total.rotate;
        num = 1 + total.rotate;

        if (total.flip) {
            if (num == 1) num *= -1;
            else num = ((k + 2) - num) * -1;
        }

        printf("%lld\n", num);
        //        printf("%d %lld\n", total.flip, total.rotate);
    }
    
    return 0;
}

void  build(long long _n)
{
    n = 1;

    while (n < _n) {
        n *= 2;
    }

    for (long long i = 0; i < 2 * n; i++) {
        tree[i] = (Query){0, 0};
    }

    return;
}

Query merge(Query a, Query b)
{
    Query x;

    x.flip = (a.flip + b.flip) % 2;

    if (b.flip) {
        x.rotate = (b.rotate - a.rotate) % k;
    } else {
        x.rotate = (a.rotate + b.rotate) % k;
    }

    return x;
}

void update(Query data, long long i)
{
    i += n - 1;

    tree[i] = data;

    while (i != 0) {
        i = (i - 1) / 2;
        tree[i] = merge(tree[i * 2 + 1], tree[i * 2 + 2]);
    }

    return;
}

Query sum(void)
{
    return tree[0];
}


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

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  for (int i = 1; i < 10; i++) {
    for (int j = 1; j < 10; j++) {
      cout << i << "x" << j << "=" << i * j << endl;
    }
  }
}


Measured memory_bytes: 3120
import sys

X, K, D=list(map(int, input().split()))

if X < 0:
    X = -X

if X-K*D>=0:
    print(X-K*D)
    sys.exit()

temp_X = X
temp_K = K

#while temp_X-D >= 0:
#    temp_X -= D
#    temp_K -= 1

k = X//D

temp_X = X-k*D
temp_K = K-k

if temp_K%2==0:
    print(temp_X)
else:
    print( abs(temp_X-D) )


Measured memory_bytes: 9196
import std.stdio;
import std.string;
import std.conv;
import std.algorithm: canFind;

void main() {
	string[] inputs = split(readln());
	int a = to!int(inputs[0]);
	int b = to!int(inputs[1]);
	int c = to!int(inputs[2]);
	
	if(b - a == c - b) "YES".writeln;
	else "NO".writeln;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>

struct Edge {
  int dst;
  long long cost;
  Edge() {}
  Edge(int x, long long y) : dst(x), cost(y) {}
};

std::vector<long long> dijkstra(int sv, std::vector<std::vector<Edge>> &G) {
  const long long LINF = 1000000000000000018LL;

  int n = (int)G.size();
  std::vector<long long> dist(n, LINF);
  dist[sv] = 0;

  typedef std::pair<long long, int> PLI;
  std::priority_queue<PLI, std::vector<PLI>, std::greater<PLI>> que;

  que.push(std::make_pair(0LL, sv));

  while (!que.empty()) {
    PLI now = que.top();
    que.pop();
    long long cur_d = now.first;
    long long cur_v = now.second;

    if (dist[cur_v] < cur_d) {
      continue;
    }

    for (int i = 0; i < (int)G[cur_v].size(); i++) {
      int next_v = G[cur_v][i].dst;
      long long cost = G[cur_v][i].cost;
      if (dist[cur_v] + cost < dist[next_v]) {
        dist[next_v] = dist[cur_v] + cost;
        que.push(std::make_pair(dist[next_v], next_v));
      }
    }
  }
  return dist;
}

int main() {
  const long long LINF = 1000000000000000018LL;
  int v, e, r;
  std::cin >> v >> e >> r;

  std::vector<std::vector<Edge>> g(v);
  for (int i = 0; i < e; i++) {
    int s, t, d;
    std::cin >> s >> t >> d;
    g[s].push_back(Edge(t, d));
  }

  std::vector<long long> dist = dijkstra(r, g);
  for (int i = 0; i < v; i++) {
    if (dist[i] == LINF) {
      std::cout << "INF" << std::endl;
    } else {
      std::cout << dist[i] << std::endl;
    }
  }
  return 0;
}


Measured memory_bytes: 19384
N = int(input())
AList = list(map(int, input().split()))
excludeNsum = 0

for x in range(0,N,2):
    excludeNsum += AList[x]

Sum = sum(AList)

Nvol = (2*excludeNsum - Sum)
test = Nvol
answer = str(Nvol)

for x in range(N-1):
    vol = AList[x]*2 - test
    answer += ' ' + str(vol)
    test = vol

print(answer)

Measured memory_bytes: 14092
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll ;
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
 ll mod=1e9+7;

void test_case()
{
	ll a,f=0,s=0;
	for(ll i=0;i<3;i++)
	{
		cin>>a;
		if(a==5)f++;
		if(a==7)s++;
	}
	if(f==2&&s==1)cout<<"YES";
	else
	cout<<"NO";
}

int main()
{
    fast;
    
//    ll t;
//    cin>>t;
//    while(t--)
    test_case();
    
    
 
   
}

		
	
	
	
	


Measured memory_bytes: 3604
package main

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

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt() int {
  n, _ := strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

func Max(A []int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}

type Items [][]int
func (I Items) Len() int { return len(I) }
func (I Items) Less(i, j int) bool {
  if I[i][1] == I[j][1] { return I[i][0] > I[j][0] }
  return I[i][1] < I[j][1]
}
func (I Items) Swap(i, j int) { I[i], I[j] = I[j], I[i] }

type BinaryIndexedTree []int
func InitBIT(N int) BinaryIndexedTree {
  BIT := make([]int, N + 1)
  return BIT
}
func (BIT *BinaryIndexedTree) Update(idx, v int) {
  N := len((*BIT))
  d := v - BIT.Get(idx) + BIT.Get(idx - 1)
  for i := idx; i < N; i += i & (-i) {
    (*BIT)[i] += d
  }
}
func (BIT *BinaryIndexedTree) Get(idx int) int {
  if idx < 1 { return 0 }
  b := 0
  for i := idx; 0 < i; i -= i & (-i) {
    b += (*BIT)[i]
  }
  return b
}

func Count(A *[]int, k int) int {
  N := len((*A))
  B := make([]int, N + 1)
  for i, a := range (*A) {
    B[i + 1] = B[i]
    if a <= k {
      B[i + 1]++
    } else {
      B[i + 1]--
    }
  }
  C := make([][]int, N + 1)
  for i, b := range B {
    C[i] = []int{i + 1, b}
  }
  sort.Sort(Items(C))
  BIT := InitBIT(N + 1)
  cnt := 0
  for _, c := range C {
    cnt += BIT.Get(c[0])
    BIT.Update(c[0], 1)
  }
  return cnt
}

func Solve(N int, A []int) int {
  high, low := Max(A), 0
  N2 := N * (N + 1) / 2
  B := N2 / 2 + 1
  for 1 < high - low {
    med := (high + low) / 2
    if Count(&A, med) < B {
      low = med
    } else {
      high = med
    }
  }
  return high
}

func main() {
  N := NextInt()
  A := NextIntVec()
  ans := Solve(N, A)
  Write(ans)
  Output()
}

Measured memory_bytes: 14464
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod;
bool g[110][110];
int main(){
  ll n,k; cin>>n>>k;
  k=(n-1)*(n-2)/2-k;
  if(k<0){
    cout<<-1<<endl;
    return 0;
  }
  for(int i=1;i<=n;i++)for(int j=1;j<i;j++)g[i][j]=0;
  for(int i=1;i<n;i++)g[n][i]=1;
  ll x=2,y=1;
  for(int i=0;i<k;i++){
    g[x][y]=1;
    y++; if(y==x)y=1,x++;
  }
  cout<<n-1+k<<endl;
  for(int i=1;i<=n;i++)for(int j=1;j<i;j++){
    if(g[i][j]==1)cout<<i<<" "<<j<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
import math

def insertion_sort(A, n, g):
    c = 0
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j + g] = A[j]
            j -= g
            c += 1
        A[j + g] = v
    return c

cnt = 0
n = int(input())

A = []
G = []

m = 0
ge = 1

while ge <= n:
    G.append(ge)
    m += 1
    ge = 3 * ge + 1
G.reverse()

for _ in range(n):
    A.append(int(input()))

for i in range(m):
    cnt += insertion_sort(A, n, G[i])

print(str(m))
print(' '.join([ str(g) for g in G ]))
print(str(cnt))

for j in range(n):
    print(str(A[j]))


Measured memory_bytes: 45596
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
ll a[1005];
int even(int n)
{
    int cnt = 0;
    for(ll i = 0; i < n; i ++)
    {
        if(a[i] % 2 == 0)
        {
            cnt ++;
        }
    }
    if(cnt == n)
    {
        return true;
    }
    else
    {
        return false;
    }
}
int main()
{
    ll n, lnt = 0;
    cin >> n;
    for(ll i = 0; i < n; i ++)
    {
        cin >> a[i];
    }
        while(even(n) == true)
        {
            for(ll i = 0; i < n; i ++)
            {
                a[i] /= 2;
            }
            lnt ++;
        }
        cout << lnt;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

int main() {
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int time;
    int time1 = 60 * h1 + m1;
    int time2 = 60 * h2 + m2;
    time = time2 - time1;

        cout << time-k << endl;
    
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;
using namespace std;
#define ll                      long long
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
#define mp                      make_pair
#define vpll                    vector<pair<ll,ll> >
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll T;cin>>T;while(T--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            for(ll i=0;i<size;i++) cout<<w[i]<<" ";
#define prll(a)                 cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,val)               lower_bound(all(v),val)-v.begin()
#define ub(v,val)               upper_bound(all(v),val)-v.begin()
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
ll pows(ll b,ll e){if(e==0)return 1;else if(e%2==0){ll a=pow(b,e/2);return a*a;}else {ll a=pow(b,e/2);return b*a*a;}}
ll powm(ll x,ll y,ll m){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
int main()
{
fastIO
ll n,m,i,j,k,x,y,z,e,f,p,q,g,l,r,w,h,count1=0,prod=1,a,b,c,d,index,x1,x2,diff,ans=0,sum=0,sum1=0,sum2=0,flag=0,flag1=0,flag2=0;
string s,s1,s2;
cin>>n>>m;
if(n<m)
{
for(i=0;i<m;i++)
{
  s+=n+'0';
}
}
else
{
for(i=0;i<n;i++)
{
  s+=m+'0';
}
}
cout<<s;
}


Measured memory_bytes: 256
n, m = gets.split( " " ).map { | val | val.to_i }
ai = Array.new( n )
ai.each_index { |i|
	ai[i] = gets.split( " " ).map { | val | val.to_i }
}
bi = Array.new( m )
bi.each_index { |i|
	bi[i] = gets.chomp!.to_i
}

ci = Array.new( n, 0 )
ai.each_index { |i|
	ai[i].each_index { |j|
		ci[i] += ( ai[i][j] * bi[j] )
	}
}
ci.each { |val|
	puts( val )
}

Measured memory_bytes: 6128
N = int(input())
D = []
for i, a in enumerate(map(int, input().split())):
    D.append((a<<11) + i)
D.sort(reverse=True)
dp = [0]*(N+1)
for i, d in enumerate(D,start=1):
    x, a = d%(1<<11),d>>11
    for j in reversed(range(i)):
        dp[j+1] = max(dp[j] + a*(x-j), dp[j+1])
        dp[j] += a*(N-(i-j)-x)
print(max(dp))

Measured memory_bytes: 73812
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long int i = start; i < end; ++i)
#define srt(x) sort((x).begin(), (x).end());
#define rsrt(x) sort((x).rbegin(), (x).rend());
#define deb(x) cout<<#x<<" = "<<(x)<<" (L"<<LINE<<")"<<endl;
#define vdeb(x) {cout<<#x<<" = { "; rep(i, x.size()) cout<<x[i]<<' '; cout <<'}'<<" (L"<<LINE<<")"<<endl;}
using namespace std;
using ll = long long int;
using vi = vector<int>;
using vivi = vector<vi>;
using vll = vector<long long int>;
using vs = vector<string>;

int main()
{
    int L;
    cin >> L;
    cout << setprecision(20) << pow(L / 3.0, 3.0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

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

using namespace std;

namespace mp = boost::multiprecision;

using ll = long long;
using Bint = mp::cpp_int;
ll mod = pow(10, 9) + 7;

int main() {
    // source
    int n;
    cin >> n;
    int temp = n;
    int sum = 0;
    while (temp != 0) {
        sum += temp % 10;
        temp /= 10;
    }

    if (n % sum == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

using CHY72;

namespace CHY72{
    
    public class PointXY<T>where T:IComparable{
        public T X , Y;
        public bool Flag = false;
        public PointXY(T _X,T _Y) {
            X = _X; Y = _Y;
        }
        public static bool operator ==(PointXY<T> P1, PointXY<T> P2) {
            return (P1.X.CompareTo( P2.X) == 0 && P1.Y.CompareTo (P2.Y) == 0);
        }
        public static bool operator !=(PointXY<T> P1, PointXY<T> P2) {return !(P1 ==P2);}
        public override int GetHashCode() {return X.GetHashCode() ^ Y.GetHashCode();}
        public override bool Equals(object obj) {
            if (obj == null || this.GetType() != obj.GetType()) {return false;}
            return (this == (PointXY<T>)obj);
        }
        //char '0' == int 48 ;....;char '9' == int 57;

    }
    
}    

public class Program {
    static bool ReadLine_1(ref int num1, bool Fin0 = true) {
        string str = Console.ReadLine();
        num1 = int.Parse(str);
        return (Fin0 && num1 == 0);
    }
    static int  ReadLine_1() {
        return  int.Parse(Console.ReadLine());
    }
    static bool ReadLine_2(ref int num1, ref int num2, char Spliter = ' ', bool Fin0 = true) {
        string str = Console.ReadLine();
        num1 = int.Parse(str.Split(Spliter)[0]);
        num2 = int.Parse(str.Split(Spliter)[1]);
        return (Fin0 && num1 == 0);
    }
    static int[] ReadLine72(char Spliter = ' ') {
        return Console.ReadLine().Split(Spliter).Select(s => int.Parse(s)).ToArray();
    }

    const int DefaultMax = 72727272;

    static void Main(string[] args) {
        while (true) {
            int e = ReadLine_1();
            if (e == 0) return;
            int SQRTe = (int)Math.Sqrt(e)+1;
            int SSQRTe = (int)Math.Pow(e, 1.0 / 3.0) + 1;
            int Min = DefaultMax;
            for (int z = 0; z <= SSQRTe; z++) {
                for (int y = 0; y <= SQRTe; y++) {
                    int x = e - y * y - z * z * z;
                    if (x >= 0 &&  x+y+z <Min) {
                        Min =x+y+z;
                    }
                }
            }
            Console.WriteLine(Min);

        }
    }
}

Measured memory_bytes: 5860
import collections
import itertools
ok = ['M', 'A', 'R', 'C', 'H']
n = int(input())
d = collections.defaultdict(int)
for _ in range(n):
    s = input()
    if any([s[0] == x for x in ok]): d[s[0]] += 1
p = [a for a in itertools.combinations(ok, 3) if all([x in d for x in a])]
ans = 0
for a, b, c in p:
    ans += d[a] * d[b] * d[c]
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define repeat(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, t, a;
    cin >> n >> t >> a;
    double h[n];
    rep(i, n){
        cin >> h[i];
    }
    int y =  t - a;
    pair<double, int> w[n];

    rep(i, n){
        w[i].second = i + 1;
        w[i].first = abs(y - h[i] * 0.006);
    }
    sort(w, w + n);
    cout << w[0].second << endl;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define int ll
#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int a, b;
    cin>>a>>b;
    for(int i = 1; i <= (int)1e6; i++) {
        int ff = (i * 8) / 100;
        int ss = (i * 1) / 10;
        if(ff == a && ss == b) {
            cout<<i;
            return 0;
        }
    }
    cout<<"-1";
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace AizuOnLine
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int count = int.Parse(Console.ReadLine());

                if (count == 0) { break; }

                int[] data = Array.ConvertAll(Console.ReadLine().Split(' '), e => int.Parse(e));

                double ave = data.Average();

                double sum = 0;
                for (int i = 0; i < data.Length; i++)
                {
                    sum += (data[i] - ave) * (data[i] - ave);
                }

                double sd = Math.Sqrt(sum / data.Length);

                Console.WriteLine(sd);
            }
        }
    }
}

Measured memory_bytes: 9596
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(__typeof((X).begin()) it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

struct timer{
	time_t start;
	timer(){start=clock();}
	~timer(){cerr<<1.*(clock()-start)/CLOCKS_PER_SEC<<" secs"<<endl;}
};

typedef istringstream iss;
typedef long long ll;
typedef pair<int,int> pi;
typedef stringstream sst;
typedef vector<int> vi;

ll n,m,a,b,p,q;
vector<ll> v;

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	cin>>n>>m>>a>>b>>p>>q;
	if(a==1 && b==1){
		ll t=p+q;
		if(n < (m+t-1)/t){
			cout<<m-t*n<<endl;
		}else{
			cout<<min(m%t,t-m%t)<<endl;
		}
		return 0;
	}
	vector<ll> v;
	ll pa=p,qb=q;
	double pa_=p,qb_=q;
	rep(i,n){
		if(pa_+qb_>3*m)break;
		if(pa+qb>2*m)break;
		v.pb(pa+qb);
		pa*=a,qb*=b;
		pa_*=a,qb_*=b;
	}
	//rep(i,sz(v))cout<<v[i]<<" ";cout<<endl;
	
	vector<ll> v0,v1,sum;
	int N=sz(v)/2;
	rep(i,sz(v)){
		if(i<N)v0.pb(v[i]);
		else v1.pb(v[i]);
	}
	rep(mask,1<<sz(v1)){
		ll s=0;
		rep(i,sz(v1))if(mask>>i&1){
			s+=v1[i];
		}
		sum.pb(s);
	}
	sort(sum.begin(),sum.end());
	
	ll ans=m;
	rep(mask,1<<sz(v0)){
		ll s=0;
		rep(i,sz(v0))if(mask>>i&1){
			s+=v0[i];
		}
		if(s>=m){
			ans=min(ans,s-m);
		}else{
			ll rest=m-s;
			vector<ll>::ite it=lower_bound(sum.begin(),sum.end(),rest);
			if(it!=sum.end())ans=min(ans,*it-rest);
			it--;
			ans=min(ans,rest-*it);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 18540
#include<bits/stdc++.h>
using namespace std;
char s1[3005],s2[3005];
int n1,n2;
int dp[3005][3005];
pair<int,int> table[3005][3005];
int solve (int ptr1,int ptr2){
    if(ptr1 == n1 || ptr2 == n2)
        return 0;
    if(dp[ptr1][ptr2]!= -1){
        return dp[ptr1][ptr2];
    }
    if(s1[ptr1] == s2[ptr2]) {
        table[ptr1][ptr2] = {ptr1+1,ptr2+1};
        return dp[ptr1][ptr2] = 1 + solve(ptr1 + 1, ptr2 + 1);
    }else {
        int st = solve(ptr1+1,ptr2);
        int nd = solve(ptr1,ptr2+1);
        if(st>nd){
            table[ptr1][ptr2] = {ptr1+1,ptr2};
        } else
            table [ptr1][ptr2] = {ptr1,ptr2+1};
        return dp[ptr1][ptr2] = max(st, nd);
    }
}
int main() {
    scanf("%s\n%s",s1,s2);
    n1 = strlen(s1);
    n2 = strlen(s2);
    memset(dp,-1,sizeof dp);
    solve(0,0);
    pair<int,int> curr = {0,0};
    string s;
    while(curr.first <n1 && curr.second <n2){
        if(s1[curr.first] == s2[curr.second]){
            s.push_back(s1[curr.first]);
        }
        curr = table[curr.first][curr.second];
    }
    printf("%s",s.c_str());
}

Measured memory_bytes: 109828
def solve():
    V, E = map(int, input().split())
    edges = [[] for _ in [0]*V]
    for _ in [0]*E:
        s, t, d = map(int, input().split())
        edges[s].append((t, d))

    result = float("inf")
    beam_width = 80
    for i in range(V):
        q = [(0, i, {i})]
        for j in range(V-1):
            _q = []
            append = _q.append
            for cost, v, visited in q[:beam_width+1]:
                for dest, d_cost in edges[v]:
                    if dest not in visited:
                        append((cost+d_cost, dest, visited | {dest}))
            q = sorted(_q)
        for cost, v, visited in q[:beam_width+1]:
            for dest, d_cost in edges[v]:
                if dest == i:
                    if result > cost + d_cost:
                        result = cost + d_cost
                        break

    print(result if result < float("inf") else -1)


if __name__ == "__main__":
    solve()

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

int main(){
    int x, y, z;
    cin >> x >> y >> z;
    int b = 0;
    
    for (int a = x; a <= y ; a += 1){
        if (z % a == 0){
            b += 1;
        }
    }
    
    cout << b << endl;
    
    return 0;
}


Measured memory_bytes: 3112
#include<iostream>
int main()
{
	double min = 1000001, max = -1;
	for (double height; std::cin >> height;)
	{
		if (min > height)min = height;
		if (max < height)max = height;
	}
	std::cout << max - min << std::endl;
	return 0;
}


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

namespace ABC
{
    class ProgramA
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(" ");
            var result = inputs[0][0].ToString() + inputs[1][0] + inputs[2][0];
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 25660
n = int(input())
vs = list(map(int, input().split()))
es = {}
os = {}
for i, v in enumerate(vs):
    if i % 2 == 0:
        v0 = es.get(v, 0)
        es[v] = v0 + 1
    else:
        v0 = os.get(v, 0)
        os[v] = v0 + 1

es_max = max(es, key=es.get)
es_cnt = sum(es.values())
es_ch_len = es_cnt - es[es_max]
del es[es_max]

os_max = max(os, key=os.get)
os_cnt = sum(os.values())
os_ch_len = os_cnt - os[os_max]
del os[os_max]

if os_max == es_max:
    if es == {}:
        es_len = 0
    else:
        es_snd = max(es, key=es.get)
        es_len = es[es_snd]
    if os == {}:
        os_len = 0
    else:
        os_snd = max(os, key=os.get)
        os_len = os[os_snd]
    if es_len > os_len:
        es_ch_len = es_cnt - es_len
    else:
        os_ch_len = os_cnt - os_len

print(os_ch_len+es_ch_len)


Measured memory_bytes: 17652
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    ll N; scanf("%lld", &N);

    vector<ll> divs;
    for(ll i=1; i*i<=N; i++) {
        if(N % i == 0) {
            divs.emplace_back(i);
            if(i != N / i) divs.emplace_back(N/i);
        }
    }
    sort(divs.begin(), divs.end());

    ll ans = 0;
    {
        auto check = [&](ll v) {
            auto ptr = lower_bound(divs.begin(), divs.end(), v);
            if(ptr == divs.end() or *ptr != v) return true;
            else return false;
        };
        
        ll M = N - 1;
        for(ll i=1; i*i<=M; i++) {
            if(M % i == 0) {
                if(check(i)) ans++;
                if(i != M/i and check(M/i)) ans++;
            }
        }
    }

    for(auto d : divs) {
        if(d == 1) continue;
        ll M = N;
        while(M % d == 0) M /= d;
        M %= d;
        if(M == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
package main

import (
	"fmt"
	"strings"
)

func main() {
	var a, b, c string
	fmt.Scan(&a, &b, &c)

	playerCards := [][]string{
		strings.Split(a, ""),
		strings.Split(b, ""),
		strings.Split(c, ""),
	}
	cardPlayerIdxMap := map[string]int{
		"a": 0,
		"b": 1,
		"c": 2,
	}
	playerIdxNameMap := map[int]string{
		0: "A",
		1: "B",
		2: "C",
	}
	curTurn := 0
	for {
		curCards := playerCards[curTurn]
		if len(curCards) == 0 {
			fmt.Println(playerIdxNameMap[curTurn])
			return
		}
		card := curCards[0]
		playerCards[curTurn] = curCards[1:]
		curTurn = cardPlayerIdxMap[card]
	}
}


Measured memory_bytes: 1840
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,k,a[200010],s[200010];
map<ll,ll> cnt;
ll pmod(ll x){
	return(x%k+k)%k;
}
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
	}
	for(int i=1;i<=n;i++){
		s[i]=s[i-1]+a[i];
	}
	ll ans=0;
	for(int i=n;i>=1;i--){
		cnt[(s[i]-i)%k]++;
		if(i+k-1<=n){
			int tt=i+k-1;
			cnt[(s[tt]-tt)%k]--;
		}
		ll tmp=(s[i-1]-i+1ll)%k;
		ans+=cnt[tmp];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 15872
let input = require('fs').readFileSync('/dev/stdin', 'utf8');
let [a,b,c] = input.trim().split(" ").map(Number);
let [d,sum] = [1,a];

while(1){
    if(c <= sum){
        console.log(d);
        break;
    }
    ++d;
    sum += a;
    if(d % 7 === 0){
        sum += b;
    }
}


Measured memory_bytes: 15164
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
 
    string s1;
    int n;
    cin >> n >> s1;
    for (int i=0;i<s1.size();i++) {
        s1[i] = s1[i] + n;
        if (s1[i] > 'Z') s1[i] -= 26;
    }
    cout << s1;
 
    
 
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
int main(){
    string s; cin >> s;
    bool first;
    if(s.size()%2==0){
        if(s[0] == s[s.size()-1]){
            first = true;
        }else{
            first = false;
        }
    }else{
        if(s[0] == s[s.size()-1]){
            first = false;
        }else{
            first = true;
        }
    }
    if(first){
        cout << "First" << endl;
    }else{
        cout << "Second" << endl;
    }

}

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

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

    int num_1 = 0, num_2 = 0;
    for (int i = 0; i < S.size(); i++) {
        if (i % 2 == 0) {
            if (S[i] == '0') num_1++;
        } else {
            if (S[i] == '1') num_1++;
        }
    }
    for (int i = 0; i < S.size(); i++) {
        if (i % 2 == 0) {
            if (S[i] == '1') num_2++;
        } else {
            if (S[i] == '0') num_2++;
        }
    }
    cout << min(num_1, num_2) << endl;
    return 0;
}

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

typedef long long ll;
#define MOD 1000000007

ll calc(int n)
{
    ll ret = 1;
    for (int i = 0; i < n; i++)
        ret = (ret << 1) % MOD;
    return ret;
}

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    sort(a.begin(), a.end());
    if (n % 2)
        for (int i = 0; i < n; i++)
        {
            int j = (i > 0) ? (i + 1) / 2 : 0;
            if (a[i] != 2 * j)
            {
                cout << 0 << endl;
                return 0;
            }
        }
    else
        for (int i = 0; i < n; i++)
        {
            int j = i / 2;
            if (a[i] != 2 * j + 1)
            {
                cout << 0 << endl;
                return 0;
            }
        }
    if (n % 2)
        cout << calc((n - 1) / 2) << endl;
    else
        cout << calc(n / 2) << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;

int main(){
    int n;cin>>n;
    if(n==10||n==100||n==1000||n==10000||n==100000)cout<<10<<endl;
    else{
	int ans=0;
	while(n)ans+=n%10,n/=10;
	cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
def main():
    A, B, K = map(int, input().split())
    num = []
    for i in range(A, A + K):
        num.append(i)

    for i in range(B, B - K, -1):
        num.append(i)

    num = list(set(num))
    num.sort()
    num = filter(lambda x: A <= x <= B, num)
    for i in num:
        print(i)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(void){
    int a, b, c;
    cin >> a >> b >> c;
    
    if(a==b and b==c) {
        std::cout << "1" << std::endl;
    }else if(a==b or b==c or c==a) {
        std::cout << "2" << std::endl;
    }else{
        std::cout << "3" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256