akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string S; cin >> S;

	int i = 0;
	while (i < S.size() && S[i] == '9') ++i;
	int ans = i * 9;
	if (i != S.size()) {
		if (i != 0) {
			ans += 9 * (S.size() - i) - 1;
		} else {
			ans += 9 * (S.size() - i - 1);
			ans += S[i] - '1';
		}
	}
	if (S.size() == 1) print(S);
	else {
		int o = 0;
		for (char c : S) o += c - '0';
		print(max(o, ans));
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for(int i = (a); i<(b); ++i)
#define rep(i, n) for (int i=0; i<(n); ++i)
#define out(x) cout << x << endl

int check(int N, vector<int> b, int a1, int a2, int a3) {
    int a1_flag=0;
    int a2_flag=0;
    int a3_flag=0;
    for(int bb : b){
        if(bb == a1){
            a1_flag=1;
            break;
        }
    }
    for(int bb : b){
        if(bb == a2){
            a2_flag=1;
            break;
        }
    }
    for(int bb : b){
        if(bb == a3){
            a3_flag=1;
            break;
        }
    }
    return a1_flag && a2_flag && a3_flag;
}

int main(){
    vector<vector<int>> A(3, vector<int>(3));
    rep(i, 3){
        rep(j, 3){
            cin  >> A.at(i).at(j);
        }
    }
    int N;
    cin >> N;
    vector<int> b(N);
    rep(i, N) cin >> b.at(i);
    rep(i, 3){
        if(check(N, b, A.at(i).at(0), A.at(i).at(1), A.at(i).at(2))){
            out("Yes");
            return 0;
        }
    }
    rep(j, 3){
        if(check(N, b, A.at(0).at(j), A.at(1).at(j), A.at(2).at(j))){
            out("Yes");
            return 0;
        }
    }
    if(check(N, b, A.at(0).at(2), A.at(1).at(1), A.at(2).at(0))){
        out("Yes");
        return 0;
    }
    if(check(N, b, A.at(0).at(0), A.at(1).at(1), A.at(2).at(2))){
        out("Yes");
        return 0;
    }
    out("No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++) cout<<'x';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
int main(){
    using namespace std;
    int w,h,x,y,r;
    cin>>w>>h>>x>>y>>r;
    if(x-r>=0 && x+r<=w && y-r>=0 && y+r<=h){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3108
import heapq
n, k = map(int, input().split())
r = min(n, k)
v = list(map(int, input().split()))
ans = 0
for i in range(1, r+1):
  for j in range(i+1):
    a = j
    b = i-j
    v_temp = v[:a]
    v_temp.extend(v[n-b:])
    heapq.heapify(v_temp)
    for l in range(k-i):
      get = heapq.heappop(v_temp)
      if get>=0:
        heapq.heappush(v_temp, get)
        break
      if not v_temp:
        break
    v_temp.append(0)
    ans = max(ans, sum(v_temp))
print(ans)

Measured memory_bytes: 53852
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#include<cmath>
#include<random>
#include<string.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("YES");
	else say("NO");
}

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	yn(b - a == c - b);
}

Measured memory_bytes: 256
def main():
    n = int(input())
    A,B = [],[]
    for _ in range(n):
        a,b = map(int,input().split())
        A.append(a)
        B.append(b)
    A,B = sorted(A),sorted(B)
    if n%2==0:
        a_m,b_m = (A[n//2]+A[n//2-1]),(B[n//2]+B[n//2-1])
        print(b_m-a_m+1)
    else:
        a_m,b_m = A[n//2],B[n//2]
        print(b_m-a_m+1)

if __name__ == "__main__":
    main()


Measured memory_bytes: 28644
using System;
using System.Collections.Generic;
class Program
{
	static void Main()
	{
		var n = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
        var p = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
        Array.Sort(p);
		 long sum = 0;
  for(long i = n[0]-1; i >= 0; i--){
      if(i<=n[0]-1-n[1]){
        sum += p[i];
      }
}
      Console.WriteLine(sum);
	}
}


Measured memory_bytes: 31744
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  string s,t;
  cin >> s >> t;
  char u='a';
  vector<char> k(26,'0');
  rep(i,s.size()){
    int q=(s[i]-'a');
    if(k[q]=='0'){
      k[q]=u;
      s[i]=u;
      u++;
    }
    else{
      s[i]=k[q];
    } 
  }
  char o='a';
  vector<char> w(26,'0');
  rep(i,t.size()){
    int p=(t[i]-'a');
    if(w[p]=='0'){
      w[p]=o;
      t[i]=o;
      o++;
    }
    else{
      t[i]=w[p];
    } 
  }
  if(s==t)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 776
N, K  = map(int, input().split())

AAA = []
for _ in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    AAA = AAA + A

AAA = list(set(AAA))

AA = []
for i in range(N):
    AA = AA + [i + 1]

a = AAA + AA
ANS = len([i for i in list(set(a)) if a.count(i) == 1])

print(ANS)

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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(x)	cout << #x << " " << x << endl;

typedef long long int ll;

class CO {
	public:
	int net, open, close;
	
	CO(int c, int o) {
		open = o;
		close = c;
		net = open-close;
	}

	void printCO() {
		cout << "(" << close << "," << open << " " << net << ")" << endl;
	}
};

class compCO {
	public:

	bool operator() (CO a, CO b) {
		return a.net == b.net ? a.close < b.close: a.net > b.net;
		return a.close == b.close ? a.open > b.open : a.close < b.close;
	}
};

CO makeCO(string &s) {
	int oc = 0, cc = 0;
	for (char x: s) {
		if (x == '(')
			oc++;
		else
			cc++;
	}

	return CO(cc, oc);
}

void shorten(string &s) {
	stack<char> st;
	for (char x: s) {
		if (st.empty())
			st.push(x);
		
		else {
			if (x == ')' && st.top() == '(')
				st.pop();

			else
				st.push(x);
		}		
	}

	s = "";
	while (!st.empty()) {
		s = st.top() + s;
		st.pop();
	}
}

int main() {

	IOS

	int n;
	cin >> n;

	string s[n];

	for (int i = 0; i < n; i++)
		cin >> s[i];


	int pos = 0, neg = 0;
	vector<CO> v;

	for (int i = 0; i < n; i++) {
		shorten(s[i]);

		// deb(s[i]);

		int open_found = s[i].find('(');
		int close_found = s[i].find(')');

		if (open_found != string::npos && close_found != string::npos) {
			v.push_back(makeCO(s[i]));

		} else if (open_found != string::npos) {
			pos += s[i].size();

		} else {
			neg += s[i].size();
		}
	}

	// deb(pos);
	// deb(neg);

	sort(v.begin(), v.end(), compCO());

	// for (auto x: v)
	// 	x.printCO();

	int cur_depth = pos;
	bool can = true;

	for (auto x: v) {
		if (pos < x.close) {
			can = false;
			// cout << "broken at " << pos ;
			// x.printCO();
			break;
		}

		pos += x.net;
	}

	// deb(pos);

	if (can) {
		if (pos != neg)
			can = false;
	}

	cout << (can ? "Yes" : "No") << endl;


	return 0;
}

Measured memory_bytes: 34764
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

//inline int read(){int t = 0;int neg=1;char c;while((c=getchar_unlocked())!='\n'&&c!=' '&&c!=EOF){if(c=='-'){neg=-1;continue;}t=t*10+c-48;}return neg*t;}
//inline int readl(){long long t = 0;long long neg=1ll;char c;while((c=getchar_unlocked())!='\n'&&c!=' '&&c!=EOF){if(c=='-'){neg=-1ll;continue;}t=t*10+c-48;}return neg*t;}

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pi;
typedef pair<lli,lli> plli;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector<pi> vpi;
typedef vector<plli> vplli;
const lli M=1000000007ll;

int main(){
	fast_io
	int k,r; cin>>k>>r;
	if(k>=10) cout<<r;
	else cout<<r+100*(10-k); 
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

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

    map<int,int> mp;

    REP(i, n){
        int a;
        cin >> a;
        mp[a]++;
    }

    int sum = 0;
    for(auto i : mp){
        sum += i.second - 1;
    }

    sum += sum%2;

    cout << n - sum << endl;

    return 0;
}

Measured memory_bytes: 4992
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        x: u64,
    }
    println!(
        "{}",
        if x == 3 || x == 5 || x == 7 {
            "YES"
        } else {
            "NO"
        }
    );
}


Measured memory_bytes: 4352
<?php
// Your code here!
$arr = explode(" ",trim(fgets(STDIN)));


  function gcd($m, $n){
    if($n > $m) list($m, $n) = array($n, $m);
     
    while($n !== 0){
        $tmp_n = $n;
        $n = $m % $n;
        $m = $tmp_n;
    }
    return $m;
 }
 
function lcm($m, $n){
    return $m * $n / gcd($m, $n);
}

echo lcm($arr[0],$arr[1]);
?>


Measured memory_bytes: 4604
// Nihesh Anderson - knandy

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
ll MOD=1000000007;

#define fast_cin() ios_base::sync_with_stdio(false)
#define pb push_back
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define debug1(x) cerr << x << endl;
#define debug2(x,y) cerr << x << " " << y << endl;
#define debug3(x,y,z) cerr << x << " " << y << " " << z << endl;
#define FOR(i, a, b) for (ll i=a; i<(b); i++)
#define FORR(i, a, b) for (ll i=a; i>=(b); i--)
ll INF = 2000000000000000001;
double EPS = 1e-9;
ll nextll(){ll inp; cin>>inp; return inp;}
string nextStr(){string inp; cin>>inp; return inp;}
double nextDouble(){double inp; cin>>inp; return inp;}
ll power(ll a, ll n, ll md){if(n==0){return 1;}else{ll res=power(a,n/2,md);res=(res*res)%md;if(n%2!=0){res=(res*a)%md;}return res;}}
random_device rndm;
mt19937 grndm(rndm());
void mix(ll* a, ll* b){shuffle(a,b,grndm);}

int main(){
	fast_cin();
	ll a,b;
	cin>>a>>b;
	if(a+b==15){
		cout<<"+"<<endl;
	}
	else if(a*b==15){
		cout<<"*"<<endl;
	}
	else{
		cout<<"x"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n, m, sm = 0, ara[102], a, b;
  scanf("%d", &n);
  for(int i = 0; i < n; i++)
  {
      scanf("%d", &ara[i]);
      sm += ara[i];
  }
  scanf("%d", &m);
  for(int i = 0; i < m; i++)
  {
      scanf("%d%d", &a, &b);
      printf("%d\n", sm-ara[a-1]+b);
  }
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main()
{
        int a, b, c;
        int rct = 0, rhm = 0;

        while (scanf("%d%*c%d%*c%d", &a, &b, &c) != EOF) {
                if (a * a + b * b == c * c) {
                        rct++;
                }
                else if (a == b) {
                        rhm++;
                }
        }

        printf("%d\n%d\n", rct, rhm);

        return 0;
}

Measured memory_bytes: 2580
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n;
Vi a;
deque<ll> dp;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n;
    a.resize(n);
    rep(i,n){
        cin>>a[i];
    }
    rep(i,n){
        ll tp = lower_bound(all(dp),a[i]) - dp.begin();
        if(tp==0)dp.push_front(a[i]);
        else dp[tp-1]=a[i];
    }
    print(dp.size());
    return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
int main(){
	int k, n;
	cin >> k >> n;
	vector<int> a(n);
	for(int i=0; i<n; ++i){
		cin >> a[i];
	}

	int mx=k-(a[n-1]-a[0]);
	for(int i=0; i<n-1; ++i){
		mx=max(mx,a[i+1]-a[i]);
	}

	cout << k-mx << endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9+ 7;
const int INF = numeric_limits<int>::max() - 1e8;
const ll INFLL = numeric_limits<ll>::max() - 1e17;

signed main() {
    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    vector<pair<char, char>> move(Q);
    for (int i = 0; i < Q; i++) cin >> move[i].first >> move[i].second;
    auto simulation = [&](int idx, bool goalLeft) {
        for (int i = 0; i < Q; i++) {
            if (S[idx] == move[i].first) {
                if (move[i].second == 'L') idx--;
                else idx++;
            }
            if (idx == -1 || idx == N) break;
        }
        if (goalLeft) {
            return idx == -1;
        } else {
            return idx == N;
        }
    };
    int ansLeft = 0, ansRight = N - 1;
    {
        int left = -1, right = N;
        while (right - left > 1) {
            int mid = left + (right - left) / 2;
            if (simulation(mid, true)) left = mid;
            else right = mid;
        }
        ansLeft = left;
    }
    {
        int left = -1, right = N;
        while (right - left > 1) {
            int mid = left + (right - left) / 2;
            if (simulation(mid, false)) right = mid;
            else left = mid;
        }
        ansRight = right;
    }
    if (ansLeft == 0 && !simulation(0, true)) ansLeft = -1;
    if (ansRight == N - 1 && !simulation(N - 1, false)) ansRight = N;
    cout << ansRight - ansLeft - 1 << endl;
}


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

#define MorsheD ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
typedef long long ll;

int main() {
	// ===================
	MorsheD;
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	// ===================

	string s;
	cin >> s;

	int cnt, res = 0;

	for (int i = 0; i < s.size(); ++i) {
		cnt = 0;
		if (s[i] == 'R') {
			while (s[i] == 'R' && i < s.size()) {
				cnt++;
				i++;
			}
			res = max(res, cnt);
		}
	}

	cout << res << '\n';

	return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>
#include<math.h>
int main(void){
  int N=0;
  int a=0,b=0,c=0;
  scanf("%d",&N);
  a=N/100;
  b=(N-a*100)/10;
  c=(N-a*100-b*10);
  if(a==7||b==7||c==7)printf("Yes");
  else printf("No");
return 0;
}

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

using namespace std;

const int maxn = 4e3 + 3;
const int mod = 998244353;

int k, n;
long long po2[maxn];
long long C[maxn][maxn];
long long has[maxn];

int main() {
	cin >> k >> n;
	
	po2[0] = 1;
	for (int i = 1; i < maxn; i++) {
		po2[i] = po2[i - 1] * 2 % mod;
	}
	for (int i = 0; i < maxn; i++) {
		C[i][0] = 1;
		for (int j = 1; j <= i; j++) {
			C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
		}
	}

	for (int i = 0; i <= k / 2; i++) {
		int rem = k - i * 2;
		for (int j = 0; j <= i; j++) {
			int tot = j + rem;
			if (n - 2 - j < 0) continue;
			long long res = po2[j] * C[i][j] % mod * C[n - 2 - j + tot - 1][n - 2 - j] % mod;
			has[i] += res;
			has[i] %= mod;
		}
	}

	for (int i = 2; i <= 2 * k; i++) {
		int cnt = 0;
		int tar = min(k, i);
		for (int j = 1; j <= tar; j++) {
			int t = i - j;
			if (t < j) break;
			if (t <= k) cnt++;
		}
		long long res = 0;
		for (int j = 0; j < cnt; j++) {
			res += has[j];
			res %= mod;
		}
		res = C[n + k - 1][n] - res;
		if (res < 0) res += mod;
		cout << res << '\n';
	}

	return 0;
}


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

int main()
{
    array<int, 5> t;
    for (int i = 0; i < 5; i++) {
        cin >> t.at(i);
    }
    int ans = 0;
    int m = 0;
    for (int i = 0; i < 5; i++) {
        int amari = (150 - t.at(i)) % 10;
        ans += t.at(i) + amari;
        if (amari > m) {
            m = amari;
        }
    }
    ans -= m;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 1000000000;
using namespace std;
int main() {
  int n, m;
  char q;
  cin >> n >> m;
  int dp[n][n];
  rep(i, n) rep(j, n) dp[i][j] = i == j ? 0 : INF;
  rep(i, m) {
    int a, b, c, d;
    cin >> a >> q >> b >> q >> c >> q >> d;
    a--;
    b--;
    dp[a][b] = c;
    dp[b][a] = d;
  }
  rep(k, n) rep(i, n) rep(j, n) dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
  int s, g, V, P;
  cin >> s >> q >> g >> q >> V >> q >> P;
  s--;
  g--;
  cout << V - P - dp[s][g] - dp[g][s] << endl;
  return 0;
}

Measured memory_bytes: 3016
h,w,a,b=map(int,input().split())
for i in range(b):
  s=''
  for j in range(a):
    s+='1'
  for j in range(w-a):
    s+='0'
  print(s)
for i in range(h-b):
  s=''
  for j in range(a):
    s+='0'
  for j in range(w-a):
    s+='1'
  print(s)

Measured memory_bytes: 3956
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int X, Y;
    cin >> X >> Y;
    if(X < Y) {
        cout << X << endl;
    } else if(X % Y == 0) {
        cout << -1 << endl;
    } else {
        cout << X << endl;
    }
}

Measured memory_bytes: 256
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

#include <bits/stdc++.h>

using namespace std;

const int MOD = 1000000007;

#define MUL(a,b) ((long long)(a) * (b) % MOD)

int main()
{
#ifdef _MSC_VER
	freopen("d.in", "r", stdin);
#endif
	std::ios::sync_with_stdio(false);
	int h;
	cin >> h;
	int l = (1 << (h - 1));
	vector<int> p(l);
	for (int i = 0; i < l; ++i) {
		cin >> p[i];
		--p[i];
	}

	int wc = 0;
	vector<int> c(l * 2);
	vector<int> val(l * 2);

	std::function<void(int, int)> dfs1 = [&](int id, int multi) {
		multi = MUL(multi, id);
		if (id >= l) {
			for (int next_id = p[id - l] + l; next_id > 0; next_id /= 2) {
				multi = MUL(multi, next_id);
				if (c[next_id] != wc) {
					c[next_id] = wc;
					val[next_id] = 0;
				}
				val[next_id] = (val[next_id] + multi) % MOD;
			}
			return;
		}
		dfs1(id * 2, multi);
		dfs1(id * 2 + 1, multi);
	};
	int ret = 0;
	std::function<void(int, int)> dfs2 = [&](int id, int multi) {
		multi = MUL(multi, id);
		if (id >= l) {
			for (int next_id = p[id - l] + l; next_id > 0; next_id /= 2) {
				multi = MUL(multi, next_id);
				if (next_id > 1 && c[next_id ^ 1] == wc) {
					ret = (ret + MUL(MUL(multi, val[next_id ^ 1]), next_id / 2)) % MOD;
				}
			}
			return;
		}
		dfs2(id * 2, multi);
		dfs2(id * 2 + 1, multi);
	};
	for (int r = 1; r < l; r++) {
		++wc;
		dfs1(r * 2, r);
		dfs2(r * 2 + 1, 1);
	}
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 5892
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

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

   int a;
   cin >> a;
   int ans = a + a * a + a * a * a;
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 3608
#include "bits/stdc++.h"
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
typedef long long ll;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef set<int> SI;
typedef map<string, int> MSI;
typedef map<int, int> MII;
typedef pair<ll, ll> PLL;
typedef pair<ll, pair<ll, ll>> PLLL;

#define flash ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MP make_pair
#define PB push_back
#define FF first
#define SS second
#define MOD 1000000007
#define test ll t;cin>>t;while(t--)

void solve()
{
	ll n;
	cin >> n;
	int dp[2001]={0};
	dp[1]=0;dp[2]=0;dp[3]=1;
	for(int i=4;i<=2000;i++)
		dp[i]=(dp[i-1]+dp[i-3])%MOD;

	cout << dp[n];
	return;
}

int main()
{
	flash;

	// test
	// {
	// 	solve();
	// }
	solve();

	return 0;
}


Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.util.TreeMap;

public class Main {

	/* several useful subroutines */
	private static final BigDecimal BD1000000007 = new BigDecimal(1000000007);
	private static BufferedReader brStdin = new BufferedReader(new InputStreamReader(System.in));
	private static String[] readBuf = null;
	private static int readPtr = 0;
	private static String getString() throws IOException {
		while ( readBuf == null || readPtr >= readBuf.length ) {
			readBuf = brStdin.readLine().split(" ");
			readPtr = 0;
		}
		return readBuf[readPtr++];
	}
	private static int getInt() throws IOException {
		return Integer.parseInt(getString());
	}
	private static long getLong() throws IOException {
		return Long.parseLong(getString());
	}
	private static BigDecimal getBD() throws IOException {
		return new BigDecimal(getString());
	}
	@SuppressWarnings("unused")
	private static String[] getStringArray(int size) throws IOException {
		String stringArray[] = new String[size];
		for (int i = 0; i < stringArray.length; i++) {
			stringArray[i] = getString();
		}
		return stringArray;
	}
	@SuppressWarnings("unused")
	private static int[] getIntArray(int size) throws IOException {
		int intArray[] = new int[size];
		for (int i = 0; i < intArray.length; i++) {
			intArray[i] = getInt();
		}
		return intArray;
	}
	@SuppressWarnings("unused")
	private static long[] getLongArray(int size) throws IOException {
		long longArray[] = new long[size];
		for (int i = 0; i < longArray.length; i++) {
			longArray[i] = getLong();
		}
		return longArray;
	}
	@SuppressWarnings("unused")
	private static BigDecimal[] getBDArray(int size) throws IOException {
		BigDecimal bdArray[] = new BigDecimal[size];
		for (int i = 0; i < bdArray.length; i++) {
			bdArray[i] = getBD();
		}
		return bdArray;
	}
	private static BigDecimal mod1000000007(BigDecimal bd) {
		return bd.subtract(BD1000000007.multiply(bd.divide(BD1000000007, BigDecimal.ROUND_DOWN))) ;
	}
	@SuppressWarnings("unused")
	private static BigDecimal mod1000000007(int i) {
		return mod1000000007(new BigDecimal(i)) ;
	}
	@SuppressWarnings("unused")
	private static BigDecimal mod1000000007(long l) {
		return mod1000000007(new BigDecimal(l)) ;
	}

	
	/* main routine */
	public static void main(String args[]) throws IOException {
		int n = getInt();
		int a[] = getIntArray(n);
		TreeMap<Integer,Integer> tm = new TreeMap<>();

		for ( int b : a ) {
			Integer x = tm.navigableKeySet().floor(b-1);
			if ( x != null ) {
				int c = tm.get(x)-1;
				if ( c == 0 ) {
					tm.remove(x);
				} else {
					tm.put(x, c);
				}
				if ( tm.containsKey(b) ) {
					tm.put(b, tm.get(b)+1);
				} else {
					tm.put(b, 1);
				}
			} else {
				if ( tm.containsKey(b) ) {
					tm.put(b, tm.get(b)+1);
				} else {
					tm.put(b, 1);
				}
			}
		}
		int ans = 0;
		for ( int c : tm.values() ) {
			ans += c;
		}
		System.out.println( ans );
	}
}


Measured memory_bytes: 43092
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());
        int m = Integer.parseInt(sc.next());
        int[][] e = new int[n][n];
        for (int i = 0; i < m; i++) {
            int a = Integer.parseInt(sc.next()) - 1;
            int b = Integer.parseInt(sc.next()) - 1;
            e[a][b] = 1;
            e[b][a] = 1;
        }
        boolean[] visited = new boolean[n];
        visited[0] = true;
        System.out.println(dfs(0, n, visited, e));
    }

    private static int dfs(int v, int n, boolean[] visited, int[][] e) {
        boolean allVisited = true;
        for (int i = 0; i < n; i++) {
            if (!visited[i]) {
                allVisited = false;
                break;
            }
        }
        if (allVisited) {
            return 1;
        }
        int ans = 0;
        for (int i = 0; i < n; i++) {
            if (e[v][i] == 0) {
                continue;
            }
            if (visited[i]) {
                continue;
            }
            visited[i] = true;
            ans += dfs(i, n, visited, e);
            visited[i] = false;
        }
        return ans;
    }
}

Measured memory_bytes: 23764
/*
問題文
プログラミングでは 16 進数がよく使われます。
16 進数では 0,1,…,9 の数字の他に A, B, C, D, E, F の 6 つのアルファベットを使い，それぞれ 10,11,12,13,14,15 を表します。
この問題では 2 つのアルファベット X,Y が与えられます。 X と Y はどちらも A, B, C, D, E, F のうちどれかです。
X と Y を 16 進数として見たとき，どちらのほうが大きいかを判定してください。
*/

#include<iostream>
#include<vector>
#include<map>

int main() {
	std::vector<char> v;
	v.resize(2);  //reserveがなんか…？
	std::map<char, int> mp;
	mp['A'] = 10;  //結局連番の大小なので0から並べても良かったが問題に従った
	mp['B'] = 11;
	mp['C'] = 12;
	mp['D'] = 13;
	mp['E'] = 14;
	mp['F'] = 15;

	for (auto&& x : v) {
		std::cin >> x;
	}

	std::cout << (mp[v[0]] < mp[v[1]] ? "<":mp[v[0]]>mp[v[1]]? ">":"=") << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <vector>

#define TRACE(x) std::cout << #x << " = " << x << "\n"
#define _ << " _ " <<

using namespace std;

using i64 = int64_t;

struct Pt {
  i64 x, y;
};

int ccw(Pt& a, Pt& b, Pt& c) {
  i64 w = 0;
  w += a.x * (b.y - c.y);
  w += b.x * (c.y - a.y);
  w += c.x * (a.y - b.y);
  return w < 0 ? -1 : w > 0;
}

int main() {
  std::ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  vector<i64> A(N, 0), B(N, 0);
  for (int i = 0; i < N; ++i) cin >> A[i];
  for (int i = 0; i < N; ++i) cin >> B[i];

  int idx = max_element(A.begin(), A.end()) - A.begin();
  rotate(A.begin(), A.begin() + idx, A.end());
  rotate(B.begin(), B.begin() + idx, B.end());

  A.push_back(A[0]);
  B.push_back(B[0]);
  N++;

  vector<i64> C(N);
  vector<i64> D(N);
  D[N - 1] = -2 * B[N - 1];
  for (int i = N - 2; i >= 0; --i) {
    D[i] = D[i + 1] - 2 * B[i];
  }

  C[0] = D[0];
  for (int i = 1; i < N; ++i) {
    C[i] = C[i - 1] + D[i];
  }

  vector<Pt> hull;
  for (int i = 0; i < N; ++i) {
    Pt p{i, A[i] - C[i]};
    while (hull.size() >= 2 &&
           ccw(hull[hull.size() - 2], hull.back(), p) >= 0) {
      hull.pop_back();
    }
    hull.push_back(p);
  }

  vector<long double> ret(N);
  for (auto& p : hull) ret[p.x] = p.y;

  for (int i = 0; i + 1 < (int)hull.size(); ++i) {
    int l = hull[i].x;
    int r = hull[i + 1].x;
    for (int j = l + 1; j < r; ++j) {
      ret[j] = (ret[l] * (r - j) + ret[r] * (j - l)) / (r - l);
    }
  }
  for (int i = 0; i < N; ++i) {
    ret[i] += C[i];
  }

  long double ans = accumulate(ret.begin(), ret.end() - 1, 0.0) / (N - 1);
  cout << setprecision(30) << ans << '\n';
  return 0;
}


Measured memory_bytes: 17080
// -*- mode:c++; coding:utf-8; indent-tabs-mode:nil; -*-
// ALDS1_5-C: Koch Curve

#include <cstdio>
#include <cmath>

struct point {
  const double x_, y_;
  point(double x, double y) : x_(x), y_(y) { }
  point rotate_m60() const;
private:
  static double sin60, cos60;
};

double point::sin60 = std::sin(M_PI*60.0/180.0);
double point::cos60 = std::cos(M_PI*60.0/180.0);

point point::rotate_m60() const {
  return point(x_*cos60 - y_*sin60,
               x_*sin60 + y_*cos60);
}

point operator +(const point& p, const point& q) { return point(p.x_+q.x_, p.y_+q.y_); }
point operator -(const point& p, const point& q) { return point(p.x_-q.x_, p.y_-q.y_); }
point operator *(const double m, const point& p) { return point(m*p.x_, m*p.y_); }
point operator /(const point& p, const double d) { return point(p.x_/d, p.y_/d); }

void print_point(const point& p) { std::printf("%.8f %.8f\n", p.x_, p.y_); }

void print_koch(unsigned int n, const point& p1, const point& p2) {
  if (n == 0) return;
  point s = (2*p1 + p2)/3;
  point t = (p1 + 2*p2)/3;
  point u = (t-s).rotate_m60() + s;

  print_koch(n-1, p1, s);
  print_point(s);
  print_koch(n-1, s, u);
  print_point(u);
  print_koch(n-1, u, t);
  print_point(t);
  print_koch(n-1, t, p2);
}

int main(void) {
  unsigned int n;
  std::scanf("%d", &n);

  point p1 = point(0.0, 0.0);
  point p2 = point(100.0, 0.0);

  print_point(p1);
  print_koch(n, p1, p2);
  print_point(p2);

  return 0;
}

// end

Measured memory_bytes: 2752
#!/usr/bin/env python3
count=0
n,m=map(int,input().split())
ans=[0]*m
data=[list(map(int,input().split())) for i in range(n)]
for i in range(n):
    for j in range(1,len(data[i])):
        ans[data[i][j]-1]+=1
for a in ans:
    if a==n:
        count+=1
print(count)


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int main(){
    string s, t;
    cin >> s >> t;
    ll count = 0;
    rep(i,3){
        if(s[i]==t[i]){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = len(s);
    if(s[n-1] == '1' || s[0] == '0'){
        cout << "-1\n";
        return 0;
    }
    rep(i,(n-1)/2){
        if(s[i] != s[n-2-i]){
            cout << "-1\n";
            return 0;
        }
    }
    if(s[(n-1)/2] == '0'){
        vp vec;
        int nw = 0;
        rep(i,n/2-1){
            vec.pb(P(nw+1, i+2)), vec.pb(P(n-nw, n-i-1));
            if(s[i] == '1'){
                nw = i+1;
            }
        }
        if(n % 2 == 0){
            rep(i,len(vec)){
                cout << ((vec[i].fi == n-nw)?(nw+1):(vec[i].fi)) << " " << ((vec[i].se == n-nw)?(nw+1):(vec[i].se)) << "\n";
            }
            cout << nw+1 << " " << n-nw << "\n";
        }else{
            rep(i,len(vec)){
                cout << ((vec[i].fi == n-nw)?(nw+1):(vec[i].fi)) << " " << ((vec[i].se == n-nw)?(nw+1):(vec[i].se)) << "\n";
            }
            cout << nw+1 << " " << n-nw << "\n";
            cout << nw+1 << " " << n/2+1 << "\n";
        }
    }else{
        int nw = 0;
        rep(i,(n-1)/2){
            cout << nw+1 << " " << i+2 << "\n";
            cout << n-nw << " " << n-i-1 << "\n";
            if(s[i] == '1'){
                nw = i+1;
            }
        }
        if(n % 2 == 0){
            cout << nw+1 << " " << n-nw << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 2292
import itertools

def comb(a,b):
    if a<=0:
        return 0
    if b==1:
        return a
    elif b==2:
        return a*(a-1)//2
    else:
        return a*(a-1)*(a-2)//6

def tmp(L, K):
    ret=[]
    if K==1:
        bases=itertools.combinations(range(L+1),K)    
        for b in bases:
            ret+=[ k*10**b[0] for k in range(1,10)]
    if K==2:
        bases=itertools.combinations(range(L+1),K)
        kk=list(itertools.product(range(1,10),range(1,10)))
        for b in bases:
            ret+=[ k[0]*10**b[0] + k[1]*10**b[1] for k in kk]
    return ret

Nst=input()
K=int(input())
L=len(Nst)
N1=int(Nst[0])

if K==1:
    ans=comb( L-1, K) * 9 + N1
elif K>=2:
    ans=comb( L-1, K) * 9**(K) + comb( L-1, K-1) * 9**(K-1) *(N1-1)
    lst=[ 10**(L-1)*N1 + a for a in tmp(L-1, K-1)]
    ans+=sum([x <= int(Nst) for x in lst])
print (ans)

Measured memory_bytes: 147344
s = []
N = int(input())
for i in range(N):
    s.append(input())

count_A = 0
count_B = 0
count_AB = 0
count = 0

for i in range(N):
    flag = False
    for j in range(len(s[i])):
        if j == 0 and s[i][j] == "B":
            count_B += 1
            flag = True
        if s[i][j] == "A":
            if j == len(s[i]) - 1:
                count_A += 1
                if flag:
                    count_A -= 1
                    count_B -= 1
                    count_AB += 1
            elif s[i][j+1] == "B":
                count += 1

if count_A == 0 and count_B == 0:
    if count_AB > 0:
        count += count_AB - 1

else:
    if count_A <= count_B:
        count += count_A
    else:
        count += count_B

    count += count_AB

print(count)

Measured memory_bytes: 45148
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<bitset>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x%p;
		x = x * x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
short ctos(char a) {
	return (int)(a - '0');
}
#define int short
const long long Inf = 4523372036854775807;
const int inf = 15000000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int n, m, x, y, t, X = -1000, Y = 1000;
	cin >> n >> m >> x >> y;
	for (int i = 0; i < n; i++) {
		cin >> t;
		X = max(X, t);
	}
	for (int i = 0; i < m; i++) {
		cin >> t;
		Y = min(t, Y);
	}
	for (int i = X + 1; i <= Y; i++) {
		if (x < i&&i <= y) {
			cout << "No War\n";
			return 0;
		}
	}
	cout << "War\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int main()
{
int n;
cin >> n;
vector<int> p(n),q(n);
rep(i,n) cin >> p[i];
rep(i,n) cin >> q[i];

vector<int> a(n);
rep(i,n) a[i]=i+1;

map<vector<int>, int> mp;
do{
    mp[a] = mp.size();
}while(next_permutation(a.begin(),a.end()));

int ans = abs(mp[p] - mp[q]);
cout << ans << endl;

return 0;
}

Measured memory_bytes: 5248
#include <stdio.h>
#include <math.h>

int main()
{
    double x1, y1, x2, y2;
    scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2);

    printf("%lf\n", (double)hypot(x1-x2, y1-y2));

    return 0;
}


Measured memory_bytes: 2816
# Pythonの組み込み関数powを使ったバージョン
MOD = 10**9+7

fact, invfact = [0]*(10**5+2), [0]*(10**5+2)
fact[0], invfact[0] = 1, 1

for i in range(1, 10**5+2):
  fact[i] = (fact[i-1]*i)%MOD
  invfact[i] = pow(fact[i], MOD-2, MOD)

def mod_comb(n, r):
  if n<r or n==0 or r==0: return 0
  return (((fact[n]*invfact[r])%MOD)*invfact[n-r])%MOD

from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
d = defaultdict(int)
for i, ele in enumerate(a):
  if d[ele] == 0:
    d[ele]= i+1
  else:
    l = d[ele]
    r = i+1

print(n)
for k in range(2, n+2):
  print((mod_comb(n+1, k)-mod_comb(l-1+n-r+1, k-1))%MOD)

Measured memory_bytes: 28920
#include<stdio.h>
int main(){
    int a,b,d,r;
    double f;
    scanf("%d %d",&a,&b);
    d = a/b;
    r = a%b;
    f = (double)a/(double)b;
    printf("%d %d %lf\n",d,r,f);
    return 0;
}

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

int main(){
  
  int a,ans,i;
  string s,t;
  ans=0;
 cin >> s >> t;
  
  a = s.length();
  
  for(i=0;i<a;i++){
    if(s[i]!=t[i]){
     ans++;
    }
  }
  
  cout << ans;
  
  return 0;
}

Measured memory_bytes: 3848
#include "bits/stdc++.h"
#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define p(s) cout<<(s)<< endl
#define p2(a, b) cout<<(a) << " " << (b) << endl
using namespace std;
typedef long long ll;

struct rect{
	ll height;
	ll width;
	ll taikaku;
};

bool cmp_height(const rect &A, const rect &B){
	return A.height < B.height;
}

bool cmp_taikaku(const rect &A, const rect &B){
	return A.taikaku < B.taikaku;
}

int main() {
	ll height,width;
	vector<rect> rectangles;
	while(cin >> height >> width && height) {
		rectangles.clear();
		REP(h, 1, 151) {
			REP(w, h+1, 151) {
				if (w > h) rectangles.push_back({h, w, h*h + w*w});
			}
		}
		sort(rectangles.begin(),rectangles.end(), cmp_height);
		stable_sort(rectangles.begin(),rectangles.end(), cmp_taikaku);

		/**
		for (auto r : rectangles) {
			p2(r.width,r.height);
		}
		 **/



		bool flag=false;
		ll ans_h,ans_w;
		for (auto r : rectangles) {
			if(flag){
				ans_h = r.height;
				ans_w = r.width;
				break;
			}
			if(r.height==height && r.width==width) flag=true;
		}
		p2(ans_h, ans_w);


	}
	return 0;
}


Measured memory_bytes: 3512
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n,a=0,b=0,ans=0,u=0;
    cin >> n;
    vector<string> s(n);
    for (int i=0;i<n;i++){
        cin >> s.at(i);
        if (s.at(i).at(0)=='B' &&s.at(i).at(s.at(i).size()-1)=='A') u++;
        else if (s.at(i).at(0)=='B') b++;
        else if (s.at(i).at(s.at(i).size()-1)=='A') a++;
        for (int I=0;I<s.at(i).size()-1;I++){
            if (s.at(i).at(I)=='A' && s.at(i).at(I+1)=='B') ans++;
        }
    }
    if (a==0 && b==0 && u>0) cout << ans+u-1<< endl;
    else cout << ans+min(u+a,u+b) << endl;
}


Measured memory_bytes: 768
N,M = map(int, input().split())
List = []
for i in range(N):
    List.append([int(m) for m in input().split()])

for j in range(N):
    List[j].remove(List[j][0])

ans = 0
for k in range(len(List[0])):
    num = 0
    for l in range(1,N):
        if List[0][k] in List[l]:
            num += 1
        else:
            break
    if num == N-1:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define _ << " " <<
#define all(v) v.begin(), v.end()
#define sp(n) fixed << setprecision(n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

const int mod = 1e9 + 7;

struct pr {
	int d, n;
};

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	for (int& i : a) cin >> i;
	for (int i = 0; i < n - 1; i++) swap(a[i], a.back());
	vector<pr> b(n);
	b[0] = { a[0], -1 };
	for (int i = 1; i < n; i++) b[i] = pr{ a[i] - b[i - 1].d,  -b[i - 1].n };

	vector<int> ans(n);
	ans.back() = b.back().d / (1 - b.back().n);
	ans[0] = a[0] - ans.back();
	for (int i = 1; i < n - 1; i++) ans[i] = a[i] - ans[i - 1];
	for (int& i : ans) i *= 2;
	for (int& i : ans) cout << i << " ";
	cout << endl;
	return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N; cin>>N;
  vi A(3*N);
  rep(i,0,3*N) cin>>A[i];
  sort(ALL(A));
  int ans=0;
  rep(i,N,3*N){
    if((i-N)%2==0)
      ans+=A[i];
  }
  cout<<ans<<endl;
  }


Measured memory_bytes: 2560