akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
double ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
 ll n;sc(n);
 map<ll,ll>map;
 ll a; 
 rep(i,0,n){
  sc(a);
  if(!map[a]){
   ans++;
   map[a]++;
  }
  else{
   ans--;map[a]=0;
  }
 }
 pr(ans);
  
return 0;}

Measured memory_bytes: 9920
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define MX              200005
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
void codeforces()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
int n, m, k;
string s[6];
int fun(int a, int b)
{
    int cnt = 0;
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            if( s[i][j] == '.') continue;
            int k1 = 1<<i;
            int k2 = 1<<j;
            if( (a&k1) == 0 && (b&k2) == 0 ) cnt++;
        }
    }
    return cnt;
}
int32_t main()
{
    cin>>n>>m>>k;
    for(int i=0; i<n; i++) cin>>s[i];
    int ans = 0;
    for(int i=0; i<(1ll<<n); i++){
        for(int j=0;j<(1ll<<m); j++){
            if(fun(i, j) == k) ans++;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3548
#include<iostream>
#include<algorithm>

using namespace std;

int pos[15][15], ans[15][15], area[105], x, y;
int tmp[15][15];
bool used[105], one, more;
void solve(int a, int b){
    if(ans[a][b]){
	a++;
	a %= x;
	if(a == 0)b++;
	if(b == y){
	    if(one || more){
		more = true;
		one = false;
	    }
	    else one = true;
	    for(int i = 0;i < x;i++)
		for(int j = 0;j < y;j++)
		    tmp[i][j] = ans[i][j];
	    return ;
	}
	solve(a, b);
	return;
    }
    for(int p = 1;area[p];p++){
	if(used[p])continue;
	for(int i = 1;i * i <= area[p];i++){
	    if(area[p] % i)continue;
	    int j = area[p] / i;
	    if(a + i <= x && b + j <= y){
		bool ok = true, found = false;
		for(int k = a;k < a + i && ok;k++){
		    for(int l = b;l < b + j && ok;l++){
			if(pos[k][l] != 0 && pos[k][l] != p)ok = false;
			if(ans[k][l] != 0)ok = false;
			if(pos[k][l] == p)found = true;
		    }
		}
		if(ok && found){
		    for(int k = a;k < a + i && ok;k++){
			for(int l = b;l < b + j && ok;l++){
			    ans[k][l] = p;
			}
		    }
		    solve(a, b);
		    for(int k = a;k < a + i && ok;k++){
			for(int l = b;l < b + j && ok;l++){
			    ans[k][l] = 0;
			}
		    }
		}
	    }
	    if(i == j)continue;
	    swap(i, j);
	    
	    if(a + i <= x && b + j <= y){
		bool ok = true, found = false;
		for(int k = a;k < a + i && ok;k++){
		    for(int l = b;l < b + j && ok;l++){
			if(pos[k][l] != 0 && pos[k][l] != p)ok = false;
			if(ans[k][l] != 0)ok = false;
			if(pos[k][l] == p)found = true;
		    }
		}
		if(ok && found){
		    for(int k = a;k < a + i && ok;k++){
			for(int l = b;l < b + j && ok;l++){
			    ans[k][l] = p;
			}
		    }
		    solve(a, b);
		    for(int k = a;k < a + i && ok;k++){
			for(int l = b;l < b + j && ok;l++){
			    ans[k][l] = 0;
			}
		    }
		}
	    }

	    swap(i, j);

	}
    }
}

int main(){
    int n, a, b;
    while(cin >> x >> y >> n, n){
	swap(x, y);
	one = more = false;
	for(int i = 0;i < x;i++)
	    for(int j = 0;j < y;j++)
		ans[i][j] = 0;
	for(int i = 0;i < n;i++){
	    cin >> a >> b;
	    area[a] = b;
	}
	area[n + 1] = 0;
	for(int i = 0;i < x;i++)
	    for(int j = 0;j < y;j++)
		cin >> pos[i][j];
	solve(0, 0);
	if(one){
	    for(int i = 0;i < x;i++){
		for(int j = 0;j < y;j++){
		    if(j)cout << " ";
		    cout  << tmp[i][j];
		}
		cout << endl;
	    }
	}
	else
	    cout << "NA" << endl;
    }
    return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include <string>
using namespace std;
int main(void){
   int a,b;
   cin >> a >> b;
   if(a == 0){
       if(b<=1911){cout << "M" << b-1867 << endl;}
       else if(b<=1925){cout << "T" << b-1911 << endl;}
       else if(b<=1988){cout << "S" << b-1925 << endl;}
       else if(b<=2016){cout << "H" << b-1988 << endl;}
   }else if(a == 1){
       cout << b+1867 << endl;
   }else if(a == 2){
       cout << b+1911 << endl;
   }else if(a == 3){
       cout << b+1925 << endl;
   }else if(a == 4){
       cout << b+1988 << endl;
   }
}


Measured memory_bytes: 3104
import sys
readline = sys.stdin.readline

import numpy as np
from collections import Counter
from numba import njit




N = int(input())
A = np.array(readline().split(), np.int32)

count = np.zeros((A.max() + 1))
for a in A:
    if count[a] > 1:
        continue
    count[::a] += 1

ret = 0
for a in A:
    ret += count[a] == 1

print(ret)

Measured memory_bytes: 112512
#include <stdio.h>
#include<string.h>
#define LENGTH 256

int calculate(int price){
    int charge;
    int i = 0;
    while(1){
        charge = i*1000 - price;
        if(charge>0){
            return charge;
        }else if(charge == 0){
            return charge;
        }else{
            i = i+1;
        }
    }
}
void main() {
        int r,d;
        scanf("%d", &d);
        r = calculate(d);
        printf("%d\n", r);
}


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

int main() {
  int n;
  cin >> n;
  map<int, int> a;

  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    a[tmp] = 1;
  }

  if (a.size() == n)
    cout << "YES";
  else
    cout << "NO";
}

Measured memory_bytes: 9600
n=int(input())
sp = 0
sp_i=1
for i in range(1,n+1):
  s_i=i
  count =0
  a =True
  while a:
    if i % 2 ==0:
      i=i/2
      count += 1
    else:
      a =False
  if count >sp:
    sp = count
    sp_i = s_i
    
    
print(sp_i)

Measured memory_bytes: 3060
#include <iostream>
#include <math.h>
#include <vector>
#include <stack>
#include <cstdio>
#include <string>
#include <bitset>
#include <list>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <functional>
#include <queue>
// #include "bits/stdc++.h"

using namespace std;
//debug

#define rep(i, N) for (ll i = 0; i < N; i++)
#define rep2(i, N, M) for (ll i = N; i < M; i++)
#define pb push_back



typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef priority_queue<pll, vector<pll>, greater<pll>> greater_pq;


#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define vec(a) vector<a>

#define MAX_NUM 2<<20



int main() {
	int R;
	cin >> R;
	cout <<  (R < 1200 ? "ABC" : (R < 2800 ? "ARC" : "AGC"));
	return 0;
}



Measured memory_bytes: 256
#include <iostream>

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

long long Modinv(long long a, long long mod)
{
	return Modpow(a, mod - 2, mod);
}

int main()
{
	constexpr int MOD = 1000000007;

	int r1 = 0;
	int r2 = 0;
	int c1 = 0;
	int c2 = 0;
	std::cin >> r1 >> c1 >> r2 >> c2;

	long long num1 = 1;
	long long num2 = 1;
	long long den = 1;

	for (int i = 0; i < r1 + 1; ++i)
	{
		num1 = num1 * (r1 + c2 + 1 - i) % MOD;
		num2 = num2 * (r1 + c1 - i) % MOD;
		den = den * (i + 1) % MOD;
	}

	long long curPath = ((num1 * Modinv(den, MOD) % MOD) - (num2 * Modinv(den, MOD) % MOD)) % MOD;

	if (curPath < 0)
	{
		curPath += MOD;
	}

	long long sum = curPath;

	for (int r = r1 + 1; r <= r2; ++r)
	{
		num1 = num1 * (r + c2 + 1) % MOD;
		num2 = num2 * (r + c1) % MOD;
		den = den * (r + 1) % MOD;
		curPath = ((num1 * Modinv(den, MOD) % MOD) - (num2 * Modinv(den, MOD) % MOD)) % MOD;
		if (curPath < 0)
		{
			curPath += MOD;
		}
		sum = (sum + curPath) % MOD;
	}

	std::cout << sum << std::endl;
}

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

using namespace std;

int main() {
	int flag = 1;
	string output[2] = { "YES","NO" };

	int A, B, C;
	cin >> A >> B >> C;
	for (int i = 0; i < A; i++) {
		if ((B*i + C) % A == 0) {
			flag = 0;
			break;
		}
	}

	cout << output[flag] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

/////////////////////////////////////
vmint f, finv, inv;

void cominit(ll N) {
	f.assign(N + 1, 1);
	finv.assign(N + 1, 1);
	inv.assign(N + 1, 1);
	inv[1] = 1;

	repn(i, N) {
		f[i] = f[i - 1] * i;
		if (i > 1)inv[i] = -inv[MOD % i] * (MOD / i);
		finv[i] = finv[i - 1] * inv[i];
	}
}

mint com(ll a, ll b) {
	if (a < 0 || b < 0 || a < b) { return 0; }
	return f[a] * finv[b] * finv[a - b];
}


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

	ll S = N + M + K;
	cominit(S + 1);

	vmint c(S + 1);
	c[0] = 1;
	repn(i, S) {
		c[i] = c[i - 1] * 2;
		c[i] -= com(i - 1, M);
		c[i] -= com(i - 1, K);
	}

	mint ans = 0;
	rep(i, S) {
		if (i < N-1) { continue; }
		mint now = com(i, N - 1) * c[i - (N - 1)] * pw(3, S - 1 - i);
		ans += now;
	}
	cout << ans << endl;
}


Measured memory_bytes: 31428
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.stream.Collectors;
import java.util.stream.Stream;
 
public class Main {

  public static void main(String[] args) throws IOException {
    try ( BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) ) {

      String[] lines = br.readLine().split(" ");
      int r = Integer.parseInt( lines[0] );
      int c = Integer.parseInt( lines[1] );
      int[][] sheet = new int[r+1][c+1]; 
      int sumR = 0;
      int[] sumC = new int[c+1];
      Arrays.fill( sumC, 0 );

      for ( int i = 0; i < sheet.length; i++ ) {
        if ( i != (sheet.length-1) ) lines = br.readLine().split(" ");
        for( int j = 0; j < sheet[i].length; j++) {
          if( i == (sheet.length-1) ) {
            if( j == (sheet[i].length-1)) sheet[i][j] = sumR;
            else {
              sheet[i][j] = sumC[j];
              sumR += sheet[i][j];
            }
          }
          else if( j == (sheet[i].length-1) ) sheet[i][j] = sumR;
          else {
            sumR += (sheet[i][j] = Integer.parseInt(lines[j]));
            sumC[j] += sheet[i][j];
          }
        }
        sumR = 0;
      }

      System.out.println(
        Stream.of(sheet)
              .map( a -> ArrayToString(a) )
              .collect(Collectors.joining("\n"))
      );
    }
  }
  public static String ArrayToString(int[] a) {
      if (a == null)
          return "null";
      int iMax = a.length - 1;
      if (iMax == -1)
          return "[]";

      StringBuilder b = new StringBuilder();
      for (int i = 0; ; i++) {
          b.append(a[i]);
          if (i == iMax)
              return b.toString();
          b.append(" ");
      }
  }
}


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

Measured memory_bytes: 592
//
//  main.cpp
//  test130
//
//  Created by  on 2019/06/16.
//  Copyright © 2 All rights reserved.
//
//
//  main.cpp
//  new
//
//  Created on 2019/06/09.
//  Copyright  All rights reserved.
//

// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
 */

// 17.4.1.2 Headers

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#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>
#endif

// 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 <atomic>
#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>
#endif

using namespace std;

int n,q,a,b,p,x,oya[200004],add[200004];

signed main(){
    cin>>n;
    printf("%16lf",double((n-(n/2)))/double(n));
    cout<<endl;
}





Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll h;
vector<ll> a(0);
void maxHeapify(ll i) {
	ll l = 2 * i + 1, r = 2 * i + 2, largest;
	if (l < h && a[l] > a[i]) largest = l;
	else largest = i;
	if (r < h && a[r] > a[largest]) largest = r;

	if (largest != i) {
		swap(a[i], a[largest]);
		maxHeapify(largest);
	}
}
void buildMaxHeap() {
	for (ll i = h / 2; i >= 0; i--) {
		maxHeapify(i);
	}
}
int main() {
	cin >> h;
	for (ll i = 0; i < h; i++) {
		ll tmp;
		scanf("%lld", &tmp);
		a.push_back(tmp);
	}
	buildMaxHeap();
	for (ll i = 0; i < h; i++) {
		cout << " ";
		cout << a[i];
	}
	cout << endl;
}


Measured memory_bytes: 7024
unittest
{
	assert( [ "4 6", "1 3 2", "7 13 10", "18 20 13", "3 4 2", "0", "1", "2", "3", "5", "8" ].parse.expand.solve == "2\n2\n10\n-1\n13\n-1" );
}



import std.algorithm;
import std.conv;
import std.container;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nq = input.front.split.to!( long[] );
	auto stxs = new long[ 3 ][ nq[ 0 ] ];
	foreach( ref stx; stxs )
	{
		input.popFront;
		stx = input.front.split.to!( long[] );
	}
	auto ds = new long[ nq[ 1 ] ];
	foreach( ref d; ds )
	{
		input.popFront;
		d = input.front.to!( long );
	}
	return tuple( stxs, ds );
}

auto solve( long[ 3 ][] stxs, long[] ds )
{
	auto es = new Tuple!( long, bool, long )[ stxs.length * 2 ];
	foreach( i, stx; stxs )
	{
		es[ i               ] = tuple( stx[ 0 ] - stx[ 2 ], true,  stx[ 2 ] );		// 工事はじまる
		es[ i + stxs.length ] = tuple( stx[ 1 ] - stx[ 2 ], false, stx[ 2 ] );		// 工事おわる
	}
	es.sort();
	
	auto anss = new long[ ds.length ];
	auto rbt = new RedBlackTree!( long );
	foreach( ref ans, d; lockstep( anss, ds ) )
	{
		while( !es.empty && es.front[ 0 ] <= d )
		{
			if( es.front[ 1 ] ) rbt.insert( es.front[ 2 ] );
			else                rbt.removeKey( es.front[ 2 ] );
			es.popFront;
		}
		if( rbt.empty ) ans = -1;
		else            ans = rbt.front;
	}
	return anss.to!( string[] ).join( "\n" );
}


Measured memory_bytes: 43388
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  lint L; cin >> L;
  V<lint> x(n); for (auto&& e : x) cin >> e;
  V<lint> t(n); for (auto&& e : t) cin >> e;
  lint res = 0;
  for (int i = 0; i < n; ++i) {
    lint q = (t[i] - 1) / (2 * L);
    res += 2 * L * q;
    t[i] -= 2 * L * q;
  }
  V<lint> lf, rf, bi;
  int mx = 0;
  for (int i = 0; i < n; ++i) {
    if (t[i] > 2 * max(x[i], L - x[i])) {
      res += 2 * L;
      mx = x[i];
    } else if (t[i] > 2 * (L - x[i])) {
      lf.push_back(x[i]);
    } else if (t[i] > 2 * x[i]) {
      rf.push_back(L - x[i]);
    } else {
      bi.push_back(x[i]);
    }
  }
  int m = bi.size();
  auto calc = [&](int x) -> lint {
    auto l = lf, r = rf;
    for (int i = 0; i < x; ++i) l.push_back(bi[i]);
    for (int i = x; i < m; ++i) r.push_back(L - bi[i]);
    sort(begin(l), end(l));
    sort(rbegin(r), rend(r));
    lint curr = 2 * L * r.size();
    int j = 0;
    for (int i = 0; i < l.size(); ++i) {
      while (j < r.size() and l[i] + r[j] > L) ++j;
      if (j == r.size()) {
        curr += ((int) l.size() - i + 1) * 2 * L;
        break;
      }
      ++j;
      if (i == (int) l.size() - 1 and j == (int) r.size()) {
        curr += 2 * L;
      }
    }
    if (!curr and mx or curr == 2 * L * r.size() and mx + r.back() > L) {
      curr += 2 * L;
    }
    return curr;
  };
  int l = 0, r = m;
  while (r - l > 2) {
    int ml = (2 * l + r) / 3;
    int mr = (l + 2 * r) / 3;
    if (calc(ml) < calc(mr)) r = mr;
    else l = ml;
  }
  lint mn = 9e18;
  for (int x = l; x <= r; ++x) {
    mn = min(mn, calc(x));
  }
  res += mn;
  cout << res << '\n';
}

Measured memory_bytes: 15108
N = int(input())
number = list(map(int,input().split()))

count = 0
for i in range(0,len(number)):
    mini = i
    for j in range(i,len(number)):
        if number[j] < number[mini]:
            mini = j
    if mini != i:
        count += 1
        temp = number[i]
        number[i] = number[mini]
        number[mini] = temp


print(" ".join(map(str,number)))
print (count)


Measured memory_bytes: 5596
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<char, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
int a[55], b[55];

int memo[55][55];

bool check(int c, int d, ll bit, int l) {
    if (c == d) return true;
    if (c < d) return false;
    if (memo[c][d] < 0) {
        int res = 0;
        for (int i = d+1; i <= l; i++) {
            if (c < i) continue;
            if (c % i == d) {
                res = 1;
                break;
            } else if (c % i > d) {
                res = max(res, (int)check(c%i, d, bit, l));
            }
        }
        for (int i = l+1; i <= 50; i++) {
            if ((bit>>i)&1) {
                if (c < i) continue;
                if (c % i == d) {
                    res = 1;
                    break;
                } else if (c % i > d) {
                    res = max(res, (int)check(c%i, d, bit, l));
                }
            }
        }
        
        memo[c][d] = res;
    }
    return memo[c][d] == 1;
}

bool feasible() {
    memset(memo, -1, sizeof(memo));
    for (int i = 0; i < n; i++) {
        if (!check(a[i], b[i], 0LL, 50))
            return false;
    }
    return true;
}

ll solve() {
    if (!feasible()) return -1;
    ll res = 0;
    for (int i = 50; i >= 0; i--) {
        memset(memo, -1, sizeof(memo));
        bool f = true;
        for (int j = 0; j < n; j++) {
            if (!check(a[j], b[j], res, i)) {
                f = false;
                break;
            }
        }
        if (!f) {
            res |= (1LL<<(i+1));
        }
    }
    return res;
}

void input() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 3604
h, w = map(int, input().split())
s = [[i for i in input().split()] for _ in range(h)]
for i, s_row in enumerate(s):
    for j in range(w):
        if s_row[j] == "snuke":
            print(chr(65 + j) + "{}".format(i+1))
            exit()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> r, g, b;
  rep(i, n) {
    if(s[i] == 'R') r.push_back(i);
    if(s[i] == 'G') g.push_back(i);
    if(s[i] == 'B') b.push_back(i);
  }
  ll ans = r.size() * g.size() * b.size();
  
  rep(i, r.size()) {
    rep(j, g.size()) {
      int d = abs(r[i] - g[j]);
      int minv = min(r[i], g[j]) - d;
      int maxv = max(r[i], g[j]) + d;
      int center = min(r[i], g[j]) + d / 2;
      if(d % 2) center = -10000000;
      int diff = 0;
      diff += binary_search(b.begin(), b.end(), minv);
      diff += binary_search(b.begin(), b.end(), maxv);
      diff += binary_search(b.begin(), b.end(), center);
      ans -= diff;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <stdio.h>
#include <set>
#include <string.h>

typedef long long ll;

using namespace std;

void dfs(int me, vector<int> &visited, vector<vector<int> > &table, int left) {
    if (visited[me]==1) return;
    if (left<0) return;

    visited[me]=1;
    for (int i=0; i<table[me].size(); i++)
        dfs(table[me][i], visited, table, left-1);
}

int main() {
    std::ios::sync_with_stdio(false);
    int n, k; cin>>n>>k;
    vector<vector<int> > table(n);

    for (int i=0; i<n-1; i++) {
        int tmp1, tmp2; cin>>tmp1>>tmp2;
        table[tmp1-1].push_back(tmp2-1);
        table[tmp2-1].push_back(tmp1-1);
    }

    int ans=n;
    if (k%2==0) {
        for (int i=0; i<n; i++) {
            vector<int> visited(n, 0);
            dfs(i, visited, table, k/2);

            int tmp=0;
            for (int i=0; i<visited.size(); i++) if (visited[i]==0) tmp++;
            ans=min(ans, tmp);
        }
    }
    else {
        for (int i=0; i<n; i++) for (int j=0; j<table[i].size(); j++) {
            vector<int> visited(n, 0);
            int t=table[i][j];
            visited[i]=1; dfs(t, visited, table, (k-1)/2);
            visited[i]=0; dfs(i, visited, table, (k-1)/2);

            int tmp=0;
            for (int i=0; i<visited.size(); i++) if (visited[i]==0) tmp++;
            ans=min(ans, tmp);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.*;

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

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        char[] candidates = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'};
        Set<String> set = new HashSet<>();
        StringBuilder init = new StringBuilder();
        set.add("a");
        for (int i = 1; i < N; i++) {
            Set<String> next_set = new HashSet<>();
            for (String s : set) {
                char[] data = s.toCharArray();
                Set<Character> count = new HashSet<>();
                for (int j = 0; j < data.length; j++) {
                    count.add(data[j]);
                }
                for (int j = 0; j <= count.size(); j++) {
                    next_set.add(s + candidates[j]);
                }
            }
            StringBuilder sb = new StringBuilder();
            for (int j = 0; j <= i; j++) {
                sb.append(candidates[j]);
            }
            next_set.add(sb.toString());
            set = next_set;
        }
        List<String> ans = new ArrayList<>();
        for (String x : set) {
            ans.add(x);
        }
        ans.sort(Comparator.naturalOrder());
        for (int i = 0; i < ans.size(); i++) {
            System.out.println(ans.get(i));
        }
    }
}


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

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

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
 0 0 0 10 10 10 23
  0 153 10 10 23
  }*/

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

  vi b(n-1);
  rep(i, 0, n-1) cin >> b[i];

  int ans = b[0] + b[n-2];
  rep(i, 0, n-2){
    ans += min(b[i], b[i+1]);
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string alphabet = "abcdefghijklmnopqrstuvwxyz";
  int N,ans = 0;
  cin >> N;
  char S[N];
  vector<int> imos(N,0);
  vector<int> count(26,0);
  for(int i = 0;i < N;i++){
    cin >> S[i];
    for(int j = 0;j < 26;j++){
      if(S[i] == alphabet.at(j))count[j]++;
    }
  }
  for(int i = 0;i < 26;i++){
    if(count[i] > 1){
      for(int j = 0;j < N;j++){
        if(S[j] == alphabet.at(i)){
          imos[j]++;
          break;
        }
      }
      for(int j = N - 1;j > -1;j--){
        if(S[j] == alphabet.at(i)){
          imos[j]--;
          break;
        }
      }
    }
  }
  int s_imos = 0;
  for(int i = 0;i < N;i++){
    s_imos += imos[i];
    ans = max(ans,s_imos);
  }
  cout << ans;
}

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

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

  if (b-a<=0) cout << "delicious" << endl;
  else if (x>=b-a) cout << "safe" << endl;
  else cout << "dangerous" << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 入力
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();

        // (9 * 60 + 0 - 12 * 0) / 720 = 540 / 720
        double rate = (h * 60 + m - 12 * m) / 720.0;
        if (rate > 0.5) {
            rate = 1.0 - rate;
        }
        double rad = 2 * Math.PI * rate;
        
        // c^2 = a^2 + b^2 - 2ab cos C
        double c2 = a * a + b * b - 2 * a * b * Math.cos(rad);
        double c = Math.sqrt(c2);

        System.out.println(c);
    }
}


Measured memory_bytes: 35964
#include <stdio.h>

int main(void)
{
	int ct[6] = {0};
	int i, j;
	float h;
	int n;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		scanf("%f", &h);
		
		if (h < 165.0){
			ct[0]++;
		}
		else if (h < 170.0){
			ct[1]++;
		}
		else if (h < 175.0){
			ct[2]++;
		}
		else if (h < 180.0){
			ct[3]++;
		}
		else if (h < 185.0){
			ct[4]++;
		}
		else {
			ct[5]++;
		}
	}
	
	for (i = 0; i < 6; i++){
		printf("%d:", i + 1);
		for (j = 0; j < ct[i]; j++){
			printf("*");
		}
		printf("\n");
	}
	
	return (0);
}

Measured memory_bytes: 636
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

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

    long long res = 9000000000;
    for(int k = 0;k <= 2 * std::max(x, y);k++){
        long long m = a * (x >= k ? x - k : 0) +
            b * (y >= k ? y - k : 0) + c * 2 * k;
        if(m < res){
            res = m;
        }

    }
    std::cout<<res<<std::endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("avx,popcnt")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
const int maxn = 60, mod = 1e9 + 7, i2 = (mod+1)/2;
int n;
array<int, 10> a, na;
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n;
	fill(all(a), -(1<<30));
	a[0] = 0;
	for(int t, i = 0; i < n; i++) {
		cin >> t;
		na = a;
		for(int j = 0; j < 10; j++) na[(j+t)%10] = max(na[(j+t)%10], a[j] + t);
		a = na;
	}
	int ans = 0;
	for(int i = 1; i < 10; i++) ans =max(ans, a[i]);
	cout << ans;
	return 0;
}


Measured memory_bytes: 3620
//競技プログラミング用のテンプレート
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>
#include <stack>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repr(i, n) for(int i = n - 1; i >= 0; i--)

using namespace std;
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;

int main()
{
  int a, b, k;
  cin >> k >> a >> b;
  for(int i = a; i <= b; i++)
  {
    if(i % k == 0) 
    {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
}


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'
#define all(x) x.begin(), x.end()
#define arr array

template<typename T> void umin(T& a,T b){a = min(a,b);}
template<typename T> void umax(T& a,T b){a = max(a,b);}

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;
using pll = pair<ll, ll> ;

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;


void pre(){

    

}

const ll N = 2005;
vector<ll> A;
ll dp[N];
bool vis[N];

ll go(ll sum){
    if(sum < 0)
        return 0;
    if(sum == 0)
        return 1;
    if(vis[sum]){
        return dp[sum];
    } 
    vis[sum] = true;
    ll ans=0;
    for(auto it : A){
        ans += go(sum-it);
        ans %= mod;
    }
    return dp[sum] = ans;
}

void solve(){

    int s;
    cin >> s;
    // for(int i=3;i<=s;i++){
    //     A.push_back(i);
    // }
    // reverse(all(A));
    // ll ans = go(s);
    // cout << ans;
    vector<ll> dp(s+1);
    dp[0] = 1;
    for(int i=3;i<=s;i++){
        for(int j=i;j>=3;j--){
            dp[i] += dp[i-j];
            dp[i] %= mod;
        }
    }
    cout << dp[s];  

}


int32_t main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
namespace Computational_Geometry
{
	const long double eps=1e-8;
	struct Vector2
	{
		long double x,y;
		Vector2(long double X=0.0,long double Y=0.0):x(X),y(Y) {}
		Vector2 *read() {scanf("%Lf%Lf",&x,&y); return this;}
		void print() {printf("%.10Lf %.10Lf",x,y); return;}
		inline Vector2 operator - () const{return Vector2(-x,-y);}
		inline Vector2 operator + (const Vector2 &A) const{return Vector2(x+A.x,y+A.y);}
		inline Vector2 operator - (const Vector2 &A) const{return Vector2(x-A.x,y-A.y);}
		inline Vector2 operator * (const long double &k) const{return Vector2(x*k,y*k);}
		inline Vector2 operator / (const long double &k) const{return Vector2(x/k,y/k);}
		inline long double operator * (const Vector2 &A) const{return x*A.x+y*A.y;}
		inline long double operator ^ (const Vector2 &A) const{return x*A.y-y*A.x;}
		inline long double norm2() const{return x*x+y*y;}
		inline long double norm() const{return sqrtl(x*x+y*y);}
		inline bool operator < (const Vector2 &A) const{return (x<A.x-eps)||(x<=A.x+eps)&&(y<A.y-eps);}
		inline bool operator == (const Vector2 &A) const{return fabsl(x-A.x)<=eps&&fabsl(y-A.y)<=eps;}
		inline bool operator << (const Vector2 &A) const{return (y<-eps)^(A.y<-eps)?A.y<-eps:((*this^A)>eps)||((*this^A)>=-eps)&&(x>=-eps)&&(A.x<-eps);}
		inline Vector2 trans(long double a_11,long double a_12,long double a_21,long double a_22) const{return Vector2(x*a_11+y*a_12,x*a_21+y*a_22);}
	};
	#define Point Vector2
	Point Projection(Point P,Point P1,Point P2)
	{
		long double k1=(P2-P1)*(P-P1),k2=(P2-P1).norm2();
		return P1+((P2-P1)*(k1/k2));
	}
	Point Reflection(Point P,Point P1,Point P2)
	{
		long double k1=(P2-P1)*(P-P1),k2=(P2-P1).norm2();
		Point mid=P1+(P2-P1)*(k1/k2);
		return mid*2-P;
	}
};
using namespace Computational_Geometry;
Point P1,P2,P;
int Q;
int main()
{
	P1.read(),P2.read();
	scanf("%d",&Q);
	while(Q--)
	{
		P.read();
		Projection(P,P1,P2).print();
		puts("");
	}
	return 0;
}


Measured memory_bytes: 3236
#include<bits/stdc++.h>
using namespace std;
int n,k,a[200005];
int main() {
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=k+1;i<=n;i++)if(a[i]>a[i-k])puts("Yes");else puts("No");
}

Measured memory_bytes: 4412
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,K;
	while(cin>>N>>K) {
		long double v=0;
		RANGE(i, 1, N+1) {
			long double c=1;
			ll a=i;
			while(a<K) c/=2,a*=2;
			v+=c;
		}
		v/=N;
		cout<<setprecision(20)<<v<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
 
int main() {
	std::string s;
	std::cin >> s;
	for (int i = 0;i < s.size();i++) {
		std::cout << s[i];
		if (i == 3) {
			std::cout << " ";
		}
	}
	std::cout << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
const int MAX_N = 1005;
int arr[MAX_N][MAX_N];
int main(void) 
{
	int H, W, A, B;
	cin >> H >> W >> A >> B;
	for (int i = 1; i <= B; i++)
	{
		for (int j = 1; j <= A; j++) 
		{
			arr[i][j] = 1;
		}
	}
	for (int i = B + 1; i <= H; i++)
	{
		for (int j = A + 1; j <= W; j++) 
		{
			arr[i][j] = 1;
		}
	}
	for (int i = 1; i <= H; i++) 
	{
		for (int j = 1; j <= W; j++) 
		{
			printf("%d", arr[i][j]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 5120
s = input()
out = [0]*len(s)

cnt = 0
idx = 0
for i in range(0, len(s)):
  if s[i] == "R":
    cnt += 1
    if s[i] != s[i+1]:
      out[i] = cnt
      cnt = 0
  if s[i] == "L":
    if s[i] != s[i-1]:
      idx = i
    out[idx] += 1

i = 0
while i < len(out)-1:
  if out[i] > 0 and out[i+1] > 0:
    if (out[i]+out[i+1])%2 == 0:
      x = (out[i]+out[i+1])//2
      print(x, end = " ")
      print(x, end = " ")
    elif out[i] > out[i+1]:
      x = (out[i]+out[i+1])//2
      if out[i]%2 != 0:
        print(x+1, end = " ")
        print(x, end = " ")
      else:
        print(x, end = " ")
        print(x+1, end = " ")
    else:
      x = (out[i]+out[i+1])//2
      if out[i+1]%2 != 0:
        print(x, end = " ")
        print(x+1, end = " ")
      else:
        print(x+1, end = " ")
        print(x, end = " ")
    i += 1
  else:
    print(0, end = " ")
  i += 1

if s[len(s)-2] != "R":
  print(0)

    

Measured memory_bytes: 4992
import math




def main():
    n = int(input())
    lista = []
    for i in range(0, n):
        lista.append(int(input()))
    maxim1 = -999999
    maxim2 = -9999999
    for element in lista:
        if element > maxim1:
            maxim2 = maxim1
            maxim1 = element
        elif element <= maxim1 and element > maxim2:
            maxim2 = element
    
    for element in lista:
        if element == maxim1:
            print(maxim2)
        else:
            print(maxim1)



if __name__ == "__main__":
    main()

Measured memory_bytes: 12640
#include <bits/stdc++.h>
#define int long long
#define moder (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % moder;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), moder - 2, moder) % moder * mod_pow(kai(y), moder - 2, moder) % moder;
}
/*--------Library Zone!--------*/


P dat[1000000];
int size_ = 1;
void init(int x) {
	while (size_ < x)size_ *= 2;
	//rep(i, 2 * size_ - 1)dat[i] = { ((int)(1) << 31) - 1,inf };
}
void eval(int k, int l, int r) {
	if (dat[k].second) {
		dat[k].first += dat[k].second;
		if (r - l > 1) {
			dat[k * 2 + 1].second += dat[k].second / 2;
			dat[k * 2 + 2].second += dat[k].second / 2;
		}
		dat[k].second = 0;
	}
}
void update(int a, int b, int k, int x, int l, int r) {
	eval(k, l, r);
	if (r <= a || b <= l)return;
	if (a <= l && r <= b) {
		dat[k].second += x * (r - l);
		eval(k, l, r);
	}
	else {
		update(a, b, k * 2 + 1, x, l, (l + r) / 2);
		update(a, b, k * 2 + 2, x, (l + r) / 2, r);
		dat[k].first = dat[k * 2 + 1].first + dat[k * 2 + 2].first;
	}
}
int query(int a, int b, int k, int l, int r) {
	eval(k, l, r);
	if (r <= a || b <= l)return 0;
	if (a <= l && r <= b) {
		return dat[k].first;
	}
	int lv = query(a, b, k * 2 + 1, l, (l + r) / 2);
	int rv = query(a, b, k * 2 + 2, (l + r) / 2, r);
	return lv + rv;
}
signed main() {
	int n, q;
	cin >> n >> q;
	init(n);
	rep(i, q) {
		int a; cin >> a;
		if (!a) {
			int s, t, x; cin >> s >> t >> x;
			s--;
			update(s, t, 0, x, 0, size_);
		}
		else {
			int s, t; cin >> s >> t;
			s--;
			cout << query(s, t, 0, 0, size_) << endl;
		}
	}
}


Measured memory_bytes: 6232
#include <cstdio>
#include <cstdlib>

using namespace std;

const int N=200010,mo=1000000007;
int n,a[N];
long long sum[N],ans;

inline void re(int &x)
{
	x=0;
	bool flag=0;
	char ch=getchar();
	while(ch<'0'||ch>'9') flag|=(ch=='-'),ch=getchar();
	while(ch>='0'&&ch<='9') x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	x=flag ? -x : x;
}

int main()
{
    int i;
    re(n);
    for(i=1;i<=n;i++) re(a[i]);
    for(i=n;i>1;i--) sum[i]=(sum[i+1]+a[i])%mo;
    for(i=1;i<n;i++) ans=(ans+(a[i]*sum[i+1])%mo)%mo;
    printf("%lld",ans);
    return 0;
}

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

int main(){
  int m, f, r;

  while (1) {
    cin >> m >> f >> r;
    if (m == -1 && f == -1 && r == -1) {
      break;
    }
    if (m == -1 || f == -1) {
      cout << "F";
    }
    else if (m + f >= 80) {
      cout << "A";
    }
    else if (m + f >= 65) {
      cout << "B";
    }
    else if (m + f >= 50) {
      cout << "C";
    }
    else if (m + f >= 30) {
      if (r >= 50) {
        cout << "C";
      }
      else {
        cout << "D";
      }
    }
    else {
      cout << "F";
    }
    cout << endl;
  }
}



Measured memory_bytes: 3096