akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 998244353;
int h,w,n;
signed main(){
    cin >> h >> w >> n;
    int sr,sc;
    cin >> sr >> sc;
    string S,T;
    cin >> S >> T;
    //上下,左右別で考える
    //L
    int nc = sc;
    rep(i,n){
        if(S[i] == 'L')nc--;
        if(nc == 0){
            cout << "NO" << endl;
            return 0;
        }
        if(T[i] == 'R' && nc != w)nc++;
    }
    //R
    nc = sc;
    rep(i,n){
        if(S[i] == 'R')nc++;
        if(nc == w+1){
            cout << "NO" << endl;
            return 0;
        }
        if(T[i] == 'L'&& nc != 1)nc--;
    }
    //U
    nc = sr;
    rep(i,n){
        if(S[i] == 'U')nc--;
        if(nc == 0){
            cout << "NO" << endl;
            return 0;
        }
        if(T[i] == 'D'&& nc != h)nc++;
    }
    //D
    nc = sr;
    rep(i,n){
        if(S[i] == 'D')nc++;
        if(nc == h+1){
            cout << "NO" << endl;
            return 0;
        }
        if(T[i] == 'U'&& nc != 1)nc--;
    }
    cout << "YES" << endl;


    return 0; 
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://agc033.contest.atcoder.jp/tasks/agc033_a

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


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

    string s; cin >> s;
    int q; cin >> q;
    bool rev_flag = false;

    list<string> str = {s};
    for (int i = 0; i < q; i++) {
        int t, f;
        string c;
        cin >> t;
        if (t == 1) {
            rev_flag = !rev_flag;
        } else {
            cin >> f >> c;
            if (rev_flag) f = (f == 1) ? 2 : 1;
            if (f == 1) {
                str.push_front(c);
            } else {
                str.push_back(c);
            }
        }
    }
    if (!rev_flag) {
        for (auto itr = str.begin(); itr != str.end(); itr++) {
            cout << *itr;
        }
    } else {
        for (auto itr = str.end(); itr != str.begin(); itr--) {
            if (itr == str.end()) continue;
            string o = *itr;
            reverse(o.begin(), o.end());
            cout << o;
        }
        cout << *str.begin();
    }
    cout << endl;




    return 0;
}



Measured memory_bytes: 16336
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define speed                   \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define ll long long
#define pb push_back
#define endl "\n"
#define mod 1000000007
#define ff first
#define ss second
#define inf 1e18
#define N 5000005
#define all(v) v.begin(), v.end()
#define sbit(a) __builtin_popcount(a)
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef pair<ll, ll> pll;
typedef pair<pll, ll> ppl;
typedef map<ll, ll> mpll;
typedef map<vector<ll>, ll> mpvl;
// vector<ll> par, rnk, dep;
// vector<vector<ll>> adj;
// vector<ll> ance;
// vector<ll> vis;
// ll sp[N][26], bp[N][20];
ll power(ll x, ll y, ll p)
{
  ll res = 1;

  x = x % p;

  if (x == 0)
    return 0;
  while (y > 0)
  {

    if (y & 1)
      res = (res * x) % p;

    y = y >> 1;
    x = (x * x) % p;
  }

  return res;
}
void spt(ll n, ll arr[], ll sp[N][26])
{
  for (ll i = 0; i < n; i++)
    sp[i][0] = arr[i];
  for (ll j = 1; j <= 25; j++)
  {
    for (ll i = 0; i + (1 << j) <= n; i++)
    {
      sp[i][j] = min(sp[i][j - 1], sp[i + (1 << (j - 1))][j - 1]);
    }
  }
}
void solve()
{

  ll n;
  cin >> n;
  vector<ll> arr(n, 0);
  for (ll i = 0; i < n; i++)
  {
    cin >> arr[i];
  }
  stack<ll> st;
  ll L[n], R[n];
  fill(L, L + n, -1);
  fill(R, R + n,n);
  for (ll i = 0; i < n; i++)
  {
    while (!st.empty() && arr[st.top()] > arr[i])
    {
      st.pop();
    }
    if (!st.empty())
      L[i] = st.top();
    st.push(i);
  }
  while (!st.empty())
    st.pop();

  for (ll i = n - 1; i >= 0; i--)
  {
    while (!st.empty() && arr[st.top()] >= arr[i])
    {

      st.pop();
    }
    if (!st.empty())
      R[i] = st.top();
    st.push(i);
  }
  ll ansmin[n];
  ll sumin=0,sumax=0;
  for(ll i=0;i<n;i++)
  {
    ansmin[i]=(i-L[i])*(R[i]-i)*arr[i];
    sumin+=ansmin[i];
  }
  cout<<sumin<<endl;
  //  while (!st.empty())
  //   st.pop();
  // fill(L, L + n, -1);
  // fill(R, R + n,n);
  // for (ll i = 0; i < n; i++)
  // {
  //   while (!st.empty() && arr[st.top()]<arr[i])
  //   {
  //     st.pop();
  //   }
  //   if (!st.empty())
  //     L[i] = st.top();
  //   st.push(i);
  // }
  // while (!st.empty())
  //   st.pop();

  // for (ll i = n - 1; i >= 0; i--)
  // {
  //   while (!st.empty() && arr[st.top()] <= arr[i])
  //   {

  //     st.pop();
  //   }
  //   if (!st.empty())
  //     R[i] = st.top();
  //   st.push(i);
  // }
  // ll ansmax[n];
  // for(ll i=0;i<n;i++)
  // {
  //   ansmax[i]=(i-L[i])*(R[i]-i)*arr[i];
  //   sumax+=ansmax[i];
  // }
  // cout<<sumax-sumin<<endl;
 
 

}

int main()
{

  speed;
  ll t;
  t = 1;
  // cin >> t;
  while (t--)
  {

    solve();
  }
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
//	cout << fixed << setprecision(15);
	int s, w;
	cin >> s >> w;
	cout << ((w >= s) ? "unsafe" : "safe") << endl;
}


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

#define REP(i, x) for (int i = 0; i < (x); i++)
#define RREP(i, x) for (int i = (x) - 1; i >= 0; i--)

using ll = long long;

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

    const int MAXN = 5010;

    static ll a[MAXN];

    REP (i, N) {
        cin >> a[i];
    }
    sort(a, a + N);

    int M = 0;
    REP (i, N) {
        if (a[i] < K) M++;
    }
    int nes = N - M;    // 必要なもの

    static int dp[5010][10010];
    const int INF = (1 << 28);

    REP (i, 5010) REP (j, 10010) dp[i][j] = INF;
    dp[0][0] = 1;
    REP (i, M) {
        REP (j, 2 * K) {
            dp[i + 1][j] = dp[i][j];
            if (j - a[i] >= 0) {
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - a[i]]);
            }
        }
    }

    REP (i, 2 * K) {
        dp[M][i] = (i >= K and dp[M][i] < INF ? i : INF);
    }

    RREP (i, M) {
        int x = INF;
        REP (j, K) {
            if (dp[i][j] >= INF) continue;
            x = min(x, dp[i + 1][j + a[i]]);
        }
        if (x - a[i] < K) nes++;

        REP (j, 2 * K) {
            dp[i][j] = dp[i + 1][j];
            if (j + a[i] < 2 * K) {
                dp[i][j] = min(dp[i][j], dp[i + 1][j + a[i]]);
            }
        }
    }

    cout << N - nes << endl;

    return 0;
}

Measured memory_bytes: 196224
import sys
import numpy as np


def main():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    seq = np.zeros(N, dtype=int)
    for _ in range(M):
        l, r = map(int, input().split())
        seq[l-1] += 1
        if r < N:
            seq[r] -= 1
    csum = np.cumsum(seq)
    ans = np.add.reduce(np.where(csum == M, 1, 0))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 15780
n=int(input())
w=[input()for i in range(n)]
isSaid=[]
safe=True
for i in w:
    if i in isSaid or (len(isSaid)>0 and isSaid[-1][-1]!=i[0]):
        safe=False
    else:
        isSaid.append(i)
if safe:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9188
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define REP(i, n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define pb(a) push_back(a)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

typedef long long unsigned int ull;
typedef long long int ll;
typedef pair<ll, ll> P;

int main()
{
    int k;
    int a,b;
    cin >> k >> a >> b;
    if(a%k==0||b%k==0){
        cout << "OK" << endl;
        //return 0;
    }else if(b/k!=a/k){
        cout << "OK" << endl;

    }else{
        cout << "NG" << endl;
    }

}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int n,x[100010],p;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i,j,k;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	  scanf("%d",&x[i]);
	sort(x+1,x+n+1);
	for(i=n,j=1;j<=x[i];i--,j++);
	i++,j--;
	if(x[i]-j&1)
	  p=1;
	for(k=i;x[k-1]>=j;k--);
	if(i-k&1)
	  p=1;
	if(p==1)
	  printf("First\n");
	else
	  printf("Second\n");
	return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
int n;
string a;
map <string,int> m;
long long ans;
int main()
{
	ios::sync_with_stdio(false);

	cin>>n;
	while(n--)
	{
		cin>>a;
		sort(a.begin(),a.end());
		m[a]++;
		ans+=m[a]-1;
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 11264
#include<bits/stdc++.h>
#define mins(a,b) a=min(a,b)
#define maxs(a,b) a=max(a,b)
using namespace std;

const long long INF=9000000000000000;
int main(){
  string s,t;
  int ans;
  bool ok=true;
  cin>>s;
  for(int i=2;i<s.size();i+=2){
    t=s.substr(0,i);
    for(int j=0;j<t.size()/2;j++){
      if(t[j]!=t[j+(t.size()/2)]){
        ok=false;
        break;
      }
      else
        ok=true;
    }
    if(ok)
      ans=t.size();
  }
  cout<<ans<<endl;
}

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

int main(){
    int A,B;
    cin >> A >> B;
    const int value_max=100000;
    for(int i=1;i<value_max;i++){
        if((int)(i*0.08)==A && (int)(i*0.10)==B){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

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

int N, K;
int H[100010];
int KK[100010];
int pKK = 0;

int main() {
    //freopen("in.txt", "r", stdin);
	scanf("%d %d", &N, &K);
	for (int i = 0; i < N; i++)
		scanf("%d", &H[i]);

	sort(H, H + N);

	for (int i = 1; i < N; i++) {
		KK[pKK++] = H[i] - H[i - 1];
	}

	//int ans;
	int Min = INT_MAX;
	for (int i = 0; i < pKK - K + 2; i++) {
		int tmp = 0;
		for (int j = i; j < K-1+i; j++) {
			tmp += KK[j];
		}
		if (tmp < Min) Min = tmp;
	}

	/*
	int l2r = 0, r2l = 0;
	for (int i = 0; i < K-1; i++) {
		l2r += KK[i];
		r2l += KK[pKK - i - 1];
	}
	ans = min(l2r, r2l);
	*/
	
	printf("%d\n", Min);
	return 0;
}

Measured memory_bytes: 1152
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int cnt = 0;
		for(int i=0;i<N-1;i++){
			if(A[i] == i+1 && A[i+1] == i+2){
				Swap(ref A[i],ref A[i+1]);
				cnt++;
			}
		}
		
		for(int i=0;i<N;i++){
			if(A[i] == i+1) cnt++;
		}
		Console.WriteLine(cnt);
		
	}
	
	void Swap<T>(ref T a, ref T b){ T tmp = a; a = b; b = tmp;}
	
	int N;
	int[] A;
	public Sol(){
		N = ri();
		A = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

int main()
{
	long long a,b,p,r,lcm;
	cin>>a>>b;
	p=a*b;
	
	do{
		r=a%b;
		a=b;
		b=r;
	}while(r!=0);
	
	lcm=p/a;
	
	cout<<lcm;
	
	return 0;
	
}

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

int G[223][223];
int dis[223];
int n;

struct st {
  int pos;
  int v;
};

int main() {
  cin >> n;
  for(int i = 1; i <= n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    for(int j = 0; j < v; j++) {
      int t;
      scanf("%d", &t);
      G[u][t] = 1;
    }
  }

  memset(dis, 0x3f, sizeof dis);

  int start = 1;
  queue<st> q;
  q.push((st) {
    1, 0
  });

  while(!q.empty()) {

    st u = q.front();
    q.pop();
    if(dis[u.pos] < 1000000) continue;

    dis[u.pos] = u.v;

    for(int i = 1; i <= n; i++) {
      if(i == u.pos) continue;
      if(G[u.pos][i] == 0) continue;
      q.push((st) {
        i, u.v + 1
      });
    }
  }

  for(int i = 1; i <= n; i++) {
    printf("%d %d\n", i, dis[i] > 100000 ? -1 : dis[i]);
  }

  return 0;
}

Measured memory_bytes: 1332
import math
MOD = 10**9 + 7

n = int(input())

array = [0] * 1000

for i in range(2, n+1):
  tmp = i
  j = 2
  while j <= math.ceil(math.sqrt(tmp)):
    if tmp % j == 0:
      while tmp % j ==0:
        array[j] += 1
        tmp //= j
    
    j += 1
      
  if tmp != 1:
    array[tmp] += 1
  
ans = 1
for v in array:
  ans = ((v+1)*ans) % MOD
  
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000+20;
const int INF = 0x3f3f3f3f;
int p[maxn], v[maxn];
int dp[20000+50];
int main()
{
    int n, m;
    while(scanf("%d %d", &m, &n)!=EOF) {
        for(int i = 1; i <= n; i++) {
            scanf("%d %d", &v[i], &p[i]);
        }
        memset(dp, INF, sizeof(dp));
        dp[0] = 0;
        for(int i = 1; i <= n; i++) {
            for(int j = v[i]; j <= 20000; j++) {
                dp[j] = min(dp[j], dp[j-v[i]] + p[i]);
            }
        }

        int maxx = dp[m];
        for(int i=m;i<=20000;i++)
        {
            if(dp[i]<maxx)maxx=dp[i];
        }
        printf("%d\n",maxx);

    }


    return 0;
}



Measured memory_bytes: 384
#define _CRT_SECURE_NO_WvNINGS
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e5 + 5;
int n, W, ans;
ll dp[N][110];
int w[110], v[110];

int main() {
    cin.sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> n >> W;
    for (int i = 1; i <= n; i++) {
        cin >> w[i] >> v[i];
    }
    for (int c = 1; c <= n; c++) {
        for (int r = 0; r < N; r++) {
            dp[r][c] = 1e15;
        }
    }

    //printf("%lld\n", dp[3191][1]);
    dp[0][1] = 0, dp[v[1]][1] = w[1];
    //printf("%lld\n", dp[3191][1]);

    for (int c = 1; c <= n; c++) {
        for (int r = 0; r < N; r++) {
            if (dp[r][c] > W)continue;
            //printf("%d %d %lld\n", c, r, dp[r][c]);
            dp[r][c + 1] = min(dp[r][c + 1], dp[r][c]);

            if(r + v[c+1] < N)
                dp[r + v[c + 1]][c + 1] = min(dp[r + v[c + 1]][c + 1], dp[r][c] + w[c+1]);
            //printf("%d %lld %lld\n", c, dp[c + 1][r], dp[c + 1][r + v[r + 1]]);
        }
    }
    for (int i = 0; i < N; i++) {
        if (dp[i][n] <= W) {
            //cout << dp[n][i] << endl;
            ans = i;
        }
    }
    cout << ans;
    return 0;
}

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

int main() {
  int x,y,z;
  cin >> x>>y>>z;
  vector<int> aaa={x,y,z};
  sort(aaa.begin(),aaa.end());
  
  
  
  
  cout << aaa.at(2)-aaa.at(0)<< endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int n;
	while (cin >> n)
	{
		long long *p = new long long[n];
		int sum = 0;
		for (int i = 0;i < n;i++)
		{
			cin >> p[i];
			sum += p[i];
		}
		int f = sum - n;
		cout << f << endl;
		delete[]p;
	}
	return 0;
}

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

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

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

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

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), "={:?} "),*), $($a),*);
    }
}

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

fn main() {
    input!{
      h: usize,
      w: usize,
    }
    let mut ans;

    // 1
    if w%3==0 {
        return println!("{}", 0);
    } else {
        ans = (h*(w/3+1)) - h*(w/3);
    }

    // 2
    if h%3==0 {
        return println!("{}", 0);
    } else {
        let a = (w*(h/3+1)) - w*(h/3);
        ans = min(ans, a);
    }

    // 3
    for w1 in 1..w {
        let a1 = w1*h;
        let h2 = h/2;
        let a2 = (w-w1) * h2;
        let h3 = h/2 + h%2;
        let a3 = (w-w1) * h3;
        let a_max = max(a1, max(a2, a3));
        let a_min = min(a1, min(a2, a3));
        ans = min(ans, a_max - a_min);
        // debug!(w1, a1, a2, a3, ans);
    }


    for h1 in 1..h {
        let a1 = h1*w;
        let w2 = w/2;
        let a2 = (h-h1) * w2;
        let w3 = w/2 + w%2;
        let a3 = (h-h1) * w3;
        let a_max = max(a1, max(a2, a3));
        let a_min = min(a1, min(a2, a3));
        ans = min(ans, a_max - a_min);
        // debug!(h1, a1, a2, a3, ans);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
import fractions
n , m = map(int,input().split())
s = input()
t = input()
l = n*m//fractions.gcd(n,m)
p = l//n
q = l//m

for i in range(10**9):
    if q*i >= n or p*i >= m:
        print(l)
        exit()
    if s[q*i] != t[p*i]:
        print(-1)
        exit()

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

int N;

int main() {
    cin >> N;
    if (N == 3) {
        cout << 2 << " " << 5 << " " << 63 << endl;
      return 0;
    }
    vector<int> S = {2, 3, 4, 9};
    if (N % 2) S.push_back(6);
    vector<pair<int, int>> A;
    for (int i = 0; 10 + 6 * i < 30000 ; i++) {
        A.push_back(make_pair(8 + 6 * i, 10 + 6 * i));
    }
    for (int i = 0; 21 + 12 * i < 30000 ; i++) {
        A.push_back(make_pair(15 + 12 * i, 21 + 12 * i));
    }
    for (int i = 0; 18 + 12 * i < 30000; i++) {
        A.push_back(make_pair(12 + 12 * i, 18 + 12 * i));
    }
    sort(A.begin(), A.end());
    
    for (int i = 0; i < A.size(); i++) {
        if (S.size() == N) break;
        S.push_back(A[i].first); S.push_back(A[i].second);
    }
    if (S.size() < N) {
      S.push_back(30000);
      S.push_back(6);
    }
    
    for (int i = 0; i < S.size(); i++) {
        cout << S[i] << " ";
    }
    cout << endl;
}


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

bool finished=false;

int main() {
 int N;
 vector<string> S(N);
 cin >> N;

  for(int i=0;i<N;i++){
    cin >> S.at(i);
  }

  int size_N1=0;


  for(int i=0;i<N;i++){
    if(i==0){
    }
    else{
      size_N1=S.at(i-1).size();
      

      for(int j=0;j<i;j++){
        if(S.at(i)==S.at(j)){
          finished=true;
          break;
        }
      }
      if(!(S.at(i-1).at(size_N1-1)==S.at(i).at(0))){
        finished=true;
      }
      if(finished){
        
        break;
      }
    }

  }

  if(finished){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }


}

Measured memory_bytes: 512
#include <cstdio>
#include <vector>
#include <string>

int main() {
  size_t N, Q;
  scanf("%zu %zu", &N, &Q);

  char buf[131072];
  scanf("%s", buf);
  std::string S = buf;

  std::vector<int> a(N+1);
  for (size_t i = 1; i < N; ++i) {
    if (S[i-1] == 'A' && S[i] == 'C') {
      ++a[i+1];
    }
  }

  for (size_t i = 1; i <= N; ++i)
    a[i] += a[i-1];

  for (size_t i = 0; i < Q; ++i) {
    size_t l, r;
    scanf("%zu %zu", &l, &r);
    printf("%d\n", a[r]-a[l]);
  }
}


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

int main(){
    int x,y;
    cin>>x>>y;

    if(4*x>=y && 2*x<=y && y%2==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

}


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

int main() {
  ll n; cin>>n;
  vector<ll> v(3*n);
  rep(i,3*n){cin>>v[i];}
  sort(v.begin(),v.end());
  ll ans=0,i=n;
  while(i<3*n-1){
    ans+=v[i];//cout<<i;
    i+=2;
  }
  cout<<ans<<endl;
} 

Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = Console.ReadLine();

            if (x[0] == x[1] &&  x[1] == x[2] || x[1] == x[2] && x[2] == x[3])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 13140
package main

import (
	"fmt"
)

func main() {
	var a, b, ans int
	fmt.Scan(&a, &b)

	if (a+b)%2 == 0 {
		ans = (a + b) / 2
	} else {
		ans = (a+b)/2 + 1
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
n, x = map(int, input().split())

p = [1]
h = [1]

for i in range(50):
    p.append(1 + p[-1] * 2)
    h.append(3 + h[-1] * 2)


def f(n, x):
    if n == 0:
        return 0 if x <= 0 else 1

    if x <= 1 + h[n - 1]:
        return f(n - 1, x - 1)

    return p[n - 1] + 1 + f(n - 1, x - 2 - h[n - 1])


print(f(n, x))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
vector<pair<ll,ll> > v[60];
ll a[60],M,dp[60][(1<<20)+5],n;
set<ll> st;
void dfs(ll x,ll p,ll y,ll j,ll idx){
	if(x==y){
		for(set<ll>::iterator i=st.begin();i!=st.end();i++)
			a[*i]|=(1<<j);
		return ;
	}
	for(int i=0;i<v[x].size();i++){
		pair<ll,ll> it=v[x][i];
		if(it.first!=p){
			st.insert(it.second);
			dfs(it.first,x,y,j,it.second);
		}
	}
	st.erase(idx);
}
ll gao(int i,ll y){
	if(i==n)return (y+1==(1<<M));
	if(dp[i][y]!=-1)return dp[i][y];
	ll res=0;
	res=gao(i+1,y|a[i])+gao(i + 1,y);
	return dp[i][y]=res;
}
int main(){
	memset(dp,-1,sizeof(dp));
	n=read();
	for(ll i=1;i<n;i++){
		ll x=read(),y=read();
		v[x].push_back({y,i});
		v[y].push_back({x,i});
	}
	M=read();
	for(ll i=0;i<M;i++){
		ll x=read(),y=read();
		dfs(x,-1,y,i,-1);
		st.clear();
	}
	cout << gao(1,0);
	return 0;
}

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

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

  for (i = 1; i <= 3; i++) {
    if (i == A || i == B) {
      continue;
    }else{
      printf("%d\n", i);
    }
  }

}


Measured memory_bytes: 256
N=int(input())
R=sorted([list(map(int,input().split(' '))) for i in range(N)])
ans = 1
now = R[0][0]+R[0][1]
for x,l in R[1:]:
    if now > x-l and now> x+l:
        now = x+l
    elif now <=x-l:
        ans += 1
        now = x+l
print(ans)

Measured memory_bytes: 28664
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;


int main() {
   

    string s,t;
    int a,b;
    string u;
    cin >> s >> t >> a >> b >> u;
    if(s == u){
        cout << a-1 << " " << b << endl;
    }else{
        cout << a << " " << b-1 << endl;
    }
}

Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	sc.Split(bufio.ScanWords)

	N, A, B := getInt(), getInt(), getInt()
	vmax := 0
	h := make([]int, N)
	for i := 0; i < N; i++ {
		h[i] = getInt()
		if vmax < h[i] {
			vmax = h[i]
		}
	}

	r := 0x7FFFFFFF
	l := 0
	diff := A - B
	for l+1 < r {
		mid := (l + r) / 2
		dmg := B * mid
		ex := mid
		f := true
		for i := 0; i < N; i++ {
			if h[i] > dmg {
				d := h[i] - dmg
				ex -= (d + diff - 1) / diff
			}
			if ex < 0 {
				f = false
				break
			}
		}
		if f {
			r = mid
		} else {
			l = mid
		}
	}

	out(r)
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    double ans = a[0];
    for (int i = 1; i < n; i++){
        ans += a[i];
        ans /= 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

using namespace std;

int main(){

    ll n,m,l;

    cin >> n >> m >> l;

    ll d[301][301] = {};

    rep(i,301){
        rep(j,301){
            d[i][j] = LLONG_MAX / 2;
            if(i == j) d[i][j] = 0;
        }
    }

    rep(i,m){
        ll a,b,c;
        cin >> a >> b >> c;

        d[a][b] = c;
        d[b][a] = c;
    }

    for(int k = 1; k <= n; k++){
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= n; j++){
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            if(d[i][j] <= l){
                d[i][j] = 1;
            }else{
                d[i][j] = LLONG_MAX / 2;
            }
        }
    }

    for(int k = 1; k <= n; k++){
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= n; j++){
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

    int q;
    cin >> q;

    rep(i,q){
        int s,t;
        cin >> s >> t;

        if(d[s][t] != LLONG_MAX /2){
            cout << d[s][t] - 1 << endl;
        }else cout << -1 << endl;
    }

    return 0;
}

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

def main():
    N, M = map(int, input().split())
    c = list(map(int, input().split()))

    dp = [i+100 for i in range(N+1)]
    dp[0] = 0

    for i in range(1, N+1):
        for t in c:
            if i - t >= 0:
                dp[i] = min(dp[i], dp[i-t] + 1)
    # print(dp)
    print(dp[N])

if __name__ == "__main__":
    main()


Measured memory_bytes: 7640
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, k float64
	fmt.Scan(&a, &b, &k)

	t := math.Min(a, k)
	a -= t
	k -= t

	t = math.Min(b, k)
	b -= t

	fmt.Printf("%d %d\n", int(a), int(b))
}


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

using namespace std;

char c[8] = {'1','2','3','4','5','6','7','8'};

int main(){
    int n,p_ = 0,q_ = 0;
    cin >> n;
    string p,q;
    for(int i = 0;i < n;i++){
        char x;cin >> x;
        p += x;
    }
    for(int i = 0;i < n;i++){
        char x;cin >> x;
        q += x;
    }
    vector<char> order(n);
    for(int i = 0;i < n;i++)order[i] = c[i];
    do{
        string s = "";
        for(int i = 0;i < n;i++){
            s += order[i];
        }
        if(s < p)p_++;
        if(s < q)q_++;
    }while(next_permutation(order.begin(),order.end()));
    cout << abs(p_ - q_);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch FaceProducesUnhappiness | diff FaceProducesUnhappiness.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address FaceProducesUnhappiness.cpp && ./a.out

/*
 
 9/7/2019
 
 5:15-
 
 */

//const int MAX_N=1e6+1;
int N,K;
string S;

int f_wrong(char c) {
  string T=S;
  vector<II> xs;
  REP(i,N) if(T[i]!=c) {
    if(i==0||T[i-1]!=T[i]) xs.emplace_back(0,i);
    if(xs.back().first==0) xs.back().first++;
    if(i!=N-1)xs.back().first+=1;
  }
  sort(ALL(xs)),reverse(ALL(xs));
  dumpc(xs);
  REP(i,min(SZ(xs),K)) {
    auto p=xs[i];
    int j=p.second;
    assert(T[j]!=c);
    while(j<N&&T[j]!=c) T[j++]=c;
  }
  int res=0;
  dump(c,T);
  REP(i,N-1) res+=T[i+1]==T[i];
  return res;
}
int f(char c) {
  string T=S;
  int cnt=0;
  REP(i,N-1) if(T[i]!=T[i+1]) ++cnt;
  if(T[N-1]!=c) ++cnt;
  cnt-=2*K;
  cnt=max(0,cnt);
  return N-1-cnt;
}
void solve() {
  int res=max(f('L'),f('R'));
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N>>K>>S;
  solve();
  
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

template< typename Monoid >
struct SegmentTree {
  using F = function< Monoid(Monoid, Monoid) >;

  int sz;
  vector< Monoid > seg;

  const F f;
  const Monoid M1;

  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }

  void set(int k, const Monoid &x) {
    seg[k + sz] = x;
  }

  void build() {
    for(int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  void update(int k, const Monoid &x) {
    k += sz;
    seg[k] = x;
    while(k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  Monoid query(int a, int b) {
    Monoid L = M1, R = M1;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) L = f(L, seg[a++]);
      if(b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }

  Monoid operator[](const int &k) const {
    return seg[k + sz];
  }
};

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    int N; cin >> N;
    VI P(N);
    int min = INF;
    int ans = 0;
    REP(i,N) {
        cin >> P[i];
        if(min > P[i]){
            ans++;
            min = P[i];
        }
    }
    cout << ans << endl;



}


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

using namespace std;

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

  int n, t;
  cin >> n >> t;
  vector<int> a(n);
  for(auto &i : a){
    cin >> i;
  }

  int ans = 0;
  int g = 0;
  vector<int> ga;
  int root = a[0];
  for(int i = 1;i < n;i++){
      if(root >= a[i]){
        root = a[i];
        continue;
      }
      if(g <= a[i] - root){
        g = a[i] - root;
        ga.push_back(g);
        ans++;
      }
  }

  for(auto i : ga){
    if(i != g)ans--;
    else break;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1276
#include<iostream> 
#include<cstdio>
using namespace std; 
int main() 
{ int a,b; while(scanf("%d%d",&a,&b)!=EOF) 
{ int x=a+b; int cnt=0; 
while(x) { cnt++; x/=10; } 
cout <<cnt<<endl;
} 
return 0; 
}

Measured memory_bytes: 1212
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}

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

  int n, l; cin >> n >> l;
  vector<int> v;
  rep(i, n) {
    v.push_back(l + i);
  }

  int sum = accumulate(all(v), int());

  int ans = 1e9;
  int INF = 1e9;

  for (int i = 0; i < n; ++i) {
    if (abs(sum - (sum - v[i])) < INF) {
      INF = abs(sum - (sum - v[i]));
      ans = sum - v[i];
    }
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, d; cin >> n >> d;
  d = 2 * d + 1;
  cout << (n + d - 1) / d << '\n';
  return 0;
}


Measured memory_bytes: 256
use std::io;
use std::cmp;
use io_ext::Reader;

fn main() {
    let stdin = io::stdin();
    let mut r = Reader::new(io::BufReader::new(stdin.lock()));
    r.read_line();
    let ds: Vec<u64> = r.read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();

    let mut sum = 0;
    
    for &d in &ds {
        sum += d;
    }

    let mut ans = 0;
    for &d in &ds {
        let rest = sum - d;
        ans += d * rest;
    }
    ans /= 2;

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

/// Extension of io module.
pub mod io_ext {
    use std::io::BufRead;

    pub struct Reader<R> {
        buf: String,
        inner: R,
    }

    impl<R> Reader<R> {
        #[inline]
        pub fn new(inner: R) -> Self {
            Reader { buf: String::new(), inner: inner }
        }

        #[inline]
        pub fn into_inner(self) -> R {
            self.inner
        }
    }

    impl<R: BufRead> Reader<R> {
        #[allow(deprecated)]
        #[inline]
        pub fn read_line(&mut self) -> &str {
            self.buf.clear();
            self.inner.read_line(&mut self.buf).unwrap_or_else(|e| panic!("{}", e));
            self.buf.trim_right()
        }
    }
}

/// Module supporting to parse strings.
pub mod parse {
    use std::str::FromStr;
    use std::borrow::Borrow;

    pub trait ParseNext: Iterator {
        fn parse_next<F: FromStr>(&mut self) -> F;
    }

    impl<'a, S: Borrow<str>, I: Iterator<Item=S>> ParseNext for I {
        fn parse_next<F: FromStr>(&mut self) -> F {
            if let Some(s) = self.next() {
                match s.borrow().parse() {
                    Ok(x) => x,
                    Err(_) => panic!("provided string cannot be parsed")
                }
            } else {
                panic!("iterator has no next element")
            }
        }
    }
}


Measured memory_bytes: 4476
n = int(input())
lst = [[-1 for _ in range(n)] for _ in range(n)]
for _ in range(n):
    c = int(input())
    for c1 in range(c):
        x, y = map(int, input().split())
        x -= 1
        lst[_][x] = y
        
ans = 0
for bit in range(2**n):
    flg = True
    for a in range(n):
        if (bit >> a) & 1:
            for x in range(n):
                if lst[a][x] != -1 and ((bit >> x) & 1) != lst[a][x]:
                  flg = False
                  break
    if flg:
        ans = max(ans, bin(bit).count('1'))
print(ans)


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

typedef long double ld;
int n;
bool vis[8];
ld crd[8][2];

ld recurse(ld dst, int vtx){
	vis[vtx] = true;
	ld cnt = 0;
	bool val = false;
	for(int i = 0; i < n; i++)
		if(!vis[i])
			val = true, cnt += recurse(dst + sqrt((crd[vtx][0] - crd[i][0]) * (crd[vtx][0] - crd[i][0]) + (crd[vtx][1] - crd[i][1]) * (crd[vtx][1] - crd[i][1])), i);
	vis[vtx] = false;
	if(!val){
		return dst;
	}
	return cnt;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for(int i = 0; i < n; i++) cin >> crd[i][0] >> crd[i][1];
    ld cnt = 0;
	for(int i = 0; i < n; i++) cnt += recurse(0, i);
	for(int i = 1; i <= n; i++) cnt /= i;
	cout << fixed << setprecision(9) << cnt << "\n";
    return 0;
}

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

#define fff(i,a,b) for(int (i)=(a);(i)<=(b);i++)
#define pb push_back()
#define len(a) (a).length()
#define all(a) (a).begin(),(a).end()
#define sz(a) (a).size()

using namespace std;

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

int dp[100000]={0};
int solve(int n,int a[])
{
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	fff(i,2,n-1)
	{
		dp[i]=min((dp[i-2]+abs(a[i-2]-a[i])),(dp[i-1]+abs(a[i]-a[i-1])));
	}
	return dp[n-1];
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	int n;
	cin>>n;
	int a[n];
	fff(i,0,n-1) cin>>a[i];
	cout<<solve(n,a)<<endl;	
	
 	return 0;
}

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

using namespace std;

int main()
{
	string s;
	int ans = 0, mx = 0;

	cin >> s;

	for(int i = 0; i < s.size(); i++)
	{
		if(s[i]=='A' or s[i]=='T' or s[i]=='C' or s[i]=='G')
		{
			ans++;

			mx = max(ans, mx);
		}
		else ans = 0;
	}

	cout << mx << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[26],b[26],n,ans;
string s,t;

int main() {
  cin >> n >> s >> t;
  for(int i=0; i<n; i++) {
    a[s[i]-'a']++;
    b[t[i]-'a']++;
  }
  sort(a,a+26);
  sort(b,b+26);
  for(int i=0; i<26; i++) ans+=max(0,b[i]-a[i]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3332
#include <iostream>
#include <vector>
using namespace std;
int main() {
  const long N = 1000000;
  vector<bool> primes(N, true);
  primes[0] = primes[1] = false;
  for (int i = 2; i * i < N; i++) {
    if (!primes[i]) continue;
    for (int j = i * i; j < N; j += i)
      primes[j] = false;
  }
  vector<long> answer(N);
  answer[0] = 0;
  for (long i = 1; i < N; i++)
    answer[i] = answer[i - 1] + primes[i];
  long n;
  while (cin >> n)
    cout << answer[n] << endl;
}

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

// "1+2-3"のような文字列の計算を行い、結果が7の時true
bool calc(string s) {
  int ans = 0;
  bool op = true;

  for (char c : s) {
    if (c == '+') {
      op = true;
    } else if (c == '-') {
      op = false;
    } else {
      if (op)
        ans += c - '0';
      else
        ans -= c - '0';
    }
  }

  return ((ans == 7) ? true : false);
}

void dfs(string s, int x, string &S, string &ans) {
  if (x == (int)S.size()) {
    if (calc(s)) ans = s;
  } else if (x > 0) {
    dfs(s + "+" + S.at(x), x + 1, S, ans);
    dfs(s + "-" + S.at(x), x + 1, S, ans);
  } else {
    // x == 0
    dfs(s + S.at(x), x + 1, S, ans);
  }
  return;
}

int main() {
  string S;
  cin >> S;

  string ans;
  dfs("", 0, S, ans);
  printf("%s=7\n", ans.c_str());
  return 0;
}


Measured memory_bytes: 256
import itertools

n = int(input())
f = [list(map(int, input().split())) for i in range(n)]
p = [list(map(int, input().split())) for i in range(n)]

max_gain = -float('inf')
for status in itertools.product([True, False], repeat=10):
    if not any(status):
        continue
    gain = 0
    for i in range(n):
        same_time_cnt = 0
        for j in range(10):
            if status[j] and f[i][j]:
                same_time_cnt += 1
        gain += p[i][same_time_cnt]
    max_gain = max(max_gain, gain)
print(max_gain)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

int main() {
    int n,k;
    cin>>n>>k;
    vector<int>h(n);
    for(int i=0;i<n;i++){
        cin>>h.at(i);
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(h.at(i)>=k){
            ans++;
        }
    }

    cout<<ans<<endl;




    return 0;
}


Measured memory_bytes: 640
import           Data.Maybe
import qualified Data.Vector.Unboxed           as V
import qualified Data.ByteString.Lazy.Char8    as BC

main = do
    n  <- readLn
    as <-
        V.fromList
        .   map (pred . fst . fromJust . BC.readInt)
        .   BC.lines
        <$> BC.getContents
    print $ fromMaybe (-1) $ V.elemIndex 1 $ V.iterateN (n+1) (as V.!) 0

Measured memory_bytes: 4348