akhauriyash/Code-Regression huggingface dataset:
from collections import deque

h,w = map(int, input().split())
adj = deque(maxlen=h*w)
maze = [list(input()) for _ in range(h)]
# maze = [[0]*w for _ in range(h)]
inf = 999999
dist = [[inf]*w for _ in range(h)]
max = h*w
for l in maze:
    max -= l.count('#')
# print(max)


def bfs(i,j):
    if maze[i][j]=='#' or (i,j) == (w-1,j-1):
        return
    maze[i][j]='#'
    d=dist[i][j] + 1
    if i+1<h:
        if maze[i+1][j]!='#' and dist[i+1][j]>d:
            adj.append([i+1,j])
            dist[i+1][j] = d
    if j+1<w:
        if maze[i][j+1]!='#' and dist[i][j+1]>d:
            adj.append([i,j+1])
            dist[i][j+1] = d
    if i-1>=0:
        if maze[i-1][j]!='#' and dist[i-1][j]>d:
            adj.append([i-1,j])
            dist[i-1][j] = d
    if j-1>=0:
        if maze[i][j-1]!='#' and dist[i][j-1]>d:
            adj.append([i,j-1])
            dist[i][j-1] = d

def print_maze(lst):
    for l in lst:
        print(l)
    print('\n')

adj.append([0,0])
dist[0][0]=1
time=0
while len(adj)>0:
    p = adj.popleft()
    bfs(p[0],p[1])
if dist[h-1][w-1] == inf:
    print(-1)
else:
    print(max - dist[h-1][w-1])


Measured memory_bytes: 3316
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

constexpr int MOD = 1000000007;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> PLL;

// does `b` exist such that:
// f(b, n) = s
// 1 <= n, s <= 10^11

int main() {
    LL N, S;
    cin >> N >> S;

    if (N == S) {
        cout << N+1 << endl;
        return 0;
    }

    for (LL j = 2; j <= sqrt(N); ++j) {
        LL digsum = 0;
        for (LL t = N; t > 0; t /= j) {
            digsum += t % j;
        }
        if (digsum == S) {
            cout << j << endl;
            return 0;
        }
    }

    LL ans = -1;

    for (LL j = 1; j <= sqrt(N); ++j) {
        LL q = S - j;
        if ((N-q) % j == 0) {
            LL b = (N-q) / j;
            if (b == 0) { continue; }
            LL digsum = 0;
            for (LL t = N; t > 0; t /= b) {
                digsum += t % b;
            }
            if (digsum == S) {
                ans = b;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#define int long long

using namespace std;

signed main(){
    int n;
    cin>>n;
    int sum = 0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int k=1;k<=n;k++){
                sum += __gcd(__gcd(i,j),k);
            }
        }
    }
    cout<<sum;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
const int lmt=1e5+10;
int n,m;
vector<int>adj[lmt];
vector<int>ans(lmt);
bool vis[lmt];
int dp(int now)
{
    if(vis[now]) return ans[now];
    vis[now]=1;
    int res=0;
    for(int i=0;i<adj[now].size();i++)
    {
        int v=adj[now][i];
        res=max(res,dp(v));
    }
    return ans[now]=res+1;
}
int main()
{
    //freopen("take.in","r",stdin);
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        int u,v;
        cin>>u>>v;
        adj[u].push_back(v);
    }
    memset(vis,0,sizeof vis);
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            ans[i]=max(ans[i],dp(i));
        }
    }
    int res=0;
    for(int i=1;i<=n;i++) res=max(res,ans[i]-1);
    cout<<res<<endl;
}

Measured memory_bytes: 8192
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B2SnukesColoring2ABCEdit solver = new B2SnukesColoring2ABCEdit();
        solver.solve(1, in, out);
        out.close();
    }

    static class B2SnukesColoring2ABCEdit {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            int w = in.ints(), h = in.ints(), n = in.ints();
            int xmax = w, xmin = 0, ymax = h, ymin = 0;
            for (int i = 0; i < n; i++) {
                int x = in.ints(), y = in.ints(), a = in.ints();
                switch (a) {
                    case 1:
                        xmin = Math.max(x, xmin);
                        break;
                    case 2:
                        xmax = Math.min(x, xmax);
                        break;
                    case 3:
                        ymin = Math.max(y, ymin);
                        break;
                    case 4:
                        ymax = Math.min(y, ymax);
                        break;
                }
            }
            if (xmax <= xmin || ymax <= ymin) {
                out.println(0);
            } else {
                out.println((xmax - xmin) * (ymax - ymin));
            }
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

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

        public int ints() {
            return Integer.parseInt(string());
        }

    }
}



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

int main()
{
 int a,b,c,x;
  int ans=0;
  cin>>a>>b>>c>>x;
  for(int i=0;i<=a;i++)
    for(int j=0;j<=b;j++)
      for(int k=0;k<=c;k++)
        if(i*500+j*100+k*50==x)
          ans++;
  cout<<ans<<"\n";
  
  
  
  return 0;
}

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

int main()
{
    int A, B;
    cin >> A >> B;
    int sum;

    for(int i = 0; i < 2; i++){
        if(A >= B) sum += A--;
        else sum += B--;
    }
    cout << sum << endl;

    return 0;
}

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


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
typedef long long ll;
const int mod = 1e9+7;

int main(){
  int n, m;
  cin >> n >> m;
  int s[n];
  int t[m];
  rep(i, n) cin >> s[i];
  rep(i, m) cin >> t[i];
  vector<vector<int>> dp(n+1, vector<int>(m+1, 0));
  rep(i,n){
    rep(j,m){
      if(s[i] == t[j]) dp[i+1][j+1] = (dp[i+1][j] + dp[i][j+1] + 1) % mod;
      else dp[i+1][j+1] = (dp[i+1][j] + dp[i][j+1] - dp[i][j]) % mod;
    }
  }
  int ans = ((dp[n][m] + 1) % mod  + mod) % mod;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 16000
#!/usr/bin/env python3
s = str(input())
for i in range(len(s)//2):
    if s[i] != s[len(s)-1-i]:
        print("No")
        exit()
for i in range((len(s)-1)//2):
    if s[i] != s[(len(s)-1)//2-1-i]:
        print("No")
        exit()
    if s[i + (len(s)+1)//2] != s[len(s)-1-i]:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 3064
/* ***********************************************
Author        :taciturnity
Created Time  :2020/2/21 8:23:51
File Name     :TEST.cpp
************************************************ */

#include <iostream>
#include <vector>
#include <queue>
#include <cstdio>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define ll long long
#define INF 0x3f3f3f3f
#define bug puts("--------------")
const int N = 1e5 + 10;
const ll mod = 1e9 + 7 ;
using namespace std;
ll mulit(ll a,ll b,ll m)
{
    ll ans=0;
    while(b)
    {
        if(b&1)
            ans=(ans+a)%m;
        a=(a<<1)%m;
        b>>=1;
    }
    return ans;
}
ll quick_mod(ll a,ll b,ll m)
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=mulit(ans,a,m);
        a=mulit(a,a,m);
        b>>=1;
    }
    return ans;
}
ll comp(ll a,ll b,ll m)
{
    if(a<b)
        return 0;
    if(a==b)
        return 1;
    if(b>a-b)
        b=a-b;
    ll ans=1,ca=1,cb=1;
    for(int i=0; i<b; i++)
    {
        ca=ca*(a-i)%m;
        cb=cb*(b-i)%m;
    }
    ans=ca*quick_mod(cb,m-2,m)%m;
    return ans;
}
ll lucas(ll a,ll b,ll m)
{
    ll ans=1;
    while(a&&b)
    {
        ans=(ans*comp(a%m,b%m,m))%m;
        a/=m;
        b/=m;
    }
    return ans;
}
int main()
{
    ll n,a,b;
    cin >> n >> a >> b;
    cout <<((quick_mod(2,n,mod) - lucas(n,a,mod)-lucas(n,b,mod))%mod - 1+mod)%mod;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

vector<vector<int>> edges;
vector<int> shirube;

void bfs() {
    // {cur, prev}
    queue<pair<int, int>> q;
    q.push({0, 0});

    while (!q.empty()) {
        pair<int, int> ent = q.front();
        const int cur = ent.first;
        const int prev = ent.second;
        q.pop();
        for (auto &nv : edges[cur]) {
            if (shirube[nv] < 0) {
                shirube[nv] = prev;
                q.push({nv, nv});
            }
        }
    }
}

int main(void) {
    int N, M;
    cin >> N >> M;

    edges.resize(N);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    shirube.resize(N, -1);
    shirube[0] = 0;

    bfs();

    cout << "Yes" << endl;
    for (int i = 1; i < N; i++) {
        cout << shirube[i] + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 10552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define F first
#define S second
#define PB push_back
using namespace std;
int n,cn[35],m,ans;
int main(void){
    cin>>n>>m;
    for(int i=0;i<n;i++){
        int k;
        cin>>k;
        for(int j=0;j<k;j++){
            int a;
            cin>>a;
            cn[a]++;
        }
    }
    for(int i=1;i<=m;i++)if(cn[i]==n)ans++;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int maxn=2e5+7;
vi G[maxn];
int fa[maxn];
int sz[maxn];
int Find(int x)
{
	return x==fa[x]?x:fa[x]=Find(fa[x]);
}
void Union(int x,int y)
{
	x=Find(x),y=Find(y);
	if(y!=x)
	{
		fa[y]=x;
		sz[x]+=sz[y];
	}
}
int main()
{
	for(int i=0;i<maxn;i++) sz[i]=1,fa[i]=i;
	int n;
	cin>>n;
	vi a(n),b(n);
	vi all;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		all.push_back(a[i]);
	}
	for(int i=0;i<n;i++)
	{
		cin>>b[i];
		all.push_back(b[i]);
	}
	int x=0;
	for(int i=0;i<n;i++) x^=a[i];
	all.push_back(x);
	sort(all.begin(),all.end());
	all.erase(unique(all.begin(),all.end()),all.end());
	auto getid=[&](int x){
		return lower_bound(all.begin(),all.end(),x)-all.begin();
	};
	map<int,int> cnt;
	for(auto u:b) cnt[u]++;
	int dif=0;
	for(auto u:a)
		cnt[u]--;
	cnt[x]--;
	for(auto u:cnt)
		dif+=abs(u.second);
	if(dif>1){
		cout<<-1<<'\n';
		return 0;
	}
	int tar=-1;
	for(auto u:cnt) if(u.second) tar=u.first;
	for(auto &u:a) u=getid(u);
	for(auto &u:b) u=getid(u);
	Union(getid(tar),getid(x));
	int ans=0;
	for(int i=0;i<n;i++)
	{
		if(a[i]!=b[i]) ans++;
		Union(a[i],b[i]);
	}
	for(int i=0;i<maxn;i++)
	{
		if(Find(i)==i&&sz[Find(i)]!=1)
			ans++;
	}
	if(sz[Find(getid(x))]!=1) ans--;
	cout<<ans<<'\n';
}


Measured memory_bytes: 15728
#include <map>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <sstream>
#include <vector>
using namespace std;

int main()
{
	int a[10];
	for (int i = 0; i < 6; i++)
	{
		cin >> a[i];
	}
	int c[10] = {};
	int tmp = 0;
	for (int i = 0; i < 6; i++)
	{
		c[a[i]]++;
		if (c[a[i]] == 2) tmp++;
	}

	if (tmp == 2)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    string a, b, c;
    cin >> a;
    cin >> b;
    cin >> c;
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(a[i] != b[i]){
            ans++;
        }
        if(b[i] != c[i]){
            ans++;
            if(a[i] == c[i]){
                ans--;
            }
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main()
{int N; cin >> N; vector<char> S(N);
 for(int i = 0; i < N; i++){
   cin >> S[i];}
 vector<int> W(N); vector<int> E(N);
  if(S[0] != 'W'){ W[0] = 0;} else{ W[0] = 1;}
  if(S[N-1] != 'E'){ E[N-1] = 0;} else{E[N-1] = 1;}
  
 for(int k = 1; k < N ; k++){
   if(S[k] == 'W'){ W[k] = W[k - 1] + 1;}
    else{ W [k] = W[k-1];}}//W[i]は０〜iまでのWの個数
 
 for(int l = N-2;l >= 0; l--){
   if(S[l] == 'E'){ E[l] = E[l + 1] + 1;}
 else{ E[l] = E[l + 1];}}//N-1 ~ iまでのEの個数
 
 int min_cnt = 1e9;
 
 if( N >= 3){
 for(int i = 1; i <= N - 2; i++)
 { min_cnt = min(min_cnt, W[i-1] + E[i+1]);}}
 else{ min_cnt = min(E[1],W[0]);}
                 
cout << min(min_cnt,min(E[1],W[N-2])) << endl;
                 
             return 0;
                 }


Measured memory_bytes: 2944
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp14
{
    class Class36
    {
        static void Main()
        {
            int X = int.Parse(Console.ReadLine());
            bool[] DP = new bool[X + 106];
            for (int i = 1; i <= X; i++) DP[i] = false;
            DP[0] = true;

            for(int i = 0; i < X; i++)
            {
                if (DP[i])
                {
                    DP[i + 100] = true;
                    DP[i + 101] = true;
                    DP[i + 102] = true;
                    DP[i + 103] = true;
                    DP[i + 104] = true;
                    DP[i + 105] = true;
                }
            }
            Console.WriteLine(DP[X] ? "1" : "0");
        }
    }
}


Measured memory_bytes: 11112
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

int main() {
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  ll cnt = 0LL;
  while(a>=b) {
    b *= 2LL;
    cnt++;
  }
  while(b>=c) {
    c *= 2LL;
    cnt++;
  }
  if(cnt<=k) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3632
x1, y1, x2, y2 = map(int, input().split())

x3 = x2 + y1 - y2
y3 = y2 + x2 - x1
x4 = x1 + y1 - y2
y4 = y1 + x2 - x1

print(' '.join(map(str, [x3, y3, x4, y4])))

Measured memory_bytes: 2940
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

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

    if(s[0] == s[1]) {
        cout<<"Bad"<<endl;
    } else if(s[1] == s[2]) {
        cout<<"Bad"<<endl;
    } else if(s[2] == s[3]) {
        cout<<"Bad"<<endl;
    } else {
        cout<<"Good"<<endl;
    }

    return  0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<endl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<a.size();zz++) cerr<<a[zz]<<" ";cerr<<endl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<"\n"
#define mod 1000000007ll
#define inf 9999999999999999ll
#define nl endl
#define sz(x) (ll)(x).size()
#define all(x) x.begin(), x.end()
#define modulo 998244353ll

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,num,d;
    cin>>n>>num>>d;
    d++;
    string s;
    cin>>s;
    vi a;
    for(ll i=0;i<n;i++)
        if(s[i]!='x')
            a.pb(i);
    n=sz(a);
    vb s1(n,false);
    s1[0]=true;
    ll index=0;
    while(index<n)
    {
        ll low=index+1;
        while(low<n  && a[low]-a[index]<d)
            low++;
        if(low<n)
            s1[low]=true;
        index=low;
    }
    ll count=0;
    for(ll i=0;i<n;i++)
    {
        if(s1[i])
            count++;
    }
    if(count>num)
    {
        cout<<nl;
        return 0;
    }
    vb s2(n,false);
    s2[n-1]=true;
    index=n-1;
    while(index>=0)
    {
        ll low=index-1;
        while(low>=0 && a[index]-a[low]<d)
        {
            low--;
        }
        if(low>=0)
            s2[low]=true;
        index=low;
    }
    count=0;
    for(ll i=0;i<n;i++)
    {
        if(s2[i])
            count++;
    }
    if(count>num)
    {
        cout<<nl;
        return 0;
    }
    for(ll i=0;i<n;i++)
    {
        if(s1[i]&& s2[i])
        {
            cout<<a[i]+1<<nl;
        }
    }
}


Measured memory_bytes: 3464
#include <bits/stdc++.h>
 
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define li long long
#define itn int
 
using namespace std;
 
inline int nxt(){
	int n;
	scanf("%d", &n);
	return n;
}

template <typename T>
ostream& operator <<(ostream& ostr, const vector<T>& a) {
	ostr << "(";
	for (size_t i = 0; i < a.size(); ++i) {
		if (i) {
			ostr << ", ";
		}
		ostr << a[i];
	}
	ostr << ")";
	return ostr;
}

const int mod = 1000000007;

long long pw(long long a, long long b) {
	long long res = 1;
	while (b) {
		if (b & 1ll) {
			res = res * a % mod;
		}
		b >>= 1;
		a = a * a % mod;
	}
	return res;
}

int main() {
	string s;
	cin >> s;
	int ans = s.length();
	for (char c : s) {
		int tmp = 0, cur = 0;
		for (char d : s) {
			if (d == c) {
				cur = 0;
			} else {
				cur += 1;
			}
			tmp = max(tmp, cur);
		}
		ans = min(ans, tmp);
	}

	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 764
import Data.List.Split
main :: IO ()
main = do
    l1 <- getLinel :: IO [Int]
    l2 <- getLinel :: IO [Int]
    l3 <- getLinel :: IO [Int]
    if solve l1 l2 l3
        then putStrLn "Yes"
        else putStrLn "No"
    where
        getLinel :: Read a => IO [a]
        getLinel = getLine >>= return . map read . splitOn " "
        listdiff :: [Int] -> [Int] -> [Int]
        listdiff [] _ = []
        listdiff _ [] = []
        listdiff (x:xs) (y:ys) = (x-y):listdiff xs ys
        isSameElem :: [Int] -> Bool
        isSameElem [] = False
        isSameElem (x:xs) = foldr (\a b -> (a == x) && b) True xs
        solve :: [Int] -> [Int] -> [Int] -> Bool
        solve l1 l2 l3 = (isSameElem $ listdiff l1 l2) && (isSameElem $ listdiff l1 l3)

Measured memory_bytes: 508
/* be name khoda */

#define long_enable
#include <iostream>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <vector>
#include <fstream>
#include <set>
#include <map>
using namespace std;

#ifdef long_enable
typedef long long int ll;
#else
typedef int ll;
#endif

typedef pair<ll, ll> pii;
typedef pair<pii, ll> ppi;
typedef pair<ll, pii> pip;
typedef vector<ll> vi;
typedef vector<pii> vpii;

#define forifrom(i, s, n) for (ll i = s; i < n; ++i)
#define forirto(i, n, e) for (ll i = (n) - 1; i >= e; --i)
#define fori(i, n) forifrom (i, 0, n)
#define forir(i, n) forirto (i, n, 0)

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define smin(a, b) a = min(a, (b))
#define smax(a, b) a = max(a, (b))

#define debug(x) cout << #x << " -> " << (x) << endl
#define debug2(x, y) cout << #x << ' ' << #y << " -> " << (x) << ' ' << (y) << endl
#define debug3(x, y, z) cout << #x << ' ' << #y << ' ' << #z << " -> " << (x) << ' ' << (y) << ' ' << (z) << endl
#define debug4(x, y, z, t) cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> " << (x) << ' ' << (y) << ' ' << (z) << ' ' << (t) << endl
#define debuga(x, n) cout << #x << " -> "; fori (i1_da, n) { cout << (x)[i1_da] << ' '; } cout << endl
#define debugaa(x, n, m) cout << #x << " ->\n"; fori (i1_daa, n) { fori (i2_daa, m) { cout << (x)[i1_daa][i2_daa] << ' '; } cout << '\n'; } cout << endl

const ll MOD = 1000000007;
const ll INF = 2000000000;
const long long BIG = 1446803456761533460LL;

#define XL (x << 1)
#define XR (XL | 1)
#define MD ((l + r) >> 1)
#define Add(a, b) a = ((a) + (b)) % MOD
#define Mul(a, b) a = (1LL * (a) * (b)) % MOD

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

const ll maxn = 100010;

ll n, m, q;
ll rt[maxn], en;
pii es[maxn];

ll root(ll x) {
    return rt[x] == x ? x : rt[x] = root(rt[x]);
}

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

    cin >> n >> m >> q;
    iota(rt, rt + n, 0);
    fori (i, q) {
        ll a, b, c; cin >> a >> b >> c;
        if (c == 1) es[en++] = {a, b};
        else {
            a = root(a);
            b = root(b);
            if (a != b) rt[a] = b;
        }
    }
    fori (i, en) {
        if (root(es[i].F) == root(es[i].S)) return cout << "No\n", 0;
    }
    if (m == n - 1 && en > 0) return cout << "No\n", 0;
    ll c = 0;
    fori (i, n) {
        c += root(i) == i;
    }
    if (m > c * (c - 1) / 2 + n - c) return cout << "No\n", 0;
    cout << "Yes\n";

}


Measured memory_bytes: 5828
#include "bits/stdc++.h"
#define int long long
#define range(i, a, b) for(auto i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const long double EPS = 1e-8;
using vi = vector <int>;
using vvi = vector <vi>;

signed main() {
	int a, b, c, x;
	cin >> a >> b >> c >> x;
	a++, b++, c++;
	int ans = 0;
	rep (i, a) {
		rep (j, b) {
			rep (k, c) {
				if (500 * i + 100 * j + 50 * k == x) {
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const double PI=3.14159265358979323846;
  
int main(){
  double a, b, h, m; cin >> a >> b >> h >> m;
  double p1 = (double)(60 * h + m) * 2 * PI / 720;
  double p2 = (double)m * 2 * PI / 60;
  double ans = (double)a * a + b * b - 2 * a * b * cos(p1 - p2);
  cout << fixed << setprecision(15) << sqrt(ans) << endl;
}

Measured memory_bytes: 4228
#include<cstdio>
#include<queue>
#include<iostream>
#include<algorithm>
#include<list>
#include<vector>
using namespace std;
int a[2000];
int main() {
	int t;
	scanf("%d", &t);
	for (int i = 0; i <t; i++)
	{
		scanf("%d", &a[i]);
	}
	int n;
	scanf("%d", &n);
	while (n--)
	{
		int i, j, k;
		scanf("%d%d%d", &i, &j, &k);
		int ans=0;
		for (int p = i; p < j; p++)
		{
			if (a[p] == k)ans++;
		}
		cout << ans << endl;
	}
}




Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10, mod = 1e9 + 7;
using ll = long long ;

int add (int a, int b) {
    return ((a += b) >= mod) ? a -= mod : a;
}

int sub (int a, int b) {
    return ((a -= b) < 0) ? a + mod : a;
}

int mul (int a, int b) {
    return 1LL * a * b % mod;
}

int ans;

int n, p[nax];
ll a[nax], b[nax];

map <pair <ll, ll> , int> mp ;
map <pair <ll, ll>, bool> vis;

pair <ll , ll > norm (ll x, ll y) {
    ll g = abs(__gcd(x, y));
    x /= g, y /= g;

    if (x < 0) {
        x = -x;
        y = -y;
    }

    return make_pair(x, y);

}

pair <ll, ll>  get_slope (ll x, ll y) {

    ll g = abs(__gcd(x, y));
    x /= g, y /= g;

    if (y < 0) {
        x = -x;
        y = -y;
    }

    return make_pair(y, x);
}

int sig (ll x) {
    if (x > 0) return 1;
    else if (x == 0) return 0;
    else if (x < 0) return -1;
    else throw;
}

map < pair <ll, ll>, int> good;
map < pair <ll, ll>, int> bad;

int main () {
    scanf("%d", &n);

    p[0] = 1;

    for (int i = 1 ; i < nax ; ++ i) {
        p[i] = add(p[i - 1], p[i - 1]);
    }

    int ct = 0;

    for (int i = 1 ; i <= n ; ++ i) {
        scanf("%lld %lld", a + i, b + i);

        if (a[i] == 0 && b[i] == 0) ++ ct;
        else {

            if (sig(a[i]) * sig(b[i]) >= 0 && b[i] != 0) {
                auto res = get_slope(a[i], b[i]);
                res.first = abs(res.first);
                res.second = abs(res.second);
                good[res] ++;
            } else {
                auto res = get_slope(a[i], b[i]);
                res.first = -abs(res.first);
                res.second = abs(res.second);
                bad[res] ++;
            }
        }
    }

    int s = 1;

    for (auto q : good) {
        auto res = q.first;
        swap(res.first, res.second);
        res.first = -res.first;


        vis[res] = true;


        int f = add(p[q.second], p[bad[res]]);
        f = sub(f, 1);
        s = mul(s, f);
    }

    for (auto q : bad) {

        if (vis[q.first]) continue;

        int f = p[q.second];
        s = mul(s, f);

    }

    printf("%d\n", add(ct, sub(s, 1)));
}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 39180
#include <stdio.h>
int main( void ){
	int n,a,s,m;
	for(;scanf("%d",&n),n;printf("%d\n",m))
		for(s=0,m=-10000000;n--;){
			scanf("%d",&a);
			s += a;
			if( s > m ) m = s;
			if( s < 0 ) s = 0;
		}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main(int argc,char* argv[]){
  int i;
  double right,left;
  int eyes[4][2] = {0};
  
  while(scanf("%lf %lf",&right,&left) != EOF){
    if(right >= 1.1){
      eyes[0][0]++;
    }else if(right >= 0.6){
      eyes[1][0]++;
    }else if(right >= 0.2){
      eyes[2][0]++;
    }else{
      eyes[3][0]++;
    }

    if(left >= 1.1){
      eyes[0][1]++;
    }else if(left >= 0.6){
      eyes[1][1]++;
    }else if(left >= 0.2){
      eyes[2][1]++;
    }else{
      eyes[3][1]++;
    }
  }

  for(i = 0; i < 4; i++){
    printf("%d %d\n",eyes[i][0],eyes[i][1]);
  }
  
  return 0;
  
}

Measured memory_bytes: 0
from collections import Counter

N = int(input())
S = [list(input()) for _ in range(N)]

cnt = Counter(S[0])
for s in S[1:]:
    for t, c in cnt.items():
        cnt[t] = min(c, s.count(t))

ans = []
for s, c in cnt.items():
    ans += [s] * c

ans.sort()
print(''.join(ans))

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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int N;
    string s, t;
    cin >> N;
    cin >> s >> t;
    REP(i, N) {
        cout << s[i] << t[i];
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.*;
import java.util.ArrayDeque;
import java.util.Queue;
import java.math.RoundingMode;
import java.math.BigDecimal;


public class Main{
	 public static void main(String[] args){
	   Scanner sc = new Scanner(System.in);
	   int n = sc.nextInt();
	   long m = sc.nextLong();
	   PriorityQueue<Long> pq = new PriorityQueue<>(Collections.reverseOrder());
	   for(int i = 0; i < n; i++) {
		   long a = sc.nextLong();
		   pq.add(a);
	   }
	   for(int i=0; i<m; i++){
			Long a = pq.poll();
			a = a/2;
			pq.add(a);
		}
	   long ans = 0;
		while(pq.size() > 0){
			ans += pq.poll();
		}
		System.out.println(ans);
	  }
	}

Measured memory_bytes: 53248
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
ll a, b, c, i, j, k, n, m, t, arr[200005], ar[200005];
int main() {
    string s;
    cin >> n;
    a = (n / 500) * 1000;
    n %= 500;
    a += (n / 5) * 5;
    cout << a;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 20) + 1;
	
	char buf[L], *S , *T, c;
	 
	char getchar() {
		if(S == T) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}
	
	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	char B[25], *outs=B+20, *outr=B+20;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;
		
		if(!a)*--outs = '0';
		else 
			while(a)
				*--outs = (a % 10) + 48, a /= 10;
		
		if(x)
			*--outs = x;
		
		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inp_ll;

const int MAXN = 100010;
const int INF = 1000000000;
const int MOD = 1000000007;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

int main()
{
	
	string s, t;
	cin >> s >> t;
	for (int i = 0; i < s.size(); ++ i)
	{
		if (s.substr(i)+s.substr(0, i) == t)
		{
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <functional>
#include <sstream>
#include <complex>
#include <climits>
using namespace std;

#define REP(i,a,n) for(int i=(a);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define EPS 1e-8

int dp[2][1000000];
int data[200];

void init(){
	for(int i=1; i<200; i++)data[i-1]=i*(i+1)*(i+2)/6;
	dp[0][0]=dp[1][0]=0;
	REP(i,1,1000000){
		dp[0][i] = dp[1][i] = i;
		for(int j=0; j<199 && i-data[j]>=0; j++){
			dp[0][i] = min(dp[0][i], dp[0][i-data[j]]+1);
			if( data[j]%2 ){
				dp[1][i] = min(dp[1][i], dp[1][i-data[j]]+1);
			}
		}
	}
}

int main(){
	int n;
	init();
	while(scanf("%d",&n),n){
		printf("%d %d\n",dp[0][n],dp[1][n]);
	}
	return 0;
}

Measured memory_bytes: 8528
#include<iostream>
#include<vector>
#include<set>
#include<string>
#include<map>
#include<cmath>
#define P pair<int ,int>
#define N 10
using namespace std;

bool n_zero[N], f[N];
int coe[N], cnt, c;

void dfs(int n, int s) {
	if (n == cnt) {
		if (!s) c++;
		return;
	}
	
	for (int i = 0; i < N; i++) {
		if (f[i] || (!i && n_zero[n])) continue;
		
		f[i] = 1;
		dfs(n + 1, s + i * coe[n]); 
		f[i] = 0;
	}
	
}

int main()
{	
	int n;
	
	while (cin >> n, n) {
		vector<string> str(n);
		map<char, int> index;
		cnt = c = 0;
		
		for (int i = 0; i < N; i++)
			n_zero[i] = coe[i] = f[i] = 0;
		
		for (int i = 0; i < n; i++) {
			cin >> str[i];
			
			for (int j = 0; j < str[i].size(); j++) {
				if (index.find(str[i][j]) == index.end()) {
					index[str[i][j]] = cnt;
					cnt++;
				}
				
				if ( str[i].size() > 1 && !j) n_zero[index[str[i][j]]] = 1;
				
				if (i != n - 1)
					coe[index[str[i][j]]] += (int)pow(10.0, (int)str[i].size() - 1 - j);
				else
					coe[index[str[i][j]]] -= (int)pow(10.0, (int)str[i].size() - 1 - j);
			}
		}
		
		dfs(0, 0);
		
		cout << c << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1216
import java.io.*;
import java.util.*;

public class Main {

	void submit() {
		char[] s = nextToken().toCharArray();
		int n = s.length;
		
		int[] mask = new int[n + 1];
		for (int i = 0; i < s.length; i++) {
			int ch = s[i] - 'a';
			mask[i + 1] = mask[i] ^ (1 << ch);
		}
		
		if (mask[n] == 0) {
			out.println(1);
			return;
		}
		
		int[] dp = new int[1 << 26];
		Arrays.fill(dp, Integer.MAX_VALUE);
		dp[0] = 0;
		
		for (int x : mask) {
			int dist = dp[x];
			for (int i = 0; i < 26; i++) {
				int y = x ^ (1 << i);
				dp[y] = Math.min(dp[y], dist + 1);
			}
		}
		
		out.println(dp[mask[n]]);
	}

	void preCalc() {

	}

	void stress() {

	}

	void test() {

	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		//stress();
		//test();
		out.close();
	}

	static final Random rng = new Random();

	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;

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

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	long nextLong() {
		return Long.parseLong(nextToken());
	}

	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}


Measured memory_bytes: 292692
n = int(input())
switch_list = [ int(input())-1 for i in range(n)]
move_list = [0] + [None for  i in range(n-1)]
for i in range(n-1):
    move_list[i+1] = switch_list[move_list[i]]


if move_list.count(1) == 0:
    ans = -1
else:
    ans = move_list.index(1)
print(ans)

Measured memory_bytes: 8620
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int N, button, ans;
  vector<int> a;
  vector<bool> visited;

  cin >> N;
  a.resize(N);
  visited.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    a[i]--;
    visited[i] = false;
  }

  ans = 0;
  button = 0;
  while (!visited[button]) {
    visited[button] = true;
    button = a[button];
    ans++;
    if (button == 1) break;
  }

  if (button == 1) {
    cout << ans << endl;
  } else {
    cout << -1 << endl;
  }

  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>

#define rep(i,p) for(long long int i=0;i<p;i++)
#define reep(i,p) for(long long int i=1;i<=p;i++)
#define ll long long

using namespace std;

int main(){

 ll int N;
 ll int maxim = 0;
  	cin >> N;
 vector<ll int > A(N);
 rep(i,N){
	 cin >> A[i];
	if( maxim <A[i]){
		maxim = A[i];
	}
	else{}
 }
 ll int Q;
 cin >> Q;
 vector<ll int > B(Q);
 vector<ll int > C(Q);
rep(i,Q){
	cin >> B[i] >> C[i];
	if( maxim <C[i]){
		maxim = C[i];
	}
	else{}
}
map<ll int,ll int> counter;
 rep(i,N){

	counter[A[i]] += 1;
 }

for( long long int j=1;j<=maxim;j++){
	if(counter[j]<1){
		counter[j]=0;
	}
	else{}
}


/*
for( long long int j=1;j<=4;j++){
	cout << j << " " <<  counter[j]<< endl;
}
        cout << endl;
*/

ll int ans=0;
	for( long long int j=1;j<=maxim;j++){
	//	cout << j << " " <<  counter[j]*j<< endl;
		ans += counter[j]*j;
	}
ll int tasu,hiku;
for( long long int i=0;i<Q;i++){
	ans = ans +  counter[B[i]]*C[i] - counter[B[i]]*B[i];
	counter[C[i]] += counter[B[i]];
	counter[B[i]] = 0;
//	cout << 2 << " " <<  counter[2]1<< endl;


cout << ans << endl;
}









	return 0;

}



Measured memory_bytes: 11888
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
#define endl '\n'
#define pi pair<int, int>

const int m = 1000001;
int lcp[m];
vector<int> primes;
 
void pgen(){
	for(int i = 2; i < m; i++){
		if(!lcp[i]){
			lcp[i] = i;
			primes.push_back(i);
		}
		for(int j = 0; j < primes.size() && primes[j] <= lcp[i] && i * primes[j] < m; j++){
			lcp[i * primes[j]] = primes[j];
		}
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	pgen();
	
	int n;
	cin >> n;
	
	while(lcp[n] != n) n++;
	
	cout << n << endl;

	return 0;
}

Measured memory_bytes: 4860
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
before = 55555
for a in A:
    ans += B[a-1]
    if before == a-1:
        ans += C[before-1]
    before = a
print(ans)

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

int main() {
  int n, k;
  cin >> n >> k;
  double ans = 0;
  for (int i = 1; i <= n; ++i) {
    double tmp = 1.0 / n;
    int now = i;
    while (now < k) {
      now *= 2;
      tmp /= 2.0;
    }
    ans += tmp;
  }
  cout << fixed << setprecision(12) << ans << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <complex>
#include <bitset>
#define full(c) c.begin(), c.end()
#define vector2d(name,type,h,w,init) vector<vector<type>> name(h,vector<type>(w,init)) 
const int PRIME = 1000000007;
const int INT_INF = 2147483647;
const long long int LL_INF = 9223372036854775807;
const double PI = acos(-1);
const double EPS = 0.000000001;
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

int main(){
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	int k, i, n;
	ll cnt = 1;
	cin >> n;
	vector<int> prime;
	{
		vector<int> flag(n + 1, true);
		flag[0] = false;
		flag[1] = false;
		for (k = 2; k*k <= n; k++){
			for (i = 2; k*i <= n; i++){
				flag[k*i] = false;
			}
		}
		for (i = 0; i <= n; i++){
			if (flag[i] == true) prime.push_back(i);
		}
	}
	vector<int> pw(prime.size(), 0);
	for (k = 0; k < prime.size(); k++){
		int d = prime[k];
		while (d <= n){
			pw[k] += n / d;
			d *= prime[k];
		}
	}
	for (k = 0; k < pw.size(); k++){
		cnt *= pw[k] + 1;
		cnt %= PRIME;
	}
	cout << cnt << endl;
	return 0;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

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

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  deque<char> d;
  rep(i,s.size()){
    if(s[i]=='B'){
      if(d.empty()) continue;
      d.pop_back();
    }else{
      d.push_back(s[i]);
    }
  }
  while(!d.empty()){
    cout<<d.front();
    d.pop_front();
  }
  cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
#define mod 1000000007
#define pi 3.1415926535
typedef long long ll;
typedef vector<int> ve;
int main(){
    int A,B,K;
    cin>>A>>B>>K;
    set<int>s;
    FOR(i,A,A+K){
        s.insert(i);
    }
    for(int i=B;i>B-K;i--){
        s.insert(i);
    }
    for(auto x:s){
        if(x>=A&&x<=B){
            cout<<x<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
S = input()
N = len(S)
db = [[0]*N for _ in range(400)]
db[0] =  [i+1 if S[i]=='R' else i-1 for i in range(N)]
for i in range(1,400):
  for j in range(N):
    db[i][j] = db[i-1][db[i-1][j]]
ans = [0]*N
for i in range(N):
  K = 10**100
  p = 0
  pos = i
  while K:
    if K%2:
      pos = db[p][pos]
    p += 1
    K >>= 1
  ans[pos] += 1
print(*ans)

Measured memory_bytes: 394700
#include <bits/stdc++.h>
    using namespace std;
    typedef long long lint;
    typedef pair<int,int> pint;
    typedef vector<int> vint;
    #define rep(i, n) for(int i = 0; i < n; i++)
    #define rep2(i, m, n) for(int i = m; i < n; i++)
    #define rep3(elem, vec) for(auto elem: vec)
    #define SORT(V) sort((V).begin(),(V).end())
    #define RSORT(V) sort((V).rbegin(), (V).rend())
    #define COUT(N) cout<<fixed<<setprecision(N)
    lint gcd(int a,int b){return b?gcd(b,a%b):a;}
    lint lcm(int a,int b){return a*b/gcd(a,b);}
    lint comb(int a,int b){return b?comb(a-1,b-1)*a/b:1;}
    int dx[4] ={1,0,-1,0},dy[4] = {0,1,0,-1};
    int MOD = 1e9+7;

int main(){
    int S,W;
    cin >> S>>W;
    if(W>=S)cout << "unsafe";
    else cout << "safe";
    return 0;
}

Measured memory_bytes: 3624
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {  
            string[] input = Console.ReadLine().Split(' ');

            int ball = Int32.Parse(input[0]);
            int ninzu = Int32.Parse(input[1]);

            int result = ninzu == 1 ? 0 : ball - ninzu;

            Console.WriteLine(result.ToString());

        } 
    }
}


Measured memory_bytes: 13140
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int A = sc.nextInt();
	int B = sc.nextInt();
	if(A>=13){
	    System.out.print(B);
	}else if(A>=6 && A<=12){
	    System.out.print(B/2);
	}else{
	    System.out.print(0);
	}
    }
}


Measured memory_bytes: 21844
#datetimeモジュールのインポート
import datetime

#標準入力をし、いずれかが負の数なら、処理を終了する。
while True:
    y1,m1,d1,y2,m2,d2 = map(int,input().split())
    if y1 < 0 or y2 < 0 or m1 < 0 or m2 < 0 or d1 < 0 or d2 < 0:break

    #入力値をdatetime型にする
    dt1 = datetime.date(y1,m1,d1)
    dt2 = datetime.date(y2,m2,d2)
    
    #差を求めて出力する
    days = max(dt1,dt2) - min(dt1,dt2)
    print(days.days)


Measured memory_bytes: 6032
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <locale>
#include <iomanip>

#define nl '\n'

using namespace std;

int a, b, x;
string s;
 
int main(){

    cin >> a >> b;

    for(int i = a; i < b+1; i++){
        s = to_string(i);
        reverse(s.begin(), s.end());
        if(to_string(i) == s){
            x++;
        }
    }

    cout << x;

 
 
 
 
}

//g++ -std=c++14 comp.cpp -o b; ./b.exe

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};
constexpr int MAX_LOG_CNT = 52;

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

    // cnt[d][i] := d が 2^i 個続いたときの操作回数
    // a[d][i] := d が 2^i 個続いたときに操作が完了するときの値
    ll cnt[10][MAX_LOG_CNT+1], a[10][MAX_LOG_CNT+1];
    for(int d=0;d<10;++d) {
        a[d][0] = d;
        cnt[d][0] = 0;
        for(int i=1;i<=MAX_LOG_CNT;++i) {
            a[d][i] = a[d][i-1] + a[d][i-1];
            cnt[d][i] = cnt[d][i-1] * 2 + 1;
            while(a[d][i] >= 10) {
                a[d][i] = a[d][i]/10 + a[d][i]%10;
                ++cnt[d][i];
            }
        }
    }

    int m, d;
    ll c;
    cin >> m;
    vector<ll> dd(m);
    ll ans = 0LL;
    for(int i=0;i<m;++i){
        cin >> d >> c;
        ll tmp_cnt = -1LL;
        ll tmp_d = 0LL;
        for(int j=MAX_LOG_CNT;j>=0;--j) {
            if(c & (1LL<<j)) {
                tmp_cnt += cnt[d][j];
                ll s = tmp_d + a[d][j];
                ++tmp_cnt;
                while(s >= 10) {
                    s = s/10 + s%10;
                    ++tmp_cnt;
                }
                tmp_d = s;
            }
        }
        ans += tmp_cnt;
        dd[i] = tmp_d;
    }

    ll tmp_d = dd[0];
    for(int i=1;i<m;++i) {
        ll s = tmp_d + dd[i];
        ++ans;
        while(s >= 10) {
            s = s/10 + s%10;
            ++ans;
        }
        tmp_d = s;
    }

    cout << ans << endl;

}


Measured memory_bytes: 1792