akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }


long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

map<int, int> prime(ll x) {
    map<int, int> p_map;
    ll p = 2;
    int cnt = 0;
    int i = 0;
    while (p * p <= x) {
        if (x % p == 0) {
            x /= p;
            p_map[p]++;
        }
        else {
            p++;
        }
    }
    if (x != 1) {
        p_map[x]++;
    }
    return p_map;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    vll A(N);
    ll m = 1000000007;
    rep(i, N) cin >> A[i];
    map<int, int> ans_pmap;
    rep(i, N) {
        auto pmap = prime(A[i]);
        for (auto& p : pmap) {
            ans_pmap[p.first] = max(ans_pmap[p.first], pmap[p.first]);
        }
    }

    ll ans = 0;
    rep(i, N) {
        ans += modinv(A[i], m);
        ans %= m;

    }
    for (auto& p : ans_pmap) {
        ans *= modpow(p.first, p.second, m);
        ans %= m;
    }
    

    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 N = sc.nextInt();
		String[] s = new String[N + 1];
		String[] a = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s",
				"t", "u", "v", "w", "x", "y", "z" };
		int[] b = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
		int[] c = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
		int d = 0;

		for (int i = 0; i <= N; i++) {
			s[i] = sc.nextLine();
		}

		// 文字列ごとのループ
		for (int i = 1; i <= N; i++) {
			// 文字ごとのループ
			for (int j = 0; j < s[i].length(); j++) {
				// アルファベットごとのループ
				String str = s[i].substring(j, j + 1);
				for (int k = 0; k < 26; k++) {
					if (a[k].equals(str)) {
						c[k]++;
						break;
					}
				}
			}
			for (int j = 0; j < 26; j++) {
				if (i > 1) {
					if (b[j] > 0) {
						if (c[j] < b[j]) {
							int n = Integer.valueOf(c[j]); 
							b[j] = n;
							c[j] = 0;
						} else {
							c[j] = 0;
						}
					} else {
						c[j] = 0;
					}
				} else {
					int n = Integer.valueOf(c[j]); 
					b[j] = n;
				}
			}
		}
		for (int i = 0; i < 26; i++) {
			while (b[i] >= 1) {
				System.out.print(a[i]);
				b[i]--;
				d++;
			}
		}
		if (d != 0) {
			System.out.print(" ");
		}

		sc.close();
	}
}


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

typedef pair<long long int, long long int > point;

bool cw(const point &a, const point &b, const point &c) {
    return (b.first - a.first) * (c.second - a.second) - (b.second - a.second) * (c.first - a.first) < 0;
}

vector<point> convexHull(vector<point> p) {
    long long int n = p.size();
    if (n <= 1)
        return p;
    int k = 0;
    sort(p.begin(), p.end());
    vector<point> q(n * 2);
    for (long long int i = 0; i < n; q[k++] = p[i++])
        for (; k >= 2 && !cw(q[k - 2], q[k - 1], p[i]); --k)
            ;
    for (long long int i = n - 2, t = k; i >= 0; q[k++] = p[i--])
        for (; k > t && !cw(q[k - 2], q[k - 1], p[i]); --k)
            ;
    q.resize(k - 1 - (q[0] == q[1]));
    return q;
}

long long int area(const point &a, const point &b, const point &c) {
    return abs((b.first - a.first) * (c.second - a.second) - (b.second - a.second) * (c.first - a.first));
}

long long int dist(const point &a, const point &b) {
    return abs(a.first - b.first)+ abs(a.second - b.second);
}

long long int diameter(const vector<point> &p) {
    vector<point> h = convexHull(p);
    long long int m = h.size();
    if (m == 1)
        return 0;
    if (m == 2)
        return dist(h[0], h[1]);
    int k = 1;
    while (area(h[m - 1], h[0], h[(k + 1) % m]) > area(h[m - 1], h[0], h[k]))
        ++k;
    long long int res = 0;
    for (long long int i = 0, j = k; i <= k && j < m; i++) {
        res = max(res, dist(h[i], h[j]));
        while (j < m && area(h[i], h[(i + 1) % m], h[(j + 1) % m]) > area(h[i], h[(i + 1) % m], h[j])) {
            res = max(res, dist(h[i], h[(j + 1) % m]));
            ++j;
        }
    }
    return res;
}

int main() {
	long long n,i,j,k,x,y,z,M;
	cin>>n;
    vector<point> points(n);
    for (i=0;i<n;i++)
    {
    	cin>>x>>y;
    	points[i]=point(x,y);
	}
    long long int d = diameter(points);
    cout << d << endl;
}

Measured memory_bytes: 15612
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <sstream>
#include <cmath>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(s,i,n) for(int i=s;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define skip(i,n,p) for(int i=0;i<n;i+=p)
#define all(a)  (a).begin(),(a).end()
#define int64 long long
#define debug cout << __FILE__ << ":" << __LINE__ << endl;
#define INF 1e9

struct Init {
    Init() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
        cout << fixed;
    }
} init;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    for(int i = 0; i < (int) v.size(); i++) {
        ostr << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const map<_K, _V>& v) {
    ostr << "{";
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << (*iter).first << ": " << (*iter).second << ", ";
    }
    ostr << "}";
    return ostr;
}

template <typename _K>
ostream& operator << (ostream& ostr, const set<_K>& v) {
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << *iter << (iter != v.end() ? " " : "");
    }
    return ostr;
}

int64 gcd(int64 a, int64 b) {
    if (a < b) a, b = b, a;
    if (a % b == 0) return b;
    return gcd(b, a % b);
}

int64 modinv(int64 a, int64 m) {
    int64 b = m, u = 1, v = 0;
    while (b) {
        int64 t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// https://en.wikipedia.org/wiki/Trial_division
#define M map<int64, int64>
M f(int64 n) {
    M m;

    while (n % 2 == 0) {
        m[2]++;
        n = n / 2;
    }

    int64 c = 3;
    while (c * c <= n) {
        if (n % c == 0) {
            n = n / c;
            m[c]++;
        } else {
            c += 2;
        }
    }
    if (n != 1) m[n]++;
    return m;
}

int main() {
    int H, N;
    cin >> H >> N;
    
    int A[N], B[N];
    rep(i, N) cin >> A[i] >> B[i];

    int dp[N+1][H+1];
    rep(i, H + 1) dp[0][i] = INF;

    rep(i, N) {
        int a = A[i];
        int b = B[i];

        rep(j, H+1) dp[i+1][j] = dp[i][j];
        dp[i+1][0] = 0;

        reps(1, j, H+1) {
            if (j <= a) {
                dp[i+1][j] = min(dp[i+1][j], b);
            } else {
                dp[i+1][j] = min(dp[i+1][j], dp[i+1][j-a] + b);
            }
        }
    }

    cout << dp[N][H] << endl;
}


Measured memory_bytes: 39424
#include <cstdio>
#include <cstring>
using namespace std;

int n, m, s;
int dp[100][3010];

void solve(){
	n *= n;
	memset(dp,0,sizeof(dp));
	dp[0][0] = 1;
	for(int i = 1; i <= m; i++){
		for(int j = n; j > 0; j--){
			for(int k = i; k <= s; k++){
				dp[j][k] = (dp[j][k]+dp[j-1][k-i])%100000;
			}
		}
	}
	printf("%d\n", dp[n][s]);
}

int main(){
	while(scanf("%d%d%d",&n,&m,&s),n||m||s) solve();
}

Measured memory_bytes: 2212
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
ll n,m,v,i;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n;
  std::vector<ll> v(n*3);
  rep(i,n*3) cin>>v[i];
  sort(all(v));
  // rep(i,n*3) cout<<v[i]<<endl;
  ll ans = 0,cnt = 0;
  for(i = n*3 - 2 ; cnt < n; i -= 2 ) {
    ans += v[i];
    cnt++;
    // cout<<v[i]<<endl;
    if(cnt >= n) break;
  }
  cout<<ans<<endl;
}

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


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef pair<string,string> P;
const int M=1000000007;
class RH {
public:
  unsigned long long p[111],h[111];
  int n;
  void init(string s) {
    n=s.size();
    p[0]=1;h[0]=0;
    for(int i=0; i<n; i++) {
      h[i+1]=h[i]*M+s[i];
      p[i+1]=p[i]*M;
    }
  }
  unsigned long long H() {
    return h[n];
  }
};
map<unsigned long long,vector<string> > m;
 
void change(string s) {
  int n=s.size();
  for(int i=0; i<n; i++) {
    string t=s.substr(0,i)+s.substr(i+1);
    RH r;
    r.init(t);
    m[r.H()].push_back(s);
    for(int j=0; j<26; j++) {
      t=s;
      t[i]='a'+j;
      r.init(t);
      m[r.H()].push_back(s);
    } 
  }
  for(int i=0; i<=n; i++) {
    for(int j=0; j<26; j++) {
      string t=s.substr(0,i)+(char)('a'+j)+s.substr(i);
      RH r;
      r.init(t);
      m[r.H()].push_back(s);
    }
  }
  for(int i=0; i<n-1; i++) {
    swap(s[i],s[i+1]);
    RH r;
    r.init(s);
    swap(s[i],s[i+1]);
    m[r.H()].push_back(s);
  }
}
int main() {
  int n;
  while(cin >> n && n) {
    m.clear();
    int d;
    cin >> d;
    string s[n];
    for(int i=0; i<n; i++) {
      cin >> s[i];
      change(s[i]);
    }
    vector<P> ans;
    if(d==1) {
      for(int i=0; i<n; i++) {
        RH r;
        r.init(s[i]);
        vector<string> v=m[r.H()];
        for(int j=0; j<v.size(); j++) {
          if(s[i]==v[j]) continue;
          P p=P(s[i],v[j]);
          if(p.first>p.second) swap(p.first,p.second);
          ans.push_back(p);
        }
      }
    } else {
      for(map<unsigned long long,vector<string> >::iterator it=m.begin(); it!=m.end(); it++) {
        vector<string> v=it->second;
        sort(v.begin(),v.end());
        v.erase(unique(v.begin(),v.end()),v.end());
        for(int i=0; i<v.size(); i++) {
          for(int j=i+1; j<v.size(); j++) {
            ans.push_back(P(v[i],v[j]));
          }
        }
      }
    }
    sort(ans.begin(),ans.end());
    ans.erase(unique(ans.begin(),ans.end()),ans.end());
    for(int i=0; i<ans.size(); i++) cout << ans[i].first << "," << ans[i].second << endl;
    cout << ans.size() << endl;
  }
  return 0;
}


Measured memory_bytes: 17376
<?php
  
$sString = readline();
$strList = ["A","T","C","G"];
$longestString = 0;
$strCtr = 0;
$len = strlen($sString);
for($x = 0; $x< $len; $x++){
  if(in_array($sString[$x],$strList)){
    $strCtr++;
  } else {
    $strCtr = 0;      
  }
  if($strCtr > $longestString){$longestString = $strCtr;}
}

print $longestString;

Measured memory_bytes: 5112
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(a) a.begin(),a.end()
typedef long long ll;
typedef pair<int,int> Bug;
vector<Bug> bug;
int N;

int solve(int l,int r){
	if(l+1==r)return l;
	int k=(l+r)/2;
	ll sumA=0;
	priority_queue<int> pq;
	rep(i,k){
		sumA+=bug[i].second;
		pq.push(bug[i].second);
	}

	if(sumA<=(ll)k*bug[k-1].first){
		return solve(k,r);
	}

	for(int i=k;i<N;i++){
		int d=pq.top()-bug[i].second;
		if(d>0){
			sumA-=d;
			pq.pop();
			pq.push(bug[i].second);
			if(sumA<=(ll)k*bug[i].first){
				return solve(k,r);
			}
		}
	}
	return solve(l,k);
}


int main(void){
	cin>>N;
	bug.resize(N);
	rep(i,N)cin>>bug[i].second>>bug[i].first;
	sort(all(bug),greater<Bug>());
	cout<<solve(0,N+1)<<endl;

	return 0;
}

Measured memory_bytes: 28040
let nil = -1

type tree = { mutable parent : int; mutable child : int; mutable bro : int; mutable depth : int }

let make () = { parent = nil; child = nil; bro = nil; depth = nil }

let set_depth t n =
  let rec root i =
    if i = n then nil
    else if t.(i).parent = nil then i
    else root (i + 1) in
  let rec doit i d =
    t.(i).depth <- d;
    if t.(i).bro <> nil then doit t.(i).bro d;
    if t.(i).child <> nil then doit t.(i).child (d + 1) in
  doit (root 0) 0

let print_tree t =
  t |> Array.iteri (fun i _ ->
    print_string "node "; print_int i;
    print_string ": parent = "; print_int t.(i).parent;
    print_string ", depth = "; print_int t.(i).depth;
    print_string (if t.(i).parent = nil then ", root, [" else if t.(i).child = nil then ", leaf, [" else ", internal node, [");
    let rec print_children c =
      if c <> nil then begin
        if c <> t.(i).child then print_string ", ";
        print_int c;
        print_children t.(c).bro
      end in
    print_children t.(i).child;
    print_string "]\n")

let () =
  let n = Scanf.scanf "%d " (fun i -> i) in
  let t = Array.init n (fun _ -> make ()) in
  for _ = 0 to n - 1 do
    let (id, k) = Scanf.scanf "%d %d " (fun id k -> (id, k)) in
    let left_child = ref 0 in
    for i = 0 to k - 1 do
      let c = Scanf.scanf "%d " (fun i -> i) in
      t.(c).parent <- id;
      if i = 0 then t.(id).child <- c else t.(!left_child).bro <- c;
      left_child := c;
    done;
  done;
  set_depth t n;
  print_tree t

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

using namespace std;

int main() {
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  vector<int> x(N);
  vector<int> y(M);
  for (int i=0; i<N; ++i) cin >> x.at(i);
  for (int i=0; i<M; ++i) cin >> y.at(i);
  
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  int dz = y.at(0) - x.at(N-1);
  if (dz <= 0) cout << "War" << endl;
  else if (X >= Y) cout << "War" << endl;
  else {
    vector<int> z(dz);
    for (int i=0; i<dz; ++i) {
      z.at(i) = y.at(0) - i;
    }
    bool flag = false;
    for (int i=0; i<dz; ++i) {
      for (int j=X+1; j<=Y; ++j) {
        if (j == z.at(i)) {
          flag = true;
          break;
        }
      }
    }
    if (flag == false) cout << "War" << endl;
    else cout << "No War" << endl;
  }
}
  
  

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

n, m = map(int, input().split())

wa = 0
marked = [0 for _ in range(n)]
cnt = [0 for _ in range(n)]

for i in range(m):
    x, s = map(str, input().split())
    x = int(x) - 1
    if s == "AC":
        if marked[x] == False:
            wa += cnt[x]
            marked[x] = True
    else:
        cnt[x] += 1

print(sum(marked), wa)

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

int main(){
    int a,b;
    cin >> a >> b;
    if((a+b)%2==0){
        cout << (a+b)/2 << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int h, w;
    
    while(1){
        cin >>h >>w;
        if((h == 0) &&(w == 0)){
            break;
        }
        for(int i = 1;i <= h;i++){
            for(int j = 1;j <= w;j++){
                cout << "#";
            }
            cout << endl; 
        }
        cout <<endl;
    }
    return 0;
}


Measured memory_bytes: 3080
# coding: utf-8
def prime_factorization(N):
    # 辞書型で素因数分解を返す
    pf = {}
    for i in range(2, int(N**0.5) + 1):
        while N % i == 0:
            if i not in pf.keys():
                pf[i] = 1
            else:
                pf[i] += 1
            N //= i
    if N > 1:
        pf[N] = 1
    return pf

N, P = map(int, input().split())
pf = prime_factorization(P)
ans = 1
for k in pf.keys():
    ans *= k ** (pf[k] // N)
print(ans)

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

int main(){
  int n;
  cin >> n;
  int r=n,l=0;
  
  string t,u;
  cout << l << endl;
  cin >> t;
  if(t=="Vacant"){return 0;}
  u=t;
  
  while(r-l>1){
    int y=(l+r)/2;
    cout << y << endl;
    string s;
    cin >> s;
    if(s=="Vacant"){return 0;}
    if(((y-l+1)%2==0 && u!=s) || ((y-l+1)%2 != 0 && u==s)){
      l=y;
      u=s;
    }else {r=y;}
}
  
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  int n;
  cin >> n;
  vector<string> ss(n);
  vector<int> ts(n);
  for (int i = 0; i < n; i++) {
    cin >> ss[i] >> ts[i];
  }
  string key;
  cin >> key;
  bool flag = false;
  int64 ans = 0;
  for (int i = 0; i < n; i++) {
    if(flag) {
      ans += ts[i];
    }
    if (ss[i] == key) flag = true;
  }
  cout << ans << endl;
}

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

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

    return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}
#define N 100000
pii p[3*N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x = gi();
    int y = gi();
    int a = gi();
    int b = gi();
    int c = gi();

    int pn = 0;
    for (int i = 0; i < a; i++)
        p[pn++] = {gi(), 0};
    for (int i = 0; i < b; i++)
        p[pn++] = {gi(), 1};
    for (int i = 0; i < c; i++)
        p[pn++] = {gi(), 2};
    sort(p, p+a+b+c, greater<pii>());

    ll res = 0, rm = x+y;
    for (int i = 0; i < a+b+c && rm; i++) {
        while (x == 0 && p[i].second == 0)
            i++;
        while (y == 0 && p[i].second == 1)
            i++;
        res += p[i].first;
        rm--;
        if (p[i].second == 0)
            x--;
        if (p[i].second == 1)
            y--;
    }

    cout << res << endl;

    return 0;
}


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

int main() {
	int	N;
	cin >> N;
	map<string, int> m;
	rep(i, N)
	{
		int	a;
		string b;
		cin >> a >> b;
		if (a == 0)
		{
			int c;
			cin >> c;
			m[b] = c;
		}
		else if (a == 1)
		{
			if (m.count(b))
				cout << m.at(b) << endl;
			else
				cout << 0 << endl;
		}
		else
			m.erase(b);
	}
}



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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main(){
	ll n,m, ans = 1;
	cin >>n >>m;
	
	for(ll i=1; i*i <=m; i++){
		if(m % i != 0) continue;
		
		if(i*n <=m)     ans = max(ans, i);
		if((m/i)*n <=m) ans = max(ans, m/i);
		
	}
	cout << ans <<"\n";
}


Measured memory_bytes: 256
jun = 0
while True:
    num = 0
    a,b = map(int,input().split())
    if a == 0 and b == 0:
        break
    if jun > 0:
        print()
    for i in range(a,b + 1):
        if i % 400 == 0:
            print(i)
            num += 1
        elif i % 100 == 0:
            continue
        elif i % 4 == 0:
            print(i)
            num += 1
    if num == 0:
        print("NA")
    jun += 1

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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int n, Q;
int arr[N + 2];


void solve()
{
	int n;
	cin >> n;
	lop(i, 1, n )
	{
		int x; cin >> x;
		arr[x]++;
	}
	lop(i, 1, n + 1) cout << arr[i] << endl;

}

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

	int test = 1;
	// cin >> test;
	while (test--)solve();


}





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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()

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

  int A, B, C;
  cin >> A >> B >> C;
  int fivCount = 0;
  int sevCount = 0;

  if(A == 5) fivCount++;
  if(A == 7) sevCount++;

  if(B == 5) fivCount++;
  if(B == 7) sevCount++;

  if(C == 5) fivCount++;
  if(C == 7) sevCount++;

  if(fivCount == 2 && sevCount == 1) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
const long long mod = 1000000007;
//const long long mod = 998244353;

char s[100001];
long long r[100001][13];
int main() {
	scanf("%s", s);
	int m = 1;
	int N;
	for (int i = 0; ; i++) {
		if (s[i] == 0) {
			N = i;
			break;
		}
	}
	for (int i = 0; i < N; i++) {
		if (s[N - i - 1] == '?') {
			if (i == 0) {
				for (int j = 0; j < 10; j++) {
					r[0][j] = 1;
				}
			}
			else {
				for (int k = 0; k < 10; k++) {
					for (int j = 0; j < 13; j++) {
						r[i][(j + m * k) % 13] += r[i - 1][j];
						r[i][(j + m * k) % 13] %= mod;
					}
				}
			}
		}
		else {
			int n = s[N - i - 1] - '0';
			if (i == 0) {
				r[0][n] = 1;
			}
			else {
				for (int j = 0; j < 13; j++) {
					r[i][(j + m * n) % 13] = r[i - 1][j];
				}
			}
		}
		m *= 10;
		m %= 13;
	}
	printf("%lld", r[N - 1][5]);
	return 0;
}

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

int main()
{
    long long size;
    cin >> size;
    queue<long long> n[size];
    long long q;
    cin >> q;
    for (long long i = 0; i < q; i++)
    {
        long long a, t, x;
        cin >> a >> t;
        if (a == 0)
        {
            cin >> x;
            n[t].push(x);
        }
        else if (a == 1)
        {
            if(n[t].empty() == 1) continue;
            cout << n[t].front() << endl;
        }
        else
        {
            if(n[t].empty() == 1) continue;
            //n[t].dequeue();
            n[t].pop();
        }
    }

    return 0;
}


Measured memory_bytes: 5040
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main{

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		
		String str[] = reader.readLine().split(" ");
		
		int stoneCount= Integer.parseInt(str[0]);
		int maxJump = Integer.parseInt(str[1]);
		
		String str1[] = reader.readLine().split(" ");
		
	    int stones[] = new int[stoneCount];
	    for(int i=0;i<stoneCount; i++) stones[i] = Integer.parseInt(str1[i]);
	    
	    int dp[] = new int[stoneCount+1];
	    Arrays.fill(dp, Integer.MAX_VALUE);
	    dp[0] = 0;
	    for(int i=0;i<stoneCount; i++)
	    {
	    	for(int j=i+1; j<=i+maxJump; j++)
	    	{
	    		if(j<stoneCount)
	    		{
	    			dp[j] = Math.min(dp[j], dp[i] + Math.abs(stones[i] - stones[j]));
	    		}
	    	}
	    }
	    System.out.println(dp[stoneCount-1]);
	}
}


Measured memory_bytes: 41264
#include<iostream>
#include<string.h>
#include<algorithm>

using namespace std;

const char leftKey[]={'q','w','e','r','t','a','s','d','f','g','z','x','c','v','b'};
const char rightKey[]={'y','u','i','o','p','h','j','k','l','n','m'};

int main(){
	
	char str[32];
	int inpStrNum;
	int cnt;
	int lr,foundKey;
	
	while(true){
		fill(str,str+32,'\0');
		cnt=0;
		
		lr=true;//leftならfalse、rightならtrue
		
		cin>>str;
		
		if(str[0]=='#'){
			break;
		}
		
		lr=1;
		for(int i=0;i<15;i++){
			if(str[0]==leftKey[i]){
				lr=0;
				break;
			}
		}
		
		for(int i=1;i<strlen(str);i++){
			for(int j=0;j<15;j++){
				if(str[i]==leftKey[j] && lr==1){
					cnt++;
					//foundKey=true;
					lr=0;
					break;
				}
			}
			for(int j=0;j<11;j++){
				if(str[i]==rightKey[j] && lr==0){
					cnt++;
					lr=1;
					break;
				}
			}
		}
		
		cout<<cnt<<endl;
	}
}

Measured memory_bytes: 1140
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define printP(x) "(" << (x).first << ", " << (x).second << ")"
#define mod 1000000007
using namespace std;
typedef pair<llint, llint> P;
typedef pair<llint, P> E;

struct UnionFind{
	int size;
	vector<int> parent;
	
	UnionFind(){}
	UnionFind(int size){
		this->size = size;
		parent.resize(size+1);
		init();
	}
	void init(){
		for(int i = 0; i <= size; i++) parent[i] = i;
	}
	int root(int i){
		if(parent[i] == i) return i;
		return parent[i] = root(parent[i]);
	}
	bool same(int i, int j){
		return root(i) == root(j);
	}
	void unite(int i, int j){
		int root_i = root(i), root_j = root(j);
		if(root_i == root_j) return;
		parent[root_i] = root_j;
	}
};


llint n, k;
llint p[200005], sum[200005];
UnionFind uf(200005);
set<llint> S;

int main(void)
{
	cin >> n >> k;
	for(int i = 1; i <= n; i++){
		cin >> p[i];
		sum[i] = sum[i-1];
		if(p[i] < p[i-1]) sum[i]++;
	}
	
	for(int i = 1; i <= n-k+1; i++){
		if(sum[i+k-1]-sum[i] == 0) uf.unite(0, i);
	}
	for(int i = 1; i < k; i++) S.insert(p[i]);
	
	bool flag = false;
	for(int i = 1; i <= n-k+1; i++){
		S.insert(p[i+k-1]);
		if(flag && *S.rbegin() == p[i+k-1]) uf.unite(i-1, i);
		flag = (*S.begin() == p[i]);
		S.erase(p[i]);
	}
	
	S.clear();
	for(int i = 1; i <= n-k+1; i++) S.insert(uf.root(i));
	cout << S.size() << endl;
	
	return 0;
}


Measured memory_bytes: 13568
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] ai = new int[n + 1];
    for (int i = 1; i <= n; i++) {
      int a = sc.nextInt();
      ai[a] = i;
    }

    for (int i = 1; i <= n; i++) {
      int i1 = ai[i];
      System.out.print(i1);
      System.out.print(i == n ? "\n" : " ");
    }
  }
}


Measured memory_bytes: 64332
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
#define int long long

signed main(){
	int n;
	int ans = 1;
	cin >> n;
	int a[n];
	LOOP(i,n){
		cin >> a[i];
	}
	int c[1000001][3]={};

	LOOP(i,n){
		int cnt = 0;
		LOOP(j,3){
			c[i+1][j] = c[i][j];
			if(c[i][j]==a[i]){
				cnt++;
				if(cnt==1)c[i+1][j]++;
			}
			// cerr << c[i][j] << " ";
		}
		// cerr << endl;
		ans *= cnt;
		ans %= 1000000007;
	}
	cout << ans << endl;

}


Measured memory_bytes: 24448
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr ll mod = 1e9+7;
int main(){ 
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  auto make = [&](string s) {
    string tmp = "";
    int prev = 0;
    s += "#";
    for (int i = 0; i < s.size(); i++) {
      if (s[prev] != s[i]) {
        tmp += s[prev];
        prev = i;
      }
    }
    return tmp;
  };
  s = make(s);
  t = make(t);
  n = s.size();
  ll res = (s[0] == t[0] ? 3 : 6);

  for (int i = 1; i < n; i++) {
    if (s[i] == t[i]) {
      if (s[i - 1] == t[i - 1]) res *= 2;
      else res *= 1;
    } else {
      if (s[i - 1] == t[i - 1]) res *= 2;
      else res *= 3;
    }
    res %= mod;
  }
  cout << res << endl;
  return 0; 
} 

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

int main()
{
    lint n, k;
    cin >> n >> k;

    lint ans=0;

    REP(i, n) {
        int h;
        cin >> h;
        if(h>=k){
            ans += 1;
        }
    }
    
    cout << ans <<"\n";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++) 
#define fs first
#define sc second
#define _GLIBCXX_DEBUG

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}

template <class S>
void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){
		cerr << v[i] << ' ';
	}
	cerr << endl;
}
template <class S>
void print(vector<vector<S>> &v) {
  	for (ll i = 0; i < (ll)v.size(); i++) {
    	for (ll j = 0; j < (ll)v[i].size(); j++) {
      		cerr << v[i][j] << ' ';
    	}
    	cerr << endl;
  	}
}

int main(){
	ll n,m,x; cin >>n>>m>>x;
	vector<ll> cost(n);
	vector<vector<ll>> rikai(n,vector<ll>(m,0));
	rep(i,n){
		cin >> cost[i];
		rep(j,m){
			cin >> rikai[i][j];
		}
	}
	
	ll minc = 100000000;
	bool suc = false;
	for(int bit=0; bit<(1 << n); bit++){
		vector<ll> gain(m,0);
		ll c = 0;
		bool ok = true;
		rep(i,n){
			if((bit >> i) & 1){
				c += cost[i];
				rep(j, m){
					gain[j] += rikai[i][j];
				}
			}
		}
		rep(j,m){
			if(gain[j] < x){
				ok=false;
				break;
			}
		}
		if(ok){
			suc = true;
			minc = min(minc, c);
		}
	}
	cout << (suc ? minc : -1) << endl;
}

Measured memory_bytes: 3628
N = int(input())
a = []

for i in range(N):
	a.append(int(input()))

maxv = -10e10
minv = a[0]

for i in range(1, N):
	maxv = a[i] - minv if maxv < a[i] - minv else maxv
	minv = a[i] if minv > a[i] else minv

print(maxv)


Measured memory_bytes: 13624
import java.util.*;
import java.io.*;
 
public class Main{
 
	public static void main(String[] $){
		Scanner s = new Scanner(System.in);
        int N = s.nextInt();
        String[] S = new String[N];
        for(int i = 0; i < N; i++){
            S[i] = s.next();
        }
        HashMap<String, Integer> Hash = new HashMap<String, Integer>();
        int max = 0;
        List<String> list = new ArrayList<String>();
        for(int i = 0; i < N; i++){
            if(Hash.get(S[i]) == null){
                Hash.put(S[i], 1);
                list.add(S[i]);
                max = Math.max(max, 1);
            }else{
                int a = Hash.get(S[i]);
                a++;
                Hash.put(S[i], a);
                max = Math.max(a, max);
            }
        }
        List<String> list2 = new ArrayList<String>();
        for(int i = 0; i < list.size(); i++){
            if(Hash.get(list.get(i)) == max){
                list2.add(list.get(i));
            }
        }

        Collections.sort(list2);
        for(int i = 0; i < list2.size(); i++){
            System.out.println(list2.get(i));
        }
        
	}
} 

Measured memory_bytes: 81140
#include <bits/stdc++.h>
    using namespace std; 
    typedef long long int ll; 
     
    int main() {
        int N;
        cin >> N; 
        ll H[N]; 
      cin >> H[0]; 
      int times = 0;
      int answer = 0; 
      for(int i=1; i<N; i++){
        cin >> H[i]; 
        if( H[i-1] >= H[i]){
          times ++;
          answer = max(times, answer); 
        }
        else{
          times =0; 
        }
      }
		cout << answer; 
    }

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] a = new int[5];
		for (int i=0;i<5;i++) {
			a[i] = sc.nextInt();
			if (a[i] == 0) {
				System.out.println(i+1);
			}
		}
	}
}


Measured memory_bytes: 35704
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <set>
#include <iostream>
#include <cassert>
#include <queue>
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define rep(i,a,b) for(int i = a;i < b; ++i)
using namespace std;
int find(vector<vector<char>>& A, int startX, int startY) {
    int M = A.size(), N = A[0].size();
    vector<vector<char>> vis(M, vector<char>(N));
    queue<pair<int, int>> qu;
    qu.push({startX, startY});
    int depth = 0;
    vis[startX][startY] = 1;
    int dir[4][2] = {{0,1},{0,-1},{-1,0},{1,0}};
    while (!qu.empty()) {
        int len = qu.size();
        while (len--) {
            auto pr = qu.front();
            qu.pop();
            int x = pr.first;
            int y = pr.second;
            for (int i = 0; i < 4; ++i) {
                int nx = x + dir[i][0];
                int ny = y + dir[i][1];
                if (nx >= 0 && nx < M && ny >= 0 && ny < N && A[nx][ny] == '.' && vis[nx][ny] == 0) {
                    qu.push({nx, ny});
                    vis[nx][ny] = 1;
                }
            }
        }
        depth++;
    }
    return depth;
}
int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> A(H, vector<char>(W));
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cin >> A[i][j];
        }
    }
    int ans = 0;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            char c = A[i][j];
            if (c == '.') {
                ans = max(ans, find(A, i, j) - 1);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

class combination
{
public:
  vector<ll> fac, finv, inv;

  combination(ll M)
  {
    fac = vector<ll>(M, 1);
    finv = vector<ll>(M, 1);
    inv = vector<ll>(M, 1);

    for (ll i = 2; i < M; i++)
    {
      fac.at(i) = fac.at(i - 1) * i % MOD;
      inv.at(i) = MOD - inv.at(MOD % i) * (MOD / i) % MOD;
      finv.at(i) = finv.at(i - 1) * inv.at(i) % MOD;
    }
  }

  ll P(ll N, ll K)
  {
    if (N < K) return 0;
    if (N < 0 || K < 0) return 0;
    return fac.at(N) * finv.at(N - K) % MOD;
  }

  ll C(ll N, ll K)
  {
    if (N < K) return 0;
    if (N < 0 || K < 0) return 0;
    return fac.at(N) * (finv.at(K) * finv.at(N - K) % MOD) % MOD;
  }

  ll H(ll N, ll K)
  {
    return C(N + K - 1, K);
  }
};

int main()
{
  ll N;
  cin >> N;
  vector<ll> A(N + 1);
  vector<ll> B(N + 1, -1);
  ll X, Y;
  for (ll i = 0; i < N + 1; i++)
  {
    cin >> A.at(i);
    if (B.at(A.at(i)) != -1)
      X = B.at(A.at(i)) + 1, Y = i + 1;
    else
      B.at(A.at(i)) = i;
  }

  combination com(N + 10);

  for (ll k = 1; k <= N + 1; k++)
  {
    ll ans = (com.C(N + 1, k) + MOD - com.C(X + N - Y, k - 1)) % MOD;
    cout << ans << endl;
  }
}


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

int powcount(int x, int y){
  int count = 0;
  while(x < y){
    count++;
    x *= 2;
  }
  return count;
}

int main(){
  int N, K; cin >> N >> K;
  double ans = 0;
  for(int i = 1; i <= N; i++){
    ans += double(pow(0.5, powcount(i, K))/N);
  }
  cout << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools, os
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-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 _pf(s): return print(s, flush=True)
def perr(s): return print(s, file=sys.stderr)

N = _I()
A = LI()

ans = 0
for a in A:
    ans += 1/a

print(1/ans)


Measured memory_bytes: 6604
//#pragma GCC optimize("-Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2")  //Enable AVX
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//order_of_key(x) : number of items less than x
//find_by_order(x) : iterator to x

#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F                   first
#define S                   second
#define all(v)              (v).begin(),(v).end()

const ld pi=3.14159265359;
ll INF=1e18+10;
ll MOD=998244353;
ll mod=1e9+7;

inline ll add(ll a,ll b,ll m){
    if(a+b>=m)return (a+b)-m;
    return a+b;
}

inline ll mul(ll a,ll b,ll m){
    if((a*b)<m)return a*b;
    return (a*b)%m;
}

int main()
{
    ll n,k;cin>>n>>k;
    cout<<min(n%k,abs(k-(n%k)))<<endl;
}


Measured memory_bytes: 256
#
H, W, D = list(map(int, input().split()))
A = {}
for y in range(H):
    tmp = list(map(int, input().split()))
    for x in range(W):
        A[tmp[x]] = (x+1, y+1)
Q = int(input())

#
d = [0 for _ in range(H*W)]
for i in range(1, D+1):
    x, y = A[i]

    j = i
    while j+D<=H*W:
        s, t = A[j+D]
        d[j+D-1] = d[j-1] + abs(x-s) + abs(y-t)
        x = s
        y = t
        j += D

#print(d)
for i in range(Q):
    L, R = list(map(int, input().split()))

    print(d[R-1] - d[L-1])


Measured memory_bytes: 23032
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
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; }
const int INF = 1<<29;
const ll LINF = 1LL<<58;
const int mod = 1000000007;

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> P(n);
    for(int i = 0; i < n; i++){
        cin >> P[i];
        P[i]++;
    }
    ll sum = 0;
    ll ans = 0;
    for(int i = 0; i < n; i++){
        sum += P[i];
        if(i - k >= 0) sum -= P[i-k];
        chmax(ans, sum);
    }
    cout << fixed << setprecision(10) << ans / 2.0 << endl;
    return 0;
}


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

int main () {
    string s[7] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    string t;
    cin >> t;
    for (int i = 0; i < 7; i++) {
        if (s[i] == t) cout << 7-i << endl;
    }
}

Measured memory_bytes: 256
N,K = map(int,input().split())
L = list(map(int,input().split()))
L = sorted(L)

MOD=10**9+7

ans=1
if N==K:
    for a in L:
        ans*=a
        ans%=MOD

#全部ふで奇数個
elif all(l<0 for l in L) and K%2==1:
    #小さい方からKこ
    for l in L[-K:]:
        ans*=l
        ans%=MOD
else:#生徒ふが入り混じり
    absL = sorted(L,key=lambda x:-abs(x))

    ans_cand=[v for v in absL[:K]]
    remain=[v for v in absL[K:]]

    if len(list(filter(lambda x:x<0,ans_cand)))%2==0:
        for a in ans_cand:
            ans*=a
            ans%=MOD
    else:
        ans_cand_min_neg = None
        ans_cand_min_pos=None
        remain_cand_max_neg=None
        remain_cand_max_pos=None

        for a in ans_cand:
            if a<0:
                ans_cand_min_neg=a

        #できるだけ絶対値が大きいやつ
        for a in remain:
            if a>=0:
                remain_cand_max_pos=a
                break

        #正の数をans_candから一つ取り除いき、remain_candから負の数を一つ取ってくる

        for a in ans_cand:
            if a>0:
                ans_cand_min_pos=a
        for a in remain:
            if a<=0:
                remain_cand_max_neg=a
                break

        NG=None
        if not None in {ans_cand_min_pos,ans_cand_min_neg,remain_cand_max_neg,remain_cand_max_pos}:
            A = abs(ans_cand_min_pos*remain_cand_max_pos)
            B = abs(ans_cand_min_neg*remain_cand_max_neg)
            if A>=B:
                ans_cand.append(remain_cand_max_pos)
                NG=ans_cand_min_neg
            else:
                ans_cand.append(remain_cand_max_neg)
                NG=ans_cand_min_pos
        elif not None in {ans_cand_min_pos,remain_cand_max_neg}:
            ans_cand.append(remain_cand_max_neg)
            NG=ans_cand_min_pos
        elif not None in {ans_cand_min_neg,remain_cand_max_pos}:
            ans_cand.append(remain_cand_max_pos)
            NG=ans_cand_min_neg


        for a in ans_cand:
            if a!=NG:
                ans*=a
                ans%=MOD
            else:
                NG=None
print(ans)


Measured memory_bytes: 121280
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <fstream>
#include <cassert>
#include <ctime>
#include <list>
#include <numeric>
#include <iomanip>


using namespace std;
static const double EPS = 1e-6;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#ifndef M_PI
const double M_PI=acos(-1);
#endif
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int((a).size()))
#define F first
#define S second
int dx[]={0,1,0,-1,1,1,-1,-1},dy[]={1,0,-1,0,1,-1,1,-1};

string in;

void solve(){
  stack<char> st;

  bool ok = true;

  FOR(it,in){
    char c = *it;
    if(c == '(' || c == '[') st.push(c);
    if(c == ')'){
      if(st.empty() || st.top() != '('){
        ok = false;
        break;
      }
      st.pop();
    }

    if(c == ']'){
      if(st.empty() || st.top() != '['){
        ok = false;
        break;
      }
      st.pop();
    }
  }

  cout << (st.empty() && ok ? "yes" : "no") << endl;
}

main(){
  while(getline(cin,in),in != ".") solve();
}

Measured memory_bytes: 1176