akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

typedef long long ll;

int A[201];

#define INF 10000

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

    int ans = INF;
    for (int i = 0; i < N; ++i)
    {
        int a;
        cin >> a;

        int cnt = 0;
        while (a % 2 == 0) a /= 2, ++cnt;
        ans = min(ans, cnt);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M = map(int, input().split())
P = list(map(int, input().split()))

uf = UnionFind(N)

for i in range(M):
    node1, node2 = map(int, input().split())
    uf.union(node1 - 1, node2 - 1)

cnt = 0
for i in range(N):
    if uf.same(i, P[i] - 1):
        cnt += 1
print(cnt)


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

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  
  if(A>=B && A>=C){cout << 10*A+B+C;}
  else if(B>=A && B>=C){cout << 10*B+C+A;}
  else{cout << 10*C+A+B;}
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef pair<int, int> pii;
typedef long long LL;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, k; cin >> n >> k;
    vector<int> data(n);
    for (auto &v : data)
        cin >> v;
    int sum = 0;
    for (int i = 0 ; i < k - 1 ; i++)
        sum += data[i];
    int maxV = 0;
    for (int i = k - 1 ; i < n ; i++) {
        sum += data[i];
        maxV = max(maxV, sum);
        sum -= data[i - k + 1];
    }
    cout << fixed << setprecision(10) << (maxV + k) / 2.0 << '\n';
}


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

using namespace std;


int n;
vector<int> w;

enum MEMO {
  NOT_CHECKED,
  TRUE,
  FALSE
};


MEMO memo[301][301];

MEMO rec(int l, int r) {
  if (r == l) {
    return TRUE;
  }
  if (r - l - 1 == 1) {
    if (abs(w[r - 1] - w[l]) <= 1) {
      return memo[l][r] = TRUE;
    } else {
      return memo[l][r] = FALSE;
    }
  }

  if (r - 1 == l) {
    return memo[l][r] = FALSE;
  }

  if (memo[l][r] != NOT_CHECKED) {
    return memo[l][r];
  }

  if (abs(w[l] - w[r - 1]) <= 1) {
    for (int i = l + 1; i < r; i++) {
      int temp1 = rec(l + 1, i);
      int temp2 = rec(i, r - 1);
      if (temp1 == TRUE && temp2 == TRUE) {
        return memo[l][r] = TRUE;
      }
    }
  }

  for (int i = l + 1; i < r; i++) {
    int temp1 = rec(l, i);
    int temp2 = rec(i, r);
    if (temp1 == TRUE && temp2 == TRUE) {
      return memo[l][r] = TRUE;
    }
  }

  return memo[l][r] = FALSE;
}

int main() {
  while (true) {
    cin >> n;
    if (n == 0) {
      break;
    }
    w.resize(n);

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

    for (int i = 0; i <= n; i++) {
      for (int j = 0; j <= n; j++) {
        memo[i][j] = NOT_CHECKED;
      }
    }

    rec(0, n);

    int dp[301] = { 0 };
    for (int r = 1; r <= n; r++) {
      dp[r] = dp[r - 1];
      for (int l = 0; l < r; l++) {
        if (memo[l][r] == TRUE) {
          dp[r] = max(dp[r], dp[l] + (r - l));
        }
      }
    }

    int ans = dp[n];
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 3488
#include<bits/stdc++.h>
using namespace std;
int n,ans=0,a,i;
int sub(int x){
  if(x==2)return true;
  if(x<2||x%2==0)return false;
  i=3;
  while(i<=sqrt(x)){
    if(x%i==0)return false;
    i = i+2;
  }
  return true;
}
int main(){
  cin>>n;
  for(int j=0;j<n;j++){
    cin>>a;
    ans+=sub(a);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3072
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
#define all(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
 typedef pair<int, int> P;

struct kekka2{
    ll Sosuu;
    ll Shisuu;
};

vector<kekka2> soinsu(ll n){
    vector<kekka2> rtn;
    ll m = n;
    for(ll i=2;i*i<=n;++i){
        kekka2 k2;
        k2.Sosuu = i;
        k2.Shisuu = 0;
        while(m%i==0){
            k2.Shisuu++;
            m/=i;
        }
        if(k2.Shisuu>0){
            rtn.push_back(k2);
        }
    }
    if(m>1){
        kekka2 k2;
        k2.Sosuu = m;
        k2.Shisuu = 1;
        rtn.push_back(k2);
    }
    return rtn;
}
ll n,p;

int main() {
    cin >> n >> p;
    vector<kekka2> k =soinsu(p);
    ll res = 1;
    REP(i,k.size()){
        if(k[i].Shisuu>=n){
            REP(j,k[i].Shisuu/n){
                res*=k[i].Sosuu;
            }
        }
    }
    put(res);
    return 0;
}
 


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

int main(){
  int n ; 
  cin >> n ;
  set<string> set ; 
  for(int i = 0; i < n; i++){
    string s ; 
    cin >> s ; 
    set.insert(s) ; 
  }
  cout << set.size() << endl;
}

Measured memory_bytes: 19180
from collections import deque

N = int(input())
K = int(input())

Q = deque([(1, 0)])
H = []
while Q:
    q = Q.popleft()
    if q[1] == N:
        H.append(q[0])
    else:
        Q.append((q[0] * 2, q[1] + 1))
        Q.append((q[0] + K, q[1] + 1))

print(min(H))

Measured memory_bytes: 3316
#include <bits/stdc++.h>  // ver1.9.5
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define Pii pair<int,int>
#define pb push_back
#define mp make_pair
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define Vout(a) rep(i,0,a.size()-1)cout<<a[i]<<' ';cout<<a[a.size()-1]<<endl
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;

signed main() {
  cout << fixed << setprecision(8);
  int n,qw,er;
  cin >> n;
  Vi a(0);
  cin >> qw;
  if(n==1||n==2){cout<<1<<endl;return 0;}
  rep(i,0,n-1) {
    er = qw;
    cin >> qw;
    if(er>qw) a.pb(-1);
    else if(er<qw) a.pb(1);
  }
  
  int ans = 1,now=a[0];
  rep(i,0,a.size()){
    if(now==0) {now=a[i];continue;}
    if(now==a[i]) continue;
    else {
      ans++;
      now = 0;
    }
  }
  cout << ans << endl;
  return 0;
}


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    string S; cin >> S;
    int N = S.length();
    vector<ll> dp(N, 0); //dp[i]: S[i]以降の部分列"BC"の数
    vector<ll> cnt_C(N, 0); //cnt_C[i]: S[i+1]~S[N-1]で'C'が出現する回数
    vector<ll> cnt_Q(N, 0);
    if(S[N-1] == 'C') cnt_C[N-2] = 1;
    else if(S[N-1] == '?') cnt_Q[N-2] = 1;
    for(int i = N-2; i >= 1; i--){
        if(S[i] == 'C'){
            cnt_C[i-1] = cnt_C[i] + 1;
            cnt_Q[i-1] = cnt_Q[i];
        }
        else if(S[i] == '?'){
            cnt_C[i-1] = cnt_C[i];
            cnt_Q[i-1] = cnt_Q[i] + 1;
        }
        else{
            cnt_C[i-1] = cnt_C[i];
            cnt_Q[i-1] = cnt_Q[i];
        }
    }

    ll ans = 0;
    ll fac3[100001];
    fac3[0] = 1;
    for(int i = 1; i <= 100000; i++) fac3[i] = (fac3[i-1]*3) % mod;

    dp[N-1] = 0;
    for(int i = N-2; i >= 0; i--){
        if(S[i] == 'A' || S[i] == 'C') dp[i] = dp[i+1];
        else if(S[i] == 'B'){
            dp[i] = (dp[i+1] + (cnt_C[i]*fac3[cnt_Q[i]] % mod) + (cnt_Q[i]*fac3[cnt_Q[i]-1] % mod)) % mod;
        }
        else{
            dp[i] = ((dp[i+1]*3 % mod) + (cnt_C[i]*fac3[cnt_Q[i]] % mod) + (cnt_Q[i]*fac3[cnt_Q[i]-1] % mod)) % mod;
        }
    }
    //S[i-1]までに出てくる'?'の数を知らないときつい
    vector<ll> Q_head(N+1, 0); //Q_head[i]: S[0]が?ならQ_head[1] = 1
    for(int i = 1; i <= N; i++){
        if(S[i-1] == '?') Q_head[i] = Q_head[i-1] + 1;
        else Q_head[i] = Q_head[i-1];
    }
    for(int i = 0; i < N-2; i++) if(S[i] == 'A' || S[i] == '?') ans = (ans + (fac3[Q_head[i]]*dp[i+1] % mod)) % mod;
    cout << ans << endl;
    //rep(i, N) cout << dp[i] << " "; cout << endl;
    return 0;
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ln '\n';
int lim=1e6;
int inf=1e9+7;
vector<vector<int> > dp;
vector<int> a;int n;
bool solve(int k,int i){
    if(dp[k][i]!=-1){
        return dp[k][i];
    }else{
        bool ans=0;
        for(int j=0;j<n;j++){
            if(a[j]<=k){
                bool tmp=solve(k-a[j],!i);
                ans=ans or (!tmp);
                if(ans){
                    break;
                }
            }
        }
        dp[k][i]=ans;
        return ans;
    }
}
int main()
{   
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int k;
    cin>>n>>k;
    a.resize(n);dp.resize(k+1,vector<int>(2,-1));
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    if(solve(k,0)){
        cout<<"First"<<ln;
    }else{
        cout<<"Second"<<ln;
    }
}


Measured memory_bytes: 13568
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <queue>
#include <sstream>
#include <unordered_map>
#include <cstring>
#include <iomanip>

using namespace std;

typedef long long ll;

const ll INF=1e9+7;

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

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

int main(){
    int N;
    cin>>N;
    int A[N],B[N];
    rep(i,N){
        cin>>A[i];
        B[i]=A[i];
    }
    sort(B,B+N);
    int MAX1=B[N-1],MAX2=B[N-2];
    rep(i,N){
        if(A[i]==MAX1){
            cout<<MAX2<<endl;
        }else{
            cout<<MAX1<<endl;
        }
    }
    return 0;
}

//a=97,z=122

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

int main()
{
    //自作関数の宣言
    vector<unsigned long long> next_p_mod(unsigned, long long);
    unsigned long long modpow(unsigned long long , unsigned long long , unsigned long long);
    void comb(vector<vector<long long int>>, unsigned long long);
    unsigned long long modinv(unsigned long long , unsigned long long);
    //
    ll N;
  string S;
  cin>>N>>S;
  string c_sum;
  c_sum+=S.at(0);
//  cout<<c_sum<<endl;

  char buff=S.at(0);
 for(int i=1;i<N;i++){
	if(buff==S.at(i)){
    }else{
    c_sum+=S.at(i);
    }
    buff=S.at(i);
  }
	cout<<c_sum.size()<<endl;
    return 0;
}

vector<unsigned long long> next_p_mod(unsigned N, long long mod)
{ //next_permutation
    vector<unsigned long long> Next_p(N);
    unsigned long long Next_p_buff = 1;
    for (int i = 0; i < N; i++)
    {
        Next_p_buff *= (i + 1) % mod;
        Next_p.at(i) = Next_p_buff % mod;
    }
    return Next_p;
}
unsigned long long modpow(unsigned long long a, unsigned long long n, unsigned long long mod)
{
    unsigned long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
void comb(vector<vector<long long int>> &v, unsigned long long mod)
{
    //vector<入れたい型> v(配列の個数(x),vector<入れたい型> (配列の個数,初期値));
    for (int i = 0; i < v.size(); i++)
    {
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for (int k = 1; k < v.size(); k++)
    {
        for (int j = 1; j < k; j++)
        {
            v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]) % mod;
        }
    }
}
// a^{-1} mod を計算する
unsigned long long modinv(unsigned long long a, unsigned long long mod)
{
    return modpow(a, mod - 2, mod);
}

// modinv
/*void modinv(unsigned long long N, unsigned long long mod,unsigned long long *inv) {
 // unsigned long long inv[N] ;
  for (unsigned long long i = 1; i < N; i++) {
    inv[i] = (i == 1) ? 1 : (mod - (mod / i) * inv[mod % i] % mod);
    assert(inv[i] * i % mod == 1);
  }
  //return 0;
}*/




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

#define rep(i, n) for(long long i=0;i<n;i++)
using ll = long long;
const ll INF = (1LL<<60);

int main(){

    ll a, b; cin >> a >> b;

    rep(i, 1001){
        if((ll)(i*0.08) == a && (ll)(i*0.1) == b){
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
from decimal import Decimal, getcontext
 
getcontext().prec = 1000
a,b,c = map(int,input().split())

ab = Decimal(a) * Decimal(b)
ab = ab.sqrt()

eps = Decimal(10) ** (-100)
 
cond = a + b + 2*ab < c
answer = 'Yes' if cond else 'No'
print(answer)

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

using namespace std;

int INF = INT_MAX;

struct SegmentTree{
private:
    int n;
    vector<int> node;

public:
    SegmentTree(){}
    SegmentTree(vector<int> v){
        int sz = v.size();
        int height = ceil(log2(sz));

        n = pow(2, height);
        node.resize(2*n-1, 0);
        for(int i = 0; i < sz; i++){
            node[i + (n-1)] = v[i];
        }
        for(int i = n-2; i >= 0; i--){
            node[i] = node[(i << 1) + 1] + node[(i << 1) + 2];
        }
    }

    //区間和の取得
    int getsum(int a, int b, int k=0, int l=0, int r=-1){
        if(r < 0) r = n;

        //[l, r)は[a, b)と全く重ならない -> 0(単位元)を返す
        if(r <= a || b <= l) return 0;

        //[l, r)は[a, b)を完全に含む -> その区間の総和を返す
        if(a <= l && r <= b) return node[k];

        //[l, r)は[a, b)を一部含む -> 子を探索して左右の子の和を返す
        int vl = getsum(a, b, (k << 1) + 1, l, (l+r)/2);
        int vr = getsum(a, b, (k << 1) + 2, (l+r)/2, r);
        return vl + vr;
    }

    //1点の値を更新
    void update(int idx, int val){
        idx = idx + (n-1);
        node[idx] += val;
        while(idx > 0){
            idx = (idx % 2 == 0)? idx/2 - 1 : idx/2;
            node[idx] = node[(idx << 1) + 1] + node[(idx << 1) + 2];
        }
    }

    void show(){
        for(int i = 0; i < n; i++){
            cout << node[i + (n-1)] << " ";
        }
        cout << endl;
    }
};

int main(){
    int n, q; cin >> n >> q;
    vector<int> A(n, 0);
    SegmentTree segtree(A);
    //segtree.show();
    for(int i = 0; i < q; i++){
        int cmd, x, y; cin >> cmd >> x >> y;
        if(cmd == 0){
            x--;
            segtree.update(x, y);
        }
        else{
            x--; y--;
            cout << segtree.getsum(x, y+1) << endl;
        }
        //segtree.show();
    }
    return 0;
}


Measured memory_bytes: 4992
import bisect

num = int(input())
top = sorted([int(x) for x in input().split()])
middle = sorted([int(x) for x in input().split()])
bottom = sorted([int(x) for x in input().split()])


# middleの配列でループを回したほうが早い(topとbottomを同時に処理できるため)
res = 0
for i in middle:
    index = bisect.bisect_left(top, i)
    index2 = len(bottom)-bisect.bisect_right(bottom, i)
    res += index*index2

print(res)

Measured memory_bytes: 23092
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vii = vector<ii>;
const ll MOD = 998244353;
const int INF = 1e9+9;
const int MAXN = 1000006;


int n, a[MAXN];
string s;

int solve(int i, int j) {
    if (i == 0) return a[j];
    for (int p = 0; (1<<p) <= i; p++) {
        if (i & (1<<p)) {
            return solve(i- (1<<p), j) ^ solve(i-(1<<p), j+(1<<p));
        }
    }
    return 0;
}

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> s;
    int mult = 1;
    if (s.find('2') != s.npos) {
        for (int i = 0; i < n; ++i) {
            a[i] = s[i]=='2';
        }
    } else {
        mult = 2;
        for (int i = 0; i < n; ++i) {
            a[i] = s[i]=='3';
        }
    }
    int ans = solve(n-1, 0);
    cout << mult*ans << endl;
}


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

#define debug(x) cout << '>' << #x << ':' << x << endl;
#define loop0(i,n) for(int i=0; i<(n); i++)
#define loop1(i,n) for(int i=1; i<=(n); i++)
#define fori(a,b,i) for(int i=(a); i<=(b); i++)
#define ford(a,b,i) for(int i=(a); i>=(b); i--)
#define fast_io ios_base::sync_with_stdio(false), cin.tie(NULL)
#define ign cin.ignore(numeric_limits<streamsize>::max(),'\n')

#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define endl "\n"
#define fir first
#define sec second
#define pb push_back
#define mp make_pair

typedef long long int ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<vector<int>> MAT;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MII;
typedef map<int,int> MCI;
typedef unordered_map<int,int> UMII;
typedef unordered_map<ll,ll> UMLL;
typedef unordered_map<char,int> UMCI;
typedef set<int> SI;
typedef unordered_set<int> USI;

// Display Map
//~for (auto const& pair: m) {
//~std::cout << "{" << pair.first << ": " << pair.second << "}\n";
//~}

// Extract word(w) from sentence(s)
//~stringstream str(s);
//~string w;
//~while(str >> w){
//~// w is your word
//~}

//Memset Syntax
// memset(array, value,sizeof(array)) val is 0,-1 or bool only

// To get accurate precision
//~cout.precision(20);

// Concatinate Vectors
//~

//~Vector of size n*m with zero
//~vector<vector<int> > vec( n , vector<int> (m, 0));



int main() {
    fast_io;
	string s;
	cin >> s;
	int n = s.size();
	if(s[n-1] == 's'){
		s += "es";
	}
	else s += "s";
	cout << s << endl;
}



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

using namespace std;
typedef long long LL;

const int MAXN = 2E5 + 5;
const int MOD = 998244353;

int n, k;
int l[20], r[20];
LL dp[MAXN], sum[MAXN];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= k; i++) cin >> l[i] >> r[i];
    dp[1] = 1;
    sum[1] = 1;
    for (int i = 2; i <= n; i++)
        for (int j = 1; j <= k; j++) {
            if (i - l[j] >= 0) {
                dp[i] += sum[i - l[j]] - sum[max(0, i - r[j] - 1)];
                dp[i] = (dp[i] % MOD + MOD) % MOD;
            }
            sum[i] = (sum[i - 1] + dp[i]) % MOD;
        }
    cout << dp[n];
    return 0;
}


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

int main(){
    int n;cin >> n;
    int a[n],b[n],c[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
        a[i] --;
    }
    for(int i=0;i<n;i++){
        cin >> b[i];
    }
    for(int i=0;i<n-1;i++){
        cin >> c[i];
    }
    int ans = 0;
    ans += b[a[0]];
    for(int i=1;i<n;i++){
        ans += b[a[i]];
        if(a[i-1] == a[i]-1){
            ans += c[a[i-1]];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0)
#define scl(n) scanf("%lld", &n)
#define pcl(n) printf("%lld\n", n)
#define pcl1(n) printf("%lld ", n)
#define nln printf("\n")
#define dev(x) cout << #x << " " << x << " ";
#define PTT pair<ll, ll>

map<ll, ll> mp, mp1;
map<ll, ll>::iterator itr;

int main()
{
    ll t, n, x;
    scl(n);
    vector<ll> v;
    for (int i = 0; i < n; i++)
    {
        scl(x);
        v.push_back(x);
    }
    ll mx = -1;
    ll ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (v[i] < mx)
        {
            ans += (mx - v[i]);
        }
        mx = max(mx, v[i]);
    }
    pcl(ans);
    return 0;
}

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

int n;
vector<int> a(100001);
int main()
{
	cin >> n;

	int x;
	for (int i = 0; i < n; ++i) 
		cin >> x, a[x]++;

	int ans = 0, cnt = 0;
	for (int i = 0; i < 100000; ++i){
		if (a[i] == 0) continue;

		if (a[i] & 1) ans++;
		else cnt++;
	}
	
	ans += cnt - (cnt & 1);
	cout << ans << endl;
}


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

using namespace std;

int main(){
    int N,K;
    cin >> N >> K ;
    vector<int> V(N);   //count the number of each number
    for(int i=0;i<N;i++){
        int tmp;
        cin >> tmp;
        V[tmp-1]++;
    }
    sort(V.begin(),V.end());
    reverse(V.begin(),V.end());
    int sum=0;
    for(int i=0;i<K;i++){
        sum+=V[i];
    }
    cout << N-sum <<endl;
    return 0;
}

Measured memory_bytes: 1024
R,C,N = list(map(int,input().split()))

point = []

def XtoZ(x,y):
    if x==0:
        if y==0:
            return 0
        else:
            return 2*R + 2*C - y
    elif x==R:
        return R + y
    elif y==0:
        return x
    elif y==C:
        return 2*R + C - x

for i in range(N):
    x1,y1,x2,y2 = list(map(int,input().split()))
    if ((x1==0 or x1==R) or (y1==0 or y1==C)) and ((x2==0 or x2==R) or (y2==0 or y2==C)):
        point.append([XtoZ(x1,y1),i])
        point.append([XtoZ(x2,y2),i])

point.sort(key = lambda x:x[0])

flag = [0]*N

from collections import deque

Q = deque()

flag = [True]*N
flag2=False
for p in point:
    if flag[p[1]]:
        Q.append(p[1])
        flag[p[1]] = False
    else:
        if Q.pop()!=p[1]:
            flag2=True
            break

if flag2:
    print("NO")
else:
    print("YES")

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

int main(){
	int ans = 0, n, a[110];
	
	cin>>n;
	
	a[0] = -1;
	for(int i = 1; i <= n; i++){
		cin>>a[i];
		if(a[i-1] == a[i] && a[i-1] != 0){
			a[i] = 0;
			ans++;
		}
	}
	
	
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
using namespace std;
int main(){
    long long n,m;
    cin>>n>>m;
    if(n<=m){
        cout<<"unsafe"<<endl;
    }
    else{
        cout<<"safe"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
int main(void) {
 int N,i,j,A[2][100],x,S=0,maxy=0;
 scanf("%d",&N);
 for(i=0;i<2;i++){
  for(j=0;j<N;j++){
   scanf("%d",&A[i][j]);
  }
 }
 for(x=0;x<N;x++){
  for(j=0;j<=x;j++){
   S+=A[0][j];
  }
  for(j=x;j<N;j++){
   S+=A[1][j];
  }
  if(maxy<S){
   maxy=S;
  }
  S=0;
 
 }
 printf("%d\n",maxy);
 return 0;
}

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;

int main() {
    string s;
    cin >> s;
    REP(i, s.size()) {
        if(s[i] == '?') s[i] = 'D';
    }

    cout << s << endl;

}

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

int main(){
int t=0;
string s;
cin >> s;
int N = s.length();
int M = (N-1)/2;
for(int i=0;i<(N-1)/2;i++){
	if(s.at(i) != s.at(N-1-i)){
		cout << "No" << endl;
		return 0;
	}
}
for(int i=0;i<(N+1)/4;i++){
	if(s.at(i) != s.at(M-1-i)){
		cout << "No" << endl;
		return 0;
	}
}
for(int i=(N+3)/2-1;i<N;i++){
	if(s.at(i) != s.at(N-1-i)){
		cout << "No" << endl;
		return 0;
	}
}

cout << "Yes" << endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const ll MOD = 1e9+7;


#define REP(i, N) for (ll i = 0; i < (N); i++)
#define REPP(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((ll)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<ll>>

using namespace std;
// 変数初期化
vector<ll> bsv; // binary_search用のvector
ll a,b,c,n,m;
typedef pair<ll, ll> Pll;
vector<Pll> facts; // 素因数分解の結果格納用(基数:乗数)
vector<vector<ll> > bit_search_v; //nit全探索の結果格納用

// index が条件を満たすかどうか
bool isOK(ll index, ll key) {
    if (bsv[index] >= key) return true;
    else return false;
}

// 汎用的な二分探索のテンプレ
ll binary_search(int key) {
    int ng = -1;
    int ok = (ll)bsv.size();

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key)) ok = mid;
        else ng = mid;
    }
    // OK(key以上となる)のindex番号を返す
    return ok;
}

// 最大公約数
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}

// 最小公倍数
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}


// 階乗計算
ll fuctorial(ll n) {
    ll ans = 1;
    for(ll i = 1; i <= n;i++){
        ans *= i;
        }

        return ans;
        }

// コンビネーション
vector<vector<ll> > comb(ll n, ll r) {
    vector<vector<ll> > v(n + 1,vector<ll>(n + 1, 0));
    for (ll i = 0; i < v.size(); i++) {
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for (ll j = 1; j < v.size(); j++) {
        for (ll k = 1; k < j; k++) {
            v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
        }
    }
    return v;
}

//　素因数分解
void prime_fact(ll target){
    ll base=2, exp=0;
    while (base*base<=target) {
        while (target%base==0) {
            target /= base; exp++;
        }
        if (exp>0) {
            facts.push_back(make_pair(base, exp));
        }
        base++; exp=0;
    }
    if (target>1) facts.push_back(make_pair(target,1));
}
// prime_factの結果の確認用
void print_facts(){
    for (int i=0; i<facts.size(); i++) {
        cout << facts[i].first << " " << facts[i].second << endl;
    }
}

// bit全探索
void bit_search(ll target){
    for (ll i=0; i<(1<<target); ++i) {
        if (i==0) continue;
        vector<ll> v;
        for (ll j=0; j<target; ++j) {
            if (i&(1<<j)) v.push_back(j);
            if (i&(1<<j)) cout << i << "  :  " << j << endl;
        }
        bit_search_v.push_back(v);
    }
}
// bit全探索の結果確認用
void print_bit_search(){
    for (ll i=0; i<bit_search_v.size(); ++i) {
        for (ll j=0; j<bit_search_v[i].size(); ++j) {
            cout << bit_search_v[i][j] << " ";
        }
        cout << endl;
    }
}



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

    cin >> n;
    if(n%1000 == 0) cout << 0 << endl;
    else  cout << 1000 - n%1000 << endl;

    return 0;
}

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

int main(){
  int n;
  cin>> n;
  vector<int> h(n);
  for (int i=0; i<n; i++) cin>> h.at(i);
  
  string ans="Yes";
  int higher,lower;
  for (int i=n-1; i>0; i--){
    higher=h.at(i);
    lower=h.at(i-1);
    if (lower<=higher) continue;
    else if (lower-1<=higher && 0<lower-1) h.at(i-1)=lower-1;
    else {ans="No"; break;}
  }
  cout<< ans <<endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#define swap(x, y) {int z; z=y; y=x; x=z;}
int main ()
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if(a > b)
	{
		swap(a, b);
	}
	if(a > c)
	{
		swap(a, c);
	}
	if(b > c)
	{
		swap(b, c);
	}
	printf("%d %d %d\n", a, b, c);
	return 0;
} 


Measured memory_bytes: 2756
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <cassert>
#include <functional>

using namespace std;
typedef long long ll;


#define SIZE 50001
#define INF 1000000000
#define LLINF 1000000000000000000LL

int main(){
  int n,m,p;
  int s[SIZE],t[SIZE],e[SIZE];
  scanf("%d%d",&n,&m);

  for(p=0;;p++){
    scanf("%d%d%d",s+p,t+p,e+p);
    s[p]--;
    t[p]--;
    if(e[p]==0) break;
  }

  int l;
  int b[10001];
  
  scanf("%d",&l);
  for(int i=0;i<l;i++){
    ll ans[10001] = {0};
    for(int j=0;j<m;j++){
      scanf("%d",b+j);
    }

    for(int j=0;j<p;j++){
      ans[s[j]] += (ll)b[t[j]] * e[j];
    }

    for(int j=0;j<n;j++){
      printf(j<n-1?"%lld ":"%lld\n",ans[j]);
    }
  }
  
  return 0;
}

Measured memory_bytes: 1884
#include<stdio.h>

int main()
{
  int x,y,a,m;

  scanf("%d%d",&x,&y);
  if(x < y){
    m = x;
    x = y;
    y = m;
  }

  while(1){
    a = x % y;

    if(a == 0) break;
    
    x = y;
    y = a; 
  }

  printf("%d\n",y);

  return 0;
}

Measured memory_bytes: 592
use std::i32::MAX;
fn main() {
    proconio::input! {
        n:usize,
        m:usize,
        x:usize,
        mat:[(i32, [usize;m]);n],
    }
    let try_num = |num| {
        let mut money  = 0;
        let mut skills = vec![0;m];
        for i in 0..n {
            if (1 << i) & num == 0 {
                continue;
            }
            money += mat[i].0;
            for j in 0..m {
                skills[j] += (mat[i].1)[j];
            }
        }
        if skills.iter().all(|&sv| sv >= x ) {
            Some(money)
        } else {
            None
        }
    };
    let mut ans = MAX;
    (0..(1<<n)).for_each(|num| {
        match try_num(num) {
            Some(money) => ans = ans.min(money),
            None        => (),
        }
    });
    println!("{}", if ans == MAX { -1 } else { ans })
}

Measured memory_bytes: 2168
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<map>  
#include<set>
#include<iterator>
#include<list>
#include<utility>
#include<cstdlib>
#include<queue>
#include<stack>
#include<bitset>
//#include<bits/stdc++.h>
#define PI  2*acos(0.0)
#define pb push_back

       
using namespace std;
using ll = long long;
using lli = long long int;
using ld = long double;



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

ll n;
cin>>n;
ll a[n];
for(int i=0;i<n;i++)  cin>>a[i];

ll cnt=0;

for(int i=0;i<n-1;i++)
{
	if(a[i]>a[i+1])
	{
		cnt+=a[i]-a[i+1];
		a[i+1]=a[i];
	}
}


cout<<cnt<<"\n";


	
	
	return 0;
	
	
	       /***Israil Hosen
	            Computer Science & Engineering
	         University Of Rajshahi.
	         ***/
	
	
	
}

Measured memory_bytes: 4760
import numpy as np

H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]
S = np.array(S) == "."

L = np.zeros((H, W), dtype=int)
R = np.zeros((H, W), dtype=int)
U = np.zeros((H, W), dtype=int)
D = np.zeros((H, W), dtype=int)

for i in range(H):
    D[i] = (D[i-1]+1) * S[i]
    U[-i-1] = (U[-i]+1) * S[-i-1]

for i in range(W):
    R[:, i] = (R[:, i-1]+1) * S[:, i]
    L[:, -i-1] = (L[:, -i]+1) * S[:, -i-1]

print(np.max(L+R+U+D)-3)


Measured memory_bytes: 239124
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<cstring>
#include<algorithm>
#include<string>
#include<stack>
#include<cmath>
#include<map>
#define rep(i,l,r) for(int i=(l);i<(r);i++)
#define per(i,l,r) for(int i=(r-1);i>=l;i--)
#define P pair<int,int>
#define ll long long
using namespace std;
int a[55],b[55];
int main ()
{
	int n;
	cin>>n;
	rep(i,0,n)cin>>a[i],b[i]=a[i];
	sort(a,a+n);
	int c=0;
	rep(i,0,n)
	{
		if(b[i]!=a[i])c++;
	}
	if(c>2)cout<<"NO";
	else cout<<"YES";
//	while(1);
	return 0;
}

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

int main(){
        int W,a,b;
        cin >> W >> a >> b;
        int ans=0;
        if((b >= a && b <= a+W) || (b+W >= a && b+W <= a+W) || (a >= b && a <= b +W)) {
                ans = 0;
        }else{
                if(a < b) {
                        ans = b - a - W;
                }else{
                        ans = a - b - W;
                }
        }
        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long long ll;
int main(){
	ll n ; 
	cin >> n ; 
	vector<pair<ll,ll> > tree[n+1] ; 
	vector<ll> dist(n+1) ; 
	vector<ll> vis(n+1) ; 
	for(ll i=0;i<n-1;i++){
		ll x , y , c ; 
		cin >> x >> y >> c ; 
		tree[x].push_back({y,c}) ; 
		tree[y].push_back({x,c});
	}
	ll m , start ; 
	cin >> m >> start ; 
	queue<pair<ll,ll> > q ; 
	q.push({start,0});
	vis[start] = true ; 
	dist[start] = 0 ; 
	while(q.size()){
		auto f = q.front() ; q.pop() ; 
		for(auto p : tree[f.first]){
			if ( !vis[p.first] ) {
				dist[p.first] = dist[f.first] + p.second ; 
				vis[p.first] = true ; 
				q.push({p.first,dist[p.first]});
			}
		}
	}
	debug() << imie(dist) ; 
	while(m--){
		ll x , y ; 
		cin >> x >> y ; 
		cout << dist[x] + dist[y] << endl;
	}
    return 0 ;
}


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

#ifdef TESTING
  #include "dump.hpp"
#else
  #define DUMP(...)
  #define DEBUG(...)
#endif

#define _REP(_1,_2,_3,_4,name,...) name
#define _REP4(i,b,e,s) for(decltype(e) _b=(b),_e=(e),i=_b+(0<(s)?0:(s));(0<(s)?i<_e:_e<=i);i+=(s))
#define _REP3(i,b,e) for(decltype(e) _b=(b),_e=(e),i=(_b<_e?_b:_b-1);(_b<_e?i<_e:_e<=i);(_b<_e?i++:i--))
#define _REP2(i,n) for(decltype(n) i=0,_n=(n);i<_n;i++)
#define _REP1(n) for(decltype(n) _i=0,_n=(n);_i<_n;_i++)
#define REP(...) _REP(__VA_ARGS__,_REP4,_REP3,_REP2,_REP1)(__VA_ARGS__)
#define FOR(it,c) for(auto&& it=begin(c);it!=end(c);it++)
#define ROF(it,c) for(auto&& it=rbegin(c);it!=rend(c);it++)
#define INT(n) int n;assert(0<scanf("%d",&n))
#define VI(v,n) vector<int> v(n);REP(i,n){assert(0<scanf("%d",&v[i]));}

int main(){
  INT(n); INT(m); VI(as, n);
  vector<int> cnt(n + 1, 0), cover(n, 0);
  int ans = n;
  for(int a: as){
    cnt[a]++;
    if (cover[max(a - cnt[a], 0)] == 0){ans--;}
    cover[max(a - cnt[a], 0)]++;
  }
  REP(m){
    INT(x); INT(y); int a = as[x - 1];
    cover[max(a - cnt[a], 0)]--;
    if (cover[max(a - cnt[a], 0)] == 0){ans++;}
    cnt[a]--;
    as[x - 1] = y;
    cnt[y]++;
    if (cover[max(y - cnt[y], 0)] == 0){ans--;}
    cover[max(y - cnt[y], 0)]++;
    printf("%d\n", ans);
  }
  return 0;
}

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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

const int dx[4] = {+1, 0, -1, 0};
const int dy[4] = {0, -1, 0, +1};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int a, b, c; cin >> a >> b >> c;
    if(a + b + c >= 22){
        cout << "bust" << endl;
    }else{
        cout << "win" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int rp(int a,int t){
    int c=a*(100+t);
    int b=c/100;
    return b;
}

int main(){
    int E;
    while(cin >> E && E!=0){
        int x=0,y=0,z=0;
        int z3,y2;
        int minx,miny,minz;
        int mini=INF;
        while(z*z*z<=E){
            int z3=z*z*z;
            y=0;
            while(y*y<=E-z3){
                y2=y*y;
                x=E-z3-y2;
                mini=min(mini,x+y+z);
                y++;
            }
            z++;
        }
        cout << mini << endl;
    }
    return 0;
}


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

using namespace std;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if((a==b)&&(a!=c)) cout<<"Yes"<<endl;
    else if((a==c)&&(b!=c)) cout<<"Yes"<<endl;
    else if((b==c)&&(c!=a)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

const int MAX = 210000;
int Q;
long long type[MAX], a[MAX], b[MAX];

int main() {
    cin >> Q;

    long long sum = 0;
    priority_queue<long long> zen;
    priority_queue<long long, vector<long long>, greater<long long> > kou;
    long long zensum = 0;
    long long kousum = 0;
    
    for (int i = 0; i < Q; ++i) {
        cin >> type[i];
        if (type[i] == 1) {
            cin >> a[i] >> b[i];
            sum += b[i];

            if (zen.size() > kou.size()) {
                // kou に
                int t = zen.top();
                if (a[i] >= t) {
                    kou.push(a[i]); kousum += a[i];
                }
                else {
                    zen.pop(); zensum -= t;
                    zen.push(a[i]); zensum += a[i];
                    kou.push(t); kousum += t;
                }
            }
            else {
                // zen に
                if (zen.empty()) zen.push(a[i]), zensum += a[i];
                else {
                    int t = kou.top();
                    if (a[i] <= t) {
                        zen.push(a[i]); zensum += a[i];
                    }
                    else {
                        kou.pop(); kousum -= t;
                        kou.push(a[i]); kousum += a[i];
                        zen.push(t); zensum += t;
                    }
                }
            }
        }
        else {
            long long x = zen.top();
            long long res = (x * (int)zen.size() - zensum) + (kousum - x * (int)kou.size()) + sum;
            cout << x << " " << res << endl;
        }
    }
}

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

int main() {
  ll n; cin >> n;
  vector<ll> v(n);
  rep(i,n) cin >> v[i];
  sort(v.begin(), v.end());
  double ans = v[0];
  
  for(ll i=1; i<n; i++){
    ans += v[i];
    ans /= 2;
  }
  cout << fixed << setprecision(7);
  cout << ans << endl;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

vector<vector<ll>> g(110000);
ll p[110000],ans[110000];
queue<ll> q;
int main(){
    ll n,m,x,y;
    cin>>n>>m;
    rep(i,0,m){cin>>x>>y;g[x].pb(y);g[y].pb(x);}
    p[1]=1;
    q.push(1);
    while(!q.empty()){
        ll v=q.front();
        q.pop();
        for(auto i:g[v]){
            if(p[i])continue;
            else{
                p[i]=1;
                ans[i]=v;
                q.push(i);
            }
        }
    }
    cout<<"Yes"<<endl;
    rep(i,2,n+1)cout<<ans[i]<<endl;
}

Measured memory_bytes: 13864
#include<bits/stdc++.h>
using namespace std;
int main(){
int a[10];
for(int i =0; i < 10; i++){
cin >> a[i];
}
sort( a, a + 10, greater<int>());
for(int j = 0; j < 3; j++){
cout << a[j] << endl;
}
return 0;
}

Measured memory_bytes: 3060
x,y = map(int,input().split())

g1 = [1,3,5,7,8,10,12]
g2 = [4,6,9,11]
g3 = [2]

if (x in g1 and y in g1) or (x in g2 and y in g2):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,d;cin>>n;
    long long c=0;
    vector<int> a(n+1),b(n);
    for(int i=0;i<n+1;i++){
        cin>>a.at(i);
    }
    for(int i=0;i<n;i++){
        cin>>b.at(i);
    }
    for(int i=0;i<n;i++){
        if(b.at(i)-a.at(i)>0){
            c+=a.at(i);
            d=b.at(i)-a.at(i);
            if(d>=a.at(i+1)){
                c+=a.at(i+1);
                a.at(i+1)=0;
            }
            else{
                a.at(i+1) -= d;
                c+=d;
            }
        }
        else c+=b.at(i);
    }
    cout <<  c <<endl;
}

Measured memory_bytes: 1024
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
if((a[0]+b[1] == a[1]+b[0])
  and (a[0]+c[1] == a[1]+c[0])
  and (a[0]+b[2] == a[2]+b[0])
  and (a[0]+c[2] == a[2]+c[0])
  and (a[1]+b[2] == a[2]+b[1])
  and (a[1]+c[2] == a[2]+c[1])
  and (b[0]+c[1] == b[1]+c[0])
  and (b[0]+c[2] == b[2]+c[0])):
    print("Yes")
else:
    print("No")

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

 int main(){
     int a,b;
     cin >> a >> b;
     if(a % 2 == 0 || b % 2 == 0 ){
         cout<<"Even"<< endl;
     }else{
         cout<<"Odd"<< endl;
     }  
     return 0;
 }


Measured memory_bytes: 888
#include<bits/stdc++.h>
#define ll long long
#define int long long
#define M 1000000007
#define sz(c) c.size()
#define fr first
#define sc second
#define pb push_back
#define sz(c) c.size()
#define ppb  pop_back
#define mp make_pair
#define all(a)      (a).begin(),(a).end()
#define rep(i,a,n)   for( int i=a ; i<n ; i++)
#define what_is(x)  cout << #x << " is " << x << endl;
#define U 1000000007
#define N 100005
using namespace std;
int n;
int a[2000];
int check(int m,int i,int j)
{
  if(a[m]<a[i]+a[j]) return 1;
  else return 0;
}
signed main()
{
  ios_base::sync_with_stdio(false);
  
  cin>>n;
  rep(i,0,n) cin>>a[i];
  sort(a,a+n);
  int ans=0;
  rep(i,0,n)
  {
    rep(j,i+1,n)
    { 
      int hi=n-1,lo=j+1;
      if(lo>=n) continue;
      if(a[lo]>a[i]+a[j]) continue;
      int mid=(hi+lo)/2;
      while(hi-lo>1)
      {
        if(check(mid,i,j))lo=mid;
        else hi=mid;
        mid=(hi+lo)/2;
      }
      if(check(hi,i,j)) ans+=hi-j;
      else if(check(lo,i,j)) ans+=lo-j;
      
      //cout<<ans<<" "<<i<<" "<<j<<" "<<mid<<endl;
    }
  }
  cout<<ans;




}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void){
	int m, c, a, n;
	cin >> m;
	rep(i, m){
		cin >> c >> a >> n;
		int cost = 0;
		while(1){
			c--;
			a--;
			n--;
			if(c == -1 || a == -1 || n == -1){
				c++;
				a++;
				n++;
				break;
			}
			cost++;
		}

		while(1){
			c -= 2;
			a--;
			if(c < 0|| a == -1){
				c += 2;
				a++;
				break;
			}
			cost++;
		}

		while(1){
			c -= 3;
			if(c < 0){
				c+=3;
				break;
			}
			cost++;
		}
		cout << cost << endl;
		
	}
	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

Measured memory_bytes: 1164
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.nextLong();
            int res = digits(n);
            for (long i = 1L; i * i <= n; ++i) {
                if (n % i != 0) continue;
                long cur = n / i;
                res = Math.min(res, Math.max(digits(i), digits(cur)));
            }
            out.println(res);
        }

        private int digits(long cur) {
            int digs = 0;
            while (cur > 0) {
                cur /= 10;
                ++digs;
            }
            return digs;
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}



Measured memory_bytes: 21460
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int b1,b2;
		String str = sc.nextLine();
		String[] a = str.split(" ");
		String str1 = sc.nextLine();
		String[] a1 = str1.split(" ");
		String str2 = sc.nextLine();
		if(str2.equals(a[0])) {
			b1 = Integer.parseInt(a1[0])-1;
			b2 = Integer.parseInt(a1[1]);
		}
		else {
			b1 = Integer.parseInt(a1[0]);
			b2 = Integer.parseInt(a1[1])-1;
		}
		System.out.println(b1+" "+b2);
		
	}
}

Measured memory_bytes: 22996
#include <iostream>
using namespace std;
int main () {
    int W, H, x, y,r;
    cin >> W >> H >> x >> y >> r;
    if (W - x >= r && x >= r && H - y >= r && y >= r){
        cout << "Yes"<< endl;
        
    }else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3100
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
using namespace std;

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

	if (X == 7 || X == 5 || X == 3)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;

	}

	return 0;
}


Measured memory_bytes: 256