akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#define ps(arr) \
    for(auto e: arr) cout << e << " "; \
    cout << endl;
#else
#define debug(fmt, ...)
#define ps(arr)
#endif

#define INF (1e+13)

int64_t calc_ms(vector<int>& arr, vector<int64_t>& foods, int64_t key) {
    int num = arr.size();
    vector<int64_t> after(num);
    for(int i = 0; i < num; i++) {
        after[i] = key / foods[i];
    }
    sort(after.begin(), after.end());
    ps(arr); ps(after);
    int64_t ans = 0;
    for(int i = 0; i < num; i++) {
        ans += max(arr[i] - after[i], (int64_t)0);
    }
    debug("%lld -> %lld\n", key, ans);
    return ans;
}

int main(void) {
    int num;
    int64_t k;
    cin >> num >> k;
    vector<int> arr(num);
    cins(arr);
    sort(arr.begin(), arr.end());
    vector<int64_t> foods(num);
    cins(foods);

    int64_t low = -1;
    int64_t high = INF;
    while(low + 1 < high) {
        int64_t mid = (low + high) / 2;
        if(calc_ms(arr, foods, mid) <= k) {
            high = mid;
        } else {
            low = mid;
        }
        debug("%lld %lld %lld\n", low, mid, high);
    }
    cout << high << endl;
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector< vector<int> > A(2, vector<int>(N));
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < N; j++) {
            cin >> A.at(i).at(j);
        }
    }

    int ans1 = 0, ans2;
    for (int k = 0; k < N; k++) {
        ans2 = 0;
        for (int l = 0; l <= k; l++) {
            ans2 += A.at(0).at(l);
        }
        for (int m = k; m < N; m++) {
            ans2 += A.at(1).at(m);
        }
        ans1 = max(ans1, ans2);
    }

    cout << ans1 << endl;
}

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

int main() {
	int a,b,min,max;
	int ans = -1;
	cin >> a >> b;
	if((a * 100) % 8==0) min = a * 100 / 8;
	else min = a * 100 / 8 + 1;
	if ((a + 1) * 100 % 8 == 0)max = (a + 1) * 100 / 8;
	else max = (a + 1) * 100 / 8 + 1;

	for (int i = min;i < max;i++) {
		if ((int)(i*0.1) == b) {
			ans = i;
			cout << ans << "\n";
			return 0;
		}
	}

	cout << ans<< "\n";
	return 0;
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

int main() {
    int N;
    ll X[100005];
    cin >> N;

    ll ans = 1;
    for (int i = 0; i < N; i++) cin >> X[i];
    
    int j = 0;
    for (int i = 0; i < N - 1; i++) {
        while (j < N - 1 && (j - i) * 2 + 1 <= X[j]) j++;
        (ans *= (j - i + 1)) %= mod;
    }
    cout << ans << endl;

    return (0);
}

Measured memory_bytes: 1024
import java.util.Scanner;

class Main {
    static public void main(String args[]){

        Scanner scan = new Scanner(System.in);
        int Apizza = scan.nextInt();
        int Bpizza = scan.nextInt();
        int ABpizza = scan.nextInt();
        int X = scan.nextInt();
        int Y = scan.nextInt();

        int price=(int)1e9;

        price = Math.min(price, ABpizza * Math.max(X,Y)) * 2;
        price = Math.min(price, ABpizza * Math.min(X,Y) * 2 + (Math.max(X,Y)==X ? Apizza : Bpizza) * Math.abs(X-Y));
        price = Math.min(price, Apizza * X + Bpizza * Y);

        System.out.println(price);

    }
}

Measured memory_bytes: 21844
a = []
while(True):
    n = int(input())
    if n == 0:
        break
    a.append(n)
    if len(a) == 5:
        uni = set(a)
        if len(uni) == 2 and 1 in uni and 2 in uni:
            for b in a: print(2 if b == 2 else 1)
        elif len(uni) == 2 and 2 in uni and 3 in uni:
            for b in a: print(2 if b == 3 else 1)
        elif len(uni) == 2 and 3 in uni and 1 in uni:
            for b in a: print(2 if b == 1 else 1)
        else:
            for _ in range(5): print(3)
        a = []



Measured memory_bytes: 5588
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
from bisect import bisect_left

n, k = map(int, input().split())
v = list( map(int, input().split()))

amax = min(n,k)
ans = 0
for a in range(amax+1):
    bmax = amax - a
    for b in range(bmax+1):

        getlist = v[:a] + v[n-b:]
        getlist.sort()
        cdmax = k - a - b
        zero_index = bisect_left(getlist, 0)
        start = min(zero_index, cdmax)
        tmp = sum(getlist[start:])
        ans = max(ans, tmp)

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;


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

    int n;
    cin >> n;
    vector<int> a(n),b(n);
    rep(i,n) cin >> a[i] >> b[i];
    vector<vector<int>> dp(n,vector<int>(n,1e9)); 
    rep(i,n) dp[i][i]=0;
    repr(i,1,n) {
        invrep(j,i) {
            repr(k,j,i) {
                dp[j][i]=min(dp[j][i],dp[j][k]+dp[k+1][i]+a[j]*b[k]*b[i]);
            }
        }
    }
    cout << dp[0][n-1] << endl;

    return 0;   
}



Measured memory_bytes: 3176
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const int MAX_N = 405;

vector<pair<int, int>> adj [MAX_N];

int vis [MAX_N];
int fuck [MAX_N];
vector<pair<int, pair<int, int>>> constr [MAX_N];

void add_constr (int u, int t, int src) {
  vis[u] = 1;
  for (pair<int, int> nxt : adj[u]) {
    if (nxt.first >= t) {
      break;
    }

    if (vis[nxt.second]) {
      fuck[src] = 1;
      break;
    }

    constr[src].push_back(make_pair(nxt.first, make_pair(u, nxt.second)));
    add_constr(nxt.second, nxt.first, src);
  }
}

vector<pair<int, pair<int, int>>> merge (const vector<pair<int, pair<int, int>>> &u,
                                         const vector<pair<int, pair<int, int>>> &v) {
  vector<pair<int, pair<int, int>>> ans;
  int uptr = 0, vptr = 0;
  while (uptr < (int) u.size() && vptr < (int) v.size()) {
    if (u[uptr] < v[vptr]) {
      ans.push_back(u[uptr]);
      uptr++;
    } else {
      ans.push_back(v[vptr]);
      vptr++;
    }
  }

  while (uptr < (int) u.size()) {
    ans.push_back(u[uptr]);
    uptr++;
  }

  while (vptr < (int) v.size()) {
    ans.push_back(v[vptr]);
    vptr++;
  }

  return ans;
}

int indeg [MAX_N];
bool fits (int u, int v, int n) {
  for (int i = 1; i <= n; i++) {
    indeg[i] = 0;
  }

  vector<pair<int, pair<int, int>>> merged = merge(constr[u], constr[v]);
  pair<int, pair<int, int>> last = {-1, {-1, -1}};
  for (auto pr : merged) {
    if (pr.first == last.first) {
      if (pr.second != last.second) {
        return false;
      }
    } else {
      indeg[pr.second.second]++;
    }
    last = pr;
  }

  for (int i = 1; i <= n; i++) {
    if (indeg[i] > 1) return false;
  }

  if (indeg[u] > 0) return false;
  if (indeg[v] > 0) return false;
  return true;
}

int main () {
  ios::sync_with_stdio(false);

  int n, m;
  cin >> n >> m;

  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;

    adj[u].push_back(make_pair(i, v));
    adj[v].push_back(make_pair(i, u));
  }

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      vis[j] = 0;
    }
    add_constr(i, m, i);
    sort(constr[i].begin(), constr[i].end());
  }

  int ans = 0;
  for (int u = 1; u <= n; u++) {
    if (!fuck[u]) {
      for (int v = u + 1; v <= n; v++) {
        if (!fuck[v]) {
          if (fits(u, v, n)) {
            ans++;
          }
        }
      }
    }
  }

  cout << ans << endl;
}


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

int main(){
  string S; cin >> S;
  if(S=="SUN") cout << 7;
  else if(S=="MON") cout << 6;
  else if(S=="TUE") cout << 5;
  else if(S=="WED") cout << 4;
  else if(S=="THU") cout << 3;
  else if(S=="FRI") cout << 2;
  else if(S=="SAT") cout << 1;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
using namespace __gnu_pbds;
using namespace std;
typedef tree<
    pair<int, int>,
    null_type,
    less_equal<pair<int, int>>,
    rb_tree_tag,
    tree_order_statistics_node_update>
    ordered_set;
#define int long long
#define double long double
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define lb(v, z) lower_bound(all(v), z)
#define ub(v, z) upper_bound(all(v), z)
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define rdp(i, a, b) for (int i = (a); i >= (b); i--)
#define rlt(i, a, b) for (int i = (a); i < (b); i++)
#define cns(z) cout << (z) << ' '
#define cnl(z) cout << (z) << '\n'
#define M1 1000000007
#define M2 998244353
#define MAXN 300005
#define INF (1ll << 60)
#define endl "\n"
#define garr(ip)       \
    for (auto &x : ip) \
        cin >> x;
#define parr(ip)          \
    for (auto &x : ip)    \
        cout << x << " "; \
    cout << endl;
#define nl cout << endl
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vp;

void solve(int testCaseNumber = 1)
{
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vi r(A), g(B), c(C);
    garr(r);
    garr(g);
    garr(c);
    sort(all(r), greater<int>());
    sort(all(g), greater<int>());
    rlt(i, 0, X) c.push_back(r[i]);
    rlt(i, 0, Y) c.push_back(g[i]);
    sort(all(c), greater<int>());
    int ans = 0;
    rlt(i, 0, X + Y) ans += c[i];
    cnl(ans);
}

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

Measured memory_bytes: 7824
#include<bits/stdc++.h>
#include<numeric>
using namespace std;
#define ll long long
#define Graph vector<vector<long long>>
#define all(v) v.begin(),v.end()
#define PI acos(-1)
#define inf 5000000321
#define mod107 1000000007;

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

int main(){
    string S;
    cin >> S;
    if(S[S.size()-1] == 's')cout << S  << "es" << endl;
    else cout << S << "s" << endl;
}


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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second
//#define x real()
//#define y imag()
#define length(a) (hypot((a).imag() , (a).real()))
#define point complex<ld>
#define perp(a) point((-(a).Y,(a).X))
#define dot(a,b) ( (conj(a)*(b)).real() )
#define cross(a,b) ( (conj(a)*(b)).imag() )
#define rotate0(p,ang) (p * exp(point(0,ang)) )

const int N = 5e5+5;

ll n,k,a[N];

bool check(ll mid)
{
    ll kk=k , tmp;
    for(int i=1; i<=n; i++)
    {
        if (a[i] < mid) continue;
        tmp = (a[i]/mid)-1 + (a[i]%mid != 0);
        if (tmp > kk) return 0;
        kk -= tmp;
    }
    return 1;
}

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

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

    ll l=1 , h=1e9 , mid , idx=1e9;
    while(l<=h)
    {
        mid = (l+h)/2;
        if (check(mid))
        {
            idx = min(idx , mid);
            h = mid-1;
        }
        else l=mid+1;
    }

    cout << idx << '\n';

    return 0;
}


Measured memory_bytes: 5100
import java.util.*;

public class Main {

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

        final int N = sc.nextInt();
        final int M = sc.nextInt();

        int L = Integer.MIN_VALUE;
        int R = Integer.MAX_VALUE;
        for (int i = 0; i < M; i++) {
            L = Math.max(L, sc.nextInt());
            R = Math.min(R, sc.nextInt());
        }

        System.out.println(R >= L ? R - L + 1 : 0);
    }
}


Measured memory_bytes: 63420
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N + 1];
		Arrays.setAll(A, i -> sc.nextInt());
		int[] B = new int[N];
		Arrays.setAll(B, i -> sc.nextInt());
		sc.close();

		long ans = 0;
		for (int i = N - 1; i >= 0; i--) {
			// i番目のヒーローが倒した敵の数
			int buster = Math.min(B[i], A[i + 1] + A[i]);
			// i番目のヒーローがあと倒せる数
			int restPower = Math.max(0, B[i] - A[i + 1]);
			// A[i]番目で倒されなかったモンスターの数
			int restMonster = Math.max(0, A[i] - restPower);

			ans += buster;
			A[i] = restMonster;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 88256
N = int(input())

A = sorted(list(map(int,input().split())),reverse=True)

min_abs = A[0]
ans = 1
for i in range(1,N):
    if A[i]*2 >= min_abs:
        ans += 1
    elif sum(A[i:])*2 >= min_abs:
        ans += 1
    else:
        break
    min_abs = A[i]
    
print(ans)

Measured memory_bytes: 14320
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
int main(){
	string s,t;
	cin>>s>>t;
	int A = s.size(), B = t.size();
	VV<int> dp(A+1,V<int>(B+1,-1));
	dp[0][0] = 0;
	VV<int> from(A+1,V<int>(B+1,0));
	rep(i,A+1) rep(j,B+1){
		if(i!=A){
			if(dp[i+1][j] < dp[i][j]){
				dp[i+1][j] = dp[i][j];
				from[i+1][j] = 0;
			}
		}
		if(j!=B){
			if(dp[i][j+1] < dp[i][j]){
				dp[i][j+1] = dp[i][j];
				from[i][j+1] = 1;
			}
		}
		if(i!=A && j!=B && s[i]==t[j]){
			if(dp[i+1][j+1] < dp[i][j]+1){
				dp[i+1][j+1] = dp[i][j]+1;
				from[i+1][j+1] = 2;
			}
		}
	}
	string ans;
	int x = A, y = B;
	while(!(x==0 && y==0)){
		if(from[x][y]==0){
			x--;
		}else if(from[x][y]==1){
			y--;
		}else{
			x--,y--;
			ans += s[x];
		}
	}
	reverse(all(ans));
	cout<<ans<<endl;
}

Measured memory_bytes: 70912
#include <stdio.h>
#include <string.h>

#define S_MAX 100000

int main(){

    char s[S_MAX];
    int len;
    int cnt_0 = 0; 
    int cnt_1 = 0;
    int i;

    scanf("%s", s);
    len = strlen(s);

    for(i=0 ; i<len ; i++){
        if(s[i]=='0'){
            cnt_0++;
        }
        else{
            cnt_1++;
        }
    }
    
    if(cnt_0 < cnt_1){
        printf("%d", cnt_0*2);
    }
    else{
        printf("%d", cnt_1*2);        
    }

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int N, K,x;
	int ans = 0;
	cin >> N >> K;
	for (int i = 0; i < N; i++)
	{
		cin >> x;
		if (K-x<x)
		{
			ans += (K - x) * 2;
		}
		else
		{
			ans += x * 2;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int a, b ,c, d;
    cin >> a >> b >> c >> d;

    print(min(a, b) + min(c, d));
    
}


Measured memory_bytes: 3596
#include<stdio.h>

int main(void)
{
	int i, a1, a2, a3, n;
	a1 = a2 = a3 = 0;
	for( i=0; i<10; i++ ) {
		scanf( "%d", &n);
		if(n > a1){
			a3 = a2;
			a2 = a1;
			a1 = n;
		}
		else
			if(n > a2){
				a3 = a2;
				a2 = n;
			}
			else
				if(n > a3)
					a3 = n;
	}
		printf( "%d\n%d\n%d\n", a1, a2, a3);
		return 0;
}

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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;

typedef long long ll;
typedef pair<int,int> pii;

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 3e5 + 9, M = 4e5 + 9, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;

int main(){
    init();

    int a, b;   cin >> a >> b;
    for(int i = 1;i <= 1000;i++){
        if(int(i * 0.08) == a && int(i * 0.1) == b)   return cout << i, 0;
    }

    cout << -1;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
lr=[list(map(int,input().split())) for _ in range(k)]

mod=998244353

dp=[0]*(n+1)
csum=[0]*(n+2)
dp[0]=1

for i in range(n):
    for j in range(k):
        l,r=lr[j]
        dp[i]+=csum[max(i+1-l,0)]-csum[max(i-r,0)]
        dp[i]%=mod
    csum[i+1]+=dp[i]+csum[i]
    csum[i+1]%=mod

print(dp[n-1])

Measured memory_bytes: 76932
import collections
 
def answer(list,n):
    Even = collections.Counter(list[::2]).most_common(2)
    Odd = collections.Counter(list[1::2]).most_common(2)
 
    if Even[0][0] != Odd[0][0]:
        return n - Even[0][1] - Odd[0][1]
    else:
        if len(Even) == 1 or len(Odd) == 1:
            return n // 2
        else:
            return n - max(Even[0][1]+Odd[1][1],Even[1][1]+Odd[0][1])
 
N = int(input())
list = input().split(" ")
print(answer(list,N))

Measured memory_bytes: 16224
#include<stdio.h>

int main(void){
  int x;
  scanf("%d",&x);
  if(x<=599){
    printf("8");
    return 0;
  }
  else if(x<=799){
    printf("7");
    return 0;
  }
  else if(x<=999){
    printf("6");
    return 0;
  }
  else if(x<=1199){
    printf("5");
    return 0;
  }
  else if(x<=1399){
    printf("4");
    return 0;
  }
  else if(x<=1599){
    printf("3");
    return 0;
  }
  if(x<=1799){
    printf("2");
    return 0;
  }
  else if(x<=1999){
    printf("1");
    return 0;
  }
  return 0;
}

Measured memory_bytes: 1644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
const ld EPS = 1e-12L;
const ld PI = 3.1415926535897932385L;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class S, class T>inline bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class S, class T>inline bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

template<class T>
void PrintVector(vector<T>& vec){
    int n = vec.size();
    for(int i = 0; i < n; i++){
        cout << vec[i] << (i == n-1 ? "\n" : " ");
    }
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll h, w, k;
    cin >> h >> w >> k;
    vs s(h);
    rep(i, h){
        cin >> s[i];
    }
    vvll ans(h, vll(w, 0));
    ll cnt = 0;
    rep(i, h){
        rep(j, w){
            if(s[i][j] == '#'){
                cnt++;
                ll k = j;
                while(k >= 0 && ans[i][k] == 0){
                    ans[i][k] = cnt;
                    k--;
                }
            }
        }
    }
    rep(i, h){
        if(ans[i][w-1] == 0)repb(j, w){
            if(ans[i][j] != 0){
                repr(k, j+1, w){
                    ans[i][k] = ans[i][j];
                }
                break;
            }
        }
    }
    repr(i, 1, h){
        if(ans[i][0] == 0){
            rep(j, w) ans[i][j] = ans[i-1][j];
        }
    }
    repb(i, h-1){
        if(ans[i][0] == 0){
            rep(j, w) ans[i][j] = ans[i+1][j];
        }
    }
    rep(i, h) PrintVector(ans[i]);
    return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string T;
    cin >> T;
    int length = (int)T.length();

    for (int i = 0; i < length; i++)
    {
        if (T[i] == '?')
            T[i] = 'D';
    }

    cout << T;

    return 0;
}

Measured memory_bytes: 3752
// ABC067_A.cpp : Defines the entry point for the console application.
//

#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
	int a[3], n = 0, m = 0;
	cin >> a[0] >> a[1] >> a[2];
	for (int i = 0; i < 3; i++) {
		if (a[i] == 5) { n++; }
		if (a[i] == 7) { m++; }
	}
	if (n == 2 && m == 1) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}



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

const int mod = 1000000007;
// const int mod = 998244353;

int main(){
    long long n;
    cin>>n;
    vll vec(n);
    rep(i,n){cin>>vec.at(i);}
    sort(vec.begin(),vec.end());
    ll ans;
    ans=vec.at(0);
    rep(i,n){ans=gcd(ans,vec.at(i));}
    cout<<ans;

}


Measured memory_bytes: 4036
/*-------------------------------*
| Name: Ayush Kumar              |
| Site: CSES                     |
| Email: ayushkr667@gmail.com    |
*-------------------------------*/

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define INF (ll) 1e18
const double PI = 3.141592653589793238460;
string s1, s2;
int dp[3001][3001];

void solve(int l1, int l2)
{
    //if l1 or l2 =0 it is already initialized with 0
    for (ll i = 1; i <= l1 ; i++)
    {
        for (int j = 1; j <= l2; j++)
        {
            if( s1[i-1] == s2[j-1])
                dp[i][j] = 1 + dp[i-1][j-1];

            else
                dp[i][j] =  max( dp[i][j-1], dp[i-1][j] );
        }    
    }
}

void lcs(int l1, int l2)
{
    string result ="";
    while (l1 > 0 && l2 > 0)
    {
        if( s1[l1-1] == s2[l2-1] )
        {
            result.pb(s1[l1-1]);
            l1--, l2--;
        }
        else
        {
            if(dp[l1-1][l2] > dp[l1][l2-1])
            {
                l1--;
            }
            else
            {
                l2--;
            }  
        }
    }
    reverse(result.begin(), result.end());
    cout<<result;
}


int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    memset(dp, 0, sizeof(dp));
    cin>>s1>>s2;
    int l1 = s1.size();
    int l2 = s2.size();
    solve(l1, l2);
    lcs(l1, l2);
    return 0;
}


Measured memory_bytes: 38832
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#include <bitset>
#define M 1000000007
#define M1 998244353

#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define fast                        \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

ll power(ll x, ll n)
{
    ll result = 1;
    while (n)
    {
        if (n % 2 == 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}

ll gcd(ll a, ll b)
{
    if (!b)
        return a;
    return gcd(b, a % b);
}

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

inline ll mul(ll x, ll y, ll m)
{
    ll z = 1LL * x * y;
    if (z >= m)
    {
        z %= m;
    }
    return z;
}

ll powmod(ll x, ll y, ll m)
{
    ll r = 1;
    while (y)
    {
        if (y & 1)
        {
            r = mul(r, x, m);
        }
        y >>= 1;
        x = mul(x, x, m);
    }
    return r;
}



void start()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
/***********************************************************************************************************/

int main()
{
    start();
    int n, k, q;
    cin>>n>>k>>q;
    int a[n+1];
    memset(a, 0, sizeof(a));
    unordered_map<int, int> m;
    int t=q;
    while (t--)
    {
        int x;
        cin>>x;
        m[x]++;
    }

    for (int i=1;i<=n;i++)
    {
        if (m.find(i)!=m.end())
        {
            a[i]+=m[i];
        }
        a[i]+=k-q;
        if (a[i]<=0)
        {
            cout<<"No"<<"\n";
        }
        else
        {
            cout<<"Yes"<<"\n";
        }
    }


    return 0;
}

Measured memory_bytes: 6896
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> PII;
typedef long long ll;
const ll mod = 1e9+7;

int scnt[100100][2];
int tcnt[100100][2];

int calc_mod(int num){
  int m = num % 3;
  return (m+3)%3;
}

int main(void){
  string s,t;
  cin >> s;
  scnt[0][0] = 0;scnt[0][1] = 0;
  for(int i = 0;i < (int)s.size();++i){
    scnt[i+1][0] = scnt[i][0];
    scnt[i+1][1] = scnt[i][1];
    if(s[i] == 'A'){
      ++scnt[i+1][0];
    }else{
      ++scnt[i+1][1];
    }
  }
  
  cin >> t;
  tcnt[0][0] = 0;tcnt[0][1] = 0;
  for(int i = 0;i < (int)t.size();++i){
    tcnt[i+1][0] = tcnt[i][0];
    tcnt[i+1][1] = tcnt[i][1];
    if(t[i] == 'A'){
      ++tcnt[i+1][0];
    }else{
      ++tcnt[i+1][1];
    }
  }
  int q;
  cin >> q;
  for(int i = 0;i < q;++i){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int diffs =
      (scnt[b][0] - scnt[a-1][0])
      - (scnt[b][1] - scnt[a-1][1]);
    int difft =
      (tcnt[d][0] - tcnt[c-1][0])
      - (tcnt[d][1] - tcnt[c-1][1]);
    int mods = calc_mod(diffs);
    int modt = calc_mod(difft);
    if(mods == modt){
      puts("YES");
    }else{
      puts("NO");
    }
  }
  return 0;
}


Measured memory_bytes: 2560
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
using namespace std;

int main()
{   
    int n,m;
    cin >> n >> m;
    int a[n];
    int cnt = 0;
    int all = 0;
    for(int i = 0; i< n; i++){
        cin >> a[i];
        all += a[i];
    }
    double ave = double(all) / (4 * m);

    for(int i = 0; i< n; i++){
        if(double(a[i])  >= ave) cnt++;
    }

    if(cnt >= m)  cout << "Yes"<<endl; 
    else  cout <<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
N = input()
ans = ''
if int(N[0]) < int(N[1]):
  ans += str(int(N[0]) + 1)
  ans += str(int(N[0]) + 1)
  ans += str(int(N[0]) + 1)
elif int(N[0]) > int(N[1]):
  ans += N[0]
  ans += N[0]
  ans += N[0]
else:
  if int(N[1]) < int(N[2]):
    ans += str(int(N[0]) + 1)
    ans += str(int(N[0]) + 1)
    ans += str(int(N[0]) + 1)
  elif int(N[1]) > int(N[2]):
    ans += N[0]
    ans += N[0]
    ans += N[0]
  else:
    ans += str(N)
print(ans)


Measured memory_bytes: 3064
S = int(input())
X1,Y1,Y3 = 0,0,10**9
X2,X3,Y2 = [
    [S//(10**9)+1,(10**9)-S%(10**9),1],
    [10**9,0,0]
][S == 10**18]
print(X1,Y1,X2,Y2,X3,Y3)

Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
    int n;
    int array[128];
    unsigned long long dp[128][32] = {0};
    int i, j;

    scanf("%d", &n);
    for (i = 0; i < n; i++) scanf("%d", array + i);
    dp[0][*array] = 1;
    for (i = 1; i < n - 1; i++){
        for (j = 0; j <= 20; j++){
            if (dp[i - 1][j] > 0){
                if (j + array[i] <= 20) dp[i][j + array[i]] += dp[i - 1][j];
                if (j - array[i] >= 0) dp[i][j - array[i]] += dp[i - 1][j];
            }
        }
    }
    printf("%llu\n", dp[n - 2][array[n - 1]]);

    return 0;
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;

string n;
int num;

int rec( string current_num = "" ) {

    int res = 0;

    if ( current_num.size() <= n.size() )
    {
        bool san  = false;
        bool go   = false;
        bool nana = false;
        for( auto & c : current_num )
        {
            san  |= c == '3';
            go   |= c == '5';
            nana |= c == '7';
        }

        if ( atoi( n.c_str() ) >= atoi( current_num.c_str() )
             && san
             && go
             && nana )
        {
            res += rec( current_num + "7" ) + rec( current_num + "5") + rec( current_num + "3") + 1;
        }
        else
        {
            res += rec( current_num + "7" ) + rec( current_num + "5") + rec( current_num + "3");
        }
    }
    return res;
}

int main() {
    cin >> n;
    num = stoi( n.c_str() );

    cout << rec() << endl;
    return 0;
}

Measured memory_bytes: 256
//! Framework <https://github.com/vain0x/procon>

#![allow(non_snake_case)]
#![allow(unused_imports)]

use std::collections::*;

pub struct Scan(Box<dyn Iterator<Item = &'static str>>); // '

impl Scan {
    fn new() -> Self {
        let mut buf = String::new();
        let read_line = move || {
            std::io::stdin().read_line(&mut buf).unwrap();
            Box::leak(buf.split_off(0).into_boxed_str()).split_whitespace()
        };
        Scan(Box::new(std::iter::repeat_with(read_line).flatten()))
    }

    pub fn word<T: std::str::FromStr>(&mut self) -> T {
        self.0.next().unwrap().parse().ok().unwrap()
    }

    pub fn list<T: std::str::FromStr>(&mut self, len: usize) -> Vec<T> {
        std::iter::repeat_with(|| self.word()).take(len).collect()
    }
}

fn main() {
    let mut scan = Scan::new();

    let N = scan.word::<usize>();
    let a = scan.list::<usize>(N);

    let count = a
        .iter()
        .enumerate()
        .filter(|(i, &x)| (i + 1) % 2 == 1 && x % 2 == 1)
        .count();

    println!("{}", count);
}


Measured memory_bytes: 2120
import itertools
import functools
import math
from collections import Counter
from itertools import combinations
import re

N = int(input())

OK = 0
cnt = 0
for i in range(N):
    A = list(map(int,input().split()))
    if A[0] == A[1]:
        cnt = cnt + 1
    else:
        cnt = 0
    if cnt >= 3:
        OK = 1

if OK >= 1:
    print('Yes')
else:
    print('No')


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

#include<bits/stdc++.h>
using namespace std;

int DEPTH;

vector<int> l(10, -1);
int N;
double ans=0, tmp;
vector<double> x(8), y(8);


void calc(vector<int> v) {
    for(int i=0; i<N-1; i++){
	ans += sqrt((x[v[i]]-x[v[i+1]])*(x[v[i]]-x[v[i+1]])+(y[v[i]]-y[v[i+1]])*(y[v[i]]-y[v[i+1]]));
    }
}
void DFS(int depth, vector<int> v) {
    vector<int> a(depth);
    for(int i=0; i<depth; i++){
	a[i] = v[i];
    }
    sort(a.begin(), a.end());
    for(int i=0; i<depth-1; i++){
	if(a[i]==a[i+1])
	    return;
    }
    
    if(depth == DEPTH){
	calc(v);
	return;
    }    
    for(int i=0; i<DEPTH; i++){
	v[depth] = i;

	DFS(depth+1, v);
    }
}


int main(){
    cin >> N;
    DEPTH=N;
    for(int i=0; i<N; i++)
	cin >> x[i] >> y[i];
    vector<int> v(N);    
    DFS(0, v);
    for(int i=1; i<=N; i++){
	ans /= i;
    }



    printf("%.10f", ans);
}



Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
vector<int> dx = {-1, -1, -1, 0, 0, 1, 1, 1};
vector<int> dy = {-1, 0, 1, -1, 1, -1, 0, 1};

int main () {
    int n, k; cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    int cnt = 0;
    while (cnt < k) {
        vector<ll> s(n+1);
        rep(i, n) {
            int l = i - a[i];
            int r = i + a[i]+1;
            if (l < 0) l = 0;
            if (r > n) r = n;
            s[l] += 1;
            s[r] += -1;
        }
        rep(i, n) {
            s[i+1] += s[i];
        }
        s.pop_back();
        if (s == a) break;
        a = s;
        cnt++;
    }
    rep(i, n) {
        printf("%lld ", a[i]);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 6416
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> a(N,0);
  for(int i=0; i<M; i++){
    int A;
    cin >> A;
    a[A] = 1;
  }
  vector<int> dp(N+1);
  dp[0] = 1;
  if(a[1] != 0){
    dp[1] = 0;
  }else{
    dp[1] = 1;
  }
  for(int i=2; i<=N; i++){
    if(a[i] == 1){
      dp[i] = 0;
    }else{
      dp[i] = dp[i-1]+dp[i-2];
    }
    dp[i] %= INFI;
    if(dp[i] == 0 && dp[i-1] == 0){
      cout << 0 << endl;
      return 0;
    }
  }
  cout << dp[N] << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>

using namespace std;

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

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

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

    int t_sum = 0;
    for (int i = 0; i < n; i++) {
        t_sum += t[i];
    }

    int v_max = 0;
    for (int i = 0; i < n; i++) {
        v_max = max(v_max, v[i]);
    }

    vector<int> t2v(2 * t_sum + 1, 1 << 30);
    t2v[0] = t2v[2 * t_sum] = 0;
    for (int i = 0, j = 0; i < n; i++, j--) {
        for (int k = 0; k <= 2 * t[i]; j++, k++) {
            t2v[j] = min(t2v[j], 2 * v[i]);
        }
    }

    vector<vector<double>> dp(2 * t_sum + 1, vector<double>(2 * v_max + 1, -1));
    dp[0][0] = 0;
    for (int i = 0; i < 2 * t_sum; i++) {
        for (int j = 0; j <= 2 * v_max; j++) {
            if (dp[i][j] == -1) {
                continue;
            }

            if (0 <= j - 1 && j - 1 <= t2v[i + 1]) {
                dp[i + 1][j - 1] = max(dp[i + 1][j - 1], dp[i][j] + 0.25 * j - 0.125);
            }

            if (j <= t2v[i + 1]) {
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + 0.25 * j);
            }

            if (j + 1 <= t2v[i + 1]) {
                dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 0.25 * j + 0.125);
            }
        }
    }

    cout << setprecision(12) << fixed << dp[2 * t_sum][0] << endl;
}


Measured memory_bytes: 34560
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
//	cout << fixed << setprecision(15);
	int n, k, c;
	cin >> n >> k >> c;
	string s;
	cin >> s;
	vi a, b;
	for(int i = 0; i < s.size(); i++) {
		if(s[i] == 'o') {
			a.push_back(i+1);
			i += c;
		}
	}
	if(a.size() != k) return 0;
	reverse(s.begin(), s.end());
	for(int i = 0; i < s.size(); i++) {
		if(s[i] == 'o') {
			b.push_back(n-i);
			i += c;
		}
	}
	if(b.size() != k) return 0;
	reverse(b.begin(), b.end());
	int i = 0, j = 0;
	vi ans;
	while(i < a.size() && j < b.size()) {
		if(a[i] == b[j]) {
			ans.push_back(a[i]);
			i++;
			j++;
		}
		else if(a[i] > b[j]) j++;
		else i++;
	}
	for(auto k: ans) cout << k << endl;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}


int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	int r; cin >> r;
	cout << r*r << "\n";


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
// greater<int>()
typedef long long ll;
ll GCD(ll x, ll y) { return y ? GCD(y, x%y) : x; }
ll LCM(ll x, ll y) { return x * y / GCD(x, y); }

using namespace std;


int main() {

	int H, W;
	while (true) {
		cin >> H >> W;

		if (W == 0 && H == 0)break;

		for (int j = 0; j < H; j++)
		{
			for (int i = 0; i < W; i++)
			{
				if (j % 2 == 0) {
					if (i % 2 == 0) {
						cout << "#";
					}
					else {
						cout << ".";
					}
				}
				else {
					if (i % 2 == 0) {
						cout << ".";
					}
					else {
						cout << "#";
					}
				}


			
			}
			cout << endl;
		}
		cout << endl;

	}

}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define fio ios_base::sync_with_stdio(false)
#define pdl cout << "*" << endl
#define MOD 1000000007
#define INF 1000000000
#define INFLL 1000000000000000000ll
#define pb push_back
#define ff first
#define ss second
#define long int64_t
using namespace std;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution<> dis(0, INF<<1);
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char* name, Arg1&& arg1){ cerr << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args)
{ const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma+1, args...); }

int cnt[4];

int main()
{
	fio;
	int n, ans = 0;
	cin >> n;
	for(int i=0; i<n; i++)
	{
		string s;
		cin >> s;
		int l = s.length();
		for(int i=1; i<l; i++)
			if(s[i-1] == 'A' and s[i] == 'B')
				ans++;
		int mask = 0;
		if(s[0] == 'B')
			mask |= 1;
		if(s[l-1] == 'A')
			mask |= 2;
		cnt[mask]++;
	}
	if(cnt[3])
	{
		ans += cnt[3] - 1;
		if(cnt[2])
		{
			ans++;
			cnt[2]--;
		}
		if(cnt[1])
		{
			ans++;
			cnt[1]--;
		}
	}
	ans += min(cnt[1], cnt[2]);
	cout << ans << endl;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    int m=n;
    int sumnum=0;
    while(n!=0){
        sumnum += n%10;
        n /= 10;
    }
    if(m%sumnum==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


    return 0;
}

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

int main() {
  vector<int> k(32);
  k={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int l;
  cin >> l;
  cout << k[l-1] << endl;
}

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

typedef long long ll;
#define rep(i, s, n) for(int i=s;i<n;i++)
#define repeq(i,s,n) for(int i=s;i<=n;i++)
#define MOD 10e9+7

void max_self(int& a, int b) { a=a>b?a:b; }
void min_self(int& a, int b) { a=a<b?a:b; }

using namespace std;

int n, k;

string s1;
string s2;

int main() {

    cin >> s2 >> s1;

    cout << s1+s2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#define LL long long
using namespace std;
#define maxn 100007


int main()
{
    int n,d,i,j,k,x,y;
    scanf("%d%d%d",&n,&d,&x);
    while(n--)
    {
        scanf("%d",&y);
        x+=(d+y-1)/y;
    }
    printf("%d\n",x);
    return 0;
}



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

using i64 = int64_t;

int main(){
    vector<int> v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << v[k-1] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <deque>
#include <numeric>
#include <sstream>
#include <iomanip>
#define ALL(X) X.begin(), X.end()
using lint = long long;
template <typename T>
void print_container(std::vector<T> vec)
{
    for (auto iter = vec.begin(); iter != vec.end(); ++iter)
    {
        std::cout << *iter << " ";
    }
    std::cout << std::endl;
}

int main()
{

    lint n, k;
    scanf("%lld", &n);
    scanf("%lld", &k);

    std::vector<lint> a(n);

    for (int i = 0; i < n; ++i)
    {
        scanf("%lld", &a[i]);
    }

    for (int i = 0; i < k; ++i)
    {
        std::vector<lint> ne(n, 0);

        for (int j = 0; j < n; ++j)
        {
            lint cur = a[j];
            ne[std::max(0ll, j - cur)] += 1;
            if ((lint)(n) > j + cur + 1)
            {
                ne[j + cur + 1] -= 1;
            }
        }

        std::partial_sum(ALL(ne), a.begin());

        if (*std::min_element(ALL(a)) == n)
        {
            break;
        }
    }

    print_container<lint>(a);

    return 0;
}


Measured memory_bytes: 6052
/*************************************************************************
> File Name: test.cpp
> Author: Akira 
> Mail: qaq.febr2.qaq@gmail.com 
************************************************************************/

#include<bits/stdc++.h>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Sqr(a) ((a)*(a))
#define ALL(a) a.begin(), a.end()
#define mp make_pair
#define pb push_back
using namespace std;                                                                                              

#define MaxN 100005
#define MaxM MaxN*10
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626
const int mod = 1E9+7;
const double eps = 1e-6;
#define bug cout<<88888888<<endl;
#define debug(x) cout << #x" = " << x << endl;
template<typename T> T abs(T val){return val>0?val:-val;}
inline int max2(int a, int b) {return ((a > b)? a : b);}
inline int min2(int a, int b) {return ((a < b)? a : b);}
inline int max3(int a, int b, int c) {return max2(a, max2(b, c));}
inline int min3(int a, int b, int c) {return min2(a, min2(b, c));}
template <class T> inline void read(T &ret) {char c; ret=0;while((c=getchar())<'0'||c>'9');while(c>='0'&&c<='9') ret=ret*10+(c-'0'),c=getchar();}
template <class T> inline void out(T x) {if(x>9) out(x/10);putchar(x%10+'0');}

LL Q,H,S,D,N;
int main()
{
    //std::ios::sync_with_stdio(false);
    read(Q);read(H);read(S);read(D);
    read(N);
    LL one = min3(4*Q, 2*H, S);
    LL two = min2(2*one, D);
    LL ans = (N/2)*two+(N&1)*one;
    out(ans);puts("");
    // system("pause");
    //printf("%lld\n", ((x)%mod+mod)%mod );
    //printf("\n%.2lf sec \n", (double)clock() / CLOCKS_PER_SEC);
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;
typedef string::const_iterator State;

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


int main(void) {

	int d, g;
	int p[11], c[11];
	int mini = INF;
	int total = 0;
	int count = 0;
	bitset<10> bit;


	cin >> d >> g;
	FOR(i, 1, d) {
		cin >> p[i] >> c[i];
	}
	FOR(i, 0, pow(2, d) - 1) {
		bit = i;
		total = 0;
		count = 0;
		FOR(j, 0, d - 1) {
			if (bit[j] == true) {
				total += (j + 1) * 100 * p[j + 1] + c[j + 1];
				count += p[j + 1];
			}
		}
		if (total >= g) {
			if (count < mini) {
				mini = count;
			}
		}
		else {
			RFOR(j, d - 1, 0) {
				if (bit[j] == false) {
					FOR(k, 1, p[j + 1] - 1) {
						total += (j + 1) * 100;
						count++;
						if (total >= g) {
							if (count < mini) {
								mini = count;
							}
							break;
						}
					}
					break;
				}
			}
		}
	}

	cout << mini << endl;

	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

#define MAXN 100005

int A[300000];

long long solve(vector<int> A, int x) {
  // returns # {(l, r) | med of A[l..r] >= x}
  int N = A.size();
  long long total = (long long) N * (N+1) / 2;
  vector<int> b(2 * MAXN); b[MAXN] = 1;
  int s = MAXN; long long t = 0;

  REP (j, N) {
    if (A[j] >= x) { s++; t-=b[s]; } 
    else { t+=b[s]; s--; }
    b[s]++; 
    total -= t;
  }

  return total;
}

int main() {
  ios::sync_with_stdio(false);

  int N;
  cin >> N;

  vector<int> A(N);
  REP(i, N) {
    cin >> A[i];
  }

  long long thre = (long long) N * (N+1) / 4;

  vector<int> A_sorted(A);
  sort(A_sorted.begin(), A_sorted.end());

  int l = -1, r = N-1;
  while (r - l > 1) {
    long long m = (l + r) / 2;
    if (solve(A, A_sorted[m]+1) < thre) {
      r = m;
    } else {
      l = m;
    }
    cerr << l << " " << r << endl;
  }
 
  cout << A_sorted[r] << endl;
}


Measured memory_bytes: 2280