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

using namespace std;
#define INF 1000007
#define MOD 1000000007
#define int long long
#define maxn 101
#define maxh 1001
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
const int dx[4] = {0, 1, -1, 0}, dy[4] = {1, 0, 0, -1};
typedef std::pair<int, int> P;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void) {
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++) {
        if (!prime[i]) {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i) {
            prime[j] = false;
        }
    }
}

int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b) { return a / gcd(a, b) * b; }

bool IsPrime(int num) //素数判定
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }

    return true;
}

vector<int> divisor(int n) //約数列挙
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i - 1);
            if (i * i != n) {
                ret.push_back((n / i) - 1);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return (ret);
}

int a, b;

void f(int x) {
    while (x) {
        a++;
        b = x;
        x /= 10;
    }
}

const int nmax = 8;
bool ab[nmax][nmax];

int dfs(int v, int N, bool visited[nmax]) {
    bool all_visited = true;
    rep(i, N) {
        if (visited[i] == false) {
            all_visited = false;
        }
    }
    if (all_visited) {
        return 1;
    }
    int ret = 0;
    for (int i = 0; i < N; i++) {
        if (ab[v][i] == false)continue;
        if (visited[i])continue;
        visited[i] = true;
        ret += dfs(i, N, visited);
        visited[i] = false;
    }
    return ret;
}

signed main() {
    int N, M;
    cin >> N >> M;
    bool visited[nmax];
    Fill(ab, false);
    Fill(visited, false);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        ab[a][b] = true;
        ab[b][a] = true;
    }
    visited[0] = true;
    cout << dfs(0, N, visited) << endl;
}



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

using namespace std;

int n;
char x[105], la;
set<string> s;

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s", x);
		if ((i && x[0] != la) || !s.insert(x).second) {
			printf("No\n");
			return 0;
		}
		la = x[strlen(x) - 1];
	}
	printf("Yes\n");
	return 0;
}

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

using namespace std;

const int INF = 1001001001;

struct Edge {
	int to, cost, cost2;
	Edge(int to, int cost, int cost2 = 0) : to(to), cost(cost), cost2(cost2){}
	Edge(){}
	bool operator > (const Edge &a) const {
		return (cost > a.cost);
	}
};

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

	while (scanf("%d %d %d", &n, &m, &c) && n){
		vector<Edge> G[128];

		for (int i = 0; i < m; i++){
			int f, t, cst;
			scanf("%d %d %d", &f, &t, &cst);
			G[f - 1].push_back(Edge(t - 1, cst));
		}

		bool vis[128][1024];
		memset(vis, 0, sizeof(vis));

		priority_queue< Edge, vector<Edge>, greater<Edge> > pq;
		pq.push(Edge(0, 0));

		int ans = m;
		while (pq.size()){
			Edge e = pq.top(); pq.pop();
			if (vis[e.to][e.cost2]) continue;
			vis[e.to][e.cost2] = true;

			if (e.to == n - 1){
				ans = min(ans, e.cost2);
				continue;
			}

			for (int i = 0; i < G[e.to].size(); i++){
				Edge nxt = G[e.to][i];
				if (e.cost + nxt.cost <= c && !vis[nxt.to][e.cost2]) pq.push(Edge(nxt.to, e.cost + nxt.cost, e.cost2));
				if (e.cost2 < m && !vis[nxt.to][e.cost2 + 1]) pq.push(Edge(nxt.to, e.cost, e.cost2 + 1));
			}
		}

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

	return (0);
}

Measured memory_bytes: 12604
#include <cstdio>
#include <iostream>
#include <cstring>
#include <set>
using namespace std;
 
set<string> p;
int main ()
{
    string s;
    int k;
    cin>>s>>k;
    int i,j;
    int n=s.size();
    for (i=0;i<=n-1;i++)
        for (j=1;j<=5;j++)
        {
            if (i+j-1>=n) continue;
            p.insert(s.substr(i,j));
        }
    for (i=1;i<=k-1;i++)
    {
        p.erase(p.begin());
    }
    cout<<(*(p.begin()))<<endl;//这样使用
    return 0;
}

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

int main(){
	int n, vmax, dmin, vmin;
	dmin = 1100000000;
	cin >> n;
	vector<int> a(n);
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	sort(a.begin(), a.end());

	vmax = a[n-1];
	for(int i=0; i<n-1; i++){
		if(abs(2*a[i] - vmax) < dmin){
			vmin = a[i];
			dmin = abs(2*a[i] - vmax);
		}
	}
	cout << vmax << " " << vmin << endl;
	return 0;

}

Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<ctime>
using namespace std;
int main(){
	long long k;
	int a[35]={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};
	while(cin>>k){
		k%=32;
		if(k==0) k=32;
		cout<<a[k-1]<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()

r_cnt = s.count('R')
g_cnt = s.count('G')
b_cnt = s.count('B')

ans = r_cnt * g_cnt * b_cnt

for i in range(n):
    for d in range(n):
        j = i + d
        k = j + d
        if k >= n:break
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            ans -= 1

print(ans)


Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll

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 (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


ll T, n, m;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cin >> n;
    vi v(n+2);
    ll sum = 0;
    REPS(i, n) {
        cin >> v[i];
        sum += abs(v[i] - v[i-1]);
    }
    sum += abs(v[n + 1] - v[n]);
    REPS(i, n) {
        cout << sum - abs(v[i] - v[i-1]) - abs(v[i] - v[i+1]) + abs(v[i+1] - v[i-1]) << endl;
    }
    return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define w(t) int t;cin>>t;while(t--)
#define pb   push_back
#define mk   make_pair
#define u_s  unordered_set
#define endl "\n"
#define prDouble(x) cout<<fixed<<setprecision(10)<<x
#define ll long long int
#define ipair pair<int,int>
#define all(x) (x).begin(), (x).end()

const int mod=pow(10,9)+7;

bool compare(pair<int,int>p1,pair<int,int>p2){
    return p1.second<p2.first;
}
void open_file(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}
void fast_io(){
    ios_base::sync_with_stdio(false); 
    cin.tie(nullptr); 
    cout.tie(nullptr);
      
}
/*
  ll C(ll n,ll k){
  
  if(k>n)return 0;
  
  ll ans=1;

  if(k>n-k)
    k=n-k;
  for(ll i=1;i<=k;i++)
    ans*=(n-i+1),ans/=i;

  return ans;
  }
  unsigned long long fact(long long a)
  {
  unsigned long long res=1;
  for(long long i=a;i>0;i--)
    res*=i;
  return res;
  }
  unsigned long long comb(long long a,long long b)
  {
  if((a-b)<b) b=a-b;
  if(a<=19) return fact(a)/(fact(a-b)*fact(b));
  if(a==b||b==0) return 1;
  if(b==1) return a;
  return comb(a-1,b-1)+comb(a-1,b);
  }
*/



void solve(){
     
  int n,k; cin>>n>>k; vector<int>A(n);

  for(int i=0;i<n;i++)cin>>A[i];
  
  bool dp[k+2];
  
  memset(dp,0,sizeof dp);
  
  for(int i=1;i<=k;i++){

      for(int move:A){

         if(move>i)continue;
         if(dp[i-move]==0)
          dp[i]=1;
      }
  }
  
  cout<<(dp[k]==1 ? "First" : "Second");
}
int main(){

//  open_file();
  fast_io();
  
  solve();
  
  return 0;  
    
}


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

using namespace std;

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

const ll MOD = (ll)1e9 + 7LL;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	ll N; cin >> N;
	ll res = 1LL;

	for (ll i = 1LL; i <= N; ++i){
		res = (res * i) % MOD;
	} // end for

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pl = pair<ll, ll>;
const ll MOD = 998244353;
const int inf = 1e9 + 10;
const ll INF = 4e18;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0}, dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	int x[n], y[n], h[n];
	int X, Y, H;
	rep(i, n) {
		cin >> x[i] >> y[i] >> h[i];
		if (h[i] != 0) X = x[i], Y = y[i], H = h[i];
	}
	rep(i, 101) {
		rep(j, 101) {
			int T = H + abs(i - X) + abs(j - Y);
			bool ch = 1;
			rep(k, n) {
				if (max(T - abs(i - x[k]) - abs(j - y[k]), 0LL) != h[k]) {
					ch = 0;
					break;
				}
			}
			if (ch) {
				cout << i << " " << j << " " << T << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.begin(), c.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
#define Sort(a) sort(Range(a));
#define DeSort(a) sort(RevRange(a));

using namespace std;
using ll = long long;

int main(void){
    Cins(int, 3, a);
    //Cout();
    Sort(a);
    Cout((a[0] + a[1] == a[2]) ? "Yes" : "No");
    //Cout(() ? "YES" : "NO");
}

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

using namespace std;
using LL = long long;

constexpr int N = 1e5 + 5;

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

    int n;
    LL m;
    cin >> n >> m;
    LL lcm = 1;

    vector< LL> v(n);
    for (int i = 0; i < n; i++) {
        LL x;
        cin >> x;
        lcm = lcm / __gcd(lcm, x / 2) * (x / 2);
        if (lcm > m) {
            cout << 0 << endl;
            return 0;
        }
        v[i] = x;
    }
    for (auto x : v) if (lcm % x == 0) return cout << 0 << endl, 0;
    cout << (m / lcm + 1) / 2 << endl;
}

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

//pragmas
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
*/

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

const long double pi = acos(-1.0);

#define FOR(a,b,c) for(ll (a)=(b);(a)<(c);++(a))
#define FORE(a,b,c) for(ll (a)=(b);(a)<=(c);++(a))
#define FORN(a,b,c) for(ll (a)=(b);(a)>(c);--(a))
#define FORNE(a,b,c) for(ll (a)=(b);(a)>=(c);--(a))
#define COUT(n) printf("%d\n", (n))
#define COUTLL(n) printf("%lld\n", (n))
#define CIN(n) scanf("%d", &(n))
#define CINLL(n) scanf("%lld", &(n))
#define MEM(a,b) memset((a), (b), sizeof((a)))
#define MAX(a,b) (a) = max((a), (b))
#define MIN(a,b) (a) = min((a), (b))
#define nl '\n'
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

void init(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

void infile(){
	freopen("input.in", "r", stdin);
}

void outfile(){
	freopen("output.out", "w", stdout);
}

ll modex(ll a, ll b, ll mod){
	if(b == 0)
		return 1;
	if(b == 1)
		return a;
	ll tmp = modex(a, b/2, mod);
	tmp = (tmp * tmp) % mod;
	if(b & 1)
		tmp = (tmp * a) % mod;
	return tmp;
}

//End of template

int n;
ll arr[100005];
ll memo[100005];

ll dp(int pos){
	if(pos == n-1){
		return 0;
	}
	if(memo[pos] != -1){
		return memo[pos];
	}
	if(pos == n-2){
		return memo[pos] = abs(arr[n-1]-arr[pos]) + dp(pos+1);
	}
	return memo[pos] = min(abs(arr[pos+1]-arr[pos]) + dp(pos+1), abs(arr[pos+2]-arr[pos]) + dp(pos+2));
}

int main(){
	init();

	cin >> n;
	MEM(memo, -1);
	FOR(i, 0, n){
		cin >> arr[i];
	}
	cout << dp(0) << nl;
	return 0;	
}

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

#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

using namespace std;

using ll=long long;
using ull=unsigned long long;
using pii=pair<int, int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using pill=pair<int,ll>;
using vvi=vector<vi>;

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

ll fast_exp(ll base, ll n, ll m)
{
    if(n==0) return 1;
    ll t=fast_exp(base,n/2,m);
    if(n%2==0) return (t*t)%m;
    else return (((t*t)%m)*base)%m;
}

template <typename T, typename Q>
auto my_binary_search(T low,
                      T high, 
                      function<bool (Q)> condition,
                      double precision = 1,
                      function<bool (T, T)> comp = std::less<T>(),
                      function<T (T, T)> mid_value = [](auto a, auto b){return a+((b-a)>>1);},
                      function<T (T)> next_value = [](T a){return a+1;}) 
{
    assert(condition(high));
    assert(precision <= 1);

    while (comp(low, high)) {
        T m = mid_value(low, high);
        if (condition(m)) high = m;
        else low = next_value(m);
    }
    
    assert(condition(low));

    if (precision == 1)
        return static_cast<Q>(low);
    
    T l = 0, r = 1/precision;
    while (comp(l, r)) {
        T m = mid_value(l, r);
        if (condition(low-1+m*precision)) r = m;
        else l = next_value(m);
    }

    return static_cast<Q>(low-1+l*precision);
}

int h[16][16];

int main()
{
    ios::sync_with_stdio(false);
    int n;cin>>n;
    for (int i=0; i<n; ++i) {
        int a;cin>>a;
        while (a--) {
            int x, y;cin>>x>>y;
            h[i][x-1] = y==1 ? 1 : -1;
        }
    }
    int ans=0;
    for (int i=1; i<(1<<n); ++i) {
        queue<int> q;
        int tag[16]{0};
        for (int j=0; j<n; ++j) {
            if ((i>>j)&1)
                q.push(j), tag[j]=1;
        }
        bool f=true;
        while (!q.empty()) {
            int x = q.front();
            q.pop();
            for (int j=0; j<n; ++j) {
                if (not h[x][j]) continue;
                if (tag[j]) {
                    if (h[x][j] != tag[j]) {
                        f = false;
                        break;
                    }
                }
                else {
                    tag[j] = h[x][j];
                    if (h[x][j] == 1)
                        q.push(j);
                }
            }
            if (not f) break;
        }
        if (f) {
            int c=0;
            for (int j=0; j<n; ++j) if(tag[j]==1) ++c;
            ans = max(ans, c);
        }
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    l,r  = list(map(int, input().split(" ")))
    res = 2019
    n = l // 2019
    if l % 2019 == 0:
        print(0)
    elif l//(n+1) <= 2019  and 2019 <= r//(n+1):
        print(0)
    else:
        for i in range(2019):
            for j in range(i+1, 2019):
                if l+i > r or j+l > r:
                    break
                res1 = (((l+i) % 2019) * (l+j % 2019)) % 2019
                if res1 < res:
                    res = res1
        print(res)


Measured memory_bytes: 3064
#include <math.h>
#include <algorithm>  //sort,二分探索,など
#include <array>
#include <bitset>         //固定長bit集合
#include <cmath>          //pow,logなど
#include <complex>        //複素数
#include <deque>          //両端アクセスのキュー
#include <functional>     //sortのgreater
#include <iomanip>        //setprecision(浮動小数点の出力の誤差)
#include <iostream>       //入出力
#include <map>            //map(辞書)s
#include <numeric>        //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>          //キュー
#include <set>            //集合
#include <stack>          //スタック
#include <string>         //文字列
#include <unordered_map>  //イテレータあるけど順序保持しないmap
#include <unordered_set>  //イテレータあるけど順序保持しないset
#include <utility>        //pair
#include <vector>         //可変長配列

using namespace std;
typedef long long 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 FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())  // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second


int main() {
  int n;
  cin >> n;
  // 2からnまでの番号を入力
  int a[2000000];
  for (int i = 2; i <= n; ++i) {
    cin >> a[i];
  }
  // ansに、何人部下がいるか記録させる
  int ans[2000000];
  for (int i = 0; i <2000000; ++i) {
    ans[i] = 0;}
    // 2（番）からn（番）までの社員の上司が誰か記録する
    for (int i = 2; i <= n; ++i) ans[a[i]]++;
    //番号が２の社員の上司の番号はA_２に入っているので、
    //ある上司A_xの「直属の部下」の番号はx
    // 1（番）からn（番）までの上司に対応する部下の数（＝ans）をn回出力
    for (int i = 1; i <= n; ++i) cout << ans[i] << endl;
  }

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

  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 500;

const int INF = (1LL << 30) - 1;
  int dp[N][N]; //stores minimum distances
  int dp2[N][N]; //stores Minimum number of times tank refilled



int32_t main()
{/*
    #ifndef ONLINE_JUDGE
       freopen("in.txt","r",stdin);
       freopen("out.txt","w",stdout);
    #endif*/


    IOS

    for(int i = 0; i < N;i++)
    {
    	for(int j = 0; j < N;j++)
    	{
    		dp[i][j] = INF;
    		dp2[i][j] = INF;
    	}
    }


    int n,m,l;
    cin >> n >> m >> l;



    for(int i = 1; i<= m; i++)
    {
    	int a,b,c;
    	cin >> a >> b >> c;
    	dp[a][b] = min(dp[a][b],c);
    	dp[b][a] = min(dp[a][b],dp[b][a]);
    }


//since constraints are small, dijkstra's can be done by 3-loops
    //third loop searches for a mid-point essentially that might reduce the distance cost


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

    		}
    	}
    }


    for(int i = 1; i <= n; i++)
    {
    	for(int j = 1; j <= n; j++)
    	{
    		//trace3(i,j,dp[i][j]);
    		if(dp[i][j] <=l)
    		{
    			dp2[i][j] = 1;
    			dp2[j][i] = 1;
    		}
    	}
    }

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

    int q;
    cin >> q;

    while(q--)
    {
    	int x,y;
    	cin >> x >> y;
    	//trace2(x,y);
    	if(dp2[x][y] == INF )dp2[x][y] = 0;
    	cout << dp2[x][y] - 1<< endl;
    }

    return 0;
}




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

#ifdef LOCAL
#include "../dump.hpp"
#else
#define dump(...)
#endif

using namespace std;

#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(a) (int)a.size()
#define pb push_back
#define fst first
#define snd second
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

int main(){
  string s; cin >> s;
  int ans = sz(s);

  rep(i,sz(s)-1){
    if(s[i] != s[i+1]) ans = min(ans, max(i+1, sz(s)-i-1));
  }

  cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const long long INF = 1e18;
# define len(x) ((int)(x).size())
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define foreps(i, m, n) for(int i = m;i < n;i++)
# define ALL(x) (x).begin(), (x).end()
# define rall(x) (x).rbegin(), (x).rend()
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; }

int main() {
    ll N; cin >> N;
    vector<ll> A(N + 2);
    reps(i, N) cin >> A[i];

    ll sum = 0;
    rep(i, N + 1) sum += abs(A[i + 1] - A[i]);
    rep(i, N) {
        ll x = abs(A[i + 2] - A[i + 1]) + abs(A[i + 1] - A[i]);
        ll y = abs(A[i + 2] - A[i]);
        cout << sum - x + y << endl;
    }
}

Measured memory_bytes: 3980
#include <bits/stdc++.h>
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RFORE(i,a,b) for(int i=(b);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) (UB(c,x)-LB(c,x))
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (bool)((s).find(e)!=(s).end())
#define PB push_back
#define MP make_pair
#define DEL(v) decltype(v)().swap(v)
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
using namespace std;
template<typename T1, typename T2> using P = pair<T1,T2>;
template<typename T> using V = vector<T>;
struct edge { int from, to; int cost; };
bool operator< (const edge &edge1, const edge &edge2) { return edge1.cost < edge2.cost; };
const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator << (ostream& s, const V<T>& v) {
   s << "[";
   for (int i = 0; i < v.size(); i++) { s << v[i]; if (i < v.size() - 1) s << " "; }
   s << "]";
   return s;
}

signed main()
{
   string s; cin >> s;
   int X, Y; cin >> X >> Y;

   int N = SZ(s);
   V<int> L;
   int cnt = 0;
   FORE(i, 0, N) {
      if (i != N && s[i] == 'F') {
         cnt++;
      } else {
         L.PB(cnt);
         cnt = 0;
      }
   }

   V<int> RL, UD;
   FOR(i, 1, SZ(L)) {
      if (i % 2 == 0) RL.PB(L[i]);
      else UD.PB(L[i]);
   }

   V<V<bool>> dp0(2, V<bool>(2*N+1, false));
   dp0[0][L[0] +N] = true;
   FOR(i, 0, SZ(RL)) {
      fill(ALL(dp0[(i+1)%2]), false);
      FOR(x, 0, 2*N) {
         if (x-RL[i] >=   0) dp0[(i+1)%2][x-RL[i]] = dp0[(i+1)%2][x-RL[i]] || dp0[i%2][x];
         if (x+RL[i] <= 2*N) dp0[(i+1)%2][x+RL[i]] = dp0[(i+1)%2][x+RL[i]] || dp0[i%2][x];
      }
   }

   V<V<bool>> dp1(2, V<bool>(2*N+1, false));
   dp1[0][N] = true;
   FOR(i, 0, SZ(UD)) {
      fill(ALL(dp1[(i+1)%2]), false);
      FOR(y, 0, 2*N) {
         if (y-UD[i] >=   0) dp1[(i+1)%2][y-UD[i]] = dp1[(i+1)%2][y-UD[i]] || dp1[i%2][y];
         if (y+UD[i] <= 2*N) dp1[(i+1)%2][y+UD[i]] = dp1[(i+1)%2][y+UD[i]] || dp1[i%2][y];
      }
   }

   bool ans = dp0[SZ(RL)%2][X+N] && dp1[SZ(UD)%2][Y+N];
   cout << (ans ? "Yes" : "No") << endl;

   return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>

using namespace std;

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

    int a = B-A;
    int flag = 0;
    for(int i=A; i<=B; i++){
        if(i%K == 0){
            flag = 1;
            break;
        }
    }

    if(flag > 0){
        cout << "OK";
    }
    else{
        cout << "NG";
    }

    return 0;
}

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

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

    int a;
    cin >> a;
    string s;
    cin >> s;
    if(a >= 3200){
        cout << s << endl;
    }else{
        cout << "red" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static long[]S = new long[262144];
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int M = int.Parse(str[1]);
		int[][]A = new int[M][];
		for(var i=0;i<M;i++){
			string[] str2 = Console.ReadLine().Split();
			A[i] = new int[3]{int.Parse(str2[0]),int.Parse(str2[1]),int.Parse(str2[2])};
		}
		Array.Sort(A,(x,y)=>x[0].CompareTo(y[0]));
		long INF = 9999999999999999;
		for(var i=0;i<262144;i++){
			S[i] = INF;
		}
		S[131071] = 0;
		for(var i=0;i<M;i++){
			int a = A[i][0]-1;
			int b = A[i][1];
			long c = A[i][2];
			long ia = a+131071;
			long m = S[ia];
			while(ia>0){
				ia = (ia-1)/2;
				m = Math.Min(S[ia],m);
			}
			query(a,b,0,0,131072,m+c);
		}
		int ib = N-1 + 131071;
		long ans = S[ib];
		while(ib>0){
			ib = (ib-1)/2;
			ans = Math.Min(S[ib],ans);
		}
		if(ans==INF){
			ans = -1;
		}
		Console.WriteLine(ans);
	}

	public static int query(int a, int b, int k, int l, int r,long T) {
	if (r <= a || b <= l) return 1000000007;
		if (a <= l && r <= b) {
			S[k] = Math.Min(S[k],T);
			return 0;
		} else {
			int c1 = query(a, b, 2 * k + 1, l, (l + r) / 2, T);
			int c2 = query(a, b, 2 * k + 2, (l + r) / 2, r, T);
			return 0;
		}
	}
}

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

int main() {
    int count = 0;
    string s;
    cin >> s;
    for(int i = 0; i < 3; i++) {
        if(s[i] == 'R') {
            count++;
        } else if(count > 0) {
            break;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3600
N, P = map(int,input().split())
A = list(map(int,input().split()))
dp = [0 for _ in range(2)]
dp[0] = 1
for i in range(N):
    c = A[i]%2
    if c == 0:
        dp[0]*=2
        dp[1]*=2
    else:
        s = dp[0]+dp[1]
        dp[0], dp[1] = s, s
print(dp[P])


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int main() {
	string s, t;
	cin >> s >> t;
	string ans = s;
	int pos = -1;
	for (int i = 0; i + (int) t.size() <= (int) s.size(); i++) {
		string s_ = s.substr(i, t.size());
		bool flag = true;
		for (int j = 0; j < (int) t.size(); j++) {
			if (s_[j] != '?' && s_[j] != t[j]) {
				flag = false;
				break;
			}
		}
		if (flag) pos = i;
	}
	if (pos != -1) {
		ans.replace(pos, t.size(), t);
		for (int j = 0; j < (int) ans.size(); j++)
			if (ans[j] == '?') ans[j] = 'a';
		cout << ans << endl;
	} else {
		cout << "UNRESTORABLE" << endl;
	}
}

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

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

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

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

  ll a, b;
  cin >> a >> b;
  a = a * b;
  cout << ((a % 2) ? "Odd" : "Even") << endl;

  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define FOR0(i,n) for(int i=0, _##i=(n); i<_##i; ++i)
#define FOR(i,l,r) for(int i=(l), _##i=(r); i<_##i; ++i)
#define FORD(i,l,r) for(int i=(r), _##i=(l); --i>=_##i; )
#define repi(i,a) for(__typeof((a).begin()) i=(a).begin(), _##i=(a).end(); i!=_##i; ++i)
#define dwni(i,a) for(__typeof((a).rbegin()) i=(a).rbegin(), _##i=(a).rend(); i!=_##i; ++i)
#define SZ(a) ((int)((a).size()))
#define printCase() "Case #" << caseNum << ": "
#define pb push_back
#define mp make_pair
#define INF ((int)1e9 + 5)
#define SYNC std::ios::sync_with_stdio(false);  cin.tie(NULL);
#define ff first
#define ss second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define N 105
int main() {
    SYNC
    int n, tot, w[N], v[N], dp[N][N][3*N];
    cin >> n >> tot;
    FOR0(i, n) {
        cin >> w[i] >> v[i];
    }
    memset(dp, -1, sizeof dp);
    dp[0][0][0] = 0;
    int ans = 0;
    dp[0][1][0] = v[0];
    FOR(i, 1, n) {
        dp[i][0][0] = 0;
        FOR(taken, 1, n + 1) {
            FOR(wt, 0, 3*taken + 1) {
                int val = (wt-(w[i] - w[0]) >= 0 ? dp[i-1][taken-1][wt-(w[i] - w[0])]: -1);
                if(val >= 0) val += v[i];
                dp[i][taken][wt] = max(dp[i-1][taken][wt], val);
            }
        }
    }
    FOR(taken, 1, n+1) {
        FOR0(wt, 3*taken + 1) {
            if(wt + taken*((ll)w[0]) <= tot) ans = max(ans, dp[n-1][taken][wt]);
        }
    }
    cout << ans;
}

Measured memory_bytes: 13952
def main():
    A,B,C,X,Y = map(int, input().split())

    max_c = max([X,Y]) * 2
    yen = [0 for _ in range(max_c+1)]
    for c in range(max_c+1):
        x = X - c//2
        if x < 0:
            x = 0
        y = Y - c//2
        if y < 0:
            y = 0
        yen[c] = x*A + y*B + c*C
    return min(yen)

if __name__ == '__main__':
    print(main())



Measured memory_bytes: 11032
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
constexpr int MOD = 1e9 + 7;

ll dp[22][(1<<22)];

int main(){
    int N;bool a[22][22];
    cin >> N;
    for(int i=0;i<N;++i) for(int j=0;j<N;++j) cin >> a[i][j];
    dp[0][0] = 1;
    for(int bit = 0; bit < (1<<N); ++bit){
        for(int m = 0; m < N; ++m){
            if(__builtin_popcount(bit)==m){
                for(int w = 0; w < N; ++w){
                    if(!(bit & (1<<w)) && a[m][w]) dp[m+1][bit|(1<<w)] += dp[m][bit]%MOD;
                }
            }
        }
    }
    cout << dp[N][(1<<N)-1]%MOD << endl;
    return 0;
}

Measured memory_bytes: 321792
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
int a, b;
cin >> a >> b;

if (a*b % 2 == 0){
    cout << "No" << endl;
}
else {
    cout << "Yes" << endl;
}

return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  int a[N];
  long long int total=0;
  long long int max=-10000001,min=10000001;
  for(int i=0;i<N;i++){
    cin >> a[i];
    if(max<a[i])max=a[i];
    if(min>a[i])min=a[i];
    total+=a[i];
  }
  cout << min << ' '<<max << ' '<<total<< endl;
return 0;
}

Measured memory_bytes: 3096
import math

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

cnt_1 = 0
for i in range(len(A)):
  for j in range(i+1, len(A)):
    if A[i] > A[j]:
      cnt_1 += 1

cnt_2 = 0
for i in range(len(A)):
  for j in range(len(A)):
    if A[i] > A[j]:
      cnt_2 += 1

cnt = cnt_1 * K + cnt_2 * ((K-1)*K//2)

print(cnt % (10**9 + 7))


Measured memory_bytes: 3188
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  string s,t; cin >> s;
  rep(i,s.size()){
    t+='x';
  }
  cout << t << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
#include <map>
#include <numeric>
using namespace std;


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

    sort(h.begin(), h.end());

    long long int res = 10000000000;
    for (int i = 0; i < n - k + 1; i++) {
        long long int diff;
        diff = h[i + k - 1] - h[i];
        res = min(res, diff);
    }
    cout << res << endl;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  string str;
  cin >> N >> str;
  
  bool ret = true;
  if(N % 2==0){
    for(int i = 0; i < N/2;i++){
      if(str.at(i) != str.at(i + N / 2)){
        ret = false;
        break;
      }
    }
  }else {ret = false;}
  
  if(ret) cout <<"Yes";
  else cout << "No";
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <ctype.h>
#include <algorithm>
#include <cmath>

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define square(x) (x) * (x)
#define cube(x) (x) * (x) * (x)

const int INF = 1e9;

using namespace std;
int cnt = 0;

vector<int> insertion_sort(vector<int> a, int n, int g) {

    for(int i=g; i<n; i++){
        int key = a[i];
        int j = i - g;
        while(j >= 0 && a[j] > key){
            a[j+g] = a[j];
            j -= g;
            cnt++;
        }
        a[j+g] = key;
    }
    return a;
}

vector<int> shell_sort(vector<int> a, int n){
    cnt = 0;
    int m = 11;
    int mm = m;
    int g[] = {1, 2, 8, 32, 128, 512, 2048, 2048*4, 2048*16, 2048*64, 2048*256};
    REP(i, m){
        if(g[m-1-i] > n)
            mm--;
    }
    cout << mm << endl;
    REP(i, mm-1){
        cout << g[mm-1-i] << " ";
        a = insertion_sort(a, n, g[mm-1-i]);
    }
    cout << g[0] << endl;
    a = insertion_sort(a, n, g[0]);

    return a;

}
/*
vector<string> selection_sort(vector<string> s){
    int n = s.size();
    vector<int> a;
    REP(i, n)
        a.push_back(atoi(s[i].substr(1, 1).c_str()));

    REP(i, n){
        int mini = i;
        for(int j = i; j < n ; j++){
            if(a[j] < a[mini])
                mini = j;
        }
        if(i != mini){
            swap(a[i], a[mini]);
            swap(s[i], s[mini]);
        }
    }
    return s;
}

vector<string> bubble_sort(vector<string> s) {
    int n = s.size();
    vector<int> a;
    REP(i, n)
        a.push_back(atoi(s[i].substr(1, 1).c_str()));

    REP(i, n)
        for(int j = n - 1; j > i; j--)
            if(a[j] < a[j-1]){
                swap(a[j], a[j-1]);
                swap(s[j], s[j-1]);
            }

    return s;
}

int find(vector<string> target, string query){
    int i = 0;
    vector<string>::iterator iter = target.begin();
    while(iter != target.end()){
        if (*iter == query)
            break;
        i++;
        iter++;
    }

    return i;
}
*/

int main() {
    int n;
    cin >> n;
    int in[n];
    vector<int> a;
    REP(i, n) { cin >> in[i]; a.push_back(in[i]);}
    a = shell_sort(a, n);
    cout << cnt << endl;
    REP(i, n)
        cout << a[i] << endl;

    return 0;
}

Measured memory_bytes: 16916
#include<iostream>

using namespace std;

int main()
{
  string S;
  cin >> S;
  bool allA = S[0] == 'A' && S[1] == 'A' && S[2] == 'A';
  bool allB = S[0] == 'B' && S[1] == 'B' && S[2] == 'B';
  
  if (allA || allB)
  {
    cout << "No" << endl;
  }
  else
  {
    cout << "Yes" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int d = in.nextInt();
            int ans = (n + 2 * d) / (2 * d + 1);
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21460
#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
using namespace std;
#define mp make_pair
typedef pair<int, int> P;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

int N, M;
char maze[110][110];
unsigned int minp[110][110];

int main() {
	for(;;) {
		memset(minp, -1, sizeof minp);
		scanf(" %d %d", &N, &M);
		if(!N && !M) break;
		for(int i = 0; i < M; i++) {
			scanf(" %s", maze[i]);
		}

		// P = (x, y)
		// maze[y][x]
		queue<P> que;
		{
			P put;
			for(int x = 0; x < N; x++) {
				for(int y = 0; y < M; y++) {
					if(maze[y][x] == '&') {
						put.first = x;
						put.second = y;
						minp[y][x] = 0;
						maze[y][x] = '.';
					}
				}
			}
			que.push(put);
		}
		;
		while(!que.empty()) {
			P p = que.front();
			que.pop();

			// push
			for(int i = 0; i < 4; i++) {
				int nx = p.first + dx[i];
				int ny = p.second + dy[i];
				if(0 <= nx && nx < N && 0 <= ny && ny < M && maze[p.second][p.first] == '.' && maze[ny][nx] == '.' && minp[ny][nx] > minp[p.second][p.first]) {
					minp[ny][nx] = minp[p.second][p.first];
					que.push(mp(nx, ny));
				}

				if(0 <= nx && nx < N && 0 <= ny && ny < M && maze[p.second][p.first] == '#' && maze[ny][nx] == '#' && minp[ny][nx] > minp[p.second][p.first]) {
					minp[ny][nx] = minp[p.second][p.first];
					que.push(mp(nx, ny));
				}

				if(0 <= nx && nx < N && 0 <= ny && ny < M && maze[p.second][p.first] == '.' && maze[ny][nx] == '#' && minp[ny][nx] > minp[p.second][p.first]) {
					minp[ny][nx] = minp[p.second][p.first] + 1;
					que.push(mp(nx, ny));
				}

				if(0 <= nx && nx < N && 0 <= ny && ny < M && maze[p.second][p.first] == '#' && maze[ny][nx] == '.' && minp[ny][nx] > minp[p.second][p.first]) {
					minp[ny][nx] = minp[p.second][p.first];
					que.push(mp(nx, ny));
				}
			}
		}
		unsigned int minv = 100000000;
		for(int i = 0; i < N; i++) {
			minv = min(minv, min(minp[0][i], minp[M - 1][i]));
		}
		for(int i = 0; i < M; i++) {
			minv = min(minv, min(minp[i][0], minp[N - 1][i]));
		}
		printf("%d\n", minv);
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main(void)
{

  int x, y, r, tmp;


  scanf("%d%d", &x,&y);
  

  if(x<y){
    tmp = x;
    x = y;
    y = tmp;
  }

  r = x % y;
  while(r!=0){
    x = y;
    y = r;
    r = x % y;
  }

  printf("%d\n", y);

  return 0;
}

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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

    string s, t;
    cin >> s >> t;

    vector<int> st(26, -1);
    vector<int> gl(26, -1);

    rep (i, 0, (int)s.size()) {
	int a = s[i] - 'a';
	int b = t[i] - 'a';
	if (st[a] != -1 || gl[b] != -1) {
	    if (st[a] != b || gl[b] != a) {
		cout << "No" << endl;
		return 0;
	    }
	} else {
	    st[a] = b;
	    gl[b] = a;
	}
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 916
n = int(input())
h = [int(i) for i in input().split()]
dp = [float('inf')]*n
dp[0] = 0
dp[1] = abs(h[1]-h[0])
if n == 2:
    print(dp[1])
else:
    for i in range(2,n):
        dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]))
    print(dp[n-1])

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

int main(){
    int a, b;
    cin >> a >> b;
    if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }
    return 0;
}

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

using namespace std;

int main(){
    int n;
    int result[6];

    cin>>n;
    for(int i=0;i<5;i++){
        result[i]=0;
    }

    for(int i=1;i<=n;i++){
        result[int(log10(i))]++;
    }
    cout<<result[0]+result[2]+result[4]<<endl;
    return 0;
}

Measured memory_bytes: 512
import math
n=int(input())
A,B=[list(range(1,n+1)) for i in range(2)]
P,Q=[list(map(int,input().split())) for i in range(2)]
p=0
for i in range(n-1):
    p+=(A.index(P[i]))*math.factorial(n-i-1)
    A.remove(P[i])
q=0
for i in range(n-1):
    q+=(B.index(Q[i]))*math.factorial(n-i-1)
    B.remove(Q[i])
print(abs(p-q))

Measured memory_bytes: 3064
def count_adjacent_bombs(expanded_grid, i, j):
  dx = [-1, 0, 1, -1, 1, -1, 0, 1]
  dy = [1, 1, 1, 0, 0, -1, -1, -1]
  bombs = 0
  for ind in range(8):
    if expanded_grid[i+dx[ind]][j+dy[ind]] == '#':
      bombs += 1
  return bombs


h, w = map(int, input().split())
grid = [input() for _ in range(h)]

expanded_grid = []
expanded_grid.append('.' * (w+2))
for i in range(h):
  expanded_grid.append('.' + grid[i] + '.')
expanded_grid.append('.' * (w+2))


for i in range(1, h+1):
  for j in range(1, w+1):
    if expanded_grid[i][j] == '#':
      print('#', end='')
    else:
      print(count_adjacent_bombs(expanded_grid, i, j), end='')
  print('')


Measured memory_bytes: 45676
N,M = map(int,input().split())
T = {}
for i in range(M):
    a,b = map(int,input().split())
    if a not in T.keys():
        T[a] = []
    if b not in T.keys():
        T[b] = []
    T[a].append(b)
    T[b].append(a)

ans = 0
def dfs(graph,start,path):
    global ans
    global N
    path = path + [start]

    if len(path) == N:
        ans += 1

    for node in graph[start]:
        if node not in path:
            new = dfs(graph,node,path)

    return ans


print(dfs(T,1,[]))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(ll i=0;i<(ll)n;++i)
const ll INF = 999999999999999;
 
int main(){
  ll n,k;
  cin >> n >> k;
  vector<bool> a(n);
  rep(i,k){
    ll d;
    cin >> d;
    rep(j,d){
      ll c;
      cin >> c;
      c--;
      a.at(c) = true;
    }
  }
  ll cnt = 0;
  rep(i,n){
    if( !a.at(i) ) cnt++;
  }
  cout << cnt << endl;
    
  return 0;
}


Measured memory_bytes: 3632
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

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

    if(S.size() <= K){
        cout << S;
        return 0;
    }
    rep(i, K){
        cout << S[i];
    }
    cout << "...";
}

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

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef vector<LL> 		VL;
#define si(n) cin>>n
#define dout(n) cout<<n<<"\n"
#define DRT() int t; si(t); while(t--)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//# define M_PI           3.14159265358979323846264338327950288
// DSU
void IO(){
	#ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
	#endif
	srand(chrono::steady_clock::now().time_since_epoch().count());
	off;
}

int main(){
	IO();
	LL n;
	cin>>n;
	LL a;
	LL ans = 0;
	rep(i,1,n+1){
		cin>>a;
		if((a%2) == 1 && (i%2) == 1)
			ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3620