Code Viblo Huy Chat Pro

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import sys

count = 0
number_of_people = 0

for line in sys.stdin:
if line[0] == '+':
number_of_people += 1
elif line[0] == '-':
number_of_people -=1
else:
# print(line.split(':')[1])
# print(len(line.split(':')[1]))
# print(number_of_people)
index_colon = line.find(':')
line = line[index_colon:]
s = line.rstrip().lstrip()
if s != ':':
count += (len(s)) * number_of_people

print(count)