akhauriyash/Code-Regression huggingface dataset:
import  java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    
    String[] s = sc.nextLine().split(" ");
    int H = Integer.parseInt(s[0]);
    int W = Integer.parseInt(s[1]);
    
    char[][] map = new char[H][W];
    int[][] route = new int[H][W];
    
    int dots = 0;
    for(int i = 0; i < H; i++){
      String str = sc.nextLine();
      for(int j = 0; j < W; j++){
        map[i][j] = str.charAt(j);
        if(i == 0 && j == 0){
          route[i][j] = 1;
          dots++;
        }else if(map[i][j] == '.'){
          route[i][j] = 0;
          dots++;
        }else{
          route[i][j] = -1;
        }
      } 
    }
    
    int[] ih = {+1, 0, -1, 0};
    int[] iw = {0, +1, 0, -1};
    
    Queue<Integer> qh = new ArrayDeque<>();
    Queue<Integer> qw = new ArrayDeque<>();
    qh.add(0);
    qw.add(0);
    boolean b = false;
    
    while(qh.size() > 0){
      int nh = qh.poll();
      int nw = qw.poll();
      
      if(nh == H - 1 && nw == W - 1){
        b = true;
        break;
      }
      
      for(int i = 0; i < 4; i++){
        int fh = nh + ih[i];
        int fw = nw + iw[i];
        
        if(fh >= 0 && fw >= 0 && fh < H && fw < W && route[fh][fw] == 0){
          qh.add(fh);
          qw.add(fw);
          route[fh][fw] = route[nh][nw] + 1;
        }
      }
    }
    if(b){
      System.out.println(dots - route[H-1][W-1]);
    }else{
      System.out.println(-1);
    }
  }
}

Measured memory_bytes: 22996
#include <algorithm>
#include <iostream>
#include <vector>
#include <tuple>
using namespace std;
const long long INF = 1LL << 60;    // 1.15x10^18
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using edge = pair<int, long long>;
using Graph = vector<vector<edge>>;

int main() {
    int n, m; cin >> n >> m;
    int l; cin >> l;
    Graph g(n);
    for (int i = 0; i < m; i++) {
        int a, b, c; cin >> a >> b >> c; a--, b--;
        if (c > l) continue;
        g[a].emplace_back(b, c);
        g[b].emplace_back(a, c);
    }
    using pll = pair<long long, long long>;
    vector<vector<pll>> dp(n, vector<pll>(n, {INF, INF}));
    for (int s = 0; s < n; s++) {
        dp[s][s] = {0, 0};
        vector<bool> fixed(n);
        while (true) {
            int u = -1;
            for (int i = 0; i < n; i++) if (!fixed[i]) {
                if (u == -1 || dp[s][i] < dp[s][u]) u = i;
            }
            if (u == -1) break;
            fixed[u] = true;
            long long cnt, used; tie(cnt, used) = dp[s][u];
            for (auto &e: g[u]) {
                int v; long long c; tie(v, c) = e;
                long long nused = used + c;
                pll np = {cnt, nused};
                if (nused > l) np = {cnt + 1, c};
                chmin(dp[s][v], np);
            }
        }
    }
    int q; cin >> q;
    while (q--) {
        int a, b; cin >> a >> b; a--, b--;
        long long res = dp[a][b].first;
        if (res == INF) cout << -1 << endl;
        else cout << res << endl;
    }
    return 0;
}

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

int A[10000000];
int n,q;

int bisearch(int key){
    int left = 0;
    int right = n;
    while(left < right){
        int mid = (left + right) /2;
        if (A[mid] == key) return 1;
        else if (key < A[mid]) right = mid;
        else left = mid+1;
    }
    return 0;
}

int main(){
    int cou =0;
    cin >> n;
    for(int i =0; i<n; i++){
         cin >> A[i];
    }
    cin >> q;
    int t;
    for (int i =0; i<q; i++){
        cin >> t;
        if (bisearch(t)) cou++;
        }
    cout << cou << endl;
    return 0;
}


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

int main(){
    int n;cin>>n;
    vector<pair<long long, long long>> scores(n);
    for (int i=0;i<n;i++){
        long long a, b;cin>>a>>b;
        scores[i] = make_pair(a, b);
    }
    sort(scores.begin(), scores.end(), greater<pair<long long, long long>>());
    cout << scores[0].first + scores[0].second << endl;
    return 0;

}

Measured memory_bytes: 1792
n=int(input())
lists=list(map(int,input().split()))
lists=sorted(lists)
length=len(lists)
anslist=[]
for j in range(-100,101):
    ans=0
    for i in range(n):
        ans+=(lists[i]-j)**2
    anslist.append(ans)
print(min(anslist))

Measured memory_bytes: 3064
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define PI 3.14159265358979
typedef long long int ll;
const int inf=1001001001;
int main()
{
    double m,b,c,n,sum=0;int ans=0;
    string s,t;
    cin>>n>>m;
    vector<double>a(n);
    rep(i,n){cin>>a[i];sum+=a[i];}
    rep(i,n){
    	if(a[i]>=double(sum/(4*m)))ans++;
    }
    cout<<(ans>=m?"Yes":"No");
}


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

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

int main() {
#define int long long
	int n,x;
	cin >> n >> x;
	vector<long long> hogea;
	for(int i = 0; i < n; i++) {
		long long geko;
		cin >> geko;
		hogea.push_back(llabs(geko - x));
	}
	long long ans = max(hogea[0], 0LL);
	for (int i = 1; i < n; ++i) {
		ans = gcd(ans, hogea[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll value[1005],weight[1005];
ll dp[1005][100005];
ll ans(ll n,ll w)
{
    if(dp[n][w]!=-1)
    return dp[n][w];
    if(weight[n]>w)
    {dp[n][w]=ans(n-1,w);
    return dp[n][w];}
    else
    {
        dp[n][w]=max(ans(n-1,w),value[n]+ans(n-1,w-weight[n]));
        return dp[n][w];
    }
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t;
    t=1;
    while(t--)
    {
        ll n,w;
        cin>>n>>w;
        for(ll i=1;i<=n;i++)
        cin>>weight[i]>>value[i];
        for(ll i=0;i<=n;i++)
        for(ll j=0;j<=w;j++)
        if(i==0||j==0)
        dp[i][j]=0;
        else
        dp[i][j]=-1;
        cout<<ans(n,w)<<"\n";
    }
    return 0;
}

Measured memory_bytes: 82528
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
    long P = sc.nextLong();
    
    PriorityQueue<Long> q = new PriorityQueue<>();
    for (long i = 1; i*i <= P; i++) {
      if (P%i == 0) {
        if (i != 1) {
          q.offer(i);
        }
        if (P/i != 1) {
          q.offer(P/i);
        }
      }
    }
    
    Map<Long, Integer> map = new HashMap<>();
    while (!q.isEmpty()) {
      long d = q.poll();
      while (P%d == 0) {
        map.put(d, map.getOrDefault(d, 0)+1);
        P /= d;
      }
      d++;
    }
    
    long ans = 1;
    for (Map.Entry<Long, Integer> entry : map.entrySet()) {
      long prime = entry.getKey();
      int count = entry.getValue();
      for (int i = 0; i < count/N; i++) {
        ans *= prime;
      }
    }

    System.out.println(ans);
  }
}

Measured memory_bytes: 23892
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define SIZE 100010
int main(){

    int N,M;
    cin >> N >> M;
    vector<pair<int,int>> city[SIZE];

    for(int i=0; i<M; i++){
        int name_tmp, year_tmp;
        cin >> name_tmp >> year_tmp;
        city[name_tmp-1].push_back({year_tmp,i});
    }

    char ans[SIZE][13];

    for(int i=0;i<N;i++){
        sort(city[i].begin(), city[i].end());
 
        for(int j=0;j<city[i].size();j++){
            sprintf(ans[city[i][j].second], "%06d%06d", i+1, j+1);
        }
    }

    for(int i=0; i<M; i++){
        printf("%s\n", ans[i]);
    }

    return 0;
}







Measured memory_bytes: 8192
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
using namespace std;
using ll = long long;

const int mod = 1e9 + 7;

vector<vector<int>> matrix_mul(
    const vector<vector<int>> &a,
    const vector<vector<int>> &b) {

  int n = a.size();
  vector<vector<int>> c(a.size(), vector<int>(a.size(), 0));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      for (int k = 0; k < n; ++k) {
        c[i][j] += a[i][k] * 1ll * b[k][j] % mod;
        if (c[i][j] >= mod) {
          c[i][j] -= mod;
        }
      }
    }
  }
  return c;
}

long long binpow(vector<vector<int>> a, long long b) {
  int n = a.size();
  vector<vector<int>> res(n, vector<int>(n, 0));
  for (int i = 0; i < n; ++i) {
    res[i][i] = 1;
  }
  while (b > 0) {
    if (b & 1)
      res = matrix_mul(res, a);
    a = matrix_mul(a, a);
    b >>= 1;
  }
  long long r = 0ll;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      r += res[i][j];
      if (r >= mod) {
        r -= mod;
      }
    }
  }
  return r;
}

int main() {
  int n;
  ll K;
  cin >> n >> K; // K ~ 10 ^ 18

  vector<vector<int>> a(n, vector<int>(n));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      cin >> a[i][j];
    }
  }
  cout << binpow(a, K) << '\n';
  return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
using namespace std;


int main(void)
{
	int N; cin >> N;
	map<int, int> prime;
	rep(i, 2, N + 1) {
		int n = i;
		rep(j, 2, n + 1) {
			while (n > 0 && n%j == 0) {
				n /= j;
				prime[j]++;
			}
		}
	}

	lli ans = 1;
	map<int, int>::iterator it;
	for (it = prime.begin(); it != prime.end(); it++) {
		ans = (ans*(it->second + 1)) % MOD;
		//cout << it->first << it->second << endl;
	}

	cout << ans << endl;

	return 0;
}


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

using namespace std;

int main() {
	int n, b, f, r, v, p[4][3][10];
	memset(p, 0, sizeof(p));
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> b >> f >> r >> v;
		p[b-1][f-1][r-1] += v;
	}
	for (int i = 0; i < 4; i++) {
		if (i != 0)
			cout << "####################" << endl;
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 10; k++) {
				cout << " " << p[i][j][k];
			}
			cout << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1168
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<climits>

struct item{
	long long w;
	long long v;
};

int main(){
	int n, w;
	long long ans=0;
	std::cin>>n>>w;

	std::vector<item> itemList(n);
	std::vector<long long> dpList(w+1, 0);

	for(int i=0; i<n; i++)
		std::cin>>itemList[i].w>>itemList[i].v;

	for(int i=0; i<n; i++){
		for(int j=w; j>=0; j--){
			if(j!=0 && dpList[j]==0)
				continue;

			if(j+itemList[i].w >w)
				continue;

			dpList[j+ itemList[i].w]= std::max(dpList[j+ itemList[i].w], dpList[j]+itemList[i].v);
		}	
	}

	for(int i=0; i<w+1; i++)
		ans= std::max(ans, dpList[i]);

	std::cout<<ans<<std::endl;

	return 0; 
}

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

vector<vector<int>> G, C, D;
int par[100010][21], euler[200010], ve[100010], dep[100010];
vector<vector<int>> s, t, num;
bool looked[100010];

int dfs(int key, int now){
	looked[key]=1;
	ve[key]=now;
	int res=now;
	for(int i=0; i<G[key].size(); ++i){
		if(!looked[G[key][i]]){
			par[G[key][i]][0]=key;
			dep[G[key][i]]=dep[key]+1;
			euler[res+1]=euler[res]+D[key][i];
			int tb=t[C[key][i]].back()+D[key][i], nb=num[C[key][i]].back();
			s[C[key][i]].emplace_back(res+1);
			t[C[key][i]].emplace_back(tb);
			num[C[key][i]].emplace_back(nb+1);
			res=dfs(G[key][i], res+1);
			euler[res+1]=euler[res]-D[key][i];
			tb -= D[key][i];
			s[C[key][i]].emplace_back(res+1);
			t[C[key][i]].emplace_back(tb);
			num[C[key][i]].emplace_back(nb);
			++res;
		}
	}
	return res;
}

int dist(int key, int X, int Y){
	int ok=0, ng=s[X].size();
	while(ok+1<ng){
		int mid=(ok+ng)/2;
		if(s[X][mid]<=ve[key]) ok=mid;
		else ng=mid;
	}
	return euler[ve[key]]-t[X][ok]+num[X][ok]*Y;
}

int solve(int X, int Y, int U, int V){
	int ut=U, vt=V;
	if(dep[ut]<dep[vt]) swap(ut, vt);
	for(int i=20; i>=0; --i){
		if((dep[ut]-dep[vt])&(1<<i)){
			ut=par[ut][i];
		}
	}
	int lca;
	if(ut==vt) lca=ut;
	else{
		for(int i=20; i>=0; --i){
			if(par[ut][i]!=par[vt][i]){
				ut=par[ut][i];
				vt=par[vt][i];
			}
		}
		lca=par[ut][0];
	}
	int p=dist(lca, X, Y);
	return (dist(U, X, Y)-p)+(dist(V, X, Y)-p);
}

int main() {
	int N, Q;
	cin >> N >> Q;
	G.resize(N+1);
	C.resize(N+1);
	D.resize(N+1);
	for(int i=1; i<N; ++i){
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		G[a].emplace_back(b);
		C[a].emplace_back(c);
		D[a].emplace_back(d);
		G[b].emplace_back(a);
		C[b].emplace_back(c);
		D[b].emplace_back(d);
	}
	par[1][0]=0;
	dep[1]=0;
	s.assign(N+1, {0});
	t.assign(N+1, {0});
	num.assign(N+1, {0});
	dfs(1, 0);
	for(int i=1; i<21; ++i){
		for(int j=1; j<=N; ++j) par[j][i]=par[par[j][i-1]][i-1];
	}
	for(int i=0; i<Q; ++i){
		int x, y, u, v;
		cin >> x >> y >> u >> v;
		cout << solve(x, y, u, v) << endl;
	}
	return 0;
}

Measured memory_bytes: 52960
N = int(input())
A = sorted(list(map(int, input().split())))
l = []

for i in range(N):
  l.append(2**(i+1))

l = sorted(l, reverse = True)
  
array_multiple = list(map(lambda x,n: x/n, A, l))

print(sum(array_multiple)+A[0]/(2**N))

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

using namespace std;

int main (void) {
    long long n, a, b;
    cin >> n;
    cin >> a;
    cin >> b;
    long long count = n/(a+b);
    long long mod = n%(a+b);
    long long res = count * a + min(mod, a);
    cout << res;
}

Measured memory_bytes: 256
from collections import deque
N,Q = map(int,input().split())
tree = [[] for _ in range(N+1)]
counter = [0]*(N+1)
for i in range(N-1):
    a,b = map(int,input().split())
    tree[a].append(b)
    tree[b].append(a)
for i in range(Q):
    p,x = map(int,input().split())
    counter[p] += x
already = set()
d = deque([1])

while d:
    a = d.popleft()
    for b in tree[a]:
        if not b in already:
            counter[b] += counter[a]
            d.append(b)
    already.add(a)

print(*counter[1:])

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  cout << "{";
  for (int i = 0; i < vec.size(); i++)
    os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  cout << "}";
  return os;
}

// ====================================================================

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

  bool can = false;
  for (int i = 0; i < n - 1; i++) {
    for (int j = i; j < n; j++) {
      vector<int> res(v);
      swap(res[i], res[j]);
      // cout << res << endl;
      bool ok = true;
      for (int k = 0; k < res.size() - 1; k++)
        if (res[k] > res[k + 1]) ok = false;
      if (ok) can = true;
    }
  }
  cout << ((can) ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
import sys
import collections
import bisect

input = sys.stdin.readline

N, K = map(int, input().split())
S = input().strip()

zerocnt = collections.Counter()
zeroindex = [-1] * N
onecnt = collections.Counter()
oneindex = [-1] * N

zh = oh = None
for i, x in enumerate(S):
    if x == "0":
        if i == 0 or S[i - 1] == "1":
            zh = i
    else:
        if i == 0 or S[i - 1] == "0":
            oh = i
    if zh is not None:
        zeroindex[i] = zh
        zerocnt[zh] += x == "0"
    if oh is not None:
        oneindex[i] = oh
        onecnt[oh] += x == "1"

zerolist = sorted(zerocnt.keys()) + [N]
onelist = sorted(onecnt.keys())


def solve():
    maxval = -1
    maxrange = None
    for i, head in enumerate(zerolist):
        zstart = max(i - K, 0)
        start = zerolist[zstart]
        if start > 0:
            assert S[start - 1] == "1"
            start = oneindex[start - 1]
        val = head - start
        if maxval < val:
            maxval = val
            maxrange = (start, head)
    return maxval


if len(zerocnt) <= K:
    print(N)
else:
    print(solve())


Measured memory_bytes: 15732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

typedef struct fast_prime_factorization {
    ll PRIME_FACTORIZE_MAX;
    vector<ll> primes;

    void erathos() {
        for(ll i = 2; i <= PRIME_FACTORIZE_MAX; i++) {
            if(primes[i] != 1) continue;
            for(ll j = i; j <= PRIME_FACTORIZE_MAX; j += i) {
                primes[j] = i;
            }
        }
    }

    fast_prime_factorization(ll _NMAX) : PRIME_FACTORIZE_MAX(_NMAX) {
        primes.resize(PRIME_FACTORIZE_MAX, 1);
        erathos();
    }

    vector<pair<ll,ll>> factorize(ll n){
        vector<pair<ll,ll>> res;
        while(n != 1) {
            ll cur = primes[n];
            ll cnt = 0;
            while(n % cur == 0) {
                n /= cur;
                cnt++;
            }
            res.push_back({cur, cnt});
        }
        return res;
    }
} osa_k;


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

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

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, 0, n) cin >> a[i];
    bool pair_wise = true;
    set<ll> seen;
    osa_k p(1000010);
    rep(i, 0, n) {
        auto v = p.factorize(a[i]);
        for(auto e : v) {
            if(seen.count(e.first)) {
                pair_wise = false;
                break;
            }
            seen.insert(e.first);
        }
        if(!pair_wise) break;
    }
    if(pair_wise) {
        cout << "pairwise coprime" << endl;
        return 0;
    }
    ll g = a[0];
    rep(i, 0, n) g = gcd(g, a[i]);
    if(g == 1) cout << "setwise coprime" << endl;
    else cout << "not coprime" << endl;
    return 0;
}

Measured memory_bytes: 18756
#include<stdio.h>

int main(void){

	int N, N1, N2, N3;

	scanf("%d", &N);

	N3 = N / 100;
	N2 = (N - N3 * 100)  / 10; 
	N1 = N - N3 * 100 - N2 * 10;

	if(N1 == 7 || N2 == 7 || N3 == 7 )
		printf("Yes");
	else
		printf("No");

	return 0;

}

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

int main(){
	int n,p,cnt1=0,cnt2=0;;cin>>n>>p;
  	long long int ans=0;
  	vector<int> a(n);
  	for(int i=0;i<n;i++){
      cin>>a[i];
      if(a[i]%2==0) cnt2++;
      if(a[i]%2==1) cnt1++;
    }
  if(p%2==1){
    if(cnt1==0){
    	ans=0;
    }else{
		ans=pow(2,n-1);
    }
  } 
  if(p%2==0){
    if(cnt1==0){
  		ans=pow(2,n);
  	}else{
    	ans=pow(2,n-1);
    }
  }
  cout<<ans<<endl;
  
}   

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int T[10000];
  int S[10000];
  int i,j,n,m,count=0;

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&T[i]);

  scanf("%d",&m);
  for(i=0;i<m;i++) scanf("%d",&S[i]);
  
  for(i=0;i<m;i++)
    {
    for(j=0;j<n;j++)
      {
      if(S[i] == T[j]){
	count++;
	break;
      }
      }
    }

  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set1;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

int main() 
{
	ll x,n;
	cin>>x>>n;
	unordered_map<ll,ll> um;
	REP(i,0,n){
		ll x1;
		cin>>x1;
		um[x1] = 1;
	}
	if(!um.count(x)){
		cout<<x<<endl;
		return 0;
	}
	ll curr1 = x-1;
	ll curr2 = x+1;
	while(1){
		if(!um.count(curr1)){
			cout<<curr1<<endl;
			return 0;
		}
		else curr1--;

		if(!um.count(curr2)){
			cout<<curr2<<endl;
			return 0;
		}
		else curr2++;
	}
	return 0;
}

Measured memory_bytes: 3632
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils,Classes;
var
  a,h,w,i,j,count,x,y,sw,m,n,b,c,soeji,sum,max:Integer;
  //a:array of Integer;
  s,s123,s1,s2,s3:string;
  tf:Boolean;
  nyu:TStringList;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Readln(s);
    //s2 := Copy( s1, 3, 2 );

    for i := (Length(s)div 2 - 1) downto 1 do begin
      if Copy(s,1,i)=Copy(s,i+1,i) then begin
        Writeln(i*2);
        break;//exit;
      end;
    end;
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.


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

#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) \
  for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) \
  for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int;  // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9) + 7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";
const double PI = acos(-1);

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector<pair<ll, ll>> prime_factorize(ll n) {
  vector<pair<ll, ll>> p;
  for (ll i = 2; i * i <= n; i++) {
    if ((n % i) != 0) continue;
    pair<ll, ll> a = make_pair(i, 0);
    while ((n % i) == 0) {
      n /= i;
      a.second += 1;
    }
    p.push_back(a);
  }

  if (n != 1) p.push_back(make_pair(n, 1));
  return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a) {
  ll b = MOD, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= MOD;
  if (u < 0) {
    u += MOD;
  }
  return u;
}
// 順列
ll permutation(const ll n, const ll m) {
  ll result = 1;
  for (ll i = n; i > n - m; i--) {
    result = (result * i) % MOD;
  }
  return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x) {
  if (x == 0) return 1;
  ll res = repeat_square(n, x / 2);
  res = res * res % MOD;
  if ((x % 2) == 1) res = res * n % MOD;
  return res;
}
// 組み合わせ nCm
ll combination(ll n, ll m) {
  ll p = permutation(n, m);
  ll div = 1;
  for (ll i = 2; i <= m; i++) {
    div = (div * i) % MOD;
  }
  return (p * modinv(div)) % MOD;
}

// アルファベットの取得
string get_alphabet(ll n) {
  n--;
  return string(1, 'a' + (n % 26));
}

int main() {
  int X;
  cin >> X;
  if (1800 <= X) {
    cout << "1" << endl;
  } else if (1600 <= X) {
    cout << "2" << endl;
  } else if (1400 <= X) {
    cout << "3" << endl;
  } else if (1200 <= X) {
    cout << "4" << endl;
  } else if (1000 <= X) {
    cout << "5" << endl;
  } else if (800 <= X) {
    cout << "6" << endl;
  } else if (600 <= X) {
    cout << "7" << endl;
  } else if (400 <= X) {
    cout << "8" << endl;
  }
  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vll2 = vector<vector<ll>>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> d(n), c(n, -1);
    vector<P> v;
    vector<vector<P>> G(n);
    for (int i = 0; i < n; i++) {
        cin >> d[i];
        v.push_back(P(d[i], i));
    }
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        G[a].push_back(P(b, i));
        G[b].push_back(P(a, i));
    }
    sort(all(v));
    int M = 1000000000;
    vector<int> res(m, M);
    for (int id = 0; id < n; id++) {
        int i = v[id].second;
        bool f = false;
        int c0 = 0, c1 = 0, c2 = 0, c3 = 0;
        for (auto &e : G[i]) {
            int cc = res[e.second], to = e.first;
            if (d[to] < d[i]) {
                res[e.second] = d[i];
                if (c[to]) {
                    c1++;
                } else {
                    c0++;
                }
                f = true;
            } else if (d[to] == d[i]) {
                res[e.second] = d[i];
                if (c[to] != -1) {
                    if (c[to]) {
                        c3++;
                    } else {
                        c2++;
                    }
                }
                f = true;
            }
        }
        if (c0 > 0 || c3 > 0) {
            c[i] = 0;
        } else {
            c[i] = 1;
        }
        if (!f) {
            cout << -1 << endl;
            return 0;
        }
        for (auto &e : G[i]) {
            int to = e.first;
            if (d[to] < d[i]) {
                if (c[i] == c[to]) {
                    res[e.second] = d[i] - d[to];
                }
            }
        }
    }
    for (int i = 0; i < n; i++) {
        if (c[i]) {
            cout << "B";
        } else {
            cout << "W";
        }
    }
    cout << endl;
    for (int i = 0; i < m; i++) {
        cout << res[i] << endl;
    }
}


Measured memory_bytes: 17392
#include <bits/stdc++.h>
using namespace std;
const int INF = 2100100100;
using ll = long long;

int main() {
    int n;
    cin >> n;
    set<int> input;
    for (int i=0;i<n;i++){
        int n;
        cin >> n;
        input.insert(n);
    }
    int num = input.size();
    if (num == n){
        cout << "YES" << endl;
        return 0;
    }
    cout << "NO" << endl;
    return 0;
}



Measured memory_bytes: 9600
//in the name of god
//if you read this code please search about imam hussain
#include<bits/stdc++.h>
using namespace std;typedef long long ll;

#define pb push_back
#define endl "\n";
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define read freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
const int maxn=1e5+5;const int mod=1e9+7;const int inf=1e9;const int del=728729;int n , a[maxn] , last[maxn]; ll ans;int main(){migmig ;cin>>n ; for(int i = 1 ; i <= n ; i ++){cin>>a[i] ;}int ans = 0 ; fill(last,last+maxn,-inf) ; for(int i = 1 ; i <= n ; i++){int l = 1 , r = maxn ;while(r - l > 1){int mid = (l + r) / 2 ; if(last[mid] >= a[i]) l = mid ; else r = mid ; }ans = max(ans , l+1) ;last[l+1] = max(last[l+1] , a[i]) ; }cout<<ans-1;}



Measured memory_bytes: 1024
/***
 *      __  __            _    _       _
 *     |  \/  |          | |  | |     | |
 *     | \  / |_ __      | |  | |_ __ | | ___ __   _____      ___ __
 *     | |\/| | '__|     | |  | | '_ \| |/ / '_ \ / _ \ \ /\ / / '_ \
 *     | |  | | |     _  | |__| | | | |   <| | | | (_) \ V  V /| | | |
 *     |_|  |_|_|    (_)  \____/|_| |_|_|\_\_| |_|\___/ \_/\_/ |_| |_|
 *
 *
***/
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
/*---------------for_stuff-------------------*/
#define f(i,a,b) for (int i=a;i<=b;i++)
#define f_(i,a,b) for (int i=a;i>=b;i--)
/*---------------pair_stuff------------------*/
#define MP make_pair
#define ii pair<int,int>
#define Iii pair<int,ii>
#define ill pair<int,ll>
#define lli pair<ll,int>
#define iiI pair<ii,int>
#define llll pair<ll,ll>
#define fi first
#define se second
/*--------------vector_stuff-----------------*/
#define pb push_back
#define ppb pop_back
/*--------------const_stuff-----------------*/
const ll mod=1000000007;
const int N=1005;
/*--------------map_stuff--------------------*/
// why do you think I should write something in this part? :v

int x,y,z,k,K;
ll a[N],b[N],c[N],tong[3000005],anothertong[3000005];
int main() {
//	freopen("","r",stdin);
//	freopen("","w",stdout);
	scanf("%d %d %d %d", &x, &y, &z, &k);
	f(i,1,x) scanf("%lld", &a[i]);
	f(i,1,y) scanf("%lld", &b[i]);
	f(i,1,z) scanf("%lld", &c[i]);
	K=k;
	/*
	f(i,1,x) cout<<a[i]<<" ";
	cout<<"\n";
	f(i,1,y) cout<<b[i]<<" ";
	cout<<"\n";
	f(i,1,z) cout<<c[i]<<" ";
	cout<<"\n";
	*/
	f(i,1,x) 
		f(j,1,y) 
			tong[(i-1)*y+j]=a[i]+b[j];
	
	// f(i,1,x*y) cout<<tong[i]<<" ";
	// cout<<"\n\n";
	sort(tong+1,tong+1+x*y);
	k=min(k,x*y);
	// f(i,1,x*y) cout<<tong[i]<<" ";
	// cout<<"\n\n";
	f(i,1,k) tong[i]=tong[x*y-k+i];
	// f(i,1,x*y) cout<<tong[i]<<" ";
	// cout<<"\n\n";
	f(i,1,k) {
		f(j,1,z) {
			anothertong[(i-1)*z+j]=tong[i]+c[j];
			// cout<<(i-1)*k+j<<" ";
		}
	}
	// cout<<"\n";
	// f(i,1,k*z) cout<<anothertong[i]<<" ";
	// cout<<"\n\n";
	sort(anothertong+1,anothertong+1+k*z);
	int dem=0;
	for (int i=k*z;i>0;i--) {
		dem++;
		printf("%lld\n", anothertong[i]);
		if (dem==K) break;
	}
	return 0;
}

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

struct SGreater{
  bool operator() (string a,string b){
    if(a.size()!=b.size())
      return a.size()>b.size();
    else
      return a>b;
  }
};

int main()
{
  int n;
  cin>>n;
  map<string,int> data;
  priority_queue<string, vector<string>, SGreater> qu;
  for(;n--;)
    {
      string s;
      int x;
      cin>>s>>x;
      if(data[s])
	{
	  data[s]+=x;
	}
      else
	{
	  data[s]=x;
	  qu.push(s);
	}
    }
  while(!qu.empty())
    {
      cout<<qu.top()<<" "<<data[qu.top()]<<endl;
      qu.pop();
    }
}

Measured memory_bytes: 1224
#include<set>
#include<map>
#include<list>
#include<queue>
#include<cmath>
#include<vector>
#include<cstdio>
#include<cctype>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define qread(x) x=read()
#define mes(x,y) memset(x,y,sizeof(x))
#define mpy(x,y) memcpy(x,y,sizeof(x))
#define INF 2147483647
inline int read(){
	int f=1,x=0;char ch;
	while(!(ch>='0'&&ch<='9')){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return f*x;
}
int a,b,c,x,y,ans;
int main(){
	qread(a),qread(b),qread(c),qread(x),qread(y);
	ans=0;
	if(2*c<a+b){
		ans+=std::min(x,y)*c*2;
		if(x<y){
			y-=x;
			if(2*c<=b)ans+=y*c*2;
			else ans+=y*b; 
		}
		else{
			x-=y;
			if(2*c<=a)ans+=x*c*2;
			else ans+=x*a;
		}
	}
	else{
		ans=x*a+y*b;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)

func main() {
	n := readInt64()
	ans := ""
	for n > 0 {
		n--
		ans = string('a'+n%26) + ans
		n /= 26
	}
	fmt.Println(ans)

}

var (
	scanner *bufio.Scanner
)

func init() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
}

func readInt64() int64 {
	var t string

	if scanner.Scan() {
		t = scanner.Text()
	}

	n, err := strconv.ParseInt(t, 10, 64)
	if err != nil {
		log.Fatal(err)
	}

	return n

}


Measured memory_bytes: 1832
def get(text,n):
    ans = [""]*n
    i = 0
    for x in text:
        if x==" ":
            i = i + 1
        ans[i] = ans[i]+x
    return ans

hn = input()
H = int(get(hn,2)[0])
N = int(get(hn,2)[1])

a_text = input()
a = get(a_text,N)

s = 0
for i in range(N):
    s = s +  int(a[i])

if s >= H:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 10496
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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

    cout << a-b+1 << endl;
}


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

int main(){
    int n;
    cin >> n;
    int s[n];
    for(int i=0;i<n;i++)cin >> s[i];
    int q;
    cin >> q;
    int t[q];
    for(int i=0;i<q;i++)cin >> t[i];
    int count=0;
    for(int i=0;i<q;i++){
        for(int j=0;j<n;j++){
            if(t[i]==s[j]){
                count++;
                break;
            }
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 3104
#include <stdio.h>
#define NUM 10000
int main(int argc, const char * argv[]) {

//    int D[NUM];
//
//    int y;
//    for(int x=1;x<10001;x++){
//        scanf("%d",&y);
//        D[x]=y;
//        if(y==0){
//            break;
//        }
//    }
//    for(int x=1;x<10001;x++){
//        if(D[x]==0){
//            break;
//        }
//    printf("case %d:%d\n",x,D[x]);
//
//    }
//
//    return 0;
//}
    int a,b=1,c;
    while(1){
        scanf("%d",&a);
        if(a==0){break;}
        printf("Case %d: %d\n",b,a);
        b++;
    }
    return 0;
}



Measured memory_bytes: 2024
package main

import (
	"fmt"
	"log"
)

func solution(a, b int) int {
	ans := 1 << 31
	for i := 1250; i > 0; i-- {
		if int(float64(i)*0.08) == a && int(float64(i)*0.1) == b {
			log.Print(i)
			ans = min(ans, i)
		}
	}
	if ans != 1<<31 {
		return ans
	}
	return -1
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	fmt.Println(solution(a, b))
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int a[13];
int n;
vector<int> v;

bool dfs(int sum) {
  if (sum == 0) return 1;
  //cout << sum << endl;
  REP(i, 13) {
    if (a[i] == 0)  continue;
    if ((sum - (i+1)) % (i+1) == 0) {
      v.push_back(i+1);
      a[i]--;
      if (dfs(sum-(i+1)))
        return 1;
      a[i]++;
      v.pop_back();
    }
  }
  return 0;
}

int main() {
  while(cin>>n,n) {
    memset(a,0,sizeof(a));
    int sum = 0;
    REP(i,n) {
      int b;cin>>b;
      a[b-1]++;
      sum += b;
    }
    v.clear();
    if (dfs(sum)) {
      reverse(ALL(v));
      REP(i, v.size()) {
        if (i) cout << " ";
        cout << v[i];
      }
      cout << endl;
    } else {
      cout << "No" << endl;
    }
  }
}

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


int main(){
        int n,k;
        cin >> n >> k;
        int a[n],sum[n+1];
        sum[0]=0;
        rep(i,n){
                cin >>a[i];
                sum[i+1]=sum[i]+a[i];
        }
        int max=0,temp=0;
        rep(i,n-k+1){
                int temp=sum[i+k]-sum[i];
                if(max < temp)max=temp;
        }
        cout <<fixed<<setprecision(6)<<(max+k)/2.0<<endl;
}

Measured memory_bytes: 1792
n=int(input())
a=list(map(int,input().split()))
ans=0
flg=True
while flg:
    for i in range(n):
        if a[i]%2!=1:
            a[i]=a[i]//2
        else:
            flg=False
            break
    if flg:
        ans+=1
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
    int mansion[4][3][10];//4mansions 3floors 10rooms

    for(int z = 0; z < 4; z++){
        for(int y = 0; y < 3; y++){
            for(int x = 0; x < 10; x++){
                mansion[z][y][x] = 0;
            }
        }
    }//初期化

    int informations;
    
    cin >> informations;

    int man[informations];
    int floor[informations];
    int room[informations];
    int people[informations];

    for(int i = 0; i < informations; i++){
        cin >> man[i]>> floor[i] >> room[i] >> people[i];
    }
    //標準入力完了

    for(int i = 0; i < informations; i++){
        mansion[man[i] - 1][floor[i] - 1][room[i] - 1] += people[i];

    }
    //情報を入力完了

    for(int z = 0; z < 4; z++){
        for(int y = 0; y < 3; y++){
            for(int x = 0; x < 10; x++){
                if (x != 9){
                printf(" %d", mansion[z][y][x]);
                }
                else{
                    printf(" %d\n", mansion[z][y][x]);
                }
            }
        }
        if(z < 3){
            printf("####################\n");
        }
    }
    //printf("%d\n", mansion[4])
    return 0;

}


Measured memory_bytes: 3224
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int x1 = sc.nextInt();
        int y1 = sc.nextInt();
        int x2 = sc.nextInt();
        int y2 = sc.nextInt();
        int x3=0, y3=0, x4=0, y4=0;
        
        System.out.print(x2-(y2-y1)+" ");
        System.out.print(y2+(x2-x1)+" ");
        System.out.print(x1-(y2-y1)+" ");
        System.out.println(y1+(x2-x1));      
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < b; i++)
using namespace std;

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

    vector<string> s(n);
    rep(i, 0, n) cin >> s[i];

    map<string, int> mp;
    rep(i, 0, n) {
        mp[s[i]]++;
    }

    int max_cnt = -1;
    for (auto e : mp) {
        max_cnt = max(max_cnt, e.second);
    }

    vector<string> ans;
    rep(i, 0, n) {
        if (mp[s[i]] == max_cnt) ans.push_back(s[i]);
    }

    sort(ans.begin(), ans.end());
    ans.erase(unique(ans.begin(), ans.end()), ans.end());

    for (auto e : ans) cout << e << endl;
    
    return 0;
}

Measured memory_bytes: 28656
from sys import exit, stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
B = [int(_) for _ in stdin.readline().rstrip().split()]
if (sum(A) < sum(B)):
    print(-1)
else:
    ans = 0
    diff = [a-b for a, b in zip(A,B)]
    plus = sorted([d for d in diff if d > 0])
    minus = [d for d in diff if d < 0]
    smms = sum(minus)
    while smms < 0:
        smms += plus.pop()
        ans += 1
    print(ans + len(minus))

Measured memory_bytes: 18292
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;

using namespace std;


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

  double ans = 0;
  FOR(i, 1, N+1){
    int cur = i;
    int cnt = 0;
    while(cur < K){
      cur *= 2;
      cnt++;
    }
    ans += pow(0.5, cnt)/N;
  }

  printf("%.15f\n", ans);

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

void dijkstra();

int num,a[100][100];

int main(){
  int i,j,u,k,v,c;

  scanf("%d",&num);

  for(i = 0; i< num; i++){
    for(j = 0; j < num; j++){
      a[i][j] = 1000000;
    }
  }

  for(i = 0; i< num; i++){
    scanf("%d %d",&u,&k);
    for(j = 0; j < k; j++){
      scanf("%d %d",&v,&c);
      a[u][v] = c;
    }
  }

  dijkstra();
  return 0;
}


void dijkstra(){

  int minv,i,u,v;
  int d[100],color[100];

  for(i = 0; i < num; i++){
    d[i] = 1000000;
    color[i] = 0;
  }

  d[0] = 0;
  color[0] = 1;

  while(1){
    minv = 1000000;
    u = -1;
    for(i = 0; i < num; i++){
      if(minv > d[i] && color[i] != 2){
	u  = i;
	minv = d[i];
      }
    }
    
    if(u == -1)break;
    color[u] = 2;

    for(v = 0; v < num; v++){
      if(color[v] != 2 && a[u][v] != 1000000){
	if(d[v] > d[u] + a[u][v]){
	  d[v] = d[u] + a[u][v];
	  color[v] = 1;
	}
      }
    }
  }

  for(i = 0; i < num; i++){
    printf("%d ",i);
    if(d[i] == 1000000)printf("-1");
    else printf("%d\n",d[i]);
  }
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
 
int n, a1[200004], a2[200004];
 
int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin>>n;
	for(int i = 0;i<n;i++){
		cin>>a1[i];
		a2[i] = a1[i];
	}
	sort(a2, a2+n);
	for(int i = 0;i<n;i++){
		int idx = lower_bound(a2, a2+n, a1[i]) - a2;
		if(idx == n - 1)	cout<<a2[n-2]<<'\n';
		else	cout<<a2[n-1]<<'\n';
	}
	return 0;
}

Measured memory_bytes: 3200
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

const long p = 1_000_000_000 + 7;

class UnionFindTree {
public:
    this(size_t n) {
        parent = iota(n).array();
        rank = new size_t[](n);
    }
    size_t find(size_t n) {
        if(n == parent[n]) {
            return n;
        } else {
            parent[n] = find(parent[n]);
            return parent[n];
        }
    }
    void unite(size_t n, size_t m) {
        auto p1 = find(n);
        auto p2 = find(m);
        if(n == m) {
            return;
        }
        if(rank[p1] < rank[p2]) {
            swap(p1, p2);
        }
        if(rank[p1] == rank[p2]) {
            ++rank[p1];
        }
        parent[p2] = p1;
    }
private:
    size_t[] parent;
    size_t[] rank;
}

unittest {
    auto uft = new UnionFindTree(10);
    foreach(i; iota(10)) {
        assert(uft.find(i) == i);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0).drop(1)) {
        uft.unite(i, i-3);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0)) {
        assert(uft.find(0) == uft.find(i));
    }
    foreach(i; iota(10).filter!(a => a%3 != 0)) {
        assert(uft.find(0) != uft.find(i));
    }
}

void main(){
    auto n = readLong();

    long[] x, y;
    foreach(i; iota(n)) {
        auto l = readLongs();
        x ~= l[0];
        y ~= l[1];
    }

    auto uft = new UnionFindTree(n);
    size_t[] idx = iota(n.to!size_t).array();
    sort(zip(x, y, idx));
    foreach(i; iota(n-1)) {
        if(x[i] == x[i+1]) {
            uft.unite(idx[i], idx[i+1]);
        }
    }
    sort(zip(y, x, idx));
    foreach(i; iota(n-1)) {
        if(y[i] == y[i+1]) {
            uft.unite(idx[i], idx[i+1]);
        }
    }

    size_t[][] s;
    foreach(i; iota(n-1)) {
        if(y[i] != y[i+1] && x[i] != x[i+1]) {
            s ~= [idx[i], idx[i+1]];
        }
    }
    sort(zip(x, y, idx));
    foreach(i; iota(n-1)) {
        if(y[i] != y[i+1] && x[i] != x[i+1]) {
            s ~= [idx[i], idx[i+1]];
        }
    }

    sort(zip(idx, x, y));
    size_t dist(size_t i, size_t j) {
        return min(abs(x[i] - x[j]), abs(y[i] - y[j]));
    }
    s.sort!((a, b) => dist(a[0], a[1]) < dist(b[0], b[1]))();

    long ans = 0;
    foreach(si; s) {
        auto idx1 = si[0];
        auto idx2 = si[1];
        if(uft.find(idx1) != uft.find(idx2)) {
            uft.unite(idx1, idx2);
            ans += dist(idx1, idx2);
        }
    }
    writeln(ans);
}



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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 3010, M = 1010;

int n, m;
int w[N], v[N];
int f1[N][N], f2[N][N];

int main()
{
	cin >> n >> m;
	for (int i = 1; i <= n; i ++ ) cin >> v[i] >> w[i];
	
	for (int i = 1; i <= n; i ++ )
		for (int j = 0; j < m; j ++ )
		{
			f1[i][j] = f1[i - 1][j];
			if (j >= v[i]) f1[i][j] = max(f1[i][j], f1[i - 1][j - v[i]] + w[i]);
		}
	
	for (int i = n; i >= 1; i -- )
		for (int j = 0; j < m; j ++ )
		{
			f2[i][j] = f2[i + 1][j];
			if (j >= v[i]) f2[i][j] = max(f2[i][j], f2[i + 1][j - v[i]] + w[i]);
		}
	
	int res = 0;
	for (int i = 1; i <= n; i ++ )
		for (int j = 0; j < m; j ++ )
			res = max(res, f1[i - 1][j] + f2[i + 1][m - 1 - j] + w[i]);
			
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 70912
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説通りに作成したソースコード
 */
public class Main {

	/** 文字列ABC */
	private static final char[] ABC = new char[] { 'A', 'B', 'C' };
	/** 文字? */
	private static final char ALL = '?';
	/** 1_000_000_007 */
	private static final long MOD = 1_000_000_007L;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			char[] s = scanner.next().toCharArray();
			int n = s.length;
			long[][] dp = new long[n + 1][4];
			dp[n][3] = 1L;
			dp[n][0] = dp[n][1] = dp[n][2] = 0L;
			IntStream.rangeClosed(1, n).map(i -> n - i).forEach(i -> {
				dp[i][3] = ((ALL == s[i]) ? 3 : 1) * dp[i + 1][3] % MOD;
				IntStream.range(0, 3).forEach(j -> dp[i][j] = (((ALL == s[i]) ? 3 : 1) * dp[i + 1][j] % MOD
						+ (((ALL == s[i]) || (ABC[j] == s[i])) ? 1 : 0) * dp[i + 1][j + 1] % MOD) % MOD);
			});
			System.out.println(dp[0][0]);
		}
	}
}


Measured memory_bytes: 60832
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
using namespace std;
int main(){
    long long k,n,ans=1000000000;
    cin>>n>>k;
    long long h[n];
    f(i,0,n){
        cin>>h[i];
    }
    sort(h,h+n);
    f(i,0,n-k+1){
        ans=min(h[i+k-1]-h[i],ans);
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    if(s.substr(0, n / 2) == s.substr(n / 2, n)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" <<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''

def main():
    X = int(input())

    i = X // 100
    j = X - (i * 100)
    if j > 5 * i:
        print(0)
    else:
        print(1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 2940