akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long   // aaaaaaaaaaaaaaaaaa
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define SIZE(buff) (sizeof(buff)/sizeof(buff[0]))
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
template<typename T, typename U>ostream& operator << (ostream& os, pair<T, U>& pair_var)
{os << "(" << pair_var.first << ", " << pair_var.second << ")";return os;}
// head
int q,m,n,k,res,tmp,tmp2;
VI a;
int b[200010] = {};
vector<pair<int,int>> v[305];
deque<PII> que;
//int dp[305][305][305] = {};
string s;
int rui[100002] = {};
int grui[100002] = {};
int migi,hidari,mid;
signed main() {
	cin.tie(0);
    ios::sync_with_stdio(false);
	std::cin >>n>>q;
	rep(i,0,n){
		cin>>k;
		a.pb(k);
	}
	rep(i,0,q){
		cin>>b[i];
	}
	rep(i,0,n){
		rui[i+1] = rui[i]+a[i];
		if(i%2==1)grui[i/2+1] = grui[i/2]+a[i];
	}
	rep(i,0,q){
		int x = b[i];
		int ue = (int)pow(10,9);
		int sita = -1;
		if(x*2>a[n-1]+a[n-2]){
			if (n%2==1){
				cout<<rui[n]-grui[(n)/2]<<endl;
			}
			else{
				cout<<grui[(n)/2]<<endl;
			}
			continue;
		}
		int flag = -1;
		int mae = -1;
		while(ue-sita>1){
			mid = (ue+sita)/2;
			hidari = lower_bound(a.begin(), a.end(), x-mid)-a.begin();
			migi = lower_bound(a.begin(), a.end(), x+mid)-a.begin();
			if (migi==n) migi-=1;
			if (x+mid < a[migi])migi-=1;
			int taka = n-1-migi;
			int ao = migi-hidari+1;
			if (taka == ao) {flag = 1; break;}
			else if(taka-ao == 1){ flag = 0; break;}
			else if (ao-1 == taka && (x-a[hidari] == a[migi]-x)){
				migi-=1;
				flag = 0;
				break;
			}
			if (taka>ao){
				sita = mid; mae=0;

			}
			else{
				ue = mid; mae=1;
			}
		}
		res = 0;
		res += rui[n] - rui[migi+1];
		if (flag){
		if (hidari){
			int kon = hidari;
			if (kon%2==1){
				res += rui[kon]-grui[(kon)/2];
			}
			else{
				res +=grui[(kon)/2];
			}			
		}
		}
		else{
		if (hidari){
			int kon = hidari;
			if (kon%2==0){
				res += rui[kon]-grui[(kon)/2];
			}
			else{
				res +=grui[(kon)/2];
			}			
		}			
		}
		cout<<res<<endl;
	}
}


Measured memory_bytes: 4596
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <cmath>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

int H[100009];

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

	int N; cin >> N;
	for (int i = 0; i < N; i++) cin >> H[i];

	int flag = true;
	H[0]--;
	for (int i = 1; i < N && flag; i++) {
		if (H[i] - 1 >= H[i - 1]) H[i]--;

		if (H[i] < H[i - 1]) flag = false;
	}

	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;


	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
#include <sstream> 
#include <limits>
#include <numeric>
#include<string.h>
#include<set>
using namespace std;
#define ll long long int
#define all(v) begin(v), end(v)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
//typedef vector<int> V;
//typedef vector<V> VV;
//typedef vector<VV> VVV;
using namespace std;



int main(void) {
	string s;
	cin >> s;
	if ((s[0] == s[1] && s[0] != s[2] && s[2] == s[3]) || (s[0] == s[2] && s[0] != s[1] && s[1] == s[3]) || (s[0] == s[3] && s[0] != s[2] && s[2] == s[1]))cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
from sys import stdin

readline = stdin.readline

def main():
    input()
    H = map(int, readline().split())
    ans = 0
    prev = int(1e9+7)
    cnt = -1
    for cur in H:
        if prev >= cur:
            cnt += 1
        else:
            if ans < cnt:
                ans = cnt
            cnt = 0
        prev = cur
    if ans < cnt:
        ans = cnt
    print(ans)
    return


main()


Measured memory_bytes: 11312
N, M = map(int, input().split())
H = list(map(int, input().split()))

badN = set()
for i in range(M):
    A, B = map(int, input().split())
    if H[A-1]==H[B-1]:
        badN.add(A)
        badN.add(B)
    elif H[A-1]>H[B-1]:
        badN.add(B)
    else:
        badN.add(A)

print(N-len(badN))


Measured memory_bytes: 20004
import Control.Applicative
import Control.Monad
import Data.List
import Data.Function


main :: IO()
main = do
    n <- readLn
    csfs <- replicateM (n-1) (map read . words <$> getLine)
    ($ 0) . fix $ \loop i ->
        unless (i == n) $ do
            print $ foldl' time 0 (drop i csfs)
            loop (i+1)
    where
        time t [c,s,f] = c + s + f * k
            where k = max 0 ((t - s - 1) `div` f + 1)


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
#define Size(n) (n).size()

typedef long long ll;

using namespace std;

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

//long long int kaizyo(long long int hh){
  //  cmp=1;
    //while(hh>1){
      //  cmp=(cmp*hh)%MOD;
        //hh--;
    //}
    //return cmp;
//}
//long long int ruizyo(long long int aa, long long int bb){
  //  if(aa==0){
    //    return 1;
    //}
    //else if(aa%2==0){
      //  long long int tt=ruizyo(aa/2,bb);
        //return (tt*tt)%MOD;
    //}
    //else{
      //  return (ruizyo(aa-1,bb)*bb)%MOD;
    //}
//}フェルマ－のア


//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

//bool f[100001];//1000000以下の素数を調べよう！
//rrep(i,2,100001){
  //      f[i]=false;
    //}
//rrep(i,2,100001){
  //      if(!f[i]){
    //        for(int j=i+i;j<=100000;j+=i){
      //          f[j]=true;
        //    }
        //}
    //}
    //for(int i=3;i<=100000;i+=2){
      //  if(!f[i]){
        //    c[i]++;
      //  }
   // }

//visited=vector<vector<bool>>(10,vector<bool>(10,false));アを全部falseに


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,k,w,x,y,sum=0,pos,s;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz");
bool fl=true;

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

       cin >> k >> s;
       rep(i,k+1){
           rep(j,k+1){
               if(s-i-j>=0&&s-i-j<=k){
                   ans++;
               }
           }
       }
       
       Cout(ans);
return 0;
}


Measured memory_bytes: 256
from collections import Counter

n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
s_cnt = Counter(s)
t_cnt = Counter(t)
ans = []

for i in s_cnt:
    if i in t_cnt:
        cal = s_cnt[i] - t_cnt[i]
        if cal <= 0:
            cal = 0
        ans.append(cal)
    else:
        ans.append(s_cnt[i])
print(max(ans))


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

int main() {
  int num_query; cin >> num_query;
  map<string, int> dictionary;
  
  for (int i = 0; i < num_query; i++) {
    int command; scanf("%d", &command);
    char key[20]; scanf("%s", key);
    
    switch (command) {
      case 0:
        int value; scanf("%d", &value);
        if (dictionary.count(key)) {
          dictionary.at(key) = value;
        } else {
          dictionary.insert(make_pair(key, value));
        }
        break;
        
      case 1:
        if (dictionary.count(key)) printf("%d\n", dictionary.at(key));
        else printf("%d\n", 0);
        break;
        
      case 2:
        dictionary.erase(key);
        break;
    }
  }
}


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

int main(){
	ll n;
	cin >> n;
	if(n == 0){
		cout << 0 << endl;
		return 0;
	}
	vll ans;
	while(n != 0){
		ll r = n % 2;
		if(r < 0) r = 1;
		n = (n - r) / (-2);
		ans.push_back(r);
	}
	ll l = ans.size();
	REPR(i, l) cout << ans[i];
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define repm(i,a,b) for(int i=(int)a;i>(int)b;--i)
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

const int vy = 100005;

vector<vector<int>>v;
vector<int>visited;
vector<ll>cnt(2,0);

void dfs(int i) {
	if (visited[i])return;
	visited[i] = true; 
	if (i < vy)++cnt[0];//xの頂点数
	else ++cnt[1];//yの頂点数
	for (auto x : v[i])dfs(x);
}
int main() {
	int n;
	cin >> n;
	int x, y;
	visited.resize(2*vy);
	v.resize(2*vy);
	repp(i, 0, n) {
		cin >> x >> y;
		v[x].push_back(y + vy);//xとyを区別
		v[y + vy].push_back(x);
	}ll ans = 0;
	repp(i, 0, 2 * vy) {
		cnt[0] = 0; cnt[1] = 0;//連結とは限らないため
		if (visited[i])continue;
		dfs(i);
		ans += cnt[0] * cnt[1];
	}
	ans -= n;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 10752
import collections
n = int(input())
v = list(map(int, input().split()))
e=[]
o=[]
for i, vi in enumerate(v,start=0):
  if i%2 == 0:
    e.append(vi)
  else:
    o.append(vi)
ec=collections.Counter(e)
oc=collections.Counter(o)

ecs = sorted(ec.items(), key=lambda x:x[1],reverse=True)
ocs = sorted(oc.items(), key=lambda x:x[1],reverse=True)

t=ecs[0][1]+ocs[0][1]
if ecs[0][0] == ocs[0][0]:
  if ecs[0][1] == ocs[0][1]:
    te = 0 if len(ecs) < 2 else ecs[1][1]
    to = 0 if len(ocs) < 2 else ocs[1][1]
    t=max(te,to)+ecs[0][1]
print(n-t)

Measured memory_bytes: 23768
//Created by Kira

#include<bits/stdc++.h>
using namespace std;

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    



int main(){
   IOS

    int n; cin>>n;

    unordered_map<string , int> mp;

    for(int i = 0; i < n; i++){
        string s; cin>>s;
        mp[s]++;
    }

    vector<string> v = {"AC", "WA", "TLE", "RE"};

    for(auto i : v){
        cout<<i<<" x "<<mp[i]<<"\n";
    }
    







}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1) res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



Measured memory_bytes: 3668
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input():
    return sys.stdin.readline().rstrip()

def main():
    N,Q=map(int,input().split())
    S=list(input())+['Z']
    ans=[0]*(N+1)
    for i in range(N):
        if S[i]=='A' and S[i+1]=='C':
            ans[i+1]=ans[i]+1
        else:
            ans[i+1]=ans[i]
    for _ in range(Q):
        l,r=map(lambda x:int(x)-1,input().split())
        print(ans[r]-ans[l])

if __name__ == '__main__':
    main()


Measured memory_bytes: 57048
#include <bits/stdc++.h>
#include<unordered_map>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 50
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
ll ans = 0;
int main() {
	cin >> A >> B;
	cout << ((A <= 8 && B <= 8) ? "Yay!" : ":(");
}


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

int main()
{
    ll a,b;
    cin>>a>>b;
    ll ans=(a*b)/2;
    if((a*b)%2) ans++;
    if(min(a,b)==1)
    {
        cout<<"1";
        return 0;
    }
    cout<<ans;
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

h = ni()

def dfs(h):
    if h == 1:
        return 1
    else:
        return dfs(h//2)*2 + 1

print(dfs(h))

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define ALL(vec) vec.begin(), vec.end()

using namespace std;
using ch = char;
using VC = vector<ch>;

int main(void){
    int n;
    int ii;
    cin >> n;
    VC array(n, 'a');
    rep(ii, n){
        cin >> array[ii];
    }
    sort(ALL(array));
    auto endPoint = unique(ALL(array));
    array.erase(endPoint, array.end());
    if(array.size() == 3){
        cout << "Three" << endl;
    }else if(array.size() == 4){
        cout << "Four" << endl;
    }
    return 0;
}


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

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
//#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

signed main() {
  int n;
  vi a(2), b(2);
  cin >> n;
  rep (i, 2) {
    cin >> a[i];
    a[i]--;
  }
  rep (i, 2) {
    cin >> b[i];
    b[i]--;
  }
  
  string s;
  cin >> s;
  s += "##";

  bool rev = false;
  if (b[0] > b[1]) rev = true;

  bool flag = true;
  vi idx;
  if (rev) idx = {0, 1};
  else idx = {1, 0};

  for (int i: idx) {
    int now = a[i];
    while (now < b[i]) {
      if (s[now + 1] != '#') now++;
      else if (s[now + 2] != '#') now += 2;
      else {
        flag = false;
        break;
      }
    }
  }

  if (rev) {
    bool flag2 = false;
    for (int i = a[1] - 1; i < b[1]; i++) {
      if (i > 0) {
        if (s[i] == '.' and s[i + 1] == '.' and s[i + 2] == '.') flag2 = true;
      }
    }
    if (not flag2) flag = false;
  }

  if (flag) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 640
n = int(input())
st = list(map(int,input().split()))
srtkey = lambda x: x[1] 
ans = []
for i,j in zip(range(n),st):
  ans.append([i+1,j])
srt = sorted(ans,key=srtkey)
for i,j in srt:
  print(i,end=" ")

Measured memory_bytes: 23360
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define pll pair<ll, ll>
#define vint vector<int >
#define vll vector<ll >
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int x,n;
    cin >> x >> n;
    int p[n];
    REP(i,n) cin >> p[i];
    int P[102];
    REP(i,102) P[i]=0;
    REP(i,n){
        P[p[i]] = 1;
    }

    int ans = 0;
    REP(i,102){
        if (x-i >= 0 && P[x-i] == 0){
            cout << x-i << "\n";
            return 0;
        }
        if (x+i <= 101 && P[x+i] == 0){
            cout << x+i << "\n";
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3616
io = STDIN
$s=io.gets.chomp.reverse
$t=io.gets.chomp.reverse
$n=$s.size-$t.size+1
def calc2(i,ans)
  $t.size.times do |j|
    if $s[i+j]==$t[j] ||
       $s[i+j]=="?"
       ans[i+j]=$t[j]
    else
      return false
    end
  end
  return ans
end
def calc1()
  ans=""
  $n.times do |i|
    ans=$s.clone
    if ans=calc2(i,ans)
      return ans.reverse.gsub("?","a")
    end
  end
  'UNRESTORABLE'
end
puts calc1


Measured memory_bytes: 1788
#include <iostream>

int main()
{
	int N = 0;
	std::cin >> N;

	int* T = new int[N];
	for (int i = 0; i < N; ++i)
	{
		std::cin >> T[i];
	}

	int M = 0;
	std::cin >> M;

	int* ans = new int[M];
	for (int i = 0; i < M; ++i)
	{
		int P, X = 0;
		std::cin >> P >> X;

		for (int j = 0; j < N; ++j)
		{
			if (j != (P - 1))
			{
				ans[i] += T[j];
			}
			else
			{
				ans[i] += X;
			}
		}
	}

	for (int i = 0; i < M; ++i)
	{
		std::cout << ans[i] << "\n";
	}

	return 0;
}

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

constexpr int si = 1020 * 1002, si_log = 7 + 10, mod = static_cast<int>(1e9) + 7;
int n, m, ar[si];

int64_t sol() {
   return 0;
}

int main() {
   ios_base::sync_with_stdio(0); cin.tie(0);
   while(cin >> n)
   {
      //auto s = sol();
      map<int, int> mm;
      for (int i = 0; i < n; i++)
      {
         int x; cin >> x;
         mm[x]++;
      }

      priority_queue<int, vector<int>, greater<int>> v;
      for (const auto &p: mm)
      {
         if (4 <= p.second)
         {
            v.push(p.first); v.push(p.first);
         }
         else if (2 <= p.second)
         {
            v.push(p.first);
         }
         while (2 < v.size())
         {
            v.pop();
         }
      }
      int64_t ans = 0;
      if (2 == v.size()) {
         int64_t n1 = v.top();
         v.pop();
         int64_t n2 = v.top();
         ans = n1*n2;
      }
      
      cout << ans << '\n';
   }
   return 0;
}

Measured memory_bytes: 4992
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <tuple>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j

template<class T> inline bool chMax(T& a, T b){ if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chMin(T& a, T b){ if (a > b) { a = b; return true; } return false; }

int main(){
    string S;
    cin >> S;
    rep(i, 0, S.size()){
        if (0 == i % 2){
            cout << S[i];
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>

using vi = std::vector<int>;
using vvi = std::vector<vi>;

int step(const vvi &g, vi &q, vi &marked) {
    vi q2;
    int r = 0;
    for (auto a : q) {
        if (!marked[a]) {
            marked[a] = 1;
            r++;
            for (auto b : g[a]) {
                if (!marked[b]) q2.push_back(b);
            }
        }
    }
    q.clear();
    std::swap(q, q2);
    return r;
}

int main() {
    int n; std::cin >> n;
    vvi g(n);
    for (int i = 0; i < n-1; i++) {
        int a, b; std::cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    vi marked(n);
    vi q1 = {0}, q2 = {n-1};
    int c1 = 0, c2 = 0;

    while (!(q1.empty() || q2.empty())) {
        c1 += step(g, q1, marked);
        c2 += step(g, q2, marked);
    }
    while (!q1.empty()) c1 += step(g, q1, marked);
    while (!q2.empty()) c2 += step(g, q2, marked);

    std::cout << (c1 > c2 ? "Fennec" : "Snuke") << std::endl;
}


Measured memory_bytes: 6400
#include <iostream>
#include<string>
#include<algorithm>
using namespace std;
typedef struct{
   int m[6];
}Dice;
Dice D[100], d[2];
int n;
string s = "NNENN", w="HHHH";
void roll(char c, Dice *d){
   switch(c){
       case 'N':
       swap(d->m[0],d->m[1]);
       swap(d->m[1],d->m[5]);
       swap(d->m[5],d->m[4]);
       break;
       case 'S':
       swap(d->m[0],d->m[4]);
       swap(d->m[4],d->m[5]);
       swap(d->m[5],d->m[1]);
       break;
       case 'E':
       swap(d->m[0],d->m[3]);
       swap(d->m[3],d->m[5]);
       swap(d->m[5],d->m[2]);
       break;
       case 'W':
       swap(d->m[0],d->m[2]);
       swap(d->m[2],d->m[5]);
       swap(d->m[5],d->m[3]);
       break;
       case 'H':
       swap(d->m[1],d->m[2]);
       swap(d->m[2],d->m[4]);
       swap(d->m[4],d->m[3]);
       break;
   }
}
bool isDifferent(Dice *d, Dice *e){
   for(unsigned i=0;i<s.size()+1;i++){
       for(unsigned j=0;j<w.size();j++){
           for(int k=0;k<6;k++){
               if(d->m[k] != e->m[k])break;
               if(k==5) return false;
           }
           roll(w[j],d);
       }
       if(i<s.size()) roll(s[i],d);
   }
   return true;
}
int main(void){
   int n=0;
   cin>>n;
   for(int i=0;i<n;i++)for(int j=0;j<6;j++) cin>>D[i].m[j];
   for(int i=0;i<n-1;i++){
       d[0]=D[i];
       for(int j=i+1;j<n;j++){
           d[1]=D[j];
           if(!isDifferent(&d[0],&d[1])){
               cout<<"No"<<endl;
               return 0;
           }
       }
   }
   cout<<"Yes"<<endl;
}





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

namespace _0191
{
    public class Program

    {
        public static void Main(string[] args)
        {
            while (true)
            {
                int[] nm = RIntAr();
                if (nm.Sum() == 0) break;

                int n = nm[0];
                int m = nm[1];

                double[,] growthRate = new double[n, n];
                for (int i = 0 ; i < n ; i++)
                {
                    double[] line = RDoubleAr();
                    for (int j = 0 ; j < n ; j++)
                    {
                        growthRate[i, j] = line[j];
                    }
                }

                double[,] dp = new double[m, n];
                for (int i = 0 ; i < n ; i++) dp[0, i] = 1;

                for (int i = 1 ; i < m ; i++)
                {
                    for (int j = 0 ; j < n ; j++)
                    {
                        for (int k = 0 ; k < n ; k++)
                        {
                            dp[i, j] = Math.Max(dp[i, j], dp[i - 1, k] * growthRate[k, j]);
                        }
                    }
                }

                double max = int.MinValue;
                for (int i = 0 ; i < n ; i++)
                {
                    max = Math.Max(max, dp[m - 1, i]);
                }
                Console.WriteLine(Math.Round(max, 2, MidpointRounding.AwayFromZero).ToString("0.00"));
            }

        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



Measured memory_bytes: 18180
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  string s,t;
  cin >> s >> t;
  int answer = 0;
  REP(i,3) answer += s[i] == t[i];
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define MOD 1000000007
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define int long long
#define ALL(A) A.begin(),A.end()
using vi=vector<int>;
using vii=vector<vi>;
signed main(){
  string S;
  int N,ans=0;
  cin>>N;
  rep(i,0,N){
    int X;
    cin>>X;
    ans+=X-1;
    }
  cout<<ans<<endl;
}


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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  bool A = false;
  if(abs(a-c)<=d){
    A=true;
  }
  else if(abs(b-c)<=d && abs(a-b)<=d){
    A=true;
  }
  if(A){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,L;
  cin >> N >> L;
  vector<string> vec(N);
  for (int i=0;i<N;i++){
    cin >> vec[i];
  }
  sort(vec.begin(),vec.end());
  string S="";
  for (string x : vec){
    S+=x;
  }
  cout << S << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main (String args[]){
    Scanner sc = new Scanner(System.in);

    int k = sc.nextInt();
    int n = sc.nextInt();
    int ans = 0;
    
    int[] array = new int[n];
    
    for(int i = 0; i < n; i++){
      array[i] = sc.nextInt();
    }
    
    Arrays.sort(array);
    
    int[] gapArray = new int[n];
    
    for(int i = 0; i < n-1; i++){
      int a = i;
      int b = a+1;
      
      gapArray[i] = array[b]-array[a];
    }
    
    gapArray[n-1] = array[0] + k-array[n-1];
    
    Arrays.sort(gapArray);
    
    for(int i = 0; i < n-1; i++){
      ans += gapArray[i];
    }
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 66596
// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//


#define _USE_MATH_DEFINES
#include<math.h>

//#include<cmath>

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>



//#include "Ants.h"
using namespace std;
typedef long long ll;
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<n;i++)
#define show(s) cout<<s<<endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define LINF (1000000000000000000ll)
typedef pair < int, int> P;
ll gcd(ll a, ll b) {//最大公約数を求める///最大公倍数a*b/gcd(a,b)
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcd(ll a, ll b) {//最小公倍数を求める　b=0のときaを返す
	if (b == 0) return a;
	return (a / gcd(a, b)) * b;
}
vector<int> divnum(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p;
}
int digiter(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p.size();
}
vector<int> convert(string s) {
	vector<int> d;
	ll n = s.size();
	rep(i, n) {
		d.push_back(s[i]-'0');
	}
	return d;
}
ll a, b, c;
int main()
{
	cin >> a >> b >> c;
	if ((c-a-b)*(c-a-b) > 4*a*b&&c-a-b>=0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
}

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

int main( void ) {
    
    string s;
    cin >> s;
    
    if( ( s.size() + ( s.front() == s.back() ) ) & 1 )
        cout << "First" << endl;
    else
        cout << "Second" << endl;
    
    return 0;
}

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

int main()
{
  int N, M;
  cin >> N >> M;
  vector<int> A(M);
  for (int i = 0; i < M; i++)
  {
    cin >> A.at(i);
    N -= A.at(i);
  }
  if (N < 0) cout << -1 << endl;
  else cout << N << endl;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<string> vs;
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }

int main()
{
  int n, x;
  cin >> n >> x;
  vi m(n);
  int s = 0;
  re(i, n) {
    cin >> m[i];
    s += m[i];
  }

  int cnt = n;
  s = x - s;

  int a = 1000;
  re(i, n) {
    a = min(a, m[i]);
  }

  cnt += s / a;
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int a[334334],res[334334];
signed main(){
	int n;
	cin>>n;
	for(int i=0;i<n*3;i++)cin>>a[i];
	priority_queue<int,vector<int>,greater<int> > Q;
	
	int sum=0;
	for(int i=0;i<n;i++){Q.push(a[i]);sum+=a[i];}
	res[n-1]=sum;
	for(int i=n;i<2*n;i++){
		Q.push(a[i]);
		sum+=a[i];
		sum-=Q.top();
		Q.pop();
		res[i]=sum;
		}
		
		priority_queue<int>Q1;
		int sum1=0;
		for(int i=3*n-1;i>=2*n;i--){Q1.push(a[i]);sum1+=a[i];}
		res[2*n-1]-=sum1;
		for(int i=2*n-1;i>=n;i--){
			Q1.push(a[i]);
			sum1+=a[i];
			sum1-=Q1.top();
			Q1.pop();
			res[i-1]-=sum1;
			}
		int ans=-1e15;
		for(int i=n-1;i<2*n;i++){ans=max(ans,res[i]);}
		cout<<ans<<endl;
	}


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

using namespace std;

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


int main(){
 long n;
   cin >> n;

 vector<long> p(n);
  rep(i,0,n) cin >> p[i];
   
  long res=0;
  rep(i,0,n-1){
   if(p[i]==i+1) {
     swap(p[i],p[i+1]);
     res++;
   }
  }
  if(p[n-1]==n) res++;
  
  cout << res << endl;
  
}

Measured memory_bytes: 1024
N = int(input())
ABC = [ list(map(int,input().split())) for i in range(N)]

def dp(N):
  #初期化
  inf=float("inf")
  dp=[[-inf for i in range(3)] for j in range(N)]
  for i in range(3): dp[0][i]=ABC[0][i]
    
  for i in range(N):
    if i != 0:
      for j in range(3):
        for k in range(3):
          if j!=k:
            dp[i][j] = max(dp[i-1][k]+ABC[i][j],dp[i][j])
    
  return max(dp[N-1][0],dp[N-1][1],dp[N-1][2])

print(dp(N))

Measured memory_bytes: 85080
#include <iostream>

using namespace std;

void solve(int k, int low, int high){
	
   for(int i = low; i <= high; i++){
   		if(i % k == 0){
        	cout << "OK" << endl;
            return;
        }
   }
  
   cout << "NG" << endl;
}

int main(){
 
  int k, low, high;
  cin >> k >> low >> high;
  
  solve(k, low, high);
  
  return 0;
}

Measured memory_bytes: 3132
Scanf.scanf "%c%c%c" (fun a b c ->
    Printf.printf "%c%c%c\n"
        (if a = '1' then '9' else if a = '9' then '1' else a)
        (if b = '1' then '9' else if b = '9' then '1' else b)
        (if c = '1' then '9' else if c = '9' then '1' else c)
)

Measured memory_bytes: 3744
#include <stdio.h>

int arr[100];

int main() {
	int len, tmp, swp_cnt = 0;
	scanf("%d", &len);
	for (int i = 0; i < len; i++) scanf("%d", &arr[i]);

	for (int i = 0; i < len; i++)
	{
		int min = i;
		for (int j = i+1; j < len; j++)
		{
			if (arr[min] > arr[j])
			{
				min = j;
			}
		}
		if (i != min) {
			tmp = arr[i];
			arr[i] = arr[min];
			arr[min] = tmp;
			swp_cnt++;
		}
	}

	printf("%d", arr[0]);
	for (int i = 1; i < len; i++)
	{
		printf(" %d", arr[i]);
	}
	printf("\n%d\n", swp_cnt);
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
 
int main()
{
    int a;
    string s;
    cin >> a >> s;
    if (a < 3200)
    {
        cout << "red" << endl;

    }
    else{
        cout << s << endl;
    }
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int a[]= new int[n];
		for(int i=0;i<n;i++) {
			a[i]=scan.nextInt();
		}
		scan.close();
		Arrays.sort(a);
		System.out.println(a[n-1]-a[0]);
	}
}

Measured memory_bytes: 21460
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 10000000000
using namespace std;
using ll = long long;
int main()
{
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;
    if(u==s){
        a--;
    }else{
        b--;
    }
    cout << a << " " << b << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
	long long P, C[500000];

	int N, Q;

	scanf("%d", &N);

	scanf("%lld", &P);

	scanf("%d", &Q);

	long long zenbugaishoku = 0;

	for (int i = 0; i < N; i++)
	{
		scanf("%lld", &C[i]);

		zenbugaishoku += C[i];

		C[i] = C[i] - (Q - i) * P;
	}

	long long *E = C + N;

	sort(C, E);

	long long Answer = zenbugaishoku;

	long long sum = zenbugaishoku;

	long long V = 2 * P;

	for (int i = 0; i < N; i++)
	{
		sum += V * i - C[i];

		Answer = max(sum, Answer);
	}

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

	return 0;
}

Measured memory_bytes: 6688
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication5
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string answer = "Christmas";
            for(int i = n; i-25 < 0;i++)
            {
                answer += " Eve";
            }
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <iomanip>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath>      // abs など
#include <numeric>    // accumulate, gcd など
#include <cassert>    // assert
#include <stdexcept>
#include <bitset>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
typedef long long ll;

//////////////// //////////////// //////////////// //////////////// ////////////////
//////////////// //////////////// //////////////// //////////////// ////////////////

// セグメント木
// seg.size() = 2*N
// [N,2*N)に列を格納, seg[1]が根
vector<int> seg;

// i番目(0-based)にaを加算
void seg_add(int i, int a)
{
    i += seg.size() / 2;
    seg[i] += a;
    while (i > 1)
    {
        i /= 2;
        seg[i] = seg[2 * i] + seg[2 * i + 1];
    }
}

// [l,r)の和
int seg_sum(int l, int r)
{
    l += seg.size() / 2;
    r += seg.size() / 2;
    int ret = 0;
    while (l < r)
    {
        if (l & 1)
        {
            ret += seg[l];
            l++;
        }
        if (r & 1)
        {
            r--;
            ret += seg[r];
        }
        l /= 2;
        r /= 2;
    }
    return ret;
}

// 閉区間[left,right](0-based), index番目(0-based)のクエリ
struct interval
{
    int left;
    int right;
    int index;
};

int main()
{
    // 高速な入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(15); // 浮動小数の表示の精度

    int n, q;
    cin >> n >> q;
    seg.resize(2 * n);
    vector<int> col_s(n);
    rep(pos, n)
    {
        cin >> col_s[pos];
        col_s[pos]--;
    }
    vector<interval> intervals(q);
    rep(i_q, q)
    {
        int l, r;
        cin >> l >> r;
        intervals[i_q] = { l - 1, r - 1, i_q };
    }
    sort(intervals.begin(), intervals.end(), [](interval x, interval y) {
        return x.right < y.right;
    });

    // pos_ball[color] : 一番右のcolor(0-based)の場所pos(0-based)
    vector<int> pos_ball(n, -1);
    vector<int> ans(q);
    int ii_q = 0;
    rep(pos, n)
    {
        // pos_ball の更新
        if (pos_ball[col_s[pos]] >= 0)
        {
            seg_add(pos_ball[col_s[pos]], -1);
        }
        pos_ball[col_s[pos]] = pos;
        seg_add(pos, 1);

        // ansに格納
        while (ii_q < q and intervals[ii_q].right == pos)
        {
            ans[intervals[ii_q].index] = seg_sum(intervals[ii_q].left, intervals[ii_q].right + 1);
            ii_q++;
        }
    }

    rep(i_q, q)
    {
        cout << ans[i_q] << '\n';
    }

    return 0;
}


Measured memory_bytes: 19348
#include<iostream>
using namespace std;
#include<string.h>
#define MAX 1000000

int A[MAX], head = 0, tail = 0;

void insert(int x) {
        A[tail] = x;
        tail++;
}

void dlt(int x) {
        int a, b = 0, i;
        for(i = tail - 1; i >= head; i--) {
                if(x == A[i]) {
                        a = i; b = 1; break;
                }
        }
        if(b == 1) {
                for(int j = i; j < tail; j++) A[j] = A[j+1];
                tail--;
        }
}

int main() {
        int n, c;
        string str;
        cin >> n;
        for(int i = 0; i < n; i++) {
                cin >> str;
                if(str == "insert") {
                        cin >> c;
                        insert(c);
                }
                else if(str == "delete") {
                        cin >> c;
                        dlt(c);
                }
                else if(str == "deleteFirst") tail--;
                else head++;
        }
        for(int j = tail - 1; j >= head; j--) {
                if(j != tail - 1) cout << " ";
                cout << A[j];
        }
        cout << endl;
        return 0;
}

Measured memory_bytes: 7060
#include<iostream>
#include<algorithm>
using namespace std;
#define MAXN 200000

int N;
int A[MAXN];

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

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
int dp[100010];
int a[100],p;
void f()
{
    int ans=1;
    p=0;
    for(int i=1;i<=5;i++)
    {
        ans*=9;
        a[p++]=ans;
    }
    ans=1;
    for(int i=1;i<=6;i++)
    {
        ans*=6;
        a[p++]=ans;
    }
    a[p++]=1;
    sort(a,a+p);
}
int main()
{
    int t,A;
    int i,j;
    f();
    while(scanf("%d",&t)==1)
    {
        for(i=1;i<=t;i++)
            dp[i]=INF;
        for(i=0;i<p;i++)
        {
            A=a[i];
            for(j=A;j<=t;j++)
                dp[j]=min(dp[j],dp[j-A]+1);
        }
        for(i=t;dp[i]>=INF;i--);
            printf("%d\n",dp[i]);
    }
    return 0;
}

Measured memory_bytes: 640
n, m = map(int, input().split())
alist = list(sorted(map(int, input().split())))
bc = []
total = 0
for _ in range(m):
  bc.append(tuple(map(int, input().split())))

lim = n-1
total = 0
ans = 0
for b, c in sorted(bc, key=lambda x: -x[1]):
  while lim >= 0 and alist[lim] >= c:
    ans += alist[lim]
    lim -= 1
    total += 1
  ans += c * min(b, n-total)
  total += min(b, n-total)
  if total == n:
    break
if total == n:
  print(ans)
else:
  print(ans + sum(alist[total:]))


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

int main(){
  ll l,r; cin >> l >> r;

  if(l / 2019 != r / 2019) {
    cout << 0 << endl;
    return 0;
  }

  l = l % 2019;
  r = r % 2019;
  int ans = 2019;

  for(int i = l; i < r; i++){
    for(int j = i + 1; j <= r; j++){
      int tmp = (i * j)%2019;
      //cout << tmp << endl;
      ans = min(tmp,ans);
    }
  }

  cout << ans << endl;
}



Measured memory_bytes: 256
line=input()
data=input()
line=line.split()
data=data.split()
num=0
if int(line[0])<=int(line[1]):
    print(0)
else:
    data=[int(s) for s in data]
    data_sorted=data.sort()
    for i in range(len(data)-int(line[1])):
        num+=data[i]
    print(num)

Measured memory_bytes: 26024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<double, double> pd;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pld;
 
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pd> vpd;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;
ll x,y;
ll inv[10000100];
ll FactorialInv[10000100];
ll Factorial[10000100];

ll mymod(ll a,ll b){
    a%=MOD;
    ll result=1;
    while(b>0){
        if(b&1){
            result=(result*a)%MOD;
        }
        a=(a*a)%MOD;
        b>>=1;
    }
    return result;
    
}
ll modInverse(ll n){
    return mymod(n,MOD-2);
}

void init_combination(){
    const int MAX = 10000002;   //1e6+2
    Factorial[0]=1;
    inv[0]=1;
    for(int i=1;i<=MAX;i++){
        Factorial[i]=(Factorial[i-1]*i)%MOD;
    }
    FactorialInv[MAX]=modInverse(Factorial[MAX]);
    for(int i=MAX-1;i>=0;i--){
        FactorialInv[i]=FactorialInv[i+1]*(i+1)%MOD;
    }
    for(int i=1;i<=MAX;i++){
        inv[i]=(FactorialInv[i]*FactorialInv[i-1])%MOD;
    }
}

ll combination(ll n,ll k){
    if(n==k||k==0){
        return 1;
    }
    if(n<k){
        return 0;
    }
    ll ans=(Factorial[n]*FactorialInv[k])%MOD;
    ans=(ans*FactorialInv[n-k])%MOD;
    return ans;
}


int main(){
    int N,T;
    cin>>N>>T;
    vpi ab(N);
    F0R(i,N){
        cin>>ab[i].first>>ab[i].second;
    }
    sort(all(ab));
    vvi dp(N+1,vi(T+1,0));
    int res=0;
    F0R(i,N){
        F0R(j,T){
            if(j+ab[i].first<T){
                dp[i+1][j+ab[i].first]=max(dp[i+1][j+ab[i].first],dp[i][j]+ab[i].second);
            }
            dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
            res=max(res,dp[i][j]+ab[i].second);
        }
    }
    out(res);
}


Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1000000007;

void solve() {
  int r, d, xtt;
  cin >> r >> d >> xtt;

  int x = xtt;

  rep(i,10) {
    x = r * x - d;
    cout << x << endl;
  }
}

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

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

int main()
{
    int n, Y;
    cin >> n >> Y;
    for(int x=0; x<=n; x++)
    {
        for(int y=0; y<=n-x; y++)
        {
            int z = n-x-y;
            if(x*10000 + y*5000 + z*1000 == Y)
            {
                cout << x << ' ' << y << ' ' << z << endl;
              	return 0;
            }
        }
    }
  	cout << -1 << ' ' << -1 << ' ' << -1;
}


Measured memory_bytes: 256