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

double f(int n) {
  double res = 0;
  double n_ = n * (n + 1) / 2;
  res = n_ / n;
  return res;
}

int main() {

  int N, K;
  cin >> N >> K;

  vector<int> p(N);
  vector<double> k(N);
  vector<double> sum(N);
  double all = 0;

  for (int i = 0; i < N; i++) {
    cin >> p[i];
    k[i] = f(p[i]);
    if (i == 0) {
      sum[i] = k[i];
    } else {
      sum[i] = k[i] + sum[i-1];
    }
  }

  double answer = sum[K - 1];

  for (int i = K; i < N; i++) {
    answer = max(answer, sum[i] - sum[i - K]);
  }

  cout << setprecision(11) << answer << endl;

  return 0;

}

Measured memory_bytes: 4096
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        try {
           int n = scanner.nextInt();

           Set<String> set = new HashSet<>();
            for (int i = 0; i < n; i++) {
                int a = scanner.nextInt();
                String s = Integer.toString(a);
                set.add(s);
            }
            int m = scanner.nextInt();
            boolean flag = true;
            for (int i = 0; i < m; i++) {
                int b = scanner.nextInt();
                String s1 = Integer.toString(b);
                if (!set.contains(s1)){
                    flag = false;
                    break;
                }
            }
            System.out.println(flag?1:0);

        } catch (Exception e) {

        } finally {

        }

    }

}




Measured memory_bytes: 166388
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j, key;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  
  trace(A, n);

  for(i = 2; i <= n; i++){
    key = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > key){
      A[j+1] = A[j];
      j--;
      A[j+1] = key;
    }
    trace(A, n);
  }

  return 0;
}

Measured memory_bytes: 608
#include <iostream>
#include <algorithm>
#include <complex>
#include <iomanip>
/*２点 P1(x1, y1), P2(x2, y2) の距離を求めるプログラムを作成せよ。
 */
using namespace std;

int main(){
	double x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	cout << setprecision(100) << sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
}



Measured memory_bytes: 3236
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)

n,k = map(int,input().split())
a = list(map(int,input().split()))

bit_sum = [0]*40
keta = [0]*40

for i in a:
    for j in range(40):
        if i&2**j == 2**j:
            bit_sum[j] += 1

k_bit = [0]*40
flag = False

for i in range(40):
    if k&2**i == 2**i:
        k_bit[i] = 1

def count(ke):
    global flag
    if ke == -1:
        return 0
    if k_bit[ke] == 1:
        if flag:
            return max(2**ke*bit_sum[ke],2**ke*(n-bit_sum[ke]))+count(ke-1)
        else:
            if 2**ke*(n-bit_sum[ke]) > 2**ke*bit_sum[ke]:
                return 2**ke*(n-bit_sum[ke])+count(ke-1)
            else:
                flag = True
                return 2**ke*bit_sum[ke]+count(ke-1)
    else:
        if flag:
            return max(2**ke*bit_sum[ke],2**ke*(n-bit_sum[ke]))+count(ke-1)
        else:
            return 2**ke*bit_sum[ke]+count(ke-1)

print(count(39))

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int x;
  cin >> x;
  
  if(x < 100){
    cout << 0 << "\n";
    return 0;
  }
  
  if(x >= 2000){
    cout << 1 << endl;
    return 0;
  }
  
  int a, b;
  a = x / 100;
  b = x % 100;
  if(a * 5 >= b){
    cout << 1 << endl;
    return 0;
  }
  else{
    cout << 0 << endl;
    return 0;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX_A 2000001 
#define MAX_C 10000  

int n;
int *A;
int *B;
int C[MAX_C];

void CountingSort()
{
  int i;

  for(i = 0; i < MAX_C; i++)
    {
      C[i] = 0;
    }
  for(i = 1; i <= n; i++)
    {
      C[A[i]]++;
    }
  for(i = 1; i < MAX_C; i++)
    {
      C[i] += C[i - 1];
    }
  for(i = n; i > 0; i--)
    {
      B[C[A[i]]] = A[i];
      C[A[i]]--;
    }
}

int main()
{
  int i;

  scanf("%d", &n);

  A = (int *)malloc((n + 1) * sizeof(int));
  B = (int *)malloc((n + 1) * sizeof(int));

  for(i = 1; i <= n; i++)
    {
      scanf("%d", &A[i]);
    }

  CountingSort();

  for(i = 1; i < n; i++)
    {
      printf("%d ", B[i]);
    }
  printf("%d\n", B[n]);

  return 0;
}

Measured memory_bytes: 16268
#include<vector>
#include<map>
#include<algorithm>
#include<set>
#include<iostream>
#include<string>
#include<set>
#include<queue>
#include<random>

using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")

#define pb push_back
#define ld long double
#define int long long
#define mp make_pair

mt19937 rnd(51);

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    int a, b, n, ans = 0;
    cin >> a >> b >> n;
    int x = min(b - 1, n);
    ans = max(ans, (a * x / b) - a * (x / b));
    cout << ans;
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <numeric>
#include <regex>
#include <climits>

#define FOR(i, f, n) for(int (i) = (f), TMPend = (n); (i) < TMPend; (i)++)
#define RFOR(i, f, n) for(int (i) = (f), TMPend = (n); (i) >= TMPend; (i)--)
#define REP(i, n) for(int (i) = 0, TMPend = (n); (i) < TMPend; (i)++)
#define RREP(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define rep(i, n) for(int (i) = 0, TMPend = (n); (i) < TMPend; (i)++)
#define rrep(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define forin(i, a) for(auto i: (a))
#define p(...) printf(__VA_ARGS__); cout << endl;
#define in(...) __VA_ARGS__; input__(__VA_ARGS__);
#define input(...) in(__VA_ARGS__)
#define out(...) output__(__VA_ARGS__);
#define output(...) out(__VA_ARGS__)
#define list_input(x, n) x[(n)]; for(int (i) = 0; (i) < (n); (i)++) cin >> x[i];
#define lambda(a, b, c) [](auto const &a, auto const &b){ return c ;}
#define key(t, x, compare) [](const t &a, const t &b){ return a x compare b x ;}
#define unless(a) if(!(a))

using namespace std;

using pii = pair<int, int>;

template <class... T>
void input__(T &...a) {
  for(auto v: {&a...}) {
    cin >> *v;
  }
}

void output__(){
  cout << endl;
}

template <class Head, class... T>
void output__(Head const &v, T const &...a) {
  if(sizeof...(a) == 0) {
    cout << v;
  } else {
    cout << v << " ";
  }
  output__(a...);
}
struct D {
  int x, y;
};

int h, w, ch, cw, dh, dw;
int main(){
  vector<D> directions = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
  vector<D> magic(25);
  REP(i, 5) REP(j, 5) {
    magic[i * 5 + j] = {i - 2, j - 2};
  }

  cin >> h >> w >> ch >> cw >> dh >> dw;
  ch--; cw--; dh--; dw--;

  vector<string> s(h);
  REP(i, h) cin >> s[i];
  struct Value {
    int cost, y, x;
  };
  auto comp = [&](Value &v1, Value &v2){
    return v1.cost > v2.cost;
  };
  priority_queue<Value, vector<Value>, decltype(comp)> que(comp);

  que.push({0, ch, cw});
  vector<vector<int>> visited(h, vector<int>(w, -1));
  while(!que.empty()) {
    Value value = que.top();
    que.pop();
    if(visited[value.y][value.x] != -1) continue;
    visited[value.y][value.x] = value.cost;

    for (auto d: directions) {
      int ny = value.y + d.y;
      int nx = value.x + d.x;
      if (0 <= ny && ny < h && 0 <= nx && nx < w && s[ny][nx] == '.') {
        que.push({value.cost, ny, nx});
      }
    }

    for (auto d: magic) {
      int ny = value.y + d.y;
      int nx = value.x + d.x;
      if (0 <= ny && ny < h && 0 <= nx && nx < w && s[ny][nx] == '.') {
        que.push({value.cost + 1, ny, nx});
      }
    }
  }

  cout << visited[dh][dw] << endl;
  /* for(auto v: visited) { */
  /*   for (auto vv: v) { */
  /*     cout << vv << " "; */
  /*   } */
  /*   cout << endl; */
  /* } */
}


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

#define FOR(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define FORN(i, m, n) for(int (i) = (m); (i) <= (n); (i)++)
#define FORR(i, m, n) for(int (i) = (m); (i) >= (n); (i)--)
#define rep(i, n) FOR(i, 0, n)
#define repn(i, n) FORN(i, 1, n)
#define repr(i, n) FORR(i, n, 0)
#define repnr(i, n) FORR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> Vec;

const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

struct Edge{
	ll no;
	ll to;
};

ll maxi = 0;
vector<vector<Edge> > tree;
Vec edges;

void dfs(ll node, ll color){
	for(Edge e : tree[node]){
		if(!edges[e.no]){
			color = color%maxi+1;
			edges[e.no] = color;
			dfs(e.to, color);
		}
	}
}

int main(void){
	ll n;
	cin >> n;
	edges.resize(n-1);
	tree.resize(n);
	
	rep(i, n-1){
		ll a, b;
		cin >> a >> b;
		a--; b--;
		tree[a].pb(Edge {i, b});
		tree[b].pb(Edge {i, a});
	}
	rep(i, n){
		maxi = max(maxi, (ll)tree[i].size());
	}

	dfs(0LL, 0LL);
	
	co(maxi);
	rep(i, n-1) co(edges[i]);

	return 0;
}


Measured memory_bytes: 8704
/// Bismillahir Rahmanir Rahim
//Author: Tanvir Hussain
//ICE,NSTU
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
const long long MOD = 1000000007;
#define SET(x) memset(x, 0, sizeof(x))
#define SET2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define SETBOOL(x) memset(x,false,sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define PII pair<int, int>
#define pf printf
#define sf scanf
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define no1 __builtin_popcount
#define BOUNDARY(i, j) ((i >= 0 && i < row) && (j >= 0 && j < column))
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define sz(a) int(a.size())
#define ff first
#define ss second
#define endl "\n"
#define forch(it,s) for(auto it:s)
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >


int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}
double sq(double x) {return x*x;}
void solve(){
    int n,k;
    cin>>n>>k;
    int cnt=0;
    while(n!=0){
        n/=k;
        cnt++;
    }
    cout<<cnt<<endl;
}

signed main()

{
    IOS;
    /*#ifndef ONLINE_JUDGE
        freopen ("data.in","r",stdin);
        freopen ("data.out","w",stdout);
    #endif*/
    int t;
    t=1;
    while(t--){
        solve();
    }

     return 0;

}
///Alhamdulillah




Measured memory_bytes: 256
dic = {"AC":0, "WA":0, "TLE":0, "RE":0}
a = int(input())
for _ in range(a):
    s = str(input())
    dic[s] += 1
print("AC x " + str(dic["AC"]))
print("WA x " + str(dic["WA"]))
print("TLE x " + str(dic["TLE"]))
print("RE x " + str(dic["RE"]))


Measured memory_bytes: 69860
#define DEBUG 0
#include <algorithm>
#include <cmath>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using tll = tuple<ll, ll, ll>;
#define pb push_back
#define all(v) v.begin(), v.end()
#define for1(i, n) for (ll i = 0; i < (n); i++)
#define for2(i, m, n) for (ll i = (m); i < (n); i++)
#define for3(i, m, n, d) for (ll i = (m); i < (n); i += (d))
#define INF (1LL << 60)
#if DEBUG
#define dump(v1) dump_1(#v1, v1)
#define dump2(v1, v2) dump_2(#v1, v1, #v2, v2)
#define dump3(v1, v2, v3) dump_3(#v1, v1, #v2, v2, #v3, v3)
#else
#define dump(v1)
#define dump2(v1, v2)
#define dump3(v1, v2, v3)
#endif
#if DEBUG
template <typename T> void dump_1(const string &n1, const T &v1) {
    cerr << n1 << ": " << v1 << endl;
}
template <typename T1, typename T2>
void dump_2(const string &n1, const T1 &v1, const string &n2, const T2 &v2) {
    cerr << n1 << ": " << v1 << "  " << n2 << ": " << v2 << endl;
}
template <typename T1, typename T2, typename T3>
void dump_3(const string &n1, const T1 &v1, const string &n2, const T2 &v2,
            const string &n3, const T3 &v3) {
    cerr << n1 << ": " << v1 << "  " << n2 << ": " << v2 << "  " << n3 << ": "
         << v3 << endl;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &v) {
    os << "(" << v.first << ", " << v.second << ")";
    return os;
}
template <typename T1, typename T2, typename T3>
ostream &operator<<(ostream &os, const tuple<T1, T2, T3> &v) {
    os << "(" << get<0>(v) << ", " << get<1>(v) << ", " << get<2>(v) << ")";
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    for (auto it = v.begin(); it != v.end(); it++) {
        if (it != v.begin()) {
            os << ", ";
        }
        os << *it;
    }
    os << "]";
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const set<T> &v) {
    os << "{";
    for (auto it = v.begin(); it != v.end(); it++) {
        if (it != v.begin()) {
            os << ", ";
        }
        os << *it;
    }
    os << "}";
    return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &v) {
    os << "{";
    for (auto it = v.begin(); it != v.end(); it++) {
        if (it != v.begin()) {
            os << ", ";
        }
        os << it->first << ":" << it->second;
    }
    os << "}";
    return os;
}
#endif // DEBUG
void Yes(void) { cout << "Yes" << endl; }
void No(void) { cout << "No" << endl; }
void YES(void) { cout << "YES" << endl; }
void NO(void) { cout << "NO" << endl; }
template <typename T> void print(const T &v) { cout << v << endl; }
//---------------------------------------------------------

void solve() {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    print(max(A * B, C * D));
}

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


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int S=0;
    int up=0,temp=0,down=0;
    scanf("%d",&S);
    temp=S/100;
    up=temp*100;
    down=S-up;
    if(up>1200){
        if(down>12||down<1){
            printf("NA\n");
        }
        else{
            printf("YYMM\n");
        }
    }
    else{
        if(down<1){
            if(up<1){
                printf("NA\n");
            }
            else{
                printf("MMYY\n");
            }
        }
        else if(down>12){
            if(up<1){
                printf("NA\n");
            }
            else {
                printf("MMYY\n");
            }
            
        }
        else{
            if(up<1){
                printf("YYMM\n");
            }
            else {
                printf("AMBIGUOUS\n");
            }
        }
    }
    
    return 0;
}

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

int main()
{
    char a,b;
    scanf("%c %c",&a,&b);
    while((a == 'H' || a == 'D') && (b == 'H' || b == 'D'))
    {
        if(a == 'H' && b == 'H')
        {
            printf("H\n");
            break;
        }

        else if(a == 'H' && b == 'D')
        {
            printf("D\n");
            break;
        }

        else if(a == 'D' && b == 'D')
        {
            printf("H\n");
            break;
        }

        else if(a == 'D' && b == 'H')
        {
            printf("D\n");
            break;
        }

    }

    return 0;
}


Measured memory_bytes: 128
%:include <cstdio>
%:include <algorithm>
using namespace std;

int main() <%
  for(int tci = 0; ; tci++) <%
    int n; scanf("%d", &n);
    if(n==0) break;
    int minv = 1000, maxv=0, sum=0;
    for(int i = 0; i < n; i++) <%
      int x; scanf("%d", &x);
      minv=min(minv,x);
      maxv=max(maxv,x);
      sum+=x;
    %>
    printf("%d\n", (sum-maxv-minv)/(n-2));
  %>
  return 0;
%>

Measured memory_bytes: 1028
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

signed main(){

	lli h,w;
	cin>>h>>w;

	lli data[10][10]={0};
	REP(i,0,h)REP(j,0,w){
		char tmp;
		cin>>tmp;
		data[i][j]=(tmp=='#');
	}

	lli sx=0,sy=0;

	if(data[sy][sx]==0){
		cout<<"Impossible"<<endl;
		return 0;
	}

	while(1){
		data[sy][sx]=0;
		bool move=true;
		if(data[sy][sx+1]==1)sx++;
		else{
			if(data[sy+1][sx]==1)sy++;
			else{
				move=false;
			}
		}
		if(!move)break;
	}

	if( (sy != (h-1)) && (sx != (w-1)) ){
		cout<<"Impossible"<<endl;
		return 0;
	}

	for(lli i=0;i<h;i++)for(lli j=0;j<w;j++){
		if(data[i][j]){
			cout<<"Impossible"<<endl;
			return 0;
		}
	}
	cout<<"Possible"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,cnt =0,minj;
  cin >> N;
  int select[N];
  for(int i=0;i<N;i++){
    cin >> select[i];
  }
  for(int i=0;i<N-1;i++){
    minj=i;
    for(int j=i;j<=N-1;j++){
      if (select[j] < select[minj]){
	minj = j;
      }
    }
    if(i!=minj){
    swap(select[i],select[minj]);
    cnt++;
    }
  }
  for(int i=0;i<N;i++){
    if(i!=N-1){
      cout << select[i] <<" ";
    }
    else{
      cout << select[i] << endl;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std ;
using ll = long long ;
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()

int main(){
	ll x,y,z,k ;
	cin >> x >> y >> z >> k ;
	vll a(x),b(y),c(z) ;
	for(auto &i:a) cin >> i ;
	for(auto &i:b) cin >> i ;
	for(auto &i:c) cin >> i ;
	sort(all(a)) ; reverse(all(a)) ;
	sort(all(b)) ; reverse(all(b)) ;
	sort(all(c)) ; reverse(all(c)) ;
    priority_queue<ll> pq1,pq2 ;
    for(int i=0;i<x;i++) for(int j=0;j<y;j++) pq1.push(a.at(i)+b.at(j)) ;
    vll sum(min(k,x*y)) ;
    for(int i=0;i<min(k,x*y);i++){
        sum.at(i) = pq1.top() ;
        pq1.pop() ;
    }
    for(int i=0;i<min(k,x*y);i++){
        for(int j=0;j<z;j++){
            pq2.push(sum.at(i)+c.at(j)) ;
        }
    }
    for(int i=0;i<k;i++){
        cout << pq2.top() << endl ;
        pq2.pop() ;
    }
}

Measured memory_bytes: 43108
R,G,B,N=map(int,input().split())
cnt=0
a=max(R,G,B)
if a==R:
  b=max(G,B)
elif a==G:
  b=max(B,R)
else:
  b=max(R,G)
c=min(R,G,B)
for i in range(N//a+1):
  for j in range((N-a*i)//b+1):
    if ((N-a*i)-b*j)%c==0:
      cnt+=1
print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int mod = 1e9 + 7;
const int inf = 2e18;

signed main() {
    int N, M;
    cin >> N >> M;
    vector<int> check(N + 1, 0);
    vector<vector<int>> G(N + 1);
    for (int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;
        G[x].push_back(y);
        check[y]++;
    }
    vector<int> start;
    for (int i = 1; i <= N; i++) if (check[i] == 0) start.push_back(i);
    vector<int> dp(N + 1, -1);
    queue<int> next;
    for (int temp : start) {
        dp[temp] = 0;
        next.push(temp);
        while (!next.empty()) {
            int me = next.front();
            next.pop();
            for (int g : G[me]) {
                dp[g] = max(dp[g], dp[me] + 1);
                check[g]--;
                if (check[g] == 0) next.push(g);
            }
        }
    }
    int ans = 0;
    for (int i = 1; i <= N; i++) ans = max(ans, dp[i]);
    cout << ans << endl;
}



Measured memory_bytes: 7296
// Problem : C - /\/\/\/
// Contest : AtCoder - AtCoder Beginner Contest 111
// URL : https://atcoder.jp/contests/abc111/tasks/arc103_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
 struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
int main() 
{
	// && has higher precedence than ||
	ios_base::sync_with_stdio(0); cin.tie(0);    
	int N;
	cin>>N;
	unordered_map<int,int> m0,m1;
	vpi v0,v1;
	v0.reserve(N);
	v1.reserve(N);
	F0R(x,N)
	{
		int nb;
		cin>>nb;
		if(x%2==0)
			m0[nb]++;
		else
			m1[nb]++;
	}
	// int a0=-1,a1=-1;
	for(auto i:m0)
	{
		v0.pb({i.s,i.f});
	}
	for(auto i:m1)
	{
		v1.pb({i.s,i.f});
	}
	sort(v0.rbegin(),v0.rend());
	sort(v1.rbegin(),v1.rend());
	if(v0[0].s!=v1[0].s)
	{
		cout<<N/2-v0[0].f+N/2-v1[0].f<<nl;
	}
	else if(sz(v0)==1 && sz(v1)==1)
	{
		cout<<N/2<<nl;
		// return 0;
	}
	else if(sz(v0)==1)
	{
		cout<<N/2-v1[1].f<<nl;
		// return 0;
	}
	else if(sz(v1)==1)
	{
		cout<<N/2-v0[1].f<<nl;
		// return 0;
	}
	else
	{
		int ans=min(N/2-v0[0].f+N/2-v1[1].f,N/2-v0[1].f+N/2-v1[0].f);
		cout<<ans<<nl;
	}
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 8060
from operator import add, sub
from operator import mul, floordiv
class Two_pointer:
    def __init__(self, cond, init=0, right=add, left=sub):
        self.cond = cond
        self.s = init
        self.next_right = right
        self.next_left = left
        
    def __call__(self, A):
        s = self.s
        cond = self.cond
        next_right, next_left = self.next_right, self.next_left
        n = len(A)
        X = []
        r = 0
        for l in range(n):
            while r < n and cond(s, A[r]):
                s = next_right(s, A[r])
                X.append((l, r+1))
                r += 1
            if l == r:
                r += 1
            else:
                s = next_left(s, A[l])
        return X

n, *A = map(int, open(0).read().split())
X = Two_pointer(lambda s, n: s + n == s ^ n)(A)
print(sum(r-l for l, r in X))

Measured memory_bytes: 44420
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())

z=[]
w=[]
for i in range(n):
  x,y=nii()
  z.append(x-y)
  w.append(x+y)

z_ans=max(z)-min(z)
w_ans=max(w)-min(w)
print(max(z_ans,w_ans))

Measured memory_bytes: 24904
using System;
using System.Diagnostics;
using System.Collections.Generic;

class Myon

{
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }
    static Scanner cin;

    void calc()
    {
        if (calc2()) Console.WriteLine("Yes");
        else
        {
            Console.WriteLine("No");
        }
    }
    
    bool calc2()
    {
        int N = cin.nextInt();

        int pret = 0;
        int prex = 0;
        int prey = 0;

        for (int i = 0; i < N; i++)
        {
            int t = cin.nextInt();
            int x = cin.nextInt();
            int y = cin.nextInt();

            int tdiff = t - pret;
            int diff = Math.Abs(y - prey) + Math.Abs(x - prex);
            if (diff > tdiff || (tdiff - diff) % 2 == 1) return false;
            pret = t;
            prex = x;
            prey = y;
        }

        return true;
    }

}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}




Measured memory_bytes: 13268
def update(A,N):
    B=[0 for i in range(N+1)]

    for i in range(N):
        l = max(0,i-A[i])
        r = min(N,i+A[i]+1)
        B[l]+=1
        B[r]-=1
    x = A[0] == B[0]
    A[0]=B[0]
    for i in range(1,N):
        B[i]+=B[i-1]
        x = x and A[i] == B[i]
        A[i]=B[i]
    return x

def resolve():
    N,M = map(int,input().split())
    A = list(map(int,input().split()))
    for i in range(M):
        x=update(A,N)
        if x:
            break
    print(" ".join(map(str,A)))
resolve()


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

int main () {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x, y, c;
    cin >> x >> y;
    c = y;
    int nb[x];
    for (int i = 0; i < x; i ++) {
        nb[i] = -1;
    }
    int a, b;
    bool guess = true;
    while (c -- && guess) {
        cin >> a >> b;
        if (nb[a - 1] != -1 && nb[a - 1] != b) {
            guess = false;
        }
        if ((b == 0 && a == 1) && x > 1) {
            guess = false;
        }
        nb[a - 1] = b;
    }
    if (guess) {
        if (nb[0] == -1 && x > 1) {
            nb[0] = 1;
        }
        for (int i = 0; i < x; i ++) {
            if (nb[i] != -1) {
                cout << nb[i];
            } else {
                cout << 0;
            }
        }
    } else {
        cout << -1;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
// #define int ll
using namespace std;
const int INF (1 << 30);
const ll LLINF (1LL << 55LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi=3.14159265358979;



ll n,x[1010],y[1010];

double length(double theta) {
    double dx = cos(theta);
    double dy = sin(theta);
    double len = 0;
    rep(i, n) {
        len += max(0.0, x[i] * dx + y[i] * dy);
    }
    return len;
}



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll F = 500000;
    double ans=0.0;
    cin>>n;
    rep(i,n){
        cin>>x[i]>>y[i];
    }
    rep(i,F){
        ans=max(ans,length(2*pi*i/F));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;
#define mp make_pair
typedef pair<int, int> pint;
const int INF = 100000000;

int h, w, n;
char maze[1000][1000];
int i, j;

struct {
	int x, y;
} dir[4] = {
	{1, 0}, // right
	{0, 1}, // down
	{-1, 0}, // left
	{0, -1} // up
};

int dist[1000][1000];

int bfs(int hp) {
	for(int x = 0; x < w; x++) {
		for(int y = 0; y < h; y++) {
			dist[y][x] = INF;
		}
	}
	dist[i][j] = 0;
	queue<pint> q;
	q.push(mp(i, j));
	while(!q.empty()) {
		int y = q.front().first;
		int x = q.front().second;
		q.pop();
		if(maze[y][x] == (char)('0' + hp)) {
			i = y;
			j = x;
			maze[i][j] = '.';
			break;
		}
		for(int k = 0; k < 4; k++) {
			int nx = x + dir[k].x;
			int ny = y + dir[k].y;
			if(0 <= nx && nx < w && 0 <= ny && ny < h && maze[ny][nx] != 'X') {
				if(dist[ny][nx] == INF) { // never searched
					dist[ny][nx] = dist[y][x] + 1;
					q.push(mp(ny, nx));
				}
			}
		}
	}
	int ret = dist[i][j];
	return ret;
}

int main() {
	scanf(" %d %d %d", &h, &w, &n);
	for(int y = 0; y < h; y++) {
		scanf(" %s", maze[y]);
	}
	int ans = 0;
	for(int x = 0; x < w; x++) {
		for(int y = 0; y < h; y++) {
			if(maze[y][x] == 'S') {
				i = y;
				j = x;
				maze[y][x] = '.';
				break;
			}
		}
	}
	for(int x = 1; x <= n; x++) {
		ans += bfs(x);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 5668
#include <stdio.h>

int main() {
	char s1[10], s2[10], s3[10];

	scanf("%s %s %s", s1, s2, s3);

	printf("%c%c%c\n", s1[0] - 32, s2[0] - 32, s3[0] - 32);

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <math.h>
#include <assert.h>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
#include <time.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stack>
#include <ctype.h>
#include <numeric>
#include <sstream>
#include <unistd.h>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <random>
#include <chrono>
#include <iomanip>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using ll = long long;
#define endl '\n'
#define debug(name) DEBUG(#name, (name))
template<typename T>
void DEBUG(string label, T value) {
    cerr << "[" << label << " = " << value << "]\n";
}

void solve(){
    int n;
    cin>> n;
    vector<int> arr(n);
    for(int i = 0; i < n; ++i){
        cin >> arr[i];
    }
    sort(arr.begin(), arr.end());
    int 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(arr[i] != arr[j] && arr[j] != arr[k] && arr[i] + arr[j] > arr[k]){
                    ++ans;
                }
            }
        }
    }
    cout << ans << endl;
}
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    solve();
}


Measured memory_bytes: 3664
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll ab, bc, ca;
  cin >> ab >> bc >> ca;
  cout << bc * ab / 2 << endl;
  return 0;
}

Measured memory_bytes: 3620
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144 * 4LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

void init() {
    iostream::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}


#define int ll

unsigned long xor128() {
    static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned long t = (x ^ (x << 11));
    x = y; y = z; z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void solve() {
    while (true) {
        int n, k;
        cin >> n >> k;
        if (n == 0) return;
        string ans;
        int bo = 9;
        for (int i = 1;; ++i) {
            if (bo * i >= n) {
                int geko = (n - 1) / i;
                n -= geko * i;
                geko += bo / 9;
                while (ans.length() <= 1000) {
                    ans += to_string(geko);
                    geko++;
                }
                break;
            }
            else {
                n -= bo * i;
            }
            bo *= 10;
        }
        reverse(ALL(ans));
        while (n > 1) {
            ans.pop_back();
            n--;
        }
        reverse(ALL(ans));
        REP(i, k) {
            cout << ans[i];
        }
        cout << endl;
    }
}

#undef int
int main() {
    init();
    solve();
}



Measured memory_bytes: 3220
from bisect import bisect_left

N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
B = sorted(A)
for i in range(N):
    for j in range(i + 1, N):
        if A[i] > A[j]:
            ans += 1
ans *= K
S = set(A)
less = [0] * 2000
for s in S:
    less[s - 1] = bisect_left(B, s)
    ans += bisect_left(B, s) * A.count(s) * (K * (K - 1)) // 2
    ans %= 10 ** 9 + 7

print(ans)


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

int main(){
    int n;
    cin >> n;
    int a[n];
    int sum = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }
    int ans = 1000000000;
    int tmp = 0;
    for(int i = 0; i < n; i++){
        if(ans > abs(sum - a[i] * n)){
            ans = abs(sum - a[i] * n);
            tmp = i;
        }
    }
    cout << tmp << endl;

    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define SE second
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define mp make_pair
#define LL long long
#define LI long int
#define LLI long long int
#define REP(i,a,b) for(long long i=a;i<b;i++)
#define PER(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl

using namespace std;
int main() {
    string T,P="AC";
    LL q;
    cin >>T>>q>>T;
    LL a[100001];
    for (LL i = 0; i + P.size() <= T.size(); i++) {
        if (P==T.substr(i,2)) {
            a[i+1]=a[i]+1;
        }else{
            a[i+1]=a[i];
        }
    }
    REP(i,0,q){
        LL r,l;
        cin>>l>>r;
        cout<<a[r-1]-a[l-1]<<endl;
    }
}



Measured memory_bytes: 1792
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class D
{
	public static void Main()
	{
		string S = GetString();

		int tMin = S.Length;
		for(int i = 0; i < S.Length - 1; i++)
		{
			if(S[i] != S[i+1])
				tMin = Math.Min(tMin, Math.Max(i+1, S.Length-1-i));
		}
		
		Console.WriteLine(tMin);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

Measured memory_bytes: 13908
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << "\n"; }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}


#line 2 "tmp.cpp"

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

  int n;
  cin >> n;
  vector<string> str(n);
  REP(i, n) { cin >> str[i]; }

  vector<pair<int, int>> up, down;
  for (const auto s : str) {
    int bottom = 0;
    int left = 0;
    int depth = 0;
    for (const auto c : s) {
      if (c == '(') {
        left++;
        depth--;
      } else {
        depth++;
        left--;
      }
      chmax(bottom, depth);
    }

    if (left >= 0) {
      up.push_back({bottom, left});
    } else {
      down.push_back({bottom + left, -left});
    }
  }

  auto comp = [](pair<int, int> r, pair<int, int> l) -> bool {
    if (r.first > l.first) {
      return false;
    }
    if (r.first < l.first) {
      return true;
    }
    return r.second > l.second;
  };

  sort(ALL(up), comp);
  sort(ALL(down), comp);
  int up_cur = 0;
  for (const auto e : up) {
    if (up_cur - e.first < 0) {
      cout << "No" << endl;
      return 0;
    }
    up_cur += e.second;
  }

  int down_cur = 0;
  for (const auto e : down) {
    if (down_cur - e.first < 0) {
      cout << "No" << endl;
      return 0;
    }
    down_cur += e.second;
  }
  say<string>(up_cur == down_cur);
  return 0;
}


Measured memory_bytes: 42436
using System;
namespace pro
{
    class MainClass
    {
        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            int count = 1;
            for (int i = 0; i < 3; i++)
            {
                count *= n;
            }
            Console.WriteLine(count);

        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
double s;
int main(){
   int n;
   cin>>n;
  vector<double>v(n);
  rep(i,n)cin>>v[i];
  sort(v.begin(),v.end());
  
 if(n==2){
    cout<<(v[0]+v[1])/2.0<<endl;
    return 0;
  }
  else if(n==3){
   cout<<(((v[0]+v[1])/2.0)+v[2])/2.0<<endl;
    return 0;
  }
  else{
    s=(((v[0]+v[1])/2.0)+v[2])/2.0;
   for(int i=3;i<n;i++){
    s=(s+v[i])/2.0;
   }
  }
 
  
 
cout<<s<<endl;
}


Measured memory_bytes: 256
def Schedule(schedule):
    """
    :return: 複数の区間が与えられた時の重複の無い区間の選び方の最大数
    """
    schedule = sorted(schedule, key=lambda x: x[1])
    N = len(schedule)
    res = 0
    end = -float("inf")

    for i in range(N):
        if end <= schedule[i][0]:  # 重複がダメならば等号を消す
            end = schedule[i][1]  # 終点でソートされているので、自動的に可能な中で最速の終点が選ばれている
            res += 1
    return res

################################################################################

import sys
input = sys.stdin.readline

N = int(input())
schedule = []
for i in range(N):
    x, l = map(int, input().split())
    schedule.append((x - l, l + x))             # schedule = (始点、終点)

print(Schedule(schedule))

Measured memory_bytes: 83984
n=int(input())
lst=list(map(int,input().split()))
count=0
for i in range(n-1):
    minlst=min(lst[i:])
    if lst[i]==minlst:continue
    count+=1
    for j in range(i+1,n):
        if minlst==lst[j]:
            lst[i],lst[j]=lst[j],lst[i]
            break
print(*lst)
print(count)


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

int main()
{
	int a, b;
	cin >> a >> b;

	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
	{
		cout << "Possible" << endl;
	}
	else
	{
		cout << "Impossible" << endl;
	}
}


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



int main(){

    int n,m;
    cin>>n>>m;
    vector<pair<ll,ll>> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i].first>>a[i].second;
    }
    sort(a.begin(),a.end());
    ll ans=0;
    for(int i=0;i<n;i++){
        if(m<=0)
            break;
        ans+=min((ll)m,a[i].second)*a[i].first;
        m-=min((ll)m,a[i].second);
    }
    cout<<ans;


return 0;
}


Measured memory_bytes: 4828
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt();
    if(n==1)
    {
        cout<<"1\n";
        return 0;
    }
    vector <int> primes;
    SieveOfEratosthenes(sqrt(n),primes);
    int p=primes.size();
    map <int,int> m;
    for(int i=1;i<=n;i++)
    {
        int x=i;
        for(int j=0;j<p&&primes[j]*primes[j]<=x;j++)
        {
            while(x%primes[j]==0)
            {
                x/=primes[j];
                m[primes[j]]+=1;
            }
        }
        if(x>1)
            m[x]+=1;
    }
    ll mod=1e9+7;
    ll test=1;
    for(auto it=m.begin();it!=m.end();it++)
        (test*=(it->second+1))%=mod;
    cout<<test<<endl;
    
    return 0;   
}




 
 


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

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

bool b[114514];

signed main() {
	int n, m;
	cin >> n >> m;
	int dp[114514];
	fill(dp, dp + n + 1, 0);
	rep(i, n + 1) {
		b[i] = true;
	}
	rep(i, m) {
		int a;
		cin >> a;
		b[a] = false;
	}
	dp[0] = 1;
	if (b[1]) dp[1] = 1;
	for (int i = 2; i <= n; i++) {
		if (b[i]) {
			dp[i] = dp[i - 1] + dp[i - 2];
			dp[i] %= mod;
		}
	}
	cout << dp[n] << endl;

	return 0;
}


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

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

  string ans = (N ? "" : "0");

  while (N) {
    ans = (N & 1 ? "1" : "0") + ans;
    N = (N > 0 ? - N / 2 : - (N - 1) / 2);
  }

  cout << ans << "\n";
}

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

namespace AtCoder
{
	public class Program
	{

		static void Main(string[] args)
		{
			int[] vs = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();

			int A = vs[0];
			int B = vs[1];

			int sum = 0;
			for (int i = 0; i < 2; i++) {
				if (A > B) {
					sum += A;
					A--;
				} else {
					sum += B;
					B--;
				}
			}
			Console.WriteLine(sum);
		}
	}
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
int main() {
    char g[101][101];
    int n , m; cin>>n>>m;
    for(int i = 1 ; i <= n; ++i){
        for(int j = 1 ; j <= m; ++j){
            cin>>g[i][j];
        }
    }
    for(int i = 1 ; i <= 2 * n ; i++){
       for(int j = 1 ; j <= m; ++j){
          cout << g[(i + 1) / 2][j]<<"";
       }
       cout << endl;
    }

}

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

long inf = 1000000007;


int main() {
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	int count = 0;
	int p = 1;
	for (int i = 0; i < n; i++) {
		if (a[i] == p) {
			count++;
			p++;
		}
	}
	if (count == 0) {
		cout << -1 << endl;
	}
	else {
		cout << n - count << endl;
	}
}

Measured memory_bytes: 1152