text
stringlengths
49
983k
#include <bits/stdc++.h> using namespace std; int main() { int pp = 0; char s[255]; int ret = 0; while (cin.getline(s, 200)) { if (s[0] == '+') { pp++; continue; } if (s[0] == '-') { pp--; continue; } int ls = strlen(s); for (int i = 0; i < ls; ++i) { if (s[i] == ':') { ret += (ls - i - 1) * pp; break; } } } printf("%d\n", ret); }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); string s; int cur = 0, ans = 0; while (getline(cin, s)) { if (s[0] == '+') cur++; else if (s[0] == '-') cur--; else { for (int i = 0; i < s.size(); ++i) { if (s[i] == ':') { ans += cur * (s.size() - i - 1); break; } } } } cout << ans << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; string str; vector<string> l; char a[110]; int m; int tedad; int main() { while (getline(cin, str)) { if (str[0] == '+') { tedad++; } else if (str[0] == '-') { tedad--; } else { string p = ""; int shomar = 0; while (str[shomar] != ':') { shomar++; } shomar++; for (int i = shomar; i < str.size(); i++) { p = p + (str[i]); } m += (p.size()) * tedad; } } cout << m; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string ch; long long int c = 0, a = 0, b = 0, d, l, t; while (getline(cin, ch)) { a = 0; if (ch[0] == '+') c++; else if (ch[0] == '-') c--; else { l = ch.length(); for (long long int i = 0; i < l; i++) { if (ch[i] == ':') { a++; break; } a++; } b += (l - a) * c; } } cout << b << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int maxn = 5005; const int maxm = 10005; int n, m; set<string> se; char s[10000]; int main() { string str; int ans = 0; while (gets(s)) { str = s; if (str[0] == '+') se.insert(str.substr(1)); else if (str[0] == '-') se.erase(str.substr(1)); else { int len = str.length(); for (int i = 0; i < len; i++) { if (str[i] == ':') { ans += se.size() * (len - i - 1); break; } } } } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int people = 0; int sum = 0; string s; while (getline(cin, s)) { if (s[0] == '-') { people--; } else if (s[0] == '+') { people++; } else { int i = 0; while (s[i] != ':') { i++; } sum += people * (s.size() - i - 1); } } cout << sum << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int maxn = int(2e5); const int maxnn = int(2e3); char s[maxnn]; int res = 0, human = 0; char newstring[maxnn]; int main() { while (gets(s)) { int len = strlen(s); if (s[0] == '+') human++; else if (s[0] == '-') human--; else { int i = 0; while (s[i] != ':') i++; i++; res += human * (len - i); } } cout << res; return 0; }
#include <bits/stdc++.h> using namespace std; int dl(string s) { for (int i = 0; i < s.size(); i++) if (s[i] == ':') return (s.size() - i - 1); } int main() { int k = 0, ans = 0; string s; while (getline(cin, s)) { if (s[0] == '+') k++; else if (s[0] == '-') k--; else ans += k * dl(s); } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int ans = 0, usr = 0; string tmp; while (getline(cin, tmp)) if (tmp[0] == '+') usr++; else if (tmp[0] == '-') usr--; else ans += usr * (tmp.size() - tmp.find(':') - 1); cout << ans << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int add, ans; string cmd; int main() { while (getline(cin, cmd)) { if (cmd[0] == '+') add++; else if (cmd[0] == '-') add--; else ans += add * (cmd.size() - cmd.find(":") - 1); } cout << ans; }
#include <bits/stdc++.h> using namespace std; int main() { int b = 0, sum = 0, d; string a; while (getline(cin, a)) { if (a[0] == '+') b++; else if (a[0] == '-') b--; else { for (int j = 0; j < a.size(); j++) if (a[j] == ':') { d = j + 1; break; } sum += (a.size() - d) * b; } } cout << sum; return 0; }
#include <bits/stdc++.h> using namespace std; set<string> s; string ss; int main() { int sum = 0; while (getline(cin, ss)) { if (ss[0] == '+') { s.insert(ss.substr(1, ss.size())); } else if (ss[0] == '-') { s.erase(ss.substr(1, ss.size())); } else { int i; string ::iterator it; for (it = ss.begin(), i = 0; it != ss.end(); ++it, ++i) { if (*it == ':') { i++; break; } } sum += s.size() * (ss.size() - (ss.substr(0, i)).size()); } } printf("%d\n", sum); return 0; }
#include <bits/stdc++.h> using namespace std; int32_t main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); string s; set<string> st; int cnt = 0; while (getline(cin, s)) if (s[0] == '+') st.insert(s.substr(1)); else if (s[0] == '-') st.erase(s.substr(1)); else cnt += st.size() * (int)s.substr(s.find(":") + 1).size(); cout << cnt; return 0; }
#include <bits/stdc++.h> using namespace std; int n, k, x; string s; int main() { while (getline(cin, s)) { switch (s[0]) { case '+': { n++; break; } case '-': { n--; break; } default: x = s.find(':'); k = k + n * (s.size() - x - 1); } } cout << k; }
#include <bits/stdc++.h> using namespace std; int main() { char s[100]; int len, c = 0, l = 0, i; while (1) { gets(s); if (s[0] == '+') c++; else if (s[0] == '-') c--; else { len = strlen(s); if (len == 0) break; for (i = 0; i < len; i++) { if (s[i] == ':') break; } l = l + (len - i - 1) * c; } s[0] = '\0'; } cout << l; return 0; }
#include <bits/stdc++.h> using namespace std; map<string, int> mp; int main() { string s; int k = 0; while (getline(cin, s)) { if (s[0] == '+') mp[s.substr(1)]++; else if (s[0] == '-') mp.erase(s.substr(1)); else { int j = s.size() - s.find(":") - 1; k += j * mp.size(); } } cout << k; }
#include <bits/stdc++.h> using namespace std; int add, ans; int main() { string s; while (getline(cin, s)) { if (s[0] == '+') { add++; } else if (s[0] == '-') { add--; } else ans += add * (s.size() - s.find(":") - 1); } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; string str; int main() { int add = 0, remove = 0, ans = 0; while (getline(cin, str)) { string::size_type len = str.size(); if (str[0] == '+') add++; else if (str[0] == '-') remove++; else { int flag = 0; for (string::size_type i = 0; i != len; i++) if (str[i] == ':') { flag = i; break; } int lena = len - flag - 1; ans = ans + lena * (add - remove); } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string s; int ans = 0, a = 0; while (getline(cin, s)) { if (s[0] == '+') a++; else { if (s[0] == '-') a--; else ans += a * (s.size() - s.find(':') - 1); } } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; int p = 0, ans = 0; while (getline(cin, s)) { if (s[0] == '+') p++; else if (s[0] == '-') p--; else { int l = s.length(); for (int i = 0; i < l; i++) { if (s[i] == ':') { ans += (l - i - 1) * p; break; } } } } cout << ans; return 0; }
#include <bits/stdc++.h> int main() { char a[200]; int t3 = 0, t1 = 0; while (gets(a)) { int z, t2; if (a[0] == '+') t1++; else if (a[0] == '-') t1--; else { int n = strlen(a); for (z = 0; z < n; z++) { if (a[z] == ':') { t2 = n - z - 1; break; } } t2 = t2 * t1; t3 = t3 + t2; } } printf("%d\n", t3); return 0; }
#include <bits/stdc++.h> using namespace std; map<string, int> names; char buf[110]; int main() { int sum = 0; while (gets(buf)) { if (buf[0] == '+') { string s = string(&(buf[1])); names[s]++; continue; } if (buf[0] == '-') { string s = string(&(buf[1])); names[s] = 0; continue; } int i = 0; while (buf[i] != ':') i++; i = strlen(buf) - i - 1; map<string, int>::iterator it; for (it = names.begin(); it != names.end(); ++it) { if (it->second > 0) { sum += i; } } } cout << sum << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string line; int persons = 0; int data = 0; while (getline(cin, line)) { if (line[0] == '+') ++persons; else if (line[0] == '-') --persons; else data += (line.size() - line.find(':') - 1) * persons; } cout << data << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int users = 0; int output = 0; string name; while (getline(cin, name)) { if (name[0] == '+') users++; if (name[0] == '-') users--; else { int n = name.length() - 1; for (int i = 0; i <= n; i++) { if (name[i] == ':') { output += users * (n - i); break; } } } } cout << output; }
#include <bits/stdc++.h> using namespace std; int main() { char c[5000]; long int r = 0; int cnt = 0; long int ans = 0; while (gets(c)) { string s(c); if (s.size() == 0) break; if (s[0] == '+') { ans += 1; } else if (s[0] == '-') ans -= 1; else { cnt = 0; int l = s.size(), n = 0; if (s[l - 1] == ':') { n = 0; } else { for (int j = 0; j < l; j++) { if (s[j] == ':') { break; } cnt += 1; } n = l - cnt + 1 - 2; } r += n * ans; } } cout << r << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { char com[200]; char *p; int man = 0; int sum = 0; int i; int word; while (scanf("%c", com) == 1) { i = 1; while ((com[i] = getchar()) != '\n') i++; com[i] = '\0'; word = 0; if (com[0] == '+') { man++; continue; } if (com[0] == '-') { man--; continue; } p = strchr(com, ':'); p += 1; while (*(p++) != '\0') { word++; } sum += word * man; } printf("%d", sum); }
#include <bits/stdc++.h> using namespace std; vector<int> v; vector<int> u; priority_queue<int> pq; std::map<int, int> m; const int N = 1e6 + 10; int main() { std::string line; int users(0), total(0); while (getline(std::cin, line)) { if (line[0] == '+') { ++users; } else if (line[0] == '-') { --users; } else { total += users * (line.size() - line.find(':') - 1); } } std::cout << total << std::endl; return 0; }
#include <bits/stdc++.h> using namespace std; int c, d, i, n, m, k, x, y, j; string s; int main() { string s; while (getline(cin, s)) { if (s[0] == '+') n++; else if (s[0] == '-') n--; else { c = s.find(':'); k += n * (s.size() - c - 1); } } cout << k; }
#include <bits/stdc++.h> using namespace std; int main() { int n = 0, l = 0; while (cin.peek() != EOF) { string s; s = ""; getline(cin, s); if (s[0] == '+') { n++; continue; } if (s[0] == '-') { n--; continue; } else { int j = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == ':') { j = i + 1; break; } } l += (s.size() - j) * n; } } cout << l; }
#include <bits/stdc++.h> using namespace std; int main() { int y, z = 0, sum = 0; string s; while (getline(cin, s)) { y = s.find(":"); if (y >= 0) { s.erase(0, y + 1); sum = sum + (s.size() * z); } else if (s[0] == '+') { z++; } else if (s[0] == '-') { z--; } } cout << sum; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int l, max, min, r, k, i, flag = 0, ans = 0, temp = 0, pos = 0, neg = 0, cnt = 0, d = 0, size; char s[109]; for (int j = 0; j < 100; j++) { cin.getline(s, 105); if (strlen(s) == 0) { break; } if (s[0] == '+') temp++; if (s[0] == '-') temp--; if (s[0] != '+' && s[0] != '-') { i = 0; cnt = 0; while (s[i] != ':') { cnt++; i++; } k = (strlen(s) - cnt - 1); ans = ans + temp * k; } } cout << ans; return 0; }
#include <bits/stdc++.h> char st[111]; int main() { int n = 0; int status = 0; while (gets(st)) { if (st[0] == '+') n++; else if (st[0] == '-') n--; else { int len = strlen(st); for (int i = 0; i < len; i++) { if (st[i] == ':') { status += (len - i - 1) * n; break; } } } memset(st, 0, sizeof(st)); } printf("%d\n", status); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { char cmd[101]; char msg[99] = {}; int res = 0; int online = 0; while (gets(cmd)) { if (cmd[0] == '+') ++online; else if (cmd[0] == '-') --online; else { char *p = cmd; size_t size = 0; while (*p != ':') p++; while (*(++p)) size++; res += size * online; } } cout << res << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { set<string> ppl; char str[10000]; int i, j, len, ans = 0; while (scanf("%[^\n]", str) != EOF) { getchar(); if (str[0] == '+') ppl.insert((string)(str + 1)); else if (str[0] == '-') ppl.erase((string)(str + 1)); else { len = strlen(str); for (i = 0; i < len && ((str[i] >= 'a' && str[i] <= 'z') || (str[i] >= 'A' && str[i] <= 'z') || (str[i] >= '0' && str[i] <= '9')); i++) ; for (j = i + 1; j < len && ((str[j] >= 'a' && str[j] <= 'z') || (str[j] >= 'A' && str[j] <= 'z') || (str[j] >= '0' && str[j] <= '9') || str[j] == ' '); j++) ; ans += (j - i - 1) * ppl.size(); } } printf("%d\n", ans); }
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const double eps = 1e-8; const int mod = 1e9 + 7; const int P = 1e9 + 7; const int N = 2e7; const int MAXN = 1e6 + 5; char s[105]; long long t, sum, ans, len1, pos; int main() { sum = ans = 0; while (gets(s)) { if (s[0] == '+') ans++; else if (s[0] == '-') ans--; else { len1 = strlen(s); for (long long i = 0; i < len1; ++i) { if (s[i] == ':') { pos = i; break; } } sum += (len1 - pos - 1) * ans; } } printf("%lld\n", sum); }
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #pragma GCC optimization("unroll-loops") vector<long long int> v; vector<long long int> w, ab, bc; set<long long int> uo; map<long long int, long long int> ww, cc, u; vector<pair<long long int, long long int> > uu, su; map<long long int, vector<long long int> > uuu; map<pair<long long int, long long int>, long long int> vo; map<pair<long long int, long long int>, long long int> vu; map<long long int, pair<long long int, pair<long long int, long long int> > > vs; priority_queue<long long int, vector<long long int>, greater<long long int> > moy; long long int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1}; long long int dy[] = {0, 1, 0, -1, -1, 1, 1, -1}; long long int dxx[] = {2, 1, -1, -2, -2, -1, 1, 2}; long long int dyy[] = {1, 2, 2, 1, -1, -2, -2, -1}; long long int dp[101][10001]; long long int ar[10][10]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); char ch; string a, b, c; double x, y, d, e, f, g, h; long long int n, i, j, k, p, q, o, l, s, tt = 1, m, t, z, aa, r = 0; for (long long int mau = 1; mau <= tt; mau++) { v.clear(); w.clear(); ww.clear(); uu.clear(); uo.clear(); vo.clear(); vu.clear(); ab.clear(); bc.clear(); cc.clear(); uuu.clear(); a.clear(); b.clear(); c.clear(); u.clear(); k = 0; l = 0; while (getline(cin, a)) { if (a[0] == '+') l++; else if (a[0] == '-') l--; else { o = a.size(); for (i = 0; a[i]; i++) { if (a[i] != ':') o--; else { o--; break; } } k += l * o; } } cout << k << "\n"; } return 0; }
#include <bits/stdc++.h> using namespace std; char s[110]; int num = 0; int main() { num = 0; set<string> t; int ans = 0; while (gets(s)) { if (s[0] == '+') { string tmp = ""; int len = strlen(s); for (int i = 1; i < len; i++) tmp += s[i]; t.insert(tmp); num++; } else if (s[0] == '-') { string tmp = ""; int len = strlen(s); for (int i = 1; i < len; i++) tmp += s[i]; t.erase(tmp); num--; } else { int i = 0; for (i = 0; i < strlen(s); i++) if (s[i] == ':') break; ans += (strlen(s) - i - 1) * num; } } cout << ans << endl; return (0); }
#include <bits/stdc++.h> using namespace std; int main() { int i = 1; string s; long long ans = 0; long long c = 0; getline(std::cin, s); do { if (s[0] == '+') c++; else if (s[0] == '-') c--; else { int j = s.find(':', 0); ans += (s.length() - j - 1) * c; } } while (getline(std::cin, s)); cout << ans; }
#include <bits/stdc++.h> using namespace std; int main() { string s; int t = 0; long long ans = 0; while (getline(cin, s)) { if (s.size() == 0) break; if (s[0] == '+') t++; else if (s[0] == '-') t--; else { int i = 0; while (s[i] != ':') i++; ans += (s.size() - i - 1) * t; } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; set<string> st; int main() { int i, l, ans = 0; char op[101], msg[101], tp[101]; while (gets(op) != NULL) { if (op[0] == '+') st.insert(op + 1); else if (op[0] == '-') st.erase(op + 1); else { sscanf(op, "%[^:]:%*[^:]", tp); l = strlen(op) - strlen(tp) - 1; ans += st.size() * l; } } printf("%d", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int sum = 0, count = 0; string s; while (getline(cin, s)) { if (s[0] == '+') sum++; else if (s[0] == '-') sum--; else { long long int i = 0; while (s[i] != ':') { i++; } count += (s.size() - i - 1) * sum; } } cout << count << endl; return 0; }
#include <bits/stdc++.h> using namespace std; string s; int main() { int i, j; int sum = 0; int num = 0; while (getline(cin, s)) { if (s[0] == '+') num++; else if (s[0] == '-') num--; else sum += num * (s.length() - s.find(':') - 1); } cout << sum << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string s; int ans = 0, cnt = 0; while (getline(cin, s)) { if (s[0] == '+') { cnt++; } else if (s[0] == '-') { cnt--; } else { int l = (s.length() - s.find(':') - 1); ans += cnt * l; } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; void init_code() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int main() { clock_t clk = clock(); string s; int p = 0, l = 0, x, i; char ch; while (scanf("%c", &ch) != EOF) { getline(cin, s); if (ch == '+') p++; else if (ch == '-') p--; else { for (i = 0; i < s.length(); i++) { if (s[i] == ':') { break; } } l += ((s.length() - i - 1) * p); } } cout << l; clk = clock() - clk; cerr << "Time Elapsed: " << fixed << setprecision(10) << ((long double)clk) / CLOCKS_PER_SEC << "\n"; }
#include <bits/stdc++.h> using namespace std; int k, ans; string s; int main() { for (; getline(cin, s);) if (s[0] == '+') k++; else if (s[0] == '-') k--; else ans += (s.size() - s.find(':') - 1) * k; printf("%d", ans); }
#include <bits/stdc++.h> using namespace std; int num = 0, ans = 0; char str[1001]; int main() { while (gets(str) != NULL) { if (str[0] == '+') num++; else if (str[0] == '-') num--; else { int l1 = strlen(str), l2 = 0; while (str[l2] != ':') l2++; ans += num * (l1 - l2 - 1); } } printf("%d", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string com; map<string, bool> mp; int ans = 0; while (getline(cin, com)) { if (com[0] == '+') { com.erase(com.begin(), com.begin() + 1); mp[com] = 1; } else if (com[0] == '-') { com.erase(com.begin(), com.begin() + 1); mp[com] = 0; } else { int len = com.size() - com.find(':') - 1, cnt = 0; for (map<string, bool>::iterator it = mp.begin(); it != mp.end(); it++) { if (it->second) cnt++; } ans += cnt * len; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; int dem = 0, kq = 0; ; while (getline(cin, s)) { if (s[0] == '+') dem++; else { if (s[0] == '-') dem--; else { int i = 0, tam = s.length() - 1; while (s[i] != ':') i++; tam = tam - i; kq += dem * tam; } } } cout << kq; }
#include <bits/stdc++.h> int main() { char c, s[1000000]; double sum = 0, l = 0; long i = 0; while (c = getchar()) { if (c == EOF) break; else if (c != '\n') { s[i++] = c; } else { if (s[0] == '+') ++sum; else if (s[0] == '-') --sum; else { long n = 0; while (s[n] != ':') ++n; l += (strlen(s) - n - 1) * sum; } if (s[strlen(s) - 1] == EOF) break; for (long f = strlen(s) - 1; f >= 0; --f) s[f] = '\0'; i = 0; } } printf("%.lf", l); }
#include <bits/stdc++.h> using namespace std; char s[111]; int main() { int n = 0; int re = 0; int i, l, x; while (gets(s)) { if (s[0] == '+') n++; else if (s[0] == '-') n--; else { i = 0; l = strlen(s); while (s[i] != ':') i++; re += (l - i - 1) * n; } } cout << re << endl; return 0; }
#include <bits/stdc++.h> using namespace std; void solve(); signed main() { solve(); } string getstring(string &s) { cin >> s; return s; } void solve() { string s; long long p = 0, l = 0, x, i; char ch; while (scanf("%c", &ch) != EOF) { getline(cin, s); if (ch == '+') p++; else if (ch == '-') p--; else { for (i = 0; i <= s.length(); i++) { if (s[i] == ':') { break; } } l += ((s.length() - i - 1) * p); } } cout << l; }
#include <bits/stdc++.h> using namespace std; int main() { int sum = 0, cnt = 0, l, i; string ch; while (1) { getline(cin, ch); if (ch.size() == 0) break; if (ch[0] == '+') cnt++; else if (ch[0] == '-') cnt--; else { l = ch.size(); for (i = 0; i < l; i++) { if (ch[i] == ':') { break; } } sum = sum + ((l - i - 1) * cnt); } } printf("%d\n", sum); return 0; }
#include <bits/stdc++.h> using namespace std; char buf[110]; set<string> guys; int ans = 0; int main() { while (gets(buf)) { if (buf[0] == '+' || buf[0] == '-') { string cur = buf + 1; if (buf[0] == '+') guys.insert(cur); else guys.erase(cur); } else { int colonPos = int(strstr(buf, ":") - buf); int messageLength = (int)strlen(buf) - colonPos - 1; ans += messageLength * guys.size(); } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; int sum = 0, ans = 0; while (getline(cin, s)) { if (s[0] == '+') ++sum; else if (s[0] == '-') --sum; else { int all = 0; for (int i = 0; i < s.size(); ++i) { if (all) ++all; else if (s[i] == ':') ++all; } ans += (all - 1) * sum; } } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string str; int sum = 0; int people = 0; while (getline(cin, str)) { if (str[0] == '+') people++; else if (str[0] == '-') people--; else { sum += people * (str.size() - str.find(":") - 1); } } cout << sum << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { set<string> names; string str; int sum = 0; char s1[10000]; char s2[10000]; while (getline(cin, str)) { if (str[0] == '+') names.insert(str.substr(1)); else if (str[0] == '-') names.erase(str.substr(1)); else { string mes; for (int i = 0; i < str.size(); i++) { if (str[i] == ':') mes = str.substr(i + 1); } sum += mes.size() * names.size(); } } cout << sum << endl; return 0; }
#include <bits/stdc++.h> using namespace std; char str[65536]; int cnt = 0, res = 0; int find(char c, char s[]) { for (int i = 0; s[i]; ++i) if (s[i] == c) return i; return -1; } int main() { while (gets(str) != NULL) { if (str[0] == '+') cnt++; else if (str[0] == '-') cnt--; else { int len = strlen(str), p = find(':', str); res += (len - p - 1) * cnt; } } printf("%d\n", res); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int i, j, k = 0, n, w = 0; string s; while (getline(cin, s)) { if (s[0] == '+') { k++; continue; } if (s[0] == '-') { k--; continue; } n = s.find(':'); j = s.size(); w += (j - n - 1) * k; } cout << w; }
#include <bits/stdc++.h> using namespace std; int main() { string s, x; int sum = 0, result = 0, c; while (getline(cin, x)) { if (x[0] == '-') sum -= 1; else if (x[0] == '+') sum += 1; else { c = x.find(':'); c++; s = x.substr(c, x.size() - 1); result += s.size() * sum; } } cout << result; return 0; }
#include <bits/stdc++.h> using namespace std; set<string> st; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; string s; int ans = 0; getline(cin, s); while (!s.empty()) { if (s[0] == '+') st.insert(s); else if (s[0] == '-') { s[0] = '+'; st.erase(s); } else { for (int x = 0; x < (int)s.size(); x++) { if (s[x] == ':') { ans += (int)st.size() * ((int)s.size() - 1 - x); break; } } } getline(cin, s); } cout << ans << "\n"; }
#include <bits/stdc++.h> using namespace std; int main() { string s; int ans = 0, aux = 0; while (getline(cin, s)) { if (s[0] == '+') { aux++; } else if (s[0] == '-') { aux--; } else { ans += (s.length() - s.find(":") - 1) * aux; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> int main() { int n, num = 0, ans = 0; char str[11111]; while (gets(str) != NULL) { if (str[0] == '+') num++; else if (str[0] == '-') num--; else { ans += (strlen(str) - 1 - (strstr(str, ":") - &str[0])) * num; } } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; string s, s1[110], s2; long long num = 1, sum, ans, f = 0; int pd(string s) { int e = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == ':') { e = 1; break; } } return e; } int main() { while (getline(cin, s)) { if (s[0] == '+') { num++; } else if (s[0] == '-') { num--; } else if (pd(s)) { ans += (num - 1) * (s.size() - 1 - s.find(':')); } } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; } inline int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } template <typename T> string to_str(T str) { stringstream stream; stream << str; return stream.str(); } template <typename T> int to_int(T num) { int val; stringstream stream; stream << num; stream >> val; return val; } vector<string> split(const string& s, char delim) { vector<string> elems; stringstream ss(s); string item; while (getline(ss, item, delim)) elems.push_back(item); return elems; } const int dr[] = {-1, -1, 0, 1, 1, 1, 0, -1}; const int dc[] = {0, 1, 1, 1, 0, -1, -1, -1}; int ans, cnt; int main() { string s; while (getline(cin, s)) { if (s[0] == '+') cnt++; else if (s[0] == '-') cnt--; else { int i, sz = s.size(); for (i = 0; s[i]; i++) { if (s[i] == ':') break; } ans += cnt * (sz - i - 1); } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string Data; int t = 0, ans = 0; while (getline(cin, Data)) { if (Data[0] == '+') t++; else if (Data[0] == '-') t--; else { int i = 0; while (Data[i] != ':') i++; i++; ans += (Data.size() - i) * t; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int textLength(char s[]) { int len = 0; for (int i = 0; i < strlen(s); i++) if (s[i] == ':') { len = strlen(s) - i - 1; break; } return len; } int main() { char s[1000]; int byteFig = 0, memNum = 0; while (!cin.eof()) { cin.getline(s, 1000); if (s[0] == '+') memNum++; else { if (s[0] == '-') memNum--; else byteFig += memNum * textLength(s); } } cout << byteFig << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; int ans = 0, t1 = 0, t2 = 0; while (getline(cin, s)) { int res = 0; if (s[0] == '+') { t1++; } else if (s[0] == '-') { t2++; } for (int i = 0; i < s.size(); i++) { if (s[i] == ':') { int b = s.size() - i - 1; res = t1 - t2; res *= b; } } ans += res; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; map<string, int> mp; int main() { string s; int i, j, k, ln; int sm = 0; while (getline(cin, s)) { if (s[0] == '+') { s.erase(0, 1); ; mp[s]++; } else if (s[0] == '-') { s.erase(0, 1); mp[s]--; } else { ln = s.size(); for (i = 0; i < ln; i++) { if (s[i] == ':') { j = i; break; } } k = 0; for (map<string, int>::iterator it = mp.begin(); it != mp.end(); it++) { if ((*it).second) k++; } sm += k * (ln - 1 - (j)); } } cout << sm << endl; }
#include <bits/stdc++.h> using namespace std; int q, c, e; string s; int main() { while (getline(cin, s)) { if (s[0] == '+') { c++; } else if (s[0] == '-') { c--; } else { for (int i = 0; i < s.size(); i++) { if (s[i] != ':') { e++; } else { break; } } q += (s.size() - (e + 1)) * c; } e = 0; } cout << q; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; int ans = 0, ct = 0; while (getline(cin, s)) { if (s[0] == '+') ct++; else if (s[0] == '-') ct--; else { int i = 0; while (i < s.length() && s[i] != ':') i++; ans += (s.length() - (i + 1)) * ct; } } cout << ans; }
#include <bits/stdc++.h> using namespace std; int main() { char input[1000000]; int participants = 0; int traffic = 0; int i, j; while (gets(input) != NULL) { if (input[0] == '+') ++participants; else if (input[0] == '-') --participants; else { char message[100000]; int len = strlen(input); for (i = 0; i < len && input[i] != ':'; ++i) ; ++i; for (j = 0; i <= len; ++i, ++j) message[j] = input[i]; traffic += strlen(message) * (participants); } } printf("%d\n", traffic); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int i, l, u; char str[101]; istringstream iss(); u = l = 0; while (!cin.eof()) { cin.getline(str, 102); if (str[0] == '+') { u++; continue; } if (str[0] == '-') { u--; continue; } for (i = 0; i < strlen(str); i++) if (str[i] == ':') { l += (strlen(str) - (i + 1)) * u; break; } } cout << l; return 0; }
#include <bits/stdc++.h> using namespace std; const long long int mod = pow(10, 9) + 7; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); string s; long long int ans = 0, c = 0; while (getline(cin, s)) { if (s[0] == '+') c += 1; else if (s[0] == '-') c -= 1; else { long long int x = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == ':') { x = s.size() - i - 1; break; } } ans += x * c; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; map<string, bool> idx; string nama; char msk[200]; int ans, x, y, len; int main() { ans = 0; while (gets(msk)) switch (msk[0]) { case ('+'): len = strlen(msk); nama.clear(); for (x = 1; x < len; x++) nama += msk[x]; idx[nama] = true; break; case ('-'): len = strlen(msk); nama.clear(); for (x = 1; x < len; x++) nama += msk[x]; idx.erase(nama); break; default: nama = msk; x = nama.find(':'); y = (int)nama.size() - x - 1; ans += y * (int)idx.size(); } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int getline(char* str) { int i; char tc; for (i = 0; (tc = getchar()) != '\r' && tc != '\n' && !feof(stdin); i++) { fflush(stdout); str[i] = tc; } if (feof(stdin)) return 0; str[i] = 0; if (tc == '\r') getchar(); return i; } int main() { set<string> ppl; char str[10000]; int i, len, ans = 0; while (len = getline(str)) { if (str[0] == '+') ppl.insert((string)(str + 1)); else if (str[0] == '-') ppl.erase((string)(str + 1)); else { for (i = 0; i < len && ((str[i] >= 'a' && str[i] <= 'z') || (str[i] >= 'A' && str[i] <= 'z') || (str[i] >= '0' && str[i] <= '9')); i++) ; ans += (len - i - 1) * ppl.size(); } } printf("%d\n", ans); }
#include <bits/stdc++.h> using namespace std; int main() { set<string> online; string str, temp; int cnt = 0; while (!cin.eof()) { getline(cin, str); if (str[0] == '+' || str[0] == '-') { temp = str.substr(1); if (str[0] == '+') online.insert(temp); else online.erase(temp); } else { cnt += online.size() * (str.length() - str.find(":") - 1); } } printf("%d\n", cnt); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int i, j, k, l, m, n, ans = 0; long long int cnt = 0, q = 100; string s; while (getline(cin, s)) { if (s.length() > 0) { if (s[0] == '+') { cnt++; } else if (s[0] == '-') { cnt--; } else { long long int tl = s.length(), cnti, rem = 0, f = 0; for (i = 0; i < tl; i++) { if (s[i] == ':') { cnti++; f = 1; } else { if (f == 0) { cnti++; } else if (f == 1) { rem++; } } } ans = ans + (cnt * rem); } } } cout << ans; }
#include <bits/stdc++.h> using namespace std; int main() { string s; int person = 0, total = 0, l, i; while (getline(cin, s)) { if (s[0] == '+') person++; else if (s[0] == '-') person--; else { for (i = 0; i < s.size(); i++) if (s[i] == ':') break; l = s.size() - (i + 1); total += l * person; } } cout << total << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const double eps = 1e-7; set<string> S; int main() { string s; int cnt = 0; while (getline(cin, s)) { if (s[0] == '-') S.erase(s.substr(1)); else if (s[0] == '+') S.insert(s.substr(1)); else cnt += (S.size() * (s.size() - s.find(':') - 1)); } cout << cnt; return 0; }
#include <bits/stdc++.h> using namespace std; const long long maxn = 2e5 + 4; long long gcd(long long a, long long b) { while (a > 0 && b > 0) if (a > b) a %= b; else b %= a; return a + b; } long long power(long long x, unsigned int y) { long long temp; if (y == 0) return 1; temp = power(x, y / 2); if ((y % 2) == 0) return temp * temp; else return x * temp * temp; } string s; int main() { ios_base::sync_with_stdio(false); cin.tie(0); long long n = 0; long long ans = 0; while (getline(cin, s)) { if (s[0] == '+') { n += 1; continue; } else if (s[0] == '-') { n -= 1; continue; } long long start; for (long long i = 0; i < (long long)s.size(); i++) { if (s[i] == ':') { start = i; break; } } long long mlen = s.size() - start - 1; ans += n * mlen; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; int cur = 0, res = 0; while (getline(cin, s)) { if (s[0] == '+') cur++; else if (s[0] == '-') cur--; else { for (int i = 0; i < s.size(); i++) { if (s[i] == ':') res += cur * (s.size() - 1 - i); } } } cout << res; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int x, z = 0, sum = 0; string s; while (getline(cin, s)) { x = s.find(":"); if (x >= 0) { s.erase(0, x + 1); sum = sum + (s.size() * z); } else if (s[0] == '+') { z++; } else if (s[0] == '-') { z--; } } cout << sum; return 0; }
#include <bits/stdc++.h> using namespace std; int t; int main() { ios_base::sync_with_stdio(0); int s = 0; string a; while (getline(cin, a)) { if (a[0] == '+') { s++; } else if (a[0] == '-') { s--; } else { int u = 0; for (int i = a.size() - 1; i >= 0; i--) { if (a[i] == ':') { break; } else { u++; } } t += u * s; } } cout << t; }
#include <bits/stdc++.h> using namespace std; int n, x; char a[1000]; int main() { while (gets(a)) { if (a[0] == '+') { n++; } else if (a[0] == '-') { n--; } else { int j = 0; while (a[j] != ':') { j++; } j++; int ylen = strlen(a); x += (ylen - j) * n; } } cout << x; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; string s1 = ":"; int present = 0, sum = 0; while (getline(cin, s)) { if (s[0] == '+') { present++; } else if (s[0] == '-') { present--; } else { std::size_t found = s.find(s1); sum = sum + (present * (s.size() - 1 - found)); } } cout << sum; }
#include <bits/stdc++.h> int main() { char com[101]; int peo = 0, tra = 0; while (gets(com)) { if (com[0] == '+') { ++peo; continue; } if (com[0] == '-') { --peo; continue; } tra += (strlen(com) - (strchr(com, ':') - (com + 0) + 1)) * peo; } printf("%d\n", tra); return 0; }
#include <bits/stdc++.h> int main() { int ans = 0; int hum = 0; char mess[200]; while (gets(mess) != NULL) { bool f = false; if (mess[0] == '+') { hum++; f = true; } if (mess[0] == '-') { hum--; f = true; } if (!f) { for (int i = 0, len = strlen(mess); i < len; i++) { if (mess[i] == ':') { ans += hum * strlen(mess + i + 1); } } } } printf("%d", ans); }
#include <bits/stdc++.h> using namespace std; int main() { char a[100]; int sum = 0; int ans = 0; while (gets(a)) { int len = strlen(a); if (a[0] == '+') sum++; else if (a[0] == '-') sum--; else { int p = 0; for (int i = 0; i < len; i++) { if (a[i] == ':') { p = i; } } ans += (len - p - 1) * sum; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; unsigned long long GCD(unsigned long long x, unsigned long long y) { if (y == 0) return x; else return GCD(y, x % y); } unsigned long long LCM(unsigned long long a, unsigned long long b) { return (a * b / (GCD(a, b))); } bool PRIME(int p) { if (p <= 1) return false; if (p <= 3) return true; if (p % 2 == 0 || p % 3 == 0) return false; for (int i = 5; p >= i * i; i = i + 6) { if (p % i == 0 || p % (i + 2) == 0) return false; } return true; } int main() { long long a, b, c, d, e, t, i, j, k, sum = 0, ans = 0, x, y, z, m, n; string A, B; while (getline(cin, A)) { if (A[0] == '+') { sum++; continue; } if (A[0] == '-') { sum--; continue; } else { x = A.size(); for (i = 0; i < x; i++) { if (A[i] == ':') { a = i; break; } } a++; ans += sum * (x - a); } } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; template <typename T> inline T abs(T a) { return ((a < 0) ? -a : a); } template <typename T> inline T sqr(T a) { return a * a; } const int N = 100009; const int logN = 20; const int sqrN = 450; const int MOD = 100000; const int INF = 1e9; const long long INF64 = 1e18; const long double PI = 3.1415926535897932384626433832795; const long double eps = 1e-9; int dx[] = {0, 0, -1, 1}; int dy[] = {-1, 1, 0, 0}; set<string> S; int main() { srand(time(NULL)); cout << setprecision(10) << fixed; cerr << setprecision(10) << fixed; long long ans = 0; string s; while (getline(cin, s)) { if (s[0] == '+') { string s2 = ""; for (int i = 1; i < (int)(s.size()); ++i) s2 += s[i]; S.insert(s2); } else if (s[0] == '-') { string s2 = ""; for (int i = 1; i < (int)(s.size()); ++i) s2 += s[i]; S.erase(s2); } else { string s2 = ""; int pos = 0; while (pos < (int)(s.size()) && s[pos] != ':') ++pos; ++pos; for (; pos < (int)(s.size()); ++pos) s2 += s[pos]; ans += (int)(s2.size()) * (int)(S.size()); } } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { char buf[500]; vector<string> v; int res = 0; while (gets(buf)) { string com = buf; if (com[0] == '+') v.push_back(com.substr(1)); if (com[0] == '-') for (int i = 0; i < (v.size()); ++i) if (v[i] == com.substr(1)) { v.erase(v.begin() + i); break; } if (com[0] != '+' && com[0] != '-') { for (int i = 0; i < (com.size()); ++i) if (com[i] == ':') res += (com.size() - i - 1) * v.size(); } } cout << res; return 0; }
#include <bits/stdc++.h> using namespace std; string c; long long i, l, a, s1; int main() { while (getline(cin, c)) { if (c[0] == 43) s1++; if (c[0] == 45) s1--; l = c.size(); if (c[0] != 43 && c[0] != 45) { for (i = 1; i <= l; i++) { if (c[i] == 58) a += (l - i - 1) * s1; } } } cout << a; return 0; }
#include <bits/stdc++.h> using namespace std; int n_people = 0; int output_lines = 0; void read_lines() { string chat_line; while (getline(cin, chat_line)) { if (chat_line[0] == '+') { ++n_people; } else if (chat_line[0] == '-') { --n_people; } else { int message_len = (chat_line.size() - chat_line.find(':') - 1); output_lines += n_people * message_len; } } } int main() { read_lines(); cout << output_lines << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int nump = 0, numc = 0, ans = 0, len, i; char c, m[101]; while (scanf("%c", &c) != EOF) { if (c == '+') nump++; if (c == '-') nump--; gets(m); len = strlen(m); if (c != '+' && c != '-') { for (i = 0, numc = 0; i < len; i++, numc++) if (m[i] == ':') numc = 0; numc--; ans += numc * nump; } } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; set<string> l; int ans = 0; while (getline(cin, s)) { if (s == "") break; if (s[0] == '+') { l.insert(s.substr(1)); } else if (s[0] == '-') { l.erase(s.substr(1)); } else { int i = 0; while (s[i] != ':') i++; ans += ((int)s.size() - i - 1) * l.size(); } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #pragma warning(disable : 4996) string s, s1; int res; set<string> m; int main() { s1.resize(200); while (!feof(stdin)) { gets(&s1[0]); s.clear(); if (s1.empty()) break; if (feof(stdin)) break; for (int i = 0; s1[i] != 0; i++) s += s1[i]; if (s[0] == '+') { s.erase(0, 1); m.insert(s); } else if (s[0] == '-') { s.erase(0, 1); m.erase(s); } else { int i; for (i = 0; s[i] != ':'; i++) ; res += (s.size() - i - 1) * m.size(); }; }; cout << res << endl; return 0; };
#include <bits/stdc++.h> using namespace std; int main() { int people = 0; int ans = 0; do { char c; cin >> c; if (c == '+') { people++; cin.ignore(100, '\n'); } else if (c == '-') { people--; cin.ignore(100, '\n'); } else { cin.ignore(100, ':'); string message; getline(cin, message); ans += people * message.length(); } } while (cin.peek() != EOF); cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int i, sum, a, j; char z[105]; i = 0; sum = 0; while (gets(z)) { if (z[0] == '+') { i++; } else if (z[0] == '-') { i--; } else { for (a = 0; strlen(z) > a; a++) { if (z[a] == ':') { break; } } j = strlen(z) - a - 1; sum += i * j; } } cout << sum << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const double inf = 1e20, eps = 1e-9; char s[100]; int main() { int tot = 0, n = 0; while (gets(s)) { if (*s == '+') ++n; else if (*s == '-') --n; else { char *p = strchr(s, ':'); tot += strlen(p + 1) * n; } } printf("%d\n", tot); return 0; }
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const long long INF = 1e9 + 9; const long long N = 500500; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); set<string> p; long long ans = 0; while (1) { string s; getline(cin, s, '\n'); if (s == "") break; if (s[0] == '+') { p.insert(s.substr(1)); } else if (s[0] == '-') { p.erase(s.substr(1)); } else { for (long long i = 0; i < s.size(); i++) { if (s[i] == ':') { ans += ((long long)p.size()) * (s.substr(i + 1).size()); } } } } cout << ans; return 0; }