akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>

// #include <unordered_set>
// #include <unordered_map>

#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

#define pb push_back
#define mp make_pair

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

typedef std::pair<int, int> P;
typedef long long ll;
typedef long double ld;

const int MOD = 1000000007;
const int INF = 1e9;
const ll LINF = INF * 1ll * INF;
const ld DINF = 1e200;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

using namespace std;

// #define int long long

signed main(){
  

    ios::sync_with_stdio(false);
    cin.tie(0);
	//cin高速化

	
	int a,b;
	string s;

	cin>>a>>b>>s;

	REP(i,a){
		if(s[i]=='-'){
			cout<<"No"<<endl;
			return 0;
		}
	}

	for(int i=a+1;i<s.size();i++){
		if(s[i]=='-'){
			cout<<"No"<<endl;
			return 0;
		}
	}

	if(s[a]!='-'){
		cout<<"No"<<endl;
		return 0;
	}

	cout<<"Yes"<<endl;
  
 	return 0;

}

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

int main() {
    int k, s;
    long long ans = 0;
    cin >> k >> s;
    for (int i = 0; i <= k; i++) {
        for (int j = 0; j <= k; j++) {
            if(0 <= s - i - j && s - i - j <= k) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3588
#時間の無駄なのでクソ問と割り切って飛ばす
def prod(array):
    res = 1
    for a, _ in array:
        res *= a
        res %= MOD
    return res

MOD = 10**9 + 7
N, K = map(int, input().split())
if N==K:
    res = 1
    for a in map(int, input().split()):
        res *= a
        res %= MOD
    print(res)
    exit()
A = []
allsgn = 0
for a in map(int, input().split()):
    A.append((abs(a), a < 0))
    allsgn += a<0
A.sort(reverse=True)
sgn = 0
s0 = -1
lastA = -1
for i, p in enumerate(A[:K]):
    a, s = p
    sgn += s
    if s != s0:
        lastA = i-1
    s0 = s
lasts = s0
if allsgn==N:
    if K%2==1:
        print((-prod(A[-K:]))%MOD)
        exit()
    else:
        print(prod(A[:K])%MOD)
        exit()
if sgn%2==0:
    print(prod(A[:K])%MOD)
    exit()
if lasts != A[K][1]:
    res = prod(A[:K-1])*A[K][0]
else:
    firstA = None
    for i, p in enumerate(A[K:],start=K):
        a, s = p
        if s != lasts:
            firstA = i
            break
    if lastA == -1 or (firstA is not None and A[K][0]/A[lastA][0] < A[firstA][0]/A[K-1][0]):
        res = prod(A[:K - 1]) * A[firstA][0]
    else:
        res = prod(A[:lastA]) * prod(A[lastA + 1:K + 1])
print(res%MOD)
"""
6 3
5 -3 -3 -3 -3 -2

10 7
-10 -10 -10 -10 10 10 10 10 10 10
"""


Measured memory_bytes: 105568
#include<bits/stdc++.h>
using namespace std;
main(){
  string s;
  cin>>s;
  int l=0,r=s.size()-1,c=0;
  while(l<r){
    if(s[l]==s[r])++l,--r;
    else if(s[l]=='x')++l,++c;
    else if(s[r]=='x')--r,++c;
    else return cout<<-1,0;
  }
  cout<<c;
}

Measured memory_bytes: 512
#include <iostream>
#include <sstream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int main() {
  string a[20] = {"yotta","zetta","exa","peta","tera","giga","mega","kilo","hecto","deca","deci","centi",
                  "milli","micro","nano","pico","femto","ato","zepto","yocto"};
  int b[20] = {24,21,18,15,12,9,6,3,2,1,-1,-2,-3,-6,-9,-12,-15,-18,-21,-24};
  map<string, int> mp;
  REP(i,20) mp[a[i]] = b[i];
  int N;
  cin >> N;
  while(N--) {
    string num, s, t;
    cin >>num>>s;
    if (mp.count(s) == 0) {
      t = s;
    } else cin >> t;
    int ten = -1, pos = -1;
    REP(i, num.size()) {
      if (num[i]=='.') ten=i;
      else if (num[i]!='0' && pos==-1) pos = i;
    }
    int yuko = num.size() - pos;
    int aa;
    string res;
    if (ten == -1) {
      res += string(1,num[0]) + "." + num.substr(1);
      aa = -num.size()+1;
    } else if (ten<pos) {
      res += string(1,num[pos]) + "." + num.substr(pos+1);
      int zero = yuko-res.size()+1;
      //cout << res << " " << zero << endl;
      res += string(zero,'0');
      aa = pos-1;
    } else {
      res += string(1,num[pos]) + "." + num.substr(pos+1, ten-pos-1) + num.substr(ten+1);
      int zero = yuko-res.size();
      res += string(zero,'0');
      aa = -ten+1;
    }
    if (res[res.size()-1] == '.') res = res.substr(0, res.size()-1);
    aa *= -1;
    //cout << num << " " << aa << " " << mp[s] << endl;
    aa += mp[s];
    cout << res <<  " * 10^" << aa << " " << t << endl;
  }
}

Measured memory_bytes: 0
package main

import (
	"fmt"
	"math"
	"strconv"
)

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	var n int
	fmt.Scan(&n)

	ans := math.MaxInt64
	for i := 1; i <= n/2; i++ {
		sum := 0
		for _, r := range strconv.Itoa(i) {
			sum += int(r - '0')
		}
		for _, r := range strconv.Itoa(n - i) {
			sum += int(r - '0')
		}
		ans = min(ans, sum)
	}
	fmt.Println(ans)
}


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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

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

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll n, x;
	cin >> n >> x;
	
	cout << (n - gcd(n, x)) * 3 << endl;
	
	
	return 0;
}

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

int main()
{
   /*int ye,mo,da;
   string sl, sr;
   cin >> ye >> sl >> mo >> sr >> da;
   cout << ye+1 << sl << mo << sr << da << endl;*/
   string n;
   cin >> n;
   n[3] = '8';
   cout << n << endl;
 
  
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String wstrg = sc.next();
        int count = 0;
        if(wstrg.equals("SSS")) count = 0;
        if(wstrg.equals("SSR")) count = 1;
        if(wstrg.equals("SRS")) count = 1;
        if(wstrg.equals("RSS")) count = 1;
        if(wstrg.equals("RRS")) count = 2;
        if(wstrg.equals("SRR")) count = 2;
        if(wstrg.equals("RSR")) count = 1;
        if(wstrg.equals("RRR")) count = 3;
        System.out.println(count);
    }
}

Measured memory_bytes: 35736
#include <bits/stdc++.h>
using namespace std;
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;
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

using P = pair<int, int>;

struct RollingHash {
    const int b1 = 1007, b2 = 2009;
    const int mod1 = 1e9 + 7, mod2 = 1e9 + 9;
    vector<ll> h1, h2, p1, p2;

    RollingHash(const vector<ll> &s) {
        int n = s.size();
        h1.resize(n + 1, 0);
        h2.resize(n + 1, 0);
        p1.resize(n + 1, 1);
        p2.resize(n + 1, 1);
        for(int i = 0; i < n; i++) {
            h1[i + 1] = (h1[i] * b1 + s[i]) % mod1;
            h2[i + 1] = (h2[i] * b2 + s[i]) % mod2;
            p1[i + 1] = (p1[i] * b1) % mod1;
            p2[i + 1] = (p2[i] * b2) % mod2;
        }
    }

    pair<ll, ll> get(int l, int r) {
        ll res1 = h1[r] - h1[l] * p1[r - l] % mod1;
        if(res1 < 0) {
            res1 += mod1;
        }
        ll res2 = h2[r] - h2[l] * p2[r - l] % mod2;
        if(res2 < 0) {
            res2 += mod2;
        }
        return make_pair(res1, res2);
    }

    int get_lcp(int a, int b) {
        int len = min((int)h1.size() - a, (int)h1.size() - b);
        int ok = 0, ng = len;
        while(ng - ok > 1) {
            int mid = (ok + ng) >> 1;
            (get(a, a + mid) == get(b, b + mid) ? ok : ng) = mid;
        }
        return ok;
    }

    int get_lcp(RollingHash &t, int a, int b) {
        int len = min((int)h1.size() - a, (int)h1.size() - b);
        int ok = 0, ng = len;
        while(ng - ok > 1) {
            int mid = (ok + ng) >> 1;
            (get(a, a + mid) == t.get(b, b + mid) ? ok : ng) = mid;
        }
        return ok;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for(auto &it : a) {
        cin >> it;
    }
    for(auto &it : b) {
        cin >> it;
    }
    vector<ll> a2(2 * n), b2(2 * n);
    for(int i = 0; i < 2 * n; i++) {
        a2[i] = a[i % n] ^ a[(i + 1) % n];
        b2[i] = b[i % n] ^ b[(i + 1) % n];
    }
    RollingHash ha(a2), hb(b2);
    for(int k = 0; k < n; k++) {
        if(ha.get_lcp(hb, k, 0) >= n) {
            cout << k << " " << (b[0] ^ a[k]) << endl;
        }
    }
}

Measured memory_bytes: 36352
p = 10**9+7
N = int(input())
dp = [[[[[0 for _ in range(4)] for _ in range(4)] for _ in range(4)] for _ in range(4)] for _ in range(N+1)]
for j in range(4):
    for k in range(4):
        for l in range(4):
            if not(j==0 and k==1 and l==2) and not(j==0 and k==2 and l==1) and not(j==1 and k==0 and l==2):
                dp[3][0][j][k][l] = 1
for n in range(4,N+1):
    for i in range(4):
        for j in range(4):
            for k in range(4):
                for l in range(4):
                    if not(j==0 and k==1 and l==2) and not(j==0 and k==2 and l==1) and not(j==1 and k==0 and l==2) \
                    and not(i==0 and k==1 and l==2) and not(i==0 and j==1 and l==2):
                        dp[n][i][j][k][l] = 0
                        for m in range(4):
                            dp[n][i][j][k][l] = (dp[n][i][j][k][l]+dp[n-1][m][i][j][k])%p
tot = 0
for i in range(4):
    for j in range(4):
        for k in range(4):
            for l in range(4):
                tot = (tot + dp[N][i][j][k][l])%p
print(tot)

Measured memory_bytes: 51824
import fractions
N=int(input())
ls=[int(s) for s in input().split()]
gcd_l=[0 for _ in range(N+1)]
gcd_l[0]=ls[0]
gcd_r=[0 for _ in range(N+1)]
gcd_r[N-1]=ls[N-1]
for i in range(N-1):
  gcd_l[i+1]=fractions.gcd(gcd_l[i],ls[i+1])
  gcd_r[N-i-2]=fractions.gcd(gcd_r[N-i-1],ls[N-i-2])
ans=set()
for i in range(N):
  ans.add(fractions.gcd(gcd_l[i-1],gcd_r[i+1]))
print(max(ans))

Measured memory_bytes: 16140
#include<iostream>

int h = 0 , m = 0 , s = 0 ;

int main()
{
	std::cin >> s ;
	for(;s >= 60;)
	{
		m += 1 ;
		s -= 60 ;
	}
	for(;m >= 60;)
	{
		h += 1 ;
		m -= 60 ;
	}
	std::cout << h << ":" << m << ":" << s <<std::endl ;
}

Measured memory_bytes: 1164
#include<stdio.h>
int main(void)
{
  int a,b;
  int max;
  
  scanf("%d",&a);
  scanf("%d",&b);
  
  max=a+b;
  
  if(a+b<=a-b){
    max=a-b;
  }
  if(a+b<=a*b){
    max=a*b;
  }
  
  printf("%d",max);
  
  return 0;
}
  
  

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

int n, k, ans, d, t;
bool vis[105];

int main() {
	cin >> n >> k;
	for (int i = 1; i <= k; ++i) {
		cin >> d;
		for (int j = 1; j <= d; ++j) {
			cin >> t;
			vis[t] = 1;
		}
	}
	for (int i = 1; i <= n; ++i)
		if (!vis[i])
			ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3588
n,l = map(int,input().split())
a = list(map(int,input().split()))

memo = -1
for i in range(n-1):
    if a[i]+a[i+1] >= l:
        memo = i

if memo == -1:
    print("Impossible")
else:
    print("Possible")
    for i in range(memo):
        print(i+1)
    for i in range(n-2,memo-1,-1):
        print(i+1)




Measured memory_bytes: 14304
#include<stdio.h>
int main(void)
{
    long long int n,m,l,a[105][105],b[105][105],c[105][105]={0};
    int i,j,k;
    scanf("%lld %lld %lld",&n,&m,&l);
    for(i=1;i<=n;i++){
        for(j=1;j<=m;j++){
            scanf("%lld",&a[i][j]);
        }
    }
    for(i=1;i<=m;i++){
        for(j=1;j<=l;j++){
            scanf("%lld",&b[i][j]);
        }
    }
    for(i=1;i<=n;i++){
        for(j=1;j<=l;j++){
            for(k=1;k<=m;k++){
                c[i][j]+=a[i][k]*b[k][j];
            }
            printf("%lld",c[i][j]);
            if(j<l)printf(" ");
        }
        printf("\n");
    }
 
 
 
    return 0;
}

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

int main()
{
	int count=0,n;
	bitset<1000001> prime;

	prime[0]=1;
	prime[1]=1;
	for(int i=2;i<=1000;i++)
		if(prime[i]==0)
			for(int j=i+1;j<=1000000;j++)
				if(j%i==0)
					prime[j]=1;
	
	while(cin>>n)
	{
		for(int i=0;i<=n;i++)
			if(prime[i]==0)
				count++;
		cout<<count<<endl;
		count=0;
	}
		
}

Measured memory_bytes: 1280
#include <iostream>
using namespace std;
int main()
{
	int a,b;
	cin >> a >> b;
	if (1<=a && a<=12){
		if(1<=b && b<=31){
			if(a<=b){
				cout << a << endl;
			}else{
				cout << a-1 << endl;
			}
		}
	}
}

Measured memory_bytes: 256
import heapq
def dijkstra_heap(s,edge):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    for i,j in enumerate(used):
        if j:
            d[i]=-1
    return d

n,w,r = map(int,input().split()) #n:頂点数　w:辺の数
edge = [[] for i in range(n)]
#edge[i] : iから出る道の[重み,行先]の配列
for i in range(w):
    x,y,z = map(int,input().split())
    edge[x].append([z,y])
for i in dijkstra_heap(r,edge):
    if i==-1:
        print('INF')
    else:
        print(i)


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

int main()
{
	int N, ans = 0;
	cin >> N;

	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a.at(i);
	}

	int j = 0;
	bool flg = false;
	for (int i = 0; i < N; i++) {
		ans++;
		if (a.at(j) == 2) {
			flg = true;
			break;
		}
		j = a.at(j) - 1;
	}

	cout << (flg ? ans : -1) << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <bitset>

using namespace std;

int n;
const int N = 2001;

int a[N];

bitset<N * N> s;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	s[0] = 1;
	for (int i = 0; i < n; i++) s = s | (s << a[i]);
	int x = 0;
	for (int i = 0; i < n; i++) x += a[i];
	if (s.count() % 2 == 1)
    {
        cout << x / 2;
        return 0;
    }
    for (int i = (x + 1) / 2; i <= x; i++) if (s[i])
    {
        cout << i;
        return 0;
    }
}


Measured memory_bytes: 2176
#include <stdio.h>
typedef long long int ll;
int main()
{
    int n;
    scanf("%d",&n);
    ll a[n],total=0;
    for(int i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
        total^=a[i];
    }
    for(int i=0;i<n;i++)
    printf("%lld ",total^a[i]);
}


Measured memory_bytes: 4004
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
  i64 n, s = 0;
  cin >> n;
  while (n--) {
    i64 l, r;
    cin >> l >> r;
    s += r - l + 1;
  }
  cout << s << '\n';
  return 0;
}



Measured memory_bytes: 256
import sys
import numpy as np

N, D = list(map(int, input().split()))

X = np.zeros([N,D])
for n in range(N):
    X[n,:] = np.array(list(map(int, input().split())))

cnt = 0
for n1 in range(N):
    for n2 in range(n1+1,N):
        r = 0
        for d in range(D):
            r += (X[n1,d]-X[n2,d])**2

        if np.sqrt(r) == int(np.sqrt(r)):
            cnt += 1

print(cnt)
    


Measured memory_bytes: 13176
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;
int keta (int x) {
    int keta = 0;
    while(x>0){
        x/=10;
        keta++;
    }
    return keta;
}
int main() {
    int a, b;
    cin >> a >> b;
    int num = a*pow(10, keta(b)) + b;
    double x = sqrt(num);
    if(floor(x)==x) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    int sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    if(sum%10!=0)
    {
        cout<<sum;
        return 0;
    }
    sort(a,a+n);
    int store=sum;
    int k=0;
    int b[n];
    for(int i=0;i<n;i++)
    {
        store-=a[i];
        b[k]=store;
        store=sum;
        k++;
    }
    int answer=0;
    for(int i=0;i<n;i++)
    {
        if(b[i]%10!=0)
        {
            answer=b[i];
            break;
        }
    }
    cout<<answer;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int) n; i++)
#define repb(i, n) for (int i = (int) n; i >= 0; i--)
#define reps(i, m, n) for (int i = (int) m; i < (int) n; i++)
#define repsb(i, m, n) for (int i = (int) m; i >= (int) n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
# define pb(a) push_back(a)
#define ll long long int
const ll LLINF = 1e18 + 10;
int dy[] = { 0, 0, 1, -1, 0 };
int dx[] = { 1, -1, 0, 0, 0 };
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return 1; } return 0; }
template < class T > bool chmin(T & a,const T & b) { if (b < a) { a = b; return 1; } return 0; }
//vector<vector<int>> vec(n_rows, vector<int>(n_cols, value));
using namespace std;
int main(int argc, char const * argv[]){
    int n,ans;
    cin >> n;
    ll x;
    vector<ll> v(n,-1);
    cin>>x;
    rep(i,n) cin>>v[i];
    VSORT(v);
    ll cnt=0;
    if(v[0]>x){
        cout<<0<<endl;
        return 0;
    }
    rep(i, n)
    {
        cnt+=v[i];
        if(cnt==x){
            ans = i+1;
            break;
        }
        if(cnt>x){
            ans = i;
            break;
        }
        ans = n - 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/


int main() {
    cin >> n >> m;
    REP(i,m/10000+1) {
        REP(j,(m-i*10000)/5000+1) {
            k = n - i - j;
            if(i*10000+j*5000+k*1000==m){
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
}

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

template <typename Tp> inline void getint(Tp &num){
	register int ch, neg = 0;
	while(!isdigit(ch = getchar())) if(ch == '-') neg = 1;
	num = ch & 15;
	while(isdigit(ch = getchar())) num = num * 10 + (ch & 15);
	if(neg) num = -num;
}

int N, ans = 0, cntl = 0, cntr = 0, cntlr = 0;
char str[12];

int main(){
	getint(N);
	for(register int i = 1, len; i <= N; i++){
		scanf("%s", str + 1), len = strlen(str + 1);
		for(register int j = 1; j < len; j++) if(str[j] == 'A' && str[j + 1] == 'B') ans++;
		str[1] == 'B' && str[len] == 'A' ? cntlr++ : str[1] == 'B' ? cntl++ : str[len] == 'A' ? cntr++ : 0;
	}
	if(cntlr) printf("%d\n", ans + (cntlr - 1) + (cntl > 0) + (cntr > 0) + min(cntl - (cntl > 0), cntr - (cntr > 0)));
	else printf("%d\n", ans + min(cntl, cntr));
	return 0;
}


Measured memory_bytes: 256
def lower_elements(A, b):
    ''' リストAの要素のうち，b未満のものの個数を返す関数 '''
    lower_bound = -1
    upper_bound = len(A)
    while upper_bound - lower_bound > 1:
        middle = (lower_bound + upper_bound) // 2
        if A[middle] < b:
            lower_bound = middle
        else:
            upper_bound = middle
    return lower_bound + 1


def upper_elements(C, b):
    ''' リストCの要素のうち，cより大きいものの個数を返す関数 '''
    i = -1
    j = len(C)
    while j - i > 1:
        m = (i + j) // 2
        if C[m] > b:
            j = m
        else:
            i = m
    return len(C) - j


def answer(N, A, B, C):
    A.sort()
    B.sort()
    C.sort()
    count = 0
    for b in B:
        count += lower_elements(A, b) * upper_elements(C, b)
    return count


N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
print(answer(N, A, B, C))


Measured memory_bytes: 23156
#include <bits/stdc++.h>
#define r(i,a,n) for(int i=a;i<n;i++)
using namespace std;
int main(){
	int n,t,cc=0,aa[11514];
	string sss[11514],pp;
	cin>>n>>t;
	if(n)cin>>pp>>pp;
	r(i,0,n-1){
		int a,b,c,d;
		string s,ss;
		scanf("%d:%d",&a,&b);
		cin>>s;
		scanf("%d:%d",&c,&d);
		cin>>ss;
		if(((c*60+d)-(a*60+b))>=t){
			sss[cc]=ss;
			aa[cc++]=(c*60+d)-(a*60+b);
		}
	}
	if(n)cin>>pp>>pp;
	cout<<cc<<endl;
	r(i,0,cc)cout<<sss[i]<<' '<<aa[i]<<endl;
}

Measured memory_bytes: 3388
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//String tmp = sc.next();
		//int tmp = sc.nextInt();
		//Long tmp = sc.nextLong();
      int A = sc.nextInt();
      int B = sc.nextInt();
      if(A >= 13){
        System.out.println(B);
      }else if(A <= 12 && A >= 6){
        System.out.println(B / 2);
      }else{
        System.out.println(0);
      }
	}
}


Measured memory_bytes: 22740
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // dequef
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a) (a).begin(), (a).end()
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  ll n;
  cin >> n;
  int moji = int('a') - 1;
  string ans = "";
  while(n){
    int num = n % 26;
    if(!num){
      num = 26;
      n--;
    }
    ans += char(num + moji);
    n /= 26;
  }
  reverse(all(ans));
  cout << ans << endl;
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		while (n-- > 0) {
			int a = scanner.nextInt();
			boolean[][] map = new boolean[a + 4][a + 4];
			for (int i = 0; i < a + 4; i++) {
				for (int j = 0; j < a + 4; j++) {
					if (i == 0 || j == 0 || i == a + 3 || j == a + 3) {
						map[i][j] = true;
					}
				}
			}
			int x = 2;
			int y = a + 1;
			int h = 0;
			int[][] dxy = { { 1, 0 }, { 0, -1 }, { -1, 0 }, { 0, 1 } };
			boolean flag = false;
			loop: while (true) {
				if (flag) {
					for (int i = 0; i < 4; i++) {
						if (i == h) {
							continue;
						}
						int py = y + dxy[i][0];
						int px = x + dxy[i][1];
						if (map[py][px]) {
							break loop;
						}
					}
				}
				flag = false;
				map[y][x] = true;
				if (h == 0) {
					if (map[y - 2][x]) {
						x++;
						h = 1;
						flag = true;
					} else {
						y--;
					}
				} else if (h == 1) {
					if (map[y][x + 2]) {
						y++;
						h = 2;
						flag = true;
					} else {
						x++;
					}
				} else if (h == 2) {
					if (map[y + 2][x]) {
						x--;
						h = 3;
						flag = true;
					} else {
						y++;
					}
				} else {
					if (map[y][x - 2]) {
						y--;
						h = 0;
						flag = true;
					} else {
						x--;
					}
				}
			}
			for (int i = 2; i < a + 2; i++) {
				for (int j = 2; j < a + 2; j++) {
					System.out.print(map[i][j] ? "#" : " ");
				}
				System.out.println();
			}
			if (n != 0) {
				System.out.println();
			}
		}
	}
}

Measured memory_bytes: 24772
#include<bits/stdc++.h>
using namespace std;
int a[101];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	long long ans=1e9;
	for(int i=1;i<=100;i++)
	{
		long long cnt=0;
		for(int j=1;j<=n;j++)
		{
			cnt+=abs(a[j]-i)*abs(a[j]-i);
		}
		ans=min(cnt,ans);
	}
	cout<<ans;
} 

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

long long a, b;

long long solve();

int main() {
  cin >> a >> b;
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long res = 0, dig = 0, x, cnt = 0;
  while ((1LL << (dig + 1)) <= b) ++dig;
  while (b && (a >> dig & 1) == (b >> dig & 1)) {
    a &= (1LL << dig) - 1;
    b &= (1LL << dig) - 1;
    --dig;
  }
  if (b == 0) return 1;
  res = (1LL << dig) - a;
  x = b - (1LL << dig);
  while (x) x >>= 1, ++cnt;
  res += min(1LL << dig, res + (1LL << cnt));
  return res;
}

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

const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
const int MOD=1000000007;

int main(){
	int n,r;cin>>n>>r;
	if(n>=10)cout<<r<<endl;
	else cout<<r+100*(10-n)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <sstream>
#include <vector>
#include <string>
#include <iomanip>
#include <bitset>
#define INF	100000000
#define pb	push_back
using namespace std;
typedef pair<int, int> P;
typedef long long int	ll;

int main(){
	int n, m;
	while(cin >> n >> m){
		int ans = 0;
		if(n == 0 && m == 0) break;
		bool a[10][10000], b[10][10000];
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				cin >> a[i][j];
			}
		}
		for(int i = 0; i < pow(2,n); i++){
			for(int j = 0; j < n; j++){
				for(int k = 0; k < m; k++){
					b[j][k] = a[j][k];
				}
			}
			bitset<10> bs(i);
			int kari = 0;
			for(int j = 0; j < n; j++){
				if(bs[j] == true){
					for(int k = 0; k < m; k++){
						if(a[j][k] == true) b[j][k] = false;
						else b[j][k] = true;
					}
				}
			}
			for(int j = 0; j < m; j++){
				int x = 0;
				int t = 0;
				for(int k = 0; k < n; k++){
					x += b[k][j];
				}
				if(x > n/2) kari += x;
				else kari += n-x;
			}
			if(ans < kari) ans = kari;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1392
/// ****** Property of vipulks ****** \

#include <stdio.h>
#include <limits.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define ll long long

int main(){
	ll t,n,i,j,k,ans,a,b,c,d;
	t=1;//scanf("%lld",&t);
	while(t--){
		char s[200];
		scanf("%lld",&k);
		scanf("\n%s",s);
		n=strlen(s);
		if(n<=k)
			printf("%s\n",s);
		else{
			for(i=0;i<k;i++)
				printf("%c",s[i]);
			printf("...\n");
		}
	}
	return 0;
}

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

int main(void){
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    while(1){
        C -= B; 
        if(C <= 0){
            cout << "Yes" << endl;
            break;
        }
        A -= D;
        if(A <= 0){
            cout << "No" << endl;
            break;
        }
    }
    
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
    
//-------------------------↓↓↓↓↓↓------------------------
    
//------ 自分を天才だと信じる ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>a>>b>>c>>d;
    rep(i,100000){
        if(a<=i&&i<b&&c<=i&&i<d)ans++;
    }
    Cout(ans);
    return 0;
}

Measured memory_bytes: 764
//
// Created by yamunaku on 2020/01/18.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    // CFS;
    int h,w,n;
    cin >> h >> w >> n;
    h = max(h, w);
    cout << (n+h-1)/h << endl;
    return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc143/tasks/abc143_a
# -*- coding: utf-8 -*-

stu_bangou = list(map(int, input().strip().split()))

if stu_bangou[0] < (stu_bangou[1] * 2):
    print(0)
else:
    print(stu_bangou[0] - (stu_bangou[1] * 2))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define fast ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL)
#define F(i,a,b) for(int i= (int)(a); i<(int)(b);i++)
#define FI(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define RF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define what_is(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pii pair<int,int>
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define mp make_pair
#define ff first
#define ss second
#define MOD 1000000007
const int N = 1e6+7 ;
string s ;
bool vis[N] ;
deque<pii> dq ;
int main(){fast ;
	int k ;
	cin >> k ;
	dq.push_front({1,1}) ;
	while(!dq.empty()){
		pii now = dq.front() ;
		dq.pop_front() ;
		if(vis[now.ff])
			continue ;
		vis[now.ff] = true ;
		if(!now.ff){
			return cout << now.ss << endl , 0 ;
		}
		dq.push_front({now.ff * 10 % k , now.ss}) ;
		dq.push_back({(now.ff+1) % k , now.ss+1}) ;
	}
}




Measured memory_bytes: 1152
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr ll INF = 1ll << 55;

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

// multi-dimensional vector (require c++14)
template <typename T, typename U>
static inline vector<U> make_nd_vector(T &&n, U &&val) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<U>(forward<T>(n), forward<U>(val));
}
template <typename T, typename... Args>
static inline decltype(auto) make_nd_vector(T &&n, Args &&... args) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<decltype(make_nd_vector(forward<Args>(args)...))>(
      forward<T>(n), make_nd_vector(forward<Args>(args)...));
}
//
// Print from Iterator
template <typename ite>
void print_ite(ite start, ite end, char sp = ' ', char en = '\n') {
  for (auto i = start; i != end; i++)
    cout << *i << sp;
  cout << en;
}
//
inline void Yes(bool condition) { cout << (condition ? "Yes\n" : "No\n"); }

int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  if (n >= b - 1) {
    cout << a * (b - 1) / b << endl;
  } else {
    cout << a * n / b - a * (n / b) << endl;
  }
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};



signed main(){
  int A,B;cin>>A>>B;
  string s;cin>>s;

  for(int t=0;t<A+B+1;t++){
    if(t==A){
      if(s[t]!='-'){
        cout<<"No"<<endl;
        return 0;
      }
    }else{
      if(s[t]=='-'){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }

  cout<<"Yes"<<endl;
  return 0;
}


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

int main() {
	double d;
	while(cin >> d, d >= 0) {
		int a = 0;
		string b = "";
		a = d;
		d -= a;
		for(int i = 0; i < 4; i++) {
			b += (char)((d * 2) + '0');
			d *= 2;
			if(d >= 1) d -= 1;
		}
		if(d > 1e-9 || a >= (1 << 8))
			cout << "NA" << endl;
		else {
			for(int i = 0; i < 8; i++) {
				cout << !!(a & (1 << (7-i)));
			}
			cout << "." << b;
			cout << endl;
		}
	}
}

Measured memory_bytes: 1232
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//
constexpr ll MOD = 1e9 + 7;
/*/
const ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll a, b, k;
  cin >> a >> b >> k;
  if(k >= a){
    k -= a;
    a = 0;
  }else{
    a -= k;
    k = 0;
  }
  if(k > 0){
    b = max(b-k, 0ll);
  }
  print(a, b);
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<double> L(N);
  for(int i=0; i<N; i++){
    cin>>L[i];
  }
  sort(L.begin(),L.end());
  double t=L[0];
  for(int i=0; i<N-1; i++){
     t=(t+L[i+1])/2;
  }
  cout<<t<<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0148

"""
import sys
from sys import stdin

input = stdin.readline


def main(args):
    for line in sys.stdin:
        candy = int(line)
        hit = candy % 39
        if hit == 0:
            hit = 39
        print('3C{:02d}'.format(hit))



if __name__ == '__main__':
    main(sys.argv[1:])
    

Measured memory_bytes: 7676
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

MOD = 998244353
N, A, B, K = lr()
answer = 0
# A * x + B * y = K
# nCx * nCy

def F(x, y):
    return comb[x] * comb[y] % MOD

def cumprod(arr, MOD):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq)
    for n in range(1, Lsq):
        arr[:, n] *= arr[:, n-1]; arr[:, n] %= MOD
    for n in range(1, Lsq):
        arr[n] *= arr[n-1, -1]; arr[n] %= MOD
    return arr.ravel()[:L]

def make_fact(U, MOD):
    x = np.arange(U, dtype=np.int64); x[0] = 1
    fact = cumprod(x, MOD)
    x = np.arange(U, 0, -1, dtype=np.int64); x[0] = pow(int(fact[-1]), MOD-2, MOD)
    fact_inv = cumprod(x, MOD)[::-1]
    return fact, fact_inv

U = N + 1 # 階乗テーブルの上限
fact, fact_inv = make_fact(U, MOD)
fact_N = fact[N]
comb = fact_N * fact_inv % MOD * fact_inv[::-1] % MOD

for x in range(N+1):
    temp = K-A*x
    q, r = divmod(temp, B)
    if r != 0:
        continue
    if q > N:
        continue
    if q < 0:
        break
    answer += F(x, q)
    answer %= MOD

print(answer % MOD)


Measured memory_bytes: 28316
def check(x, y)
  2.times do |z|
    4.times do
      return true if x == y
      a, b, c, d, e, f  = x
      x = z.zero? ? [e, a, c, d, f, b] : [d, b, a, f, e, c]
      c = x
      4.times do
        i, j, k, l, m, n = c
        c = [i, k, m, j, l, n]
        return true if c == y
      end
    end
  end
  false
end

g = $<.map{|h| h.chomp.split}.drop(1)
g.size.times do |x|
  (x+1).upto(g.size - 1) do |y|
    (puts 'No')^exit if check(g[x], g[y])
  end
end
puts 'Yes'

Measured memory_bytes: 9816
#include<iostream>
#include<vector>
#include <unordered_map>  
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <sstream>
#include <cmath>
#include <float.h>
using namespace std;

void A();
void B();
#define INT_MAX 7368793
bool f[INT_MAX];

void del_flag(int m) {
	int tmp = m;
	while (tmp < INT_MAX) {
		f[tmp] = false;
		tmp += m;
	}
}

int main(){
	int m, n;
	while (cin >> m >> n, n) {
		for (int i = 0; i < INT_MAX; ++i) {
			f[i] = true;
		}
		int tmp = m;
		for (int i = 0; i < n; ++i) {
			while (!f[tmp]) ++tmp;
			del_flag(tmp);
		}
		while (!f[tmp]) ++tmp;
		cout << tmp << endl;
	}
	return 0;
}


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

//#################################################################
//最近点対 O(n log n)

namespace closest_pair{

typedef pair<double, double> P;

const int MAX_N = 1000000;
const double INF = 1e77;

int N;
P A[MAX_N];

bool compare_y(P a, P b){
	return a.second < b.second;
}

//配列aはsortしなければいけない！！
double closest_pair(P *a, int n){
	if(n <= 1) return INF;
	int m = n / 2;
	double x = a[m].first;
	double d = min(closest_pair(a, m), closest_pair(a + m, n - m));
	inplace_merge(a, a + m, a + n, compare_y);

	vector<P> b;
	for(int i=0;i<n;i++){
		if(fabs(a[i].first - x) >= d) continue;
		for(int j=0;j<b.size();j++){
			double dx = a[i].first - b[b.size() - j - 1].first;
			double dy = a[i].second - b[b.size() - j - 1].second;
			if(dy >= d) break;
			d = min(d, sqrt(dx * dx + dy * dy));
		}
		b.push_back(a[i]);
	}
	return d;
}

  void solve() {
    cin >> N;
    for(int i = 0; i < N; ++i) {
      cin >> A[i].first >> A[i].second;
    }
    sort(A, A+N);
    printf("%.10f\n", closest_pair(A, N));
  }

}

int main() {
  closest_pair::solve();
  return 0;
}

Measured memory_bytes: 20108
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>
#include <cstdint>
#define _USE_CMATH_DEFINES

const long INF = (1l << 30);
const long LINF = (1l << 60); //1.15*10^18

class Combination{
private:
    long long m_mod;
    long long *fac;
    long long *finv;
    long long max_n;
    long long power(long long a, long long b);
    long long ext_gcd(long long a, long long b, long long &x, long long &y);
public:
    Combination(long n, long mod);//max_n, mod
    ~Combination();
    long long comb(long n, long r);
    void fac_vis();
    void finv_vis();
};
long long Combination::power(long long a, long long b){
    if(b == 0){
        return 1ll;
    }else if(b % 2){
        return power(a, b-1) * a % m_mod;
    }else{
        return power(a, b/2) * power(a, b/2) % m_mod;
    }
}
long long ext_gcd(long long a, long long b, long long &x, long long &y){//ax + by = gcd(a, b), returns gcd. |x| + |y| is minimum and x <= y.
    if(b == 0){
        x = 1;
        y = 0;
        return a;
    }
    long d = ext_gcd(b, a % b, y, x);
    y -= a/b * x;
    return d;
}
long long mod(long long a, long long m){
    return (a % m + m) % m;
}
long long modinv(long long a, long long m){
    long long x, y;
    ext_gcd(a, m, x, y);
    return mod(x, m);
}
Combination::Combination(long n, long mod){
    max_n = n;
    m_mod = mod;
    fac = new long long[n+1];
    finv = new long long[n+1];
    fac[0] = finv[0] = 1;
    if(max_n > 0){
        fac[1] = finv[1] = 1;
    }
    for(long long i = 2; i <= max_n; i++){
        fac[i] = fac[i-1] * i % m_mod;
    }
    finv[n] = modinv(fac[n], m_mod);
    for(long long i = max_n-1; i >= 0; i--){
        finv[i] = finv[i+1] * (i+1) % m_mod;
    }
}
Combination::~Combination(){
    delete[] fac;
    delete[] finv;
}
long long Combination::comb(long n, long r){
    if(n < r || n < 0 || r < 0){
        return 0;
    }
    return fac[n] * finv[r] % m_mod * finv[n-r] % m_mod;
}
void Combination::fac_vis(){
    for(int i = 0; i <= max_n; i++){
        printf("%lld ", fac[i]);
    }
    printf("\n");
}
void Combination::finv_vis(){
    for(int i = 0; i <= max_n; i++){
        printf("%lld ", finv[i]);
    }
    printf("\n");
}

const long MOD = 1000000007;

long solve(long n, long k){
    Combination nCr(n, MOD);
    long ans = 0;
    for(long i = std::max(n-k, 1l); i <= n; i++){
        ans += nCr.comb(n-1, i-1) * nCr.comb(n, i) % MOD;
        ans %= MOD;
    }
    return ans;
}

int main(){
    long n, k;
    scanf("%ld%ld", &n, &k);
    printf("%ld\n", solve(n, k));
}


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

using namespace std;

int main(){
    int n;
    cin >> n;
    int m = 1 << n;
    string S;
    cin >> S;
    vector<int> P(m);
    for (int i = 0; i < m; i++)
        scanf("%d", &P[i]);

    vector<vector<int>> memo(n + 1, vector<int>(m + 1, -1));

    auto dfs = [&](int i, int k, auto self) -> int {
        if (k == 0)
            return i;
        if (memo[k][i] >= 0)
            return memo[k][i];
        int l = self(i, k - 1, self);
        int r = self((i + (1 << (k - 1))) & (m - 1), k - 1, self);

        if (P[l] > P[r])
            swap(l, r);

        return memo[k][i] = S[P[r] - P[l] - 1] == '1' ? r : l;
    };

    for (int i = 0; i < m; i++)
        printf("%d\n", P[dfs(i, n, dfs)]);
}


Measured memory_bytes: 24924
a,b,k=map(int,input().split())
if a+k-1<b-k+1:
 for i in range(a,a+k):
  print(i)
 for j in range(b-k+1,b+1):
  print(j)
else:
 for k in range(a,b+1):
  print(k)

Measured memory_bytes: 3060
import scala.io.StdIn.readLine

object Main extends App {
  val m = for(i<-1 to 6) yield readLine.split(" ").map(_.toInt).sorted
  val n = m.sortWith( (x,y) => if(x(0) > y(0)) true else if(x(0)==y(0) && x(1) > y(1)) true else false )
  if(n(0)(0) == n(1)(0) && n(0)(1) == n(1)(1) &&
     n(2)(0) == n(3)(0) && n(2)(1) == n(3)(1) &&
     n(4)(0) == n(5)(0) && n(4)(1) == n(5)(1)) {
    if( (n(0)(0) == n(2)(0) && n(0)(1) == n(4)(0) && n(2)(1) == n(4)(1)) ||
       (n(0)(1) == n(2)(0) && n(0)(0) == n(4)(0) && n(2)(1) == n(4)(1)) ||
       (n(0)(0) == n(2)(1) && n(0)(1) == n(4)(1) && n(2)(0) == n(4)(0)) ||
       (n(0)(1) == n(2)(1) && n(0)(0) == n(4)(1) && n(2)(0) == n(4)(0)))
       println("yes")
    else println("no")
  }
  else
    println("no")
}

Measured memory_bytes: 44076