akhauriyash/Code-Regression huggingface dataset:
tmp = list(map(int, raw_input().split()))
tmp.sort()
A,B,C = tmp[0],tmp[1],tmp[2]
count = 0
if (B - A) % 2 == 0:
    t = (B-A)/2
    count += t
    count += C - B
    print(count)
else:
    count += 1
    A += 1
    C += 1
    count += (B-A)/2
    count += C -B
    print(count)

Measured memory_bytes: 2568
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	int a = 0, b = 0, c = 0,n[2];
	cin >> n[0] >> n[1];
	for (int i = 0; i < 2; i++) {
		int N = n[i];
		if (N==2)a++;
		else if (N == 4 || N == 6 || N == 9 || N == 11)b++;
		else c++;
	}
	if (a == 2 || b == 2 || c == 2)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


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

int main(){
  int a,b,c;
  cin >> a;
  b = a/10;
  c = a/100;
    	if(a == 000){
      cout << 0 << endl;
    }else{
      cout << c+(b - c*10 )+(a - b*10) << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int n, m, q;
vector<int> a, b, c, d;
int ans;
void dfs(vector<int> A){
  if(A.size() == n+1){
    int now = 0;
    for(int i = 0;  i < q; i++){
      if(A[b[i]] - A[a[i]] == c[i]) now += d[i];
    }
    ans = max(ans, now);
    return;
  }
  A.push_back(A.back());
  while(A.back() <= m){
    dfs(A);
    A.back()++;
  }
}
int main(){
  cin >> n >> m >> q;
  a = b = c = d = vector<int> (q);
  for(int i = 0; i < q; i++){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  dfs(vector<int> (1, 1));
  cout << ans << endl;
}

Measured memory_bytes: 3616
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//円周率
const double PI = 3.14159265358979323846;

int main() {
	ll N, Y; cin >> N >> Y;

	ll a = Y / 10000;
	for (int x = a; x >= 0; x--) {
		ll r1 = Y - 10000 * x;
		ll b = r1 / 5000;
		for (int y = b; y >= 0; y--) {
			ll r2 = r1 - 5000 * y;
			if (r2 % 1000 == 0 && x+ y + r2 / 1000 == N) {
				cout << x << " " << y << " " << r2 / 1000 << endl;
				return 0;
			}
		}
	}

	cout << -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 256
package main

import (
	. "fmt"
	"math"
)

// github.com/EndlessCheng/codeforces-go
func main() {
	n:=0
	Scan(&n)
	m := int(math.Sqrt(float64(n)) + 1e-8)
	s := -m * (m + 1) * (2*m + 1) / 6
	for i := 1; i <= m; i++ {
		s += i * (i + n/i) * (n/i + 1 - i)
	}
	Print(s)
}


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

int main(){
  int h,w;
  string c = "Yes";
  cin >> h >> w;
  char image[h][w];
  int movex[4]={1,-1,0,0};
  int movey[4]={0,0,1,-1};
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> image[i][j];
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(image[i][j]=='#'){
        bool isblack = 0;
        for(int k=0;k<4;k++){
            if(h<=i+movex[k]||i+movex[k]<0||j+movey[k]<0||w<=j+movey[k])
              continue;
            else if(image[i+movex[k]][j+movey[k]]=='#'){
              isblack = 1;
            }
        }
        if(!isblack){
          c = "No";
        }
      }
    }
  }
  cout << c << endl;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/abc118/tasks/abc118_c

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))

//ユークリッドの互除法
int gcd(int a, int b)
{
    int c;

    if (a < b)
    {
        a += b;
        b = a - b;
        a -= b;
    }

    while (b != 0)
    {
        c = a % b;
        a = b;
        b = c;
    }

    return a;
}

int main()
{
    int n, buf, ans = 1000000001;
    scanf("%d", &n);
    int hp[n];

    // 初期化
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &buf);
        hp[i] = buf;
    }

    // コンビネーションで剰余を取る
    ans = gcd(hp[0], hp[1]);
    for (int i = 2; i < n - 1; i++)
    {
        ans = gcd(ans, hp[i]);
    }
    printf("%d", ans);

    return 0;
}


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

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define YN(a, b, c) ((c)? a : b)
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) (i64)(a / (f64)__gcd(a, b) * b) /* 最小公倍数 */

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

void Main() {
    i32 N, K;
    cin >> N >> K;
    Vec<i32> M(N + 1, 0);
    for (i32 i = 0; i < N; i++) {
        i32 A;
        cin >> A;
        M[A]++;
    }
    sort(ALL(M));
    i32 total = 0;
    for (i32 i = 0; i <= N; i++) {
        if (M[i] != 0) total++;
    }
    i32 index = 0;
    while (M[index] == 0) index++;
    i64 sum = 0;
    while (total > K) {
        sum += M[index];
        total--;
        index++;
    }
    cout << sum << endl;

}


Measured memory_bytes: 3992
#include <bits/stdc++.h>
#define rep( i, n ) for (long long i = 0; i < ( long long )(n); i++)

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

int main(){
 ll x;
 cin>>x;

 ll a = x/500;
 ll b = (x-a*500)/5;
 cout<<a*1000+b*5;
} 

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

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

  for (int i = 0; i < 1000; i++) {
    int tmp;
    tmp = N + i;
    int xxx, xx, x;
    x = tmp % 10;
    tmp = tmp / 10;
    xx = tmp % 10;
    tmp = tmp / 10;
    xxx = tmp;
    if (x == xx && xx == xxx) {
      cout << N + i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("01B0");
            //00
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("0BB1");
            //1
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        var CharList = new List<char>();

        foreach (char EachStr in InputList[0]) {
            if (EachStr == 'B') {
                if (CharList.Count > 0) CharList.RemoveAt(CharList.Count - 1);
            }
            else CharList.Add(EachStr);
        }
        CharList.ForEach(X => Console.Write(X));
        Console.WriteLine();
    }
}


Measured memory_bytes: 2904
package main

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

var r_sc = bufio.NewScanner(os.Stdin)

func nextRow() string {
	r_sc.Scan()
	return r_sc.Text()
}

func main() {
	var h, w int
	fmt.Scanf("%d %d", &h, &w)
	grid := make([][]string, h)
	for i := 0; i < h; i++ {
		slice := strings.Split(nextRow(), "")
		grid[i] = slice
	}
	ans := true
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if grid[i][j] == "#" {
				cnt := 0
				if i > 0 {
					if grid[i - 1][j] == "#" {
						cnt += 1
					}
				}
				if j < (w - 1) {
					if grid[i][j + 1] == "#" {
						cnt += 1
					}
				}
				if i < (h - 1) {
					if grid[i + 1][j] == "#" {
						cnt += 1
					}
				}
				if j > 0 {
					if grid[i][j - 1] == "#" {
						cnt += 1
					}
				}
				if cnt == 0 {
					ans = false
				}
			}
		}
	}
	if ans {
		fmt.Println("Yes")

	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1896
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> ti;
 
#define REP(a,b,c) for(ll a=b;a<(c);a++)
#define PER(a,b,c) for(ll a=b;a>=(c);a--)
 
inline ll ii(){ ll x; cin >> x; return x; }
inline string is(){ string x; cin >> x; return x; }
inline ld id(){ ld x; cin >> x; return x; }
inline void oi(ll x){ cout << x; }
inline void od(ld x){ cout << fixed << setprecision(10) << x; }
inline void os(string x){ cout << x; }
inline void oe(){ cout << endl; }
inline void oie(ll x){ oi(x); oe(); }
inline void ode(ld x){ od(x); oe(); }
inline void ose(string x){ os(x); oe(); }
inline void maxin(ll &a, ll b){ a=max(a,b); }
inline void minin(ll &a, ll b){ a=min(a,b); }

int main(){
    ll i=ii();
    if(i==0){
        oie(1);
    }else{
        oie(0);
    }
    return 0;
}


Measured memory_bytes: 3624
n = int(input())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))

diff = []
total1 = 0
total2 = 0
total3 = 0

for i in range(n):
    diff.append(abs(X[i] - Y[i]))
    total1 += diff[i]
    total2 += diff[i] ** 2
    total3 += diff[i] ** 3

print("{0:.6f}" . format(total1))
print("{0:.6f}" . format(total2 ** 0.5))
print("{0:.6f}" . format(total3 ** (1 / 3)))
print("{0:.6f}" . format(max(diff)))


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

using namespace std;
typedef long long ll;
typedef pair< int , int > P;
typedef tuple<int, int, int> T;
    
int main(){
    int x,y;
    cin>>x>>y;
    for(int i=0;i<=x;i++){
        if(y==(i*2+(x-i)*4)){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
}

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

int main(){ 
	int array[9][9];
	for(int num1=1;num1<=9;num1++){
		for(int num2=1;num2<=9;num2++){

	cout << num1 << 'x' << num2 << '=' << num1*num2 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1116
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n, v) rep(i, n) cin >> v[i]

using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1, 0, -1, 0}, y_pos[4] = {0, 1, 0, -1};
int ctoi(char c)
{
	if (c >= '0' && c <= '9')
	{
		return c - '0';
	}
	return 0;
}

char upper(char c)
{
	return c - 0x20;
}

char lower(char c)
{
	return c + 0x20;
}

void unique_vector(vector<int> &v)
{
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val)
{
	std::fill((T *)array, (T *)(array + N), val);
}

//ユークリッドの互除法
//最大公約数
ll gcd(ll x, ll y)
{
	if (y == 0)
		return x;
	return gcd(y, x % y);
}

//最小公倍数
ll lcm(ll x, ll y)
{
	ll g = gcd(x, y);
	return x / g * y;
}

ll myPow(ll x, ll n, ll m)
{
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

//k!
ll facctorialMethod(ll k)
{
	ll sum = 1;
	for (ll i = 1; i <= k; ++i)
	{
		sum *= i;
		sum %= MOD;
	}
	return sum;
}

//nCr
ll permutationMethod(ll n, ll r)
{
	ll n_sum, r_sum;
	r = n - r;
	n_sum = facctorialMethod(n);
	r_sum = facctorialMethod(r);
	return n_sum / r_sum;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll pow_kai(int a, int n)
{ //aのn乗を計算します。
	ll x = 1;
	while (n > 0)
	{ //全てのbitが捨てられるまで。
		if (n & 1)
		{ //1番右のbitが1のとき。
			x = (x * a) % MOD;
		}
		a = (a * a) % MOD;
		n >>= 1; //bit全体を右に1つシフトして一番右を捨てる。
	}
	return x % MOD;
}

ll sum(ll a, ll d, ll n, ll mod)
{
	mod *= 2;
	ll ret = (2 * a + d * (n - 1)) % mod;
	ret = ret * n % mod;
	return ret / 2;
}

int main()
{
	ll n, k;
	cin >> n >> k;
	ll ans = 0;
	for (int i = k; i <= n; i++){
		ll a = sum(n - i + 1, 1, i, MOD);
		ll b = sum(0, 1, i, MOD);
		ans += a-b+1;
		if (ans < 0){
			ans += MOD;
		}
		ans %= MOD;
	}
	ans += 1;
	cout << ans%MOD << endl;
}


Measured memory_bytes: 3640
from collections import deque
N = int(input())
A = sorted(map(int, input().split()), reverse=True)

ans = A[0]
q = deque((A[1], A[1]))
for i in range(2, N):
    ans += q.popleft()
    q.append(A[i])
    q.append(A[i])
print(ans)

Measured memory_bytes: 33128
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define gc getchar
#define int long long
const int N=1e5+5;
const int mod=1e9+7;
int n,ans,f[N][14];
char a[N];
/*char buf[1<<21],*p1=buf,*p2=buf;
inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}*/
inline int read()
{
    int ret=0,f=0;char c=gc();
    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
    if(f)return -ret;return ret;
}
signed main()
{
	scanf("%s",a+1);
	n=strlen(a+1);
	if(a[1]=='?')for(int i=0;i<10;i++)f[1][i]=1;
	else f[1][a[1]-'0']=1;
	for(int i=1;i<n;i++)
	{
		for(int j=0;j<13;j++)
		{
			if(a[i+1]=='?')
			{
				for(int k=0;k<10;k++)
				{
					int x=j*10+k;
					x=x%13;
					f[i+1][x]+=f[i][j];
					f[i+1][x]%=mod;
				}
			}
			else{
				int x=a[i+1]-'0';
				x=j*10+x;
				x%=13;
				f[i+1][x]+=f[i][j];
				f[i+1][x]%=mod;
			}
		}
	}
	cout<<f[n][5];
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
#include <numeric>
#include <iomanip>
using namespace std;
    
#define int long long
#define pb push_back
#define ub upper_bound
#define lb upper_bound
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
    
using ll = long long;
const ll INF = LLONG_MAX - 100;
ll mod = 1e9 + 7;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;
    
class fact {
public:
    int fmod = 1e9+7;
    vector<int> fac, inv;
    fact (int n, int Mod = 1e9+7) {
        fmod = Mod;
        fac = vector<int>(n,0);
        inv = vector<int>(n,0);
        fac[0] = 1; for (int i = 1; i < n; i++) fac[i] = fac[i-1] * i % fmod;
        for (int i = 0;i < n;i++) inv[i] = fact::POW(fac[i],fmod-2);
    }
    ll nCr(ll n, ll r) {return (fac[n] * inv[r] % fmod) * inv[n-r] % fmod;}
    ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%fmod;}a = a * a%fmod; b >>= 1;}return c;}
};
    
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
void EMP(int x) {cout<<"!!!"<<x<<"!!!"<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%mod;}a = a * a%mod; b >>= 1;}return c;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}
bool isSqrt(ll a) {return pow(sqrt(a),2) == a ? 1 : 0;}
void YesNo(bool a) {if (a) cout << "Yes"; else cout << "No"; cout << endl;}
void yesno(bool a) {if (a) cout << "yes"; else cout << "no"; cout << endl;}
void YESNO(bool a) {if (a) cout << "YES"; else cout << "NO"; cout << endl;}
int poorpow(int b, int a) {
    int tmp = 1;
    REP (i,a) {
        tmp *= b;
    }
    return tmp;
}


bool solve() {
    int a,b,c,d; cin >> a >> b >> c >> d;
    cout << max(a*b,c*d) << endl;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
cin>>N>>M;
  int i,ar[M];
  for(i=0;i<M;i++)
  {
    cin>>ar[i];}
  int sum=0;
  for(i=0;i<M;i++){
    sum=sum+ar[i];}
  int a;
  a=N-sum;
  if(a>=0)
  {cout<<a;}
  else
  {cout<<"-1";}
  return 0;
}


Measured memory_bytes: 3616
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const ll MOD = 1000000007;
// const int INF = 2000000000;

int N;
vector<string> S;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  S.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> S[i];
  }

  int ans = 0;
  int ab_num = 0;
  int a_num = 0;
  int b_num = 0;

  for (int i = 0; i < N; i++) {
    string s = S[i];
    int last = s.size() - 1;
    if (s[0] == 'B' && s[last] == 'A') {
      ab_num++;
    } else if (s[0] == 'B') {
      b_num++;
    } else if (s[last] == 'A') {
      a_num++;
    }

    for (int j = 1; j <= last; j++) {
      if (s[j - 1] == 'A' && s[j] == 'B') {
        ans++;
      }
    }
  }

  if (ab_num > 0) {
    ans += (ab_num - 1);
  }
  if (ab_num > 0 && (a_num > 0 || b_num > 0)) {
    a_num++;
    b_num++;
  }

  ans += min(a_num, b_num);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 768
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::f64::consts::PI;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}


fn main() {
    let line: Vec<usize> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = line[0];
    let k = line[1];
    if n >= 10 {
        println!("{}", k);
    } else {
        println!("{}", k + 100 * (10 - n));
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

const int MAX = 210000;
const int MOD = 998244353;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

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

long long modinv(long long a, long long mod) {
    long long b = mod, u = 1, v = 0;
    while (b) {
        long long t = a/b;
        a -= t*b; swap(a, b);
        u -= t*v; swap(u, v);
    }
    u %= mod;
    if (u < 0) u += mod;
    return u;
}


int main() {
    COMinit();
    int K, N;
    while (cin >> K >> N) {
        for (int query = 2; query <= K*2; ++query) {
            long long res = 0;
            int Q = query;
            if (query > K + 1) Q = (K+1)*2 - query;
            int a = Q/2;
            for (int i = 0; i <= a; ++i) {
                long long tmp = COM(a, i) * COM(K - a + N - i - 1, N - i) % MOD;
                res = (res + tmp) % MOD;
            }
            cout << res << endl;
        }
    }
}































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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define whole(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define bit(n) (1LL<<(n))
// functions
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;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << p.first << " " << p.second; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20);}
} fast_io_;


int main(int argc, char const* argv[])
{
  int a, b; cin >> a >> b;
  string A = ""; rep(i, b)A += char(a + '0');
  string B = ""; rep(i, a)B += char(b + '0');
  cout << min(A, B) << endl;
  return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Moon0603
 */
 
#include <bits/stdc++.h>
 
using namespace std;
 
class BTwoArrays
{
public:
    void solve(istream& in, ostream& out)
    {
        int n;
        in >> n;
        vector<int> a(n), b(n);
        for (int i = 0; i < n; ++i)
        {
            in >> a[i];
        }
        for (int i = 0; i < n; ++i)
        {
            in >> b[i];
        }
        long long cnta = 0, cntb = 0;
        for (int i = 0; i < n; ++i)
        {
            if (a[i] < b[i])
            {
                if ((b[i] - a[i]) & 1)
                {
                    cnta += (b[i] - a[i] + 1) / 2;
                    cntb += 1;
                }
                else
                {
                    cnta += (b[i] - a[i]) / 2;
                }
            }
            else
            {
                cntb += a[i] - b[i];
            }
        }

        out << (cntb>cnta ? "No" : "Yes") << '\n';
    }
};
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    BTwoArrays solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}

Measured memory_bytes: 384
def validate(paths, start):
    """
    有効な経路をDFS(深さ優先探索)
    経路をsetで返す
    """

    valid_paths = {start}
    stack = [start]

    while stack:
        v = stack.pop()
        if v not in paths:
            continue
        for w in paths[v]:
            if w in valid_paths:
                continue
            valid_paths.add(w)
            stack.append(w)
    return valid_paths


def bellman_ford(edges, num_v, start, end):
    """
    有向グラフ(負閉路有り)の最短距離

    num_v: 頂点の数(number_of_vertex)
    edges: 頂点(from, to, cost)
    """

    # グラフの初期化
    INF = 10**18
    dist = [INF] * num_v
    # 始点は0にする
    dist[start] = 0

    # 辺の緩和
    # 負の閉路が無ければ、num_v-1回までで収束する
    for _ in range(num_v):
        updated = False
        for f, t, c in edges:
            if dist[f] == INF:
                continue

            # コストが以前のものより小さければ更新
            cost = dist[f] + c
            if cost < dist[t]:
                dist[t] = cost
                updated = True
        if not updated:
            break
    else:
        # num_v回の時に更新があるなら負閉路が存在する
        return -1

    return max(-dist[end], 0)


def main():
    from collections import defaultdict

    n, m, p, *tmp = map(int, open(0).read().split())

    paths_rev = defaultdict(list)
    edges = []
    for a, b, c in zip(*[iter(tmp)]*3):
        # 頂点nからの経路をdfsするため、辺の向きを逆にする
        paths_rev[b-1].append(a-1)
        edges.append((a-1, b-1, p-c))

    valid_paths = validate(paths_rev, n-1)
    edges = [
        (a, b, c)
        for a, b, c in edges
        if a in valid_paths and b in valid_paths
    ]
    res = bellman_ford(edges, n, 0, n-1)
    print(res)

if __name__ == '__main__':
    main()


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

int a[100];
bool dp[100001][2];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

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

    dp[0][0] = false;
    dp[0][1] = true;
    for (int i=1; i<=k; i++) {
        dp[i][0] = false;
        dp[i][1] = true;
        for (int j=0; j<n; j++)
            if (a[j] <= i) {
                dp[i][0] |= dp[i-a[j]][1];
                dp[i][1] &= dp[i-a[j]][0];
            }
    }

    cout << (dp[k][0] ? "First" : "Second") << "\n";

    return 0;
}


Measured memory_bytes: 512
n=int(input())
h=list(map(int,input().split()))
dp=[0,abs(h[1]-h[0])]+[99999999]*102000
for i in range(2,n):
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[n-1])

Measured memory_bytes: 13928
#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int m=1,i,lasti=-1;
    while(n){
        i=n%10;
        if(i==lasti) m++;
        else{
           if(m!=3) m=1;
        }
        lasti=i;
        n/=10;
    }
    if(m<3) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P = pair<int,int>;

int main(){
    int n; cin >> n;
    // vector<ll> H(n);
    // rep(i,n) cin >> n;
    string ans = "Yes";
    ll a; cin >> a;
    for(int i=1; i<n; i++){
        ll memo;
        cin >> memo;
        if(a>memo){
            if(a-1>memo)
                ans = "No";
        }
        if(a<memo)
            a = memo;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
# Reference: https://ikatakos.com/pot/programming_algorithm/data_structure/binary_indexed_tree
class BinaryIndexedTree:
    # a = [0] * n
    def __init__(self, n):
        self.size = n
        self.data = [0] * (n+1)

    # return sum(a[0:i])
    def cumulative_sum(self, i):
        ans = 0
        while i > 0:
            ans += self.data[i]
            i -= i & -i
        return ans

    # a[i] += x
    def add(self, i, x):
        i += 1
        while i <= self.size:
            self.data[i] += x
            i += i & -i

from sys import stdin
input = stdin.buffer.readline

def main():
    n, q = map(int, input().split())
    c = list(map(int, input().split()))

    lis = [[] for _ in range(n + 1)]
    for i, ci in enumerate(c):
        lis[ci].append(i)

    BIT = BinaryIndexedTree(n)
    for i in range(n+1):
        if len(lis[i]) > 0:
            BIT.add(lis[i].pop(-1), 1)

    query = [0] * q
    ans = [-1] * q
    for lap in range(q):
        l, r = map(int, input().split())
        query[lap] = (l-1, r, lap)
    
    query.sort(reverse=True, key=lambda x: x[1])

    now_r = n
    for ind, (l, r, lap) in enumerate(query):
        while now_r > r:
            now_r -= 1
            BIT.add(now_r, -1) # delete
            if len(lis[c[now_r]]) > 0:
                BIT.add(lis[c[now_r]].pop(-1), 1) # add
        ans[lap] = BIT.cumulative_sum(r) - BIT.cumulative_sum(l)
    
    for i in ans:
        print(i)

main()


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))
#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define all(x) (x).begin(),(x).end()
#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))
#define _end '\n'
#define Out(x) cout<<(x)<<_end
template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

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

    int n, m;

    cin >> n;

    map<string, int> red, blue;
    string s;
    int ans = 0;

    int i;

    rep(i, n) {
        cin >> s;

        red[s]++;
    }

    cin >> m;

    rep(i, m) {
        cin >> s;

        blue[s]++;
    }

    repit(red) {
        if (blue.find(it->first) == blue.end()) Max(ans, it->second);
        else Max(ans, it->second - blue[it->first]);
    }

    Out(ans);

    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = input().split()
for s in range(len(a)-1):
        print(a[s],end=' ')
print(a[-1])
for i in range(1,n):
    x = int(a[i])
    j = i-1
    while j >=0 and int(a[j])>x:
        t = int(a[j])
        r = int(a[j+1])
        a[j+1] = t
        a[j] = r
        j -=1
    s = 0
    for s in range(len(a)-1):
        print(int(a[s]),end=' ')
    print(int(a[-1]))


Measured memory_bytes: 5984
#include<stdio.h>

#define MAX 100

int G[MAX+1][MAX+1];

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            G[i][j] = 0;
        }
    }
    for (int i = 0; i < n; ++i) {
        int u,k;
        scanf("%d %d", &u, &k);
        for (int j = 0; j < k; ++j) {
            int t;
            scanf("%d", &t);
            G[u][t] = 1;
        }
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            if (j > 1) printf(" ");
            printf("%d",G[i][j]);
        }
        printf("\n");
    }
}

Measured memory_bytes: 2720
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
   
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n=int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
    
a=factorization(n)
le=len(a)
cnt=0
b=0
for i in range(le):
	b=1
	while a[i][1]>=b: 
		a[i][1]-=b
		b+=1
		cnt+=1

if n==1:
	print(0)
else:
	print(cnt)

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

int main(){
  string N;
  cin >> N;
  
  int ans = 0;
  for (int i=0 ; i<3 ; i++){
    if (N.at(i) == '7'){
      ans = 1;
      break;
    }
  }
  
  if (ans == 1)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<58;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,m;
vvi g;
vvi used;
vi a;

void dfs(int v,int t){
	used[v][t]=1;
	t^=1;
	for(int i=0;i<g[v].size();i++){
		int u=g[v][i];
		if(!used[u][t]) dfs(u,t);
	}
}

pll DFS(int v){
	a[v]=1;
	int res=1,num=(used[v][0]?1:0);
	for(int i=0;i<g[v].size();i++){
		int u=g[v][i];
		if(!a[u]){
			pll p=DFS(u);
			res+=p.first;
			num+=p.second;
		}
	}
	return {res,num};
}

int main(){
	cin>>n>>m;
	g=vvi(n);
	used=vvi(n,vi(2));
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(0,0);
	a=vi(n);
	ll res=0;
	for(int i=0;i<n;i++) if(!a[i]){
		pll p=DFS(i);
		ll F=p.first,S=p.second;
		if(used[i][0]&&used[i][1]) res+=F*(F-1)/2;
		else res+=S*(F-S);
	}
	cout<<res-m<<endl;
//	for(int i=0;i<n;i++) cout<<used[i][0]<<' '<<used[i][1]<<endl;
}

Measured memory_bytes: 12672
#include<stdio.h>
int main(){
int h,w,x,y,r;
scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
if((0 <= x-r && x+r<=w )&&(0<=y-r && y+r <=h)) printf("Yes\n");
else printf("No\n");
return 0;
}

Measured memory_bytes: 1812
#include<iostream>
#include<string>

using namespace std;

int main(){
    string dance;
    int flag=0;
    cin >> dance;
    for(int i=0; i < dance.length(); i++)
    {
      if(dance[i] == 'R' or dance[i] == 'U' or dance[i] == 'L' or dance[i] == 'D')
        {
            if(i % 2 == 1 and dance[i] == 'R')                                 
             {
               flag = 1;
               break;
             }
            else if(i % 2 == 0 and dance[i] == 'L' )
            {
              flag = 1;
              break;
            }
            else
            {   
                continue;
            }

        }
    }
  

   if(flag == 0)
    {
      cout << "Yes" << endl;
    }
    else
    {
      cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int a, b;
    cin >> a >> b;
    cout << max(0, a - 2 * b) << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int k = scanner.nextInt();
		int s = scanner.nextInt();
		int ans = 0;

		for (int i = 0; i <= k; i++) {
			for (int j = 0; j <= k; j++) {
				if(s-(i+j)<=k && s-(i+j) >=0){
					ans++;
				}
			}
		}
		System.out.println(ans);
 	}
}

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


int main() {
int n;
while(cin>>n){
	if(n==0) break;

n=1000-n;
int ans=0;
ans=ans+n/500;
n=n%500;

ans=ans+n/100;
n=n%100;

ans=ans+n/50;
n=n%50;

ans=ans+n/10;
n=n%10;

ans=ans+n/5;
n=n%5;
ans=ans+n;
cout<<ans<<endl;
}
	return 0;
}

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

using namespace std;

void makec(vector<int>& c, int& x, int& y, int z) {//zはどこまで


    if (y == z) {
        char s;
        for (int i = 0; i < z; i++) {
            s = c[i] + 96;
            cout << s;
        }
        cout << endl;
    } else {
        int temp = x;
        int temp2 = 1;

        while (temp2 < temp+1)
        {
            c.push_back(temp2);
            y++;
            temp2++;
            makec(c, x, y, z);
            c.pop_back();
            y--;
        }

        c.push_back(temp + 1);
        x++;
        y++;
        makec(c, x, y, z);
        c.pop_back();
        x--;
        y--;

        
    }
}


int main() {//97がa
    int n;
    cin >> n;

    vector<int>c;
    int x = 0;//使用可能文字
    int y = 0;//桁数
    
    makec(c, x, y, n);




    return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if (a+b >= c) {
    cout << "Yes" << endl;
  } else {


  cout << "No" << endl;
}
}


Measured memory_bytes: 256
let n, k = Scanf.scanf " %d %d" @@ fun a b -> a, b
let memo = Array.make_matrix 3000 3000 @@ -1
let rec comb n k =
  if memo.(n).(k) > -1 then memo.(n).(k)
  else
    (memo.(n).(k) <- if n < k then 0 else if n = k then 1 else if k = 0 then 1
      else (comb (n - 1) (k - 1) + comb (n - 1) k) mod 1_000_000_007;
    memo.(n).(k))
let _ =
  for i = 1 to k do
    Printf.printf "%d\n" @@ comb (k - 1) (i - 1) * comb (n - k + 1) i mod 1_000_000_007 done

Measured memory_bytes: 73592
#include <iostream>
using namespace std;
int func(int n)
{
    int sum=0;
    while(n>0){
        sum+=n%10;
        n /= 10;
    }
    return sum;
}
int main()
{
    int n,a,b;
    int sum=0;
    cin>>n>>a>>b;
    int total=0;
    for(int i=1;i<=n;i++){
        int sum=func(i);
        if(a<=sum&&sum<=b)total+=i;
    }
    cout<<total<<'\n';
    return 0;
}

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

#define int long long
int N, A;
int D[51][2501];

signed main() {
  cin >> N >> A;
  D[0][0] = 1;
  for (int i=0; i<N; i++) {
    int x;
    cin >> x;
    for (int j=i; j>=0; j--) {
      for (int k=0; k<=50*(j+1); k++) {
        D[j+1][k+x] += D[j][k];
      }
    }
  }
  int c = 0;
  for (int i=1; i<=N; i++) {
    c += D[i][i*A];
  }
  cout << c << "\n";
  return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <set>

int main(int argc, char *argv[]) {
  int n;
  std::cin >> n;
  std::set<int> s;
  for (int i = 0; i < n; ++i) {
    int n;
    std::cin >> n;
    s.insert(n);
  }
  std::cout << ((int)s.size() == n ? "YES" : "NO") << std::endl;
}


Measured memory_bytes: 9600
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        String s = sc.next();
        String t = sc.next();

        for (int i = 0; i < n; i++) {
            System.out.printf("%s%s",s.charAt(i), t.charAt(i));
        }
        System.out.printf("\n");
    }
}


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

using namespace std;

int main() {
    int r;
    cin >> r;
    if (r < 1200) {
        cout << "ABC";
    }
    else if (r < 2800) {
        cout << "ARC";
    }
    else {
        cout << "AGC";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)
#define Graph vector<vecctor<ll>>
#define pairs vector<pair<ll,ll>>
#define pb push_back



using namespace std;
using ll = long long;
const ll INF = 1e18;
const double PI = acos(-1);

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



int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    ll n,ans = 0;
    string s;
    cin >> n >> s;
    cerr << s << endl;
    vector<vector<ll>> num(10);
    rep(i,n){
        int index = s[i]-'0';
        num[index].pb(i);
    }

    rep(i,10){
        if(num[i].size() <= 1)continue;
        sort(num[i].begin(),num[i].end());
      
    }
    rep(i,10){
        rep(j,10){
            rep(k,10){
                if(num[i].empty() || num[j].empty() || num[k].empty())continue;
                if(num[i][0] < num[k][num[k].size()-1] && num[i][0] < num[j][num[j].size()-1] && num[k][num[k].size()-1] > num[j][0]){
                    for(ll x : num[j]){
                        if(x < num[k][num[k].size()-1] && x > num[i][0]){
                            ans++;
                            break;
                        }
                    }
                }
            }
        }
    }

    cout << ans << endl;

    
    





    return 0;
}



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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const long double EPS = 0.0000000001;

int n;
int main(){
	cin >> n;
	vector<int>p(n);
	for(int i = 0; i < n; i++)cin >> p[i];
	int ans = 0;
	int tempmin = INTMAX;
	for(int i = 0; i < n; i++){
		if(tempmin > p[i]){
			tempmin = p[i];
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i, n) for(i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define PI 3.14159265359

int main(){
  ll A, B, N, i, p;
  cin >> A >> B >> N;
  
  if(N < B){
    p = N;
  } else {
    p = B - 1;
  }

  cout << A*p/B - A*(p/B) << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define LL long long
#define Rg register
#define RI register int
#define RC register char
#define ed puts("") 
#define Pair pair<LL,LL>
#define space putchar(' ')
using namespace std;   
template <typename tp> inline void read(tp & x) 
{	
    x=0;
    RI f=1; 
    RC c=getchar();  
    while(c<'0' || c>'9'){if(c=='-') f=-1;c=getchar();} 
    while(c>='0' && c<='9'){x=(x<<1)+(x<<3)+(c^48);c=getchar();} 
 	x*=f;
} 	
    	
template <typename Tp> inline void print(Tp x)  
{							  	
    if(x<0) x=-x,putchar('-');  
    if(x>9) print(x/10);      
    putchar(x%10+'0');		  	
}

#define int long long
const int maxn=2e6+10;
int n;
int tot; 
int a[maxn];
int b[maxn];
int c[maxn]; 
int L[maxn];
int R[maxn]; 
bool vis[maxn];
int ans;
priority_queue<Pair> q;

inline bool check()
{
	for(RI i=1;i<=n;++i)
		if(a[i]!=b[i])
			return false;
	return true;
}

signed main()
{
	read(n);
	for(RI i=1;i<=n;++i)
		read(a[i]);
	for(RI i=1;i<=n;++i)
		read(b[i]),q.push(make_pair(b[i],i)),L[i]=i-1,R[i]=i+1;
	for(RI i=1;i<=n;++i)
	{
		if(a[i]!=b[i])
			break;
		if(i==n)
		{
			print(0);
			return 0; 
		}
	}
		
	L[1]=n;
	R[n]=1;
	int ans=0;	
	
	while(q.size())
	{
		int num=q.top().second;
		q.pop(); 
		
		if(b[num]==a[num])
			continue;
		if(b[num]<a[num])
		{
			print(-1);
			return 0;
		}
		if(b[num]>=a[num] && (b[num]-a[num])%(b[L[num]]+b[R[num]])==0)
		{
			int times=(b[num]-a[num])/(b[L[num]]+b[R[num]]);
			ans+=times;
			b[num]=a[num];
		}
		else
		{
			int maxx=max(b[L[num]],b[R[num]]);
			int times=(b[num]-maxx)/(b[L[num]]+b[R[num]]);
			if((b[num]-maxx)%(b[L[num]]+b[R[num]])!=0)
				times++;
			ans+=times;
			b[num]-=(b[L[num]]+b[R[num]])*times;
		}
		if(b[num]<a[num])
		{
			print(-1);
			return 0;
		}
		q.push(make_pair(b[num],num));
	}
	for(RI i=1;i<=n;++i)
	{
		if(a[i]!=b[i])
		{
			print(-1);
			return 0;
		}
	}
	print(ans);	
	return 0;
}

Measured memory_bytes: 20848