Problem: Takahashi participated in a contest on AtCoder.  The contest had N problems.  Takahashi made M submissions during the contest.  The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`).  The number of Takahashi's correct answers is the number of problems on which he received an `AC` once or more.  The number of Takahashi's penalties is the sum of the following count for the problems on which he received an `AC` once or more: the number of `WA`s received before receiving an `AC` for the first time on that problem.  Find the numbers of Takahashi's correct answers and penalties.

Submission attempts (in order):
import sys
N,M = map(int,input().split())
if M == 0:
	print('0 0')
	sys.exit()


p = [0]*M
s = [0]*M

for i in range(M):
	p[i],s[i] = input().split()

cor_count = 0
pen_count = 0
AC_list = []

for i in range(M):
	if not p[i+1] in AC_list:
		if s[i+1] == 'AC':
			AC_list.append(p[i+1])
		else:
			pen_count += 1

#print(AC_list)
cor_count = len(set(AC_list))
if M != 0:
	print(cor_count,pen_count)





import sys
N,M = map(int,input().split())

cor_count = 0
pen_count = 0
AC_list = []

p = [0]*M
s = [0]*M

if M == 0 or N==0:
	print('0 0')
	sys.exit()


l = []
for i in range(M):
	p[i],s[i] = input().split()

for i in range(M-1):
	if p[i] != p[i+1]:
		l.append(i+1)
print(l)
x = 0
for i in range(M):
	if not p[i] in AC_list:
		if s[i] == 'AC':
			AC_list.append(p[i])
		else:
			pen_count += 1
	else:
		i = l[x]
		x += 1

#print(AC_list)
cor_count = len(set(AC_list))

print(cor_count,pen_count)



import sys
N,M = map(int,input().split())

cor_count = 0
pen_count = 0
AC_list = []

p = [0]*M
s = [0]*M

if M == 0 or N==0:
	print('0 0')
	sys.exit()


l = []
for i in range(M):
	p[i],s[i] = input().split()

for i in range(M-1):
	if p[i] != p[i+1]:
		l.append(i+1)
print(l)
x = 0
for i in range(M):
	if not p[i] in AC_list:
		if s[i] == 'AC':
			AC_list.append(p[i])
		else:
			pen_count += 1
	else:
		if len(l)!= 0:
			i = l[x]
			x += 1

#print(AC_list)
cor_count = len(set(AC_list))

print(cor_count,pen_count)



N,M = map(int,input().split())

AC = 0
WA = 0


was = [0]*(N+1)
acs = [0]*(N+1)

for i in range(M):
	p,s = input().split()
	p = int(p)

	if s = "AC":
		if acs[p] == 0:
			AC += 1
			WA += was[p]
			acs[p] = 1
	else:
		was[p] += 1

print(AC,WA)

import sys
N,M = map(int,input().split())
if M == 0:
	print('0 0')
	sys.exit()


p = [0]*M
s = [0]*M

for i in range(M):
	p[i],s[i] = input().split()

cor_count = 0
pen_count = 0
AC_list = []


if s[0] == 'AC':
	AC_list.append(p[0])
	cor_count += 1
else:
	pen_count += 1

for i in range(M-1):
	if not p[i+1] in AC_list:
		if s[i+1] =='AC':
			AC_list.append(p[i+1])
		else:
			pen_count += 1
	if s[i+1] =='AC':
		AC_list.append(p[i+1])
	else:
		pen_count += 1
#print(AC_list)
cor_count = len(set(AC_list))
if M != 0:
	print(cor_count,pen_count)



N,M = map(int,input().split())

AC = 0
WA = 0


was = [0]*(N+1)
acs = [0]*(N+1)

for i in range(M):
	p,s = input().split()
	p = int(p)

	if s == "AC":

		if acs[p] == 0:

			AC += 1
			WA += was[p]
			acs[p] = 1
			
	else:
		was[p] += 1

print(AC,WA)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Accepted