akhauriyash/Code-Regression huggingface dataset:
// マニ

#include<bits/stdc++.h>
#define ll        	long long 
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define pb          push_back
#define mp          make_pair
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)  for(ll int i=a;i<b;i++)
#define rrep(i,a,b) for(ll int i=a;i>=b;i--)
#define all(a)      (a).begin(),(a).end()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define PI 3.14159265358979323846
#define tr(i, cont) for(auto i=cont.begin();i!=cont.end();i++)
#define ios        	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define trace(x)                 cerr << #x << ": " << x << "\n";
#define trace1(x)                cerr << #x << ": " << x << "\n";
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << "\n";
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << "\n";
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << "\n";
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << "\n";
#define ar array
#define endl "\n"
using namespace std;

int main(){
	ios;
	ll n;
	cin>>n;
	ll ans=0;
	rep(i,1,n+1){
		ll x;
		cin>>x;
		if(i%2==1 && x%2==1)
			ans++;
	}
	cout<<ans;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<endl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<a.size();zz++) cerr<<a[zz]<<" ";cerr<<endl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<"\n"
#define mod 1000000007ll
#define inf 9999999999999999ll
#define nl endl

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lf a;
    cin>>a;
    a/=3;
    cout<<setprecision(10)<<a*a*a<<nl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k;
    string s;
    cin>>k;
    cin>>s;
    if(s.size()<=k)
        cout<<s;
    else{
        for(int i=0;i<k;i++)
            cout<<s[i];
        cout<<"...";
    }
    return 0;
}


Measured memory_bytes: 3596
#include <algorithm>
#include <iostream>

using namespace std;

int main()
{
  int n;
  cin >> n;
  int l[2000];
  for (int i = 0; i < n; ++i)
    cin >> l[i];
  sort(l, l+n);
  
  int cnt = 0;
  for (int i = 0; i < n-2; ++i)
    for (int j = i+1; j < n-1; ++j)
      for (int k = n-1; k > j; --k)
        if (l[i]+l[j]>l[k]) {
          cnt += k - j;
          break;
        }

  cout << cnt;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  double a,b;
  while(cin >> a){
    b=48.00;
    if(a<=b){
      cout << "light fly" << endl;
    }
    else if(a<=b+3){
      cout << "fly" << endl;
    }
    else if(a<=b+6){
      cout << "bantam" << endl;
    }
    else if(a<=b+9){
      cout << "feather" << endl;
    }
    else if(a<=b+12){
      cout << "light" << endl;
    }
    else if(a<=b+16){
      cout << "light welter" << endl;
    }
    else if(a<=b+21){
      cout << "welter" << endl;
    }
    else if(a<=b+27){
      cout << "light middle" << endl;
    }
    else if(a<=b+33){
      cout << "middle" << endl;
    }
    else if(a<=b+43){
      cout << "light heavy" << endl;
    }
    else{
      cout << "heavy" << endl;
    }
  }
  return (0);
}

Measured memory_bytes: 1220
#include <iostream>

int dp[1010][1010];
bool isPath[1010][1010];

int main(){
    int h, w;
    std::cin >> h >> w;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            char c;
            std::cin >> c;
            isPath[i][j] = (c == '.');
        }
    }
    for(int i = 0; i < h; i++){
        dp[i][0] = 1;
        if(!isPath[i+1][0]) break;
    }
    for(int j = 0; j < w; j++){
        dp[0][j] = 1;
        if(!isPath[0][j+1]) break;
    }
    for(int i = 1; i < h; i++){
        for(int j = 0; j < w; j++){
            if(isPath[i][j]){
                dp[i][j] = (dp[i-1][j] + dp[i][j-1])%int(1e9+7);
            }
        }
    }
    std::cout << dp[h-1][w-1] << std::endl;
}


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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	string s;
	cin>>s;
	set<char> ss;
	rep(i,s.size())ss.emplace(s[i]);
	cout<<(ss.size()==2?"Yes":"No")<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cstdio>
#include<functional>
#include<iostream>
#include<cfloat>
#include<climits>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<time.h>
#include<vector>
using namespace std;
int main()
{
	long long n,m;
        cin >> n >> m;
	if(n==1&&m==1) cout<<1<<endl;
	else if(n==1||m==1) cout<<n*m-2<<endl;
	else if(n==2||m==2) cout<<0<<endl;
	else cout<<(n-2)*(m-2)<<endl;
	system("pause");
	return 0;
}

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

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

    vector<int> height(no_of_stones + 1, 0);
    for (int i = 1; i <= no_of_stones; i++)
        cin >> height[i];

    vector<int> minimum_cost(no_of_stones + 1);
    minimum_cost[2] = abs(height[2] - height[1]);
    for (int i = 3; i <= no_of_stones; i++)
        minimum_cost[i] = min(minimum_cost[i - 1] + abs(height[i] - height[i - 1]),
                              minimum_cost[i - 2] + abs(height[i] - height[i - 2]));

    cout << minimum_cost[no_of_stones];
    return 0;
}

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

using namespace std;

typedef long long ll;
#define INF (1<<29)
#define INFF 0x7fffffff
#define LINF (1ll<<60)
#define LINFF 0x7fffffffffffffff
#define PI 3.14159265359
#define _fi(n) for(int i = 0;i < n;i++)
#define _fj(n) for(int j = 0;j < n;j++)
#define _fk(n) for(int k = 0;k < n;k++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define endl '\n'

vector<int>adj[100005];
int dist[100005] = {};

int solve(int a){
    if (dist[a] == 0){
        int d = 0;
        for(auto b:adj[a]){
            d = max(d, solve(b)+1);
        }
        dist[a] = d;
    }
    return dist[a];
}

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

    int n, m;cin>>n>>m;
    for(int i = 0;i < m;i++){
        int a, b;cin>>a>>b;
        adj[a].pb(b);
    }

    int ans = 0;
    for(int i = 1;i <= n;i++) {
        ans = max(ans, solve(i));
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;
using pii=pair<int,int>;
using ll=long long;

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

    string s;
    cin>>s;
    int check[26]={0};
    int cnt=0;
    bool answer=true;
    for(char ch : s){
        if(check[ch-'A']==0) cnt+=1;
        if(cnt>2) answer=false;
        check[ch-'A']+=1;
        if(check[ch-'A']>2) answer=false;
    }
    if(answer) cout<<"Yes";
    else cout<<"No";

    return 0;
}


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

int counter(int n){
  
  int count = 0;
  bool judge = true;
  
  while(judge){
  if(n % 2 == 0){
    n /= 2;
    count++;
  }
    else{
      judge = false;
    }
  }
  
  return count;
}
    

int main(){
  int N;
  cin >> N;
  int maxcount = 0;
  int find = 1;
  
  vector<int> num(N);
  for(int i = 0; i < N; i++){
    if(counter(i + 1) > maxcount){
      maxcount = counter(i + 1);
       find = i + 1;
    }
  }
  
  cout << find << endl;
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define pair pair<int,int>
#define ll long long
#define f first
#define se second
using namespace std;
double pi=acos(-1.0);
int main(){
  int n,w;
  scanf("%d %d",&n,&w);
  vector<pair> v(n+1);
  for(int i=1;i<=n;i++)
    scanf("%d %d",&v[i].f,&v[i].se);
  auto it=v.begin();it++;
  sort(it,v.end());
  ll ans[n+1][w+1];
  for(int i=0;i<=n;i++)
    ans[i][0]=0;
  for(int i=0;i<=w;i++)
    ans[0][i]=0;
  for(int i=1;i<=n;i++)
  {
    for(int j=1;j<=w;j++)
    {
     // cout<<v[i].f<<" "<<v[i].se<<"\n";
      if(v[i].f>j)
        ans[i][j]=ans[i-1][j];
      else
        ans[i][j]=max(ans[i-1][j],ans[i-1][j-v[i].f]+v[i].se);
    }
  }
 /* for(int i=0;i<=n;i++)
  {
    for(int j=0;j<=w;j++)
      printf("%d ",ans[i][j]);
    printf("\n");
  }*/
  printf("%lli",ans[n][w]);
}

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

int find(vector<long long>& v, long long val) {
  for (int i=0; i<v.size(); i++) if (v[i] == val) return i;
  return -1;
}

void solve(long long X, long long N, std::vector<long long> p){
  sort(p.begin(), p.end());
  int idx = find(p, X);
  if (idx < 0) {
    cout << X << endl;
    return;
  }

  int l = idx, r = idx;
  int l_val = X, r_val = X;
  while (true) {
    if (l-1 < 0) {
      cout << l_val - 1 << endl;
      return;
    }
    if (p[--l] != --l_val) {
      cout << l_val << endl;
      return;
    }

    if (p.size()-1 < r+1) {
      cout << r_val+1 << endl;
      return;
    }
    if (p[++r] != ++r_val) {
      cout << r_val << endl;
      return;
    }

  }

}

int main(){
    long long X;
    scanf("%lld",&X);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> p(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&p[i]);
    }
    solve(X, N, std::move(p));
    return 0;
}


Measured memory_bytes: 3688
#include<iostream>
using namespace std;
int main()
{
	int scale = 0;
	int count = 0;
	int arr[101] = {0};
	cin >> scale;
	for (int i = 0; i < scale; i++) 
	{
		cin >> arr[i];
	}
	for (int i = 0; i < scale; i += 2) {
		if (arr[i] % 2 == 1)
		{
			count++;
		}
	}
	cout << count << endl;
    return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string S,T,U;
int A,B;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S>>T>>A>>B>>U;
	if(S==U) A--;
	else B--;
	cout<<A<<" "<<B<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
//verma_ankit484

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

#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
const int mod = 998244353;

using namespace std;
//using namespace __gnu_pbds;

//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
int dp[3001][3001];
int s, n;
vector<int> vc;

int rec(int idx, int sum) {
  if (sum > s) return 0;
  if (sum == s) {
    return n - idx + 1;
  }
  if (idx >= n) return 0;
  int &ans = dp[idx][sum];
  if (ans != -1) return ans;
  ans = 0;
  ans = rec(idx + 1, sum);
  // cout << ans << ' ' << ans % mod << endl;
  ans %= mod;
  ans += rec(idx + 1, sum + vc[idx]);
  ans %= mod;
  return ans;
}

int32_t main() {
  IOS
  #ifdef AV
  freopen("input.txt", "r", stdin);
  #endif
  cin >> n >> s;
  vc.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> vc[i];
  }
  memset(dp, -1, sizeof(dp));
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += rec(i, 0);
    ans %= mod;
  }
  cout << ans << endl;
  // cout << rec(0, 0) << endl;
  return 0;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define INX(x) (cin >> x)
#define OUTX(x) (cout << x << endl)

#define ADD emplace_back
#define MP make_pair

#define MAXC (100000 * 12 + 1)

vector<int> vectorplus(vector<int> v1, vector<int> v2)
{
    vector<int> result(v1.size(), 0);
    for (int i = 0; i < result.size(); i++)
    {
        result[i] = v1[i] + v2[i];
    }
    return result;
}

vector<int> vectorcopy(vector<int> v)
{
    vector<int> result(v.size());
    for (int i = 0; i < result.size(); i++)
    {
        result[i] = v[i];
    }
    return result;
}

int main()
{
    int N; //参考書の数
    int M; //アルゴリズムの数
    int X; //理解度の目標値
    cin >> N >> M >> X;
    
    vector<int> ca;
    vector<vector<int>> va;
    for (int i = 0; i < N; i++)
    {
        int tmpi;
        cin >> tmpi;
        ca.ADD(tmpi);

        vector<int> tmp;
        for (int j = 0; j < M; j++)
        {
            cin >> tmpi;
            tmp.ADD(tmpi);
        }
        va.ADD(tmp);
    }
    
    queue<vector<int>> que; //パターン
    queue<int> queca; //合計額
    queue<vector<int>> queva; //学習
    for (int i = 0; i < N; i++)
    {
        que.push(vector<int>(1, i));
        queca.push(ca[i]);

        vector<int> tmp(M);
        for (int j = 0; j < M; j++)
        {
            tmp[j] = va[i][j];
        }
        queva.push(tmp);
    }

    int minc = MAXC;
    while(que.size() > 0)
    {
        vector<int> tmp = que.front();
        int tmpca = queca.front();
        vector<int> tmpva = queva.front();
        
        //条件判定
        bool isOK = true;
        for (int i = 0; i < M; i++)
        {
            isOK &= (tmpva[i] >= X);
        }

        if(isOK)
        { //学習度が達成できたらこれ以上参考書を増やさない
            if(minc > tmpca)
            {
                minc = tmpca;
            }
        }
        else
        { //学習度が達成できていない場合は参考書を増やして確認
            for (int i = tmp.back() + 1; i < N; i++)
            {
                vector<int> tmpn = vectorcopy(tmp);
                tmpn.ADD(i);
                que.push(tmpn);
                queca.push(tmpca + ca[i]);
                queva.push(vectorplus(tmpva, va[i]));
            }
        }

        //このパターンは消去
        que.pop();
        queca.pop();
        queva.pop();
    }
    

    if(minc == MAXC)
    {
        OUTX(-1);
    }
    else
    {
        OUTX(minc);
    }
    



    int wait;
    INX(wait); //結果確認用の待ち（提出時に消してね）

    return 0;
}


Measured memory_bytes: 3780
#include<iostream>
#include<map>
using namespace std;
#define df 0
#define MOD 998244353
typedef long int li;

template<li p>
class modint{
  li val;
  //  static const li modulo=p;
public:
  modint(li a){ val=a%p; };
  modint(int a){ val=a%p; };
  modint(){ val=0; };
  li repr() const { return val+(val<0?p:0); };
  const modint operator+(const modint<p>& b){return (modint)(val+b.repr());};
  modint& operator+=(const modint<p>& b){*this=*this+b; return *this;};
  const modint operator-(const modint<p>& b){return (modint)(val-b.repr());};
  modint& operator-=(const modint<p>& b){*this=*this-b; return *this;};
  const modint operator*(const modint<p>& b){return (modint)(val*b.repr());};
  modint& operator*=(const modint<p>& b){*this=*this*b; return *this;};
  const modint operator+() const {return *this;};
  const modint operator-() const {return 0-(*this);};
  modint& operator++() const {+this+=1;return *this;};
  modint& operator--() const {+this-=1;return *this;};
  const bool operator==(const modint<p>& b)
  {return this->repr()==b.repr();};

};

template<li p>
ostream& operator<<(ostream& os,const modint<p>& a){
  os << a.repr();
  return os;
}
template<li p>
istream& operator>>(istream& is, modint<p>& x){
  li a; cin >>a;
  x=(modint<p>)a;
  return is;
}
template<li p>
const modint<p> pow(modint<p> m,modint<p-1> a){
  li k=a.repr();
  modint<p> s=1;
  while(k){
    if(k%2)s*=m;
    m*=m;
    k/=2;
  }
  return s;
}
template<li p>
const modint<p> pow(modint<p> m,int a){
  li k=a;
  modint<p> s=1;
  while(k){
    if(k%2)s*=m;
    m*=m;
    k/=2;
  }
  return s;
}


int main(){
  if(df) printf("*debug mode*\n");

  int n; cin >>n;
  int a; cin >>a;
  if(a!=0){
    printf("0");
    return 0;
  }
  map<int,int> mp;
  int mx=0;
  for(int i=1;i<n;i++){
    cin >>a;
    if(a==0){
      printf("0");
      return 0;
    }
    mp[a]++;
    if(mx<a)mx=a;
  }
  modint<MOD> s=1;
  mp[0]=1;
  for(int i=0;i<mx;i++){
    s*=pow(modint<MOD>(mp[i]),modint<MOD-1>(mp[i+1]));
  }
  
   cout << s;
}

/// confirm df==0 ///


Measured memory_bytes: 4992
#include<stdio.h>
int main(){
	int wa=0,i=0,N, X, L[100];
	scanf("%d %d", &N, &X);
	L[N] = 10001;
	while(wa<=X&&i<=N)
	{
		scanf("%d", &L[i]);
		wa += L[i];
		i++;
	}
	printf("%d", i);
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    private static final Scanner  SC = new Scanner(System.in);
    private static final String RESULT = SC.next();

    public static void main(String[] args) {
        int victory = 0;
        int day = 0;
        final int BORDER = 8;

        for(char c : RESULT.toCharArray()){
            day++;
            if(c=='o'){
                victory++;
            }
        }

        final int DAYS_LEFT = 15-day;

        if ((DAYS_LEFT - (BORDER - victory))<0) {
            System.out.println("NO");
        }else{
            System.out.println("YES");
        }
    }
}

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

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

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N, A, B;
    cin >> N >> A >> B;

    cout << min( N*A, B) << endl;
}


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

n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]

connection=[[] for i in range(n)]
for i in range(m):
  connection[l[i][0]-1].append(l[i][1]-1)
  connection[l[i][1]-1].append(l[i][0]-1)

colors=[0 for i in range(n)]

def dfs(v,color):
    colors[v]=color
    for to in connection[v]:
        if colors[to]==color:
            return False
        if colors[to]==0 and not dfs(to, -color):
            return False
    return True

if dfs(0,1)==0:
  print(n*(n-1)//2-m)
  sys.exit()

def bfs(v):
  distance=[-1]*n
  distance[v]=0
  next=connection[v]
  next2=set()
  visited=[-1]*n
  visited[v]=1
  visitct=1
  ct=0
  while len(next)!=0 and visitct!=n:
    ct+=1
    for i in range(len(next)):
      if visited[next[i]]==-1:
        distance[next[i]]=ct
        visited[next[i]]=1
        visitct+=1
        for j in range(len(connection[next[i]])):
          if visited[connection[next[i]][j]]==-1:
            next2.add(connection[next[i]][j])
    next=list(next2)
    next2=set()
  return distance

B=bfs(0)
cta=0;ctb=0
for i in range(n):
  if B[i]%2==0:
    cta+=1
  else:
    ctb+=1
print(cta*ctb-m)

Measured memory_bytes: 114520
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;
const ll INF=1e9;
const ll IINF=1e18;

template<class T> inline bool chmin(T &a,T b){
    if (a>b){
        a=b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T &a,T b){
    if (a<b){
        a=b;
        return true;
    }
    return false;
}

int main(){
    string L;
    cin >> L;
    ll s=L.size();
    vector<ll> mod3(s+1),d2(s+1);
    mod3[0]=1,d2[0]=1;
    rep(i,s){
        mod3[i+1]=(mod3[i]*3)%MOD;
        d2[i+1]=(d2[i]*2)%MOD;
    }
    ll ans=0,count=0;
    rep(i,s){
        if(L[i]=='1'){
            ans+=(mod3[s-1-i]*d2[count])%MOD;
            ans%=MOD;
            count++;
        }
    }
    ans+=d2[count];
    ans%=MOD;
    cout << ans << endl;
}

Measured memory_bytes: 2048
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }

#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
    for (auto &e : t) fill(e, v);
}


int N, M;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    while (cin >> N >> M) {
        long long res = 0;
        long long ac = 0;
        
        map<int, long long> num;
        set<int> alr;
        for (int i = 0; i < M; ++i) {
            int p; string s;
            cin >> p >> s;
            if (s == "AC") {
                if (!alr.count(p)) {
                    res += num[p];
                    ++ac;
                }
                alr.insert(p);
            }
            else {
                num[p]++;
            }
        }
        cout << ac << " " << res << endl;
    }
}


















Measured memory_bytes: 11264
import sys
import collections
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsl = lambda: map(str, sys.stdin.readline().split())

n, m = nm()
lis = [[] for _ in range(n + 1)]
for i in range(m):
    a, b = nm()
    lis[a].append(b)
    lis[b].append(a)
for i in range(len(lis[1])):
    l = lis[1][i]
    if n in lis[l]:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')


Measured memory_bytes: 38652
n, m = map(int, input().split())
if m == 1:print(2 ** n % 1000000)
else:
  dp = [[[0] * (n + 1) for _ in range(3)] for _ in range(n + 1)]
  dp[0][0][0] = 1
  for y in range(n):
    for x in range(3):
      for slide_limit in range(y + 1):
        if x == 0:
          dp[y + 1][0][slide_limit] += dp[y][0][slide_limit]
          dp[y + 1][1][y + 1] += dp[y][0][slide_limit]
          dp[y + 1][2][y + 1] += dp[y][0][slide_limit] * (y - slide_limit + 1)
        if x == 1:
          dp[y + 1][0][y + 1] += dp[y][1][slide_limit]
          dp[y + 1][1][slide_limit] += dp[y][1][slide_limit]
          dp[y + 1][2][y + 1] += dp[y][1][slide_limit]
        if x == 2:
          dp[y + 1][0][y + 1] += dp[y][2][slide_limit] * (y - slide_limit + 1)
          dp[y + 1][1][y + 1] += dp[y][2][slide_limit]
          dp[y + 1][2][slide_limit] += dp[y][2][slide_limit]
  print((sum([sum(line) for line in dp[n]]) + sum([dp[n][0][slide_limit] * (n - slide_limit) for slide_limit in range(n + 1)])) % 1000000)


Measured memory_bytes: 6388
from sys import stdin
input = stdin.readline
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
c = Counter(a)
s = set()
ans = 0
for i in sorted(set(a)):
    j=i*2
    while j<=1000000:
        s.add(j)
        j+=i
    if i not in s and c[i]==1:
        ans+=1
            
print(ans)

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

int main(){
    int N;
    cin >> N;
    vector<int> H(N);
    for (int i = 0; i < N; i++){
        cin >> H.at(i);
    }
    int ans = 0;
    int count = 0;
    for (int i = 0; i < N - 1; i++){
        if(H.at(i) >= H.at(i + 1)){
            count++;
        }
        else{
            ans = max(ans, count);
            count = 0;
        }
    }
    ans = max(ans, count);
    cout << ans <<endl;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void){
	while(1){
		int n, i, j;
		int a[4], b[4];
		long c[4];
		
		scanf(" %d", &n);
		if(n==0) break;

		for(i=0; i<n; i++){
			for(j=0; j<4; j++)
				scanf(" %d", &a[j]);
			for(j=0; j<4; j++)
				scanf(" %d", &b[j]);
			
			c[0] = a[0]*b[0] - a[1]*b[1] - a[2]*b[2] - a[3]*b[3];
			c[1] = a[0]*b[1] + a[1]*b[0] + a[2]*b[3] - a[3]*b[2];
			c[2] = a[0]*b[2] - a[1]*b[3] + a[2]*b[0] + a[3]*b[1];
			c[3] = a[0]*b[3] + a[1]*b[2] - a[2]*b[1] +a[3]*b[0];
				
			for(j=0; j<4; j++) {
				printf("%ld", c[j]);
				if(j<3) printf(" ");	
			}
			printf("\n");
		
		}

	}

	return 0;
}

Measured memory_bytes: 600
import sys
range = xrange
input = raw_input
 
def find_SCC(coupl):
    SCC, S, P = [], [], []
    depth = [0] * len(coupl)
 
    stack = list(range(len(coupl)))
    while stack:
        node = stack.pop()
        if node < 0:
            d = depth[~node] - 1
            if P[-1] > d:
                SCC.append(S[d:])
                del S[d:], P[-1]
                for node in SCC[-1]:
                    depth[node] = -1
        elif depth[node] > 0:
            while P[-1] > depth[node]:
                P.pop()
        elif depth[node] == 0:
            S.append(node)
            P.append(len(S))
            depth[node] = len(S)
            stack.append(~node)
            stack += coupl[node]
    return SCC[::-1]

class TwoSAT:
    def __init__(self, n):
        self.n = n
        self.graph = [[] for _ in range(2 * n)]

    def _imply(self, x, y):
        self.graph[x].append(y if y >= 0 else 2 * self.n + y)

    def either(self, x, y):
        """either x or y must be True"""
        self._imply(~x, y)
        self._imply(~y, x)

    def set(self, x):
        """x must be True"""
        self._imply(~x, x)

    def solve(self):
        SCC = find_SCC(self.graph)
        
        inSCC = [0] * (2 * self.n)
        for scc_ind, scc in enumerate(SCC):
            for node in scc:
                inSCC[node] = scc_ind
        
        for i in range(self.n):
            if inSCC[i] == inSCC[~i]:
                return False, None
        
        return True, [+(inSCC[i] < inSCC[~i]) for i in range(self.n)]

inp = [int(x) for x in sys.stdin.read().split()]; ii = 0
 
n = inp[ii]; ii += 1
d = inp[ii]; ii += 1

sat = TwoSAT(n)

X = inp[ii + 0: ii + 2 * n: 2] 
Y = inp[ii + 1: ii + 2 * n: 2] 
ii += 2 * n

for i in range(n):
    for j in range(i + 1, n):
        
        if abs(X[i] - X[j]) < d:
            sat.either(i, j)
        
        if abs(Y[i] - Y[j]) < d:
            sat.either(~i, ~j)
        
        if abs(X[i] - Y[j]) < d:
            sat.either(i, ~j)
        
        if abs(Y[i] - X[j]) < d:
            sat.either(~i, j)

exists, solution = sat.solve()

if not exists:
    print 'No'
else:
    print 'Yes'
    print ' '.join(str(X[i] if b else Y[i]) for i, b in enumerate(solution))



Measured memory_bytes: 79956
n, m = gets.split.map(&:to_i)
sc = m.times.map { gets.split.map(&:to_i) }

a = 'a' * n

if n > 3
  puts '-1'
  exit
end
if m == 0
  if n == 1
    puts 0
  elsif n == 2
    puts 10
  elsif n == 3
    puts 100
  end
  exit
end

sc.each do |e|
  s = e[0] - 1
  c = e[1].to_s
  if s >= n
    puts '-1'
    exit
  end
  if a[s] == 'a'
    a[s] = c
  elsif a[s] != c
    puts '-1'
    exit
  end
end

a[0] = '1' if a[0] == 'a' && n != 1
a.tr!('a', '0')
x = a.to_i.to_s

if x.size == n
  puts x
else
  puts '-1'
end


Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
#define MAX 1000010

int main(){
	int hamming[MAX];
	for(int i=0;i<MAX;i++){
		hamming[i]=0;
	}
	long int tmp =0;
	for(int i=0;tmp<MAX;i++){
		for(int j=0;tmp<MAX;j++){
			for(int k=0;tmp<MAX;k++){
				tmp =pow(2,i)*pow(3,j)*pow(5,k);
				if(tmp<MAX){
					hamming[tmp]=1;
				}
			}
			tmp =pow(2,i)*pow(3,j+1)*pow(5,0);
		}
		tmp =pow(2,i+1)*pow(3,0)*pow(5,0);
	}
	
	
	int a,b;
	while(cin>>a,a!=0){
		cin>>b;
		int ans=0;
		for(int i=a;i<b+1;i++){
			ans+=hamming[i];
		}
		cout<<ans<<endl;
	}
	
}

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

ll gcd(ll a,ll b){
  while(b!=0){
    a%=b;
    swap(a,b);
  }
  return a;
}

ll kaizyou(ll N){
  ll num=1;
  for(ll i=1;i<=N;i++){
  num*=i;
  }
  return num;
}

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

 
int main(){
  ll H;
  cin >> H;
  ll H2=H;
  ll num=0;
  while(H2/2!=0){
    H2/=2;
    num++;
  }
  cout << ll(pow(2,num+1)-1) << endl;
}
      
  
  
  

Measured memory_bytes: 384
N, M, X = map(int, input().split())

C = []
A = []
for i in range(N):
    # この1行をtとする
    t = list(map(int, input().split()))
    C.append(t[0])
    # c以降はそれぞれAに代入
    A.append(t[1:])

result = -1
for i in range(1 << N):
    # 0をm個分複製
    t = [0] * M
    c = 0
    for j in range(N):
        # i を j回右にシフトして 1 と論理積を取る　これがfalseならcontinue
        if (i >> j) & 1 == 0:
            continue
        # trueならc[j]円カウントする　最終的に180円になる
        c += C[j]
        for k in range(M):
            # Aj冊目のkをリストtにいれる 0 1 2 と順番に
            t[k] += A[j][k]
    # xが指定のXの理解度に達するまで上のtをチェック
    if all(x >= X for x in t):
        if result == -1:
            result = c
        else:
            result = min(result, c)
print(result)

Measured memory_bytes: 9224
N,K = map(int,input().split())
a = list(map(int,input().split()))
ball = {}
i = 0
num = 0
change = 0
for n in range(len(a)):
    if a[n] in ball:
        ball[a[n]] = ball[a[n]] + 1
    else:
        ball[a[n]] = 1

num = len(ball)
s = sorted(ball.items(),key=lambda ball: ball[1])
while K < num:
    num -= 1
    change += s[i][1]
    i += 1

print(change)

Measured memory_bytes: 39064
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rel register ll
#define rec register char
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) pc('-'),x=-x;
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int yuzu=1e5;
map<ll,int> mp;
typedef ll fuko[yuzu|10];
fuko sum;
int main(){
int i,n=read(),m=read();
for (i=1;i<=n;++i) sum[i]=(sum[i-1]+read())%m;
ll llx=0;
for (i=0;i<=n;++i) llx+=mp[sum[i]],mp[sum[i]]++; 
write(llx),pl;
}
/*0,0,1,0*/

Measured memory_bytes: 4992
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
    int i,j;
    string a;
    cin>>a;
    int ans=0;
    for (char c:a) c=='-'?ans--:ans++;
    cout<<ans;
}

Measured memory_bytes: 256
#include <cstdio>
int N, M, Q, s[2001][2001], sx[2001][2001], sy[2001][2001];
char a[2001][2001];
int main()
{
	scanf("%d%d%d", &N, &M, &Q);
	for (int i = 1; i <= N; i++)
		scanf("%s", a[i] + 1);
	for (int i = 1; i <= N; i++)
		for (int j = 1; j <= M; j++)
			s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + (a[i][j] == '1');
	for (int i = 2; i <= N; i++)
		for (int j = 1; j <= M; j++)
			sx[i][j] = sx[i - 1][j] + sx[i][j - 1] - sx[i - 1][j - 1] + (a[i - 1][j] == '1' && a[i][j] == '1');
	for (int i = 1; i <= N; i++)
		for (int j = 2; j <= M; j++)
			sy[i][j] = sy[i - 1][j] + sy[i][j - 1] - sy[i - 1][j - 1] + (a[i][j - 1] == '1' && a[i][j] == '1');
	while (Q--)
	{
		int u, l, d, r;
		scanf("%d%d%d%d", &u, &l, &d, &r);
		printf("%d\n", s[d][r] - s[u - 1][r] - s[d][l - 1] + s[u - 1][l - 1] - sx[d][r] + sx[u][r] + sx[d][l - 1] - sx[u][l - 1] - sy[d][r] + sy[u - 1][r] + sy[d][l] - sy[u - 1][l]);
	}
	return 0;
}


Measured memory_bytes: 52608
n, m, c = map(int, input().split())
b = list(map(int, input().split()))

count = 0
for _ in range(n):
    a = list(map(int, input().split()))
    if sum([a[i] * b[i] for i in range(len(a))]) + c > 0:
        count += 1

print(count)

Measured memory_bytes: 3060
A,B,C,D = gets.split.map(&:to_i)

if A-C > 0
  StartTime = A
else
  StartTime = C
end

if B-D>0
  FinishTime = D
else
  FinishTime = B
end

if FinishTime - StartTime > 0
  puts(FinishTime - StartTime)
else
  puts(0)
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int N;
    cin >> N;
    string S,T;
    cin >> S >> T;
    for(int i = 0; i < N;i++)cout << S.substr(i,1)<< T.substr(i,1);
    cout <<endl;
}


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


int main() {
    int n;cin>>n;
    vector<ll> by(0);
    vector<ll> a(n);
    vector<bool> ch(n,true);
    for(ll i=1;i<=20000000000;i*=2) by.push_back(i);
    rep(i,n)cin>>a[i];
    sort(a.begin(),a.end());
    int ans=0;
    
    for(int i=n-1;i>=0;i--){
        if(!ch[i]) continue;
        ll k=a[i];
        ll l=*upper_bound(by.begin(),by.end(),k); 
        ch[i]=false;   
        auto its=lower_bound(a.begin(),a.end(),l-k);
        if(*its==l-k&&ch[its-a.begin()]){
            ans++;
            ch[its-a.begin()]=false;
            a[its-a.begin()]--;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
	long long a, b, c, d;
	vector<long long> ans;

	cin >> a >> b >> c >> d;

	ans.push_back(a * c);
	ans.push_back(a * d);
	ans.push_back(b * c);
	ans.push_back(b * d);

	sort(ans.begin(), ans.end());
	

	cout << ans[3] << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <set>
#include <numeric>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }





int main() {

  char a;
  cin >> a;

  if (a >= 'a' && a <= 'z') a = 'a';
  else if (a >= 'A' && a <= 'Z') a = 'A';

  cout << a << endl;

  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


int main() {
  ll n; cin >> n;
  Vll a(n); cin >> a;

  ll sum = 0;
  rep(i, n) sum += a[i];

  ll nn = n*(n+1)/2;

  if (sum % nn != 0) {
    cout << "NO" << endl;
    return 0;
  }

  ll k = sum / nn;

  Vll b(n);
  rep(i, n) {
    int i0 = (i-1+n)%n;
    int i1 = (i+1)%n;
    b[i] = a[i0] + a[i1] - 2*a[i];
    if (b[i] % n != 0) {
      cout << "NO" << endl;
      return 0;
    }
    b[i] /= n;
  }

  Vll x(n);
  ll xmin = 0;
  rep(i, n-1) {
    x[i+1] = x[i] - b[i+1];
    chmin(xmin, x[i+1]);
  }
  rep(i, n) x[i] -= xmin;

  ll xsum = 0;
  rep(i, n) xsum += x[i];

  if (k >= xsum && (k-xsum)%n == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;

int main(){
	
	ll n,a,b; cin>>n>>a>>b;
	if(!(abs(a-b)%2)){
		cout << abs(a-b)/2 << endl;
	}
	else{
		if(a-1<n-b){
			cout << a+(b-a-1)/2 << endl;
		}
		else{
			cout << n-b+1+(n-(a+n-b+1))/2 << endl;
		}
	}
	
	
}



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

const int INF = 1e9;

int main() {
  int q;
  cin>>q;
  int median = -1e9 - 1;
  long long val = 0;
  multiset<int> left, right;

  for (int i=0; i<q; i++) {
    int type;
    cin>>type;
    if (type == 1) {
      int a, b;
      cin>>a>>b;
      val += b;
      if (median == -1e9 - 1) {
        median = a;
        continue;
      }
      if (left.size() == right.size()) {
        if (a <= median) {
          left.insert(a);
        } else {
          right.insert(a);
        }
        val += abs(a - median);
        if (left.size() > right.size()) {
          int prev_median = median;
          auto it = left.rbegin();
          median = *it;
          right.insert(prev_median);
          left.erase(next(it).base());
        }
      } else  {
        val += abs(a - median);
        if (a <= median) {
          left.insert(a);
        } else {
          right.insert(a);
        }
        if (left.size() - right.size() == 2) {
          int prev_median = median;
          auto it = left.rbegin();
          right.insert(median);
          median = *it;
          left.erase(next(it).base());
          val -= prev_median - median;
        } else if (right.size() - left.size() == 2) {
          int prev_median = median;
          auto it = right.begin();
          left.insert(median);
          median = *it;
          right.erase(it);
          val -= median - prev_median;
        }
      }
    } else {
      cout<<median<<" "<<val<<endl;
    }
  }
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = false;
}  // namespace mydef
using namespace mydef;
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans


void solve() {
}


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

    int A, B, V, W, T;
    cin >> A >> V >> B >> W >> T;
    int C = abs(A - B);

    if (C <= (V - W) * T)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;


    solve();
    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int a,b; cin>>a>>b;
	cout<<(a+b-1)/b;
	
	return 0;
}

Measured memory_bytes: 3628
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])


s = input()
if s.islower():
    print("a")
else:
    print("A")


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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;

int main() {
  int A, B,C,D;
  cin >>A>>B>>C>>D;
  int x = A / D;
  int y = C / B;
  if(A%D!=0) x++;
  if(C%B!=0) y++;
  if(y<=x) cout << "Yes" << endl;
  if(y>x) cout << "No" << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    string s;
    cin>>s;
    string ans="";
    rep(0,i,s.length())ans+=s[i]=='?'?'D':s[i];
    cout<<ans;
}


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

#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;

LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
LL lcm(LL a,LL b){return a/gcd(a,b)*b;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
const int N = 2e5 +11;
int n,k;
int q[N],su[N];
char a[N];
int ch(int len){
	// cout<<len<<endl;
	for(int i=1;i+len-1<=n;i++){
		int la=su[i+len-1]-su[i-1];
		if(q[i]==1)la--;
		if(la&&a[i+len-1]=='0')la++;
		// if()
		// if(len==3)cout<<"dad->"<<la<<endl;
		if(la<=k)return 1;
	}
	return 0;
}
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>k>>a+1;
	for(int i=2;i<=n;i++){
		if(a[i]=='1'&&a[i-1]=='0')q[i]=1;
	}
	for(int i=1;i<=n;i++)su[i]+=su[i-1]+q[i];
	int l=0,r=n+1,ans=0;
	while(l<=r){
		int mid=l+r>>1;
		if(ch(mid))ans=mid,l=mid+1;
		else r=mid-1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>
int main()
{
	int a,b;
	int x,y,z,max;
	scanf("%d %d",&a,&b);
	x=a+b;
	y=a-b;
	z=a*b;
	max=x;
	if(y>max){
		max=y;
	}
	if(z>max){
		max=z;
	}
	printf("%d\n",max);
	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)


int main(){
	int g[6][2]={
		{1,2},{-1,3},{1,-1},{4,5},{5,2},{2,1}
	};
	int l,n;
	char p[100];
	for(;;){
		scanf("%s",p);
		if(p[0]=='#')break;
		l=strlen(p);
		n=0;
		rep(i,l)if(n!=-1)n=g[n][p[i]-'0'];
		if(n==5)puts("Yes");
		else puts("No");
	}
	return 0;
}

Measured memory_bytes: 1108
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
char dt[200001][2]={};
int n,q,l,r,tl,tr;string s;
bool ps(int idx,int ck)
{
	int cr = idx;
	for (int i=0;i<q;i++)
	{
		if (cr<0||cr>=n) {break;}
		if (dt[i][0]==s[cr])
		{
			if (dt[i][1]=='L') {cr--;}
			else {cr++;}
		}
	}
	if (ck&&cr<0) {return true;}
	else if (!ck&&cr>=n) {return true;}
	else {return false;}
}
int main()
{
	cin>>n>>q>>s;
	for (int i=0;i<q;i++)
	{
		cin>>dt[i][0]>>dt[i][1];
	}
	l=0,r=n;
	while (l<r)
	{
		int pv = (l+r)>>1;
		if (ps(pv,1)) {l=pv+1;}
		else {r=pv;}
	}
	tl = l;
	l=0;r=n;
	while (l<r)
	{
		int pv = (l+r)>>1;
		if (ps(pv,0)) {r=pv;}
		else {l=pv+1;}
	}
	tr = l;
	//cout<<tl<<" "<<tr<<"\n";
	cout<<tr-tl<<"\n";
	return 0;
}

Measured memory_bytes: 900