akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<queue>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdio>
using namespace std;
#define N 100000
#define M 300000
#define HT 1000000000
#define INF 2e18
#define int long long
#define MP(i, j) make_pair((i), (j))
typedef pair<int, int> P;
int n, m, x, ans = INF, tree[N + 1];
vector<P> g[N + 1];
int flag[N + 1] = {};


struct S {
	int to, ti, nh;
	S(int i_to, int i_ti, int i_nh) : to(i_to), ti(i_ti), nh(i_nh) {}
	bool operator < (const S & s)const {
	  if(ti != s.ti)
		return ti > s.ti;
	}
};
priority_queue<S> pq;
void dijkstra(int sta) {
	for (int i = 0; i < g[1].size(); i++) {
		if (tree[1] >= g[1][i].second) {
			if (sta >= g[1][i].second) {
				if (sta > g[1][i].second + tree[g[1][i].first]) {
					pq.push({g[1][i].first, sta - tree[g[1][i].first],  tree[g[1][i].first] });
				}
				else {
					pq.push({g[1][i].first, g[1][i].second, sta - g[1][i].second });
				}
			}
			else {
				if (g[1][i].second - sta <= tree[1])
					pq.push({g[1][i].first, g[1][i].second - sta + g[1][i].second, 0 });
			}
		}
	}
	while (!pq.empty()) {
		S s = pq.top();
		pq.pop();
		if (flag[s.to] && flag[s.to] <= s.ti) continue;
		flag[s.to] = s.ti;
		if (s.to == n) {
			ans = min(ans, tree[n] - s.nh + flag[s.to]);
			break;
		}
		for (int i = 0; i < g[s.to].size(); i++) {
			if (tree[s.to] >= g[s.to][i].second) {
			  if (s.nh >= g[s.to][i].second) {
					if (s.nh > g[s.to][i].second + tree[g[s.to][i].first]) {
						pq.push({g[s.to][i].first, s.nh - tree[g[s.to][i].first] + s.ti,  tree[g[s.to][i].first] });
					}
					else {
						pq.push({g[s.to][i].first, g[s.to][i].second + s.ti, s.nh - g[s.to][i].second });
					}
				}
				else {
					if (g[s.to][i].second - s.nh <= tree[s.to])
						pq.push({g[s.to][i].first, g[s.to][i].second - s.nh+ g[s.to][i].second + s.ti, 0 });
				}
			}
		}
	}
}
signed main() {
  scanf("%ld%ld%ld", &n, &m, &x);
	for (int i = 1; i <= n; i++)
		scanf("%ld", tree + i);
	for (int i = 0; i < m; i++) {
		int a, b, c;
		scanf("%ld%ld%ld", &a, &b, &c);
		g[a].push_back(MP(b, c));
		g[b].push_back(MP(a, c));
	}
		dijkstra(x);
	if (ans != INF)
		cout << ans << endl;
	else
		cout << -1 << endl;
}

Measured memory_bytes: 33288
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int h,a;
    cin >> h >> a;
    cout << (h+a-1)/a << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
int main(){

  char S[4];
  scanf("%s",S);
  //printf("%c\n",S[0]);
  char T[4];
  scanf("%s",T);
  //printf("%c\n",S[0]);
  int ans=0;
  for (int i=0; i<3; i++){
    //printf("%c, %c\n",S[i],T[i]);
    if (S[i]==T[i]){
      ans++;
    }
  }
  //printf("%c\n",S[0]);
  printf("%d\n",ans);

  return 0;
}

Measured memory_bytes: 256
S = input()

flag = 0

for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == 'L':
            flag = 1
    elif i % 2 == 1:
        if S[i] == 'R':
            flag = 1

if flag == 0:
    print('Yes')
else:
    print('No')


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

int main(){
	while(1){	
	int n,s[1000],sa,h;
	cin>>n;
	if(n==0) break;
	for(int i=0;i<n;i++)
		cin>>s[i];
	sa=s[1]-s[0];
	if(sa<0) sa=sa*(-1);
	for(int i=0;i<n-1;i++){
		for(int l=i+1;l<n;l++){
			h=s[l]-s[i];
			if(h<0) h=h*(-1);
			if(sa>=h) sa=h;
		}
	}
	cout<<sa<<endl;
	}	
    return 0;
}


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

int main(){
    int n,mini = 10000,maxi = -10000;
    int all = 0,ans;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    for(int i = 0;i < n;i++){
        cin >> a[i];
        if(i != 0){
            all += abs(a[i] - a[i - 1]);
        }
    }
    all += abs(a[0]);
    all += abs(a[n - 1]);

    for(int i = 0;i < n;i++){
        if(i == 0){
            ans = all - abs(a[0]) -abs(a[1] - a[0]) + abs(a[1]);
        }else if(i == n - 1){
            ans = all - abs(a[n - 1]) -abs(a[n - 1] - a[n - 2]) + abs(a[n - 2]);
        }else{
            ans = all - abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i]) + abs(a[i + 1] - a[i - 1]);
        }
        cout << ans << endl;
    }
}

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

const int INF = 1001001001;
const int mod = 1000000007;

ll pow(ll base, ll order) {
	ll ans = 1;
	rep(i,order - 1) ans *= base;
	return ans;
}

int gcd(int a, int b) {
	if (a < b) {
		int c = a;
		a = b;
		b = c;
	}
	if (b == 0) return a;
	return gcd (b, a % b);
}

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

	vector<bool> good(n, true);
	rep(i, m) {
		int v1, v2;
		cin >> v1 >> v2;
		v1--; v2--;
		if (h[v1] >= h[v2]) good[v2] = false;
		if (h[v1] <= h[v2]) good[v1] = false;
	}
	int ans = 0;
	rep(i, n) if (good[i]) ans++;
	cout << ans << endl;
} 

Measured memory_bytes: 3788
#include<stdio.h>
int main(){
  int x,y;
  int d;
  int m,n;
  scanf("%d%d",&x,&y);
if(x>=y){
  m = x;
  n = y;
}
else{
  m = y;
  n = x;
}
while(n!=0){
  d = n;
  n = m%n;
  m = d;
}
printf("%d\n",m);
return 0;
}


Measured memory_bytes: 2144
# include <bits/stdc++.h>
using namespace std;
long long n,d,b,j,k[200005],k2[200005],w,sum,ans,sum1[200005];
pair <long long, long long> a[200005];
int main()
{
	cin>>n>>d>>b;
	for (int i=1; i<=n; i++)
	{
		cin>>a[i].first>>a[i].second;
	}
	sort(a+1, a+n+1);
     j=1;
	for (int i=1; i<=n;i++)
	{
	     while(k[j]<a[i].first && j<i)
		{
			sum-=sum1[j];
			j++;
		}
		a[i].second-=sum;
		if (a[i].second>0)
		{
		k[i]=a[i].first+2*d;
		if (a[i].second%b==0)
		{
			w=a[i].second/b;
		}
		else
		w=a[i].second/b+1;
		long long bbb=0;
		sum+=max(bbb,w*b);
		sum1[i]=max(bbb,w*b);
		if (w>0)
	     ans+=w;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 7936
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <bitset>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <climits>
#include <ctime>
#include <random>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define eps 1e-9
#define inf 0x3f3f3f3f
#define mod 1000000007
using namespace std;



int main() {
	speed;
	int h, w, m, a, b;
	cin >> h >> w >> m;
	map<int, int>x, y;
	set<pair<int, int>>p;
	for (int i = 0; i < m; ++i) {
		cin >> a >> b;
		x[a]++;
		y[b]++;
		p.insert({ a,b });
	}

	vector<int>mxx, mxy;
	int bx = 0, by = 0;
	for (auto i : x)
		bx = max(bx, i.second);
	for (auto i : x) {
		if (i.second == bx)
			mxx.push_back(i.first);
	}
	for (auto i : y)
		by = max(by, i.second);
	for (auto i : y) {
		if (i.second == by)
			mxy.push_back(i.first);
	}

	int ans = bx+by;
	bool d = 1;
	for (auto i : mxx) {
		for (auto j : mxy) {
			if (!p.count({ i,j })) {
				d = 0;
				goto ans;
			}
		}
	}
	ans:
	cout << ans - d;
}

Measured memory_bytes: 49016
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
    int n, a;
    cin>>n>>a;
    cout<<n*n -a<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;
 
int main() {
  long long int n;
  cin >> n;
  int max = 0;
  for (int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      max = i;
    }
  }
  long long int res = (max - 1) + ((n / max) - 1);
  cout << res << endl;
  return 0;
}

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

using namespace std;

int main(){
  
  long int N, A, B;
  cin >> N >> A >> B;
  
  long int c = N / (A + B);
  long int d = N % (A + B);
  
  long int e = 0;
  if(d < A){
    e = d;
  }
  else{
    e = A;
  }
  
  long int resA = A * c + e;
  
  cout << resA << endl;
  
  return 0;
}

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

int main(){
  int n;
  cin >>n;
  string s;
  cin >>s;
  
  int res=0;
  rep(i,n-2) {
    if(s.substr(i,3)=="ABC")
   res++;
  }
  cout<<res<<endl;
return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
#include <cstring>
#include <numeric>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define repll(i,n) for(long long int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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 int INF = INT_MAX;
const long long LLINF = 1LL<<60;
template <typename T_char>
char ToUpper (char cX) { return toupper(cX); }
//g++ -std=c++1z temp.cpp
//./a.exe
ll digit(ll a){
    ll count = 0;
    for (ll i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }
    }
    return count;
}

uintmax_t comb(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}
//桁数のカウント
//pow(x,n) == x^n
//sum = accumulate(v.begin(),v.end(),0);
using Graph = vector<vector<int>>;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a,   b) * b;}


int digsum(int n) {
      int res = 0;
      while(n > 0) {
          res += n%10;
          n /= 10;
      }
      return res;
  }
#include <iomanip>


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

string s;
cin >> s;
cout << s[0] << s[1] << s[2] << endl;






//////////////////////////////////////////////////////
return 0;}


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

int main() {
    int n;
    cin>>n;
    long long int a[n][3];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>a[i][j];
            if(i>0)
            {
                if(j==0)
                    a[i][j]+=max(a[i-1][j+1],a[i-1][j+2]);
                else if(j==1)
                    a[i][j]+=max(a[i-1][j+1],a[i-1][j-1]);
                else
                    a[i][j]+=max(a[i-1][j-1],a[i-1][j-2]);
            }
        }
    }
    cout<<max(a[n-1][0],max(a[n-1][1],a[n-1][2]));
	return 0;
}

Measured memory_bytes: 5936
using System;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();
            int sum = 1;
            for(int i=0;i<N-1;i++)
            {
                if(S[i] == S[i+1])
                {
                    continue;
                }
                else
                {
                    sum++;
                }

            }
            
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 27644
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(void){
    int k,i,a[100005];
    ll l,r,mid,th,nmax,nmin;
    
    cin >> k;
    for (i=0;i<k;i++) cin >> a[i];
    
    l=0;
    r=1e18;
    while (r-l>1){
        mid=(l+r)/2;
        th=mid;
        for (i=0;i<k;i++){
            th-=th%a[i];
        }
        if (th>=2) r=mid;
        else l=mid;
    }
    
    nmin=r;
    
    l=0;
    r=1e18;
    while (r-l>1){
        mid=(l+r)/2;
        th=mid;
        for (i=0;i<k;i++){
            th-=th%a[i];
        }
        if (th<=2) l=mid;
        else r=mid;
    }
    
    nmax=l;
    
    if (nmax<nmin) cout << -1 << endl;
    else cout << nmin << ' ' << nmax << endl;
    
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void){
  int num;
  char n[128];
  fgets(n,128,stdin);
  sscanf(n,"%d",&num);
  
  int number[num];
  int b[num];
  for(int i=0;i<num;i++){
    scanf("%d",&number[i]);
  }

  int c=num/2;
  int d=num%2;
  int e=0;
  
  for(int i=0;i<num;i++){
    b[c]=number[i];
    if(d==1){
      if(e==0){
	c=c+(i+1);
	e=1;
      }else{
	c=c-(i+1);
	e=0;
      }
    }else if(d==0){
      if(e==0){
	c=c-(i+1);
	e=1;
      }else{
	c=c+(i+1);
	e=0;
      }
    }
  }
  
  for(int i=0;i<num;i++){
    printf("%d ",b[i]);
  }
  printf("\n");
}

Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <vector>
#include <queue>

std::vector<int> a[100000], b[100000];
int n, m, k, x, y, tmp, cnt;

void solve() {
	std::cin >> n >> m >> k;

    for (int i=0; i<m; ++i) {
		std::cin >> x >> y;
		a[x].push_back(y);
		a[y].push_back(x);
	}

	cnt = 0;
	std::vector<bool> done(n + 1, 0);
	std::vector<int> ans(n + 1, 0);
	std::vector<int> groupnum(n + 1);
	std::queue<int> que;
    for (int i=1; i<n+1; ++i) {
		std::vector<int> group;
		if (done[i] == true)
            continue;
		done[i] = true;
		group.push_back(i);
		for (auto nx : a[i]) {
			que.push(nx);
			done[nx] = true;
			group.push_back(nx);
		}
		while (!que.empty()) {
			tmp = que.front();
			que.pop();
			for (auto nx : a[tmp]) {
				if (done[nx] == true)
                    continue;
				que.push(nx);
				done[nx] = true;
				group.push_back(nx);
			}
		}
		for (auto s : group) {
			ans[s] = group.size();
			groupnum[s] = cnt;
		}
		cnt++;
	}

    for (int i=0; i<k; ++i) {
		std::cin >> x >> y;
		if (groupnum[x] == groupnum[y]) {
			b[x].push_back(y);
			b[y].push_back(x);
		}
	}

    for (int i=1; i<n+1; ++i)
		std::cout << ans[i] - a[i].size() - b[i].size() - 1 << " ";
    std::cout << std::endl;
}

int main() {
    std::ios_base::sync_with_stdio(0);
    solve();
    return 0;
}


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

int n;
string str;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    int ans = 0, A = 0, B = 0, AB = 0;
    for (int i = 0; i < n; i++) {
        cin >> str;
        for (int j = 0; j < (int)str.size() - 1; j++)
            if (str[j] == 'A' && str[j + 1] == 'B')
                ans++;
        if (str[(int)str.size() - 1] == 'A')
            A++;
        if (str[0] == 'B')
            B++;
        if (str[0] == 'B' && str[(int)str.size() - 1] == 'A')
            AB++;
    }
    int c = min(A, B);
    if (c == n)
        ans += n - 1;
    else if (A == B && A == AB)
        ans += max(c - 1, 0);
    else
        ans += c;
    cout << ans << "\n";
}


Measured memory_bytes: 256
def count_section_by_zero(data):
  count = 0
  flg = False
  start = 0
  for i, d in enumerate(data):
    if flg is False and d != 0:
      count += 1
      flg = True
      
    if d == 0:
      flg = False
  return count

def input_list():
  return list(map(int, input().split()))

def input_list_str():
  return list(map(str, input().split()))

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c

# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def main():
  n,k = input_list()
  a = n % k
  b = k - a
  print(min(a, b))

import math
import fractions
import collections
import itertools
from functools import reduce
main()

Measured memory_bytes: 64748
#include <iostream>
#include <cmath>
using namespace std;
 
int prime_check(int x){
    int upper = (int)sqrt(x);
    for(int i = 2; i <= upper; i++){
        if(x % i == 0) return 0;
    }
    return 1;
}
 
int main(void){
    int n, x, sum = 0;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> x;
        sum += prime_check(x);
    }
    cout << sum << endl;
 
    return 0;
}


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



int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#ifndef ONLINE_JUDGE
  freopen("in", "r", stdin);
  freopen("out", "w", stdout);
#endif

  int n;
  cin >> n;
  if (n >= 30) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}


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

// header area

int main(){
    int N, K; cin >> N >> K;
    vector<int> vec;
    rep(i, N){
        int tmp; cin >> tmp;
        vec.push_back(tmp);
    }

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

    int ans=0;
    rep(i, K){
        ans += vec[i];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cmath>
#include <iomanip>
#include <array>
#include <algorithm>

//auto print = [](auto x){ std::cout << x; };
auto println = [](auto x){ std::cout << x << std::endl; };
auto read = [](auto &x){ std::cin >> x; };

int main ()
{
  auto const maxn = 1001;
  std::array<double, maxn> s;
  int n;

  read(n);
  while (n != 0)
    {
      std::for_each(s.begin(), s.begin()+n, read);
      auto sqmean = 0.0, mean = 0.0;
      std::for_each(s.begin(), s.begin()+n, [&](auto x){sqmean += x*x; mean += x;});
      sqmean /= n;
      mean /= n;
      auto stdv = std::sqrt(sqmean - mean*mean);

      std::cout << std::setprecision(20);
      println(stdv);

      read(n);
    }
}



Measured memory_bytes: 3300
use std::io;
use std::collections::HashMap;


fn main() {
    let s = read_one::<String>().chars().collect::<Vec<char>>();
    let t = read_one::<String>().chars().collect::<Vec<char>>();

    let mut flg = true;
    let mut s_t = HashMap::new();
    let mut t_s = HashMap::new();
    for i in 0..s.len() {
        let j = s_t.entry(s[i]).or_insert(i);
        let k = t_s.entry(t[i]).or_insert(i);
        if t[*j] != t[i] { flg = false; }
        if s[*k] != s[i] { flg = false; }
    }

    if flg { println!("Yes"); }
    else { println!("No"); }
}

#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 6396
import math
a,b,x = input().strip().split()
a = int(a)
b = int(b)
x = int(x)
if x <= a * a * b /2:
    p = math.degrees(math.atan(a * b * b / 2 / x))
else:
    p = math.degrees(math.atan(2 * (a * a * b - x)/a/a/a))
print(p)

Measured memory_bytes: 3060
primes = [2]
def prime():
    c = 3
    while True:
        for i in primes:
            if i * i > c:
                primes.append(c)
                break
            if c % i == 0:
                break
            
        c += 1
        if c > 10**6:
            return


prime()

def check(a):
    if a == 1:
        return False
    for i in primes:
        if i * i > a:
            return True
        if a % i == 0:
            return False
        i += 1


#print('a')
def solve(a,d,n):
    while True:
        if check(a):
            n -= 1
            if n == 0:
                print(a)
                return 
        a += d 

while True:
    l = input().split(' ')
    a = int(l[0])
    d = int(l[1])
    n = int(l[2])
    if a == 0:
        break
    solve(a,d,n)
            




Measured memory_bytes: 8764
#include <bits/stdc++.h>
#define int long long
#define ll long long int
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
bool tab[10000];
int32_t main()
{
  BOOST;
	int x,n;
	cin>>x>>n;
	for (int i=1;i<=n;i++)
	{
		int a;
		cin>>a;
		tab[a]=true;
	}
	int ans=1e9+9,wsk=-1;
	for (int i=0;i<=1000;i++)
	{
		if (!tab[i] && abs(x-i)<ans){wsk=i,ans=abs(x-i);}
	}
	cout<<wsk;
  return 0;
}

Measured memory_bytes: 3648
#include "bits/stdc++.h"
/* Properties of modulo:
	(a/b)%m ,where m is prime  = (a%m) * (b^(m-2))%m
*/
    /*ROLLING HASH
    Rabin-Karp algorithm for pattern matching in a string in O(n) time
    Calculating the number of different substrings of a string in O(n2logn)
    Calculating the number of palindromic substrings in a string.
    */
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define IOS { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define ll long long
#define pb push_back
#define nl cout<<"\n"
#define endl "\n"
#define all(c) (c).begin(),(c).end()
#define trav(a,x) for(auto a = x.begin() ; a != x.end() ; a++)
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[i].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
//template<typename T>
//#define o_set(T) tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>
// o_set(ll) name ; -- defining ordered set
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : counting from zero it returns the k-th largest or smallest element in the set - returns iterator
bool compare(ll a, ll b){
    return a > b;
}
inline ll max(ll a,ll b)
{return ((a>b)?a:b);}
inline ll min(ll a,ll b)
{return ((a>b)?b:a);}
inline ll gcd(ll a ,ll b)
{if(b==0) return a;a%=b;return gcd(b,a);}
ll power(ll x, ll ex ) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) ;
        ex >>= 1ll;
        x = (x * x) ;
    }
    return ans;
}
void solve(){
    ll n;
    cin >> n;
    bool flag = false;
    for(ll i = -150 ; i <= 150 ; i++){
        for(ll j = -150 ; j<= 150 ; j++){
            if(power(i,5) - power(j,5) == n){
                flag = true;
                cout << i <<" " << j << endl;
            }
        }
        if(flag == true) break;
    }
    if(!flag) cout << "-1\n";
}
int main(){
    IOS;
    ll T=1;
    //cin>>T;
    ll t=0;
    while(t++<T){
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 3780
#include <iostream>

int main() {
	int n, q, s, t;
	std::cin >> n;
	int S[n + 1];
	for (s = 0; s < n; s++) {
		std::cin >> S[s];
	}
	std::cin >> q;
	int T[q];
	for (t = 0; t < q; t++) {
		std::cin >> T[t];
	}
	
	int C = 0;
	for (t = 0; t < q; t++) {
		S[n] = T[t];
		s = 0;
		while (S[s] != T[t]) {
			s++;
		}
		if (s < n) {
			C++;
		}
	}
	
	std::cout << C << std::endl;
	
	return 0;
}


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

#define int long long int
#define vi vector<int>

signed main() {
    int t = 1;
    //cin >> t;
    while(t--) {
        int n, m, k;
        cin >> n >> m >> k;
        vi a(n), b(m);
        for(int i = 0; i < n; i++)  cin >> a[i];
        for(int i = 0; i < m; i++)  cin >> b[i];
        int cnt = 0, sum = 0;
        vi pa(n), pb(m);
        pa[0] = a[0]; pb[0] = b[0];
        for(int i = 0; i < n; i++) {
            sum += a[i];
            pa[i] = sum;
        }
        sum = 0;
        for(int i = 0; i < m; i++) {
            sum += b[i];
            pb[i] = sum;
        }
        int ans = 0, j = m - 1;
        for(int i = 0; i < n; i++) {
            if(pa[i] <= k) {
                ans = max(ans, i + 1);
                int diff = k - pa[i];
                while(j >= 0 && pa[i] + pb[j] > k) {
                    j--;
                }
                if(j >= 0) {
                    ans = max(ans, i + j + 2);
                }
            }
        }
        j = n - 1;
        for(int i = 0; i < m; i++) {
            if(pb[i] <= k) {
                ans = max(ans, i + 1);
                int diff = k - pb[i];
                while(j >= 0 && pb[i] + pa[j] > k) {
                    j--;
                }
                if(j >= 0) {
                    ans = max(ans, i + j + 2);
                }
            }
        }
        cout << ans;
    }
}

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

int main(){
    string s;
    static int tmp,ans=0;
    cin >> s;
    int len = s.length();
    for(int i=0;i<len;i++){
        if(s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C'){
            ++tmp;
        }else{
            ans = max(ans,tmp);
            tmp = 0;
        }
        if(i == len - 1){
            ans = max(ans, tmp);
        }

    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void)
{
	int a;
	double b, c;
	
	scanf("%d", &a);
	b=a;
	c=(b+1)/(2*b);
	
	if(a%2==0){
		printf("%f", 1.0/2.0);
	}

	else{
		printf("%f", c);
	}

	return 0;
}

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

using namespace std;

typedef long long int ll;
const int maxn = 100100;

const int p = 1e9 + 7;
inline int add(const int a, const int b)
{
  return (0ll + a + b) % p;
}
inline int mul(const int a, const int b)
{
  return (1ll * a * b) % p;
}

struct jsum
{
  int s[maxn];
  int qow(int a, int x)
  {
    int ret = 1;
    while (x)
    {
      if (1 & x) ret = mul(ret, a);
      a = mul(a, a);
      x >>= 1;
    }
    return ret;
  }
  jsum(void)
  {
    s[0] = 0;
    for (int i = 1; i < maxn; i++)
    {
      int d = qow(i, p - 2);
      s[i] = add(s[i - 1], d);
    }
  }
  int operator[](const unsigned pos) const { return s[pos]; }
}S;
struct fact
{
  int f[maxn];
  fact(void)
  {
    f[0] = 1;
    for (int i = 1; i < maxn; i++)
    {
      f[i] = mul(f[i - 1], i);
    }
  }
  int operator[](const unsigned pos) const { return f[pos]; }
}f;

int main(void)
{
  int N;
  int ans = 0;
  scanf("%d", &N);
  for (int i = 1; i <= N; i++)
  {
    int Ai;
    scanf("%d", &Ai);
    int d = add(add(S[i], S[N - i + 1]), p - 1);
    ans = add(ans, mul(mul(Ai, f[N]), d));
  }
  printf("%d\n", ans);
  return 0;
}


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

int main() {
  int K;
  string S;
  cin >> K >> S;
  if (K >= S.size())
  {
    cout << S << endl;
  }
  else
  {
    for (int i = 0; i < K; i++)
    {
      cout << S.at(i);
    }
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3588
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn readu() -> usize {
    read::<usize>()
}

#[allow(dead_code)]
fn readi() -> i32 {
    read::<i32>()
}

fn main() {
    input! {
        n: usize,
        mut a: [usize; n + 1],
        b: [usize; n],
    }

    let mut ans = 0;
    for i in 0..(n + 1) {
        let mut pow = 0;
        if i < n {
            pow += b[i];
        }
        if pow > a[i] {
            ans += a[i];
            pow -= a[i];
            if i + 1 < n + 1 {
                if pow > a[i + 1] {
                    ans += a[i + 1];
                    a[i + 1] = 0;
                } else {
                    a[i + 1] = a[i + 1] - pow;
                    ans += pow;
                }
            }
        } else {
            ans += pow;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
char notes[110][10];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n;
	cin >> n;
	vector<ll>a(n), b(n);
	ll total = 0;
	rep(i, n)cin >> a[i];
	rep(i, n)cin >> b[i];
	ll res = 0;
	rep(i, n) {
		if (a[i] < b[i])res += (b[i] - a[i]) / 2;
		if (a[i] > b[i])res -= a[i] - b[i];
	}
	if (res >= 0)puts("Yes");
	else {
		puts("No");
	}
	return 0;
}


Measured memory_bytes: 3752
#include<stdio.h>
#include<algorithm>
using namespace std;
int d[10][10];
int main(){
	int h,w;
	scanf("%d%d",&h,&w);
	for(int i=0; i<10; i++)for(int j=0; j<10; j++)scanf("%d",&d[i][j]);
	for(int k=0; k<10; k++)for(int i=0; i<10; i++)for(int j=0; j<10; j++)
		d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
	int res=0;
	for(int i=0; i<h; i++)for(int j=0; j<w; j++){
		int x;
		scanf("%d",&x);
		if(x!=-1)res += d[x][1];
	}
	printf("%d\n",res);
	return 0;
}


Measured memory_bytes: 128
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

po = [-1 for i in range(101)]

a = [[0 for i in range(3)] for j in range(3)]

for i in range(3):
    b = l()
    for j in range(3):
        po[b[j]] = i*3 + j

n = onem()

for i in range(n):
    o = onem()
    if po[o] != -1:
        a[po[o]//3][po[o]%3] = 1

fl = False

for i in range(3):
    if sum(a[i]) == 3:
        fl = True

for i in range(3):
    if a[0][i] + a[1][i] + a[2][i]== 3:
        fl = True

if a[0][0] + a[1][1] + a[2][2] == 3:
    fl = True

if a[0][2] + a[1][1] + a[2][0] == 3:
    fl = True

if fl:
    print("Yes")
else:
    print("No")



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

int main() {
	int n, cnt = 0, ans = 0;
	string c;
	cin >> n >> c;
	rep(i, c.size()) if (c[i] == 'R') cnt++;
	rep(i, cnt) if (c[i] == 'W') ans++;
	cout << ans << endl;
}

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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var NK = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var N = NK[0];
            var K = NK[1];
            var hs = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var memo = new List<int>(Enumerable.Range(0, N).Select(s => int.MaxValue));
            Action<List<int>, int, int> chmin =
                (ls, index, val) =>
                {
                    if (val < ls[index]) ls[index] = val;
                };
            memo[0] = 0;
            for (var i = 1; i < N; i++)
            {
                for(var k=K-1;0<=k;k--)
                {
                    if (i - (K - k) < 0) continue;
                    chmin(memo, i, Math.Abs(hs[i - (K-k)] - hs[i]) + memo[i - (K - k)]);
                }
            }
            Console.WriteLine(memo[N - 1]);
        }
    }
}

Measured memory_bytes: 20832
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	long long ans = 0;
	long long n = s.size();
	ans = n * (n - 1) / 2 + 1;
	map<char,int>mp;
	for(int i = 0; i < n; ++i){
		ans -= mp[s[i]]++;
	}
	cout<<ans<<endl;
}


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

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
//~ const int mod = (int)1e9 + 7;
const int mod = 998244353;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};

string conv(int a){stringstream ss;ss << a;string str = ss.str();return str;}
string conv(char a){stringstream ss;ss << a;string str = ss.str();return str;}
int conv(string a){stringstream geek(a); int x = 0; geek >> x;   return x;}



int main(void) 
{	
	string s;
	cin>> s;
	int w = 0, l = 0;
	rep(i,0,sz(s)-1){
		if(s[i] == 'o')
			w++;
		else
			l++;
	}
	int p = 15-sz(s);
	if(p + w >=8)
		cout<<"YES";
	else
		cout<<"NO";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp> 
// using namespace boost::multiprecision;
// #define int cpp_int
using namespace std;

#define fastio 			ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int 			long long
#define ll 				long long
#define ld 				long double
#define vi 				vector<int>
#define pii 			pair<int,int>
#define vpii 			vector< pair<int,int> >
#define uset			unordered_set
#define umap 			unordered_map
#define maxpq 			priority_queue<int>
#define minpq			priority_queue<int,vi,greater<int>()>

#define all(v) 			v.begin(),v.end()
#define part(v,s,e)		v.begin()+s,v.begin()+e
#define rev(v)			reverse(v.begin(),v.end())
#define sz(x)			(int)x.size()
#define def(v)			memset(v,-1,sizeof(v));
#define def0(v)			memset(v,0,sizeof(v));
#define minv(a)			*min_element(all(a))
#define maxv(a)			*max_element(all(a))
#define sumv(a)			accumulate(all(a),0)

#define	lb				lower_bound
#define	ub				upper_bound
#define	desc			greater<int>()
#define	pb				emplace_back
#define	mp				make_pair
#define	F				first
#define	S				second

#define	mod 			1000000007
#define	inf 			1000000000000000
#define infty			1000000000000000000LL
#define	md				998244353
#define	PI				acos(-1.0)
#define	endl 			"\n"
#define	rr				return
#define	br				cout<<"\n";

#define gcd(a,b)		__gcd(a,b)
#define lcm(a,b)		(a/(__gcd(a,b)))*b

#define setbits(x) 		__builtin_popcountll(x)
#define zerobits(x)		__builtin_ctzll(x)

#define ip(v)	 		for(auto& i:v)	cin>>i;
#define op(v) 			for(auto i:v)	cout<<i<<" ";cout<<endl;
#define deb(x) 			cout <<"Value of " #x << " : " << x << endl;


void solve()
{	

	int n;
	cin>>n;

	int a[n];
	ip(a);

	sort(a,a+n);

	float ans=(a[0]+a[1])/(2*1.0);

	for(int i=2;i<n;i++)
	{
		ans=(ans+a[i])/2;
	}
	cout<<ans<<endl;

}	

int32_t main()
{

	fastio
	cout<<setprecision(15)<<fixed;



	int t=1;
	// cin>>t;
	
	for(int i=1;i<=t;i++)
	{
		// cout<<"Case "<<i<<" : "<<endl;
		solve();
	}
	
	#ifndef ONLINE_JUDGE	
		cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
	#endif

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,n,k,inf=1e9+5;
    cin>>n>>k;
    vector<int> dp(n,inf),a(n);
    dp[0]=0;
    for(i=0;i<n;i++)
        cin>>a[i];
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<=i+k;j++)
        {
            if(j<n)
                dp[j]=min(dp[j],dp[i]+abs(a[j]-a[i]));
        }
    }
    cout<<dp[n-1];
    return 0;
}



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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

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


    lint h,w,n;
    cin >> h>>w>>n;

    lint ans, tmp;

    ans = n / max(h, w) + 1 - (n % max(h, w)==0);

    cout << ans <<"\n";

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int H,W;
  std::cin >> H >> W;
  while(H != 0 && W != 0) {
    for(int i = 0; i < H; i++) {
      for(int j = 0; j < W; j++) {
        if (i%2 == 0 ) {
          if(j%2 == 0) {
            printf("#");
          } else {
            printf(".");
          }
        } else {
          if(j%2 == 0) {
            printf(".");
          } else {
            printf("#");
          }
        }
      }
      printf("\n");
    }
    printf("\n");
    std::cin >> H >> W;
  }
  return 0;
}

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


int main(){

	long long n, k;
	cin >> n >> k;
	long long ans=0;
	ans += pow(n/k, 3);

	if(k % 2 == 0){
		ans += pow((n+k/2)/k, 3);
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<stack> 
#include<queue>
#include<cmath>
#include<map>
#include<bitset>
#define LL long long
#define N 100100
#define M 1010
#define MOD 1000000007
#define FOR(i,l,r) for (int i = (l); i <= (r); i ++)
#define CLR(a,x) memset(a,x,sizeof(a))
#define INF 0x3f3f3f3f
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define X first
#define Y second
using namespace std;
int main(){
	int l1,r1,l2,r2;
	cin >> l1 >> r1 >> l2 >> r2;
	printf("%d\n",max(0,min(r1,r2) - max(l1,l2)));
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll X, Y; cin >> X >> Y;
    cout << X + Y / 2 << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main () {
  long a, b, c, d, k;
  cin >> a >> b >> c >> d >> k;
  long min;
  if(a == c){
    min = d - b;
    min -= k;
  } else {
    min = 60 - b;
    a++;
    min += 60 * (c - a) + d;
    min -= k;
  }
  cout << min << endl;
  return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <set>
using namespace std;
typedef long long lint;

// Graph Templates
using Weight = lint;
// using Flow = int;
struct Edge {
    int src, dst;
    Weight weight;
    // Flow cap;
    Edge() : src(0), dst(0), weight(0) {}
    Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;
const Weight INF = numeric_limits<Weight>::max() / 8;

// add edge a <--(weight = w)--> b
void add_edge(Graph &g, int a, int b, Weight w) {
    g[a].push_back(Edge(a, b, w));
    g[b].push_back(Edge(b, a, w));
}

// add edge a --(weight = w)--> b
void add_arc(Graph &g, int a, int b, Weight w) { g[a].push_back(Edge(a, b, w)); }

// Dijkstra
// g is graph, s is start
vector<Weight> dijkstra(const Graph &g, int s) {
    // const Weight INF = numeric_limits<Weight>::max() / 8;
    using state = tuple<Weight, int>;
    priority_queue<state> q;
    vector<Weight> dist(g.size(), INF);
    dist[s] = 0;
    q.emplace(0, s);
    while (q.size()) {
        Weight d;
        int v;
        tie(d, v) = q.top();
        q.pop();
        d *= -1;
        /* if(v == t) return d; */
        if (dist[v] < d) continue;
        for (auto &e : g[v]) {
            if (dist[e.dst] > dist[v] + e.weight) {
                dist[e.dst] = dist[v] + e.weight;
                q.emplace(-dist[e.dst], e.dst);
            }
        }
    }
    return dist;
}

int main(){
    int v, e, r;
    int s, t;
    Weight d;
    Graph g;
    vector<Weight> dist;
    cin >> v >> e >> r;
    g.resize(v);
    for (int i=0; i<e; ++i){
        cin >> s >> t >> d;
        add_arc(g, s, t, d);
    }
    dist = dijkstra(g, r);
    for (int i=0; i<(int)dist.size(); ++i){
        if(dist[i] != INF){
            cout << dist[i] << endl;
        }
        else {
            cout << "INF" << endl;
        }
    }
    
    return 0;
}



Measured memory_bytes: 19404