akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <array>

using namespace std;

int gcd(int a, int b) {
    int r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

int main()
{
    string s, ans;
    cin >> s;
    vector<int> count(3, 0);
    bool a, b, c, d;
    a = false;
    b = false;
    c = false;
    d = false;
    int l = s.length();
    for(int i=0; i<l; ++i){
        count[s[i] - 'a']++;
        if(s[i] == 'a'){
            a = true;
        }
        if(s[i] == 'b'){
            b = true;
        }
        if(s[i] == 'c'){
            c = true;
        }
    }
    // 1
    if((a && !b && !c) || (!a && b && !c) || (!a && !b && c)){
        ans = (l == 1) ? "YES" : "NO";
    }
    // 2
    else if((a && b && !c) || (a && !b && c) || (!a && b && c)){
        ans = (l <= 2) ? "YES" : "NO";
    }
    // 3
    else if(a && b && c){
        d = (abs(count[0] - count[1]) <= 1) && (abs(count[1] - count[2]) <= 1) && (abs(count[2] - count[0]) <= 1);
        ans = d ? "YES" : "NO";
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <utility>
using namespace std;

int main(){
  int n, a;
  double t;
  cin >> n >> t >> a;
  priority_queue<pair<double, int>>Q;
  for(int i=0; i<n; i++){
    double h;
    cin >> h;
    Q.push(make_pair(-abs(t-0.006*h-a), i+1));
  }
  cout << Q.top().second << endl;
  return 0;
}

Measured memory_bytes: 256
n , l = map(int,input().split())
taste = l*n + (n*(n+1)//2) - n
tgt = 1 - l
if tgt <= 0 :
    eat = 1
elif tgt > n:
    eat = n
else :
    eat = tgt
ans = taste - (l+eat-1)
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;
typedef pair<int,int> pair;


vector<ll> A(50);
vector<ll> P(50);

ll burger(ll n,ll x){
  if(n == 0) return 1;
  if(x == 1) return 0;
  if(x <= 1+A[n-1]) return burger(n-1,x-1);
  if(x == 2+A[n-1]) return 1+P[n-1];
  if(x <= A[n]-1) return 1+P[n-1]+burger(n-1,x-2-A[n-1]);
  if(x == A[n]) return P[n];
  return 0;
}

int main(){
  ll n,x;
  cin >>n>>x;
  A[0] = 1;
  P[0] = 1;
  rep1(i,n){
    A[i] = 3+2*A[i-1];
    P[i] = 1+2*P[i-1];
  }
  cout << burger(n,x) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<deque>
using namespace std;
typedef long long ll;
int n, m;
deque<int>d, t;
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int k; cin >> k;
		d.push_back(k);
	}
	sort(d.begin(), d.end());
	cin >> m;
	for (int i = 0; i < m; i++) {
		int k; cin >> k;
		t.push_back(k);
	}
	sort(t.begin(), t.end());
	while (d.size() && t.size()) {
		if (d.front() == t.front()) {
			d.pop_front();
			t.pop_front();
		}
		else d.pop_front();
	}
	if (t.size() == 0)cout << "YES\n";
	else cout << "NO\n";
}

Measured memory_bytes: 1792
//#define _GLIBCXX_DEBUG

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};
vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i,0,n)cin>>a[i];
  sort(ALLR(a));
  ll now=1;ll k=n-2;
  res=a[0];
  rep(i,1,n){
    res+=min(k,2LL)*a[i];
    k=max(k-2,0LL);
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 4776
#include <iostream>
#include <cstdio>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
bool calc (int *x) {
	if(x[1] % 2 == 0 || x[2] % 2 == 0) return false;
	int i = 3;
	while(x[i]) {
		if(x[i] % 2 != 0) return false;
		i++;
	}
	return true;
}
int main() {
	int a, b;
	int x[110] = {};
	while(cin >> a >> b) {
		if(!(a || b)) {
			if(calc(x)) cout << "OK" << endl;
			else cout << "NG" << endl;
			rep(i,110) x[i] = 0;
		} else {
			x[a]++, x[b]++;
		}
	}
	return 0;
}

Measured memory_bytes: 1156
N = int(input())
A = [0] * N
B = [0] * N
C = [[] for i in range(N)]
for i in range(N):
  A[i], B[i] = map(int, input().split())
  C[i] = [A[i], B[i], A[i] + B[i]]
C.sort(reverse=True, key=lambda x: x[2])
print(sum([c[0] for c in C[0::2]]) - sum([c[1] for c in C[1::2]]))

Measured memory_bytes: 25988
#include<bits/stdc++.h>
using namespace std;
int main(){
	char a[3][3];
	for(int i=0;i<3;i++)
		for(int j=0;j<3;j++)
			cin>>a[i][j];
	cout<<a[0][0]<<a[1][1]<<a[2][2];
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
string S[1000]; int  n, p[5] = { 5,12,17,24,31 };
int main() {
    while (true) {
        cin >> n; if (n == 0)break;
        for (int i = 0; i < n; i++)cin >> S[i];
        for (int i = 0; i < n; i++) {
            int cnt = 0, sum = 0;
            for (int j = i; j < n; j++) {
                if (cnt >= 5)continue;
                sum += S[j].size();
                if (p[cnt] == sum)cnt++;
            }
            if (cnt == 5) { cout << i + 1 << endl; break; }
        }
    }
    return 0;
}

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

int main(void){
  int n,m,c;
  int a;
  cin >> n >> m >> c;
  int b[m];
  int count = 0;
  for(int i = 0;i < m;i++){
    cin >> b[i];
  }
  for(int i = 0;i < n;i++){
    int ans = 0;
    for(int j = 0;j < m;j++){
      cin >> a;
      ans = ans + a*b[j];
    }
    if(ans+c > 0){
      count++;
    }
  }
  cout << count << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>

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

using namespace std;

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

#define fcout cout<<fixed<<setprecision(15)
#define rep(i,j,k) for(int i=j; i<k; ++i)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
	fast_io 
	char c; cin>>c;
	cout<<(char)(c+1);
	
	
	return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std ;
int n,cek,a;
int main(){
	
	cin>>n;
	
	while(n--){
		
		cin>>a;
		
		if(a%2==0){
			if(a%3!=0 and a%5!=0){
				cek=1;
			}
		}
	}
	
	if(cek==0){
		cout<<"APPROVED"<<endl;
	}
	else{
		cout<<"DENIED"<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

const ll MAX = 1e6 + 1000;
const ll MOD = 1e9 + 7;
vector<ll> fac(MAX);
vector<ll> finv(MAX);
vector<ll> inv(MAX);

void COMinit(){
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(ll i = 2; i < MAX; i++){
    fac[i] = fac[i-1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
    finv[i] = finv[i-1] * inv[i] % MOD;
  }
}

// auto MP = PrimeFac(N);
// for(auto i : MP){
//   cout << i.first << " " << i.second << endl;
// }
map<ll, ll> PrimeFac(ll n){
  map<ll, ll> mp;
  ll cnt = 0;
  while(n%2 == 0){
    n /= 2;
    cnt++;
  }
  if(cnt != 0) mp[2] = cnt;
  for(ll i = 3; i*i <= n; i += 2){
    cnt = 0;
    while(n%i == 0){
      n /= i;
      cnt++;
    }
    if(cnt != 0) mp[i] = cnt;
  }
  if(n != 1) mp[n] = 1;
  return mp;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N; cin >> N;
  vector<ll> a(N, 0);
  map<ll, ll> m;
  REP(i, N){
    cin >> a[i];
    auto M = PrimeFac(a[i]);
    for(auto j : M){
      if(m[j.first] < j.second) m[j.first] = j.second;
    }
  }
  ll ans = 0, tmp = 1;
  for(auto i : m){
    tmp *= pow(i.first, i.second);
    tmp %= MOD;
  }
  COMinit();
  REP(i, N){
    ans += tmp * inv[a[i]] % MOD;
    ans %= MOD;
  }
  cout << ans << endl;
}




Measured memory_bytes: 25984
#include <stdio.h>
#include <iostream>
#include <utility>
using namespace std;

typedef struct {
	char mark;
	int num;
} TRUMP;

void bubbleSort(TRUMP a[], int n);
void selectionSort(TRUMP a[], int n);
void dispTrumpList(const TRUMP trump[], int n);
bool isStable(const TRUMP t1[], const TRUMP t2[], int n);

int main(void)
{	
	int n;
	cin >> n;
	
	TRUMP trump[36], trump1[36], trump2[36];
	for (int i = 0; i < n; i++) {
		cin >> trump[i].mark >> trump[i].num;
		trump1[i].mark = trump[i].mark;
		trump1[i].num = trump[i].num;
		trump2[i].mark = trump[i].mark;
		trump2[i].num = trump[i].num;
	}
	
	bubbleSort(trump1, n);
	dispTrumpList(trump1, n);
	if (isStable(trump, trump1, n)) cout << "Stable" << endl;
	else cout << "Not stable" << endl;
	
	selectionSort(trump2, n);
	dispTrumpList(trump2, n);
	if (isStable(trump, trump2, n)) cout << "Stable" << endl;
	else cout << "Not stable" << endl;
	
	return 0;
}

void bubbleSort(TRUMP a[], int n)
{
	for (int i = 0; i < n; i++) {
		for (int j = n - 1; j > i; j--) {
			if (a[j].num < a[j-1].num) {
				swap(a[j], a[j-1]);
			}
		}
	}
}

void selectionSort(TRUMP a[], int n)
{
	int i, j;
	for (i = 0; i < n; i++) {
		int minj = i;
		for (j = i; j < n; j++) {
			if (a[j].num < a[minj].num) {
				minj = j;
			}
		}
		swap(a[i], a[minj]);
	}
}

void dispTrumpList(const TRUMP trump[], int n)
{
	for (int i = 0; i < n; i++) {
		cout << trump[i].mark << trump[i].num;
		if (i < n - 1) cout << " ";
		else cout << endl;
	}
}

bool isStable(const TRUMP t1[], const TRUMP t2[], int n)
{
	char m1[9][4] = {"\0"};
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 4; j++) {
			if (m1[t1[i].num-1][j] == '\0') {
				m1[t1[i].num-1][j] = t1[i].mark;
				break;
			}
		}
	}
	
	char m2[9][4] = {"\0"};
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 4; j++) {
			if (m2[t2[i].num-1][j] == '\0') {
				m2[t2[i].num-1][j] = t2[i].mark;
				break;
			}
		}
	}
	
	for (int i = 0; i < 9; i++) {
		for (int j = 0; j < 4; j++) {
			if (m1[i][j] != m2[i][j]) return false;
		}
	}
	return true;
}

Measured memory_bytes: 3096
#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;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    vector<int> v;
    ll sum=0;
    for(int i=0;i<n;i++){
        int q;
        cin>>q;
        sum+=q;
        v.pb(q);
    }
    ll x=v[0],y=sum-v[0];
    ll ans=abs(x-y);
    for(int i=1;i<n-1;i++){
        x+=v[i];
        y-=v[i];
        if(abs(x-y)<ans){
            ans=abs(x-y);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1400
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

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

    int n;
    cin >> n;
    vector<int> x(n + 1);
    rep(i, n) cin >> x[i+1];
    int len, q;
    cin >> len >> q;

    vector<vector<int>> l(31, vector<int>(n+1)), r(31, vector<int>(n+1));
    for(int i = 1; i <= n; i++){
        int lo, hi;
        lo = 1;
        hi = n + 1;
        while(hi - lo > 1){
            int mid = (lo + hi) / 2;
            if(x[mid] <= x[i] + len){
                lo = mid;
            }else{
                hi = mid;
            }
        }
        r[0][i] = lo;

        lo = 0;
        hi = n;
        while(hi - lo > 1){
            int mid = (lo + hi) / 2;
            if(x[mid] >= x[i] - len){
                hi = mid;
            }else{
                lo = mid;
            }
        }
        l[0][i] = hi;
    }

    rep(i, 30){
        for(int j = 1; j <= n; j++){
            r[i+1][j] = r[i][r[i][j]];
            l[i+1][j] = l[i][l[i][j]];
        }
    }

    vector<int> p(31);
    p[0] = 1;
    rep(i, 30) p[i+1] = p[i] * 2;

    rep(i, q){
        int a, b;
        cin >> a >> b;
        int ans = 0;
        int pos = a;

        int id = 0;
        if(a < b){
            while(pos < b){
                if(r[id][pos] < b){
                    id++;
                    continue;
                }
                if(id == 0){
                    id++;
                    ans++;
                    break;
                }
                ans += p[id-1];
                pos = r[id-1][pos];
                id = 0;
            }
        }else{
            while(pos > b){
                if(l[id][pos] > b){
                    id++;
                    continue;
                }
                if(id == 0){
                    id++;
                    ans++;
                    break;
                }
                ans += p[id-1];
                pos = l[id-1][pos];
                id = 0;
            }
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 51056
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf pop_front()
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define inf 100000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define vll vector<lli>
#define eps 0.000001
#define endl '\n'
#define mo 998244353
 
using namespace std ;
 
#define N 200000 + 5 

typedef tree<lli,null_type,less<lli>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

lli tr[4*N];

lli qry(lli n,lli s,lli e,lli l,lli r)
{
    if(l>e || s>r)
    return 0;

    if(s>=l && e<=r)
    return tr[n];

    else
    {
        lli mid = (s+e)/2;
        lli x = qry(2*n,s,mid,l,r);
        lli y = qry(2*n + 1,mid+1,e,l,r);
        return max(x,y);
    } 
}

void upd(lli n,lli s,lli e,lli in,lli val)
{
    if(s == e)
    {
        tr[n] = val;
        return;
    }

    lli mid = (s+e)/2 ;

    if(in>=s && in<=mid)
        upd(2*n,s,mid,in,val);

    else
        upd(2*n + 1,mid+1,e,in,val);

    tr[n] = max(tr[2*n],tr[2*n + 1]);
}

int main()
{
///////////////////////////////////////////
    fastio;

    lli n;
    cin>>n;

    lli h[n+1] , b[n+1] , m[n+1];
    pll pos[n+1];

    loopl(i,1,n+1) 
    {
        cin>>h[i];
        pos[i] = {h[i],i};
    }
    sort(pos+1,pos+n+1);

    loopl(i,1,n+1)
    m[pos[i].ss] = i;

    loopl(i,1,n+1) cin>>b[i];

    lli ans = b[0];

    upd(1,1,n,m[1],b[1]);


    loopl(i,2,n+1)
    {
        lli x = qry(1,1,n,1,m[i]);
        ans = max(ans , x+b[i]);
        upd(1,1,n,m[i],x+b[i]);
    }

    //loopl(i,1,8) cout<<tr[i]<<" ";
    //cout<<endl;

    cout<<tr[1]<<endl;

}

Measured memory_bytes: 14208
#encoding utf-8

n = int(input())
s = list(str(input()))

maxcha = 0
for i in range(n):
    left = set(s[:i])
    right = set(s[i:])
    now = len(left & right)
    maxcha = max(maxcha,now)
    # print(now)

print(maxcha)



Measured memory_bytes: 3064
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#ifdef PERVEEVM_LOCAL
    #define debug(x) std::cerr << (#x) << ":\t" << (x) << std::endl
#else
    #define debug(x) 238;
#endif

#define fastIO std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0)
#define NAME "File"

using ll = long long;
using ld = long double;

#ifdef PERVEEVM_LOCAL
    std::mt19937 rnd(238);
#else
    std::mt19937 rnd(std::chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

const double PI = atan2(0.0, -1.0);
const int INF = 0x3f3f3f3f;
const ll LINF = (ll)2e18;
const int N = 3100;

double dp[N][N];
double p[N];

void run() {
    int n;
    scanf("%d", &n);

    for (int i = 1; i <= n; ++i) {
        scanf("%lf", &p[i]);
        p[i] = 1.0 - p[i];
    }

    dp[0][0] = 1.0;

    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= i; ++j) {
            dp[i][j] = dp[i - 1][j] * p[i];

            if (j != 0) {
                dp[i][j] += dp[i - 1][j - 1] * (1.0 - p[i]);
            }
        }
    }

    double ans = 0.0;
    for (int i = n / 2 + 1; i <= n; ++i) {
        ans += dp[n][i];
    }

    printf("%.10lf\n", ans);
}

int main(void) {
    // freopen(NAME".in", "r", stdin);
    // freopen(NAME".out", "w", stdout);

    auto start = std::chrono::high_resolution_clock::now();
    run();
    auto end = std::chrono::high_resolution_clock::now();

    #ifdef PERVEEVM_LOCAL
        std::cerr << "Execution time: "
                  << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count()
                  << " ms" << std::endl;
    #endif

    return 0;
}


Measured memory_bytes: 72320
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
const int N = 101;
const int M = 51;
double dp[N][M][M];//probability: who,ith place,num of QK
double t[N][M];//num: who,num of QK,

void solve(int n,int I,double prob){
  dp[I][0][0]=1-prob;
  dp[I][0][1]=prob;
  REP(i,1,n){
    REP(j,0,n+1){
      dp[I][i][j]=0;
      dp[I][i][j]+=dp[I][i-1][j]*(1-prob);
      if (j-1 >= 0){
        dp[I][i][j]+=dp[I][i-1][j-1]*prob;
      }
    }
  }
}

int main(){
  int n,m,l;
  while(cin>>n>>m>>l){
    double p[n],ti[n],v[n];
    rep(i,n){
      cin>>p[i]>>ti[i]>>v[i];
      p[i]=p[i]/100.0;
      double tttt=l/v[i];
      rep(j,m+1){
        t[i][j]=tttt+j*ti[i];
      }
    }
    rep(i,n)solve(m,i,p[i]);
    /*
    rep(i,n){
      rep(j,m+1){
        cout << t[i][j] <<"," << dp[i][m-1][j] <<" ";
      }
      cout << endl;
    }
    */
    if (m == 0){
      rep(i,n){
        double a=1;
        rep(j,n){
          if (i == j)continue;
          if (v[i] <= v[j])a=0;
        }
        printf("%.12lf\n",a);
      }
    }else {
      rep(i,n){//
        double sum=0;
        rep(k,m+1){
          double prob=1;
          rep(j,n){
            if (i == j)continue;
            double ahoge=0;
            rep(l,m+1){
              if (t[i][k] < t[j][l])ahoge+=dp[j][m-1][l];
            }
            prob*=ahoge;
          }
          sum+=prob*dp[i][m-1][k];
        }
        printf("%.12lf\n",sum);
      }
      //cout << endl;
#ifdef DEBUG
      printf("end\n");
#endif
    }

  }
  return false;
}

Measured memory_bytes: 3060
import java.io.*;
import java.util.*;
import java.lang.*;

class Main {
    public static void main(String [] args){
        Scanner scan = new Scanner(System.in);
        int [] count = new int[26];
        
        while(scan.hasNext()){
            String line  = scan.next();
            
            for(int i = 0; i < line.length(); ++i){
                if(Character.isLowerCase(line.charAt(i))){
                    ++count[line.charAt(i) - 'a'];
                }
                
                else if(Character.isUpperCase(line.charAt(i))){
                    ++count[line.charAt(i) - 'A'];
                }
            }
        }
        
        for(int i = 0; i < count.length; ++i){
            System.out.println((char)('a' + i) + " : " + count[i]);
        }
    }
}


Measured memory_bytes: 26184
inp = list(map(int,input().split()))
w = inp[0]
h = inp[1]
x = inp[2]
y = inp[3]
r = inp[4]
if x+r <= w and x-r >= 0 and y+r <= h and y-r >= 0:
    print("Yes")
else:
    print("No")

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

ll C(ll N, ll k){
    ll res = 0;
    while(N-- && k != 0){
        res += k;
        k /= 2;
    }
    return res;
}

int main(){
    ll N, K; cin >> N >> K;
    ll lb = 1, ub = 1e18 + 1;
    while(ub - lb > 1){
        ll m = (lb + ub) /2 ;
        if(C(N, m) <= K) lb = m;
        else ub = m;
        //cerr << lb << " " << ub << endl;
    }
    cout << lb << endl;
}


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

int main() {
  vector<int> vi(3);
  cin >> vi[0] >> vi[1] >> vi[2];
  sort(vi.begin(),vi.end());
  int r = vi[2]*10 + vi[1] + vi[0];
  cout << r;
}

Measured memory_bytes: 256
#include <stdio.h>
     
    int setmax(int*,int);
     
    int main(void){
        int n;
        scanf("%d",&n);
        
        int i;
        int priceset[n];
        for(i=0;i<n;i++){
            scanf("%d",&priceset[i]);
        }
        
        int ans=0;
        int m = setmax(priceset,n);
        for(i=0;i<n;i++){
            if(priceset[i]==m){
                ans += m/2;
                m=114514;
            }else{
                ans += priceset[i];
            }
        }
        printf("%d\n",ans);
    }
        
     
    int setmax(int data[],int n){
        int a =0;
        for(int i=0;i<n;i++){
            if(data[i]>a){
                a = data[i];
            }
        }
        return a;
    }

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, x;
  cin >> n >> x;
  
  vector<int>L(n);
  for(int i = 0; i < n; i++)
    cin >> L.at(i);
  
  int count = 0;//はねた回数
  int b = 0;//ボールの場所
  for(int i = 0; i < n; i++){
    if(b > x)
      break;
    count++;
    b += L.at(i);
  }
  if(b <= x)
    count++;
  cout << count << endl;
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
maxa = max(a)
mina = min(a)
a.insert(0, 0), a.append(0)
total = 0
for i in range(N + 1):
    total += abs(a[i] - a[i + 1])

for i in range(N):
        ans = total - abs(a[i] - a[i + 1]) - abs(a[i + 1] - a[i + 2]) + abs(a[i] - a[i + 2])
        print(ans)

Measured memory_bytes: 64108
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#define rep(i,j,n) for(i=j;i<(n);i++)

using namespace std;

int main(){
    map<char,string> s;
    char k='a',h;
    cin>>s['a']>>s['b']>>s['c'];
    while(1){
        h=k;
        if(s[h].size()==0){
            break;
        }
        k=s[h][0];
//        cout<<h<<"さんが持っている中で最初のカードである「"<<k<<"」を捨てる。次は"<<k<<"さんの番"<<endl;
        s[h].erase(s[h].begin());
    }
    h=toupper(h);
    cout<<h<<endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define R(_x, _y) (0 <= _x && _x <= M - 1 && 0 <= _y && _y <= N - 1)
#define A(a) (!(R(x + dx[a], y + dy[a]) && b[y + dy[a]][x + dx[a]]))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
int main() {
	int N, C = 0, a, b, ans;
	cin >> N;
	vector<pair<int, int>> p(N);
	map<pair<int, int>, int> mp;
	rep(i, 0, N)cin >> p[i].first >> p[i].second;
	rep(i, 0, N) {
		rep(i2, 0, N) {
			if (i == i2)continue;
			mp[make_pair(p[i].first - p[i2].first, p[i].second - p[i2].second)]++;
		}
	}
	ans = N;
	for (auto it : mp) {
		//printf("%d\n", it.second);
		ans = min(ans, N - it.second);
	}
	printf("%d\n", ans);
	return 0;
}

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

int comp(const void *a,const void *b){
    return *(int*)b - *(int*)a;
}


int main(void){
    int n,k;
    scanf("%d %d",&n,&k);
    int a[n];
    for(int i = 0;i < n;i++)scanf("%d",&a[i]);
    int kind_num[n];
    for(int i = 0;i < n;i++)kind_num[i] = 0;
    for(int i = 0;i < n;i++)kind_num[a[i]-1]++;
    qsort(kind_num,n,sizeof(int),comp);
    int ans = 0;
    for(int i = k;i < n;i++)if(kind_num[i])ans += kind_num[i];
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 2172
#include <cstdio>
#include <cstdlib>
#include <cstring>

struct Node {
  int key;
  Node *next, *prev;
};

Node *nil;

Node *listSearch(int key) {
  Node *cur = nil->next;
  while ( cur != nil && cur->key != key ) {
    cur = cur->next;
  }
  return cur;
}

void init() {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList() {
  Node *cur = nil->next;
  int isf = 0;
  while ( 1 ) {
    if ( cur == nil ) break;
    if ( isf++ > 0 ) printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t) {
  if ( t == nil ) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst() {
  deleteNode(nil->next);
}

void deleteLast() {
  deleteNode(nil->prev);
}

void deleteKey(int key) {
  deleteNode(listSearch(key));
}

void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  // 番兵の直後に要素を追加
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main() {
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ) {
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) { insert(key); np++; size++; }
    else if ( com[0] == 'd' ) {
      if ( strlen(com) > 6 ) {
        if ( com[6] == 'F' ) deleteFirst();
        else if ( com[6] == 'L' ) deleteLast();
      } else {
        deleteKey(key); nd++;
      }
      size--;
    }
  }
  
  printList();
  
  return 0;
}


Measured memory_bytes: 33972
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>>vvi;

int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a.begin(),a.end());
  int ma=a[n-1];
  a[n-1]=INF;
  int med=ma/2;
  int k;
  double MIN=INF;
  for(int i=0;i<n;i++){
    int d;
    if(ma%2==0){
      
       d=abs(a[i]-med);
    }
    if(ma%2!=0) d=min(abs(a[i]-med),abs(a[i]-(med+1)));
    if(MIN>d){
      k=a[i];
      MIN=d;
    }
  }
  cout<<ma<<" "<<k<<endl;
}
    

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

int main() {
  std::string S;

  std::cin >> S;
  int sum = 0;
  for (auto ch : S) {
    if (ch == '+') {
      sum += 1;
    } else {
      sum -= 1;
    }
  }
  std::cout << sum << std::endl;

  return 0;
}

Measured memory_bytes: 256
//A
#include <iostream>

using namespace std;

int main() {
    int n;

    cin >> n;

    switch (n % 10) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        cout << "hon" << endl;
        break;
    case 0:
    case 1:
    case 6:
    case 8:
        cout << "pon" << endl;
        break;

    default:
        cout << "bon" << endl;
        break;
    }

    return 0;
}

Measured memory_bytes: 3592
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <deque>
using namespace std;

#define iter(i, n) for (int i = 1; i <= n; ++i)
#define iter0(i, n) for (int i = 0; i < n; ++i)
#define iter_r(i, n) for (int i = n; i >= 1; --i)

const int NR = 1e6 + 10;

deque<int> q;
int L[NR], R[NR], n;
char s[NR], t[NR];

int main() {
	scanf("%d%s%s", &n, s + 1, t + 1);

	if (strcmp(s + 1, t + 1) == 0) {
		puts("0"); return 0;
	}


	int j = n;

	iter_r(i, n) {
		while (j > 0 && (j > i || s[j] != t[i])) --j;
		if (j == 0) { puts("-1"); return 0; }
		
		L[j] = i;
		if (R[j] == 0) R[j] = i;
	}
	
	//iter(i, n) printf("[%d %d] ", L[i], R[i]); puts("");

	int ans = 0, tag = 0; bool inited = false;
	iter_r(i, n) if (L[i] != 0) {
		if (!inited) {
			inited = true;
			q.push_back(i);
			q.push_back(L[i]);
		} else {
			int cnt = 1;
			while (!q.empty() && q.back() - tag - 1 >= L[i]) {
				if (q.back() - tag - 1 < R[i]) ++cnt;
				q.pop_back();
			}
			++tag;
			iter(k, cnt) q.push_back(L[i] + tag);
			q.push_front(i + tag);
			
		}
	//	for (int pos : q) printf("%d ", pos - tag); puts("");
		ans = max(ans, (int) q.size() - 1);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 14080
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  string un;
  cin >> H >> W;
  W +=2;
  getline(cin,un);
  vector<string> vec(H);
  for(int i=0;i<H;i++){
    for(int j=-1;j<i;j++){
      vec.at(i)+="mi";
    }
  }
    string ni;
  for(int i=0;i<W;i++)cout << "#";
    cout << endl;
  
    for(int i=0;i<H;i++){
      ni = vec.at(i);
      getline(cin,ni);
        cout << "#" + ni + "#" << endl;
    }
    for(int i=0;i<W;i++)cout << "#";
    cout << endl;
  }


Measured memory_bytes: 256
n = int(input())
num = [[0 for _ in range(10)] for _ in range(10)]
for i in range(1, n + 1):
    num[int(str(i)[0])][int(str(i)[-1])] += 1
ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += num[i][j] * num[j][i]
print(ans)

Measured memory_bytes: 9196
//ÃˆÃ“Ã£ Ã‡Ã¡Ã¡Ã¥ Ã¦Ã¡Ã‡ ÃÃ¦Ã¡ Ã¦Ã¡Ã‡ ÃžÃ¦Ã‰ Ã…Ã¡Ã‡ ÃˆÃ‡Ã¡Ã¡Ã¥
#include<bits/stdc++.h>
#define ll long long
#define fir first
#define sec second
#define pb push_back
#define ins insert
#define be begin
#define en end
#define fast ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
using namespace std;
const int INF=1e9;
//ll a,b;
ll a[202020],b[202020];
vector<ll>v;
pair<ll,ll>p;
map<string,int>mp;
//map<string,int>::iterator it;
set<ll>st;
set<ll>::iterator it;
string s,t;
ll q,n,m,k,z,x,y,d,sum,cnt,mx=0,ans;
ll cum[2020202];
ll M=1e9+7;
int main(){
	fast;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		cum[i]=i>0? cum[i-1]+a[i] : a[i];
	}
	for(int i=0;i<n;i++){
		sum=(cum[n-1]-cum[i]);
		ans=((ans%M)+(((a[i]%M)*(sum%M))%M))%M;

	}
	cout<<ans;
}

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

int main() {
	int sum = 0;
	size_t N;
	cin >> N;
	vector<bool> tmp(N);
	vector<int> A(N + 2);
	for (size_t i = 1; i <= N; ++i) cin >> A[i];
	for (size_t i = 0; i <= N; ++i) sum += abs(A[i] - A[i + 1]);
	for (size_t i = 1; i <= N; ++i) {
		if (A[i - 1] > A[i] && A[i] < A[i + 1] || A[i - 1] < A[i] && A[i] > A[i + 1]) cout << sum - 2 * min(abs(A[i - 1] - A[i]), abs(A[i] - A[i + 1]));
		else cout << sum;
		cout << endl;
	}
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(n); ++i)
const int INF = 1001001001;
int main() {
    int N;
    cin >> N;
    vector<double> V(N);
    rep(i,N) cin >> V[i];
        sort(V.begin(), V.end());
        double syn;
    rep(i,N-1) {
        syn = (V[0] + V[1])/2;
        V[0] = syn;
        V[1] = INF;
        sort(V.begin(), V.end());
    }
    cout << V[0] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <utility>
using namespace std;

vector<int> chi[100000];
int fir[100000], dep = 0;
vector< pair<int, int> > et; //Euler Tour

int min(int a, int b) {
  return a < b ? a : b;
}

void dfs(int a) {
   int i;
   if(fir[a] == -1) fir[a] = et.size();
   et.push_back(make_pair(a, dep));
   for(i = 0; i < chi[a].size(); ++i) {
     dep++;
     dfs(chi[a][i]);
     dep--;
     et.push_back(make_pair(a, dep));
   }
}

int main(void) {
  int i, j, k, n, c, now, q, u, v;
  scanf("%d", &n);
  for(i = 0; i < n; ++i) fir[i] = -1;
  for(i = 0; i < n; ++i) {
    scanf("%d", &k);
    for(j = 0; j < k; ++j) {
       scanf("%d", &c);
       chi[i].push_back(c);
    }
  }
  dfs(0);
  int sm = 1;
  while(sm < et.size()) sm *= 2;
  pair<int, int> seg[sm * 2];
  int las[sm * 2];
  for(i = sm; i < sm * 2; ++i) {
    if(i < sm + et.size()) seg[i].first = et[i - sm].second, seg[i].second = et[i - sm].first;
    else seg[i] = make_pair(1000000, 1000000);
    if(i % 2) {
      now = i / 2;
      while(now) seg[now] = min(seg[now * 2], seg[now * 2 + 1]), now /= 2;
    }
  }
  now = 1;
  for(i = 1; i < sm * 2; ++i) {
    if(now * 2 == i) now *= 2;
    las[i] = (sm / now) * (i - now + 1) - 1;
  }
  scanf("%d", &q);
  for(i = 0; i < q; ++i) {
    int t;
    scanf("%d%d", &u, &v);
    if(fir[u] > fir[v]) t = u, u = v, v = t;
    now = sm + fir[u];
    pair<int, int> min = make_pair(1000000, 1000000);
    while( 1 ) {
      while(!(now % 2)) now /= 2;
      while(las[now] > fir[v]) now *= 2;
      if(min > seg[now]) min = seg[now];
      if(las[now] == fir[v]) break;
      now++;
    }
    printf("%d\n", min.second);
  }
  return 0;
}


Measured memory_bytes: 16044
#include<bits/stdc++.h>
using namespace std;
map<string, int> m = {
  {"MON", 6},
  {"TUE", 5},
  {"WED", 4},
  {"THU", 3},
  {"FRI", 2},
  {"SAT", 1},
  {"SUN", 7}
};
int main(){
  string s; cin >> s;
  cout << m[s] << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cstdlib>
#include<iomanip>
#include<queue>
#include<set>
#include <valarray>
#include<stack>
#include<sstream>
#include<math.h>
   
using namespace std;
    
void Solution()
{
    int m, f, r;
  
    while(cin>>m>>f>>r)
    {
        if(m == -1 && f == -1 && r == -1) break;
            else if(m + f >= 80 && m != -1 && f != -1) cout<<"A"<<endl;
            else if(m + f >= 65 && m + f < 80 && m != -1 && f != -1) cout<<"B"<<endl;
            else if(m + f >= 50 && m + f < 65 && m != -1 && f != -1) cout<<"C"<<endl;
            else if(m + f >= 30 && m + f < 50 && r < 50 && m != -1 && f != -1) cout<<"D"<<endl;
            else if(m + f >= 30 && m + f < 50 && r >= 50 && m != -1 && f != -1) cout<<"C"<<endl;
            else if(m + f < 30 && m + f < 80 && m != -1 && f != -1) cout<<"F"<<endl;
            else if(m == -1 || f == -1) cout<<"F"<<endl;
    }
     
    
}
   
int main()
{
    Solution();
    return 0;
}

Measured memory_bytes: 1152
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class BVotingJudges {
public:
    int N, M, V, P;

    void solve(std::istream& cin, std::ostream& cout) {
        cin >> N >> M >> V >> P;

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

        sort(A.begin(), A.end());
        int b = A[N - 1 - (P - 1)];

        vector<int> sum(N + 1);
        REP(i, N) sum[i + 1] = sum[i] + A[i];

        int res = 0;
        REP(i, N) {
            int a = A[i];
            if (a >= b) {
                res++;
                continue;
            }
            if (a + M < b) {
                continue;
            }

            int rem = V - (P - 1 + i + 1);
            rem *= M;
            if (rem <= 0) {
                res++;
                continue;
            }

            int from = i + 1;
            int to = N - 1 - (P - 1);
            int num = to - from + 1;
            int val = (A[i] + M) * num - (sum[to + 1] - sum[from]);
            if (rem <= val) {
                res++;
            }
        }
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    BVotingJudges solver;
    solver.solve(in, out);
    return 0;
}


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

int dp[101][10001], v[101], w[101];
int main(){
	int N, W;
	cin >> N >> W;
	for(int i=1; i<=N; i++){
		cin >> v[i] >> w[i];
	}
	for(int i=0; i<=W; i++){
		dp[0][i]=0;
	}
	for(int i=1; i<=N; i++)
		for(int j=0; j<=W; j++)
			if(w[i] > j)
				dp[i][j] = dp[i-1][j];
			else if(dp[i-1][j] >= dp[i-1][j-w[i]] + v[i])
				dp[i][j] = dp[i-1][j];
			else dp[i][j] = dp[i-1][j-w[i]] + v[i];
	cout << dp[N][W] << endl;
	return 0;
}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll L, R;
    cin >> L >> R;
    if (R - L + 1 >= 2019) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 2019;
    for (ll i = L; i <= R; i++) {
        for (ll j = i + 1; j <= R; j++) {
            ans = min(ans, i * j % 2019);
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  const int64_t absmax= 200;
  int64_t X;
  cin >> X;

  bool is_found= false;
  for(int64_t A= -absmax; A<absmax; A++){
    for(int64_t B= -absmax; B<absmax; B++){
      if(A*A*A*A*A- B*B*B*B*B == X){
        cout << A <<" "<< B << endl;
        is_found= true;
        break;
      }
    }
    if(is_found){ break; }
  }
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX = 200010;
LL N, T, t[MAX];

int main(void) {
    scanf("%lld%lld", &N, &T);
    REP(i, N) {
        scanf("%lld", t + i + 1);
    }
    LL ans = 0;
    LL nextStop = 0;
    t[0] = 0;
    REP(i, N) {
        if (nextStop < t[i + 1]) {
            ans += T;
            nextStop = t[i + 1] + T;
        } else {
            ans += T - (nextStop - t[i + 1]);
            nextStop = t[i + 1] +T;
        }
        //DEBUG(ans)
        //DEBUG(nextStop)
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
# -*- coding: utf-8 -*-

n, m, x = map(int, input().split())
a = list(map(int, input().split()))
to_zero = len([v for v in a if v > 0 and v < x])
to_n = len([v for v in a if v > x and v < n])
print(min(to_zero, to_n))

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  int N;
  cin >> N;
  vector<ll> A(N);
  REP(i, N)
  cin >> A[i];
  ll ans = 0;
  int left = 0, right = 0;
  ll sum = 0;
  for (; left < N; ++left)
  {
    while (right < N && ((left == right) || (sum + A[right]) == (sum ^ A[right])))
    {
      sum += A[right];
      right++;
    }
    ans += right - left;
    if (left == right)
      right++;
    else
      sum -= A[left];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1920
#include<stdio.h>
int main()
{
    int n,i,max=0;
    scanf("%d",&n);
    int a[n+5];
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        if(max<a[i])max=a[i];
    }
    for(i=0;i<n;i++)
    {
        if(max==a[i])
        {
            a[i]=a[i]/2;
            break;
        }
    }
    long long int sum=0;
    for(i=0;i<n;i++)
    {
        sum=sum+a[i];
    }
    printf("%lld\n",sum);
    return 0;
}


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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define N 111111

const int INF = 1 << 30 ;
typedef long long ll ;
typedef pair < int , int > pii ;

int main() {
  int n,  m , mx = INT_MIN ;
  string s ;
  map<string, int> mp ;

  scanf("%d", &n) ;
  for(int i = 0 ;i<n ;i++){
    cin >> s ;
    mp[s]++ ;
  }
  scanf("%d",&m) ;
  for(int i = 0 ; i<m ;i++){
    cin >>  s;
    mp[s]-- ;
  }

  for(auto it:mp){
    mx = max(mx, it.second) ;
  }
  cout << max(mx, 0) <<endl ;
	
  return 0 ;
}

Measured memory_bytes: 256
package main

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

func main() {
	sc := NewScanner()

	n := sc.ReadInt()
	s := sc.ReadString()

	if n < 3 {
		fmt.Println(0)
		return
	}

	r := 0
	g := 0
	b := 0
	for i := 0; i < n; i++ {
		c := s[i]
		if c == 'R' {
			r++
		} else if c == 'G' {
			g++
		} else {
			b++
		}
	}

	cnt := int64(r) * int64(g) * int64(b)

	for j := 1; j < n-1; j++ {
		cj := s[j]
		if j-0 >= (n-1)-j {
			for k := j + 1; k < n; k++ {
				ck := s[k]
				if ck == cj {
					continue
				}

				i := j*2 - k
				ci := s[i]
				if ci != cj && ci != ck {
					cnt--
				}
			}
		} else {
			for i := 0; i <= j-1; i++ {
				ci := s[i]
				if ci == cj {
					continue
				}

				k := j*2 - i
				ck := s[k]
				if ck != cj && ck != ci {
					cnt--
				}
			}
		}
	}

	fmt.Println(cnt)
}

// util
// *   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base int, exponent uint) int {
	answer := 1
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

func Abs64(x int64) int64 {
	if x >= 0 {
		return x
	}
	return -x
}

func Min64(values ...int64) int64 {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max64(values ...int64) int64 {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow64(base int64, exponent uint) int64 {
	answer := int64(1)
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

// *   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}

func (sc *Scanner) ReadInt64() int64 {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.ParseInt(text, 10, 64)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 1780