akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;




int main()
{
    int N;
    cin >> N;
    vl A(3*N);
    in(3*N,A);
    sort(all(A));
    reverse(all(A));
    
    ll ans = 0;
    rep(i,N){
        
        ans += A[2*i+1];
    }
    cout << ans << endl;

    
    
    
    

    return 0;
}


Measured memory_bytes: 2560
#include<cstdio>
#include<algorithm>
#include<cstring>
#define rep(i, s, t) for(i = s; i <= t; ++i)
#define dep(i, s, t) for(i = s; i >= t; --i)

using namespace std;

typedef long long LL;
const int P = 1e9 + 7;
const int N = 4010;
int n, m;
LL X, sum;
struct edge{int ed, ne, v;} e[N]; int he[N], en;
int fa[N];
bool chs[N];
struct D{int u, v, w;} a[N];
int de[N], f[N][15]; LL g[N][15];
int num1, num2; LL ans;

int lp(int a, int b) {
	int ret = 1;
	for(; b; b >>= 1, a = (LL)a * a % P)
		if(b & 1) ret = (LL)ret * a % P;
	return ret;
}

void ins(int a, int b, int c) {
	e[++en].ed = b; e[en].v = c; e[en].ne = he[a]; he[a] = en;
}

bool cmp(D a, D b) {return a.w < b.w;}

int find(int x) {return x == fa[x]? x: fa[x] = find(fa[x]);}

void dfs(int u, int fa) {
	int i, v;
	de[u] = de[fa] + 1;
	rep(i, 1, 11) {
		f[u][i] = f[f[u][i-1]][i-1];
		g[u][i] = max(g[u][i-1], g[f[u][i-1]][i-1]);
	}
	for(i = he[u]; i; i = e[i].ne)
	if(e[i].ed != fa) {
		v = e[i].ed;
		f[v][0] = u; g[v][0] = e[i].v;
		dfs(v, u);
	}
}

LL lca(int x, int y) {
	LL t = 0; int i;
	if(de[x] < de[y]) swap(x, y);
	dep(i, 11, 0)
		if(de[f[x][i]] >= de[y]) {t = max(t, g[x][i]); x = f[x][i];}
	if(x == y) return t;
	dep(i, 11, 0)
		if(f[x][i] != f[y][i]) {
			t = max(t, g[x][i]); x = f[x][i];
			t = max(t, g[y][i]); y = f[y][i];
		}
	t = max(t, max(g[x][0], g[y][0]));
	return t;
}

void info() {
	int i; LL t;
	if(sum > X) {ans = 0; return;}
	if(sum == X) {
		num1 = n-1;
		rep(i, 1, m)
		if(!chs[i] && lca(a[i].u, a[i].v) == a[i].w) ++num1;
		num2 = m - num1;
		ans = (LL)(lp(2, num1) - 2ll + P) % P * lp(2, num2) % P;
		return;
	}
	if(sum < X) {
		rep(i, 1, m)
		if(!chs[i]) {
			t = sum - lca(a[i].u, a[i].v) + a[i].w;
			if(t == X) ++num1; else
				if(t > X) ++num2;
		}
		ans = (LL)(lp(2, num1) - 1ll + P) % P * lp(2, num2+1) % P;
		return;
	}
}

int main() {
	int i, j, x, y;
	scanf("%d%d", &n, &m);
	scanf("%lld", &X);
	rep(i, 1, m) scanf("%d%d%d", &a[i].u, &a[i].v, &a[i].w);
	
	sort(a+1, a+m+1, cmp);
	rep(i, 1, n) fa[i] = i;
	rep(i, 1, m) {
		x = find(a[i].u); y = find(a[i].v);
		if(x != y) {
			sum += a[i].w;
			fa[x] = y;
			chs[i] = 1;
			ins(a[i].u, a[i].v, a[i].w); ins(a[i].v, a[i].u, a[i].w);
		}
	}
	
	dfs(1, 0);
	info();
	printf("%lld\n", max(ans, 0ll));
	return 0;
}

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

int main()
{
    string s,t; cin>>s>>t;
    int a,b; cin>>a>>b;
    string u; cin>>u;
    if(u==s){
        cout<<a-1<<" "<<b<<endl;
    }
    else if(u==t){
        cout<<a<<" "<<b-1<<endl;
    }
}


Measured memory_bytes: 3628
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,m,a[200005];
int ask(int l,int m,int r)
{
	if(l<=r)return l<=m&&m<=r;
	else return l<=m||m<=r;
}
bool check(int v)
{
	int ansl=0,ansr=0;
	for(int i=1;i<=2*n;i++)
	{
		int l=(m-a[i])%m;
		int r=(v-a[i]+m)%m;
		int ll=1,rr=2*n;
		while(ll<=rr)
		{
			int mid=(ll+rr)/2;
			if(a[mid]<l)ll=mid+1;
			else rr=mid-1;
		}
		int nowl=ll;
		ll=1,rr=2*n;
		while(ll<=rr)
		{
			int mid=(ll+rr)/2;
			if(a[mid]<=r)ll=mid+1;
			else rr=mid-1;
		}
		int nowr=rr;
		nowl=(nowl+2*n-1)%(2*n)+1;
		nowr=(nowr+2*n-1)%(2*n)+1;
		if((a[nowl]+a[i])%m>v||(a[nowr]+a[i])%m>v)return 0;
		nowl=(nowl+i-2)%(2*n)+1;
		nowr=(nowr+i-2)%(2*n)+1;
		if(i==1)ansl=nowl,ansr=nowr;
		else
		{
			if(ask(ansl,ansr,nowl)&&ask(ansr,nowl,nowr)&&ask(nowl,nowr,ansl)&&ask(nowr,ansl,ansr)&&ansr!=nowl&&ansl!=nowr)
			  return 0;
			if(ansl>ansr)
			{
				if(nowl>=ansl||nowl<=ansr)ansl=nowl;
			}
			else
			{
				if(nowl>=ansl&&nowl<=ansr)ansl=nowl;
			}
			if(ansl>ansr)
			{
				if(nowr>=ansl||nowr<=ansr)ansr=nowr;
			}
			else
			{
				if(nowr>=ansl&&nowr<=ansr)ansr=nowr;
			}
		}
	}
	if(ansl==ansr&&(ansl&1)==1)return 0;
	return 1;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=2*n;i++)scanf("%d",&a[i]);
	sort(a+1,a+2*n+1);
	int l=0,r=m;
	while(l<=r)
	{
		int mid=(l+r)/2;
		if(check(mid))r=mid-1;
		else l=mid+1;
	}
	printf("%d\n",l);
	return 0;
}

Measured memory_bytes: 896
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
s=input()
n=len(s)
mod=10**9+7
dp=[[0]*(n+1) for _ in range(4)]
dp[0][0]=1
for i in range(n):
    for j in range(4):
        if s[i]=="?":
            dp[j][i+1]+=dp[j][i]*3
        else:
            dp[j][i+1]+=dp[j][i]
    if s[i]=="A" or s[i]=="?":
        dp[1][i+1]+=dp[0][i]
    if s[i]=="B" or s[i]=="?":
        dp[2][i+1]+=dp[1][i]
    if s[i]=="C" or s[i]=="?":
        dp[3][i+1]+=dp[2][i]
    for j in range(4):
        dp[j][i+1]%=mod
print(dp[3][-1])

Measured memory_bytes: 82192
def main():
    x1, y1, x2, y2 = map(int, input().strip().split())
    
    dx = x2 - x1
    dy = y2 - y1

    x3 = x2 - dy
    y3 = y2 + dx

    x4 = x3 - dx
    y4 = y3 - dy

    print(x3, y3, x4, y4)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef unsigned long long ull;
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}

inline void solve(void){
  int N;
  in(N);
  up(i,1,9){
    if(N%i==0&&N/i<10){
      out("Yes");
      return;
    }
  }
  out("No");
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
double p[3000];
double ans[3000][3000];
double func(int i,int c){
    if(i==n){
        if(c>n/2)
            return 1;
        return 0;
    }
    // if(i-c > n/2)
    //     return 0;
    if(ans[i][c] != -1)
        return ans[i][c];
    return ans[i][c] = func(i+1,c+1)*p[i] + func(i+1,c)*(1-p[i]);
}
int main(){
    // int n;
    cin >> n;
    // double p[n+1];
    for(int i=0; i<n; i++){
        cin >> p[i];
    }
    // double ans[n+1][n+1];
    // for(int i=0;i<)
    for(int i=0;i<3000; i++){
        for(int j=0; j<3000; j++){
            ans[i][j] = -1;
        }
    }
    cout << setprecision(15) << fixed;
    cout << func(0,0);
    return 0;
}

Measured memory_bytes: 74280
#include<iostream>
using namespace std ;
int main()
{
	int cards[4][13]={} , i=0 , s=0 , a=0 , ia=0 , ib=0 ;
	char mark ;
	cin >> s ;
	for (i=0;i<s;i++)
	{
		cin >> mark >> a ;
		if(mark=='S')
		{
			cards[0][a-1]=1 ;
		}
		else if(mark=='H')
		{
			cards[1][a-1]=1 ;
		}
		else if(mark=='C')
		{
			cards[2][a-1]=1 ;
		}
		else if(mark=='D')
		{
			cards[3][a-1]=1 ;
		}
	}
	for(ia=0;ia<4;ia++)
	{
		for(ib=1;ib<=13;ib++)
		{
			if(cards[ia][ib-1]==0)
			{
				if(ia==0)
				{
					cout << "S" << " " << ib << endl ;
				}
				else if(ia==1)
				{
					cout << "H" << " " << ib << endl ;
				}
				else if(ia==2)
				{
					cout << "C" << " " << ib << endl ;
				}
				else if(ia==3)
				{
					cout << "D" << " " << ib << endl ;
				}
			}
		}
	}
	return 0 ;
}



Measured memory_bytes: 3084
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define ll long long
#define rep(i, s, n) for(int i = s; i < n; i++)

int main() {
    int n;
    cin >> n;
    vector<int> x(n);
    rep(i, 0, n) cin >> x[i];
    sort(x.begin(), x.end());
    int p;
    int diff = 0;
    int l, r;
    rep(i, 1, n) {
        if(diff < x[i]-x[i-1]) {
            diff = x[i]-x[i-1];
            l = x[i-1];
            r = x[i];
        }
    }
    //cout << l << " " << r << endl;
    int ans = 1000000;
    rep(i, 1, 101) {
        int sum = 0;
        rep(j, 0, n) {
            sum += pow(x[j]-i, 2);
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


class Program
{
    static void Main()
    {
        string arg = Console.ReadLine();
        string[] args = arg.Split(' ');

        int A = int.Parse(args[0]);
        string op = args[1];
        int B = int.Parse(args[2]);
        int Ans = 0;

        if (op.Equals("+"))
        {
            Ans = A + B;
        }
        else
        {
            Ans = A - B;
        }

        Console.WriteLine(Ans);
    }
}



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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    ll n;cin>>n;
    ll ans=0;
    for(ll i=1;i*i<=n;++i){
        if(n%i==0){
            if(n/i-1>0&&n/i-1>i){
                ans+=n/i-1;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF=1e18;
const int maxn=110;
void chkmin(long long &x,long long y){
	x=x<y?x:y;
}
void chkmax(long long &x,long long y){
	x=x>y?x:y;
}
struct node{
	long long pri;
	int siz,lim;
}a[maxn],stk[10010];
bool cmp(const node &A,const node &B){
	return A.siz*B.pri>B.siz*A.pri;
}
int n,X,D;
int f[maxn];
long long dp[51*51*51];
void get_dp(){
	int top=0,l;
	for(int i=1;i<=n;i++){
		l=a[i].lim<=n?a[i].lim:n;
		a[i].lim-=l;
		for(int j=0;;j++){
			if((1<<j)<=l){
				stk[++top]=(node){a[i].pri*(1<<j),a[i].siz*(1<<j),1};
				l-=1<<j;
			}
			else
				break;
		}
		if(l) stk[++top]=(node){a[i].pri*l,a[i].siz*l,1};
	}
	for(int i=n*n*n;i>=0;i--)
		dp[i]=INF;
	dp[0]=0;
	for(int i=1;i<=top;i++)
		for(int j=n*n*n;j>=stk[i].siz;j--){
			chkmin(dp[j],dp[j-stk[i].siz]+stk[i].pri);
		}
}
int main(){
	scanf("%d%d%d",&n,&X,&D);
	scanf("%lld",&a[1].pri);
	for(int i=2;i<=n;i++)
		scanf("%lld%d",&a[i].pri,&f[i]);
	for(int i=n;i>=1;i--){
		a[i].siz++;
		a[f[i]].pri+=a[i].pri;
		a[f[i]].siz+=a[i].siz;
	}
	for(int i=2;i<=n;i++)
		a[i].lim=D;
	a[1].lim=1e9+100;
	sort(a+1,a+n+1,cmp);
	get_dp();
	long long ans=0,sum;
	long long res,v;
	for(int i=n*n*n;i>=0;i--){
		res=X-dp[i],sum=i;
		if(res<0) continue;
		for(int j=1;j<=n;j++){
			v=res/a[j].pri;
			if(a[j].lim<v) v=a[j].lim;
			res-=v*a[j].pri;
			sum=sum+v*a[j].siz;
		}
		chkmax(ans,sum);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define va first
#define vb second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MN = 1e5+5;
int H,W,K,A[20][2000],D[20],C[20];
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> H >> W >> K;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            char c;
            cin >> c;
            A[i][j] = c-'0';
        }
    }
    int X = 1<<(H-1), ans = 100000;
    for(int x=0; x<X; x++){
        int cnt = __builtin_popcount(x);
        bool impos = 0;
        for(int i=0; i<H; i++) D[i] = 0;
        for(int j=0; j<W; j++){
            bool ch = 0;
            int pos = 0;
            for(int i=0; i<H; i++) C[i] = 0;
            for(int i=0; i<H; i++){
                C[pos] += A[i][j];
                if(x&1<<i) pos++;
            }
            for(int i=0; i<=pos; i++){
                if(D[i]+C[i]>K) ch = 1;
                if(C[i]>K){
                    impos = 1;
                    break;
                }
            }
            if(impos) break;
            for(int i=0; i<=pos; i++){
                if(ch) D[i] = C[i];
                else D[i] = D[i]+C[i];
            }
            if(ch) cnt++;
        }
        if(impos) continue;
        ans = min(ans,cnt);
    }
    cout << ans;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vii = vector<ii>;
const ll oo = 1e18L+5;

// dp[i][j] - minimum cost to convert all vertices in interval [i,j)
//            into one vertex

int main() {
    
    int n;
    scanf("%d",&n);
    
    vi a(n);
    for(int& x : a) {
        scanf("%d",&x);
    }
    
    vector<vector<ll>> dp(n, vector<ll>(n,oo));
    
    for(int L = n-1; L >= 0; --L) {
        for(int R = L; R < n; ++R) {
            if(L == R) {
                dp[L][R] = 0;
            } else {
                
                ll sum = 0;
                for(int i = L; i <= R; ++i) {
                    sum += (ll)a[i];
                }
                
                for(int k = L; k < R; ++k) {
                    dp[L][R] = min(dp[L][R], dp[L][k]+dp[k+1][R]+sum);
                }
            }
        }
    }
    
    printf("%lld\n", dp[0][n-1]);
    
    return 0;
}




Measured memory_bytes: 1536
x,k,d=list(map(int,input().split()))
x=abs(x)
syou, amari = divmod(abs(x),d)
if x>0:
    if x-k*d==0:
        print(0)
    elif x-k*d<0:
        if amari==0:
            newk=k-syou
            if newk%2==0:
                print(0)
            else:
                print(d)
        elif amari!=0:
            newk=k-syou+1
            if newk%2==0:
                print(abs(x-d*(syou+1)))
            else:
                print(abs(x-d*syou))
    elif x-k*d>0:
        print(abs(x-k*d))
if x==0:
    if k%2==0:
        print(0)
    else:
        print(d)


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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)2e18);
const int ninf=((int)-2e18);
const int mod=1000000007;

using namespace std;

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("../in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);


    int n,d;

    cin>>n>>d;

    int ans=ceil(n*1.0/(2*d+1));

    cout<<ans;



    return 0;
}


Measured memory_bytes: 3676
#include<iostream>
#include<vector>
using namespace std;
vector<pair<long long,long long>> prime(long long n){
  vector<pair<long long,long long>>res;
  for(long long a=2;a*a<=n;a++){
    if(n%a!=0) continue;
    long long ex=0;
    while(n%a==0){
      ex++;
      n/=a;
    }
    res.push_back({a,ex});
  }
  if(n!=1) res.push_back({n,1});
  return res;
}
int main(){
  long long n;
  cin>>n;
  auto a=prime(n);
  long long ans=0;
  for(auto pf:a){
    long long e=pf.second;
    long long tmp=0,cur=1;
    while(e>=cur) e-=cur++,++tmp;
    ans+=tmp;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3620
#[allow(unused_imports)]
use proconio::{input, marker::*};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

fn main() {
    input! {
        n: usize,
        a: [usize;n],
    }
    let mut count = 0usize;
    for i in 0..n {
        if i % 2 == 0 && a[i] % 2 == 1 {
            count += 1;
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
// #include <math.h>
// #include <cmath>
// #include <vector>
// #include <utility> 
// #include <unordered_map>
#include <map>
// #include <string>

using namespace std;
typedef long long int lli;

#define M_PI_H  3.14159265358979323846/2  /* pi by two*/
#define rep(i, start, end) for(int i = start; i < end; i++) 
#define repr(i, start, end) for(int i = start; i >= end; i--)   //INCLUSIVE



int main() 
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
	
	int n; cin>>n;
	map<lli , lli> mp;

	lli sum=0;
	rep(i, 0, n){
		lli j; cin>>j;
		mp[j]++;
		sum+=j;
	}

	int q; cin>>q;

	rep(i, 0, q){
		lli b, c; cin>>b>>c;
		sum -= mp[b] * b;
		sum += mp[b] * c;
		mp[c] += mp[b];
		mp[b] = 0;
		cout<<sum<<"\n";
	}
	
    return 0;
}

Measured memory_bytes: 9472
import Control.Applicative

main :: IO ()
main = do  
  x <- getInts
  let a = x !! 0 - x !! 1
  if a == 0 then putStrLn "a == b"
  else if a > 0 then putStrLn "a > b"
  else putStrLn "a < b"




getInts = do 
  x <- getLine 
  let y = (map$toInt)$words x
  return y

toInt :: (String -> Int)
toInt x = read x :: Int



Measured memory_bytes: 3572
#import math
import fractions
from functools import reduce

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

B = []
for i in range(N):
    B.append(abs(X- A[i]))

#最大公約数    
def gcd_list(numbers):
    #return reduce(math.gcd, numbers)
    return reduce(fractions.gcd, numbers)

print(gcd_list(B))


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

using namespace std;
#define ll long long int

int main()
{
    ll n,m;
    cin>>n>>m;
    ll a[n+1]={0};
    for(int i=1;i<=n;i++)
        cin>>a[i];
    ll b[n+1];
    for(int i=0;i<=n;i++)
        b[i]=1;
    while(m--)
    {
        ll a1,b1;
        cin>>a1>>b1;
        if(a[a1]>a[b1])
        {
             b[b1]=-1;
        }
        else if(a[a1]<a[b1] )
        {
            b[a1]=-1;
        }
        else if(a[a1]==a[b1])
        {
                b[a1]=-1;
                b[b1]=-1;
        }

    }
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        if(b[i]==1)
        ans++;
        //cout<<b[i]<<" ";
    }
    cout<<ans;
}


Measured memory_bytes: 5176
import java.util.*;
public class Main {

	static long[][] dp;
	static PriorityQueue<S> q;
	
	static class S{
		int a, b;
		long c;
		S(int a, int b, long c){
			this.a = a;
			this.b = b;
			this.c = c;
		}
	}
	
	static void push(int a, int b, long c) {
		if(b < 0)
			return;
		if(dp[a][b] <= c)
			return;
		dp[a][b] = c;
		q.add(new S(a, b, c));
	}
	
	public static void main(String[] args) {
		long INF = Long.MAX_VALUE/10;
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int S = sc.nextInt();
		int smax = 50 * N;
		Set<S>[] E = new Set[N];
		for(int i = 0; i < N; i++)
			E[i] = new HashSet<>();
		for(int i = 0; i < M; i++) {
			int U = sc.nextInt()-1;
			int V = sc.nextInt()-1;
			int A = sc.nextInt();
			int B = sc.nextInt();
			E[U].add(new S(V, A, B));
			E[V].add(new S(U, A, B));
		}
		int[] C = new int[N];
		int[] D = new int[N];
		for(int i = 0; i < N; i++) {
			C[i] = sc.nextInt();
			D[i] = sc.nextInt();
		}
		dp = new long[N][smax+1];
		for(int i = 0; i < N; i++)
			Arrays.fill(dp[i], INF);
		dp[0][Math.min(smax, S)] = 0;
		q = new PriorityQueue<>((p1,p2)->Long.compare(p1.c,p2.c));
		q.add(new S(0, Math.min(smax, S), 0));
		while(q.size() > 0) {
			S s = q.poll();
			if(dp[s.a][s.b] != s.c)
				continue;
			push(s.a, Math.min(s.b + C[s.a], smax), s.c+D[s.a]);
			for(S e : E[s.a])
				push(e.a, s.b-e.b, s.c+e.c);
		}
		for(int i = 1; i < N; i++) {
			long ans = INF;
			for(long t : dp[i])
				ans = Math.min(ans, t);
			System.out.println(ans);
		}
	}

}

Measured memory_bytes: 54816
#include<algorithm>
#include<iostream>
#include<vector>

int main()
{
    int_fast16_t n;
    std::cin >> n;

    std::vector<int_fast16_t> as(n);
    for(auto i = 0; i < n; i++)
    {
        std::cin >> as[i];
    }

    std::sort(as.begin(), as.end(), std::greater<int_fast16_t>());
    int_fast32_t alice = 0;
    int_fast32_t bob = 0;
    for (auto i = 0; i < n; i++)
    {
        if( i%2 == 0)
        {
            alice += as[i];
        }
        else
        {
            bob += as[i];
        }
    }
    
    std::cout << alice - bob << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define rep(i, a, b) for(int i = a; i < b; i++)


int main()
{ 
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);     
  ll n;
  cin >> n;
  ll a[n+1];
  map<ll,ll>m;
  rep(i,0,n)
  {
    cin>>a[i];
    m[a[i]]++;
  }
  rep(i,1,n+1)
  {
    if(m[i]==0)m[i]=0;
  }
  rep(i,1,n+1)cout<<m[i]<<endl;

} 

Measured memory_bytes: 17684
#include <bits/stdc++.h>
using namespace std;
const int N=100005;
int n,k,t,a[N];
void Get_t(){
	t=-1;
	for (int i=1;i<=n;i++)
		if (a[i]==0)
			t=i;
	if (~t)
		return;
	k++;
	a[++n]=0;
	sort(a+1,a+n+1);
	for (int i=1;i<=n;i++)
		if (a[i]==0)
			t=i;
}
int main(){
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	int ans=1e9;
	Get_t();
//	printf("%d\n",t);
//	for (int i=1;i<=n;i++)
//		printf("%d ",a[i]);puts("");
	if (n-t+1>=k)
		ans=min(ans,abs(a[t+k-1]));
	if (t>=k)
		ans=min(ans,abs(a[t-k+1]));
	for (int i=max(1,k-t);i<=min(n-t,k-1);i++)
		ans=min(ans,abs(a[t-(k-i)+1])+2*abs(a[t+i]));
	for (int i=max(1,k-(n-t+1));i<=min(t-1,k-1);i++)
		ans=min(ans,abs(a[t+(k-i)-1])+2*abs(a[t-i]));
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include<vector>
#include<iostream>
#include<string>
#include<deque>
using namespace std;


int main() {
	int q;
	int d;
	int x;
	int p;
	int query;
	deque<int> arr;

	cin >> q;

	for (int i = 0; i < q; i++)
	{
		cin >> query;
		switch (query)
		{
		case 0:
			cin >> d;
			cin >> x;
			if (d == 0)
			{
				arr.push_front(x);
			}
			else
			{
				arr.push_back(x);
			}
			break;
		case 1:
			cin >> p;
			cout << arr[p]<<endl;
			break;
		case 2:
			cin >> d;
			if (d == 0)
			{
				arr.pop_front();
			}
			else
			{
				arr.pop_back();
			}
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 4608
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<math.h>
#include<set>
#include<iomanip>
#include<stdio.h>
#include<deque>
#include<stack>
#include<map>
#include<queue>
#include<cstring>
#define M 1000000007
#define pb push_back
#define mp make_pair
#define int long long
using namespace std;
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,k,q;
	cin>>n>>k>>q;
	int a[n]={0},i;
	for(i=0;i<q;i++)
	{
		int x;
		cin>>x;
		x--;
		a[x]++;
	}
	for(i=0;i<n;i++)
	{
		if(q-a[i]>=k)
			cout<<"No\n";
		else
			cout<<"Yes\n";
	}
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define INF 1000000007
//S.size()

using namespace std;


typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<bool> VB;
typedef unsigned long long ll;



int main(void){
  int N,D,X;cin>>N>>D>>X;
  int a[N];rep(i , N)cin>>a[i];

  int cnt = 0;

  for(int t = 0;t < N;t++){
    for(int j = 1;j <= 10000;j++){
      if(a[t] * j + 1 <= D)cnt++;
      else break;
    }
    
  }
  cout<<cnt + N + X;
}


Measured memory_bytes: 256
while True:
   N = int(input())
   if N == 0:
      break
   s = list(range(1, (N+1)//2+1))
   c = 0
   for i in range(len(s)):
      for j in range(len(s)):
         if s[i] + 1 <= s[j]:
            if N == sum(range(s[i],s[j]+1)):
               c += 1
   print(c)


Measured memory_bytes: 5604
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define Set set<int>
#define int long long
#define P pair<int,int>
const int maxn = 1e6;
const int INF = 1e18 +6;
using namespace std;
int n,m,a[maxn],b[maxn],c[maxn];

int32_t main() {
    IOS;
    int r,D,x;
    cin>>r>>D>>x;
    fu(i,1,10) {
        cout <<r*x-D<<endl;
        x=r*x-D;
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define revrep(i, n) for(int i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;
double EPS = 1e-11;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A){printf("%.9lf\n", A);}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};


//コンビネーション
const int MAXcomb = 2000010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

const int MAXkai = 200010;
ll kai_memo[MAXkai];
ll kai(ll N){
  if(kai_memo[N] != 0) return kai_memo[N];
  if(N <= 1) return 1;
  return kai_memo[N] = N * kai(N-1) % MOD;
}

ll disit(ll s, ll base = 10){
  ll res = 0;
  while(s){
    res++;
    s /= base;
  }
  return res;
}


ll n;
ll s[100010];
void solve(){
  cin >> n;
  rep(i, n) cin >> s[i];
  ll ans = 0;
  for(ll i = 1; i <= n - 1; i++){
    ll sum = 0;
    set<ll> used;
    used.insert(0);
    used.insert(n-1);
    for(ll t = 1; t <= n; t++){
      ll u = n-1 - i * t;
      ll d = i * t;
      if(u < 0) break;
      if(d >= n) break;
      if(u == d) break;
      if(used.count(d)) break;
      used.insert(d);
      if(used.count(u)) break;
      used.insert(u);
      if(u <= i) break;//!!!!!
      sum += s[u] + s[d];
      ans = max(ans, sum);
    }
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 5760
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
  int c[3];
  cin >> c[0] >> c[1] >> c[2];
  sort(c, c + 3);
  if(c[0] + c[1] == c[2]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

int main() {
    int A, B;
    cin >> A >> B;
    FOR(i, 1, 4) {
        if ((A*B*i) % 2 == 1) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << 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>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;


#define LETS_GET_SCHWIFTY ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);  
#define ff              first
#define ss              second
#define int             long long
#define ll              long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define vpii            vector<pair<int,int> >
#define all(x)          x.begin(),x.end()
#define matrixprint(arr,a,b,c,d) for(int i=a;i<=c;i++){for(int j=b;j<=d;j++){cout<<arr[i][j]<<" ";}cout<<"\n";}
#define show(arr,x,y)   for(int i=x;i<=y;i++){cout<<arr[i]<<" ";}cout<<"\n"
#define sz(x)           (int)x.size()
#define db(x)           cout<<x<<"\n";

const int N = 2e5 + 5;

#define TRACE
#ifdef TRACE
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define deb(...)
#endif

	
//////////////////////////////code//////////////////////////////


int n,m;
int dp[1001][1001];
char arr[1001][1001];

int sol(int i,int j)
{
    if(i==n-1 && j==m-1)
    return 1;
    
    if(dp[i][j]!=-1)
    return dp[i][j];
    
    int a1 = 0,a2 = 0;
    
    if(i+1<n && arr[i+1][j]=='.')
    a1 = sol(i+1,j);
    
    if(j+1<m && arr[i][j+1]=='.')
    a2 = sol(i,j+1);
    
    return dp[i][j]=(a1+a2)%mod;
}


void solve()
{
  //  cout << "-------------------" << "\n";
   
   cin>>n>>m;
   
   for(int i=0;i<n;i++)
    for(int j=0;j<m;j++)
     cin>>arr[i][j];
     
     memset(dp,-1,sizeof(dp));
     
   cout<<sol(0,0);
    

  
   // cout << "-------------------" << "\n";

}

int32_t main()
{

    LETS_GET_SCHWIFTY;

    int t = 1;
   // cin >> t;

    while (t--)
        solve();

}

// check out for following mistakes-
// if using pb operation on vector and then trying to access index..check if sizeof that vec could remain 0 only
// is using prime sieve make sure it fits
// when using factorial template or combinatorics make sure that you edit fillfac fun values and array values


Measured memory_bytes: 12532
N = int(input())
xn, un =[0]*N, [0]*N
for i in range(N):
    xn[i], un[i] = map(str,input().split())

ans = 0
for i in range(N):
    if un[i] == "JPY":
        ans += float(xn[i])
    if un[i] == "BTC":
        ans += float(xn[i])*380000
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define N (long long)(998244353)
#define MAX 500000
using namespace std;

long long factorial[MAX] = {0}, finverse[MAX] = {0},
          inverse[MAX] = {0};

void smodfact() {
  factorial[0] = factorial[1] = 1;
  finverse[0] = finverse[1] = 1;
  inverse[1] = 1;
  for(int i = 2; i < MAX; ++i) {
    factorial[i] = factorial[i - 1] * i % N;
    inverse[i] = N - (inverse[N % i] * (N / i)) % N;
    finverse[i] = finverse[i - 1] * inverse[i] % N;
  }
}

long long calccomb(long long n, long long k) {
  if(n == k && n == 0) return 1;
  if(n < 0 || k < 0 || n < k) return 0;
  return factorial[n] * finverse[k] % N * finverse[n - k] %
         N;
}

// as + bt = GCD(a,b) a,b:const s,t:var(any)
// return GCD(a,b)
long long extGCD(long long a, long long b, long long& s,
                 long long& t) {
  s = 1, t = 0;
  while(b) {
    long long tmp = a / b;
    a -= b * tmp;
    s -= t * tmp;
    swap(a, b);
    swap(s, t);
  }
  return a;
}

// (mod)x+ay=1, calculate y -> a^-1 (mod m) (a,m : coprime)
long long calcinv(long long a, long long m) {
  long long s, t;
  extGCD(a, m, s, t);
  return (s + m) % m;
}

long long mod_pow(long long x, long long n, long long mod) {
  long long res = 1;
  while(n > 0) {
    if(n & 1) (res *= x) %= mod;
    (x *= x) %= mod;
    n >>= 1;
  }
  return res;
}

long long m, n, k;
long long mci[1005] = {0};
long long dp[1005][1005] = {0};

long long solve();

int main() {
  cin >> m >> n >> k;
  cout << solve() << endl;
  return 0;
}

long long solve() {
  if(m < k) return 0;
  smodfact();
  long long ans = mod_pow(m % N, n, N);
  mci[0] = 1LL;
  for(long long i = 0; i < k; ++i)
    mci[i + 1] =
        mci[i] * ((m - i) % N) % N * calcinv(i + 1, N) % N;
  // dp
  dp[0][0] = 1;
  for(long long i = 1; i <= k; ++i)
    for(long long j = 1; j <= i; ++j) {
      if(i != j) {
        dp[i][j] = calccomb(i, j) * dp[j][j] % N;
        (dp[i][j] += dp[i][j - 1]) %= N;
      }
      else {
        dp[i][j] = mod_pow(i % N, n, N);
        dp[i][j] -= dp[i][j - 1];
        (dp[i][j] += N) %= N;
      }
    }

  for(int i = 0; i < k - 1; ++i) {
    ans -= mci[i + 1] * dp[i + 1][i + 1] % N;
    (ans += N) %= N;
  }
  return ans;
}



Measured memory_bytes: 21676
#include <stdio.h>

void ma(int*,int,int,int);
void mS(int*,int,int);
int cnt=0;

int main(){
  int i,n;

  scanf("%d",&n);
  int S[n];
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  
  mS(S,0,n);
  
  for(i=0;i<n-1;i++){
    printf("%d ",S[i]);
  }
  printf("%d\n%d\n",S[n-1],cnt);
  
  return 0;
}

void ma(int *S, int l,int m,int r){
  int i,j,k,n1=m-l,n2=r-m;
  int L[n1],R[n2];

  for(i=0;i<n1;i++){
    L[i]=S[l+i];
  }
  for(i=0;i<n2;i++){
    R[i]=S[m+i];
  }
  L[n1]=1000000000;
  R[n2]=1000000000;
  i=0;
  j=0;
  for(k=l;k<r;k++){
    if(L[i]<=R[j]){
      S[k]=L[i];
      i+=1;
    }
    else{
      S[k]=R[j];
      j+=1;
    }
    cnt++;
  }
}

void mS(int *S,int l, int r){
  int m;
  
  if(l+1<r){
    m=(l+r)/2;
    mS(S,l,m);
    mS(S,m,r);
    ma(S,l,m,r);
  }
  
}


Measured memory_bytes: 5748
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n,k;
    cin>>n>>k;
    if(k==1){
        cout<<0<<endl;
    }else{
        cout<<n-k<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x)  ((x) * (x)) 
#define cub(x)  ((x) * (x) * (x))
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll gcd(ll x, ll y)
{
    ll temp;
    while (y != 0) {
        temp = y;
        y = x % y;
        x = temp;
    }
    return (x);
}

ll lcm( ll m, ll n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm

int main() {
  ll n,m; cin >> n >> m;
  ll a[n];
  ll b[n];
  ll lcma,lcmb;
  FOR(i,0,n-1) {
    cin >> a[i];
    b[i] = a[i]/2;
  }
  lcma = a[0]; lcmb = b[0];
  FOR(i,1,n-1){
    lcmb = lcm(lcmb,b[i]);
    lcma = lcmb * 2;

    if(lcmb>m){
      cout << 0 << endl;
      return 0;
    }
  }

  ll ref = 0;

  while(a[0]%2==0){
    a[0] /= 2;
    ++ref;
  }

  FOR(i,1,n-1){
    ll refref = 0;
    while(a[i]%2==0){
      a[i] /= 2;
      ++refref;
    }

    if(ref!=refref){
      cout << 0 << endl;
      return 0;
    }
  }

  cout << 1 + (m-lcmb) / lcma << endl;




}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <ccomplex>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


// Modint
struct Mint {
	static const ll mod = (ll)(1e9 + 7);
	ll val;

	Mint() { val = 0; }
	Mint(ll a) { val = a; verify_value(); }

	void verify_value() {
		if (val >= mod) val %= mod;
		if (val < 0) val %= mod, val += mod;
	}

	Mint pow(ll p) const {
		Mint cur = Mint(val), ret = 1;
		while (p > 0) {
			if (p & 1) ret *= cur;
			cur *= cur;
			p >>= 1LL;
		}
		return ret;
	}
	Mint inv() const {
		if (val == 0) cerr << "WARNING: inv() is called with 0." << endl;
		return pow(mod - 2);
	}

	Mint operator+() const { return *this; }
	Mint operator-() const { return Mint(mod - val); }

	Mint operator+=(const Mint &a) {
		val += a.val;
		if (val >= mod) val -= mod;
		return Mint(val);
	}
	Mint operator*=(const Mint &a) {
		val *= a.val;
		if (val >= mod) val %= mod;
		return Mint(val);
	}
	Mint operator-=(const Mint &a) { return *this += -a; }
	Mint operator/=(const Mint &a) { return *this *= a.inv(); }

	Mint operator++() { return *this += Mint(1); }
	Mint operator--() { return *this -= Mint(1); }
	Mint operator++(int) {
		Mint ret = *this;
		++(*this);
		return ret;
	}
	Mint operator--(int) {
		Mint ret = *this;
		--(*this);
		return ret;
	}

	operator ll() const { return val; }
};

Mint operator+(const Mint &a, const Mint &b) {
	ll ret = a.val + b.val;
	if (ret >= Mint::mod) ret -= Mint::mod;
	return Mint(ret);
}
Mint operator*(const Mint &a, const Mint &b) {
	ll ret = a.val * b.val;
	if (ret >= Mint::mod) ret %= Mint::mod;
	return Mint(ret);
}
Mint operator-(const Mint &a, const Mint &b) { return a + (-b); }
Mint operator/(const Mint &a, const Mint &b) { return a * b.inv(); }

ostream &operator<<(ostream &out, const Mint &a) { return out << a.val; }
istream &operator>>(istream &in, Mint &a) {
	in >> a.val;
	a.verify_value();
	return in;
}

Mint pow(Mint a, ll b) {
	return a.pow(b);
}

// Combinatorics
constexpr int MAX_N = 2000003;
Mint fact[MAX_N], inv[MAX_N];

void init_fact() {
	fact[0] = inv[0] = 1;
	for (ll i = 1; i < MAX_N; i++) {
		fact[i] = fact[i - 1] * Mint(i);
		inv[i] = fact[i].inv();
	}
}

// aCb
Mint C(int a, int b) {
	if (a < b) return 0;
	Mint res = fact[a];
	res *= inv[b];
	res *= inv[a - b];
	return res;
}

// aPb
Mint P(int a, int b) {
	if (a < b) return 0;
	return fact[a] * inv[a - b];
}

// aHb
Mint H(int a, int b) {
	if (b == 0) return 1;
	return C(a + b - 1, b);
}


int main() {
	int r1, c1, r2, c2; cin >> r1 >> c1 >> r2 >> c2;
	init_fact();
	Mint ans = 0;
	auto sum = [](int r, int c) {
		Mint ret = 0;
		for (int i = 0; i <= r; i++) {
			ret += C(i + 1 + c, c);
		}
		return ret;
	};
	cout << sum(r2, c2) - sum(r1 - 1, c2) - sum(r2, c1 - 1) + sum(r1 - 1, c1 - 1) << endl;
	return 0;
}


Measured memory_bytes: 31488
int main(){
  
  int a, b, k;
  int ans[100];
  int n = 1;
  int max = 0;
  
  scanf("%d%d%d", &a, &b, &k);

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

  for(int cnt = max; cnt > 0; cnt--){
    if((a % cnt == 0) && (b % cnt == 0)){
      ans[n++] = cnt;
    }
  }
  
  printf("%d\n",  ans[k]);
  
}


Measured memory_bytes: 128
n=int(input())
arr=[]
for _ in range(n):
  k=int(input())
  tmp=[list(map(int,input().split())) for _ in range(k)]
  arr.append(tmp)
ans=0
for i in range(2**n):
  tmp=format(i,'b')
  if len(tmp)<n:
    tmp='0'*(n-len(tmp))+tmp
  flag=True
  for i in range(n):
    c=int(tmp[i])
    if c==0:
      continue
    for a,b in arr[i]:
      if int(tmp[a-1])!=b:
        flag=False
        break
  if flag==True:
    ans=max(ans,tmp.count('1'))
print(ans)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define fst first
#define scd second
signed main()
{
	string s, t;
	cin >> s >> t;
	for(int i = 0; i < s.size(); ++i)
	{
		if(s[i] != t[i])
		{
			cout << "No\n";
			return 0;
		}
	}
	if(s.size() + 1 == t.size())
	{
		cout << "Yes\n";
		return 0;
	}
	cout << "No\n";
}


Measured memory_bytes: 3624
//
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <array>
#include <numeric>
#include <functional>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <complex>

using namespace std;

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

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

int main(){

	int n;
	cin >> n;
	cout << 3*n*n << endl;
	return 0;
}


Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
int MAXN = 1010;

int main(){
  int N,l,r;
  int ans = 0;
	cin >> N;
  for (int i = 0; i < N; i++){
    cin >> l >> r;
    ans += r - l +1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;

int main(){
  // 入力
  string N;
  cin >> N;

  string result = "No";
  if(N[0]=='7' || N[1]=='7'  || N[2]=='7' ) {
    result = "Yes";
  }

  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3624
<?php
ini_set('error_reporting', E_ALL & ~E_NOTICE);

fscanf(STDIN, "%d %d", $H, $W);

for ($y = 0; $y < $H; $y++) {
	fscanf(STDIN, "%s", $S);
	$a[$y] = str_split($S);
	for ($x = 0; $x < count($a[$y]); $x++) {
		if ($a[$y][$x] == "#") {
			$sumX[$x]++;
			$sumY[$y]++;
		}
	}
}

for ($y = 0; $y < $H; $y++) {
	if ($sumY[$y] == 0) {
		continue;
	}

	for ($x = 0; $x < $W; $x++) {
		if ($sumX[$x] == 0) {
			continue;
		}

		echo $a[$y][$x];
	}
	echo "\n";
}


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

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

    cin.tie(0);
    ios::sync_with_stdio(false);

    int H;
    int A;

    cin >> H >> A;

    int turn = 0;
    while (H > 0) {
        turn++;
        H -= A;
    }

    cout << turn;

    return 0;
}


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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,r;
    cin >> n >> r;
    if(n >= 10){
        cout << r << "\n";
    }
    else{
        cout << r + (100 *(10-n)) << "\n";
    }
    return 0;
}



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

int main() {
	long long N, ANS = 1, RG = 0, GB = 0, BR = 0, R = 0, G = 0, B = 0, MOD = 998244353;
	string S;
	cin >> N >> S;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'R') {
			if (GB != 0) {
				ANS *= GB;
				ANS %= MOD;
				GB--;
			}
			else if (G != 0) {
				ANS *= G;
				ANS %= MOD;
				G--;
				RG++;
			}
			else if (B != 0) {
				ANS *= B;
				ANS %= MOD;
				B--;
				BR++;
			}
			else {
				R++;
			}
		}
		if (S[i] == 'G') {
			if (BR != 0) {
				ANS *= BR;
				ANS %= MOD;
				BR--;
			}
			else if (B != 0) {
				ANS *= B;
				ANS %= MOD;
				B--;
				GB++;
			}
			else if (R != 0) {
				ANS *= R;
				ANS %= MOD;
				R--;
				RG++;
			}
			else {
				G++;
			}
		}
		if (S[i] == 'B') {
			if (RG != 0) {
				ANS *= RG;
				ANS %= MOD;
				RG--;
			}
			else if (R != 0) {
				ANS *= R;
				ANS %= MOD;
				R--;
				BR++;
			}
			else if (G != 0) {
				ANS *= G;
				ANS %= MOD;
				G--;
				GB++;
			}
			else {
				B++;
			}
		}
	}
	for (int i = 1; i <= N; i++) {
		ANS *= i;
		ANS %= MOD;
	}
	cout << ANS << endl;
}

Measured memory_bytes: 900