akhauriyash/Code-Regression huggingface dataset:
//
// tested with : g++ (GCC) 8.3.0
//

#include <iostream>
using namespace std;

int f(int x) {
    int wa = 0;
    while (x > 0) {
        wa += x % 10;
        x = x / 10;
    }
    return wa;
}
int main() {
    int x;
    cin >> x;

    int wa = f(x);//和
    if (x % wa == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
        
    return 0;
}


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

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


Measured memory_bytes: 3084
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define repc(i, s, t) for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    cin >> __VA_ARGS__;
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

template <class T>
inline istream &operator,(istream &is, T &rhs) {
    return is >> rhs;
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.setf(ios_base::fixed);
    cout.precision(12);

    var(string, s, t);

    int ans = INF;
    rep(i, 0, int(s.length()) - int(t.length()) + 1) {
        int cnt = 0;
        rep(k, 0, t.length()) {
            if (s[i + k] != t[k]) ++cnt;
        }
        chmin(ans, cnt);
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 3676
#include <algorithm>
#include <iostream>
#define ll long long
using namespace std;

ll N, K, W[100000];

bool ok(ll P){
  ll cnt = 1;
  ll totalweight = 0;
  for(ll i = 0; i < N; i++){
    if(W[i] > P)
      return false;
    if(totalweight + W[i] > P){
      cnt++;
      totalweight = W[i];
    }else{
      totalweight += W[i];
    }
  }
  if(cnt <= K){
    return true;
  }else{
    return false;
  }

}
int main(){
  cin >> N >> K;
  for(ll i = 0; i < N; i++){
    cin >> W[i];
  }
  ll left = 0;
  ll right = 100000000000000;
  while(right - left > 2){
    if(ok((left + right) / 2))
      right = (left + right) / 2 + 1;
    else
      left = (right + left) / 2 + 1;
    
  }

  for(ll i = left; i < right; i++){
    if(ok(i)){
      cout << i << endl;
      return 0;
    }

  }

  
}

Measured memory_bytes: 3852
#include<stdio.h>

int gcd( int x , int y );

int main( void ){
	
	int x , y;
	int g;
	
	scanf( "%d %d"  , &x , &y );
	
	g = gcd( x , y );
	
	printf( "%d\n" , g );
}

int gcd( int x , int y ){
	
	int temp;
	
	if( y >= x ){
		temp = y;
		y = x; 
		x = temp;
	}
	
	if( x % y == 0 ){ return y; }
	else{ return gcd( y , x % y ); }
}


Measured memory_bytes: 2144
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int p = sc.nextInt();
		int q = sc.nextInt();
		int r = sc.nextInt();
		System.out.println(Math.min(Math.min(p + q, r + q), p + r));
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  //木の根なら-(size of tree) それ以外は木の根のindexが入っている。                 
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

struct edge{
  int from,to;
};

void dfs(int *depth, vector<int> *gv, int s, int d){
  depth[s]=d;
  rep(i,gv[s].size()){
    if(depth[gv[s][i]]==-1){
      dfs( depth, gv, gv[s][i], d+1);
    }
  }
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N,M;
  cin >> N >> M;
  int a,b;
  //  int used[N];
  vector<edge > g;
  //  rep(i,M) used[i]=0;
  rep(i,M){
    cin >> a >> b;
    a--;b--;
    g.push_back({a,b});
  }
  if(M%2==1){
    cout << -1 << endl;
    return 0;
  }
  UnionFind gra(N);//全域木作成用のunion-find
  vector<int > gv[N];//全域木
  //  vector<int > ans[N];//回答用の有向グラフ
  int V[N];//出るへんの数 mod2
  rep(i,N) V[i] = 0;
  rep(i,M){
    edge &e=g[i];
    if(gra.unite(e.from,e.to)){
      gv[e.from].pb(e.to);
      gv[e.to].pb(e.from);
    }
    else{
      cout << e.from+1 << " " <<e.to+1 << endl;
      V[e.from]++;
    }
  }
  int depth[N];
  rep(i,N) depth[i]=-1;
  int s;
  rep(i,N){
    if(gv[i].size()==1){
      s=i;
      break;      
    }
  }

  dfs(depth, gv, s, 0);
  pair<int, int> P[N];//深さ並び替え
  rep(i,N) P[i] = mp(depth[i],i);
  sort(P,P+N);
  //深いところから
  for(int i=N-1; i>=0;i--){
    int l=P[i].second;
    rep(j,gv[l].size()){
      int p=gv[l][j];
      if(depth[p] < depth[l]){
	if(V[l]%2==0){
	  cout << p+1<< " " << l+1 << endl;
	  V[p]++;
	}
	else{
	  cout <<l+1 << " " << p+1 << endl;
	  V[l]++;
	}
      }
    }
  }

  
  return 0;
    

}


Measured memory_bytes: 13556
use proconio::input;

#[allow(non_snake_case)]
fn main() {
    input! {
        S:usize,
    }

    if S < 3 {
        println!("0");
        return;
    }

    let m = 1000_000_000 + 7u64;
    let mut dp = vec![0; S + 1];

    for i in 3..=S {
        dp[i] += 1;
        for j in 3..=i {
            dp[i] = (dp[i] + dp[i - j]) % m;
        }
    }

    println!("{}", dp[S] % m);
}


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

#define int long long
#define fast ios_base::sync_with_stdio(false); cin.tie(0);
#define rep(i,a,n) for(int i=a;i<n;i++)
#define all(x) x.begin(),x.end()
#define V(x) vector<x>
#define P(x,y) pair<x,y>
#define UMP(x,y) unordered_map<x,y>
#define MP(x,y) map<x,y>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define inf 1e18
#define endl "\n"
#define coutd(n) cout << fixed << setprecision(n)
#define watch(x) cout<<#x<<" = "<<x<<endl;
typedef double db;
typedef long double ld;	
const int mod = 1000000007;

using namespace std;

int32_t main(){
    fast
    	
    //int t;
	//cin>>t;
	//rep(_,0,t){	
		
	//}
	string str;
	int n;
	cin>>n>>str;
	if(n >= str.length())
		cout<<str;
	else{
		rep(i,0,n)
			cout<<str[i];
		cout<<"...";
	}
    return 0;
}


Measured memory_bytes: 3652
n=int(input())
xy=[]
for _ in range(n):
    x,y=map(int,input().split())
    xy.append([x,y])
ans=0
for i in range(n):
    for j in range(n):
        ans +=((xy[i][0]-xy[j][0])**2+(xy[i][1]-xy[j][1])**2)**0.5
print(ans/n)


Measured memory_bytes: 3060
#include <stdio.h>

int main()
{
	int N;
	scanf("%d", &N);
	
	const int bit[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
	int i, j, k;
	for (i = 0; i < N - 1; i++) {
		for (j = i + 1; j < N - 1; j++) {
			for (k = 0; k < 10; k++) if ((i & bit[k]) != (j & bit[k])) break;
			printf("%d ", k + 1);
		}
		for (k = 0; k < 10; k++) if ((i & bit[k]) != ((N - 1) & bit[k])) break;
		printf("%d\n", k + 1);
	}
	
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1700
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <cassert>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d>>(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;


typedef array<ll, 2> ary;
pair<vvl, vvl> calc(ll n, ll k, vector<ll>& a){
  vvl nxt = VV(n, 30, -1, ll);
  vvl s = VV(n, 30, 0, ll);
  for(int i=0;i<30;i++){
    if(i==0){
      for(int j=0;j<n;j++){
        auto idx = lower_bound(all(a), a[j]+k) - a.begin();//k先のidx
        if(j==n-1) idx = n;
        nxt[j][0] = idx;
        if(idx!=n) s[j][0] = idx;
      }
    }else{
      for(int j=0;j<n;j++){
        nxt[j][i] = (nxt[j][i-1]==n?n:nxt[nxt[j][i-1]][i-1]);
        s[j][i] = s[j][i-1] + (nxt[j][i-1]==n?0:s[nxt[j][i-1]][i-1]);
      }
    }
  }
  return {nxt, s};
}

int main(){
  ll n, k;scanf("%lld %lld", &n, &k);
  vll a(n);
  re(i, n) scanf("%lld", &a[i]);
  vll b = a;
  reverse(all(b));
  for(int i=0;i<n;i++) b[i] = -b[i];
  vvl nxt, nxt2, s, s2;
  auto tmp = calc(n, k, a);
  nxt = tmp.first;
  s = tmp.second;
  tmp = calc(n, k, b);
  nxt2 = tmp.first;
  s2 = tmp.second;
  auto f = [&](ll l, ll r){//操作回数
    ll cnt = 0;
    ll S = 0;
    ll now = l;
    while(now<r){
      auto idx = upper_bound(all(nxt[now]), r) - nxt[now].begin() - 1;
      if(idx==-1||idx==n||nxt[now][idx]==n||a[nxt[now][idx]]-a[now] < k) break;//もう移動できない
      cnt += (1<<idx);
      S += s[now][idx];
      now = nxt[now][idx];
    }
    return ary{cnt+1, S+l};
  };

  auto g = [&](ll l, ll r){
    l = n - 1 - l, r = n - 1 - r;
    swap(l, r);
    ll cnt = 0;
    ll S = 0;
    ll now = l;
    while(now<r){
      auto idx = upper_bound(all(nxt2[now]), r) - nxt2[now].begin() - 1;
      if(idx==-1||idx==n||nxt2[now][idx]==n||b[nxt2[now][idx]]-b[now]<k) break;//もう移動できない
      cnt += (1<<idx);
      S += s2[now][idx];
      now = nxt2[now][idx];
    }
    return ary{cnt+1, S+l};
  };

  ll q;scanf("%lld", &q);
  for(int i=0;i<q;i++){
    ll x, y;scanf("%lld %lld", &x, &y);
    x--, y--;
    auto h = f(x, y);
    auto u = g(x, y);
    ll cnt = h[0] + 1;
    cnt += u[1] - h[1];
    u[1] = (n-1)*u[0] - u[1];
    ll ret = u[0] + u[1] - h[1];
    printf("%lld\n", ret);
  }
}



Measured memory_bytes: 444032
dList = list(str(input()))

former = int(''.join([dList[0],dList[1]]))
latter = int(''.join([dList[2],dList[3]]))

if 1 <= former <= 12: 
  if 1<= latter<= 12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
elif former > 12:
  if 1<= latter<= 12:
    print("YYMM")
  else:
    print("NA")
else:
  if latter == 0 or latter > 13:
    print("NA")
  else:
    print("YYMM")
  

Measured memory_bytes: 3064
S=input()
l=len(S)
if l%2==1:
    m=S[l//2]
    c=1
    for i in range(l//2):
        if S[l//2-i-1]==m and S[l//2+i+1]==m:
            c+=2
        else:
            break
    ans=c+(l-c)//2
else:
    m1=S[l//2-1]
    m2=S[l//2]
    c=0
    if m1==m2:
        c=2
        for i in range(l//2-1):
            if S[l//2-i-2]==m1 and S[l//2+i+1]==m1:
                c+=2
            else:
                break
    ans=c+(l-c)//2
print(ans)



Measured memory_bytes: 9164
N = int(input())
A = list(map(int, input().split()))

se = set()
dic = dict()

for i in range(N):
    if A[i] in se:
        dic[A[i]] += 1
    else:
        se.add(A[i])
        dic.update({A[i]: 1})

c = 0
for k in dic.keys():
    c += (dic[k])*(dic[k]-1)//2

result = [0]*N
for i in range(N):
    result[i] = c - (dic[A[i]])*(dic[A[i]]-1)//2 + (dic[A[i]]-1)*(dic[A[i]]-2)//2

print("\n".join(list(map(str, result))))


Measured memory_bytes: 43836
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();   //プロセス数
        int q = sc.nextInt();   //クオンタム
        int R_time = 0;   //実時間

        ArrayDeque<Proc> queue = new ArrayDeque<>();    //キュー
        Proc tmp;

        for(int i = 0;i < n;i++){
            String name = sc.next();    //プロセス名
            int P_time = sc.nextInt();    //プロセス時間
            queue.add(new Proc(name,P_time));
        }

        while(queue.size() > 0){
            //クオンタム以下
            if(queue.getFirst().num <= q){
                R_time += queue.getFirst().num;
                System.out.println(queue.getFirst().name+" "+R_time);
                queue.removeFirst();
            }
            else{
                R_time += q;
                tmp = queue.getFirst(); //先頭をコピー
                tmp.num -= q;   //プロセス時間からクオンタムを引く
                queue.addLast(tmp); //先頭を末尾に
                queue.removeFirst();    //先頭削除
            }
        }
    }
}

class Proc{
    String name;
    int num;

    Proc(String name,int num){
        this.name = name;
        this.num = num;
    }
}


Measured memory_bytes: 72800
#include<bits/stdc++.h>
using namespace std;
string rote(string s){
  int l=s.size();
  return s.at(l-1)+s.substr(0,l-1);
}
int main(){
  string s,t;
  cin >> s >> t;
  int i,l=s.size();
  for(i=0;i<l;i++){
    if(s==t){
      cout << "Yes";
      return 0;
    }
    s=rote(s);
  }
  cout << "No";
}


Measured memory_bytes: 256
import itertools

n = int(input())
l = list(map(int, input().split()))

list = list(itertools.combinations(l,3))

count = 0

for i in list:
    sor = sorted(i)
    a = sor[0]
    b = sor[1]
    c = sor[2]
    if a != b and a != c and b != c and c < (a+b):
      count += 1

print(count)

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

int main(void){
    int n;
    cin >> n;
    set<char>s;
    for(int i=0;i<n;i++){
        char c; cin >> c;
        s.insert(c);
    }
    int cnt = s.size();
    if(cnt == 3){
        cout << "Three" << endl;
    }else{
        cout << "Four" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int main(){
	int a,b;
	int sum;
	while(scanf("%d%d",&a,&b)!=EOF){
		sum=1;
		for(int i=1; i<=a; ++i){
			if(sum<=b) sum+=sum;	
			else sum+=b;
		}
		printf("%d\n",sum);
		
	}
	
	
}

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

int main(){
   int n;
  cin >> n;	
	long long a[n];
{
	int i;
	a[0]=2;
	a[1]=1;
	for(i=2; i<=n;i++)
		a[i]=a[i-1]+a[i-2];
}
cout << a[n] << endl;
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define REP(i,x) for(int i=0; i<(int)(x); i++)       // 0 <= i < x
#define REPS(i,x) for(int i=1; i<=(int)(x); i++)     // 0 < i <= x
#define RREP(i,x) for(int i=((int)(x)-1); i>=0; i--) // x > i >= 0
#define RREPS(i,x) for(int i=((int)(x)); i>0; i--)   // x >= i > 0
#define INF 999999999
#define ll long long
 
using namespace std;
 
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
 
#define MAX_N 100000
 
int main(void){
	ll N;
	ll a[MAX_N], b[MAX_N], c[MAX_N];
	scanf("%lld", &N);
	REP(i, N){
		scanf("%lld", &a[i]);
	}
	REP(i, N){
		scanf("%lld", &b[i]);
	}
	REP(i, N){
		scanf("%lld", &c[i]);
	}
 
	sort(a, a+N);
	//sort(b, b+N);
	sort(c, c+N);
 
	//Biより大きいCiの個数
	ll countc[N];
	ll counta[N];
	
	REP(i, N){
	    countc[i] = c + N - upper_bound(c, c+N, b[i]);
		counta[i] = lower_bound(a, a+N, b[i]) - a;
	}
 
	ll ans = 0;
	REP(i, N){
	    ans += countc[i]*counta[i];
	}
 
	printf("%lld\n", ans);
 
	return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int MOD=1000000007;
using namespace std;
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main(){
    int n;
    cin>>n;
    
    vector<ll> l(90);
    l[0]=2;
    l[1]=1;
    rep(i,2,n+1) l[i]=l[i-1]+l[i-2];
    cout<<l[n]<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (long i=0;i<(n);i++)
#define FOR(i,a,b) for (long i=(a);i<(b);i++)
#define RREP(i,n) for(long i=n;i>=0;i--)
#define RFOR(i,a,b) for(long i=(a);i>(b);i--)
#define dump1d_arr(array) REP(i,array.size()) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl;
#define dump2d_arr(array) REP(i,array.size()) REP(j,array[i].size()) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl;
#define dump(x)  cerr << #x << " => " << (x) << endl;
#define CLR(vec) { REP(i,vec.size()) vec[i] = 0; } 
#define llINF (long long) 9223372036854775807
#define loINF (long) 2147483647
#define shINF (short) 32767
#define SORT(c) sort((c).begin(),(c).end())
#define DEBUG

using namespace std;
typedef vector<long> VI;
typedef vector<VI> VVI;
typedef pair<long,long> pr;
typedef map<double,pr> mp;
typedef long long LL;

string s;
int A, B, t, cnt = 0, p, r = 0;

int main ()
{
    cin >> A >> B;
    for(int i = A; i <= B; i++){
        t = i;
        r = 0;
        while(t != 0){
            p = t % 10;
            r = r * 10 + p;

            t /= 10;
        }

        if (r == i){
            cnt++;
        }
    }
    cout << cnt;
    return 0;
}

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

#define DEBUG(C) cerr << #C << " = " << C << endl

using namespace std;

const int MAX = 2 * 1e5 + 10;
int n;
long long a[MAX];
map<long long, long long> mp;

int main() {
  scanf("%d", &n);
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    scanf("%lld", a + i);
    sum += a[i];
  }
  long long ans = 1e18;
  long long sum2 = 0;
  for (int i = 0; i < n - 1; i++) {
    sum2 += a[i];
    sum -= a[i];
    ans = min(ans, llabs(sum - sum2));
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
using namespace std;
#define N 100005
#define ll long long
int n,a[N],s[N],Sum[N],tot;ll ans;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]),s[i]=a[i];
    sort(s+1,s+1+n);
    tot=unique(s+1,s+1+n)-s-1;
    for(int i=1;i<=n;i++) a[i]=lower_bound(s+1,s+1+tot,a[i])-s,Sum[a[i]]++;
    for(int i=tot;i;i--)
    {
        if(Sum[i]>1)
        {
            if(ans) {ans=(ll)ans*s[i];break;}
            else ans=s[i];
        }
        if(Sum[i]>3) {ans=(ll)ans*s[i];break;}
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;



int main(int argc, char const *argv[])
{
    int x,y,z,k,l; cin >> x >> y >> z >> k;
    l = min(k, x*y);
    vector<unsigned long long> a(x,0), b(y,0), c(z,0);
    vector<unsigned long long> e(x*y,0);
    vector<unsigned long long> f(k*z,0);
    
    for(auto i=0;i<x;++i) cin >> a[i];
    for(auto i=0;i<y;++i) cin >> b[i];
    for(auto i=0;i<z;++i) cin >> c[i];

    for(auto i=0;i<x;++i) {
        for(auto j=0;j<y;++j) {
            e[i*y+j] = a[i] + b[j];
        }
    }
    
    sort(e.begin(), e.end(), greater<unsigned long long>());
    for(auto i=0;i<l;++i) {
        for(auto j=0;j<z;++j) {
            f[i*z+j] = e[i] + c[j];
        }
    }
    sort(f.begin(), f.end(), greater<unsigned long long>());

    for(auto i=0;i<k;++i) {
        cout << f[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 31616
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    int n;
    cin >> n;

    auto gcd = [&](long long P, long long Q) {
        while (P != 0) {
            Q %= P;
            swap(P, Q);
        }
        return Q;
    };

   
    long long res = 0;
    int m = 0;

    map<pair<int,int>, int> cnts;
    for (int i = 0; i < n; ++i) {
        long double p;
        cin >> p;

        long long x = llround(p * 1e9);


        int twos = 0;
        int fives = 0;
        while (x != 0 && x % 2 == 0) {
            x /= 2;
            ++twos;
        }
        while (x != 0 && x % 5 == 0) {
            x /= 5;
            ++fives;
        }

        for (auto& p : cnts) {
            int t = p.first.first;
            int f = p.first.second;
            if (t + twos >= 18 && f + fives >= 18) {
                res += p.second;
            }
        }

        cnts[make_pair(twos, fives)] += 1;
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 3760
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
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;}
// clang-format on

void solve(long long N, long long K, std::vector<long long> h) {
  ll a = 0;
  rep(i, N) {
    if (h[i] >= K) {
      a += 1;
    }
  }
  cout << a << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long K;
  scanf("%lld", &K);
  std::vector<long long> h(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &h[i]);
  }
  solve(N, K, std::move(h));
  return 0;
}


Measured memory_bytes: 1024
program main
  implicit none

  integer :: n, y, ans1, ans2, i
  integer, allocatable :: a(:), a2(:)
  

  read(*,*) n

  allocate(a(n))
  allocate(a2(n))

  read(*,*) a

  do i = 1, n
     a2(i) = a(i) * a(i)
  end do

  
  y = sum(a) / n
  ans1 = n * y * y - 2 * sum(a) * y + sum(a2)

  y = sum(a) / n + 1
  ans2 = n * y * y - 2 * sum(a) * y + sum(a2)

  if (ans1 >= ans2) then
     write(*,*) ans2
  else
     write(*,*) ans1
  end if

end program main


  


Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,K=MI()
    print(K*((K-1)**(N-1)))
if __name__ == '__main__':
    main()

Measured memory_bytes: 3572
let () =
  Scanf.scanf "%d" @@ fun n ->
  let v = Array.init n (fun _ -> Scanf.scanf " %d" ((+) 0)) in
  let c = Array.init n (fun _ -> Scanf.scanf " %d" ((+) 0)) in
  Array.init n (fun i -> max 0 @@ v.(i) - c.(i))
  |> Array.fold_left (+) 0 |> Printf.printf "%d\n"


Measured memory_bytes: 384
#include <iostream>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;


int main(){
  string s;
  cin >> s;
  if(s[0] != 'A'){
    cout << "WA" << endl;
    return 0;
  }
  bool flag = false;
  repd(i, 1, s.size()){
    if(s[i] == 'C' && !flag && i > 1 && i <= s.size()-2){
      flag = true;
      continue;
    }
    // cout << s[i] << "=" << s[i]-'a' << endl;
    if(0 > s[i]-'a' || s[i]-'a' > 25){
      cout << "WA" << endl;
      return 0;
    }
  }
  if(!flag){
    cout << "WA" << endl;
    return 0;
  }
  cout << "AC" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] a = new int[N + 1];
		int[] b = new int[N + 1];
		int[] c = new int[M + 1];
		int[] d = new int[M + 1];
		int[] ans = new int[N + 1];

		for (int i = 1; i <= N; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		for (int i = 1; i <= M; i++) {
			c[i] = sc.nextInt();
			d[i] = sc.nextInt();
		}
		
		for (int i = 1; i <= N; i++) {
			int dif = Math.abs(a[i] - c[1]) + Math.abs(b[i] - d[1]);
			ans[i] = 1;
			for (int j = 2; j <= M; j++) {
				if (dif > (Math.abs(a[i] - c[j]) + Math.abs(b[i] - d[j]))) {
					ans[i] = j;
					dif = Math.abs(a[i] - c[j]) + Math.abs(b[i] - d[j]);
				}
			}
		}

		for (int i = 1; i <= N; i++) {
			System.out.println(ans[i]);
		}


		sc.close();
	}
}

Measured memory_bytes: 23124
#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 long long INF = 1LL << 60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    int k;cin>>k;
    int sum=k;
    int count= 1;
    while(sum!=0){
        count++;
        sum+=k;
        sum%=360;
    }
    cout<<count<<endl;

}

Measured memory_bytes: 3592
n, a, b, c, d = map(int, input().split())
s = input()

if "##" in s[a:max(c,d)]:
    print("No")
elif c > d:
    if "..." in s[b-2:d+1]:
        print("Yes")
    else:
        print("No")

else:
    print("Yes")


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    if (a <= 9 && b <= 9) {
        println(a * b);
    }
    else {
        println(-1)
    }
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <queue>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
#define INF 1000000000000
using namespace std;
using ll = long long;
int main(){
    ll h,w;
    cin >> h >> w;
    ll ans = INF;
    ll ans1,ans2,ans3,ans4;
    ll smax,smin,smed,diff;
    if(h%3==0||w%3==0){
        ans = 0;
    }else{
        ans1 = INF;
            for(ll i=1;i<h;i++){
                smax = i*w;
                smin = (h-i)*(w/2);
                smed = (h-i)*((w/2)+w%2);
                diff = max(max(abs(smax-smin),abs(smax-smed)),abs(smed-smin));
                if(ans1>diff){
                    ans1 = diff;
                }
            }
        ans2 = INF;
            for(ll i=1;i<w;i++){
                smax = i*h;
                smin = (w-i)*(h/2);
                smed = (w-i)*((h/2)+h%2);
                diff = max(max(abs(smax-smin),abs(smax-smed)),abs(smed-smin));
                if(ans2>diff){
                    ans2 = diff;
                }
            }
            smax = (w/3+1)*h;
            smin = (w/3)*h;
            ans3 = smax-smin;
            
            smax = (h/3+1)*w;
            smin = (h/3)*w; 
            ans4 = smax-smin;
        }
    cout << min(min(ans1,ans2),min(ans3,ans4)) << endl;
}

Measured memory_bytes: 256
ia, ib = map(int, input().split())
sa = str(ia)
sb = str(ib)
sc = sa+sb
c = int(sc)
fc = float(c**0.50)
ic = int(c**0.50)
if abs(fc-ic)<0.0001:
    print('Yes')
else:
    print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll h, w, n, x, y, ans[10];
set<pair<ll, ll>> b;

int main(){
	cin >> h >> w >> n;
	for(ll i = 1; i <= n; i++){
		cin >> y >> x;
		b.insert(make_pair(x, y));
	}
	memset(ans, 0, sizeof(ans));
	
	for(auto itr = b.begin(); itr != b.end(); itr++){
		x = (*itr).first;
		y = (*itr).second;
		for(ll i = max(x-1, 2LL); i <= min(x+1, w-1); i++){
			for(ll j = max(y-1, 2LL); j <= min(y+1, h-1); j++){
				int cnt = 0;
				for(ll mi = i-1; mi <= i+1; mi++){
					for(ll mj = j-1; mj <= j+1; mj++){
						if(b.find(make_pair(mi, mj)) != b.end()){cnt++;}
					}
				}
				ans[cnt]++;
			}
		}
		//cout << x << y << endl;
	}
	
	ans[0] = (h-2)*(w-2);
	for(ll ai = 1; ai <= 9; ai++){
		ans[ai] /= ai;
		ans[0] -= ans[ai];
	}
	for(ll ai = 0; ai <= 9; ai++){cout << ans[ai] << endl;}
	return 0;
}

Measured memory_bytes: 6528
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include <vector>

#define LL long long

using namespace std;

long long A[200000] = { 0 };

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

	LL a,b;
	


	cin >> a >> b;

	if (a + b == 15)
		cout << "+" << endl;
	else if (a*b == 15)
		cout << "*" << endl;
	else
		cout << "x" << endl;


}

Measured memory_bytes: 256
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def kaizyo(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n=0,d=0) Array.new(n,d)end
def na2(n=0,m=0,d=0) Array.new(n){Array.new(m,d)}end
def na3(n=0,m=0,l=0,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
n,t=inp
d=inp
max = t
ans = t
d.each do |dd|
  if(dd>max)
    ans += t
    max = dd+t
  else
    l = dd+t
    ans += l-max
    max = l
  end
end
p ans


Measured memory_bytes: 17940
#include <iostream>
#include <stdlib.h>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(int argc,char** argv){
  int n;
  cin >> n;
  char s[n],a[n];
  for(int i = 0; i < n; i++){
    cin >> s[i];
    a[i] = s[i];
  }
  int r1,r2;
  r1 = 0;
  r2 = 0;
  for(int i = 0; i < n; i++){
    if(s[i] == '.') r2++;
  }

  int r = r1 + r2;
  for(int i = 0; i < n; i++){
    if(s[i] == '#'){
      r1++;
    }else{
      r2--;
    }
    if( r > r1 + r2){
      r = r1 + r2;
    }
  }
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define plll pair<ll,pll>
#define ppll pair<pll, pll>
#define pii pair<int, int> 
#define pb push_back
#define mod 1000000007

ll power(ll a,ll b){
    ll res=1ll;
    while(b>0){
        if(b%2!=0) res=(res*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return res%mod;
}
ll ncr(ll n,ll k){
    if(k>n-k) k=n-k;
    ll pro=1;
    for(ll i=0;i<k;i++){
        pro=(pro*(n-i))%mod;
        pro/=(i+1);
    }
    return (pro)%mod;
}

void swap(ll *a,ll *b) {
    ll temp=*a;
    *a=*b;
    *b=temp;
}
vector<ll> prime;
void seive(){
    vector<bool > isprime(1000001,true);
    for(int i=2;i*i<=1000000;i++){
        if(isprime[i]){
            for(int j=i*i;j<=1000000;j+=i){
                isprime[j]=false;
            }
        }
    }
    for(int i=2;i<=1000000;i++){
        if(isprime[i]) prime.push_back(i);
    }
}
vector<ll> parent;
ll find(ll p) {
    if(parent[p]==p) return parent[p];
    return parent[p]=find(parent[p]); 
}
void unun(ll a,ll b) {
    ll r1=find(a);
    ll r2=find(b);
    if(r1!=r2) parent[r2]=r1;
}
vector<ll> arr;
vector<vector<ll>> v;
ll backtrack(ll i,vector<ll> skill,ll n,ll m,ll x) {
    if(i==n) {
        for(int j=0;j<m;j++) {
            if(skill[j]<x) {
                return (ll)1e10;
            }
        }
        return 0;
    }
    ll ans=backtrack(i+1,skill,n,m,x);
    for(int j=0;j<m;j++) {
        skill[j]+=v[i][j];
    }
    ans=min(ans,arr[i]+backtrack(i+1,skill,n,m,x));
    return ans;
}
void solve() {
    ll n,m,x;
    cin>>n>>m>>x;
    arr= vector<ll>(n);
    v = vector<vector<ll>>(n,vector<ll>(m));
    for(int i=0;i<n;i++) {
        cin>>arr[i];
        for(int j=0;j<m;j++) {
            cin>>v[i][j];
        }
    }
    vector<ll> skill(m);
    ll ans=backtrack(0,skill,n,m,x);
    if(ans>=(ll)1e9) {
        cout<<"-1";
    }
    else cout<<ans;
}   


int main(void){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    t=1;
    // cin>>t;
    while(t--) {
        solve();
        cout<<endl;
    }
    return 0; 

}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

using namespace std;

int main() {
    int P,Q,R;
    cin >> P >> Q >> R;
    cout << min(P+Q,min(Q+R,P+R)) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
 
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

int main(void){
	string S;
	cin>>S;
	S[3]='8';
	print(S);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <vector>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  string s[5];
  for(int i=0;i<3;i++){
    cin>>s[i];
  }
  cout<<s[0][0]<<s[1][1]<<s[2][2]<<"\n";
  
  return 0;
}

Measured memory_bytes: 3624
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int X;
int dp[100001];
int main(){
  int k;
  rd(X);
  dp[0] = 1;
  for(k=(100);k<(106);k++){
    int i;
    for(i=(k);i<(X+1);i++){
      dp[i] |= dp[i-k];
    }
  }
  wt_L(dp[X]);
  wt_L('\n');
  return 0;
}
// cLay varsion 20191227-1

// --- original code ---
// int X;
// int dp[100001];
// {
//   rd(X);
//   dp[0] = 1;
//   rep(k,100,106) rep(i,k,X+1) dp[i] |= dp[i-k];
//   wt(dp[X]);
// }


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n;
  cin >> n;
  priority_queue<ld, vector<ld>, greater<ld>> v;
  rep(i, n) {
    int temp;
    cin >> temp;
    v.push(temp);
  }
  while (SIZE(v) > 1) {
    ld v1 = v.top();
    v.pop();
    ld v2 = v.top();
    v.pop();
    v.push((v1 + v2) * 0.5);
  }
  cout << fixed << setprecision(15) << v.top() << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std; 
#define MAXA 100
#define MAXB 100
int main(int argc,char const* argv[])
{
  string a,b,tmpa,tmpb;
  int i,sizea,sizeb;
  cin >> a >> b;
  sizea=a.size();
  sizeb=b.size();
  if(sizea>sizeb)
    {
      cout << "GREATER" <<endl;
      return 0;
    }
  else if(sizea<sizeb)
    {
      cout << "LESS" <<endl;
      return 0;
    }
  else
    {
      for(i=0;i<sizea;i++)
	{
	  if(a[i]>b[i])
	    {
	      cout << "GREATER" <<endl;
	      return 0;
	    }
	  else if(a[i]<b[i])
	    {
	      cout << "LESS" <<endl;
	      return 0;
	    }
	  else{}
	}
      cout << "EQUAL" <<endl;     
    }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
using namespace std;
struct node
{
	int x,y,dis;
};
queue<node> q;
int fx[6]={-1,1,0,0};
int fy[6]={0,0,-1,1};
char s[1010][1010];
int a[1010][1010];
bool vis[1010][1010];
int main()
{
	int n,m,i,j,xx,yy,xx1,yy1,ans,dd;
	scanf("%d %d",&n,&m);
	for(i=1;i<=n;i++)scanf("\n%s",s[i]+1);
	
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)a[i][j]=INF;
	}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			if(vis[i][j]==false&&s[i][j]=='#')
			{
				q.push((node){i,j,0});
				vis[i][j]=true;
				a[i][j]=0;
			}
		}
	}
	
	while(!q.empty())
	{
		node T=q.front();q.pop();
		xx=T.x;yy=T.y;//dd=T.dis;
		vis[xx][yy]=false;
		for(i=0;i<=3;i++)
		{
			xx1=xx+fx[i];
			yy1=yy+fy[i];
			if(a[xx1][yy1]>a[xx][yy]+1)
			{
				a[xx1][yy1]=a[xx][yy]+1;
				if(vis[xx1][yy1]==false)
				{
					vis[xx1][yy1]=true;
					q.push((node){xx1,yy1,a[xx1][yy1]});
				}
			}
		}
	}
	
	ans=0;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)ans=max(ans,a[i][j]);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 18320
#include <bits/stdc++.h>
#include <limits>
using namespace std;
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define lli long long int
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define um unordered_map
#define F first
#define S second
#define clr(x) memset(x, 0, sizeof(x))
#define mem(data_structure, val) memset(data_structure, val, sizeof(data_structure))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define endl "\n"
const ll mod = 1e9+7;
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vll;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vll>		vvll;

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
}; 
um<pii, int, hash_pair> map_with_pair{};
priority_queue <int, vector<int>, greater<int> > pq_desc; // decreasing order

lli minCost(int n, int k, lli *h) {
	lli cost[n];
	memset(cost, 10000, sizeof(cost));
	cost[0] = 0;
	Fo(i, 1, n) {
		for(int j=i-1; j>=0&&j>=i-k; j--) {
			cost[i] = min(cost[i], cost[j]+abs(h[j]-h[i]));
		}
	}
	return cost[n-1];
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n, k;
	cin >> n >> k;

	lli h[n];
	fo(i, n) cin >> h[i];

	lli ans = minCost(n, k, h);

	cout << ans << endl;

	return 0;
}

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

int main() {
    long long H, W;
    cin >> H >> W;
    
    if (H == 1 || W == 1) {
        cout << 1 << endl;
        return 0;
    }

    long long ans = (H / 2) * (W / 2);
    ans += (H - H / 2) * (W - W / 2);
    cout << ans << endl;
    return 0;
}

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

int main(void)
{
    long A, B, C, K;

    scanf("%ld", &A);
    scanf("%ld", &B);
    scanf("%ld", &C);
    scanf("%ld", &K);

    if(K < A) {
        printf("%ld\n", K);
    } else if(K >= A && K <= (A+B)) {
        printf("%ld\n", A);
    } else {
        printf("%ld\n", (A - (K-A-B)));
    }

    return 0;
}

Measured memory_bytes: 1700
from sys import stdin

n = int(stdin.readline().rstrip())
v = list(map(int,stdin.readline().rstrip().split()))
c = list(map(int,stdin.readline().rstrip().split()))
li = []
for i in range(n):
    if v[i] -c[i] > 0:
        li.append(v[i]-c[i])
li.sort()
print(sum(li))

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
using namespace std;
string s;
int dp[200000][2];
int main() {
	cin>>s;
	dp[0][0]=1;
	for(register int i=1;i<s.length();i++){
		if(s[i]!=s[i-1])dp[i][0]=max(dp[i-1][0],dp[i-1][1])+1;
		else dp[i][0]=dp[i-1][1]+1;
		if(i>2&&s[i]==s[i-2]&&s[i-1]==s[i-3])dp[i][1]=dp[i-2][0]+1;
		else dp[i][1]=max(dp[i-2][0],dp[i-2][1])+1;
	}
	cout<<max(dp[s.length()-1][0],dp[s.length()-1][1]);
}

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

int main() {
  int n, b, c, d, sum;
  cin >> n;
  cin >> b;
  sum = b;
  c = b;
  rep(i, n-2)
  {
    cin >> c;
    sum += min(b, c);
    b = c;
  }
  sum += c;
  cout << sum;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int N;
  cin>>N;
  string str;
  cin>>str;

  Int ans = 1;
  Int open = 0;
  for(Int i=0;i<2*N;i++){
    char ch = str[i];
    if(open % 2 == 1) ch = ch == 'B'? 'W':'B';
    pr(i, open, ch);

    if(ch == 'B') open++;
    else ans = ans * open % mod, open--;
    if(open < 0) ans = 0;
  }

  if(open != 0) ans = 0;
  for(Int i=1;i<=N;i++) ans = ans * i % mod;
  cout<<ans<<endl;




  return 0;
}


Measured memory_bytes: 720