akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

bool match(string &a, string &b, int as, int ae, int bs, int be) {
    assert(ae - as == be - bs);
    int n = ae - as;
    for (int i = 0; i < n; i++) {
        char x = a[i + as];
        char y = b[i + bs];
        if (x == '?' || y == '?' || x == y) continue;
        return false;
    }

    return true;

}

int check(string &a, string &b, string &c) {
    int la = a.size(), lb = b.size(), lc = c.size();

    vector<bool> ab(la + 1), bc(lb + 1), ac(la + 1);

    // ab
    rep(i, la + 1) {
        ab[i] = match(a, b, i, min(la, i + lb), 0, min(lb, la - i));
    }

    // bc
    rep(i, lb + 1) {
        bc[i] = match(b, c, i, min(lb, i + lc), 0, min(lc, lb - i));
    }

    // ac
    rep(i, la + 1) {
        ac[i] = match(a, c, i, min(la, i + lc), 0, min(lc, la - i));
    }

    assert(ab.back());
    assert(bc.back());
    assert(ac.back());

    int ans = INT_MAX;

    rep(i, la + 1) {
        if (!ab[i])continue;

        rep(j, lb + 1) {
            if (!bc[j])continue;
            if (!ac[min(i + j, la)]) continue;
            int at = la;
            int bt = i + lb;
            int ct = i + j + lc;
            int now = max({at, bt, ct});
            cmin(ans, now);
        }

        for (int j = i + lb; j <= la; j++) {
            if (!ac[j]) continue;
            int at = la;
            int ct = j + lc;
            int now = max({at, ct});
            cmin(ans, now);
        }

    }

    return ans;
}

int main() {

//    ifstream cin("C:\\Users\\riku\\Downloads\\056.txt");

    string a, b, c;
    cin >> a >> b >> c;


    int ans = INT_MAX;
    cmin(ans, check(a, b, c));
    cmin(ans, check(a, c, b));
    cmin(ans, check(b, a, c));
    cmin(ans, check(b, c, a));
    cmin(ans, check(c, a, b));
    cmin(ans, check(c, b, a));

    cout << ans << endl;
}


Measured memory_bytes: 3664
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

using int64 = long long;

const int MAX_W = 301;
const int MAX_H = 301;
const int64 INF = (1LL << 50);

char C[MAX_W][MAX_H];   // C[i][j] := 
int cost[MAX_W][MAX_H][MAX_H];
int64 dp[MAX_H][MAX_H];

int H, W;

int calc_cost(int id, int LH, int RH) {
    if (cost[id][LH][RH] >= 0) return cost[id][LH][RH];
    if (LH == 0 or RH == 0) return cost[id][LH][RH] = 0;
    // どっちも1より大きい
    int idxl = H - LH + 1;
    int idxr = H - RH + 1;
    return cost[id][LH][RH] = calc_cost(id, LH - 1, RH - 1) + (C[id][idxl] == C[id + 1][idxr]);
}

int main() {
    cin >> H >> W;

    for (int r = 0; r < H; r++) {
        string s;
        cin >> s;
        for (int c = 0; c < W; c++) C[c][H - r] = s[c];
    }

    memset(cost, -1, sizeof(cost));

    int64 ans = 0;
    for (int c = 0; c < W - 1; c++) {
        // dp
        fill((int64*)dp, (int64*)(dp + MAX_H), INF);

        dp[0][0] = 0;
        for (int LH = 0; LH <= H; LH++) {
            for (int RH = 0; RH <= H; RH++) {
                if (LH == 0 and RH == 0) continue;
                if (LH > 0) dp[LH][RH] = min(dp[LH][RH], dp[LH - 1][RH] + calc_cost(c, LH, RH));
                if (RH > 0) dp[LH][RH] = min(dp[LH][RH], dp[LH][RH - 1] + calc_cost(c, LH, RH));
            }
        }

        ans += dp[H][H];
        // cerr << "c: " << dp[H][H] << endl;
    }
    cout << ans << endl;

    /*
    cerr << "deg: " << calc_cost(1, 2, 2) << endl;
    cerr << "deg: " << calc_cost(1, 1, 1) << endl;
    */
    
    return 0;
}

Measured memory_bytes: 107520
N, M = list(map(int, input().split()))
record = [1 for i in range(N)]
H = list(map(int, input().split()))
grid = []
for i in range(M):
    array = list(map(int, input().split()))
    grid.append(array)

for i in range(M):
    if H[grid[i][0]-1] > H[grid[i][1]-1]:
        record[grid[i][1]-1] = 0
    elif H[grid[i][0]-1] < H[grid[i][1]-1]:
        record[grid[i][0]-1] = 0
    elif H[grid[i][0]-1] == H[grid[i][1]-1]:
        record[grid[i][0]-1] = 0
        record[grid[i][1]-1] = 0

flag = 0
for i in range(N):
    if record[i] == 1:
        flag += 1
print(flag)


Measured memory_bytes: 32736
#include <stdio.h>
#define N_MAX 101

int main(void)
{
     int h, i, j;
     char map[N_MAX][N_MAX], used[N_MAX][N_MAX];
     
     while(1){

	  for(i=0; i<N_MAX; i++)
	       for(j=0; j<N_MAX; j++)
		    map[i][j]='.', used[i][j]=0;
	  
	  scanf("%d %*d",&h); if(h==0) return 0;
	  for(i=0; i<h; i++) scanf("%s",map[i]);

	  i=j=0;
	  while(!used[i][j] && map[i][j]!='.'){
	       used[i][j]=1;

	       switch(map[i][j]){
	       case '>': j++; break; case '<': j--; break;
	       case '^': i--; break; case 'v': i++; break;
	       }
	  }

	  if(used[i][j]) puts("LOOP");
	  else printf("%d %d\n",j,i);
     }
}

Measured memory_bytes: 0
def main():
    #H , W = map(int, input().split())
    X = int(input())

    Sen = X // 500
    #print("%s" % Sen)
    XX = X - Sen * 500
    #print("%s" % XX)
    go = XX // 5

    print (str(Sen * 1000 + go * 5))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FSP(x) fixed << setprecision(x)
using namespace std;
using ll = long long;
constexpr ll INF = LLONG_MAX;
constexpr long double PI = acosl(-1);
void Yes() {cout << "Yes\n";}
void No() {cout << "No\n";}
void YES() {cout << "YES\n";}
void NO() {cout << "NO\n";}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//constexpr ll P = 1000000007;
	//constexpr ll P = 998244353;

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

	vector<ll> sum(n + 1, 0);
	for (ll i = 0; i < n; i++) sum[i + 1] = (sum[i] + a[i]) % m;

	map<ll, ll> mp;
	mp[0]++;
	ll ans = 0;
	for (ll i = 0; i < n; i++) {
		ans += mp[sum[i + 1]];
		mp[sum[i + 1]]++;
	}

	cout << ans << endl;
}

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

int max_profit(int w[],int p[],int n,int m){
	int a[n+1][m+1];
	for(int i=0;i<=n;i++){
		for(int j=0;j<=m;j++){
			if(i==0 || j==0){
				a[i][j]=0;
			}else{
				int num;
				if(j-w[i]<0) num=INT_MIN;
				else num=a[i-1][j-w[i]];
				
				a[i][j] = max(a[i-1][j],num+p[i]);
			}
		}
	}
	
	return a[n][m];
}

int32_t main()
{
   int n,m;cin>>n>>m;
    int w[n+1],p[n+1];
    for(int i=1;i<=n;i++){
    	cin>>w[i]>>p[i];
    }
    int ans=max_profit(w,p,n,m);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 79104
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    int A , B , C ;
    int K ;
    cin >> A >> B >> C >> K ;
    for(int i = 0 ; i < K ; i++){
        if(B <= A){
            B = B * 2 ;

        }else{
            C = C * 2 ;
        }

        

    }
    if(A < B && B < C){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
  
}

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

int main() {
    int N,count=0;
    cin >> N;
    int A[N],B[N-1];
  
  for(int i=0;i<N-1;i++){
    cin >> B[i];
  }
  A[0] = B[0];
  A[1] = B[0];
  
for (int i= 1; i < N-1 ; i++)
{
  if(A[i] > B[i]){A[i] = B[i];}
   A[i+1] = B[i];
}
  
  for (int i= 0; i < N; i++)
{
  count += A[i];
}

  cout <<   count;

  return 0;
}

Measured memory_bytes: 256
n=int(input())
a=[]
for i in range(n):
  m=int(input())
  a.append([])
  for i in range(m):
    a[-1].append(list(map(int,input().split())))
ans=0
for i in range(2**n):
  s=bin(i)[2:].zfill(n)
  f=True
  for j,k in enumerate(a):
    for x,y in k:
      if s[x-1]!=str(y) and s[j]=="1":f=False
  if f:ans=max(ans,s.count("1"))
print(ans)

Measured memory_bytes: 42860
# Code for D - I hate Factorization
# Use input() to fetch data from STDIN
import sys

LIMIT = 10 ** 9
X = int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

divs = make_divisors(X)
for div in divs:
    x = X / div
    for a in range(0, 100000):
        b = a - div
        t = (a ** 4 + (a ** 3) * b + (a ** 2) * (b ** 2) + a * (b ** 3) + b ** 4)

        if t == x:
            print(a, b)
            sys.exit()



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

int main() {
  ll n,m;
  cin >> n >> m;
  ll ans = 0;
  
  if(n*2 >= m){
    ans += m/2;
  }
  else{
    ans += n;
    m -= n*2;
    m /= 4; 
    ans += m;
  }
  
  cout << ans << endl;
    

}

Measured memory_bytes: 3588
#include <iostream>
#include <string>

using namespace std;

bool hantei(char mozi){

  if((96<mozi && mozi<104) || (112<mozi && mozi<117) || (117<mozi && mozi!=121))
    return 1;
  else
    return 0;
}

int main(void)
{
  string typ;
  int str_size;
  bool now;
  int count;
  
  while(cin >> typ){
    count=0;

    if(typ=="#")
      return 0;
    
    str_size=typ.size();

    now=hantei(typ[0]);
    
    for(int i=1;i<str_size;i++){
      if(now!=hantei(typ[i])){
	count++;
	now=hantei(typ[i]);
      }
    }

    cout << count << endl;
  }

  return 0;
}
     
    



Measured memory_bytes: 3144
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

signed main(){
    int N; cin >> N;
    string S,T; cin >> S >> T;
    vector<char> A(2*N);
    for(int i = 0; i < N; i++) {
        cout << S.at(i) << T.at(i);
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
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; }
int main()
{
    int N, M;
    cin >> N >> M;
    vector<int>from_1_to_X;
    map<int, int>d;
    for (int i=0; i<M; i++) {
        int n, m;
        cin >> n >> m;
        if (n == 1) {
            from_1_to_X.emplace_back(m);
        } else if (m == N) {
            d[n] = 1;
        }
    }

    bool is_possible = false;
    for (int i=0; i<from_1_to_X.size(); i++) {
        int chukanti = from_1_to_X[i];
        if (d.count(chukanti) > 0) {
            is_possible = true;
            break;
        }
    }

    if (is_possible) {
        cout << "POSSIBLE" << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}

Measured memory_bytes: 8072
PROGRAM piyo
      IMPLICIT NONE
      INTEGER,PARAMETER :: p = 8
      integer(p) :: n,a,b,c ,nn=10**6
      integer(p) :: t(0:10**6)
      
      read*,n
      
      do a = 1,nn
        do b = 1, nn/a
          if( a*b>10**6 )cycle
          
          t(a*b) = t(a*b) + 1
        end do
      end do
      
      print*,sum(t(1:n-1))
      
      
      
      stop
      !debugg
      
      
      
      END PROGRAM

Measured memory_bytes: 10672
import java.util.*;

public class Main {

    long INF = Long.MAX_VALUE;

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] A = new long[N];
        long ans = 1;
        boolean f = true;
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextLong();
        }
        lavel:
        for (int i = 1; i < N; i++) {
            if (A[i - 1] < A[i]) {
                f = true;
            } else if (A[i - 1] > A[i]) {
                f = false;
            }
            if (A[i - 1] == A[i]) {
                continue;
            }
            for (int j = i + 1; j < N; j++) {
                if ((f == false) && A[j - 1] < A[j]) {
                    ans++;
                    i = j;
                    break;
                } else if ((f == true) && A[j - 1] > A[j]) {
                    ans++;
                    i = j;
                    break;
                }
                if (A[j - 1] == A[j]) {
                    continue;
                }
                if (j == N - 1) {
                    break lavel;
                }
            }
        }
        System.out.println(ans);
    }
}

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

int main(){
    i64 w,h;
    cin>>w>>h;
    if(w==1||h==1){
        cout<<1<<endl;
        return 0;
    }
    cout<<(w*h+1)/2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;
int main(void){
    int A,B,C,X;
    cin >> A >> B >> C >> X;
    
    int adapt = 0;
    for(int i=0;i <= A;i++) {
        for(int j=0;j <= B;j++) {
            for(int k=0;k <= C;k++) {
                if(500*i + 100*j + 50*k == X) { adapt++;}
            }
        }
    }
    cout << adapt;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

int main()
{
	std::string S, T;
	std::cin >> S >> T;

	std::vector<int> sv( 26 ), tv( 26 );

	for ( int i = 0; i < S.length(); i++ )
	{
		// S, Tのアルファベットの出現頻度を数える
		sv[S[i] - 'a']++;
		tv[T[i] - 'a']++;
	}

	std::sort( sv.begin(), sv.end() );
	std::sort( tv.begin(), tv.end() );

	bool isYes = true;
	for ( int i = 0; i < sv.size(); i++ )
	{
		if ( sv[i] != tv[i] )
		{
			isYes = false;
			break;
		}
	}

	std::cout << ( isYes ? "Yes" : "No" ) << std::endl;

	return ( 0 );
}


Measured memory_bytes: 1020
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <string>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>

typedef long long ll;

#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())

using namespace std;

string S;
ll K;
int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N = 5000000000000000;
    cin >> S >> K;
    vector<int> num;
    REP(i,S.size()){
        num.push_back((int)(S[i] - '0'));
    }
    REP(i,num.size()){
        if(num[i] == 1){
            K--;
            if(K == 0){ 
                cout << num[i] << endl;
                break;
            }
        }else{
            cout << num[i] << endl;
            break;
        }
    }

    return 0;
}

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

using namespace std;

using ll = long long;

int main()
{
    ll K, N;
    cin >> K >> N;

    vector<ll> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

    ll max = A[0] + K - A[N - 1];
    for (int i = 1; i < N; i++) {
        if (max < A[i] - A[i - 1]) max = A[i] - A[i - 1];
    }

    cout << K - max << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
 
int main() {
  int a1,a2,a3;
  cin >> a1>>a2>>a3;
  
  if(a1+a2+a3>=22)cout << "bust" << endl;
  else cout << "win" << endl;
}



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

vector<int>adj[20];
vector<int>v;
int n;

int f()
{
    map<int,int>m;
   int counter=0;

   for(int i=1;i<=n;i++)
   {
       m[i]=1;
   }
   for(int i=0;i<v.size();i++)
   {
       m[v[i]+1]=2;
   }


  // for(int i=0;i<v.size();i++)cout<<v[i]<<" ";cout<<endl;
    bool he = true;
    for(int i=0;i<v.size();i++)
   {
       int  k=v[i]+1;
    //   cout<<v[i]<<endl;
       for(int j=0;j<adj[k].size();j+=2)
       {
           if(adj[k][j+1]==0&&m[adj[k][j]]==2)
           {
              he=false;
              break;
           }
           else if(adj[k][j+1]==1&&m[adj[k][j]]==1)
           {
               he=false;
               break;
           }
       }
   }
   return he;

}

int main()
{
  //  int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        int a;
        cin>>a;
        for(int j=0;j<a;j++)
        {
            int c,d;
            cin>>c>>d;
            adj[i].push_back(c);
            adj[i].push_back(d);
        }
    }


    int sum=0;
    for(int i=1;i<pow(2,n);i++)
    {
        //vector<int>v;
        v.clear();
        for(int j=0;j<n;j++)
        {
            if(i&(1<<j))
            {
                v.push_back(j);
            }
        }
      // for(int i=0;i<v.size();i++)cout<<v[i]<<" ";cout<<endl;
        int p;
        if(f())p=v.size();
        else p=0;
       sum=max(p,sum);
    }
    cout<<sum<<endl;

}


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

int main() {
    double r;
    cin >> r;
    double a = r * r * 3.141592653589;
    double b = 2 * r * 3.141592653589;
    printf("%lf %lf\n",a ,b );
    
    return 0;
}



Measured memory_bytes: 3200
while True:
    n,x=map(int,input().split())
    if (n==0 and x==0):
        break
    ans=0
    for i in range(1,n):
        for j in range(i+1,n):
            for k in range(j+1,n+1):
                if (i+j+k==x):
                    ans+=1
    print(ans)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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;
}

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  ll Q, H;
  cin >> Q >> H;
  ll S, D;
  cin >> S >> D;
  ll N;
  cin >> N;

  Q *= 8, H *= 4, S *= 2;
  // All 2L //

  ll ans = 0;
  ll mn = min({Q, H, S, D});
  ans += (N / 2) * mn;

  N %= 2;
  if (N) {
    Q /= 2, H /= 2, S /= 2;
    ll mn = min({Q, H, S});
    ans += mn;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
 
//#define getchar_unlocked()  getchar()
int in()
{
    int n = 0, c = getchar_unlocked();
    do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
    return n;
}
 
int gcd(int a, int b)
{
    int r;
    while (b != 0) r = a % b, a = b, b = r;
    return a;
}
 
int main()
{
    int a, b;
 
    a = in(), b = in();
    printf("%d\n", gcd(a, b));
    return 0;
}


Measured memory_bytes: 2132
n = int(input())
l_h = list(map(int, input().split()))

max_mov_cnt = 0
tmp = 0
for i in range(n-1):
    if l_h[i] >= l_h[i+1]:
        tmp += 1
    else:
        max_mov_cnt = max(max_mov_cnt, tmp)
        tmp = 0

max_mov_cnt = max(max_mov_cnt, tmp)
print(max_mov_cnt)


Measured memory_bytes: 20456
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int n, q;
  cin >> n >> q;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<long long> sum1(n + 1), sum2(n + 1);
  for (int i = 0; i < n; i++) {
    sum1[i + 1] = sum1[i] + a[i];
    sum2[i + 1] = (i - 1 >= 0 ? sum2[i - 1] : 0LL) + a[i];
  }
  while (q--) {
    long long x;
    cin >> x;
    int lo = 0, hi = n;
    while (hi - lo > 1) {
      int mid = (lo + hi) >> 1;
      if (n - mid - mid + 1 >= 0 && a[n - mid] - x >= x - a[n - mid - mid + 1]) lo = mid;
      else hi = mid;
    }
    cout << sum1[n] - sum1[n - lo] + (n - lo - lo >= 0 ? sum2[n - lo - lo] : 0LL) << '\n';
  }
  return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define maxn 100003
using namespace std;
char s[maxn];
int n,z[maxn],cnt;
bool no(){
	if(s[n]=='1'||s[1]=='0')return 1;
	for(int i=1;i<=(n>>1);i++)if(s[i]!=s[n-i])return 1;
	return 0;
}
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	if(no()){puts("-1");return 0;}
	z[0]=n;
	for(int i=(n>>1),rt=n;i>=1;i--){
		if(s[i]=='1')z[++cnt]=i,rt=i;
	}
	for(int i=1,j=cnt;i<n;i++){
		if(i==z[j])j--;
		printf("%d %d\n",i,z[j]);
	}
	return 0;
}

Measured memory_bytes: 1664
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var xs = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

        Console.WriteLine(string.Join(" ", xs.Select(x => x.ToString()).ToArray()));

        for (var i = 1; i < n; i++)
        {
            var v = xs[i];
            var j = i - 1;

            while (j >= 0 && xs[j] > v)
            {
                xs[j + 1] = xs[j];
                j--;
            }

            xs[j + 1] = v;

            Console.WriteLine(string.Join(" ", xs.Select(x => x.ToString()).ToArray()));
        }
    }
}


Measured memory_bytes: 9812
def check(st):
  flag = True
  n = len(st)
  for i in range(int(n/2)):
    if st[i] != st[n-1-i]:
      flag = False
  return flag
 
s=input()
n=len(s)
one = s[0:int((n-1)/2)]
two = s[int(((n+3)/2)) - 1:n]
 
if check(one) and check(two) and check(s):
  print("Yes")
else:
  print("No")

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



int main(){
    int n,k;
    int h[100005];
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    int dp[100005];
    dp[0]=0;
    for(int i=1;i<n;i++){
        dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
        for(int j=1;j<=k&&i-j>=0;j++){
            dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}




Measured memory_bytes: 1024
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
using namespace std;
int read()
{
	int s=0,t=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')	t=-1; ch=getchar();}
	while(ch>='0' && ch<='9')	s=s*10+ch-'0',ch=getchar();
	return s*t;
}
#define N 3010
int mdn;
void upd(int &x,int y){x+=x+y>=mdn?y-mdn:y;}
int ksm(int bs,int mi)
{
	int ans=1;
	while(mi)
	{
		if(mi&1)	ans=1ll*ans*bs%mdn;
		bs=1ll*bs*bs%mdn; mi>>=1;
	}
	return ans;
}
int qsm(int bs,int mi)
{
	int ans=1;
	while(mi)
	{
		if(mi&1)	ans=1ll*ans*bs%(mdn-1);
		bs=1ll*bs*bs%(mdn-1); mi>>=1;
	}
	return ans;
}
int f[N][N],n,c[N][N];
void init()
{
	f[1][1]=1; c[0][0]=c[1][0]=c[1][1]=1;
	for(int i=2;i<=n+1;c[i][0]=1,i++)	for(int j=1;j<=n+1;j++)
		f[i][j]=(f[i-1][j-1]+1ll*f[i-1][j]*j%mdn)%mdn,
		c[i][j]=(c[i-1][j-1]+c[i-1][j])%mdn;
}
int F(int x)
{
	int ans=0,k=ksm(2,n-x),tmp=1,w=ksm(2,qsm(2,n-x));
	for(int i=0;i<=x;i++)	upd(ans,1ll*tmp*f[x+1][i+1]%mdn*w%mdn),tmp=1ll*tmp*k%mdn;
	return ans;
}
int main()
{
	n=read(); mdn=read(); init(); int ans=0;
	for(int i=0;i<=n;i++)	upd(ans,1ll*(i&1?mdn-1:1)*F(i)%mdn*c[n][i]%mdn);
	printf("%d\n",ans);
	return 0;
}

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

struct point {
	int x; int y;
};

bool order(point a, point b) {
	return a.x < b.x;
}

point blue[200];
point red[200];
int used[200] = {};

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int p, q;
		cin >> p >> q;
		red[i] = { p,q };
	}
	for (int i = 0; i < n; i++) {
		int p, q;
		cin >> p >> q;
		blue[i] = { p,q };
	}
	int ans = 0;
	sort(blue, blue + n, order);
	for (int i = 0; i < n; i++) {
		int bx = blue[i].x;
		int by = blue[i].y;
		int max_red = -1;
		int max_red_y = -1000000;
		for (int j = 0; j < n; j++) {
			if (used[j] == 0 && red[j].x < bx && red[j].y < by && red[j].y > max_red_y) {
				max_red = j;
				max_red_y = red[j].y;
			}
		}
		if (max_red != -1) {
			ans++;
			used[max_red] = 1;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
def operator?(s)
	s =~ /\+|-|\*/
end

def number?(s)
	return true if s.is_a? Integer
	s =~ /\A-?\d+\Z/
end

def operate(x, y, o)
x = x.to_i unless x.is_a? Integer
	y = y.to_i unless y.is_a? Integer
	case o
	when "+"
		x + y
	when "-"
		x - y
	when "*"
		x * y
	else
		raise "Illegal statement. #{x} #{y} #{o}"
	end
end

inputs = STDIN.gets.split
stack = []
inputs.each do |e|
	if number?(e)
		stack.push(e)
	elsif operator?(e)
		x, y = stack.pop(2)
		stack.push(operate x, y, e)
	end
end

puts stack.pop

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

#define MAX_N 100000

using namespace std;

typedef long long lint;

lint rez;

int n, k;

struct elem
{
    int a, b;
};

elem v[MAX_N + 1];

void readFile()
{
    scanf("%d%d", &n, &k);

    int i;
    for(i = 1; i <= n; i ++)
        scanf("%d%d", &v[i].a, &v[i].b);
}

void getWin(int cop)
{
    int i;
    lint win = 0;
    for(i = 1; i <= n; i ++)
    {
        if((v[i].a | cop) == cop)
        {
            win += v[i].b;
        }
    }

    rez = max(rez, win);
}

void solve()
{
    getWin(k);
    int j;
    for(j = 0; j <= 29; j ++)
    {
        if(((1 << j) & k) != 0)
        {
            int cop = (k ^ (1 << j));
            cop = (cop | ((1 << j) - 1));
            getWin(cop);
        }
    }
}

void printFile()
{
    printf("%lld\n", rez);
}

int main()
{
    readFile();

    solve();

    printFile();

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define ifaxb(a, x, b) if (a < x && x < b)
#define toInt(x) (x - '0')
#define vi vector<int>
#define vs vector<string>
#define all(x) x.begin(), x.end()
#define INF 2147483647
#define _INF -2147483647
#define pi 3.1415926536
#define MAXN 100004
using namespace std;
typedef long long ll;

int main() {
  int X1, X2, Y1, Y2;
  cin >> X1 >> Y1 >> X2 >> Y2;

  int yoko = X2 - X1;
  int tate = Y2 - Y1;
  int X3, X4, Y3, Y4;
  Y3 = Y2 + yoko;
  X3 = X2 - tate;
  Y4 = Y3 - tate;
  X4 = X3 - yoko;
  cout << X3 << " " << Y3 << " " << X4 << " " << Y4 << " " << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	char s[19], i;
	
	scanf("%s", s);

	for (i = 0;i < 19;i++) {
		if (s[i] != ',') {
			printf("%c", s[i]);
		}
		else if (s[i] == ',') {
			printf(" ");
		}
	}
	printf("\n");
	
	return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define out(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    string s; cin >> s;
    int x, y;
    cin >> x >> y;

    vector<int> vx,vy;
    int tcount = 0;
    int fcount = 0;
    REP(i,s.size()+1) {
        if (i == s.size() || s[i] == 'T') {
            if (tcount % 2 == 0) vx.push_back(fcount);
            else vy.push_back(fcount);
            tcount++;
            fcount = 0;
        } else {
            fcount++;
        }
    }

    set<int> dpx,dpy;
    dpx.insert(0);
    dpy.insert(0);
    
    REP(i,vx.size()) {
        set<int> tmp(move(dpx));
        dpx.clear();
        //swap(dpx,tmp);
        for(auto m:tmp) {
            dpx.insert(m+vx[i]);
            if (i != 0) dpx.insert(m-vx[i]);
        }
    }

    REP(i,vy.size()) {
        set<int> tmp(move(dpy));
        dpy.clear();
        //swap(dpy,tmp);
        for(auto m:tmp) {
            dpy.insert(m+vy[i]);
            dpy.insert(m-vy[i]);
        }
    }
    
    ATYN(dpx.find(x) != dpx.end() && dpy.find(y) != dpy.end())

    return 0;
}

Measured memory_bytes: 768
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-12 12:01:42
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<x>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod)
{
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod)
{
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod)
{
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l)
{
    if (l > 0) return gcd(l, k%l);
    else return k;
}

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int count(int n)
{
    if (n % 2 == 0) return 1 + count(n/2);
    else return 0;
}

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

    vector<int> cnt(n);
    for (int i = 0; i < n; i++) {
        cnt[i] = count(a[i]);
    }

    int ans = INF;
    for (int i = 0; i < n; i++) {
        int c = cnt[i];
        if (c < ans) ans = c;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define int long long
using namespace std;
const int N = 405, mod = 998244353;
int read() {
	int x = 0, f = 1; char ch;
	while(! isdigit(ch = getchar())) (ch == '-') && (f = -f);
	for(x = ch ^ 48; isdigit(ch = getchar()); x = (x << 3) + (x << 1) + (ch ^ 48));
	return x * f;
}
template <class T> T Max(T a, T b) { return a > b ? a : b; }
template <class T> T Min(T a, T b) { return a < b ? a : b; }
int n, Sa, Sb, a[N], b[N], A[N][N], inv[N], fac[N], f[N][N][N];
int ksm(int x, int y) {
	int res = 1;
	for( ; y; x = x * x % mod, y >>= 1) {
		if(y & 1) res = res * x % mod;
	}
	return res;
}
signed main() {
	n = read(); f[0][0][0] = -1; fac[0] = 1;
	for(int i = 1; i <= n; ++ i) Sa += (a[i] = read()), Sb += (b[i] = read());
	for(int i = 1; i <= Sb; ++ i) fac[i] = fac[i - 1] * i % mod;
	inv[Sb] = ksm(fac[Sb], mod - 2);
	for(int i = Sb - 1; ~i; -- i) inv[i] = inv[i + 1] * (i + 1) % mod;
	for(int i = 1; i <= n; ++ i) for(int j = 0; j <= Sb; ++ j) A[i][j] = (j == 0) ? 1 : A[i][j - 1] * a[i] % mod;
	for(int i = 1; i <= n; ++ i) 
		for(int j = 0; j <= Sa; ++ j) 
			for(int k = 0; k <= Sb; ++ k) {
				f[i][j][k] = f[i - 1][j][k];
				for(int l = 0; l < b[i]; ++ l) if(j >= a[i] && k >= l) f[i][j][k] = ((f[i][j][k] - f[i - 1][j - a[i]][k - l] * A[i][l] % mod * inv[l] % mod) % mod + mod) % mod;
			}
	int ans = 0;
	for(int i = 0; i <= Sa; ++ i) for(int j = 0; j <= Sb; ++ j) ans = (ans + Sa * ksm(ksm(i, mod - 2), j + 1) % mod * f[n][i][j] % mod * fac[j] % mod) % mod;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 515584
N = int(input())
A = list(map(int,input().split()))
# ミソなのは対称性とかをきれいな解法を使わずに，a1を最初に求めて，そのあとは帰納法で次の数字を求めていくこと

S = sum(A)
x1 = S - 2*sum(A[1::2])

X = [x1] * (N)
for i in range(1,N):
    X[i] = 2*A[i-1] - X[i-1]

print(' '.join([str(xi) for xi in X]))


Measured memory_bytes: 25076
def main():
    n, m = map(int, input().split())
    p = list(map(int, input().split()))
    global parent, rank
    parent = list(range(n+1))
    rank = [0]*(n+1)
    cnt = 0
    for _ in range(m):
        x, y = map(int, input().split())
        unite(x, y)
    for i, pi in enumerate(p, 1):
        if same(i, pi):
            cnt += 1
    print(cnt)
        
def root(x):
    if parent[x] == x:
        return x
    parent[x] = root(parent[x])
    return parent[x]

def same(x, y):
    return root(x) == root(y)

def unite(x, y):
    x = root(x)
    y = root(y)
    if x != y:
        if rank[x] < rank[y]:
            parent[x] = y
        elif rank[x] > rank[y]:
            parent[y] = x
        else:
            parent[y] = x
            rank[x] += 1

if __name__ == "__main__":
    main()


Measured memory_bytes: 13812
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
typedef pair<int,ll> Pil;
typedef pair<ll,ll> Pll;
typedef pair<string,int> Psi;
typedef pair<Psi,int> Psii;

const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

ll dp[2001][2001]={};

ll calc(int a,int b){
	if(dp[a][b]>=0)return dp[a][b];
	if(a<b)return 0;
	if(b==1||a==b)return 1;
	if(b==0)return 0;
	ll r=calc(a-1,b)+calc(a-1,b-1);
	r%=1000000007;
	dp[a][b]=r;
	return r;
}
int main() {
	int n,k;
	cin>>n>>k;

	rep(i,n+1){
		rep(j,n+1){
			dp[i][j]=-1;
		}
	}
	rep(i,k){
			ll r=calc(k,i+1)*(calc(n-k,i+2)+2*calc(n-k,i+1)+calc(n-k,i));
//			cout<<calc(n-k,i+2)+2*calc(n-k,i+1)+calc(n-k,i)<<endl;
			r%=1000000007;
			cout<<r<<endl;
	}
	return 0;
}


Measured memory_bytes: 31616
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), m = scanner.nextInt();
			System.out.println(getResult(n, m));
		}
	}

	/**
	 * m/n 以下最大のmの約数を計算する
	 * 
	 * @param n
	 * @param m
	 * @return m/n より小さい最大のmの約数
	 */
	private static int getResult(int n, int m) {
		for (int i = m / n; i >= 1; i--) {
			if (0 == (m % i)) {
				return i;
			}
		}
		return 1;
	}
}


Measured memory_bytes: 35684
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define PI 3.141592653589793238
int main()
{
    // #ifndef ONLINE_JUDGE
    // freopen("/home/pushkar/cpp/input.txt", "r", stdin);
    // freopen("/home/pushkar/cpp/output.txt", "w", stdout);
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll i, n, w = 0, x = 0;
    cin >> n;
    string s;
    cin >> s;
    for (i=0;i<s.length();i++)
    {
        if (s[i] == 'W')
        w++;
    }
    for (i=0;i<w;i++)
    {
        if (s[n-i-1] == 'W')
        x++;
    }
    cout << w - x;
    return 0;
}

Measured memory_bytes: 3728
# -*- coding: utf-8 -*-
"""
Created on Sat Jul 11 17:23:36 2020

@author: Aruto Hosaka
"""

N = int(input())
S = input()


color = ['R','G','B']
k = 1

A = {color[0]:0,color[1]:0,color[2]:0}

for c1 in color:
    for c2 in color:
        for c3 in color:
            if c1 != c2 and c2 != c3 and c1 != c3:
                A[(c1,c2,c3)] = 0

for c1 in color:
    for c2 in color:
        if c1!=c2:
            A[(c1,c2)] = 0

for i in range(N):
    if S[i] == 'R':
        A[('G','B','R')] += A[('G','B')]
        A[('B','G','R')] += A[('B','G')]
        A[('B','R')] += A['B']
        A[('G','R')] += A['G']
    if S[i] == 'G':
        A[('R','B','G')] += A[('R','B')]
        A[('B','R','G')] += A[('B','R')]
        A[('B','G')] += A['B']
        A[('R','G')] += A['R']
    if S[i] == 'B':
        A[('G','R','B')] += A[('G','R')]
        A[('R','G','B')] += A[('R','G')]
        A[('R','B')] += A['R']
        A[('G','B')] += A['G']
    A[S[i]] += 1

counter = 0
for c1 in color:
    for c2 in color:
        for c3 in color:
            if c1 != c2 and c2 != c3 and c1 != c3:
                counter += A[(c1,c2,c3)]
                
dc = 0
for i in range(N-2):
    k = 1
    while k*2+i < N:
        if S[i+k] != S[i] and S[i] != S[i+k*2] and S[i+k] != S[i+k*2]:
            dc += 1
        k += 1
print(counter-dc)

Measured memory_bytes: 9280
k = int(input())

all_lun = []
def dfs(d):
    all_lun.append(d)
    if len(str(d))==10:
        return
    for i in [-1, 0, 1]:
        if 0<=d%10+i<10: dfs(d*10+d%10+i)
for i in range(1, 10):
    dfs(i)
all_lun.sort()
print(all_lun[k-1])

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

int main() {
  while (1) {
    int n;
    cin >> n;
    if (n == 0) break;
    int s[n];

    double sum = 0;
    for (int i = 0; i < n; i++) {
      cin >> s[i];
      sum += s[i];
    }
    double m = sum / n;
    double t = 0;
    for (int i = 0; i < n; i++) {
      t += (s[i]-m)*(s[i]-m);
    }
    double a = sqrt(t/n);

    cout << a << endl;
  }
      
}



Measured memory_bytes: 3248
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll K; cin >> K;
	int N = 50;
	vector<ll> a(N, 0LL);
	rep (i, N){
		a[i] = N - 1LL;
	} // end rep
	ll t = K / (ll)N;
	rep (i, N){
		a[i] += t;
	} // end rep
	int m = K % N;
	rep (i, m){
		rep (j, N){
			if (i == j){
				a[j] += (ll)N;
			}else{
				--a[j];
			} // end if
		} // end rep
	} // end rep
	cout << N << endl;
	rep (i, N){
		cout << a[i] << (i !=  N - 1 ? ' ' : '\n');
	} // end rep 
	return 0;
}

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

using namespace std;

#define IoFast ios_base::sync_with_stdio(0);cin.tie(0);
#define ll long long int
#define float long double
#define foor(i, a, b) for ( int (i) = (a); (i)<(b); (i)++ )
#define foor2(i, a, b) for( int (i) = (a); (i)>(b); (i)-- )
#define foorl(i, a, b) for ( ll (i) = (a); (i)<(b); (i)++ )
#define foorl2(i, a, b) for( ll (i) = (a); (i)>(b); (i)-- )
#define mp make_pair
#define f1 first
#define f2 second
#define pb push_back
#define pii pair<int,int>
#define vpii vector <pii>
#define vi vector<int>
#define sz(a) (int) a.size( )
#define fillArr(n, a) foor(i, 0, n) cin >> a[i];
#define print(a) cout << #a << endl;
#define umax(a,b) a = max ( a, b )
#define umin(a,b) a = min ( a, b )
#define all(k) k.begin ( ), k.end( )
#define rall(k) k.rbegin ( ), k.rend( )
#define clean(k) memset( k, 0, sizeof(k) )
#define endl '\n'

const int maxn = 15000;

int test[maxn];

int main(){
	int a, b, c;
	cin >> a >> b >> c;

    if (a == b && c == b && a % 2 == 0) {
       cout << -1 << endl;
       return 0;
    }

    int ans = 0;
	int nextA, nextB, nextC;
    while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
       ans ++;
       nextA = b / 2 + c / 2;
       nextB = c / 2 + a / 2;
       nextC = a / 2 + b / 2;
       a = nextA;
       b = nextB;
       c = nextC;
    }
       cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


ll N;

int main(){

	scanf("%lld",&N);

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

		ans += i*(N+1-i);
	}

	ll a,b;

	for(ll i = 0; i < N-1; i++){

		scanf("%lld %lld",&a,&b);

		if(a > b)swap(a,b);

		ans -= a*(N-b+1);
	}

	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 3824
import bisect,collections,copy,heapq,itertools,math,string
import sys
def I():
    #1 line 1 int
     return int(sys.stdin.readline().rstrip())
def LI():
    #1 line n int
     return list(map(int,sys.stdin.readline().rstrip().split()))
def S():
    #1 line 1 string
     return sys.stdin.readline().rstrip()
def LS():
    #1 line n strings
     return list(sys.stdin.readline().rstrip().split())

N,A,B=LI()
x=N*A
y=B

if x <= y:
    print(x)
else:
    print(y)

Measured memory_bytes: 10044
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int,int> vii;
typedef vector<ll,ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef set <int> :: iterator sitr;
typedef set <ll> :: iterator sltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef mset <int> :: iterator msitr;
typedef mset <ll> :: iterator msltr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
bool exist[20];
str s;
int mn;
vector<int> num;
int main(){
    cin>>s;
    mn = 1000;
    for(int i=0;i<s.size()-2;i++){
        int a,b,c;
        a = int(s[i] - '0');
        b = int(s[i+1] - '0');
        c = int(s[i+2] - '0');
        mn = min(mn, abs(753 - (100*a + 10*b + c)) );
    }
    cout<<mn<<endl;

}


Measured memory_bytes: 256
import sys
N=int(input())

for h in range(1,3501):
  for n in range(1,3501):
    bb=(4*h*n-N*n-N*h)
    bs=(N*h*n)
    if bb==0:
      continue

    if bs%bb==0 and 1<=bs//bb:
      print(h,n,bs//bb)
      sys.exit()

Measured memory_bytes: 67072
N = int(input())
my_list = list(map(int, input().split()))
my_dict1 = {}
my_dict2 = {}

# j - i == Aj + Ai
# j - Aj == Ai + i

#Ai + i
for i in range(N):
    key = my_list[i] + i
    if key in my_dict1.keys():
        my_dict1[key] += 1
    else:
        my_dict1[key] = 1

#j - Aj
for j in range(N):
    key = j - my_list[j]
    if key in my_dict2.keys():
        my_dict2[key] += 1
    else:
        my_dict2[key] = 1


ans = 0
for key in my_dict1.keys():
    if key in my_dict2.keys():
        ans += my_dict1[key] * my_dict2[key]

print(ans)


Measured memory_bytes: 59620
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (1) {
		int n;
		cin >> n;
		if (!n)break;
		vi v(26, 0);
		vector<char> c(n);
		REP(i, n)cin >> c[i];
		REP(i, n) {
	
			v[c[i] - 'A']++;
			vi a = v;
			sort(ALL(a), greater<int>());
			if (a[0] - a[1] > n - i-1) {
				cout << char(int(max_element(ALL(v)) - v.begin()) + 'A') << " " << i + 1 << endl;
				break;
			}
			else {
				if (i == n - 1)cout << "TIE" << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3124
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a: usize,
        b: usize
    }

    println!("{}", std::cmp::min(n * a, b))
}

Measured memory_bytes: 4352