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

using namespace std;

#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const int ddx[8]={1,-1,0,0,1,1,-1,-1};
static const int ddy[8]={0,0,1,-1,1,-1,1,-1};

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

int N,M;
int A[100005];

signed main(){
    cin>>N>>M;
    priority_queue<int> pq;
    for(int i=0;i<N;++i){
        int a;
        cin>>a;
        pq.push(a);
    }
    for(int i=0;i<M;++i){
        int p=pq.top();
        pq.pop();
        p/=2;
        pq.push(p);
    }
    int ans=0;
    while(pq.size()){
        ans+=pq.top();
        pq.pop();
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4328
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>

void Output(const std::vector<std::pair<int, int> >& List)
{
    for(std::vector<std::pair<int, int> >::const_iterator It = List.begin();
        It != List.end();
        ++It)
    {
        std::cout << " " << It->second;
    }
    std::cout << std::endl;
}

int main()
{
    std::string l;
    std::cin >> l;

    std::vector<int> S1;
    std::vector<std::pair<int, int> > S2;
    int sum = 0;
    for(int i = 0; i < l.size(); ++i){
        if(l[i] == '\\'){
            S1.push_back(i);
        }else
        if(l[i] == '/' && S1.empty() == false){
            int j = S1.back(); S1.pop_back();
            int a = i - j;
            sum += a;
            
            while( S2.empty() == false && S2.back().first > j){
                a += S2.back().second; S2.pop_back();
            }
            S2.push_back(std::pair<int, int>(j, a));
        }
    }
    std::cout << sum << std::endl;
    std::cout << S2.size();
    Output(S2);
    return 0;
}

Measured memory_bytes: 1376
#include <iostream>
#include <vector>
#include <algorithm>
#define INF (1LL<<62)
using namespace std;

int main(){
    long long N,K; cin >> N >> K;
    vector<long long> P(N+1,0),C(N+1,0);
    vector< vector<long long> > scores(N+1,vector<long long>(N+1,0));
    for(int i=1;i<=N;i++) cin >> P.at(i);
    for(int i=1;i<=N;i++) cin >> C.at(i);
    for(int i=1;i<=N;i++){
        int p=P.at(i);
        for(int j=1;j<=N;j++){
            if(p==i){
                scores.at(i).at(j)=scores.at(i).at(j-1)+C.at(p);
                for(int k=j+1;k<=N;k++){
                    scores.at(i).at(k)=INF;
                }
                break;
            }
            scores.at(i).at(j)=scores.at(i).at(j-1)+C.at(p);
            p=P.at(p);
        }
    }
    vector< vector<long long> > scores_copy=scores;
    for(int i=1;i<=N;i++){
        long long score_max;
        score_max=0;
        for(int j=1;j<=N;j++){
            score_max=max(score_max,scores_copy.at(i).at(j));
            scores_copy.at(i).at(j)=score_max;
        }
    }
    /*
    for(int i=0;i<=N;i++){
        for(int j=0;j<=N;j++){
            cout << scores.at(i).at(j) << " ";
        }
        cout << endl;
    }
    cout << endl;
    for(int i=0;i<=N;i++){
        for(int j=0;j<=N;j++){
            cout << scores_copy.at(i).at(j) << " ";
        }
        cout << endl;
    }
    */
    long long ans=-INF;
    for(int i=1;i<=N;i++){
        int m=N;
        long long temp=-INF;
        for(int j=1;j<=N;j++){
            if(scores.at(i).at(j)==INF){
                m=j-1;
                break;
            }
        }
        if(K<=m){
            temp=scores.at(i).at(1);
            for(int j=2;j<=K;j++){
                temp=max(temp,scores.at(i).at(j));
            }
        }else if(K>m){
            temp=scores.at(i).at(1);
            for(int j=1;j<=m;j++){
                temp=max(temp,scores.at(i).at(j));
            }
            //cout << K%m << " " << m << " " << i << endl;
            if(K%m>0){
                temp=max(temp,((K/m)*scores.at(i).at(m))+scores_copy.at(i).at(K%m));
            }else{
                temp=max(temp,(((K/m)-1)*scores.at(i).at(m))+scores_copy.at(i).at(m));
            }
        }
        ans=max(ans,temp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 394788
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m,i,j,a,max=0;
	scanf("%d%d",&n,&m);
	for(i=0;i<m;i++){
		scanf("%d",&a);
		max+=a;
	}
	if(max>=n)cout<<"Yes";
	else cout<<"No";

}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int m; cin >> m;
    vll d(m), c(m);
    for (int i = 0; i < m; i++) cin >> d[i] >> c[i];
    ll ans = accumulate(ALL(c), 0LL) - 1;
    ll tmp = 0;
    for (int i = 0; i < m; i++) tmp += d[i] * c[i];
    cout << ans + (tmp - 1) / 9 << '\n';
    return 0;
}


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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define rall(v) v.rbegin(), v.rend()
#define F first
#define S second

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

#define MAX 10000007

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

	int x, y, a, b, c; 
    cin >> x >> y >> a >> b >> c;
    vector<ll> r(a), g(b), l(c);
    FOR(i, a) cin >> r[i];
    FOR(i, b) cin >> g[i];
    FOR(i, c) cin >> l[i];

    sort(rall(r));
    sort(rall(g));
    sort(rall(l));

    int p1 = x-1, p2 = y-1;
    ll ans = 0;
    FOR(i, x) ans += r[i];
    FOR(i, y) ans += g[i];

    FOR(i, c){
        ll m;
        if(p1 >= 0 && p2 >= 0)
            m = min(r[p1], g[p2]);
        else if(p1 >= 0)
            m = r[p1];
        else if(p2 >= 0)
            m = g[p2];
        else{
            break;
        }
        bool ok = false;
        if(ans - m + l[i] > ans){
            ans += l[i]-m;
            if(m == r[p1]) p1--;
            else p2--;
            ok = true;
        }
        if(!ok) break;
    }

    cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 2560
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)

# ax ≡ 1 (mod m)
def modinv(a, m):
    (inv, q, gcd_val) = egcd(a, m)
    return inv % m
N = 10**9+7
R = 10**5*2
modfact = [0]*(R+1)
def modfact_memo(n,N):
    r = 1
    modfact[0] = 1
    for i in range(1,n+1):
        r = r % N * i % N
        modfact[i] = r
modfact_memo(R,N)

# ax ≡ 1 (mod m)
modinv=[0]*(R+1)
def modinv_memo(a,m):
    for i in range(a+1):
        j = modfact[i]
        (inv, q, gcd_val) = egcd(j, m)
        modinv[i] = inv % m
modinv_memo(R,N)

def modconb(n,r,N):
    p = modfact[n]
    q1 = modinv[r]
    q2 = modinv[n-r]
    return p*q1%N*q2%N

H,W,A,B = map(int,input().split())
ans = 0
for r in range(B,W):
    ans += modconb(H-A-1+r,r,N)*modconb(A-1+W-r-1,A-1,N)
    ans %= N

print(ans)

Measured memory_bytes: 20384
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define rep0(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)

using namespace std;

int main(){

	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif*/

	int n,k;
	cin >> n >> k;
	long double ans = 0;
	rep1(i,min(n,k-1)){
		int count = 0, num = k/i;
		while(num!=0){
			count++;
			num /= 2;
		}
		int newnum = 1;
		rep1(j,count-1) newnum *= 2;
		if(newnum==k/i && k%i==0) count--;
		long double var = 1.0/n;
		rep0(j,count) var /= 2.0;
		ans += var;
	}
	if(n>=k) rep1(i,n-k+1) ans += 1.0/n;
	cout << setprecision(20) << ans;

	//cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";

	return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>

int a()
{
    int n;
    std::cin >> n;
    
    std::vector<int> vec(32);
    vec[0] = 1;
    vec[1] = 1;
    vec[2] = 1;
    vec[3] = 2;
    vec[4] = 1;
    vec[5] = 2;
    vec[6] = 1;
    vec[7] = 5;
    vec[8] = 2;
    vec[9] = 2;
    vec[10] = 1;
    vec[11] = 5;
    vec[12] = 1;
    vec[13] = 2;
    vec[14] = 1;
    vec[15] = 14;
    vec[16] = 1;
    vec[17] = 5;
    vec[18] = 1;
    vec[19] = 5;
    vec[20]= 2;
    vec[21] = 2;
    vec[22] = 1;
    vec[23] = 15;
    vec[24] = 2;
    vec[25] = 2;
    vec[26] = 5;
    vec[27] = 4;
    vec[28] = 1;
    vec[29] = 4;
    vec[30] = 1;
    vec[31] = 51;
    
    
    std::cout << vec[n-1];
    
    return 0;

}

int main(int argc, const char * argv[])
{
    a();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,Hp,H;
  bool ans = true;
  cin >> N;
  cin >> Hp;
  for(int i=1;i<N;i++){
    cin >> H;
    if(Hp-1 > H){
      ans = false;
      break;
    }
    if(Hp < H){
      Hp = H;
    }
  }
  if(ans){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<string>
using namespace std;
int main(){
	int n,e=1,some=0,dim;
	string s;
	cin>>s;
	for(int i=s.size()-1;0<=i;i--){
		some+=s[i]-'0';
		n+=((int)(s[i]-'0'))*e;
		dim=n;
		e*=10;
	}
	//dim=n;
	//cout<<dim<<endl;
	if(dim%some==0){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}

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

int main(){
    int n,k;
    cin >> n >> k;
    long long count = 0;
    if(k % 2 == 0){
        long long odd=0,eve=0;
        for(int i = 1; i <= n; i++){
            if(i%k == 0)
                eve++;
            else if(i%k == k/2)
                odd++;
        }
        if(eve > 0)
            count += pow(eve,3);
        if(odd > 0)
            count += pow(odd,3);
    }
    else{
        int c = 0;
        for(int i= 1; i <=n; i++){
            if(i%k == 0)
                c++;
        }
        if(c > 0)
            count = pow(c,3);
    }
    cout << count;
}

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

ll gcd(ll x, ll y);
int fac(ll n, vector<int> num);

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

const int INF = 1001001001;

//mint�p�̒萔 (10��9��)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

int main() {
    int n;
    cin >> n;
    vector<vector<int> > abc(n, vector<int> (3));
    rep(i, n) cin >> abc[i][0] >> abc[i][1] >> abc[i][2];

    vector<vector<int> > dp(n + 1 , vector<int>(3));
    rep(i, n) {
        rep(j, 3) {
            rep(k, 3) {
                if (j == k) continue;
                chmax(dp[i + 1][j], dp[i][k] + abc[i][k]);
            }
        }
    }

    int ans = 0;
    rep(i, 3) {
        ans = max(dp[n][i], ans);
    }
    cout << ans << endl;
    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
ll gcd(ll x, ll y) {
    ll num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

Measured memory_bytes: 14152
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int fx = 0;
        int tmp = N;
        
        while(tmp != 0){
            fx += tmp % 10;
            tmp /= 10;
        }
        System.out.println(N % fx == 0 ? "Yes" : "No");
    }   
}


Measured memory_bytes: 23892
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
long double a,b,c;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a>>b>>c;
    long double al=sqrt(a*b);
    if(a+b+2*al<c)yes;
    else no;
}


Measured memory_bytes: 256
#include "stdio.h"
#include "stdbool.h"

int main(){
	int n;
	scanf("%d",&n);
	int ans=0;
	for(int i=0;i<n;++i){
		int x;
		scanf("%d",&x);
		bool ok=true;
		for(int j=2;j*j<=x;++j){
			if(x%j==0){
				ok=false;
				break;
			}
		}
		ans+=ok;
	}
	printf("%d\n",ans);
}



Measured memory_bytes: 2112
import sys

n, m = list(map(int, input().split()))
aaa = list(map(int, input().split()))
aaa.sort()
bc = []
for line in sys.stdin:
    b, c = map(int, line.split())
    bc.append((c, b))
bc.sort(reverse=True)
ans = 0
cnt = 0
for c, b in bc:
    while aaa and aaa[-1] >= c and cnt < n:
        ans += aaa.pop()
        cnt += 1
    if cnt + b >= n:
        ans += c * (n - cnt)
        cnt = n
        break
    ans += c * b
    cnt += b
if cnt < n:
    ans += sum(aaa[cnt - n:])
print(ans)


Measured memory_bytes: 21036
s = gets.chomp

l = 0
r = s.size - 1
res = 0
while r > l
  if s[l] == s[r]
    l += 1
    r -= 1
    next
  end
  if s[l] == 'x'
    # xooo
    l += 1
  elsif s[r] == 'x'
    # ooox
    r -= 1
  else
    # aoo
    res = -1
    break
  end
  res += 1
end
puts res

Measured memory_bytes: 1916
N = int(input())
K = int(input())
Ns = input().split()
Ns = list(map(int,Ns))

kyori = []
for i in range(len(Ns)):
	a = Ns[i]
	b = K - Ns[i]

	if(a<=b):
		kyori.append(a*2)
	else:
		kyori.append(b*2)

print(sum(kyori))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;

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;}

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    ll n,m;
    cin>>n>>m;
    vll h(n);
    rep(i,0,n)cin>>h[i];
    vi conne[n];
    rep(i,0,m){
        int a,b;
        cin>>a>>b;
        a--,b--;
        conne[a].push_back(b);
        conne[b].push_back(a);
    }
    ll ans=0;
    rep(mt,0,n){
        bool check=true;
        for(int cmp:conne[mt]){
            if(h[cmp]>=h[mt]){
                check=false;
                break;
            }
        }
        if(check)ans++;
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 9068
S = gets.chomp

s = S.dup
s.delete!('x')

if s != s.reverse
  puts -1
  exit
end

queue = S.chars
ans = 0

while queue.size > 1
  if queue.first == queue.last
    queue.pop
    queue.shift
  elsif queue.first == 'x'
    ans += 1
    queue.shift
  else
    ans += 1
    queue.pop
  end
end

puts ans



Measured memory_bytes: 9596
import math
n=int(input())
P=list(map(int,input().split()))
Q=list(map(int,input().split()))
L=[]
R=[]
ans=0
p,q=0,0
cntp,cntq=0,0
for i in range(n):
  L.append(i+1)
  R.append(i+1)
  

for i in range(n):
    for j in L:
        if P[i] > j:
            cntp += 1
    for j in R:
        if Q[i] > j:
            cntq += 1
            
    p+=cntp*math.factorial(n-i-1)
    q+=cntq*math.factorial(n-i-1)
   
    L.remove(P[i])
    R.remove(Q[i])
    cntp,cntq=0,0
print(abs(p-q))
  


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
using std::swap;


int main() {
	int n;
	cin >> n;
	cout << 3 * n*n << "\n";

	return 0;
}

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

using namespace std;
const int IINF = INT_MAX;
using ll = long long;
using P = pair<int,int>;
#define INF 100000000

const double pai = 3.141592653589793238;
int main(){
    int a[3][3];
    rep(i,3){
      rep(j,3)  cin >> a[i][j];
    }
    int n; cin >> n;
    vector<vector<bool> > stamp(3,vector<bool>(3,false));
    
    rep(i,n){
    	int b; cin >> b;
    	rep(i,3){
    		rep(j,3){
    			if(a[i][j] == b){
    				stamp[i][j] = true;
    				break;
    			}
    		}
    	}
    }
    
    rep(i,3){
    	if(stamp[i][0] && stamp[i][1] && stamp[i][2] ){
    		cout << "Yes" << endl;
    		return 0;
    	}
    	if(stamp[0][i] && stamp[1][i] && stamp[2][i] ){
    		cout << "Yes" << endl;
    		return 0;
    	}
    }
    if(stamp[0][0] && stamp[1][1] && stamp[2][2] ){
    		cout << "Yes" << endl;
    		return 0;
    }
    if(stamp[0][2] && stamp[1][1] && stamp[2][0] ){
    		cout << "Yes" << endl;
    		return 0;
    }
    
     cout << "No" << endl;
    
    return 0;	
}

Measured memory_bytes: 256
#include<cstdio>
#include <algorithm>
#define MAX 300005
using namespace std;

int main(){
    int n, mn = 0, t = 0, u = 0;
    char s[MAX];
    scanf("%d\n%s", &n, s);
    for(int i = 1; i < n; i++){
        t += (s[i-1] == 'W') + (s[i] == 'W') - 1;
        u += (s[i] == 'E');
        mn = min(mn, t);
    }
    printf("%d\n", u+mn);
}

Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <functional>


#ifdef _DEBUG
#define typeof(X) std::identity<decltype(X)>::type //C++0x (for vs2010)
#else
#define typeof(X) __typeof__(X) // for gcc
#endif

using namespace std;
static const double EPS = 1e-6;
typedef long long ll;
const int MODULO = 1000000007;
const int INF = 100000000; //1e8

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef complex<double> Cd;


int main(){
	int cnt= 0;
	string s;
	while(cin>>s){
		string v(s.rbegin(),s.rend());
		if(s == v) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

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

const ll INF = 1ll << 60;
ll MOD = 998244353;

int main()
{

    int k, x;
    cin >> k;
    cin >> x;
    if (x <= 500 * k)
        cout << "Yes";
    else
        cout << "No";

    return 0;
}

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

int main() {
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  int c5 = 0;
  int c7 = 0;
  for (int i = 0; i < 3; i++) {
    if (a[i] == 5) c5++;
    else if (a[i] == 7) c7++;
  }
  cout << ((c5 == 2 && c7 == 1) ? "YES" : "NO") << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
lli n,k;
vector<lli>v;
vector<lli>ans;
int frog2(lli i)
{
    lli y = min(k,(n-1-i));
    lli m =1000000000000000;

    for(lli l=1;l<=y;l++)
    {
        lli a = abs(v[i+l]-v[i])+ans[i+l];
        m = min(a,m);
    }
    ans[i] =m;

}
int main()
{
    cin >>n >>k;
    lli p;
    for(lli i=0;i<n;i++)
    {
        cin >>p ;v.push_back(p);
    }
    ans.resize(n+1);
    ans[n-1]=0;
    ans[n-2] = abs(v[n-1]-v[n-2]);
    for(lli j= n-3;j>=0;j--)
    {
        frog2(j);
    }
    cout <<ans[0]<<"\n";
}

Measured memory_bytes: 1908
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)


int main(){

    int n;
    cin >> n;
    vector<int> v(n);
    REP(i,n){cin >> v[i];}
    sort(v.begin(), v.end(), greater<int>());
    cout << accumulate(v.begin(), v.end(), 0) - v[0] / 2 << endl;

    return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){

  int n,k;
  cin >> n >> k;
  vector<ll> h(n);
  REP(i,n)cin >> h[i];
  ll res = (1ll << 60);
  for(int bit = 1;bit < (1 << n);bit++){
    vector<bool> is(n,0);
    REP(i,n)if(bit >> i & 1)is[i] = true;
    ll height = 0;
    ll sum = 0;
    int c = 0;
    REP(i,n){
      if(!is[i]){
        if(h[i] > height)c++;
        height = max(height,h[i]);
        continue;
      }
      c++;
      if(h[i] <= height)sum += height-h[i]+1;
      height = max(h[i],height+1);
    }
    if(c >= k)res = min(res,sum);
  }

  cout << res << endl;
  



  return 0;
}

Measured memory_bytes: 256
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int an=0;
    int ma=0;
    REP(i,5){
        int x;
        R(x);
        an+=(x+9)/10*10;
        ma=max(ma,(x+9)/10*10-x);
    }
    W(an-ma);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
int main(void) {
    int i, n;
    cin >> n;
    ll a[n], mx=0;
    for(i=0; i<n; i++) {
        scanf("%lld", &a[i]);
        if(mx<=a[i])
            mx=a[i];
    }
    ll mi=mx, tmp=-1;
    for(i=0; i<n; i++) {
        if(mi>abs(mx/2-a[i]) && mx!=a[i]) {
            mi = abs(mx/2-a[i]);
            tmp = a[i];
        }
        
    }
    cout << mx << ' ' << tmp << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>

using namespace std;

int main() {
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	int money = 0;
	if (c <= (a + b) / 2) {
		if (x <= y) {
			money = 2 * c * x + (y - x) * b;
			if (money > 2 * c * y) money = 2 * c * y;
		}
		else {
			money = 2 * c * y + (x - y) * a;
			if (money > 2 * c * x) money = 2 * c * x;
		}
	}
	else {
		money = a * x + b * y;
	}
	cout << money << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        long X = scan.nextInt();
        long c1 = X / 500;
        long remain = X - c1 * 500;
        long c2 = remain / 5;
        long ans = c1 * 1000 + c2 * 5;
        System.out.println(ans);
    }
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  int n, a, b; cin >> n >> a >> b;
  vector<int> p(n); for(int i = 0; i < n; i++) cin >> p[i];
  int c=0, d=0, e=0;
  for(int i = 0; i < n; i++) {
    if(p[i] <= a) c++;
    else if(a+1 <= p[i] && p[i] <= b) d++;
    else if(b+1 <= p[i]) e++;
  }
  int f = min(c, d);
  cout << min(f, e) << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=30;
int f[N];
int main()
{
	memset(f,0,sizeof(f));
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		f[s[i]-'a']++;
	}
	for(int i=0;i<26;i++)
	{
		if(f[i]%2==1)
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(0);   

  #ifndef ONLINE_JUDGE
      if(fopen("INPUT.txt","r"))
      {
      freopen ("INPUT.txt" , "r" , stdin);
      freopen ("OUTPUT.txt" , "w" , stdout);
      }
  #endif

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

}


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

using namespace std;

#define int long long

int gcd(int a, int b){
    while (a > 0 && b > 0){
        int t = a % b;
        a = b;
        b = t;
    }
    return a + b;
}

main(){
    //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int k = c * d / gcd(c, d);
    cout << b - a + 1 - (b / c - (a - 1) / c) - (b / d - (a - 1) / d) + (b / k - (a - 1) / k) << '\n';
    return 0;
}



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

int max(int a, int b)
{
    if (a >= b) return a;
    else return b;
}


int main(void)
{
    int N, W;
    int weight[1001] = {0};
    int value[1001] = {0};
    int dp[101][10001];
    int i, w;
    scanf("%d %d", &N, &W);
    for (i=0; i<N; ++i) {
        scanf("%d %d", &value[i], &weight[i]);
    }
    for (w=0;w<=W;++w) dp[0][w] = 0;

    for (i=0; i<N; ++i) {
        for (w=0;w<=W;++w) {
            if (w >= weight[i]) dp[i+1][w] = max(dp[i][w-weight[i]] + value[i], dp[i][w]);
            else dp[i+1][w] = dp[i][w];
        }
    }
    printf("%d\n", dp[N][W]);
}



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

int main()
{
	int n, d, x;
	cin >> n >> d >> x;
	for(auto i = 0; i < n; ++i){
		int a;
		cin >> a;
		x += ((d - 1) / a + 1);
	}
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll 				long long
#define ld 				long double
#define fastio 			ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define debug(x) 		cerr<<#x<<" "<<x<<endl
#define cina(a,n) 		for(ll i = 0;i<n;i++)	cin>>a[i];
#define couta(a,n) 		for(ll i = 0;i<n;i++) cout<<a[i]<<" ";
#define fauto(ar)		for(auto x : ar)	cout<<x<<" ";
#define mod 			1000000007
#define inf				100100100100100100
#define siz 			100005
#define f 				first
#define s 				second
#define pb 				push_back
#define endl 			"\n"
#define ci 				cin.ignore()
using namespace std;
ll dp[siz][2];
// 0 means black 
// 1 means white
// black black is not allowed
void dfs(vector<ll> *graph,ll source,ll parent)
{
	dp[source][0] = dp[source][1] = 1;
	
	for(ll x : graph[source])
		if(x != parent)
			dfs(graph,x,source);
	
	for(ll x : graph[source])
	{
		if(x == parent)	continue;
		
		dp[source][0] *= dp[x][1];
		dp[source][1] *= (dp[x][0] + dp[x][1]);
		
		dp[source][0] %= mod;
		dp[source][1] %= mod;
	}
	
}
int main()
{
	ll n,i,j,a,b;
	cin>>n;
	vector<ll> graph[n+1];
	for(i = 0;i<n-1;i++)
	{
		cin>>a>>b;
		graph[a].pb(b);
		graph[b].pb(a);
	}
	
	dfs(graph,1,-1);
	
	ll ans = dp[1][0] + dp[1][1];
	ans %= mod;
	cout<<ans;
	
}

Measured memory_bytes: 17624
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define speed                   \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define ll long long
#define pb push_back
#define mem1(a) memset(a, -1, sizeof(a))
#define mem0(a) memset(a, 0, sizeof(a))
#define endl "\n"
#define mod 1000000007
#define mod1 998244353
#define ff first
#define ss second
#define MAX 500005
#define N 200005
#define INF 1000000009
#define all(v) v.begin(), v.end()
#define sbit(a) __builtin_popcount(a)
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef pair<ll, ll> pll;
typedef pair<pll, ll> ppl;
typedef map<ll, ll> mpll;
typedef map<vector<ll>, ll> mpvl;
ll power(ll x, ll y, ll p)
{
  ll res = 1;

  x = x % p;

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

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

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

  return res;
}
ll l[2005][2005] = { 0 }; 
  
void initialize() 
{ 
  
    // 0C0 = 1 
    l[0][0] = 1; 
    for (ll i = 1; i < 2002; i++) { 
        // Set every nCr = 1 where r = 0 
        l[i][0] = 1; 
        for (ll j = 1; j < i + 1; j++) { 
  
            // Value for the current cell of Pascal's triangle 
            l[i][j] = (l[i - 1][j - 1]%mod + l[i - 1][j]%mod)%mod; 
        } 
    } 
} 
  
void solve()
{
  ll s;
  cin>>s;
  if(s==1||s==2)
  {
    cout<<0<<endl;
    return;
  }
  ll ans=0;
 // cout<<l[2000][20]<<endl;
  for(ll i=1;i<=s;i++)
  {
       if(s-i*3>=0)
       { 
         
          ans+=l[s-3*i+i-1][s-3*i];
          //cout<<l[4][4]<<endl;
          ans%=mod;
          //cout<<ans<<endl;
       }
  }
  cout<<ans<<endl;


}

int main()
{ 
  speed;
  initialize() ;
  ll kk;
  kk = 1;
  //cin >> kk;
  while (kk--)
  {
    solve();
  }
  return 0;
}

Measured memory_bytes: 26276
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(M)]

ans = -1
for i in range(10**N):
    n = str(i)
    if len(n) < N:
        continue

    ok = True
    for s, c in sc:
        if s > len(n):
            ok = False
            break
        if n[s-1] != str(c):
            ok = False
            break
    if ok:
        ans = n
        break
print(ans)


Measured memory_bytes: 38384
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        String s = new Scanner(System.in).nextLine();
        int i = 0;
        while (i < s.length()) {
            String str5 = s.substring(i, Math.min(i + 5, s.length()));
            if (str5.equals("dream")) {
                i += 5;
                if (i + 1 < s.length() && s.charAt(i) == 'e' && s.charAt(i + 1) == 'r'
                    && (i + 2 == s.length() || s.charAt(i + 2) != 'a')) {
                    i += 2;
                }
            }
            else if (str5.equals("erase")) {
                i += 5;
                if (i < s.length() && s.charAt(i) == 'r') {
                    i++;
                }
            }
            else {
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    }
}


Measured memory_bytes: 26564
/* ex4_1 KitamoriFumiya */
#include <stdio.h>
#include <math.h> // ceil関数を呼び出すため

int main(void){
	float apple, number, monitor; // apple(りんごの木の本数), number(監視できるりんごの木の本数), monitor(監視員の数)をfloat型の変数として宣言
	scanf("%f %f", &apple, &number); // appleとnumberを入力
	monitor = (apple / (number * 2 + 1)); // monitorを計算
	monitor = ceil(monitor); // monitorは人数なので少数を切り上げて整数にする
	printf("%d\n", (int)monitor); // monitorを整数として出力する
	
	return 0;
}

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

int main() {
    
  int N,A,B,C,D;
  cin >> N;
  
  A = N/1000;
  B = (N%1000)/100;
  C = (N%1000)%100/10;
  D = (N%1000)%100%10;
    
  if(A==B&&B==C){
      cout<<"Yes"<<endl;
  }
  else if( B==C&&C==D){
      
   cout<<"Yes"<<endl;
  }
   else{
       cout <<"No"<<endl;
   }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<tuple>
#include<utility>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<iomanip>
#include<map>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const int INF = 1e9 + 7;
int dx[8] = { 1,0,-1,0,1,1,-1,-1 };
int dy[8] = { 0,1,0,-1,1,-1,1,-1 };





int main() { 	


	int n, d;
	cin >> n >> d;

	cout << (n + 2 * d+1 - 1) / (2 * d+1) << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
import itertools
# import numpy as np
import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
H,W = map(int,readline().split())
A = [list(map(int,readline().split())) for _ in range(H)]
B = [list(map(int,readline().split())) for _ in range(H)]
C = [[abs(A[i][j] - B[i][j]) for j in range(W)] for i in range(H)]
 
X = (H + W) * 80
L = X + X + 1
dp = [[0] * W for _ in range(H)]

# X点持った状態から始める
dp[0][0] |= 1 << (X - C[0][0])
dp[0][0] |= 1 << (X + C[0][0])
for i in range(H):
    for j in range(W):
        if i > 0:
            dp[i][j] |= dp[i - 1][j] << C[i][j]
            dp[i][j] |= dp[i - 1][j] >> C[i][j]
        if j > 0:
            dp[i][j] |= dp[i][j - 1] << C[i][j]
            dp[i][j] |= dp[i][j - 1] >> C[i][j]

ans = L
for i in range(L):
    if dp[-1][-1] & 1 << i > 0:
        ans = min(ans, abs(i - X))
print(ans)


Measured memory_bytes: 26412
#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>;

vector<vector<int>> g;
vector<int> o;
map<int, int> ad;
vector<ll> c;

int f(int x, int xm, int add){
	o.at(x) = xm;
	add += ad[x];
	c.at(x) += add;
	rep(i, g.at(x).size()){
		if(g.at(x).at(i) == xm) continue;
		f(g.at(x).at(i), x, add);
	}
	add -= ad[x];
	return 0;
}

int main(){
	int n, q;
	cin >> n >> q;
	g = vector<vector<int>>(n, vector<int>(0));
	o = vector<int>(n);
	c = vector<ll>(n);
	rep(i, n-1){
		int a, b;
		cin >> a >> b;
		a--; b--;
		g.at(a).push_back(b);
		g.at(b).push_back(a);
	}
	rep(i, n){
		o.at(i) = -1;
		c.at(i) = 0;
	}
	rep(i, q){
		int p, x;
		cin >> p >> x;
		p--;
		if(ad[p] == 0){
			ad[p] = x;
		}else{
			ad[p] += x;
		}
	}
	f(0, -1, 0);
	rep(i, n){
		cout << c.at(i) << ' ';
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 43776
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(itr,c) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
int main(){
	int n;
	cin>>n;
	string a,b;
	cin>>a>>b;
	rep(i,n){
		cout<<a[i]<<b[i];
	}
	re 0;
}

Measured memory_bytes: 256
N,K = map(int, input().split())
MOD = 10 ** 9 + 7
s_upper = sum(range(1, N + 1))
s_bottom = sum(range(1, N + 1))
ans = 0
for i in range(N + 1 -( K -1) ):
    ans += (s_upper - s_bottom) + 1
    ans %= MOD
    s_upper -= (i )
    s_bottom-= (N - i)
print(ans)




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

using namespace std;

int main( ) {
    ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t,a,b,c;
	t = 1;
	while(t--) {
	 cin >> a >> b >> c;
	 if(a <= c && c <= b)
	  cout << "Yes" << endl;
	 else
	  cout << "No" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
while True:
    m, f, r = map(int, input().split())

    if (m == -1) and (f == -1) and (r == -1):
        break
    elif (m == -1) or (f == -1):
        print("F")
    elif (m + f) >= 80:
        print("A")
    elif (m + f) >= 65 and (m + f) < 80:
        print("B")
    elif (m + f) >= 50 and (m + f) < 65:
        print("C")
    elif (m+f) < 30:
        print("F")
    else:
        if r < 50:
            print("D")
        else:
            print("C")


Measured memory_bytes: 5592
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);i++)
#define urep(i,a,n) for(ll i = (a);i>=(n);i--)
#define all(x) (x).begin(),(x).end()
#define INF 1e9
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll N, M, Q;
ll A, B;
ll LR[502][502];
ll ans;
string S;
ll K;
int main() {
	cin >> N >> M >> Q;
	rep(i, 0, M) {
		ll L, R;
		cin >> L >> R;
		LR[L][R]++;
	}
	rep(i, 1, N + 1) {
		urep(j, N-1, 0) {
			LR[j][i] += LR[j+1][i];
		}
	}
	rep(i, 0, N + 1) {
		rep(j, 1, N + 1) {
			LR[i][j] += LR[i][j-1];
		}
	}
	rep(i, 0, Q) {
		ll p, q;
		cin >> p >> q;
		cout << LR[p][q] << endl;
	}
	
	cin >> ans;
	return 0;
}

Measured memory_bytes: 2944
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
 
using namespace std;

int gcd(int a,int b){
	if(b>a) swap(a,b);
	int tem;
	while (b!=0){
		tem=a%b;
		a=b;
		b=tem;
	}
	return a;
}

int MOD=1000000007;
int main() {
	int N,X,x;
	cin >> N >> X >> x;
	int ans=abs(x-X);
	for(int i=0; i<N-1; i++){
		cin >> x;
		ans=gcd(ans,abs(X-x));
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

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

	while (scanf("%d", &q), ~q){
		double x = q / 2.;
		while (fabs(x * x * x - q) >= 0.00001 * q){
			x = x - ((x * x * x - q) / (3 * x * x));
		}
		printf("%.6f\n", x);
	}

	return (0);
}

Measured memory_bytes: 636
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 200005
#define inf 1e9
#define eps 1e-10
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

const ll mod=1e9+7;
ll n,k,fac[maxn],inv[maxn],ans;

inline ll qpow(ll a,ll b)
{
	ll ans=1,base=a;
	while(b)
	{
		if(b&1) ans=(ans*base)%mod;
		base=(base*base)%mod; b>>=1;
	}
	return ans;
}

inline ll C(int n,int m){return (fac[n]*inv[m]%mod)*inv[n-m]%mod;}

int main()
{
	cin>>n>>k; fac[0]=1; k=min(n-1,k);
	for(int i=1;i<=n;i++) fac[i]=(fac[i-1]*i)%mod;
	for(int i=0;i<=n;i++) inv[i]=qpow(fac[i],mod-2); ans=1;
	for(int i=1;i<=k;i++) ans=(ans+C(n-1,n-i-1)*C(n,n-i)%mod)%mod;//cout<<ans<<endl;
	cout<<ans<<endl;
	return 0;
}

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



int main(){
    string S;
    cin >> S;
    size_t len =  S.length();
    long cnt = 0;
    for (size_t i = 0; i < len/2; i++)
    {
        if(S.at(i)!=S.at(len-1-i)){
            cnt ++;
        }
    }
    cout << cnt << endl;
    
}


Measured memory_bytes: 256