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

using namespace std;

int main() {
  int n;
  long long int k, kk = 0;
  cin >> n >> k;
  long long int a[123456];
  memset(a, 0, sizeof a);
  int x, y;
  while (n--) {
    cin >> x >> y;
    a[x] += y;
  }
  for (int i = 1; i < 123456; i++) {
    kk += a[i];
    if (kk >= k) {
      cout << i << endl;
      break;
    }
  }
}


Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
using namespace std;
string n;
int k;
bool ok[10];
int len;
vector<int> ans;
int mn=10;
void solve(int pl,bool flag){
	if (pl==len){
		if (ans.size()==len){
			for (int i=0;i<ans.size();i++){
				cout<<ans[i];
			}
			exit(0);
		}
	//	cout<<"pl="<<pl<<endl;
	//	exit(0);
	}
	if (flag==0){
		if (ok[n[pl]-'0']){
			ans.push_back(n[pl]-'0');
			//cout<<n[pl]-'0';
			solve(pl+1,flag);
		}
		else{
			for (int i=n[pl]-'0'+1;i<10;i++){
				if (ok[i]){
					ans.push_back(i);
					//cout<<i;
					solve(pl+1,1);
				}
			}
		}
	}
	else{
		ans.push_back(mn);
	//	cout<<0;
		solve(pl+1,flag);
	}
}
int main(){
	cin>>n>>k;
	memset(ok,1,sizeof(ok));
	for (int i=1;i<=k;i++){
		int x;
		cin>>x;
	//	cout<<x<<endl;
		ok[x]=false;
	}
	for (int i=0;i<10;i++){
		if (ok[i]){
			mn=min(mn,i);
		}
	}
	len=n.size();
	solve(0,0);
	for (int i=1;i<10;i++){
		if (ok[i]){
			cout<<i;
			break;
		}
	}
	for (int i=0;i<len;i++){
		cout<<mn;
	}
	return 0;
}

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

struct Edge {
  int from, to, cost;
  Edge() : from(0), to(0), cost(0) { }
  Edge(int from, int to, int cost) : from(from), to(to), cost(cost) { }
};

struct UnionFind {
  vector<int> data;

  UnionFind(int n) : data(n, -1) { }

  bool same(int i, int j) {
    return root(i) == root(j);
  }

  int root(int i) {
    return data[i] < 0 ? i : data[i] = root(data[i]);
  }

  void join(int i, int j) {
    data[root(i)] += data[root(j)];
    data[root(j)] = root(i);
  }
};

int main() {
  for(int n, m; cin >> n >> m && n; ) {
    vector<Edge> edges(m);

    for(int i = 0; i < m; i++) {
      cin >> edges[i].from >> edges[i].to >> edges[i].cost;
    }

    sort(edges.begin(), edges.end(), [](const Edge& a, const Edge& b) {
      return a.cost < b.cost;
    });

    int cost = 0;
    UnionFind uf(n);

    for(auto it = edges.begin(); it != edges.end(); it++) {
      if(!uf.same(it->from, it->to)) {
        uf.join(it->from, it->to);
        cost += it->cost;
      }
    }

    cout << cost << endl;
  }
}

Measured memory_bytes: 2928
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	x := 0
	ans := 0
	for i := 0; i < n; i++ {
		a := scanInt()
		if a > 0 {
			if x > a {
				ans += a
				x = 0
			} else {
				ans += x
				x = a - x
				if x >= 2 {
					ans += x / 2
					x %= 2
				}
			}
		} else {
			x = 0
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 2304
#include<stdio.h>

int main() {
	long long N, i, G = 15, A = 16, T = 16, C = 14, GB = G, AB = A, TB = T, CB = C, AC = 3, GA = 4, AG = 4,AGX = 3, SUM = 61;
	long long MAXNUM = 1000000007;
	scanf("%lld", &N);
	for (i = 3; i < N; i++) {
		G = (SUM - AC + MAXNUM)%MAXNUM;
		A = SUM;
		T = SUM;
		C = (SUM - AG - GA - AGX+MAXNUM*3)%MAXNUM;
		AGX = AG * 3;
		AC = AB - GA;
		GA = GB;
		AG = AB;
		GB = G; AB = A; TB = T; CB = C;
		SUM = (A+T+G+C) % MAXNUM;
	}
	printf("%lld\n", SUM);
	return 0;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int w,d;
int wh[11],dh[11];

int main(){
	cin.sync_with_stdio(false);
	while(1){
		cin>>w>>d;
		if(w==0)break;
		rep(i,w)cin>>wh[i];
		rep(i,d)cin>>dh[i];
		sort(wh,wh+w);
		sort(dh,dh+d);
		int res=0;
		repl(h,1,21){
			int wn=upper_bound(wh,wh+w,h)-lower_bound(wh,wh+w,h);
			int dn=upper_bound(dh,dh+d,h)-lower_bound(dh,dh+d,h);
			res+=max(wn,dn)*h;
		}
		cout<<res<<endl;
	}
	return 0;
}

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

int main(){
    int N, K, S=0;
    int A[120000];
    int ans = 0;

    cin >> N >> K;

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

    if (K == 2)
        cout << N-1 << endl; 

    else if (N % (K-1) > 1)
        cout << (N/(K-1))+1 << endl; 
    else
        cout <<  N/(K-1) << endl;
}



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

int main(){
  int n,y;
  cin>>n>>y;
  for(int i=0;i<=n;++i){
    for(int j=0;j<=n-i;++j){
      if(y==i*10000+j*5000+(n-i-j)*1000){
        cout<<i<<" "<<j<<" "<<(n-i-j);
        return 0;
      }
    }
  }
  cout<<"-1 -1 -1";
  return 0;
}


Measured memory_bytes: 256
"use strict";
const main = input => {
    const n = parseInt(input[0], 10);
    let d = input[1].split(' ').map(p => Number(p));
    d = d.sort((p,q) => p-q);
    console.log(d[n/2]-d[n/2-1]);    
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));


Measured memory_bytes: 28284
import sys

def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    A = [int(a) for a in input().split()]
    sumA = sum(A)
    D = []
    for i in range(1, sumA + 1):
        if i ** 2 > sumA: break
        if sumA % i == 0:
            D.append(i)
            if i ** 2 != sumA: D.append(sumA // i)
    D.sort(reverse = True)
    for i, d in enumerate(D):
        L = []
        count = 0
        for a in A:
            if a % d > 0: 
                L.append(a % d)
                count += 1
        L.sort()
        if count > 0:
            minus, plus = [0] * count, [0] * count
            minus[0] = L[0]
            plus[count - 1] = d - L[count - 1]
            for i in range(1, count):
                minus[i] = minus[i-1] + L[i]
                plus[count - 1 - i] = plus[count - i] +  d - L[count - 1 - i]
            Op = K + 1
            for i in range(count - 1):
                if abs(minus[i] - plus[i + 1]) % d == 0: Op = min(Op, max(minus[i], plus[i + 1]))
            if Op <= K:
                print(d)
                break
    else: print(1)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define mx 100009
ll ar[mx][3];
ll mem[mx][3];
ll n;

ll dp(ll ind,ll f){
    if(ind>=n) return 0;
    else if(mem[ind][f]!=-1) return mem[ind][f];

    ll ans=0;
    if(f==0){
        ll x=ar[ind+1][1]+dp(ind+1,1);
        ll y=ar[ind+1][2]+dp(ind+1,2);
        ans=max(x,y);
    }
    else if(f==1){
        ll x=ar[ind+1][0]+dp(ind+1,0);
        ll y=ar[ind+1][2]+dp(ind+1,2);
        ans=max(x,y);
    }
    else{
        ll x=ar[ind+1][1]+dp(ind+1,1);
        ll y=ar[ind+1][0]+dp(ind+1,0);
        ans=max(x,y);
    }
    return mem[ind][f]=ans;
}

int main()
{
    memset(mem,-1,sizeof(mem));
    cin>>n;
    for(ll i=1;i<=n;i++){
        cin>>ar[i][0]>>ar[i][1]>>ar[i][2];
    }
    ll a=ar[1][0]+dp(1,0);
    ll b=ar[1][1]+dp(1,1);
    ll c=ar[1][2]+dp(1,2);
    cout<<max(a,max(b,c))<<endl;
    return 0;
}


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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 55556;

int N;

struct Eratosthenes {
  vector< bool > prime;
  Eratosthenes(int _size) {
    init(_size);
  }

  void init(int n) {
    prime.resize(n + 1);
    REP(i, prime.size()) prime[i] = true;
    prime[0] = prime[1] = false;
    for(int i = 2; i < sqrt(n); i++) {
      if (prime[i]) {
        for (int j = 0; i * (j + 2) < n; j++) {
	  prime[i * (j + 2)] = false;
	}
      }
    }
  }
};


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

  Eratosthenes e(MAX_N);

  cin >> N;

  int cnt = 0;
  vector< int > list;
  REP(i, MAX_N) {
    int tmp = 5 * i + 1;
    if (e.prime[tmp]) {
      cnt++;
      list.emplace_back(tmp);
    }
    if (cnt > 55) {
      break;
    }
  }

  // int sum = 0;
  REP(i, N) {
    cout << list[i];
    // sum += list[i];
    if (i < N - 1) cout << " ";
    else cout << endl;
  }

  // debug(sum);
  
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdarg.h>
#include <assert.h>
#include <ctype.h>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/filter/gzip.hpp>
#include <boost/iostreams/device/file_descriptor.hpp>

using namespace std;
typedef long long int lli;
typedef vector<int> iv;
typedef vector<bool> bv;
typedef vector<string> sv;
typedef vector<long long int> llv;
typedef vector<double> dv;

#define sor_(vec) sort(vec.begin(),vec.end())
#define rev_(vec) reverse(vec.begin(),vec.end())
#define rep(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define reps(i,n,s) for(int i=static_cast<int>(s);i<static_cast<int>(n);i++)
#define isposi(num) if(num>0)
const long long mod = 1000000007;

template<typename TypeInt>
std::string Itoa(const TypeInt v, int base)
{
    static const char table[] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    string ret;
    static numeric_limits<TypeInt> t;
    TypeInt n = v;
    if (t.is_signed) {
        if (v < 0) n *= -1;
    }

    while (n >= base) {
        ret += table[n%base];
        n /= base;
    }
    ret += table[n];
    if (t.is_signed) {
        if (v < 0 && base == 10) ret += '-';
    }
    std::reverse(ret.begin(), ret.end());

    return ret;
}

int upf(double num){
    if(num-(int)num>0)return (int)num+1;
    else return num;
}

void printm(char const *format,...){
    va_list arguments;
    va_start(arguments,format);
    unsigned index=0;
    while (format[index]!='\0') {
        if(format[index]=='%'){
            index++;
            if(format[index]=='d')printf("%d",va_arg(arguments, int));
            else if(format[index]=='c')printf("%c",va_arg(arguments, int));
            else if(format[index]=='x')printf("%x",va_arg(arguments,int));
            else if(format[index]=='o')printf("%o",va_arg(arguments,int));
            else if(format[index]=='f')printf("%f",va_arg(arguments, double));
            else if(format[index]=='s')printf("%s",va_arg(arguments, char const *));
            else if(format[index]=='p')printf("%p",va_arg(arguments,void*));
            else if(format[index]=='y')printf("Yes");
            else if(format[index]=='n')printf("No");
            else if(format[index]=='%')printf("%%");
            else assert(!"Unknown format with %.");
        }
        else printf("%c",format[index]);
        index++;
    }
    va_end(arguments);
    return;
}

struct Chara{
    int hp;
    int sp;
};
bool pairCompare(const pair<int,int>& firstElof, const pair<int,int>& secondElof)
{
    return firstElof.second > secondElof.second;
}

int main(void){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    size_t k;
    string str,ans;
    cin>>k>>str;
    if(str.length()>k)cout<<str.substr(0,k)<<"...";
    else cout<<str;
    return 0;
}


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

void bubblesort(int v[],int n){
  int temp;
  for(int i = 0; i < n; i++){
    for(int j = n-1; j > i; j--){
      if(v[j] < v[j-1]){
        temp = v[j];
        v[j] = v[j-1];
        v[j-1] = temp;
      }
    }
  }
}

int main(void){
  int n; cin >> n;
  int v[n];
  for(int i= 0; i < n; i++){
    cin >> v[i];
  }
  bubblesort(v,n);
  double ans = v[0];
  for(int i=1; i < n; i++){
    ans = (ans +v[i])/2;
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 384
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    x,y = LI()
    ans = 0
    f = [300000,200000,100000,0]
    if x == 1 and y == 1:
        print(1000000)
    else:
        ans = f[min(3,x-1)]+f[min(3,y-1)]
        print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 39408
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorders
{
	public class Program
	{
		static void Main(string[] args)
		{
			var nw = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			int n = nw[0];
			int w = nw[1];
			var knups = new Knup[n];
			for (int i = 0; i < n; i++) {
				var temp = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
				knups[i] = new Knup { W = temp[0], V = temp[1] };
			}

			int w0 = knups[0].W;
			var c = new int[4];
			for (int i = 0; i < n; i++) {
				c[knups[i].W - w0]++;
			}

			for (int i = 0; i < 4; i++) {
				c[i]++;
			}

			var dp = new int[c[0], c[1], c[2], c[3]];
			for (int i = 0; i < n; i++) {
				int wi = knups[i].W - w0;

				var dst = new int[c[0], c[1], c[2], c[3]];
				for (int j0 = 0; j0 < c[0]; j0++) {
					for (int j1 = 0; j1 < c[1]; j1++) {
						for (int j2 = 0; j2 < c[2]; j2++) {
							for (int j3 = 0; j3 < c[3]; j3++) {
								if (dp[j0, j1, j2, j3] == 0) {
									continue;
								}

								dst[j0, j1, j2, j3] = Math.Max(
									dst[j0, j1, j2, j3],
									dp[j0, j1, j2, j3]);
								switch (wi) {
									case 0:
										dst[j0 + 1, j1, j2, j3] = Math.Max(
											dst[j0 + 1, j1, j2, j3],
											dp[j0, j1, j2, j3] + knups[i].V);
										break;
									case 1:
										dst[j0, j1 + 1, j2, j3] = Math.Max(
											dst[j0, j1 + 1, j2, j3],
											dp[j0, j1, j2, j3] + knups[i].V);
										break;
									case 2:
										dst[j0, j1, j2 + 1, j3] = Math.Max(
											dst[j0, j1, j2 + 1, j3],
											dp[j0, j1, j2, j3] + knups[i].V);
										break;
									case 3:
										dst[j0, j1, j2, j3 + 1] = Math.Max(
											dst[j0, j1, j2, j3 + 1],
											dp[j0, j1, j2, j3] + knups[i].V);
										break;
								}
							}
						}
					}
				}

				switch (wi) {
					case 0:
						dst[1, 0, 0, 0] = Math.Max(
							dst[1, 0, 0, 0],
							knups[i].V);
						break;
					case 1:
						dst[0, 1, 0, 0] = Math.Max(
							dst[0, 1, 0, 0],
							knups[i].V);
						break;
					case 2:
						dst[0, 0, 1, 0] = Math.Max(
							dst[0, 0, 1, 0],
							knups[i].V);
						break;
					case 3:
						dst[0, 0, 0, 1] = Math.Max(
							dst[0, 0, 0, 1],
							knups[i].V);
						break;
				}

				dp = dst;
			}

			int ans = 0;
			for (int j0 = 0; j0 < c[0]; j0++) {
				for (int j1 = 0; j1 < c[1]; j1++) {
					for (int j2 = 0; j2 < c[2]; j2++) {
						for (int j3 = 0; j3 < c[3]; j3++) {
							long weight = (long)w0 * j0
								+ (long)(w0 + 1) * j1
								+ (long)(w0 + 2) * j2
								+ (long)(w0 + 3) * j3;
							if (weight <= w) {
								ans = Math.Max(ans, dp[j0, j1, j2, j3]);
							}
						}
					}
				}
			}

			Console.WriteLine(ans);
		}

		struct Knup
		{
			public int W { get; set; }
			public int V { get; set; }
		}
	}
}

Measured memory_bytes: 32556
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
ll MOD = 998244353;
const ll N = 1e7+10;
ll f[N], rf[N];
ll inv(ll x) {
    ll res = 1;
    ll k = MOD - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % MOD;
        y = (y * y) % MOD;
        k /= 2;
    }
    return res;
}
void init() {
    f[0] = 1;
    for(int i = 1; i < N; i++) f[i] = (f[i - 1] * i) % MOD;
    rf[N - 1] = inv(f[N - 1]);
    for(int i = N-2; i >= 0; i--) rf[i] = (rf[i + 1] * (i + 1)) % MOD;
}
ll C(int n, int k) {
    if(k < 0 || n < k) return 0;
    ll a = f[n]; // = n!
    ll b = rf[n-k]; // = (n-k)!^(-1)
    ll c = rf[k]; // = k!^(-1)
    ll bc = (b * c) % MOD;
    return (a * bc) % MOD;
}
ll p(int n, int k) {
    if (k < 0 || n < k) return 0;
    ll a = f[n]; // = n!
    ll b = rf[n - k]; // = (n-k)!^(-1)
    return (a * b) % MOD;
}
ll H(int n, int k) {
    if (n == 0 && k == 0) return 1;
    return C(n + k - 1, k);
}
ll mod_pow(ll x, ll n)
{
    ll res = 1;
    while(n > 0)
    {
        if(n & 1)
        {
            res = res * x % MOD;
        }
        x = x * x % MOD;
        n >>= 1;
    }
    return res;
}

int main()
{
    init();
    int n, m, k;
    cin >> n >> m >> k;
    ll ans = 0;
    for(int i = 0; i <= k; i++)
    {
        ll tmp = (C(n-1, i) * m) % MOD;
        tmp = tmp * mod_pow(m-1, n-i-1) % MOD;
        ans = (ans + tmp) % MOD;
    }
    ans = (ans + MOD) % MOD;
    cout << ans << endl;
}



Measured memory_bytes: 159796
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(fst) (int)(fst).size()
#define forn(i, n) for (ll i = 0; i < ll(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(fst) fst.begin(), fst.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s, t;
    cin >> s >> t;
    cout << t << s << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
using namespace std;
// your code goes here
int n,m,k,tmp;
deque<int> lib;

void shuffle(){
	deque<int> a,b;
	for(int i=0;i<n;i++){
	a.push_back(lib[i]);
	}
	for(int i=n;i<2*n;i++){
	b.push_back(lib[i]);
	}
	lib.clear();
	for(int i=0;i<n;i++){
		lib.push_back(a.front());
		lib.push_back(b.front());
		a.pop_front();
		b.pop_front();
	}
}
int main() {
	cin >> n >> m;
	for(int i=1;i<=n*2;i++)
	lib.push_back(i);
	for(int i=0;i<m;i++){
		cin >>k;
		if(k==0)
		shuffle();
		else
		for(int j=0;j<lib.size()-k;j++){
			tmp=lib.back();
			lib.pop_back();
			lib.push_front(tmp);
		}
	}
	for(int i=0;i<lib.size();i++)
	cout << lib[i] << endl;
	return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
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;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  string s;
  cin>>s;
  vector<Int> dp1(n+1,0),dp2(n+1,0);
  for(Int i=0;i<n;i++){
    dp1[i+1]=dp1[i]+(s[i]=='#');    
  }
  for(Int i=n;i>0;i--){
    dp2[i-1]=dp2[i]+(s[i-1]=='.');
  }
  Int ans=dp1[0]+dp2[0];
  for(Int i=0;i<=n;i++){
    chmin(ans,dp1[i]+dp2[i]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3716
n = int(input())
A = []
X_Y = [[] for _ in range(n)]

for i in range(n):
    a = int(input())
    A.append(a)
    for j in range(a):
        x, y = map(int, input().split())
        tap = (x-1, y)
        X_Y[i].append(tap)

ans = 0

#まずはbitの列挙、一つずつ探索する
for bit in range(1<<n):
    check = str(bin(bit)).count('1')
    for i in range(n):
        #各bitが1の場合は正直者とする、0の場合は関係なし
        if (bit>>i)&1 == 1 :
            #X_Y[i]の中身が正直者には1, 不明者には0が向いているかを確認
            count = 0
            for obj in X_Y[i]:
                #対象が嘘つきの場合
                if (obj[1] == 0) and (bit>>obj[0]&1 == 0):
                    count += 1
                #対象が正直者の場合
                elif (obj[1] == 1) and (bit>>obj[0]&1 == 1):
                    count += 1
                else:
                    pass

            #正直者の発言が正しい場合
            if count == A[i]:
                check -= 1
            # #正しくない場合は次のbitへ向かう
            # else:
            #     break
    #全員の成否を確かめた後に、正直者の発言がすべて正しいか判定
    if check == 0:
        can = str(bin(bit)).count('1')
        #正直者の発言が正しい場合はansを比較
        if ans <= can:
            ans = can
print(ans)


            

                



Measured memory_bytes: 3064
import math
n=int(input())
x=math.floor((n*25)/27)
x=int(x)
for i in range(x,n+1):
    if math.floor(i*1.08)==n:
        print(i)
        break
    elif math.floor(i*1.08)>n:
        print(":(")
        break
        
        
        




Measured memory_bytes: 2940
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

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

int main()
{
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i, n) cin >> d[i];

    sort(d.begin(), d.end());

    if (d[n / 2] == d[n / 2 -1]) cout << 0 << endl;
    else cout << d[n / 2] - d[n / 2 - 1] << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int X;
    cin>>X;
    int maxv=0;
    int num=0;
    for(int i=1;i<=X;i++){
        num=i*i;
        if(i!=1){
        while(num<=X){
            if(num*i>X){
                break;
            }
            num*=i;
        }
        }
            if(num<=X){
            maxv=max(maxv,num);
        }
    }
    cout<<maxv<<endl;
}

Measured memory_bytes: 256
N = int(input())
mod = 10 ** 9 + 7

combi_all = 10 ** N
not0 = 9 ** N
not9 = 9 ** N
not09 = 8 ** N
ans = combi_all - not0 - not9 + not09

if ans >= mod:
  print(int(ans % mod))
else:
  print(ans)

Measured memory_bytes: 11596
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#define INF 1000000000

using namespace std;

queue<pair<int, int>> que;
int h, w;

void Search(vector<vector<int>> &d) {
	if (que.empty())
		return;
	int i = que.front().first, j = que.front().second;
	if (i > 0 && d[i - 1][j] == INF) {
		que.push(make_pair(i - 1, j));
		d[i - 1][j] = d[i][j] + 1;
	}
	if (j > 0 && d[i][j - 1] == INF) {
		que.push(make_pair(i, j - 1));
		d[i][j - 1] = d[i][j] + 1;
	}
	if (i < h - 1 && d[i + 1][j] == INF) {
		que.push(make_pair(i + 1, j));
		d[i + 1][j] = d[i][j] + 1;
	}
	if (j < w - 1 && d[i][j + 1] == INF) {
		que.push(make_pair(i, j + 1));
		d[i][j + 1] = d[i][j] + 1;
	}
	que.pop();
	Search(d);
}

int main(void) {
	int i, j, ans = 0;
	cin >> h >> w;
	vector<vector<int>> d(h, vector<int>(w, INF));
	vector<string> s(h);
	for (i = 0; i < h; i++) {
		cin >> s[i];
		for (j = 0; j < w; j++) {
			if (s[i][j] == '#') {
				d[i][j] = 0;
				que.push(make_pair(i, j));
			}
		}
	}
	Search(d);
	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++)
			ans = max(ans, d[i][j]);
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 91536
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    from math import ceil
    K=int(input())
    X,Y=map(int,input().split())
    # defaultは 0 <= Y <= X
    def trans(u,v):
        if(abs(X)<abs(Y)): u,v=v,u
        if(X<0): u=-u
        if(Y<0): v=-v
        return u,v

    x,y=max(abs(X),abs(Y)),min(abs(X),abs(Y))
    if(K%2==0 and (X+Y)&1):
        print(-1)
        return

    # x+y<K
    if(x+y<K and (x+y)&1):
        print(3)
        print(*trans(x,-K+x))
        print(*trans(x+(K+x-y)//2,-(K-x-y)//2))
        print(*trans(x,y))
        return
    if(x+y<K and (not (x+y)&1)):
        print(2)
        print(*trans((x+y)//2,-K+(x+y)//2))
        print(*trans(x,y))
        return

    # x+y=K
    if(x+y==K):
        print(1)
        print(*trans(x,y))
        return
    
    # x+y>K
    c=(-x-y)%K
    n=ceil((x+y)/K)+(c&1)
    l=(K*n-x-y)//2
    print(n)
    nx,ny=K-l,-l
    print(*trans(nx,ny))
    while(nx+K<=x):
        nx+=K
        print(*trans(nx,ny))
    nx,ny=x,ny+(K-(x-nx))
    print(*trans(nx,ny))
    while(ny+K<=y):
        ny+=K
        print(*trans(nx,ny))
resolve()

Measured memory_bytes: 54232
N, M = map(int, input().split())
H = list(map(int, input().split()))
root = [list(map(int, input().split())) for _ in range(M)]

is_min = [0 for _ in range(N)]
for i in range(M):
    A = root[i][0] - 1
    B = root[i][1] - 1

    if H[A] > H[B]:
        is_min[B] = 1

    elif H[A] == H[B]:
        is_min[A] = 1
        is_min[B] = 1

    else:
        is_min[A] = 1

print(N - sum(is_min))

Measured memory_bytes: 31880
#include "bits/stdc++.h"
using namespace std;

int main() {
	unsigned long long int N, A, B;
	cin >> N >> A >> B;
	cout << setprecision(20);
	if ((B - A) % 2 == 0) {
		cout << (B - A) / 2 << endl;
	}
	else {
		if (N - B >= A) {
				cout << (B - (A - 1)) / 2 + (A - 1) << endl;
		}
		else if (N - B < A) {
			cout << (N - (A + (N - B) + 1)) / 2 + (N - B) + 1 << endl;
		}
	}
}

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

int main() 
{
    int n, m;
    cin >> n >> m;
    map<int, int> mp;
    for (int i=0; i<n; i++)
    {
        int k;
        cin >> k;
        for (int j=0; j<k; j++)
        {
            int a;
            cin >> a;
            mp[a]++;
        }
    }
    int sum = 0;
    for (auto x:mp)
    {
        if (x.second == n)
            sum++;
    }
    cout << sum;
    return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl); 
#define cop(a) for(auto x:(a)){cout << x << endl;}


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
double distance(double x1, double y1, double x2, double y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        // comment this out when you use scanf or printf
        // cin.tie(0); ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(15);
    };
}fastio;

int main(){
    
    double a, b, c, d, e, f;
    scanf("%lf%lf%lf%lf%lf%lf", &a, &b, &c, &d, &e, &f);
    double A = distance(a, b, c, d);
    double B = distance(c, d, e, f);
    double C = distance(a, b, e, f); 
    double r = abs((e-a)*(d-b)-(c-a)*(f-b))/(A+B+C);
    double ok = 5000, ng = -1;
    double x = (ok+ng)/2.0;
    double m = max({A, B, C});
    while(abs(m*(r-x)/r-2*x) > 1e-12){
        x = (ok+ng)/2.0;
        if(m*(r-x)/r-2*x < 0) ok = x;
        else ng = x;
    }
    ppp(ok);  
   
    return 0;
}


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

template <class T, class F = multiplies<T>>
T power(T a, long long n, F op = multiplies<T>(), T e = {1}) {
  assert(n >= 0);
  while (n) {
    if (n & 1) e = op(e, a);
    if (n >>= 1) a = op(a, a);
  }
  return e;
}

template <unsigned M> struct modular {
  using m = modular;
  unsigned v;
  modular(long long a = 0) : v((a %= M) < 0 ? a + M : a) {}
  m operator-() const { return m() -= *this; }
  m& operator+=(m r) { if ((v += r.v) >= M) v -= M; return *this; }
  m& operator-=(m r) { if (v < r.v) v += M; v -= r.v; return *this; }
  m& operator*=(m r) { v = (uint64_t)v * r.v % M; return *this; }
  m& operator/=(m r) { return *this *= power(r, M - 2); }
  friend m operator+(m l, m r) { return l += r; }
  friend m operator-(m l, m r) { return l -= r; }
  friend m operator*(m l, m r) { return l *= r; }
  friend m operator/(m l, m r) { return l /= r; }
  friend bool operator==(m l, m r) { return l.v == r.v; }
  friend string to_string(m a) { return to_string(a.v); }
};

constexpr long long mod = 1e9 + 7;
using mint = modular<mod>;

vector<mint> fact, inv_fact, minv;
void prepare(int n) {
  fact.resize(n + 1), inv_fact.resize(n + 1), minv.resize(n + 1);
  for (int i = 0; i <= n; ++i) fact[i] = i ? i * fact[i - 1] : 1;
  inv_fact[n] = power(fact[n], mod - 2);
  for (int i = n; i; --i) inv_fact[i - 1] = i * inv_fact[i];
  for (int i = 1; i <= n; ++i) minv[i] = inv_fact[i] * fact[i - 1];
}
mint binom(int n, int k) {
  if (k < 0 or k > n) return 0;
  return fact[n] * inv_fact[k] * inv_fact[n - k];
}
template<> mint& mint::operator/=(mint r) {
  return *this *= r.v < minv.size() ? minv[r.v] : power(r, mod - 2);
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  prepare(2 * n);
  if (k >= n) {
    cout << binom(2 * n - 1, n).v << '\n';
    exit(0);
  }
  mint res;
  for (int i = 0; i <= k; ++i) {
    res += binom(n, i) * binom(i + (n - i - 1), i);
  }
  cout << res.v << '\n';
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <deque>
#include <numeric>
#include <utility>
using namespace std;

void solve(long long N, std::vector<long long> a){
    auto l=a[0];
    auto r=accumulate(a.begin()+1, a.end(), 0l);
    auto ans = abs(l-r);
    for(int i=1; i<N-1; i++){
        l+=a[i];
        r-=a[i];
        ans = min(ans, abs(l-r));
    }
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;
struct Edge{ll from, to, cost;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  string a, b;
  cin >> a >> b;
  ll n = stoi(a+b);
  bool ans = false;
  rep(i, 1000){
    ans = ans or(i*i)==n;
  }

  cout << (ans?"Yes":"No");
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        // 整数の入力
        // final int a = sc.nextInt();
        // 文字列の入力
        // final String s1 = sc.next();
        final int a = sc.nextInt();
        final int b = sc.nextInt();
        sc.close();
        int result = a * b;
        if (a >= 10 || b >= 10) {
            result = -1;
        }

        System.out.println(result);
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 998244353

using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int N; cin >> N;
	string s; cin >> s;
	for (int p = 0; p < 4; p++) {
		int flag =  0;
		vector<int> ani(N, 2);
		int temp = p;
		ani[N - 1] = temp % 2;
		temp /= 2;
		ani[1] = temp % 2;
		if (ani[N - 1] == ani[1])
			ani[0] = (s[0] == 'o' ? 0 : 1);
		else
			ani[0] = (s[0] == 'x' ? 0 : 1);
		for (int i = 1; i < N - 2; i++) {
			if (ani[i] == 0 )
				ani[i + 1] = (s[i] == 'o' ? ani[i - 1] : (ani[i - 1] + 1) % 2);
			else if (ani[i] == 1)
				ani[i + 1] = (s[i] == 'o' ? (ani[i - 1] + 1) % 2 : ani[i - 1]);
		}

		if (ani[N - 2] == 0) {
			if (s[N - 2] == 'o' && ani[N - 3] == ani[N - 1])
				flag++;
			else if (s[N - 2] == 'x' && ani[N - 3] != ani[N - 1])
				flag++;
		}
		else if (ani[N - 2] == 1) {
			if (s[N - 2] == 'o' && ani[N - 3] != ani[N-1])
				flag++;
			else if (s[N - 2] == 'x' && ani[N - 3] == ani[N-1])
				flag++;
		}
		if (ani[N - 1] == 0) {
			if (s[N - 1] == 'o' && ani[N - 2] == ani[0])
				flag++;
			else if (s[N - 1] == 'x' && ani[N - 2] != ani[0])
				flag++;
		}
		else if (ani[N - 1] == 1) {
			if (s[N - 1] == 'o' && ani[N - 2] != ani[0])
				flag++;
			else if (s[N - 1] == 'x' && ani[N - 2] == ani[0])
				flag++;
		}
		if (flag==2) {
			for (int i = 0; i < N; i++)
				cout << (ani[i] == 0 ? 'S' : 'W');
			cout << endl;
			break;
		}
		if (flag != 2 && p == 3) cout << -1 << endl;
	}
	
}


Measured memory_bytes: 1016
#include <bits/stdc++.h>
using namespace std;
#define inf 1e9
#define int long long

signed main(){
  double d,e;
  while(1){
    cin>>d>>e;
    if(d==0&e==0)break;

    double temp=inf;
    for(int i=0;i<=d/2;i++){
      double ret=d-i;
      double t=(d-i)*(d-i)+i*i;
      temp=min(temp,abs(sqrt(t)-e));
    }
    cout<<temp<<endl;
  }
}

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

int main() {
  int A, B;
  cin >> A >> B;

  if (A == 1) A = 14;
  if (B == 1) B = 14;

  cout << ((A > B) ? "Alice" : (A < B) ? "Bob" : "Draw") << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int baris,kolom,n,i= 0;
    int tamp,count =0;
    scanf("%d %d %d",&baris, &kolom, &n);
    if(baris>kolom)
	{
        tamp=baris;
    }else
	{
        tamp=kolom;
    }
    for(i=0;i<n;i=i+tamp)
	{
        count++;
    }
    printf("%d",count);
    
    
    return 0;
}

Measured memory_bytes: 1736
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=998244353;
const ll MAX_N=500010;
const ll INF=100100100100100;

int main(){
    int n;
    cin>>n;
    vector< set<string> > ss(n);
    ss[0].insert("a");
    for(int i=0;i<n-1;i++){
        for(string s:ss[i]){
            char maxchar='a';
            for(char c:s) maxchar=max(maxchar, c);
            maxchar++;
            for(char c='a';c<=maxchar; c++){
                ss[i+1].insert(s+c);
            }
        }
    }
    for(string s:ss[n-1]) cout<<s<<endl;
    
}


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

int main(void){
    int a,b = 0;
    char c;
    cin >> a;
    for(int i = 0;i < a;i++){
        cin >> c;
        if(c == 'Y')b++;
    }
    if(b == 0)cout << "Three";
    else cout << "Four";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using std::cin;
using std::cout;



int main(int argc, char* argv[])
{
  std::ios::sync_with_stdio(false);
  cin.tie(nullptr);

  std::string s;
  cin >> s;

  const std::string key = "keyence";
  const int n = s.size();
  const int kn = key.size();

  int pref = 0;
  for (int i = 0; i < std::min(n, kn); ++i)
  {
    if (s[i] == key[i]) ++pref;
    else break;
  }

  int suf = 0;
  for (int i = 0; i < std::min(n, kn); ++i)
  {
    if (s[n-i-1] == key[kn-i-1]) ++suf;
    else break;
  }

  if (pref+suf >= kn)
  {
    cout << "YES\n";
  }
  else
  {
    cout << "NO\n";
  }




  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    double n;
    cin >> n;
    cout << fixed << setprecision(10) << ceil(n / 2) / n << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
int a[3];
cin>>a[0]>>a[1]>>a[2];
sort(a,a+3);
int ans=a[2]-a[1];
a[0]=a[0]+a[2]-a[1];
if((a[2]-a[0])%2==1)
{
 ans++;
}
ans+=((a[2]-a[0]+1)/2);
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 256
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

LL n,a[100010],sum,ans=-1e18;
vector <LL> v;

int main()
{
	cin>>n;
	rep(i,n) scanf("%lld",&a[i]),sum+=a[i];
	//cout<<sum<<endl;
	rep(i,n) v.pb(-a[i]*2);
	sort(v.begin(),v.end());
	ans=max(ans,sum);
	for(int i=n-1;i>0;i-=2)
	{
		sum+=v[i]+v[i-1];
		ans=max(ans,sum);
	}
	cout<<ans<<endl;
	rt0;
}

Measured memory_bytes: 2168
#include "bits/stdc++.h"
using namespace std;
typedef long long li;

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

    li n;
    cin >> n;
    vector<li> ls(n);
    for (int i = 0; i < n; ++i) {
        cin >> ls[i];
    }
    sort(ls.begin(), ls.end());
    li ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            for (int k = j + 1; k < n; ++k) {
                if (ls[k] < ls[i] + ls[j] && ls[i] != ls[j] && ls[j] != ls[k] && ls[i] != ls[k]) {
                    ans++;
                }

            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3660
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod =1e+9+7;

const int dy[4]={0,1,0,-1};
const int dx[4]={1,0,-1,0};
const ll INF=1e10;

int main(){
    ll n; cin>>n;
    string s; cin>>s;
    ll cntl=0,cntr=0;
    ll mn=0;
    rep(i,s.size()){
        if(s[i]=='(')cntl++;
        else cntr++;
        mn=min(mn,cntl-cntr);
    }
    rep(i,abs(mn)){
        cout<<"(";
    }
    cntl+=abs(mn);
    cout<<s;
    rep(i,abs(cntr-cntl)){
        cout<<")";
    }
    cout<<endl;
}











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

const int maxn = 1e5 + 5;
std::set<int> arr[26];
char s[maxn], t[maxn], dp[maxn], cnt[26];
int last = 0, lens = 0;
long long ans = 0;
bool stat = true;
typedef std::set<int>::iterator iter;

int main(){
	scanf("%s",s+1);
	scanf("%s",t+1);
	for(int i=1;s[i];i++){
		arr[s[i]-'a'].insert(i);
		cnt[s[i]-'a'] ++;
		lens++;
	}
	for(int i=1;t[i];i++){
		if(!cnt[t[i]-'a']){
			stat = false;
			break;
		}
		int mx = *(--arr[t[i]-'a'].end());
		if(mx <= last){
			ans = ans - last + lens;
			int mn = *(arr[t[i]-'a'].begin());
			ans += (long long) mn;
			last = mn;
		}
		else{
			int pos = *(arr[t[i]-'a'].upper_bound(last));
			ans += (long long) (pos - last);
			last = pos;
		}
	}
	if(stat) printf("%lld",ans);
	else printf("-1");
	return 0;
}

Measured memory_bytes: 5120
#include<iostream>
#include<algorithm>
#include<fstream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<cmath>
#include<cctype>
#include<vector>
#include<limits.h>
#include<queue>


using namespace std;

char s[100];
int po(int n,int m)
{
    int i,ans=1;
    for(i=n; i<=m; ++i)
    {
        if(s[i]=='A'||s[i]=='C'||s[i]=='T'||s[i]=='G')
            continue;
        else
        {
            ans=0;
            break;
        }
    }
    return ans;
}
int main()
{
    scanf("%s",s);
    int i,num=strlen(s);
    int ans=0,j,n=0;
    for(i=0; i<num; ++i)
    {
        for(j=num-1; j>=i; --j)
        {
            if(po(i,j))
            {
                ans=j-i+1;
                n=max(ans,n);
            }
        }
    }
    printf("%d\n",n);
    return 0;
}


Measured memory_bytes: 256
N, Y = map(int, input().split())

a, b, c = [-1] * 3

for i in range(N + 1):
    for j in range(N - i + 1):
        k = N - i - j
        if Y == i * 10000 + j * 5000 + 1000 * k:
            a = i; b = j; c = k; break

print('{} {} {}'.format(a, b, c))

Measured memory_bytes: 3060
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP

██╗███████╗████████╗██╗ █████╗ ██╗  ██╗
██║██╔════╝╚══██╔══╝██║██╔══██╗██║ ██╔╝
██║███████╗   ██║   ██║███████║█████╔╝
██║╚════██║   ██║   ██║██╔══██║██╔═██╗
██║███████║   ██║   ██║██║  ██║██║  ██╗
╚═╝╚══════╝   ╚═╝   ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝




*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define pb push_back
#define in insert
#define mp make_pair
#define lw(v) sort(v.begin(),v.end());
#define hi(v) sort(v.begin(),v.end(),greater<long long>());
#define all(v) v.begin(),v.end()
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long t,r=1,r1=0,r2=0,k=0,ac=0,b,c=1,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    vector<string>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;
    cin>>n;
    l(i,0,n)
    {
        cin>>s1;
        if(s1=="AC")

        {
            ac++;
        }
        if(s1=="WA")

        {
            x++;
        }
        if(s1=="TLE")

        {
            y++;
        }
        if(s1=="RE")

        {
            z++;
        }
    }

    cout<<"AC"<<" x "<<ac<<endl;
    cout<<"WA"<<" x "<<x<<endl;
    cout<<"TLE"<<" x "<<y<<endl;
    cout<<"RE"<<" x "<<z<<endl;
}


Measured memory_bytes: 3656
from collections import Counter

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

if len(Counter(A)) == 1:
    print(A[0])
else:
    while sum(a > 0 for a in A) > 1:
        m = min((abs(A[i+1]-A[i]), i) for i in range(N-1) if (A[i+1] != A[i]))
        if A[m[1]+1] > A[m[1]]:
            j = m[1] + 1
            A[j] -= A[j-1]
        else:
            j = m[1]
            A[j] -= A[j+1]
        for i in range(N):
            if i != j:
                A[i] %= A[j]
    print(A[j])


Measured memory_bytes: 18600
# 2019/03/28
# AtCoder Beginner Contest 107 - B

# Input
h, w = map(int, input().split())
al = list()
wcnt = [0 for i in range(w)]
wh = h

# Input Line and Count # in line
for i in range(h):
    a = input()
    lcnt = 0
    for j in range(w):
        if a[j] == "#":
            wcnt[j] += 1
            lcnt += 1

    if lcnt > 0:
        al.append(a)
    else:
        wh -= 1

# Output Line
for i in range(wh):
    wstr = ""
    for j in range(w):
        if wcnt[j] > 0:
            wstr += al[i][j]
    print(wstr)

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


int n;
int p[510000], q[510000];

int main() {
    while (cin >> n) {
        for (int i = 0; i < n; ++i) cin >> p[i], --p[i], q[p[i]] = i;
        vector<int> a(n), b(n);
        a[0] = 1;
        for (int i = 0; i < n-1; ++i) a[i+1] = a[i] + n;
        for (int i = 0; i < n; ++i) {
            b[i] = a[n-1-i] + q[i];
        }
        for (int i = 0; i < n; ++i) cout << a[i] << " "; cout << endl;
        for (int i = 0; i < n; ++i) cout << b[i] << " ";
    }
}





Measured memory_bytes: 896
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;

main(){
    int N;
    string S;
    cin >> N >> S;
    set<string> st[3];
    for(auto c:S){
        for(int i = 1;i >= 0;i--)for(auto str:st[i])st[i+1].insert(str + c);
        
        st[0].insert(string(1,c));
    }
    //for(string s:st[2])cout << s << endl;
    cout << st[2].size() << endl;
}

Measured memory_bytes: 384
x=input()
y = list(map(int, input().split()))
total = 0
for p in y:
    for j in y:
        for k in y:
            if p != j and j!= k and k !=p:
                if p + j > k and j + k > p and k + p > j:
                    total += 1
print(int(total/6))

Measured memory_bytes: 9100
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define MAXN 100005
#define X first
#define Y second
#define MOD 1000000007
#define inf 1e18
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);
ll n,i,j,t;

int main()
{
    fastio;
    cin>>n;
    ll a=sqrt(n);
    for(i=a+1;i>0;i--){
        if(n%i==0) break;
    }
    cout<<i+(n/i)-2<<endl;
}


Measured memory_bytes: 256