akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define ss(a) scanf("%s",a)
#define mem(a,b) memset(a,b,sizeof(a))
#define PII pair<int,int>
const double pi = acos(-1.0);
using namespace std;
const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;
ll a[maxn], sum[maxn], ans;
int main(){
	int n;
	scanf("%d",&n);
	for(int i = 1; i <= n; i ++){
		scanf("%lld",&a[i]);
		sum[i] = sum[i - 1] + a[i];
		sum[i] = sum[i] % mod;
	}
	for(int i = n; i > 1; i --){
		ans = ans + a[i] * sum[i - 1] % mod;
		ans = ans % mod;
	}
	printf("%lld\n",ans);
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

string s;
ll x,y;
vector<ll> a,b;
bool dp1[2][20011],dp2[2][20011];

int main(){
  cin>>s>>x>>y;
  s+="T";
  ll n=s.size();
  ll crt=0,sum=0;
  rep(i,n){
    if(s[i]=='T'){
      if(crt==0)a.push_back(sum);
      else b.push_back(sum);
      sum=0;
      crt=1-crt;
    }else{
      sum++;
    }
  }

  crt=0;
  ll nxt=1;
  dp1[crt][10000]=true;
  rep(i,a.size()){
    memset(dp1[nxt],0,sizeof(dp1[nxt]));
    rep(j,20001){
      if(!dp1[crt][j])continue;
      if(i==0){
        if(j+a[i]<=20000)dp1[nxt][j+a[i]]=true;
      }else{
        if(j+a[i]<=20000)dp1[nxt][j+a[i]]=true;
        if(j-a[i]>=0)dp1[nxt][j-a[i]]=true;
      }
    }
    swap(crt,nxt);
  }

  if(!dp1[crt][x+10000]){
    cout<<"No"<<endl;
    return 0;
  }

  crt=0;
  nxt=1;
  dp2[crt][10000]=true;
  rep(i,b.size()){
    memset(dp2[nxt],0,sizeof(dp2[nxt]));
    rep(j,20001){
      if(!dp2[crt][j])continue;
      if(j+b[i]<=20000)dp2[nxt][j+b[i]]=true;
      if(j-b[i]>=0)dp2[nxt][j-b[i]]=true;
    }
    swap(crt,nxt);
  }

  if(!dp2[crt][y+10000]){
    cout<<"No"<<endl;
    return 0;
  }
  cout<<"Yes"<<endl;

  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9 + 7;  
int n,k;
auto x = vector<ll>();

int main(){
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        ll temp;
        cin >> temp;
        x.push_back(temp);
    }
    
    auto _min = MOD;
    
    for(int i=0;i<n-k+1;i++){
        _min = min(_min,abs(x[i]-x[i+k-1])+abs(x[i]));
    }

    for(int i=0;i<n-k+1;i++){
        _min = min(_min,abs(x[i]-x[i+k-1])+abs(x[i+k-1]));
    }

    cout << _min;
    
}
  
  

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
 
int main() {
 int a,v,b,w,t;
 cin >> a >> v;
 cin >> b >> w;
 cin >> t;

 if(w>=v){
    cout << "NO" << endl; return 0;
 }
 if(v*t>=w*t+abs(b-a)){
    cout << "YES" << endl; return 0;
 }
 cout << "NO" << endl;
return 0;
}

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

using namespace std;
const int maxn = 110;
const int inf = 0x3f3f3f3f;

int n, m;
char niz[maxn][maxn];
int dp[maxn][maxn];

int main() {
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; i++)
        scanf("%s", niz+i);

    dp[0][0] = (niz[0][0] == '#');
    for (int i = 0; i < n; i++) {
        for (int j = (i == 0); j < m; j++) {
            dp[i][j] = inf;
            if (i > 0) dp[i][j] = dp[i - 1][j] + (niz[i - 1][j] == '.' && niz[i][j] == '#');
            if (j > 0) dp[i][j] = min(dp[i][j], dp[i][j - 1] + (niz[i][j - 1] == '.' && niz[i][j] == '#'));
        }
    }
    printf("%d\n", dp[n - 1][m - 1]);
    return 0;
}


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

int main()
{
    string s1, s2;
    cin >> s1 >> s2;
    for(int i = 0; i < s1.size(); i++)
    {
        if(s1 == s2) return cout << "Yes\n", 0;
        s1.insert(s1.begin(), s1.back());
        s1.pop_back();
    }
    cout << "No\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;
const int INF = 1001001001;

int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) {
    cin >> a[i];
  }
  ll sum = 0;
  rep(i, n) {
    sum += a[i];
  }
  ll ans = LLONG_MAX;
  ll l = 0;
  for(int i = 0; i < n; ++i) {
    l += a[i];
    ll r = sum - l;
    ans = min(ans, abs(l - r));
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
import numpy as np
H, W = map(int, input().split())
mC = np.zeros((10, 10), dtype=int)
for i in range(10):
    mC[i] = list(map(int, input().split()))
A = []
for _ in range(H):
    A += list(map(int, input().split()))
from collections import Counter
cnt9 = Counter(A)
del cnt9[-1]
# Warshall-Floyd
for i in range(10):
    mC = np.minimum(mC, mC[i: i + 1] + mC[:, i: i + 1])

ans = 0
for i, cnt in cnt9.items():
    ans += mC[i, 1] * cnt

print(ans)

Measured memory_bytes: 12992
Module C
  Sub Main(ByVal args() As String)
    dim arr() as string = split(console.readline())
    dim n,m,i,s as integer
    dim c as char
    n=arr(0):m=arr(1)
    dim dummy(n-1) as char
    for i=0 to n-1
      dummy(i) = " "c
    next
    if m=0 then dummy(n-1)="0"c
    for i=1 to m
      arr = split(console.readline())
      s=arr(0):c=arr(1)
      if dummy(s-1) = " "c then
        dummy(s-1)=c
      else if dummy(s-1)<>c then
        console.writeline("-1")
        return
      end if
    next
    if (n=2 andalso dummy(0)=" "c andalso dummy(1)=" "c) orelse _
      (n=3 andalso dummy(0)=" "c andalso dummy(1)=" "c andalso dummy(2)=" "c) then
      dummy(n-1)="1"c
	end if
    if dummy(0)=" "c then dummy(0)="1"c
	for i=0 to n-1
  		dummy(i)=if(dummy(i)=" "c,"0"c,dummy(i))
    next
    dim result as string = new string(dummy)
    dim result_int as integer = integer.parse(result)
    console.writeline(if(result_int.tostring().length<n,"-1",result))
  End Sub
End Module

Measured memory_bytes: 13532
//arc077 q1
#include <cstdio>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <tuple>
#include <deque>
#define pb push_back
#define pf push_front
#define mkt make_tuple
#define pqueue priority_queue
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
const int INF =  2147483647;
const ll INFLL = 9223372036854775807;



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

  int n;
  cin >> n;
  vi a;
  for (size_t i = 0; i < n; i++) {
    int ai;
    cin >> ai;
    a.pb(ai);
  }

  deque<ll> b;
  for (size_t i = 0; i < n; i++) {
    if ((n-i) % 2 == 1) {
      b.pf(a[i]);
    } else {
      b.pb(a[i]);
    }
  }
  for_each(b.begin(), b.end(), [](ll x) {
    cout << x << ' ';
  });
  return 0;
}


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

int main(){
  int N;cin >> N;
  ll K;cin >> K;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A[i];
    A[i] --;
  }
  vector<vector<int>> T(61,vector<int>(N));
  T[0] = A;
  for(int n=1;n<61;n++){
    for(int i=0;i<N;i++){
      T[n][i] = T[n-1][T[n-1][i]];
    }
  }
  int ans = 0;
  int n=0;
  while(K>0){
    if(K%2==1){
      ans = T[n][ans];
    }
    K /= 2;
    n ++;
  }
  cout << ans+1 << endl;
}

Measured memory_bytes: 52628
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> a(N); 

  for (int i = 0; i < N; i++) 
    cin >> a.at(i);

  for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        if (a.at(i)>a.at(j)) {
          int b = a.at(i);
          a.at(i)=a.at(j);
          a.at(j)=b;
        }
      }   
  }

  int A=0, B=0;
  for (int i = 0; i < N; i++) {
    if (i%2==0)
       A+=a.at(i);
    else
       B+=a.at(i);
  }

  cout << A-B << endl;
}

Measured memory_bytes: 256
import math
from collections import deque
from collections import defaultdict

import bisect

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq
def get_sieve_of_eratosthenes(n):
	#data = [2]
	data = [0,0,0]
	for i in range(3,n+1,2):
		data.append(i)
		data.append(0)
	for i in range(len(data)):
		interval = data[i]
		if interval!=0:
			for j in range(i+interval,n-1,interval):
				data[j] = 0
	#ans = [x for x in data if x!=0]
	ans = data[:]
	return ans

def isInt(n):
	if isinstance(n, int):
		return True
	else:
		return n.is_integer()

a = readInt()
b = readInt()
c = readInt()
x = readInt()

ans = 0

for i in range(a+1):
	for j in range(b+1):
		k = (x-i*500-j*100)/50
		if isInt(k) and k<=c and k>=0:
			ans+=1

print(ans)

Measured memory_bytes: 3444
#include<stdio.h>
int main(void){
    int n,m,i,j,k,i2,k2,j2,j3;
    scanf("%d %d",&n,&m);
    int a[n][m],b[m],c[n];
    for(i=0;i<n;i++) c[i]=0;
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(i2=0;i2<m;i2++){
        scanf("%d",&b[i2]);
    }
    for(j2=0;j2<n;j2++){
        for(j3=0;j3<m;j3++){
            c[j2]+=a[j2][j3]*b[j3];
            /*printf("%d\n",c[j2]);*/
        }
        printf("%d\n",c[j2]);
    }
    return 0;
}

Measured memory_bytes: 1748
import sys


def f(n):
    re = 1
    for i in range(1,n + 1):
	re *= i
    return re


def solve():
    while True:
	n = int(raw_input())
	if n ==	0:
            break
        else:
            rr = f(n)
            ss = str(rr)
            rss = ss[::-1]
#            print rss                                                          
            for	k in range(len(rss)):
	        if rss[k] != "0":
                    print k
		    break

if __name__ == "__main__":
    solve()

Measured memory_bytes: 6204
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll b[1000],a[1000];
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b); }
int main()
{
	ll x,y;
	cin>>x>>y;
	ll cnm = gcd(x,y);
	ll cnt = 1;
	for(ll i = 2; i * i <= cnm; i++){
		if(cnm % i == 0) 
		{
			cnt++;
			cnm /= i;
			while(cnm % i == 0){
				cnm /= i;
			}
		}
	}
	if(cnm != 1) cnt++;
	cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, Q;
	cin >> N >> Q;
	int X = 0;
	int t, a;
	for (int i = 0; i < Q; i++) {
		cin >> t >> a;
		if (t == 0) {
			int res = (X + a) % N;
			if (res == 0)res = N;
			cout << res << endl;
		}
		else {
			X = (X + a) % N;
		}
	}
}


Measured memory_bytes: 3204
def main():
    s = input()
    n = len(s)
    result = "No"
    if s == s[::-1]:
        m = (n - 1) // 2
        if s[:m] == s[:m][::-1]:
            l = (n + 3) // 2
            if s[l - 1:] == s[l - 1:][::-1]:
                result = "Yes"
    print(result)

if __name__ == '__main__':
    main()


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

signed main(){
	int q;
	set<int>s;
	cin>>q;
	while(q--){
		int x,y;
		cin>>x>>y;
		if(x==1)cout<<s.count(y)<<endl;
		else if(!x){
			s.insert(y);
			cout<<s.size()<<endl;
		}
		else{
			s.erase(y);
		}
	}
}


Measured memory_bytes: 12432
import java.lang.StringBuilder

fun main(args:Array<String>) {
    val (n,q) = readLine()!!.split(" ").map { it.toInt() }
    val inpt = readLine()!!
    val ans = StringBuilder()
    val acCount = mutableListOf<Int>()
    acCount.add(0)
    for(i in (1 until inpt.length)) {
        acCount.add(acCount.last())
        if(inpt[i-1] == 'A' && inpt[i] == 'C') {
            acCount[i]++
        }
    }
    for(i in (1..q)) {
        var (start,end) = readLine()!!.split(" ").map { it.toInt() - 1 }
        if(start > 0 && inpt[start] == 'C') {
            start++
        }
        var cnt = acCount[end]
        if(start > 0) {
            cnt -= acCount[start - 1]
        }
        ans.appendln(cnt)
    }
    print(ans.toString())
}



Measured memory_bytes: 58496
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      char[] c = sc.next().toCharArray();
      int[] w = new int[n+2];
      int[] e = new int[n+2];
      for(int i = 1;i <= n;i++){
      	if(c[i-1]=='W')w[i]++;
        if(c[i-1]=='E')e[i]++;
        w[i]+=w[i-1];
        e[i]+=e[i-1];
      }
      int min = 10000000;
      if((c[0]=='E'&&w[n]==n-1)||(c[n-1]=='W'&&e[n]==n-1))min = 0;
      for(int i = 0;i <= n;i++){
        int x = e[n]-e[i+1];
        int y = w[i];
      	min = Math.min(min,x+y);
      }
      System.out.println(min);
    }
}


Measured memory_bytes: 32616
n,x,y=map(int, input().split())

ans=[0]*(n-1)

for i in range(1, n+1):
    for j in range(i+1, n+1):
        d=min(j-i, abs(x-i)+1+abs(j-y), abs(y-i)+1+abs(j-x))
        #print(i,j,d)
        ans[d-1]+=1

for a in ans:
    print(a)

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

long long int combination(long long int n, long long int r) {
  if ( r * 2 > n ) r = n - r;
  long long int dividend = 1;
  long long int divisor  = 1;
  for ( long long int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}

int main() {
    long long int n, count = 0, ans = 0;
    map<string, int> mp;
    cin >> n;
    string s_;
    for(int i = 0; i < n; ++i) {
        cin >> s_;
        sort(s_.begin(), s_.end());
        mp[s_]++;
    }

    auto begin = mp.begin(), end = mp.end();
    for (auto iter = begin; iter != end; iter++) {
        if(iter->second >= 2) {
            ans += combination(iter->second, 2);
        }
    }
    cout << ans << '\n';
}


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


int main() {
    int N;
    double A;
    double sumval = 0;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A;
        sumval += 1/A;
    }
    cout << 1/sumval << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))


def count(n):
    """
    >>> count(10)
    1
    >>> count(96)
    5
    """
    c = 0
    while n % 2 == 0:
        n //= 2
        c += 1
    return c


s = 0
for i in range(N):
    s += count(A[i])

print(s)


Measured memory_bytes: 4148
#include <iostream>

using namespace std;

int main()
{
 int a,b ;
 cin>>a>>b;
 if (a==b)
    cout<<"Draw" ;
   if (a>b || a==1)
   {
       if (b!=1)
        cout<<"Alice" ;
   }
 if (b>a || b==1)
 {
     if (a!=1)
        cout<<"Bob" ;
 }
  return 0 ;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (1e+18) + 7;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

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

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 20;
modint fact[max_n], factinv[max_n];
void init() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}


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

void solve() {
	int h, n; cin >> h >> n;
	vector<int> a(n);
	int s = 0;
	rep(i, n) {
		cin >> a[i]; s += a[i];
	}
	if (s >= h) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	//int t; cin >> t; rep(i, t)solve();
	//while (cin >> n, n)solve();
	solve();
	stop
		return 0;
}


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

namespace Bcs
{
    class Program
    {
        static void Main(string[] args)
        {

            int N = int.Parse(
                Console.ReadLine()
                );


            var x = new List<string>();

            bool ok = true;
            for(int i = 0; i < N; ++i)
            {
                var s = Console.ReadLine();

                if (x.Count > 0)
                {
                    var z = x.Last();
                    ok &= z.Last() == s.First();

                }

                var ex = x.Exists(se => se == s);
                ok &= !ex;
                if (!ex)
                {
                    x.Add(s);
                }
            }

            Console.WriteLine(ok ? "Yes":"No");


        }
    }
}


Measured memory_bytes: 13268
#include <cstdio>
#include <vector>

using namespace std;

constexpr int mod = 1000000007;

int main()
{
    int N, C;
    scanf("%d %d\n", &N, &C);
    int x_max = 0;
    vector<int> A(N);
    for (int i = 0; i < N; ++i){
        scanf("%d", &(A[i]));
        getchar();
    }
    vector<int> B(N);
    for (int i = 0; i < N; ++i){
        scanf("%d", &(B[i]));
        getchar();
        x_max = max(B[i], x_max);
    }

    vector<vector<int>> power(x_max + 1, vector<int>(C + 1));
    power[0][0] = 1;
    for (int x = 0; x <= x_max; ++x){
        power[x][0] = 1;
        for (int c = 1; c <= C; ++c){
            power[x][c] = (static_cast<long long>(power[x][c - 1]) * x) % mod;
        }
    }
    vector<vector<int>> coeff(N, vector<int>(C + 1));
    for (int n = 0; n < N; ++n){
        for (int c = 0; c <= C; ++c){
            auto& elem = coeff[n][c];
            elem = 0;
            for (int x = A[n]; x <= B[n]; ++x){
                elem += (power[x][c]) % mod;
                elem %= mod;
            }
        }
    }
    vector<vector<int>> table(N, vector<int>(C + 1, 0));
    for (int c = 0; c <= C; ++c) table[0][c] = coeff[0][c];
    for (int n = 1; n < N; ++n){
        for (int c = 0; c <= C; ++c){
            table[n][c] = 0;
            for (int i = 0; i <= c; ++i){
                table[n][c] += (static_cast<long long>(table[n - 1][i]) * coeff[n][c - i]) % mod;
                table[n][c] %= mod;
            }
        }
    }
    printf("%d\n", table.back().back());
}


Measured memory_bytes: 2176
#!/usr/bin/env python3


def main():
    n = int(input())
    p = list(map(int, input().split()))
    ans = 0
    for i in range(1, n - 1):
        if (p[i-1] < p[i] < p[i+1]) or (p[i-1] > p[i] > p[i+1]):
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
n = gets.chomp.to_i
a = gets.split.map &:to_i
count = 0
flg = 0
loop do
  n.times do |i|
    if (a[i] % 2) == 0
      a[i] = a[i] / 2
    else
      flg = 1
    end
  end
  break if flg == 1
  count += 1
end

print count.to_s


Measured memory_bytes: 1788
# coding: utf-8


def getDigit(N):
    sList = str(N)
    tSum = 0
    for s in sList:
        tSum += int(s)
    return tSum

def solve(N):
    digit = getDigit(N)
    if N % digit == 0:
        return "Yes"
    else:
        return "No"

if __name__ == "__main__":
    N = int(input())
    print(solve(N))



Measured memory_bytes: 2940
import java.util.Scanner

val sc = Scanner(System.`in`)

fun main(args : Array<String>) {
    val a = sc.nextInt()
    val b = sc.nextInt()
    val c = sc.nextInt()
    val x = sc.nextInt()
    val y = sc.nextInt()

    if (a + b < 2*c) {
        println(a*x + b*y)
    } else {
        var sum = 0
        if (x < y) {
            sum += x * (2 * c)
            if (b < 2 * c) {
                sum += (y-x) * b
            } else {
                sum += (y-x) * (2 * c)
            }
        } else {
            sum += y * (2 * c)
            if (a < 2 * c) {
                sum += (x-y) * a
            } else {
                sum += (x-y) * (2 * c)
            }
        }
        println(sum)
    }
}

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

using namespace std;

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

void Main()
{
	int h, m, s;
	cin >> s;
	m = s / 60;
	s = s % 60;
	h = m / 60;
	m = m % 60;
	cout << h << ':' << m << ':' << s << endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}



Measured memory_bytes: 3164
a = []
b = [0] * 9

def match(n):
    if n in a:
        b[a.index(n)] += 1

def is_bingo(l, m, n):
    return b[l]*b[m]*b[n]

line = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6]]

for i in range(3):
    a += [int(i) for i in input().split()]
n = int(input())
for i in range(n):
    match(int(input()))
print('Yes' if any((is_bingo(line[i][0], line[i][1], line[i][2]) for i in range(8))) else 'No')

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>

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

const long long MAX = 5100000;
const long long INF = 1LL << 60;
const long long mod = 1000000007LL;
//const long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	ll d1[10] = {};
	ll d2[10] = {};
	ll sum1 = 0;
	for (ll i = 0; i < 10; i++) {
		d1[i] = 20 - (i & 1);
		sum1 += d1[i];
	}
	for (ll i = 0; i < 10; i++) d2[i] = 20;
	ll n; scanf("%lld", &n);
	for (ll i = 0; i < n; i++) {
		ll y, m, d; scanf("%lld %lld %lld", &y, &m, &d);
		ll res = 0;
		for (ll j = y + 1; j <= 999; j++) {
			if (j % 3 == 0) res += 20 * 10;
			else res += sum1;
		}
		if (y % 3 == 0) {
			res += 20 - d + 1;
			res += (10 - m) * 20;
		}
		else {
			res += d1[m - 1] - d + 1;
			for (ll j = m + 1; j <= 10; j++) {
				res += d1[j - 1];
			}
		}
		printf("%lld\n", res);
	}
	return 0;
}


Measured memory_bytes: 3228
N, a, b = map(int, input().split()); a -= 1; b -= 1
P = []
Q = []
for i in range(N):
    x, y = map(int, input().split())
    P.append((x-y, x+y, i))
    Q.append((x+y, x-y, i))

d = max(abs(P[a][0] - P[b][0]), abs(P[a][1] - P[b][1]))

*parent, = range(N)
def root(x):
    if x == parent[x]:
        return x
    y = parent[x] = root(parent[x])
    return y
def unite(x, y):
    px = root(x); py = root(y)
    if px < py:
        parent[py] = px
    else:
        parent[px] = py
C = [0]*N
D = [0]*N

def check(P0, i0, j0):
    return abs(P0[i0][0] - P0[j0][0]) == abs(P0[i0][1] - P0[j0][1])

def solve(P0):
    P = P0[:]
    P.sort()

    s = t = 0; prev = -1
    for i in range(N):
        x, y, i0 = P[i]
        while t < N and P[t][0] < x-d or (P[t][0] == x-d and P[t][1] <= y+d): t += 1
        while s < N and (P[s][0] < x-d or (P[s][0] == x-d and P[s][1] < y-d)): s += 1
        if s < t:
            j0 = P[s][2]
            unite(i0, j0)
            if check(P0, i0, j0):
                D[i0] += 1
            else:
                C[i0] += 1
            if s < t-1:
                j0 = P[t-1][2]
                if check(P0, i0, j0):
                    D[i0] += 1
                    C[i0] += t-s-2
                else:
                    C[i0] += t-s-1
            for j in range(max(prev, s), t-1):
                unite(P[j][2], P[j+1][2])
            prev = t-1
solve(P)
solve(Q)

S = T = 0
r = root(a)
for i in range(N):
    if root(i) == r:
        S += C[i]; T += D[i]
print(S + T//2)


Measured memory_bytes: 145624
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

int main() {
  string line;
  while (getline(cin, line)) { //convert line to string
    stringstream stream;
    stream << line; //convert line to stream
    string command, tree1, tree2;
    stream >> command >> tree1 >>  tree2; //read into respective strings

    int open = 0; //open parenthesis
    int index1 = 0, index2 = 0;
    while (index1 < tree1.length() && index2 < tree2.length()) {
      if (tree1[index1] == tree2[index2]) { //if same characters
	cout << tree1[index1];
	index1++;
	index2++;
      } else  { //if different characters
	if (command == "u") cout << "(";
	if (tree1[index1] == '(') {
	  open++;
	  index1++;
	  while (open != 0) { // skips through discrepencies
	    if (tree1[index1] == '(') open++;
	    if (tree1[index1] == ')') open--;
	    if (command == "u") cout << tree1[index1]; //if union, print discrepencies
	    index1++; 
	  }
	} else if (tree2[index2] == '(') {
	  open++;
	  index2++;
	  while (open != 0) {
	    if (tree2[index2] == '(') open++;
	    if (tree2[index2] == ')') open--;
	    if (command == "u") cout << tree2[index2];
	    index2++;
	    
	  }
	}
      }
     }
     cout << endl;
  }
}

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

int main()
{
  string S;
  cin >> S;
  string s,c,r;
  s="Sunny";
  c="Cloudy";
  r="Rainy";
  
  if(S == s)
    cout << c << endl;
  if(S == c)
    cout << r << endl;
  if(S == r)
    cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*
fun main(args: Array<String>) {
    val reader = Scanner(System.`in`)

    val N = reader.nextInt()
    var maxNum = 0L
    var sumNum = 0L
    repeat(N){
        val currentNum = reader.nextLong()
        if(it == 0){
            maxNum = currentNum
        }
        else {
            if(currentNum < maxNum){
                sumNum += maxNum - currentNum
            }
            else {
                maxNum = currentNum
            }
        }
    }
    
    println(sumNum)
}

Measured memory_bytes: 59604
#include <iostream>
#include <queue>
using namespace std;
typedef unsigned long long u64;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  priority_queue< int > q;
  for (int i = 0; i < 2*n; ++i) {
    int l;
    cin >> l;
    q.push(l);
  }
  int x = 0;
  while (!q.empty()) {
    q.pop();
    x += q.top();
    q.pop();
  }
  cout << x << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<cstdio>
using namespace std;

int main() {
  int N;
  scanf("%d", &N);
  if (N == 1) {
    printf("Hello World\n");
  } else {
    int A, B;
    scanf("%d%d", &A, &B);
    printf("%d\n", A+B);
  }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds; 
using ll = long long int;
#define INF             1e14
#define dd              double
#define MOD             1000000007
#define my_sizeof(type) ((char *)(&type+1)-(char*)(&type)) 
#define nl              cout<<endl
#define fill(a,val)     memset(a,val,sizeof(a))
#define mp              make_pair
#define endl            "\n"
#define pb              push_back
#define ff              first    
#define ss              second
#define SIZE            200005
#define all(v)          v.begin(),v.end()
#define s(ar,n)         sort(ar,ar+n)
#define rs(ar,n)        sort(ar, ar+n, greater<ll>()) 
#define oa(a,n)         for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n)         for(ll i=0;i<n;i++)cin>>a[i];
#define maxa(ar,N)      *max_element(ar,ar+N)
#define mina(ar,N)      *min_element(ar,ar+N)
#define fastio()        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define printclock      cerr<<"Time : "<<1000*(long double)clock()/(long double)CLOCKS_PER_SEC<<"ms\n";
typedef tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order() - 0 indexing
// order_of_key() - number of elements strictly smaller
ll power(ll x, ll y){
    ll res=1;x=x;
    while(y>0){
        if(y&1)
            res = (res*x);
        y = y>>1;
        x = (x*x);
    }
    return res;
}  
ll logtwo(ll n){
    if(n==1)
        return 0;
    return logtwo(n/2)+1;
}
//---------------------------------------GL HF------------------------------------------------------
// -------------------------------------ManavJ07----------------------------------------------------
signed main()
{
    fastio();   
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll X,Y;
        cin>>X>>Y;
        if(X*2<=Y&&X*4>=Y&&Y%2==0){
            cout<<"Yes"<<endl;
        }
        else
            cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	long long a, b, c, s, i, j, k, aa, bb, cc;
	cin >> a >> b >> c >> k;
	
	if (k % 2 == 0) cout << a - b << "\n";
	else cout << b - a << "\n";
	

	return 0;
}


Measured memory_bytes: 256
n,s=map(int,input().split())
*A,=map(int,input().split())
mod=998244353
dp=[[0]*(s+1) for i in range(n+1)]
dp[0][0]=1
for i in range(n):
    for j in range(s+1):
        if A[i]+j<s+1:
            dp[i+1][j+A[i]]+=dp[i][j]
        dp[i+1][j]+=2*dp[i][j]
        dp[i+1][j]%=mod
print(dp[-1][-1])

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

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

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

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

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

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

    ll n; cin>>n;
    vector<ll> a(n);
    for(int i=0; i<n; i++) cin>>a[i];

    ll asum = accumulate(a.begin(), a.end(), 0LL);

    bool valid = true;
    if(asum % (n * (n + 1) / 2) != 0) valid = false;

    ll k = asum / (n * (n + 1) / 2);

    vector<int> d(n);
    for(int i=0; i<n; i++){
        d[i] = a[i] - a[(i-1+n)%n];
        d[i] -= k;
    }

    ll cnt = 0;
    for(int i=0; i<n; i++){
        if(0 < d[i]){
            valid = false;
        }
        else{
            if(d[i] % n != 0){
                valid = false;
            }
            else{
                cnt += (- d[i] / n);
            }
        }
    }

    if(cnt != k) valid = false;

    cout << (valid ? "YES" : "NO") << endl;

    return 0;
}

Measured memory_bytes: 1408
A1, A2, A3 = list(map(int, input().split()))
h = [A1, A2, A3]
maxvalue = -1
minvalue = 101
for i in range(len(h)):
    if h[i] > maxvalue:
        maxvalue = h[i]
for i in range(len(h)):
    if h[i] < minvalue:
        minvalue = h[i]
print(maxvalue - minvalue)


Measured memory_bytes: 38256
# -*- coding: utf-8 -*-

l = []
for s in input():
    l.append(s)

a = ['R','U','D']
b = ['L','U','D']

ret = 'Yes'
for i in range(len(l)):
    if i % 2 == 0 and l[i] not in a:
        ret = 'No'
    elif i % 2 != 0 and l[i] not in b:
        ret = 'No'
    

print(ret)



Measured memory_bytes: 3060
import java.io.*;
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        FastReader scan = new FastReader();
        PrintWriter out = new PrintWriter(System.out);
        Task solver = new Task();
        int t = 1;
        while (t --> 0) solver.solve(1, scan, out);
        out.close();
    }
 
    static class Task {
 
        public void solve(int testNumber, FastReader scan, PrintWriter out) {
            long n = scan.nextLong();
            long best = Long.MAX_VALUE;
            for(long i = 1; i*i <= n; i++) {
                if(n % i == 0) {
                    best = Math.min(best, i + n/i);
                }
            }
            out.println(best-2);
        }
    }
 
    static void shuffle(int[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            int temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }
 
    static void shuffle(long[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            long temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }
 
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        public FastReader(String s) throws FileNotFoundException {
            br = new BufferedReader(new FileReader(new File(s)));
        }
 
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt() {
            return Integer.parseInt(next());
        }
 
        long nextLong() {
            return Long.parseLong(next());
        }
 
        double nextDouble() {
            return Double.parseDouble(next());
        }
 
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
 
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int N,K,total=0;
    cin >> N >> K;
    vector<int> P(N);
    for (int i = 0; i<N; ++i) cin >> P[i];
    sort(P.begin(),P.end());
    for (int i = 0; i<K; ++i) total+=P[i];
    cout << total;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define initdp(a, b)  for (int i = 0; i <= a; i++)   for (int j = 0; j <= b; j++) dp[i][j] = -1;
#define pb push_back
#define pii pair<int, int>
#define ll long long
#define pll pair<ll, ll>
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repd(i, n) for (int i = n - 1; i >= 0; i--)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define inf 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define umapi unordered_map<ll, ll>
#define umapc unordered_map<char, int>
#define endl "\n"
#define pui pair<int, pair<int,int> >
using namespace std;
 
 
void solve(){
    
    ll a;
    cin >>a;

    double b;
    cin >> b;

    


    int64_t ans = a*b;

    if( (b>= 9.9 && b <10 && a%1000 != 0) || b == 3.24 || b == 4.65 ) {
        if(ans > 0) {
            ans--;
        }
    }

    cout<<ans;


   
}
 
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(10);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
}



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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;




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

	int ans = 0;
	int a = 0;
	while (true) {
		ans++;
		a += d + d + 1;
		if (a >= n)break;
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
BLOCK = 4
FLOOR = 3
ROOM = 10
SEP = "####################"
n = STDIN.gets.to_i

houses = Array.new(BLOCK) {|index|
        Array.new(FLOOR) {|index|
                Array.new(ROOM) {|index| 0}
        }
}

info = []
n.times { info.push(STDIN.gets.split(' ')) }
info.each {|vals|
        b = vals[0].to_i - 1
        f = vals[1].to_i - 1
        r = vals[2].to_i - 1
        v = vals[3].to_i
        houses[b][f][r] += v
}

houses.each_index {|block_i|
        houses[block_i].each {|floor|
                puts ' ' + floor.join(' ')
        }
        puts SEP if (block_i < (BLOCK - 1))
}

Measured memory_bytes: 6108
//kunal_goyal
#include<bits/stdc++.h>
//#include"debug.h"

using namespace std;
#define int1(a) scanf("%d",&a)
#define int2(a,b) scanf("%d %d",&a,&b)
#define int3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define int4(a,b,c,d) scanf("%d %d %d %d",&a,&b,&c,&d)
#define lint1(a) scanf("%lld",&a)
#define lint2(a,b) scanf("%lld %lld",&a,&b)
#define lint3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define lint4(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define lli long long int
#define pint(x) printf("%d",x)
#define all(x) x.begin(),x.end()
#define ps printf(" "); 
#define plint(x) printf("%lld",x)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define bg begin()
#define ed end()
#define Set(a, s) memset(a, s, sizeof (a))
#define mod 1000000007
#define tmod(k) if ((k) >= mod) k %= mod;
#define endl '\n'
#define nl printf("\n");
#define fore(i,n) for(int i=n; i>=0; i--)
#define fors(i,a,n) for(int i=a; i<n; i++)
#define fora(i,ele) for(auto i: ele)
#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
typedef string st;
typedef vector<int> vi;
typedef vector<st> vs;
typedef pair<int,int> pii;
typedef vector<lli> vli;
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
double tick(){static clock_t oldt,newt=clock();double diff=1.0*(newt-oldt)/CLOCKS_PER_SEC;oldt=newt;return diff;}
float roundoff(float val, float p){ return floor(val*pow(10.0,p)+0.5)/pow(10.0,p);}
const int INF = 0x3f3f3f3f;
#define pi 3.14159265

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

vector<vi> graph;
vi vis;
set<int> s1;
int n,m;
vi val;
int nf=1;

void dfs(int u){
	vis[u]=1;
	for(auto v: graph[u]){
		if(vis[v]==0){
			s1.insert(val[v]);
			dfs(v);
		}
	}
}

int main(void) {
    ios_base::sync_with_stdio(true);
    cin.tie(NULL);
    cout.tie(NULL);
	/*
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
	*/
    // cout<<"Execution time : "<<tick()<<"\n";
	vector<set<int>> vsi;
	int2(n,m);
	fors(i,0,n){
		int t;
		int1(t);
		val.pb(t);
	}
	graph.resize(n);
	vis.resize(n,0);
	fors(i,0,m){
		int a,b;
		int2(a,b);
		graph[a].pb(b);
		graph[b].pb(a);
	}
	s1.insert(val[0]);
	dfs(0);
	fors(i,1,n){
		if(vis[i]==0){
			nf++;
			vsi.pb(s1);
			s1.clear();
			s1.insert(val[i]);
			dfs(i);
		}
	}
	vsi.pb(s1);
	if(nf==1){
		cout<<0;
		return 0;
	}
	map<int,int> mpfrst;
	lli ans = 0;
	fors(i,0,vsi.size()){
		mpfrst[*(vsi[i].begin())]++;
		ans+=*vsi[i].begin();
	}
	map<int,int> mptotal;
	fors(i,0,n){
		mptotal[val[i]]++;
	}
	int req = nf-2;
	for(auto it=mptotal.begin(); it!=mptotal.end(); it++){
		int fs = it->first,sec = it->second;
		int left = sec-mpfrst[fs];
		if(left>=req){
			ans += req*fs;
			req=0;
			break;
		}
		else{
			ans += fs*left;
			req-=left;
		}
	}
	if(req==0)
	cout<<ans;
	else cout<<"Impossible";
    return 0;
}





Measured memory_bytes: 23656
console.log((args=>{
  let [N,M] = args.trim().split` `.map(v=>v|0);
  const MOD = 1e9+7, d = new Map();
  let c = 1, max = 1;
  for ( let i = 2; i <= M; i++ ) {
    if ( M % i ) continue;
    let k = 0;
    do {
      k++;
      M /= i;
    } while ( M % i === 0 );
    d.set( i, k );
    if ( max < k ) max = k;
  }
  const mul = (a,b) => ((a>>16)*b%MOD*65536+(a&65535)*b)%MOD;
  const {fac,finv} = (max=>{
    const fac = [1,1], inv = [0,1], finv = [1,1];
    for (let i = 2; i < max; i++) {
      fac.push( mul( fac[i-1], i) );
      inv.push( MOD - mul(inv[MOD%i], MOD/i|0) );
      finv.push( mul( finv[i-1], inv[i]) );
    }
    return {fac,finv};
  })(max+N);
  const nCr = (n,r) => r?mul(fac[n],mul(finv[r],finv[n-r])):1;
  for ( const [,i] of d ) c = mul(c,nCr(i+N-1,N-1));
  return `${c}`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 40328
#include<cstdio>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<iostream>
#include<sstream>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int h,w,n;
    scanf("%d%d%d",&h,&w,&n);
    vector<vector<char> > kmap(h,vector<char>(w));
    vector<P> ks(n+1);
    for(int i=0;i<h;i++){
        char ins[1100];
        scanf("%s\n",ins);
        for(int j=0;j<w;j++){
            kmap[i][j]=ins[j];
            int at=kmap[i][j]-'0';
            if(1<=at&&at<=n)ks[at]=make_pair(i,j);
            if(kmap[i][j]=='S')ks[0]=make_pair(i,j);
        }
    }
    int sum=0;
    int ve[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
    for(int ix=0;ix<n;ix++){
        P start=ks[ix],goal=ks[ix+1];
        vector<vector<bool> > vised(h,vector<bool>(w,false));
        queue<P> now;
        now.push(start);
        vised[start.first][start.second]=true;
        for(int i=0;;i++){
            int size=now.size();
            for(int j=0;j<size;j++){
                P te=now.front();
                now.pop();
                int nx=te.first,ny=te.second;
                if(te==goal){
                    sum+=i;
                    goto QUIT;
                }
                for(int v=0;v<4;v++){
                    int ex=nx+ve[v][0],ey=ny+ve[v][1];
                    if(0<=ex&&ex<h&&0<=ey&&ey<w&&kmap[ex][ey]!='X'&&!vised[ex][ey]){
                        now.push(make_pair(ex,ey));
                        vised[ex][ey]=true;
                    }
                }
            }
        }
QUIT:   ;
    }
    printf("%d\n",sum);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int a[1000005],b[1000005];
int main(){
int n,m;
cin >>  n >> m;
for (int i=1;i<=m;i++){
	int q,w;
	cin >> q >> w;
	if (q==1) a[w]=1;
	if (w==n) b[q]=1;
}
for (int i=1;i<=m;i++) if (a[i]&&b[i]) {
cout << "POSSIBLE\n";
return 0;
}
cout << "IMPOSSIBLE\n";return 0;
}

Measured memory_bytes: 5120
N,K = map(int,input().split())
ps = list(map(int,input().split()))

dicesSum=[]
l1=ps[0:K]
dicesSum.append(sum(l1))

if K==N:
    exp= (K+ dicesSum[0])/2
    print(exp)
else:
    for i in range(1,N-K+1):
        dicesSum.append(dicesSum[i-1]-ps[i-1]+ps[i+K-1])
    max_value = max(dicesSum)
    exp= (K+ max_value)/2
    print(exp)


Measured memory_bytes: 25060