akhauriyash/Code-Regression huggingface dataset:
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数（Greatest Common Divisor）
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数（Least Common Multiple）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

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

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//コードはここから書く.

	int A, B;
	string ans = "Draw";
	cin >> A >> B;

	if (A < B)
		ans = "Bob";
	else if (B < A)
		ans = "Alice";
	if (A == 1)
		ans = "Alice";
	else if (B == 1)
		ans = "Bob";
	if (A == 1 && B == 1)
		ans = "Draw";

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> A(n); rep(i, n) cin >> A[i];
  vector<ll> B(n); rep(i, n) cin >> B[i];
  ll sumA = accumulate(all(A), 0LL);
  ll sumB = accumulate(all(B), 0LL);
  ll m = sumB-sumA;
  ll two=0, one=0;
  rep(i, n) {
    if(A[i] > B[i]) {
      one += A[i]-B[i];
    } else if(A[i] < B[i]) {
      if((B[i]-A[i])%2) one++;
      two += (B[i]-A[i])/2;
    }
  }
  cout << (one<=m && two<=m ? "Yes" : "No") << "\n";
  return 0;
}


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

using namespace std;

#define all(x) (x).begin(),(x).end()

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;

int main(void){

    string s;
    cin >> s;

    cout << s[0] << s.length()-2 << s[s.length()-1] << "\n";

    return 0;
}


Measured memory_bytes: 3524
/* 
 * File:   main.cpp
 * Author: goryudyuma
 *
 * Created on 2014/12/26, 19:16
 */

#include <cstdlib>
#include <iostream>
#include <functional>

using namespace std;

/*
 * 
 */
int main(int argc, char** argv) {

    double x;
    while(cin>>x){
        if(x<=48||(60<x&&x<=64)||(69<x&&x<=75)||(81<x&&x<=91)){
            cout<<"light ";
        }
        if(x<=51){
            cout<<"fly";
        }else if(x<=54){
            cout<<"bantam";
        }else if(x<=57){
            cout<<"feather";
        }else if(x<=60){
            cout<<"light";
        }else if(x<=69){
            cout<<"welter";
        }else if(x<=81){
            cout<<"middle";
        }else{
            cout<<"heavy";
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 1228
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
using namespace std;

int main() {
	int a, b;
	while (cin >>a>>b,a|b) {
		int ruisekiwa[101]; ruisekiwa[0] = 0;
		for (int d = 1; d <= b; d++) {
			int e; scanf("%d", &e);
			ruisekiwa[d] = ruisekiwa[d - 1] + e;
		}
		int dp[21][101];//n???????????§??§m?????????????°????
		for (int i = 0; i < 21; i++)fill(dp[i], dp[i] + 101, 1 << 29);
		dp[0][0] = 0;
		for (int i = 1; i <=a; i++) {
			for (int j = 1; j <= b; j++) {
				for (int k = j; k >= 0;k--) {
					dp[i][j] = min(dp[i][j], max(dp[i-1][j-k],ruisekiwa[j]-ruisekiwa[j-k]));
				}
			}
		}
		cout << dp[a][b] << endl;
	}
}

Measured memory_bytes: 3204
def solve():
    N, M = map(int, input().split())
    m = 10 ** 9
    for i in range(N, min(N+2019, M)):
        for j in range(N+1, min(N+2019, M)+1):
            m = min(m, i * j % 2019)
    return m

print(solve())

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

using namespace std;
typedef long long ll;

#define pf printf
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n) FORE(i,0,n)
#define REPSZ(i,v) REP(i,SZ(v))
#define pll pair <ll, ll>

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

ll n,m;
ll arr1[10];
ll arr[10];
bitset<10>a,b;

void print(vector <ll> &v){cout << v.size() << endl;for(int i = 0; i < v.size(); i++){pf("%lld ", v[i]);}pf("\n");}
void print(vector <pll> &v){ cout << v.size() << endl; for(int i = 0; i < v.size(); i++){pf("%lld %lld\n", v[i].first, v[i].second);}}
void print(set<ll> s){set <ll> :: iterator itr;for (itr = s.begin(); itr != s.end(); ++itr){cout << *itr << " ";}cout << endl;}
void print(double d){cout << fixed << setprecision(10) << d << endl;}

void from_file(void){ freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);}

/* ------------------main section-------------! */

ll factorial(ll x) {
    ll ans = 1;
    for(int i = 2; i <= x; i++) ans *= i;
    //cout << "ok\n";
    return ans;
}


void run() {
    fastio;
    cin >> n;
    //cout << n << endl;
    for(int i = 0; i < n; i++)
    {
        cin >> arr1[i];
        //cout << arr1[i] << " ";
    }
    //cout << "ok\n";
    for(int i = 0; i < n; i++)
    {
        cin >> arr[i];
        //cout << arr[i] << " ";
    }
    //cout << "ok\n";
    ll p1 = 0,p2 = 0;
    for(int i = 0; i < n; i++)
    {
        ll x1 = arr1[i];
        a[x1] = 1;
        ll m1 = 0;
        ll f = factorial(n-i-1);
        //cout << "ok\n";
        REP(j,x1-1)
        {
            if(!(a[j+1])) m1++;
        }
        ll x2 = arr[i];
        b[x2] = 1;
        ll m2 = 0;
        REP(j,x2-1)
        {
            if(!(b[j+1])) m2++;
        }
        //cout << "ok\n";
        p1 += f*m1;
        p2 += f*m2;
    }
    //cout << p1 << " " << p2 << endl;
    cout << abs(p1-p2) << endl;
}


int main() {
    #ifndef ONLINE_JUDGE
        //from_file();
    #endif
    run();
    return 0;
}


Measured memory_bytes: 3628
N = int(input())
X = input()
c = X.count('1')
if c == 0:
  for i in range(N):
    print(1)
  quit()
if c == 1:
  if int(X[-1]):
    for i in range(N-1):
      print(2)
    print(0)
  else:
    for i in range(N-1):
      if int(X[i]):
        print(0)
      else:
        print(1)
    print(2)
  quit()

memo = {0:0, 1:1, 2:1}
def calc(x):
  global memo
  if x in memo:
    return memo[x]
  c = bin(x).count('1')
  y = x % c
  res = calc(y) + 1
  memo[x] = res

for i in range(3, 2*10**5+1):
  calc(i)

Xmodp = Xmodm = 0
digit_p = digit_m = 1
digit = {}
for i in range(N):
  if int(X[-i-1]):
    Xmodp += digit_p
    Xmodp %= c + 1
    Xmodm += digit_m
    Xmodm %= c - 1
  digit[i] = [digit_p, digit_m]
  digit_p = (digit_p * 2) % (c+1)
  digit_m = (digit_m * 2) % (c-1)

ans = []
for i in range(N):
  x = int(X[-i-1])
  if x:
    ans.append(memo[(Xmodm - digit[i][1]) % (c-1)] + 1)
  else:
    ans.append(memo[(Xmodp + digit[i][0]) % (c+1)] + 1)

ans = ans[::-1]
print(*ans, sep='\n')

Measured memory_bytes: 81132
#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    if(s[0]==s[1]||s[2]==s[3]||s[1]==s[2])cout <<"Bad";
    else  cout << "Good";
    return 0;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

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

  auto ask = [](string n) {
    cout << "? " << n << endl;
    string a;
    cin >> a;
    return a == "Y";
  };

  bool is10pow = true;
  int k = 0;
  string base = "1";
  for (int i = 1; i < 11; i++) {
    if (!ask(base)) {
      k = i - 1;
      is10pow = false;
      break;
    }
    base.push_back('0');
  }
  if (is10pow) {
    base = "9999999999";
    for (int i = 10; i > 0; i--) {
      if (!ask(base)) {
        k = i + 1;
        cout << "! 1";
        for (int j = 0; j < i; j++) cout << "0";
        cout << endl;
        return 0;
      }
      base.pop_back();
    }
    cout << "! 1" << endl;
    return 0;
  }
  base = "999999999999";

  auto bin = [&](int i) {
    int l = 0, r = 9;
    if (i == 0) l = 1;
    base[i] = '0' + l;
    if (ask(base)) {
      return;
    }
    while (r - l > 1) {
      int m = (r + l) / 2;
      base[i] = '0' + m;
      if (ask(base)) {
        r = m;
      } else {
        l = m;
      }
    }
    base[i] = '0' + r;
  };
  for (int i = 0; i < 10; i++) {
    bin(i);
  }

  cout << "! " << base.substr(0, k) << endl;

  return 0;
}


Measured memory_bytes: 632
from collections import deque
MAX= 10**5+5
INF= 10**9
def resolve():
    n,m = map(int,input().split())
    net = [[] for i in range(MAX)]
    vn = [[INF]*3 for i in range(n+1)]
    for i in range(m):
        u,v = map(int,input().split())
        net[u].append(v)
    s,t = map(int,input().split())
    vn[s][0]=0
    q = deque()
    q.appendleft((s,0))
    while q:
        data = q.pop()
        v = data[0]
        l = data[1]
        nl=(l+1)%3
        for u in net[v]:
            if vn[u][nl]==INF:
                vn[u][nl] = vn[v][l]+1
                q.appendleft((u,nl))
    ans = vn[t][0]
    if( ans==INF):
        print(-1)
    else:
        print(ans//3)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 69920
#include<iostream>

using namespace std;
int main()
{
	// 整数の入力
	int k;
	cin >> k;

	int odd_flag = k % 2;
	int even_num = k / 2;
	int kumi_num = even_num * (even_num + odd_flag);
	
	cout << kumi_num<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder.Beginner065
{
    public class ABC065C_Reconciled
    {
        public static void Main(string[] args)
        {
            // スペース区切りの整数の入力
            int[] nums = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            int dogNum = nums[0];
            int monkeyNum = nums[1];

            int dif = Math.Abs(dogNum - monkeyNum);

            // ２匹以上差がある場合は無理
            if(dif >= 2)
            {
                Console.WriteLine("0");
                return;
            }

            int modNum = 1000000007;

            // 犬の順列数
            long dogC = 1;
            for(int i = 2; i <= dogNum; i++)
            {
                dogC = (dogC * i) % modNum;
            }

            // 猿の順列数
            long monkeyC = 1;
            for(int i = 2; i <= monkeyNum; i++)
            {
                monkeyC = (monkeyC * i) % modNum;
            }

            // 結果出力
            if(dif == 1)
            {
                // １匹差－挟む形しかないので各順列数をかける
                Console.WriteLine((dogC * monkeyC) % modNum);
            }
            else
            {
                // 同数－どちらも左端になれるので、各順列数をかけ、更に2倍
                Console.WriteLine((dogC * monkeyC * 2) % modNum);
            }

            
        }

    }
}

Measured memory_bytes: 13396
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<queue>
#include<set>
#include<ctime>
using namespace std;

#define rep(i,m) for(int i=0;i<m;i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define mm1(x) memset(x,-1,sizeof(x))
#define ms(x,n) memset(x,n,sizeof(x))
#define SORT(x) sort((x).begin(),(x).end())
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

const int INF = 100000000;
const int mod = 1e9 + 7;


int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a%b);

}

int main() {
	int a, b; cin >> a >> b;
	vector<int> m(b);
	int sum = 0;
	rep(i, b) {
		cin >> m[i]; sum += m[i];
	}
	cout << (sum % (a + 1) ? sum / (a + 1) + 1 : sum / (a + 1)) << endl;

}


Measured memory_bytes: 3108
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int N,K,ans;
int main(){
	scanf("%d%d",&N,&K);
	--N;--K;
	ans=0; 
	while(N>0){
		N-=K;
		++ans;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<functional>
#include<iomanip>
#define LLI long long int

using namespace std;

int main(){
	int N;cin>>N;
	double ans=0.0;
	vector<double>v(N);
	for(int i=0;i<N;i++){
			cin>>v[i];
	}
	sort(v.begin(),v.end());
	ans=v[0];
	for(int i=1;i<N;i++){
		ans=ans/2+v[i]/2;
	}
	cout<<fixed<<setprecision(7)<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
double calc(int tA,int vA,int tB,int vB){
	return (double)(tA*vA+tB*vB)/(vA+vB);
}
int main(){
	int T,D,tA,tB,dA,dB,iA,iB;
	scanf("%d%d%d%d%d%d",&T,&D,&tA,&tB,&dA,&dB);
	double r=999999999;
	for(iA=0;iA*dA<=D;iA++)for(iB=0;iA*dA+iB*dB<=D;iB++){
		double t=fabs(T-calc(tA,iA*dA,tB,iB*dB));
		if(r>t)r=t;
	}
	printf("%f\n",r);
	return 0;
}

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

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long int 
typedef pair<int,int> pii;
vector<int>v;
map<int,int>op;
#define MAX 200005
bool visited[MAX];
vector<int>adj[MAX];
const int M=1e9+7;
int n,m;
const ll INF = 1LL << 60;

string lcs(string a,string b)
{
	int al=a.length(),bl=b.length();
	int dp[al+1][bl+1];
	for(int i=0;i<=al;i++)
	{
		for(int j=0;j<=bl;j++)
		{
			if(i==0 || j==0)
				dp[i][j]=0;
			else if(a[i-1]==b[j-1])
				dp[i][j]=dp[i-1][j-1]+1;
			else
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	int index=dp[al][bl];
	string l="";
	int i=al,j=bl;
	while(i>0 && j>0)
	{
		if(a[i-1]==b[j-1])
		{
			l+=a[i-1];
			i--,j--,index--;
		}
		else if(dp[i-1][j] > dp[i][j-1]){
			i--;
		}
		else
			j--;	
	}
	reverse(l.begin(),l.end());
	return l;
}
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL); 
	string a,b;
	cin>>a>>b;
	cout<<lcs(a,b)<<endl;
	return 0;	
}


Measured memory_bytes: 40192
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9+10;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    string s, t; cin >> s >> t;
    int n_s = s.size(), n_t = t.size();
    vint sum_s_a(n_s+1,0), sum_s_b(n_s+1,0);
    vint sum_t_a(n_t+1,0), sum_t_b(n_t+1,0);
    rep(i,n_s) {
        sum_s_a[i+1] += sum_s_a[i];
        sum_s_b[i+1] += sum_s_b[i];
        if (s[i] == 'A') sum_s_a[i+1]++;
        if (s[i] == 'B') sum_s_b[i+1]++;
    }
    rep(i,n_t) {
        sum_t_a[i+1] += sum_t_a[i];
        sum_t_b[i+1] += sum_t_b[i];
        if (t[i] == 'A') sum_t_a[i+1]++;
        if (t[i] == 'B') sum_t_b[i+1]++;
    }
    int q; cin >> q;
    rep(i,q) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        int x = (sum_s_a[b]-sum_s_a[a-1]) - (sum_s_b[b]-sum_s_b[a-1]);
        int y = (sum_t_a[d]-sum_t_a[c-1]) - (sum_t_b[d]-sum_t_b[c-1]);
        if (abs(x-y) % 3 == 0) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}

Measured memory_bytes: 5068
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long LL;
const int eps = 1e-8;
typedef long double LD;
typedef pair<int, int> pii;
#define lop(i,a,b) for(register int i = (a); i <= (b); ++i)
#define dlop(i,a,b) for(register int i = (a); i >= (b); --i)
#define bl(i) for(int i = head[u]; i; i = G[i].next)
//char buf[50<<20], *p1=buf;
//#define getchar() (*p1++)
#define MP make_pair
template<class T> void read(T & x){
  register int c = getchar(), f = 1; x = 0;
  while(!isdigit(c)){if (c == '-') f = -1; c = getchar();}
  while(isdigit(c)) x = x*10+(c&15), c = getchar();
  x *= f;
}
map<string,int>m1;
map<string,int>m2;
set<string>s1;
int n, m;

int main(void){
  //fread(buf,1,50<<20,stdin);
  read(n);
  for(int i = 1; i <= n; ++i) {
    string s; cin >> s; 
    s1.insert(s);
    m1[s]++;
  }
  read(m);
  for(int i = 1; i <= m; ++i) {
    string s; cin >> s;s1.insert(s);
    m2[s]++;
  }
  int ans = 0;
  for(set<string>::iterator it = s1.begin(); it != s1.end(); ++it) {
    int a = m1[*it], b = m2[*it];
    ans = max(ans, a-b);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
int W, H, x, y, r;
cin >> W >> H >> x >> y >> r;
if (r > x || (W - r) < x || r > y || (H - r) < y) {
cout << "No\n";
} else {
cout << "Yes\n";
} return 0;
}

Measured memory_bytes: 1128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		boolean flag = false;
		if(a==b)flag = true;
		if(b==c)flag = true;
		if(a==c)flag = true;
		if(a==b&&b==c)flag = false;
		if(flag) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
int n;
long long knapsack(int ind,int w,vector<long long>& wt,vector<long long>& val,vector<vector<long long>>& dp)
{
    if(ind==n || w==0)
    return 0;
    if(dp[ind][w]!=-1)
    return dp[ind][w];
    if(wt[ind]<=w)
     {
        long long left = val[ind]+knapsack(ind+1,w-wt[ind],wt,val,dp);
        long long right = knapsack(ind+1,w,wt,val,dp);
        return dp[ind][w] = max(left,right);
     }
     else{
         return knapsack(ind+1,w,wt,val,dp);
     }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int w;
    cin>>n>>w;
    vector<long long> wt(n);
    vector<long long> val(n);
    for(int i=0;i<n;i++)
    {
        long long w1,v1;
        cin>>w1>>v1;
        wt[i] = w1;
        val[i]=v1;
    }
    vector<vector<long long>> dp(n+1,vector<long long>(w+1,-1));
    cout<<knapsack(0,w,wt,val,dp);
    return 0;
}

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

int n, k;

int main(){
  cin >> n >> k;
  
  double res = 0;
  for(int i = 1; i <= n; i++){
    int cnt = 0;
    for(int j = i; j < k; j *= 2){
      cnt++;
    }
    res += pow(2, (-1)*cnt);
  }
  res /= n;
  cout << setprecision(10) <<  res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, m;
    cin >> n >> m;
    vector<vector<int>> g(n);
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        g[u].emplace_back(v);
        g[v].emplace_back(u);
    }
    vector<int> col(n, -1);
    bool ok;
    function<void(int, int)> dfs = [&](int v, int p) {
        for (int to : g[v]) {
            if (to == p) continue;
            if (col[to] == col[v]) {
                ok = false;
            }
            if (col[to] == -1) {
                col[to] = col[v] ^ 1;
                dfs(to, v);
            }
        }
    };
    ll a = 0, b = 0;
    ll ans = 0, all = n;
    for (int i = 0; i < n; i++) {
        if (col[i] == -1) {
            ok = true;
            col[i] = 0;
            dfs(i, -1);
            if (g[i].size() == 0) {
                all--;
            } else if (ok) {
                a++;
            } else {
                b++;
            }
        }
    }
    b += a;
    ans += n * n - all * all;
    ans += b * b + a * a;
    cout << ans << '\n';
    return 0;
}

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

typedef long long LL;

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

int main() {
    int N;
    cin >> N;
    string s;
    cin >> s;
    if(N%2 != 0) {
        cout << "No" << endl;
    }else{
        REP(i, N/2) {
            if(s[i] != s[i + N/2]) {
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    }
    return 0;
}



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

int main(){
    ll n,k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> s;
    vector<int> ord(n+1,-1);
    int c = 1;
    int l = 0;
    int v = 1;
    while(ord[v] == -1){
        ord[v] = s.size();
        s.push_back(v);
        v = a[v-1];
    }
    c = s.size() - ord[v];
    l = ord[v];
    if(k < l) cout << s[k] << endl;
    else {
        k -= l;
        k %= c;
        cout << s[l+k] << endl;
    }
}


Measured memory_bytes: 5864
#include <bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
int main() {
    int n;
    scanf("%d",&n);
    vector<int>h(n);
    for(int& x : h)
    {
        scanf("%d",&x);
    }
    vector<int> dp(n,INF);
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        for(int j:{i+1,i+2})
        {
            if(j<n)
            {
              //  cout<<j<<" ** ";
                dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
            }
        }
     //   cout<<endl;
    }
    printf("%d",dp[n-1]);
}


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

struct StExpr
{
  StExpr() : m_nPerson(0), m_nAttr(0) { }

  int m_nPerson;
  int m_nAttr;
};

void fnInput(vector<vector<StExpr>>& rvvoExpr)
{
  int nPersonSiz;
  cin >> nPersonSiz;
  rvvoExpr.resize(nPersonSiz);

  for (int i = 0; i < rvvoExpr.size(); i++)
  {
    int nAttrSiz;
    cin >> nAttrSiz;
    rvvoExpr[i].resize(nAttrSiz);

    for (int j = 0; j < rvvoExpr[i].size(); j++)
      cin >> rvvoExpr[i][j].m_nPerson >> rvvoExpr[i][j].m_nAttr;
  }
}
 
int fnHonestCheck(const vector<vector<StExpr>>& cnrvvoExpr, 
                  const vector<int>& cnrvnHonest, int nMan)
{
  if (cnrvnHonest[nMan])               // Honest
  {
    for (int j = 0; j < cnrvvoExpr[nMan].size(); j++)
      if (cnrvvoExpr[nMan][j].m_nAttr  !=
          cnrvnHonest[ cnrvvoExpr[nMan][j].m_nPerson - 1 ] )
        return 0;

    return 1;
  }
  else                                 // UnKind
  {
    for (int j = 0; j < cnrvvoExpr[nMan].size(); j++)
      if (cnrvvoExpr[nMan][j].m_nAttr  !=
          cnrvnHonest[ cnrvvoExpr[nMan][j].m_nPerson - 1 ] )
        return 1;

    return 0;
  }
}
  
int fnMaxHonestGet(const vector<vector<StExpr>>& cnrvvoExpr)
{
  vector<int> vnHonest(cnrvvoExpr.size());
  int nMaxHonestCnt = 0;
  
  for (int nCtl = 0; nCtl < ( 1 << cnrvvoExpr.size() ); nCtl++)
  {
    int nHonestCnt = 0;

    for (int nEach = 0; nEach < cnrvvoExpr.size() ; nEach++)
      if (nCtl & ( 1 << nEach ))
      {
        vnHonest[nEach] = 1;            // Honest
        nHonestCnt++;
      }
      else
        vnHonest[nEach] = 0;            // UnKind

    bool bReslt = true;

    for (int nMan = 0; nMan < vnHonest.size(); nMan++)
      if (!fnHonestCheck(cnrvvoExpr, vnHonest, nMan))
      {
        bReslt = false;
        break;
      }

    if (bReslt) nMaxHonestCnt = max(nMaxHonestCnt, nHonestCnt);
  }
  return nMaxHonestCnt;
}

int main()
{
  vector<vector<StExpr>> vvoExpr;

  fnInput(vvoExpr);
  cout << fnMaxHonestGet(vvoExpr) << endl;

  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int mod = 1000000007;
const ll INF = 1001001001;
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 main() {
  int n;
  ll m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(), a.end());
  vector<ll> s(n+1);
  rep(i,n) s[i+1] = s[i]+a[i];
 
  auto calc = [&](int x) {
    ll tot = 0, num = 0;
    rep(i,n) {
      int j = lower_bound(a.begin(), a.end(), x-a[i]) - a.begin();
      num += n-j;
      tot += s[n]-s[j];
      tot += a[i]*ll(n-j);
    }
    return make_pair(tot,num);
  };
 
  int l = 0, r = 200005;
  while (l+1<r) {
    int c = (l+r)>>1;
    if (calc(c).second >= m) l = c; else r = c;
  }
  auto p = calc(l);
  ll ans = p.first;
  ans -= (p.second-m)*l;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4584
/*Author--Vishwas Agrawal*/
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define vll vector<ll>
#define pb push_back
#define test ll t; cin>>t; while(t--)
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007LL
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define inc(i,a,n) for (ll i=a;i<n;i++)
#define dec(i,a,n) for (ll i=n-1;i>=a;i--)

int main()
{
   string s;
   cin>>s;
   ll temp=0;
   ll answer=0;
   inc(i,0,3)
   {
      if(s[i]=='R')
      {
         temp++;
         if(temp>answer)
         {
            answer=temp;
         }
      }
      else
      {
         temp=0;
      }
      


         }
         cout<<answer<<endl;
  
   return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<cstring>
#include<map>
#include<set>
#include<cstdlib>
#include<bitset> 
using namespace std;
typedef long long ll;
ll n,k;
ll a[200005];
ll b[200005]={0};
int main(void)
{
	string s;
	cin>>s;
	cout<<s[0]<<s[1]<<s[2];
}

Measured memory_bytes: 3596
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;





int main() {
	int s;
	cin >> s;
	if (s < 3) {
		cout << 0 << endl;
		return 0;
	}

	vector<ll> dp(s + 1,1);
	dp[0] = dp[1] = dp[2] = 0;
	for (int i = 3; i <= s; i++) {
		for (int j = 3; j <= i-3; j++) {
			dp[i] += dp[j];
			dp[i] %= MOD;
		}
	}
	cout << dp[s] << endl;
}

Measured memory_bytes: 3640
#include <iostream>

using namespace std;

int main()
{
    long int n,i,p;
    cin>>n;
    long long int a[n],b[n],t;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(i=0;i<n;i++)
    {
        if(i%2==0)
        {
            b[i/2]=a[n-i-1];
        }
        else
        {
            b[n-1-i/2]=a[n-1-i];
        }
    }
    for(i=0;i<n;i++)
    {
        cout<<b[i]<<" ";
    }
    return 0;
}


Measured memory_bytes: 5248
N = int(input())
yen = 0.0
goukei = 0.0
tuuka = ""
b2y = lambda y: y*380000
for i in range(N):
  yen, tuuka = input().split()
  if tuuka == "JPY":
    yen = int(yen)
    goukei += yen
  elif tuuka == "BTC":
    yen = float(yen)
    yen = b2y(yen)
    goukei += yen
print(goukei)

Measured memory_bytes: 3064
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
#include <iomanip>
#include <climits>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return b;
    }
    return gcd(b, a % b);
}

int main()
{
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << max(min(B, D) - max(A, C), 0LL) << endl;
}

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

void	paint(int a, int x, int y, int W, int H,
			vector<vector<bool>> &is_while)
{
	int	i_bgn = 0, i_end = W, j_bgn = 0, j_end = H;
	if (a == 1) i_end = x;
	if (a == 2) i_bgn = x;
	if (a == 3) j_end = y;
	if (a == 4) j_bgn = y;
	for (int i = i_bgn; i < i_end; ++i) {
		for (int j = j_bgn; j < j_end; ++j)
				is_while.at(i).at(j) = false;
	}
}

int	main()
{
	int	W, H, N;
	cin >> W >> H >> N;
	vector<vector<bool>>	is_white(W, vector<bool>(H, true));
	int	x, y, a;
	for (int i = 0; i < N; ++i) {
		cin >> x >> y >> a;
		paint(a, x, y, W, H, is_white);
	}
	int	area = 0;
	for (int i = 0; i < W; ++i) {
		for (int j = 0; j < H; ++j) {
			if (is_white.at(i).at(j))
				++area;
		}
	}
	cout << area << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int m=scan.nextInt();
		int a[][] = new int[100][100];
		int b[]= new int[100];
		int sum[]=new int[100];
		int i,j;
		for(i=0;i<n;i++) {
			for(j=0;j<m;j++) {
				int c=scan.nextInt();
				a[i][j] +=c;
			}
		}
		for(i=0;i<m;i++) {
			int c=scan.nextInt();
			b[i] +=c;
		}
		for(i=0;i<n;i++) {
			for(j=0;j<m;j++) {
				sum[i] +=a[i][j]*b[j];
			}
			System.out.println(""+sum[i]);
		}
		scan.close();
}
}


Measured memory_bytes: 40272
L, R = map(int, input().split())
# 2019の素因数：1,3,673,2019
#(2019a+b)(2019c+d) = (2019)^2*ac + 2019(ad+bc) + bd

if(R-L < 673):
    # ループで調べてもたいした量にならない.
    min_mod = 2018
    for i in range(L, R+1):
        for j in range(i+1, R+1):
            min_mod = min(min_mod, (i*j)%2019)
    print(min_mod)

else:
    # 必ず2019の倍数が存在する(673の倍数*3の倍数がかならず存在)ので0
    print(0)


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

     long long int n,w;
     cin>>n>>w;
     long long int v[n+1],we[n+1],dp[w+1][n+1];
     for(long long int i=1;i<=n;i++){
cin>>we[i]>>v[i];
                           
     }
     memset(dp,0,sizeof(dp));
     for(long long int i=1;i<=w;++i){
    for(long long int j=1;j<=n;++j){
if(we[j]<=i)
    dp[i][j]=max(dp[i-we[j]][j-1]+v[j],dp[i][j-1]);
else 
dp[i][j]=dp[i][j-1];
    }


     }
cout<<dp[w][n];






    return 0;  
      
    }

Measured memory_bytes: 79104
primes = [0, 0] + [1] * 9999
for i in range(2, 101):
    if primes[i]:
        for j in range(i*i, 10001, i):
            primes[j] = 0

while True:
    try:
        N = int(input())
    except:
        break
    print(sum(primes[i] & primes[N-i+1] for i in range(1, N+1)))

Measured memory_bytes: 7800
#include<stdio.h>
#include<math.h>
#include <stdlib.h>
#include<string.h>
#include<limits.h>

int main(){
	int n,i,j;
	long long int number[4000]={0},kazu[4000]={0},coin[4000]={0},ans[4000]={0};
	int flag=0;
	
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		for(i=0;i<n;i++){
			scanf("%lld%lld%lld",&number[i],&coin[i],&kazu[i]);
			ans[i]=kazu[i]*coin[i];
		}
		for(i=0;i<n;i++){
			for(j=i;j<n;j++){
				if(number[i]==number[j] && j!=i){
				ans[i]+=ans[j];
				ans[j]=0;
				}
			}
		}
	for(i=0;i<n;i++){
		if(ans[i]>=1000000){
			printf("%d\n",number[i]);
			flag=1;
		}
	}
	if(flag==0)printf("NA\n");
		flag=0;
	}
return 0;
}

Measured memory_bytes: 744
#include<bits/stdc++.h>
using namespace std;
/**
******************* Author:Bisnu sarkar ****************************
**/
/*
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
*/
#define fRead(x)       freopen(x,"r",stdin)
#define fWrite(x)      freopen (x,"w",stdout)
#define ull            unsigned long long
#define ll             long long
#define pii            pair<int,int>
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';
#define sz(s)          (int)s.size()
#define all(s)         s.begin(),s.end()
#define IO             ios_base::sync_with_stdio(false),cin.tie(NULL);
#define what_is(x)     cerr << #x << " is " << x << endl;
///*....Debugger....*///
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ", ";
    err(++it, args...);
}
///*....Input....*///
template <typename T> inline void Int(T &n) {
    n = 0; int f = 1; register int ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
    n = n * f;
}

template <typename T, typename TT> inline void Int(T &n, TT &m) { Int(n); Int(m); }
template <typename T, typename TT, typename TTT> inline void Int(T &n, TT &m, TTT &l) { Int(n, m); Int(l);}
double ind() {double x; scanf("%lf", &x); return x;}

///*....Bitmask....*///
int set_1(int n, int pos) {return n = (n | (1 << pos));}
int reset_0(int n, int pos) {return n = n & ~(1 << pos);}
bool check_bit(int n, int pos) {return n = n & (1 << pos);}

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

///*....Constraints....*///
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi = 2 * acos(0.0);
const double eps = 1e-9;


int main()
{
    int n;
    Int(n);

    ll x;
    Int(x);

    ll la = x,res=0;

    for (int i = 2; i <= n; ++i) {
        Int(x);

        if(x<la){
            res+=(la-x);
        }
        else{
            la=x;
        }
    }
    printf("%lld\n", res);

    return 0;
}






Measured memory_bytes: 3744
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    long N = lread();
    auto V = aryread();
    long[long][2] D;
    foreach (i; 0 .. N)
    {
        D[i & 1][V[i]] = (V[i] in D[i & 1]) ? D[i & 1][V[i]] + 1 : 1;
    }
    long[][2] k;
    long[][2] v;
    k[0] = D[0].keys;
    v[0] = D[0].values;
    zip(v[0], k[0]).sort();
    k[1] = D[1].keys;
    v[1] = D[1].values;
    zip(v[0], k[0]).sort!"b<a"();
    zip(v[1], k[1]).sort!"b<a"();
    // writeln(k);
    if (k[0][0] != k[1][0])
    {
        writeln(N - v[0][0] - v[1][0]);
        return;
    }
    if (v[0][0] + v[1][0] == N)
    {
        writeln(N / 2);
        return;
    }
    long ans = long.max;
    if (k[0][1] != k[1][0])
    {
        ans = ans.min(N - v[0][1] - v[1][0]);
    }
    if (k[0][0] != k[1][1])
    {
        ans = ans.min(N - v[0][0] - v[1][1]);
    }
    writeln(ans);
}


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

vector<char> s;

bool check1(int x, int y) {
    int count = 0;
    for (int i = x; i <= y; i++) {
        if (s[i] == '.') count = 0;
        else count++;
        if (count == 2) return false;
    }
    return true;
}

bool check2(int x, int y) {
    int count = 0;
    for (int i = x; i <= y; i++) {
        if (s[i] == '.') count++;
        else count = 0;
        if (count == 3) return true;
    }
    return false;
}

int main(void)
{
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    a--;
    b--;
    c--;
    d--;
    s = vector<char>(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    if (c < b) {
        if (check1(a, c) && check1(b, d)) cout << "Yes" << endl;
        else cout << "No" << endl;
    } else if (c < d) {
        if (check1(a, d)) cout << "Yes" << endl;
        else cout << "No" << endl;
    } else {
        if (check2(b-1, d+1) && check1(a, c)) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}



Measured memory_bytes: 384
i = list(map(int, input().split()))
K = i[0]
N = i[1]
max = 0
count = 0


A = list(map(int, input().split()))

for j in range(len(A)-1):
    count += 1
    if abs(A[j+1] - A[j]) > max:
        max = abs(A[j+1] - A[j])
    if count == (len(A)-1):
        if max < abs(A[0] + (K - A[j+1])):
            max = abs(A[0] + (K - A[j+1]))

print(K - max)

Measured memory_bytes: 26444
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
        var N = int.Parse(ReadLine());
        var A = ReadLine().Split().Select(long.Parse).ToArray();
        var x0 = 0L;
        for (int i = 0; i < N; i++)
        {
            if (i % 2 == 0) x0 += A[i];
            else x0 -= A[i];
        }
        x0 /= 2;
        var ans = new long[N];
        ans[0] = x0*2;
        for (int i = 1; i < N; i++)
        {
            ans[i] = (A[i-1] - ans[i - 1]/2)*2;
        }
        WriteLine(string.Join(" ", ans));
    }
}


Measured memory_bytes: 36144
#include <stdio.h>

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

   int count = 0;
   count = N / (2*D + 1);
   
   if (0 < N % (2*D + 1))
      count++;

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


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

double get_num(double x){
	x = x * 1000;
	if(x >= 0){
		x = (int)(x + 0.5);
		return ((double)x / 1000);
	} else {
		x = (int)(x - 0.5);
		return ((double)x / 1000);
	}
}

int main(){
	double a, b, c, d, e, f;
	double x, y;
	while(cin >> a >> b >> c
		>> d >> e >> f)
	{
		y = (c * d - f * a) / (b * d - e * a);
		if(a == 0){
			x = (f - e * y) / d;
		} else {
			x = (c - b * y) / a;
		}
		x = get_num(x);
		y = get_num(y);
		cout << fixed << setprecision(3) << x << " " << y << endl;
	}
	return 0;
}

Measured memory_bytes: 0
import sys
#input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()


def II(): return int(input())


def MI(): return map(int,input().split())


def MF(): return map(float,input().split())


def LI(): return list(map(int,input().split()))


def LF(): return list(map(float,input().split()))


def TI(): return tuple(map(int,input().split()))

# rstrip().decode('utf-8')

class BinaryIndexedTree:
	def __init__(self,n,default=0):
		self.s=[default]*(n+1)
		self.n=n
	
	def add(self,val,idx):
		while idx<self.n+1:
			self.s[idx]=self.s[idx]+val
			idx+=idx&(-idx)
		return
	
	def get(self,idx):
		res=0
		while idx>0:
			res=res+self.s[idx]
			idx-=idx&(-idx)
		return res

from collections import defaultdict

def main():
	n=II()
	s=input()
	S=[0]+list(s)
	
	d=defaultdict(lambda:BinaryIndexedTree(n))
	
	for i,si in enumerate(s):
		#print(i,si)
		d[si].add(1,i+1)
	
	q=II()
	for _ in range(q):
		f,a,b=input().split()
		if int(f)==1:
			a=int(a)
			d[S[a]].add(-1,a)
			d[b].add(1,a)
			S[a]=b
		else:
			#print(S,a,b)
			a=int(a)
			b=int(b)
			cnt=0
			for bit in d.values():
				if bit.get(b)-bit.get(a-1)>0:
					cnt+=1
			print(cnt)
		
	

if __name__=="__main__":
	main()


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

int main(void){
    set<int> S;
    int q;
    cin >> q;

    for(int i=0; i<q; i++){
        int cmd;
        cin >> cmd;
        if(cmd==0){
            int x;
            cin >> x;
            S.insert(x);
            cout << S.size() << "\n";
        }
        else if(cmd==1){
            int x;
            cin >> x;
            if(S.find(x) != S.end()){
                cout << 1 << "\n";
            }
            else{
                cout << 0 << "\n";
            }
        }
        else if(cmd==2){
            int x;
            cin >> x;
            S.erase(x);
        }
    }
    return 0;
}


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

int main() {
    long long a, b, c, k;
    cin >> a >> b >> c >> k;
    long long ans = 0;
    if (k) {
        ans += min(a, k);
        k -= a;
        if (k < 0) {
            k = 0;
        }
    }
    if (k) {
        k -= b;
        if (k < 0) {
            k = 0;
        }
    }
    if (k) {
        ans -= k;
    }
    cout << ans;
    return 0;
}


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int N;
    Scd(N);

    vector<int> a(N);

    Rep(i,N){
        Scd(a[i]);
    }

    vector<ll> ans(N);

    ll h = INF;
    ll l = -1;
    ll m = 0;
    ll fale = false;
    // (l,h]
    while( h-l > 1 ){
        fale = 0;
        m = ( l + h ) / 2;
        ans[0] = m;
        Repe(i,N,1){
            ans[i] = a[i-1] - ans[i-1];
            if( ans[i] < 0 ) {
                fale = ( i % 2 ? 1 : 2 );
                break;
            }
        }
        // Rep(i,N){
        //     printf ("%lld%c", ans[i] * 2 , i == N-1 ? '\n' : ' ' );
        // }
        ll fin = ans[N-1] + ans[0];
        if( fale == 1 ) h = m-1;
        else if( fale == 2 ) l = m;
        else if( fin < a[N-1] ) l = m;
        else h = m;
    }
    m = h;
    ans[0] = m;
    Repe(i,N,1){
        ans[i] = a[i-1] - ans[i-1];
    }

    Rep(i,N){
        printf ("%lld%c", ans[i] * 2, i == N-1 ? '\n' : ' ' );
    }

    return 0;
}



Measured memory_bytes: 2432
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
int max(const void *a, const void *b){return *(int*)b - *(int*)a;}

int n;
int s;
uint64_t dp[55][55][3000]={0};

int main(void)
{
    
    scanf("%d",&n);
    scanf("%d",&s);
    dp[0][0][0] = 1;
    for(uint64_t i=0;i<n;i++) for(uint64_t j=0;j<=i;j++) for(uint64_t k=0;k<=s;k++)
    {
        dp[i+1][j+1][k+((j+1)*2)] += dp[i][j][k];
        dp[i+1][j+1][k+((j+1)*2)] %= 1000000007;
        dp[i+1][j][k+(j*2)] += dp[i][j][k];
        dp[i+1][j][k+(j*2)] %= 1000000007;
        dp[i+1][j][k+(j*2)] += dp[i][j][k] * j * 2;
        dp[i+1][j][k+(j*2)] %= 1000000007;
        if(j>=1) {
            dp[i+1][j-1][k+((j-1)*2)] += dp[i][j][k] * j * j;
            dp[i+1][j-1][k+((j-1)*2)] %= 1000000007;
        }
    }

    printf("%ld\n", dp[n][0][s]);

    return 0;
}


Measured memory_bytes: 65792
// G++ MACRO.CPP -STD=C++14
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
template <class T = ll>
T IN(){T x;cin>>x;return (x);}
 
template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}
 
template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}
 
#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc
 
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int
 
#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>
 
#define pb(a) push_back(a)
#define mp make_pair
 
int main(){
  VC1(3,a);
  V v(3);iota(ALL(v),0);
  ll ans = LINF;
  do{
    ll sum = 0;
    REP(i,2)
      sum += abs(a[v[i]] - a[v[i+1]]);
    ans = min(sum,ans);
  }
  while(next_permutation(ALL(v)));
  COUT(ans);
 
  return 0;
}


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

int main(void){
    int N,M;
    cin >> N;
    M = N;
    
    int s=0; // s = (各位の値の合計) にする
    for(int i=0; M!=0; i++){
        s += M % 10;
        M /= 10;
    }
    if(N%s == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main() {

	int a, b, d, r;
	double f;

	scanf("%d %d", &a, &b);

	d = a / b;

	r = a % b;

	f =(double) a / b;

	printf("%d %d %f\n", d, r, f);

	return 0;


}


Measured memory_bytes: 2088