akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define ALL(a) (a.begin(), a.end())
using ll = long long;
template<typename T> void Out(T x) { cout << x << endl; }
const int maxn = 1e5 + 1;


int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  vector<int> red(A), gr(B), none(C);
  for (int i = 0; i < A; i++) cin >> red[i];
  for (int i = 0; i < B; i++) cin >> gr[i];
  for (int i = 0; i < C; i++) cin >> none[i];
  vector<int> P;
  sort(red.begin(), red.end(), greater<int>());
  for (int i = 0; i < X; i++) P.pb(red[i]);
  sort(gr.begin(), gr.end(), greater<int>());
  for (int i = 0; i < Y; i++) P.pb(gr[i]);
  sort(none.begin(), none.end(), greater<int>());
  for (int i = 0; i < min(X+Y, C); i++) P.pb(none[i]);
  sort(P.begin(), P.end(), greater<int>());
  ll res = 0;
  for (int i = 0; i < X+Y; i++) res += P[i];
  cout << res << endl;
  return 0;

}


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

using namespace std;

const int MOD = 1000000007;

int main(){
    int N, A, B; cin >> N >> A >> B;
    if(A > B) swap(A, B);
    vector<long long> ones(B, 0);
    ones[1] = 1;
    for(int i=1;i<B;i++){
        if(i+1 < B) ones[i+1] = (ones[i+1] + ones[i]) % MOD;
        for(int j=i+A+1;j<B;j++) ones[j] = (ones[j] + ones[i]) % MOD;
    }
    vector dp(N+1, vector(2, 0LL));
    dp[0][0] = dp[0][1] = 1;
    long long res = 1;
    for(int i=0;i<N;i++) res = (2 * res) % MOD;
    for(int i=A;i<B;i++){
        for(int j=i+1;j<B;j++) dp[j][1] = (dp[j][1] + ones[j-i]) % MOD;
    }
    for(int i=0;i<N;i++){
        for(int j=i+1;j<min(i+A, N+1);j++){
            dp[j][0] = (dp[j][0] + dp[i][1]) % MOD;
        }
        for(int j=i+1;j<min(i+B, N+1);j++){
            auto add = dp[i][0] * ones[j-i] % MOD;
            if(N-i < B && N-j >= A) res = (res + MOD - add) % MOD;
            dp[j][1] = (dp[j][1] + add) % MOD;
        }
    }
    for(auto& t : dp.back()) res = (res + MOD - t) % MOD;
    cout << res << endl;
}

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

// 基本テンプレート
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// 型
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// 定数
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion


int main()
{
    int a, b, c, d;
    string s, t, u, v;
    cin >> a >> b >> c >> d;
    P(max(a*b, c*d));
    return 0;
}



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

int main(){
	int y,m,d;
	char c1,c2;
	string ans;
	cin>>y>>c1>>m>>c2>>d;
	if(m<=4){
		ans="Heisei";
	}
	else{
		ans="TBD";
	}
	cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define mp make_pair
#define LL long long
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int main(){
	int n,k;
	cin>>n>>k;
	int ans=0;
	while(n)n/=k,ans++;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
def judge(a,b,k):
	# aのみを食べる場合
	if k <= a: return a-k, b
	# a,bを食べる場合
	rest_k = k-a
	if rest_k <= b: return 0, b-rest_k
	return 0,0

a,b,k = [int(e) for e in input().split(" ")]
a,b = judge(a,b,k)
print(a,b)


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

#ifdef _DEBUG
#define ASSERT(x) assert(x)
#define DLOG(x) cout << #x " " << x << endl;
#else
#define ASSERT(x)
#define DLOG(x)
#endif

using namespace std;

struct Node {
  int parent{-1};
  int sibling{-1};
  int degree{-1};
  int depth{-1};
  int height{-1};
  pair<int, int> children;
};

using Nodes = vector<Node>;

void calcHeight(int height, Nodes& nodes, int i) {
  if (i == -1) {
    return;
  }
  auto& n = nodes[i];
  n.height = max(n.height, height);
  calcHeight(height + 1, nodes, n.parent);
}

int calcDepth(Nodes& nodes, int i) {
  auto& n = nodes[i];
  if (n.depth != -1) {
    return n.depth;
  } else if (n.parent == -1) {
    return n.depth = 0;
  } else {
    return n.depth = calcDepth(nodes, n.parent) + 1;
  }
}

int main() {
  int numNodes;
  cin >> numNodes;
  vector<Node> nodes(numNodes, Node{});
  for (int i = 0; i < numNodes; ++i) {
    int id, left, right;
    cin >> id >> left >> right;
    auto& n = nodes[id];
    auto* lc = left != -1 ? &nodes[left] : nullptr;
    auto* rc = right != -1 ? &nodes[right] : nullptr;
    if (!lc && !rc) {
      n.degree = 0;
    } else if (!lc) {
      n.degree = 1;
      rc->parent = id;
    } else if (!rc) {
      n.degree = 1;
      lc->parent = id;
    } else {
      n.degree = 2;
      rc->parent = id;
      rc->sibling = left;
      lc->parent = id;
      lc->sibling = right;
    }
  }

  for (int i = 0; i < numNodes; ++i) {
    auto& n = nodes[i];
    if (!n.degree) {
      calcHeight(0, nodes, i);
    }
    calcDepth(nodes, i);
  }

  for (int i = 0; i < numNodes; ++i) {
    auto& n = nodes[i];
    cout << "node " << i << ": parent = " << n.parent
         << ", sibling = " << n.sibling << ", degree = " << n.degree
         << ", depth = " << n.depth << ", height = " << n.height << ", ";
    if (n.parent == -1) {
      cout << "root";
    } else if (!n.degree) {
      cout << "leaf";
    } else {
      cout << "internal node";
    }
    cout << endl;
  }
}



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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  int cnt = 0;
  int sum = accumulate(A.begin(), A.end(), 0);
  for (int i = 0; i < N; i++) {
    if (4 * M * A[i] >= sum) {
      cnt++;
    }
  }

  if (cnt >= M) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n;
ll d, s, tree[400005], ans;
struct node {
	ll zb, hb;
} a[200005];
bool cmp(node a, node b) {
	return a.zb < b.zb;
}
int Lowbit(int x) {
	return x&(-x);
}
ll query(int x) {
	ll res = 0;
	while(x) {
		res += tree[x];
		x -= Lowbit(x);
	}
	return res;
}
void update(int x, ll v) {
	while(x <= n) {
		tree[x] += v;
		x += Lowbit(x);
	}
}
int main() {
	cin>>n>>d>>s;
	for(int i = 1; i <= n; i++)
	   cin>>a[i].zb>>a[i].hb;
	sort(a + 1, a + n + 1, cmp);
	for(int i = 1; i <= n; i++) {
		ll dt = a[i].hb - a[i - 1].hb;
		update(i, dt);
	}
	for(int i = 1; i <= n; i++) {
		ll now = query(i);
		if(now <= 0) continue;
		int l = i, r = n, mid;
		ll lim = a[i].zb + 2 * d;
		while(l < r) {
			mid = (l + r + 1) / 2;
			if(a[mid].zb <= lim)
			   l = mid;
			else
			   r = mid - 1;
		}
		ll p = 0;
		if(now % s == 0)
		   ans += now / s, p = now; 
		else
		   ans += now / s + 1, p = (now / s + 1) * s;
		update(i, -p);
		update(r + 1, p);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6400
N = int(input())
X = list(map(int,input().rstrip().split(" ")))
ans = 0
ansb = 0
for i in range(100):
  ansb = 0
  for i2 in range(N):
    ansb += (X[i2] - i)**2
  if i == 0 or ans > ansb:
    ans = ansb
print(ans)


Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
int a[200005];
int b[200005];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
int x=(n-1)/2+1;
int w=0;

for(int i=1;i<=x;i++)
   {
 b[i]=a[n-w];
   w+=2;

}

 w=1;
for(int i=n;i>=x+1;i--)
{

   b[i]=a[n-w];
    w+=2;
}
for(int i=1;i<=n;i++)
    cout<<b[i]<<" ";
    cout<<endl;
return 0;
}


Measured memory_bytes: 3840
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define MOD 1000000007
#define INIT -1

int main() {
	int n, k;
	cin >> n >> k;
	long long int minsum = 0;
	long long int maxsum = 0;
	for (int i = 0; i < k; i++) {
		minsum += i;
		maxsum += n - i;
	}
	long long int ans = 0;
	for (int i = k; i <= n; i++) {
		ans += (maxsum - minsum + 1 + MOD) % MOD;
		ans %= MOD;
		minsum += i;
		maxsum += n - i;
	}
	ans += (maxsum - minsum + 1 + MOD) % MOD;
	ans %= MOD;
	cout << ans << endl;
}

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

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

long long GCD(long long x, long long y) {
    return y ? GCD(y, x%y) : x;
}

int main() {
    long long A, B;
    cin >> A >> B;
    long long G = GCD(A, B);
    auto pf = prime_factorize(G);
    cout << pf.size() + 1 << endl;
}

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

#define f(i,a,b) for( ll i = a; i < b ; i++ )
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(x) (ll) __builtin_popcount(x)
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define mp make_pair  
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tsie(nullptr);cout.tie(nullptr)
#define watch(x) cout << (#x) << " is " << (x) <<"#" <<endl
#define PI 3.1415926535
using namespace std;
typedef long long ll;
typedef long double ld; 
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
const ll mod = 1e9+7;
const ll MAX = 2e5+23;
const ll inf = 1e18+7;

ll a[MAX],dp[MAX],sum[MAX];
int main(){
  fastio;
  ll n;
  cin>>n;
  f(i,0,n){
    cin>>a[i];
  }
  f(i,0,n){
    (sum[i+1]+=a[i])%=mod;
    (sum[i+1]+=sum[i])%=mod;
  }
  f(i,1,n+1){
    dp[i] = (((sum[i-1]*a[i-1])%mod)+dp[i-1])%mod;
  }
  cout<<dp[n]%mod<<"\n";
  return 0; 
}

Measured memory_bytes: 8272
#include "bits/stdc++.h"
using namespace std;
int main(){
    int a;
    int p[100000];
    cin >> a;
    for (int i=0;i<a;i++) cin >> p[i];
    sort(&p[0],&p[a]);
    printf("%d",p[a/2]-p[a/2-1]);
}

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

using namespace std;

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

	vector<int> L(2*N);
	for (auto &e: L) {
		cin >> e;
	}

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

	int ans = 0;
	for (int i = 0; i < 2*N; i += 2) {
		ans += min(L[i], L[i+1]);
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    rep(i,n-1){
        if(s[i] !=s[i+1]) ans++;
    }
    ans++;
    cout << ans << endl;
}



Measured memory_bytes: 512
#include <iostream>
using namespace std;

int main() { 
    int n, x;
    cin >> n >> x;
    
    int m[n];

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

    int min = m[0];

    for(int i = 0; i < n; i++) {
        x -= m[i];
        
        if(min > m[i]) {
            min = m[i];
        }
    }

    cout << n + (x / min) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    double r, a, b;
	scanf("%lf", &r);
	a = r * r * 3.14159265358979323846256433832;
	b = 2 * r * 3.14159265358979323846256433832;
	printf("%f %f\n", a, b);
    return 0;
}


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

ans = True
for i in range(N - 1, 0, -1):
    if H[i] - H[i - 1] == -1:
        H[i - 1] -= 1
    elif H[i] - H[i - 1] < -1:
        ans = False
        break

if ans:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
int memo[1<<16][100];
int main(){
  int n,m,k,i,j,l,a,b,e,inf=1<<28;
  cin>>n>>m>>k;
  int dp[1<<m],d[n],c[k];
  map<int,int> r;
  vector<int> G[n][k];
  for(b=0;b<(1<<m);b++) dp[b]=inf;
  for(i=0;i<m;i++) cin>>d[i],r[--d[i]]=i;
  for(i=0;i<n;i++){
    for(j=0;j<k;j++){
      cin>>e;
      if(r.find(i)!=r.end()) G[e-1][j].push_back(i);
    }
  }
  typedef pair<int,int> P;
  queue<P> q;
  q.push(P(0,0));

  for(j=0;j<k;j++){
    c[j]=0;
    for(i=0;i<n;i++){
      if(r.find(i)!=r.end()) continue;
      for(l=0;l<G[i][j].size();l++)
	if(r.find(G[i][j][l])!=r.end()) c[j]|=(1<<r[G[i][j][l]]);
    }
  }
  memset(memo,-1,sizeof(memo));
  while(!q.empty()){
    a=q.front().first;b=q.front().second;q.pop();
    if(dp[b]<=a) continue;
    dp[b]=a;
    if(b==(1<<m)-1) break;
    for(j=0;j<k;j++){
      int o=0;
      if(~memo[b][j]){
	o=memo[b][j];
	if(a+1<dp[(o|c[j])]) q.push(P(a+1,(o|c[j])));
	break;
      }
      for(i=0;i<m;i++){
	if(((b>>i)&1)==0) continue;
	for(l=0;l<G[d[i]][j].size();l++)
	  o|=(1<<r[G[d[i]][j][l]]);
      }
      memo[b][j]=o;
      if(a+1<dp[(o|c[j])]) q.push(P(a+1,(o|c[j])));
    }
  }
  cout << dp[(1<<m)-1] << endl;
  return 0;
}

Measured memory_bytes: 43272
n,a,b = map(int,input().split())

sum = a + b
dev = n//sum

ans = 0
if a == 0:
    print(0)
else:
    if dev == 0:
        if n > a:
            print(a)
        else:
            print(n)
    else:
        ans = n - sum * dev 
        if ans < a:
            print(dev * a + ans)
        else:
            print(dev * a + a)

Measured memory_bytes: 3064
#include <stdio.h>
int main(void)
{
  int i,j,ans,max,tmp;
  ans=0;
  char str[11];
  int a[11];
  for(i=0;i<11;i++)
    a[i]=0;
  scanf("%s",str);
  for(i=0;i<11;i++)
  {if(str[i]=='A'||str[i]=='T'||str[i]=='C'||str[i]=='G')
  ans++;
  
    else if(str[i]!='A'||str[i]!='T'||str[i]!='C'||str[i]!='G')
    {a[i]=ans;
  	ans=0;
    }
  }
  for (i=0; i<11; ++i) {
    for (j=i+1; j<11; ++j) {
      if (a[i] < a[j]) {
        tmp =  a[i];
       a[i] = a[j];
        a[j] = tmp;
      }
    }
  }
  printf("%d",a[0]);
}

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

/*#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")   */


//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ss second
#define ff first
#define int long long
//#define double long double
#define pb push_back

const int N = 2e6 + 51, MOD = 1e9 + 7, mod = 998244353, INF = 2e18;

mt19937 Flash_new_51(51515);

using vi = vector <int>;
using vp = vector <pair <int, int>>;

int a[N], kol[N];

signed main() {
    #ifdef Flash
     freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int ans = 0, n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        kol[a[i]]++;
    }
    for (int i = 0; i <= n; i++) {
        ans += kol[i] * (kol[i] - 1) / 2;
    }
    for (int i = 0; i < n; i++) {
        cout << ans - (kol[a[i]] - 1) << "\n";
    }


}


Measured memory_bytes: 7296
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>

using namespace std;

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

	vector<pair<int, int>> sushi(N);
	for (int i = 0; i < N; i++)
	{
		cin >> sushi[i].first >> sushi[i].second;
	}

	sort(sushi.begin(), sushi.end(),
		[](const pair<int, int> a, const pair<int, int> b) {
		if (a.second == b.second) return a.first > b.first;
		return a.second > b.second;
	});

	vector<bool> flag(N + 1, false);
	stack<pair<int, int>> check;
	long long good = 0, x = 0;
	for (int i = 0; i < K; i++)
	{
		good += sushi[i].second;
		if (flag[sushi[i].first]) {
			check.push(sushi[i]);
		}
		else {
			flag[sushi[i].first] = true;
			x++;
		}
	}

	long long ans = good + x * x;
	for (int i = K; i < N; i++) {
		if (!flag[sushi[i].first]) {
			if (!check.empty()) {
				flag[sushi[i].first] = true;
				good += sushi[i].second - check.top().second;
				x++;
				check.pop();
				ans = max(ans, good + x * x);
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

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

void solve(istream& cin, ostream& cout) {
  int a;
  string s;
  cin >> a >> s;
  if (a >= 3200) {
    cout << s << endl;
  } else {
    cout << "red" << endl;
  }
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 3620
n = int(input())
a = list(map(int,input().split()))
mod = 10**9+7
s = sum(a)
# for i in a:
#     s  = s*a % mod
ans = 0
for i in a:
    ans = (ans + (s-i)*i) % mod
print(ans*pow(2,mod-2,mod) % mod)

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

int main() {
  int n; cin>>n;
  vector<int> v(n);
  for (int i=0; i<n; i++) cin>>v[i];
  
  sort(v.begin(), v.end());
  double ans=v[0];
  for (int j=1; j<n; j++){
    ans=(ans+v[j])/2.0;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
"use strict";

const main = arg => {
    const A = parseInt(arg.split("\n")[0].split(" ")[0]);
    const B = parseInt(arg.split("\n")[0].split(" ")[1]);
    
    if( A % 3 === 0 || B % 3 === 0 || (A + B) % 3 === 0 ) {
        console.log("Possible");
    } else {
        console.log("Impossible");
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool prime(ll n) {
  if (n == 1) {
    return false;
  } else {
    for (ll i = 2; i <= (ll)pow(n, 0.5); i++) {
      if (n%i == 0) return false;
    }
  }
  return true;
}
ll RepeatSquaring(ll n, ll p, ll m) {
  if (p == 0) return 1;
  if (p%2 == 0) {
    ll t = RepeatSquaring(n, p/2, m);
    return (t*t)%m;
  }
  return (n*RepeatSquaring(n, p-1, m))%m;
}

vector <ll> color(100, 0);
vector <vector <ll>> m(100, vector <ll> (100, -1));
vector <ll> d(100, INF);
vector <ll> p(100, -1);

void dijkstra(ll n) {
  d.at(0) = 0;
  p.at(0) = -1;
  while (true) {
    ll mincost = INF;
    ll u;
    rep(i, n) {
      if (color.at(i) != 2 && d.at(i) < mincost) {
        mincost = d.at(i);
        u = i;
      }
    }
    if (mincost == INF) break;
    color.at(u) = 2;
    rep(i, n) {
      if (color.at(i) != 2 && m.at(u).at(i) != -1) {
        if (d.at(u)+m.at(u).at(i) < d.at(i)) {
          d.at(i) = d.at(u) + m.at(u).at(i);
          p.at(i) = u;
          color.at(i) = 1;
        }
      }
    }
  }
  return;
}

int main() {
  ll n;
  cin >> n;
  rep(i, n) {
    ll u, k;
    cin >> u >> k;
    rep(j, k) {
      ll v, c;
      cin >> v >> c;
      m.at(i).at(v) = c;
    }
  }
  dijkstra(n);
  rep(i, n) {
    cout << i << ' ' << d.at(i) << endl;
  }
}


Measured memory_bytes: 3244
#include <iostream>
using namespace std;

int main(){
  int a, b, c, x, y;

  cin >> a >> b >> c >> x >> y;
  if(x>y){
    cout << min(min(a*x+b*y, a*(x-y)+c*2*y), c*2*x) << endl;
  }else{
    cout << min(min(a*x+b*y, b*(y-x)+c*2*x), c*2*y) << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	int[] d = new int[n];
	int cout = 1;
	for(int i = 0; i < n; i++) {
		d[i] = sc.nextInt();
	}
	Arrays.sort(d);
	for(int i = 1; i < n; i++) {
		if(d[i] > d[i - 1]) {
			cout++;
		}
	}
	System.out.println(cout);
}
}

Measured memory_bytes: 22612
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <chrono>
#include <queue>
#include <functional>

using namespace std;

typedef long long ll;

constexpr int WALL = 1000000007;

struct Point {
    int x; int y;
    Point() {}
    Point(int _x, int _y) : x(_x), y(_y) {}
};

int lab[50 + 1][50 + 1];
bool isNotSearched(int x, int y) {
    return lab[y][x] == 0;
}
int get(Point p) {
    return lab[p.y][p.x];
}
int main() {
    //cin.tie(0);
    //ios::sync_with_stdio(false);
    string S;
    cin >> S;

    int len = S.size();

    int a = 0;
    int b = 0;
    int f = 0;
    for (int i = 0; i < len; ++i) {
        // S[i == 1]
        if (f != (S[i] - '0')) ++a;
        else ++b;

        f ^= 1;
    }

    cout << min(a, b) << endl;

    return 0;
}

Measured memory_bytes: 512
import java.util.*;

import static java.util.Arrays.sort;

public class Main {
    static Scanner sc;


    public static void main(String[] args) {
        sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] l = new int[n];
        for (int i = 0; i < n; i++) {
            l[i] = sc.nextInt();
        }
        sort(l);
        int ans = 0;
        for (int a = 0; a < n; a++) {
            for (int b = a+1; b < n; b++) {
                for (int c = b + 1; c < n; c++) {
                    if(l[c] >= l[a] + l[b]) break;
                    ans++;
                }
            }
        }
        System.out.println(ans);
    }
}



Measured memory_bytes: 28008
#pragma comment(linker, "/STACK:102400000,102400000")
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define Key_Value ch[ch[root][1]][0]
#define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
#define clr(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define F first
#define S second
using namespace std;
typedef long long ll;
const int maxn=500000+5;
const int INF=0x3f3f3f3f;
const int P=1000000007;
const double PI=acos(-1.0);
template<typename T>
inline T read(T&x){
    x=0;int _f=0;char ch=getchar();
    while(ch<'0'||ch>'9')_f|=(ch=='-'),ch=getchar();
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x=_f?-x:x;
}
template <class T1, class T2>inline void gmax(T1 &a,T2 b){if (b>a) a=b;}
template <class T1, class T2>inline void gmin(T1 &a,T2 b){if (b<a) a=b;}
int n;
bool flag;
int main(){
    read(n);
    int s=0,t=0,pre=0;
    for (;n--;){
        int a,b,T;
        read(T),read(a),read(b);
        int sum=abs(s-a)+abs(t-b);
        int tmp=T-pre;
        if (sum>tmp || (tmp-sum)%2==1){
            return puts("No"),0;
        }

        s=a,t=b,pre=T;
    }
    puts("Yes");
    return 0;
}
/*int main(){
    ll a,b;
    cin>>a>>b;
    puts((a*b)&1?"Odd":"Even");
    return 0;
}*/
/*int main(){
    int a,b;cin>>a>>b;
    if (b<10) a=a*10+b;
    else if (b==100) a=a*1000+b;
    else a=a*100+b;
    if ((int)sqrt(a)==sqrt(a)) puts("Yes");
    else puts("No");
    return 0;
}*/


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

std::string str1, str2;
int arr[3001][3001];

/*std::string lcs(int n1,int n2){
    if(n1<=-1||n2<=-1){
        return "";
    }
    if(str1[n1]==str2[n2]){
        return lcs(n1-1,n2-1)+str1[n1];
    }
    else{
        std::string tmp1 = lcs(n1-1,n2), tmp2 = lcs(n1,n2-1);
        return (tmp1.size()>tmp2.size())?tmp1:tmp2;
    }
}*/
int main() {
    std::cin >> str1 >> str2;
    int size1 = str1.size(), size2 = str2.size();
    for (int i1 = 0; i1 <= size1; ++i1) {
        for (int i2 = 0; i2 <= size2; ++i2) {
            if (i1 == 0 || i2 == 0) {
                arr[i1][i2] = 0;
            }
            else if (str1[i1 - 1] == str2[i2 - 1]) {
                arr[i1][i2] = arr[i1-1][i2 - 1] + 1;
            }
            else {
                if (arr[i1-1][i2] > arr[i1][i2 - 1]) {
                    arr[i1][i2] = arr[i1-1][i2];
                }
                else {
                    arr[i1][i2] = arr[i1][i2 - 1];
                }
            }
        }
    }
    std::string lcs(arr[size1][size2],'\0');
    int i=arr[size1][size2]-1;
    for (int i1 = size1, i2 = size2; i1 > 0&& i2 > 0;) {
        if (str1[i1 - 1] == str2[i2 - 1]) {
            lcs[i--] = str1[i1 - 1];
            --i1;
            --i2;
        }
        else {
            if (arr[i1 - 1][i2] > arr[i1][i2 - 1]) {
                --i1;
            }
            else {
                --i2;
            }
        }
    }
    std::cout << lcs;
    //std::cout<<lcs(str1.size()-1,str2.size()-1);
}

Measured memory_bytes: 35456
#include<iostream>
#include<vector>
#include<algorithm>
#include<list>
#include<map>
using namespace std;
typedef unsigned long long int  ull;

ull n;

const string ACGT= "ACGT";

const ull MOD = 1e9+7;

bool check(string s){
	
	string ss = s;
	if(ss.find("AGC") != string::npos){
		return false;
	}
	for(int i=0;i<s.size();++i){
		int j= i+1;
		ss = s;
		swap(ss[i],ss[j]);
		if(ss.find("AGC") != string::npos){
			return false;
		}
	}
	return true;
}

map<string,ull> ma[101];

ull dfs(ull k,string s){
	if(ma[k].find(s) != ma[k].end()) return ma[k][s];
	
	ull res =0;
	if( check(s) == false){
		res =  0;
	}else if(k == n){
		//cout << s << endl;
		res = 1;
	}else{
		res = 0;
		for(int i=0;i<ACGT.size();++i){
			int a = s.size()-3;
			int p = max(a,0);
			string ss = s.substr(p) + ACGT[i];
			res += dfs(k+1,ss);
			res %=MOD;
		}
	}
	res %=MOD;
	ma[k][s] = res;
	return res;
}



int main(){
	cin >> n;
	
	cout << dfs(0,"") <<endl;
	
	return 0;
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define N 200100
#define pii pair<int,int>
#define rep(i,k,n) for(int i=k;i<n;i++)
#define vi vector<int>
#define inf 1e9
void solve(){
	int n;
	string s;
	cin>>n;
	cin>>s;
	ll ans=0;
	int i=0;
	while(i<n){
		if(i+2<n && s[i]=='A' && s[i+1]=='B' && s[i+2]=='C'){
			ans++;
			i+=3;
			continue;
		}
		i++;
	}
	cout<<ans<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
}

Measured memory_bytes: 256
def setM():
    K2 = K // 2
    k = K // 2
    while k:
        m = int(("1" * (K2 - k) + "0" * (K2 + k)) * 3001, 2)
        M.append((k, m))
        k //= 2

def modp(n):
    K2 = K // 2
    k = K // 2
    for k, m in M:
        n = (n & (~m)) + ((n & m) >> (K2 + k)) * ((1 << K2 + k) % P)
    return n

K = 64
P = 998244353
mm = (1 << K * 3001) - 1
mmm = (1 << K) - 1
M = []
setM()
N, S = map(int, input().split())
A = [int(a) for a in input().split()]
s = 0
ans = 0
for a in A:
    s += 1
    s += s << a * K
    s &= mm
    s = modp(s)
    ans += (s >> S * K) & mmm

print(ans % P)

Measured memory_bytes: 3640
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

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

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    vll a(n);
    set<ll> b;
    REP(i, n) {
        cin >> a[i];
        b.insert(a[i] / 2);
    }

    ll g = *b.begin();
    ll lcm = g;
    for (ll _b: b) {
        g = gcd(lcm, _b);
        lcm = _b / g * lcm;
    }

    for (ll _b: b) {
        ll d = lcm / _b;
        if (!(d & 1)) {
            cout << 0 << '\n';
            return 0;
        }
    }

    if (lcm > m) {
        cout << 0 << '\n';
        return 0;
    }

    cout << (m - lcm) / (2 * lcm) + 1 << '\n';
    return 0;
}


Measured memory_bytes: 1024
import collections
h, w = list(map(int, input().split()))
inf = h * w + 1
sharp = 0
data = []
for i in range(h):
    data.append(list(input()))
    # #の数を数えておく
    sharp += data[i].count('#')

ans = [[inf for i in range(w)] for j in range(h)]
def dfs(row, column, count,data):
    #もし配列の外を参照しているようであれば終了させる
    if(row > w - 1) or (column > h - 1) or ( row < 0 ) or ( column < 0 ):
        return

    if data[column][row] == '#':
        return
    data[column][row] == '#'
    #探索済みなので＃を入れたが、もっと良い方法があるかもしれない
    count += 1
    if row == w - 1 and column == h - 1:
        ans[column][row] = min(count, ans[column][row])
        return
    #その場所がゴールならば終了。ansにそこまでのコストを追加
    ##dataの写しを引数として渡したい。参照渡しか値渡しかを確認
    #+-1ずつ四方向に全探索
    dfs(row + 1, column,     count, data)
    dfs(row,     column + 1, count, data)
    dfs(row - 1, column,     count, data)
    dfs(row,     column - 1, count, data)
def bfs(row, column, count,data):
    becter = [-1,1]
    queue = collections.deque()
    queue.append([column, row,count])
    while len(queue) != 0:
        v = queue.popleft()
        if v[0] < 0 or v[1] < 0 or v[0] >= h or v[1] >= w:
            continue
        if data[v[0]][v[1]] != '#':

            data[v[0]][v[1]] = '#'
            v[2] += 1
            ans[v[0]][v[1]] = min(ans[v[0]][v[1]], v[2])
            queue.append([v[0] + 1, v[1],v[2]])
            queue.append([v[0], v[1] + 1,v[2]])
            queue.append([v[0] - 1, v[1],v[2]])
            queue.append([v[0], v[1] - 1,v[2]])


bfs(0, 0, 0,data)
if ans[-1][-1] == inf:
    print(-1)
    exit()
print(h * w - sharp - ans[-1][-1])


Measured memory_bytes: 3436
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <string>

using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
	int n, k;
	cin >> n >> k;
	int d[101] = {};
	int ans[101] = {};

	int count = 0;

	for (int i = 0; i<k; i++) {
		cin >> d[i];
		int a[101] = {};
		for (int j = 0; j < d[i]; j++) {
			cin >> a[j];
			ans[a[j]-1] ++;
		}

	}

	for (int i = 0; i < n; i++) {
		if (ans[i] >= 1) {
			count++;
		}
	}
	cout << n - count;
	return 0;
}

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

using namespace std;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()



int main()
{
	fastio;
	int a, b;
	cin >> a >> b;
	if(a>=13) cout << b << "\n";
	else if(a > 5) cout << b/2 << "\n";
	else cout << "0\n";
	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.math.*;
import java.awt.Point;
 
public class Main {
	//static final long MOD = 998244353L;
	//static final long INF = -1000000000000000007L;
	//static final long MOD = 1000000007L;
	static final int INF = 1000000007;
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter pw = new PrintWriter(System.out);
		int N = sc.ni();
		String s = sc.next();
		int ans = 0;
		for (int i = 0; i < N-2; i++) {
			if (s.charAt(i)=='A'&&s.charAt(i+1)=='B'&&s.charAt(i+2)=='C') {
				ans++;
			}
		}
		pw.println(ans);
		pw.close();
	}
	
	//Find the GCD of two numbers
	public static long gcd(long a, long b) {
		if (b == 0)
			return a;
		else
			return gcd(b,a%b);
	}
	
	//Fast exponentiation (x^y mod m)
	public static long power(long x, long y, long m) { 
		long ans = 1;
		x %= m;
		while (y > 0) { 
			if(y % 2 == 1) 
				ans = (ans * x) % m; 
			y /= 2;  
			x = (x * x) % m;
		} 
		return ans; 
	}
	
	public static int[][] shuffle(int[][] array) {
		Random rgen = new Random();
		for (int i = 0; i < array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    int[] temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}
		return array;
	}
	
    public static int[][] sort(int[][] array) {
    	//Sort an array (immune to quicksort TLE)
 
		Arrays.sort(array, new Comparator<int[]>() {
			  @Override
        	  public int compare(int[] arr1, int[] arr2) {
				  return arr1[1]-arr2[1]; //ascending order
	          }
		});
		return array;
	}
    
    public static long[][] sort(long[][] array) {
    	//Sort an array (immune to quicksort TLE)
		Random rgen = new Random();
		for (int i = 0; i < array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    long[] temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}
		Arrays.sort(array, new Comparator<long[]>() {
			  @Override
        	  public int compare(long[] arr1, long[] arr2) {
				  return 0;
	          }
		});
		return array;
	}
    
    static class FastScanner { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastScanner() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int ni() { 
            return Integer.parseInt(next()); 
        } 
  
        long nl() { 
            return Long.parseLong(next()); 
        } 
  
        double nd() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try { 
                str = br.readLine(); 
            } catch (IOException e) {
                e.printStackTrace(); 
            } 
            return str;
        }
    }
}

Measured memory_bytes: 21460
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long int;using ld = long double;using P = pair<ll,ll>;const int MOD = (int)1e9+7;const string rt = "\n";const string sp = " ";/* 最大公約数 */template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}/* UnionFind */template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};/* コンビネーション */template<typename T> ll combpm(T N_, T C_) {const int NUM_=400001;static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];if (fact[0]==0) {inv[1]=fact[0]=factr[0]=1;for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD;}if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;}/* 多次元ベクター */template<class T>vector<T> mvec(size_t a){return vector<T>(a);}template<class T, class... Ts>auto mvec(size_t a, Ts... ts){return vector<decltype(mvec<T>(ts...))>(a, mvec<T>(ts...));}/* テスト関数 */void test(ll n){cout << "test" << n << endl;}/* 小数点以下 */void fixsp(ll n){cout << fixed << setprecision(n);}void defsp(ll n){cout << defaultfloat << setprecision(n);}/* 重み付きUnionFind */struct WUnionFind {vector<int> par;vector<int> rank;WUnionFind(int n = 1) {init(n);}void init(int n = 1) {par.resize(n); rank.resize(n);for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;}int root(int x) {if (par[x] == x) {return x;}else {int r = root(par[x]);return par[x] = r;}}bool issame(int x, int y) {return root(x) == root(y);}bool merge(int x, int y) {x = root(x); y = root(y);if (x == y) return false;if (rank[x] < rank[y]) swap(x, y);if (rank[x] == rank[y]) ++rank[x];par[y] = x;return true;}};/* IO高速化 */void fastio(){ios::sync_with_stdio(false);cin.tie(NULL);}
/* ここからコード開始 */

int main(){
  fastio;
  ll A, B;
  cin >> A >> B;
  if(abs(B-A)%2 == 1) cout << "IMPOSSIBLE" << rt;
  else{
    cout << min(A,B) + abs(B-A)/2 << rt;
  }
}

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

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }	//最大公約数(Greatest Common Divisor)
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }			//最小公倍数(Least Common Multiple)

long long comb(long long m) {
	return (m * (m - 1)) / 2;
}


int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n)	cin >> a[i];
	rep(i, n)	a[i]--;		//0~n-1

	vector<int> cnt(n);
	rep(i, n)	cnt[a[i]]++;
	long long total = 0;
	rep(i, n)	total += comb(cnt[i]);

	long long ans;
	rep(i, n) {
		ans = total - comb(cnt[a[i]]) + comb(cnt[a[i]] - 1);
		cout << ans << endl;
		ans = total;
	}



}

Measured memory_bytes: 4096
#include <stdio.h>

int main(void)
{
        int n,i;
        scanf("%d",&n);
        long long a[n];
        for(i=0;i<n;i++)
                scanf("%lld",&a[i]);

        int z=0;
        for(i=0;i<n;i++){
                if(a[i]==0) z++;
        }
        if(z>0){
                printf("0\n");
                return 0;
        }
        long long p=1;
        for(i=0;i<n;i++){
                if(a[i]<=1000000000000000000/p){
                        p*=a[i];
                }
                else{
                        printf("-1\n");
                        return 0;
                }
        }
        printf("%lld\n",p);
        return 0;
}


Measured memory_bytes: 2504
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


class UnionFind:
    def __init__(self, size):
        """
        size:頂点の数
        """
        self.parent = [i for i in range(size)]
        self.rank = [0 for _ in range(size)]

    def find(self, x):
        """
        xのrootを返す
        """
        if self.parent[x] == x:
            return x
        else:
            return self.find(self.parent[x])

    def union(self, x, y):
        """
        x,yを同じグループとしてまとめる
        """
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return

        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same(self, x, y):
        """
        xとyが同じグループならTrue
        """
        return self.find(x) == self.find(y)

    def component(self):
        """
        各連結成分のrootの集合を返す
        len()をとれば連結成分の数が求められる
        return-> set()
        """
        comp = set()
        for i in self.parent:
            p = self.find(i)
            comp.add(p)
        return comp

    def __str__(self):
        """
        for debug
        クラスのlistの情報を出力
        """
        ret = "parents\n"
        ret += " ".join(map(str, self.parent))
        ret += '\n'
        ret += " ".join(map(str, self.rank))
        return ret


N, M = map(int, input().split())
edges = []

for _ in range(M):
    a, b = map(lambda x: int(x)-1, input().split())
    edges.append([a, b])

ans = 0
for e in edges:
    Un = UnionFind(N)
    for g in edges:
        if e == g:
            continue
        else:
            Un.union(g[0], g[1])
    if not Un.same(e[0], e[1]):
        ans += 1
print(ans)


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

#define ll long long
#define ii pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi acos(-1.0)
#define oo 1000000007
#define loo 10000000000000007

#define prime 1000000007

#define W(x) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << "\n";
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    string s, t; cin >> s >> t;
    int n = (int)s.size(), m = (int)t.size();
    int ans = prime;
    for (int i = m; i <= n; ++i){
        int aux = 0;
        for (int j = i-m; j < i; ++j){
            if(s[j]!=t[j-(i-m)]) aux++;
        }
        ans = min(ans, aux);
    }

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

Measured memory_bytes: 3656
#include<iostream>

int64_t luca(int num){
  int64_t l2=2, l1=1;
  int64_t l=l1;
  while (num-1>0) {
    l = l1 + l2;
    l2 = l1;
    l1 = l;
    num--;
  }
  return l;
}

  
int main() {
  int N;
  std::cin >> N;
  std::cout << luca(N) << std::endl;
}
  

Measured memory_bytes: 384
#include<stdio.h>
int main(void) {
	int a, b, c, d, e,f;
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	scanf("%d", &d);
	scanf("%d", &e);
	scanf("%d", &f);
	a = a * 1;
	b = b * 5;
	c = c * 10;
	d = d * 50;
	e = e * 100;
	f = f * 500;
	if (a + b+c + d + e + f >= 1000) {
		printf("1\n");
	}
	else {
		printf("0\n");
	}
	return 0;
}


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

#define ll long long
#define f(i, a, b) for(ll i=a;i<b;i++)
#define fi(i, a, b) for(ll i=b-1;i>=a;i--)
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define ml map<ll,ll>
#define pll pair<ll,ll>


int main()
{
  ll n;
  cin>>n;
  vector<ll>vec(n);

  int f=0;
  for(int i=0;i<n;i++){
  cin>>vec[i];
  }
  sort(vec.begin(),vec.end());
     ll res=1;
        double res1=0;
    for(int i=0;i<n;i++){
        if(vec[i]==0){
         res=0;
         res1=0;
         break;
       }

      res1+= (double)log10(vec[i]);
        res=res*vec[i];

        if( res> (ll) (1e18) ){
          f=1;
          break;
        }
    }
  //cout<<res1<<" "<<res<<" ";

    if(res1>18 || f){
      cout<<"-1";
    }
    else
    cout<<res;
 }


Measured memory_bytes: 4116
S = input()

even = set({})
odd = set({})
for i in range(len(S)):
    if i % 2 == 0:
        even.add(S[i])
    else:
        odd.add(S[i])
#print(even, odd)

if (not "R" in odd) and (not "L" in even):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        vector<int> tapi(4), tapu({1, 4, 7, 9});
        rep(i, 0, 4) cin >> tapi[i];
        sort(all(tapi));

        if(tapi == tapu){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }


    }
};


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

    Solve().solve();


    return 0;
}


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

int main(){
    int x,y;
    // int i = 1;
    while(true){
        cin >> x >> y;
        if(x == 0 && y == 0) break;
        if(x > y) swap(x,y);
        cout << x <<" "<< y << endl;
    }
    return 0;
}



Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int n, a[N];

int main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n;
	for(int i=0; i<n; i++) cin >> a[i];
	a[0] -= 1;
	for(int i=1; i<n; i++){
		if (a[i] == a[i-1]) continue;
		if (a[i] > a[i-1]) a[i] -= 1;
		else return 0*puts("No");
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 640
while True:
    n=int(input())
    if n==0:
        break
    
    s=list(map(int,input().split()))
    m=sum(s)/n
    sa=0

    for i in range(n):
        sa+=(s[i]-m)**2
    
    a2=sa/n
    a=a2**(1/2)
    print(a)


Measured memory_bytes: 5664