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

using namespace std;

constexpr int64_t mx{3234566667};

vector<int64_t> numbers;
set<int64_t> ss;

void create()
{
	queue<int64_t> q;

	for(int64_t i = 0; i <= 9; ++i)
	{
		q.push(i);
	}

	while(not q.empty())
	{
		const int64_t temp{q.front()};
		q.pop();

		if(temp <= mx and temp >= 0)
		{
			ss.insert(temp);
		}

		if(temp == 0LL or temp > mx)
		{
			continue;
		}

		const int last_digit{temp % 10};

		const int64_t A{temp * 10 + last_digit};
		const int64_t B{temp * 10 + last_digit - 1};
		const int64_t C{temp * 10 + last_digit + 1};

		q.push(A);

		if(last_digit == 0)
		{
			q.push(C);
		}
		else if(last_digit == 9)
		{
			q.push(B);
		}
		else
		{
			q.push(B);
			q.push(C);
		}
	}

	for(const auto e : ss)
	{
		numbers.emplace_back(e);
	}
}

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

	create();

	int N;
	cin >> N;
	cout << numbers[N] << "\n";

	return 0;
}


Measured memory_bytes: 7672
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int k,m,n;
int main(){
	n=read();m=read();
	if(n<=m)puts("unsafe");
	else puts("safe");
	return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<set>
#include<vector>
#include<array>
#include<algorithm>
#include<chrono>

uint64_t xor64(void) {
  static uint64_t x = 88172645463325252ULL;
  x = x ^ (x << 7);
  return x = x ^ (x >> 9);
}

auto b_cl = std::chrono::system_clock::now();
inline double get_time() {
  auto e_cl = std::chrono::system_clock::now();
  double msec = std::chrono::duration_cast<std::chrono::milliseconds>(e_cl - b_cl).count();
  return msec;
}

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int D; std::cin >> D;
  int c[26];
  for(auto& ci: c) std::cin >> ci;
  std::vector<std::array<int,26>> s(D);
  for(int d = 0; d < D; ++d) {
    for(auto& si: s[d]) std::cin >> si;
  }
  std::vector<int> t(D);
  for(int i = 0; i < D; ++i) t[i] = i%26;
  std::set<int> last[26];
  for(auto& li: last) li.insert(-1); // sentinel
  int ans = 0;
  for(int d = 0; d < D; ++d) {
    int t1 = t[d];
    ans += s[d][t1];
    last[t1].insert(d);
    for(int i = 0; i < 26; ++i) {
      ans -= c[i]*(d - *last[i].rbegin());
    }
  }
  for(auto& li: last) li.insert(D); // sentinel
  
  // additional score when t[d] = i compare to t[d] = -1
  auto sum_up = [](int d) { return d*(d-1)/2; };
  auto score = [&](int d, int i)->int {
    int res = s[d][i];
    auto it = last[i].lower_bound(d);
    int nd = *it;
    int pd = *--it;
    int diff = sum_up(d-pd) + sum_up(nd-d) - sum_up(nd-pd);
    res -= c[i]*diff;
    return res;
  };
  int lm = 0, renew = 0;
  int sc[26];
  auto one_day = [&](int d) {
    int pi = t[d];
    last[pi].erase(d);
    for(int i = 0; i < 26; ++i) sc[i] = score(d, i);
    int mi = std::max_element(sc, sc+26) - sc;
    if(mi != pi) {
      ans += sc[mi] - sc[pi];
      ++renew;
    }
    last[mi].insert(d);
  };
  
  // hill climbing
  for(;;) {
    int lp = -1;
    do {
      renew = 0;
      for(int d = 0; d < D; ++d) one_day(d);
      ++lp;
      if(get_time() > 1850) break;
    } while(renew > 0);
    if(lp == 0 && lm > 10) break;
    // swap
    int rep = 1+xor64()%5;
    while(rep-- > 0) {
      int d1 = xor64()%D, d2 = xor64()%D;
      while(d1 < d2-16 || d2 < d1-16 || t[d1] == t[d2]) {
        d1 = xor64()%D; d2 = xor64()%D;
      }
      int pi1 = t[d1], pi2 = t[d2];
      last[pi1].erase(d1);
      int diff = score(d1, pi2) - score(d1, pi1);
      last[pi2].insert(d1);
      last[pi2].erase(d2);
      diff += score(d2, pi1) - score(d2, pi2);
      if(diff > 0) {
        last[pi1].insert(d2);
        t[d1] = pi2;
        t[d2] = pi1;
        lm = 0;
      } else {
        last[pi2].insert(d2);
        last[pi2].erase(d1);
        last[pi1].insert(d1);
        ++lm;
      }
    }
  }
  for(auto ti: t) std::cout << ti+1 << "\n";
  return 0;
}


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

int main() {
    int N; cin >> N;
    vector<double> V(N);
    rep(i,N){
        cin >> V[i];
    }
    sort(V.begin(), V.end());

    double ans = (V[0]+V[1]) / 2.0;

    for (int i = 2; i < N; i++){
        ans += V[i];
        ans /= 2.0;
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3824
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

ll d6[]={0,1,1,0,-1,-1,0};
ll que[9999],quecnt;
ll p[199][199];

int main(){
	ll n,t;
	while(scanf("%lld%lld",&t,&n),t){
		rep(i,0,199)rep(j,0,199)p[i][j]=99;
		ll x,y;
		rep(i,0,n){
			scanf("%lld%lld",&x,&y);
			p[x+70][y+70]=-1;
		}

		ll ans=1;
		scanf("%lld%lld",&x,&y);
		p[x+70][y+70]=0;
		quecnt=0;
		que[quecnt++]=(x+70)*256+(y+70);
		for(int idx=0;idx<quecnt;idx++){
			int x=que[idx]/256;
			int y=que[idx]%256;
			if(p[x][y]==t)continue;
			
			rep(k,0,6){
				int xx=x+d6[k];
				int yy=y+d6[k+1];
				if(p[xx][yy]==99){
					p[xx][yy]=p[x][y]+1;
					que[quecnt++]=xx*256+yy;
					ans++;
				}
			}
		}
		printf("%lld\n",ans);
	}
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
typedef long long ll;
using VI = vector<int>;
using VB = vector<bool>;
using VS = vector<string>;
using graph = vector<vector<int>>;

int main()
{
string t;
cin>>t;
int a;
a=t.length();
if (t.at(0)=='?')
{
    t.at(0)='D';
}


for (int  i = 1; i < a-1; i++)
{
    if (t.at(i)=='?'&&t.at(i-1)=='D'&&t.at(i+1)=='D')
{
    t.at(i)='P';
}
    if (t.at(i)=='?'&&t.at(i-1)=='P')
{
    t.at(i)='D';
}
else if (t.at(i)=='?'&&t.at(i+1)=='?')
{
    if (t.at(i-1)=='D')
    {
t.at(i)='P';t.at(i+1)='D';
    }
    else
    {
        t.at(i)='D';
    }
  
    

}
else if (t.at(i)=='?')
{
     t.at(i)='D';
}

}
if (t.at(a-1)=='?')
{
   t.at(a-1)='D';
}

cout<<t<<endl;
    return 0;
}

Measured memory_bytes: 3760
def solve(string):
    a, b, k = map(int, string.split())
    for i in range(min(a, b), 0, -1):
        if a % i == b % i == 0:
            k -= 1
        if k == 0:
            return str(i)


if __name__ == '__main__':
    print(solve(input()))


Measured memory_bytes: 38384
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
    long n=3,x_max =7;
    cin >> n >> x_max;
    vector<long> A;
    for (long i=0;i<n;i++){
        long tmp;
        cin >> tmp;
        A.push_back(tmp);
    }

    if(x_max == 0){
        long long sum=0;
        for(int i=0;i<n;i++){
            sum += A.at(i);
        }
        printf("%lld\n",sum);
        return 0;
    }

    int C[40]={};
    for(int l=0;l<40;l++){
        for(long i=0;i<n;i++){
            if(A.at(i) & (long)pow(2,l)){
                C[l]++;
            }
        }
    }

    long sum[40] ={};

    for(long i=0;i<40;i++){
        if(!(x_max+1 & ((long)1<<i))){
            continue;
        }else{
            sum[i] += ((long)1<<i) * C[i];
        }

        for(long j=0;j<i;j++){
            if(C[j] > n - C[j]){
                sum[i] += ((long)1<<j) * C[j];
            }else{
                sum[i] += ((long)1<<j) * (n-C[j]);
            }
        }

        for(long long j=i+1;j<40;j++){
            if((x_max+1 & ((long)1<<j))){
                sum[i] += ((long)1<<j) * (n-C[j]);
            }else{
                sum[i] += ((long)1<<j) * C[j];
            }
        }
    }
    printf("%ld\n",*max_element(sum,sum+40));
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
#define N 100005
struct person{
    int a,b,c;
    bool operator <(const person &x)const{
        return a-b<x.a-x.b;
    }
}p[N];
long long pre[N],bk[N];
priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > pq;
int x,y,z,n;
int main(){
    scanf("%d%d%d",&x,&y,&z);n=x+y+z;
    for(int i=1;i<=n;i++) scanf("%d%d%d",&p[i].a,&p[i].b,&p[i].c);
    sort(p+1,p+n+1);
    long long tot=0;
    for(int i=1;i<=n;i++){
        tot+=p[i].b;pq.push(make_pair(p[i].b-p[i].c,p[i].c) );
        if(pq.size()>y){
            tot=tot-pq.top().first;
            pq.pop();
        }
        pre[i]=tot;
    }

    while(!pq.empty()) pq.pop();
    tot=0;
    for(int i=n;i>=1;i--){
        tot+=p[i].a;pq.push(make_pair(p[i].a-p[i].c,p[i].c) );
        if(pq.size()>x){
            tot=tot-pq.top().first;
            pq.pop();
        }
        bk[i]=tot;
    }

    long long ans=0;
    for(int i=y;i+x<=n;i++) ans=max(ans,pre[i]+bk[i+1]);
    cout<<ans<<endl;
    return 0;
}

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

namespace ABC064
{
    class B
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');

            int[] a = new int[input.Length];
            for (int i = 0; i < input.Length; i++)
            {
                a[i] = int.Parse(input[i]);
            }

            int max = a.Max();
            int min = a.Min();

            Console.WriteLine(max - min);
        }
    }
}

Measured memory_bytes: 13268
#include<stdio.h>

struct QNode
{
	int t;
	char name[11];
};

typedef struct QNode Queue;

int rear, front, maxsize;

Queue Q[100001];

void enqueue(Queue q)
{
	front = (front + 1) % maxsize;
	Q[front] = q;
}

Queue dequeue()
{
	rear = (rear + 1) % maxsize;
	return Q[rear];
}

void solve()
{
	rear = front = 0;
	maxsize = 100001;

	int n, t, sum = 0;
	scanf("%d%d", &n, &t);

	for (int i = 0; i < n; i++)
	{
		front++;
		scanf("%s %d", Q[front].name, &Q[front].t);
	}

	while (rear != front)
	{
		Queue tmp;
		tmp = dequeue();
		if (tmp.t > t)
		{
			sum += t;
			tmp.t -= t;
			enqueue(tmp);
		}
		else
		{
			sum += tmp.t;
			printf("%s %d\n", tmp.name, sum);
		}
	}
		
}

int main()
{
	solve();
}


Measured memory_bytes: 3328
import kotlin.math.*

fun main(args: Array<String>) {
    d()
}

fun a() {
    when(readLine()) {
        "ABC" -> println("ARC")
        "ARC" -> println("ABC")
        else -> Unit
    }
}

fun b() {
    val (N, K) = readLine()!!.split(" ").map { it.toInt() }.let { it[0] to it[1] }
    val set = (1 .. N).toMutableSet()
    repeat(K) {
        val d = readLine()!!.toInt()
        val As = readLine()!!.split(" ").map { it.toInt() }
        set.removeAll(As)
    }
    println(set.count())
}

fun c() {
    val (N, M) = readLine()!!.split(" ").map { it.toInt() }.let { it[0] to it[1] }
    val H = readLine()!!.split(" ").map { it.toLong() }
    val set = (0 until N).toMutableSet()
    repeat(M) {
        val (A, B) = readLine()!!.split(" ").map { it.toInt() - 1 }.let { it[0] to it[1] }
        when {
            H[A] == H[B] -> {
                set.remove(A)
                set.remove(B)
            }
            H[A] > H[B] -> {
                set.remove(B)
            }
            H[A] < H[B] -> {
                set.remove(A)
            }
        }
    }
    println(set.count())
}

fun d() {
    val X = readLine()!!.toLong()
    val list = divisor(X)
    list.forEach {
        val pow5 = it.toDouble().pow(5).toLong()
        when{
            pow5 == X -> { println("$it 0"); return }
            pow5 > X -> {
                var l = pow5
                var a = it
                var b = 0L
                while (l > X) {
                    a--
                    b--
                    if (l <= a*a*a*a*a - b*b*b*b*b) break
                    l = a*a*a*a*a - b*b*b*b*b
//                    println("$a^5 - $b^5 = $l")
                    if (X == l) {
                        println("$a $b")
                        return
                    }
                }
            }
            pow5 < X -> {
                var l = pow5
                var a = it
                var b = 0L
                while (l < X) {
                    a++
                    b++
                    if (l >= a*a*a*a*a - b*b*b*b*b) break
                    l = a*a*a*a*a - b*b*b*b*b
//                    println("$a^5 - $b^5 = $l")
                    if (X == l) {
                        println("$a $b")
                        return
                    }
                }
            }
        }
    }
}

fun prime(from : Long, to : Long = from) : List<Long> {
    return (from..to).filter { i ->
        val max = Math.sqrt(i.toDouble()).toLong()
        (2..max).all { j ->  i % j != 0L }
    }
}

fun divisor(value : Long) : List<Long> {
    val max = Math.sqrt(value.toDouble()).toLong()
    return (1..max)
        .filter { value % it == 0L }
        .map { listOf(it, value / it) }
        .flatten()
        .sorted()
}

Measured memory_bytes: 38676
#include <stdio.h>
#define N 100000

int hi[N];
int partition ( int a, int b);

int main()
{
  int i,n,p;

  scanf ("%d",&n);

  for(i=0;i<n;i++)
    scanf("%d",&hi[i]);

  p=partition(0,n-1);

  for(i=0;i<n;i++){
    if(i)
      printf(" ");
    if(i==p)
      printf("[");
    printf("%d",hi[i]);
    if(i==p)
      printf("]");
  }
  printf("\n");

  return 0;
}
int partition (int a, int b){
  int i,j,x,y;
x=hi[b];
i=a-1;
for(j=a;j<b;j++){
  if(hi[j]<=x){
    i++;
    y=hi[i];
    hi[i]=hi[j];
    hi[j]=y;
  }
 }

y=hi[i+1];
hi[i+1]=hi[b];
hi[b]=y;

return i+1;
}



Measured memory_bytes: 2144
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k; cin >> n >> k;
    vll h(n); REP(i, n) cin >> h[i];
    sort(ALL(h));
    reverse(ALL(h));
    for (int i = 0; i < min(k, n); i++) h[i] = 0;
    cout << accumulate(ALL(h), 0LL) << '\n';
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int N,Q;
string S;

int dp[100100]={};

int main(){
  cin >> N >> Q;
  cin >> S;

  dp[0]=0;
  for(int i=1;i<S.length();i++){
    dp[i]=dp[i-1];
    dp[i]+=(S[i]=='C' && S[i-1]=='A')?1:0;
  }

  for(int i=0;i<Q;i++){
    int l,r;
    cin >> l >> r;
    l--;r--;
    int start,end;
    start=(dp[l]=='C' && l-1>=0 && dp[l-1]=='A')?dp[l]-1:dp[l];
    end=dp[r];
    cout << end-start << endl;
  }
  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
    int A,B;
    cin>>A>>B;
    
    int ans=(A-1)*(B-1);
    
    cout<<ans<<endl;
  
   
}

Measured memory_bytes: 3524
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

#include <functional>
using namespace std;

template<class Type>
Type Syakutori(int st,int en,Type init,function<bool(int)> condition,function<Type(int,int,Type)> ansUpdate,function<void(int)> rightUpdate,function<void(int)> leftUpdate){
  int r = st;
  Type ans = init;
  for(int l = st;l < en;l++){
    while(r < en && condition(r)){
      rightUpdate(r);
      r++;
    }
    ans = ansUpdate(l,r,ans);
    if(l == r){
      r++;
    }
    else{
      leftUpdate(l);
    }
  }
  return ans;
}

int N;
i64 A[202020];

int main(){
  cin >> N;
  rep(i,0,N - 1){
    cin >> A[i];
  }
  i64 now = 0;
  cout << Syakutori<i64>(0,N,0LL,[&](int r){return (now & A[r]) == 0;},
      [&](int l,int r,i64 a){return a + r - l;},
      [&](int r){now |= A[r];},
      [&](int l){now &= ~A[l];}) << endl;
}


Measured memory_bytes: 1792
using System;

namespace AOJ.Volume2
{
    public class TemperatureDifference
    {
        public static int Main()
        {
            for(int i = 0; i < 7; i++)
            {
                var input = Console.ReadLine().Split(' ');
                int a = int.Parse(input[0]);
                int b = int.Parse(input[1]);

                Console.WriteLine(a - b);
            }
            return 0;
        }
    }
}

Measured memory_bytes: 9092
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>

using namespace std;
typedef long long ll;


int main() {
	int N, M; cin >> N >> M;
	char* s = new char[N + 1];
	for (int i = 0; i < N + 1; i++) {
		cin >> s[N - i];
	}
	vector<ll> v;
	int x = N;
	while (x > 0) {
		bool flag = true;
		for (int y = max(0, x - M); y < x; y++) {
			if (s[N - y] == '0') {
				flag = false;
				v.push_back(x - y);
				x = y;
				break;
			}
		}
		if (flag) {
			cout << -1 << endl;
			return 0;
		}
	}
	int t = v.size();
	for (int i = t - 1; i >= 0; i--) {
		cout << v[i] << " ";
	}
	return 0;
}

Measured memory_bytes: 1528
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    // freopen("in.c","r",stdin);
    int n;
    cin>>n;
    ll a[n];
    for(int i=0; i<n; i++) cin>>a[i];
    sort(a,a+n);
    int c=1,ans=0;
    for(int i=0;i<n;i++)
        if(a[i]==a[i+1]) c++;
        else
        {
            if(a[i]!=c)
            {

                if(a[i]<c) ans+=c-a[i];
                else ans+=c;
            }
            c=1;
        }
    cout<<ans<<endl;
//return main();
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	int n, i, j, k, ans, ct;
	cin >> n;
	vector<int> a(n), c(9, 0);
	for (i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] >= 3200) c[8]++;
		else c[a[i] / 400]++;
	}
	ct = 0;
	for (i = 0; i < 8; i++) {
		if (c[i] > 0) ct++;
	}
	ans = ct;
	if (c[8] > 0) ans = ct + c[8];
	if (ct == 0) ct = 1;
	cout << ct << " " << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			
			if(n == 0 && m == 0){
				break;
			}
			
			String[] chairs = new String[n];
			for(int i = 0; i < n; i++){
				chairs[i] = "#";
			}
			
			for(int i = 0; i < m; i++){
				String str = sc.next();
				
				if("A".equals(str)){
					
					for(int j = 0; j < n; j++){
						if(chairs[j].equals("#")){
							chairs[j] = "A";
							break;
						}
					}
					
				}else if("B".equals(str)){
					boolean found = false;
					
					for(int j = n-1; j >= 0; j--){
						if(chairs[j].equals("#") && (j == (n-1) || !chairs[j+1].equals("A")) && (j == 0 || !chairs[j-1].equals("A"))){
							found = true;
							chairs[j] = "B";
							break;
						}
					}
					
					if (found == false) {
						for (int j = 0; j < n; j++) {
							if (chairs[j].equals("#")) {
								chairs[j] = "B";
								break;
							}
						}
					}
					
				}else if("C".equals(str)){
					boolean found = false;
					
					for (int j = 0; j < n; j++) {
						if (!chairs[j].equals("#")){
							if(j != (n-1) && chairs[j+1].equals("#")){
								found = true;
								chairs[j+1] = "C";
								break;
							}else if(j != 0 && chairs[j-1].equals("#")){
								found = true;
								chairs[j-1] = "C";
								break;
							}
						}
					}
					
					if(found == false){
						if(n % 2 == 1){
							chairs[(n+1)/2 - 1] = "C";
						}else{
							chairs[n/2+1 - 1] = "C";
						}
					}
					
				}else if("D".equals(str)){
					int[] tmp_array = new int[n];
					int max = 0;
					boolean found = false;
					
					for(int j = 0; j < n; j++){
						if(chairs[j].equals("#")){
							tmp_array[j] = Integer.MAX_VALUE;
						}else{
							tmp_array[j] = 0;
							found = true;
						}
					}
					
					if(found == false){
						max = Integer.MAX_VALUE;
					}
					
					boolean fixed = false;
					for(int j = 0; j < n; j++){
						for(int k = 0; k < n; k++){
							if(tmp_array[k] == j){
								if(k != 0 && tmp_array[k-1] > (j + 1)){
									tmp_array[k-1] = j + 1;
									fixed = true;
								}
								
								if(k != (n-1) && tmp_array[k+1] > (j + 1)){
									tmp_array[k+1] = j + 1;
									fixed = true;
								}
							}
						}
						
						if(fixed == false){
							break;
						}else{
							fixed = false;
							max = j+1;
						}
					}
					
					for(int j = 0; j < n; j++){
						if(tmp_array[j] == max){
							chairs[j] = "D";
							break;
						}
					}
				}
				
				/*
				for (int j = 0; j < n; j++) {
					System.out.print(chairs[j]);
				}
				System.out.println();
				*/
			}
			
			for(int j = 0; j < n; j++){
				System.out.print(chairs[j]);
			}
			System.out.println();
			
			
		}
		
	}
	
}

Measured memory_bytes: 0
dict = {}
for alpha in [ chr(code) for code in range(ord('a'), ord('z') + 1) ]:
    dict[alpha] = 0

s = ''
while True:
    try:
        s += input()
    except EOFError:
        break

for c in s:
    if c.isalpha():
        dict[c.lower()] += 1

for alpha in [ chr(code) for code in range(ord('a'), ord('z') + 1) ]:
    print('{0} : {1}'.format(alpha, dict[alpha]))


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

int gcd(int a,int b){
  return a==0 ? b : gcd(b%a,a);
}
int main(){
  
  int H,W;
  int h,w;
  cin>>H>>W>>h>>w;
  if(gcd(H,h)==h && gcd(W,w)==w){
    cout<<"No"<<endl;
    return 0;
  }
  cout<<"Yes"<<endl;
  vector<vector<int>> res(H,vector<int>(W,0));
  
  for(int i=0;i<H;i+=h){
    for(int j=0;j<W;j+=w){
      res[i][j]=1e9-1;
    }
  }
  for(int i=h-1;i<H;i+=h){
    for(int j=w-1;j<W;j+=w){
      res[i][j]=-1e9;
    }
  }

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cout<<res[i][j];
      if(j+1!=W) cout<<" ";
    }
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 3968
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int maisu = Integer.parseInt(br.readLine());

		// ??????????????¨?????°??????????????????
		String[] cards = new String[52];

		// ??????????????????????????§????????????boolean???????????????
		boolean[] cardsCheck = new boolean[52];

		// 13??§?????????????????????????????????????????????
		String[] suit = { "S", "H", "C", "D" };

		// ???????????????????????????????????¨??°????????\??????
		// ??°?????????????????¨????????±??????????????? + " " + ??°??? ??§???????????\??????
		// ?????????boolean????????¨??¨?????????false?????????
		for (int a = 0; a < suit.length; a++) {
			for (int b = 1; b <= 13; b++) {
				cards[a * 13 + b - 1] = suit[a] + " " + b;
				cardsCheck[a * 13 + b - 1] = false;
			}
		}
		// ??\???????????????????????¨??°??????????????????boolean???true?????????
		// ???????????£??????break?????§?????????????¬????????????????????´¢?????????
		for (int c = 0; c < maisu; c++) {
			String nyuryokuCard = br.readLine();
			for(int d = 0; d < cards.length; d++){
				if(nyuryokuCard.equals(cards[d])){
					cardsCheck[d] = true;
					break;
				}
			}
		}
		// false?????????????????¨?????????
		for(int e = 0; e < cards.length; e++){
			if(cardsCheck[e] == false){
				System.out.println(cards[e]);
			}
		}
	}
}

Measured memory_bytes: 24184
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
template<class T>
using max_heap = priority_queue<T, vector<T>, less<T>>;
template<class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
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; }

ll s[300010]; // a[i]までN個選んだときの総和の最大値
ll t[300010]; // a[i]より右側でN個選んだときの総和の最小値

int main() {
    int n; cin >> n;
    int m = 3 * n;
    vector<ll> a(m);
    rep(i, m) cin >> a[i];

    min_heap<ll> q1;
    for (int i = 0; i < n; i++) {
        if (i == 0) s[i] = a[i];
        else s[i] = s[i-1] + a[i];
        q1.push(a[i]);
    }
    for (int i = n; i < 2*n; i++) {
        ll top = q1.top();
        if (a[i] > top) {
            q1.pop(); q1.push(a[i]);
            s[i] = s[i-1] - top + a[i];
        } else {
            s[i] = s[i-1];
        }
    }

    max_heap<ll> q2;
    for (int i = 3*n-1; i >= 2*n; i--) {
        if (i == 3*n-1) t[i] = a[i];
        else t[i] = t[i+1] + a[i];
        q2.push(a[i]);
    }
    for (int i = 2*n-1; i >= n; i--) {
        ll top = q2.top();
        if (a[i] < top) {
            q2.pop(); q2.push(a[i]);
            t[i] = t[i+1] - top + a[i];
        } else {
            t[i] = t[i+1];
        }
    }

    /*
     *rep(i, 3*n) printf("%2lld ", s[i]);
     *cout << endl;
     *rep(i, 3*n) printf("%2lld ", t[i]);
     *cout << endl;
     */

    ll ans = -LLINF;
    for (int i = n-1; i < 2*n; i++) chmax(ans, s[i] - t[i+1]);
    cout << ans << endl;
}


Measured memory_bytes: 7540
# Connected Components
from collections import defaultdict
import sys
sys.setrecursionlimit(1 << 25)  # 再起上限引き上げ

G = defaultdict(lambda: [])

# load data
N, M = list(map(int, input().split()))
color = {key: None for key in range(N)}  # 色というかグループ #intで表す #Noneは未訪問を示す
# graphをdefault dictで保持することにする。
for _ in range(M):
    s, t = list(map(int, input().split()))
    G[s].append(t)
    G[t].append(s)

def dfs(node: int, co: int):
    if color[node] is not None:
        return
    color[node] = co
    for n in G[node]:
        dfs(n, co)
    return

# すべてのnodeを開始点としてdfsで領域わけしてみる
c = 1
for node in G.keys():
    dfs(node, c)  # 訪問済みだったら色を塗り替えないというないようはdfs関数内の処理で吸収できる
    c += 1

# 問題に回答していく
Q = int(input())
for _ in range(Q):
    s, t = list(map(int, input().split()))
    if ((color[s] is not None) and (color[t] is not None)) and (color[s] == color[t]):
        # s,tも友達がいて、かつ同じグループだったら
        print('yes')
    else:
        print('no')
        


Measured memory_bytes: 143916
package main

import (
	"fmt"
)

func main() {
	var s int
	fmt.Scan(&s)
	
  	a := make([]int,0)
  	a = append(a, s)
  	
	for i := 1; ; i++ {
		if a[i-1] % 2 == 0 {
			a = append(a, a[i-1] / 2)
		} else {
			a = append(a, 3 * a[i-1] + 1)
		}
		for j := 0; j < i; j++ {
			if a[i] == a[j] {
				fmt.Println(i+1)
				return
			}
		}
	}
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>

#undef DEBUG

#ifdef DEBUG
struct testdata{
    int N;
    int L[2*1000];
    int a;
} td[] = {
    {4, {3, 4, 2, 1}, 1},
    {3, {1, 1000, 1}, 0},
    {7, {218, 786, 704, 233, 645, 728, 389}, 23},
};
#endif

int
cmp(const void *a, const void *b)
{
    return *(int *)a - *(int *)b;
}

void
solver(int n, int *l)
{
    int i, j, k;
    int a=0;

    qsort(l, n, sizeof(int), cmp);
    
    for (i=0; i<n-2; i++) {
        for (j=i+1; j<n-1; j++) {
            for (k=j+1; k<n; k++) {
                if (l[k]>l[i]+l[j])
                    break;
                if (
                    l[i]<l[j]+l[k] &&
                    l[j]<l[k]+l[i] &&
                    l[k]<l[i]+l[j]
                ) {
                    a++;
                }
            }
        }
    }
    printf("%d\n", a);
}

int
main(int argc, char *argv[])
{
    int i;
    int N;
    int L[2*1000];

#ifdef DEBUG
    for (i=0; i<3; i++) {
        solver(td[i].N, td[i].L);
        printf("ans: %d\n", td[i].a);
    }
#else
    scanf("%d", &N);
    for (i=0; i<N; i++) {
        scanf("%d", L+i);
    }
    solver(N, L);
#endif

    return 0;
}

Measured memory_bytes: 128
k,n=map(int,input().split())
if(n==0):
    print(k)
else:
  l=list(map(int,input().split()))
  c=0
  d=0
  while(d==0):
        if(k-c not in l):
            print(k-c)
            break
        if(k+c not in l):
            print(k+c)
            break
        c=c+1
      

Measured memory_bytes: 9140
// parameter "input" gets all data
function Main(input) {
	// the first line is assigned to input[0], the second line is assigned to input[1] similarly.
	
	input = input.split("\n").map((s)=>s.trim());
	var n = parseInt(input[0].split(' ')[0]);
	var x = parseInt(input[0].split(' ')[1]);
	var y = input[1].split(" ").map((s)=>Math.abs(parseInt(s.trim())-x));

	var m = -1;
	for (var i = 0; i < y.length; i++) {
		if(m==-1)
			m=y[0];
		else
			m=Math.min(y[i],m);
	}
	var yy = y.filter((_y)=>_y%m!=0);
	yy.push(m);
	if(yy.length==1){
		console.log(yy[0]);
		return;
	}else{
		for (var a = m; a > 1; a--) {
			if(m%a==0){
				var found = true;
				for (var i = 0; i < yy.length; i++) {
					if(yy[i]%a!=0){
						found = false;
						break;
					}
				}
				if(found){
					console.log(a);
					return;
				}
			}
		}
	}
	console.log(1);
}
// Don't edit this line!
//Main(require("fs").readFileSync(__dirname+'/in.txt', "utf8"));
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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; }

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



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,t; cin>>n>>t;
  vpll ab(n);
  rep(i,n){
    ll a,b; cin>>a>>b;
    ab[i]={a,b};
  }
  
  vector<vll> dp1(n+1,vll(t+1)), dp2(n+1,vll(t+1));
  rep(i,n){
    ll a=ab[i].first, b=ab[i].second;
    rep(j,t){
      if(j+a<t){
        chmax(dp1[i+1][j+a],dp1[i][j]+b);
      }
      chmax(dp1[i+1][j+1], dp1[i+1][j]);
      chmax(dp1[i+1][j+1], dp1[i][j+1]);
    }
  }
  rrep(i,n){
    ll a=ab[i].first, b=ab[i].second;
    rep(j,t){
      if(j+a<t){
        chmax(dp2[i][j+a],dp2[i+1][j]+b);
      }
      chmax(dp2[i][j+1], dp2[i+1][j+1]);
      chmax(dp2[i][j+1], dp2[i][j]);
    }
  }
  
  ll ans=0;
  irep(i,1,n){
    rep(j,t){
      chmax(ans,dp1[i][j]+dp2[i+1][t-1-j]+ab[i].second);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 141184
def main():
    n, m = map(int, input().split())
    student = []
    for _ in range(n):
        student.append([int(x) for x in input().split()])
    check_point = []
    for _ in range(m):
        check_point.append([int(x) for x in input().split()])
    answer = ["0" for _ in range(n)]
    for i in range(n):
        now_ans = 0
        now_dist = float("inf")
        for j in range(m):
            dist = abs(student[i][0] - check_point[j][0]) + abs(student[i][1] - check_point[j][1])
            if dist < now_dist:
                now_ans = j + 1
                now_dist = dist
        answer[i] = str(now_ans)
    print("\n".join(answer))


if __name__ == '__main__':
    main()



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;



struct UnionFind {

    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) {
            par[i] = i;
        }
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける

        return;
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

};

int main(){

int N;
cin>>N;

UnionFind uf(N+1);

if(N%2==1){
    for(int i=1;i<=N-1;i++){
        uf.unite(i,N-i);
    }
}
else{
    for(int i=1;i<=N/2;i++){
        uf.unite(i,N-i+1);
    }
}
int m=0;
for(int i=1;i<N;i++){
    for(int k=i+1;k<=N;k++){
        if(!uf.same(i,k)){
            //cout<<i<<" "<<k<<endl;
            m++;
        }
    }
}
cout<<m<<endl;
for(int i=1;i<N;i++){
    for(int k=i+1;k<=N;k++){
        if(!uf.same(i,k)){
            cout<<i<<" "<<k<<endl;
        }
    }
}
return 0;
}
/*
3

2
1 3
2 3

*/


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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> edge[n+1];
    vector<int> redge[n+1];
    int cnt[n+1];
    fill(cnt,cnt+n+1,0);
    for(int i=0; i<n+m-1; i++){
        int a,b;
        cin >> a >> b;
        edge[a].push_back(b);
        redge[b].push_back(a);
        cnt[b]++;
    }
    queue<int> s;
    for(int i=1; i<n+1; i++){
        if(cnt[i]==0) s.push(i);
    }
    vector<int> vec;
    int rvec[n+1];
    rvec[0] = -1;
    while(!s.empty()){
        int u = s.front();
        s.pop();
        vec.push_back(u);
        rvec[u] = vec.size();
        for(int i=0; i<edge[u].size(); i++){
            cnt[edge[u][i]]--;
            if(cnt[edge[u][i]] == 0) s.push(edge[u][i]);
        }
    }
    int ans[n+1];
    ans[vec[0]] = 0;
    for(int i=1; i<vec.size(); i++){
        int a = vec[i];
        int t = 0;
        for(int j=0; j<redge[a].size(); j++){
            int k = redge[a][j];
            if(rvec[k] > rvec[t]) t = k;
        }
        ans[a] = t;
    }
    for(int i=1; i<n+1; i++){
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 13436
N = int(input())
S = list(input() for _ in range(N))

S_set= sorted(list(set(S)))

dic = dict(zip(S_set, [0 for _ in range(len(S_set))]))

for s in S: dic[s] += 1

K_max = max(list(dic.values()))
        
for (i,s) in enumerate(sorted(S_set)): 
    if dic[s] == K_max: 
        print(s)

Measured memory_bytes: 46104
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        Set<String> s = new HashSet<String>();
        for (int i = 0; i < n; i++){
            s.add(input.next());
        }
        System.out.println(s.size());
    }
}

Measured memory_bytes: 77148
r, d, x2000 = list(map(int, input().split()))
# x = list(map(int, input().split()))
# abc = [int(input()) for i in range(5)]
# n = int(input())
# n, m = list(map(int, input().split()))
x = [x2000]
for i in range(10):
    b = r*x[i]-d
    x.append(b)
    print(b)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define si set <ll>
#define vi vector <ll>
#define popcount(x) __builtin_popcountll(x)
#define mii map <ll,ll>
#define vpi vector <pair <ll,ll> >
#define sz(c) (int)c.size()
#define fr first
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,n) for( ll i=a ; i<n ; i++)
#define ld long double
#define rall(a) (a).rbegin(),(a).rend()

ll power(ll b,ll e,ll m)
{
  if(e==0) return 1;
  if(e&1) return b*power(b*b%m,e/2,m)%m;
  return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
  if(e==0) return 1;
  if(e&1) return b*power(b*b,e/2);
  return power(b*b,e/2);
}  
bool isPowerOfTwo(ll x)
{
    // x will check if x == 0 and !(x & (x - 1)) will check if x is a power of 2 or not
    return (x && !(x & (x - 1)));
} 

void solve()
{
  ll a,b,c,k;
  cin>>a>>b>>c>>k;
  ll sum=0;
  sum+=min(a,k);
  k-=min(a,k);
  // cout<<k<<"\n";
  if(k==0)
  {
    cout<<sum<<"\n";
    return;
  }
  k-=min(b,k);
  // cout<<k<<"\n";
  if(k==0)
  {
    cout<<sum<<"\n";
    return;
  }
  // cout<<sum<<"\n";
  sum-=min(c,k);
  cout<<sum<<"\n";
}

int main()       
{
  fastio
  ll tt=1;
  while(tt--)
    solve();
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll check(ll a[],ll b[],ll n){
    ll flag=0;
    for(int i=0;i<n;i++){
        if(a[i]!=b[i]){
            flag=1;
            break;
        }
    }
    return flag;
}
int main() {
    ll n,i,j; cin>>n;
    ll a[n],b[n];
    for(i=0;i<n;i++){
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b,b+n);
    if(check(a,b,n)==0){
        cout<<"YES"<<"\n";
        return 0;
    }
    for(i=0;i<n-1;i++){
        for(j=i+1;j<n;j++){
            swap(a[i],a[j]);
            if(check(a,b,n)==0){
                cout<<"YES"<<"\n";
                return 0;
            }
            swap(a[i],a[j]);
        }
    }
    cout<<"NO"<<"\n";
}

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

typedef unsigned long long int ull;
typedef long double ldb;
typedef long long int ll;

#define MOD1        1000000007
#define MOD2        998244353
#define PI          3.1415926535897932384626433832795
#define FILL(a, value) memset(a, value, sizeof(a))
#define BOOST       ios_base::sync_with_stdio(false); cin.tie(NULL)
#define what_is(x)  cerr << #x << " is " << x << endl;
#define ASSERT(left,operator,right) { if(!((left) operator (right))){ std::cerr << "ASSERT FAILED: " << #left << #operator << #right << " @ " << __FILE__ << " (" << __LINE__ << "). " << #left << "=" << (left) << "; " << #right << "=" << (right) << std::endl; } }

#define rep01(k,n)      for (ll i=k; i<n; i++)
#define rep02(k,n)      for (ll j=k; j<n; j++)
#define rep03(k,n)      for (ll k=k; k<n; k++)
#define rep11(k,n)      for (ll i=k; i<=n; i++)
#define rep12(k,n)      for (ll j=k; j<=n; j++)
#define rep13(k,n)      for (ll k=k; k<=n; k++)
#define repIT(c,it)     for(typeof(c.begin()) it = c.begin(); it != c.end(); ++it)
#define all(c)      c.begin(), c.end()

using namespace std;

const double pi = acos(-1.0);
const double epsilon = 1e-9;        // Add epsilon when casting double to int to avoid rounding pitfall issues, eg, 0.94*8178 in int
const int maxn = 1e6+10;

void solve()
{
    ll n;
    cin >> n;
    priority_queue<double, vector<double>, greater<double>> v;

    for(int i = 0; i < n; i++)
    {
        double el;
        cin >> el;
        v.push(el);
    }

    while(v.size() > 1)
    {
        double e1 = v.top(); v.pop();
        double e2 = v.top(); v.pop();
        v.push((e1+e2)*0.5);
    }
    cout << fixed;
    cout << setprecision(14) << v.top();

}

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

    cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
    return 0;
}

Measured memory_bytes: 3824
/* created   : 2019-09-10 00:23:17
 * accepted  : 2019-09-10 00:38:58
 * author    : landcold7
 */
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#ifndef LOCAL
#define trace(...)
#endif
typedef long long ll;

void solve() {
  int n; cin >> n;
  vector<int> b(n - 1), a(n);
  for (int i = 0; i < n - 1; i++) {
    cin >> b[i];
  }
  a[0] = b[0];
  a[n - 1] = b[n - 2];
  for (int i = 1; i < n - 1; i++) {
    if (b[i] >= b[i - 1]) {
      a[i] = b[i - 1];
    }
    else {
      a[i] = b[i];
    }
  }
  trace(a);
  cout << accumulate(a.begin(), a.end(), 0) << '\n';
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}


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

		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] D = new int[4];
		int[] point = new int[4];
		int ans = 0;
		for( int i=0; i<M; i++ ){
			int a = sc.nextInt();
			int b = sc.nextInt();
			if( point[a]==0 ){
				D[a] = b;
				point[a] = 1;
			}else{
				if( D[a]!=b ){
					ans = 1;
				}
			}
		}
		if( point[1]==0 && N>1 ){
			D[1] = 1;          
        }          
		if( point[1]==1 && N>1 && D[1]==0 ){
			ans = 1;
		}
		if( ans==1 ){
			System.out.println(-1);
		}else{
			if( N==1 ){
				System.out.print(D[1]);
			}
			if( N==2 ){
				System.out.print(D[1]);
				System.out.print(D[2]);
			}
			if( N==3 ){
				System.out.print(D[1]);
				System.out.print(D[2]);
				System.out.print(D[3]);
			}
		}
	}
}


Measured memory_bytes: 21844
n = int(input())
def get_factors(n):
    f = set()
    for i in range(1,int((n**0.5))+1):
        if n % i == 0:
            f.add(i)
            f.add(n//i)
    return len(f)
ans = 0
for i in range(1,n+1):
    if get_factors(i) == 8 and i % 2 == 1:
        ans += 1
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
typedef long long int ll;
typedef long long unsigned int llu;
#define pb push_back
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define YUGEN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define lp(i,start,end) for(int i=start;i<end;i++)
#define MAX 105
#define test() ll t; cin>>t; while(t--)
using namespace std;
ll gcd(ll a,ll b) {if (a==0) return b;return gcd(b%a,a);}
int main()
 {
    YUGEN;
      ll x,k,d;
      cin>>x>>k>>d;
      ll y=abs(x);
      ll z=y/d;
      if(z<=k)
      {
          k=k-z;
          y-=z*d;
          if(k%2==1)
            cout<<min(abs(y+d),abs(y-d));
            else
            cout<<y<<endl;
      }
      else
        {
        y-=(k*d);
        cout<<y;
      }


	return 0;

 }



Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>

using namespace std;


int main(){
   int l[3];
   cin>>l[0]>>l[1]>>l[2];
   sort(l,l+3);
   int ans=l[0]*l[1]/2;
   cout<<ans<<endl;

   

}

Measured memory_bytes: 384
#include <iostream>
#include <vector>

using namespace std;

int main(){

	int n,m;
	while(cin >> n >> m){
		vector<int> buff(2*n);
		for(int i = 0; i < 2*n; i++){
			buff[i] = i+1;
		}

		for(int i = 0; i<m; i++){
			int k;
			cin >> k;
			if(k == 0){
				vector<int> tmp[2];
				for(int j = 0; j < 2*n; j++){
					if(j < n)
						tmp[0].push_back(buff[j]);
					else
						tmp[1].push_back(buff[j]);
				}
				buff.clear();
				for(int j = 0; j < 2*n; j++){
					buff.push_back(tmp[j%2][j/2]);
				}

			}
			else{
				vector<int> tmp[2];
				for(int i = 0; i < 2*n; i++){
					if(i < k){
						tmp[0].push_back(buff[i]);
					}
					else{
						tmp[1].push_back(buff[i]);
					}
				}
				buff.clear();
				for(int i = 0; i < tmp[1].size(); i++){
					buff.push_back(tmp[1][i]);
				}
				for(int i = 0; i < tmp[0].size(); i++){
					buff.push_back(tmp[0][i]);
				}
			}
		}
		for(int i = 0; i < buff.size(); i++){
			cout << buff[i] << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
 
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
/* (๑╹◡╹) */
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll MOD = 1000000007;
template<class T>
inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
 /* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)*/
template<class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
/* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹) */
///////////////////////////////////////////////

int main() {
ll ans = 0;
	ll X,Y,a;
	cin >> X >> Y;
	a = X;
	while(a <= Y)
	{
		a = a * 2;
		ans ++;
	}
	

	cout << ans << endl;

}

Measured memory_bytes: 256
import java.io.*
import java.util.*

fun solve(A: String, B: String){
    if(A.length > B.length){
        println("GREATER")
        return
    } else if(A.length < B.length){ println("LESS"); return}
    else{
        for(i in 0 until A.length){
            if(A[i] - '0' > B[i] - '0' ){
                println("GREATER")
                return
            }else if(A[i] - '0' < B[i] - '0' ){
                println("LESS")
                return
            }
        }
    }
    println("EQUAL")
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val A = sc.next()
    val B = sc.next()
    solve(A, B)
}



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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    string s;cin >>s;
    string f="",b="";
    ll t=0;
    ll q;cin >>q;
    for (int i = 0; i < q; ++i) {
        ll a;cin >>a;
        if(a==1)t++;
        else {
            ll k;cin >>k;
            char c;cin >>c;
            if(t%2==0){
                if(k==2) {
                    b += c;
                }
                else {
                    f+=c;
                }
            }
            else {
                if(k==2) {
                    f += c;
                }
                else {
                    b+=c;
                }
            }
        }
    }
    if(t%2==1){
        reverse(all(s));
        reverse(all(b));
        cout <<b<<s<<f<<endl;
    }
    else {
        reverse(all(f));
        cout <<f<<s<<b<<endl;
    }
    return 0;
}



Measured memory_bytes: 1088