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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loop2(num) for (lli j = 0 ; j < num ; j ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }
#define looppu(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . push_back (x) ;}
#define loopin(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . insert (x) ;}

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back ()
#define pof pop_front ()

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

signed main ()
{
    fastio
    //while (true){
    ll a , b , c ;
    cin >> a >> b >> c ;

    if  (a == b) {
        if (a == c)
            No ;
        else
            Yes ;
    }
    else if (b == c){
        if (b == a)
            No ;
        else
            Yes ;
    }
    else if (c == a){
        if (c == b)
            No ;
        else
            Yes ;
    }
    else
        No ;
    /*if (a == b && b == c)
        cout << "No" << endl ;
    else if (a != b && b != c)
        cout << "No" << endl ;
    else
        cout << "Yes" << endl ;}*/

    /*ll n ; cin >> n ;
    /*if (n >= 11 && (n != 13 && n != 17 )) Yes ;
    else if (n < 11){
        if (n % 4 == 0 || n % 7 == 0 )
            Yes ;
        else No ;
    }
    else
        No ;
    (n < 11 ? (n % 7 == 0 || n % 4 == 0 ? Yes : No) : (n == 13 || n == 17 ? No : Yes)) ;*/
    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    char S[6];
    fflush(stdin);
    gets(S);
    if(S[2]==S[3]&&S[4]==S[5])
    {
            printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N,X;

LL ans = 0;

vector<LL> numof_max_patty(51,-1);//レベルLバーガーが含む最大のパティ数をnumof_max_patty[L]とおく

LL numof_max_patty_init(LL L){
	if(L==1){
		if(numof_max_patty[1]==-1) numof_max_patty[1] = 3LL;
		return numof_max_patty[1];
	}
	if(numof_max_patty[L]==-1){
		numof_max_patty[L] = 2*numof_max_patty_init(L-1) + 1LL;
		return numof_max_patty[L];
	}
	return numof_max_patty[L];
}

LL get_numof_patty(LL L,LL x){//レベルLバーガーを下からx枚目まで見たときのパティの数を返す
	if(x<=1) return 0LL;
	if(L==1){
		//このとき1<=x<=5
		if(x>=5) return numof_max_patty[1];
		else return x-1LL;
	}else{
		LL numof_layer = (1LL<<(L+2)) - 3LL;//レベルLのハンバーガーの層数
		if(numof_layer/2 + 1 > x){
			return get_numof_patty(L-1,x-1);
		}
		if(numof_layer/2 + 1 == x){
			return numof_max_patty[L-1] + 1LL;
		}
		if(numof_layer/2 + 1 < x){
			LL l_1 = (1LL<<(L+1)) - 3LL;//レベルL-1のハンバーガーの層数
			return numof_max_patty[L-1] + 1LL + get_numof_patty(L-1,x-2-l_1);
		}
	}
	return -INF;
}

void solve(){
	numof_max_patty_init(50);
	ans = get_numof_patty(N,X);
}
 
int main(){
    cin >> N >> X;
 
    solve();

    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 1000005;

bool ok[MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,K;
    cin >> n >> m >> K;
    rep(i,n+1){
        rep(j,m+1){
            ok[n*m-(i*j+(n-i)*(m-j))] = true;
        }
    }
    if(ok[K]){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 1280
#include<cstdio>
#include<iostream>
#define ll long long
using namespace std;
int n,A,B,now,now1,flag;
int main(){
	 scanf("%d%d%d",&n,&A,&B);
	 if(A+B-1>n||(ll)A*(B-1)+A<n){
	 	printf("-1\n");
	 	return 0;
	 }
	 now=1;
	 B--;
	 for(int i=n-A+1;i<=n;i++){
	 	printf("%d ",i);
	 	if(now>n-A)continue;
	 	flag=1;
	 	now1=min(now+B-1,n-A);
	 	for(int j=now1;j>=now;j--)
	 		printf("%d ",j);
	 	now=now1+1;
	 
	 }
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> P(m),Y(m);
    rep(i,m) cin>>P[i]>>Y[i],P[i]--;

    vector<vector<int>> vals(n);
    rep(i,m) vals[P[i]].push_back(Y[i]);

    rep(v,n){
        sort(all(vals[v]));

        vals[v].erase(unique(all(vals[v])),vals[v].end());
    }

    rep(i,m){
        int v=P[i];
        printf("%06d",v+1);

        int id=lower_bound(all(vals[v]),Y[i])-vals[v].begin();
        printf("%06d\n",id+1);
    }
}

Measured memory_bytes: 7808
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp5
{
    class Program
    {

        static void Main(string[] args)
        {
            String S = Console.ReadLine();
            String[] L = S.Split(' ');
            long X = long.Parse(L[0]);
            long Y = long.Parse(L[1]);
            long A = long.Parse(L[2]);
            long B = long.Parse(L[3]);
            long C = long.Parse(L[4]);

            long[] P = new long[A];
            long[] Q = new long[B];
            long[] R = new long[C];

            S = Console.ReadLine();
            L = S.Split(' ');
            for (long i = 0; i < A; i++)
            {
                P[i] = long.Parse(L[i]);
            }
            S = Console.ReadLine();
            L = S.Split(' ');
            for (long i = 0; i < B; i++)
            {
                Q[i] = long.Parse(L[i]);
            }
            S = Console.ReadLine();
            L = S.Split(' ');
            for (long i = 0; i < C; i++)
            {
                R[i] = long.Parse(L[i]);
            }

            Array.Sort(P);
            Array.Sort(Q);
            Array.Sort(R);
            Array.Reverse(P);
            Array.Reverse(Q);
            Array.Reverse(R);

            long[] Eat = new long[X + Y];
            for (long i = 0; i < X; i++)
            {
                Eat[i] = P[i];
            }
            for (long i = X; i < X + Y; i++)
            {
                Eat[i] = Q[i - X];
            }



            Array.Sort(Eat);


            for (long i = 0; i < C; i++)
            {
                if (R[i] > Eat[i])
                {
                    Eat[i] = R[i];
                }
                else
                {
                    break;
                }
            }

            Console.WriteLine(Eat.Sum());




        }
    }
}

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



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define MOD 1000000007
// #define MOD 998244353
// #define MOD LLONG_MAX
const double PI=3.14159265358979323846;

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




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



void printv(vint &v){
  for(auto e:v) cout<<e<<" ";
  cout<<endl;
}


// 繰り返し二乗法
ll power(ll a, ll b){
  if(a==1)return a;
  // if(a==0)re
  ll res=1;
  while(b>0){
    if(b&1) res=res*a%MOD;
    a=a*a%MOD;
    b>>=1;
  }
  return res;
}

const int MAX=2100000;
 
ll fact[MAX], fact_inv[MAX];
 
void init_fact(ll n){
  fact[0]=1;
  // 階乗の計算
  rep(i, n) fact[i+1]=fact[i]*(i+1)%MOD;
  fact_inv[n]=power(fact[n], MOD-2);
  // 逆元の計算
  for(ll i=n-1;i>=0;i--) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
}
 
ll comb(ll n, ll r){
  return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
 
ll perm(ll n, ll r){
  return (fact[n]*fact_inv[n-r])%MOD;
}






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

  ll x; cin>>x;

  ll ans = 0;

  ans += 1000*(x/500);
  x -= (x/500)*500;
  ans += 5*(x/5);
  cout<<ans<<endl;


}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false

signed main(void){
    int N,K,a;
    vector<int> A;
    cin >> N >> K;
    REP(i,N){
        cin >> a;
        A.push_back(a);
    }
    
    const int MEM = 114514;
    int dp[104][MEM];
    REP(i,104){
        REP(j,MEM){
            dp[i][j]=0;
        }
    }
    dp[0][K]=1;
    REP(i,N){
        REP(j,K+1){
            int p = max(j-A[i],0ll);
            dp[i+1][p]+=dp[i][j];
            dp[i+1][j+1]-=dp[i][j];
        }
        REP(j,K){
            dp[i+1][j+1]+=dp[i+1][j];
            dp[i+1][j]%=MOD;
        }
        dp[i+1][K]%=MOD;
    }
    cout << dp[N][0] << endl;
    
    #if debug
    RREP(j,K+1){
        REP(i,N+1){
            cout << dp[i][j] << " ";
        }cout << endl;
    }
    #endif
    return 0;
}



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

int main(){
  char c;
  cin >> c;
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
  {
    cout << "vowel" << endl;
  }
  else
  {
    cout << "consonant" << endl;
  }
}

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

int main(void) {
 int n;
 cin >> n;
  
 vector<int> p(n);
 for(int i = 0; i < n; i++) {
  cin >> p[i];
 }
  
 int cnt = 0;
 for(int i = 1; i < n - 1; i++) {
   if(p[i] > p[i-1] && p[i] > p[i+1]) {
   }
   else if(p[i] < p[i-1] && p[i] < p[i+1]) {
   }
   else {
     cnt++;
   }
 }
  cout << cnt << endl;
  
 return 0; 
}

Measured memory_bytes: 256
#include<cstdio>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<numeric>
#include<complex>
#define inf 0x3f3f3f3f3f3f3f3f
#define fi first
#define se second
#define pb push_back
#define ll long long
#define pii pair<int,int> 
const int N=1e6+10;
const int mod=998244353;
using namespace std;


void solve(){
   int n,m; scanf("%d%d",&n,&m);
   for(int i=1,x;i<=m;++i) scanf("%d",&x),n-=x;
   n=max(n,-1);
   printf("%d\n",n);
}
int main() 
{
    int _=1;  //scanf("%d",&_);
    while(_--) solve();
return 0;
}
/*
*/
 

Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {
  
  int N,M,K;
  cin >> N >> M >> K;
  vector<vector<int>> fr(N,vector<int>(0)), bl(N,vector<int>(0));
 
  for(int i = 0;i < M;i++) {
    int a,b;
    cin >> a >> b;
    a--; b--;
    fr[a].push_back(b);
    fr[b].push_back(a);
  }

  for(int i = 0;i < K;i++) {
    int a,b;
    cin >> a >> b;
    a--; b--;
    bl[a].push_back(b);
    bl[b].push_back(a);
  }

  vector<bool> seen(N,false);
  vector<int> dis(N,0),gr(N,0);
  int g = 0;
  for(int i = 0;i < N;i++) {
    if(seen[i]) continue;
    int n = 1;
    queue<int> Q;
    Q.push(i);
    seen[i] = true;
    vector<int> cand(0);
    cand.push_back(i);
    while(!Q.empty()) {
      int q = Q.front();
      Q.pop();
      for(auto nv:fr[q]) {
        if(seen[nv]) continue;
        seen[nv] = true;
        n++;
        Q.push(nv);
        cand.push_back(nv);
      }
    }
    for(int j = 0;j < cand.size();j++) {
      dis.at(cand.at(j)) = n;
      gr.at(cand.at(j)) = g; 
    }
    g++;
  }
  
  

  for(int i = 0;i < N;i++) {
    int num = dis.at(i);
    int si = fr.at(i).size();
    //cout << si << " " << fr.at(i).size() << endl;
    for(int j = 0;j < bl.at(i).size();j++) {
      if(gr.at(i) == gr.at(bl.at(i).at(j))) num--;
    }
    cout << num-si-1 << " ";
  } 
  cout << endl;

}


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

int main(){
  int64_t N, A, B;
  cin >> N >> A >> B;
  
  int64_t ans;
  ans = N/(A+B);
  int64_t remain;
  remain = N%(A+B);
  if (remain < A) {
    cout << ans*A+remain << endl;
  } else {
    cout << ans*A+A << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  int n, ans = 0;
  cin >> n;
  vector<int> a(n);
  REP(i, n) { cin >> a[i]; }
  int cnt = 1;
  REP(i, n) {
    if (a[i] == cnt)
      cnt++;
    else
      ans++;
  }
  if (ans == n) ans = -1;
  cout << ans << "\n";
  return 0;
}


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

#define int long long
#define debug(x) cout<<#x<<" "<<x<<endl;

const int N=1e6+5;
const double eps=1e-9;
const int INF=1e18;

int ax[N],ay[N];
int a[N];
 
signed main()
{
    int n;scanf("%lld",&n);
    for(int i=1;i<=n;i++){
        cin>>ax[i]>>ay[i];
    } 
    for(int i=1;i<=n;i++) a[i]=i;
    double ans=0;
    do
    {
        for(int i=2;i<=n;i++){
            ans+=sqrt((ax[a[i-1]]-ax[a[i]])*(ax[a[i-1]]-ax[a[i]])+(ay[a[i-1]]-ay[a[i]])*(ay[a[i-1]]-ay[a[i]]));
        }
    }while(next_permutation(a+1,a+1+n));
    for(int i=1;i<=n;i++) ans/=i;
    printf("%.10lf\n",ans);
    return 0;
}

//Created Time  :2019/11/16 20:00:35

Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<math.h>
#include<iomanip>
#include<bits/stdc++.h>
#define swap(type ,a ,b) {type t; t=a; a=b; b=t;}
#define forN(i,n) for(i=0;i<n;i++)
#define forR(i,s,n) for(i=s;i<n;i++)
#define ll long long
#define pb(t,d,n) {t p;int i;forN(i,n){cin>>p;d.push_back(p);}}
#define DOUBLE fixed << setprecision(15)

using namespace std;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;

int main(){
    int n, i, res=0;
    string s;
    cin >> n >> s;
    if (n%2 == 1){
        cout << "No" << endl;
        return 0;
    }
    n /= 2;
    for(i=0;i<n;i++){
        if(s[i] != s[n+i]) res++;
    }
    if(res == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

vector<ll> v[100010];
priority_queue<ll> pq;

int main()
{
    ll n,m,ans=0;
    cin>>n>>m;

    for (ll i = 0; i < n; i++)
    {
        ll aa,bb;
        cin>>aa>>bb;
        aa--;
        v[aa].push_back(bb);
    }
    for (ll i = 0; i < m; i++)
    {
        for (ll j = 0; j < v[i].size(); j++)
        {
            pq.push(v[i][j]);
        }
        if(pq.size()>0)
        {
            ans+=pq.top();
            pq.pop();
        }
    }
    cout<<ans<<endl;

    return 0;
}

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

int main() {
	int a[4];
	for (int i = 0 ; i < 3 ; i++) {
		cin >> a[i];
	}
	sort(a,a+3);
	int ans = a[2]*10 + a[1] + a[0];
	cout << ans;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  int n, a, b, c;
  scanf("%d", &n);
  a = n / 100;
  b = n / 10 - a * 10;
  c = n - a * 100 - b * 10;
   if (a==1) {
    a = 9;
  }
  else if (a==9) {
    a = 1;
  }
 if (b==1) {
   b = 9;
 }
 else if (b==9) {
   b = 1;
 }
 if (c==1) {
  c = 9;
}
else if (c==9) {
  c = 1;
}
n = 100 * a + 10 * b + c;
printf("%d", n);
return 0;
}


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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
#define mp            make_pair
template<class T, class S> inline bool minup(T& m, const S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, const S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-10;

string s;

typedef string::const_iterator State;
class ParseError{};
class Parsing
{
  typedef string::const_iterator State;
public:
  static inline string solve(string s)
  {
    State begin = s.begin();
    return Cipher(begin);
  }

private:
  static void consume(State& begin, char expected)
  {
    if (*begin == expected) {
      begin++;
    } else {
      cerr << "Expected '" << expected << "' but got '" << *begin << "'"
           << endl;
      cerr << "Rest string is '";
      while (*begin) {
        cerr << *begin++;
      }
      cerr << "'" << endl;
      throw ParseError();
    }
  }

  static string Cipher(State& begin)
  {
    string ret = "";
    while(*begin != '$' && *begin != ']') ret += String(begin);
    return ret;
  }

  static string String(State& begin)
  {
    string ret = "";
    if(*begin != '['){
      ret += Letter(begin);
    }
    else{
      begin++;
      ret += Cipher(begin);
      reverse(ALL(ret));
      begin++;
    }
    return ret;
  }

  static char Letter(State& begin)
  {
    int cnt = 0;
    while(*begin == '+' || *begin == '-'){
      if(*begin == '+') cnt += 1;
      if(*begin == '-') cnt -= 1;
      begin++;
    }
    if(*begin == '?'){
      begin++;
      return 'A';
    }
    int ret = *begin - 'A' + cnt;
    while(ret < 0) ret += 26;
    begin++;
    return ret % 26 + 'A';
  }
};

int main()
{
  while(cin >> s, s != ".") cout << Parsing::solve(s + '$') << endl;

  return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pi=pair<ll,ll>;
using vi=vector<ll>;
using vstr=vector<string>;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
void yes(bool c) { if (c)print("Yes"); else print("No"); };

void solve() {
    int N; cin >> N;
    map<string,ll> count;
    vstr strs(N);
    string s;
    rep(i,N) {
        cin >> s;
        sort(ALL(s));
        count[s]++;
    }
    ll ans = 0;
    for(auto x:count){
        ans += x.sc * (x.sc-1) / 2;
    }
    print(ans);
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}


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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;


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

  ll cnt = 0;
  rep1(i, n){
    if(to_string(i).size()%2 == 1) cnt++;
  }

  cout << cnt << endl;


  return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main {
    
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[] A = new int[N];
        HashMap<Integer,Integer> B = new HashMap<>();
        HashMap<Integer,Integer> C = new HashMap<>();
        for (int i = 0; i < A.length; i++) {
            int a = scanner.nextInt();
            B.putIfAbsent(i+1-a, 0);
            B.put(i+1-a, B.get(i+1-a)+1);
            C.putIfAbsent(i+1+a, 0);
            C.put(i+1+a, C.get(i+1+a)+1);
        }
        long res = 0;
        for(Integer bk:B.keySet()){
            if(C.containsKey(bk)){
                res += (long)B.get(bk) * (long)C.get(bk);
            }
        }
        System.out.println(res);
    }
}

Measured memory_bytes: 80228
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    long long ans=0;
    cin>>s;
    for(int i=0;i<=s.length();i++)
    {
        if(s[i]=='o') ans++;
    }
    if(ans+15-s.length()>=8) cout<<"YES";
    else cout<<"NO";
    return 0;
}

Measured memory_bytes: 256
s=input()
l=len(s)
sa=""
sb=""
for i in range(l):
    if i%2==0:
        sa+="0"
        sb+="1"
    else:
        sa+="1"
        sb+="0"
ca=0
cb=0
for i in range(l):
    if sa[i]!=s[i]:
        ca+=1
    if sb[i]!=s[i]:
        cb+=1
#print(ca)
#print(cb)
print(min(ca,cb))


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

const double PI = acos(-1);
pair<double, double> calcCenter(double x1, double x2, double x3, double y1, double y2, double y3)
{
    double cx, cy;
    //幾何学的に求める
    //thanks for https://blog.mori-soft.com/entry/%3Fp%3D170
    double ex, ey; //(x1, y1)と(x2, y2)の中点
    double fx, fy; //(x2, y2)と(x3, y3)の中点
    ex = (x1 + x2) / 2;
    ey = (y1 + y2) / 2;
    fx = (x2 + x3) / 2;
    fy = (y2 + y3) / 2;
    double tanCE = tan(atan((y2 - y1) / (x2 - x1)) + PI / 2);
    double tanCF = tan(atan((y3 - y2) / (x3 - x2)) + PI / 2);
    cx = (ey - fy - ex * tanCE + fx * tanCF) / (tanCF - tanCE);
    cy = ey - (ex - cx) * tanCE;
    return make_pair(cx, cy);
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<double> xPoints(N);
    vector<double> yPoints(N);
    for (int i = 0; i < N; i++)
    {
        double X, Y;
        cin >> X >> Y;
        xPoints.at(i) = X;
        yPoints.at(i) = Y;
    }
    double answer = 100000;
    //二点を直径にしたケースで満たすもの最小
    for (int i = 0; i < N - 1; i++)
    {
        for (int j = i + 1; j < N; j++)
        {
            double cx, cy;
            cx = (xPoints.at(i) + xPoints.at(j)) / 2;
            cy = (yPoints.at(i) + yPoints.at(j)) / 2;
            double r2 = sqrt(pow(abs(cx - xPoints.at(j)), 2) + pow(abs(cy - yPoints.at(j)), 2));
            bool isEncloseAll = true;
            for (int k = 0; k < N; k++)
            {
                double checkR2 = sqrt(pow(abs(cx - xPoints.at(k)), 2) + pow(abs(cy - yPoints.at(k)), 2));
                if (r2 < checkR2)
                {
                    isEncloseAll = false;
                    break;
                }
            }
            if (isEncloseAll)
            {
                answer = min(answer, r2);
            }
        }
    }
    //三点を外周に含むケースで満たすもの最小
    for (int i = 0; i < N - 2; i++)
    {
        for (int j = i + 1; j < N - 1; j++)
        {
            for (int k = j + 1; k < N; k++)
            {
                double cx, cy;
                tie(cx, cy) = calcCenter(xPoints.at(i), xPoints.at(j), xPoints.at(k), yPoints.at(i), yPoints.at(j), yPoints.at(k));

                double r2 = sqrt(pow(abs(cx - xPoints.at(i)), 2) + pow(abs(cy - yPoints.at(i)), 2));
                r2 = max(r2, sqrt(pow(abs(cx - xPoints.at(j)), 2) + pow(abs(cy - yPoints.at(j)), 2)));
                r2 = max(r2, sqrt(pow(abs(cx - xPoints.at(k)), 2) + pow(abs(cy - yPoints.at(k)), 2)));
                bool isEncloseAll = true;
                for (int m = 0; m < N; m++)
                {
                    double checkR2 = sqrt(pow(abs(cx - xPoints.at(m)), 2) + pow(abs(cy - yPoints.at(m)), 2));
                    if (r2 < checkR2)
                    {
                        isEncloseAll = false;
                        break;
                    }
                }
                if (isEncloseAll)
                {
                    answer = min(answer, r2);
                }
            }
        }
    }

    cout << fixed << setprecision(11) << answer << endl;
    return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;



int main(void){
	ll A,B,C,D;
	char test[4];
	scanf("%s",test);
	A=test[0]-'0';
	B=test[1]-'0';
	C=test[2]-'0';
	D=test[3]-'0';
	if(A+B+C+D==7){
		printf("%lld+%lld+%lld+%lld=7\n",A,B,C,D);
	}else if(A+B+C-D==7){
		printf("%lld+%lld+%lld-%lld=7\n",A,B,C,D);
	}else if(A+B-C+D==7){
		printf("%lld+%lld-%lld+%lld=7\n",A,B,C,D);
	}else if(A+B-C-D==7){
		printf("%lld+%lld-%lld-%lld=7\n",A,B,C,D);
	}else if(A-B+C+D==7){
		printf("%lld-%lld+%lld+%lld=7\n",A,B,C,D);
	}else if(A-B+C-D==7){
		printf("%lld-%lld+%lld-%lld=7\n",A,B,C,D);
	}else if(A-B-C+D==7){
		printf("%lld-%lld-%lld+%lld=7\n",A,B,C,D);
	}else if(A-B-C-D==7){
		printf("%lld-%lld-%lld-%lld=7\n",A,B,C,D);
	}
	return 0;
}

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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define all(x) x.begin(), x.end()
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m) {
  int ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}

int gcd(int a, int b) {
  if (a == 0)
    return b;
  else
    return gcd(b % a, a);
}

vector<int> g[212345];
int c[212345];
vector<int> seq(212345);
int ans[212345];
int n;

void go(int u, int p) {
  // calc lis
  int index =
      lower_bound(seq.begin(), seq.begin() + n + 50, c[u]) - seq.begin();
  index--;
  int before = seq[index + 1];
  seq[index + 1] = min(seq[index + 1], c[u]);
  // get ans bruh
  int l = 0, r = n + 50;
  int xx = -1;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (seq[mid] == INF) {
      r = mid - 1;
    } else {
      xx = mid;
      l = mid + 1;
    }
  }
  ans[u] = xx;
  for (int v : g[u]) {
    if (v == p) continue;
    go(v, u);
  }
  // remove
  seq[index + 1] = before;
}

void solution() {
  cin >> n;
  for (int i = 1; i <= n + 100; i++) seq[i] = INF;
  for (int i = 1; i <= n; i++) {
    cin >> c[i];
  }
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    g[a].pb(b);
    g[b].pb(a);
  }
  seq[0] = -INF;
  go(1, -1);
  for (int i = 1; i <= n; i++) cout << ans[i] << endl;
}

int32_t main() {
  DESYNC;
  solution();
}


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

int main() {
  int n, q;
  cin >> n >> q;
  vector<priority_queue<int>> vpq(n);
  for (int i = 0; i < q; i++) {
    int a;
    cin >> a;
    if (a == 0) {
      int t, x;
      cin >> t >> x;
      vpq.at(t).push(x);
    }
    if (a == 1) {
      int t;
      cin >> t;
      if (!vpq.at(t).empty())
      cout << vpq.at(t).top() << endl;
    }
    if (a == 2) {
      int t;
      cin >> t;
      if (!vpq.at(t).empty())
      vpq.at(t).pop();
    }
  }
}


Measured memory_bytes: 4116
#include <bits/stdc++.h>
using namespace std;
string s,st;
int main()
{
    getline(cin,s);
    int k='a'-'A';
//    cout<<k<<endl;
    st.clear();
    for(int i=0;i<s.size();i++)
        if ('a'<=s[i] && s[i]<='z')
            st=st+char(s[i]-k);
        else
            if ('A'<=s[i] && s[i]<='Z')st=st+char(s[i]+k);
            else st=st+s[i];
    for(int i=0;i<st.size();i++)
        printf("%c",st[i]);
    printf("\n");
}



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

int main(){
  int n,cnt=1;
  string s;
  cin >> n >> s;

  for(int i=1;i<s.size();i++) {
    if(s.at(i-1)!=s.at(i)) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

struct SegmentTree{
  vector <int> Tree[20];
  void Make(){
    for (int i = 0; i < 20; i++){
      Tree[i].resize(1<<i);
    }
  }

  void Add(int num, ll val){
    for (int i = 19; i >= 0; i--){
      Tree[i][num] += val;
      num /= 2;
    }
  }

  ll Count(int num){
    int now = 19; 
    ll ans = Tree[now][num];
    while (now > 0 && num > 0){
      if (num % 2 != 0){
        num--;
      }else{
        now--; num /= 2; num--;
      }
      ans += Tree[now][num];
    }
    return ans;
  }

};

int N; ll K;
ll A[int(2e5+5)], sum[int(2e5+5)];
map <ll, int> Index;

void Make_Index(){
  map <ll, bool> used;
  vector <ll> now;
  for (int i = 0; i <= N; i++){
    if (used[sum[i]]) continue;
    used[sum[i]] = true;
    now.push_back(sum[i]);
  }
  sort(now.begin(), now.end());
  for (int i = 0; i < now.size(); i++){
    Index[now[i]] = i;
  }
}

int main(){
  cin >> N >> K;
  for (int i = 1; i <= N; i++){
    cin >> A[i];
    sum[i] = sum[i-1] + A[i];
  }
  for (ll i = 0; i <= N; i++){
    sum[i] -= i * K;
  }
  Make_Index();
  for (int i = 0; i <= N; i++){
    sum[i] = Index[sum[i]];
  }

  SegmentTree Tree; Tree.Make();
  ll ans = 0;
  for (int i = 0; i <= N; i++){
    ans += Tree.Count(sum[i]);
    Tree.Add(sum[i], 1);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 32912
#include<bits/stdc++.h>
#define M 1000000007
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;

using namespace std;
ll fac[200005],inf[200005];
ll power(ll x,ll y){
    ll t=1;
    while(y){
        if(y&1) t=(t*x)%M;
        y>>=1;
        x=(x*x)%M;
    }
    return t;
}
ll per(ll n,ll r){
    return (fac[n]*((inf[r]*inf[n-r])%M)%M);
}
void pre(){
    fac[0]=fac[1]=1;
    ll i=2;
    while(i<200003){
        fac[i]=(fac[i-1]*i)%M;
        i++;
    }
}
void pre2(){
    inf[0]=inf[1]=1;
    ll i=2;
    while(i<200003){
        inf[i]=power(fac[i],M-2);
        i++;
    }
}
int main(){
    cs;
    pre();
    pre2();
    ll n,k,ans=0;
    cin>>n>>k;
    if(k>n-1) k=n-1;
    for(ll i=0;i<=k;i++) ans=(ans+per(n,i)*per(n-1,i))%M; 
    while(ans<0) ans+=M;
    cout<<ans;
}

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)


void aryan_p() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	return;
}


bool cmp(pii a , pii b) {
	return a.second < b.second;
}

int32_t main() {
	aryan_p();

	int n ;
	cin >> n ;
	pii a[n];


	for (int i = 0 ; i < n ; i++) {
		a[i].first = i + 1;
		cin >> a[i].second;
	}
	sort(a, a + n, cmp);
	for (auto p : a) {
		cout << p.first << " ";
	}





	return 0;
}


Measured memory_bytes: 5208
#include<iostream>
using namespace std;
int main(){
  long long n,d;
  long long cnt=0;
  cin>>n>>d;
  for(int i=0;i<n;i++){
    long long x,y;
    cin>>x>>y;
    if(x*x+y*y<=d*d){
      cnt++;
    }
  }
  cout<<cnt<<endl;
  return(0);
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define FasterIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef unsigned long long ull;
typedef long long ll;
typedef double db;

#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define ff first
#define ss second
#define mk make_pair
#define pi pair<int,int>
#define vi vector<int>
#define pL pair<ll,ll>
#define vL vector<ll>
#define vp vector<pi>
#define vpL vector<pL>

const int MX=2000;
const ll inf=1e9;
const ll mod=1e9+7;

string g[MX];

int n, m, a, b;

void make()
{
    for(int j=0; j<m-1 && a; j+=2)
    {
        for(int i=0; i<n && a; i++)
        {
            if(g[i][j]=='.' && g[i][j+1]=='.')
            {
                g[i][j]='<', g[i][j+1]='>', a--;
            }
        }
    }

    for(int j=0; j<m && b; j++)
    {
        for(int i=0; i<n-1 && b; i++)
        {
            if(g[i][j]=='.' && g[i+1][j]=='.')
            {
                g[i][j]='^', g[i+1][j]='v', b--, i++;
            }
        }
    }

}

int main()
{

    FasterIO;


    cin>>n>>m>>a>>b;

    for(int i=0; i<n; i++) g[i].resize(m, '.');

    if(n&1 && m&1)
    {
        for(int i=0; i<m-1 && a; i+=2) g[0][i]='<', g[0][i+1]='>', a--;

        if(a&1 && m-2>=0)
        {
            g[n-1][m-2]='<', g[n-1][m-1]='>', a--;
        }

        make();
    }
    else
    {
        if(n&1)
        {
            for(int i=0; i<m-1 && a; i+=2) g[0][i]='<', g[0][i+1]='>', a--;
        }
        make();
    }

    if(a || b)
    {
        cout<<"NO"<<endl; return 0;
    }

    cout<<"YES"<<endl;
    for(int i=0; i<n; i++) cout<<g[i]<<endl;

    return 0;
}


Measured memory_bytes: 2304
#ifdef __GNUC__ 
#include <bits/stdc++.h>
#endif
#include <immintrin.h>
using namespace std;

int main() {
#ifdef __GNUC__ 
	auto & in = cin;
#else
	istringstream in("3\n#.#");
#endif
	uint64_t n;
	string s;
	in >> n;
	in >> s;
	vector<pair<uint64_t,char > > count;
	vector<pair<uint64_t,uint64_t> > sumv;
	uint64_t i = 0;
	char prevc= s[0];
	for (auto c : s) {
		if (c == prevc) {
			++i;
		}
		else {
			count.emplace_back (i,prevc);
			i = 1; prevc = c;
		}
	}
	if(i!=0)count.emplace_back(i, prevc);
	vector < uint64_t> wsumv;
	wsumv.reserve(count.size());
	uint64_t bsum = 0, wsum = 0; vector< uint64_t >result;
	result.reserve(count.size() + 2);
	for (auto & p : count) {
		if (p.second == '#') {
		}
		else {
			wsum += p.first;
		}
		wsumv.push_back(wsum);
	}
	uint64_t index = 0;
	for (auto & p : count) {
		if (p.second == '#') {
			result.emplace_back(bsum+ wsumv.back() -wsumv[index]);
			bsum += p.first;
		}
		else {

			//for (auto &r : result) {
			//	r += p.first;
			//}
		}
		++index;
	}
	result.push_back(bsum);
	if (result.size() == 0) {
		cout << 0 << endl;
	}
	else {
		cout << *std::min_element(result.begin(), result.end()) << endl;
	}
}


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

using namespace std;
#define ll long long int
ll n,cap,dp[105][100005],weight[105],val[105];

ll func(ll indx, ll w)
{
    if(indx==n+1) return 0;
    if(dp[indx][w]!=-1) return dp[indx][w];
    ll p1=0,p2=0;
    if(w+weight[indx]<=cap) p1=val[indx]+func(indx+1,w+weight[indx]);
    p2=func(indx+1,w);
    return dp[indx][w]=max(p1,p2);
}


int main()
{
    ll i,j;
    cin>>n>>cap;
    for(i=1; i<=n; i++) cin>>weight[i]>>val[i];
    memset(dp, -1, sizeof dp);
    ll ans=func(0,0);
    cout<<ans<<endl;
    return 0;




}


Measured memory_bytes: 82304
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
from itertools import accumulate #list(accumulate(A))

Q = ii()
lr = li2(Q)
from collections import deque
que = deque()

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

prime = [0]*(10**5+1)
flag = [0]*(10**5+1)
prime[2] = 1

for i in range(3, 10**5+1, 2):
    if is_prime(i):
        prime[i] = 1

for i in range(3, 10**5+1, 2):
    if prime[i] and prime[(i+1)//2]:
        flag[i] = 1

ans = list(accumulate(flag))

for i in range(Q):
    print(ans[lr[i][1]]-ans[lr[i][0]-1])

Measured memory_bytes: 65884
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();

		long ans = 0L;
		long[] array = new long[n+1];
		for(long j=1L;j<=n;j++) {
			for(long i=1;i*j<=n;i++) {
				array[(int) (i*j)] = array[(int) (i*j)] + 1L;
			}
		}
		for(long j=1L;j<=n;j++) {
			ans = ans + j*array[(int) j];
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 115732
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
  {
      cin>>a[i];
  }
  sort(a,a+n);
  ll ans=1;
  int f=0;
  for(int i=n-1;i>=0;i--)
  {
      int it=lower_bound(a,a+n,a[i])-a;
      if((n-it)>1)
      {
         // cout<<n-it<<"\n";
          int N=(n-it)/2;
          if(N>=2)
          {
              if(ans==1){
              ans=ans*(ll)a[i]*a[i];
              f=2;
              break;
              }else
              {
                  f++;
                  ans=ans*(ll)a[i];
              }
          }else if(N==1)
          {
              f++;
              ans=ans*(ll)a[i];
          }
      }
      i=it;
      n=it;
      if(f==2)
        break;
  }
  if(f==2)
    cout<<ans;
  else
    cout<<"0";
  return 0;
}


Measured memory_bytes: 640
// Pratiyush Mishra(pratiush7)
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define repab(i,a,b) for(ll i=a;i<=b;i++)
#define ull unsigned long long int
#define ll long long int
#define LL_MAX 9223372036854775807
#define pb push_back
#define pf push_front
#define mp make_pair
#define popb pop_back
#define vl vector<ll>
#define bs(v,x) binary_search(v.begin(),v.end(),x)
#define popf pop_front
#define p() cout<<'\n'
#define p0(x) cout<<x<<" "
#define p1(x) cout<<x<<'\n'
#define p2(x,y) cout<<x<<" "<<y<<'\n'
#define p3(x,y,z) cout<<x<<" "<<y<<" "<<z<<'\n'
#define pr1(x) cout<<fixed<<setprecision(15)<<x<<'\n'
#define mod 1000000007
#define mod1 998244353
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define get(n) ll n;cin>>n
#define getvec(v,n) vector<ll> v(n);for(ll i=0;i<n;i++) cin>>v[i];
#define getstr(s) string s;cin>>s
#define all(x) x.begin(),x.end()
#define countBits(x) __builtin_popcount (x)
using namespace std;

int main(){
  fio;
  get(n);
  getstr(s);
  ll cnt=0;
  rep(i,n-2){
    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
      cnt++;
  }
  p1(cnt);
  return 0;
}


Measured memory_bytes: 256
module IO = struct

  (* @since 4.04.0 *)
  let split_on_char sep s =
    let open String in
    let r = ref [] in
    let j = ref (length s) in
    for i = length s - 1 downto 0 do
      if get s i = sep then begin
        r := sub s (i + 1) (!j - i - 1) :: !r;
        j := i
      end
    done;
    sub s 0 !j :: !r

  let read_ns () = read_line () |> split_on_char ' ' |> List.map int_of_string

end

let () =
  let rec p (x, y) = function
    | [] -> true
    | z :: _ when x > z && y > z -> false
    | z :: tl ->
      if x < z && y > z then p (z, y) tl
      else if x > z && y < z then p (x, z) tl
      else if x < z && y < z then p (x, z) tl || p (z, y) tl
      else false in
  let n = read_int () in
  for _ = 0 to n - 1 do
    let l = IO.read_ns () in
    print_endline (if p (0, 0) l then "YES" else "NO")
  done

Measured memory_bytes: 2116
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

int pow(int x, int n){
  if(n == 0)return 1;
  if(n % 2 == 0)return pow(x * x % MOD, n/2);
  else return x * pow(x, n-1) % MOD;
}

vector< int > divisor(int n) {
  vector< int > ret;
  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret),greater<int>());
  return (ret);
}
int n,q;
vector<int> g[210000];
vector<int> ans(210000,0);

void dfs(int v, int pre){
  //cout << v << " " << pre << endl;
  rep(i,g[v].size()){
    if(g[v][i] == pre)continue;
    ans[g[v][i]] += ans[v];
    dfs(g[v][i], v);
  }
}

signed main(){
  cin>>n>>q;
  rep(i,n-1){
    int a,b;cin>>a>>b;
    a--;b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  rep(i,q){
    int p,x;cin>>p>>x;
    p--;ans[p] += x;
  }
  dfs(0,-1);
  rep(i,n){
    cout << ans[i] << (i == n-1 ? "\n" : " ");
  }
}


Measured memory_bytes: 27648
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.immutable.Queue

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  @tailrec
  private def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}


object Main {
  def solve(sc: => Scanner): Unit = {
    val n = (sc.next + sc.next).toInt
    if ((math.sqrt(n).toInt) * (math.sqrt(n).toInt) == n) {
      println("Yes")
    } else {
      println("No")
    }
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}



Measured memory_bytes: 27316
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cmath>
#include <map>
using namespace std;

int main() {
  cout << fixed << setprecision(18);
  double A, B, H, M, pi, C, ans;
  cin >> A >> B >> H >> M;
  pi=3.14159265358979323846;
  C=A*A+B*B-2*A*B*cos(((60*H-11*M)*pi)/360);
  ans=sqrt(C);
  cout << ans << endl;
}

Measured memory_bytes: 4124
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<math.h>
#include<map>
using namespace std;


int main(){
    long long x,y;
    scanf("%lld%lld",&x,&y);
    int ans=0;
    while(x<=y){
        ans+=1;
        x<<=1;
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 128