akhauriyash/Code-Regression huggingface dataset:
x, n = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]

for i in range(0, 100):
    a = x - i
    b = x + i

    if a >= 0 and a not in p:
        print(a)
        break
    elif b <= 101 and b not in p:
        print(b)
        break

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

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

typedef bitset<128> Bit;
vector<Bit> dat;
unordered_map<Bit,int> memo;
int M, N;

int dfs(const Bit& rest){
  if(memo.count(rest)) return memo[rest];
  int& res = memo[rest];
  res = 1e9;
  if(rest.none() || rest.count() == 1) return res = 0;
  REP(k,M){
	Bit y = rest, n = rest;
	REP(i,N){
	  if(rest.test(i)){
		if(dat[i].test(k))
		  n.reset(i);
		else
		  y.reset(i);
	  }
	}
	if(y == rest || n == rest) continue;
	res = min(res, max(dfs(y)+1, dfs(n)+1));
  }
  
  return res;
}

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

  while(cin>>M>>N,M){
	memo.clear();
	dat.clear();
	REP(i,N){
	  string s; cin >> s;
	  dat.emplace_back(s);
	}
	int ans = dfs(Bit(string(N, '1')));
	/*
	for(int bit=0;bit<1<<M;++bit){
	  bool ok = true;
	  set<string> memo;
	  for(int i=0;i<N;++i){
		for(int j=i+1;j<N;++j){
		  int k;
		  for(k=0;k<M;++k)
			if((bit>>k&1) && fet[i][k] != fet[j][k])
			  break;
		  if(k == M){
			ok = false;
			i = j = N;
		  }
		}
	  if(ok) ans = min(ans, bc(bit));
	}
	*/
	cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 2324
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	Scanner sc;
	public void run(){
		sc = new Scanner(System.in);
		ArrayList<Integer> n = new ArrayList<Integer>();

		while(sc.hasNextInt()){
			int value = sc.nextInt();
			if(value != 0){
				int w = sc.nextInt();
				int h = sc.nextInt();
				calc(value,w,h);
			}
			else{
				break;
			}
		}
	}
	public void calc(int n, int w, int h){
		int[][] map = new int[w][h];
		for(int i = 0; i < n; i++){
			int x = sc.nextInt();
			int y = sc.nextInt();
			map[x-1][y-1] = 1;
		}
		int s = sc.nextInt();
		int t = sc.nextInt();
		int ans = 0;
		for(int i = 0; i < w-s+1; i++){
			for(int j = 0; j < h-t+1; j++){
				int temp = 0;
				for(int a = 0; a < s; a++){
					for(int b = 0; b < t; b++){
						temp = temp + map[i+a][j+b];
					}
				}
				if(temp > ans) ans = temp;
			}
		}
		System.out.println(ans);
	}
	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 34196
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define eps 1e-6

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

ll n;
int uk;
vector<int> prosti;
void faktor() {
    int brojac=0;
    for(ll p=2; p*p<=n; ++p) {
        while(n%p==0) {
            ++brojac;
            n/=p;
        }
        if(brojac==0) continue;
        prosti.push_back(brojac);
        brojac=0;
        if(p!=2) ++p;
    }
    if(n>2) prosti.push_back(1);
}
int main() {
    IOS; cin >> n;
    faktor();
    /*if(prosti.empty()) {
        if(n==1) cout << 0;
        else cout << 1;
        return 0;
    }*/
    for(auto tren:prosti)
        uk+=(int)(sqrt((double)(2*tren+0.25))-0.5);
    cout << uk;
    return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define int long long
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18 * 5;

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

    int a, b;
    cin >> a >> b;
    if(a <= 0 && 0 <= b) puts("Zero");
    else if(a > 0) puts("Positive");
    else{
        puts((b-a)%2 ? "Positive" : "Negative");
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

#define mod 1000000007LL
#define eps 0.0001
#define pi acos(-1)
#define INF 10000000000000000

#define rep(i, n) for(int i = 0;i < n;++i)
#define rep1(i, n) for(int i = 1;i < n;++i)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define chmin

#define lset(h, n) memset(h, n, sizeof(h));
    

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // ---------------------
    // コーディング開始
    // ---------------------

    ll N,K;
    cin >> N >> K;
    ll ok[100001];
    lset(ok,0);

    rep(i,N){
        int a;
        int b;
        cin >> a >> b;
        ok[a]+=b;
    }

    //ここまで
    ll cnt =0;
    rep(i,100001){
        cnt+=ok[i];
        if(cnt>=K){
            pri(i);
            return 0;
        }
    }
            return 0;
}












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

int main(void){
    string s1;
    cin >> s1;

    if(s1 == "Sunny"){
        cout << "Cloudy" << endl;
    }else if(s1 == "Cloudy"){
        cout << "Rainy" << endl;
    }else{
        cout << "Sunny" << endl;
    }
    return 0;
}

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

using namespace std;

int main(){
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if(y < r || x < r || w - x < r || h - y < r){
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3096
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

fact = {0: 1}
for i in range(1, n):
  fact[i] = fact[i-1] * i

num_list = [ i+1 for i in range(n) ]
p_order = 0
for i, p_i in enumerate(p):
  p_order += num_list.index(p_i) * fact[n - i - 1]
  num_list.remove(p_i)

num_list = [ i+1 for i in range(10) ]
q_order = 0
for i, q_i in enumerate(q):
  q_order += num_list.index(q_i) * fact[n - i - 1]
  num_list.remove(q_i)

print(abs(p_order - q_order))



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef pair<Int,Int> Pl;
const int mod = 1e9+7;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) v.begin(),v.end()
#define Pr(type) priority_queue<type>
#define gPr(type) priority_queue<type,vector<type>,greater<type>>
#define V(type) vector<type>
#define rep(i,n) for(int i=0; i<n; i++)
#define rer(i,st,en,h) for(int i=st; i<=en; i+=h)
#define eb emplace_back
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n,m,_,ans,p,q;
string s;

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

  cin>>s; string ans="No";
  for (int i = 0; i < s.size(); i++){
    if(i%2){if(s[i]=='R')END}
    else{
      if(s[i]=='L')END
    }
  }
  cout<<"Yes"<<'\n';
}

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

#define ll long long int

int main() {

    ll n,k,d,x,i,j;
    cin>>n>>k;
    vector<ll> arr (n,0);
    for(i=0;i<k;i++) {
        cin>>d;
        for(j=0;j<d;j++) {
            cin>>x;
            arr[x-1]++;
        }
    }

    ll ans = 0;
    for(i=0;i<n;i++) {
        if(!arr[i])
            ans++;
    }
    cout<<ans<<"\n";
    
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int a,b,c,q[110000],e[110000];
string s;
signed main()
{
	cin>>a>>b>>c;
	rep(i,c){
		cin>>q[i];
		e[q[i]-1]++;
	}
	rep(i,a){
		if(e[i]+b-c>0){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

const ll MOD=1e9+7;
const ll INF=1e18;

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

int main(){
    int n; cin>>n;
    vector<ll> p(n);
    ll sum=0, maxp=0;
    for(int i=0; i<n; i++){
        cin>>p[i];
        sum+=p[i];
        chmax(maxp, p[i]);
    }
    cout << sum-maxp/2 << endl;
}

Measured memory_bytes: 256
/**
 * D's Ambition
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

		line = br.readLine();

		int A, I, D, U, N, Y, X;
		A = I = D = U = N = Y = X = 0;
		char[] out = new char[line.length()];

		for (int i = 0; i < line.length(); i++) {
			char c1 = line.charAt(i);
			switch (c1) {
				case 'A':
					A++;
					break;
				case 'I':
					I++;
					break;
				case 'D':
					D++;
					break;
				case 'U':
					U++;
					break;
				case 'N':
					N++;
					break;
				case 'Y':
					Y++;
					break;
				default:
					X++;
					break;
			}
			out[i] = c1;
			//
			if (i >= 8) {
				char c2 = line.charAt(i - 8);
				switch (c2) {
					case 'A':
						A--;
						break;
					case 'I':
						I--;
						break;
					case 'D':
						D--;
						break;
					case 'U':
						U--;
						break;
					case 'N':
						N--;
						break;
					case 'Y':
						Y--;
						break;
					default:
						X--;
						break;
				}
			}
			if (i >= 7) {
				if (A == 2 && I == 1 && D == 1 && U == 1 && N == 2 && Y == 1 && X == 0) {
					for (int j = i - 7, k = 0; j <= i; j++, k++) {
						out[j] = "AIZUNYAN".charAt(k);
					}
				}
			}
		}
		System.out.println(out);
	} //end main
}

Measured memory_bytes: 17064
#include <bits/stdc++.h>
#define uint unsigned long long
#define ll long long
#define db double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(register int i = x; i <= y; i ++)
#define rrep(i, x, y) for(register int i = x; i >= y; i --)
#define eps 1e-8
#define lb(x) x & -x
#define INF 0x3f3f3f3f
#define sz(x) (x).size()
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
inline ll read1()
{
	ll x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
const int N = 18;
const int L = 65600;
const int mod = 1e9 + 7;
int n, m, a[N], f[N][L];
ll js[L], inv[L];
int cnt[L];
 
ll dec(ll x,ll y)
{
	return x < y ? x - y + mod : x - y;
}
ll add(ll x,ll y)
{
	return x + y >= mod ? x + y - mod : x + y;
}
 
int main()
{
	n = read();
	m = read();
	rep(i, 1, m) a[i] = read();
	js[0] = inv[0] = inv[1] = 1;
	rep(i, 1, 1 << n) js[i] = js[i - 1] * i % mod;
	rep(i, 2, 1 << n) inv[i] = 1ll * (mod - mod / i) * inv[mod % i] % mod;
	rep(i, 2, 1 << n) inv[i] = inv[i] * inv[i-1] % mod;
	f[m + 1][0] = 1;
	sort(a + 1, a + 1 + m);
	rrep(i, m, 1)
	{
		rep(j, 0, (1 << n) - 1)
			if (f[i + 1][j])
			{
				rep(x, 0, n - 1)
				if (((1 << x) & j) == 0 && (j + (1 << x) <= (1 << n) - a[i] + 1))
					f[i][j | (1 << x)] = add(f[i][j | (1 << x)], 1ll * f[i + 1][j] * (1 << x) % mod * js[(1 << n) - a[i] - j] % mod * inv[(1 << n) - a[i] - j - ((1 << x) - 1)] % mod);
				f[i][j] = add(f[i][j], f[i + 1][j]);
			}
	}
	rep(i, 1, (1 << n) - 1) cnt[i] = cnt[i - (i & -i)] + 1;
	ll ans=0;
	rep(i, 0, (1 << n) - 1)
	{
		ll v = f[1][i];
		v = v * js[(1 << n) - i - 1] % mod;
		if (cnt[i] % 2 == 0) ans = add(ans, v);
		else ans = dec(ans, v);
	}
	ans = ans * (1 << n) % mod;
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 4864
import sys
sys.setrecursionlimit(1000000)

n, a, b = map(int, input().split())
mod = 10**9 + 7
nca = 1

for i in range(a):
    nca *= (n-i)
    nca *= pow(i+1, mod-2, mod)
    nca %= mod
ncb = 1
for i in range(b):
    ncb *= (n-i)
    ncb *= pow(i+1, mod-2, mod)
    ncb %= mod

nca %= mod
ncb %= mod


ans = pow(2, n, mod) - nca - ncb - 1
# print(pow(2, n, mod), nca, ncb)
while ans < 0:
    ans += mod
print(ans)

Measured memory_bytes: 40556
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define str string
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define eps 1e-6
#define pi atan(1) * 4
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000000
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
#define FORl(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORDl(i, a, b) for (ll i = (a); i >= (b); i--)
using namespace std;
vector< vector<bool> > mp;
vector< vector<pii> > dist[4];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct hk {
  int x, y, k;
  pii v;
};
struct cmp {
  bool operator() (const hk &a, const hk &b) const {
    if (a.v.fi != b.v.fi) return (a.v.fi > b.v.fi);
    return (a.v.se < b.v.se);
  }
};
priority_queue<hk, vector<hk>, cmp> pq;
bool operator < (pii a, pii b) {
  if (a.fi != b.fi) return (a.fi < b.fi);
  return (a.se > b.se);
}
int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  int h, w, t, sx, sy, tx, ty;
  cin >> h >> w >> t >> sx >> sy >> tx >> ty;
  mp.resize(h + 5);
  FOR(k, 0, 3) dist[k].resize(h + 5);
  FOR(i, 1, h) {
    string S;
    cin >> S;
    mp[i].resize(w + 5);
    FOR(k, 0, 3) dist[k][i].resize(w + 5);
    FOR(j, 1, w) {
      mp[i][j] = S[j - 1] == '.';
      FOR(k, 0, 3) dist[k][i][j] = {inf, 0};
    }
  }
  FOR(k, 0, 3) {
    dist[k][sx][sy] = {0, 0};
    int nx = sx + dx[k];
    int ny = sy + dy[k];
    pii nv = {1, t - 1};
    if (nx >= 1 && nx <= h && ny >= 1 && ny <= w && mp[nx][ny] && nv < dist[k][nx][ny]) {
      dist[k][nx][ny] = nv;
      pq.push({nx, ny, k, nv});
    }
  }
  while (!pq.empty()) {
    auto u = pq.top(); pq.pop();
    // cout << u.x << ' ' << u.y << ' ' << u.k << ' ' << u.v.fi << ' ' << u.v.se << endl;
    if (u.x == tx && u.y == ty) {
      printf("%d\n", u.v.fi);
      return 0;
    }
    FOR(k, 0, 3) {
      int nx = u.x + dx[k];
      int ny = u.y + dy[k];
      pii nv = u.v;
      if (k == u.k && nv.se) --nv.se;
      else nv.fi++, nv.se = t - 1;
      if (nx >= 1 && nx <= h && ny >= 1 && ny <= w && mp[nx][ny] && nv < dist[k][nx][ny]) {
        dist[k][nx][ny] = nv;
        pq.push({nx, ny, k, nv});
      }
    }
  }
  printf("-1\n");
  return 0;
}

Measured memory_bytes: 39980
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;
int main() {
  int a,b,c;
  cin >> a ;
  int d=0;
  rep(i, a) {
    rep(j, a) {
      rep(k, a) {
        d += gcd(gcd(i,j),k);
      }
    }
  }
  cout << d;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
sort(all(list));
sort(all(list), greater<int>());
//配列の内容表示
dout << "====listの内容====\n";
for (int i = 0; i < N; i++) dout << list[i] << endl;
dout << "====ここまで====\n";
*/


Measured memory_bytes: 3636
from collections import deque
n = int(input())
graph = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
c = list(map(int, input().split()))
c.sort(reverse=True)
ans = [None]*n
ans[0] = c[0]
q = deque([0])
i = 1
while q:
    node = q.popleft()
    for c_node in graph[node]:
        if ans[c_node] is not None:
            continue
        ans[c_node] = c[i]
        i += 1
        q.append(c_node)
print(sum(c)-c[0])
print(*ans)

Measured memory_bytes: 6160
class SegmentTree():
    def __init__(self, n, inf=float('inf')):
        #self.n = 2**(n-1).bit_length()
        _n = 1
        while _n < n:
            _n *= 2
        self.n = _n
        self.inf = inf
        self.data = [inf]*(2*self.n)

    def update(self, k, a):
        k += self.n-1
        self.data[k] = a

        while k > 0:
            k = (k-1)//2
            self.data[k] = min(self.data[k*2+1], self.data[k*2+2])

    def query(self, l, r):
        L = l+self.n
        R = r+self.n
        ret = self.inf
        while L < R:
            if R & 1:
                R -= 1
                ret = min(ret, self.data[R-1])
            if L & 1:
                ret = min(ret, self.data[L-1])
                L += 1
            L >>= 1
            R >>= 1
        return ret


n, q = map(int, input().split())
T = SegmentTree(n, 2**31-1)

ans = []
for _ in range(q):
    c, x, y = map(int, input().split())
    if c:
        ans.append(T.query(x, y+1))
    else:
        T.update(x, y)
print("\n".join(map(str, ans)))



Measured memory_bytes: 12736
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void){
	char s[1000];
	int n = 0;
	int w = 0;
	int S = 0;
	int e = 0;
	int i = 0;
	scanf("%s",s);
	while(s[i]){
		if(s[i] == 'N'){
			n = 1;
		}else if(s[i] == 'W'){
			w = 1;
		}else if(s[i] == 'S'){
			S = 1;
		}else if(s[i] == 'E'){
			e = 1;
		}
		i++;
	}
	if(n != S || w != e){
		printf("No\n");
	}else{
		printf("Yes\n");
	}
	return 0;
}

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

using namespace std;

int n, t, a[3005], b[3005], dp[3005][2];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> t;
	for (int i=0; i<n; i++) {
		cin >> a[i] >> b[i];
		for (int j=t; j>=a[i]; j--) {
			dp[j][1] = max(dp[j][1], dp[j - a[i]][1] + b[i]);
//			cout << "New dp value for " << j << " is " << dp[j][1] << endl;
		}
		for (int j=t; j>=1; j--) dp[j][1] = max(dp[j][1], dp[j - 1][0] + b[i]);
		for (int j=t; j>=a[i]; j--) dp[j][0] = max(dp[j][0], dp[j - a[i]][0] + b[i]);
	}
	cout << max(dp[t][1], dp[t][0]) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int y,m,d,num;
	while(scanf("%d %d %d",&y,&m,&d)!=EOF){
		num=y*10000+m*100+d;
		if(num<18680908)puts("pre-meiji");
		else if(num<19120730)printf("meiji %d %d %d\n",y-1867,m,d);
		else if(num<19261225)printf("taisho %d %d %d\n",y-1911,m,d);
		else if(num<19890108)printf("showa %d %d %d\n",y-1925,m,d);
		else printf("heisei %d %d %d\n",y-1988,m,d);
	}
return 0;
}

Measured memory_bytes: 608
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    int n;
    cin >> n;
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        if (to_string(i).size()%2 == 1) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define ll  long long
#define endl '\n'
#define pi 3.14159265
ll mark[500000]={0};
int main()
{       
    IOS;
   	ll n,x;
   	cin>>n>>x;
   	if(x==1||x==2*n-1)
   	{
   		cout<<"No";
   		return 0;
   	}
   	cout<<"Yes"<<endl;
   	if(n==2)
   	{
   		cout<<1<<endl<<2<<endl<<3<<endl;
   		return 0;
   	}
   	n=2*n-1;
   	if(x==n-1)
   	{
   		
   		mark[1]=1;
   		mark[x]=1;
   		mark[n]=1;
   		mark[x-1]=1;
   		ll count=0;
   		for(ll i=1;i<=n;i++)
   		{
   			if(count==(n-4)/2)
   				break;
   			if(mark[i]==0)
   			{
   				mark[i]=1;
   				count++;
   				cout<<i<<endl;
   			}
   		}
   		cout<<1<<endl<<x<<endl<<n<<endl<<x-1<<endl;
   		count=0;
   		for(ll i=1;i<=n;i++)
   		{
   			if(mark[i]==0)
   			{
   				mark[i]=1;
   				cout<<i<<endl;
   			}
   		}
   		return 0;
   	}
   	if(x==2)
   	{
   		for(ll i=1;i<=4;i++)
   			mark[i]=1;
   		ll count=0;
   		for(ll i=1;i<=n;i++)
   		{
   			if(count==(n-4)/2)
   				break;
   			if(mark[i]==0)
   			{
   				mark[i]=1;
   				count++;
   				cout<<i<<endl;
   			}
   		}
   		cout<<3<<endl<<2<<endl<<1<<endl<<4<<endl;
   		count=0;
   		for(ll i=1;i<=n;i++)
   		{
   			if(mark[i]==0)
   			{
   				mark[i]=1;
   				cout<<i<<endl;
   			}
   		}
   		return 0;
   	}
   	
   	for(ll i=x-2;i<=x+2;i++)
   		mark[i]=1;
   	ll count=0;
	for(ll i=1;i<=n;i++)
	{
		if(count==(n-5)/2)
			break;
		if(mark[i]==0)
		{
			mark[i]=1;
			count++;
			cout<<i<<endl;
		}
	}
	cout<<x+1<<endl<<x-1<<endl<<x<<endl<<x+2<<endl<<x-2<<endl;
	count=0;
	for(ll i=1;i<=n;i++)
	{
		if(mark[i]==0)
		{
			mark[i]=1;
			cout<<i<<endl;
		}
	}
}    	

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

int main() {
  long long N, K;
  cin >> N >> K;
  long long N2=N%K;
  if(N2<=(K+1)/2) {
    cout << N2 << endl;
  }
  else {
    cout << K-N2 << endl;
  }
}

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

const long long mod=1000000007LL;

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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	long long iv[n+5]={};
	for (int i = 1; i < n+5; ++i)
	{
		iv[i]=modinv(i,mod);
	}
	long long s[n+5]={};
	for (int i = 1; i < n+5; ++i)
	{
		s[i]=s[i-1]+iv[i];
		s[i]%=mod;
	}
	long long a,ans=0LL;
	for (int i = 1; i <= n; ++i)
	{
		cin>>a;
		ans+=a*(s[i]+s[n-i+1]-1LL)%mod;
		ans%=mod;
	}
	for (long long i = 1; i <= n; ++i)
	{
		ans*=i;
		ans%=mod;
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;
typedef long long ll;


int main()
{
    ios_base::sync_with_stdio(0);

   
        int x;
        cin >> x;

        string s = (x >= 30) ? "Yes" : "No";

        cout << s;



        cout << endl;
    


    return 0;
}



Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
// ascending order
#define asort(array, N) sort(array, array + N)
// descending order
#define asort_r(array, N) sort(array, array + N, greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	map<string, ll> d;
	for(int i = 0; i < N; i++) {
		string s;
		cin >> s;
		d[s]++;
	}
	int M;
	cin >> M;
	for(int i = 0; i < M; i++) {
		string t;
		cin >> t;
		d[t]--;
	}
	ll maxV = 0;
	for(auto p:d) {
		maxV = max(maxV, p.second);
	}
	cout << maxV << endl;	
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

void dijkstra() {
	int minv;
	int d[MAX], color[MAX];
	for (int i = 0; i < n; i++) {
		d[i] = INFTY;
		color[i] = WHITE;
	}
	d[0] = 0;
	color[0] = GRAY;
	while (1) {
		minv = INFTY;
		int u = -1;
		for (int i = 0; i < n; i++) {
			if (minv > d[i] && color[i] != BLACK) {
				u = i;
				minv = d[i];
			}
		}
		if (u == -1) break;
		color[u] = BLACK;
		for (int v = 0; v < n; v++) {
			if (color[v] != BLACK && M[u][v] != INFTY) {
				if (d[v] > d[u] + M[u][v]) {
					d[v] = d[u] + M[u][v];
					color[v] = GRAY;
				}
			}
		}
	}
	for (int i = 0; i < n; i++) {
		cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
	}
}
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) M[i][j] = INFTY;
	}
	int k, c, u, v;
	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			cin >> v >> c;
			M[u][v] = c;
		}
	}
	dijkstra();
	return 0;
}


Measured memory_bytes: 3124
#include <iostream>
#include <string>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;

int main() {
    int M, D;
    cin >> M >> D;
    int count = 0;
    rep(i, 1, M + 1) {
        rep(j, 1, D + 1) {
            if(j % 10 >= 2 && j / 10 >= 2 && (j % 10) * (j / 10) == i) {
                count++;
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#define _DEBUG 1
#define _GLIBCXX_DEBUG

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

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                         \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z     \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

const ll LINF = 2e18;
const int INF = 1e9;

void solve(ll N, std::vector<ll> A) {
  vector<int> C(N, 0);

  for (auto a : A) {
    C.at(a - 1)++;
  }

  for (auto c : C) {
    cout << c << endl;
  }
}

int main() {
  ll N;
  scanf("%lld", &N);
  std::vector<ll> A(N - 2 + 1);
  for (int i = 0; i < N - 2 + 1; i++) {
    scanf("%lld", &A[i]);
  }
  solve(N, std::move(A));
  return 0;
}


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

int main()
{
    string s;
    cin >> s;
    string ans = "Yes";
    string yaki = "YAKI";
    rep(i, 4) {
        if(s[i] != yaki[i]) ans = "No";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

/*
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()
*/

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-9;

void solve() {
    ll a, b;
    cin >> a >> b;
    ll ans = -INFL;
    chmax(ans, a + b);
    chmax(ans, a - b);
    chmax(ans, a * b);
    cout << ans << endl;
    return;
}

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


Measured memory_bytes: 256
#include <iostream>

using namespace std;


int main(){

    int A, B, C, D;

    cin >> A >> B >> C >> D;

    const int AB = A * B;
    const int CD = C * D;

    if(AB > CD){
        cout << AB << endl;
    } else if(AB < CD){
        cout << CD << endl;
    } else if(AB == CD){
        cout << AB << endl;
    }

    return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
line = gets.chomp.split(' ').map(&:to_i)
cnt = 0
n.times do |i|
    next if i == 0 || i == n-1
    if line[i-1] < line[i]
        cnt += 1 if line[i] < line[i+1]
    else
        cnt += 1 if line[i] > line[i+1]
    end
end
puts(cnt)

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

using namespace std;

//FILE *fi=freopen("1.txt","r",stdin);

long long a,b,dem=1;
bool f[1000001];
vector<long long> v;

void sang()
{
    for (int i=2;i<=1000000;++i)
    {
        if (!f[i])
        {
            v.push_back(i);
            for (int j=i*2;j<=1000000;j+=i)
                f[j]=1;
        }
    }
}

void process()
{
    sang();
    long long k=__gcd(a,b);
    for (auto i:v)
    {
        if (k%i==0) dem++;
        while (k%i==0)
            k/=i;
    }
    dem+=(k!=1);
    cout<<dem;
}

int main()
{
    scanf("%lld %lld",&a,&b);
    process();
    return 0;
}


Measured memory_bytes: 2424
import math

n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

test_case = []
for i in range(n):
    x1, y1 = xy[i]
    test_case.append((y1, -x1))
    test_case.append((-y1, x1))

ret = 0
for x1, y1 in test_case:
    sx, sy, tx, ty = 0, 0, 0, 0
    for j in range(n):
        x2, y2 = xy[j]
        if x1 * x2 + y1 * y2 > 0 or (x1 * x2 + y1 * y2 == 0 and -y1 * x2 + x1 * y2 <= 0):
            sx += x2
            sy += y2
    ret = max(ret, math.hypot(sx, sy), math.hypot(tx, ty))
print(ret)

Measured memory_bytes: 39536
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}



int main(){
	FIO
	
	priority_queue<int> s[1100];
	int n, q;
	cin >> n >> q;
	while(q--){
		int op, t;
		cin >> op >> t;
		if(op == 0){
			int x;
			cin >> x;
			s[t].push(x);
		}else if(op == 1){
			if(s[t].empty());
			else cout << s[t].top() << '\n';
		}else{
			if(!s[t].empty())
				s[t].pop();
		}
	}
	return 0;
}



Measured memory_bytes: 4028
X, Y, A, B, C = [int(x) for x in input().split()]
p = sorted([int(x) for x in input().split()], reverse=True)[:X]
q = sorted([int(x) for x in input().split()], reverse=True)[:Y]
r = sorted([int(x) for x in input().split()], reverse=True)[:X + Y]

s = sorted(p + q + r, reverse=True)

ans = sum(s[:X + Y])

print(ans)

Measured memory_bytes: 28372
K,N=map(int,input().split())
A=list(map(int,input().split()))
dis=0
for i in range(1,N):
    tmp=A[i]-A[i-1]
    dis=max(dis,tmp)
tmp=K+A[0]-A[N-1]
dis=max(dis,tmp)
print(K-dis)

Measured memory_bytes: 26436
#include <bits/stdc++.h>
using namespace std;
const int N=105,Mod=1e9+7;
int Head[N],Next[N<<1],Adj[N<<1],tot=0;
void addedge(int u,int v) {
	Next[++tot]=Head[u],Head[u]=tot,Adj[tot]=v;
	Next[++tot]=Head[v],Head[v]=tot,Adj[tot]=u;
}
inline int qpow(int a,int b) {
	int ans=1;
	while (b) {
		if (b&1) ans=1ll*ans*a%Mod;
		a=1ll*a*a%Mod,b>>=1;
	}
	return ans;
}
int n,m,k;
const int inv2=qpow(2,Mod-2);
inline int calc1() {
	return k;
}
inline int calc2(int len) {
	int sum=0;
	for (int i=1; i<=len; i++) sum=(sum+qpow(k,__gcd(i,len)))%Mod;
	return 1ll*sum*qpow(len,Mod-2)%Mod;
}
int fac[N<<1],inv[N<<1];
inline int C(int n,int m) {
	return 1ll*fac[n]*inv[m]%Mod*inv[n-m]%Mod;
}
inline int calc3(int len) {
	return C(k+len-1,k-1);
}
vector <int> bcc[N];int cnt=0;
int dfn[N],low[N],Time,s[N],top;
inline void Tarjan(int x,int fa){
	low[x]=dfn[x]=++Time;
	for (int e=Head[x];e;e=Next[e])
		if (!dfn[Adj[e]]){
			s[++top]=Adj[e];
			Tarjan(Adj[e],x);
			low[x]=min(low[x],low[Adj[e]]);
			if (low[Adj[e]]>=dfn[x]){
				++cnt;
				while (s[top]!=Adj[e])
					bcc[cnt].push_back(s[top--]);
				bcc[cnt].push_back(s[top--]);
				bcc[cnt].push_back(x);
			}
		}else if (Adj[e]!=fa) low[x]=min(low[x],dfn[Adj[e]]);
}
bool in[N];
int main () {
//	freopen ("c.in","r",stdin);
	scanf ("%d%d%d",&n,&m,&k);
	fac[0]=1;for (int i=1;i<=m+k;i++) fac[i]=1ll*fac[i-1]*i%Mod;
	inv[m+k]=qpow(fac[m+k],Mod-2);
	for (int i=m+k-1;i>=0;i--) inv[i]=1ll*inv[i+1]*(i+1)%Mod;
	for (int i=1; i<=m; i++) {
		int u,v;
		scanf ("%d%d",&u,&v);
		addedge(u,v);
	}
//	printf ("%d %d\n",c,s);
	for (int i=1;i<=n;i++)
		if (!dfn[i]) s[top=1]=i,Tarjan(i,0);
	int ans=1;
//	for (int i=1;i<=cnt;i++,puts(""))
//		for (int j=0;j<bcc[i].size();j++)
//			printf ("%d ",bcc[i][j]);
	for (int i=1;i<=cnt;i++){
		int counter=0,edge=0;
		for (int j=0;j<bcc[i].size();j++) in[bcc[i][j]]=true;
		for (int j=0;j<bcc[i].size();j++)
			for (int e=Head[bcc[i][j]];e;e=Next[e])
				if (in[Adj[e]]) edge++;
		edge>>=1;
		for (int j=0;j<bcc[i].size();j++) in[bcc[i][j]]=false;
		if (edge<bcc[i].size()) ans=1ll*ans*calc1()%Mod;
		else if (edge==bcc[i].size()) ans=1ll*ans*calc2(edge)%Mod;
		else ans=1ll*ans*calc3(edge)%Mod;
	}
	printf ("%d",ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lp(i, x, n) for (int i = x; i < (int)n; ++i)
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()
#define ll long long
#define N 111
int n;
int eq(int hw) {
        int nm = (hw * 10 + hw);
        int nm2 = (nm * 10 + hw);
        return nm2;
}
int main() {
        cin >> n;
        int nm2 = eq(n / 100);
        if (nm2 >= n) {
                cout << nm2;
        } else {
                cout << eq(n / 100 + 1);
        }
        return 0;
}


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

ll f(ll a) {
  ll tmp = (a + 1) / 2;
  return (tmp % 2) ^ ((a + 1) % 2 * a);
}

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

  ll a, b; cin >> a >> b;
  
  if(a == 0) cout << f(b) << endl;
  else cout << (f(b) ^ f(a-1)) << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include <float.h>
#include<math.h>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

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

  cout << fixed << setprecision(12);
  int N; cin >> N;
  int K; cin >> K;
  ld ans = 0;
  int cnt[100100];
  rep(i, N + 1) cnt[i] = 0;
  rep1(i, N) {
    int j = i;
    while(j < K) {
        j *= 2;
        cnt[i] ++;
    }
  }
  int power[100100];
  power[0] = 1;
  rep(i, cnt[1] + 1) {
      power[i + 1] = power[i] * 2; 
  }
  ld p = 1.0 / N;
  rep1(i, N) {
      ld q = 1.0 / power[cnt[i]];
      ans += p * q;
  }
  cout << ans << endl;
  return 0;
}

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

#define ll  long long
#define PII pair<ll,ll>
#define VI  vector<ll>
#define VB  vector<bool>
#define VC  vector<char>
#define VVI vector<vector<ll>>
#define VVC vector<vector<char>>
#define VS  vector<string>
#define VP  vector<PII>
#define lf(i,a,b) for(ll i=a;i<=b;i++)
#define lr(i,a,b) for(ll i=a;i>=b;i--)
#define lfl(i,v) for(ll i=0;i<v.size();i++)
#define lrl(i,v) for(ll i=(ll)(v.size())-1;i>=0;i--)
#define chk2(a,b) cout<<"check :  "<<a<<" "<<b<<endl
#define chk3(a,b,c) cout<<"check :  "<<a<<" "<<b<<" "<<c<<endl
#define chk4(a,b,c,d) cout<<"check :  "<<a<<" "<<b<<" "<<c<<" "<<d<<endl
#define chk5(a,b,c,d,e) cout<<"check :  "<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl
#define l_b(v,k)  lower_bound(v.begin(),v.end(),k)-v.begin()
#define u_b(v,k)  upper_bound(v.begin(),v.end(),k)-v.begin()
#define mod 1000000007
#define sort(v) sort(v.begin(),v.end())
#define p_b push_back
#define p_f push_front
#define m_p make_pair
#define fir first
#define sec second
#define sz size()

ll dfs(VVI &gp,ll v,VB &vis)
	{	ll cnt=1;
		vis[v]=true;
		lfl(i,gp[v])
		{	if(!vis[gp[v][i]])
			{	cnt+=dfs(gp,gp[v][i],vis);
			}
		}
		return cnt;
	}

int main() 
{	ll T;
	T=1;
	while(T--)
	{	ll n,m;cin>>n>>m;
		VVI gp(n+1);
		lf(i,1,m)
		{	ll u,v;cin>>u>>v;
			gp[u].p_b(v);
			gp[v].p_b(u);
		}
		ll maxi=0;
		VB vis(n+1,false);
		lf(i,1,n)
		{	if(!vis[i])
			{	maxi=max(maxi,dfs(gp,i,vis));
			}
		}
		cout<<maxi<<endl;
	}  		
}      


Measured memory_bytes: 26696
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long lint;

int main(){
	int L;
	cin >> L;
	printf("%.10f",L*L*L/27.0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sz 100002
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define pi pair<int,int>
#define PQ priority_queue<double, vector<double>, greater<double> >q
#define _sort(v) sort(v.begin(),v.end())
#define MP map<ll int,ll int>mp
#define MEM(x) memset(x,0,sizeof(x))
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define vec() vector<ll int>v1,v2
#define VEC(n) ll int x; vector<ll int>v;for(int i=0;i<n;i++){cin>>x;v.pb(x);}
#define TEST() int test;cin>>test; while(test--)
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
//Upper_bound   auto x=upper_bound(v[a].begin(),v[a].end(),les);les=*x; if(x==v[a].end())break;
//ll int LCM(ll int a,ll int b) { ll int gcd=__gcd(a,b);ll int lcm=a*b/gcd;return lcm;}
//ll int bigmod(ll int b, ll int p, ll int m){if(p==0)return 1;if(p%2!=0) return b%m*fun(b,p-1,m)%m;if(p%2==0){ ll int res=fun(b,p/2,m);return (res%m*res%m)%m;}}
//ll mod_inverse(ll a, ll mod){return bigmod(a,mod-2,mod);}
//void seive() { prime[np++]=2;for(i=3; i<=sz; i+=2){if(mark[i]==0){ prime[np++]=i;for(j=i*i; j<=sz; j+=i) mark[j]=1; } }}
//string add(string s1,string s2) {string s;int j=s1.size()-1,c=0,m; for(int i=s2.size()-1; i>=0; i--) {if(j>=0)m=s2[i]-'0'+s1[j]-'0'+c;else m=s2[i]-'0'+c; if(m>9) { s+=m%10+'0';c=m/10; } else {  c=0;s+=m+'0'; }j--; } if(c!=0) {s+=c+'0'; }reverse(s.begin(),s.end());return s;}
//int pos;string mul(int n) {string s;for(int i=0; i<pos; i++) { s+="0"; }pos++;int c=0,m; for(int i=s1.size()-1; i>=0; i--) { m=(s1[i]-'0')*n+c;if(m>9) { s+=m%10+'0';c=m/10;} else { c=0; s+=m+'0';} }while(c!=0) { s+=c%10+'0';c=c/10;}    reverse(s.begin(),s.end());return s;}

int main()
{
    ll int n,m,res=0,cnt=0;
  string s;
  cin>>s;
  int i;
  for( i=0;i<s.size();i++)cout<<s[i];
  if(s[i-1]=='s')cout<<"es"<<endl;
  else cout<<"s";


}


Measured memory_bytes: 3624
#N
n = int(input())
#a
a = list(map(int, input().split()))

#flg
out_flg = "N"

for i in range(len(a)):
    if a[i] %2 == 0 and a[i] %3 != 0 and a[i] %5 != 0:
        out_flg = "Y"
        break

if out_flg == "Y":
    print("DENIED")
else:
    print("APPROVED")

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <list>
#include <vector>
#include <stack>
#define N 100001
#define WHITE 0
#define GRAY 1

using namespace std;

int color[N];
vector<int> G[N];
list<int> L;
stack<int> S;

void dfs (int u, int V) {
  color[u] = GRAY;
  S.push(u);

  while (S.size()) {
    bool flag = false;

    for (int i = 0; i < G[S.top()].size(); i++) {
      int v = G[S.top()][i];

      if (color[v] == WHITE) {
        S.push(v);
        color[v] = GRAY;
        flag = true;
        break;
      }
    }

    if (!flag) {
      L.push_front(S.top());
      S.pop();
    }
  }
}

void dfs_init (int V) {
  for (int i = 0; i < V; i++) {
    if (color[i] == WHITE) {
      dfs(i, V);
    }
  }
}

int main () {
  int V, E, u, v;
  
  cin >> V >> E;

  for (int i = 0; i < E; i++) {
    cin >> u >> v;
    G[u].push_back(v);
  }

  dfs_init(V);

  for (list<int>::iterator it = L.begin(); it != L.end(); it++)
    cout << *it << endl;

  return 0;
}


Measured memory_bytes: 6224
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <algorithm>
#include <functional>
#include <string.h>

using namespace std;
typedef pair<long long, long long> P;

class Node
{
public:
	int left;
	int val;
	int right;
	Node()
	{
		left = 0;
		val = 0;
		right = 0;
	}
};

void solve()
{
	int N, K;
	cin >> N >> K;
	string S;
	cin >> S;
	int size = S.size();
	vector<int> vec1;
	vector<int> vec0;
	int cnt1 = 0;
	int cnt0 = 0;
	char cur = S[0];
	if (cur == '0')
	{
		cnt0 = 1;
		vec1.push_back(0);
	}
	else
	{
		cnt1 = 1;
	}
	for (int i = 1; i < size; ++i)
	{
		if (S[i] == cur)
		{
			if (cur == '0')
			{
				++cnt0;
			}
			else
			{
				++cnt1;
			}
		}
		else
		{
			if (cur == '0')
			{
				vec0.push_back(cnt0);
				cnt0 = 0;
				cnt1 = 1;
			}
			else
			{
				vec1.push_back(cnt1);
				cnt1 = 0;
				cnt0 = 1;
			}
			cur = S[i];
		}
	}
	if (cur == '0')
	{
		vec0.push_back(cnt0);
		vec1.push_back(0);
	}
	else
	{
		vec1.push_back(cnt1);
	}
	//for (int i = 0; i < vec1.size(); ++i)
	//{
	//	cout << vec1[i] << " ";
	//}
	//cout << endl;
	//for (int i = 0; i < vec0.size(); ++i)
	//{
	//	cout << vec0[i] << " ";
	//}
	//cout << endl;
	K = min(K, (int)vec0.size());

	if (vec1.size() == 0 || vec0.size() == 0)
	{
		if (vec0.size() == 0)
		{
			cout << vec1[0] << endl;
		}
		else
		{
			cout << S.size() << endl;
		}
		return;
	}
	bool flag = true;
	for (int i = 0; i < vec1.size(); ++i)
	{
		if (vec1[i] != 0)
		{
			flag = false;
		}
	}
	if (flag)
	{
		cout << S.size() << endl;
		return;
	}
	int val = vec1[0];
	int ans = val;
	for (int i = 0; i < K; ++i)
	{
		val += vec0[i] + vec1[i + 1];
	}
	ans = max(ans, val);
	for (int i = K; i < vec0.size(); ++i)
	{
		val -= vec0[i - K] + vec1[i - K];
		val += vec0[i] + vec1[i + 1];
		ans = max(ans, val);
	}
	cout << ans << endl;
}

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

Measured memory_bytes: 1020
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

fn main() {
    input! {
        a: usize,
        b: usize,
    }
    let mut ans = 0;

    let mut s = 1;
    while s < b {
        s += a - 1;
        ans += 1;
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352