akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define em3 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
#define X real()
#define Y imag()
#define cross(a, b) ((conj(a) * (b)).Y)
#define dot(a, b) ((conj(a) * (b)).X)
#define EPS 1e-7
long long mod = 1e9 + 7;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const double pi = acos(-1);
typedef complex <double> point;
typedef tuple<int, int, int> line;
typedef vector<point> polygon;

int main()
{
    em3
    ll n , ans1 , ans2 , ans3 , a , b , c;
    cin >> n >> a >> b >> c;
    ans1 = a , ans2 = b , ans3 = c;
    for(int i = 1 ; i < n ; i++)
    {
        cin >> a >> b >> c;
        ll temp1 = ans1, temp2 = ans2 , temp3 = ans3;
        ans1 = max(temp2 , temp3) + a;
        ans2 = max(temp1 , temp3) + b;
        ans3 = max(temp1 , temp2) + c;
    }
    cout << max(ans1 , max(ans2 , ans3));
    return 0;
}


Measured memory_bytes: 256
def calc_p_1_minkowski(n, x, y)
  p_1_minkowski = 0
  length = x.length
  for i in 0..(length-1)
    p_1_minkowski += (x[i] - y[i]).abs
  end
  return p_1_minkowski
end

def calc_p_2_minkowski(n, x, y)
  tmp = 0
  length = x.length
  for i in 0..(length-1)
    tmp += ((x[i] - y[i]).abs)**2
  end
  p_2_minkowski = tmp**(1/2.0)
  return p_2_minkowski
end

def calc_p_3_minkowski(n, x, y)
  tmp = 0
  length = x.length
  for i in 0..(length-1)
    tmp += ((x[i] - y[i]).abs)**3
  end
  p_3_minkowski = tmp**(1/3.0)
  return p_3_minkowski
end

def calc_p_inf_minkowski(n, x, y)
  length = x.length
  xy_array = []
  for i in 0..(length-1)
    xy_array.push((x[i]-y[i]).abs)
  end
  p_inf_minkowski = xy_array.max
  return p_inf_minkowski
end

n = gets.chomp.to_i
x = gets.chomp.split.map(&:to_i)
y = gets.chomp.split.map(&:to_i)

puts calc_p_1_minkowski(n, x, y)
puts calc_p_2_minkowski(n, x, y).round(6)
puts calc_p_3_minkowski(n, x, y).round(6)
puts calc_p_inf_minkowski(n, x, y)

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

typedef long long ll;

int main(){
  string s;
  int a[30];

  cin >> s;

  for(int i=0;i<26;i++)a[i] = 0;
  for(int i=0;i<(int)s.size();i++)a[s[i]-'a']++;

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

  if(cnt>1){
    cout << 0 << endl;
    return 0;
  }
  
  vector<int> u;
  
  for(int i=2;i<=sum;i++)u.push_back(i);
  
  for(int i=0;i<26;i++){
    for(int j=2;j<=a[i];j++){
      int tmp = j;
      for(int k=0;k<(int)u.size();k++){
	if(tmp == 1)break;
	int g = __gcd(tmp,u[k]);
	tmp/=g; u[k]/=g;
      }
    }
  }
  
  ll ans = 1;
  for(int i=0;i<(int)u.size();i++)ans *= u[i];
  cout << ans << endl;
}

Measured memory_bytes: 0
te=input()
a,b,c,d=te
a=int(a)
b=int(b)
c=int(c)
d=int(d)

#0 →  +  1→-
pm=[1,-1]
hugou=["+","-"]
for i in range(2):
    for j in range(2):
        for k in range(2):
            if a+pm[i]*b+pm[j]*c+pm[k]*d==7:
                print(str(a)+hugou[i]+str(b)+hugou[j]+str(c)+hugou[k]+str(d)+"=7")
                exit()

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

ll dp[1001][1001];
char maze[1001][1001];
const ll mod =1e9+7;

int main(){
   int h,w;
   cin >> h >> w;
   rep(i,h) rep(j,w) cin >> maze[i][j];
   dp[0][0]=1;
   rep(i,h){
      rep(j,w){
         if (i+1 < h && maze[i+1][j]!='#'){
            dp[i+1][j]+=dp[i][j];
            dp[i+1][j]%=mod;
         }
         if (j+1 < w && maze[i][j+1] != '#'){
            dp[i][j+1] += dp[i][j];
            dp[i][j+1]%=mod;
         }
      }
   }
   cout << dp[h-1][w-1] << endl;

   
   return 0;
}



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

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
 int f(int n){
     if(n%2==0)
     return n/2;
     else
     {
         return 3*n+1;
     }
     
 }

int main() {
    int s;cin>>s;
    bool can=true;
    bool can2=false;
    vector<int>a(1000000);
    a.at(0)=s;
    int i=1;
    while(can)
    {
    a.at(i)=f(a.at(i-1));
    for(int j = 0; j <= i-1; j++)
    {
        if(a.at(i)==a.at(j))
        {
            cout<<i+1<<endl;
            can2=true;
            break;
        }
    }
    if (can2) {
        break;
    }
    
    i++;

        
    }
}
    

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

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

	int n; cin >> n;
	vector<ll> d(n);
	for (int i = 0; i < n; i++) cin >> d[i];
	int m; cin >> m;
	vector<ll> t(m);
	for (int i = 0; i < m; i++) cin >> t[i];
	sort(d.begin(), d.end());
	sort(t.begin(), t.end());
	int idx = 0;
	for (int i = 0; i < m; i++) {
		while (true) {
			if (d[idx] == t[i]) {
				idx++;
				break;
			}
			else {
				idx++;
				if (idx >= n) {
					cout << "NO" << endl;
					return 0;
				}
			}
		}
	}
	cout << "YES" << endl;
}


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

typedef long long ll;

#define PB push_back
#define MP make_pair

const int mxN = 2e5 + 1;
ll a[mxN], b[mxN];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
    ll n, m, k; cin >> n >> m >> k;
    for (ll i = 0; i < n; ++i) {
        cin >> a[i + 1];
        a[i + 1] += a[i];
    }
    for (ll i = 0; i < m; ++i) {
        cin >> b[i + 1];
        b[i + 1] += b[i];
    }
    int ans = 0;
    for (int i = 0, j = m; i <= n; ++i) {
        if (a[i] > k) break;
        while (a[i] + b[j] > k) j--;
        ans = max(i + j, ans);
    }
    cout << ans << "\n";
}



Measured memory_bytes: 6760
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a + b == 15) {
			System.out.println("+");
		} else if(a * b == 15) {
			System.out.println("*");
		} else {
			System.out.println("x");
		}
	}
}


Measured memory_bytes: 21844
n=int(input())
zp=[]
zl=[]
for i in range(n):
    a,b=map(int,input().split())
    zp.append(a+b)
    zl.append(a-b)
ans=max((max(zp)-min(zp)),(max(zl)-min(zl)))
print(ans)

Measured memory_bytes: 24772
S = list(map(int, input()))
length = len(S)

dp = {}

for i in range(length):
  for j in range(2):
    if i == 0:
      dp[(i,j)] = 0 if S[0] == j else 1
      continue

    # print('i,j:', i, j)
    inverse = 0 if S[i] == 1 else 1

    if S[i] == j: # 最后 S[i] 不动
      dp[(i, j)] = dp[(i-1, inverse)]
    else: # 最后 S[i] 变成inverse
      dp[(i, j)] = dp[(i-1, S[i])] + 1




# print('dp', dp)
print(min(dp[(length-1, 0)], dp[(length-1, 1)]))


Measured memory_bytes: 38984
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <string.h>
#include <string>
#include <queue>
#include <stack>
using namespace std;
typedef long long int ll;
ll dp[51][51][2510];
ll ans;
int x[51];
int n, av;
int main(void)
{
	scanf("%d %d",&n,&av);
	int i, j, k;
	for(i=1 ; i<=n ; i++)
	{
		scanf("%d",&x[i]);
	}
	dp[0][0][0]=1;
	for(i=1 ; i<=n ; i++)
	{
		for(j=0 ; j<=n ; j++)
		{
			for(k=0 ; k<=50*n ; k++)
			{
				if(k>=x[i] && j>=1)
				{
					dp[i][j][k]+=dp[i-1][j-1][k-x[i]];
				}
				dp[i][j][k]+=dp[i-1][j][k];
			}
		}
	}
	for(j=1 ; j<=n ; j++)
	{
		ans+=dp[n][j][j*av];
	}
	cout<<ans;
}

Measured memory_bytes: 50304
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def main():
    N = I()
    B = LI()
    ans = B[0] + B[-1]
    for i in range(1, N-1):
        ans += min(B[i], B[i-1]) # a[i]
    print(ans)
main()



Measured memory_bytes: 6704
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] ar = new int[N];
        for (int i = 0; i < N; i++) {
            ar[i] = sc.nextInt();
        }
        int count = 0;
        for (int i = 0; i < N-2; i++) {
            int max = Math.max(Math.max(ar[i], ar[i+1]), ar[i+2]);
            int min = Math.min(Math.min(ar[i], ar[i+1]), ar[i+2]);
            if (ar[i+1] != max && ar[i+1] != min) {
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <stdio.h>
#include <string>
#include <bitset>

using namespace std;
int main(){
  int H,W,K,ans=0;
  cin >> H >> W >> K ;
  char k;
  int M[H][W];

  for (int i=0;i<H;i++){
    for (int j=0;j<W;j++){
      cin >> k;
      if (k=='#'){
        M[i][j]=1;
      }
      else{
        M[i][j]=0;
      }
    }
  }
  int count;
  for (int bit = 0; bit < (1<<H); ++bit){
    for (int bit2 = 0; bit2 < (1<<W); ++bit2){
      count =0;
      for (int i=0; i<H;i++){
        for (int j=0; j<W;j++){
          if((bit & (1<<i))==0 && (bit2 & (1<<j))==0 && M[i][j]==1 ){
            count++;
          }
        }
      }
      if (count==K){
        ans++;
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
vector<int> v(10, 1);
int n, m, a, b, path[10][10], cnt=0;

void solve(int i){
    if(i==n-1){
        ++cnt;
        return;
    }
    if(path[v[i]][v[i+1]]!=-1){
        solve(i+1);
    }
}

int main(void){
    for(int i=0;i<10;++i)v[i] = i+1;
    for(int i=0;i<10;++i) for(int j=0;j<10;++j) path[i][j] = -1;
    cin >> n >> m;
    for(int i=0;i<m;++i){
        cin >> a >> b;
        path[a][b] = 1;
        path[b][a] = 1;
    }
    do{
        if(v[0]!=1) break;
        solve(0);
    }while(next_permutation(v.begin(), v.begin()+n));
    cout << cnt << endl;
}

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

int main(){
  long long int A, B, V, W, T;
  cin >> A >> V >> B >> W >> T;
  if(A == B){
    cout << "YES";
  }else if(A < B){
    A += V*T;
    B += W*T;
    if(B <= A) cout << "YES";
    else cout << "NO";
  }else{
    A -= V*T;
    B -= W*T;
    if(A <= B) cout << "YES";
    else cout << "NO";
  }

  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;

int N,Q;
string S;
vector<pair<char,char>> Query;

// 左に落ちるとき-1
// 落ちないとき0
// 右に落ちるとき1
int Check(int ind) {
  int now = ind;
  for (int i = 0; i < Q; i++) {
    if (S[now] == Query[i].fi) {
      if (Query[i].se == 'L') {
        now--;
      } else {
        now++;
      }
    }
    if (now == -1) {
      return -1;
    }
    if (now == N) {
      return 1;
    }
  }
  return 0;
}
int main() {
  cin >> N >> Q;
  cin >> S;
  int L = 0;
  int R = 0;
  for (int i = 0; i < Q; i++) {
    char c,d;
    cin >> c >> d;
    Query.emplace_back(c,d);
  }
  int left = -1;
  int right = N;
  while (right - left > 1) {
    int mid = (left + right) / 2;
    if (Check(mid) == -1) {
      left = mid;
    } else {
      right = mid;
    }
  }
  L = right;
  left = -1;
  right = N;
  while (right - left > 1) {
    int mid = (left + right) / 2;
    if (Check(mid) == 1) {
      right = mid;
    } else {
      left = mid;
    }
  }
  R = left;
  cout << R - L + 1 << endl;
  return 0;
}

Measured memory_bytes: 4104
//code written by a living bruh moment
import java.io.*;
import java.lang.*;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.StringTokenizer;
import java.util.Random;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collections;

public class Main {
    static InputReader in = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        out.println(c/a*b);
        out.close();
    }

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

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

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

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong()
        {
            return Long.parseLong(next());
        }
        public double nextDouble()
        {
            return Double.parseDouble(next());
        }
        public String nextLine()
        {
            try
            {
                return reader.readLine();
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
            return null;
        }
        public boolean hasNext()
        {
            String next=null;
            try
            {
                next=reader.readLine();
            }
            catch(Exception e)
            {
            }
            if(next==null)
            {
                return false;
            }
            tokenizer=new StringTokenizer(next);
            return true;
        }
    }
}

Measured memory_bytes: 32740
import java.io.FileNotFoundException;
import java.util.Scanner;

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

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		String S = sc.next();

		char[] s = S.toCharArray();
		for(int i=0;i<3;i++) {
			System.out.print(s[i]);
		}
		System.out.println();

	}
}

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

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

Measured memory_bytes: 3084
N, W = map(int, input().split())
a = list()
a.append([0, 0])
inf = float('inf')
for _ in range(N):
  x = list(map(int, input().split()))
  a.append(x)
dp = [[-inf for _ in range(W+1)]for _ in range(N+1)]
# dp[i][w] : i番目までで、wを超えないように選んだ時の価値の最大値
for w in range(W+1):
  dp[0][w] = 0
for i in range(N):
  for w in range(W+1):
    # i+1番目を選ぶかもしれないとき
    if w - a[i+1][0] >= 0:
      dp[i+1][w] = max(dp[i][w], dp[i][w-a[i+1][0]] + a[i+1][1])
    # i+1番目を選ばないとき
    else:
      dp[i+1][w] = dp[i][w]
print(dp[N][W])

Measured memory_bytes: 313656
import sys,re
c=lambda w,n:"".join([chr((ord(x)-97+n)%26+97)if x.isalpha()else x for x in w])
for i in sys.stdin:
	n=0
	while not re.search("th(e|is|at)",c(i,n)):n+=1
	print c(i,n).strip()

Measured memory_bytes: 4200
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	// your code goes here
	
  	ll N, K;
    cin>>N>>K;
	vector<pair<ll,ll>> vec;
	for(int i=0;i<N;i++){
      	ll a,b;
	  	cin>>a>>b;
		vec.push_back(make_pair(a,b));
	}
	sort(vec.begin(),vec.end());
  	int k=0;
  	ll ans;
  	while(K>0){
      if(vec[k].second>=K) {
      	ans=vec[k].first;  
  		break;
      }
      K-=vec[k].second;
      k++;
    }
  	cout<<ans;
	return 0;
}

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

n = input()
for i in range(len(n)-2):
    if n[i] == n[i+1] and n[i+1] == n[i+2]:
        print("Yes")
        sys.exit()
print("No")

Measured memory_bytes: 3316
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String args[]) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        String s1 = br.readLine().trim();
        String s2 = br.readLine().trim();
        int cnt=0;
        int n = Math.min(s1.length(), s2.length());
        for(int i=0;i<n;i++) {
            if(s1.charAt(i)!=s2.charAt(i))++cnt;
        }
        out.println(cnt);
        out.flush();
    }
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<string> s(N);
  int n_starts_with_b = 0;
  int n_ends_with_a = 0;
  int tmp = 0;
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    cin >> s[i];
    for (int j = 1; j < (int)s[i].size(); ++j) {
      if (s[i][j] == 'B' && s[i][j - 1] == 'A') {
	ans++;
      }
    }
    if (s[i][0] == 'B') n_starts_with_b++;
    if (s[i][s[i].size() - 1] == 'A') n_ends_with_a++;
    if (s[i][0] == 'B' && s[i][s[i].size() - 1] == 'A') tmp++;
    
  }
  if (max(n_starts_with_b, n_ends_with_a) == 0) {
    cout << ans << endl;
    return 0;
  }
  ans += min(n_starts_with_b, n_ends_with_a);
  if (tmp == max(n_starts_with_b, n_ends_with_a)) {
    ans -= 1;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 768
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] dish = new int[5];
		
		int maxMargin = 0;
		int sum = 0;
		for (int i = 0; i < 5; i++) {
			dish[i] = sc.nextInt();
			
			int margin = (10 - dish[i] % 10) % 10;
			
			sum += dish[i] + margin;
			maxMargin = Math.max(maxMargin, margin);
		}
		
		sum -= maxMargin;
		System.out.println(sum);
		
		sc.close();
	}
	
}




Measured memory_bytes: 26896
import java.util.*;

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

        int[] a = new int[3];
        a[0] = sc.nextInt();
        a[1] = sc.nextInt();
        a[2] = sc.nextInt();
        Arrays.sort(a);
        System.out.println(a[0] + a[1]);

    }
}


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

int main(){
  const int LIST_MAX_SIZE = 100; 
  int n;
  int nums[LIST_MAX_SIZE];
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> nums[i];
  }
  for(int i=0; i<n; i++){
    cout << nums[n-1-i];
    if(i<n-1)
      cout << " ";
  }
  cout << endl;
  return 0;  
}


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

#define ONLINE_JUDGE
#define pb(a) push_back(a)
#define ALL(a) (a.begin(), a.end())
#define FOR(x,to) for(x=0;x<(to);x++)

using ll = long long;

const int E5 = 1e5;

//////////// Solution /////////////////////////////////

int s(int n) {
	int res = 0;
	while (n) {
		res += n%10;
		n /= 10;
	}
	return res;
}
void solve() {
	int n;
	cin >> n;
	if (n%s(n)) {
		cout << "No\n";
	} else {
		cout << "Yes\n";
	}
}	

/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
	FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
	clock_t time_start = clock();
	#endif

	ios::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

	#ifndef ONLINE_JUDGE
	fclose(FIN);
	cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

	return 0;
}

	//////// End Initialization ///////////////////////////////////////

Measured memory_bytes: 256
use std::io::{BufRead, Write, stdin, stdout};
use std::cmp::min;
use std::collections::btree_map::BTreeMap;
use std::collections::btree_map::Entry::*;

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut s = String::new();
    input.read_line(&mut s).unwrap();
    s.clear();
    input.read_line(&mut s).unwrap();
    let a: Vec<u64> = s.split_whitespace().map(|x| x.parse().unwrap()).collect();
    let n = a.len();
    let mut map: BTreeMap<u64, (u64, u64)> = BTreeMap::new(); // number => (minimum index, amount)
    for (i, val) in a.into_iter().enumerate() {
        match map.entry(val) {
            Vacant(e) => {
                e.insert((i as u64, 1));
            }
            Occupied(mut e) => {
                let &(index, amount) = e.get();
                e.insert((min(i as u64, index), amount + 1));
            }
        }
    }
    let mut result = vec![0u64;n];
    while map.len() >= 2 {
        let max_n = *map.keys().next_back().unwrap();
        let max = map.remove(&max_n).unwrap();
        let next = map.iter_mut().next_back().unwrap();
        (next.1).0 = min((next.1).0, max.0);
        (next.1).1 += max.1;
        result[max.0 as usize] += (max_n - next.0) * max.1;
    }
    {
        let max_n = *map.keys().next_back().unwrap();
        let max = map.remove(&max_n).unwrap();
        result[max.0 as usize] += max_n * max.1;
    }
    for i in result {
        writeln!(output, "{}", i).unwrap();
    }
}

fn main() {
    let stdin = stdin();
    solve(stdin.lock(), stdout());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v = Vec::<u8>::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }
    #[test]
    fn case1() {
        test("2
1 2\n",
             "2
1\n");
    }
    #[test]
    fn case2() {
        test("10
1 2 1 3 2 4 2 5 8 1\n",
             "10
7
0
4
0
3
0
2
3
0\n");
    }
}

Measured memory_bytes: 14588
#include<cstdio>
#include<cstring>
char str[200005];
int cnt[30],sum[30];
int main(){
  scanf("%s",str+1);
  int n=strlen(str+1);
  for(int i=1;i<=n;++i)sum[str[i]-'a'+1]++;
  long long ans=0;
  for(int i=1;i<=n;++i){
    cnt[str[i]-'a'+1]++;
    ans=ans+n-i-(sum[str[i]-'a'+1]-cnt[str[i]-'a'+1]);
  }
  printf("%lld\n",ans+1);
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <climits>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define ll long long int
#define si(x) scanf("%d", &x)
#define sl(x) scanf("%lld", &x)
#define ss(s) scanf("%s", s)
#define pi(x) printf("%d\n", x)
#define pl(x) printf("%lld\n", x)
#define ps(s) printf("%s\n", s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define loop(i, L, R) for (int i = L; i < R; ++i)
#define looprev(i, L, R) for (int i = L; i > R; --i)
#define MAX(x, y) (x > y ? x : y)
#define MIN(x, y) (x < y ? x : y)
#define wh(t) while (t--)
#define pii pair<int, int>
#define ppi pair<int, pii>
#define pll pair<ll, ll>
#define ppl pair<ll, pll>
#define vii vector<int>
#define vvi vector<vii>
#define vl vector<ll>
#define vvl vector<vl>
#define maxHi priority_queue<int>
#define maxHl priority_queue<ll>
#define minHi priority_queue < int, vector<int>, greater<int>>
#define minHl priority_queue < ll, vector<ll>, greater<ll>>
#define mod 1000000007
#define inf 1000000000000000001
#define PI 3.1415926535897932384626
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define mp(x, y) make_pair(x, y)
#define mem(a, val) memset(a, val, sizeof(a))
#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(false)
#define endl "\n"
using namespace std;

/*  AH SH*T,  HERE WE GO AGAIN.  */



void solve()
{
    ll i, j, n, m;

    sl(n);

    ll ans = n + n * n + n * n * n;


    cout << ans << endl;

}


int32_t main()
{

    IOS;
    cin.tie(NULL);

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int T = 1;



    wh(T)
    {

        solve();

    }
}

Measured memory_bytes: 3780
#include <stdio.h>

long long a [100010];

int main (){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%lld",&a[i]);
    int zero =0;
    for(int i=0;i<n;i++)if(a[i]==0) zero ++;
    if(zero >0){
        // a[i] contains 0
        printf("0\n");
        return 0;
    }
    long long prod =1;
    for(int i=0;i<n;i++){
    if(a[i ] <=1000000000000000000/ prod ){
        // This condition is equivalent to prod*a[i] <=10ˆ18
        prod *=a[i];
    }else{
        printf("-1\n");
        return 0;
    }
    }
    printf("%lld\n",prod );
}


Measured memory_bytes: 2508
loop do
  n = gets.chomp.to_i
  break if n == 0
  scores = []
  n.times do |i|
    scores << gets.chomp.to_i
  end

  total = scores.inject{|memo, item| memo + item}
  total -= (scores.max + scores.min)
  puts total / (n - 2)
end

Measured memory_bytes: 6092
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
int c[26];

int main() {
	while(1) {
		char s[1210];
		if(scanf("%s", s) == EOF) break;
		for(int i = 0; s[i] != '\0'; ++i) {
			rep(j,26) {
				if(s[i] - 'a' == j) {
					c[j]++;
					break;
				} else if(s[i] - 'A' == j) {
					c[j]++;
					break;
				}
			}
		}
	}
	rep(i,26) {
		cout << (char)('a' + i) << " : " << c[i] << endl; 
	}
	return 0;
}

Measured memory_bytes: 1156
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int h = sc.nextInt();
        int a = sc.nextInt();

        int result = h / a;
        if (h % a != 0) {
            result += 1;
        }

        System.out.println(result);
    }
}

Measured memory_bytes: 22356
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;

int gcd(int x, int y) {
  int a = max(x, y);
  int b = min(x, y);
  int c = a%b;
  if (c != 0) return gcd(b, c);
  else return b;
   
  return 0;
}

int main(void) {
  int A, B, C;
  cin >> A >> B >> C;
  if (C % gcd(A, B) == 0) printf("YES");
  else printf("NO");
    
  return 0;
}

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

#define N 25
#define NIL -1


typedef struct {
  int pare, sib;
}Node;


int Depth(int);
int Height(int);



Node node[N];
int n = 0;


int main () {
  
  int i, j, k = 0, m = 0, child = 0, x = 0, cnt = 0;

  scanf("%d", &n);


  for(i = 0 ; i < n ; i++) {
    node[i].pare = NIL;
    node[i].sib = NIL;
  }
  
  for(i = 0 ; i < n ; i++){
    
    scanf("%d",&m);

    for(j = 0 ; j < 2 ; j++) {
      scanf("%d",&child);
      if(j == 0) x = child;
      else {
	node[child].sib = x;
	node[x].sib = child;
      }
      node[child].pare = m;
    }
  }


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

    cnt = 0;
    
    printf("node %d: parent = %d, sibling = %d, ", i, node[i].pare, node[i].sib);

    for(j = 0 ; j < n ; j++) {
      if(node[j].pare == i) cnt++; 
    }

    printf("degree = %d, depth = %d, height = %d, ", cnt, Depth(i), Height(i));

    if(node[i].pare == NIL) printf("root\n");
    else if(cnt > 0) printf("internal node\n");
    else printf("leaf\n");
  }
  
  return 0;
}



int Depth(int x) {

  if(node[x].pare == NIL) return 0;
  else return Depth(node[x].pare) + 1;
}


int Height(int x) {
  int i, r = NIL, l = NIL;

  for(i = 0 ; i < n ; i++) {
    if(node[i].pare == x) {
      if(l == NIL) l = Height(i);
      else r = Height(i);
    }
  }
  if(r > l) return r + 1;
  else return l + 1;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define substr(s,f,t) (s.substr(f-1,t-f+1))
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{ll x,y,t;};
struct Edge{ll to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=201010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(ll from,ll to,ll cost){E[from].pb({to,cost});}
};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll i,o,t,j,l,s,z;
  cin>>i>>o>>t>>j>>l>>s>>z;
  if(i>0&&j>0&&l>0){
    cout<<o+max((i-1)/2*2+(j-1)/2*2+(l-1)/2*2+3,i/2*2+j/2*2+l/2*2)<<endl;
  }else{
    cout<<o+i/2*2+j/2*2+l/2*2<<endl;
  }
  return 0;
}


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

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

Measured memory_bytes: 256
#include <cstdio>
static const int MAX = 10001;
int search(int A[],int n,int key);

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

    return 0;
}



int search(int A[], int n,int key){
    int i = 0;
    A[n] = key;
    while(A[i] != key) i++;
    return i != n;
}


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

int main(){
  string s;
  cin>>s;
  bool ad=false;
  for(int i=0;i<s.size();i++){
    for(int j=i+1;j<s.size();j++){
      if(s[i]==s[j]){
        ad=true;
        break;
      }
    }
  }
  if(ad) cout<<"no"<<endl;
  else cout<<"yes"<<endl;
}
     
      
      
      
    


Measured memory_bytes: 256
// ABC071A - 

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

typedef unsigned long long int ull;
typedef long long int ll;

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

	if (abs(x - a) < abs(x - b)) {
		cout << 'A' << endl;
	} else {
		cout << 'B' << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> (a);)
#define all(v) (v).begin(),(v).end()
#define trav(x,v) for(auto &x : v)
#define sz(v) int(v.size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;

int main(){
	cin.sync_with_stdio(0);
	cin.tie(0);

	int n, d1, d2;
	cin >> n >> d1 >> d2;

	vector<vi> c(2*n, vi(2*n));

	function<bool(int,int,int)> isgood = [&](int k, int i, int j){
		if(k == 0) return (i+j)%2 == 0;
		if((i+j)%2) ++j;
		int p = (i+j)/2;
		int q = (i-j)/2;
		return isgood(k-1, p, q);
	};

	auto f = [&](int d, int dif){
		int v2 = 0;
		while(d%2 == 0){
			d /= 2;
			 v2++;
		}
		rep(i,0,2*n) rep(j,0,2*n) c[i][j] += dif * isgood(v2, i, j);
	};
	f(d1, 1);
	f(d2, 2);

	vi cnt(4);

	rep(i,0,2*n) rep(j,0,2*n) cnt[c[i][j]]++;

	rep(t,0,4){
		if(cnt[t] >= n*n){
			int cur = 0;
			rep(i,0,2*n) rep(j,0,2*n) if(c[i][j] == t){
				cout << i << ' ' << j << endl;
				if(++cur == n*n) return 0;
			}
		}
	}
}

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

int main (){
    
    int x = 1 ;
    int i = 1 ;

    while( i != 0 ){
        cin >> i;
        if (i == 0) break;
        cout << "Case " << x << ": " << i << endl ;
        x++;
    }
    
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max()/2;
const int MOD = 1e9+7;

int k;
double p,e,t;
double res=0;

void dfs(int depth, double low, double high,double prob){
    if(depth==k){
        if(t-e<=(low+high)/2 && (low+high)/2<=t+e) res+=prob;
        return ;
    }
    if(t-e<=low && high<=t+e){
        res+=prob;
        return ;
    }
    if(t+e<low || high<t-e){
        return ;
    }
    double mid=(low+high)/2;
    if(mid>=t){
        double next=prob*p;
        dfs(depth+1,low,mid,prob-next);
        dfs(depth+1,mid,high,next);
    }
    else{
        double next=prob*p;
        dfs(depth+1,low,mid,next);
        dfs(depth+1,mid,high,prob-next);
    }
    return ;
}

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

    double low,high;
    cin>>k>>low>>high;
    cin>>p>>e>>t;
    dfs(0,low,high,1);
    cout<<fixed<<setprecision(10)<<res<<endl;
}


Measured memory_bytes: 3268
#include <iostream>
#include <string>
#include <utility>

struct dice{
	char right, front, top;

	dice( char r, char f, char t ){
		right = r, front = f, top = t;
	}

	void Roll( bool b ){
		std::swap( right, front );
		if( b ) right = 7 - right;
		else front = 7 - front;
	}

	void North(){
		std::swap( top, front );
		front = 7 - front;
	}

	void South(){
		std::swap( top, front );
		top = 7 - top;
	}

	void East(){
		std::swap( top, right );
		top = 7 - top;
	}

	void West(){
		std::swap( top, right );
		right = 7 - right;
	}

};


int main(){
	int n;
	while( std::cin >> n, n ){
		int sum = 1;
		dice d = dice( 3, 2, 1 );

		while( n-- ){
			std::string str;
			std::cin >> str;
			switch( str[0] ){
			case 'R':
				d.Roll(1);
				break;
			case 'L':
				d.Roll(0);
				break;
			case 'N':
				d.North();
				break;
			case 'S':
				d.South();
				break;
			case 'E':
				d.East();
				break;
			case 'W':
				d.West();
				break;
			}
			sum += d.top;
		}
		std::cout << sum << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1204
import java.util.Scanner;

public class Main {

    public static void main(final String[] args) {
        try(final Scanner scanner = new Scanner(System.in);) {
            final int first = scanner.nextInt();
            final int second = scanner.nextInt();
            if (first % 2 == 0 || second % 2 == 0) {
                System.out.println("Even");
            } else {
                System.out.println("Odd");
            }
        }
    }
}

Measured memory_bytes: 22740
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#include<cmath>
#include<queue>
#include<stack>
#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}
using namespace std;
typedef long long ll;
ll gcd(ll, ll);
vector<bool> to_binary(int);
int sum(vector<int>);
int min(vector<int>);
int max(vector<int>);
ll nCr(ll n, ll r);

const ll INF = 1LL << 60;

typedef tuple<ll, ll> mtupl;

bool mycomp(mtupl x, mtupl y) {
	return get<1>(x) < get<1>(y);
}

vector<vector<ll>> memo;

ll get(int x, int y) {
	if (memo[x][y] != -1)
		return memo[x][y];

	if (x == 0) return 1;
	if (y < x) return 0;

	memo[x][y] = get(x, y - 1) + get(x - 1, y - 1);
	return memo[x][y];
}

ll mpow(ll a, ll b) {
	ll ans = 1;
	for (ll i = 0; i < b; i++) {
		ans *= a;
		ans %= 1000000007;
	}
	return ans;
}

ll nCr(ll n, ll r) {
	ll res = 1;
	for (int i = 0; i < r; i++) {
		res *= (n - i);
	}
	for (int i = 1; i <= r; i++) {
		res /= i;
	}
	return res;
}

int vsum(vector<int> v) {
	int res = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		res += *it;
	return res;
}
int vmin(vector<int> v) {
	int min = INT32_MAX;
	for (auto it = v.begin(); it != v.end(); it++)
		min = std::min(min, *it);
	return min;
}
int vmax(vector<int> v) {
	int max = INT32_MIN;
	for (auto it = v.begin(); it != v.end(); it++)
		max = std::max(max, *it);
	return max;
}

ll gcd(ll A, ll B) {
	if (A == 0 || B == 0) return max(A, B);
	int r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}
	return B;
}

ll _gcd(ll A, ll B) {
	return (B == 0) ? A : gcd(A % B, B);
}

vector<bool> to_binary(int x) {
	vector<bool> res;
	while (x != 0) {
		res.push_back(x % 2);
		x /= 2;
	}
	return res;
}

template<int index>
bool comp(tuple<ll, ll, ll, ll> a, tuple<ll, ll, ll, ll> b) {
	return get<index>(a) < get<index>(b);
}

int vector_finder(std::vector<ll> vec, ll number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return index;
	}
	else { // 発見できなかったとき
		return 0;
	}
}


int len(int x) {
	return (int)log10(x) + 1;
}

int same_vec(vector<int> a, vector<int> b) {
	int res = 1, num = a.size();
	for (int i = 0; i < num; i++) {
		if (a[i] != b[i]) {
			res = 0;
			break;
		}
	}
	return res;
}


ll fibs[100] = { 0 };
ll fib(int n) {
	if (fibs[n] == 0) {
		return fibs[n] = fib(n - 1) + fib(n - 2);
	}
	return fibs[n];
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Program Start	

	int N, M;
	cin >> N >> M;

	priority_queue<ll> A;
	ll tmp;
	rep(i, N) {
		cin >> tmp;
		A.push(tmp);
	}

	rep(i, M) {
		A.push(A.top() / 2);
		A.pop();
	}

	ll Sum = 0;
	rep(i, N) {
		Sum += A.top();
		A.pop();
	}

	cout << Sum << endl;

ProgramEndPointLabel:;

	//Program End
#ifndef DEBUG
	system("pause");
#endif // !DEBUG


	return 0;
}




Measured memory_bytes: 1400
a, b, h, m = gets.split.map(&:to_f)
h_rad = 2 * Math::PI * ((h * 60.0 + m) / 720.0)
m_rad = 2 * Math::PI * (m / 60.0)
puts Math.sqrt(a * a + b * b - 2.0 * a * b * Math.cos(m_rad - h_rad))


Measured memory_bytes: 14692
#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 ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

void solve() {
  int n, x;
  cin >> n >> x;
  vector<int> v(n);
  rep(i,n) cin >> v[i];
  int ans = abs(x - v[0]);
  rep(i,n) ans = gcd(ans, abs(x - v[i]));
  cout << ans << endl;
}

int main() {
  solve();
  return 0;
}

Measured memory_bytes: 3796
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0
for i in range(a + 1):
    for j in range(b + 1):
        y = x - 500*i - 100*j
        if y >= 0 and y//50 <= c:
            cnt += 1
print(cnt)


Measured memory_bytes: 3060
def insertionSort(A, N):
    for i in range(N):
        s = ""
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
            A[j+1] = v
        print(' '.join(map(str, A)))
            
if __name__ == '__main__':
    N = int(input()) #1行目のNを取得する
    M = list(map(int,input().split()))
    insertionSort(M, N)


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

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <map>

using namespace std;

typedef pair<int,int> Paint;

bool Pairsecond(const Paint& pf,Paint&ps){//sortCompare
  return pf.second < ps.second;
}

#define anyfill(n,s) setw(n) << setfill(s)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define pb push_back
#define MAX 1000000000
#define MOD 1000000007


/*
確認ポイント
to_string() はC++11以降の実装;
cout<< (char)数値 //数値にあった文字に置き換えられる
cout<< (double)int型/(2など)//小数になる
length(),size()に括弧をつけ忘れてないか;
sort()が使える型//vector,string...
大文字小文字間違えてないか
cout << fixed << 小数計算//正しい小数表記になる(基本6桁)(e記法回避にも使える)
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
sqrt(数値型)でrootが取れる
vector.unique()は隣接した同じ要素を削除するので先にソートをする
*/
int main() { 
  int n,k;cin>>n>>k;
  //1/n * それぞれの試行回数
  int syokai;
  int ret = 0;
  for(int i = 1; n >= i; i++){
    int kaisu = 0;
    int nw;
    int peki = 1;
    for(int j = i; k > j; j*=2){
      kaisu++;
      nw = j;
      peki *= 2;
    }
    if(i == 1){
      syokai = peki;
      ret += 1;
    }else{
      ret += (syokai * n)/(peki * n);
    }
  }
  cout <<fixed << setprecision(10) << (double)(ret)/(syokai*n) << endl;
  return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

using P = pair<int, int>;

// 座標圧縮
int compress(vector<int> &x1, vector<int> &x2, int w, int n)
{
	vector<int> xs;
	for (int i = 0; i < n; i++)
	{
		for (int d = -1; d <= 1; d++)
		{
			int tx1 = x1[i] + d;
			int tx2 = x2[i] + d;
			if (0 <= tx1 && tx1 < w)
			{
				xs.push_back(tx1);
			}
			if (0 <= tx2 && tx2 < w)
			{
				xs.push_back(tx2);
			}
		}
	}
	sort(ALL(xs));
	xs.erase(unique(ALL(xs)), xs.end());
	for (int i = 0; i < n; i++)
	{
		x1[i] = lower_bound(ALL(xs), x1[i]) - xs.begin();
		x2[i] = lower_bound(ALL(xs), x2[i]) - xs.begin();
	}
	return (int)xs.size();
}
bool filled[6030][6030];

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (1)
	{
		int w, h, n;
		cin >> w >> h;
		if (w == 0 && h == 0)
		{
			break;
		}
		cin >> n;
		w *= 2;
		h *= 2;
		vector<int> x1(n), x2(n), y1(n), y2(n);
		for (int i = 0; i < n; i++)
		{
			cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
			x1[i] *= 2;
			x2[i] *= 2;
			y1[i] *= 2;
			y2[i] *= 2;
		}
		w = compress(x1, x2, w, n);
		h = compress(y1, y2, h, n);
		for (int i = 0; i < 6030; i++)
		{
			for (int j = 0; j < 6030; j++)
			{
				filled[i][j] = false;
			}
		}
		for (int i = 0; i < n; i++)
		{
			for (int j = x1[i]; j <= x2[i]; j++)
			{
				for (int k = y1[i]; k <= y2[i]; k++)
				{
					filled[k][j] = true;
				}
			}
		}
		int ans = 0;
		for (int y = 0; y < h; y++)
		{
			for (int x = 0; x < w; x++)
			{
				if (filled[y][x])
				{
					continue;
				}
				ans++;
				queue<P> que;
				que.push(P(x, y));
				filled[y][x] = true;
				while (que.size())
				{
					auto now = que.front();
					// cout << now.first << ' ' << now.second << endl;
					que.pop();
					for (int i = 0; i < 4; i++)
					{
						int nx = now.first + dx[i];
						int ny = now.second + dy[i];
						if (0 <= nx && nx < w && 0 <= ny && ny < h)
						{
							if (!filled[ny][nx])
							{
								que.push(P(nx, ny));
								filled[ny][nx] = true;
							}
						}
					}
				}
			}
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 38616
#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() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

auto GCD(auto a, auto b) { //ユークリッドの互助法で最大公約数
    if(a % b == 0)return b;
    else return GCD(b, a % b);
}
auto LCM(auto a, auto b) { //GCDを使って最小公倍数を求める
    auto g = GCD(a, b);
    return (a / g) * b;
}

int main() {
    int K;cin >> K;
    LL ans = 0;
    for(LL i = 1;i <= K;++i) for(LL j = 1;j <= K;++j) for(LL k = 1;k <= K;++k) {
        LL tmp = GCD(i,j);
        ans += GCD(tmp,k);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3648
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

// AOJ 0044
public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		while (sc.hasNextInt()) {
			int n = sc.nextInt(), a, b;
			for (a = n - 1; !isPrime(a); a--) {}
			for (b = n + 1; !isPrime(b); b++) {}
			
			System.out.println(a + " " + b);
		}
	}
	
	public static boolean isPrime(int n) {
		for (int i = 2; i * i <= n; i++) 
			if (n % i == 0) return false;
		return n != 1;
	}	
}

Measured memory_bytes: 12000
n = int(input())
a = [int(i) for i in input().split()]

ans = 0

for i in range(n):
    cur = a[i]
    #print(cur)
    while(cur != 0):
        if cur % 2 == 0:
            cur = cur // 2
            ans += 1
        else:
            break
        
print(ans)

Measured memory_bytes: 4148
#include <iostream>
#include <string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<limits.h>
#include<string>
#include<iomanip>
#include<numeric>
#include<queue>
using namespace std;

long long  mod = 1000000007;

long max(long x, long y) {
	return x > y ? x : y;
}

long min(long x, long y) {
	return x < y ? x : y;
}

long factorial(long n) {
	if (n == 1) {
		return 1;
	}
	else {
		return n * factorial(n - 1);
	}
}

long long  fel(long long  n,long long  f) {

		if (f == 1) {
			return n % mod;
		}
		else if (f % 2 == 0) {
			return (fel(n,f / 2) * fel(n,f / 2)) % mod;
		}
		else {
			return ((n  * fel(n,f / 2) %mod) * fel(n,f / 2))% mod;
		}
	

}


int main()
{
	int a, b;
	cin >> a >> b;
	for (int i = 1;i <= 3;i++) {
		if (a!= i and b!= i) {
			cout << i;
		}
	}
	}






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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aut(r,v) __typeof(v) r = (v)
#define each(it,o) for(aut(it,(o).begin()); it!=(o).end(); ++it)
#define reach(it,o) for(aut(it,(o).rbegin()); it!=(o).rend(); ++it)
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T1, typename T2> ostream& operator<<(ostream& o, const pair<T1, T2>& p)
{return o<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>string join(const vector<T>&v, string del=", ")
{stringstream s;rep(i,v.size())s<<del<<v[i];return s.str().substr(del.size());}
template<typename T>ostream& operator<<(ostream& o, const vector<T>&v)
{if(v.size())o<<"["<<join(v)<<"]";return o;}
template<typename T>ostream& operator<<(ostream& o, const vector<vector<T> >&vv)
{int l=vv.size();if(l){o<<endl;rep(i,l){o<<(i==0?"[ ":",\n  ")<<vv[i]<<(i==l-1?" ]":"");}}return o;}
template<typename T>ostream& operator<<(ostream& o, const set<T>& st)
{vector<T> v(st.begin(),st.end());o<<"{ "<<join(v)<<" }";return o;}
template<typename T1, typename T2>ostream& operator<<(ostream& o, const map<T1, T2>& m)
{each(p,m){o<<(p==m.begin()?"{ ":",\n  ")<<*p<<(p==--m.end()?" }":"");}return o;}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

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

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const ll INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int di[] = {0, -1, -1, -1, 0, 1, 1, 1};
int dj[] = {1, 1, 0, -1, -1, -1, 0, 1};

int w,h;
vvi C;

void dfs(pii cur, pii pre, int num){
    int i = cur.fi, j = cur.se;
    C[i][j] = 0;
    rep(k,8){
        int ni = i+di[k];
        int nj = j+dj[k];
        if(ni < 0 || h <= ni) continue;
        if(nj < 0 || w <= nj) continue;
        if(C[ni][nj] == 0) continue;
        if(ni == pre.fi && nj == pre.se) continue;
        dfs(pii(ni,nj), pii(i,j), num);
    }
}

void solve(){
    C = vvi(h, vi(w));
    rep(i,h) rep(j,w) cin >> C[i][j];

    int cnt = 0;
    rep(i,h){
        rep(j,w){
            if(C[i][j] == 1)
                dfs(pii(i,j), pii(-1,-1), ++cnt);
        }
    }
    cout << cnt << endl;
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    while(cin >> w >> h, w != 0 && h != 0){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3424