func_code_string: #include <bits/stdc++.h>   const int Maxn = 500010;   using namespace std;   multiset<long long> S;   int n, m;   long long t[Maxn];   void add(int pos, int x) {     for (; pos <= m; pos += pos & -pos) {       t[pos] += x;     }   }   long long query(int pos) {     long long ans = 0;     for (; pos; pos ^= pos & -pos) ans += t[pos];     return ans;   }   char c[Maxn];   int num[Maxn], b[Maxn];   int Get_ans() {     if (S.size() == 0) return 0;     multiset<long long>::iterator x = S.begin(), y;     int cnt = 0;     while (x != S.end()) {       int pos = lower_bound(b + 1, b + m + 1, *x) - b;       if (x != S.begin()) {         long long sum = query(pos - 1);         if (sum * 2 < *x) cnt++;       }       long long sum = query(pos);       x = S.upper_bound(sum * 2);       if (x == S.end()) break;     }     return S.size() - cnt - 1;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       cin >> c[i] >> num[i];       b[i] = num[i];     }     sort(b + 1, b + n + 1);     m = unique(b + 1, b + n + 1) - b - 1;     for (int i = 1; i <= n; i++) {       int w = lower_bound(b + 1, b + m + 1, num[i]) - b;       if (c[i] ==  + ) {         S.insert(num[i]);         add(w, num[i]);         printf( %d n , Get_ans());       } else {         multiset<long long>::iterator ite = S.find(num[i]);         S.erase(ite);         add(w, -num[i]);         printf( %d n , Get_ans());       }     }   }   