akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    int N, K, Q;
    cin >> N >> K >> Q;

    int n[N];
    for (int i = 0; i < N; ++i) {
        n[i] = K - Q;
    }

    for (int i = 0; i < Q; ++i) {
        int add;
        cin >> add;
        n[add-1]++;
    }

    for (int i = 0; i < N; ++i) {
        if (n[i] > 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,m,c;
cin>>n>>m>>c;
int d[m];
int a[n][m],e=0,f=0;

for(int i=0;i<m;i++){
    cin>>d[i];
}

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

for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
        e=e+a[i][j]*d[j];
    }
    e=e+c;
    if(e>0)
        f++;
    e=0;
}
cout<<f;
}


Measured memory_bytes: 256
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main(){
   
    int x,t;
    cin>>x>>t;
    
    if(x>=t){
    cout<<x-t<<endl;
    }else{
        cout<<"0"<<endl;
    }
        
    return 0;
}






Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,i,m=0;
  cin>>n;
  long long a[n+1];
  for(i=1;i<=n;i++)
  cin>>a[i];
  for(i=1;i<=n;i++){
      if(i==a[a[i]])
      m++;
  }m=m/2;
  cout<<m;

  return 0;
  
}


Measured memory_bytes: 1024
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2019-12-08 23:02:03
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>

using namespace std;

using int64 = long long;
#define debug(_) cerr << #_ << ": " << (_) << '\n'
template<class T> ostream& operator<<(ostream& os, vector<T>& _) { os << '{'; for (T& x : _) { os << x; if (&x != &_.back()) os << ','; } os << '}'; return os; }
template<class T, class U> ostream& operator<<(ostream& os, pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

constexpr int MAX = 80 * 80 * 2;

bool dp[80][80][MAX + 100];
// dp[i][j][k] : (i, j) にいったときの偏りを k にできるか

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

  int h, w; cin >> h >> w;
  vector<vector<int>> a(h, vector<int>(w));
  vector<vector<int>> b(h, vector<int>(w));

  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) cin >> a[i][j];
  }

  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) cin >> b[i][j];
  }

  dp[0][0][abs(a[0][0] - b[0][0])] = 1;

  for (int i = 1; i < w; ++i) {
    int d = abs(a[0][i] - b[0][i]);
    for (int j = 0; j <= MAX; ++j) {
      dp[0][i][j] |= (dp[0][i - 1][j + d] || dp[0][i - 1][abs(j - d)]);
    }
  }

  for (int i = 1; i < h; ++i) {
    int d = abs(a[i][0] - b[i][0]);
    for (int j = 0; j <= MAX; ++j) {
      dp[i][0][j] |= (dp[i - 1][0][j + d] || dp[i - 1][0][abs(j - d)]);
    }
  }

  for (int i = 1; i < h; ++i) {
    for (int j = 1; j < w; ++j) {
      int d = abs(a[i][j] - b[i][j]);
      for (int k = 0; k <= MAX; ++k) {
        dp[i][j][k] |= (dp[i][j - 1][k + d] || dp[i][j - 1][abs(k - d)]);
        dp[i][j][k] |= (dp[i - 1][j][k + d] || dp[i - 1][j][abs(k - d)]);
      }
    }
  }

  int ans = 0;

  for (int i = 0; i <= MAX; ++i) {
    if (dp[h - 1][w - 1][i]) {
      cout << i << endl;
      return 0;
    }
  }
/*
  cerr << '\n';
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cerr << dp[i][j][0] << " ";
    }
    cerr << '\n';
  }
*/
  return 0;
}

Measured memory_bytes: 81024
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define fi first
#define se second
#define inf (INT_MAX/2-1)
#define infl (1LL<<60)
#define vi vector<int>
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) begin(a),end(a)
#define y0 y5656
#define y1 y7878
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<": "<<(x)<<'\n',aaa
#define dbga(x,n) cerr<<(#x)<<"[]: ";for(int _=0;_<n;_++)cerr<<x[_]<<' ';cerr<<'\n',aaa
#define dbgs(x) cerr<<(#x)<<"[stl]: ";for(int _:x)cerr<<_<<' ';cerr<<'\n',aaa
#define dbgp(x) cerr<<(#x)<<": "<<x.fi<<' '<<x.se<<'\n',aaa
#define maxn 200000

using namespace std;

pll v[maxn+5];///fi=coord se=health
map<ll,vector<pil> > hh;///fi=tip
///0=query, se=cat ai la pozitia aia
///1=update, se=tocmai ai iesit dintr-o zona, creste diff cu atat

ll bruh (ll a, ll b) { return a/b + (a%b > 0); }

int main () {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n; ll d, a; cin >> n >> d >> a;
  int i, j, z;
  for (i = 1; i <= n; i++) cin >> v[i].fi >> v[i].se;
  for (i = 1; i <= n; i++) hh[v[i].fi].pb({0, v[i].se});
  ///bagi updateurile ulterior
  ll ans = 0, diff = 0, cat;
  for (auto &cur: hh) {
    sort(all(cur.se), greater<pil>());
    for (pil x: cur.se) {
      if (x.fi == 0 && x.se+diff > 0) {
        cat = bruh(x.se+diff, a);
        ans += cat;
        hh[cur.fi+2*d+1].pb({1, cat*a});
        diff -= cat*a;
      } else if (x.fi == 1) diff += x.se;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 47104
#include <bits/stdc++.h>
    const int MAXN = 1000;
    const int INF = 0x3f3f3f3f;
    using namespace std;
    inline int read() {
      int x = 0, w = 1;
      char c = ' ';
      while (c < '0' || c > '9') {
        c = getchar();
        if (c == '-') w = -1;
      }
      while (c >= '0' && c <= '9') {
        x = (x << 1) + (x << 3) + (c ^ 48);
        c = getchar();
      }
      return x * w;
    }
    int n, m, ga[MAXN + 5][MAXN + 5], belong[MAXN + 5], vis[MAXN + 5], sum[2];
    bool f;
    void dfs(int u, int col) {
      if (f) return;
      belong[u] = col;
      vis[u] = true;
      ++sum[col];
      for (int i = 1; i <= n; ++i) {
        if (i != u && !ga[u][i]) {
          int v = i;
          if (!vis[v]) {
            dfs(v, col ^ 1);
          } else if (col == belong[v]) {
            f = true;
            return;
          }
        }
      }
    }
    void init() {
      n = read();
      m = read();
     
      for (int i = 1; i <= m; ++i) {
        int u = read(), v = read();
        ga[u][v] = true;
        ga[v][u] = true;
      }
    }
    bitset<705>S;
    int main() {
      init();
      S[0] = 1;
      for (int i = 1; i <= n; ++i) {
        if (!vis[i]) {
          memset(sum, 0, sizeof(sum));
          dfs(i, 0);
          S = (S << sum[0]) | (S << sum[1]);
        }
      }
      if (f) {
        puts("-1");
        return 0;
      }
      int ans = INF;
      for (int i = 0; i < n; ++i) if (S[i]) ans = min(ans, i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2);
      cout<<ans;
      return 0;
    }

Measured memory_bytes: 3072
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner st = new Scanner(System.in);
		String s = st.nextLine();
		String a = "CODEFESTIVAL2016" ;
		char[] sAr = s.toCharArray();
		char[] aAr = a.toCharArray();
		int count = 0;
		for (int i=0;i<s.length();i++){
			if((sAr[i]^aAr[i])!=0){
				count++;
			}
		}
		System.out.println(count);
	}

}

Measured memory_bytes: 10068
#pragma region
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define VPII vector<PII>
#define VPLL vector<PLL>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
#pragma endregion
//-------------------
const int MX = 100000;
int dp[MX];

int main(){
    cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15);
    int n; cin >> n;
    fill(dp+1, dp+n+1, INF);
    FOR(i,1,n) {
        for(int k=6; i-k>=0; k*=6) chmin(dp[i], dp[i-k] + 1);
        for(int k=9; i-k>=0; k*=9) chmin(dp[i], dp[i-k] + 1);
        chmin(dp[i], dp[i-1]+1);
    }
    cout << dp[n]  << endl;
    return 0;
}


Measured memory_bytes: 4048
package main

import (
	"fmt"
)

func main() {
	var a, b, k int
	fmt.Scan(&a, &b, &k)
	var cnt int
	for i := min(a, b); i >= 1; i-- {
		if a%i == 0 && b%i == 0 {
			cnt++
			if cnt == k {
				fmt.Println(i)
				return
			}
		}
	}
}

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

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

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 1764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    //freopen("in.txt","r",stdin);
    ll n,k;
    cin >> n >> k;
    ll sum =0,cnt = 0;
    int i;
    ll mul= 1,p=0;
    for(i=0;;i++){
        mul *= k;
        p++;
        if(mul > n)break;
    }
    cout << p << endl;

}


Measured memory_bytes: 256
(() -> begin
  k = readline() |> x->parse.(Int,x)
  ans = 0
  for a in 1:k
    for b in 1:k
      tmp = gcd(a, b)
      for c in 1:k
        ans += gcd(tmp, c)
      end
    end
  end
  println(ans)
end)()


Measured memory_bytes: 163524
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    int N, K;
    cin >> N >> K;
    
    vec<int> A(N);
    rep(i, N) cin >> A[i];

    for(int i=0;i<N-K;++i){
        if(A[K+i]>A[i]){
            cout << "Yes" << '\n';
        } else {
            cout << "No" << '\n';
        }
    }
}


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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);


int main(void)
{
    ll n; cin>>n;
    vector<ll> a(2*n);
    rep(i,2*n) cin>>a[i];
    sort(all(a));
    ll cnt=0;
    for(int i=0;i<2*n;i+=2){
        cnt+=min(a[i],a[i+1]);
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <utility>
#include <vector>
#include <array>
using namespace std;

#define _gp(l) const auto gcu{getchar##l}; const auto pcu{putchar##l}
#ifdef __linux
_gp(_unlocked);
#else
_gp();
#endif
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;for(char c;c=gcu(),c!=' '&&c!='\n';)s+=c;return s;}
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;if((c=gcu())=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
_T _SCAN(T &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);T t=move(in);o=move(t);return true;}}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
_HT _OUT(H &&h, T... t){out(h);out(t...);}
template <typename... T> _OUTL(T... t){out(t...);outl();}
struct range{
	int e,b=0,s=1; range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
	struct it { int v, s; it (int _v, int _s) : v(_v), s(_s) {} operator int()const{return v;} operator int&(){return v;} int operator*()const{return v;}
		it& operator++(){v+=s;return *this;} }; it begin() {return {b, s};} it end() {return {e, s};}};

int main() {
	int N {in};
	vector<array<array<int ,3>, 2>> v(N, {-1, -1, -1, -1, -1, -1});
	range r3(3);
	for (int K {in}; K; K--) {
		int A {(int)in - 1}, B {(int)in - 1};
		for (int i: r3)
			if (B != i)
				v[A][0][i] = v[A][1][i] = 0;
	}
	for (int i: r3)
		if (v[0][0][i] < 0) {
			v[0][0][i] = 1;
			v[0][1][i] = 0;
		}
	for (int i: range(1, N))
		for (int j: r3)
			if (v[i][0][j] < 0) {
				v[i][0][j] = 0;
				for (int k: r3)
					if (j != k)
						v[i][0][j] = (v[i][0][j] + v[i - 1][0][k] + v[i - 1][1][k]) % 10000;
				v[i][1][j] = v[i - 1][0][j];
			}
	int r {};
	for (int i: r3)
		r += v.back()[0][i] + v.back()[1][i];
	outl(r % 10000);
}


Measured memory_bytes: 2564
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
long nCr(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

signed main() {
	string s;
	cin >> s;
	int l = 0, r = s.size() - 1, ans = 0;
	while (l < r) {
		if (s[l] == s[r]) {
			l++; r--; continue;
		}
		elif(s[l] == 'x') {
			l++;
			ans++;
		}
		elif(s[r] == 'x') {
			r--;
			ans++;
		}
		else {
			cout << -1 << endl; ggr
		}
	}
	cout << ans << endl;ggr
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1e5;
//typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
int main(){
  int n;  cin >> n;
  vector<int> v(n);
  int cnt2=0, cnt4=0, other=0;
  rep(i,0,n){
    cin >> v[i];
    if(v[i]%4==0) cnt4++;
    else if(v[i]%2==0) cnt2++;
    else other++;
  }
  other += cnt2%2;
  string s="";
  if(other-1<=cnt4) s="Yes";
  else s="No";
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 640
s = input()

tens = 1
mod = 2019

rests = [0 for i in range(len(s))]

for i in range(len(s)):
    if i == 0:
        rests[-(i+1)] = int(s[-(i+1)])
    else:
        rests[-(i+1)] = (rests[-i] + (tens * int(s[-(i+1)]))) % mod

    tens *= 10
    tens = tens % mod

dic = {}
for i in range(len(rests)):
    if dic.get(rests[i], None) is None:
        dic[rests[i]] = 1
    else:
        dic[rests[i]] += 1

ans = 0

for k in dic:
    if k == 0:
        ans += dic[k]
        ans += dic[k] * (dic[k] - 1) // 2

    elif dic[k] > 1:
        ans += (dic[k] * (dic[k] - 1)) // 2

print(ans)


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

int main(){
  int f=0,s=0;
  for(int i=0;i<3;i++){
    int a;
    cin >> a;
    if(a==5)f++;
    if(a==7)s++;
  }
  cout << (f==2 && s==1 ? "YES":"NO") << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int C,D,W,X;
int E_table[15][30],F_table[15][30];
int dp[31][51][6];

bool rangeCheck(int area){
	if(area >= 0 && area <= C-1){
		return true;
	}else{
		return false;
	}
}


void func(){

	for(int area = 0; area < C; area++){
		for(int day = 0; day < D; day++)scanf("%d",&E_table[area][day]);
	}

	for(int area = 0; area < C; area++){
		for(int day = 0; day < D; day++)scanf("%d",&F_table[area][day]);
	}

	for(int day = 0; day <= D; day++){
		for(int futan = 0; futan <= W; futan++){
			for(int num = 0; num <= X; num++){
				dp[day][futan][num] = -1;
			}
		}
	}

	dp[0][0][0] = 0;

	int ans = 0;
	bool FLG;
	int tmp_futan,tmp_E;

	for(int day = 0; day <= D-1; day++){
		for(int futan = 0; futan <= W; futan++){
			for(int num = 0; num <= X; num++){
				if(dp[day][futan][num] == -1)continue;

				dp[day+1][futan][num] = max(dp[day+1][futan][num],dp[day][futan][num]);

				for(int area = 0; area <= C-1; area++){
					if(E_table[area][day] == 0 || futan+F_table[area][day] > W)continue;

					dp[day+1][futan+F_table[area][day]][num] = max(dp[day+1][futan+F_table[area][day]][num],dp[day][futan][num]+E_table[area][day]);
					ans = max(ans,dp[day+1][futan+F_table[area][day]][num]);

					if(num == X)continue;

					for(int count = 2; area+count <= C; count++){
						FLG = true;
						tmp_futan = 0;
						tmp_E = 0;
						for(int i = 0; i < count; i++){
							if(rangeCheck(area+i) == false || E_table[area+i][day] == 0){
								FLG = false;
								break;
							}
							tmp_futan += F_table[area+i][day];
							tmp_E += E_table[area+i][day];
						}

						if(FLG == false || futan+tmp_futan > W)continue;

						dp[day+1][futan+tmp_futan][num+1] = max(dp[day+1][futan+tmp_futan][num+1],dp[day][futan][num]+tmp_E);
						ans = max(ans,dp[day+1][futan+tmp_futan][num+1]);
					}
				}
			}
		}
	}

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

int main(){

	while(true){
		scanf("%d %d %d %d",&C,&D,&W,&X);
		if(C == 0 && D == 0 && W == 0 && X == 0)break;

		func();
	}

	return 0;
}

Measured memory_bytes: 3172
#include <string>
#include <bits/stdc++.h>
#include <stdio.h>
#include<math.h>
#include <ctype.h>
using namespace std;

int main() {
  int n,m;
  cin >> n >> m;
  vector<int> vec(m);
  for(int i=0;i<m;i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  vector<int> t(m-1);
  for(int i=0;i<m-1;i++){
    t.at(i)=vec.at(i+1)-vec.at(i);
  }
  sort(t.begin(),t.end());
  int sum=0;
  
  
  for(int i=0;i<m-n;i++){
    sum=sum+t.at(i);
  }
  cout << sum << endl;
}
 


Measured memory_bytes: 1024
S = gets.chomp
N = S.size
if N < 26
  puts S + ([*?a..?z] - S.chars).first
else
  (N-1).downto(0) do |i|
    c = S[i]
    next_c = (c.succ..?z).find do |d|
      !S[0..i][d]
    end
    if next_c
      puts S[0...i] + next_c
      exit
    end
  end
  puts -1
end



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

#define TASKNAME ""

using namespace std;

const int INF = 1e9 + 7;
const int MAXN = 1e6 + 7;
const double EPS = 1e-8;

int main() {
    #ifdef MY
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #else
        //freopen(TASKNAME".in", "r", stdin);
        //freopen(TASKNAME".out", "w", stdout);
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
    #endif // MY
    int n, k;
    cin >> n >> k;
    ll res = 0;
    for (int i = 0; i < k; i++) {
        int j = k - i;
        if (2 * i % k != 0) continue;
        ll ci = n / k, cj = n / k;
        if (n % k >= (i ? i : k)) {
            ci++;
        }
        if (n % k >= j) {
            cj++;
        }
        //cout << i << " " << j << " " << ci << " " << cj << "\n";
        res += ci * cj * ci;
    }
    cout << res;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[100][100];
int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cin >> a[i][j];
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			int sum = 0;
			for (int k = 1; k <= m; k++) {
				sum += (a[i][k] - a[j][k]) * (a[i][k] - a[j][k]);
			}
			int t = sqrt(sum);
			if (t * t == sum) {
				ans++;
			}
		} 
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

n = int(input())
j = 0
for i in range(n):
    a, b = map(int, input().split())
    if a==b:
        j+=1
    else:
        j = 0

    if j>=3:
        break

if j >= 3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9172
import java.util.Scanner;

public class Main{
	static final int N = 8;
	static int[] row = new int[N];
	static int[] col = new int[N];
	static int[] dpos = new int[2 * N - 1];
	static int[] dneg = new int[2 * N - 1];
	static boolean[][] X = new boolean[N][N];
	static final int FREE = -1;
	static final int NOT_FREE = 1;
	public static void main(String[] args) {
		initialize();
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int[] r = new int[k];
		int[] c = new int[k];
		for(int i = 0; i < k; i++) {
			r[i] = sc.nextInt();
			c[i] = sc.nextInt();
		}
		sc.close();

		for(int i = 0; i < N; i++) {
			for(int j = 0; j < N; j++) {
				X[i][j] = false;
			}
		}
		for(int i = 0; i < k; i++) {
			X[r[i]][c[i]] = true;
		}
		rec(0);
	}
	static void initialize() {
		for(int i = 0; i < N; i++) {
			row[i] = FREE;
			col[i] = FREE;
		}
		for(int i = 0; i < 2 * N - 1; i++) {
			dpos[i] = FREE;
			dneg[i] = FREE;
		}
	}
	static void printBoard() {
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < N; j++) {
				if(X[i][j]) {
					if(row[i] != j) return;
				}
			}
		}
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < N; j++) {
				if(row[i] == j) {
					System.out.print("Q");
				}else {
					System.out.print(".");
				}
			}
			System.out.println();
		}
	}
	static void rec(int i) {
		if(i == N) {
			printBoard();
			return;
		}
		for(int j = 0; j < N; j++) {
			if(col[j] == NOT_FREE || dpos[i + j] == NOT_FREE || dneg[i - j + N - 1] == NOT_FREE) {
				continue;
			}
			row[i] = j;
			col[j]=dpos[i+j]=dneg[i-j+N-1]=NOT_FREE;
			rec(i + 1);
			row[i]=col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
		}
	}
}


Measured memory_bytes: 26456
A, B = gets.chomp.split(" ").map(&:to_i)

x = A / 0.08
y = B / 0.1
i = 1

if x <= y 
    z = y.ceil
    if (z * 0.08).floor == A
        puts z
    elsif 
        while i < 13 do 
            if ((z + i)* 0.08).floor == A && ((z + i)* 0.1).floor == B
                puts (z + i)
            end
            i += 1
        end
    else
        puts -1
    end
    else
    z = x.ceil
    if (z * 0.1).floor == B
      puts z
    elsif 
        while i < 10 do 
        if ((z + i)* 0.1).floor == B && ((z + i)* 0.08).floor == A
            puts (z + i)
        end
        i += 1
    end
    else
        puts -1
    end
    end


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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

int main() {
  ll n, k;
  cin >> n >> k;

  ll d = 60;
  vector<vector<ll>> to(d, vector<ll>(n));
  for (ll i = 0; i < n; ++i) {
    cin >> to[0][i];
    to[0][i]--;
  }

  for (ll i = 1; i < d; ++i) {
    for (ll j = 0; j < n; ++j) {
      to[i][j] = to[i-1][to[i-1][j]];
    }
  }

  ll ans = 0;
  for (ll i = d-1; i >= 0; --i) {
    ll x = 1ll<<i;
    if (x <= k) {
      ans = to[i][ans];
      k -= x;
    }
  }

  cout << ans+1 << endl;

  return 0;
}


Measured memory_bytes: 98564
a, b = map(int, input().split())
i, j = 1, 1
cnt = 0
for i in range(1, a + 1):
    d = 0
    if i == a:
        d = b
    else:
        d = 31
    for j in range(1, d + 1):
        if i == j:
            cnt += 1
print(cnt)


Measured memory_bytes: 2940
class UnionFind():
  def __init__(self, n=10**6):
    self.n = n
    self.root = [-1]*(n+1)
    self.rnk = [0]*(n+1)
  def find(self, x):
    if(self.root[x] < 0):
      return x
    else:
      self.root[x] = self.find(self.root[x])
      return self.root[x]
  def unite(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if(x == y):return 
    elif(self.rnk[x] > self.rnk[y]):
      self.root[x] += self.root[y]
      self.root[y] = x
    else:
      self.root[y] += self.root[x]
      self.root[x] = y
      if(self.rnk[x] == self.rnk[y]):
        self.rnk[y] += 1
  def same(self, x, y):
    return self.find(x) == self.find(y)
  def count(self, x):
    return -self.root[self.find(x)]
uf=UnionFind()
n=int(input())
for _ in range(n-1):
  u,v,w=map(int,input().split())
  if w%2:
    uf.unite(2*u,2*v-1)
    uf.unite(2*u-1,2*v)
  else:
    uf.unite(2*u,2*v)
    uf.unite(2*u-1,2*v-1)
f=uf.find(2*1)
for i in range(1,n+1):
  print(int(uf.find(2*i)==f))

Measured memory_bytes: 100196
#include <iostream>
#include <cstdio>
using namespace std;
const long long mod = 1e9+7;
long long n, m;
int main(){
	long long i, j, k;
	cin >> n >> k;
	long long m = (((k + 1) * k) / 2) % mod;
	long long p = ((k * (k - 1)) / 2) % mod;
	long long a[n];
	for(i = 0; i < n; ++i)scanf("%lld",&a[i]);
	long long cnt = 0;
	for(i = 0; i < n; ++i){
		long long sum = 0;
		long long ans = 0;
		for(j = i + 1; j < n; ++j){
			if(a[i] > a[j])++sum;
		} 
		sum %= mod;
		cnt += (sum * (m % mod)) % mod;
		for(j = i - 1; j >= 0; --j){
			if(a[i] > a[j])++ans;
		}
		ans %= mod;
		cnt += (ans * (p % mod)) % mod;
	}
	cout << cnt % mod << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define MOD 1000000007
#define MAX 300000
using ll = long long;
using namespace std;

ll kaijo[MAX + 1];
ll gyaku[MAX + 1];

ll myPow(ll a, ll b) {
	ll res = 1;
	while (b) {
		if (b & 1) {
			res = (res * a) % MOD;
		}
		a = (a * a) % MOD;
		b >>= 1;
	}
	return res;
}

ll C(ll n, ll k) {
	return min(k, n - k) >= 0 ? kaijo[n] * gyaku[k] % MOD * gyaku[n - k] % MOD : 0;
}

int main()
{
	kaijo[0] = gyaku[0] = 1;
	for (int i = 1; i <= MAX;i++) {
		kaijo[i] = (kaijo[i - 1] * i) % MOD;
		gyaku[i] = myPow(kaijo[i], MOD - 2);
	}
	ll N, M, K, res = 0;
	cin >> N >> M >> K;
	for (ll i = 0; i <= K; i++) {
		res = (res + (C(N + M + K * 2, M + i * 2) * ((C(M + i * 2, i) + MOD - C(M + i * 2, i - 1)) % MOD) % MOD * ((C(N + (K - i) * 2, K - i) + MOD - C(N + (K - i) * 2, K - i - 1)) % MOD) % MOD)) % MOD;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 7800
#include<iostream>
#include<queue>
#include<utility>
#include<algorithm>
using namespace std;
typedef pair<int,int> P;

int main(){   
    int n,m;
    cin >> n >> m;
    P b[n];
    for(int i=0;i<n;i++){
        int x;
        cin >> b[i].first >> x;
        b[i].second=-x;
    }
    sort(b, b+n);

    int ans=0;
    priority_queue<int> que;
    int cur=0;
    for(int i=1;i<=m;i++){
        while(cur<n && b[cur].first<=i) que.push(-b[cur].second), cur++;
        if(!que.empty()) ans+=que.top(), que.pop();
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1660
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#define MAX 200010
#define inf 2000000000
int A[MAX],n;
int l[MAX/2+10],r[MAX/2+10];
long long int cnt=0;
void merge(int left,int mid,int right)
{
	int i,Lstart=1,Rstart=1,rn=0;
	int n1=mid-left;
	int n2=right-mid;
	for(i=1;i<=n1;i++)
		l[i]=A[left+i-1];
	for(i=1;i<=n2;i++)
		r[i]=A[mid+i-1];
	l[n1+1]=inf;
	r[n2+1]=inf;
	for(i=left;i<=right-1;i++)
	{
		if(l[Lstart]<=r[Rstart])
		{
			A[i]=l[Lstart];
			Lstart++;
			cnt+=rn;
		}
		else
		{
			A[i]=r[Rstart];
			Rstart++;
			rn++;
		}
	}
	return;
}
void mergesort(int left,int right)
{
	if(left+1>=right)
		return;
	int mid=(left+right)/2;
	mergesort(left,mid);
	mergesort(mid,right);
	merge(left,mid,right);
	return;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&A[i]);
	mergesort(1,n+1);
	printf("%lld\n",cnt);
	return 0;
}


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

int main() {
  int n;
  cin>>n;
  string w[n];
  for (int i=0; i<n; i++) cin>>w[i];
  for (int i=0; i<n-1; i++) {
    int l = w[i].length();
    if (w[i][l-1] != w[i+1][0]) {
      cout<<"No"<<endl;
      return 0;
    }
  }
  for (int i=0; i<n; i++) {
    for (int j=i+1; j<n; j++) {
      if (w[i] == w[j]) {
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
 
const int N = 1e5 + 5;


int32_t main()
{
   IOS;
   int n;
   int a=0,b=0,c=0,d=0;
   //vector<string> s;
   cin >> n;

   for(int i=0; i<n; i++)
   {
   		string s;
         cin >> s;

   		if(s=="AC")
   			a++;
   		else if(s=="WA")
   			b++;
   		else if(s=="TLE")
   			c++;
   		else if(s=="RE")
   			d++;


   }

   cout << "AC x " << a << endl;
   cout << "WA x " << b << endl;
   cout << "TLE x " << c << endl;
   cout << "RE x " << d << endl;

   


   return 0;
}
 

Measured memory_bytes: 3652
while True:
    counter = 0
    n,x = map(int,input().split())
    if n == x == 0:
        break
    else:
        for i in range(1,n+1):
            for j in range(1,n+1):
                for k in range(1,n+1):
                    if i + j + k == x and i != j and j != k and k != i:
                        counter += 1
        print(int(counter/6))


Measured memory_bytes: 5592
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int main(void)
{
  int N;
  cin >> N;
  cout << lcm(2, N) << endl;
  return 0;
}


Measured memory_bytes: 256
S = input()
y = int(S[0:4])
m = int(S[5:7])
d = int(S[8:10])
if y > 2019:
  print ("TBD")
elif y == 2019:
  if m > 4:
    print ("TBD") 
  else:
    print ("Heisei")
else:
  print ("Heisei")

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){

  int N;
  cin>>N;
  vector<long long>A(N);
  long long allsum=0;
  for(int i=0;i<=N-1;i++){
  
    cin>>A[i];
    allsum+=A[i];
  }
  long long ans=allsum;
  long long check=0;
  for(int i=0;i<=N-1;i++){
  
    check+=A[i];
    allsum-=A[i];
    if(ans>abs(check-allsum))ans=abs(check-allsum);
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 4744
#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.at(i);
  A.insert(A.begin(), 0);
  A.insert(A.end(), 0);
  N += 2;
  int sum = 0;
  for (int i = 1; i < N; i++) {
    sum += abs(A.at(i - 1) - A.at(i));
  }
  for (int i = 1; i + 1 < N; i++) {
    int tmp1 = abs(A.at(i - 1) - A.at(i)) + abs(A.at(i + 1) - A.at(i));
    int tmp2 = abs(A.at(i - 1) - A.at(i + 1));
    cout << sum - tmp1 + tmp2 << "\n";
  }
}

Measured memory_bytes: 4048
#include<stdio.h>

int main(){
  int a,b,c=0,d=0,x=0,N;
  N = 499500;
  scanf("%d",&a );
  scanf("%d",&b );
  for (int i=1;i<N;i++){
    c += i;
    d = c + i + 1;
    if(c-a == d-b){
      x = c-a;
      break;
    }
    else continue;
  }

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

Measured memory_bytes: 128
import math

a,b,H,M=map(int,input().split())

theta_a = math.pi/6 * (H+M/60)
theta_b = math.pi*2*M/60

theta = abs(theta_a - theta_b)

ans = math.sqrt(a**2 + b**2 - 2*b*a*math.cos(theta))

print(ans)

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


//SHORTCUTS

#define ll long long
#define endl '\n'
#define i1(a) cin>>a
#define i2(a,b) cin>>a>>b
#define i3(a,b,c) cin>>a>>b>>c
#define o1(a) cout<<a<<endl
#define o2(a,b) cout<<a<<" "<<b<<endl
#define o3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define f(i,a,b) for(int i = a;i<b;i++)
#define fe(i,a,b) for(int i = a;i<=b;i++)
#define fi(i,a,b) for(i=a;i<b;i++)
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair


// DEBUG CODE & FAST OUTPUT

#define printv(a) for (int i = 0; i < a.size(); i++) cout << a[i] << ' ';
#define printvl(a) for (int i = 0; i < a.size(); i++) cout << a[i] << endl;
#define printa(a, n) for (int i = 0; i< n; i++) cout << a[i] << ' ';
#define printal(a, n) for (int i = 0; i < n; i++) cout << a[i] << endl;


//DATA STRUCTURES

#define pq priority_queue
#define ms multiset
// #define y0 _y0_
// #define y1 _y1_
// #define div divi

typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;

//IMP CONSTANT
const int mod = 1e9 + 7, inf = 1e9 + 7;
const ll infll = 1e18 + 7;
bool google_contest = false;


//MODULAR OPERATIONS
ll myadd(ll a,ll b){
    ll ans = a+b;
    ans-= ans>=mod ? mod : 0;
    return ans; 
}
ll mysub(ll a, ll b){
    return (a-b+mod)%mod;
}
ll mymul(ll a,ll b){
    return (a*b)%mod;
}
ll mypow(ll a, ll b){
    ll ans = 1;
    while(b>0)
        if(b&1) ans = mymul(ans,a),b--;
        else a = mymul(a,a),b >>= 1;
    return ans;
}
ll nCr(ll n,ll r){
    if(r==0)return 1;
    if(r==1)return n;
    if(n==0)return 0;
    return mymul(n,mymul(nCr(n-1,r-1),mypow(r,mod-2)));
}

//    /\    |  |\  /|                      
//   /__\   |  | \/ |           
//  /    \  |  |    | 

vvi graph;
vi ans;

void bfs(int s){
    ans[s] = 0;
    queue<int> q;
    q.push(1);
    while(!q.empty()){
        int c = q.front();
        q.pop();
        for(auto i : graph[c]){
            if(ans[i]!=-1)continue;
            ans[i] = c;
            q.push(i);
        }
    }
}
int main(){

ios_base::sync_with_stdio(0);
cin.tie(0); 
cout.tie(0);

int t,tt;
t=1;
// i1(t);
if(google_contest)tt=1;

while(t--){
int n,m;
i2(n,m);

graph.assign(n+1, vi());
f(i,0,m){
    int a,b;
    i2(a,b);
    graph[a].pb(b);
    graph[b].pb(a);
}

ans.assign(n+1,-1);
bfs(1);

bool ok = true;

f(i,2,n+1)if(ans[i]==-1)ok=false;
if(!ok){
    o1("No");
    continue;
}
o1("Yes"); 
f(i,2,n+1){
    o1(ans[i]);
}

if(google_contest){
    cout<<"Case "<<tt++<<": ";
}
}

return 0;   
}


//    /\    |  |\  /|                      
//   /__\   |  | \/ |           
//  /    \  |  |    |   OVER!!!!


Measured memory_bytes: 10052
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<queue>
#define FOR(i,l,r) for(register int i=(l),i##R=(r);i<=i##R;i++)
#define DOR(i,r,l) for(register int i=(r),i##L=(l);i>=i##L;i--)
#define loop(i,n) for(int i=0,i##R=(n);i<i##R;i++)
#define mms(a,x) memset(a,x,sizeof a)
#define pii pair<int,int>
#define fi first
#define se second
using namespace std;
typedef long long ll;
template<typename A,typename B>inline void chkmax(A &x,const B y){if(x<y)x=y;}
template<typename A,typename B>inline void chkmin(A &x,const B y){if(x>y)x=y;}
int n,D;
int main(){
	scanf("%d%d",&n,&D);
	printf("%d\n",n/(D+D+1)+(n%(D+D+1)!=0));
	return 0;
}

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

#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...) void()
#endif

using namespace std;

mt19937 rng(58);

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  using namespace chrono;
  auto start = system_clock::now();
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (auto&& e : a) {
    cin >> e;
  }
  for (auto&& e : b) {
    cin >> e;
  }
  reverse(b.begin(), b.end());
  bool ok = false;
  auto end = system_clock::now();
  double time = duration_cast<milliseconds>(end - start).count();
  while (time < 1950) {
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] == b[i]) {
        swap(b[i], b[rng() % n]);
        cnt++;
      }
    }
    if (cnt == 0) {
      ok = true;
      break;
    }
    end = system_clock::now();
    time = duration_cast<milliseconds>(end - start).count();
  }
  if (ok) {
    cout << "Yes" << '\n';
    for (int i = 0; i < n; i++) {
      cout << b[i] << (i == n - 1 ? '\n' : ' ');
    }
  } else {
    cout << "No" << '\n';
  }
  return 0;
}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  
  bool ok = false;
  rep(i,N){
    cin >> A[i];
    if(A[i] == K){
      ok = true;
    }
  }
  if(ok) cout << "POSSIBLE" <<endl;
  else{
  	sort(A.begin(),A.end(),greater<ll>());
    if(A[0]<K) cout << "IMPOSSIBLE" << endl;
    else{
      int g=A[0];
      rep(i,N-1){
        g=gcd(g,A[i+1]);
      }
      if(g == 1) cout << "POSSIBLE" <<endl;
      else if(gcd(g,K) == 1) cout << "IMPOSSIBLE" << endl;
      else cout << "POSSIBLE" <<endl;
    }
  }
}
  



Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>

#define REP(i,x,y) for(int i=(int)(x);i<(int)(y);i++)
#define RREP(i,x,y) for(int i=(int)(x);i>(int)(y);i--)
#define all(x) (x).begin(),(x).end()

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

typedef long long ll;

using namespace std;

int X, A, B;

string solve() {
    string ans;
    if(B - A <= 0) ans = "delicious";
    else if(B - A <= X) ans = "safe";
    else ans = "dangerous";
    return ans;
}

int main() {
    // to shorten execution time for iostream
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> X >> A >> B;
    cout << solve() << "\n";
    return 0;
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))

minus = 0
for i in range(N):
    if a[i] < 0:
        minus += 1

for i in range(N):
    a[i] = abs(a[i])
if minus % 2 == 0:
    print(sum(a))
else:
    print(sum(a)-2*min(a))


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

using namespace std;

typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<vector<long long>>> vvvll;

vvvll memo(55, vvll(2550, vll(55, -1)));


long long dp(int i, long long sum, int elements, int A, vector<int> arr) {
  long long ans;
  if(i == (arr.size()-1)){
    if(elements == 0)
      memo[i][sum][elements] = 0;
    else
      memo[i][sum][elements] = (sum/(float)elements == A)? 1 : 0;
    //cout<<"i:"<<i<<" sum:"<<sum<<" el:"<<elements<<" ans:"<<memo[i][sum][elements]<<endl;
    return memo[i][sum][elements];
  }
  
  if (memo[i+1][sum][elements] == -1)
    memo[i+1][sum][elements] = dp(i+1, sum, elements, A, arr);
  
  if (memo[i+1][sum+arr[i+1]][elements+1] == -1)
    memo[i+1][sum+arr[i+1]][elements+1] = dp(i+1, sum+arr[i+1], elements + 1, A, arr);

  ans = memo[i+1][sum][elements] + memo[i+1][sum+arr[i+1]][elements+1];
  //cout<<"i:"<<i<<" sum:"<<sum<<" el:"<<elements<<" ans:"<<ans<<endl;
  return ans;  
}

int main(){
  int N, A;
  cin>>N>>A;
  vector<int> arr(N);
  for(int i=0; i<N; i++)
    cin>>arr[i];
  cout<<dp(-1,0,0,A,arr)<<endl;
  return 0;
}


Measured memory_bytes: 66176
##!/usr/bin/env python3
import sys
# from operator import itemgetter
# gcd
# from fractions import gcd
# 切り上げ，切り捨て
# from math import ceil, floor
# リストの真のコピー（変更が伝播しない）
# from copy import deepcopy
# 累積和。list(accumulate(A))としてAの累積和
# from itertools import accumulate
# l = ['a', 'b', 'b', 'c', 'b', 'a', 'c', 'c', 'b', 'c', 'b', 'a']
# S = Counter(l)  # カウンタークラスが作られる。S=Counter({'b': 5, 'c': 4, 'a': 3})
# print(S.most_common(2))  # [('b', 5), ('c', 4)]
# print(S.keys())  # dict_keys(['a', 'b', 'c'])
# print(S.values())  # dict_values([3, 5, 4])
# print(S.items())  # dict_items([('a', 3), ('b', 5), ('c', 4)])
# from collections import Counter
# import math
# from functools import reduce
#
# # input関係の定義
# fin = open('in_2.txt', 'r')
# sys.stdin = fin
# # 提出時はコメントアウト+上のshebangを有効にする
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


def iterate_tokens():
    for line in sys.stdin:
        for word in line.split():
            yield word


if __name__ == '__main__':

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    L = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"

    # write code
    tmp = 1
    D = 0
    i = 0
    if sum(L) <= X:
        print(N + 1)
        sys.exit()
    while True:
        D += L[i]
        i += 1
        tmp += 1
        if D > X:
            break
    print(tmp-1)



Measured memory_bytes: 38384
object Main {
  def main(args: Array[String]): Unit = {
    val Array(x, y, _*) = io.StdIn.readLine().split(" ").map(_.toInt)
    println(gcd(x, y))
  }

  @annotation.tailrec
  def gcd(x: Int, y: Int): Int = {
    if (y == 0)
      x
    else if (x > y)
      gcd(y, x % y)
    else
      gcd(x, y % x)
  }
}

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

int main() {
  while (1) {
    string s;
    cin >> s;

    if (s == "-") break;

    int m;
    cin >> m;

    for (int i = 0; i < m; i++) {
      int h;
      cin >> h;

      string sub = s.substr(0, h);
      s.erase(0, h);
      s = s + sub;
    }

    cout << s << endl;
  }

  return 0;
}



Measured memory_bytes: 3144
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N;
		N = sc.nextInt();
		int A=0;
		for(int i=0;i<N;++i) {
			A |= sc.nextInt();
		}
		System.out.println(Integer.numberOfTrailingZeros(A));
	}
}


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

int table[10000001] = {}; // 0だったら素数

int main()
{
  int n;
  table[1] = 1;
  table[0] = 1;
  for(int i = 2;i < 10000001;++i){
    if(table[i]) continue;
    for(int j = i + i;j < 10000001;j += i){
      table[j] = 1;
    }
  }

  /*
  for(int i = 0;i < 20;++i){
    cout << i << ':' << table[i] << endl;
  }
  */

  while(1){
    cin >> n;
    if(n == 0) break;
    
    for(;n > 1;--n){
      if(!table[n] && !table[n - 2] && !table[n - 6] && !table[n - 8]){
	cout << n << endl;
	break;
      }
    }
  }

  return 0;
}



Measured memory_bytes: 42148
#include<cstdio>
#include<cctype>
#define For(i,j,k) for(int i=j;i<=k;++i)
using namespace std;
int read(){
	int l=1,x=0; char ch=getchar();
	while(!isdigit(ch)) {if (ch=='-') l=-1; ch=getchar();}
	while(isdigit(ch)) x=x*10+(ch^48),ch=getchar();
	return x*l;
}
char ch;
void gchar(){
	ch=getchar();
	while(ch<'a'||ch>'z') ch=getchar();
}
int main(){
	int k,fl=0,n=read(),m=read(),a[27]={0},s1=0,s2=0;
	For(i,1,n)
		For(j,1,m) gchar(),a[ch-96]++;
	if (n%2==0) fl++; if (m%2==0) fl++;
	For(i,1,26){
		if (a[i]%2==1) s1++;
		else if (a[i]%4==2) s2++;
	}
	if (!fl){
		if (s1>1||s2*2>n+m-2) printf("No");
		else printf("Yes");
	}
	else if (fl==1){
		if (n%2==0) k=n; else k=m;
		if (s1||s2*2>k) printf("No");
		else printf("Yes");
	}
	else{
		if (s1||s2) printf("No");
		else printf("Yes");
	}
	//printf("\n%d %d\n",s1,s2);
	return 0;
}

Measured memory_bytes: 128
void main(){
	int m = _scan();
	writeln(48-m);
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


Measured memory_bytes: 2656
s = list(map(int,input().split()))
N = s[0]
W = s[1]

v=[]
w=[]
for i in range(N):
    x = list(map(int,input().split()))
    v.append(x[0])
    w.append(x[1])

dp=[[0 for i in range(W+1)] for j in range(N+2)] #initialize DP

for i in range(W+1):
    dp[0][i]=i

#print(dp)

for i in range(2,N+2):#i(row) derection:-2
    for j in range(W+1):
        if j<w[i-2]:
            dp[i][j]=dp[i-1][j]
        else:
            x1=dp[i-1][j]
            x2=dp[i-1][j-w[i-2]]+v[i-2]
            dp[i][j]=max([x1,x2])

#print(dp)
print(dp[N+1][W])



Measured memory_bytes: 26328
# https://atcoder.jp/contests/dp/tasks/dp_d

def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

N, W = MAP()
w, v = [], []
for _ in range(N):
    wi, vi = MAP()
    w.append(wi)
    v.append(vi)

DP = [[0] * (N+1) for _ in range(W+1)]

for i in range(1, W+1):
    for j in range(1, N+1):
        if i < w[j-1]:
            DP[i][j] = max(
                DP[i][j-1],
                DP[i-1][j])
        else:
            DP[i][j] = max(
                DP[i][j-1],
                DP[i-w[j-1]][j-1] + v[j-1],
                DP[i-1][j])

print(DP[-1][-1])






Measured memory_bytes: 130652
s = " " + input()
t = " " + input()

dp = [[0 for _ in range(len(t))] for _ in range(len(s))]

for i in range(1, len(s)):
    for j in range(1, len(t)):
        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - 1] + (1 if s[i] == t[j] else 0))

i = len(s) - 1
j = len(t) - 1
c = 0
ans = []
ansl = dp[-1][-1]
while (c < ansl):
    if s[i] == t[j]:
        ans.append(s[i])
        i -= 1
        j -= 1
        c += 1
    else:
        if dp[i - 1][j] > dp[i][j - 1]:
            i -= 1
        else:
            j -= 1
ans.reverse()
print("".join(ans))

Measured memory_bytes: 120284