akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvl;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long int, long long int>> vll;
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() long long int t; cin >> t; cin.ignore(); while(t--) 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define SMOD 998244353
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sp " "
#define inp(a) ll a;cin>>a;cin.ignore()
#define inps(a,b) ll a,b;cin>>a>>b;cin.ignore()
#define out(a) cout<<SP(20)<<a<<'\n'
#define outs(a,b) cout<<SP(20)<<a<<" "<<b<<'\n'
#define ins insert
#define er erase
#define lb lower_bound
#define ub upper_bound
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define inpa(a,n) ll a[n]; for(int i=0; i<n; i++){cin>>a[i];}
#define inpv(a,n) vl a; for(int i=0; i<n; i++){inp(x);a.pb(x);}
#define outa(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
#define outv(v) for(auto i:v){cout<<i;}cout<<'\n';
set<char> vow = {'a','e','i','o','u','A','E','I','O','U'};
ll xpow(ll n, ll m){if(m==0){return 1;}else{ll x = xpow(n, m/2);if(m&1){return x*x*n;}else{return x*x;}}}
ll xmod(ll a, ll m){return (((a%m)+m)%m);}
ll xmodpow(ll n, ll m, ll y){if(m==0){return 1;}else{ll x = xmodpow(n, m/2, y);if(m&1){return xmod((xmod((xmod(x,y)*xmod(x,y)),y)*xmod(n,y)),y);}else{return xmod((xmod(x,y)*xmod(x,y)),y);}}}
 
int main(){
    fast();
 
/* you get what you work for not what you wish for */
    
    ll n, l;
    cin >> n >> l;
    vector <string> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    sort(all(a));
    outv(a);
}


Measured memory_bytes: 256
#include<stdio.h>
main()
{
    int n,a,r;
    scanf("%d%d",&n,&a);
    if(a==0){
        if(n%500==0){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    }
    else if(a>0 && a<=1000){
        r=n%500;
        if(r<=a){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    }
    return 0;
}


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

int main() {
 
int a, b, d;
  
  cin >> a >> b;

  d = (a * b) % 2;
    
    
  if (d == 0) {
    cout << "Even" << endl;
  }
  
  else { 
    cout << "Odd" << endl; 
  }
}

Measured memory_bytes: 256
N = int(input())
X = list(map(int, input().split()))

cur = 1000
stock = 0
state = 0  # 1=increase, 0=decrease
for i in range(N - 1):
    if state == 1 and X[i] > X[i + 1]:
        cur += X[i] * stock
        stock = 0
        state = 0
    elif state == 0 and X[i] < X[i + 1]:
        n = cur // X[i]
        cur -= X[i] * n
        stock += n
        state = 1

print(cur + stock * X[-1])


Measured memory_bytes: 61980
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cstring>
#include <cassert>
#include <bitset>
#include <sstream>
#include <queue>

#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define sz(a) ((int) (a).size())
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

typedef long long int64;
typedef long double ldb;

const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = acos(-1);

template <class T> T sqr (T x) {return x * x;}
template <class T> T abs (T x) {return x < 0 ? -x : x;}

int main () {
    ios_base::sync_with_stdio(0);
//	freopen("input.txt", "rt", stdin);
//	freopen("output.txt", "wt", stdout);

	int n;
	cin >> n;

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

	vector<long long> sum_max(3 * n + 1);
	sum_max[0] = 0;
	
	multiset<int> cur;            
    for (int i = 0; i < 3 * n; ++i) {
		sum_max[i + 1] = sum_max[i] + a[i];
		cur.insert(a[i]);

		if (sz(cur) == n + 1) {
			auto it = cur.begin();
			sum_max[i + 1] -= *it;
			cur.erase(it);
		}
	}

	cur.clear();
	vector<long long> sum_min(3 * n + 1);
	reverse(a.begin(), a.end());
	for (int i = 0; i < 3 * n; ++i) {
		sum_min[i + 1] = sum_min[i] + a[i];
		cur.insert(a[i]);

		if (sz(cur) == n + 1) {
			auto it = cur.end();
			--it;
			sum_min[i + 1] -= *it;
			cur.erase(it);
		}
	}

	long long res = -inf64;
	for (int i = n; i <= 2 * n; ++i) {
		res = max(res, sum_max[i] - sum_min[3 * n - i]);
	}

	cout << res << endl;

	return 0;
}


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

string s;
ll x,y;
vector<int>a[2];
bool ok[2][8001][16010];

int main(){
    cin>>s>>x>>y;
    int t=0,f=0;
    rep(i,s.size()){
        if(s[i]=='F')f++;
        else{
            if(f){
                a[t%2].push_back(f);
                f=0;
            }
            t++;
        }
    }
    if(f)a[t%2].push_back(f);

    ok[0][0][8000]=1;
    ok[1][0][8000]=1;

    bool fir=0;
    if(s[0]=='T')fir=true;
    rep(i,2){
        rep(j,a[i].size()){
            rep(k,16001){
                if(!ok[i][j][k])continue;
                if(k-a[i][j]>=0&&fir)ok[i][j+1][k-a[i][j]]=true;
                if(k+a[i][j]<=16000)ok[i][j+1][k+a[i][j]]=true;
                fir=true;
            }
        }
    }

    cout<<(ok[0][a[0].size()][x+8000]&&ok[1][a[1].size()][y+8000]?"Yes\n":"No\n");
}

Measured memory_bytes: 64256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define pb push_back
#define ll long long int
# define pll pair<ll,ll>
# define fio ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;

int main()
{   fio;
    ll n;
    ll a[200009];
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+n+1);
    ll sum=0;
    if(n%2==0)
    {
        sum+=a[n];
        for(ll i=n-1;i>=n/2+1;i--) sum+=2*a[i];
        cout<<sum;
    }
    else{
        sum+=a[n];
        for(ll i=n-1;i>=(n+3)/2 ;i--) sum+=2*a[i];
        sum+=a[(n+1)/2];
        cout<<sum;
    }
    
        
}

Measured memory_bytes: 5180
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,
             tree_order_statistics_node_update>
    indexed_set;

int main()
{
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
/*
ll t;
cin>>t;

while(t--)
{
*/


ll n,r;
cin>>n>>r;

if(n>=10)
cout<<r<<endl;
else
{
  cout<<r+(100*(10-n))<<endl;

}

return 0;
}






Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int a, b;
	cin >> a >> b;
	if(a > b){
		cout << "a > b" << endl;
	}else if(a == b){
		cout << "a == b" << endl;
	}else{
		cout << "a < b" << endl;
	}
	return 0;
}

Measured memory_bytes: 3076
N=int(input())
C=[int(input())-1 for i in range(N)]
mod=10**9+7
pre_dp=[0]*(max(C)+1)
dp=[0]*(N+1)
dp[0]=1
dp[1]=1
pre_dp[C[0]]=1
for i in range(1,N):
  if C[i]!=C[i-1]:
    dp[i+1]=(dp[i]+pre_dp[C[i]])%mod
    pre_dp[C[i]]=(pre_dp[C[i]]+dp[i])%mod
  else:
    dp[i+1]=dp[i]
    
print(dp[N])


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

int convert(int b){
  if(b==1){
    return 9;
  }else{
    return 1;
  }
}

int pow(int x, int y){
  int ret=1;
  for(int i=0;i<y;i++){
    ret *= x;
  }
  return ret;
}

int main(){
  int n;
  cin>>n;
  int last;
  int ans;
  for(int i=0;i<3;i++){
    last = n%10;
    ans += convert(last)*pow(10,i);
    n = n/10;
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
#define irep(i,a,b) for(int i=int(a);i>=int(b);i--)
using ll = long long;
using namespace std;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
//sort(a, a + N, greater<ll>())   // descend
//sort(a, a+N)                    //  ascend

/**
void comb(vector<vector <long long int > > &v) {
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
/*main内でnCn~nC0 生成 **
vector<vector<long long int> > v(n + 1, vector<long long int>(n + 1, 0));
comb(v);
*/

int main() {
	ll n, m;
	cin >> n >> m;
	ll a[110000];
	ll b[110000];
	pair<ll, ll> p[110000];
	rep(i, 0, n) cin >> a[i] >> b[i];
	rep(i, 0, n) p[i] = make_pair(a[i], b[i]);
	sort(p, p + n);
	ll money = 0;
	rep(i, 0, n) {
		ll cnt =min(p[i].second, m);
		money += cnt * p[i].first;
		m -= cnt;
		if (m == 0) break;
	}
	cout << money;
}

Measured memory_bytes: 3712
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

#define REP(i,n) for(int i=0;(i)<(n);(i)++)
#define ll long long

int main() {
	int A, B;
	cin >> A >> B;
	
	if (A == B) {
		cout << "Draw" << endl;
		return 0;
	}

	if (A == 1) A = 14;
	if (B == 1) B = 14;

	cout << (A > B ? "Alice" : "Bob") << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int llu;
typedef long double ld;
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pair<int,int>>
#define pb push_back
#define pf push_front
#define mp map<ll,ll>
#define INF 1000000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
ll gcd(ll a,ll b)
{
    if(a==0)
    {
        return b;
    }
    else
    {
        return gcd(b%a,a);   
    }
}
ll lcm(ll a,ll b)
{
    return a*b/gcd(a,b);
}
int f(char c)
{
    return (int)c-96;
}
/**********************************************************************
***********************************************************************
*********************ACTUAL CODE BEGINS HERE***************************/
int main()
{   
    fast;
    int n;
    cin>>n;
    int a[105];
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    int ans=0;
    for(int i=1;i<=n-2;i++)
    {
        for(int j=i+1;j<=n-1;j++)
        {
            for(int k=j+1;k<=n;k++)
            {
                set<int> s;
                s.insert(a[i]);s.insert(a[j]);s.insert(a[k]);
                if(s.size()==3)
                {
                    if(a[i]+a[j]>a[k])
                    {
                        ans++;
                    }
                }
            }
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>
#include <stdlib.h>

int main () {
    int N;
    int M;
    scanf("%d", &N);
    scanf("%d", &M);
    int *DP = malloc((1 + N) * sizeof(int));
    int *a = malloc((1 + M) * sizeof(int));
    DP[0] = 1;
    DP[1] = 1;
    for (int i = 1; i <= M; i++) {
        scanf("%d", &a[i]);
        if (a[i] == 1) {
            DP[1] = 0;
            continue;
        }
        DP[a[i]] = -1;
    }
    for (int i = 2; i <= N; i++) {
        if (DP[i] == -1) {
            DP[i] = 0;
            continue;
        }
        DP[i] = 0;
        if (DP[i - 2] != 0)
            DP[i] = (DP[i] + DP[i - 2]) % 1000000007
  ;
        if (DP[i - 1] != 0)
            DP[i] = (DP[i] + DP[i - 1]) % 1000000007;
    }
    printf("%d\n", DP[N]);

    return 0;
}



Measured memory_bytes: 896
a = []
for i in range(3):
    a.append(list(map(int, input().split())))
n = int(input().strip())
bs = []
for i in range(n):
    bs.append(int(input().strip()))
c = [[False] * 3 for _ in range(3)]

for b in bs:
    for i in range(3):
        for j in range(3):
            if b == a[i][j]:
                c[i][j] = True

for i in range(3):
    if all(c[i]):
        print("Yes")
        exit()

col = [0] * 3
for i in range(3):
    for j in range(3):
        if c[i][j]:
            col[j] += 1
if any(map(lambda x: x == 3, col)):
    print("Yes")
    exit()

if (c[0][0] and c[1][1] and c[2][2]) or (c[2][0] and c[1][1] and c[0][2]):
    print("Yes")
    exit()

print("No")


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

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

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  LL N, A;
  cin >> N >> A;

  N %= 500;
  cout << (N <= A? "Yes": "No") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vs){
  for (const T& v : vs) os << v << " ";
  return os;
}

int main() {
  int A, B, K; cin >> A >> B >> K;
  vector<int> ans;
  for (int i = 1; i <= min(A, B); ++i) {
    if ((A % i) == 0 && (B % i) == 0) ans.push_back(i);
  }
  cout << ans[ans.size()-K] << endl;
}


Measured memory_bytes: 3596
#include <iostream>
#include <iomanip>
#include <stdio.h>
using namespace std;

int main()
{
	int S, h, m, s;
	int wk;
	
	cin >> S;
	
	wk = S;
	
	h = wk/3600;		wk %= 3600;
	m = wk/60;			wk %= 60;
	s = wk;
	
	printf("%d:%d:%d\n", h, m, s);
	
	return 0;
}



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

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

  vector<int> a={100,101,102,103,104,105};
  vector<bool> dp(X+1,false);
  dp.at(0)=true;
  for(int i=0;i<6;i++){
    for(int j=0;j<X+1;j++){
      if(j-a.at(i)>=0)  dp.at(j)=dp.at(j)|dp.at(j-a.at(i));
    }
  }
  if(dp.at(X))  cout << 1 << endl;
  else  cout << 0 << endl;

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("trapv")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n;
vector<vi> g;
vector<pi> e;
vi lvl;
int t;
void dfs(int v, int p, int d) {
	t = max(t, d);
	lvl[d] = max(lvl[d], (ll)g[v].size() - (v!=p));
	for(auto i : g[v])
		if(i!=p) dfs(i, v, d+1);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	g.resize(n+1);
	for(int f, t, i = 1; i < n; i++) {
		cin >> f >> t;
		g[f].pb(t);
		g[t].pb(f);
		e.pb({f, t});
	}
	pair<ll, ll> ans = {1e18, 1e18};
	for(int i = 1; i <= n; i++) {
		lvl.assign(n, 1), t = 0;
		dfs(i, i, 0);
		ll q = 1;
		for(int i = 0; i <= t; i++)
			q*=lvl[i];
		ans = min(ans, {t+1, q});
	}
	for(auto i : e) {
		lvl.assign(n, 1), t = 0;
		dfs(i.first, i.second, 0);
		dfs(i.second, i.first, 0);
		ll q = 2;
		for(int i = 0; i <= t; i++)
			q*=lvl[i];
		ans = min(ans, {t+1, q});
	}
	cout << ans.first << " " << ans.second;
}


Measured memory_bytes: 256
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
void solve(){
    ll n, k;
    cin>>n>>k;
    vector<ll> perm(n+1), value(n+1);
    for(int i = 1; i <= n; i++)
        cin>>perm[i];
    for(int i = 1; i <= n; i++)
        cin>>value[i];
    ll ans = LONG_LONG_MIN;

    for(int i = 1; i <= n ; i++){
        ll cycle_len = 0;
        ll cycle_val = 0;
        ll vertex = i;
        while(true){
            cycle_val += value[vertex];
            cycle_len++;
            vertex = perm[vertex];
            if(vertex == i)
                break;
        }

        ll fst_cnt = 0;
        ll fst_len = 0;
        vertex = i;
        while(true){    // going from front
            fst_cnt += value[vertex];
            fst_len++;
            if(fst_len > k)
                break;
            ans = max(ans, fst_cnt + max(0ll, cycle_val)*((k-fst_len)/cycle_len));
            vertex = perm[vertex];
            if(vertex == i)
                break;
        }
    }
    cout<<ans;
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;
const ll INF = 9e18;

int main() {
    ll H, W;
    cin >> H >> W;
    ll sh, sw, gh, gw;
    cin >> sh >> sw;
    cin >> gh >> gw;
    sh--;
    sw--;
    gh--;
    gw--;

    // 道の一覧
    vector<vector<bool>> roads(H, vector<bool>(W, false));
    for (ll h = 0; h < H; h++) {
        for (ll w = 0; w < W; w++) {
            char c;
            cin >> c;
            while (c != '.' && c != '#') {
                cin >> c;
            }
            if (c == '.') {
                roads[h][w] = true;
            }
        }
    }

    vector<vector<ll>> distmap(H, vector<ll>(W, INF));
    vector<vector<bool>> done(H, vector<bool>(W, false));
    deque<pair<ll, ll>> bfs;
    bfs.push_front(make_pair(sh, sw));
    distmap[sh][sw] = 0;
    while (!bfs.empty()) {
        auto src = bfs.front();
        bfs.pop_front();
        ll h = src.first;
        ll w = src.second;
        if (done[h][w]) {
            continue;
        }
        done[h][w] = true;
        for (ll y = h - 2; y <= h + 2; y++) {
            for (ll x = w - 2; x <= w + 2; x++) {
                if (y >= 0 && y < H && x >= 0 && x < W && roads[y][x]) {
                    if (x == w && y == h) {
                        continue;
                    } else if (abs(x - w) + abs(y - h) == 1 && distmap[y][x] > distmap[h][w]) {
                        distmap[y][x] = distmap[h][w];
                        bfs.push_front(make_pair(y, x));
                    } else if (distmap[y][x] == INF) {
                        distmap[y][x] = distmap[h][w] + 1;
                        bfs.push_back(make_pair(y, x));
                    }
                }
            }
        }
    }
    if (distmap[gh][gw] == INF) {
        cout << -1 << endl;
    } else {
        cout << distmap[gh][gw] << endl;
    }
}


Measured memory_bytes: 11988
#include <cstdio>

int main() {
    char weather[3];
    scanf("%s", weather);
    int maxCount = 0;
    int count = 0;
    for (int i = 0; i < 3; i++) {
        if (weather[i] == 'R') {
            count++;
        } else {
            count = 0;
        }
        if (count > maxCount) {
            maxCount = count;
        }
    }

    printf("%d", maxCount);

    return 0;
}


Measured memory_bytes: 1708
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
#define mkpr make_pair
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


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


  string S; cin>>S;  
  reverse(S.begin(), S.end());
  S += '0';
  int L = S.size(); // 品物の価格の桁数

  vvi dp(1e6+MGN, vi(2, INF));
  // dp[i][j] := 下 i 桁 [0,i] を決めて、繰り下がりが j (ある 1, ない 0) 
  // のとき必要な紙幣の最小枚数

  dp[0][0] = 0;
  
  REP(i,L+1) {
    int x = S[i] - '0'; // x: 品物の価格 N の i 桁目
    REP(j,2) {
      x += j;
      REP(a,10) { // a: 支払額 A の i 桁目 (10**i の紙幣の使用枚数)
        int b = a - x; // b: おつり B の i 桁目 (10**i の紙幣の使用枚数)
        if (b < 0) { // 繰り下がりあり
          b += 10;
          dp[i+1][1] = min(dp[i+1][1], dp[i][j]+a+b);
        } else { // 繰り下がりなし
          dp[i+1][0] = min(dp[i+1][0], dp[i][j]+a+b);
        }
      }
    }
  }

  int  ans = dp[L][0];
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 55964
s = input()

c01 = 0
c02 = 0

#01パターン
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == "1":
            c01 += 1
    else:
        if s[i] == "0":
            c01 += 1

#10パターン
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == "0":
            c02 += 1
    else:
        if s[i] == "1":
            c02 += 1

if all(x == 0 for x in [c01, c02]):
    print(0)
else:
    print(min(c01,c02))

Measured memory_bytes: 9192
import collections
N = int(input())
S = [input() for i in range(N)]
votes_collection = collections.Counter(S)
vote_max_num = votes_collection.most_common(1)[0][1]
max_votes = sorted([i[0]
                    for i in votes_collection.items() if i[1] == vote_max_num])
for i in max_votes:
    print(i)

Measured memory_bytes: 35572
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define cans cout << ans << endl
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
typedef long long ll;
using Graph = vector<vector<int>>;


int main(){
    int n,x,y;
    cin >> n >> x >> y;
    x--; y--;
    Graph G(n);
    vector<int> D(n+1);
    for(int i=0; i<n-1; i++){
        G[i].push_back(i+1);
        G[i+1].push_back(i);
    }
    G[x].push_back(y);
    G[y].push_back(x);
    for(int i=0; i<n; i++){
        vector<int> dist(n,-1);
        queue<int> que;
        dist[i] = 0;
        que.push(i);
        
        while(!que.empty()){
            int v = que.front();
            que.pop();
            for(int nv : G[v]){
                if(dist[nv] != -1) continue;
                dist[nv] = dist[v]+1;
                que.push(nv);
            }
        }
        for(int j=0; j<n; j++){
            D[dist[j]]++;
        }
    }
    

    for(int i=1; i<=n-1; i++){
        cout << D[i]/2 << endl;
    }       
    return 0;
}

Measured memory_bytes: 3744
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    N = int(input())
    G = [[] for _ in range(N)]
    for i in range(N - 1):
        a,b = map(int,input().split())
        a -= 1
        b -= 1
        G[a].append((b,i))
        G[b].append((a,i))
    
    between = [[set() for _ in range(N)] for _ in range(N)]
    for i in range(N):
        stack = [(i,[])]
        while stack:
            v,before = stack.pop()
            between[i][v] = set(before)
            for e,j in G[v]:
                if e == i or len(between[i][e]) >= 1:
                    continue
                between[i][e] = set(before + [j])
                stack.append((e,before + [j]))
            #print('before: ',before)
            #print('v :',v)
    
    #print(between)

    M = int(input())
    condition = [tuple(map(int,input().split())) for _ in range(M)]
    condition = [(a - 1,b - 1) for a,b in condition]
    
    ans = 0
    for bit in range(1<<M):
        ret = set()
        cnt = 0
        for i in range(M):
            if (bit>>i)&1:
                cnt += 1
                ret |= between[condition[i][0]][condition[i][1]]
        
        free = N - len(ret) - 1
        #print('free :',free)
        if cnt%2 == 0:
            ans += pow(2,free)
        else:
            ans -= pow(2,free)
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 75432
import java.util.*;

public class Main {
    private static int[] costs = new int[]{-1, 2, 5, 5, 4, 5, 6, 3, 7, 6};

    private static class RunLenNum implements Comparable<RunLenNum> {
        private int totLen;
        private int[] numCounts;

        public RunLenNum() {
            this.totLen = 0;
            this.numCounts = new int[10];
        }

        public RunLenNum addNum(int num) {
            RunLenNum res = new RunLenNum();
            res.totLen = totLen + 1;
            res.numCounts = Arrays.copyOf(numCounts, numCounts.length);
            res.numCounts[num]++;

            return res;
        }

        @Override
        public int compareTo(RunLenNum o) {
            if (o == null)
                return 1;

            if (totLen != o.totLen)
                return Integer.compare(totLen, o.totLen);

            for (int i = 9; i > 0; i--) {
                if (numCounts[i] != o.numCounts[i])
                    return Integer.compare(numCounts[i], o.numCounts[i]);
            }

            return 0;
        }

        @Override
        public String toString() {
            StringBuilder sb = new StringBuilder();

            for (int i = 9; i > 0; i--) {
                if (numCounts[i] == 0)
                    continue;

                for (int j = 0; j < numCounts[i]; j++) {
                    sb.append(i);
                }
            }

            return sb.toString();
        }
    }

    private static RunLenNum findBest(RunLenNum[] memo, int minDigits, int n, List<Integer> digits) {
        if (n < minDigits)
            return null;

        if (memo[n] != null)
            return memo[n];

        ArrayList<RunLenNum> choices = new ArrayList<>();

        for (int d : digits) {
            if (costs[d] == n)
                choices.add(new RunLenNum().addNum(d));
        }

        for (int d : digits) {
            RunLenNum bestWithoutThis = findBest(memo, minDigits, n - costs[d], digits);

            if (bestWithoutThis != null)
                choices.add(bestWithoutThis.addNum(d));
        }

        if (choices.size() == 0)
            memo[n] = null;
        else
            memo[n] = Collections.max(choices);

        return memo[n];
    }

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

        int n = sc.nextInt(), m = sc.nextInt();

        ArrayList<Integer> ds = new ArrayList<>(m);

        for (int i = 0; i < m; i++) {
            ds.add(sc.nextInt());
        }

        int minDigits = 10;

        for (int d : ds) {
            minDigits = Math.min(minDigits, costs[d]);
        }

        RunLenNum[] memo = new RunLenNum[Math.max(10, n + 1)];

        System.out.println(findBest(memo, minDigits, n, ds));
    }
}

Measured memory_bytes: 37292
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
ll strtoint(string str);
int main(){
	fast;
	ll n,cnt=0,cur=0; cin>>n;
	vector<ll> arr(n);
	for(auto& nums:arr)cin>>nums;
	for(auto i=0;i<n;++i){
		if(abs(cur-arr[i])==1){
			cur=arr[i];
			++cnt;
		}
	}
	cnt=n-cnt;
	if(cnt==n)cout<<"-1\n";
	else
		cout<<cnt<<'\n';
	return 0;
}
ll strtoint(string str){
	ll x=0;
	stringstream ss;
	ss<<str;
	ss>>x;
	return x;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=305;
const int mod=1e9+7;
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
    inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){if(y==0)return 1;int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
typedef pair<int,int> P;
#define fi first
#define se second
int n,m;
vector<P> lim[max_n];
int dp[max_n][max_n],newdp[max_n][max_n];
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        int l,r,x;scanf("%d%d%d",&l,&r,&x);
        lim[r].push_back(P(l,x));
    }
    dp[0][0]=1;
    for(int i=0;i<n;i++){
        for(int j=0;j<=i+1;j++){
            for(int k=j;k<=i+1;k++)newdp[j][k]=0;
        }
        for(int j=0;j<=i;j++){
            for(int k=j;k<=i;k++){
                if(dp[j][k]==0)continue;
                newdp[j][k]=Add(newdp[j][k],dp[j][k]);
                newdp[k][i]=Add(newdp[k][i],dp[j][k]);
                newdp[j][i]=Add(newdp[j][i],dp[j][k]);
            }
        }
        for(int j=0;j<=i+1;j++){
            for(int k=j;k<=i+1;k++){
                for(auto p:lim[i+1]){
                    int x=1+(p.fi<=k)+(p.fi<=j);
                    if(x!=p.se)newdp[j][k]=0;
                }
            }
        }
        for(int j=0;j<=i+1;j++){
            for(int k=j;k<=i+1;k++){
                dp[j][k]=newdp[j][k];
            }
        }
    }
    int ans=0;
    for(int j=0;j<=n;j++){
        for(int k=j;k<=n;k++)ans=Add(ans,dp[j][k]);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>

int main(int argc, char *argv[])
{
    int n, x;
    int l[100];
    int pos;
    int ans;

    std::cin >> n >> x;

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

    ans = 1;
    pos = 0;

    for (int i = 0; i < n; i++) {
        pos += l[i];
        if (x < pos) {break;}
        ans++;
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
s=input()
t=s[0]
c=1
d=[]
k*=2
for i in s[1:]:
    if t!=i and k==0:
        d.append(c)
        c=0
    elif t!=i:
        k-=1
    t=i
    c+=1
d.append(c)
print(sum(d)-len(d))

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

int main(){
  int N,Y;
  cin >> N >> Y;
  
  int cnt =0;
  for(int i=0;i<=N;i++){
    if(Y>10000*N){
      cout << -1 << " " << -1 << " " << -1 <<endl;
      break;
      }
    if(cnt==1){
      break;
    }
    for(int j=0;j<=N-i;j++){
      if(Y==10000*i+5000*j+1000*(N-i-j)){
        cout << i << " " << j << " " << N-i-j <<endl;
        cnt++;
        break;
      }
      if(N==i){
        cout << -1 << " " << -1 << " " << -1 <<endl;
      }
      if(Y!=10000*i+5000*j+1000*(N-i-j)){
        continue;
      }
      
    }
  }
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<vector<int>> ab(n, vector<int>(2));
  vector<vector<int>> ba(n, vector<int>(2));
  
  for(int i = 0; i < n; i++) {
    int m; cin >> m;
    ab.at(i).at(0) = m;
    ba.at(i).at(1) = m;
    cin >> m;
    ab.at(i).at(1) = m;
    ba.at(i).at(0) = m;
  }
  
  
  
  if(n % 2 == 1) {
    
    
    int mids;
    
    sort(ab.begin(), ab.end());
    sort(ba.begin(), ba.end());
    
    mids = ba.at(n /2).at(0) - ab.at(n /2).at(0) +1;
    
    cout << mids << endl;
  }
  
  
  else {
    
    
    int mids;
    
    sort(ab.begin(), ab.end());
    sort(ba.begin(), ba.end());
    
    mids = ba.at(n /2 -1).at(0) + ba.at(n /2).at(0) - ab.at(n /2 -1).at(0) - ab.at(n /2).at(0) +1;
    
    cout << mids << endl;
  }
}

Measured memory_bytes: 25172
def examA():
    N = I()
    X = [LI()for _ in range(N)]
    l = 0; r = inf
    while(r-l>_ep):
        now = (l+r)/2
        x_l = -inf; x_r = inf
        y_l = -inf; y_r = inf
        for x,y,c in X:
            move = now / c
            x_l = max(x_l,x-move)
            x_r = min(x_r,x+move)
            y_l = max(y_l,y-move)
            y_r = min(y_r,y+move)
        if x_l<=x_r-_ep and y_l<=y_r-_ep:
            r = now
        else:
            l = now
    ans = r
    print(ans)
    return

def examB():
    N = I()
    C = LI()
    C.sort()
    base = pow(2,2*N-1,mod)
    inv = pow(2,mod-2,mod)
    ans = 0
    for i in range(N):
        cur = C[i]*base*(1+(N-1-i)*inv)
        ans += cur
        ans %= mod
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return


import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(readline())
def LI(): return list(map(int,readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-9)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examB()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Measured memory_bytes: 24268
#include <iostream>
using namespace std;
long long ruijou(long long a,long long b){
    long long c,mod;
    mod=1e9+7;
    if(b==1){
        return a;
    }else{
        c=ruijou(a,b/2);
        c=(c*c)%mod;
        if(b%2==1){
            c=(c*a)%mod;
        }
        return c;
    }
}
int main(void){
    long long N,K,i,a,mod,r;
    mod=1e9+7;
    cin>>N>>K;
    a=N-K+1;
    for(i=1;i<K+1;i++){
        cout<<a<<endl;
        r=ruijou((i+1)*i,mod-2);
        a=((a*(N-K+1-i)*(K-i))%mod*r)%mod;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[100005];
int b[100005],n,s;
int main(){
	memset(b,0,sizeof(b));
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]>100000) s++;
		else b[a[i]]++;
	}
	for(int i=1;i<=100000;i++){
		if(i<=b[i]) s+=b[i]-i;
		else if(i>b[i]) s+=b[i];
	}
	cout<<s<<endl;
	return 0;
} 

Measured memory_bytes: 1024
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;
int compare(string a, string b) {
    if (a.size() < b.size()) {
        return -1;
    } else if (a.size() > b.size()) {
        return 1;
    } else {
        rep(i, a.size()) {
            if (a[i] < b[i]) {
                return -1;
            } else if (a[i] > b[i]) {
                return 1;
            }
        }
    }
    return 0;
}
int main() {
    string a, b; cin >> a >> b;
    int res = compare(a, b);
    if (res == 0) {
        cout << "EQUAL" << endl;
    } else if (res == -1) {
        cout << "LESS" << endl;
    } else {
        cout << "GREATER" << endl;
    }

}


Measured memory_bytes: 504
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
using namespace std;

int main() {
  int N;
  cin >> N;
  // vector<int> adj[N + 1];
  vector<pair<int, int>> adj[N + 1];

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

  // for (int i = 0; i < N; i++) {
  //   for (auto a = adj[i].begin(); a != adj[i].end(); ++a) {
  //     cout << (*a).first << "," << (*a).second << " ";
  //   }
  //   cout << endl;
  // }

  // bfs
  queue<int> que;
  int color[N + 1];
  for (int i = 1; i <= N; i++) {
    color[i] = -1;
  }

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

  while (que.size() > 0) {
    int cur = que.front();
    // cout << "cur: " << cur << endl;
    que.pop();

    for (auto next = adj[cur].begin(); next != adj[cur].end(); ++next) {
      int v = (*next).first;
      int w = (*next).second;
      if (color[v] == -1) {
        if (w % 2 == 0) {
          color[v] = color[cur];
        } else {
          color[v] = (color[cur] + 1) % 2;
        }

        que.push(v);
      }
    }
  }

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

  return 0;
}

Measured memory_bytes: 6784
n = int(input())
p = tuple(map(int, input().split()))

cnt = 0
for i in range(1, n - 2 + 1):
    if (p[i - 1] < p[i] < p[i + 1]) or (p[i - 1] > p[i] > p[i + 1]):
        cnt += 1
print(cnt)


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

using namespace std;
using ll = long long;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

int main()
{
    ll H, W;
    cin >> H >> W;

    vector<string> s(H);
    REP(i,0,H) cin >> s[i];

    vector<vector<ll>> dp(H, vector<ll>(W));
    dp[0][0] = (s[0][0] == '.' ? 0 : 1);

    REP(i,1,H) {
        if(s[i][0] == '.') 
            dp[i][0] = dp[i-1][0];
        else if(s[i][0] == '#' && s[i-1][0] == '.')
            dp[i][0] = dp[i-1][0] + 1;
        else
            dp[i][0] = dp[i-1][0];
    }
    REP(j,1,W) {
        if(s[0][j] == '.') 
            dp[0][j] = dp[0][j-1];
        else if(s[0][j] == '#' && s[0][j-1] == '.')
            dp[0][j] = dp[0][j-1] + 1;
        else
            dp[0][j] = dp[0][j-1];
    }

    REP(i,1,H) {
        REP(j,1,W) {
            if(s[i][j] == '.') 
                dp[i][j] = MIN(dp[i-1][j],dp[i][j-1]);
            else if(s[i][j] == '#' && s[i-1][j] == '.' && s[i][j-1] == '#')
                dp[i][j] = MIN(dp[i-1][j]+1,dp[i][j-1]); 
            else if(s[i][j] == '#' && s[i-1][j] == '#' && s[i][j-1] == '.')
                dp[i][j] = MIN(dp[i-1][j],dp[i][j-1]+1);
            else if(s[i][j] == '#' && s[i-1][j] == '#' && s[i][j-1] == '#')
                dp[i][j] = MIN(dp[i-1][j],dp[i][j-1]); 
            else
                dp[i][j] = MIN(dp[i-1][j]+1,dp[i][j-1]+1);
        }
    }
    _PR(dp[H-1][W-1]);

    return 0;
}

/*

    ..#...#.
    .####.##
    ##.###..
    #.##..##
    ##.#####

    .-># +1

    00111122
    01111122
    11122222
    11222233
    11122222
    

*/

Measured memory_bytes: 384
from bisect import bisect_right

N = int(input())
L = list(map(int, input().split()))

L_sorted = sorted(L)

count = 0
for i in range(N):  # longest stick
    for j in reversed(range(i)):  # second longest stick
        r = bisect_right(L_sorted, L_sorted[i] - L_sorted[j])
        if j <= r:
            break
        else:
            count += j - r

print(count)

Measured memory_bytes: 3188
N = int(input())
A = [int(_) for _ in input().split()]

X = [0 for _ in range(N)]
ans = []
for i in range(N)[::-1]:
    v = 0
    for j in range(i, N, i+1):
        v += X[j]
    if v % 2 != A[i]:
        X[i] = 1
        ans.append(i+1)

print(len(ans))
for i in ans:
    print(i)


Measured memory_bytes: 16608
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <sstream>
#include <algorithm>
#include <math.h>
#include<string>
#include<vector>
using namespace std;
int main()
{
    double r;
    cin >> r;
    cout << double(2.0 * r * M_PI) << endl;
}


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

int main()
{
    int N, M, C;
    cin >> N >> M >> C;
    int B[M];
    int A[N][M];
    int cnt = 0;

    for (size_t i = 0; i < M; ++i)
    {
        cin >> B[i];
    }
    for (size_t i = 0; i < N; ++i)
    {
        for (size_t j = 0; j < M; ++j)
        {
            cin >> A[i][j];
        }
    }

    for (size_t i = 0; i < N; ++i)
    {
        int sum = 0;
        for (size_t j = 0; j < M; ++j)
        {
            sum += A[i][j] * B[j];
        }
        sum += C;
        if (sum > 0)
        {
            ++cnt;
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
from bisect import bisect_right
import numpy as np
N, M, K = map(int, input().split())
A = np.array([0] + list(map(int, input().split())))
B = np.array([0] + list(map(int, input().split())))

if A.sum() + B.sum() <= K:
    print(N + M)
    exit()

cumsum_A = A.cumsum()
cumsum_B = B.cumsum()
# print('cusmum_A', cumsum_A)
# print('cusmum_B', cumsum_B)

ans = 0
for num_A in range(len(cumsum_A)):
    t = cumsum_A[num_A]
    if t > K:
        continue
    num_B = bisect_right(cumsum_B, K - t) - 1
    # print('num_A, num_B', num_A, num_B)
    ans = max(ans, num_A + num_B)
print(ans)


Measured memory_bytes: 53944
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    int n;
    scanf("%d", &n);
    int money = 100000;
    for(int i = 0; i < n; i++)
    {
        money *= 1.05;
        money = ceil((double)money / 1000) * 1000;
    }
    printf("%d\n", money);
}



Measured memory_bytes: 2048
import sys
from sys import exit
from collections import deque
from copy import deepcopy
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod=MOD):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x,mode='counter'):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    if mode=='counter':
        return C
    S = set([1])
    for k in C:
        T = deepcopy(S)
        for x in T:
            for i in range(1,C[k]+1):
                S.add(x*(k**i))
    if mode=='set':
        return S
    if mode=='list':
        return sorted(list(S))

######################################################

N,K=mint()
S=input()
r1=0
r2=0
now=0
mark=S[0]
tmp=None
for i in range(N):
    if i<N-1 and S[i]==S[i+1]:
        now+=1
    if tmp==mark and S[i]!=mark:
        r2+=1
    tmp=S[i]
if tmp!=mark:
    r1+=1
    r2-=1
now+=2*min(K,r2)
K-=min(K,r2)
now+=min(K,r1)
print(now)

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

using namespace std;
using ll = long long;

int main() {
  ll N;
  cin >> N;
  vector<ll> W(N);
  ll sum = 0;
  for (int i = 0; i < N; ++i) {
    cin >> W[i];
    sum += W[i];
  }
  int a = sum;
  int b = 0;
  int ret = sum;
  for (int i = 0; i < N-1; ++i) {
    a-=W[i];
    b+=W[i];
    ret = min(ret, abs(a-b));
  }
  cout << ret <<endl;
}


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

int main() {
	cin.tie(0)->sync_with_stdio(false);

	int n, k; cin >> n >> k;
	vector<int> a(n);
	REP(i, n) cin >> a[i];

	REP(i, n - k) {
		if (a[i] < a[i + k]) cout << "Yes" << '\n';
		else cout << "No" << '\n';
	}
	return 0;
}

Measured memory_bytes: 3984
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;

fn main() {
    input! {
        s: Chars,
        t: Chars,
    }

    let n = s.len();
    let mut ans = 0;

    for i in 0..n {
        if s[i] != t[i] {
            ans += 1;
        }
    }

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


Measured memory_bytes: 3940
using System;
using System.Linq;

namespace AGC024_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var A = input[0];
            var B = input[1];
            var C = input[2];
            var K = input[3];

            if (Math.Abs(A-B) >= Math.Pow(10,18)) Console.WriteLine("Unfair");
            else Console.WriteLine(K % 2 == 0 ? A - B : B - A);
        }
    }
}


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

signed main(){
	int n,m,ma = 0;
	map<string,int> mp;
	cin >> n;
	for(int i = 0;i < n;i++){
		string s;
		cin >> s;
		mp[s]++;
	}
	cin >> m;
	for(int i = 0;i < m;i++){
		string t;
		cin >> t;
		mp[t]--;
	}
	for(auto it : mp) ma = max(ma,it.second);
	cout << ma << endl;
	return 0;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e9 + 7;


// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, m, k, u, v;
string s, t;

// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>n;

	cout<<n*(n-1)/2;
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}

Measured memory_bytes: 3652
# coding: utf-8

#最大積載量がPのとき、必要になるトラックの台数を返す
def trackNum(P, wi, n):
    track = 1
    sum = 0
    if P < max(wi):
        return -1
    for i in range(n):
        sum += wi[i]
        if sum > P:
            track += 1
            sum = wi[i]
        elif sum == P and i < n - 1:
            track += 1
            sum = 0
    return track
    
n, k = map(int,input().rstrip().split())
wi = []
for i in range(n):
    wi.append(int(input().rstrip()))
#必要になるトラックがk以下になる最小のPを求める
start = max(wi)
end = sum(wi)
while start < end:
    half = int((start+end)/2)
    if trackNum(half, wi, n) > k:
        start = half
    else: 
        end = half
    if start + 1 == end:
        if trackNum(start, wi, n) <= k:
            end = start
        break

print(end)


Measured memory_bytes: 9564