akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);
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; }

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

  int ans = 0;
  for (int i = 1; i < n; ++i) {
    int cnt = 0;
    for (char c = 'a'; c <= 'z'; c++) {
      bool left = false, right = false;
      for (int j = 0; j < i; j++) {
        if (s[j] == c) left = true;
      }
      for (int j = i; j < n; ++j) {
        if (s[j] == c) right = true;
      }
      if (left && right) cnt++;
    }
    if (ans < cnt) ans = cnt;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import deque


def dfs(G, start):
    S = deque()
    child = deque()
    VL[start[1]][start[0]] = 1
    S.append(start)
    while len(S) > 0:
        node = S.pop()
        for i in range(len(dx)):
            child.clear()
            nx = node[0] + dx[i]
            ny = node[1] + dy[i]

            if nx < 0 or nx >= W or ny < 0 or ny >= H:
                continue
            if G[ny][nx] == 0:
                continue
            if VL[ny][nx] == 1:
                continue

            child.append((nx, ny))

            if len(child) > 0:
                for c in child:
                    VL[c[1]][c[0]] = 1
                    S.append(c)


ok = True
while ok:
    W, H = map(int, input().split())

    if W == 0 and H == 0:
        break

    G = [list(map(int, input().split())) for _ in range(H)]
    VL = [[0 for _ in range(W)] for _ in range(H)]

    dx = [1, 0, -1, 0, 1, 1, -1, -1]
    dy = [0, 1, 0, -1, 1, -1, 1, -1]

    res = 0
    for i in range(H):
        for j in range(W):
            if G[i][j] == 1 and VL[i][j] == 0:
                dfs(G, (j, i))
                res += 1

    print(res)



Measured memory_bytes: 6052
#include <stdio.h>
#include <stdlib.h>
int main(){
    int n,i,k=0,s[100];
    scanf("%d",&n);
    if(!n)printf("0");
    for(k=0;n!=0;k++){
      s[k] = abs(n)%2;
      n = (n-s[k])/(-2);
    }
    for(i=k-1;i>=0;i--)printf("%d",s[i]);
}

Measured memory_bytes: 128
N,K=map(int,input().split())
MOD=10**9+7
res=0
ans=0
for k in range(K,N+2):
    begin=k*(k-1)//2
    end=(2*N-k+1)*k//2
    res=end-begin+1
    ans= (ans+res) %MOD

print(ans)


Measured memory_bytes: 9172
#include<vector>
#include<random>
#include<stack>
#include<sstream>
#include<list>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cstdio>
#include<limits>
#include<cmath>
#include<deque>
#include<iostream>
#include<unordered_map>
#include<unordered_set>
#include<queue>
using namespace std;
template<typename T>
void pprintv(T arr)
{
	for(int i=0;i<arr.size();++i)
	{
		cout<<arr[i]<<" ";
	}
	cout<<endl;
}



void solve()
{
	int n;
	int a,b;
	cin>>n>>a>>b;
	string s;
	cin>>s;
	int c_both=0;
	int c_b=0;
	for(int i=0;i<n;++i)
	{
		if(s[i]=='c')cout<<"No"<<endl;
		else if(s[i]=='a')
		{
			if(c_both<a+b)
			{
				cout<<"Yes"<<endl;
				++c_both;
			}
				
			else cout<<"No"<<endl;
		}
		else 
		{

			if(c_both>=a+b)
				cout<<"No"<<endl;
			else
			{
				if(c_b+1>b)cout<<"No"<<endl;
				else 
				{
					cout<<"Yes"<<endl;
					++c_both;
				}
			}
			++c_b;
		}
	}

}


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


Measured memory_bytes: 896
#include <stdio.h>
#include<stdlib.h>
#include<algorithm>
using namespace std;
int main()
{   int a[200];
int i,x,sum=0;
    scanf("%d",&x); 
	for(i=0;i<x;i++)
	scanf("%d",&a[i]);
    sort(a,a+x);
	sum=a[x-1]-a[0];
	printf("%d\n",sum);

}

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

namespace ABC122 {
	class ABC122_B {
		static void Main(string[] args) {
			var inputLine = Console.ReadLine();
			var count = 0;
			var currentMax = 0;
			foreach (var c in inputLine) {
				switch(c) {
					case 'A':
					case 'G':
					case 'C':
					case 'T':
						count++;
						if (currentMax < count) {
							currentMax = count;
						}
						continue;
				}

				count = 0;
			}
			Console.WriteLine(currentMax);
		}
	}
}


Measured memory_bytes: 11092
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back 
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define LLINF (1<<60)
#define MOD 1000000007
#define rep(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

int main() {
    int n;
    vector<string> s;
    char ss;
    cin >> n;
    for (int i = 0; i < n; i++) {
        string sss;
        cin >> sss;
        for (int j = 0; j < s.size(); j++) {
            if (sss == s[j]) {
                No;
                return 0;
            }
        }
        s.pb(sss);
        if (i != 0) {
            if (s[i][0] != ss) {
                No;
                return 0;
            }
        }
        ss = sss[sss.length() - 1];
    }
    Yes;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String args []){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int max = 0;
        int before = sc.nextInt();
        int num = 0;
        for(int i=0;i<N-1;i++){
            int now = sc.nextInt();
            if(before<now){
                if(num>max) max = num;
                num = 0;
            }
            else if(before>=now&&i!=N-2) num++;
            else if(before >= now && i==N-2){
                num++;
                if(num > max) max = num;
            }
            before = now;
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 48464
#include<bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define pa pair<int,int>
const int N=1e6+10; 
const int mod=998244353;
using namespace std;

ll b[N],a[N];
int main()
{
	int n; cin>>n; ll g=0;
	for(int i=1;i<=n;++i) cin>>a[i],b[i]=abs(a[i]),g+=b[i];
	int f=0,zero=0;
	for(int i=1;i<=n;++i) f+=(a[i]<0),zero+=(a[i]==0); 
	if(f%2==0||zero) return cout<<g<<endl,0;
    ll mi=inf;
	for(int i=1;i<=n;++i) mi=min(mi,b[i]);
	cout<<g-2*mi<<endl;
return 0;
}
/*
*/

Measured memory_bytes: 5120
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;


int main()
{
	int takahashi = 0;
	int a;
	int b;
	cin >> a >> b;
	for (int i = 1; i <= a; ++i) {
		if (i != a) {
			for (int j = 1; j <= 31; ++j) {
				if (i == j) {
					++takahashi;
				}
			}
		}
		else if (i == a) {
			for (int j = 1; j <= b; ++j) {
				if (i == j) {
					++takahashi;
				}
			}
		}
	}
	cout << takahashi;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <iostream>

template<typename ForwardIter>
void dump(ForwardIter begin, ForwardIter end)
{
    while (begin != end)
        std::cout << *begin++ << " ";
    std::cout << std::endl;
}

const int kN = 2000 + 5;
int a[kN], n;
std::vector<std::pair<int, int>> edges[kN];
std::vector<int> seq[kN];
bool vis[kN];

int gcd(int a, int b)
{
    return b == 0 ? a : gcd(b, a % b);
}

void dfs(int u)
{
    std::sort(edges[u].begin(), edges[u].end());
    for (auto t : edges[u]) {
        int v = t.second;
        if (vis[v]) continue;
        vis[v] = true;
        dfs(v);
        std::vector<int> vec;
        for (int i = 0, j = 0; i < seq[u].size() || j < seq[v].size(); ) {
            if (i < seq[u].size() && j < seq[v].size())
                vec.emplace_back(seq[u][i] > seq[v][j] ? seq[u][i ++] : seq[v][j ++]);
            else if (i < seq[u].size())
                vec.emplace_back(seq[u][i ++]);
            else
                vec.emplace_back(seq[v][j ++]);
        }
        vec.swap(seq[u]);
    }
    seq[u].insert(seq[u].begin(), a[u]);
}

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; ++ i) {
        scanf("%d", a + i);
    }
    std::sort(a, a + n);
    for (int i = 0; i < n; ++ i) {
        for (int j = i + 1; j < n; ++ j) {
            if (gcd(a[i], a[j]) > 1) {
                edges[i].emplace_back(a[j], j);
                edges[j].emplace_back(a[i], i);
            }
        }
    }
    for (int i = 0; i < n; ++ i) edges[n].emplace_back(a[i], i);
    dfs(n);
    for (int i = 1; i <= n; ++ i) {
        printf("%d%c", seq[n][i], " \n"[i == n]);
    }
}


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

N = int(input())
S={}
for _ in range(N):
  s = ''.join(sorted(input().rstrip()))
  if s in S:
    S[s] += 1
  else:
    S[s] = 1

ans=0
for s in S.values():
  ans += s*(s-1)//2
  
print(ans)

Measured memory_bytes: 17848
import java.util.*;


public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
        }

        int t = f(a[0]);
        for (int i = 1; i < N; i++) {
            if (f(a[i]) != t) {
                System.out.println(0);
                return;
            }
        }

        long l = 1;
        for (int i = 0; i < N; i++) {
            l = lcm(l, a[i]/2);
            if (l > M) {
                System.out.println(0);
                return;
            }
        }

        System.out.println((M/l+1)/2);
    }

    private static long gcd(long a, long b) {
        return b>0 ? gcd(b,a%b) : a;
    }

    private static long lcm(long a, long b) {
        return a/gcd(a,b)*b;
    }

    private static int f(int x) {
        int ret = 0;
        while (x%2 == 0) {
            ret++;
            x /= 2;
        }

        return ret;
    }
}


Measured memory_bytes: 52116
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
using namespace std;

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;

// マクロ
#define repr(itr, bgn, end) for (ll itr = (ll)bgn; itr < (ll)end; itr++)
#define rep(itr, end) repr(itr, 0, end)
#define reprrev(itr, bgn, end) for (ll itr = (ll)end - 1; itr >= (ll)bgn; i--)
#define reprev(itr, end) reprrev(i, 0, end)
#define all(container) container.begin(), container.end()
#define yn(cond) cond ? (cout << "Yes" << endl) : (cout << "No" << endl)
#define YN(cond) cond ? (cout << "YES" << endl) : (cout << "NO" << endl)

// 定数
#define LLONG_MAX 9223372036854775807i64
constexpr double PI = 3.14159265358979323846;
constexpr ll INF = 1 << 15;
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-7;

// よく使うもの
constexpr int dy[4] = { 0, 1, 0, -1 };
constexpr int dx[4] = { 1, 0, -1, 0 };
struct edge { ll to; ll cost; };


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}

// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
    for (T& x : vec) os << x << " ";
    return os;
}

// ***<ここから>****************************************************************


int main(void) {

    string S;
    int w;
    cin >> S >> w;

    string ans;
    for (int i = 0; i < S.length(); i += w){
        ans.push_back(S[i]);
    }

    cout << ans << endl;
 
    return 0;
}

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

typedef long long int LL;
typedef long long int LLint;

//Faster Program
#define endl "\n"

//Faster Coding
#define ED return
#define GET(a) int a;cin >> a
#define DGET(a) double a;cin >> a
#define SGET(a) string a;cin >> a
#define CGET(a) char a;cin >> a
#define PRINT(a) cout << a << "\n"
#define ANS(a,b) int a;cin >> a;cout << b << "\n"
#define FOR(n) for(int i = 0;i < n;i++)
#define SORT(vec) sort(vec.begin(),vec.end())
#define REV(vec) reverse(vec.begin(),vec.end())

//As Function
#define UP(a,b) ((a+(b-1))/b)
#define ipow(x,y) LL(pow(x,y))

//Debug
#define TEST cout << "OK" << endl

const double PI = M_PI;
const long long INF = int(10e9-1);
const long long MOD = int(10e9+7);

//Settings
const bool DO_BENCHMARK = false;
const int DOUBLE_ACCURACY = 15;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(DOUBLE_ACCURACY);
    void solve();
    if(DO_BENCHMARK){
        clock_t start = clock();
        solve();
        clock_t end = clock();
        const double time = static_cast<double>(end-start)/CLOCKS_PER_SEC*1000.0;
        cout << "\n" << time << "[ms]\n";
    }
    else solve();
}

void solve(){
   GET(N);
   ANS(K,N-K+1);
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;

int main(int argc, char **argv) {
    i64 n;
    cin >> n;

    std::vector<int> vec(n);
    for (int i=0; i<n; ++i) cin >> vec[i];

    int mini=vec[0];
    int ans{0};

    for (int i : vec) {
        if (i <= mini) {
            mini = min(mini, i);
            ++ans;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			PriorityQueue<Integer> Q=new PriorityQueue<Integer>(11, Collections.reverseOrder());
			
			while(sc.hasNext()) {
				String str=sc.next();
				if(str.equals("end")) {
					break;
				}
				if(str.equals("insert")) {
					int value=sc.nextInt();
					Q.add(value);
				}
				else {
					System.out.println(Q.poll());
				}
			}
			

		}
	}
}


Measured memory_bytes: 579764
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pp;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> super_set;

#define x1 dfds
#define y1 dsfdsfe
#define pb push_back
#define forn(i,n) for(ll i = 1;i<=n;++i)
#define fi first
#define sc second
#define endl '\n'
#define po(x) (1ll<<x)
const ll DIM = 1E5+14;
const ll INF = 1E19;
ll n,a,b,c,d;
map<ll,ll> M;
ll solve(ll num){
    if (M.count(num)==1)return M[num];

    ll n2 = (num/2)*2;
    ll n22 = ((num+1)/2)*2;
    ll n3 = (num/3)*3;
    ll n33 = ((num+2)/3)*3;
    ll n5 = (num/5)*5;
    ll n55 = ((num+4)/5)*5;

    ll r2 = abs(n2-num)*d+a+solve(num/2);
    ll r22 = abs(n22-num)*d+a+solve(n22/2);
    ll r3 = abs(n3-num)*d+b+solve(n3/3);
    ll r33 = abs(n33-num)*d+b+solve(n33/3);
    ll r5 = abs(n5-num)*d+c+solve(n5/5);
    ll r55 = abs(n55-num)*d+c+solve(n55/5);
    ll r = INF;
    if (num<r/d)r = num*d;
    r = min(r,r2);
    r = min(r,r22);
    r = min(r,r3);
    r = min(r,r33);
    r = min(r,r5);
    r = min(r,r55);
    M[num] = r;
    return r;
}
int main()
{
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll t;
    cin>>t;
    while(t--){
        M.clear();
        cin>>n>>a>>b>>c>>d;
        M[0] = 0;
        M[1] = d;

        cout<<solve(n)<<endl;
    }
    return 0;
}


Measured memory_bytes: 4384
a, b, c, k = gets.split.map(&:to_i)

def min(num1, num2)
    if num1 <= num2
        return num1
    else
        return num2
    end
end

xa = min(a, k)
k = k - xa

xb = min(b, k)
k = k - xb

xc = min(c, k)

sum = xa - xc
puts(sum)

Measured memory_bytes: 14224
#include<bits/stdc++.h>
using namespace std;
struct data
{
    long long f;
    int s;
};
data a[100009];
int n, m, l = 0;
long long kq = 0;
bool tmp(data x, data y)
{
    return x.f < y.f;
}
int main()
{
    cin >> n >> m;
    for(int i = 1; i <= n; ++ i)
    {
        cin >> a[i].f >> a[i].s;
    }
    sort(a + 1, a + 1 + n, tmp);
    //for(int i = 1; i <= n; ++ i)
   // {
     //   cout << a[i].f << " " << a[i].s << endl;
    //}
    for(int i = 1; i <= n; ++ i)
    {
        if(l + a[i].s <= m)
        {
            kq += a[i].s * a[i].f;
            l += a[i].s;
            //cout << l << endl;
        }
        else
        {
            kq += (m - l) * a[i].f;
            break;
        }
    }
    cout << kq;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
    int c = 1000000007;
    int H , W;
    cin >> H >> W;
    vector<string> M(H);
    for(int i=0 ; i<H ; i++)
        cin >> M[i];
    long long d[H][W];
    for(int i=0 ; i<H ; i++)
        for(int j=0 ; j<W ; j++)
            d[i][j] = 0;
    d[0][0] = 1;
    for(int i=0 ; i<H ; i++)
        for(int j=0 ; j<W ; j++)
        {
            if(i>0 && M[i-1][j] == '.')
                d[i][j] += d[i-1][j]%c;
            if(j>0 && M[i][j-1] == '.')
                d[i][j] += d[i][j-1]%c;
        }
    cout << d[H-1][W-1]%c;
}

Measured memory_bytes: 9088
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
using namespace std;
int p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(long long i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<pin,int>
#define V vector
#define Endl endl
#define veb vector<bool>
#define sq(a) (a)*(a)
#define rev(s) reverse(s.begin(),s.end())
#define end_pr(s) cout << s <<endl;return 0
#define itn int
#define bs bitset<5001>

int kai_size = 1000001;
vel kai(kai_size, 1);
vel ink(kai_size, 1);
vel dist;
int sz(pin x) { return x.first*x.second; }
void make(int c, int pot, int d, vel &col, vel &max_use,vvel &way) {
	if (max_use[pot] < d) {
		if (col[pot] == 0) { col[pot] = c; }
		max_use[pot] = d;
		for (auto x : way[pot]) {
			make(c, x, d - 1, col, max_use, way);
		}
	}
}
signed main() {
	int n; cin >> n;
	int d; cin >> d;
	d *= 2; d++;
	cout << (n + d - 1) / d << endl;
	return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)
#define REPLL(i, n) for(ll i = 0;i < (n);++i)

#define endl "\n"
#define pb push_back
#define MOD 1000000007LL
#define PI 3.1415926

typedef long long ll;

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T> inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int n, m, k[30], a[30][30];
	bool like[31];
	REP(i, 31) like[i] = 1;
	cin >> n >> m;
	REP(i, n){
		cin >> k[i];
		REP(j, k[i]){
			cin >> a[i][j];
		}
		for (int j = 1; j <= m; j++) {
			bool exist = 1;
			REP(l, k[i]) if(j == a[i][l]) exist = 0;
			if(exist) like[j] = 0;
		}
	}
	int ans = 0;
	for (int i = 1; i < m+1; i++) {
		if(like[i]) ans++;
	}
	cout << ans << endl;


	return 0;
}

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



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string S;
    cin >> S;
    int Q;
    cin >> Q;
    deque<char> ans(S.begin(), S.end());
    int cnt = 0;
    rep(q, Q) {
        int T;
        cin >> T;
        if (T == 1) {
            cnt++;
        }
        else {
            int F;
            char C;
            cin >> F >> C;
            if (cnt % 2 == 1) {
                if (F == 2) F = 1;
                else F = 2;
            }
            if (F == 1) ans.push_front(C);
            else ans.push_back(C);
        }
    }
    if (cnt % 2 == 1) {
        reverse(ans.begin(), ans.end());
    }
    string ans_str(ans.begin(), ans.end());

    cout << ans_str << endl;
    return 0;
}

Measured memory_bytes: 1232
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}


 main()

{
    fast
    string s;
    cin>>s;
    int n=s.size();
    s="#"+s;
    for(int i=1;i<=n;i++)
    {
       if(i%2==1)
       {if(!(s[i]=='R' || s[i]=='U' || s[i]=='D'))
        {
            cout<<"No"<<endl;
            return 0;
        }

       }
        else
       {if(!(s[i]=='L' || s[i]=='U' || s[i]=='D'))
        {
            cout<<"No"<<endl;
            return 0;
        }

       }
    }
    cout<<"Yes"<<endl;


















    return 0;

}













Measured memory_bytes: 256
def checkbingo(map_):
  for i in range(3):
    if map_[i][0] * map_[i][1] * map_[i][2] == 1:
      return True
    if map_[0][i] * map_[1][i] * map_[2][i] == 1:
      return True
  if map_[0][0] * map_[1][1] * map_[2][2] == 1:
    return True
  if map_[0][2] * map_[1][1] * map_[2][0] == 1:
    return True
  return False 

A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
A = [A1,A2,A3]
bingomap = [[0,0,0],[0,0,0],[0,0,0]]
N = int(input())
b = list()
ret = 'No'
for i in range(N):
  b.append(int(input()))
for i in range(N):
  for j in range(3):
    if b[i] in A[j]:
      bingomap[j][A[j].index(b[i])] = 1
      break
  if i >= 2 :
    if checkbingo(bingomap) == True:
      ret = 'Yes'
      break
print(ret)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
#include<utility>
#include<fstream>
#include<queue>
#include <iomanip>
using namespace std;
typedef long long ll;
#define rep(i,k) for(i=0;i<k;i++)
#define P pair<int,int>
ll n,p, k, b, c, i, j, x, y, z = 1, m = 0;
ll a[100000] = {}, yy[100000] = {};
double xx,zz=0;
string s;
P pp[100000];
vector<ll> v;
char cc[100000][10];
int main() {
	
	cin>>n ;
	rep(i, n) {
		cin >> xx;
		zz += 1 / xx;

	}
	cout << fixed<< setprecision(7)<<1/zz;

	return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		char[] x = sc.next().toCharArray();
		sc.close();

		int cnt = 0;
		for (int i = 0; i < n; i++) {
			if (x[i] == '1') {
				cnt++;
			}
		}
		int p0 = cnt + 1;
		int p1 = cnt - 1;
		int[] dp = new int[n];
		for (int i = 1; i < n; i++) {
			int next = i % Integer.bitCount(i);
			dp[i] = dp[next] + 1;
		}

		long v0 = 0;
		for (int i = 0; i < n; i++) {
			v0 *= 2;
			v0 %= p0;
			if (x[i] == '1') {
				v0++;
			}
		}
		v0 %= p0;

		long v1 = 0;
		if (p1 > 0) {
			for (int i = 0; i < n; i++) {
				v1 *= 2;
				v1 %= p1;
				if (x[i] == '1') {
					v1++;
				}
			}
			v1 %= p1;
		}

		PrintWriter pw = new PrintWriter(System.out);
		for (int i = 0; i < n; i++) {
			if (x[i] == '0') {
				long a = power(2, n - 1 - i, p0);
				long val = v0 + a;
				int next = (int) (val % p0);
				pw.println(dp[next] + 1);
			} else {
				if (p1 == 0) {
					pw.println(0);
				} else {
					long a = power(2, n - 1 - i, p1);
					long val = v1 - a + p1;
					int next = (int) (val % p1);
					pw.println(dp[next] + 1);
				}
			}
		}
		pw.flush();
	}

	static long power(long x, long n, int m) {
		if (n == 0) {
			return 1;
		}
		long val = power(x, n / 2, m);
		val = val * val % m;
		if (n % 2 == 1) {
			val = val * x % m;
		}
		return val;
	}
}


Measured memory_bytes: 51376
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    a = i_input()
    b = i_input()

    if a == b:
        print('EQUAL')
    elif a > b:
        print('GREATER')
    else:
        print('LESS')

if __name__ == '__main__':
    main()


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

int main() {
	string S, T;
	cin >> S >> T;
	int A, B;
	cin >> A >> B;
	string U;
	cin >> U;

	if(U == S)
		cout << A - 1 << " " << B << endl;
	else
		cout << A << " " << B - 1 << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		List<Integer> list = new ArrayList<>();
		list.add(2);
		int tmp = 3;
		while(list.size() < k) {
			boolean flag = true;
			for(int i = 2; i < tmp; i++) {
				if(tmp % i == 0) {
					flag = false;
					break;
				}
			}
			if(flag && tmp % 5 == 1) {
				list.add(tmp);
			}
			tmp += 2;
		}
		list.forEach(e -> System.out.println(e));
	}

}


Measured memory_bytes: 26836
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	ans := 0
	for i := 1; i <= N; i += 2 {
		c := 0
		for j := 1; j <= N; j++ {
			if i%j == 0 {
				c++
			}
		}
		if c == 8 {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy

def main():
    s = input()
    count = 0
    for i in s:
        if i == "+":
            count += 1
        else:
            count -= 1

    print(count)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3444
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
 
public class Program
{
 
    public static void Main()
    {
        string c1 = Console.ReadLine();
        string c2 = Console.ReadLine();
        string ans = "NO";
        c2 = new string(c2.Reverse().ToArray());
        if (c1 == c2) ans = "YES";
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13268
# coding: utf-8
# Your code here!
# coding: utf-8
from fractions import gcd 
from functools import reduce
import sys
sys.setrecursionlimit(200000000)
from inspect import currentframe


# my functions here!
#標準エラー出力
def printargs2err(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' : '+repr(arg) for arg in args),file=sys.stderr)
def debug(x):
    print(x,file=sys.stderr)
def printglobals():
    for (symbol, value) in globals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
def printlocals():
    for (symbol, value) in locals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
#入力（後でいじる）
def pin(type=int):
    return map(type,input().split())

#繰り返し自乗法だよ
#これはnのp乗をmで割ったあまりをだすよ
def modular_w_binary_method (n,m,p):
    ans=1 if n>0 else 0
    while(p>0):
        if p%2==1:
            ans=(ans*n)%m
        n=(n**2)%m
        p//=2
    return ans
#mod上でのaの逆元を出すよ
"""
    フェルマーの小定理より a**(p)%p==a isTrue
    これを利用すれば a**(p-2)%p==a**(-1) isTrue
    元と逆元とをかけてpで割れば1が余るよ！
"""
def modular_inverse(a,prime):
    return(modular_w_binary_method(a,prime,prime-2))
#逆元を使うと容易に頑張れるｃ
def conbination(n,a,mod=10**9+7):
    #cはイラない
    res=1 
    for s in range(a):
        res=(res*(n-s)*(modular_inverse(s+1,mod)))%mod

        
    return res
#操作から作れるものの組み合わせは何個かー＞同じものでも違う方法で構成できるかから考える方法もある
"""
"""

#solution:

#input
N,=pin()
ans=0
A,B=[],[]
for _ in range(N):
    a,b=pin()
    A.append(a)
    B.append(b)
for i in range(N-1,-1,-1):
    #print("b-a=",(B[i]-A[i])%B[i])
    temp=(B[i]-A[i]-ans)%B[i]
    #print(temp)
    ans+=temp
print(ans)
#print(h)
#print(m)
#print(["No","Yes"][cond])
#print([["NA","YYMM"],["MMYY","AMBIGUOUS"]][cMMYY][cYYMM])
"""
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じるの忘れてるだろ
"""

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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a + b > c + d) {
        cout << "Left";
    }
    else if (a + b < c + d) {
        cout << "Right";
    }
    else {
        cout << "Balanced";
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;

int main(void){
    ll s;
    int digit[10];
    cin >> s;
    
    if (s == 1) {
        cout << 1 << endl;
        return 0;
    }
    int keta = 0;
    while (pow(10, keta) < s) keta++;
    
    for (int i = 0; i < keta; i++) {
        digit[keta - 1 - i] = s % 10;
        s /= 10;
    }
    
    int bi[10];
    ll ans = 0;
    for (int i = 0; i < pow(2, keta - 1); i++) {
        int ic = i;
        for (int j = 0; j < keta - 1; j++) {
            bi[j] = ic % 2;
            ic /= 2;
        }
        
        ll sum = 0, now = digit[0];
        for (int j = 0; j < keta - 1; j++) {
            if (bi[j] == 0) now = now * 10 + digit[j + 1];
            else {
                sum += now;
                now = digit[j + 1];
            }
        }
        sum += now;
        ans += sum;
        //cout << sum << endl;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define ff first
#define ss second
#define ll long long
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define repr(i, a, n) for (ll i = (n); i >= (a); --i)
using namespace std;
const int INF(1 << 30);
const ll LLINF(1LL << 55LL);
const int pi = 3.1415926536;
const int MOD = 1000000007;
const int MAX = 510000;

void Main() {
  int x, a, b;
  cin >> x >> a >> b;
  cout << (x - a) % b << endl;
}

int main() {
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // CとC++の入出力出力を非同期
  std::cout << std::fixed << std::setprecision(15);  // 小数を10進数表示
  Main();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
string s[1001],t[3];
int h,w,sum,ans=0;
int dx[]={0,0,-1,-1};
int dy[]={0,-1,0,-1};
int gx[]={0,0,1,1};
int gy[]={0,1,0,1};
char c[]={'J','O','I'};
bool used[1001][1001];
void get_sum(){
  r(i,h-1)r(j,w-1){
    if(s[i][j]==t[0][0]&&s[i+1][j]==t[1][0]&s[i][j+1]==t[0][1]&&s[i+1][j+1]==t[1][1]){
      used[i][j]=1;
      sum++;
    }
  }
}
int get_res(int y,int x){
  int res=sum;
  r(i,4){
    int yy=y+dy[i];
    int xx=x+dx[i];
    if(yy<0||xx<0||yy>=h||xx>=w)continue;
    if(used[yy][xx])res--;
  }
  r(i,4){
     int yy=y+dy[i];
     int xx=x+dx[i];
     if(yy<0||xx<0||yy>=h||xx>=w)continue;
     r(k,4){
       int sy=yy+gy[k];
       int sx=xx+gx[k];
       if(sy<0||sx<0||sy>=h||sx>=w)continue;
       if(s[sy][sx]!=t[gy[k]][gx[k]])break;
       if(k==3)res++;
     }
  }
  return res;
}
int get_ans(int y,int x){
  char tmp = s[y][x];
  int res=0;
  r(i,3){
    if(s[y][x]!=c[i]){
      s[y][x]=c[i];
      res=max(res,get_res(y,x));
      s[y][x]=tmp;
    }
  }
  return res;
}
int main(){
  cin>>h>>w;
  r(i,h)cin>>s[i];
  r(i,2)cin>>t[i];
  get_sum();
  ans=sum;
  r(i,h)r(j,w){
    ans=max(ans,get_ans(i,j));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 5068
n,c,*t=map(int,open(0).read().split())
X=t[::2];V=t[1::2]
def s(X,v):
 V=[0];X=[0]+X;r=[0];l=[0]*-~n
 for i in v:V+=V[-1]+i,
 for i in range(n):r+=V[i+1]-2*X[i+1],;l[n-i-1]=max(l[n-i],V[n]-V[n-i-1]-(c-X[n-i]))
 return [i+j for i,j in zip(r,l)]
print(max(s([c-i for i in X[::-1]],V[::-1])+s(X,V)))

Measured memory_bytes: 115204
S = input()

tail = 2
for i in range(1,len(S)//2):
    #print(S[0:len(S)//2-i])
    #print(S[len(S)//2-i:len(S)-tail])

    if S[0:len(S)//2-i] == S[len(S)//2-i:len(S)-tail]:
        print(len(S[0:len(S)//2-i]) * 2)
        exit()
    tail += 2

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define REP1(i, n) for(int i=1; i<=(n); i++)
#define RREP1(i, n) for(int i=(n); i>=1; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define out(...) printf(__VA_ARGS__)
#if DEBUG
#define debug(...) printf(__VA_ARGS__)
#else
#define debug(...) /* ... */
#endif

void solve();
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

/*================================*/
#if DEBUG
#define SIZE 100
#else
#define SIZE 223450
#endif

int N,A[SIZE],B[SIZE];

void solve() {
    cin>>N;
    REP(i,N)cin>>A[i]>>B[i];
    sort(A,A+N);
    sort(B,B+N);
    if (N%2) {
        int mi = A[N/2];
        int ma = B[N/2];
        cout << ma-mi+1 << endl;
    } else {
        int mi = A[N/2-1]+A[N/2];
        int ma = B[N/2-1]+B[N/2];
        cout << ma-mi+1 << endl;
    }
}



Measured memory_bytes: 6832
#include<iostream>
#include<math.h>
using namespace std;
int N;
double a, b, c;

void rep(double* x,double* y){
	double d;
	d = *x;
	*x = *y;
	*y = d;
}

int main(){
	
	cin >> N;
	for(int i = 0; i < N; ++i){
		cin >> a >> b >> c;
		
		if(a < b || a < c){
			if(b < c){
				rep(&a, &c);
			}else{
				rep(&a, &b);
			}
		}

		if( a*a == b*b + c*c){
			cout << "YES\n";
		}else{
			cout << "NO\n";
		}


	}
	return 0;
}

Measured memory_bytes: 0
a = input().split()
a = [int(i) for i in a]

def f(a):
    for i in range(len(a)):
        for j in range(i+1, len(a)):
            if (a[i] == a[j]) and (a[list(set([0,1,2])-set([i,j]))[0]] != a[i]):
                print("Yes")
                return
    print("No")
f(a)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define deb(x) cout<<#x<<" "<<x<<endl;  //for debugging variables 
#define check cout<<"check"<<endl; // checking 


void solve(){


int n;

cin>>n;


vector<long long>a(n);


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



long long  st = 0;

long long m = 1000;



for(int i=0;i<n-1;i++){


    
    if(a[i]<a[i+1]){

        
     long long x = m/a[i];

     st+=x;
    m = m-(x*a[i]);

    }
    else if(a[i]>a[i+1]){


       m = m+(st*a[i]);

        st = 0;


    }







}


m+=(st*a[n-1]);



cout<<m<<endl;




}






int main(){



int t;
//cin>>t;

t=1;
while(t--){
solve();
}
	return 0;
} 

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

int main() {
  int n;
  cin >> n;
  int64_t ans = 1;
  
  vector<int64_t> v(n);
  bool z = false;
  for (int i = 0; i < n; i++) {
    cin >> v.at(i);
    if (v.at(i) == 0) {
      cout << 0 << endl;
      z = true;
      break;
    }
  }
  if (!z) {
    for (int i = 0; i < n; i++) {
      int64_t x = v.at(i);
      if (x > 1000000000000000000 / ans) {
        cout << -1 << endl;
        break;
      }
      else {
        ans *= x;
      }
      if (i == n - 1)
        cout << ans << endl;
    }
  }
}

Measured memory_bytes: 4052
#include<bits/stdc++.h>
using namespace std;
main()
{
	//freopen("input.txt","rt",stdin);
	int n,k;
	cin>>n>>k;
	double sum =0;
	for(int i=0;i<n;i++)
	{
		int s = n;
		int p = i+1;
		while(p < k)
		{
			p *= 2;
			s *= 2;
		}
		sum += (double)1/(double)s;
	}
	cout<<setprecision(10)<<fixed<<sum<<endl;
}

Measured memory_bytes: 256
#define REP(i, s, e) for(register int i = s; i <= e ;i++)

#include <bits/stdc++.h>

using namespace std;

bool cnt;

int main() {
#ifdef CraZYali
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
#endif
	char c;
	while ((c = getchar()) != EOF) {
		if (!cnt) putchar(c);
		cnt ^= 1;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
            using namespace std;
            #define rep(i,a,b) for(ll i =a; i<b;++i)
            #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
            #define endl "\n"
            #define pb push_back
            #define F first
            #define S second
            #define print(a)       for(auto x : a) cout << x << " "; cout << endl
            #define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
            #define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl
            #define mk(x,y)  make_pair(x,y)
            typedef  long long  int ll;
            const int N = ( 2e5 + 5 );
            const int mod = 1e9+7;
            ll  n,k,r,b,g,a[N];
    ll pow_mod_m(ll a , ll n)
    {
        if(!n)
            return 1;
        ll pt =  pow_mod_m(a,n/2);
        pt *= pt ; pt %= mod;
        if(n&1)
            pt *= a , pt %= mod;
        return pt;
    }


    int main()
    {
         IOS;
      //     freopen("a_example (2).txt","r",stdin);
      //     freopen("c.txt","w",stdout);

        int ts =1;
        //cin>>ts;
        rep(t,1,ts+1)
        {
            cin >> n ;
            string s;
            cin >> s;
            for(auto u : s)
            {
                if(u == 'R') r++;
                if(u == 'G') g++;
                if(u == 'B') b++;
            }
            ll ans  = r*g*b;
            rep(i,0,n)
            {
                rep(j,1,n)
                {
                    ll l = i-j;
                    ll r = i+j;
                    if( l >=0 and r <n and s[l]!= s[i] and s[l]!= s[r] and s[r]!= s[i]) ans--;
                }
            }
            cout << ans << endl;
        }
    }


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int main()
{
    int n, cnt = 0;
    cin>>n;
    REP(i,n) {
        int p;
        cin>>p;
        if (p != i+1) {
            cnt++;
        }
    }
    YES(cnt<=2);


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using lint=int64_t;
using namespace std;

int bsearch(int* L,int N,int t)
{
	int l=0;
	int r=N;
	while(r-l>1)
	{
		int mid=(l+r)/2;
		if(L[mid]>=t)r=mid;
		else l=mid;
	}
	return r;
}

int main()
{
	int N;
	int L[2010]={};

	cin >> N;
	for(int i=0;i<N;i++)
		cin >> L[i];

	sort(L,L+N);
	
	int ans=0;
	for(int i=0;i<N;i++)
	{
		for(int j=i+1;j<N;j++)
		{
			int r=bsearch(L,N,L[i]+L[j]);
			ans+=max(0,r-j-1);
		}
	}
	
	cout << ans << endl;
	return 0;
}



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

int main(){
  int N, K;
  cin >> N >> K;
  char S[N];
  for(int i = 0; i < N; i++){
    cin >> S[i];
  }
  S[K-1] += 0x20;
  
 for(int i = 0; i < N; i++){
   cout << S[i];
 }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
int main(){

int a,b;
cin>>a>>b;
int sum=0;
for(int i=1;i<1000;i++){
if(i !=(b-a)){
     sum+=i;
}else{
 	break;
}
}
cout<<sum-a<<endl;
 
 
return 0;
}

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

int main() {
  int h, w, n, sr, sc;
  cin >> h >> w >> n >> sr >> sc;
  string s, t;
  cin >> s >> t;
  reverse(s.begin(), s.end());
  reverse(t.begin(), t.end());
  int lx = 1, rx = w, ly = 1, ry = h;
  for (int i = 0; i < n; i++) {
    switch (t.at(i)) {
      case 'L':
        if (rx < w) rx++;
        break;
      case 'R':
        if (lx > 1) lx--;
        break;
      case 'U':
        if (ry < h) ry++;
        break;
      case 'D':
        if (ly > 1) ly--;
        break;
    }
    switch (s.at(i)) {
      case 'L':
        lx++;
        break;
      case 'R':
        rx--;
        break;
      case 'U':
        ly++;
        break;
      case 'D':
        ry--;
        break;
    }
    if (lx > rx or ly > ry) {
      puts("NO");
      return 0;
    }
  }
  if (lx <= sc and sc <= rx and ly <= sr and sr <= ry) {
    puts("YES");
  } else {
    puts("NO");
  }
}


Measured memory_bytes: 3924
#include <iostream>
#include <string>
using namespace	std;
int main(){
  string s;
  cin>>s;
  int r=1e9,l=s.size();
  for(int i=0;i<l-1;i++) if(s[i]!=s[i+1]) {
      int r0=max(i+1,l-i-1);
      r=min(r,r0);
  }
  if(r==1e9) cout<<l<<endl;
  else cout<<r<<endl;
  return 0;
}


Measured memory_bytes: 512
import sys
mod = 10**9+7
sys.setrecursionlimit(mod)
N,M=map(int, input().split())

adj={i: set() for i in range(1,N+1)}
for i in range(M):
  x,y,z=map(int, input().split())
  adj[x].add(y)
  adj[y].add(x)
V=set()
def dfs(v):
  if v not in V:
    V.add(v)
    for u in adj[v]: dfs(u)
cnt=0
for i in range(1,N+1):
  if i not in V:
    cnt += 1
    dfs(i)
print(cnt)

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

using namespace std;

const int N=1e5+10;
const int M=4e3+10;

int n1,n2,w[12][12];


int gw[205][205];


void buildgraph(){
        for(int u1=0;u1<=100;u1++)
                for(int u2=0;u2<=100;u2++){
                        int& rwei=gw[u1][201-u2];
                        for(int w1=1;w1<=n1;w1++)
                                for(int w2=1;w2<=n2;w2++)
                                        rwei=max(rwei,w[w1][w2]-u1*w1-u2*w2);
                }
}
int d[205];
int dijkstra(int w1,int w2){
        d[100]=200;
        for(int i=101;i<=201;i++){
                d[i]=d[i-1]+w2;
                for(int u1=0;u1<=100;u1++) d[i]=min(d[i],gw[u1][i]+u1*w1);
        }
        return d[201];
}
int main(){
        cin>>n1>>n2;
        for(int i=1;i<=n1;i++)
                for(int j=1;j<=n2;j++) cin>>w[i][j];
        buildgraph();
        for(int w1=1;w1<=n1;w1++)
                for(int w2=1;w2<=n2;w2++){
                        if (dijkstra(w1,w2)!=w[w1][w2]) {
                                cout<<"Impossible";
                                return 0;
                        }
        }
        cout<<"Possible\n202 10401\n";
        for(int i=1;i<=100;i++) cout<<i<<" "<<i+1<<" X\n";
        for(int i=102;i<=201;i++) cout<<i<<" "<<i+1<<" Y\n";
        for(int i=0;i<=100;i++)
                for(int j=101;j<=201;j++) cout<<i+1<<" "<<j+1<<" "<<gw[i][j]<<'\n';
        cout<<"1 202";
}


Measured memory_bytes: 384