akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}




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


  string str; cin >> str;
  cout << str[0] <<str.size()-2 << str[str.size()-1]  << endl;
  
  
  
  
  //cout << fixed << setprecision(16) << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict as dd
N,T = map(int,input().split())
a = list(map(int,input().split()))
dic=dd(int)
mi = a[0]
for i in range(1,N):
    if a[i] < mi:
        mi = a[i]
    else:
        profit = a[i]-mi
        dic[profit] += 1
res = dic[max(dic.keys())]
print(res)

Measured memory_bytes: 20960
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func main() {
	S := getStdin()
	if S[1] == 'B' {
		fmt.Printf("ARC\n")
	} else if S[1] == 'R' {
		fmt.Printf("ABC\n")
	}
}

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}

func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}

func readLine() string {
	buf := make([]byte, 0, 1024*1024*10)
	for {
		l, p, e := sc.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


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

int main(){
  int N,M,X;
  cin >> N >> M >> X;
  int gate[100];
  for(int i=0;i<M;++i){
    cin >> gate[i];
  }
  
  int left =0,right =0;
  for(int i=0;i<M;++i){
    if(gate[i]<X)++left;
    else right++;
  }
  
  cout << min(left,right) << endl;
  return 0;
}


Measured memory_bytes: 256
'''
問題：
    1118 のような、3 つ以上の同じ数字が連続して並んだ
    4 桁の整数を 良い整数 とします。

    4 桁の整数N が与えられるので、N が 良い整数 かどうかを答えてください。
'''

'''
制約：
    1000 ≦ N ≦ 9999
    入力は整数からなる
'''

# 標準入力から N を取得する
n = int(input())
list_n = list(str(n))

result = ""

if (list_n[0] == list_n[1]) and (list_n[1] == list_n[2]):
    result = "Yes"
elif (list_n[1] == list_n[2]) and (list_n[2] == list_n[3]):
    result = "Yes"
else:
    result = "No"

print(result)


Measured memory_bytes: 9196
n = gets.to_i

ymd = []
n.times do
	ymd.push(gets.split.map(&:to_i))
end
ymd.each do |ymd_tmp|
	y = ymd_tmp[0]
	m = ymd_tmp[1]
	d = ymd_tmp[2]
	sum = 0
	tmp_y = y
	while tmp_y != 1000
		if tmp_y % 3 == 0 
			sum += 200
		else
			sum += 195
		end
		tmp_y += 1
	end
	sum += 1
	tmp_m = 1
	while tmp_m != m+1   # calcurating border month,becaouse of m+1
		if tmp_m % 2 == 0 && y % 3 != 0
			sum -= 19 
		elsif tmp_m % 2 == 1 && y % 3 != 0
			sum -= 20 
		elsif tmp_m % 2 == 0 && y % 3 == 0
			sum -= 20 
		elsif tmp_m % 2 == 1 && y % 3 == 0
			sum -= 20 
		end
		tmp_m += 1
	end
	if m % 2 == 0 && y % 3 != 0
		sum += 19 - d
	elsif m % 2 == 1 && y % 3 != 0
		sum += 20 - d 
	elsif m % 2 == 0 && y % 3 == 0
		sum += 20 - d
	elsif m % 2 == 1 && y % 3 == 0
		sum += 20 - d
	end
	puts sum
end

Measured memory_bytes: 8612
#include<iostream>
#include<iomanip>
#include<vector>
using namespace std;

int n;
vector<int> t;
vector<int> v;

double func(double l,double r,double v,double x){
  if(x<=l){
    return v+(l-x);
  }else if(l<x && x<r){
    return v;
  }else{
    return v+(x-r);
  }
}

double getv(double x){
  double ret = func(0,0,0,x);
  int tt = 0;
  for(int i=0;i<n;++i){
    ret = min(ret, func(tt,tt+t[i],v[i],x));
    tt += t[i];
  }
  ret = min(ret, func(tt,tt,0,x));
  return ret;
}

int main(){
  int T = 0;
  cin>>n;
  for(int i=0;i<n;++i){
    int tmp;
    cin>>tmp;
    T += tmp;
    t.push_back(tmp);
  }
  for(int i=0;i<n;++i){
    int tmp;
    cin>>tmp;
    v.push_back(tmp);
  }

  double ret = 0;
  for(int i=0;i<2*T;++i){
    double a1 = i*0.5;
    double a2 = (i+1)*0.5;
    double v1 = getv(a1);
    double v2 = getv(a2);
    ret += 0.5*0.5*(v1+v2);
  }
  cout<<fixed<<setprecision(15)<<ret<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W,cnt=0;
  cin >> H >> W;
  vector<vector<char>> data(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
	  for (int j = 0; j < W; j++) {
	    cin >> data.at(i).at(j);
      }
  }
  for (int i = 0; i< W; i++) {
    for (int j= 0; j<H ;j++) {
      if(data.at(j).at(i)=='.' ||data.at(j).at(i)=='X')
        cnt++;
    }
    if(cnt==H){
      for (int j= 0; j<H ;j++) {
        data.at(j).at(i)='Y';
      }
    }
    cnt=0;
  }  
  for (int i = 0; i< H; i++) {
    for (int j= 0; j<W ;j++) {
      if(data.at(i).at(j)=='.'||data.at(i).at(j)=='Y')
        cnt++;
    }
    if(cnt==W){
      for (int j= 0; j<W ;j++) {
        data.at(i).at(j)='X';
      }
    }
    cnt=0;
  }  

  for (int i = 0; i< H; i++) {
    for (int j= 0; j<W ;j++) {
      if(data.at(i).at(j)!='X'&&data.at(i).at(j)!='Y')
		  cout<<data.at(i).at(j);
      if (j== W-1&&data.at(i).at(j)!='X')
        cout << endl;
    }
  }  
}

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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll inf = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/


int main(){
    fIO

    int a, b;
    cin >> a >> b;

    cout << max(a + b, max(a - b, a * b));
}








Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

//ここから

void solve(){
  int n,k;
  cin>>n>>k;
  int r,s,p;
  cin>>r>>s>>p;
  string t;
  cin>>t;
  int ans=0;
  vector<bool>used(n);
  rep(i,n){
    if(i>=k){
      if(t[i-k]==t[i]){
        if(used[i-k]==true)continue;
      }
    }
    if(t[i]=='r')ans+=p;
    else if(t[i]=='p')ans+=s;
    else ans+=r;
    used[i]=true;
  }
  //rep(i,n)cout<<used[i]<<endl;
  cout<<ans;
}

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


Measured memory_bytes: 512
## D
import numpy as np
import math

def cmb(n, k, mod):
    numerator = 1
    for i in range(k):
        numerator = (numerator * (n-i)) % mod
 
    denominator = 1
    for i in range(1, k+1):
        denominator = (denominator * i) % mod
 
    return (numerator * pow(denominator, mod-2, mod)) % mod
    
    return int((n_frac * n_r_ifrac * r_ifrac) % mod)

mod = 10**9+7
x,y = map(int, input().split()) 
is_ok = True
b = (2 * x - y) / 3
a = x - 2 * b
if not (a.is_integer() and b.is_integer()):
    ans = 0
    is_ok = False
    
a = int(a)
b = int(b)
if a < 0 or b < 0:
    ans = 0
    is_ok = False
if is_ok:    
    ans = cmb(a+b, a, mod)
print(ans)

Measured memory_bytes: 12488
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
AB = [LIST() for _ in range(N)]

X = -sum([x[1] for x in AB])

for i, (A, B) in enumerate(sorted(AB, key=lambda x:x[0]+x[1], reverse=True)):
	if i%2 == 0:
		X += A+B
print(X)


Measured memory_bytes: 34888
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a;
    cin>>a;
    string s;
    cin>>s;
    if(a>=3200) cout<<s<<endl;
    else cout<<"red"<<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

const ll mod=1e9+7;

int main(){
    string s;
    cin >> s;
    ll n=s.length();
    cout << s[0];
    cout << n-2;
    cout << s[n-1] << endl;
    return 0;
} 


Measured memory_bytes: 3548
#include <iostream>
using namespace std;
int main(void){
    int i,len;
    string s;
    int count[27];
    for(i=0;i<26;i++) count[i]=0;
    while(getline(cin,s)) {
        len=(int)s.length();
        for(i=0;i<len;i++){
            if(s[i]>='a'&&s[i]<='z') count[s[i]-97]+=1;
            else if(s[i]>='A'&&s[i]<='Z') count[s[i]-65]+=1;
        }
    }
    for(i=0;i<26;i++) cout << char(97+i) << " : " << count[i] << endl;
}



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

typedef long long ll;

ll gcd(ll a, ll b){
    if(a<b) return gcd(b,a);
    ll r;
    while(r=a%b){
        a = b; b = r;
    }
    return b;
}

int main(){
    int N;
    cin >> N;
    cout << ( N <= 999 ? "ABC" : "ABD") << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<stack>
#include<queue>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	int n;
	cin >> n;
	if (n <= 999) cout << "ABC" << endl;
	else cout << "ABD" << endl;
}

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
typedef complex<ld> Point;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 1e5 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

int main() {
    ll n, d, a;
    cin >> n >> d >> a;
    vector<pair<ll, ll>> v(n);
    vl reach(n, 0);
    vl damage(n, 0);
    vl diff(n, 0);
    ll ans = 0;
    rep(i, n) cin >> v[i].first >> v[i].second;
    auto comPair = [](const P &firstElof, const P &secondElof) {
        return firstElof.first < secondElof.first;
    };
    sort(all(v), comPair);
    // debug(v[2].first);

    int r = 0;
    rep(l, n) {
        if (l == r) r++;

        while (v[r].first - v[l].first <= 2 * d && r < n) {
            r++;
        }

        // debug(l);
        // debug(r);

        reach[l] = r - 1;
    }

    rep(i, n) {
        ll res = v[i].second - damage[i];
        ll bomb_num;
        if (res <= 0)
            bomb_num = 0;
        else
            bomb_num = (res + a - 1) / a;
        ll bomb = bomb_num * a;

        ans += bomb_num;
        damage[i] += bomb;
        if (i == n - 1) break;
        if (i > 0)
            diff[i - 1] += bomb;
        if (reach[i] < n - 1)
            diff[reach[i]] -= bomb;
        damage[i + 1] = damage[i] + diff[i];

        // debug(i);
        // debug(reach[i]);
        // debug(damage[i]);
        // debug(bomb_num);
    }

    out(ans);

    return 0;
}


Measured memory_bytes: 8064
N = int(input())
A,B = [],[]
total = 0
for i in range(N):
    (a,b) = map(int,input().split())
    A.append(a)
    B.append(b)
for i in range(N):
    if (A[N-i-1]+total)%B[N-i-1] == 0:
        continue
    else:
        total += B[N-i-1]-((A[N-i-1]+total)%B[N-i-1])
print(total)

Measured memory_bytes: 16836
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>

using namespace std;

int main() {
	int i, j, N;
	int a[100001] = { 0 }, b[100001] = { 0 };

	int min = 2000000000;
	int max = 0;
	int maxi = 0;
	cin >> N;
	for (i = 0; i < N; i++) {
		cin >> a[i] >> b[i];
		if (min > a[i]) {
			min = a[i];
		}
		if (max < a[i]) {
			max = a[i];
			maxi = i;
		}
	}

	cout << (max-min+1)+ (min - 1) + b[maxi] << endl;



	return 0;
}

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

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

	vector<pair<int, int> > a;

	for (int i = 0; i < n; i++) {
		int x; cin >> x;
		a.push_back({x, i + 1});
	}
	sort(a.begin(), a.end());

	for (int i = 0; i < n; i++) {
		cout << a[i].second << " ";
	}
	return 0;
}

Measured memory_bytes: 1780
N = int(input())
A_list = list(map(int, input().split()))
# my_list = []
# for i in range(len(A_list)):
#     my_list.append((A_list[i], i+1))
# my_list.sort()
# for val in my_list:
#     print(val[1], end=" ")
# print()

my_list = [0] * N
for i in range(len(A_list)):
    my_list[A_list[i] - 1] = i + 1
for val in my_list:
    print(val, end=" ")
print()


Measured memory_bytes: 13812
#include<cstdio>
using ll = long long;
int x[4] = {-1, 0, 1, 0};
int y[4] = {0, 1, 0, -1};
int H, W;
bool S[400][400];
bool has_been_discovered[400][400];
ll members[160000][2];
void DepthFirstSearch(int row, int column, int group_number){
	has_been_discovered[row][column] = true;
	members[group_number][S[row][column]]++;
	for(int i = 0;i < 4;++i){
		if(0 <= row + x[i] && row + x[i] < H && 0 <= column + y[i] && column + y[i] < W && !has_been_discovered[row + x[i]][column + y[i]] && (S[row][column] ^ S[row + x[i]][column + y[i]])){
			DepthFirstSearch(row + x[i], column + y[i], group_number);
		}
	}
}


int main(){
	scanf("%d %d", &H, &W);
	for (int i = 0; i < H; ++i){
		for (int j = 0; j < W; ++j){
			if(!j) scanf("\n");
			char tmp;
			scanf("%c", &tmp);
			S[i][j] = tmp == '#';
		}
	}
	int group_number_ = 0;
	for (int i = 0; i < H; ++i){
		for (int j = 0; j < W; ++j) if(!has_been_discovered[i][j]) DepthFirstSearch(i, j, group_number_++);
	}
	ll answer = 0;
	for (int i = 0; i < group_number_; ++i) answer += members[i][0]*members[i][1];
	printf("%lld\n", answer);
	return 0;
}

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

using namespace std;

using LL = long long;

int n, a, b;
LL dp[5005][5005];
int arr[5005], pos[5005], cnt[5005];

int main() {
	scanf("%d%d%d", &n, &a, &b);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", arr + i);
		pos[arr[i]] = i;
	}
	memset(dp, 0x3f, sizeof(dp));
	for (int i = 0; i <= n; ++i) dp[0][i] = dp[i][0] = 0;
	for (int i = 1; i <= n; ++i) {
		for (int j = arr[i] + 1; j <= n; ++j)
			if (pos[j] < i) ++cnt[j];
		for (int j = 1; j <= n; ++j)
			if (pos[j] <= i) {
				if (cnt[j] == 0)
					dp[i][j] = dp[i][j - 1];
				else
					dp[i][j] = min(dp[i][j - 1] + a, dp[pos[j] - 1][j] + 1LL * b * cnt[j]);
			} else {
				dp[i][j] = dp[i][j - 1];
			}
	}
	printf("%lld\n", dp[n][n]);
}

Measured memory_bytes: 199528
"use strict";
const main = input => {
    let n = parseInt(input[0].split(' ')[0],10), m = parseInt(input[0].split(' ')[1],10);
    let arr = new Array(n+1),a=0;
    arr[0] = 1,arr[1] = 1;
    for(let i=0; i<m; i++) {
        a = parseInt(input[i+1],10);
        arr[a] = 0;
    }
    for(let i=2; i<n+1; i++) {
        if (arr[i]!=0) {
            arr[i] = (arr[i-1]+arr[i-2])%1000000007;
        }
    }
    // console.log(arr);
        
    console.log(arr[n]);
    
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

Measured memory_bytes: 16716
#include<iostream>
#include<cstdio>
#include<stack>

using namespace std;

#define MAX 50
#define WALL 0
#define BLANK 1
#define BLACK 2
#define WHITE 3
#define JUDGE 4
#define NOT 5
#define BLFIE 6
#define WHFIE 7

struct S{
	int x,y;
};

int main(){

	int h,w;
	int field[MAX+5][MAX+5];
	char inp;
	S tmp,no;
	stack<S> po;
	int rean=0;
	int dy[]={0,0,1,-1};
	int dx[]={1,-1,0,0};
	int bcn,wcn;

	while(1){

		cin>>w>>h;
		if(w==0&&h==0) break;

		for(int i=0;i<=h+1;i++){
			for(int j=0;j<=w+1;j++){
				field[i][j]=WALL;
			}
		}

		for(int i=1;i<=h;i++){
			getchar();
			for(int j=1;j<=w;j++){
				inp=getchar();
				switch(inp){
					case '.':
						field[i][j]=BLANK;
						break;
					case 'W':
						field[i][j]=WHITE;
						break;
					case 'B':
						field[i][j]=BLACK;
						break;
				}
			}
		}

		for(int i=1;i<=h;i++){
			for(int j=1;j<=w;j++){
				if(field[i][j]!=BLANK) continue;
				tmp.x=j,tmp.y=i;
				po.push(tmp);
				rean=0;
				while(!po.empty()){
					no=po.top();
					po.pop();
					field[no.y][no.x]=JUDGE;
					for(int k=0;k<4;k++){
						switch(field[no.y+dy[k]][no.x+dx[k]]){
							case WALL:
								break;
							case BLACK:
								if(rean/10==0) rean+=10;
								break;
							case WHITE:
								if(rean%10==0) rean+=1;
								break;
							case BLANK:
								tmp.x=no.x+dx[k];
								tmp.y=no.y+dy[k];
								po.push(tmp);
								break;
							default:
								break;
						}
					}
				}
				for(int k=1;k<=h;k++){
					for(int l=1;l<=w;l++){
						if(field[k][l]!=JUDGE) continue;
						switch(rean){
							case 1:
								field[k][l]=WHFIE;
								break;
							case 10:
								field[k][l]=BLFIE;
								break;
							default:
								field[k][l]=NOT;
								break;
						}
					}
				}
			}

		}

		bcn=0,wcn=0;
		for(int i=1;i<=h;i++){
			for(int j=1;j<=w;j++){
				switch(field[i][j]){
				case WHFIE:
					wcn++;
					break;
				case BLFIE:
					bcn++;
					break;
				default:
					break;
				}
			}
		}
		cout<<bcn<<" "<<wcn<<endl;
	}

	return 0;
}

Measured memory_bytes: 1252
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
using ll = long long;
using namespace std;

int main()
{
	string S, T;
	cin >> S >> T;
	int max_count = 0;
	//int num = 0;

	for (unsigned int i = 0; i < S.size()-T.size()+1; i++) {
		int count = 0;
		for (unsigned int j = 0; j < T.size(); j++) {
			if (S[j + i] == T[j]) {
				count++;
			}
		}
		if (max_count < count) {
			max_count = count;
		}
	}
	cout << T.size() - max_count << endl;
}



Measured memory_bytes: 3220
#python3
import operator as op
n = int(input())
a = []
for _ in range(n):
    x, l = map(int, input().split())
    a.append((x - l, x + l))


a.sort(key=op.itemgetter(1))

tmp = - int(1e12)
cnt = 0
for i in range(n):
    MIN, MAX = a[i]
    if tmp > MIN:
        pass
    else:
        cnt +=1
        tmp = MAX
print(cnt)


    
    

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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

#define long long ll

int main(){
    int n;
    cin >> n;
    int cnt = 0;
    rep(i,n){
        cnt += i + 1;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int taHP = A;
		int aoHP = C;

		while((taHP > 0) && (aoHP> 0)) {
			aoHP  = aoHP - B;
			if(aoHP <= 0) {
				System.out.println("Yes");
				break;
			}

			taHP = taHP - D;
			if(taHP <= 0) {
				System.out.println("No");
				break;
			}
		}

	}

}

Measured memory_bytes: 35652
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
 
int main(){ 
  string s;
  cin >> s;
  string t = "keyence";
  int n = s.size();
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (t == s.substr(0,i+1) + s.substr(j)) {
        cout << "YES" << endl;
        return 0;
      }
    }
  }
  cout << "NO" << endl;
  
  return 0;
} 

Measured memory_bytes: 256
import sys

s_args = sys.stdin.read().splitlines()

a = [int(s_a) for s_a in s_args[1:]]

a.sort()

res = 0
for ai in a:
    res += ai

if res % 10 != 0:
    print(res)
else:
    for ai in a:
        if ai % 10 != 0:
            print(res - ai)
            sys.exit()
    print('0')


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;

ll n, k, a, b, x, y, ans, M=1e9+7;
int main() {
	int i;
	cin >> n >> k;
	for(a=0, b=n; a<k; a++, b--) {
		x += a;
		y += b;
	}
	ans = y-x+1;
	for(i=k; i<=n; i++) {
		x += a;
		y += b;
		(ans += y-x+1) %= M;
		++a;
		--b;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

  int H,W,K;  int L;
  Scd3(H,W,K);
  char s[123][123];
  Rep(i,H) Scs(s[i]);
  Rep(i,H) Rep(j,W) if( s[i][j] == '#' ) L++;
  int ans = 0;  
  int cnt;
  Rep(bh,1<<H) Rep(bw,1<<W) {
    cnt = 0;
    Rep(h,H) Rep(w,W) {
      if( ( ((bh>>h) | (bw>>w)) & 1 ) && s[h][w] == '#' ) cnt++; 
    }
    if( L-cnt == K ) ans++;
  }
  
  printf("%d\n", ans );

  return 0;
  
}


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

#define int long long

void fastio()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
	fastio();
	char s;
	cin >> s;
	if (isupper(s))
		cout << 'A';
	else
		cout << 'a';

	return 0;
}


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

vector<int> table(100001);

int pr2() {
  int sum = 0;
  int cnt = 0;
  for (int i = 1; i < table.size(); i++) {
    sum = 0;
    for (int j = i; ; j++){
      sum += j;
      if (sum >= table.size()) break;
      table[sum]++;
    }
  }
  return (cnt);
}

int process(int a, int b) {
  return table[a] * table[b];
}

int main() {
  int S; cin >> S;
  pr2();
  for (int i = 1; i < 10; i++){
    // cout << table[i] << endl;
  }
  long long ans = 0;
  for (int a = 1; a <= S; a++) {
    if (S%a == 0) {
      int b = S/a;
      ans += process(a, b);
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,a,b,sum,cnt=0,n1;
	cin>>n>>a>>b;
	sum=a+b;
	n1=n/sum;
	cnt+=n1*a;
	n-=n1*sum;
	if(n>a){
		cnt+=a;
	}
	else{
		cnt+=n;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <cmath>
 
using namespace std;
 
int main() {
    float x, y, a=0;
    cin >> x >> y;
    while( a <= 1000 ){
        a++;
        if( floor(a * 0.08) == x && floor(a * 0.1) == y ){
            cout << a;
            return 0;
        }
    }
    cout << -1;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

k = int(input())
l = 10
A = [str(i+1) for i in range(9)]
B = ["0"] + A
ans = []
#print(l)

def dfs(num,l):
    if len(num) >= l:
        ans.append(int(num))
    else:
        ans.append(int(num))
        for i in B:
            if abs(int(num[-1])-int(i)) < 2:
                dfs(num + i,l)
if k <= 9:
    print(k)
else:
    for i in A:
        dfs(i,l)
    ans = sorted(ans)
    #print(ans)
    print(ans[k-1])


Measured memory_bytes: 84444
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,j=0;
  int a[3];
  cin>>n;
  while(j<n){
    for(int i=0;i<3;i++){
      cin>>a[i];
    }
    sort(a,a+3);
    if(a[2]*a[2]==a[1]*a[1]+a[0]*a[0]){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
  j++;
  }
}

Measured memory_bytes: 3132
#include <stdio.h>
struct data{
    int par;
    int son;
    int sib;
};
typedef struct data node;

node tree[100000];
int main(){
    int n,i,j,cur,cur_n,m,par,dep=0;
    for(i=0;i<100000;i++){
        tree[i].par=-1;
        tree[i].son=-1;
        tree[i].sib=-1;
    }
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d %d",&cur,&cur_n);
        par=cur;
        for(j=0;j<cur_n;j++){
            scanf("%d",&m);
            if(j){
                tree[cur].sib=m;
            }
            else{
                tree[cur].son=m;
            }
            cur=m;
            tree[cur].par=par;         
        }
    }
    /*
    for(i=0;i<n;i++){
        printf("%d   %d %d %d\n",i,tree[i].par,tree[i].sib,tree[i].son);
    }
    */

    for(i=0;i<n;i++){
        printf("node %d: parent = %d, ",i,tree[i].par);
        cur=i;
        while(1){
            if(tree[cur].par==-1) break;
            dep++;
            cur=tree[cur].par;
        }
        cur=i;
        printf("depth = %d, ",dep);
        dep=0;
        if(tree[cur].son==-1 && n!=1){
            printf("leaf, []\n");
        }
        else{
            if(tree[cur].par==-1){
                printf("root, ");
            }
            else{
                printf("internal node, ");
            }
            m=tree[cur].son;
            printf("[");
            while(n!=1){
                printf("%d",m);
                m=tree[m].sib;
                if(m==-1) break;
                printf(", ");
            }
            printf("]\n");
        }
    }
    return 0;
}



Measured memory_bytes: 3028
#include <bits/stdc++.h>
#define d(i) cout << #i << " = " << i << endl
#define int long long
using namespace std;

const int maxn = 2e3+10, maxl = 1e3+10;;

int n, l[maxn], cnt[maxl<<1], sum[maxl<<1], ans;

signed main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> l[i];
		cnt[l[i]]++;
	}
	for (int i = 1; i < maxl<<1; ++i)
		sum[i] = sum[i-1]+cnt[i];
	for (int i = 0; i < maxl; ++i) if (cnt[i]) {
		for (int j = 0; j <= i; ++j) if (cnt[j] > (i==j)) {
			if (i == j) {
				ans += (sum[i+j-1]-sum[i])*cnt[i]*(cnt[i]-1)/2;
				ans += cnt[i]*(cnt[i]-1)*(cnt[i]-2)/6;
			} else {
				ans += (sum[i+j-1]-sum[i])*cnt[i]*cnt[j];
				ans += cnt[i]*(cnt[i]-1)/2*cnt[j];
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
 
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());

        int[] w = new int[N];
        int sum = 0;
        for(int i = 0; i < N; i++) {
            w[i] = Integer.parseInt(sc.next());
            sum += w[i];
        }
        
        int s1 = 0;
        for(int i = 0; i < N; i++) {
            s1 += w[i];
            if(s1 >= sum/2) {
                if(s1 - (sum-s1) <= (sum-s1+w[i]) - (s1-w[i])) {
                    System.out.println(s1 - (sum-s1));
                }else {
                    System.out.println((sum-s1+w[i]) - (s1-w[i]));
                }
                break;
            }
        }
    }
}

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

char Map[100][100];
int H, W;
int dx[4] = { 0, 0, 1, -1 };
int dy[4] = { 1, -1, 0, 0 };

void solve(int x, int y, char c)
{
	Map[x][y] = -1;
	for (int i = 0; i < 4; i++)
	{
		int X = x + dx[i];
		int Y = y + dy[i];
		if (0 <= X && X < W && 0 <= Y && Y < H && Map[X][Y] == c)
		{
			solve(X, Y, c);
		}
	}
}


int main()
{
	while (cin >> H >> W, H + W)
	{
		int count = 0;
		for (int y = 0; y < H; y++)
		{
			for (int x = 0; x < W; x++)
			{
				cin >> Map[x][y];
			}
		}

		for (int y = 0; y < H; y++)
		{
			for (int x = 0; x < W; x++)
			{
				if (Map[x][y] == -1) continue;
				count++;
				solve(x, y, Map[x][y]);
			}
		}

		cout << count << endl;
	}

	return 0;
}

Measured memory_bytes: 1636
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
int main(){
    int a,b,now;
    in(a);in(b);now=b-a+1;
    for(int i=0;i<=2*a-2;i++)
    printf("%d ",i+now);
    return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int64_t x,y; cin>>x>>y;
	int64_t ans=1;
	while(x<=y)x*=2,++ans;
	cout<<ans-1<<"\n"s;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#define ll long long
const int MOD = 1e9+7;
using namespace std;


int main(){
	int n, k, q, temp;
	cin >> n >> k >> q;
	vector<int> a(q);
	vector<int> point(n+1);
	for (int i = 0; i < q; i++){
		cin >> a[i];
		point[a[i]]++;
	}
	for (int i = 1; i <= n; i++){
		if (point[i] <= q-k) cout << "No" << endl;
		else cout << "Yes" << endl;
	}
	return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int u=101,hd[101],tl[101],ct1,ct2;ll n;
int main(){
	scanf("%lld",&n);++n;
	while(n>1){
		if(n&1) hd[++ct1]=--u,n--;
		else tl[++ct2]=--u,n>>=1;
	}printf("%d\n",(ct1+ct2)<<1);
	for(int i=1;i<=ct1;i++) printf("%d ",hd[i]);
	for(int i=ct2;i>=1;i--) printf("%d ",tl[i]);
	for(int i=u;i<=100;i++) printf("%d ",i);
	return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    println!("{}", 2 * 24 - n);
}

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

#define SIZEOF(x) (sizeof x) / (sizeof x[0])


int main(){
    char S[4];
    cin>>S[0]>>S[1]>>S[2]>>S[3];
    int count1=0;
    int count2 = 0;
    char k=S[0];
    char l;
    bool frag = true;

    if(S[1] == k){

        if (S[2]==k){
            frag = false;

        }else{
            l = S[2];
            if (S[3] != l){
                frag = false;
            }
        }
    }else{
        l = S[1];
        if(S[2] != S[1] && S[2] != S[0]){
            frag = false;
        }else{
            if((S[3] != S[0] && S[3] != S[1]) || S[3] == S[2]){
                frag = false;
            }
        }
    }

    if(frag)printf("Yes");
    else printf("No");

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
ll a[1 << 14];
int main(){
	int n;
	while (cin >> n, n) {
		ll sum = 0;
		rep(i, n) {
			cin >> a[i]; sum += a[i];
		}
		ll ave = sum / n;
		sort(a, a + n);
		int out = upper_bound(a, a + n, ave) - a;
		cout << out << endl;
	}
	return 0;
}


Measured memory_bytes: 3224
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

// ?????°???????????¨
// ????????? 2n ??? (n=2^k)
// query ?????????????????????
struct SegmentTree {
	int n;
	vector<int> d;
	SegmentTree(int m, int x) {
		for (n = 1; n < m; n *= 2);
		d.assign(2 * n - 1, x);
	}
	void update(int k, int x) {
		k += n - 1;
		d[k] = x;
		while (k > 0) {
			k = (k - 1) / 2;
			d[k] = min(d[2 * k + 1], d[2 * k + 2]);
		}
	}
	int query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l)return INT_MAX;
		if (a <= l&&r <= b)return d[k];
		int xl = query(a, b, 2 * k + 1, l, (l + r) / 2);
		int xr = query(a, b, 2 * k + 2, (l + r) / 2, r);
		return min(xl, xr);
	}
	int query(int a, int b) {
		return query(a, b, 0, 0, n);
	}
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q; cin >> n >> q;
	SegmentTree st(n, INT_MAX);
	rep(i, 0, q) {
		int com, x, y; cin >> com >> x >> y;
		dump(com, x, y);
		if (com == 0) {
			st.update(x, y);
		}
		else {
			cout << st.query(x, y + 1) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3896
def main():
    N = int(input())
    A = list(map(int, input().split()))
    W = 0
    cnt = 0
    for i in range(len(A)):
        W = max(A[i],W)
        if W ==A[i]:
            cnt+=1

    print(cnt)




if __name__ == '__main__':
    main()


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

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

    int temp = 0;
    temp = N % 500;

    if (temp <= A){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 3644
#include <math.h>
#include <iostream>
#include<string>
#include <algorithm>
#include <bits/stdc++.h>
#include <vector>
#include <stdlib.h>
using namespace std;

int main()
{
long long N,k,l;
int a;
bool ver=false;
int ans=10000000;
cin >> N;
k=sqrt(N);
for(long long i=1;i<k+1;i++)
{
a=0;ver=false;
if(N%i==0)l=max(i,N/i);
while(l>0){l/=10;a++;ver=true;}
if(ver)ans=min(a,ans);
}
cout << ans;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>

using namespace std;
typedef long long int ll;

double n,m;

int main(){
    cin>>n>>m;
    cout<<ceil((n+m)/2)<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var x = sc.nextInt();
		var y = sc.nextInt();
		sc.close();

		var a = 4 * x - y;
		var b = y - 2 * x;
		if (a % 2 == 0 && b % 2 == 0 && a >= 0 && b >= 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 35804
def main():
    n = int(input())
    plus = []
    minus = []

    for _ in range(n):
        x, y = map(int, input().split())
        plus.append(x + y)
        minus.append(x - y)

    plus_max = max(plus)
    plus_min = min(plus)
    minus_max = max(minus)
    minus_min = min(minus)

    print(max(plus_max - plus_min, minus_max - minus_min))


if __name__ == "__main__":
    main()

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

int main(){
  string s; cin>>s;
  int a=0;
  for(int i=0;i<s.size();i++){
    if(i%2==0&&s.at(i)=='1') a++;
    if(i%2==1&&s.at(i)=='0') a++;
  }
  if(s.size()-a>a) cout<<a<<endl;
  else cout<<s.size()-a;
}

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

int N, Q;
vector<int> G[200000];
long C[200000];
long A[200000];

void rec(int from, int prev, long sum) {
  A[from] = sum + C[from];
  for (int to : G[from]) {
    if (to == prev) continue;
    rec(to, from, A[from]);
  }
}

int main() {
  cin >> N >> Q;
  for (int i = 1; i < N; ++i) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  
  for (int i = 0; i < Q; ++i) {
    int p, x;
    cin >> p >> x;
    --p;
    C[p] += x;
  }
  
  rec(0, -1, 0);
  
  for (int i = 0; i < N; ++i) {
    cout << A[i] << ' ';
  }
  cout << endl;
}


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

const int Mod=998244353;

int N,Cnt1,Cnt2,Ans;
char A[10005],B[10005];
int Fac[10005],Inv[10005];
int F[10005][10005];

int C(int n,int m){
	return 1llu*Fac[n]*Inv[m]%Mod*Inv[n-m]%Mod;
}

int main(){
	int i,j;
	scanf("%s%s",A+1,B+1);
	N=strlen(A+1);
	for(i=1;i<=N;i++)
		if(A[i]=='1')
			B[i]=='1'?Cnt1++:Cnt2++;
	Fac[0]=Inv[0]=Fac[1]=Inv[1]=1;
	for(i=2;i<=N;i++){
		Fac[i]=1llu*Fac[i-1]*i%Mod;
		Inv[i]=1llu*(Mod-Mod/i)*Inv[Mod%i]%Mod;
	}
	for(i=2;i<=N;i++)
		Inv[i]=1llu*Inv[i-1]*Inv[i]%Mod;
	F[0][0]=1;
	for(i=0;i<=Cnt1;i++)
		for(j=1;j<=Cnt2;j++)
			F[i][j]=(1llu*F[i][j-1]*(Cnt2-j+1)*(Cnt2-j+1)+(i?1llu*F[i-1][j]*i*j:0))%Mod;
	for(i=0;i<=Cnt1;i++)
		Ans=(Ans+1llu*F[i][Cnt2]*Fac[Cnt1-i]%Mod*Fac[Cnt1-i]%Mod*C(Cnt1,i)%Mod*C(Cnt1+Cnt2,i+Cnt2))%Mod;
	printf("%d\n",Ans);
	return 0;
}

Measured memory_bytes: 148224
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    int flag=0;
    string city="A";
    string s;
    while (cin>>s) {
        if (s=="#") {
            break;
        } else {
            for (int i=0;i<s.size();i++) {
                char c=s.at(i);
                if (city=="A"&&c=='0') {
                    city="X";
                } else if (city=="A"&&c=='1') {
                    city="Y";
                } else if (city=="X"&&c=='1') {
                    city="Z";
                } else if (city=="Y"&&c=='0') {
                    city="X";
                } else if (city=="Z"&&c=='0') {
                    city="W";
                } else if (city=="Z"&&c=='1') {
                    city="B";
                    flag=1;
                } else if (city=="W"&&c=='0') {
                    city="B";
                    flag=1;
                } else if (city=="W"&&c=='1') {
                    city="Y";
                } else if (city=="B"&&c=='0') {
                    city="Y";
                    flag=0;
                } else if (city=="B"&&c=='1') {
                    city="X";
                    flag=0;
                } else {
                    break;
                }
            }
            if (flag==1) {
                cout<<"Yes"<<endl;
            } else {
                cout<<"No"<<endl;
            }
            flag=0;
            city="A";
        }
    }
}


Measured memory_bytes: 3176
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define INPUT "/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.in"
#define OUTPUT "/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.out"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

typedef long long ll;
#define pb push_back
#define mp make_pair

void solve()
{
    int n, d, x;
    cin >> n >> d >> x;
    ll res = 0;
    for(int i = 0; i < n; i++)
    {
        int temp;
        cin >> temp;
        for(int k = 0; k * temp + 1 <= d; k++)
        {
            res++;
        }
    }
    cout << res + x;
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0);
    //freopen(INPUT, "r", stdin);freopen(OUTPUT, "w", stdout);
    int t = 1;
    //cin >> t;
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int INF = 1e9 + 7;

int pos[100005];
int par[100005];
vector<int> G[100005];
int dfn[100005], dep[100005], tot;

void dfs(int v, int cd)
{
	dep[v] = cd;
	dfn[v] = tot ++;
	rep(i, G[v].size())
	dfs(G[v][i], cd + 1);
}

int main()
{
	int n, l, q;
	scanf("%d", &n);
	rep(i, n) scanf("%d", &pos[i]);
	scanf("%d%d", &l, &q);
	int rp = 0;
	rep(i, n - 1) {
		while(rp < n && pos[rp] - pos[i] <= l) rp ++;
		par[i] = rp - 1;
	}
	rep(i, n - 1) G[par[i]].push_back(i);
	dfs(n - 1, 0);
	rep(i, q) {
		int a, b;
		scanf("%d%d", &a, &b);
		a --; b --;
		if(a > b) swap(a, b);
		int ans = dep[a] - dep[b];
		if(dfn[a] < dfn[b]) ans ++;
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 12544
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        n:usize,
        k:usize,
        a:[i128;n],
    }
    let mut pr = 1i128;
    let mut ans = vec![];
    // let n = 100000;
    // let k = 50000;
    // let mut a = vec![1000000000; n];
    for i in 0..n {
        if i < k {
            // pr *= a[i];
        } else {
            // let now = pr / a[i - k] * a[i];
            if a[i - k] < a[i] {
                ans.push(true);
            } else {
                ans.push(false);
            }
            // pr = now;
        }
        //
    }
    pub fn yn(ans: bool) {
        if ans {
            println!("Yes");
        } else {
            println!("No");
        }
    }
    for &x in ans.iter() {
        yn(x);
    }
}


Measured memory_bytes: 7568
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int r, D, x2000;
  cin >> r >> D >> x2000;
  vector<int> x(11);
  x.at(0) = x2000;
  for (int i = 1; i < 11; i++) {
  	x.at(i) = r * x.at(i - 1) - D;
    cout << x.at(i) << endl;
  }
  
}


Measured memory_bytes: 256