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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N, M;
  cin >> N >> M;
  vector<int> ok(N);
  vector<int> num(N);
  rep(i, N){
    ok[i] = 0;
    num[i] = 1;
  }
  ok[0] = 1;
  rep(i, M){
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    if(num[x] > 0){
      ok[y] = max(ok[y], ok[x]);
      num[y]++;
      num[x]--;
      if(num[x]==0){
        ok[x] = 0;
      }
    }
  }

  int ans = 0;
  rep(i, N){
    if(ok[i]==1 && num[i]>0){
      ans++;
    }
  }

  cout << ans << endl;


  return 0;
}


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

bool f(int x){
    int keta=0;
    while(x){
        keta++;
        x /=10;
    }
    return keta % 2 == 1;
}

int main(){ 
    int n;
    cin >> n;
    int ans =0;
    for(int i=1;i<=n;i++){
        if(f(i))ans++;

    } 
    cout << ans << endl;
    
}

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

long ans;
long M, N, K;
long X, Y;
long H, W;
vector<long> A, B, C;
// vector<long> P;

int main(void) {

    cin >> N; A.resize(N);
    for (long i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end(), greater<long>());

    if (N > 1) {
        ans += A[0];
    }

    for (long i = 3; i <= N; i++) {
        ans += A[(i-1)/2];
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 4804
n, k = [int(x) for x in input().split()]
h_list = sorted([int(input()) for _ in range(n)])

temp = h_list[k - 1] - h_list[0]
ans = temp
for i in range(k, n):
    temp = h_list[i] - h_list[i - k + 1]
    if ans > temp:
        ans = temp
print(ans)

Measured memory_bytes: 8200
#include <bits/stdc++.h>
 
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
 
#define pb push_back 
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second 
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define forn(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n); i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
#define RETURN(x) do{cout << x << '\n'; return 0;}while(0)
 
const int MAXN = 2e5+3;
const int MOD = 1e9+7;
const int INF = 1e9+1;

vector<int> primes;
int smallest[MAXN];

void sieve(int n) {
    for (int p=2; p<=n; p++) smallest[p] = p;
    for (int p=2; p<=n; p++) {
        if (smallest[p] == p) {
            primes.pb(p);
            for (int i = p+p; i <= n; i += p)
                smallest[i] = p;
        }
    }
}

int main() {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    sieve(2e5);
    int x; cin >> x;
    int idx = lower_bound(primes.begin(), primes.end(), x) - primes.begin();
    cout << primes[idx] << endl;
    return 0;
    
}


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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int main(void){

	int N; cin >> N;
	int ans = 0;

	FOR(i,1,N+1){
		string s = to_string(i);
		if(s.length() % 2 == 1) ans++;
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

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

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

bool dp[81][81][13000];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    auto ab = make_vec<int>(H, W);

    REP(h, H) {
        REP(w, W) {
            int a;
            cin >> a;
            ab[h][w] = a;
        }
    }

    REP(h, H) {
        REP(w, W) {
            int b;
            cin >> b;
            ab[h][w] = abs(ab[h][w] - b);
        }
    }
    memset(dp, 0, sizeof(dp));
    dp[0][0][ab[0][0]] = true;
    REP(h, H) {
        REP(w, W) {
            REP(i, 13000) {
                if (dp[h][w][i]) {
                    if (h + 1 < H) {
                        dp[h + 1][w][i + ab[h + 1][w]] = true;
                        dp[h + 1][w][abs(i - ab[h + 1][w])] = true;
                    }
                    if (w + 1 < W) {
                        dp[h][w + 1][i + ab[h][w + 1]] = true;
                        dp[h][w + 1][abs(i - ab[h][w + 1])] = true;
                    }
                }
            }
        }
    }

    int ans = INF;
    REP(i, 30000) {
        if (dp[H - 1][W - 1][i]) {
            // cout << i << endl;
            chmin(ans, i);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 83712
#include<bits/stdc++.h>
using namespace std;
int swap(int *a, int *b);
int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  swap(&a,&b);
  swap(&a,&c);
  cout<<a<<" "<<b<<" "<<c;
  return 0;
}
int swap(int *a,int *b)
{
  int x = *a;
  *a=*b;
  *b=x;
 // return(a,b);
}
  


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main(int i, char** c){

  int n,d;
  int r = scanf("%d %d",&n, &d);
  d=d*2+1;
  printf("%.0f", ceil( (float)n / (float) (d) ) );
  
  return 0;

}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define rep(i,a,b) for(register int i=(a);i<=(b);i++)
#define dep(i,a,b) for(register int i=(a);i>=(b);i--)
using namespace std;
#define maxn 100005
#define mod 1000000007
ll a,b,x,y,n,z;
char ch[maxn];
int main()
{
    scanf("%s",ch+1);
    n=strlen(ch+1);
    a=0;
    for(int i=1;i<=n;i++)
    {
        if(ch[i]!=ch[i-1]) a++;
    }
    printf("%lld\n",a-1);
}


Measured memory_bytes: 384
#include<iostream>
#include<fstream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
#include<cstdlib>

using namespace std;
string s,st;
void digui(int w)
{
	if(s[w]=='e')
	{
		st="";
		for(int i=w;i<=w+4;i++)
		{
			st+=s[i];
		}
		if(st=="erase")
		{
			if(w+4==s.size()-1)
			{
				cout<<"YES";
				exit(0);
			}
			if(s[w+5]=='r')
			{
				if(w+5==s.size()-1)
				{
					cout<<"YES";
					exit(0);
				}
				digui(w+5+1);
			}
			else
			{
				digui(w+4+1);
			}
		}
		else
		return ;
	}
	if(s[w]=='d')
	{
		st="";
		for(int i=w;i<=w+4;i++)
		{
			st+=s[i];
		}
		if(st=="dream")
		{
			if(w+4==s.size()-1)
			{
				cout<<"YES";
				exit(0);
			}
			if(s[w+5]=='e'&&s[w+6]=='r')
			{
				if(w+6==s.size()-1)
				{
					cout<<"YES";
					exit(0);
				}
				digui(w+6+1);
				digui(w+4+1);
			}
			else
			{
				digui(w+4+1);
			}
		}
		else
		return ;
	}
}
int main()
{
	cin>>s;
	if(s[0]!='d'&&s[0]!='e')
	{
		cout<<"NO";
		return 0;
	}
	digui(0);
	cout<<"NO";
	return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
using ll = long long;

ll N;

int main(void){

    cin >> N;

    ll ans = 0;
    ll S[N + 10];
    for (int i = 1;i < N; i++) S[i] = 0;

    for (int i = 1;i < N; i++){
        ll limit = (N - 1) / i;
        for (int j = 1; j <= limit; j++){
            ll A = i * j;
            S[A]++;
        }
    }

    for (int i = 1;i < N; i++){
        ans += S[i];
    }

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    if (v < w) {
        cout << "NO" << '\n';
        return 0;
    }
    if (a < b) {
        if (a + (v * t) < b + (w * t)) {
            cout << "NO" << '\n';
            return 0;
        } else {
            cout << "YES" << '\n';
            return 0;
        }
    } else if (a > b) {
        if (a - (v * t) > b - (w * t)) {
            cout << "NO" << '\n';
            return 0;
        } else {
            cout << "YES" << '\n';
            return 0;
        }
    }
    cout << "NO" << '\n';
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define N 2005
using namespace std;
int L[N],R[N],H[N][N][2],num[N];
char a[N][N];int ans,n,m,i,d;
int Findl(int x,int y){
	if (x==0||num[x]<y) return x;
	return Findl(L[x],y);
}
int Findr(int x,int y){
	if (x==m||num[x]<y) return x;
	return Findr(R[x],y);
}
int main(){
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;i++)
	  scanf("%s",a[i]+1);
	ans=max(n,m);
	for (d=1;d<=n;d++){
		for (i=1;i<m;i++)
		  if (a[d][i]==a[d][i+1])
		    num[i]=H[d][i][0]=H[d-1][i][0]+1,H[d][i][1]=0;
		  else 
		    num[i]=H[d][i][1]=H[d-1][i][1]+1,H[d][i][0]=0;
		for (i=1;i<m;i++)
		  ans=max(ans,num[i]);//printf("%d ",num[i]);puts("");
		L[1]=0;
		for (i=2;i<m;i++)
		  L[i]=Findl(i-1,num[i]);
		R[m-1]=m;
		for (i=m-2;i>0;i--)
		  R[i]=Findr(i+1,num[i]);
		for (i=1;i<m;i++)
		  ans=max(ans,num[i]*(R[i]-L[i]));
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 35584
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i=0; i<n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        int[] sum = new int[2];
        for(int i=0; i<n; i++) {
            sum[i%2] += a[i];
        }

        System.out.println(n%2 == 1 ? sum[0] - sum[1] : sum[1] - sum[0]);
    }


}


Measured memory_bytes: 21972
// Problem : D - Integer Cards
// Contest : AtCoder - AtCoder Beginner Contest 127
// URL : https://atcoder.jp/contests/abc127/tasks/abc127_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
const ll MOD = 1e9 + 7;
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(c,a,b) for(ll c=a;c<b;c++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define min_heap priority_queue<pll,vector<pll>,greater<pll> >
ll dx4[]={-1,1,0,0};
ll dy4[]={0,0,-1,1};
ll dx8[]={-1,-1,-1,0,1,1,1,0};
ll dy8[]={-1,0,1,1,1,0,-1,-1};
bool isvalid(ll x,ll y,ll n,ll m)
{
    return (x>=0 and y>=0 and x<n and y<m);
}
ll isprime[1000];
vector<ll> prime;
void sievetoprime(ll n)
{
    mem(isprime,true);
    for(ll p=2;p*p<=n;p++)
    {
        if(isprime[p]==true)
        {
            for(ll i=p*p;i<=n;i+=p)
                isprime[i]=false;
        }
    }
}
ll lcm(ll a,ll b)
{
    return (a/__gcd(a,b))*b;
}
void solve()
{
    ll n,m;
    cin>>n>>m;
    vector<ll> a(n);
    rep(i,0,n)
    	cin>>a[i];
    sort(all(a));
    ll b,c;
    vector<pll> v;
    rep(i,0,m)
    {
    	cin>>b>>c;
    	v.pb({c,b});
    }
    sort(v.rbegin(),v.rend());
    vector<ll> tmp;
    rep(i,0,m)
    {
    	if(tmp.size()>=n)
    		break;
    	rep(j,0,v[i].sec)
    		tmp.pb(v[i].fir);
    }
    rep(i,0,min(n,(ll)tmp.size()))
    {
    	if(a[i]>=tmp[i])
    		break;
    	a[i]=tmp[i];
    }
    ll sum=0;
    rep(i,0,n)
    	sum+=a[i];	
    cout<<sum;
}
int main()
{
    ll inpoup = 0;
    if(inpoup==1)
    {
        #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
        #endif
    }
    IOS
    ll t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 5744
// Sakhiya07 - Yagnik Sakhiya
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld long double

#define pll pair<ll,ll>
#define ff first
#define ss second

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

#define MOD  1000000007
const int N = 100005; 

#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));

void solve()
{
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll ans = max({a*c,a*d,b*c,b*d});
    cout<<ans<<"\n";
}

int main()
{
    FAST;
    int t = 1;
 // cin >> t;
    for(int i=1;i<=t;i++)
    {
        solve();
    }
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    string s;
    cin >> n >> s;
    string s1 = s.substr(0, n / 2), s2 = s.substr(n / 2);
    cout << (s1 == s2 ? "Yes" : "No") << endl;
    return 0;
}


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

using namespace std;

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

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

  vector<uint64_t> A(N, 0);
  if (S == 1e+9) {
    A = vector<uint64_t>(N, 1);
  } else {
    A = vector<uint64_t>(N, S + 1);
  }

  N_TIMES(k, K) {
    A[k] = S;
  }

  N_TIMES(n, N) {
    cout << A[n];
    if (n + 1 < N) { cout << ' '; }
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 2160
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int i;
        double data[] = new double[1000];
        double sum=0,ave,z=0,x;

        while(true){
            int n = sc.nextInt();

            if(n==0)break;

            for(i=0;i<n;i++){
                data[i]=sc.nextInt();
                sum=sum+data[i];
            }

            ave=sum/(double)n;

            for(i=0;i<n;i++){
                z=z+(data[i]-ave)*(data[i]-ave);
            }

            x=z/(double)n;

            System.out.printf("%f\n",Math.sqrt(x));

            sum=0;
            z=0;

        }
    }
}


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

public class Main{
	public static int[][] map;
	public static int w, h;
	public static final int[] dx = {1, 0, -1, 0};
	public static final int[] dy = {0, 1, 0, -1};
	public static int gx, gy;
//	public static int turn;
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		while(true){
			w = in.nextInt();
			h = in.nextInt();
			if(w == 0) break;
			map = new int[h][w];
			int sx = 0;
			int sy = 0;
			best = 11;
			for(int i=0; i<h; i++){
				for(int j=0; j<w; j++){
					map[i][j] = in.nextInt();
					if(map[i][j] == 2){
						sx = j;
						sy = i;
						map[i][j] = 0;
					}else if(map[i][j] == 3){
						gx = j;
						gy = i;
					}
				}
			}
			dfs(sy, sx, 0);
			System.out.println(best==11? -1: best);
		}
	}
	
	public static int best;
	public static void dfs(int y, int x, int depth){
		if(depth == 10) return;
//		if(y == gy && x == gx){
//			best = Math.min(best, depth);
//			return;
//		}
		for(int i=0; i<4; i++){
			int nx = x+dx[i];
			int ny = y+dy[i];
			if(out(ny, nx) || map[ny][nx] == 1) continue;
			while(!out(ny, nx) && map[ny][nx] == 0){
				nx += dx[i];
				ny += dy[i];
			}
			if(out(ny, nx)) continue;
			if(map[ny][nx] == 3){
				best = Math.min(best, depth+1);
				return;
			}
			map[ny][nx] = 0;
			nx -= dx[i];
			ny -= dy[i];
			dfs(ny, nx, depth+1);
			map[ny+dy[i]][nx+dx[i]] = 1;
		}
	}
	
	public static boolean out(int y, int x){
		return x < 0 || x >= w || y < 0 || y >= h;
	}
}

Measured memory_bytes: 37108
use proconio::{fastout, input};

fn gcd(a: usize, b: usize) -> usize {
    use std::cmp::{max, min};
    let mi = min(a, b);
    let ma = max(a, b);

    let r = ma % mi;
    if r == 0 {
        return mi;
    }

    gcd(mi, r)
}

fn reduce(mut a: isize, mut b: isize) -> (isize, isize) {
    if a == 0 {
        return (0, 1);
    }

    if b == 0 {
        return (1, 0);
    }

    if b < 0 {
        b = -b;
        a = -a;
    }

    let g = gcd(a.abs() as usize, b.abs() as usize) as isize;
    (a / g, b / g)
}

fn inv(ab: (isize, isize)) -> (isize, isize) {
    if ab == (1, 0) {
        return (0, 1);
    }

    if ab == (0, 1) {
        return (1, 0);
    }

    if ab.0 < 0 {
        (ab.1, -ab.0)
    } else {
        (-ab.1, ab.0)
    }
}

static MOD: isize = 1000000007;

#[fastout]
fn main() {
    input! {
        n: usize,
        abs: [(isize, isize); n]
    };

    let mut f = vec![0; n + 1];
    f[0] = 1;
    for i in 1..=n {
        f[i] = (f[i - 1] * 2) % MOD;
    }

    let mut abzero = 0;
    let mut abs2 = vec![];
    let mut hash = std::collections::HashMap::<(isize, isize), usize>::new();
    for (a, b) in abs {
        if a == 0 && b == 0 {
            abzero += 1;
            continue;
        }

        let rab = reduce(a, b);
        if let Some(v) = hash.get_mut(&rab) {
            *v = *v + 1;
        } else {
            hash.insert(rab, 1);
        }

        abs2.push((a, b));
    }

    let mut set = std::collections::HashSet::<(isize, isize)>::new();
    let mut m = 1;
    let abs2len = abs2.len();

    while let Some((&rab, &c)) = hash.iter().next() {
        hash.remove(&rab);

        let mut s = 1;
        for _ in 0..c {
            s *= 2;
            s %= MOD;
        }

        let rab_inv = inv(rab);

        if let Some(d) = hash.remove(&rab_inv) {
            s += (MOD - 1);
            s %= MOD;

            let mut t = 1;
            for _ in 0..d {
                t *= 2;
                t %= MOD;
            }

            t += (MOD - 1);
            t %= MOD;

            m *= (s + t + 1) % MOD;
            m %= MOD;
        } else {
            m *= s;
            m %= MOD;
        }
    }

    if abzero == n {
        println!("{}", n);
    } else {
        println!("{}", (abzero as isize + m + (MOD - 1)) % MOD);
    }
}


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

int main() {
  int64_t N, blue, red, C, D, E, ans;
  cin >> N >> blue >> red;
  C=blue+red;
  		
  if (C!=0) {
    D=N/C;
    E=N%C;
  }
  else if (C==0) {
    D=0;
    E=0;
  }
  
    ans=D*blue+min(E,blue);
    cout << ans << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
using namespace std;
long long int inf = 1e18;

int main() {

  vector< vector<int> > c(3, vector<int>(3));
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++) cin >> c[i][j];
  }

  vector<int> a(3, 0);
  vector<int> b(3, 0);
  for(int i=0; i<=100; i++){
    bool f = true;
    a[0] = i;
    for(int j=0; j<3; j++){
      b[j] = c[0][j] - a[0];
    }

    a[1] = c[1][0] - b[0];
    for(int j=0; j<3; j++){
      if( a[1] != (c[1][j] - b[j]) ) f = false;
    }
    a[2] = c[2][0] - b[0];
    for(int j=0; j<3; j++){
      if( a[2] != (c[2][j] - b[j]) ) f = false;
    }
    if ( f ){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}




//


Measured memory_bytes: 256
import copy
a=list(input())
b=a.copy()
count1=0
count2=0
for i in range(len(a)-1):
    if a[i]==a[i+1]:
        count1+=1
        if a[i]=="0":
            a[i+1]="1"
        else:
            a[i+1]="0"

for i in range(len(b)-2,-1,-1):
    if b[i]==b[i+1]:
        count2+=1
        if b[i+1]=="0":
            b[i]="1"
        else:
            b[i]="0"
print(min(count1,count2))

Measured memory_bytes: 5284
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {

    vector<int> data{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int K;
    cin >> K;

    
    
    
    cout << data.at(K-1) << endl;


    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;
#define pi 3.141592653589793283462
int main(){
    int c;
	int d=0;
	while (cin>>c)
	{
		for(int i=0;i<=9;i++){
			for(int j=0;j<=9;j++){
				for(int k=0;k<=9;k++){
					for(int l=0;l<=9;l++){
					   if(i+j+k+l==c)
						   d++;
					}
				}
			}
		}
		cout<<d<<endl;
		d=0;
	}
	return 0;
}

Measured memory_bytes: 1160
//
// Created by munaiyi on 2020/3/7.
//

#include <bits/stdc++.h>

using namespace std;

const int maxn = 500000 + 5;

char shit[maxn];
int num[maxn << 2];

void init(int id, int l, int r) {
    if (l == r) {
        num[id] = 1 << (shit[l - 1] - 'a');
        return;
    }
    int mid = (l + r) >> 1;
    init(id << 1, l, mid);
    init(id << 1 | 1, mid + 1, r);
    num[id] = num[id << 1] | num[id << 1 | 1];
}

void update(int id, int l, int r, int w, int v) {
    if (l == r) {
        num[id] = 1 << v;
        return;
    }
    int mid = (l + r) >> 1;
    if (w <= mid) update(id << 1, l, mid, w, v);
    else update(id << 1 | 1, mid + 1, r, w, v);
    num[id] = num[id << 1] | num[id << 1 | 1];
}

int Q(int id, int l, int r, int tl, int tr) {
    if (l == tl && r == tr) {
        return num[id];
    }
    int mid = (l + r) >> 1;
    if (tr <= mid) return Q(id << 1, l, mid, tl, tr);
    else if (tl > mid) return Q(id << 1 | 1, mid + 1, r, tl, tr);
    else return Q(id << 1, l, mid, tl, mid) | Q(id << 1 | 1, mid + 1, r, mid + 1, tr);
}

int main() {
    int n;
    scanf("%d", &n);
    scanf("%s", shit);
    init(1, 1, n);
    int q;
    scanf("%d", &q);
    while (q--) {
        int op;
        scanf("%d", &op);
        if (op == 1) {
            int id;
            char v[10];
            scanf("%d%s", &id, &v);
            update(1, 1, n, id, v[0] - 'a');
        } else {
            int l, r;
            scanf("%d%d", &l, &r);
            int cnt = Q(1, 1, n, l, r);
            //printf("%d s\n", cnt);
            int ans = 0;
            while (cnt) {
                ans++;
                cnt = cnt & (cnt - 1);
            }
            printf("%d\n", ans);
        }
    }
    return 0;
}

Measured memory_bytes: 8576
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<set>
#include<vector>
#include<iomanip>
#include<numeric>
using namespace std;

int main(){
  int n,ans;cin>>n;
  for(int i=0;i<sqrt(n)+1;i++)if(i*i<=n)ans=i*i;
  cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n,k;
    cin >> n >> k;
    VLL x(n);
    REP(i,0,n) cin >> x[i];
    //LL ans = 1'000'000'000'000'000'000 * 2;
    //LL sum = 0;
    LL ans = x[k-1] - x[0] + min(abs(x[k-1]), abs(x[0]));
    REP(i,1,n-k+1) {
        LL sum = x[k-1+i] - x[i] + min(abs(x[k-1+i]), abs(x[i]));
        ans = min(ans, sum);
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define LiangJiaJun main
#define ll long long
using namespace std;
ll a[200004],ans;
int n;
ll calc(ll x){
   ll res=0;
   for(int i=1;i<=n;i++)res+=abs(a[i]-x);
   return res;
}
int LiangJiaJun(){
    ans=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
    for(int i=1;i<=n;i++)a[i]-=i;
    sort(a+1,a+n+1);

    ans=min(calc((a[(n>>1)+1]+a[n>>1])/2),min(calc(a[n>>1]),calc(a[(n>>1)+1])));
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const ll mod = 1000000007;
const int MAX = 5e5 + 10;

int main(){
    int n; cin >> n;
    ll a = 0, b = 0;
    for(int i = 0; i < n; i++){
        ll x, y; cin >> x >> y;
        if(i == 0){
            a = x; 
            b = y;
            continue;
        }
        ll cnt = max((a + x - 1) / x, (b + y - 1) / y);
        if(cnt * x >= a && cnt * y >= b){
            a = cnt * x;
            b = cnt * y;
        }
    }
    cout << a + b << endl;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
typedef long long ll;
using namespace std;
int A, B, C, D, E, F;
double DP[3005][3005]; // 水、砂糖

double dfs(int water, int sugar){ // 水の量(100の倍数)、砂糖の量
  if (DP[water][sugar]>0) return DP[water][sugar];
  double res = water>0?(double)sugar/(water+sugar):0.0;
  DP[water][sugar] = res;
  rep(i, 4){
    if (i==0){
      if (water+sugar+100*A <= F) res = max(dfs(water+100*A, sugar), res);
    } else if (i==1){
      if (water+sugar+100*B <= F) res = max(dfs(water+100*B, sugar), res);
    } else if (i==2){
      if (water+sugar+C<=F && (sugar+C)*100 <=E*water) res = max(dfs(water, sugar+C), res);
    } else {
      if (water+sugar+D<=F && (sugar+D)*100 <= E*water) res = max(dfs(water, sugar+D), res);      
    }
  }
  return res;
}

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

  cin >> A >> B >> C >> D >> E >> F;
  double ans = dfs(0, 0);
  for (int i=100*A; i<=F; i+=100){
    for (int j=0; j<=F-i; j++){
      if (DP[i][j]==ans){
        cout << i+j << ' ' << j << "\n";
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 45312
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>

using namespace std;

int main()
{
	int n, m;
	int res;

	cin >> n >> m;

	res = (n - 1) * (m - 1);
	cout << res << endl;
}

Measured memory_bytes: 764
#include "bits/stdc++.h"
using namespace std;
int main() {
	int N; cin >> N;
	N--;
	vector<int>A(N);
	vector<int>Count(N + 1, 0);
	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
		Count.at(A.at(i) - 1)++;
	}
	for (int i = 0; i <= N; i++) {
		cout << Count.at(i) << endl;
	}
}

Measured memory_bytes: 4844
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n; cin>>n;
    vector<int> l(n+1, 0), r(n+1, 0);
    for(int i=0; i<n; i++) cin>>l[i]>>r[i];
    sort(l.begin(), l.end(), greater<int>());
    sort(r.begin(), r.end());

    ll ans = 0;
    for(int i=0; i<n+1; i++){
        if(r[i] < l[i]){
            ans += 2 * (l[i] - r[i]);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string.h>
using namespace std;
int main(void){
   int n,len,sum,max=0;
	char ch[105];
	int mp[26],np[26];
	scanf("%d",&n);getchar();
	scanf("%s",ch);
	len=strlen(ch);
	for(int i=1;i<len-1;i++)
	{
		sum=0;
		for(int j=0;j<26;j++)
		{
			mp[j]=0;
			np[j]=0;
		}
		for(int j=0;j<i;j++)mp[ch[j]-'a']++;
		for(int j=i;j<=len-1;j++)np[ch[j]-'a']++;
		for(int j=0;j<26;j++)if(mp[j]!=0&&np[j]!=0)sum++;
		if(sum>max)max=sum;
	}
	printf("%d\n",max);


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>pi;
const int MAXN=200005;
const int MOD=1000000007;
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define fst first
#define snd second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())

int N;
int A[MAXN];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>N;
	FOR(i,1,N)cin>>A[i];
	sort(A+1,A+N+1);
	cout<<A[N/2+1]-A[N/2]<<"\n";
}
/*
*/


Measured memory_bytes: 640
N = int(input())

def check(n):
    if n % 2 == 0:
        return 0
    cnt = 0
    for i in range(1, n+1):
        if n % i == 0:
            cnt = cnt + 1
    return 1 if cnt == 8 else 0

ans = 0
for i in range(1, N+1):
    ans = ans + check(i)
print (ans)
    


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

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

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


  REP( i, n ){
    int res = 0;
    int y, m, d; cin >> y >> m >> d;
    FOR( j, y, 1000 ){
	
	FOR( k, m, 11 ){
	  if( k % 2 == 1 || j % 3 == 0 ){
	    res += 20 - d;
	  }else{
	    res += 19 - d;
	  }
	  d = 0;
	}
	m = 1;
    }
    
    cout << res + 1 << endl;
  }

}



Measured memory_bytes: 3084
def get_sum_arr(arr):
    sum_arr = [0]
    N = len(arr)
    for i in range(1,N+1):
        sum_arr.append(sum_arr[i-1] + arr[i-1])
    return sum_arr

def get_max_b(left_time,j,B_sum_arr):
    # [0,1,2,3,4,5]
    while B_sum_arr[j] > left_time and j > 0:
        j -= 1
    return j
def get_max_book_num(A,B,K):
    A_sum_arr,B_sum_arr = get_sum_arr(A),get_sum_arr(B)
    count,i,j = 0,0,len(B_sum_arr)-1
    for i in range(0,len(A_sum_arr)):
        if K < A_sum_arr[i]:
            break
        else:
            left_time = K - A_sum_arr[i]
            j = get_max_b(left_time,j,B_sum_arr)
        count = max(count,(i+j))
    return count
if __name__ == "__main__":
    N,M,K = list(map(int,input().split()))
    A = list(map(int,input().split()))
    B = list(map(int,input().split()))
    print(get_max_book_num(A,B,K))
    


Measured memory_bytes: 47544
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = a; i < (b); ++i)
#define rrep(i,a,b) for(int i = b; i --> (a);)
#define all(v) v.begin(),v.end()
#define trav(x,v) for(auto &x : v)
#define sz(v) (int)(v).size()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

ll gcd(ll x, ll y){
	while(x){
		y %= x;
		swap(x,y);
	}
	return y;
}

bool solve(){
	ll a,b,c,d;
	cin >> a >> b >> c >> d;
	if(b > d) return false;
	if(b > a) return false;
	if(b <= c+1) return true;
	ll g = gcd( b, d-b);
	ll r = (a-c-1) % g;
	if(r < 0) r += g;
	if(r+c+1 < b) return false;
	return true;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int t;
	cin >> t;
	while(t--){
		cout << (solve() ? "Yes" : "No") << endl;
	}

}


Measured memory_bytes: 256
#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
string grid[1000];
int dp[1000][1000],h,w;
int paths(int i,int j)
{
    if(i>=0&&i<h&&j>=0&&j<w)
    {
        // cout<<i<<" "<<j<<"  ";
        if(dp[i][j]>=0) {/*cout<<dp[i][j]<<endl;*/ return dp[i][j];}
        if(grid[i][j]=='#') {dp[i][j] = 0; /*cout<<dp[i][j]<<endl;*/ return 0;}
        if(i==h-1&&j==w-1) {dp[i][j] = 0; /*cout<<dp[i][j]<<endl;*/ return 0;}
        if(i==h-2&&j==w-1) {dp[i][j]=1; /*cout<<dp[i][j]<<endl;*/ return 1;}
        if(i==h-1&&j==w-2) {dp[i][j]=1; /*cout<<dp[i][j]<<endl;*/ return 1;}
        dp[i][j] = (paths(i+1,j)+paths(i,j+1))%1000000007;
        /*cout<<dp[i][j]<<endl;*/ return dp[i][j];
    }
    else return 0;
}
int32_t main()
{
    IOS
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif
    cin>>h>>w;
    for(int i=0;i<h;i++) cin>>grid[i];
    for(int i=0;i<h;i++) for(int j=0;j<w;j++) dp[i][j]=-1;
    cout<<paths(0,0);
    return 0;
}

Measured memory_bytes: 9216
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main(){
  int A, B;
  cin >> A >> B;
  cout << (A-1) * (B-1) << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main (String[] args){
		
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();//??????????????????
		
		int [] intAry = new int[N];
		
		for( int i = 0 ; i < intAry.length ; i++){
			intAry[i] = sc.nextInt();
		}
		
		for( int i = 0 ; i < intAry.length ; i++){
			
			if( i == 0){
				System.out.print(intAry[i]);
			}else{
				System.out.print(" " + intAry[i]);
			}
		}
		
		System.out.println();
		
		for (int i = 1; i < intAry.length; i++) {
			int j = i;
			while(j > 0 && intAry[j-1] > intAry[j]){
				int temp = intAry[j];
				intAry[j] = intAry[j-1];
				intAry[j-1] = temp;
				j--;
			}
			for( int x = 0 ; x < N ; x++ ){
				if( x == 0){
					System.out.print(intAry[x]);
				}else{
					System.out.print(" " + intAry[x]);
				}
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 32388
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
public class Hello
{
    private const int INF = 1000000007;
    public static void Main()
    {
        string s = NextString();
        int K = NextInt();
        //それぞれに対して何回でaに戻せるか考える
        int[] cost = new int[s.Length];
        for (int i = 0; i < s.Length; i++)
            cost[i] = ('z' - s[i] + 1) % 26;
        for (int i = 0; i < s.Length - 1; i++)
        {
            if (cost[i] <= K)
            {
                Console.Write('a');
                K -= cost[i];
            }
            else Console.Write(s[i]);
        }
        K %= 26;
        Console.WriteLine(((char)(s.Last() + K)) > 'z' ? (char)(s.Last() - 'z' + 'a' - 1 + K) : (char)(s.Last() + K));
    }
}

public class Input
{
    private static Queue<string> queue = new Queue<string>();
    private static void Confirm() { if (queue.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) queue.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(queue.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(queue.Dequeue()); }
    public static string NextString() { Confirm(); return queue.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(queue.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 13396
#include<stdio.h>
int main()
{
	int a[31] = { 0 }, n, i;
	for (i = 0; i < 28; i++) {
		scanf("%d", &n);
		a[n]=a[n]+1;
	}
	for (i = 1; i < 31; i++) {
		if (a[i] != 1) {
			printf("%d\n", i); 
		}
	}
}

Measured memory_bytes: 2688
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()

using namespace std;

signed main()
{
	int N, D;
	cin >> N >> D;
	int d = D * 2 + 1;
	int ans = ceil(N / (double)d);
	cout << ans << endl;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>

using namespace std;
typedef long long int ll;

#define C cout<<
#define E <<endl

ll n,m,a,b,c,x,y,z,aa[100010],ba[100010];
bool r,ra,rb,rc;
string s,sa,sb,sc;
char ca,cb,cc,cd[1000][1000];
vector<ll> va,vb,vc;


int main(){
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>aa[i];
    }
    sort(aa,aa+n,greater<ll>());
    a=0;
    for(int i=0;i<m;i++)a+=aa[i];
    C a E;
    
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
A+=[0]
A+=[0]
dp=[float("INF")]*(N+2)
dp[0]=0
dp[1]=abs(A[1]-A[0])
for i in range(N):
  dp[i+1]=min(dp[i+1],abs(A[i+1]-A[i])+dp[i])
  dp[i+2]=min(dp[i+2],abs(A[i+2]-A[i])+dp[i])
print(dp[N-1])

Measured memory_bytes: 13980
/* kadai 3_3
   nabe9393 */
 
#include<stdio.h>
 
int main(void){
  int number, base;//numberは入力値、baseは進法を表す。
  int digit = 1;//digitは桁数
  scanf("%d %d", &number, &base);//入力
  while (number / base > 0){
    digit += 1 ;
    number = number / base;
  }
  printf("%d\n", digit);
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    int a, ans = 0;
    for(int i = 0; i < n; i++){
        cin >> a;
        while(a % 2 == 0){
            a /= 2;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
// Ho-kago Tea Time

#include <bits/stdc++.h>

using namespace std;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getchar());
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getchar()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

typedef long long LL;
typedef pair<int, int> pii;

LL a, b;

inline void input()
{
	a = read<LL>(), b = read<LL>();
}

const int D = 59;

inline LL calc(LL L, LL R) { return R - L; }

inline void solve()
{
	if(a == b) { puts("1"); return; }

	for(int i = D; i >= 0; --i)
		if((a >> i & 1) ^ (b >> i & 1)) break;
		else a &= ~(1ll << i), b &= ~(1ll << i);

	int k = -1;
	for(int i = D; i >= 0; --i) if((a >> i & 1) ^ (b >> i & 1)) { k = i; break; }

	int p = -1;
	while((1ll << k) + (1ll << (p + 1)) <= b) ++p;

	if((1ll << k) + (1ll << (p + 1)) >= a + (1ll << k)) printf("%lld\n", calc(a, (1ll << (k + 1))));
	else printf("%lld\n", calc(a, (1ll << k) + (1ll << (p + 1))) + calc(a + (1ll << k), 1ll << (k + 1)));
}

int main()
{
#ifdef K_ON // K-ON!
	freopen("D.in", "r", stdin);
	freopen("D.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void){
  int h, w;
  cin >> h >> w;
  REP(i, 0, h){
    REP(j, 0, w) {
      string s;
      cin >> s;
      if (s == "snuke") {
	cout << (char)('A' + j)  << (i+ 1) << endl;
      }
    }
  }
}


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

int main() {
    int n;
    cin >> n;
    int res = 100100101;
    rep(i, n) { 
        int a, div;
        cin >> a;
        div = 0;
        while (a % 2 == 0) {
            a /= 2;
            div++;
        }
        res = min(res, div);
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
#include<algorithm>
#include<utility>
#include<vector>
#include<climits>
#include<queue>
#include<random>

#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;


int h,w;

int main(int argc, char const *argv[]) {


    cin >> h >> w;
    vector<string> field(h);
    vector<string> out(h);

    bool row[h];
    bool column[w];
    rep(i,h) row[i] = false;
    rep(i,w) column[i] = false;
    rep(i,h){
        cin >> field[i];
    }
    // rep(i,h){
    //     cout <<  field[i];
    //     cout << endl;
    // }
    for(int i=0;i<h;i++){
        bool all_white = true;
        for(int j=0;j<w;j++){
            if(field[i][j] != '.'){
                all_white = false;
            }
        }
        if(all_white){
            row[i] = true;
        }
    }

    for(int i=0;i<w;i++){
        bool all_white = true;
        for(int j=0;j<h;j++){
            if(field[j][i] != '.'){
                all_white = false;
            }
        }
        if(all_white){
            column[i] = true;
        }
    }
    //rep(i,h)cout << row[i] << endl;
    //cout << endl;
    //rep(i,w)cout << column[i] << endl;
    int index=0;
    for(int i=0;i<h;i++){
        if(!row[i]){
            string str="";
            for(int j=0;j<w;j++){
                if(!column[j]){
                    str+=field[i][j];
                }
            }
            out[index] = str;
            index++;
        }
    }
    rep(i,index){
        cout << out[i];
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a = [list((int(x) for x in input().split())) for _ in range(n)]

cnt = 0
for i in range(n):
    wk = sum([ai*bi for ai, bi in zip(a[i], b)]) + c
    if wk > 0:
        cnt += 1
ans = cnt
print(ans)


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

int main() {
  int N, cnt=0;
  cin >> N;
  vector<int> A(N), V(N);
  rep(i, N) cin >> A.at(i);
  rep(i, pow(3, N)){
    int tmp=i, Sum=1;
    rep(j, N){
      V.at(j)=tmp%3;
      tmp/=3;
    }
    rep(j, N) Sum=Sum*(A.at(j)+V.at(j)-1);
    if(Sum%2==0) cnt++;
  }
  cout<< cnt <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n,m;
  cin >> n >> m;
  int c[n];
  mem(c);
  rep(i,m) {
    int x,y;
    cin >> x >> y;
    x--,y--;
    c[x]++;
    c[y]++;
  }
  rep(i,n) pr(c[i]);

}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
S=list(input())
XXYY=[]
l=' '
for i in range(2):
    l+=S[i]
XXYY.append(int(l))
l=' '
for i in range(2,4):
    l+=S[i]
XXYY.append(int(l))

ans=[]
if XXYY[0]>12:
    if XXYY[1]<=12 and XXYY[1]>0:
        ans.append("YYMM")
    else:
        ans.append("NA")
elif XXYY[0]<=12 and XXYY[0]>0:
    if XXYY[1]>12:
        ans.append("MMYY")
    elif XXYY[1]<=12 and XXYY[1]>0:
        ans.append("AMBIGUOUS")
    else:
        ans.append("MMYY")
else:
    if XXYY[1]<=12 and XXYY[1]>0:
        ans.append("YYMM")
    else:
        ans.append("NA")
print(ans[0])

Measured memory_bytes: 3064