akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define REP3(i, x, n) for(decltype(x) i = (x); i <= (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1;i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define INF 1000000000
#define PI 3.14159265358979

#define _CRT_SECURE_NO_WARNINGS

using namespace std;

// N, E, S, W
const int dx[4] = { -1, 0,  1,  0 };
const int dy[4] = { 0, 1,  0, -1 };

typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<LL> vll;
//==============================================
vector<pair<char, int>> BubbleSort(vector<pair<char, int>> A, int  N) {
	REP(i, N) {
		for (int j = N - 1; j >= 1; j--) {
			if (A[j].second < A[j - 1].second) {
				swap(A[j].first, A[j - 1].first);
				swap(A[j].second, A[j - 1].second);
			}
		}
	}

	return A;
}

vector<pair<char, int>> SelectionSort(vector<pair<char, int>> A, int N) {
	REP(i, N) {
		int minJ = i;
		REP2(j, i, N) {
			if (A[j].second < A[minJ].second) {
				minJ = j;
			}
		}
		swap(A[i].first, A[minJ].first);
		swap(A[i].second, A[minJ].second);
	}

	return  A;
}

void print(vector<pair<char, int>> A, int N) {
	REP(i, N) {
		if (i > 0) cout << " ";
		cout << A[i].first << A[i].second;
	}
	cout << "\n";
}

bool isStable(vector<pair<char, int>> C1, vector<pair<char, int>> C2, int N) {
	REP(i, N) {
		if (C1[i].first != C2[i].first) return false;
	}
	return true;
}

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

	int n; cin >> n;
	vector<pair<char, int>> card(n);

	REP(i, n) {
		cin >> card[i].first >> card[i].second;
	}

	vector<pair<char, int>> C1 = BubbleSort(card, n);
	vector<pair<char, int>> C2 = SelectionSort(card, n);

	print(C1, n);
	cout << "Stable" << "\n";
	print(C2, n);

	if (isStable(C1, C2, n)) {
		cout << "Stable" << "\n";
	} else {
		cout << "Not stable" << "\n";
	}
	return 0;
}

Measured memory_bytes: 3196
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  double N,M;
  cin>>N>>M;
  Graph ST(N);
  REP(i,int(M)){
    int S,T;
    cin>>S>>T;
    S--,T--;
    ST[S].PB(T);
  }
  
  double P[int(N)]; // P[i]=点iへの到達確率
  REP(i,N) P[i]=0;
  P[0]=1;
  REP(i,N){
    FORE(v,ST[i]){
      P[v]+=P[i]/ST[i].size();
    }
  }
  
  double Q[int(N)]; // Q[i]=その点からの残り回数期待値
  REP(i,N) Q[i]=0;
  for(int i=N-2; i>=0; --i){
    FORE(v,ST[i]){
      Q[i]+=Q[v];
    }
    Q[i]/=ST[i].size();
    Q[i]++;
  }
  
  double ans=N-1;
  REP(i,N-1){
    if(ST[i].size()==1) continue;
    double mx=0,it=(Q[i]-1)*ST[i].size();
    FORE(v,ST[i]) chmax(mx,Q[v]);
    it=(it-mx)/(ST[i].size()-1)+1;
    chmin(ans,Q[0]-P[i]*(Q[i]-it));
  }
  
  cout<<setprecision(10)<<ans<<endl;
  return 0;
}

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

using namespace std;

#define int long long int

int32_t main(){

	unordered_map <int, int> m;
	unordered_map <int, int>:: iterator itr;
	int n, i,sum = 0;
	cin >> n;
	vector<int> v(n);

	for(i=0; i<n; i++){

		cin >> v[i];
		itr  = m.find(v[i]);
		if(itr == m.end())
			m.insert({v[i], 1});
		else
			itr->second++;
	}

	for(itr = m.begin(); itr != m.end(); itr++){
		if(itr->second > 1)
			sum += itr->second * (itr->second - 1) / 2;
	}

	for( i=0; i<n; i++){

		itr = m.find(v[i]);

		if(itr->second > 1)
			cout<< sum - (itr->second - 1) ;
		else
			cout<<sum;
		cout<<endl;
	}

	return 0;
}

Measured memory_bytes: 9160
#include <iostream>
#include <cstdio>
using namespace std;
long long r , d , x;
int main()
{
    cin >> r >> d >> x;
    for (int i = 1 ; i <= 10 ; i++)
    {
        x = r * x - d;
        cout << x << endl;
    }
    return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    a = list(map(int, input().split()))
    q = int(input())
    m = list(map(int, input().split()))

    res = list()

    def mul(a, b):
        return a * b

#   # bit探索
    # for i in range(2**n):
    #     x = [0] * n
    #     for j in range(n):
    #         if(i >> j) & 1:
    #             x[j] = 1
    #     res.append(sum(list(map(mul, a, x))))
    # for i in m:
    #     if i in res:
    #         print('yes')
    #     else:
    #         print('no')
#   # 再帰
    def dfs(A):
        # 終端条件 --- nループまで回したら処理して打ち切り
        if len(A) == n:
            # print(A)
            res.append(sum(list(map(mul, a, A))))
            return
        for v in range(2):
            A.append(v)
            dfs(A)
            A.pop()
    dfs([])
    for i in m:
        if i in res:
            print('yes')
        else:
            print('no')

if __name__ == '__main__':
    main()


Measured memory_bytes: 43084
using System;

namespace AtCoder.ABC104
{
    public class A
    {
        public static void Solve()
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            
            var rank = ""; 
            if (a < 1200)
            {
                rank = "ABC";
            }
            else if (1200 <= a && a < 2800)
            {
                rank = "ARC";
            }
            else
            {
                rank = "AGC";
            }
            
            Console.WriteLine(rank);
        }    
    }
}

namespace AtCoder {
    class Program
    {
        static void Main(string[] args)
        {
            ABC104.A.Solve();
        }
    }
}


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

typedef long long ll;

int main(){
    int n, d, a;
    cin >> n >> d >> a;
    vector<pair<int,int>> vp;
    for(int i = 0; i < n; i++){
        int x, h;
        cin >> x >> h;
        vp.push_back({x, h});
    }
    sort(vp.begin(), vp.end());
    queue<pair<ll,ll>> q;
    ll ans = 0, acc = 0;
    for(int i = 0; i < n; i++){
        while(!q.empty() && vp[i].first > q.front().first){
            acc -= q.front().second;
            q.pop();
        }
        ll res = vp[i].second-acc*a;
        if(res <= 0)    continue;
        ll need = (res+a-1)/a;
        ans += need;
        q.push({vp[i].first+2*d, need});
        acc += need;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3440
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
const int INF=1001001001;

int main() {
  int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  sort(A.rbegin(),A.rend());
  int64_t sum=0;
  int cnt=N-1;
  for(int i=0;i<N;i++){
    if(i==0){sum+=A[i];cnt--;}
    else{
      for(int j=0;j<2;j++){
        if(cnt>0){
          sum+=A[i];
          cnt--;
        }
      }
    }
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 4040
#include <iostream>
#include <algorithm>
#include <utility>
using namespace std;

//dp[H][W]
int ary[1010][1010],dp[1010][1010];
int main(){
	int H,W,N;
	while(true){
		cin>>H>>W>>N;
		if(H==0&&W==0&&N==0) break;
		for(int i=1;i<=H;i++){
			for(int j=1;j<=W;j++){
				cin>>ary[i][j];
			}
		}
		for(int i=1;i<=H+1;i++){
			for(int j=1;j<=W+1;j++){
				dp[i][j]=0;
			}
		}

		dp[1][1]=N;
		int nx,ny;
		nx=1;ny=1;
		for(int i=1;i<=H;i++){
			for(int j=1;j<=W;j++){
				int tmp=dp[i][j];
				if(tmp&1){
					if(i==ny&&j==nx){
						if(ary[i][j]){
							nx++;
						}
						else{
							ny++;
						}
					}
					if(ary[i][j]){
						dp[i][j+1]++;
					}
					else{
						dp[i+1][j]++;
					}
					dp[i][j+1]+=(dp[i][j]>>1);
					dp[i+1][j]+=(dp[i][j]>>1);
				}
				else{
					if(i==ny&&j==nx){
						if(ary[i][j]){
							ny++;
						}
						else{
							nx++;
						}
					}
					dp[i][j+1]+=(dp[i][j]>>1);
					dp[i+1][j]+=(dp[i][j]>>1);
				}
			}
		}
		cout<<ny<<" "<<nx<<endl;
	}
	return 0;
}

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

int main() {
	// your code goes here
	int a,b;
	cin>>a>>b;
	//cout<<max(a+b, max(a-b, a*b));
	for(int i=b-a+1; i<b; i++)
	    cout<<i<<" ";
	for(int i=b; i<b+a; i++)
	    cout<<i<<" ";
	//return 0;
}


Measured memory_bytes: 256
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

def main():
    n = int(input())
    a = list(map(int,input().split()))
    q = int(input())
    cnt = [0]*(10**5+7)
    for i in range(n):
        cnt[a[i]]+=1
    p = sum(a)
    for i in range(q):
        b,c = map(int,input().split())
        d = cnt[b]
        e = cnt[c]
        diff = d*(c-b)
        p += diff
        cnt[c]+=d
        cnt[b]-=d
        print(p)
if __name__ == "__main__":
    main()

Measured memory_bytes: 21416
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = readLine >>= print . solve . sort

solve :: [Int] -> Int
solve [a, b]
    | a < b - 1 = b + b - 1
    | otherwise = a + b 

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 380
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	s0, s1, s2 := getString(), getString(), getString()

	fmt.Printf("%c%c%c\n", s0[0]-'a'+'A',
		s1[0]-'a'+'A',
		s2[0]-'a'+'A',
	)
}


Measured memory_bytes: 640
#include <iostream>

int main()
{
	int x, y;
	std::cin >> x >> y;

	bool ok = false;
	for (int c = 0; c <= x; ++c)
	{
		int t = x - c;
		if ((2 * c + 4 * t) == y)
		{
			ok = true;
			break;
		}
	}

	if (ok)
	{
		std::cout << "Yes" << std::endl;
	}
	else
	{
		std::cout << "No" << std::endl;
	}	

	return 0;
}


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

using namespace std;

bool check(string &s)
{
    return (s[0] == s[1] && s[1] == s[2] && s[2] == s[3]);
}

int main()
{
    string N;
    while (cin >> N, N != "0000") {
        int cnt = 0;
        bool fail = 0;
        while (N != "6174") {
            if (check(N)) {
                fail = 1;
                break;
            }
            string L = N, S = N;
            sort(L.begin(), L.end(), greater<char>());
            sort(S.begin(), S.end());


            int diff = stoi(L) - stoi(S);            
            N = to_string(diff);
            reverse(N.begin(), N.end());
            while (N.size() != 4) {
                N += "0";
            }
            reverse(N.begin(), N.end());                        
            cnt++;            
        }
        if (fail) {
            cout << "NA" << endl;
        } else {
            cout << cnt << endl;
        }
    }        
    return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 1e9+7;

int mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}


void solve()
{
   int n;
    cin >> n;
    
   int a[n];
    f(i,n) cin >> a[i];
    
    int res = 0;
    
   f(i,n) f(j,n) f(k,n)
   {
       if(i >= j) continue;
       if(i >= k) continue;
       if(j >= k) continue;
       
       if(a[i] == a[j]) continue;
       if(a[k] == a[j]) continue;
       if(a[i] == a[k]) continue;
       
       int mx = max(a[i],max(a[j],a[k]));
       
       int oth = a[i] + a[j] + a[k] - mx;
       
       if(oth > mx) 
       {
           res++;
       }
   }
    
   cout << res; 
    
    
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ll n,k;
	cin>>n>>k;
	ll arr[n+1];
	arr[0]=0;
	for(ll i=1;i<=n;i++)
    	cin>>arr[i];

    ll dp[n+1];
    for(ll i=0;i<=n;i++) dp[i]=0;

    for(ll i=n-1;i>0;i--){

    	ll min1=1000000002;

    	for(ll j=i+1; (j<=i+k && j<=n);j++){

    		ll y = dp[j]+abs(arr[j]-arr[i]);

    		if(y<min1)
    			min1=y;
    	}
    	dp[i]=min1;
	}

	cout<<dp[1];
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include<math.h>

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);//高速化、endlは使わない

  int N;
  long int ans=1;

  cin >> N;

  for(int i=1;i<=N;i++){
    ans = ans*i%(7+(int)pow(10,9));
  }
  cout << ans << "\n";
}


Measured memory_bytes: 256
N = int(input())
A = [int(item) for item in input().split()]

def selectionSort(A, N):
    cnt = 0
    for i in range(N-1):
        minj = i
        for j in range(i, N):
            if A[j] < A[minj]:
                minj = j
        if i != minj:
            A[i], A[minj] = A[minj], A[i]
            cnt += 1
    
    print(*A)
    print(cnt)

selectionSort(A, N)


Measured memory_bytes: 5616
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <assert.h>
#include <numeric>
#include <iomanip>
#define rep(i, a, b) for (int(i) = (a); i < (b); i++)
using namespace std;

using ll = long long;

typedef pair<int, int> P;

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

ll pow_mod(ll x, ll y, ll mod)
{
	if (y == 0)
		return 1;

	if (y == 1)
		return x % mod;

	return (pow_mod(x, y - 1, mod) * x) % mod;
}

int H,W;
int c[10][10];
int d[10];
bool used[10];
ll ans=0;

void dijkstra(int s){
	fill(d,d+10,INF);
	fill(used,used+10,false);
	d[s]=0;
	while(true){
		int v=-1;
		for(int u=0;u<10;u++){
			if(!used[u]&&(v==-1 || d[u]<d[v]))v=u;
		}
		if(v==-1)break;
		used[v]=true;
		for(int u=0;u<10;u++){
			d[u]=min(d[u],d[v]+c[v][u]);
		}
	}
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	//問題文中の添え字が0-indexか1-indexか確認!
	cin>>H>>W;
	rep(i,0,10)rep(j,0,10)cin >> c[j][i];
	rep(i,0,10)c[i][i]=INF;
	dijkstra(1);
	rep(i,0,H){
		rep(j,0,W){
			int temp=0;
			cin>>temp;
			if(temp>=0)ans+=d[temp];
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <queue>
#include <string>
#include <complex>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define repa(i,s,e) for(int i=s; i<=e; i++)
#define repd(i,s,e) for(int i=s; i>=e; i--)

typedef long long ll;
typedef vector<int> vi;

int dxo[6] = { -1,  0, -1, 1, -1, 0};
int dxe[6] = { 0,  1, -1, 1, 0, 1};
int dy[6] = {-1, -1,  0, 0,  1, 1}; 

struct node { int x, y, dist, num; };

const int INF = 1000000009;
const int MAX_N = 101;
const int MAX_S = 11;
int n, m, s, t;
int cx[MAX_S], cy[MAX_S], tx[MAX_S], ty[MAX_S];
int field[MAX_N][MAX_N];
int dist[MAX_N][MAX_N];
char used[MAX_N][MAX_N];

int bfs(int x, int y) {
	rep(j,n) rep(i,m) used[i][j] = 0;

	int res = 0;
	queue<node> que;
	node md = {x, y, 0, -1};
	used[x][y] = 1;
	que.push(md);
	while(!que.empty()) {
		node nd = que.front();
		que.pop();

		if(dist[nd.x][nd.y] <= nd.dist) continue;

		used[nd.x][nd.y] = 1;
		res++;
		rep(k,6) {
			int xx = (nd.y % 2 == 0) ?  nd.x + dxo[k] : nd.x + dxe[k];
			int yy = nd.y + dy[k];
			if(xx >= 0 && yy >= 0 && xx < m && yy < n && used[xx][yy] == 0 && dist[xx][yy] > nd.dist + 1) {
				node nnd = {xx, yy, nd.dist+1, -1};
				used[xx][yy] = 1;
				que.push(nnd);
			}
		}
	}
	return res;
}

void solve() {
	rep(y,n) {
		rep(x,m) {
			field[x][y] = 0;
			dist[x][y] = INF;
		}
	}

	queue<node> que;
	rep(i,s) {
		node nd = { cx[i]-1, cy[i]-1, 0, i+1 };
		que.push(nd);
	}

	while(!que.empty()) {
		node nd = que.front();
		que.pop();

		if(dist[nd.x][nd.y] > nd.dist) {
			dist[nd.x][nd.y] = nd.dist;
			field[nd.x][nd.y] = nd.num;
		} else if(dist[nd.x][nd.y] == nd.dist && field[nd.x][nd.y] != nd.num && field[nd.x][nd.y] != 0) {
			field[nd.x][nd.y] = 0;
		} else {
			continue;
		}

		rep(k,6) {
			int xx = (nd.y % 2 == 0) ?  nd.x + dxo[k] : nd.x + dxe[k];
			int yy = nd.y + dy[k];
			if(xx >= 0 && yy >= 0 && xx < m && yy < n) {
				node nnd = { xx, yy, nd.dist+1, nd.num };
				que.push(nnd);
			}
		}
	}

	int maxval = 0;
	rep(i,t) {
		int res = bfs(tx[i]-1, ty[i]-1);
		maxval = max(res, maxval);
	}
	printf("%d\n", maxval);
}

int main() {
	for(;;) {
		scanf("%d", &m);
		if(m == 0) break;

		scanf("%d", &n);
		scanf("%d", &s);
		rep(i,s) scanf("%d%d", &cx[i], &cy[i]);

		scanf("%d", &t);
		rep(i,t) scanf("%d%d", &tx[i], &ty[i]);

		solve();
	}
}

Measured memory_bytes: 1276
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String line = scanner.nextLine();
        int number = Integer.parseInt(line);

        double logNum = Math.log10(number);
        int numDigit = ((int) logNum) + 1;

        int sum = 0;
        for (int i=1; i<numDigit; i++) {
            if (i % 2 == 1) {
                sum += count(i);
            }
        }
        if (numDigit % 2 == 1) {
            int additional = number - (((int) Math.pow(10, numDigit - 1)) - 1);
            sum += additional;
        }

        System.out.println(sum);
    }

    private static int count(int i) {
        return 9 * ((int)Math.pow(10, i - 1));
    }

}


Measured memory_bytes: 21712
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
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(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int n;
int main(){
    int h;
    cin>>h>>n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    ll adre=0;
    rep(i,n)adre+=a[i];
    if(h>adre)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}




Measured memory_bytes: 640
import java.io.*;
import java.util.*;
import java.lang.Math;
import java.util.Arrays;

public class Main {
    public static void main(final String[] args) {

        Scanner sc = new Scanner(System.in);

        int h, w;
        MainRoop : while(true){
            h = sc.nextInt();
            w = sc.nextInt();
            if(h == 0 && w == 0)break MainRoop;
            for(int i = 0; i < h; i++){
                for(int j = 0; j < w; j++){
                    if(i == 0 || i == h - 1 || j == 0 || j == w - 1)
                        System.out.print("#");
                    else 
                        System.out.print(".");
                }
                System.out.print("\n");
            }
            System.out.print("\n");
        }
    }
  
}


Measured memory_bytes: 36836
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define MAX 100
#define MOD 1000000007
#define pb push_back

/* add vars here */

ll x;

/* add your algorithm here */

int main() {
  cin >> x;

  ll ans = x / 11;
  ans *= 2;
  int a = x % 11;
  if (a != 0) {
    if (a > 6)
      ans += 2;
    else
      ans += 1;
  }

  cout << ans << endl;
}


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

int main(){
  int A,B;
  cin >> A >> B;
  if((A%3==0)||(B%3==0)||((A+B)%3==0)){
    cout << "Possible" << endl;
  }else{
    cout << "Impossible" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fr(x,i,n) for(int x = i; x < n; ++x)
#define fb(x,i,n) for(int x = i; x >= n; --x)
#define pr pair<int,int>
#define ll long long int
#define ull unsigned long long int
//const int mod=1e9+7;
const ll inf=1LL<<32;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    vector<ull> v;
    fr(i,1,10)
    v.push_back(i);
    int i=0;
    ll x;
    while(v.size()<1e6){
        x=v[i];
        if(x%10==0){
            v.push_back(x*10);
            v.push_back(x*10+1);
        }
        else if(x%10==9){
            v.push_back(x*10+9);
            v.push_back(x*10+8);
        }
        else{
            v.push_back(x*10+x%10-1);
            v.push_back(x*10+x%10);
            v.push_back(x*10+x%10+1);
        }
        i++;
    }
    sort(v.begin(),v.end());
//    cout<<v[99999];

    int k;
    cin>>k;
    cout<<v[k-1];

}


Measured memory_bytes: 10604
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] line = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int A = line[0];
            int B = line[1];
            if (A + B < 10)
            {
                Console.WriteLine(A + B);
            }
            else
            {
                Console.WriteLine("error");
            }
        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define ri register int
#define forn(i, n) for(int i = 1; i <= (n); i++)
typedef long long ll;
using namespace std;
/* Template_In_Programming_Contest */

void rd(int& u) {scanf("%d", &u);}
void rd2(int& u, int& v) {scanf("%d%d", &u, &v);}
void rd3(int& u, int& v, int& w) {scanf("%d%d%d", &u, &v, &w);}
void ptn(int u) {printf("%d\n", u);}
void pte(int u) {printf("%d ", u);}

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int , int> pii;
typedef pair <ll , ll> pll;
typedef vector <int> vi;

int n, m;
int main(){
	cin >> n >> m;
	cout << max(n - 2 * m, 0) << endl;
	return 0;
}




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

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

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main(void){
	int a[3];
	int n;
	for(int i=0; i<3; i++){
		cin >> a[i];
	}
	cin >> n;
	sort(a,a+3);
	cout << pow(2,n)*a[2]+a[1]+a[0] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
pair< int, int > rec(int X, int Y, int Step){
  if(Y == 0) return(make_pair(X, Step));
  else return(rec(Y, X % Y, Step + 1));
}
int main(){
  int X, Y;
  while(cin >> X >> Y, X|Y) {
    pair< int, int > ret = rec(max(X, Y), min(X, Y), 0);
    cout << ret.first << " " << ret.second << endl;
  }
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int a[3][3];
int main() {
  rep(i,3)rep(j,3){
    cin >> a[i][j]; 
  }
  int n;
  cin >> n;
  rep(i,n){
    int b;
    cin >> b;
    rep(i,3){
      rep(j,3){
        if(a[i][j] == b) a[i][j] = 0;
      }
    }
  }
  int isBingo = false;
  rep(i,3){
    if(a[i][0] == 0 && a[i][1] == 0 && a[i][2] == 0) isBingo = true;
    if(a[0][i] == 0 && a[1][i] == 0 && a[2][i] == 0) isBingo = true;
  }
  if(a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0) isBingo = true;
  if(a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0) isBingo = true;
  if(isBingo)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
// #include <cassert>
#include <vector>
#include <algorithm>
#include <climits>


// #include <deque>
// #include <stack>
// #include <set>
// #include <map>
// #include <string>
// #include <unordered_set>
// #include <unordered_map>
// #include <queue>
// #include <tuple>

// #include <cmath>
// #include <numeric>

using namespace std;
typedef long long ll;
typedef long l;
typedef pair<long,long> pll;
typedef pair<int,int> pii;
typedef pair<int,long> pil;
typedef pair<long,int> pli;
const char el = '\n';

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

    ll n,a,b;
    cin>>n>>a>>b;
    cin.ignore();

    ll portion1 = n/(a+b);

    portion1 *= a;

    ll mod = n%(a+b);

    ll portion2=0;
    portion2 = min(mod,a);

    cout<<portion1+portion2<<el;
    
    // long n, m;
    // cin>>n>>m; cin.ignore();

}



Measured memory_bytes: 256
# D - Friend Suggestions
from collections import Counter
N,M,K = map(int,input().split())
AB = [tuple(map(int,input().split())) for i in range(M)]
CD = [tuple(map(int,input().split())) for i in range(K)]

class UnionFind:
    def __init__(self,N):
        self.parent = [i for i in range(N)]
        self.rank = [0] * N
        self.count = 0
    def root(self,a):
        if self.parent[a] == a:
            return a
        else:
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    def is_same(self,a,b):
        return self.root(a) == self.root(b)
    def unite(self,a,b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return
        if self.rank[ra] < self.rank[rb]:
            self.parent[ra] = rb
        else:
            self.parent[rb] = ra
            if self.rank[ra] == self.rank[rb]: self.rank[ra] += 1
        self.count += 1

blocks = [[] for _ in range(N)]
for c,d in CD:
    c,d = c-1,d-1
    blocks[c].append(d)
    blocks[d].append(c)

friends = [0] * N
uf = UnionFind(N)
for a,b in AB:
    a,b = a-1,b-1
    friends[a] += 1
    friends[b] += 1
    if uf.is_same(a,b): continue
    uf.unite(a,b)
for i in range(N):
    uf.root(i)

ctr = Counter()
for i in range(N):
    r = uf.root(i)
    ctr[r] += 1

ans = []
for i in range(N):
    tmp = ctr[uf.root(i)] - 1 - friends[i]
    for b in blocks[i]:
        if uf.is_same(i,b):
            tmp -= 1
    ans.append(tmp)
print(*ans)


Measured memory_bytes: 63988
#include<stdio.h>
int main(){
  int h , m ,s;
  int t,k;
  scanf("%d",&t);
  h=t/3600;
  k=t%3600;
  m=k/60;
  s=k%60;
  printf("%d:%d:%d\n",h,m,s);
  return 0;
}

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

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

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

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

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


ll f(ll a, ll b) {
    string as = to_string(a);
    string bs = to_string(b);
    return max(as.size(), bs.size());
}

int main()
{
    ll n;
    cin >> n;
    ll res = INF;
    for(ll i=1; i<=sqrt(n); ++i) {
        ll a = i;
        if(n%a!=0.0) continue;
        ll b = n/a;
        res = min(res, f(a, b));
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int k,ans,idx;
  bool t = false;
  cin >> s >> k;
  for(int i=0;i<s.size();i++){
    int a = s.at(i);
    if(a !='1'){
      ans = a-'0';
      idx = i+1;
      t = true;
      break;
    }
  }
  if(t && k >= idx) cout << ans << endl;
  else cout << 1 << endl;
}
      

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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  while(true){
    LL n;
    cin >> n;
    if(n==0){
      break;
    }

    bool left = false;
    bool right = false;

    LL cnt = 0;
    
    REP(i,n){
      string s;
      cin>>s;
      if(s[0]=='l'){
        left = !left;
      }
      else
      {
        right = !right;
      }
      if(cnt%2==0){
        if(left&&right){
          cnt++;
        }
      }else{
        if(!left&&!right){
          cnt++;
        }
      }
    }
    cout << cnt << endl;
  }
}



Measured memory_bytes: 3132
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main(void) {
  long double x1, x2, y1, y2;
  long double d;
  cin >> x1 >> y1 >> x2 >> y2;
  d = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  cout << std::setprecision(11) << d << endl;
  return 0;
}



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

typedef long long ll;
const int maxn=1e6+7;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=1e9+7;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#define int ll
//#define endl '\n'

int32_t main()
{
    IOS
    int n,d;
    cin>>n>>d;
    cout<<(n+2*d)/(2*d+1)<<endl;
}



Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	var s string
	var k int
	fmt.Scan(&s)
	fmt.Scan(&k)

	sum := 0
	for _, ss := range s {
		if string(ss) == "1" {
			sum++
		} else {
			break
		}
	}

	if sum >= k {
		fmt.Println(1)
	} else {
		fmt.Println(string(s[sum]))
	}

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep2(i,m,n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i,n) rep2(i,0,n)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using ll = long long;
template <typename T>
T sq(T x){
  return x * x;
}

signed main (){
  ll N,M,L;
  ll A,B,C;
  string s ,t;
  vector<ll> v(10);
  vector<vector<ll>> vv(10,vector<ll>(10));

cin >> s >> t;  
rep(i,SZ(s)){
if (s.at(i) != t.at(i)){
cout << "No" << endl;
return 0;
}
}
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=998244353;
inline int add(int a,int b){a+=b;return a>=mod?a-mod:a;}
inline int sub(int a,int b){a-=b;return a<0?a+mod:a;}
inline int mul(int a,int b){return (ll)a*b%mod;}
inline int qpow(int a,int b){int ret=1;for(;b;b>>=1,a=mul(a,a))if(b&1)ret=mul(ret,a);return ret;}
const int inv2=qpow(2,mod-2);
/* math */
int n,s;
inline void FWT(int *t,int n,int type){//xor
	for(int step=1;step<n;step<<=1)
		for(int i=0;i<n;i+=step<<1)
			for(int j=0;j<step;j++){
				int x=t[i+j],y=t[i+j+step];
				t[i+j]=add(x,y),t[i+j+step]=sub(x,y);
				if(type==-1)t[i+j]=mul(t[i+j],inv2),t[i+j+step]=mul(t[i+j+step],inv2);
			}
}
const int N=1<<18;
int p[N],a[N];

int main()
{
	cin >> n;
	for(int i=0;i<1<<n;i++)scanf("%d",&p[i]),s=add(s,p[i]);
	s=qpow(s,mod-2);for(int i=0;i<1<<n;i++)p[i]=mul(p[i],s);
	for(int i=1;i<1<<n;i++)a[i]=mod-1;a[0]=(1<<n)-1;
	p[0]=sub(p[0],1);
	FWT(a,1<<n,1),FWT(p,1<<n,1);
	for(int i=0;i<1<<n;i++)a[i]=mul(a[i],qpow(p[i],mod-2));
	FWT(a,1<<n,-1);
	for(int i=0;i<1<<n;i++){
		printf("%d\n",sub(a[i],a[0]));
	}
}

Measured memory_bytes: 4864
import sys
sys.setrecursionlimit(20000000)
#input = sys.stdin.readline
n,m = map(int,input().split())
ans = []
class UnionFind():
    def __init__(self,size):
        self.table = [-1 for _  in range(size)]
    def find(self,x):
        while self.table[x] >= 0:
            x = self.table[x]
        return x

    def union(self,x,y):
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 != s2:
            if self.table[s1] != self.table[s2]:
                if self.table[s1] < self.table[s2]:
                    self.table[s2] = s1
                else:
                    self.table[s1] = s2
            else:
                self.table[s1] += -1
                self.table[s2] = s1
        return
Uni = UnionFind(n)
for i in range(m):
    x,y,z = map(int,input().split())
    x-=1;y-=1
    Uni.union(x,y)

for i in range(n):
    ans.append(Uni.find(i))
print(len(set(ans)))

Measured memory_bytes: 62368
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

//1-indexedに注意！！！
struct BIT{
    private:
    int n;
    vector<long long> bit;

    public:
    BIT(int n):n(n){
        bit.resize(n+1);
    }

    long long sum(int i){
        long long res = 0;
        while(i > 0){
                res += bit[i];
                i -= i&-i;
        }
        return res;
    }

    void add(int i,long long val){
        while(i <= n){
                bit[i] += val;
                i += i&-i;
        }
    }
};

int main(){
    int n;
    cin >> n;
    ll k;
    cin >> k;
    vector<ll> a(n),left(n+1),right(n+1);
    rep(i,n) cin >> a[i];
    rep(i,n) a[i] -= k;
    for(int i=n-1;i>=0;i--) left[i] = left[i+1] + a[i];
    for(int i=0;i<n;i++) right[i+1] = right[i] + a[i];
    ll all = right[n];
    vector<pll> lefter(n+1);
    rep(i,n+1) lefter[i] = pll(left[i],i);
    sort(lefter.begin(),lefter.end());
    vector<ll> order(n+1);
    rep(i,n+1) order[lefter[i].second] = i;

    /*
    rep(i,n+1) cout << lefter[i].second << " " ;
    cout << endl;
    rep(i,n+1) cout << order[i] << " " ;
    cout << endl;
    */

    BIT bit(n+1);
    ll ans = 0;
    for(int i=n;i>=0;i--){
        int l = -1,r = n+1;
        while(r - l > 1){
            int m = (l + r)/2;
            if(right[i]+lefter[m].first<=all) l = m;
            else r = m;
        }
        //cout << l << endl;
        ans += bit.sum(r);
        //cout << "#" << bit.sum(r) << endl;
        bit.add(order[i]+1,1);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main() {
	int h, w; cin >> h >> w;
	vector<vector<char> > grid(h, vector<char>(w));
	vector<bool> xflag(h), yflag(w);
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			cin >> grid[i][j];
			if (grid[i][j] == '#') xflag[i] = yflag[j] = true;
		}
	}
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			if (xflag[i] && yflag[j]) cout << grid[i][j];
		}
		if (xflag[i]) cout << endl;
	}


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{ int n;
    cin >> n;
    float arr[n];
    for(int i=0;i<n;i++)
    {
      cin >> arr[i];
    }
  sort(arr,arr+n);
  float ans =arr[0];
  for(int i=1;i<n;i++)
      ans = (ans+arr[i])/2;
  cout << ans << endl;
     return 0;
    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, M;
    cin >> N >> M;
    for (int i = 0; i < M; i++)
    {
        int time;
        cin >> time;
        N -= time;
        if (N < 0)
        {
            N = -1;
            break;
        }
    }
    cout << N << endl;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define mt make_tuple
#define INF 2000000000
#define INFL 1000000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
typedef pair<int, pair<int, int> > Edge;
typedef vector<Edge> vE;
typedef priority_queue<Edge, vector<Edge>, greater<Edge> > pqlE;

int B = 0, W = 1, E = 2;
int dist = 0;
int N;
vvi G;
vb used;
vi col;

bool dfs(int pos, int par, int depth) {
	if (pos == N - 1) {
		dist = depth;
		return true;
	}
	bool flag = false;
	rep(i, G[pos].size()) {
		if (G[pos][i] == par)continue;
		flag = flag || dfs(G[pos][i], pos, depth + 1);
	}
	if (flag){
		if (depth <= dist / 2) {
			col[pos] = B;
		}
		else {
			col[pos] = W;
		}
	}
	return flag;
}

int main() {
	cin >> N;
	G = vvi(N);
	int bnum = 0;
	used = vb(N, false);
	used[0] = used[N - 1] = true;

	col = vi(N, E);
	col[0] = B;
	col[N - 1] = W;

	rep(i, N - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	dfs(0, -1, 0);

	queue<pair<int, int>> Q;
	rep(i, N) {
		if (col[i] != E) {
			Q.push(mp(i, col[i]));
		}
	}
	while (!Q.empty()) {
		int pos = Q.front().first;
		int c = Q.front().second;
		Q.pop();
		rep(i, G[pos].size()) {
			if (col[G[pos][i]] != E)continue;
			Q.push(mp(G[pos][i], c));
			col[G[pos][i]] = c;
		}
	}

	rep(i, N) {
		if (col[i] == B)bnum++;

		//cout << col[i] << " ";
	}


	if (bnum > N - bnum) {
		cout << "Fennec" << endl;
	}
	else {
		cout << "Snuke" << endl;
	}

	return 0;
}

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

int main() {
  char a;
  bool iscap = true;
  vector<char> cap = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
  cin >> a;
  for (int i = 0; i < 26 ; i++) {
    if (a == cap.at(i)) {
      cout << 'a' << endl;
      iscap = false;
      break;
    }
  }
  if (iscap == true) {
    cout << 'A' << endl;
  }
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int INF = 0x3f3f3f3f;
const int N = 2e5 + 10;
const ll mod = 998244353;
bool g;
int main() {
	for (int i = 0; i < 3; i++) {
		char c;
		cin >> c;
		if (c == '7')g = 1;
	}
	puts(g ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 3624
using System;
using System.Linq;
public class Test
{
	public static void Main()
	{
		int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
		
		if((x[0]<x[1])&&(x[1]<x[2]))Console.WriteLine("Yes");
		else Console.WriteLine("No");
		
	}
}



Measured memory_bytes: 18416
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)

/* exchange */
#define chmin(a, b) (a) = min((ll)(a), (ll)(b))
#define chmax(a, b) (a) = max((ll)(a), (ll)(b))

/* output */
#define I(x) cin >> x;
#define D(x) cerr << (x) << " ";
#define BR cerr << "\n";
#define P(x) cout << (x) << endl;
#define FIX cout << fixed << setprecision(10);

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

struct UnionFind {

  vector<ll> parent;
  vector<ll> cnt;

  UnionFind(ll N) {
    parent.resize(N);
    cnt.resize(N);
    REP(i, N) {
      parent[i] = i;
      cnt[i] = 1;
    }
  }

  ll root(ll i) {
    if (parent[i] == i) return i;
    else return parent[i] = root(parent[i]);
  }

  void unite(ll x, ll y) {
    ll rx = root(x);
    ll ry = root(y);
    if (rx != ry) {
      parent[rx] = ry;
      cnt[ry] += cnt[rx];
    }
  }

  bool same(ll x, ll y) {
    return root(x) == root(y);
  }

  ll size(ll x) {
    return cnt[root(x)];
  }

  vector<ll> member(ll x) {
    vector<ll> v;
    ll r = root(x);
    REP(i, parent.size()) {
      if (r == root(i)) v.pb(i);
    }
    return move(v);
  }
};

ll N = 0;
ll M = 0;
ll ret = 0;

int main(void){
  
  I(N);
  I(M);
  UnionFind uf(N);
  REP(i, M) {
    ll x, y, z;
    I(x);
    I(y);
    I(z);
    uf.unite(x-1, y-1);
  }

  vl root(N, -1);
  FOR(i, 0, N) {
    if (root[uf.root(i)] == -1) {
      ret++;
      root[uf.root(i)] = 1;
    }
  }

  P(ret);

}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int main(){
    int n;
    cin >> n;
    vector<ll> data(n);
    int minus_cnt = 0;
    ll sum = 0;
    rep(i,0,n){
        ll num;
        cin >>num;
        data[i]=abs(num);
        if(num<-1){
            minus_cnt++;
        }
        sum += abs(data[i]);
    }
    sort(data.begin(),data.end());
    if(minus_cnt%2==1){
        sum-=abs(data[0])*2;
    }
    cout<<sum<<endl;
    
    return 0;
}


Measured memory_bytes: 4060
a,b,c = map(int,input().split())
k = int(input())

need1=0
need2=0
while True:
    if a>=b:
        b *=2
        need1+=1
    else:
        break

while True:
    if b>=c:
        c *=2
        need2+=1
    else:
        break

ans = need1 + need2

if k>=ans:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9188
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: String
    }
    println!("{}", s.replace("2017","2018"));
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

string s;

int main() {
    cin >> s;
    if (s[0] == s[1] && s[1] == s[2]) {
        cout << "Yes" << endl;
    } else if (s[1] == s[2] && s[2] == s[3]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256