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

#define pb push_back
#define all(a) (a).begin(), (a).end()

typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    int n; cin >> n;
    string s; cin >> s;
    set<int> pos[26];
    for (int i = 0; i < n; ++i) {
        pos[s[i] - 'a'].insert(i);
    }
    int q; cin >> q;
    while (q--) {
        int t; cin >> t;
        if (t == 1) {
            int i; cin >> i;
            --i;
            char c; cin >> c;
            int pc = s[i] - 'a';
            pos[pc].erase(i);
            pos[c - 'a'].insert(i);
            s[i] = c;
        } else {
            int l, r; cin >> l >> r;
            --l, --r;
            int ans = 0;
            for (int i = 0; i < 26; ++i) {
                if (pos[i].lower_bound(l) != pos[i].end() && *pos[i].lower_bound(l) <= r)
                    ++ans;
            }
            cout << ans << '\n';
        }
    }

}

Measured memory_bytes: 24220
a,b=input().split()
a=int(a)
b=int(b)
c=input()
h,i,j=c[:(b-1)],c[b-1],c[(b):]
if i=="A":
  i="a"
if i=="B":
  i="b"
if i=="C":
  i="c"
print(h+i+j)

Measured memory_bytes: 9052
import sys
from heapq import *
H=[]
O=[]
for e in sys.stdin:
 if'end'==e:break
 if'i'==e[0]:heappush(H,-int(e[7:]))
 elif't'==e[2]:O+=[-heappop(H)]
print('\n'.join(map(str,O)))


Measured memory_bytes: 99116
#include<bits/stdc++.h>
#define maxn 201000
#define inf 1000000007
using namespace std;
int n,a[maxn],b[maxn],mx=-inf,mn=inf,omx,omn,c[maxn];
int comp(int x,int y){
	return a[x]<a[y];
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d%d",&a[i],&b[i]),c[i]=i;
		if(a[i]>b[i])swap(a[i],b[i]);
		if(mx<b[i])mx=b[i],omx=a[i];
		if(mn>a[i])mn=a[i],omn=b[i];
	}
	int _mx=omx,_mn=omn;
	for(int i=1;i<=n;++i)
		_mx=max(_mx,a[i]),_mn=min(_mn,b[i]);
	long long ans=1ll*(mx-_mn)*(_mx-mn);
	sort(c+1,c+n+1,comp);
	int x=inf;
	for(int i=1;i<=n;++i)
		ans=min(ans,1ll*(mx-mn)*(_mx-min(a[c[i]],x))),x=min(b[c[i]],x),_mx=max(_mx,b[c[i]]);
	printf("%lld",ans);
}
 

Measured memory_bytes: 2560
#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 long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    string s; cin >> s;
    int q; cin >> q;
    while (q-->0) {
        int k; cin >> k;
        ll ans = 0, cd = 0, cdm = 0, cm = 0;;
        for (int i = 0; i < k; i++) {
            if (s[i] == 'D') cd++;
            else if (s[i] == 'M') cdm += cd, cm++;
            else if (s[i] == 'C') ans += (ll)cdm;
        }
        for (int i = k; i < n; i++) {
            if (s[i - k] == 'D') cd--, cdm -= cm;
            else if (s[i - k] == 'M') cm--;
            if (s[i] == 'D') cd++;
            else if (s[i] == 'M') cdm += cd, cm++;
            else if (s[i] == 'C') ans += (ll)cdm;
        }
        cout << ans << '\n';
    }
    return 0;
}


Measured memory_bytes: 1948
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
  input = input.split("\n")
  tmp0 = input[0].split(" ")
  N = tmp0[0]
  ans = 0

  for(var i=0; i < N; i++){
    tmp = input[i+1].split(" ")
    x = Number(tmp[0])
    u = tmp[1]
    if(u === "JPY"){
      ans += x
    }else{
      ans += x * 380000.0
    }
  }  
  console.log(ans)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main("2\n10000 JPY\n0.10000000 BTC")

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

sys.setrecursionlimit(1000000)

#A
def A():
    n = I()
    if n <= 1000000000:
        print(0,0,1,0,0,n)
    else:
        b = 1000000000
        a = 1
        y = -n%1000000000
        x = (n+a*y)//b
        print(0,0,x,y,a,b)
        return

    return

#B
def B():
    n,k = LI()
    a = LI()
    s = []
    f = [1]*1000000
    for i in range(k):
        for j in range(n):
            aj = a[j]
            if f[aj]:
                s.append(aj)
                f[aj] = 0
            else:
                while 1:
                    x = s.pop(-1)
                    f[x] = 1
                    if x == aj:
                        break
        print(i+1,s)
    return

#C
mod = 998244353
def C():
    def comb(a,b):
        if a < b:
            return 1
        return fact[a]*inv[b]*inv[a-b]%mod
    n,m = LI()
    MA = 3*m+max(n,2*m)-1
    fact = [1]*(MA+1)
    for i in range(MA):
        fact[i+1] = fact[i]*(i+1)%mod
    inv = [1]*(MA+1)
    inv[MA] = pow(fact[MA],mod-2,mod)
    for i in range(MA)[::-1]:
        inv[i] = inv[i+1]*(i+1)%mod
    ans = 0
    for k in range(min(m,n)+1):
        if (3*m-k)%2 == 0:
            ans += comb(n,k)*comb((3*m-k)//2+n-1,n-1)
            ans %= mod
    ans -= n*comb(3*m-(2*m+1)+n-1,n-1)
    ans %= mod
    print(ans)

    return

#D
def D():
    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

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


Measured memory_bytes: 39152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
const ll MOD = 1e9 + 7;

ll mod;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int mainsolve(){

	ll n,m;
	cin >> n >> m;
	mod = m;

	vector<vector<ll>> to(n);

	rep(i,n-1){
		ll x,y;
		cin >> x >> y;
		--x; --y;
		to[x].push_back(y);
		to[y].push_back(x);
	}

	vector<vector<mint>> dp(n); // 要素数 2(n-1)
	rep(i,n) dp[i] = vector<mint>(to[i].size()); // vの子から始まる部分木（vの子自身を含む）

	// まず普通にdfsして子方向へのdpを埋める
	function<mint(ll,ll)> dfs = [&](ll v, ll p){
		mint res = 1;
		rep(i,to[v].size()){
			ll u = to[v][i];
			if(u != p){
				dp[v][i] = dfs(u,v); // uがrootである部分木
				res *= dp[v][i] + 1;
			}
		}
		return res;
	};
	dfs(0,-1);

	vector<mint> ans(n);
	function<void(ll,ll,mint)> dfs2 = [&](ll v, ll p, mint dpP){

		ll deg = to[v].size();
  		rep(i,deg) if (to[v][i] == p) dp[v][i] = dpP;

		vector<mint> dpLeft(deg+1,1), dpRight(deg+1,1);
		rep(i,deg) dpLeft[i+1] = dpLeft[i] * (dp[v][i] + 1);
		for (int i = deg-1; i >= 0; --i) dpRight[i] = dpRight[i+1] * (dp[v][i] + 1);
		
		ans[v] = dpLeft[deg];

		rep(i,deg){
			ll u = to[v][i];
			if(u == p) continue;
			dfs2(u, v, dpLeft[i] * dpRight[i+1]);
		}
	};	
	dfs2(0,-1,1);

	rep(i,n) cout << ans[i] << endl;
	return 0;
}

int main(){

	return mainsolve();
}

Measured memory_bytes: 26752
N = int (input())
A = [int(a) for a in input().split()]
d = 0
ans = 1
for i in range(1, N):
    if A[i-1] < A[i]:
        if d < 0:
            ans += 1
            d = 0
        elif d == 0:
            d = 1

    elif A[i-1] > A [i]:
        if d > 0:
            ans +=1
            d = 0
        elif d == 0:
            d = -1

print(ans)               


Measured memory_bytes: 14224
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;

static class CodeJam
{
    static int[] Solve(string S)
    {
        int N = S.Length;
        var L = new List<int>();
        var R = new List<int>();
        for (int i = 0; i + 1 < N; ++i)
        {
            if (S[i] == 'R' && S[i + 1] == 'L')
            {
                R.Add(i);
                L.Add(i + 1);
            }
        }
        var counts = new int[N];
        for (int i = 0; i < N; ++i)
        {
            int a = 0, b;
            switch (S[i])
            {
            case 'L':
                b = L.Count - 1;
                if (L[b] <= i)
                {
                    a = b;
                }
                else
                {
                    while (b - a >= 2)
                    {
                        int m = (a + b) / 2;
                        if (L[m] <= i) { a = m; } else { b = m; }
                    }
                }
                if ((i - L[a]) % 2 == 0) { ++counts[L[a]]; } else { ++counts[R[a]]; }
                break;
            case 'R':
                if (R[a] >= i)
                {
                    b = 0;
                }
                else
                {
                    b = R.Count - 1;
                    while (b - a >= 2)
                    {
                        int m = (a + b) / 2;
                        if (R[m] >= i) { b = m; } else { a = m; }
                    }
                }
                if ((i - R[b]) % 2 == 0) { ++counts[R[b]]; } else { ++counts[L[b]]; }
                break;
            }
        }
        return counts;
    }

    static void Main(string[] args)
    {
        var ans = Solve(Console.ReadLine());
        Console.WriteLine(string.Join(" ", ans));
    }
}


Measured memory_bytes: 14304
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    c = []
    csum = 0
    for _ in range(3):
        _c = LI()
        csum += sum(_c)
        c.append(_c)

    if c[0][0] + c[1][1] + c[2][2] == csum/3:
        print('Yes')
    else:
        print('No')
main()



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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;

int N, K;
int A[200200];

signed main() {
    cin >> N >> K;
    int cnt0 = 0;
    rep(i, N) {
        cin >> A[i];
        if (A[i] == 0)cnt0++;
    }
    sort(A, A + N);
    int l = -2000000000000000000l;
    int r = 2000000000000000000l;
    while (r - l > 1) {
        int m = (l + r) / 2;
        //m以下がk個以上あればr=m
        //そうでなければl=m
        int num = 0;
        rep(i, N) {
            if (A[i] > 0) {
                int mmm;
                if (m >= 0)mmm = m / A[i];
                else mmm = -((-m + A[i] - 1) / A[i]);
                num += upper_bound(A, A + N, mmm) - A;
            } else if (A[i] < 0) {
                int mmm;
                if (m >= 0)mmm = -(m / -A[i]);
                else mmm = (-m - A[i] - 1) / -A[i];
                num += A + N - lower_bound(A, A + N, mmm);
            } else {
                if (m >= 0)num += N;
            }
            if (A[i] * A[i] <= m)num -= 1;
        }
        //cerr << m << " " << num << endl;
        num /= 2;
        if (num >= K)r = m;
        else l = m;
    }
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>

int main()
{
	int w,c;
	while(scanf("%d",&w)!=EOF)
	{
		for(c=0;c<=10 && w!=0;c++,w>>=1)
		{
			if((w&1)==1)
				printf("%d%c",1<<c,w>>1==0?'\n':' ');
		}
	}
	return 0;
}

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

const int Max=8010;
const int mod=1e9+7;
int n,m,k,ans;
int f[4010][4010],inv[Max],mul[Max],a[200010],b[200010];

inline int get_int()
{
	int x=0,f=1;
	char c;
	for(c=getchar();(!isdigit(c))&&(c!='-');c=getchar());
	if(c=='-') c=-1,c=getchar();
	for(;isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+c-'0';
	return x*f;
}

inline int ksm(int a,int b)
{
	int ans=1;
	while(b)
	{
	  if(b&1) ans=(1ll*ans*a)%mod;
	  b>>=1;
	  a=(1ll*a*a)%mod;
	}
	return ans;
}

inline void pre()
{
	mul[0]=mul[1]=1;
	for(int i=2;i<=8000;i++) mul[i]=(1ll*mul[i-1]*i)%mod;
	inv[0]=inv[1]=1;
	for(int i=2;i<=8000;i++) inv[i]=ksm(mul[i],mod-2);
}

inline int C(int n,int m)
{
	if(n>=0 && m>=0 && n>=m) return (1ll*mul[n]*inv[m]%mod*inv[n-m]%mod)%mod;
	return 0;
}

int main()
{
	pre();
	n=get_int();
	for(int i=1;i<=n;i++) a[i]=get_int(),b[i]=get_int(),f[2001-a[i]][2001-b[i]]++;
	for(int i=1;i<=4001;i++)
	  for(int j=1;j<=4001;j++)
	    f[i][j]=(f[i][j]%mod+(f[i][j-1]+f[i-1][j])%mod)%mod;

	for(int i=1;i<=n;i++) ans=(ans+f[2001+a[i]][2001+b[i]])%mod;
	for(int i=1;i<=n;i++) ans=((ans-C((a[i]<<1)+(b[i]<<1),a[i]<<1))%mod+mod)%mod;
	ans=1ll*ans*(mod+1)/2%mod;
	cout<<(ans%mod+mod)%mod<<"\n";

	return 0;
}

Measured memory_bytes: 64512
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;
ll A[100003], SUM[100003];

ll dfs(int idx, ll cc) {
  if (idx==N+2) return 0ll;
  ll max_node = min(SUM[idx], cc);
  ll nc = max_node-A[idx];
  if (nc < 0) return - INF; 
  return dfs(idx+1, nc*2)+max_node;
}

int main() {
  INCANT;
  cin >> N;
  rep(i, N+1) cin >> A[i];
  SUM[N] = A[N];
  for(int i=N-1; i>=0; i--) SUM[i] += A[i]+SUM[i+1];
  
  ll ret = dfs(0, 1);
  if (ret<0) cout << -1 << endl;
  else cout << ret << endl;
}

Measured memory_bytes: 5204
#include <bits/stdc++.h>
#define repl(i, l, r) for (int i = l; i < r; ++i)
#define rep(i, n) repl(i, 0, n)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define chmax(x,y) x = max(x, y)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using G = vector<vector<int>>;
const int MOD = 1000000007;
const int INF = 1001001001;
const int dy[] = {-1, 0, 1, 0};
const int dx[] = {0, -1, 0, 1};

int d[3005][3005];
ll dp[3005][3005][4];

int main()
{
    int R, C, n;
    cin >> R >> C >> n;
    rep(i, n) {
        int r, c, v;
        cin >> r >> c >> v;
        d[r-1][c-1] = v;
    }
    rep(i, R) {
        rep(j, C) {
            for(int k = 2; k >= 0; k--) {
                chmax(dp[i][j][k+1], dp[i][j][k] + d[i][j]);
            }
            rep(k, 4) {
                chmax(dp[i+1][j][0], dp[i][j][k]);
                chmax(dp[i][j+1][k], dp[i][j][k]);
            }
        }
    }
    ll ans = 0;
    rep(k, 4) chmax(ans, dp[R-1][C-1][k]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 320280
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){
  int h,w;
  int i,j;
  cin>>h>>w;//
  vector<string> a(h);
  for(i=0;i<h;++i)cin>>a.at(i);
  //for(i=0;i<h;++i)cout<<a.at(i);
  for(i=0;i<w+2;++i)cout<<'#';
  cout<<endl<<'#';
  for(i=0;i<h;++i)cout<<a.at(i)<<'#'<<endl<<'#';
  for(i=0;i<w+1;++i)cout<<'#';
  cout<<endl;
}

Measured memory_bytes: 256
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power(ll a, ll b, ll m)
{
	ll sol = power(a, b / 2, m);
	sol = (sol * sol) % m;
	if (b % 2 == 1)
		sol = (sol * a) % m;
	return(sol);
}
ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	else
	{
		return gcd(b, a % b);
	}
}
string s;
stack<char>sol;
void solve()
{
	cin >> s;
	sol.push(s[0]);
	int n = s.length();
	for (int i = 1; i < n; i++)
	{
		if (s[i] == 'T'&&(!sol.empty()))
		{
			if (sol.top() == 'S')
				sol.pop();
			else
				sol.push('T');
		}
		else
		{
			sol.push(s[i]);
		}
	}
	cout << sol.size();
}
int main()
{
	int t = 1;
	//cin>>t;
	while (t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Rep(i, N) for(int i = 0; i < N; i++)

int cnt = 0;
set <string> st;

void calc(string s1, string s2) {
  if(st.find(s1 + s2) == st.end()) {
    cnt++; st.insert(s1 + s2);
  }
  if(st.find(s2 + s1) == st.end()) {
    cnt++; st.insert(s2 + s1);
  }
}

signed main()
{
  int N;
  cin >> N;
  while(N--) {

    string S;
    cnt = 0; st.clear();

    cin >> S;
    for(int i = 1; i <= S.size() - 1; i++) {
      string s1 = S.substr(0, i), s2 = S.substr(i, S.size() - i);
      reverse(s1.begin(), s1.end()), reverse(s2.begin(), s2.end());
      
      string rs1 = s1, rs2 = s2;
      reverse(s1.begin(), s1.end()), reverse(s2.begin(), s2.end());

      calc(s1, s2); calc(s1, rs2); calc(rs1, s2); calc(rs1, rs2);
    }

    cout << cnt << endl;
  }
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    while (n--) {
        int y, m, d;
        cin >> y >> m >> d;
        int res = 0;
        while (true) {
            if (y % 3 == 0) {
                ++d;
                if (d > 20) d = 1, ++m;
                if (m > 10) m = 1, ++y;
            } else {
                if (m % 2) {
                    ++d;
                    if (d > 20) d = 1, ++m;
                } else {
                    ++d;
                    if (d > 19) d = 1, ++m;
                }
                if (m > 10) m = 1, ++y;
            }
            ++res;
            if (y == 1000 && m == 1 && d == 1) break;
        }
        cout << res << endl;
    }

    return 0;
}


Measured memory_bytes: 3080
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt() * 100;
		int b = sc.nextInt() * 100;
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
		int f = sc.nextInt();
		sc.close();

		int ans1 = a;
		int ans2 = 0;
		for (int w = 100; w < f; w+=100) {
			if (can(a, b, w)) {
				int rem = Math.min(e * w / 100, f - w);
				if (rem < c) {
					continue;
				}
				for (int s = rem; s >= 0; s--) {
					if (can(c, d, s)) {
						int alt1 = w + s;
						int alt2 = s;
						if (alt2 * ans1 > ans2 * alt1) {
							ans1 = alt1;
							ans2 = alt2;
						}
						break;
					}
				}
			}
		}
		System.out.println(ans1 + " " + ans2);
	}

	static boolean can(int a, int b, int v) {
		if (v % a == 0) {
			return true;
		}
		for (int i = v; i >= 0; i-=a) {
			if (i % b == 0) {
				return true;
			}
		}
		return false;
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(), v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 1;
vector<int> g[N];
vector<int> vis(N);
void solve(){
    int n;
    cin >> n;
    vector<vector<int>> cnt(n, vector<int> (26));
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        for(char &c : s){
            cnt[i][c - 'a']++;
        }
    }
    vector<int> mn(26, INF);
    string ans;
    for(int i = 0; i < 26; i++){
        for(int j = 0; j < n; j++){
            mn[i] = min(mn[i], cnt[j][i]);
        }
        for(int j = 0; j < mn[i]; j++){
            char c = i + 'a';
            ans += c;
        }
    }
    cout << ans << '\n';
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        solve();
    }
}

Measured memory_bytes: 34572
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define all(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
const int MAX = (int)2e5 + 5;

int main() {
	string s[3];
	rep(i, 3) cin >> s[i];
	rep(i, 3) cout << s[i][0];
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<cstdlib>
#include<algorithm>
#include<ctime>
using namespace std;
typedef long long LL;
int T;
LL n,k;int md,ans;
inline LL mul(LL a,LL b,const LL&md){
	LL c=a*b-LL((long double)a*b/md+.5)*md;
	return(c>>63&md)+c;
}
inline int intpow(int a,LL b){
	int ret=1;for(;b;b>>=1,a=(LL)a*a%md)if(b&1)ret=(LL)ret*a%md;return ret;
}
inline LL pow(LL a,LL b,const LL&md){
	LL ret=1;for(a%=md;b;b>>=1,a=mul(a,a,md))if(b&1)ret=mul(ret,a,md);return ret;
}
namespace MR{
	const int P[]={2,3,5,7,11,13,17,19,23,29,31,37};
	bool check(int a,LL n){
		LL x=n-1;int d=0;
		while(!(x&1))x>>=1,++d;
		for(x=pow(a,x,n);d--;){
			const LL lst=x;x=mul(x,x,n);
			if(x==1&&lst!=1&&lst!=n-1)return 0;
		}
		return x==1;
	}
	bool test(LL n){
		if(n==1)return 0;
		for(int i:P)if(n==i)return 1;
		if(!(n&1))return 0;
		for(int i:P)if(!check(i,n))return 0;
		return 1;
	}
}
vector<LL>v;
LL find(LL n,int c){
	LL x=rand()%(n-1)+1,y=x,k=2,q=1,t=1;
	for(;;k<<=1,y=x,q=1){
		for(int i=1;i<=k;++i){
			x=mul(x,x,n)+c-n;x+=x>>63&n;
			q=mul(q,llabs(x-y),n);
			if(!(i&127)){
				t=std::__gcd(q,n);
				if(t>1)return t;
			}
			t=std::__gcd(q,n);
			if(t>1)return t;
		}
	}
}
void rho(LL n){
	if(n==1)return;
	if(MR::test(n))return v.push_back(n);
	LL p=n;int c=19260817;
	while(p==n)p=find(p,c--);
	while(n%p==0)n/=p;
	rho(p),rho(n);
}
void dfs(int nw,LL t,int mx){
	if(nw==v.size()){
		if(t%2==0&&n/t%2==1)return;
		t=n/t;
		ans=(ans+intpow(k%md,t+1>>1)*((t%2==0?t/2:t)%md)%md*mx)%md;
	}else
	for(LL x=1;x<=n&&n%x==0;x=(x<=n/v[nw])?x*v[nw]:n+1)
	dfs(nw+1,t*x,(x==1)?mx:(mx*(md+1-v[nw]%md)%md));
}
int main(){
	srand(time(0));
	for(T=1;T--;){
		scanf("%lld%lld",&n,&k),ans=0,v.clear();md=1e9+7;
		rho(n),sort(v.begin(),v.end()),v.erase(unique(v.begin(),v.end()),v.end());
		dfs(0,1,1),printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 256
var W,V:array[0..100000] of longint;
     F:array[0..100,0..100000] of int64;
     n,m,i,j:longint;   f1:text;

 function max(x,y:int64):int64;
 BEGIN
  if x<y then exit(y) else exit(x);
 END;

 BEGIN
  assign(f1,''); reset(f1);
  readln(f1,n,m);
  for i:=1 to n do readln(f1,w[i],v[i]);
  for i:=0 to m do F[0,i]:=0;
  for i:=0 to n do F[i,0]:=0;
  //fillchar(f,sizeof(f),0);
  //n:=3; m:=8;
  for i:=1 to n do
   for j:=0 to m do
    BEGIN
     F[i,j]:=F[i-1,j];
     {if (j>=W[i]) and (F[i,j]<F[i-1,j-W[i]]+V[i]) then
      F[i,j]:=F[i-1,j-W[i]]+V[i]; }
     if j>=W[i] then F[i,j]:=max(F[i-1,j],F[i-1,j-W[i]]+V[i]);
    // writeln(i,' ',j,' ',F[i,j]);
    END;

  write(F[n,m]);
  readln;
  close(f1);
 END.



Measured memory_bytes: 78976
n = int(input())
s = 'abcdefghijklmnopqrstuvwxyz'
l = []
while(1):
    if n<=26:
        if n!=0:
            l.append(n)
        break
    amari = n%26
    n = n//26
    if amari==0:
        l.append(26)
        n-=1
    else:
        l.append(amari)
a = ''
for i in l[::-1]:
    a+=s[i-1]
print(a)

Measured memory_bytes: 9100
function main(input){
  var line = input[0].split(' ').sort();
  console.log(line.join('') ==='1479' ? 'YES' : 'NO' );
}


var input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main(input);
});


Measured memory_bytes: 21192
#include <iostream>

int calculate_num_pies (int num_apples_whole, int num_apples_chip)
{
	// local variables for this function
	int num_apples_chips_total;
	int num_pies;

	// STEP.01
	// calculate the number of chips we can make
	num_apples_chips_total = num_apples_chip + num_apples_whole * 3;

	// STEP.02
	// calculate the number of pies we can make
	num_pies = num_apples_chips_total / 2;

	// declare the 
	return num_pies;
}

int main (void)
{
	// variables for main process
	int num_apples_whole;
	int num_apples_chip;

	// STEP.01
	// read out the number of the apples
	std::cin >> num_apples_whole;
	std::cin >> num_apples_chip;

	// STEP.02
	// calculate & output the maximum number of apple pies we can make
	std::cout << calculate_num_pies (num_apples_whole, num_apples_chip) << std::endl;

	// STEP.END
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"


func main() {
	m := map[string]int{
		"SUN": 0,
		"MON": 1,
		"TUE": 2,
		"WED": 3,
		"THU": 4,
		"FRI": 5,
		"SAT": 6,
	}
	var s string
	fmt.Scan(&s)
	fmt.Println(7 - m[s])
}


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

int main()
{
	int ans=0;
	string str;
	
	cin >> str;
	for(int i=0;i<4;i++)
	{
		if(str[i]=='+')ans++;
		if(str[i]=='-')ans--;
	}
	cout << ans << endl;
	return 0;
}



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

using namespace std;

const int N = 110;
int dp[N][N];
string s[N];

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

  int h, w;
  cin >> h >> w;
  for (int i = 0; i < h; ++i) {
    cin >> s[i];
  }
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (i and j) {
        if (s[i][j] == '#') {
          dp[i][j] = min(dp[i - 1][j] + (s[i - 1][j] != '#'), dp[i][j - 1] + (s[i][j - 1] != '#'));
        } else {
          dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]);
        }
      } else if (i) {
        if (s[i][j] == '#') {
          if (s[i - 1][j] == '#') {
            dp[i][j] = dp[i - 1][j];
          } else {
            dp[i][j] = dp[i - 1][j] + 1;
          }
        } else {
          dp[i][j] = dp[i - 1][j];
        }
      } else if (j) {
        if (s[i][j] == '#') {
          if (s[i][j - 1] == '#') {
            dp[i][j] = dp[i][j - 1];
          } else {
            dp[i][j] = dp[i][j - 1] + 1;
          }
        } else {
          dp[i][j] = dp[i][j - 1];
        }
      } else {
        dp[i][j] = s[i][j] == '#';
      }
    }
  }
  cout << dp[h - 1][w - 1];

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <sstream>
#include <iterator>

using namespace std;

#define endl ("\n")
#define pi (3.141592653589)
#define mod 1000000007
#define int int64_t
#define float double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) c.begin(), c.end()
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
#define rep(i, n) for (int i = 0; i < n; i++)
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)

struct debugger
{
    template <typename T>
    debugger &operator,(const T &v)
    {
        cerr << v << " ";
        return *this;
    }
} dbg;

int32_t main()
{
    fast;
    int a = 100;
    int x;
    cin >> x;
    int interest = 0;
    int count = 0;
    while (a < x)
    {
        int in = a / 100;
        a += in;
        count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 3644
# -*- coding: utf-8 -*-

import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
D=LIST()
M=INT()
T=LIST()

C1=Counter(D)
C2=Counter(T)

for k, v in C2.items():
    if C1[k]<v:
        NO()
        exit()
YES()


Measured memory_bytes: 57052
#include <stdio.h>
int main(void){
    int l[10],v[2],L=0,ans[100],temp,i,j=0;
    float cp;
    while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&l[0],&l[1],&l[2],&l[3],&l[4],&l[5],&l[6],&l[7],&l[8],&l[9],&v[0],&v[1])!=EOF) {
        L=0;
        for(i=0;i<10;i++) L+=l[i];
        cp = 1.0*L*v[0]/(v[0]+v[1]);
        for(i=0;i<10;i++) {
            cp -= l[i];
            if(cp<=0) {
                ans[j]=i+1;
                break;
            }
        }
        j++;
    }
    for(i=0;i<j;i++) printf("%d\n",ans[i]);
    return 0;
}

Measured memory_bytes: 596
N, K = map(int,input().split())
S = input()
ans = []
for i in range(N):
    if i == K - 1:
        x = ord(S[i])
        x += 32
        y = chr(x)
        ans.append(y)
    else:
        ans.append(S[i])

print(''.join(ans))

Measured memory_bytes: 9144
x=int(input())
result=0
cnt=0

while True:
    if result == 0:
        for i in range(2,x+1):
            if i == x:
                result = x
                break
            else:
                if x%i == 0:
                    x+=1
                    break
                else:
                    continue
    else:
        break

print(result)

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

using namespace std;
typedef long long ll;
const int maxn=1e5+5;
int val[maxn];
ll dp[maxn];

int main()
{
	ios::sync_with_stdio(false);
	int n;
	while(cin>>n){
		for(int i=0;i<n;i++){
			cin>>val[i];
		}
		dp[0]=0,dp[1]=abs(val[0]-val[1]);
		for(int i=2;i<n;i++){
			dp[i]=min(abs(val[i]-val[i-1])+dp[i-1],abs(val[i]-val[i-2])+dp[i-2]);
		}
		cout<<dp[n-1]<<endl;
	}
	return 0;
}

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

using namespace std;

int main() {
    string s,t;
    cin>>s>>t;
    int n = s.size(), m= t.size();
    int dp[n+1][m+1];
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(s[i-1]==t[j-1])
                dp[i][j] = 1+dp[i-1][j-1];
            else
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }
    int i=n, j=m;
    string ans="";
    while(i>0 && j>0){
        if(s[i-1]==t[j-1]){
            ans+=s[i-1];
            --i,--j;
        } else if(dp[i-1][j]>=dp[i][j-1])
            --i;
        else
            --j;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<"\n";
}

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

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    int sum = a + b;
    if(sum >= 24)
    {
        cout << sum % 24 << '\n';
    }
    else
    {
        cout << sum << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
package main

import (
  "fmt"
)

func sumInt(a ...int) int {s := 0; for _, v := range a {s += v}; return s}
func maxInt(a ...int) int {m := a[0]; for _, x := range a {if x > m {m = x}}; return m}
func minInt(a ...int) int {m := a[0]; for _, x := range a {if x < m {m = x}}; return m}

func main() {
  var n, x int 
  fmt.Scan(&n, &x)
  m := make([]int, n)
  for i := 0; i < n; i++ {
    fmt.Scan(&m[i])
  }
  cnt := n
  x -= sumInt(m...)
  cnt += x / minInt(m...)
  fmt.Println(cnt)

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define MAXN 100000
int v[MAXN+1];
int main(){
   FILE*fi,*fout;
   int i,n,ans;
  // fi=fopen("A.in" ,"r");
   //fout=fopen("A.out" ,"w");
   fi=stdin;
   fout=stdout;
   fscanf(fi,"%d " ,&n);
   for(i=1;i<=n;i++)
     fscanf(fi,"%d " ,&v[i]);
   i=1;
   ans=0;
   while(i<=n){
        int poz=i;
        while(poz<n&&v[poz]<=v[poz+1])
           poz++;
        while(i<n&&v[i]>=v[i+1])
           i++;
        i=std::max(i+1,poz+1);
        ans++;
   }
   fprintf(fout,"%d\n" ,ans);
   fclose(fi);
   fclose(fout);
   return 0;
}


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

int main(){
  vector<int> A(3);
  rep(i,3) cin >> A[i];
  sort(A.begin(),A.end());
  cout << A[0]+A[1] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
    int a, b, c;
    int ans;
    cin >> a >> b >> c;
    if (a > b && a > c) ans = b * c / 2;
    else if (b > a && b > c) ans = a * c / 2;
    else ans = a * b / 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def read_line(*types): return [f(a) for a, f in zip(input().split(), types)]

a, b, k = read_line(int, int, int)

if a + k > b - k:
    for i in range(a, b + 1):
        print(i)
else:
    for i in range(a, a + k):
        print(i)
    for i in range(b - k + 1, b + 1):
        print(i)


Measured memory_bytes: 3060
/*#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
#include<limits.h>

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int IINF=INT32_MAX;
static const ll LINF=INT64_MAX;
static const ll mod=1e9+7;
static const double eps=1e-13;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};

template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}

int N;
ll A[100005];

ll res=1;

ll maxR=1e18;

bool ok=true;


int main(){
    cin>>N;
    for(int i=0;i<N;++i){
        cin>>A[i];
        if(A[i]==0)ok=false;
    }
    if(!ok){
        cout<<0<<endl;
        return 0;
    }
    for(int i=0;i<N;++i){
        ll c=maxR/res;
        if(A[i]-c>0){
            cout<<-1<<endl;
            return 0;
        }
        res*=A[i];
    }
    cout<<res<<endl;
}
*/
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int MAX = (1e18 + 0.5);

bool check(int a, int b) {
  return a <= MAX / b;
}

signed main() {
  int prod = 1;
  int N, A[100000];
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (A[i] == 0) {
      cout << "0" << endl;
      return 0;
    }
  }
  for (int i = 0; i < N; i++) {
    if (!check(prod, A[i])) {
      cout << "-1" << endl;
      return 0;
    }
    prod *= A[i];
  }
  cout << prod << endl;
  return 0;
}

Measured memory_bytes: 4400
#include <cstdio>
#include <climits>
#include <algorithm>
using namespace std;

int main() {
  int N; scanf("%d", &N);
  static char S[500003];
  scanf("%500000s", S);
  // NFA for (.|1+01|101+)*
  // q0 -0-> q0 (+0)
  // q0 -1-> q0 (+0)
  // q0 -1-> q1 (+1)
  // q1 -1-> q1 (+1)
  // q1 -0-> q2 (+0)
  // q2 -1-> q0 (+0)
  // q0 -1-> q3 (+0)
  // q3 -0-> q4 (+0)
  // q4 -1-> q4 (+1)
  // q4 -1-> q0 (+1)
  int dp[5] = {0, INT_MIN, INT_MIN, INT_MIN, INT_MIN};
  for(int i = 0; i < N; ++i) {
    int dp2[5] = {dp[0], dp[1], dp[2], dp[3], dp[4]};
    if(S[i] == '0') {
      // q0 -0-> q0 (+0)
      // q1 -0-> q2 (+0)
      // q3 -0-> q4 (+0)
      dp[0] = dp2[0];
      dp[1] = INT_MIN;
      dp[2] = dp2[1];
      dp[3] = INT_MIN;
      dp[4] = dp2[3];
    } else {
      // q0 -1-> q0 (+0)
      // q2 -1-> q0 (+0)
      // q4 -1-> q0 (+1)
      // q0 -1-> q1 (+1)
      // q1 -1-> q1 (+1)
      // q0 -1-> q3 (+0)
      // q4 -1-> q4 (+1)
      dp[0] = max({dp2[0], dp2[2], dp2[4] + 1});
      dp[1] = max({dp2[0] + 1, dp2[1] + 1});
      dp[2] = INT_MIN;
      dp[3] = dp2[0];
      dp[4] = dp2[4] + 1;
    }
  }
  printf("%d\n", dp[0]);
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
int main(){
	while(1){int a,b;
	cin>>a>>b;
	if(a==0){
	break;}
	if(a==12){b+=335;}else
	if(a==11){b+=305;}else
	if(a==10){b+=274;}else
	if(a==9){b+=244;}else
	if(a==8){b+=213;}else
	if(a==7){b+=182;}else
	if(a==6){b+=152;}else
	if(a==5){b+=121;}else
	if(a==4){b+=91;}else
	if(a==3){b+=60;}else
	if(a==2){b+=31;}
	if(b%7==1){
	cout<<"Thursday"<<endl;}else
		if(b%7==2){
	cout<<"Friday"<<endl;}else
	if(b%7==3){
	cout<<"Saturday"<<endl;}else
		if(b%7==4){
	cout<<"Sunday"<<endl;}else
	if(b%7==5){
	cout<<"Monday"<<endl;}else
	if(b%7==6){
	cout<<"Tuesday"<<endl;}else{
	cout<<"Wednesday"<<endl;}}
	return 0;}


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

int a[6],i;

int comp(const void *p,const void *q){
	return *(int *)q-*(int *)p;
}

int main(){
	scanf("%d %d %d %d %d",&a[0],&a[1],&a[2],&a[3],&a[4]);
	qsort(a,5,sizeof(int),comp);
	for(i=0;i<5;i++){
		if(i!=4)printf("%d ",a[i]);
		else printf("%d\n",a[i]);
	}
	return 0;
}

Measured memory_bytes: 0
#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());
    reverse(v.begin(), v.end());
    double ans = 0;
    for( int i = 0; i < N; i++ ) ans += i != N-1 ? (double)v[i]/pow(2,i+1) : (double)v[i]/pow(2,i);
    cout << ans << endl;
}

Measured memory_bytes: 384
// 
	#include<bits/stdc++.h> 
	#include <sstream> 
	using namespace std; 
	typedef long long ll;
	inline bool cmp(pair< ll , ll > &a , pair< ll , ll >  &b){
		if(a.first != b.first)
			return a.first > b.first;
		else
			return a.second < b.second;
	}

	int main() 
	{ 
		ios_base::sync_with_stdio(false);
	    cin.tie(NULL);
	    int n;
	    cin >> n;
	    string a , b , res = "";
	    cin >> a >> b;
	    for(int i = 0 ; i < n ; i++){
	    	res += a[i];
	    	res += b[i];
	    }
	    cout << res << endl;
	}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){

    int n,x,t;
    scanf("%d%d%d",&n,&x,&t);
    
    int ans = 0;
    
    while(n > 0){
        n -= x;
        ans += t;
    }
    
    printf("%d\n",ans);
    
}


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

using namespace std;

typedef long long int ll;
typedef pair<int,int> ii;

const int N = 1e5 + 5;

int n,m,c,b[N],ans;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cin >> n >> m >> c;
  for (int i = 1 ; i <= m ; i++)
    cin >> b[i];
  for (int i = 1 ; i <= n ; i++) {
    int sum = c;
    for (int j = 1 ; j <= m ; j++) {
      int a;
      cin >> a;
      sum += a * b[j];
    }
    if (sum > 0)
      ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i< (n); i++)
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
int main()
{
    int n,m;
    cin >> n >> m;
    Graph g(n);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<int> dist(n,-1);
    queue<int> que;
    int group = 0;
    rep(i,n){
        if(dist[i] == 1) continue;
        dist[i] = 1;
        que.push(i);
        while(!que.empty()){
            int v = que.front();
            que.pop();
            for(int nv : g[v]){
                if(dist[nv] == 1) continue;

                dist[nv] = 1;
                que.push(nv);
            }
        }
        group++;
    }
    cout << group -1 << endl;
return 0;
}

Measured memory_bytes: 8800
function Main(input) {
	input = input.trim();
	//input = input.trim().split(" ");
	//input = input.trim().split("\n");
	input = input.trim().split(" ").map((a)=>Number(a));
	//input = input.trim().split("\n").map((a)=>Number(a));
  	console.log(Math.ceil((input[0] + input[1]) / 2));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21192
#include <algorithm>
#include <bitset>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <chrono>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)
#define DEBUG(x) cout << #x << ": " << x << endl
#define INFILE() freopen("input.txt", "r", stdin)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define RREP(i, a, b) for (int i = (a); i >= (b); i--)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_i = pair<double, int>;
using i_d = pair<int, double>;
using d_d = pair<double, double>;

static constexpr ll LL_MOD = 1000000009;
static constexpr ll LL2_MOD = 1000000007;
static constexpr ll INF = 1LL << 60;
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr double PI = 3.14159265358979323846264338327950288;

static map<type_index, const char *const> scanType = {
  { typeid(int), "%d" }, { typeid(ll), "%lld" }, { typeid(double), "%lf" }, { typeid(char), "%c" }};

template <class T> static void scan(vector<T>& v);
static void scan(vector<string>& v, bool isWord = true);
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll dp[101][100001];

int main(int argc, char *argv[]) {
  //INFILE();

  ll n, w;
  cin >> n >> w;

  vector<ll> weights(static_cast<int>(n));
  vector<ll> values(static_cast<int>(n));
  REP(i, 0, n) {
    cin >> weights[i] >> values[i];
  }

  REP(i, 1, n + 1) {
    REP(j, 0, w + 1) {
      chmax(dp[i][j], dp[i - 1][j]);
      if (j - weights[i - 1] < 0) continue;
      chmax(dp[i][j], dp[i - 1][j - weights[i - 1]] + values[i - 1]);
    }
  }

  cout << dp[n][w] << endl;
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}


Measured memory_bytes: 78336
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;

const int N=100005;

int n,now,last;
char s[N];

int main(){
	int i,j;
	scanf("%s",s+1);
	n=strlen(s+1);
	if (s[n]!='0'||s[1]!='1'){
		printf("-1\n");
		return 0;
	}
	for (i=1;i<n;i++) if (s[i]!=s[n-i]){
		printf("-1\n");
		return 0;
	}
	now=1; last=1;
	for (i=2;i<=n;i++){
		if (s[i]=='1'){
			for (j=last;j<=now;j++) printf("%d %d\n",j,i);
			now=last=i;
			continue;
		}
		now++;
	}
	printf("%d %d\n",n-1,n);
	return 0;
} 

Measured memory_bytes: 1536
#include<iostream>
#include<iomanip>
#include<functional>
#include<algorithm>
#include<string>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<set>
#include<queue>
#include<cmath>

using namespace std;
#define LL long long

LL x,now=100ll,ans;

int main() {
	cin>>x;
	for(ans=0;now<x;ans++)
		now+=now/100ll;
	cout<<ans<<endl;
	
	return 0;
}



Measured memory_bytes: 3636
using System;
public class Hello{
    public static void Main(){
        string[] input = Console.ReadLine().Split(' ');
        int r = int.Parse(input[0]);
        int g = int.Parse(input[1]);
        int b = int.Parse(input[2]);
        if((r * 100 + g * 10 + b) % 4 == 0){
            Console.WriteLine("YES");
        }else{
            Console.WriteLine("NO");
        }
    }
}


Measured memory_bytes: 11092
package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	A := sc.NextIntArray()

	ans := make([]int, N)

	i := 0
	j := N - 1

	a := N - 1

	for i <= j {
		if a%2 == 0 {
			ans[i] = A[a]
			i++
		} else {
			ans[j] = A[a]
			j--
		}
		a--
	}

	if N%2 == 0 {
		reverse(ans, 0, len(ans))
	}
	PrintI(ans...)
}

func reverse(a []int, start int, length int) {
	var end = start + length - 1
	for start < end {
		a[start], a[end] = a[end], a[start]
		start++
		end--
	}
}

func PrintI(args ...int) {
	fmt.Println(strings.Join(mapToString(args), " "))
}

func mapToString(arr []int) []string {
	ret := make([]string, len(arr))
	for i := 0; i < len(arr); i++ {
		ret[i] = strconv.Itoa(arr[i])
	}
	return ret
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 20864