akhauriyash/Code-Regression huggingface dataset:
n = int(input())

ans, ba, a, b = 0, 0, 0, 0

for i in range(n):
    s = input()
    ans += s.count('AB')
    if s[0] == 'B' and s[-1] == 'A':
        ba += 1
    elif s[-1] == 'A':
        a += 1
    elif s[0] == 'B':
        b += 1

if a > 0 and b > 0 and ba > 0:
    ans += ba + 1 + min(a-1, b-1)
elif a == 0 and b == 0:
    ans += max(ba-1, 0)
elif (a > 0 or b > 0) and ba > 0:
    ans += ba
elif ba == 0:
    ans += min(a, b)

print(ans)


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

using namespace std;
vector<int> op;
vector<string> dp;
int m;
int val(int num){
	int res=0;
	if(num==1) res=2;
	if(num==2) res=5;
	if(num==3) res=5;
	if(num==4) res=4;
	if(num==5) res=5;
	if(num==6) res=6;
	if(num==7) res=3;
	if(num==8) res=7;
	if(num==9) res=6;
	return res;
}
string junt(int c){
	if(c==0) return "";
	if(dp[c]!="") return dp[c];
	string s="",aux;
	for(int i=0;i<m;i++){
		aux="";
		if(c>=val(op[i])) {
			aux=junt(c-val(op[i]));
			if(aux!="$") aux+=(char)(48+op[i]);
			else aux="";
			if(s.size()==aux.size()) s=max(s,aux);
			if(aux.size()>s.size()) s=aux;
		}
	}
	if(s=="") s="$";
	return dp[c]=s;
}

int main(){
	int n,a;
	cin>>n>>m;
	for(int i=0;i<100000;i++) dp.push_back("");
	for(int i=0;i<m;i++){
		cin>>a;
		op.push_back(a);
	}
	cout<<junt(n)<<endl;
	return 0;
}

Measured memory_bytes: 44660
#include "bits/stdc++.h"
using namespace std; 
#define LIM 1000003

#define M 1000000007
#define inf 99999999999999999LL	//long long inf
typedef long long ll;

#define sc(x) scanf("%d",&x);
#define sc2(x,y) scanf("%d%d",&x,&y);
#define sc3(x,y,z) scanf("%d%d%d",&x,&y,&z);
#define scl(x) scanf("%lld",&x);
#define scl2(x,y) scanf("%lld%lld",&x,&y);
#define scl3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z);

#define pb push_back
#define mp make_pair
#define fi first
#define se second 
ll power(ll x,ll y,ll z) {	ll ret = 1;	while(y > 0) {	if(y & 1) ret = (ret*x)%z;x = (x*x)%z;y >>= 1;}return ret;}


#define debug(x) cerr<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define debug4(x,y,z,a) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#a<<" :: "<<a<<"\n";



int main() {
	int i, j, t;
	deque< char > q;
	string s;
	cin >> s;
	for(i=0; i<s.size(); i++)
		q.push_back(s[i]);
	int query, flag=0;	sc(query);
	while(query--) {
		int type;	sc(type);
		if (type == 1)	flag ^= 1;
		else {
			int otype;	sc(otype);	otype--;
			string ss;
			cin >> ss;
			if(flag)
				otype ^= 1;
			if(otype == 0)
				q.push_front(ss[0]);
			else 
				q.push_back(ss[0]);
		}
	}
	if (flag) {
		while(!q.empty()) {
			printf("%c", q.back());
			q.pop_back();
		}	
	} else {
		while(!q.empty()) {
			printf("%c", q.front());
			q.pop_front();
		}	
	}
	
	cout << endl;
	return 0;
}




Measured memory_bytes: 896
n=int(input())
a=[0 for _ in range(n)]
b=[0 for _ in range(n)]
for i in range(n):
    a[i],b[i] = map(int,input().split())	
cnt=0
for i in range(n):
    i=n-1-i
    if (a[i]+cnt)%b[i]!=0:
        cnt+=b[i]-(a[i]+cnt)%b[i]
print(cnt)

Measured memory_bytes: 47280
#include <algorithm>
#include <cstdio>
const int N = 100050;
int A[N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", &A[i]);
  std::sort(A, A + n);
  int ans = 0;
  for (int i = 0; i < n;) {
    int b = i, x = A[i];
    while (A[++i] == x);
    if (i - b >= x) ans += i - b - x;
    else ans += i - b;
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 512
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>
#include <cstdint>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef unsigned long long		SQWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	int N, K;
	cin >> N >> K;
	vector<ll> A(N);
	REP(i, N) cin >> A[i];
	sort(A.begin(), A.end());
	int stPos = lower_bound(A.begin(), A.end(), 0) - A.begin();
	
	ll ans = (ll)INF;
	for (int i = 0; i <= N; i++) {
		int idxL = i;
		int idxR = i + K - 1;
		if (N <= idxR) {
			break;
		}
		if (A[idxR] < 0) {
			ans = min(ans, abs(A[idxL]));
		} else if ((A[idxL] < 0)&&(0 <= A[idxR])) {
			ans = min(ans, abs(A[idxL]) * 2 + A[idxR]);
			ans = min(ans, abs(A[idxL]) + A[idxR] * 2);
		} else {
			ans = min(ans, A[idxR]);
		}
	}

	cout << ans << endl;
	return 0;
}



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

int main() {
  int n,h,w;
  cin >> n >> h >> w;
  cout << (n-h+1)*(n-w+1) << endl;
}

Measured memory_bytes: 256
n = gets.to_i
ps = gets.split(' ').map(&:to_i)

count = 0

ps.each_cons(3) do |p_i_prev, p_i, p_i_next|
  t1, t2 = [p_i_prev, p_i_next].sort
  count += 1 if p_i > t1 and p_i <= t2
end

puts count


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

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

  priority_queue<int, vector<int>> A;

  rep(i, n) {
    int a;
    cin >> a;
    A.push(a);
  }

  priority_queue<int, vector<int>> next;
  ll result = A.top();

  A.pop();
  next.push(A.top());
  next.push(A.top());
  A.pop();

  while (!A.empty()) {
    result += next.top();
    next.pop();
    next.push(A.top());
    next.push(A.top());
    A.pop();
  }

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 5560
#include<iostream>
#include<string>
#include <algorithm>

using namespace std;

int main(){
    string S;
    cin >> S;
    long counter;
    counter = S.length();

    long i;
    char* array_dash;
    array_dash = new char[counter];
    for(i = 0;i < counter; i ++){
        if(i%2 == 0){
            array_dash[i] = '0';
        }else{
            array_dash[i] = '1';
        }
    }



    char* array_dash_dash;
    array_dash_dash = new char[counter];
    for(i = 0;i < counter; i ++){
        if(i%2 == 0){
            array_dash_dash[i] = '1';
        }else{
            array_dash_dash[i] = '0';
        }
    }

   
    long answer = 0;
    long temp1 = 0;
    for(i = 0;i < counter; i ++){
        if(S[i] != array_dash[i]){
            temp1++;
        }
    }
    long temp2 = 0;
    for(i = 0;i < counter; i ++){
        if(S[i] != array_dash_dash[i]){
            temp2++;
        }
    }
    if(temp1 > temp2){
        answer = temp2;
    }else{
        answer = temp1;
    }
    cout << answer << endl;

    
}

Measured memory_bytes: 512
def primeFactor(N):
    i, n, ret, d, sq = 2, N, {}, 2, 99
    while i <= sq:
        k = 0
        while n % i == 0: n, k, ret[i] = n//i, k+1, k+1
        if k > 0 or i == 97: sq = int(n**(1/2)+0.5)
        if i < 4: i = i * 2 - 1
        else: i, d = i+d, d^6
    if n > 1: ret[n] = 1
    return ret
def divisors(N):
    pf = primeFactor(N)
    ret = [1]
    for p in pf:
        ret_prev = ret
        ret = []
        for i in range(pf[p]+1):
            for r in ret_prev:
                ret.append(r * (p ** i))
    return sorted(ret)
def o_divisors(N):
    return [a for a in divisors(N) if N//a % 2 and a < N]
    
N = int(input())
T = input()
P = 998244353
ods = o_divisors(N)

bt = int(T, 2)
c = 0
ans = 0
L = []
for k in ods:
    tt = T[:k]
    tt_ = tt.replace("0", "2").replace("1", "0").replace("2", "1")
    
    ttf = tt + (tt_ + tt) * ((N//k-1)//2)
    aa = int(tt, 2)
    if int(ttf, 2) <= bt:
        aa += 1
    for l, cc in L:
        if k % l == 0:
            aa -= cc
    L.append((k, aa))
    c += aa
    ans += k*2*aa
        
ans = (ans + 2 * N * (bt - c + 1)) % P
print(ans)



Measured memory_bytes: 110852
/*
 * atcoder/abc107_2nd/c.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

/*
 * -30 -10 10 20 50
 *  K個の座標は連続していることは確か.
 *  連続区間[l:l+K)をl=[0: N-K)について全探索
 *  ただし、区間内に必ず0の左右が含まれる
 * [l:l+K) の時の最小コストはまずlを訪れてからl+Kに向かう経路とl+Kを訪れてからlに向かう経路の最小値
 */
const ll INF = 100000000000000000;
int N, K;
vector<ll> X;
void solve() {
  cin >> N >> K;
  ll x;
  loop(n,0,N) {
    cin >> x; X.push_back(x);
  }
  ll min_ = INF;
  for (int l=0; l+K<=N; l++) {
    int r=l+K-1;
    chmin(min_, abs(X[l]) + (X[r] - X[l]));
    chmin(min_, abs(X[r]) + (X[r] - X[l]));
  }
  cout << min_ << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 1400
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))

#define DIVUP(x, y) (((x) + ((y) - 1)) / (y))
#define DIVOFF(x, y) (((x) + ((y) / 2)) / (y))
#define REMAINDER(x, y) ((x) % (y))

int T[100000];
int main() {
  int N, C, K; scanf("%d%d%d", &N, &C, &K);
  for (int i{0}; i < N; ++i) scanf("%d", &T[i]);
  sort(T, T + N);

  int total{0};
  int i{0};
  while (i < N) {
    int count{1};
    int t = T[i];
    for (++i; i < N && T[i] == t; ++i) ++count;
    for (; REMAINDER(count, C) != 0 && i < N && T[i] <= t + K; ++i) ++count;
    total += DIVUP(count, C);
  }

  printf("%d\n", total);
  return 0;
}


Measured memory_bytes: 888
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int ans=min(a,k);
    k-=min(k,a);
    k-=min(k,b);
    ans-=min(k,c);
    cout<<ans<<endl;
}

Measured memory_bytes: 3584
fn main() {
    let n = readln();
    let a: Vec<i64> = readlns(n);
    let mut s = HashSet::new();
    for x in a {
        if s.contains(&x) {
            s.remove(&x);
        } else {
            s.insert(x);
        }
    }
    println!("{}", s.len());
}

// --- template ---
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};

pub trait FromLn {
    fn fromln(s: &str) -> Self;
}
pub fn readln<T: FromLn>() -> T {
    let mut buf = String::new();
    let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
    T::fromln(buf.trim())
}
pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
    let mut vs = vec![];
    for _ in 0..n {
        vs.push(readln());
    }
    vs
}
macro_rules! fromln_primitives {
    ($($t:ty),*) => { $(
        impl FromLn for $t {
            fn fromln(s: &str) -> $t {
                s.parse().unwrap()
            }
        }
    )* }
}
fromln_primitives!(
    String,
    bool,
    f32,
    f64,
    isize,
    i8,
    i16,
    i32,
    i64,
    usize,
    u8,
    u16,
    u32,
    u64
);
impl<T> FromLn for Vec<T>
where
    T: FromLn,
{
    fn fromln(s: &str) -> Vec<T> {
        s.split_whitespace().map(T::fromln).collect()
    }
}
impl FromLn for Vec<char> {
    fn fromln(s: &str) -> Vec<char> {
        s.chars().collect()
    }
}
macro_rules! fromln_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
            fn fromln(s: &str) -> ($($t),*) {
                let mut it = s.split_whitespace();
                let t = ($($t::fromln(it.next().unwrap())),*);
                assert_eq!(it.next(), None);
                t
            }
        }
    }
}
fromln_tuple!(A, B);
fromln_tuple!(A, B, C);
fromln_tuple!(A, B, C, D);
fromln_tuple!(A, B, C, D, E);
fromln_tuple!(A, B, C, D, E, F);


Measured memory_bytes: 8444
#include<iostream>
#include<string>
#include<map>

using namespace std;

int main(){
    string s;
    map<char, int> D;
    int N, my_p, score;
    cin >> s;
    N = s.length();
    for (int i=0; i<N; i++){
        if (D.find(s[i]) != D.end()){
            D[s[i]]++;
        }else{
            D[s[i]] = 1;
        }
    }
    my_p = N/2;
    score = my_p - D['p'];
    cout << score << endl;
    return 0;
}

Measured memory_bytes: 3772
#include <string>
#include <iostream>
#include <vector>
using namespace std;
int main()
{
  vector <char> s;
  string s1,s2;
  int n;
  cin>>n;
  cin>>s1>>s2;
  
  for(int i=0;i<s1.length();i++)
  {
    s.push_back(s1[i]);
    s.push_back(s2[i]);
  }
  for(int i=0;i<s.size();i++)
    cout<<s[i];
  
  return 0;
  
}
    
 

Measured memory_bytes: 256
local DBG = false
local function dbgpr(...)
    if DBG then
        io.write("[dbg]")
        print(...)
    end
end
--[[
local function xxxmemoize(f)
    local cache = {}
    return function(i, s)
        if s < 0 then
            return 0
        end
        local k = (i * 100000) + s
        if cache[k] then
            return cache[k]
        end
        local r = f(i, s)
        cache[k] = r
        return r
    end
end
]]

local function memoize(f)
    local cache = {}
    -- http://www.lua.org/doc/jucs05.pdf -- 4 Tables
    -- Make keys contiguous integer so that elements always reside array part
    for i=0, 301 * 90001 do
        cache[i] = -1
    end
    -- i=0,s=0
    cache[0] = 1
    -- i=0,s!=0
    for i=1, 90000 do
        cache[i] = 0
    end
    return function(i, s)
        if s < 0 then
            return 0
        end
        local k = (i * 90001) + s
        if cache[k] >= 0 then
            return cache[k]
        end
        local r = f(i, s)
        cache[k] = r
        return r
    end
end

-- returns (b^n) % m
local function modpow(b, n, m)
    if n == 0 then
        return 1
    --elseif n % 2 == 0 then
    --    return modpow(b * b % m, math.floor(n/2), m) % m
    else
        return b * modpow(b, n - 1, m) % m
    end
end

---
local MOD = 998244353
local N = io.read("*n")
local a = {}
local S = 0
for i=1,N do
    a[i] = io.read("*n")
    S = S + a[i]
end

local combh
combh = memoize(function(i, s)
    --[[
    if i == 0 then
        if s == 0 then
            return 1
        else
            return 0
        end
    end
    ]]
    --print(i, s, a[i])
    return (combh(i - 1, s - a[i]) + combh(i - 1, s)) % MOD
end)

-- ∑A = S/2 and ∑B = S/2 and ∑C = 0
local function getY()
    if S % 2 == 1 then
        return 0
    end
    return combh(N, math.floor(S/2))
end

local combgeh
combgeh = memoize(function(i, s)
    --[[
    if i == 0 then
        if s == 0 then
            return 1
        else
            return 0
        end
    end
    ]]
    return (combgeh(i - 1, s - a[i]) + combgeh(i - 1, s) * 2) % MOD
end)

-- ∑A >= S/2
local function getX()
    local sum = 0
    for s = math.ceil(S/2), S, 1 do
        --local c = combgeh(N, s)
        --dbgpr("s,c", s, c)
        sum = (sum + combgeh(N, s)) --% MOD
    end
    return sum % MOD
end

local X, Y = getX(), getY()
local Total = modpow(3, N, MOD)
--dbgpr(Total, X, Y)
local ans = (Total - (3 * X) % MOD + (3 * Y) % MOD) % MOD
--local ans = (Total - (3 * X) + (3 * Y)) % MOD
print(ans)


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

int main () {
  int N;
  cin >> N;
  
  int a, b, ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> a >> b;
    ans += b-a+1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

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

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 (b<a) { a=b; return 1; } return 0; }

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
const int MAX_N = 1e5+10;

LL dp[MAX_N];

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    int N,K; cin >> N >> K;
    VL h(N);
    REP(i,N) cin >> h[i];
    REP(i,N){
        dp[i] = LINF;
    }
    dp[0] = 0;
    REP(i,N){
        for(int j = i+1; j <= min(i+K,N-1); j++){
            chmin(dp[j], dp[i]+abs(h[j]-h[i]));
        }
    }
    cout << dp[N-1] << endl;


}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,s,f) for(i=s;i<f;i++)
#define hi cout<<'h'<<'i'<<'\n' 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
#define mod2 998244353
#define space 100005
//<<fixed << setprecision(9)

int main()
{
	int n,i,j,t;
	boost;

	cin>>j>>i;
	cout<<max(0,j-2*i);

	return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public void main(Scanner sc) {
        int n = sc.nextInt();
        int d[] = new int[13];
        for (int i = 0; i < n; i++) {
            d[sc.nextInt()]++;
        }

        if (d[0] >= 1 || d[12] >= 2 || Arrays.stream(d).anyMatch(cnt -> cnt >= 3)) {
            System.out.println(0);
            return;
        }

        int len = 0;
        int one[] = new int[12];
        boolean time[] = new boolean[25];
        for (int i = 0; i <= 12; i++) {
            if (d[i] == 2) {
                time[i] = true;
                time[24 - i] = true;
            } else if (d[i] == 1) {
                one[len++] = i;
            }
        }
        time[0] = true;
        time[24] = true;

        int ans = 0;
        for (int i = 0; i < (1 << len); i++) {
            boolean tmp[] = time.clone();
            for (int j = 0; j < len; j++) {
                if ((i >> j) % 2 == 0) {
                    tmp[one[j]] = true;
                } else {
                    tmp[24 - one[j]] = true;
                }
            }
            ans = Math.max(ans, calc(tmp));
        }

        System.out.println(ans);
    }

    private int calc(boolean time[]) {
        int prv = 0;
        int ans = 25;
        for (int i = 1; i <= 24; i++) {
            if (time[i]) {
                int dt = i - prv;
                ans = Math.min(ans, Math.min(dt, 24 - dt));
                prv = i;
            }
        }

        return ans;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        new Main().main(sc);
        sc.close();
    }
}


Measured memory_bytes: 26964
S = input()
A = []
A.append(0)

for i in range(len(S)):
    if S[i] == "<":
        A.append(A[i] + 1)
    else:
        A.append(0)

for i in range(len(S)):
    if S[len(S) - i - 1] == ">":
        A[len(S) - i - 1] = max(A[len(S) - i - 1], A[len(S) - i] + 1)
    else:
        continue

# print(A)
print(sum(A))


Measured memory_bytes: 24092
import math
def lcm(x,y):
    return(x*y)//math.gcd(x,y)

a,b,c,d=map(int,input().split())
e=b//c-(a-1)//c
f=b//d-(a-1)//d

g=b//lcm(c,d)-(a-1)//lcm(c,d)
ans=e+f-g
#print(e,f,g)
print(b-a+1-ans)



Measured memory_bytes: 9068
a = input().split()
b = input().split()
t = input()

d = abs(int(a[0]) - int(b[0]))

if (int(a[1]) <= int(b[1])):
    print('NO')
else:
    sek = int(a[1]) - int(b[1])

    if d <= int(t)*sek:
        print('YES')
    else :
        print('NO')

Measured memory_bytes: 9196
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

#ifdef _DEBUG
#include "../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

struct init {
	init() {
		cin.tie(nullptr); ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} init_;

int main() {

	int N;
	cin >> N;

	vector<int> L(N);
	for (int i = 0; i < N; i++) cin >> L[i];
	sort(L.begin(), L.end());

	int ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			for (int k = j + 1; k < N; k++) {
				if (L[i] == L[j] || L[j] == L[k] || L[k] == L[i]) continue;
				if (L[i] + L[j] > L[k]) ans++;
			}
		}
	}

	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 3644
#include <stdio.h>

int main(void)
{
    int x,y;

    scanf("%d%d",&x,&y);
    if(y%2==1){
        printf("No");
    } else if(y>x*4){
        printf("No");
    } else if(y<x*2){
        printf("No");
    }else {
        printf("Yes");
    }

    return 0;
}

Measured memory_bytes: 1736
from sys import stdin

def sp(G,R,V):
    d = {}
    INF = float('inf')
    for i in range(V):
        d[i] = INF
    d[R] = 0
    for i in range(1, V+1):
        for (u, v) in G.keys():
            if d[v] > d[u] + G[u, v]:
                d[v] = d[u] + G[u, v]
                if i == V:
                    print('NEGATIVE CYCLE')
                    quit()
    return d


V, E, R = [int(x) for x in stdin.readline().split()]
G = {}
for case in range(E):
    s, t, w = [int(x) for x in stdin.readline().split()]
    G[(s, t)] = w
d = sp(G, R, V)
for k in range(V):
    if d[k] == float('inf'):
        print("INF")
    else:
        print(d[k])

Measured memory_bytes: 8172
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++) 
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
	string S;
	while( getline( cin, S ) )
	{
		while( true )
		{
			REP( i, (int)S.size() )
			{
				if( S[ i ] != ' ' && S[ i ] != '.' )
				{
					if( S[ i ] == 'z' )
					{
						S[ i ] = 'a';
						continue;
					}
					S[ i ]++;
				}
			}
			if( S.find( "the" ) != string::npos || S.find( "this" ) != string::npos || S.find( "that" ) != string::npos )
			{
				break;
			}
		}
		cout << S << endl;
	}
	return 0;
}

Measured memory_bytes: 3152
# 47 A - Biscuits
N,P = map(int,input().split())
A = list(map(int,input().split()))
A = sorted(A,reverse = False)

# dp[i][p] i 番目までの袋を使ったときに余り p になる選び方
dp = [[0]*2 for _ in range(N+1)]

# 初期条件 (何も選ばないとき余りは 0)
dp[0] = [1,0]

for v in range(1,N+1):
    # 偶数の袋 (偶数を足しても足さなくても偶奇は変わらない)
    if A[v-1]%2 == 0:
        dp[v][0] = dp[v-1][0]*2
        dp[v][1] = dp[v-1][1]*2
    # 奇数の袋 (足すと偶奇が反転する)
    else:
        # 奇数の袋を選んだとき + 選ばなかったとき
        dp[v][0] = dp[v-1][1] + dp[v-1][0]
        dp[v][1] = dp[v-1][0] + dp[v-1][1]
print(dp[N][P])

Measured memory_bytes: 9164
def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)


def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g

n,m = map(int,input().split())
bulb = []

for i in range(m):
    t = map(int,input().split())
    t = list(t)[1:]
    bulb.append(t)

p = list(map(int,(input().split())))

# print(bulb)
# print(p)

ans = 0

for i in range(2**n):
    sw = bin(i)[2:].zfill(n)
    sw = list(map(int,list(sw)))
    #print(sw)
    on = 0
    for j in range(m):
        temp = 0
        for b in bulb[j]:
            if sw[b-1] == 1:
                temp += 1
        if temp % 2 == p[j]:
            on += 1
    if on == m:
        ans += 1

print(ans)









Measured memory_bytes: 3064
#include <bits/stdc++.h>
#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, m;
  cin >> n >> m;
  vector<int> h(n);
  vector<bool> ok(n, true);
  rep(i, n) cin >> h[i];
  vector<int> ans(n);
  int cnt = 0;
  rep(i, m){
    int a, b;
    cin >> a >> b;
    if(h[a-1] <= h[b-1]) ok[a-1] = false;
    if(h[b-1] <= h[a-1]) ok[b-1] = false;
  }
  rep(i, n){
    if(ok[i]) cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 4064
#include <stdio.h>
#define MAX 100000

int partition(int,int);

int A[MAX],n;

int partition(int p,int r){
  int x,i,j,t;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      t=A[i];
      A[i]=A[j];
      A[j]=t;
    }
  }
  t=A[i+1];
  A[i+1]=A[r];
  A[r]=t;
  return i+1;
}

int main()
{
  int i,j,x,q,r,t;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  q=partition(0,n-1);

  for(i=0;i<n;i++){
    if(i) printf(" ");
    if(i==q) printf("[");
    printf("%d",A[i]);
    if(i==q) printf("]");
  }

  printf("\n");

  return 0;
}

Measured memory_bytes: 2940
import sys
sys.setrecursionlimit(10**7)

n, m = map(int, input().split())
G = [[] for _ in range(n)]
for _ in range(m):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  G[a].append(b)
  G[b].append(a)
q = int(input())
vdc = [list(map(int, input().split())) for _ in range(q)][::-1]
dp = [[0]*11 for _ in range(n)]
def dfs(v, d, c):
  if dp[v][d]:
    return dp[v][d]
  if d == 0:
    dp[v][d] = c
    return
  for u in G[v]:
    dfs(u, d-1, c)
  dfs(v, d-1, c)
  dp[v][d] = c
for v, d, c in vdc:
  dfs(v-1, d, c)
for i in range(n):
  print(dp[i][0])

Measured memory_bytes: 62408
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define pb(x) push_back(x)
#define int long long

string S;

signed main(void){
	cin >> S;
	SORT(S);

	int ans=1;
	rep(i, S.size()){
		int s = S[i]-'a'+1;
		if(ans<s){
			break;
		}else{
			ans=s+1;
		}
	}

	if(ans>26){
		cout << "None" << endl;
	}else{
		char Ans = 'a'+ans-1;
		cout << Ans << endl;
	}

	return 0;
}

Measured memory_bytes: 512
//-------All power is within you,you can do Anything and Everything.---------//
 
    #include <bits/stdc++.h>
    using namespace std;
  
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ M $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
 
    #define pb push_back
    #define MP make_pair
    #define F first
    #define S second
    #define sc(x) scanf("%lld",&x)
    #define pf(x) printf("%lld\n",x)
    #define int long long
    #define all(x) x.begin(),x.end() 
    #define fo(i,a,b) for(int i=a;i<b;i++)
    #define rfo(i,b,a) for(int i=b;i>=a;i--)
    #define deb(x) cout<<#x<<" "<<x<<endl;
    #define mem( a, val ) memset(a, val, sizeof( a ) )
    #define deci( x ) cout<<fixed<<setprecision( x );
    #define bitcount( x ) __builtin_popcountll( x )
    #define endl "\n" 
 
    
    typedef vector<int> vi;
    typedef pair<int,int> pi; 
    
    const int MOD =  1000000007 ;
    const int MAX = 2e6 + 7;
    const int INF = 1e15;
    const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
    const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
 
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ V $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//  
    
    int i,j,k,t,n,q,l,r,mid;
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ F $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    string s;

    bool flag;
    void solve()
    {
        cin>>s;
        fo(i,0,3)
        {
            if(s[i]=='7')flag=1;
        }
        if(flag)cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
//                          GAME STARTS FROM HERE                            //
 
    int32_t main() 
    {
    
        // int start,stop=clock();
        // cout<<"time:"<<(stop-start)/double(CLOCKS_PER_SEC)*1000<<endl;
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);

        // sc(t);while(t--)
        // cin>>t;while(t--)
            solve();
    
        return 0;
    }

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    for(auto& e:a)cin>>e;
    sort(a.begin(),a.end());
    long long ans = 0;
    for(int i=0;i<n-k;i++)ans+=a[i];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
inline int read(){
    int f=1,x=0;
    char ch;
    do{
        ch=getchar();
        if(ch=='-'){
            f=-1;
        }
    }while(ch<'0'||ch>'9');
    do{
        x=x*10+ch-48;
        ch=getchar();
    }while(ch>='0'&&ch<='9');
    return f*x;
}
inline int cmp(int a,int b){
    if(a>b){
        return a;
    }
    else{
        return b;
    }
}
int main(){
    int n=read();
    cout<<48-n;
    putchar('\n');
    return 0;
}

Measured memory_bytes: 256
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func init() {
	buf := make([]byte, 0)
	scanner.Buffer(buf, 10000000000)
	scanner.Split(bufio.ScanWords)
}

func ScanInt() (ret int) {
	var err error
	if scanner.Scan() {
		txt := scanner.Text()
		if ret, err = strconv.Atoi(txt); err != nil {
			_, _ = fmt.Fprintf(os.Stderr, err.Error())
		}
	}
	return
}

func Min(ns ...int) int {
	if len(ns) == 0 {
		_, _ = fmt.Fprintf(os.Stderr, "Arguments are necessary")
		return 0
	}
	if len(ns) == 1 {
		return ns[0]
	}
	min := ns[0]
	for i := 1; i < len(ns); i++ {
		if min > ns[i] {
			min = ns[i]
		}
	}
	return min
}

func main() {
	n := ScanInt()
	a, b, c, d, e := ScanInt(), ScanInt(), ScanInt(), ScanInt(), ScanInt()
	m := Min(a, b, c, d, e)
	if n%m == 0 {
		fmt.Println(n/m + 4)
	} else {
		fmt.Println(n/m + 5)
	}
}


Measured memory_bytes: 1772
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>

#define NMAX = 100000;
#define KMAW = 100000;
#define WMAX =  10000;
using namespace std;

bool can_load(vector<int> w_sum, int &k, int &p){
  int loaded=0;
  auto it = w_sum.begin();
  for(int i=0;i<k;i++){
    it = upper_bound(it,w_sum.end(),p+loaded);
    auto prev = it - 1;
    loaded = *prev;
  }
  return it==w_sum.end();
}

int main(){
  int n,k; cin>>n>>k;
  vector<int> w_sum;
  int sum=0;
  for(int i=0;i<n;i++) {
    int tmp;
    scanf("%d",&tmp);
    sum+=tmp;
    w_sum.push_back(sum);
  }
  int right=sum;
  int left=sum/k;

  while(left<right){
    int mid = (right + left)/2;
    if(can_load(w_sum,k,mid)){
      right = mid;
    }else{
      left = mid + 1;
    }
  }

  cout<<right<<endl;
}

Measured memory_bytes: 3772
#include<stdio.h>
#include<string.h>
int main(){
    char A[10];
    scanf(" %s",A);
    int s_len=strlen(A);
    A[s_len]='\0';
    char B[10];
    scanf(" %s]",B);
    int s_len_b=strlen(B);
    B[s_len_b]='\0';
    char C[10];
    scanf(" %s",C);
    int s_len_c=strlen(C);
    C[s_len_c]='\0';

    if(A[s_len-1]==B[0] && B[s_len_b-1]==C[0]){
        printf("YES");
    }
    else{
        printf("NO");
    }
}

Measured memory_bytes: 128
import statistics
n = int(input())
A = [int(i) for i in input().split()]
A_list = []
ans_l,ans_h = 0,0
Min = 10**9

for i in range(n):
    A_list.append(A[i]-(i+1))

b_lowkey = statistics.median_low(A_list)
b_highkey = statistics.median_high(A_list)

for i in range(n):
    ans_l += abs(A_list[i]-b_lowkey)
    ans_h += abs(A_list[i]-b_highkey)
print(min(ans_l,ans_h))


Measured memory_bytes: 27312
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr ll INFL = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

signed main() {
  ll L, R;
  cin >> L >> R;

  if (2019 - (L % 2019) + L <= R) {
    COUT(0);
  } else {
    ll max = INFL;

    if (R - L == 1) {
      COUT((R * L) % 2019);
      return 0;
    }

    if (R % 2019 == 0 || L % 2019 == 0) {
      COUT(0);
      return 0;
    }

    rep(i, R - L + 1) {
      rep2(j, i + 1, R - L + 1) {
        ll left = i + L;
        ll right = j + L;
        // debug(left);
        // debug(right);
        ll v = (left * right) % 2019;
        if (max > v) {
          // debug(v);/
          max = v;
        }
      }
    }
    COUT(max);
  }
  return 0;
}

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

using namespace std;

int main(){
  int N;
  string S, T, A;
  cin >> N >> S >> T;
  for(int i=0; i<N; i++){
    A += S[i];
    A += T[i];
  }
  cout << A << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n,a[200007],cur,ck[200007],pw[200007],gt[200007];
long long MOD=1e9+7;
long long po(long long a,long long b){
    if(b==1) return a%MOD;
    long long z=po(a,b/2);
    if(b%2==0) return (z*z)%MOD;
    else return (((z*z)%MOD)*a)%MOD;
}
long long cal(long long a,long long b){
    if(a>b) return 0;
    return (((pw[b]*gt[a])%MOD)*gt[b-a])%MOD;
}
int main(){
    ios_base::sync_with_stdio(0);
    pw[0]=1;
    gt[0]=1;
    for(int i=1;i<=200000;i++){
        pw[i]=pw[i-1]*i;
        pw[i]%=MOD;
        gt[i]=po(pw[i],MOD-2);
    }
    cin>>n;
    for(int i=1;i<=n+1;i++){
        cin>>a[i];
        if(ck[a[i]]!=0) {cur=i;continue;}
        ck[a[i]]=i;
    }
    for(long long i=1;i<=n+1;i++){
        if(i==1) cout<<n;
        else{
            long long ans=0;
            ans=cal(i,n+1);
            ans-=cal(i-1,n+1-cur+ck[a[cur]]-1);
            cout<<(ans+MOD*MOD)%MOD;
        }
        cout<<endl;
    }
}


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

const int MAXV=(int) 1e5+1;

struct edge{
    int to;
    int distance;
};

vector <edge> G[MAXV];
int color[MAXV];

int main(){
    int N;
    cin >> N;
    int u, v, w;
    int ans,count;
    queue <int> que;

    for(int i=0; i<N-1; i++){
        cin >> u >> v >> w;
        edge e = { v, w };
        G[u].push_back(e);
        e = { u, w };
        G[v].push_back(e);
    }

    for(int i=0; i<MAXV; i++) color[i]=-1;

    color[1]=0;
    que.push(1);

    while( !que.empty() ){
        int ii = que.front();
        que.pop();
        for( auto e: G[ii] ){
            if (color[e.to]>=0) continue;
            color[e.to]= (color[ii]+e.distance%2)%2; // odd odd->even, odd even -> odd, even odd-> odd, even even -> even
            que.push(e.to);
        }
    }

    for(int i=1; i<=N; i++){
        cout << color[i] << endl;
    }

    return 0;
}

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

using namespace std;

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

  int n;
  cin >> n;
  int64_t t, a;
  int64_t taka, aoki;
  cin >> taka >> aoki;
  for (int i = 1; i < n; ++i) {
    cin >> t >> a;
    int64_t n = max((taka + t - 1) / t, (aoki + a - 1) / a);
    taka = n * t;
    aoki = n * a;
  }
  cout << taka + aoki << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
using pii = pair<int, int>;

#define rep(i,k,n) for(int i=(k); i != int(n); ++i)
#define sz(x) x.size()
#define all(x) x.begin(), x.end()

#define dbg(x) cout << #x << '=' << x << '\n'
#define dbg2(x, y) cout << #x << '=' << x << ' ' << #y << '=' << y << '\n' 

#define input() (*istream_iterator<int>(cin))
#define strin() (*istream_iterator<string>(cin))
#define output(x) cout << x << '\n' 

int main(){
    ios::sync_with_stdio(false);
    int a = input(), b = input(), c = input(), d = input();
    int turn = 0;
    while(a > 0 and c > 0){
        if(turn == 0) c -= b;
        else a -= d; 
        turn ^= 1;
    }
    if(a > 0) cout << "Yes\n";
    else cout << "No\n";
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K,x,y; cin >> K >> x >> y;
    if (!(K&1)&&(abs(x+y)&1)){cout << -1 << '\n'; return 0;}
    vector<pair<int,int>> ans;
    int X=x-y,Y=x+y;
    ans.emplace_back(X,Y);
    while (1){
        bool flagX=false,flagY=false;
        int nxtX,nxtY;
        if (X<0) X*=-1,flagX=true;
        if (Y<0) Y*=-1,flagY=true;
        if (X==K&&Y<=K) break;
        if (X<=K&&Y==K) break;
        if (X>=Y&&X>=K){
            nxtX=K,nxtY=min(K,Y-K);
            if (abs(nxtX+nxtY)&1) --nxtY;
        } else if (Y>=X&&Y>=K){
            nxtX=min(K,X-K),nxtY=K;
            if (abs(nxtX+nxtY)&1) --nxtX;
        } else {
            nxtX=K,nxtY=Y-K;
            if (abs(nxtX+nxtY)&1) ++nxtY;
        }
        if (flagX) X*=-1,nxtX*=-1;
        if (flagY) Y*=-1,nxtY*=-1;
        X-=nxtX,Y-=nxtY;
        ans.emplace_back(X,Y);
    }
    cout << ans.size() << '\n';
    reverse(ans.begin(),ans.end());
    for (int i=0;i<ans.size();++i){
        X=ans[i].first,Y=ans[i].second;
        cout << (X+Y)/2 << ' ' << (Y-X)/2 <<'\n';
    }
}

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

using namespace std;



int  jumpcost(vector<int> &heights,int i,vector<int> &dp){
    if(i == (heights.size()-1)){                // recursive code optimized with memoization
        return 0;
    }
    if(dp[i]!=-1){
        return dp[i];
    }
    int cost1,cost2= -1;
    cost1 = abs(heights[i]-heights[i+1]);
    if((i+2) < heights.size()){
    cost2 = abs(heights[i]-heights[i+2]);
    }

    if(cost2 == -1){
        return cost1+jumpcost(heights,i+1,dp);
    }

    dp[i] = min(cost1+jumpcost(heights,i+1,dp),cost2+jumpcost(heights,i+2,dp));

    return dp[i];
}

int main(){

int n;
cin>>n;

vector<int> heights(n,0);
vector<int> dp(n,-1);

for(int i=0;i<n;i++){
    cin>>heights[i];
}

cout<<jumpcost(heights,0,dp)<<"\n";

return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e9+7
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  
  ll N,M;
  cin>>N>>M;
  
  vector<ll>a(M);
  vector<ll>b(M);
  vector<pair<ll,ll>>c(M);
  vector<ll>F;
  vector<ll>E;
  
  rep(i,M){
    cin>>a[i]>>b[i];
    c[i].first=a[i];
    c[i].second=b[i];
  }
  sort(all(c));
  
  for(ll i=0;i<M;i++){
    if(c[i].first==1){
      F.push_back(c[i].second);
    }
  }
  
  for(ll i=0;i<M;i++){
    if(c[i].second==N){
E.push_back(c[i].first);
    }
  }
if(F.size()==0||E.size()==0){
 cout<<"IMPOSSIBLE"<<endl;
}
  else{
    bool flag=false;
   
    for(ll i=0;i<F.size();i++){
if(E[lower_bound(all(E),F[i])-E.begin()]==F[i]){
  flag=true;
  break;
    }
    }

   if(flag){
     cout<<"POSSIBLE"<<endl;
   }
    else{
      cout<<"IMPOSSIBLE"<<endl;
    }
  }

}
    
    
    
    
    
    
    
    

Measured memory_bytes: 8820
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;

namespace CSharpSpiral {
    class Program {
        static void Main(string[] args) {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }
		public void Solve(ConsoleInput cin) {
			var line = cin.ReadDoubleArray(4);
			double x1 = line[0], y1 = line[1], x2 = line[2], y2 = line[3];
			double dx = x2 - x1, dy = y2 - y1;
			var lenSq = dx * dx + dy * dy;
			var q = cin.ReadInt;
			for(int i = 0; i < q; i++) {
				var p = cin.ReadDoubleArray(2);
				var px = p[0] - x1;
				var py = p[1] - y1;
				var inner = dx * px + dy * py;
				var res = new double[] { x1 + inner / lenSq * dx, y1 + inner / lenSq * dy };
				Console.WriteLine(res.Join());
			}
		}
	}
	static class ExtendClass {
		public static string Join<T>(this IEnumerable<T> X, string separator = " ") => string.Join(separator, X);
	}
	class ConsoleInput {
		private readonly TextReader _stream;
		private readonly char _separator = ' ';
		private readonly Queue<string> inputStream;
		public ConsoleInput(TextReader stream, char separator = ' ') {
			this._separator = separator;
			this._stream = stream;
			inputStream = new Queue<string>();
		}
		public string Read {
			get {
				if(inputStream.Count != 0) return inputStream.Dequeue();
				string[] tmp = _stream.ReadLine().Split(_separator);
				for(int i = 0; i < tmp.Length; ++i)
					inputStream.Enqueue(tmp[i]);
				return inputStream.Dequeue();
			}
		}
		public string ReadLine { get { return _stream.ReadLine(); } }
		public int ReadInt { get { return int.Parse(Read); } }
		public long ReadLong { get { return long.Parse(Read); } }
		public double ReadDouble { get { return double.Parse(Read); } }
		public string[] ReadStrArray(long N) {
			var ret = new string[N];
			for(long i = 0; i < N; ++i)
				ret[i] = Read;
			return ret;
		}
		public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
		public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
		public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
	}
}



Measured memory_bytes: 20532
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define mod 1000000007

int main() {
	int n, m;
	cin >> n >> m;
	long long int suma[100000];
	for (int i = 1; i <= n; i++) {
		long long int a;
		cin >> a;
		suma[i] = (suma[i - 1] + a) % m;
	}
	long long int ans = 0;
	map<long long int, long long int> cnt;
	cnt[0] = 1;
	for (int i = 1; i <= n; i++) {
		if (cnt.find(suma[i]) != cnt.end()) {
			ans += cnt[suma[i]];
			cnt[suma[i]]++;
		} else {
			cnt[suma[i]] = 1;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 4992
s = input()

count = 0
count_list = [0]
for i in range(len(s)):
    if s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T":
        count += 1
    else:
        count_list.append(count)
        count = 0
count_list.append(count)
print(max(count_list))

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <typename T> bool chmax(T &a, const T &b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T> bool chmin(T &a, const T &b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
const long long INFLL = 1LL << 60;
const long long MOD = 1e9 + 7;

int main() {
    string S;
    cin >> S;
    int ans = 0;
    rep(i, 6) if(S[i] == '1') ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3652