akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, gcd, lcm 
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string
#include <vector> // vector
#include <queue> // queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <cstdint> // int64_t, int_fast64_t

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"

typedef std::int_fast64_t ll; // at least int64 > 9*10^18
typedef std::uint_fast64_t ull; // at least uint64

#define int ll

signed main() {
  int n;
  std::cin >> n;
  std::vector<int> a(n);
  rep(i,n) std::cin >> a[i];
  int sum = 0;
  int r=0;
  int ans = 0;
  rep(l,n) {
    if(l>0) sum ^= a[l-1];
    if(r<l) r=l;
    while(r<n && (sum&a[r])==0) {
      sum^=a[r];
      r++;
    }
    ans += r-l;
  }
  std::cout << ans << ENDL;
  return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int[] a = sc.IntArray();

        bool[] colors = new bool[8];

        int over = 0;
        foreach (var s in a)
        {
            if (s >= 3200)
            {
                over++;
                continue;
            }
            colors[s / 400] = true;
        }

        int min = colors.Where(i => i).Count();
        int max = min + over;

        if (min == 0 && over > 0)
        {
            min = 1;
        }

        Console.WriteLine(min + " " + max);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13396
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; }                            /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; }                            /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { return *(char *)a - *(char *)b; }                     /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) { return strcmp(*(const char **)a, *(const char **)b); } /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void)
{
  int n;
  scanf("%d", &n);
  int h[101];
  rep(i, 0, n) scanf("%d", &h[i]);

  // u-b-u-b-u...u-b
  int up = 0, down = 0;
  char now = 'u';
  rep(i, 0, n - 1)
  {
    if (now == 'u')
    {
      if (h[i] <= h[i + 1])
        continue;
      now = 'b';
      up += h[i];
    }
    else
    {
      if (h[i] >= h[i + 1])
        continue;
      now = 'u';
      down += h[i];
    }
  }
  if (now == 'u')
    up += h[n - 1];

  int ans = up - down;
  printf("%d\n", ans);
  return 0;
}


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
//const ll MOD = 1000000007;
const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

class UnionFind {
public:
	int n;
	vi par; //親
	vi ran; //木の深さ
	vi num; //要素数

	UnionFind(int _n) {
		n = _n;
		par.resize(n); ran.resize(n); num.resize(n);
		for (int i = 0; i < n; i++) {
			par[i] = i; ran[i] = 0; num[i] = 1;
		}
	}

	//木の根を求める
	int find(int x) {
		if (par[x] == x) {
			return x;
		}
		else {
			return par[x] = find(par[x]);
		}
	}

	//xとyの属する集合を併合
	void unite(int x, int y) {
		x = find(x); y = find(y);
		int numsum = num[x] + num[y];
		if (x == y) {
			return;
		}
		if (ran[x]<ran[y]) {
			par[x] = y;
		}
		else {
			par[y] = x;
			if (ran[x] == ran[y]) {
				ran[x]++;
			}
		}
		num[x] = num[y] = numsum;
	}

	//xとyが同じ集合に属するか否か
	bool same(int x, int y) {
		return find(x) == find(y);
	}

};


int main() {
  int n, m;
  cin >> n >> m;
  vii l2u(m);
  rep (i, n) {
    int k;
    cin >> k;
    rep (j, k) {
      int l;
      cin >> l;
      l--;
      l2u[l].push_back(i);
    }
  }
  UnionFind uf(n);
  rep (i, m) {
    rep (j, (int)l2u[i].size() - 1) {
      int u1 = l2u[i][j];
      int u2 = l2u[i][j + 1];
      uf.unite(u1, u2);
    }
  }
  if (uf.num[uf.find(0)] == n) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
  
}


Measured memory_bytes: 4608
s=input()
a='abcdefghijklmnopqrstuvwxyz'
r='zyxwvutsrqponmlkjihgfedcba'
if len(s)!=26:
  for i in a:
    if i not in s:
      s=s+i
      break
elif s==r:
  s=-1
else:
  for i in range(25,0,-1):
    if i==1:
      s=chr(ord(s[0])+1)
      break
    if s[i]>s[i-1]:
      l=sorted(s[i:])
      for j in l:
        if j>s[i-1]:
          m=j
          break
      s=s[:i-1]+m
      break
print(s)

Measured memory_bytes: 3064
N, A, B = map(int, input().split())
S = input()

count = 0
b_count = 0
for s in S:
    if s == "a":
        if count < A + B:
            print("Yes")
            count += 1
            continue

    elif s == "b":
        if count < A + B and b_count < B:
            print("Yes")
            count += 1
            b_count += 1
            continue

    print("No")



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

int main(void){
    
    int count[10]={};
    for(int i=0;i<3;i++){
        int x;
        cin>>x;
        count[x-1] ++;
    }
    cout<<((count[4]==2&&count[6]==1)?"YES":"NO")<<endl;
}

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



int main() 
{
  ll N,K; cin>>N>>K;
  vector<ll> vecA(N);
  rep(i,N)
  {
    cin>>vecA.at(i);
  }
  sort(vecA.begin(),vecA.end());
  vector<ll> veckosu(0);
  rep(i,N)
  {
    if(i==0) {veckosu.push_back(1); continue;}
    if(vecA.at(i)==vecA.at(i-1)) {veckosu.at(veckosu.size()-1)++; continue;}
    veckosu.push_back(1);
  }
  sort(veckosu.begin(),veckosu.end());
  if(veckosu.size()<=K) {cout<<0<<endl; return 0;}
  ll count=0;
  rep(i,veckosu.size()-K)
  {
    count+=veckosu.at(i);
  }
  cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 3956
n, m = map(int, input().split())
card = [0 for i in range(n + 1)]

for i in range(m):
    l, r = map(int, input().split())
    card[l - 1] += 1
    card[r] -= 1

for i in range(n):
    card[i + 1] += card[i]

ans = 0

for i in range(n):
    if card[i] == m:
        ans += 1

print(ans)

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

int main()
{
  int q1, b, c1, c2, q2;
  int aizu, normal;
  while (cin>>q1, q1) {
    cin>>b>>c1>>c2>>q2;
    aizu = normal = -1;
    for (; q2 > 0; q2--) {
      if (b >= q2*c1) {
	if ( (b-q2*c1)/c2 + q2 >= q1) {
	  aizu = q2;
	  normal = (b-q2*c1)/c2;
	  break;
	}
      }
    }
    if (aizu == -1) cout<<"NA"<<endl;
    else cout<<aizu<<" "<<normal<<endl;
  }

  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};


int main(){
    LL a,b,x;cin >> a >> b >> x;
    double ans;
    if(2*x>=a*a*b){
        ans = atan((double)(a*a*b-x)*2/a/a/a)*180/M_PI;
    }
    else{
        ans = 90 - atan((double)2 * x/a/b/b)*180/M_PI;
    }
    cout << setprecision(30) << fixed << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import Data.Char

main :: IO ()
main = do
  l1 <- getLine
  l2 <- getLine
  let n = read l1 :: Int
  putStrLn $ map (f . g n) l2

f c
  | c > 'Z' = chr $ (ord c) - 26
  | otherwise = c

g 0 c = c
g n c = succ $ g (n - 1) c

Measured memory_bytes: 1404
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int n = sc.nextInt();
		long sum = 0;
		for(int i=0;i<n;++i){
			sum+=sc.nextInt();
		}
		if(sum >= h) System.out.print("Yes");
		else System.out.print("No");
		
	}
}

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

using namespace std;

const int max_n = 100111, inf = 1000111222;

int n, p[max_n], nxt[max_n], used[max_n], ans[max_n];
vector<int> g[max_n], g2[max_n];

bool dfs(int v) {
    if (used[v]) {
        return false;
    }
    used[v] = 1;
    for (int to : g[v]) {
        if (p[to] == -1 || dfs(p[to])) {
            p[to] = v;
            nxt[v] = to;
            return true;
        }
    }
    return false;
}

void dfs2(int v) {
    used[v] = 1;
    for (int to : g2[v]) {
        if (used[to] == 0) {
            dfs2(to);
            ans[to] = nxt[v];
        }
    }
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d", &n);
    for (int i = 0; i + 1 < n; ++i) {
        int k;
        scanf("%d", &k);
        g[i].resize(k);
        for (int &x : g[i]) {
            scanf("%d", &x);
            --x;
        }
    }
    memset(nxt, -1, sizeof(nxt));
    memset(p, -1, sizeof(p));
    for (int run = 1; run; ) {
        run = 0;
        memset(used, 0, sizeof(used));
        for (int i = 0; i + 1 < n; ++i) {
            if (nxt[i] == -1 && dfs(i)) {
                run = 1;
            }
        }
    }
    for (int i = 0; i + 1 < n; ++i) {
        if (nxt[i] == -1) {
            puts("-1");
            return 0;
        }
    }
    int root;
    for (int i = 0; i < n; ++i) {
        if (p[i] == -1) {
            root = i;
            break;
        }
    }
    p[root] = n - 1;
    nxt[n - 1] = root;
    for (int i = 0; i + 1 < n; ++i) {
        for (int to : g[i]) {
            if (to != nxt[i]) {
                g2[p[to]].push_back(i);
            }
        }
    }
    memset(used, 0, sizeof(used));
    dfs2(n - 1);
    for (int i = 0; i < n; ++i) {
        if (!used[i]) {
            puts("-1");
            return 0;
        }
    }
    for (int i = 0; i + 1 < n; ++i) {
        printf("%d %d\n", nxt[i] + 1, ans[i] + 1);
    }
    return 0;
}


Measured memory_bytes: 17664
//### In The Name Of GOD ###

//%% Remember; (((He))) is The (((Accepter))) %%

// GOD IS GREATER ...

#include <bits/stdc++.h>

using namespace std;

typedef long long ll ;
typedef long double ld ;

//#define int ll
#define pb push_back
#define bp pop_back
#define pf push_front
#define fp pop_front
#define X first
#define Y second
#define sz(a) (int)(a.size())
#define sg(a, b) (a + b - 1) / b

const int MOD = 1000 * 1000 * 1000 + 7;
const int INF = 1000 * 1000 * 1000 + 10 ;
const int MAXN = 4194305;
const int MLOG = 17;
const int NMAX = 20;

signed main() {
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int n, m;
	cin >> n >> m;
	int ans[n + m - 1] = {};
	bool p = true;
	char ch;
	for(int i = 0; i < n; i++)
		for(int j = 0; j < m; j++) {
			cin >> ch;
			if(ch == '#') ans[i + j]++;
			if(ans[i + j] > 1) p = false;
		}
	cout << ((p) ? "Possible" : "Impossible");
}


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

int main(){
    int H, W;
    cin >> H >> W;
    vector<vector<char>> a(H, vector<char>(W));
    // 入力受け取り
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> a[i][j];
        }
    }
    
    vector<bool> Horizon(H, false);   // 全て白の行をtrue
    vector<bool> Vertiacal(W, false); // 全て白の列をtrue
    
    // 行について、白かどうか調べる
    for (int i = 0; i < H; i++) {
        bool judge = true;  // 黒があったらfalse
        for (int j = 0; j < W; j++) {
            if (a[i][j] == '#') {
                judge = false;
            }
        }
        if (judge) {
            Horizon[i] = true;
        }
    }
    
    // 同様に列について調べる(添え字注意)
    for (int j = 0; j < W; j++) {
        bool judge = true;
        for (int i = 0; i < H; i++) {
            if (a[i][j] == '#') {
                judge = false;
            }
        }
        if (judge) {
            Vertiacal[j] = true;
        }
    }
    
    // 全て白の行または列は出力しない
    for (int i = 0; i < H; i++) {
        if (Horizon[i]) {
            continue;         // 全て白の行は出力しないのでcontinue
        } else {
            for (int j = 0; j < W; j++) {
                if (Vertiacal[j]) {
                    continue; // 全て白の列は出力しないのでcontinue
                } else {
                    cout << a[i][j];
                }
            }
        }
        cout << endl;  // 改行を忘れない
    }
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc063/tasks/arc075_a

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

ll N, s, sum, m;

int main()
{
  sum = 0;
  m = INF;
  cin >> N;

  REP(i, N)
  {
    cin >> s;
    sum += s;
    if (0 < s % 10)
      m = min(m, s);
  }

  if (sum % 10 == 0)
    sum -= m;

  cout << max(0ll, sum) << '\n';

  return 0;
}


Measured memory_bytes: 384
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/04/27 12:31:13 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>

/* #include <boost/multi_array.hpp> */
/* #include <boost/optional.hpp> */
/* #include <boost/range/irange.hpp> */
/* #include <boost/range/algorithm.hpp> */
/* #include <boost/range/adaptors.hpp> */
/* #include <boost/multiprecision/cpp_int.hpp> */
/* #include <boost/algorithm/string/classification.hpp> // is_any_of */
/* #include <boost/algorithm/string/split.hpp> */
/* #include <boost/algorithm/string/join.hpp> */
/* #include <boost/algorithm/string/replace.hpp> */
/* #include <boost/math/tools/minima.hpp> */
/* namespace adaptor = boost::adaptors; */
/* using boost::math::tools::brent_find_minima; */
/* using boost::irange; */
/* using boost::algorithm::join; */
/* using boost::algorithm::split; */
/* using boost::algorithm::replace_all; */
/* using boost::multiprecision::cpp_int; */

#define MOD 1e9+7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

using namespace std;
using ll = long long;
using P = pair<int, int>;

// TOP
void	Main()
{
	int	n, m;
	cin >> n >> m;

	int	t = 100 * (n - m) + 1900 * m;
	cout << t * (1 << m) << endl;
}
// END

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


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

int main(){
	int n;
	string str;
	while(1){
		int cnt = 0;
		getline( cin, str );
		sscanf( str.c_str(), "%d", &n );
		if( str.size()==0 )	break;
		for( int a=0; a<=9; a++ ){
			for( int b=0; b<=9; b++ ){
				for( int c=0; c<=9; c++ ){
					for( int d=0; d<=9; d++ ){
						if( n == a+b+c+d ){
							cnt++;
						}
					}
				}
			}
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 10000000000
#define MOD 1000000007LL
#define MAX 100005
#define NIL -1
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
typedef pair<double, double> doup;

ll zeroer(ll x) {
    if(x<=0) return 0;
    else return x;
}

int main(void) {
    ll n, k;
    cin >> n >> k;
    ll i, j;
    ll ans=0;
    
    for(j=k+1; j<=n; j++) {
        if(k!=0)
            ans+=n/j*(j-k)+zeroer(n%j-k+1);
        else
            ans+=n;
    }
    
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(),a.end()
#define forn(i,n) for(int i=0;i<int(n);i++)
#define forr(i,n) for(int i=int(n-1);i>=0;i--)
#define fora(i,a,b) for(int i=int(a);i<=int(b);i++)
#define forb(i,a,b) for(int i=int(a);i>=int(b);i--)
using namespace std;
using ll=long long int;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<ll> vii;
typedef pair<ll ,ll> pii;
void solve()
{
	ll a,b,c;
	cin>>a>>b>>c;
	ll k;
	cin>>k;
	while(a>=b)
	{
		b*=2;
		k--;
		if(k==0)break;
	}
	while(b>=c)
	{
		if(k==0)break;
		k--;
		c*=2;
	}

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

Measured memory_bytes: 3644
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    x, y = LI()
    a = [1, 3, 5, 7, 8, 10, 12]
    b = [4, 6, 9, 11]
    c = [2]
    if x in a and y in a:
        print("Yes")
        return
    if x in b and y in b:
        print("Yes")
        return
    if x in c and y in c:
        print("Yes")
        return
    print("No")
    return

#B
def B():
    h, w = LI()
    print("#" * (w + 2))
    for _ in range(h):
        a = ["#"]
        for s in S():
            a.append(s)
        a.append("#")
        print("".join(a))
    print("#" * (w + 2))
    return

#C
def C():
    h, w = LI()
    ans = inf
    for i in range(1, h):
        ans = min(ans, max(i * w, (h - i) * (w // 2), (h - i) * (w - w // 2)) - min(i * w, (h - i) * (w // 2), (h - i) * (w - w // 2)))
        ans = min(ans, max(i * w, (h - i) // 2 * w, (h - i - (h - i) // 2) * w) - min(i * w, (h - i) // 2 * w, (h - i - (h - i) // 2) * w))
    h, w = w, h
    for i in range(1, h):
        ans = min(ans, max(i * w, (h - i) * (w // 2), (h - i) * (w - w // 2)) - min(i * w, (h - i) * (w // 2), (h - i) * (w - w // 2)))
        ans = min(ans, max(i * w, (h - i) // 2 * w, (h - i - (h - i) // 2) * w) - min(i * w, (h - i) // 2 * w, (h - i - (h - i) // 2) * w))
    print(ans)
    return

#D
def D():
    return


#Solve
if __name__ == '__main__':
    C()


Measured memory_bytes: 43376
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;


typedef long long i64;
const int inf = (int)1.05e9;


int main()
{
	int h, w, n;
	int sx, sy;
	char s_str[200005], t_str[200005];
	bool chokudai = false;

	scanf("%d%d%d%d%d%s%s", &h, &w, &n, &sx, &sy, s_str, t_str);

	for(int direction = 0; direction < 2 && !chokudai; direction++) {

		int start = (direction == 0 ? sx : sy) - 1;
		int limit = (direction == 0 ? h : w);
		char dec_char = (direction == 0 ? 'U' : 'L');
		char inc_char = (direction == 0 ? 'D' : 'R');

		int rem_lo = 0, rem_hi = 0;
		int lo = start, hi = start;

		for(int i = 0; i < n; i++) {

			char s = s_str[i], t = t_str[i];

			if(s == dec_char) {
				lo = lo - 1;
			} else if(s == inc_char) {
				hi = hi + 1;
			}

			rem_lo = max(rem_lo, 0 - lo);
			rem_hi = min(rem_hi, limit - 1 - hi);

			if(rem_lo > rem_hi) {
				chokudai = true;
				break;
			}

			if(hi - lo == 0) {
				if(t == dec_char) {
					rem_lo -= 1;
				} else if(t == inc_char) {
					rem_hi += 1;
				}
				// ???
			} else {
				if(t == dec_char) {
					hi = hi - 1;
				} else if(t == inc_char) {
					lo = lo + 1;
				}
			}
		}
	}

	printf("%s\n", chokudai ? "NO" : "YES");

	return 0;
}

/* waffle */


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

using namespace std;

typedef long long ll;

ll k, n, x, y;

int main()
{
  cin >> k >> n;
  ll ans = 0, maxn = 0, p;
  for(int i = 1; i <= n; i++)
  {
    cin >> x;
    if(i != 1)
    {
      ans += x - y;
      maxn = max(maxn, x - y);
    }
    else p = x;
    y = x;
  }
  ll t = k - x + p;
  ans += t, maxn = max(maxn, t);
  cout << ans - maxn << endl;
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007


int main() {

  int N,A,B;
  cin >> N >> A >> B;
  string S;
  cin >> S;

  int n = A + B;
  for(int i = 0;i < S.size();i++) {
    if(S.at(i) == 'a') {
      if(n > 0) {
        cout << "Yes" << endl;
        n--;
      }else cout << "No" << endl;
    }else if(S.at(i) == 'b') {
      if(n > 0 && B > 0) {
        cout << "Yes" << endl;
        n--; B--;
      }else cout << "No" << endl;
    }else {
      cout << "No" << endl;
    }
  }


}



Measured memory_bytes: 896
// author-Shivam gupta

#include <bits/stdc++.h>


using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))

#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)

#define IN(A, B, C) assert( B <= A && A <= C)

#define MP make_pair
#define FOR(i,a) for(int i=0;i<a;i++)

#define FOR1(i,j,a) for(int i=j;i<a;i++)

#define EB emplace_back

#define INF (int)1e9

#define EPS 1e-9

#define PI 3.1415926535897932384626433832795

#define MOD 1000000007
const int N = 3e5+5;

#define read(type) readInt<type>()
#define max1 100001
#define out(x) cout<<x<<'\n'
#define out1(x) cout<<x<<" "
#define END cout<<'\n'
const double pi=acos(-1.0);

typedef pair<int, int> PII;

typedef vector<int> VI;

typedef vector<string> VS;

typedef vector<PII> VII;

typedef vector<VI> VVI;

typedef map<int,int> MPII;

typedef set<int> SETI;

typedef multiset<int> MSETI;

typedef long int li;

typedef unsigned long int uli;

typedef long long int ll;

typedef unsigned long long int  ull;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const ll mod = 998244353;
using vl = vector<ll>;

bool isPowerOfTwo (int x)
{
  /* First x in the below expression is
    for the case when x is 0 */
  return x && (!(x&(x-1)));
}
void fast(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
ll power(ll x, ll y, ll p)
{
    ll res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

long long phi[max1], result[max1],F[max1];
// Precomputation of phi[] numbers. Refer below link
// for details : https://goo.gl/LUqdtY
void computeTotient()
{
    // Refer https://goo.gl/LUqdtY
    phi[1] = 1;
    for (int i=2; i<max1; i++)
    {
        if (!phi[i])
        {
            phi[i] = i-1;
            for (int j = (i<<1); j<max1; j+=i)
            {
                if (!phi[j])
                    phi[j] = j;

                phi[j] = (phi[j]/i)*(i-1);
            }
        }
    }
    for(int i=1;i<=100000;i++)
{
	for(int j=i;j<=100000;j+=i)
	{  int p=j/i;
	F[j]+=(i*phi[p])%mod;
         F[j]%=mod;

          }
}
}
int gcd(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    int x1, y1;
    int d = gcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}

bool find_any_solution(int a, int b, int c, int &x0, int &y0, int &g) {
    g = gcd(abs(a), abs(b), x0, y0);
    if (c % g) {
        return false;
    }

    x0 *= c / g;
    y0 *= c / g;
    if (a < 0) x0 = -x0;
    if (b < 0) y0 = -y0;
    return true;
}

int main() {
    fast();
int x,y;
cin>>x>>y;
int a,b;
int p=y-2*x;
if(p%2==0){b=p/2;}
else{out("No");return 0;}
a=x-b;
if(a>=0 && b>=0){out("Yes");}
else{
    out("No");
}
}


Measured memory_bytes: 3640
<?php
$n = trim(fgets(STDIN));
$vArray = explode(" ", trim(fgets(STDIN)));

foreach($vArray as $i => $v){
    $dArray = divisor($v);
    foreach($dArray as $d){
        @$map[$d]++;
    }
}
$max = 1;
foreach($map as $value => $count){
    if($count >= $n - 1){
        $max = max($max, $value);
    }
}
echo $max;

function divisor($n){
    if(!isset($GLOBALS["cache"][$n])){
        for($i = ceil(sqrt($n)); $i >= 1; $i--){
            if($n % $i == 0){
                $f[] = $i;
                $f[] = $n / $i;
            }
        }
        sort($f);
        $GLOBALS["cache"][$n] = array_unique($f);
    }
    return $GLOBALS["cache"][$n];
}

Measured memory_bytes: 14840
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#define DIVCEIL(A,B) ((A+(B-1))/B)
using namespace std;

void solve(long long N, long long M){
    if(2*N >= M)cout << M/2 << endl;
    else cout << N+(M-2*N)/4 << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    solve(N, M);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <chrono>
#include <random>
#include <unordered_map>
#include <cassert>
#pragma GCC optimize("O3")
#pragma comment(linker, "STACK:36777216")
using namespace std;
using i64 = int64_t;
constexpr i64 MOD = 1e9 + 7;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
using vi = vector<i64>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ii = pair<i64, i64>;

map<string, int> cnt;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    cnt[s] = 1;
    for (int i = 1; i < n; i++) {
        string t;
        cin >> t;
        if (cnt[t] || s.back() != t.front()) {
            cout << "No" << endl;
            return 0;
        }
        cnt[t] = 1;
        s = string(t);
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        int B[] = new int[N-1];
        for(int i = 0; i < N-1 ; i++) {
            B[i] = scan.nextInt();
        }
        int answer = 0;
        if(N == 2) {
            answer += B[0] + B[0];
        }
        for(int i = 1; i < N-1 ; i++) {
            if(B[i] > B[i-1]) {
                answer += B[i-1];
            } else {
                answer += B[i];
            }
            if(i == 1)
                answer += B[i-1];
            if(i == N-2) {
                answer += B[i];
            }
        }
        os.println(answer);
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

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

void solve() {
    int A;
    cin >> A;
    // fin,t
    vector<pair<int,int>> vp;
    REP(_,A) {
        int a,b;
        cin >> a >> b;
        auto p = make_pair(b,a);
        vp.push_back(p);
    }
    sort(ALL(vp));
    int nt = 0;
    for(const auto &p: vp) {
        nt += p.second;
        if (nt > p.first) {
            cout << "No" << endl;
            return;
        }
    }

    cout << "Yes" << endl;

}

int main() {
    solve();
    return 0;
}


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

const ll MOD =  1000000007;

//A:0 C:1 G:2 T:3
ll dp[105][4][4][4];

int main(){
	int N;
	cin >> N;
	
	rep(i,4){
		rep(j,4){
			rep(k,4){
				if(i == 1 && j == 2 && k == 0) continue;
				if(i == 2 && j == 1 && k == 0) continue;
				if(i == 1 && j == 0 && k == 2) continue;
				dp[3][i][j][k] = 1;
			}
		}
	}
	
	for (int i = 4; i <= N; ++i) {
		rep(j,4){
			rep(k,4){
				rep(l,4){
					rep(m,4){
						if(m == 1 && l == 2 && k == 0) continue;
						if(m == 2 && l == 1 && k == 0) continue;
						if(m == 1 && l == 0 && k == 2) continue;
						if(m == 1 && k == 2 && j == 0) continue;
						if(m == 1 && l == 2 && j == 0) continue;
						dp[i][m][l][k] += dp[i-1][l][k][j];
						dp[i][m][l][k] %= MOD;
					}
				}
			}
		}
	}
	
	ll ans = 0;
	
	rep(i,4){
		rep(j,4){
			rep(k,4){
				ans += dp[N][i][j][k];
				ans %= MOD;
			}
		}
	}
	
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
int modpow(int X,int Y){
  int sum=X,cnt=1;
  vi A;
  while(cnt<=Y){
    cnt*=2;
    A.pb(sum);
    sum*=sum;
    sum%=MOD;
  }
  int ret=1,M=A.size();
  REP(i,1,M){
    if(Y>=(1ll<<M-i)){
      Y-=(1ll<<M-i);
      ret*=A[M-i];
      ret%=MOD;
    }
  }
  return ret;
}
signed main(){
  int N; cin>>N;
  vi A(N);
  rep(i,0,N) cin>>A[i];
  int ans=0,sum=0,sum2=1;
  rep(i,1,N){
    sum2*=i;
    sum2%=MOD;
  }
  rep(i,1,N){
    sum+=sum2*modpow(i,MOD-2)%MOD;
    int X=A[i]-A[i-1];
    ans+=X*sum%MOD;
    ans%=MOD;
  }
  cout<<ans<<endl;
  }



Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
	int n;
	float b;
	int c[6] = {0};
	int i;
	int j;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		scanf("%f", &b);
		
		if (b < 165.0){
			c[0]++;
		}
		else if (b < 170.0){
			c[1]++;
		}
		else if (b < 175.0){
			c[2]++;
		}
		else if (b < 180.0){
			c[3]++;
		}
		else if (b < 185.0){
			c[4]++;
		}
		else {
			c[5]++;
		}
	}
	
	for (j = 1; j < 7; j++){
		printf("%d:", j);
		for (i = 0; i < c[j - 1]; i++){
			printf("*");
		}
		printf("\n");
	}
	
	return (0);
}

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

using namespace std;
typedef pair<double, double> P;

double Helon(P a, P b, P c)
{
	double square = 0;
	double x, y, z;
	x = sqrt((b.first - a.first) * (b.first - a.first) + (b.second - a.second) * (b.second - a.second));
	y = sqrt((c.first - a.first) * (c.first - a.first) + (c.second - a.second) * (c.second - a.second));
	z = sqrt((c.first - b.first) * (c.first - b.first) + (c.second - b.second) * (c.second - b.second));
	double s = (x + y + z) / 2;
	square = sqrt(s * (s - x) * (s - y) * (s - z));
	return(square);
}

void solve()
{
	vector<P> Vec(4);
	while(~scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &Vec[0].first, &Vec[0].second, 
													&Vec[1].first, &Vec[1].second, 
													&Vec[2].first, &Vec[2].second, 
													&Vec[3].first, &Vec[3].second))
	{
		double square1 = 0;
		square1 += Helon(Vec[0], Vec[1], Vec[2]);
		square1 += Helon(Vec[0], Vec[2], Vec[3]);
		double square2 = 0;
		square2 += Helon(Vec[0], Vec[1], Vec[3]);
		square2 += Helon(Vec[1], Vec[2], Vec[3]);
		if(fabs(square1 - square2) < 0.00000000001)
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
import java.util.*;
 
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        String s = sc.next();
        int memo[] = new int[n+1];
        memo[0] = 0;
        for(int i=0; i<n; i++){
            memo[i+1] = memo[i];
            if(i+1 < n && s.charAt(i)=='A' && s.charAt(i+1)=='C'){
                memo[i+1] += 1;
            }
        }

        int l[] = new int[q];
        int r[] = new int[q];

        for(int i=0; i<q; i++){
            l[i] = sc.nextInt();
            r[i] = sc.nextInt();
        }

        for(int i=0; i<q; i++){
            System.out.println(memo[r[i]-1]-memo[l[i]-1]);
        }
    }
}


Measured memory_bytes: 94032
#include<stdio.h>

int main(){
  int W,H,x,y,r;

  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

  if(r<=x && x<=(W-r) && r<=y && y<=(H-r)){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  
  return 0;
}
  

Measured memory_bytes: 584
def modpow(a,n,mod=10**9+7):
    res=1
    while n>0:
        if n&1:
            res=res*a%mod
        a=a*a%mod
        n>>=1
    return res%mod

def modcmb(n,r,mod=10**9+7):
    res=1
    div=min(r,n-r)
    for i in range(div):
        res=res*(n-i)*modpow(div-i,mod-2)%mod
    return res%mod

n,a,b=[int(i) for i in input().split()]
ans=modpow(2,n)-1
ans-=modcmb(n,a)
ans%=10**9+7
ans-=modcmb(n,b)
ans%=10**9+7
print(ans)

Measured memory_bytes: 43132
#include<stdio.h>
#include<math.h>
int main(){
    long long int m,num,k=0,t,l,sum=0;
    scanf("%lld",&num);
    t=num;
    while(t!=1){
        t/=2;
        k++;
    }
    for(l=0;l<=k;l++){
        sum+=pow(2,l);
    }
    printf("%lld",sum);
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;

const int N=100005;

struct E{
	int to,next;
}mem[N<<1];
int num,n,x,y,ans;
int head[N],f[N][22];

void add(int x,int y){
	num++;
	mem[num].to=y; mem[num].next=head[x];
	head[x]=num;
}

void dfs(int k,int pre){
	int j,u,i,lim; lim=0;
	for (j=head[k];j;j=mem[j].next){
		u=mem[j].to;
		if (u==pre) continue;
		dfs(u,k);
		for (i=0;i<=20;i++) f[k][i]+=f[u][i];
	}
	for (i=0;i<=20;i++)
		if (f[k][i]>1) lim=i+1;
	while (f[k][lim]) lim++;
	for (i=0;i<lim;i++) f[k][i]=0;
	f[k][lim]++;
	ans=max(ans,lim);
}

int main(){
	int i;
	scanf("%d",&n);
	for (i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		add(x,y); add(y,x);
	}
	dfs(1,0);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 16512
#include <stdio.h>
#include <math.h>
 
int
main (
  int   argc,
  char *argv[ ]
  )
{
  double r;
 
  scanf ( "%lf", &r );
  printf ( "%.5f %.5f\n", r * r * M_PI, 2. * r * M_PI );
 
  return ( 0 );
}



Measured memory_bytes: 2040
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def prime_factorization(n):
    """
    nを素因数分解します
    """
    res = []
    for i in range(2, int(pow(n, 0.5)) + 1):
        if n % i == 0:
            ex = 0
            while n % i == 0:
                ex += 1
                n //= i
            res.append([i, ex])
    if n != 1:
        res.append([n, 1])

    return res


def resolve():
    n = int(input())
    prime = prime_factorization(n)

    res = []
    for p, ex in prime:
        for _ in range(ex):
            res.append(p)
    print(str(n) + ":", *res)


if __name__ == '__main__':
    resolve()



Measured memory_bytes: 5656
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string str;
    cin >> str;
    int aindex = 0;
    int zindex = 0;
    bool bfindA = false;
    for(size_t i=0;i<str.size();i++)
    {
        if((str[i] == 'A') && !bfindA)
        {
            aindex = i;
            bfindA = true;
        }
        if(str[i] == 'Z')
        {
            zindex = i;
        }
    }
    cout << (zindex - aindex + 1) << endl;
    return 0;
}

Measured memory_bytes: 640
N, *L = $<.read.split.map(&:to_i)
L.sort!

sum = 0
(0..N-3).each{|i|
	(i+1..N-2).each{|j|
		a_b = L[i]+L[j]
		sum += L[j+1, N-j-1].bsearch_index{|c| a_b <= c }||N-j-1
	}
}
p sum


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

int main() {
  int X;
  cin >> X;
  int m=0, n;
  if (X==1) {m=1;}
  else {
    for (int i=2; i<=sqrt(X); i++) {
      n=i;
      while (n*i<=X) {
        n*=i;
      }
      m=max(m, n);
    } 
  }
  cout << m << endl;
}


Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main()
{
	int N, D;
	cin >> N >> D;

	if (N % (2 * D + 1) == 0) {
		cout << N / (2 * D + 1) << endl;
	}
	else {
		cout << N / (2 * D + 1)+1 << endl;
	}
}





Measured memory_bytes: 3600
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
//	freopen("testcase.pb", "r", stdin);
	string str = "";

	int rect = 0;
	int loze = 0;

	while (getline (cin, str ) ){
		int a, b, c;

		while (str.find(',') != string::npos ){
			str = str.replace(str.find(','), 1, " ");
		} // end while

		stringstream ss(str);
		ss >> a >> b >> c;
		if (a != 0 && b != 0 && c != 0){
			if (a == b){
				++loze;
			} // end if
			if (a*a + b*b == c*c){
				++rect;
			} // end if
		} // end if
	} // end while

	cout << rect << endl;
	cout << loze << endl;
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }

int main() {
    int N;
    cin >> N;
    vector<vector<int>> G(N, vector<int>(N, 0));
    for (int i = 0; i < N; i++) {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            int v;
            cin >> v;
            G[u-1][v-1]++;
        }
    }
    
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cout << G[i][j] << ((j+1==N)?"\n":" ");
        }
    }
}


Measured memory_bytes: 3164
#include<iostream>
#include<vector>

using namespace std;

const int MAX=1500001;
int h[MAX]={0},w[MAX]={0};

int main(){
	int n=0,m=0;
	while(cin>>n>>m){
		if(n==0 || m==0){break;}
		for(int i=0;i<MAX;i++){
			h[i]=w[i]=0;
		}
		int ans=0;
		vector<int> hbuf,wbuf,hdist,wdist;
		hbuf.push_back(0);
		wbuf.push_back(0);
		while(n-->0){
			int htmp=0;
			cin>>htmp;
			hbuf.push_back(hbuf[hbuf.size()-1]+htmp);
		}
		while(m-->0){
			int wtmp=0;
			cin>>wtmp;
			wbuf.push_back(wbuf[wbuf.size()-1]+wtmp);
		}
		for(int i=0;i<hbuf.size();i++){
			for(int j=0;j<i;j++){
				int hd=hbuf[i]-hbuf[j];
				if(h[hd]==0){hdist.push_back(hd);}
				h[hd]++;
			}
		}
		for(int i=0;i<wbuf.size();i++){
			for(int j=0;j<i;j++){
				int wd=wbuf[i]-wbuf[j];
				if(w[wd]==0){wdist.push_back(wd);}
				w[wd]++;
			}
		}
		for(int i=0;i<hdist.size();i++){
			ans+=h[hdist[i]]*w[hdist[i]];
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 17028
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n) { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x) { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int caves[1200][1200];
int cx[1100001];
int cy[1100001];
int main() {
	set<int> prime;
	bool b[1000001] = { false };
	FOR(i, 2, 1000001) {
		if (!b[i]) {
			prime.insert(i);
			for (int j = i + i;j < 1000001;j += i)
				b[j] = true;
		}
	}
	int x = 600, y = 600, dir = 2, go = 1, now = 0;
	FOR(i, 1, 1001 * 1001 + 1) {
		caves[y][x] = i;
		cx[i] = x;
		cy[i] = y;
		x += dx[dir];
		y += dy[dir];
		now++;
		if (go == now) {
			if (dir % 2 == 1)
				go++;
			now = 0;
			dir = (dir + 1) % 4;
		}
	}

	int m, n;
	while (cin >> m >> n, m | n) {
		map<int, int> vis;
		queue<int> Q;
		int ans = 0;
		int last = 0;
		if (EXIST(prime, n)) {
			ans = 1;
			last = n;
		}
		Q.push(n);
		while (!Q.empty()) {
			int q = Q.front();Q.pop();
			if (EXIST(vis, q))
				continue;
			int sx = cx[q];
			int sy = cy[q];
			int ma = 0;
			REP(i, 3) 
				if (EXIST(vis, caves[sy - 1][sx - 1 + i]))
					ma = max(ma, vis[caves[sy - 1][sx - 1 + i]]);
			if (EXIST(prime,q))
				ma++;
			vis[q] = ma;
			if (ans < ma) {
				ans = ma;
				last = q;
			}
			if (ans == ma&&EXIST(prime, q)) {
				last = max(last, q);
			}
			REP(i, 3) {
				if(caves[sy + 1][sx - 1 + i]<=m)
				Q.push(caves[sy + 1][sx - 1 + i]);
			}
		}
		cout << ans << ' ' << last << endl;
	}

}

Measured memory_bytes: 48608
#include<iostream>
#include<complex>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)
int main() {
	int n, a;
	cin >> n >> a;
	cout << n - a + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

class Main {
    ll a, b, c, d;
    void input() { cin >> a >> b >> c >> d; }
    void output() {
        ll res = -1e18;
        res = max(res, a * c);
        res = max(res, a * d);
        res = max(res, b * c);
        res = max(res, b * d);
        cout << res << endl;
    }

public:
    Main() {
        input();
        output();
    }
};

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

    Main();

    return 0;
}


Measured memory_bytes: 3648