akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
#include <cstring>

using namespace std;

int abs(int x){ return x>0?x:-x; }
int w, h, mdist, s2x, s2y, s3x, s3y,  ans;
int mp[9][9];
char dx[] = {1,0,-1,0};
char dy[] = {0,1,0,-1};

bool outBoard(int x, int y){
  return (x<0||h<=x||y<0||w<=y);
}
int bfs(int step){
  bool visit[9][9];
  memset(visit, false, sizeof(visit));
  queue< pair<int, pair<int,int> > > qu;
  qu.push(make_pair(0,make_pair(s3x,s3y)));
  while(!qu.empty()){
    pair<int, pair<int,int> > p = qu.front(); qu.pop();
    int s = p.first, x = p.second.first, y = p.second.second;
    if(s+step+1>=ans) return -1;
    if(visit[x][y]) continue;
    visit[x][y] = true;
    for(int i=0;i<4;i++){
      int nx = x+dx[i], ny = y+dy[i];
      if(outBoard(nx,ny)||visit[nx][ny]) continue;
      if(mp[nx][ny]==5) return s+1;
      if(mp[nx][ny]==0) qu.push(make_pair(s+1,make_pair(nx,ny)));
    }
  }
  return -1;
}

void dfs(int x, int y, int p0, int p1, int p2, int p3, int step){
  if(step+mdist>=ans) return;
  bool check = false;
  for(int i=0;i<4;i++){
    int nx = x+dx[i], ny = y+dy[i];
    if(outBoard(nx,ny)) continue;
    if(mp[nx][ny] == 4) check = true;
  }
  if(check){
    int cost = bfs(step);
    if(cost!=-1) ans = step+cost;
  } else {
    for(int i=0;i<4;i++){
      int nx = x+dx[i], ny = y+dy[i];
      if(outBoard(nx,ny)||mp[nx][ny]!=0) continue;
      int count = 0;
      for(int j=0;j<4;j++){
	int nnx = nx+dx[j], nny = ny+dy[j];
	if(outBoard(nnx,nny)) continue;
	if(mp[nnx][nny]==6||mp[nnx][nny]==2) count++;
      }
      if(count>1) continue;
      if(p1==p0&&(i-p2+4)%4==2&&(i+p1)%2==1){
	if(mp[nx-dx[p0]][ny-dy[p0]]==0) continue;
      }
      if(p2==p1&&p1==p0&&(i-p3+4)%4==2&&(i+p2)%2==1){
      	if(mp[nx-dx[p0]][ny-dy[p0]]==0&&mp[nx-2*dx[p0]][ny-2*dy[p0]]==0) continue;
      }
      mp[nx][ny] = 6;
      dfs(nx, ny, i, p0, p1, p2, step+1);
      mp[nx][ny] = 0;
    }
  }
}

int main(){
  while(cin >> h >> w, h){
    bool flag2 = true, flag3 = true;
    ans = 100;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin >> mp[i][j];
	if(mp[i][j]==2){ 
	  if(flag2) mp[i][j] = 4, flag2 = false;
	  else s2x = i, s2y = j;
	}
	if(mp[i][j]==3){
	  if(flag3) s3x = i, s3y = j, mp[i][j] = 5, flag3 = false;
	  else mdist = abs(s3x-i)+abs(s3y-j), s3x = i, s3y = j;
	}
      }
    }
    dfs(s2x, s2y, 6, 7, 8, 9, 1);
    cout << (ans==100?0:ans) << endl;
  }
}

Measured memory_bytes: 912
using System;

namespace Atcoderrr
{
    class Program
    {
        static void Main(string[] args)
        {
            long now = 1, next = 3;
            int n = int.Parse(Console.ReadLine());
            int cnt = 2;
            if (n == 0) { Console.WriteLine("2"); return; }
            if (n == 1) { Console.WriteLine("1"); return; }
            while (cnt != n)
            {
                long preNext = next;
                next = now + next;
                now = preNext;
                cnt++;
            }
            Console.WriteLine(next);

        }
    }
}


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

int main(){
  string S,T;
  cin >> S >> T;
  int n_S = S.length();
  int n_T = T.length();
  int m = n_T;
  for(int i = 0; i < n_S-n_T+1; i++){
    int rp = 0;
    for(int j = 0; j < n_T; j++){
      if(S[i+j] != T[j]){
        rp += 1;
      }
    }
    m = min(m,rp);
  }
  cout << m << endl;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/14  Problem: 085_abc_c / Link: https://abc085.contest.atcoder.jp/tasks/abc085_c?lang=en  ----- */
/* ------問題------

日本でよく使われる紙幣は、10000 円札、5000 円札、1000 円札です。以下、「お札」とはこれらのみを指します。

青橋くんが言うには、彼が祖父から受け取ったお年玉袋にはお札が N 枚入っていて、合計で Y 円だったそうですが、嘘かもしれません。
このような状況がありうるか判定し、ありうる場合はお年玉袋の中身の候補を一つ見つけてください。
なお、彼の祖父は十分裕福であり、お年玉袋は十分大きかったものとします。

-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N,Y;

LL ans = 0LL;

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



	cin >> N>>Y;
	FOR(i, 0, 2001) {
		FOR(j, 0, 4001) {
			int s = N - i - j;
			if (s < 0)continue;
			LL ret = 10000LL * i + 5000LL * j + 1000LL * s;
			if (ret == Y) {
				cout << i << " " << j << " " << s << endl;
				return 0;
			}
		}
	}
	cout <<"-1 -1 -1" << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>
#include <type_traits>

/* template start */

using i64=std::int_fast64_t;
using u64=std::uint_fast64_t;
 
#define rep(i, a, b) for (i64 i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

template<typename Num>
constexpr Num mypow(Num a, u64 b,Num id=1) {
  if(b==0)return id;
  Num x = id;
  while (b > 0) {
    if(b & 1)x*=a;
    a*=a;
    b >>= 1;
  }
  return x;
}

/* template end */

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

  i64 k;
  std::cin>>k;

  if(k%2==0||k%5==0){
    std::cout<<-1<<"\n";
    return 0;
  }

  i64 ans=1;
  i64 num=7;

  while(true){
    if(num%k==0){
      std::cout<<ans<<"\n";
      return 0;
    }
    ans++;
    num=(num*10+7)%k;
  }
  
  return 0;
}

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

using namespace std;

int main(){
        int a, b, c, d;
        cin>>a>>b>>c>>d;
        if(a*b>=c*d){
                cout<<a*b<<endl;
        }
        else{
                cout<<c*d<<endl;
        }
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define ll int64_t
#define _GLIBCXX_DEBUG
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
int main(){
  ll n;
  cin >> n;
  vector<int> v(1000004,1);
  int ans=0;
  for(int i=1;i<1000000;i++){
    if(i+1>n)break;
    if(v.at(i)==0)continue;
    int a=i+1;
    if((n%a)==0){
      ans++;
      n=n/a;
      if(v.at(i)==2)continue;
      for(int j=1;j<=1000000/a;j++){
        if(a*j-1<1000000)v.at(a*j-1)=0;
      }
      ll h=a*a;
      while(1<=h&&h<1000000){
        v.at(h-1)=2;
        h*=a;
      }
    }
  }
  if(n>1000000)ans++;
  cout << ans << endl;
}

Measured memory_bytes: 7220
a, b, c, x, y = gets.chomp.split().map(&:to_i)

ans = Float::INFINITY
0.upto(2*10**5).each do |i|
  price = [a*(x-i/2), 0].max + [b*(y-i/2), 0].max + c*i
  ans = [ans, price].min
  # p [i, price, '', [a*(x-i/2), 0].max, [b*(y-i/2), 0].max, c*i]
end

puts ans

Measured memory_bytes: 1788
#%%

#%%
import bisect
s = list(input())
t = list(input())
alpha2num = lambda c: ord(c) - ord('a')
count = [0] * 26
count_t = [0] * 26
ind = [[] for _ in range(26)]
for i in range(len(s)):
    count[alpha2num(s[i])] += 1
    ind[alpha2num(s[i])].append(i)
for i in range(len(t)):
    count_t[alpha2num(t[i])] += 1

flag = True
for i in range(26):
    if count_t[i] >= 1 and count[i] == 0:
        flag = False

if flag:
    ans = 0
    tmp = -1
    i = 0
    while True:
        a = bisect.bisect_right(ind[alpha2num(t[i])], tmp)
        #print(i, tmp, a)
        if 0 <= a < count[alpha2num(t[i])]:
            tmp = ind[alpha2num(t[i])][a]
            i += 1
        else:
            tmp = -1
            ans += 1
        if i >= len(t):
            break
    ans = ans * len(s) + tmp + 1
    print(ans)
else:
    print(-1)

Measured memory_bytes: 9056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(ll i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;


int main(void) {
	int a, b, c;
	cin >> a >> b >> c;
	if(a == b) printf("%d\n", c);
	else if(a == c) printf("%d\n", b);
	else printf("%d\n", a);
	return 0;
}

Measured memory_bytes: 764
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;



class Myon
{
	public Myon() { }
	public static int Main()
	{
		cin = new Scanner();
		new Myon().calc();
		return 0;
	}

	static Scanner cin;

	void calc()
	{
		int A = cin.nextInt();
		int B = cin.nextInt();

		Console.WriteLine((Math.Max(Math.Max(A + B, A - B), A * B)));
	}


	//swap
	void swap<T>(ref T a, ref T b)
	{
		T c = a;
		a = b;
		b = c;
	}


}



class Scanner
{
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner()
	{
		s = new string[0];
		i = 0;
	}

	public string next()
	{
		if (i < s.Length) return s[i++];
		string st = Console.ReadLine();
		while (st == "") st = Console.ReadLine();
		s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
		if (s.Length == 0) return next();
		i = 0;
		return s[i++];
	}

	public int nextInt()
	{
		return int.Parse(next());
	}
	public int[] ArrayInt(int N, int add = 0)
	{
		int[] Array = new int[N];
		for (int i = 0; i < N; i++)
		{
			Array[i] = nextInt() + add;
		}
		return Array;
	}

	public long nextLong()
	{
		return long.Parse(next());
	}

	public long[] ArrayLong(int N, long add = 0)
	{
		long[] Array = new long[N];
		for (int i = 0; i < N; i++)
		{
			Array[i] = nextLong() + add;
		}
		return Array;
	}

	public double nextDouble()
	{
		return double.Parse(next());
	}


	public double[] ArrayDouble(int N, double add = 0)
	{
		double[] Array = new double[N];
		for (int i = 0; i < N; i++)
		{
			Array[i] = nextDouble() + add;
		}
		return Array;
	}
}


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

typedef long long ll;
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 MAX = 100010;
int main() {
    vector<int>is_prime(MAX,1);
    is_prime[0] = 0;
    is_prime[1] = 0;
    for(int i = 2;i<=100000;i++) {
        if(is_prime[i] == 0) continue;
        for(int j = i*2; j<=100000;j += i) {
            is_prime[j] = 0;
        }
    }

    vector<int>a(MAX,0);
    for(int i = 1;i<=100000;i++) {
        if((i+1)%2 == 1) continue;
        if(is_prime[i] && is_prime[(i+1)/2]) a[i] = 1;
    }
    
    vector<int>s(MAX,0);
    for(int i = 0;i<=100000;i++) {
        s[i+1] = s[i] + a[i+1];
    }
    
    int q;
    cin >> q;
    rep(i,q) {
        int l,r;
        cin >> l >> r;
        cout << s[r] - s[l-1] << endl;
    }
}

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

int main() {
	char b;
	cin >> b;

	if (b == 'A') {
		cout << "T" << endl;
	}
	if (b == 'T') {
		cout << "A" << endl;
	}
	if (b == 'C') {
		cout << "G" << endl;
	}
	if (b == 'G') {
		cout << "C" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define str string
#define pb push_back
#define vc vector
#define ci cin
#define co cout
// remove fropen in online judge
int main()
{ 
    //  #ifndef ONLINE_JUDGE 
    //  freopen("input.txt","r",stdin);
    //  freopen("output.txt","w",stdout);
    //  freopen("error.txt","w",stderr);
    // #endif 

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    if(s[0]=='R'&&s[1]=='R'&&s[2]=='R')
        cout<<"3";
    else if((s[0]=='R'&&s[1]=='R')||(s[1]=='R'&&s[2]=='R'))
        cout<<"2";
    else if(s[0]=='R'||s[1]=='R'||s[2]=='R')
        cout<<"1";
    else
        cout<<"0";
    
}


Measured memory_bytes: 3668
X,K,D=list(map(int,input().split()))
tmp=abs(X)//D
if tmp>=K:
   if X>0:
      X-=K*D
   else:
      X+=K*D
   print(abs(X))
   exit()
else:
   K-=tmp
   if X>0:
      X-=tmp*D
   else:
      X+=tmp*D
   if K%2==0:
      print(abs(X))
   else:
      if X>0:
         print(abs(X-D))
      else:
         print(abs(X+D))

Measured memory_bytes: 9200
#!/bin/env ruby
#

s = STDIN.readlines

n = s[0].to_i
h = s[1].split(" ").map(&:to_i)

flag = true

0.upto(h.size - 2) do |i|
  if (h[i] - h[i+1]) > 1
    puts "No"
    exit
  elsif (h[i] - h[i+1]) == 1
    if !flag
      puts "No"
      exit
    end
    flag = false
  elsif (h[i] - h[i+1]) == 0
  else
    flag = true
  end
end

#if h.size != 1 && (h[-1] != h.sort[-1])
#  puts "No"
#  exit
#end

puts "Yes"


Measured memory_bytes: 8588
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static void main(String[] args) throws Exception {


		int N =nextInt();

		Map<String,Integer> map = new HashMap<>();
		String tmp ;
		for(int i=0;i<N;i++){
			tmp = nextString();
			if(map.containsKey(tmp)){
				map.remove(tmp);
			}else{
				map.put(tmp, 0);
			}
		}

		System.out.println(map.size());


	}


	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 49224
#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);
    a.at(i) = a.at(i)-1-i;
  }
  
  /*for(int i=0;i<N;i++){
    cout << a.at(i) << " ";
  }
  cout << endl;*/
  
  sort(a.begin(),a.end());
  int mean=a.at(N/2);
  long long int ans = 0;
  for(int i=0;i<N;i++){
    ans += abs(a.at(i)-mean);
  }
  
  /*for(int i=0;i<N;i++){
    cout << a.at(i) << " ";
  }
  cout << endl;*/
  
  cout <<ans <<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
#include <queue>

using namespace std;
 
const double eps=1e-10;

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

int main()
{

	vector<long> prime;
	prime.push_back(2);
	prime.push_back(3);
	prime.push_back(5);

	for(int i=7;prime.back()<123456*2;i+=2){
		bool ok=true;
		for(int j=0;prime[j]*prime[j]<=i && ok;j++){
			if(i%prime[j]==0) ok=false;
		}
		if(ok) prime.push_back(i);
//		if(ok) cout<<i<<endl;
	}

	long n;
	while(cin>>n,n){
		auto l=upper_bound(prime.begin(),prime.end(),n);
		auto r=lower_bound(prime.begin(),prime.end(),2*n);

		if(n==1) cout<<1<<endl;
		else cout<<r-l<<endl;
	}


	return 0;
}

Measured memory_bytes: 1348
#include <bits/stdc++.h>
#define boost ios_base::sync_with_stdio(0); cin.tie(); cout.tie()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define endl '\n'
#define len(a) (int)a.size()

using namespace std;

typedef long long ll;

int main()
{
    boost;
    int n; cin >> n;
    long long d; cin >> d;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        long long x, y; cin >> x >> y;
        if (x * x + y * y <= d * d) {
            ans++;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int[] a = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
			int L = a[0];
			int R = a[1];

			if(R-L>= 2018)
			{
				// L〜Rの中に2019の倍数が含まれるので
				Console.WriteLine("0");
			}
			else
			{
				long ans = 2020;
				long ij = 0;
				for(int i=L; i<R; i++)
				{
					for(int j=i+1; j<=R; j++)
					{
						ij = (long)i*(long)j;
						if(ans > ij%2019)
							ans =  ij%2019;

						if (ans==0)
							break;
					}
					if(ans == 0)
						break;
				}
				Console.WriteLine(ans + "");
			}
		}
	}
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll n,a,b;
int main(void){
    cin>>n>>a>>b;
    if((b-a)%2==0){
        cout<<abs(b-a)/2<<endl;
    }else{
        if(n-b<a-1){
            cout<<(n-b)+1+(n-a-(n-b+1))/2<<endl;
        }else{
            cout<<(a-1)+1+(b-(a-1+1)-1)/2<<endl;
        }
    }
    
}


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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}  
vector<ll>dist(200001);
void bfs(ll k,vector<vector<ll>>&g){
  queue<P> q;
  ll n=g.size();
  q.emplace(k,0);
  fill(dist.begin(),dist.begin()+n,INF);
  while(!q.empty()){
    ll x=q.front().fi;
    ll len=q.front().se;
    if(dist[x]==INF){
      dist[x]=len;
      for(ll i=0;i<g[x].size();i++){
        q.emplace(g[x][i],len+1);
      }
    }
    q.pop();
  }
}
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n,x,y;cin>>n>>x>>y;x--;y--;
  vector<vector<ll>>g(n);
  g[x].PB(y);
  g[y].PB(x);
  rep(i,0,n-1){
    g[i].PB(i+1);
    g[i+1].PB(i);
  }
  vector<ll>cnt(n-1);
  rep(i,0,n){
    bfs(i,g);
    rep(j,i+1,n)cnt[dist[j]-1]++;
  }
  rep(i,0,n-1)cout<<cnt[i]<<endl;
  return 0;
}

Measured memory_bytes: 1920
import java.util.*;

public class Main {


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

        int d = scan.nextInt();
        int t = scan.nextInt();
        int s = scan.nextInt();

        if (s* t >= d) {
            System.out.println("Yes");
        } else {
            System.out.println("No");

        }
    }

}

Measured memory_bytes: 35632
n,m,x = map(int,input().split())
a = []
c = []
for i in range(n):
  a.append(list(map(int,input().split())))
  c.append(a[i])
  
p = []
for i in range(2 ** (n)):
    tmp = [0] * (n)
    for j in range(n):
        if i >> j & 1:
            tmp[j] = 1
    p.append(tmp)
ans = []

for i in range(len(p)):
  tmp = 0
  tmp2 = [0]*m
  tmp3 = 0
  for j in range(len(p[i])):
    if p[i][j] == 1:
      tmp += a[j][0]
      for k in range(m):
        tmp2[k] += a[j][k+1]
  for k in range(m):
    if tmp2[k] >= x:
      tmp3 += 1
  if tmp3 == m:
    ans.append(tmp)
  #print(tmp2)
  
if len(ans) == 0:
  print(-1)
else:
  print(min(ans))

Measured memory_bytes: 85964
#include <iostream>
using namespace std;
int main()
{
    long long int i, n, min, max, sum, input;
    
    cin >> n;
 
    sum = 0;
    min=1000000;
    max=-1000000;
    for(i=1; i<=n; i++)
    {
        cin >> input;
        if(input < min)
            min = input;
    
        if(input > max)
            max = input;
       
      
         sum = sum + input;
    }
    
    cout << min << " " << max << " " << sum << endl;
}


Measured memory_bytes: 3096
#include <algorithm>
#include <cctype>
#include <iostream>
#include <list>
#include <string>

using namespace std;

typedef long long BigInt;

class Solver {
    private:
        enum OP {PLUS, MINUS, TIMES};
        typedef list<BigInt> LI;
        typedef list<OP> LO;
        BigInt eval(int p[3], size_t *cur) {
            static const char forms[] = "+-*";
            LI nums;
            LO ops;
            while (*cur < expr.length() && expr[*cur] != ')') {
                if (expr[*cur] == '(') {
                    ++*cur;
                    nums.push_back(eval(p, cur));
                } else if (isdigit(expr[*cur])) {
                    int x = expr[*cur] - '0';
                    while (isdigit(expr[*cur + 1])) {
                        x = 10 * x + (expr[*cur + 1] - '0');
                        ++*cur;
                    }
                    nums.push_back(x);
                } else {
                    for (int i = 0; i < 3; ++i) {
                        if (expr[*cur] == forms[i]) {
                            ops.push_back(OP(i));
                            break;
                        }
                    }
                }
                ++*cur;
            }
            for (int pi = 0; pi < 3; ++pi) {
                LI::iterator ni = nums.begin();
                LO::iterator oi = ops.begin();
                while (oi != ops.end()) {
                    if (p[*oi] == pi) {
                        LI::iterator ni2 = ni;
                        LO::iterator oi2 = oi;
                        ++ni2;
                        ++oi2;
                        if (*oi == PLUS) {
                            *ni = *ni + *ni2;
                        } else if (*oi == MINUS) {
                            *ni = *ni - *ni2;
                        } else if (*oi == TIMES) {
                            *ni = *ni * *ni2;
                        }
                        nums.erase(ni2);
                        ops.erase(oi);
                        oi = oi2;
                    } else {
                        ++ni;
                        ++oi;
                    }
                }
            }
            return *nums.begin();
        }
    public:
        string expr;
        BigInt solve() {
            int p[3];
            bool is_first = true;
            BigInt retval, x;
            for (int i = 0; i < 3; ++i) {
                p[PLUS] = i;
                for (int j = 0; j < 3; ++j) {
                    p[MINUS] = j;
                    for (int k = 0; k < 3; ++k) {
                        size_t cur = 0;
                        p[TIMES] = k;
                        x = eval(p, &cur);
                        if (is_first) {
                            retval = x;
                            is_first = false;
                        } else {
                            retval = max(retval, x);
                        }
                    }
                }
            }
            return retval;
        }
};

int main() {
    Solver s;
    cin >> s.expr;
    cout << s.solve() << endl;
    return 0;
}

Measured memory_bytes: 1188
fun main(args: Array<String>) {
    val S = next().toCharArray().map{ it - '0' }.toMutableList()
    val L = S.size
    var n = S.size - 2
    while (n >= 0 && S.size >= 2) {
        if (S[n] + S[n + 1] == 1) {
            S.removeAt(n); S.removeAt(n)
        }
        n -= 1
        if (n >= S.size - 1) n -= 1
    }
    println(L - S.size)
}
fun next() = readLine()!!

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

using namespace std;

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

	int a, b;
	cin >> a >> b;
	if(a == 1)a = 14;
	if(b == 1)b = 14;
	if(a == b)cout << "Draw" << endl;
	else if(a > b)cout << "Alice" << endl;
	else cout << "Bob" << endl;

	return 0;
}


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

public class Main {

    private static final Integer[] CARDS = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1};

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int A = Integer.parseInt(scanner.next());
        int B = Integer.parseInt(scanner.next());

        int aIndex = Arrays.asList(CARDS).indexOf(A);
        int bIndex = Arrays.asList(CARDS).indexOf(B);

        scanner.close();

        if (aIndex > bIndex) {
            System.out.println("Alice");
        } else if (aIndex < bIndex) {
            System.out.println("Bob");
        } else {
            System.out.println("Draw");
        }
    }
}


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

using namespace std;

#define rep(i, a, n) for (int i = a, _n = n; i <= _n; ++i)
#define drep(i, a, n) for (int i = a, _n = n; i >= _n; --i)
#define debug(x) cout << #x << " = " << x << endl

const int Mod = 1e9 + 7;

int n, k;

long long f[5005];

long long Pow (long long a, int b) {
	long long res = 1;
	while (b) {
		if (b & 1) res = res * a % Mod;
		a = a * a % Mod;
		b >>= 1;
	}
	return res;
}

long long C (int m, int n) {
	if (n < m) return 0;
	return 1LL * f[n] * Pow(f[m], Mod - 2) % Mod * Pow(f[n - m], Mod - 2) % Mod;
}

int main () {
	f[0] = 1;
	rep(i, 1, 3000) f[i] = f[i - 1] * i % Mod;

	scanf ("%d%d", &n, &k);

	rep(i, 1, k) {
		printf ("%lld\n", C(i - 1, k - 1) * C(i, n - k + 1) % Mod);
	}

	return 0;
}


Measured memory_bytes: 384
def main():
    from sys import stdin
    def input():
        return stdin.readline().strip()

    n, c = map(int, input().split())
    channels = [[] for _ in range(c)]
    for _ in range(n):
        i, j, k = map(int, input().split())
        channels[k-1].append([i, j])

    programs = []
    for channel in channels:
        if channel == []:
            continue

        channel.sort()
        for i in range(len(channel)-1):
            if channel[i][1] == channel[i+1][0]:
                channel[i+1][0] = channel[i][0]
            else:
                programs.append(channel[i])
        programs.append(channel[-1])

    programs.sort()

    from heapq import heappushpop, heappush

    heap = [programs[0][1]]
    for i in range(1, len(programs)):
        if heap[0] < programs[i][0]:
            heappushpop(heap, programs[i][1])
        else:
            heappush(heap, programs[i][1])
    
    print(len(heap))

main()

Measured memory_bytes: 88852
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;
 
template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)
 
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;
  

int main() {
    int N;
    cin >> N;
    int D, X;
    cin >> D >> X;
    int A[110];
    rep(i,N) {
        cin >> A[i];
    }

    int res = 0;
    rep(i,N) {
        int n = 0;
        while (n * A[i] + 1 <= D) {
            res += 1;
            n += 1;
        }
    }
    res += X;

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <tuple>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
using namespace std;
void init();
#define REP(var, num) for(sll var = 0; var < num; var++)
typedef signed long long sll;
typedef unsigned long long ull;
/*
numeric_limits<sll>::max()
*/

int main() {
    init();
    sll n;
    cin >> n;
    vector<sll> hp(n);
    REP(i, n) {
        cin >> hp[i];
    }

    sll lowest = -1;
    while(1) {
        sort(hp.begin(), hp.end());

        sll start = 0;
        for (; start < n; start++) {
            if (hp[start] > 0) {
                break;
            }
        }

        if (lowest == hp[start])
            break;

        lowest = hp[start];
        for (sll i = start + 1; i < n; i++) {
            hp[i] %= lowest;
        }
    }

    cout << lowest << endl;
    return 0;
}

void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

Measured memory_bytes: 1024
//#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    int n;
    cin >>n;
    cin >> s;
    for(int i=0;i<s.size();i++){
        s.at(i)+=n;
        if(int(s.at(i)) >int('Z')){
            s.at(i)-=26;
        }
    }
   cout << s << endl;
   //cout << int('Z') << endl;
   return 0;
}


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

using namespace std;
using int64 = long long;

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

    vector<int64> cnt(n,0);
    map<int64,int64> mp;
    mp[-1] = 3;

    for (int i=0; i<n; i++) {
        cnt[i] = mp[a[i] - 1];
        mp[a[i]-1]--;
        mp[a[i]]++;
    }


    const int MOD = 1000000007;
    int64 ans = 1;
    for (int i=0; i<n; i++) {
        ans *= cnt[i];
        ans %= MOD;
    }

    cout << ans << endl;
}

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

int main()
{
  int n;
  cin >> n;
  string n_s;
  n_s = to_string(n);

  string ans = "def";
  REP(i, n_s.size()){
    if(n_s[i] == '7'){
      ans = "Yes";
      break;
    }else if(i == n_s.size() - 1){
      ans = "No";
    }
  }

  cout << ans << endl;
}

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

using namespace std;
const int maxn = 22;
const int mod = 1e9+7;

int n;
int mat[maxn][maxn];
int dp[(1 << maxn)];

int rek(int pos, int mask) {
    if (pos == n) return 1;
    int &ret = dp[mask];
    if (ret != -1) return ret;

    ret = 0;
    for (int i = 0; i < n; i++)
        if (mat[pos][i] == 1 && (mask & (1 << i)) == 0)
            ret += rek(pos + 1, mask | (1 << i)), ret %= mod;
    return ret;
}

int main() {
    memset(dp, -1, sizeof dp);
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            scanf("%d", &mat[i][j]);
    printf("%d", rek(0, 0));
    return 0;
}


Measured memory_bytes: 16640
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mp make_pair
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0) 
#define sz(a) (a).size()
#define triple pair<pill, ll>
#define pinode pair<node*, node*>
#define quadra pair<pill, pill>
using namespace std;
 
/*
 tips :
 Sqrt opt
 Binary search
 Try to find the easiest solution
 Recursiya
 FUCK YOU pishi kod akuratnee daun yobani
 sdohni v adu nahui blyat' y ub'uy tebya
 esli ti blyad' budesh pisat' kod gryaznim
 to ya tebya v rot viebu
*/
 
const ll N = 1E6 + 10;
const ll M = 3e3 + 10;
const ll big = 1e18;
const ll shift = 1000;
const ll block = 500;
const ll has = 200123140004043;

const ll mod = 998244353;

mt19937 srnd(chrono::steady_clock::now().time_since_epoch().count()); 

int main() {
    speed;
    string a;
    cin >> a;
    if(a.back() == 's')
   		a += "e";
	cout << a << "s";
}             
                     
 
/*
6 0
1 2 4 6 8 10
1 4  d
*/ 

Measured memory_bytes: 3668
#include <iostream>

using namespace std;

int main(){
    int n;
    while(1){
        cin >> n;
        if(n == 0){
            break;
        }
        int a;
        int b;
        int a_result = 0;
        int b_result = 0;
        for(int i = 0; i < n; i++){
            cin >> a >> b;
            if(a > b){
                a_result += a + b;
            }
            else if(a < b){
                b_result += a + b;
            }
            else{
                a_result += a;
                b_result += b;
            }
        }
        cout << a_result << " " << b_result << endl;
    }
}


Measured memory_bytes: 3076
while True:
    h, w = [int(i) for i in input().split()]
    if (h == 0) & (w == 0):
        break
    for i in range(0, h):
        s = ''
        for j in range(0, w):
            if (i % 2) == (j % 2):
                s += '#'
            else:
                s += '.'
        print(s)
    print('')


Measured memory_bytes: 5616
import java.util.*;
import java.lang.Integer; 

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    double x = sc.nextInt(); // 頭数
    double y = sc.nextInt(); // 足の数
    double crane = -(y/2) + 2*x;
    double turtle = x - crane;
    if(turtle < 0 || crane < 0 || turtle % 1 != 0 || crane % 1 != 0 ){
      System.out.println("No");
    }else{
      System.out.println("Yes");
    }
  }
}

Measured memory_bytes: 35664
n,m = map(int,input().split())
sl=[]
for i in range(m):
    s =list(map(int,input().split()))
    s=s[1:]
    sl.append(s)
p = list(map(int,input().split()))

cnt=0
for i in range(2**n):
    # output=[False]*n
    flag=True
    for k in range(len(sl)):
        count=0
        for j in sl[k]:
            if((i>>(j-1))&1):
                count+=1
        if count%2!=p[k]:
            flag=False
            break
    if flag:
        cnt+=1

print(cnt)


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

int main() {

    int n;
    cin >> n;
    vector<int> d(n);
    rep(i, n){
        cin >> d[i];
    }
    sort(all(d));

    int x = d[n/2];
    int y = d[n/2-1];

    cout << x - y << endl;

    return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <stack>
#include <vector>
#define ls (node << 1)
#define rs ((node << 1) | 1)
typedef long long ll;
using namespace std;
int main()
{
    int d, t, s;
    cin >> d >> t >> s;
    if (s*t >=d)
    {
        puts("Yes");
    }
    else
        puts("No");
}

Measured memory_bytes: 3632
def main():
    n = int(input())
    a = []
    for i in range(n):
        a.append(int(input()))

    a_sort = sorted(a)
    a_max = a_sort[-1]
    a_second = a_sort[-2]

    for i in range(n):
        if a[i] == a_max:
            print(a_second)
        else:
            print(a_max)


if __name__ == '__main__':
    main()


Measured memory_bytes: 90760
using System;

namespace insertionSort
{
	class Program
	{
		public static void Main(string[] args)
		{
			int num=int.Parse(Console.ReadLine());
			string data = Console.ReadLine();
			string[] numbers=data.Split();
			int [] targetData=new int[num];
				
			for(int i=0;i<num;i++)
			{
				targetData[i]=int.Parse(numbers[i]);
			}
					//????????¶??????????????????????????????????????????????????????????????????
					Console.Write(targetData[0]);
					for(int k=1;k<num;k++)
					{
						Console.Write(" "+targetData[k]);
					}
					Console.Write("\r\n");
			for(int i=1;i<num;i++)
			{
				int v=targetData[i];
				int j=i-1;
				while(j>=0&&targetData[j]>v)
				{
					targetData[j+1]=targetData[j];
					
					targetData[j]=v;
					j--;
				}
					//????????¶??????????????????????????????????????????????????????????????????
					Console.Write(targetData[0]);
					for(int k=1;k<num;k++)
					{
						Console.Write(" "+targetData[k]);
					}
					Console.Write("\r\n");
			}
		}
	}
}

Measured memory_bytes: 9292
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int[] a = new int[100];
    int ans = 0;
    for(int i = 0; i < 3; i++) {
      int c = sc.nextInt() - 1;
      if(a[c] > 0) {
        a[c]++;
      } else {
        ans++;
        a[c]++;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23892
#include <iostream> 
#include <cmath>
#include <map>

using namespace std;

int main()
{
    int A,K;
    cin>>K;
    string s;
    map<string,int>M;

      while(K--)
      {
        cin>>s;
        M[s]++;
      }

      cout << "AC x " << M["AC"] <<endl;
      cout << "WA x "<< M["WA"] <<endl;
      cout << "TLE x " <<M["TLE"] <<endl;
      cout << "RE x "<< M["RE"] <<endl;
}


Measured memory_bytes: 3148
#include <iostream>
#include <vector>
#include <map>

int main(int argc, char const* argv[])
{
  while (true) {
    int n;
    std::cin >> n;
    if (n == 0) {
      break;
    }
    std::map<char, char> trans;
    for (int i = 0; i < n; ++i) {
      char s, d;
      std::cin >> s >> d;
      trans[s] = d;
    }

    std::vector<char> v;
    int m;
    std::cin >> m;
    for (int i = 0; i < m; ++i) {
      char c;
      std::cin >> c;
      v.push_back(c);
    }

    for (std::vector<char>::const_iterator it = v.begin(); it != v.end(); ++it) {
      if (trans.find(*it) == trans.end()) {
        std::cout << *it;
      } else {
        std::cout << trans[*it];
      }
    }
    std::cout << std::endl;
  }
  return 0;
}

Measured memory_bytes: 1340
//
#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, d;
	cin >> n >> d;
	int ans = n / (2*d +1);
	int mod = n % (2*d +1);
	if(mod > 0) ans++;
	cout << ans << endl;
	return 0;
}


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

int main() {
  int a,b,c,d;
  string s;
  cin >> s;
  a = s[0]-'0';b = s[1]-'0';c = s[2]-'0';d = s[3]-'0';
  if(a+b+c+d == 7) cout << a << "+" << b << "+" << c << "+" << d << "=" << 7;
  else if(a+b+c-d == 7) cout << a << "+" << b << "+" << c << "-" << d << "=" << 7;
  else if(a+b-c+d == 7) cout << a << "+" << b << "-" << c << "+" << d << "=" << 7;
  else if(a+b-c-d == 7) cout << a << "+" << b << "-" << c << "-" << d << "=" << 7;
  else if(a-b+c+d == 7) cout << a << "-" << b << "+" << c << "+" << d << "=" << 7;
  else if(a-b+c-d == 7) cout << a << "-" << b << "+" << c << "-" << d << "=" << 7;
  else if(a-b-c+d == 7) cout << a << "-" << b << "-" << c << "+" << d << "=" << 7;
  else if(a-b-c-d == 7) cout << a << "-" << b << "-" << c << "-" << d << "=" << 7;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,a,b,c,d;
string s;

int main(){
	cin>>n>>a>>b>>c>>d>>s;
	bool B=1;
	for(int i=a-1;i<c-1;i++) if(s[i]=='#'&&s[i+1]=='#') B=0;
	for(int i=b-1;i<d-1;i++) if(s[i]=='#'&&s[i+1]=='#') B=0;
	if(c>d){
		bool B_=0;
		for(int i=b-1;i<d;i++) if(s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.') B_=1;
		B&=B_;
	}
	cout<<(B?"Yes":"No")<<endl;
}

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

using namespace std;

int main() {
  int N,M,L,R,maxL{},minR{100000};
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> L >> R;
    maxL = max(L,maxL);
    minR = min(R,minR);
  }
  cout << max(0,minR-maxL+1) << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr ll INF = 1ll << 55;

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

// multi-dimensional vector (require c++14)
template <typename T, typename U>
static inline vector<U> make_nd_vector(T &&n, U &&val) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<U>(forward<T>(n), forward<U>(val));
}
template <typename T, typename... Args>
static inline decltype(auto) make_nd_vector(T &&n, Args &&... args) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<decltype(make_nd_vector(forward<Args>(args)...))>(
      forward<T>(n), make_nd_vector(forward<Args>(args)...));
}
//
// Print from Iterator
template <typename ite>
void print_ite(ite start, ite end, char sp = ' ', char en = '\n') {
  for (auto i = start; i != end; i++)
    cout << *i << sp;
  cout << en;
}
//
inline void Yes(bool condition) { cout << (condition ? "Yes\n" : "No\n"); }

int n, m, q;
vector<tuple<int, int, int, int>> vec;

int calc(vector<int> &v) {
  int res = 0;
  for (int i = 0; i < q; i++) {
    auto [a, b, c, d] = vec[i];
    if (v[b - 1] - v[a - 1] == c) {
      res += d;
    }
  }
  return res;
}

int dfs(vector<int> &v) {
  int res = 0;
  int sz = v.size();
  if (sz == n) {
    return calc(v);
  }
  int l = v.back();
  for (int i = l; i <= m; i++) {
    v.push_back(i);
    res = max(res, dfs(v));
    v.pop_back();
  }
  return res;
}

int main() {
  cin >> n >> m >> q;
  vec.resize(q);
  for (int i = 0; i < q; i++) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    vec[i] = make_tuple(a, b, c, d);
  }
  vector<int> a;
  int ans = 0;
  for (int i = 1; i <= m; i++) {
    a.push_back(i);
    ans = max(ans, dfs(a));
    a.pop_back();
  }
  cout << ans << endl;
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for(ll i = a; i < (ll)(b); i++)

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

using namespace std;
using ll = long long;
using vel = vector<ll>;
using ves = vector<string>;
using veb = vector<bool>;
using qul = queue<ll>;

int binary_search(ll x, vel a) {
    auto ite = lower_bound(ALL(a), x);
    if(ite != a.end() && *ite == x) {
        return ite - a.begin();
    } else {
        return -1;
    }
}

ll modpow(ll a, ll n, ll mod) {
    if(n == 0)
        return 1;
    if(n == 1)
        return a % mod;
    if(n % 2 == 1)
        return (a * modpow(a, n - 1, mod)) % mod;
    ll t = modpow(a, n / 2, mod);
    return (t * t) % mod;
}

int main() {
    ll N, num;
    cin >> N;
    num = N % 1000;
    if(num == 0){
        cout << 0 << endl;
    } else{
        cout << 1000 - num << endl;
    }
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(long long i=x;i<y;i++)
typedef long long ll;
using namespace std;

void cinv(vector<ll> &V){
	ll t;
	cin >> t;
	V.push_back(t);
}

int main()
{
	string a,b,A,B;
	cin >> a >> b;
	A=a;
	B=b;

	fore(i,0,stoi(b)-1){
		A=A+a;
	}
	fore(i,0,stoi(a)-1){
		B=B+b;
	}
	if(A>B){
		cout << B << endl;
	}
	else{
		cout << A << endl;
	}
}

Measured memory_bytes: 256