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

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define llrp(i,n) for(long long i=0;i<n;i++)
#define llrep(i,m,n) for(long long i=m;i<=n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if
#define vcin(a); rp(i,a.size()){cin>>a[i];}
#define vcout(a); rp(i,a.size()){cout<<a[i]<<endl;}
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef string S;
typedef pair<int,int> P;

bool isOK(int index, int key,vi a) {
    if (a[index] >= key) return true;
    else return false;
}

int binary_search(int key,vi a) {
    int left = -1;
    int right = (int)a.size();
    while (right - left > 1) {
        int mid = left + (right - left) / 2;
        
        if (isOK(mid, key,a)) right = mid;
        else left = mid;
    }
    return right;
}

int modpow(int a,int b,int p){
    if(b==0){
        return 1;
    }elif(b%2==0){
        return modpow((a*a)%p,b/2,p);
    }else{
        return (a*modpow(a,b-1,p))%p;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vll a(n),b(n);
    llrp(i,n){
        cin >> a[i] >> b[i];
    }
    ll plus=0;
    rp(i,n){
        plus+=((a[n-1-i]+plus)%b[n-1-i]?(1+(a[n-1-i]+plus)/b[n-1-i])*b[n-1-i]-(a[n-1-i]+plus):0);
    }
    cout << plus << endl;
    return 0;
}


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

#include <fstream>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  /*
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
  //*/
  int N;
  long double T, A;
  cin >> N >> T >> A;
  long double minn = 99999999;
  int ans = 0;
  for(int i = 0; i < N; i++){
    long double x;
    cin >> x;
    long double tmp = T - x * 0.006;
    if(abs(A-tmp) < minn){
    ans = i + 1;
    minn = abs(A - tmp);
    }
  }
  cout << ans <<endl;
}


Measured memory_bytes: 3748
/*
ID: wangjun30
TASK:
LANG: C++
*/
#include<iostream>
using namespace std;
int dp[int(1e6)];
int broke[int(1e6)];
int MOD=1e9+7;
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int x;
		cin>>x;
		broke[x]=true;
	}
	if((n==1 && broke[1]) || (broke[1] && broke[2])){
		cout<<0;
		return 0;
	}
	if(n==1){
		cout<<1;
		return 0;
	}
	dp[1]=broke[1]^1;
	dp[0]=1;
	for(int i=2;i<=n+5;i++){
		if(broke[i])
			continue;
		dp[i]=(dp[i-2]+dp[i-1])%MOD;
	}
	cout<<dp[n];
	return 0;
}

Measured memory_bytes: 4736
var toInt = x=>parseInt(x,10);
var toIntArr = arr=>arr.map(x=>toInt(x));
var abs = x=>x>0?x:-x;
function min(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]<val)val = rest[i];return val}
function max(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]>val)val = rest[i];return val}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
 
function Main(input){
	var input = input.split('\n');
	input = input.map(e => toIntArr(e.split(' ')));
	var n = input[0][0];
	var k = input[0][1];
	var hs = [];
	for(var i = 0; i < n; i++){
		hs[i] = input[i+1][0];
	}
	hs.sort((a,b)=>a-b);
	var ans = hs[k-1] - hs[0];
	//console.log(hs);
	for(var i = 1; i < n-k+1; i++){
		ans = min(ans,hs[k-1+i] - hs[i]);
		//console.log(k+i-1,i,ans);
	}
	
	console.log(ans);
}

Measured memory_bytes: 51016
using System;

class ABC_127_A
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int A = int.Parse(input[0]);
        int B = int.Parse(input[1]);

        if(A<=5) Console.WriteLine("0");
        else if (A <= 12) Console.WriteLine(B/2);
        else Console.WriteLine(B);
    }
}

Measured memory_bytes: 13140
n = int(input())
a_list = list(map(int,input().split()))
b_list = list(map(int,input().split()))
c_list = list(map(int,input().split()))

res = sum(b_list)

for i in range(n-1):
    if a_list[i+1]-a_list[i]==1:
        res += c_list[a_list[i]-1]
print(res)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
    int64_t N;

    cin >> N;

    int64_t k;
// cout << "f4" << endl;
    int64_t sum = 0;
    for ( int64_t i = 1; i <= N; i ++ ) { 
        // cout << i << endl;
        {
            // iの倍数でN以下のものの総和を等差数列で計算
            int64_t d = i;
            while ( d <= N ) {
                sum += d;
        //         cout << " " << i << " add " << d << endl;
                d += i;
            }

        }
    }

    cout << sum << endl;

  	return 0;
}



Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //10^19 < 9223372036854775807
typedef unsigned long long ull; //10^20 < 18446744073709551615

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 

#define MOD 1000000007


string ans = "";

string dog(ll N) {
    if (N > 0) {
        N -= 1;
        ans += ('a'+ N%26);
        N /= 26;
        return dog(N);
   }

    reverse(ALL(ans));
    return ans;
}

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

    cout << dog(N) << endl;

    return 0;
}


Measured memory_bytes: 3632
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int[] a=new int[1];
    int[] b=new int[1];
    a[0]=sc.nextInt();
    b[0]=sc.nextInt();
    int kari=b[0];
    while(kari!=0){
      a[0]*=10;
      kari/=10;
    }
    double kari2=a[0]+b[0];
    double kari3=Math.sqrt(kari2);
    if((int)kari2==(int)kari3*(int)kari3) System.out.println("Yes");
    else System.out.println("No");
  }
}

Measured memory_bytes: 21716
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
typedef long long int ll;
using namespace std;
#define P 1000000007
#define rep(i,n) for(i=0;i<n;++i)
#define repp(i,a,n) for(i=a;i<n;++i)
#define repr(i,a,n) for(i=a;i>=n;--i)

ll binpowmod(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

ll modInverse(ll n, ll p)
{
    return binpowmod(n, p-2, p);
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,f,t,j;
    cin >> n;
    double p[n+1],temp;
    repp(i,1,n+1) cin >> p[i] ;
    
    double dp[n+1][n+1];//getting j heads in first i coins
    dp[0][0]=1;
    rep(i,n+1)
    {
        rep(j,i+1)
        {
            if(i==0&&j==0) 
            {
                dp[i][j]=1;
                break;
            }
            if(j==0) dp[i][0]=dp[i-1][0]*(1-p[i]);
            else
            {
                dp[i][j]=dp[i-1][j-1]*p[i]+dp[i-1][j]*(1-p[i]);
            }
            //cout << i << " " << j << " " << dp[i][j] << endl ;  
        }
    }
    double ans=0;
    repp(i,n/2+1,n+1)
    {
        ans+=dp[n][i];
    }
    cout << fixed << setprecision(9) << ans ;
    return 0;
}

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

using ll=long long;
#define int ll

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

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

signed main(){
	// your code goes here
	int N=read();
	int T[N];
	REP(i,N) T[i]=read();
	int M=read();
	int P[M],X[M];
	REP(i,M){
		P[i]=read();
		X[i]=read();
	}
	
	REP(i,M){
		int time=0;
		REP(j,N){
			if(P[i]-1==j) time+=X[i];
			else time+=T[j];
		}
		cout << time << endl;
	}
}

Measured memory_bytes: 256
fn main() {
	proconio::input!{
		x: usize,
		y: usize,
	}

	let g1 = [1usize, 3, 5, 7, 8, 10, 12];
	let g2 = [4usize, 6, 9, 11];

	if x == y {
		println!("Yes");
		return;
	}

	match g1.binary_search(&x) {
		Ok(_) => {
			match g1.binary_search(&y) {
				Ok(_) => {
					println!("Yes");
					return;
				},
				_ => (),
			}
		},
		_ => (),		
	}

	match g2.binary_search(&x) {
		Ok(_) => {
			match g2.binary_search(&y) {
				Ok(_) => {
					println!("Yes");
					return;
				},
				_ => (),
			}
		},
		_ => (),		
	}
	println!("No");
}



Measured memory_bytes: 2060
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	string s;
  	cin >> s;
  	vi cnt(4,0);
  	rep(i,4){
      	rep(j,4){
    		if(s[i] == s[j]) cnt[j]++;
        }
    }
  	rep(i,4) {
    	if(cnt[i] != 2) {
      		puts("No");
        	return;
      	}
    }
  	puts("Yes");
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <functional>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <string>

using namespace std;

typedef long long ll;

#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--)

int const H_MAX = 100000;
ll const MOD = 1e9 + 7;

int A, B, H, W;
ll pow[2 * H_MAX + 1];

ll mod_pow(ll x, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % MOD;
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}

ll mod_inv (ll x) {
  return mod_pow(x, MOD - 2) % MOD;
}

ll comb(int n, int r) {
  return (((pow[n] * mod_inv(pow[r])) % MOD) * mod_inv(pow[n - r])) % MOD;
}

int main() {
  scanf("%d %d %d %d", &H, &W, &A, &B);

  pow[0] = 1;
  FOR(i, 1, H + W + 1) {
    pow[i] = (pow[i - 1] * i) % MOD;
  }

  ll count = 0;
  rep(i, W - B) {
    int x = B + i;
    int y = H - A - 1;
    ll res1 = comb(x + y, x);

    int y0 = y + 1;
    int dx = W - 1 - x;
    int dy = H - 1 - y0;
    ll res2 = comb(dx + dy, dx);

    ll res = res1 * res2 % MOD;
    count += res;
    count %= MOD;
  }
  printf("%lld\n", count);
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const int vx[]={1,0,-1,0}, vy[]={0,1,0,-1};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
const int sqrtN = 512;

struct SqrtDecomposition{
	vector<int> data;
	vector<int> bucketSum;
	int N, K;
	
	SqrtDecomposition(int n) : N(n){
		K = (N + sqrtN - 1) / sqrtN;
		data.assign(K * sqrtN, 0);
		bucketSum.assign(K, 0);
	}
	
	void add(int k, int x){
		data[k] += x;
		k = k / sqrtN;
		
		int sum = 0;
		for(int i = k * sqrtN; i < (k + 1) * sqrtN; i++){
			sum += data[i];
		}
		
		bucketSum[k] = sum;
	}
	
	int get(int a, int b){
		int sum = 0;
		for(int k = 0; k < K; k++){
			int l = k * sqrtN, r = (k + 1) * sqrtN;
			
			if(b<=l||r<=a) continue;
			if(a<=l&&r<=b) sum += bucketSum[k];
			else{
				for(int i = max(a, l); i < min(b, r); i++){
					sum += data[i];
				}
			}
		}
		
		return sum;
	}
};

int main(){
	int n,q; cin >> n >> q;
	SqrtDecomposition data(n);
	REP(i,0,q){
		int a,b,c; cin >> a >> b >> c;
		
		if(a == 0) data.add(b, c);
		else if(a == 1) cout << data.get(b, c + 1) << endl;
	}

	return 0;
}



Measured memory_bytes: 3124
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>
#include <iterator>


using namespace std;

using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;

#define index_of(as, x) distance(as.begin(), upper_bound(as.begin(), as.end(), x))

vector<int> lis_fast(const vector<int>& a) {
	const int n = a.size();
	vector<int> A(n, INF);
	vector<int> id(n);
	for (int i = 0; i < n; ++i) {
		id[i] = index_of(A, a[i]);
		A[id[i]] = a[i];
	}
	int m = *max_element(id.begin(), id.end());
	vector<int> b(m + 1);
	for (int i = n - 1; i >= 0; --i)
		if (id[i] == m) b[m--] = a[i];
	return b;
}

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

	vector<int> a(n);

	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	reverse(a.begin(), a.end());

	cout << lis_fast(a).size() << endl;



	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define f0(i,n) for(int i=0;i<n;i++)
#define f1(i,n) for(int i=1;i<=n;i++)
#define f2(i,a,b) for(int i=a;i<=b;i++)
#define sp <<" "                // giving space
#define sp1 <<" "<<              // giving space between two elements
                 // new line
#define M 1000000007              // for mod
#define ll long long
#define ld long double
#define vii vector <pair<int,int>>
#define vll vector <pair<ll,ll>>
#define vi vector <int>
#define vl vector <ll>
#define pb(v,x) v.push_back(x)
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define Sort(v) sort(v.begin(),v.end())
using namespace std;
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#include <set>
#include <map>


int main()
{
	ll n,k,sum=0;
	cin>>n>>k;
	vl v(n);
	f0(i,n)
	cin>>v[i];
	sort(v.begin(),v.end());
	for(int i=0;i<(n-k);i++)
		sum+=v[i];
	cout<<sum;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <climits>
using namespace std;

int main(){

    int K, N;
    cin >> K >> N;


    vector<int> dis(N);
    for (auto& val : dis)
        cin >> val;


    int maximum = INT_MIN;
    for (int i = 1; i < N; i++)
        maximum = max(maximum, dis[i]-dis[i-1]);
    maximum = max(maximum, K-dis[N-1]+dis[0]);

    cout << K-maximum << endl;

    return 0;
}


Measured memory_bytes: 1024
import sys
import math
sys.setrecursionlimit(10**9)

def main():
    X = int(input())

    def search(y):
        left = -10**18
        right = 10**18

        while right - left > 1:
            mid = (right+left)//2

            if mid**5 < y:
                left = mid
            else:
                right = mid

        return right

    for b in range(-1000,1000):
        y = X+b**5
        a = search(y)

        if a**5-b**5 == X:
            print(a,b)
            exit()




if __name__ == "__main__":
  main()


Measured memory_bytes: 67764
n=int(input())
v=input().split()

m=[{"even":0},{"odd":0}]

for i in range(0, len(v)):
	if v[i] not in m[i%2]:
		m[i%2][v[i]] = 1
	else:
		m[i%2][v[i]] += 1

l = [sorted(z.items(), key=lambda x: x[1], reverse=True) for z in m]

if l[0][0][0] == l[1][0][0]:
	print(min(n-l[0][0][1]-l[1][1][1], n-l[0][1][1]-l[1][0][1]))
else:
	print(n-l[0][0][1]-l[1][0][1])


Measured memory_bytes: 23268
#include <bits/stdc++.h>
using namespace std;
int n, X, dp[301][301][301];
string s;
int main(){
    cin>>s>>X;n=s.size();    
    for (int i=0; i<n; i++)
		for (int x=0; x<=X; x++)dp[x][i][i]=1;
	for (int x=0; x<=X; x++)
		for (int k=1; k<n; k++)
			for (int l=0, r=k; l+k<n; l++, r=l+k)
				dp[x][l][r]=max(max(dp[x][l][r-1], dp[x][l+1][r]),
							dp[max(x-min(1,abs(s[l]-s[r])), 0)][l+1][r-1]+
							2*min(1, (min(1, x)+(1-min(1,abs(s[l]-s[r]))))));
    cout<<dp[X][0][n-1]<<endl;
    return 0;
}

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

#define MAX 1000000000

int main(void){
    long long N, K;
    vector<long long> A;
    int a;

    cin >> N >> K;
    for(int i = 0; i < N; ++i){
        cin >> a;
        A.push_back(a);
    }

    long long max = MAX + 1;
    long long min = 0;
    long long mid;
    int d, CountCut;
    while(max - min > 1){
        CountCut = 0;
        mid = (max + min) / 2;
        for(int i = 0; i < N; ++i){
            d = (A[i] +mid - 1) / mid - 1;
            if(d > 0) CountCut += d;
        }
        if (CountCut <= K) max = mid;
        else min = mid;
    }

    cout << max << endl;
}


Measured memory_bytes: 5352
#include <iostream>
#include <vector>
#include <stack>

constexpr int MAX_N=1e5+10;

int n,m;

std::vector<int> g[MAX_N];

bool b[MAX_N];

int main() {

    std::cin>>n>>m;

    for(int i=0;i<m;++i){
        int x,y,z;
        std::cin>>x>>y>>z;
        g[x].emplace_back(y);
        g[y].emplace_back(x);
    }

    int c=0;

    for(int i=1;i<=n;++i){
        if(!b[i]){
            ++c;
            std::stack<int> s;
            s.push(i);
            b[i]=1;
            while(!s.empty()){
                int x=s.top();
                s.pop();
                for(int j : g[x]){
                    if(!b[j]){
                        b[j]=1;s.push(j);
                        std::cerr<<j<<std::endl;
                    }
                }
            }
        }
    }

    std::cout<<c<<std::endl;

    return 0;
}

Measured memory_bytes: 6648
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main(void) {
    int n, t, a; cin >> n >> t >> a;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    double mi = 1e8;
    int ans = 0;
    rep(i, n) {
        double tmp = t - 0.006*h[i];
        if(a>0){
            if(mi > abs(a-tmp))
                mi = abs(a-tmp), ans = i;
        }else{
            if(mi > abs(tmp-a))
                mi = abs(tmp-a), ans = i;
        }
    }
    cout << ans + 1;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n, m;
int main(){
	scanf("%d%d", &n, &m);
	int cnt = 0;
	for(int i = 0, temp; i < m; ++i){
		scanf("%d", &temp);
		cnt += temp;
	}
	if(n - cnt < 0){
		printf("-1");
	}else{
		printf("%d", n - cnt);
	}
	return 0;
}


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

int main(){
  int h,w;
  cin >> h >> w;
  string s[h];
  int sum;
  for(int i=0;i<h;++i) {cin >> s[i];}
  for(int i=0;i<h;++i){
    for(int j=0;j<w;++j){
      if(s[i][j] == '.'){
        sum = 0;
        if(i>0 && j>0 && s[i-1][j-1] == '#') {sum++;}
        if(i>0 && s[i-1][j] == '#') {sum++;}
        if(i>0 && j<w-1 && s[i-1][j+1] == '#') {sum++;}
        if(j>0 && s[i][j-1] == '#') {sum++;}
        if(j<w-1 && s[i][j+1] == '#') {sum++;}
        if(i<h-1 && j>0 && s[i+1][j-1] == '#') {sum++;}
        if(i<h-1 && s[i+1][j] == '#') {sum++;}
        if(i<h-1 && j<w-1 && s[i+1][j+1] == '#') {sum++;}
        s[i][j] = '0'+sum;
      }
    }
    cout << s[i]+"\n";
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

#define MAX 500000
#define INFINITY 1000000000

int n;
int L[MAX/2+1], R[MAX/2+1];
int sum(0);

void Merge(int A[], int left, int mid, int right) {
    int n1 = mid-left;
    int n2 = right-mid;
    for ( int i = 0; i < n1; i++ ) {
        L[i] = A[ left + i ];
    }
    for ( int i = 0; i < n2; i++ ) {
        R[i] = A[ mid + i ];
    }
    L[n1] = INFINITY;
    R[n2] = INFINITY;
    int i = 0, j = 0;
    for ( int k = left; k < right; k++ ) {
        if(L[i] <= R[j]) {
            A[k] = L[i];
            i++;
            sum++;
        } else {
            A[k] = R[j];
            j++;
            sum++;
        }
    }
}


void mergeSort(int A[], int left, int right) {
    if ( left + 1 < right ) {
        int mid = ( left + right ) / 2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        Merge(A, left, mid, right);
    }
}


int main() {
    int A[MAX];
    
    scanf("%d", &n);
    for ( int i = 0; i < n; i++ ) {
        scanf("%d", &A[i]);
    }
    
    mergeSort(A, 0, n);
    for ( int i = 0; i < n; i++ ) {
        if (i) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n%d\n", sum);
    
    return 0;
}

Measured memory_bytes: 7056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//深さ優先探索
//全て添字で扱うこと
void dfs(ll n, vector<vll> &next, vll &cnt, ll start) {
  stack<ll> task;
  task.push(start);
  vll seen(n, 0);
  seen[start] = 1;
  while (task.size() > 0) {
    vll subtask(0);
    for (ll i = 0; i < next[task.top()].size(); i++) {
      if (seen[next[task.top()][i]] == 0) {
        cnt[next[task.top()][i]] += cnt[task.top()];
        subtask.push_back(next[task.top()][i]);
        seen[next[task.top()][i]] = 1;
      }
    }
    task.pop();
    for (ll i = 0; i < subtask.size(); i++) {
      task.push(subtask[i]);
    }
  }
  return;
}

int main() {
  ll n, q;
  cin >> n >> q;
  vll a(n - 1), b(n - 1);
  for (ll i = 0; i < n - 1; i++) cin >> a[i] >> b[i];
  vll p(q), x(q);
  for (ll i = 0; i < q; i++) cin >> p[i] >> x[i];
  vector<vll> next(n, vll(0));
  for (ll i = 0; i < n - 1; i++) {
    next[a[i] - 1].push_back(b[i] - 1);
    next[b[i] - 1].push_back(a[i] - 1);
  }
  vll cnt(n, 0);
  for (ll i = 0; i < q; i++) cnt[p[i] - 1] += x[i];
  dfs(n, next, cnt, 0);
  for (ll i = 0; i < n - 1; i++) cout << cnt[i] << " ";
  cout << cnt[n - 1] << endl;
}

Measured memory_bytes: 25328
import Control.Applicative
import Control.Monad as M

main :: IO ()
main = do
  [n, m, c] <- map read . words <$> getLine
  bs <- map read . words <$> getLine
  sources <- M.replicateM n $ map read . words <$> getLine
  putStrLn $ show (solve sources bs c)

solve :: [[Int]] -> [Int] -> Int -> Int
solve sources bs c = length $ filter (== True) $ map (calc bs c) sources

calc :: [Int] -> Int -> [Int] ->  Bool
calc bs c source
  | ((foldr (+) 0 $ zipWith (*) bs source) + c) > 0 = True
  | otherwise = False


Measured memory_bytes: 1020
import random
import time
import copy

def down_score(d, c, last_d, score):
    sum = 0
    for i in range(26):
        sum = sum + c[i]*(d-last_d[i])
        
    return int(score - sum)


def main():
    D = int(input())

    c = list(map(int, input().split()))

    s = [list(map(int, input().split())) for i in range(D)]

    start = time.time()
    
    last_d = [0 for i in range(26)]
    ans = []    
    score1 = 0
    
    for i in range(D):
        max = 0
        idx = 0
        for j in range(26):
            if max < (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] != 0:
                max = s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2
                idx = j
            elif max == (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] * (i-last_d[j])*(i-last_d[j]+1)/2 > c[idx]* (i-last_d[idx])*(i-last_d[idx]+1)/2 and c[j] != 0:
                idx = j
            
        last_d[idx] = i+1
        score1 += s[i][idx]
        score1 = down_score(i+1,c,last_d,score1)
        
        ans.append(idx)

    while time.time() - start < 1.9:
        cp = ans.copy()
        last_d = [0 for i in range(26)]
        score2 = 0  
        
        idx1 = random.randint(0,25)
        idx2 = random.randint(0,25)
        idx3 = random.randint(0,25)
        if random.randint(0,1):
            d1 = random.randint(0,D-1) 
            d2 = random.randint(0,D-1)
            d3 = random.randint(0,D-1)
            if idx1 == idx2 or idx1 == idx3 or idx2 == idx3:
                continue
            if random.randint(0,1):
                ans[d1] = idx1
            elif random.randint(0,1):
                ans[d1] = idx1
                ans[d2] = idx2
            else:
                ans[d1] = idx1
                ans[d2] = idx2
                ans[d3] = idx3
                                
        #2値入れ替え
        elif random.randint(0,1):           
            d1 = random.randint(0,D-8) 
            d2 = random.randint(d1+1,d1+7)
            tmp1 = ans[d1]
            tmp2 = ans[d2]
            if random.randint(0,1):
                ans[d1] = tmp2
                ans[d2] = tmp1
            
        #3値入れ替え          
        else:
            d1 = random.randint(0,D-11) 
            d2 = random.randint(d1+1,d1+5)
            d3 = random.randint(d2+1,d2+5) 
            tmp1 = ans[d1]
            tmp2 = ans[d2]
            tmp3 = ans[d3]
            if random.randint(0,1):
                ans[d1] = tmp2
                ans[d2] = tmp3
                ans[d3] = tmp1
            else:
                ans[d1] = tmp3
                ans[d2] = tmp1
                ans[d3] = tmp2
            
        for i in range(D):
            score2 += s[i][ans[i]]
            last_d[ans[i]] = i+1
            score2 = down_score(i+1, c, last_d, score2)
        
        if score1 > score2:
            ans = cp.copy()
        else:
            score1 = score2
    
    for i in range(D):
        print(ans[i]+1)  

if __name__ == "__main__":
    main()


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

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

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long
#define MAX_V

struct modint{
    using i64=int_fast64_t;
    i64 a;
    static constexpr i64 MOD=1000000007;
    modint(){a=0;}
    modint(i64 a_){
        a=a_%MOD;
        if(a<0) a+=MOD;
    }
    modint inv()const{
        i64 n=1,m=MOD-2,A=a;
        while(m){
            if(m&1)(n*=A)%=MOD;
            (A*=A)%=MOD;
            m>>=1;
        }
        modint y(n);
        return y;
    }
    bool operator==(const modint& x){
        return a==x.a;
    }
    bool operator!=(const modint& x){
        return a!=x.a;
    }
    modint& operator=(const modint& x){
        a=x.a;
        return *this;
    }
    modint operator+(const modint& x){
        modint y;
        y.a=a+x.a;
        if(y.a>MOD) y.a-=MOD;
        return y;
    }
    modint operator-(const modint& x){
        modint y;
        y.a=a-x.a;
        if(y.a<0) y.a+=MOD;
        return y;
    }
    modint operator*(const modint& x){
        modint y;
        y.a=(a*x.a)%MOD;
        return y;
    }
    modint operator/(const modint& x){
        modint y;
        y.a=(a*x.inv().a)%MOD;
        return y;
    }
    modint& operator+=(const modint& x){
        a+=x.a;
        if(a>=MOD) a-=MOD;
        return *this;
    }
    modint& operator-=(const modint& x){
        a-=x.a;
        if(a<0) a+=MOD;
        return *this;
    }
    modint& operator*=(const modint& x){
        (a*=x.a)%=MOD;
        return *this;
    }
    modint& operator/=(const modint& x){
        (a*=x.inv().a)%=MOD;
        return *this;
    }
};
istream& operator>>(istream &in,modint& x){
    int_fast64_t a_;
    in>>a_;
    modint y(a_);
    x=y;
    return in;
}
ostream& operator<<(ostream &out,const modint& x){
    out<<x.a;
    return out;
}
modint pwr(int_fast64_t a,int_fast64_t b){
    modint _;
    int_fast64_t n=1,A=a;
    while(b){
        if(b&1) (n*=A)%=modint::MOD;
        (A*=A)%=modint::MOD;
        b>>=1;
    }
    _.a=n;
    return _;
}

/* dp[i][j][k]: 上からi桁目まで(1-indexed)見たときNで割った余りがjになるもの && 
                kはN未満かそうでないか(ぴったり) の個数 */ 
modint dp[100001][100][2];


int main(){
    int D;
    string S;
    cin >> S >> D;

    int L = S.size();
    dp[0][0][0] = 1;

    REP(i, L) REP(j, D) REP(l, 10) {
        /* 未満から未満 */
        dp[i+1][(j+l) % D][1] += dp[i][j][1];

        /* ぴったりから未満 */
        if(l < S[i] - '0') {
            dp[i+1][(j+l) % D][1] += dp[i][j][0];
        }

        /* ぴったりからぴったり */
        if(l == S[i] - '0') {
            dp[i+1][(j+l) % D][0] += dp[i][j][0]; 
        }
    }

    cout << dp[L][0][1] + dp[L][0][0] - 1 << endl;
}

Measured memory_bytes: 156544
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <cstdlib>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	ll n, k; cin >> n >> k;
	if (k % 2 == 1)
	{
		ll d = n / k;
		cout << d * d*d << endl;
	}
	else
	{
		ll d = n / k;
		d = d * d*d;
		n += k / 2;
		ll e = n / k;
		d += e * e*e;
		cout << d << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>

using std::cin;
using std::cout;
using std::endl;

int main(void) {
	std::map<int,int> seq;
	int n,m;
	cin >> n >> m;
	for (int i = 1; i < n+1; i++) {
		seq[i] = i;
	}

	int now = 0;
	int num;
	for (int i = 0; i < m; i++) {
		cin >> num;
		seq[now] = num;
		now--;
	}

	std::vector<bool> check(n+1,false);
	int count = 0;
	for (int i = now+1; i < n+1 && count != n; i++) {
		num = seq[i];
		if ( !check[num] ) {
			cout << num << endl;
			count++;
			check[num] = true;
		}
	}

	return 0;
}

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

int main(void){
    string S;
    cin>>S;
    if(S=="RRR"){
        cout<<"3\n";
        return 0;
    }
    if(S=="RRS" || S=="SRR"){
        cout<<"2\n";
        return 0;
    }
    if(S=="RSS"||S=="SRS"||S=="SSR"||S=="RSR"){
        cout<<"1\n";
        return 0;
    }
    cout<<"0\n";
    return 0;
}

Measured memory_bytes: 3588
#include<stdio.h>
#include<math.h>

int main()
{
		double x1, y1, x2, y2;
		scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
		printf("%f", sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
		return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;
typedef pair<ll  ,ll > pll;

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

const ll maxn  = 3e6;
const ll mod =1e9+7;
const ld PI = 4 * atan((ld) 1);

#define pb(x) push_back(x);
#define endl '\n'
#define dominance true
#define dokme(x) cout << x ;  return(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
#define ms(x , y) memset(x , y , sizeof x);
ll pw(ll a, ll b, ll md = mod) {
    ll res = 1;while(b){if(b&1){res=(a*res)%mod;}a=(a*a)%mod;b>>=1;}return(res);
}

int n,k;
int dp[maxn][3];

int main(){
    migmig
    cin >> n;
    for (int i = 1 ; i <= n ; i ++){
        int a,b,c;
        cin >> dp[i][0] >> dp[i][1] >> dp[i][2];
        dp[i][0]+=max(dp[i-1][1] , dp[i-1][2]);
        dp[i][2]+=max(dp[i-1][1] , dp[i-1][0]);
        dp[i][1]+=max(dp[i-1][0] , dp[i-1][2]);
    }
    cout << max(dp[n][0] , max(dp[n][1] , dp[n][2]));
    return(0);
}

//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, life is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.
//It is important to draw wisdom from diffrent places. If you take it from only one place it becomes rigid and stale.
//kuxtal jach uts chuchul u u páajtal máak jach táaj meyajilo'ob le castigadas tumen ch'aik descansos.


Measured memory_bytes: 1408
fun main(args: Array<String>) {
        val input = read()
        println(otoshidama(input))
    }

    data class Inputs(val count: Int, val total: Int)
    data class Outputs(val yukichi: Int, val ichiyo: Int, val hideyo: Int) {
        override fun toString(): String {
            return "$yukichi $ichiyo $hideyo"
        }
    }

    fun read(): Inputs {
        val inputs = readLine()!!.split(' ').map { Integer.parseInt(it) }
        return Inputs(inputs[0], inputs[1])
    }

    fun otoshidama(inputs: Inputs): Outputs {
        (0..inputs.count).forEach { yukichi ->
            (0..inputs.count - yukichi).forEach { ichiyo ->
                val hideyo = inputs.count - yukichi - ichiyo
                val sum = yukichi * 10000 + ichiyo * 5000 + hideyo * 1000
                if (inputs.total == sum) return Outputs(yukichi, ichiyo, hideyo)
            }
        }
        return Outputs(-1, -1, -1)
    }

Measured memory_bytes: 38216
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s,p;
    cin>>s>>p;
    vector <vector <int> > dp(s.size()+1, vector <int>(p.size()+1,0));
    for(int i=0; i<s.size();i++){
        for(int j=0; j<p.size();j++){
            if(s[i]==p[j]){
                dp[i+1][j+1] = dp[i][j]+1;
            }
            else{
                dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
            }
        }
    }
    int longest = dp[s.size()][p.size()];
    string result ;
    int r = s.size();
    int c = p.size();
    int cnt = 0;
    while(cnt!=longest){
        if(s[r-1]==p[c-1]){
            result+=s[r-1];
            r=r-1;
            c=c-1;
            cnt++;
        }
        else{
            if(dp[r-1][c] >= dp[r][c-1] ){
                r = r-1;
            }
            else {
                c= c-1;
            }
        }
    }
    reverse(result.begin(), result.end());
    cout<<result<<endl;
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=3.14159265358979323846;
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n;
    ll k;
    cin>>n>>k;
    vector<ll> a(n);
    ll sum=0;
    rep(i,n) {
        cin>>a[i];
        sum+=a[i];
    }
    
    vector<ll> vec;
    FOR(d,1,sqrt(sum)+1) {
        if(sum%d==0) {
            vec.push_back(d);
            vec.push_back(sum/d);
        }
    }
    sort(all(vec),greater<ll>());
    
    for(ll d:vec) {
        vector<ll> r;
        rep(i,n) {
            if(a[i]%d!=0) r.push_back(a[i]%d);
        }
        sort(all(r));
        
        int m=sz(r);
        vector<ll> sums(m+1);
        rep(i,m) sums[i+1]=sums[i]+r[i];
        
        rep(i,m+1) {
            ll left=sums[i];
            ll right=d*(m-i)-(sums[m]-sums[i]);
            if(left<=k && right<=k) {
                cout<<d<<endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 10007LL;
template <typename T>
bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for(int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T>
vector<T> make_v(size_t a) {
    return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) {
    for(auto& e : t) {
        fill_v(e, v);
    }
};
vector<int> ans;
int n;
void f(int k, int a, int b, int vis, int bit) {
    int to = (1 << n) - 1;
    to ^= vis;
    if(k == 1) {
        for(int i = 0; i < n; i++) {
            if((to >> i) & 1) {
                if(a == 0) {
                    ans.push_back(bit);
                    ans.push_back(bit | (1 << i));
                } else {
                    ans.push_back(bit | (1 << i));
                    ans.push_back(bit);
                }
            }
        }
    } else {
        vector<int> v;
        for(int i = 0; i < n; i++) {
            if((to >> i) & 1) {
                v.push_back(i);
            }
        }
        int s = -1, na = 0, nb = 0, id;
        for(int i = 0; i < k; i++) {
            if(((a ^ b) & (1 << i)) && s == -1) {
                s = v[i];
                id = i;
            } else {
                if(s == -1) {
                    na |= a & (1 << i);
                    nb |= b & (1 << i);
                } else {
                    if((a >> i) & 1) {
                        na |= (1 << (i - 1));
                    }
                    if((b >> i) & 1) {
                        nb |= (1 << (i - 1));
                    }
                }
            }
        }
        f(k - 1, na, na ^ 1, vis | (1 << s), bit | (((a >> id) & 1) << s));
        f(k - 1, na ^ 1, nb, vis | (1 << s), bit | (((b >> id) & 1) << s));
    }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> n >> a >> b;
    int c = 0;
    for(int i = 0; i < n; i++) {
        if((a ^ b) & (1 << i)) {
            c++;
        }
    }
    if(c % 2 == 0) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
        f(n, a, b, 0, 0);
        cout << ans;
    }
}


Measured memory_bytes: 2168
#include <stdio.h>
int main(void)
{
  int s[100];
  int n,i;
  int a=0;
  scanf("%d",&n);
 for(i=0;i<n;i++){
   scanf("%d",&s[i]);
    if((s[i]%2==0)&&(s[i]%3!=0)&&(s[i]%5!=0)){
     a++;
   }
 }  
  
  if(a==0){
    printf("APPROVED");
    }
    else{
      printf("DENIED");
    }
     return 0;
}

Measured memory_bytes: 1684
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
long long int a[1110000],b[111000],m,n,l,k,j,ans=1e18+5100000,ml,mr;
int main() {
	cin>>m>>n;
	ml=1;
	mr=1;
	for(int x=1; x<=m; x++) {
		cin>>l;
		if(l>0) {
			a[ml++]=l;
		} else {
			b[mr]=l;;
			b[mr++]*=-1;
		}
	}
	sort(b+1,b+mr);
	for(int x=0; x<min(n,ml); x++) {
		int v=n-x;
		if(v<ml&&x<mr)
			ans=min(ans,a[v]+b[x]*2);
	}
	for(int x=0; x<min(n,ml); x++) {
		int v=n-x;
		if(v<mr&&x<ml)
			ans=min(ans,a[x]*2+b[v]);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1024
/* WORK HARD MAN ! IT DEFINETELY AIN'T EASY FOR THE PRIZE IT HOLDS .... */
/* GET YOUR ASS TO WORK ALREADY */
/* FALTU HI LIKH ... BUT KHALI NI BAITHNA */
#include<bits/stdc++.h>

#define fast ios_base::sync_with_stdio(false); cin.tie(nullptr); cin.tie(nullptr);
#define int long long
#define ld long double
#define pb emplace_back
#define range(v) v.begin(),v.end()
#define mod (int)(1e9 + 7)
#define inf (int)1e15
#define pii pair<int,int>
#define ff first
#define ss second
// #define N --

using namespace std;

/* if not able to handle the ques.. see up */
int32_t main() {
	fast
	int t_c = 1;
	// cin >> t_c;
	while (t_c--) {
		// cout << "#: ";
		int a, b, n;
		cin >> a >> b >> n;
		int x = min(b - 1, n);
		int ans = floor((ld)(a * x) / b) - (a * floor(x / b));
		cout << ans;
	}
}

Measured memory_bytes: 3556
#include <iostream>                                                
#include <vector>                                                  
#include <numeric>                                                 
#include <cmath>                                                   
#include <iomanip>                                                 
                                                                   
using namespace std;                                               
                                                                   
                                                                   
int main (void) {                                                  
  int n, x;                                                        
  double m;                                                        
  while (true) {                                                   
    cin >> n;                                                      
    if (n==0) {                                                    
      break;                                                       
    }                                                              
    vector <double> s;                                             
    for (int i=0; i<n; i++) {                                      
      cin >> x;                                                    
      s.push_back((double)x);                                      
    }                                                              
    m = accumulate(s.begin(),s.end(),0.0)/s.size();                
    double a = 0;                                                  
    for (int i=0; i<s.size(); i++) {                               
      a += (pow(s[i]-m,2));                                        
    }                                                              
    a = sqrt(a/n);                                                 
    cout << fixed << setprecision(8) << a << endl;                 
  }                                                                
}                                                                  
                                                                   
                                       

Measured memory_bytes: 3272
<?php
  
  $a = range('a', 'z');
  $a[26] = 'a';

  $s = trim(fgets(STDIN));

  for($i =0; $i<26; $i++){
    if ($a[$i] == $s) {
      echo $a[$i+1];
      break;
    }
  }
  
  
?>

Measured memory_bytes: 4856
#include<bits/stdc++.h>
char s[50],a[9]={6,8,6,8,8};main(){for(int i,j,p,n,q;scanf("%d\n",&n),n;){for(i=0;i<n;s[i++]=strlen(gets(s+i)));for(i=j=0;j<6;)for(p=i++,j=q=0;q>=0;)for(q=a[j++]-1;q>0;q-=s[p++]);printf("%d\n",i);}}

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

namespace TestApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = Console.ReadLine()
                .Split(' ')
                .Select(_ => int.Parse(_))
                .ToArray();
            var a = n[0];
            var b = n[1];
            var diff = b - a;
            int i = 0;
            var ls = new List<int>();
            int val = 0;
            while (true)
            {
                if (i == diff)
                {
                    var before = 0;
                    for (int j = 0; j <= i; j++)
                    {
                        before += j;
                    }
                    val = before - b;
                    break;
                }
                i++;
            }
            Console.WriteLine(val);
            Console.ReadLine();
        }
    }
}



Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;

int main() {

    int n;
    cin >> n;
    
    vector<int> h(n);
    REP(i, n) cin >> h[i];
    
    for (int i = 0; i < n; i++) {
        if(i == 0) h[i]--;
        if(h[i]-1 >= h[i-1]) {
            h[i]--;
        }
        if(h[i] < h[i-1] && i != 0){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

string need[16] = {"AKIHABARA", "AKIHABAR", "AKIHABRA", "AKIHBARA", "KIHABARA", "AKIHABR", "AKIHBAR", "KIHABAR", "AKIHBRA", "KIHABRA", "KIHBARA", "AKIHBR", "KIHBAR", "KIHBRA", "KIHABR", "KIHBR"};

int main()
{
  string s;
  cin >> s;
  for (i64 i = 0; i < 16; i++)
    if (s == need[i])
    {
      cout << "YES" << endl;
      return 0;
    }
  cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int N = in.i();
        char[] s = new char[10];

        int ans = 0;
        int A = 0;
        int B = 0;
        int AB = 0;
        for (int i = 0; i < N; i++) {
            int n = in.read(s);

            boolean readA = false;
            for (int j = 0; j < n; j++) {
                if (readA && s[j] == 'B') ans++;
                readA = s[j] == 'A';
            }

            boolean tailA = s[n - 1] == 'A';
            boolean headB = s[0] == 'B';
            if (tailA && headB) AB++;
            else if (tailA) A++;
            else if (headB) B++;
        }

        if (AB > 0) {
            ans += AB - 1;
            if (A > 0 || B > 0) ans++;
        }
        ans += Math.min(A, B);
        System.out.println(ans);
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    int i() {
        int k = next() - '0';
        boolean minus = k == -3;
        int n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        int k = next() - '0';
        boolean minus = k == -3;
        long n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    char[] s(final int N) {
        char[] s = new char[N];
        for (int i = 0; i < N; i++) {
            s[i] = next();
        }
        next();
        return s;
    }

    public int read(char[] cbuf) {
        int i;
        char c;
        for (i = 0; (c = next()) != ' ' && c != '\n'; i++) cbuf[i] = c;
        return i;
    }

    public String readLine() {
        try {
            return super.readLine();
        } catch (IOException e) {
            return null;
        }
    }
}


Measured memory_bytes: 34112
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

int main() {
    ll N;
    cin >> N;
    double a[N];
    double sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        sum += a[i];
    }
    sum /= N;
    for (int i = 0; i < N; i++) {
        a[i] -= sum;
        a[i] = abs(a[i]);
    }
    double num = 1000;
    ll ans = -1;
    for (int i = 0; i < N; i++) {
        if (a[i] < num) {
            ans = i;
            num = a[i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256