Problem:
 Score : 300 points    Problem Statement 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.      Constraints  N , M , and p_i are integers.  1 \leq N \leq 10^5  0 \leq M \leq 10^5  1 \leq p_i \leq N  S_i is AC or WA .         Input Input is given from Standard Input in the following format:  N  M  p_1  S_1  :  p_M  S_M       Output Print the number of Takahashi's correct answers and the number of Takahashi's penalties.        Sample Input 1 2 5
1 WA
1 AC
2 WA
2 AC
2 WA      Sample Output 1 2 2  In his second submission, he received an AC on the first problem for the first time. Before this, he received one WA on this problem.  In his fourth submission, he received an AC on the second problem for the first time. Before this, he received one WA on this problem.  Thus, he has two correct answers and two penalties.       Sample Input 2 100000 3
7777 AC
7777 AC
7777 AC      Sample Output 2 1 0  Note that it is pointless to get an AC more than once on the same problem.       Sample Input 3 6 0      Sample Output 3 0 0

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, m = map(int, readline().split())


acCount = 0
waCount = 0
check = [0] * n
waCheck = [0] * n

for i in range(m):
    p, s = map(str, input().split())
    
    p = int(p)
    if (check[p - 1] == 0):
        if (s == 'WA'):
            waCheck[p - 1] += 1

        else:
            acCount += 1
            waCount += waCheck[p - 1]

            check[p - 1] = 1
    else:
        continue

print(acCount, waCount)

Solution (Python):
N, M = map(int, input().split())
AC = [False] * (N+1)
WA = [0] * (N+1)
for i in range(M):
    p, S = input().split()
    p = int(p)
    if S == 'AC':
        AC[p] = True
    else:
        if not AC[p]:
            WA[p] += 1
C_AC = 0
A_WA = 0
for i in range(N+1):
    if AC[i]:
        C_AC += 1
        A_WA += WA[i]

print(C_AC, A_WA)

Solution (Python):
N, M = map(int, input().split(' '))
P_n = [input().split(' ') for _ in range(M)]
ac = set([])
for p in P_n:
    if p[1] == 'AC':
        ac.add(p[0])
correct = 0
incorrect = 0
already = set([])
for p in P_n:
    if p[0] not in already and p[0] in ac:
        if p[1] == 'AC':
            correct += 1
            already.add(p[0])
        elif p[1] == 'WA':
            incorrect += 1
print(str(correct) + ' ' + str(incorrect))

Solution (Python):
N,M = list(map(int,input().split()))
ans = 0
pen = 0

check = {}

for i in range(M):
    p,S = input().split()
    p = int(p)
    if p not in check:
        if S == 'WA':
            check[p] = 1
        else:
            ans += 1
            check[p] = -1
    else:
        if S == 'WA' and check[p] != -1:
            check[p] += 1
        elif S == 'AC' and check[p] != -1:
            pen += check[p]
            ans += 1
            check[p] = -1

print(ans,pen)

Solution (Python):

N, M = map(int,input().split())
AC = [0]*N
WA = [0]*N
for i in range(M):
    p, s = input().split()
    p = int(p)
    if(s=='WA' and AC[p-1]==0):
        WA[p-1] += 1
        continue
    if(s=='AC' and AC[p-1]==0):
        AC[p-1] += 1
        continue
WA_num = sum([WA[i] for i in range(len(AC)) if AC[i] == 1])
print(sum(AC), WA_num)

Solution (Python):
N, M = map(int, input().split())
PS = [list(input().split()) for _ in range(M)]

C0 = [0 for _ in range(N + 1)]  
C1 = [0 for _ in range(N + 1)]  

for p, s in PS:
    if C0[int(p)] == 0:
        if s == "AC":
            C0[int(p)] = 1  
        else:
            C1[int(p)] += 1  


num_ac = sum(C0)
num_wa = sum([i * j for i, j in zip(C0, C1)])

print(num_ac, num_wa)

Solution (Python):
N, M = map(int, input().split())
PS = [list(input().split()) for _ in range(M)]

C0 = [0 for _ in range(N + 1)]  
C1 = [0 for _ in range(N + 1)]  

for p, s in PS:
    if C0[int(p)] == 0:
        if s == "AC":
            C0[int(p)] = 1  
        else:
            C1[int(p)] += 1  


num_ac = sum(C0)
num_wa = sum([i * j for i, j in zip(C0, C1)])

print(num_ac, num_wa)

Solution (Python):
n,m = map(int, input().split())

wa_l = [0]*(n+1)
ac_l = [False]*(n+1)
for _ in range(m):
    p,s = input().split()
    p = int(p)
    if s == 'WA' and not ac_l[p]:
        wa_l[p] += 1
    elif s == 'AC':
        ac_l[p] = True


ans_a = 0
ans_w = 0
for wa,ac in zip(wa_l,ac_l):
    if ac:
        ans_a+=1
        ans_w += wa

print(ans_a,ans_w)

Solution (Python):
import numpy as np
import sys

N, M = [int(_) for _ in input().split()]

if M == 0:
    print("0 0")
    sys.exit()

P, S = np.array([[_ for _ in input().split()] for i in range(M)]).T

dict = {}
for i in range(M):
    if not (P[i] in dict):
        dict.update({P[i]: {"AC": False, "WA": 0}})

    value = dict[P[i]]

    if not value["AC"]:
        if S[i] == "AC":
            dict[P[i]] = {"AC": True, "WA": value["WA"]}
        else:
            dict[P[i]] = {"AC": False, "WA": value["WA"] + 1}

ac = sum(value["AC"] for value in dict.values())
wa = sum(value["WA"] if value["AC"] else 0 for value in dict.values())

print(f"{ac} {wa}")

Solution (Python):
f=lambda:input().split()
n,m=map(int,f())
n+=1
a,w=[0]*n,[0]*n
for _ in range(m):
  p,s=f()
  p=int(p)
  if s=='AC': a[p]=1
  elif a[p]<1: w[p]+=1
print(sum(a),sum(i*j for i,j in zip(a,w)))

Solution (Python):
def main():
    n, m = map(int, input().split())
    p = []
    for i in range(m):
        p.append(input().split())

    if m == 0:
        print(0, 0)
        return 
    else:
        wa = [0 for i in range(n+1)]
        ac = [0 for i in range(n+1)]

        for pro, s in p:
            if ac[int(pro)] == 0:
                if s == 'WA':
                    wa[int(pro)] += 1
                elif s == 'AC':
                    ac[int(pro)] += 1
        
        sum_wa = 0
        for isac, iswa in zip(ac, wa):
            if isac == 1:
                sum_wa += iswa

        print(sum(ac), sum_wa)
    

if __name__ == '__main__':
    main()

Solution (Python):
def main():
    n, m = map(int, input().split())
    ac = [0] * n
    wanum = [0] * n
    for _ in range(m):
        p, s = input().split()
        p = int(p) - 1
        if ac[p]:
            continue
        else:
            if s == 'AC':
                ac[p] = 1
                wanum[p] *= -1
            else:
                wanum[p] -= 1
    wanum2 = [i for i in wanum if i > 0]
    print(sum(ac), sum(wanum2))

if __name__ == '__main__':
    main()

Solution (Python):
def main():
    n, m = map(int, input().split())
    ac = [0] * n
    wanum = [0] * n
    for _ in range(m):
        p, s = input().split()
        p = int(p) - 1
        if ac[p]:
            continue
        else:
            if s == 'AC':
                ac[p] = 1
                wanum[p] *= -1
            else:
                wanum[p] -= 1
    wanum2 = [i for i in wanum if i > 0]
    print(sum(ac), sum(wanum2))

if __name__ == '__main__':
    main()

Solution (Python):
n,m=map(int,input().split())
q=[0 for q in range(n)]
t=[0 for q in range(n)]
p=[]
x=0
for i in range(m):
    a=list(input().split())
    p.append(a)
    a[0]=int(a[0])
    if a[1]=="AC":
        q[a[0]-1]=1
    else:
        if q[a[0]-1]==0:
            t[a[0]-1]+=1
            
for i in range(n):
    if q[i]==1:
        x+=t[i]
print(str(q.count(1))+" "+str(x))

Solution (Python):
n,m = map(int,input().split())
ps = []
ans = [0,0]
wa = [0]*(n+1)
solved = [0]*(n+1)
for i in range(m):
  p,s = input().split()
  p = int(p)
  if not solved[p]:
    if s=="AC":
      ans[0]+=1
      ans[1]+=wa[p]
      solved[p]=1
    else:
      wa[p]+=1

print(ans[0],ans[1])

Solution (Python):
n,m = map(int,input().split())
ps = []
ans = [0,0]
wa = [0]*(n+1)
solved = [0]*(n+1)
for i in range(m):
  p,s = input().split()
  p = int(p)
  if not solved[p]:
    if s=="AC":
      ans[0]+=1
      ans[1]+=wa[p]
      solved[p]=1
    else:
      wa[p]+=1

print(ans[0],ans[1])

Solution (Python):
n,m=map(int,input().split())
if m==0:
  print("{} {}".format(0,0))
else:
  ac_count=0
  wa_count=0
  ac_list=[0]*n
  wa_list=[0]*n
  for i in range(m):
    p,s=input().split()
    if ac_list[int(p)-1]==0:
      if s=="AC":
        ac_count+=1
        ac_list[int(p)-1]+=1
      else:
        wa_list[int(p)-1]+=1
  for k in range(n):
    if ac_list[k]==1:
      wa_count+=wa_list[k]
  print("{} {}".format(ac_count,wa_count))

Solution (Python):
n,m=map(int,input().split())
p=[0]
p*=n
ac=set()
wa=0
for i in range(m):
    pi,si=input().split()
    pi=int(pi)
    if si=='AC' and not pi in ac:
        ac.add(pi) 
        wa+=p[pi-1]
    else:
        p[pi-1]+=1
ans=len(ac)
print(ans,wa,end=' ')

Solution (Python):
n,m=map(int,input().split())
if m==0:
    print(0,0)
    exit()
AC=[0]*(n+1)
WA=[0]*(n+1)

for i in range(m):
    p,s=map(str,input().split())
    if s=="AC":
        AC[int(p)]+=1
    elif s=="WA" and AC[int(p)]==0:
        WA[int(p)]+=1

for i in range(n+1):
    if AC[i]==0:
        WA[i]=0

cnt=AC.count(0)
answer=len(AC)-cnt
ans=sum(WA)
print(answer,ans)

Solution (Python):
N,M=map(int,input().split())
if M==0:
  print('0 0')
  exit()
AC=[0]*(N+1)
WA=[0]*(N+1)
for i in range(M):
  p,s=map(str,input().split())
  if s=='AC':
    key=int(p)
    AC[key]+=1
  elif s=='WA' and AC[int(p)]==0:
    WA[int(p)]+=1
for i in range(N+1):
  if AC[i]==0:
    WA[i]=0
ansc=AC.count(0)
ANSC=len(AC)-ansc
ANSW=sum(WA)
print(ANSC,ANSW)

Solution (Python):
from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
from fractions import gcd
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
EPS = 10**-7

n, m = map(int, input().split())
memo = [[ 0,0 ] for i in range(n+1)] 
for i in range(m):
    p, s = input().split()
    p = int(p)
    if s == 'AC':
        memo[p][0] = 1
    elif s == 'WA':
        if memo[p][0] == 0:
            memo[p][1] += 1

ac, wa = 0, 0
for i in range(n+1):
    if memo[i][0] == 1:
        ac += 1
        wa += memo[i][1]

print(*[ac, wa])

Solution (Python):
n , m = (int(a) for a in input().split())
ans = [0]*n
ng = [0]*n
NG = 0
for i in range(m) :
    p,s = input().split()
    p = int(p)
    if s == "AC" :
        if ans[p-1] == 0 :
            NG += ng[p-1]
            ans[p-1] = 1
    else :
        if ans[p-1] == 0 :
            ng[p-1] += 1

print(ans.count(1) , NG)

Solution (Python):
n,m=map(int,input().split())

l=[0]*n
ll=[0]*n
no_ac=0
no_pen=0

for i in range(m):
  a,b=map(str,input().split())
  a=int(a)
  if b=='AC':
    if l[a-1]==0:      
      no_ac+=1
      l[a-1]=1
  else:
    if l[a-1]==0:
      ll[a-1]+=1

for i in range(n):
  if l[i]==1:
    no_pen+=ll[i]
print(no_ac,no_pen)

Solution (Python):
N,M=map(int,input().split())
import sys
S=sys.stdin.readlines()
A=set()
WA=[0]*N
B=[0]*N
for i in range(M):
  p,t=S[i].split()
  p=int(p)
  if p not in A and t=="AC":
    A.add(p)
    B[p-1]+=WA[p-1]
  elif p not in A and t=="WA":
    WA[p-1]+=1
print(len(A))
print(sum(B))

Solution (Python):
N,M = (int(x) for x in input().split())
Problem = [False]*N
WACount = [0]*N

for T in range(0,M):
    p,s = input().split()
    p = int(p)
    if (not Problem[p-1]) and s=='AC':
        Problem[p-1] = True
    elif (not Problem[p-1]) and s=='WA':
        WACount[p-1] += 1
WACount = [x*y for (x,y) in zip(Problem,WACount)]
print('{} {}'.format(sum(Problem),sum(WACount)))

Solution (Python):
n, m = map(int, input().split())

accurate=[False]*n

wa_count=[0]*n
for i in range(m):
    p, s=input().split()
    p=int(p)
    if accurate[p-1] is False and s=="WA":
        wa_count[p-1]+=1
    if accurate[p-1] is False and s=="AC":
        accurate[p-1]=True

ac_count=accurate.count(True)
wa=0
for i in range(n):
    if accurate[i]:
        wa+=wa_count[i]

print(ac_count, wa)

Solution (Python):
N, M = map(int, input().split())
acCheck = [False] * (N + 1)
waCntList = [0] * (N + 1)
waCnt = 0
for i in range(M):
    query = list(input().split())
    idx = int(query[0])
    if acCheck[idx]:
        continue
    if query[1] == "AC":
        waCnt += waCntList[idx]
        acCheck[idx] = True
    else:
        waCntList[idx] += 1
print(str(acCheck.count(True)), str(waCnt))

Solution (Python):
n, m = map(int,input().split())

ac = [0]*n
wa = [0]*n
for _ in range(m):
    p, s = input().split()
    p = int(p) -1
    if s == 'AC':
        ac[p] = 1
    elif ac[p] == 0:
        wa[p] += 1

ans = 0
for i in range(n):
    if ac[i] == 1:
        ans += wa[i]

res = ac.count(1)

print(res, ans)

Solution (Python):
N, M = map(int, input().split())
penalty = {key: 0 for key in range(N+1)}
accept = {key: 0 for key in range(N+1)}
ac = 0
wa = 0

for i in range(M):
    tmp = list(input().split())
    if tmp[1] == 'WA':
        if accept[int(tmp[0])] == 0:
            penalty[int(tmp[0])] += 1
    else:
        if accept[int(tmp[0])] != 1:
            accept[int(tmp[0])] = 1
            ac += 1

for k, v in penalty.items():
    if accept[k] == 1:
        wa += v

print(ac, wa)

Solution (Python):
n,m = map(int,input().split())
ps = []
ans = [0,0]
wa = [0]*(n+1)
solved = [0]*(n+1)
for i in range(m):
  p,s = input().split()
  p = int(p)
  if not solved[p]:
    if s=="AC":
      ans[0]+=1
      ans[1]+=wa[p]
      solved[p]=1
    else:
      wa[p]+=1

print(ans[0],ans[1])

Solution (Python):
N,M = map(int,input().split())

AC = set()
WA = [0]*N

for i in range(M):
    k,l = input().split()
    k = int(k)
    if l=="WA":
        if not k in AC:
            WA[k-1] += 1
    
    else:
        if not k in AC:
            AC.add(k)

counter = 0
for i in AC:
    counter += WA[i-1]

print("{} {}".format(len(AC),counter))

Solution (Python):
N,M=list(map(int,input().split()))
ans_list=[0]*N
AC_list=[0]*N
 
for m in range(M):
    p,s = input().split()
    p=int(p)
    
    
    if AC_list[p-1]==1:
        continue
    else:
        if s=='AC':
            AC_list[p-1]=1
        else:
            ans_list[p-1]=ans_list[p-1]+1
    
ans_list_=[]
for n in range(N):
    ans_list_.append(AC_list[n]*ans_list[n])
    
print(sum(AC_list),sum(ans_list_))

Solution (Python):
n,m = map(int,input().split())
a = [0]*n
ac = 0
wa = 0
for i in range(m):
    p,s = map(str,input().split())
    p = int(p)
    if s == "AC" and a[p-1] != -1:
        ac +=1
        wa += a[p-1]
        a[p-1] = -1
    elif s == "WA" and a[p-1] != -1:
        a[p-1] += 1
print(ac,wa)

Solution (Python):
N,M = map(int,input().split())

AC=[0]*N
WA=[0]*N
WAtimes=0
ACtimes=0

for i in range(M):
  p,S=map(str,input().split())
  p=int(p)-1
  if 'AC'==S:
    if 0==AC[p]:
      ACtimes+=1
      WAtimes+=WA[p]
    AC[p]+=1
  if 'WA'==S:
    WA[p]+=1

print(ACtimes,WAtimes)

Solution (Python):
n , m = map(int,input().split())
if m == 0:
    print(0,0)
    exit()
ps = [0] * m
ss = [0] * m
for i in range(m):
    p,s = map(str,input().split())
    ps[i],ss[i] = int(p),s

ac = [0] * (n + 1)
wa = [0] * (n + 1)

for i in range(m):
    if ac[ps[i]] == 1:
        continue
    if ss[i] == 'AC':
        ac[ps[i]] = 1
    else:
        wa[ps[i]] += 1

for i in range(n+1):
    if ac[i] == 0:
        wa[i] = 0

print(sum(ac),sum(wa))

Solution (Python):
N,M=map(int,input().split())
A=0
PE=0
PRO=[[] for i in range(N)]
for i in range(M):
  P,S=input().split()
  P=int(P)-1
  PRO[P].append(S)

for i in range(N):
  tmp=0
  for j in range(len(PRO[i])):
    flag=False
    if PRO[i][j]=='AC':
      A+=1
      flag=True
    if PRO[i][j]=='WA':
      tmp+=1
    if flag:
      PE+=tmp
      break
print(A,PE)

Solution (Python):
n,m=map(int,input().split())
ac=[False for i in range(n)]
wa=[0 for i in range(n)]
for i in range(m):
    p,s=input().split()
    p=int(p)
    if s=="WA":
        if ac[p-1]==False:
            wa[p-1]+=1
    elif s=="AC":
        ac[p-1]=True
AC=0
WA=0
for i in range(n):
    if ac[i]==True:
        AC+=1
        WA+=wa[i]
print(AC,WA)

Solution (Python):
from collections import defaultdict
N, M = list(map(int, input().split()))
p = []
s = []
for _ in range(M):
    p_i, s_i = list(input().split())
    p += [int(p_i)]
    s += [s_i]

passed_problem = set()
penalty_problem = defaultdict(int)
for i, p_i in enumerate(p):
    if s[i] == 'WA':
        if not p[i] in passed_problem:
            penalty_problem[p[i]] += 1
    elif s[i] == 'AC':
        passed_problem.add(p[i])


penalty = 0
for n in passed_problem:
    penalty += penalty_problem[n]    

print("{} {}".format(len(passed_problem), penalty))

Solution (Python):
n,m = map(int, input().split())

result = [False]*n
count = [0]*n
for _ in range(m):
  p,s = input().split()
  p = int(p)-1
  if not result[p]:
    if s == "AC": result[p] = True
    else: count[p] += 1
      
ng = 0
for i in range(n):
  if result[i]:
    ng += count[i]
print(result.count(True),ng)

Solution (Python):
n,m=map(int,input().split())
a=[0]*n
b=[0]*n
ac=wa=0

for i in range(m):
	p,s=input().split()
	p=int(p)-1
	if s[0]=='A' and a[p]==0:
		a[p]=1
		ac+=1
		wa+=b[p]
	elif s[0]=='W':
		b[p]+=1
print(ac, wa)

Solution (Python):
n,m=map(int,input().split())

l=[0 for i in range(n)]
ll=[0 for i in range(n)]
w=0
a=0
for i in range(m):
    p,s=input().split()
    if(l[int(p)-1]==1):continue
    if(s=="WA"):ll[int(p)-1]+=1
    if(s=="AC"):
        l[int(p)-1]=1
        w+=ll[int(p)-1]
        a+=1
print(a,w)

Solution (Python):
n,m=map(int,input().split())
acl=[0]*n
wal=[0]*n
for i in range(m):
    p,s=input().split()
    p=int(p)-1
    if s=='AC' and acl[p]==0:
        acl[p]+=1
    elif s=='WA' and acl[p]==0:
        wal[p]+=1
wa=0
for i,ac in enumerate(acl):
    if ac==1:
        wa+=wal[i]

print(sum(acl),wa)

Solution (Python):
n,m=map(int,input().split())
ac=[0]*n
pn=[0]*n
for i in range(m):
  ps=input().split()
  p=int(ps[0])-1
  s=ps[1]
  if ac[p]:
    continue
  if s=='AC':
    ac[p]=1
  else:
    pn[p]+=1
acs=sum(ac)
pns=sum([x for i,x in enumerate(pn) if ac[i]])
print(acs, pns)

Solution (Python):
n,m = map(int,input().split())
ac = [False] * n
wa = [0] * n
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == "AC":
        ac[p] = True
    else:
        if not ac[p]:
            wa[p]+=1
    
        
a = 0
b = 0
for i in range(n):
    if ac[i]:
        a += 1
        b += wa[i]
print(*[a, b])

Solution (Python):
N, M=map(int, input().split())
solved=[False]*N
wal=[0]*N
ac=0
wa=0
for _ in range(M):
  p, s=input().split()
  p=int(p)-1
  if solved[p]:
    continue
  if s=="AC":
    solved[p]=True
    ac+=1
    wa+=wal[p]
  else:
    wal[p]+=1
print(ac, wa)

Solution (Python):
N,M=map(int,input().split())
L1=[0]*(N+1) 
L2=[0]*(N+1) 

for i in range(M):
    p,S=input().split()
    if L1[int(p)]==1:
        pass
    else:
        if S=='AC':
            L1[int(p)]=1
        else:
            L2[int(p)]+=1

for j in range (N+1):
    if L1[j]==0 and L2[j]>0:
        L2[j]=0

print(sum(L1),sum(L2))

Solution (Python):






def solve(N, M, pSs):
    result = [0] * (N + 1)
    penalty = [0] * (N + 1)
    for p, S in pSs:
        if S == 'AC':
            result[p] = 1
        else:
            if result[p] == 0:
                penalty[p] += 1
    print(sum(result), sum([result[i] * penalty[i] for i in range(N + 1)]))


if __name__ == '__main__':
    N, M = map(int, input().split())
    pSs = []
    for _ in range(M):
        x = input().split()
        x[0] = int(x[0])
        pSs.append(x)
    solve(N, M, pSs)

Solution (Python):
n, m, = map(int, input().split())

arr = []
for i in range(m):
    c = input().split()
    arr.append([(int)(c[0]), c[1]])


penalty_log = {}    
success_log = set([])    

for elem in arr:
    if elem[1] == 'WA':
        if elem[0] not in success_log:
            if elem[0] not in penalty_log:
                penalty_log[elem[0]] = 1
            else:
                penalty_log[elem[0]] += 1

    elif elem[1] == 'AC':
        if elem[0] not in success_log:
            success_log.add(elem[0])




success = len(success_log) 
penalty = 0 
for k, v in penalty_log.items():
    if k in success_log:
        penalty += v
print("{} {}".format(success, penalty))

Solution (Python):
N,M=map(int,input().split())
ac=[0]+[0]*N
wa=[0]+[0]*N

for _ in range(M):
    number,ans=input().split()
    number=int(number)
    if ans=='AC':
        ac[number]=1
    elif ac[number]==0:
        wa[number]+=1

print(sum(ac),sum(c for i,c in enumerate(wa) if ac[i]==1))

Solution (Python):
n, m = map(int, input().split())
correct = [False] * n
correct_count = 0
wrong_each_count = [0] * n
wrong_count = 0

for i in range(m):
    p, s = input().split()
    p = int(p)
    if correct[p - 1]:
        continue

    if s == 'AC':
        correct[p - 1] = True
        correct_count += 1
        wrong_count += wrong_each_count[p - 1]
    else:
        wrong_each_count[p - 1] += 1
print(correct_count, wrong_count)

Solution (Python):
N,M=map(int,input().split())
ls=[list(input().split()) for _ in range(M)]
AC=[0]*(N+1)
WA=[0]*(N+1)
ans=0
for i in range(M):
  a=int(ls[i][0])
  b=ls[i][1]
  if b=="AC":
    if AC[a]!=1:
      AC[a]=1
      ans+=WA[a]
  else:
    if AC[a]!=1:
      WA[a]+=1
else:
  print(sum(AC),ans)

Solution (Python):
N, M = map(int,input().split())
ac = [0] * N
wa = [0] * N
for i in range(M):
    p, s = map(str,input().split())
    num = int(p)-1
    if s == 'WA' and ac[num] == 0: 
        wa[num] += 1
    elif s == 'AC' and ac[num] == 0:
        ac[num] += 1

for i in range(N):
    if ac[i] == 0:
        wa[i] = 0

print('{} {}'.format(sum(ac), sum(wa)))

Solution (Python):
N,M=map(int,input().split())
ac=[0]*N
wa=[0]*N

for i in range(M):
  p,s=input().split()
  if s=="WA" and ac[int(p)-1]==0:
    wa[int(p)-1]+=1
  elif s=="AC" and ac[int(p)-1]==0:
    ac[int(p)-1]+=1

penalty=[wa[k] for k in [i for i,j in enumerate(ac) if j!=0]]    
print("%d %d" % (sum(ac),sum(penalty)))

Solution (Python):
n, m = map(int, input().split())

ac = [0]*n
wa = [0]*n

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

    if s == 'WA' and ac[int(p)-1] == 0:
            wa[int(p)-1] += 1
    elif s == 'AC' and ac[int(p)-1] == 0:
            ac[int(p)-1] += 1

print('%d %d' % (sum(ac), sum([wa[k] for k in [i for i, j in enumerate(ac) if j != 0]])))

Solution (Python):
N, M = map(int, input().split())
 
ac, wa = [0]*N, [0]*N
 
for i in range(M):
    p, s = input().split()
    if s == 'WA' and ac[int(p)-1] == 0:
            wa[int(p)-1] += 1
    elif s == 'AC' and ac[int(p)-1] == 0:
            ac[int(p)-1] += 1
print('%d %d' % (sum(ac), sum([wa[k] for k in [i for i, j in enumerate(ac) if j != 0]])))

Solution (Python):
from collections import defaultdict
d = defaultdict(int)
n, m = map(int, input().split())
ac = set()
for i in range(m):
  p, s = map(str, input().split())
  if s == 'AC':
    ac.add(p)
  elif s == 'WA' and p not in ac:
    d[p] += 1
for e in d.keys():
  if e not in ac:
    d[e] = 0
pn = d.values()
print(len(list(ac)), sum(pn))

Solution (Python):
n, m = map(int, input().split())

q_list = [False] * n
p_count = 0

data = []
for _ in range(m):
    a, b = map(str, input().split())
    data.append([a, b])


for _ in range(m):
    q_num, j = data[_]
    q_num = int(q_num)
    q_num -= 1
    if j == "AC":
        q_list[q_num] = True


q2_list = [False] * n

for i in range(m):
    q_num, j = data[i]
    q_num = int(q_num)
    q_num -= 1
    if q2_list[q_num] == False:
        if j == "WA" and q_list[q_num]:
            p_count += 1
        else:
            q2_list[q_num] = True

print(q_list.count(True), p_count)

Solution (Python):
import sys
input = sys.stdin.readline
def main():
  L=list()
  R=list()
  a,b=map(int,input().split())
  for i in range(b):
    c,d=input().split()
    c=int(c)
    if d=="AC":
      L.append(c)
    elif d=="WA":
      if c not in L:
        R.append(c)
  L=set(L)
  t=len(L)
  P=[1 for i in R if i in L]
  s=sum(P)
  print(t,s)
main()

Solution (Python):
n,m=map(int,input().split())
p=[input().split() for _ in range(m)]
q=[0 for _ in range(n)]
r=[0 for _ in range(n)]
for a in p:
  e=int(a[0])-1
  if a[1]=="WA":
    q[e]+=1
  else:
    if r[e]==0:
      r[e]=q[e]+1
c=0
d=0
for b in r:
  if b>0:
    c+=1
    d+=b-1
print(c,d)

Solution (Python):
n,m=map(int,input().split())
ac=[0]*n
pena=[0]*n
for i in range(m):
  p,s=input().split()
  p=int(p)
  if ac[p-1]==0:
    if s=="AC":
      ac[p-1]=1
      LAC=i
    if s=="WA":
      pena[p-1]+=1
if m==0:
  print("0 0")
else:
  pen=0
  for (x,y) in zip(ac,pena):
    pen+=x*y
  print("{} {}".format(ac.count(1),pen))

Solution (Python):
N, M = map(int, input().split())

ac, wa = [0]*N, [0]*N

for i in range(M):
    p, s = input().split()
    if s == 'WA' and ac[int(p)-1] == 0:
            wa[int(p)-1] += 1
    elif s == 'AC' and ac[int(p)-1] == 0:
            ac[int(p)-1] += 1
print('%d %d' % (sum(ac), sum([wa[k] for k in [i for i, j in enumerate(ac) if j != 0]])))

Solution (Python):
from sys import stdin
from collections import defaultdict

N, M = map(int, stdin.readline().split())

WAinProblem=defaultdict(int)
totalWA=0
totalAC=0
for _ in range(M):
  line=stdin.readline().split()
  problem_number=int(line[0])
  result=line[1]

  if result == "WA":
    if WAinProblem[problem_number]!=-1:
      WAinProblem[problem_number]+=1
  else:
    if WAinProblem[problem_number]!=-1:
      totalWA+=WAinProblem[problem_number]
      totalAC += 1
      WAinProblem[problem_number]=-1
print("{} {}".format(totalAC,totalWA))

Solution (Python):
n, m = map(int, input().split())
ps = []
for i in range(m):
    ps.append(list(map(str, input().split())))

res = [0, 0]
stat = ['WA' for i in range(n)]
for i in range(m):
    if ps[i][1] == 'AC':
        stat[int(ps[i][0]) - 1] = 'P'
for i in range(m):
    if ps[i][1] == 'AC':
        if stat[int(ps[i][0]) - 1] == 'P':
            res[0] += 1
            stat[int(ps[i][0]) - 1] = 'AC'
    if ps[i][1] == 'WA':
        if stat[int(ps[i][0]) - 1] == 'P':
            res[1] += 1
print('{} {}'.format(res[0], res[1]))

Solution (Python):

N,M = map(int,input().split())
PS =[""]*N
PS2 =[0]*N

PENALTY = 0
AC = 0
for m in range(M):
    p,s = map(str,input().split())
    p=int(p)-1
    if PS[p]!="AC" and s=="WA":
        PS2[p]+=1
    elif PS[p]!="AC" and s=="AC":
        AC+=1
        PENALTY+=PS2[p]
        PS[p]="AC"
        
print(AC,PENALTY)

Solution (Python):
N, M = map(int, input().split())
S = []
A = [0] * (N + 1)
for i in range(0, M):
  a = input().split()
  S.append(a)
  
ac = 0
wa = 0
for a in S:
  s = int(a[0])
  p = a[1]
  if p == 'WA':
    if A[s] >= 0:
      A[s] += 1
  else:
    if A[s] >= 0:
      wa += A[s]
      A[s] = -1
      ac += 1
      
print(*[ac, wa], sep = ' ')

Solution (Python):
N,M = map(int,input().split())

wa_count = { i+1: 0 for i in range(N) }
ac_count = { i+1: False for i in range(N) }
wa,ac = 0,0

for _ in range(M):
  p,s = map(str,input().split())
  p = int(p)
  if s == "AC" and not ac_count[p]:
    ac += 1
    wa += wa_count[p]
    ac_count[p] = True
  else:
    wa_count[p] += 1

print(ac, wa)

Solution (Python):
n, m = map(int,input().split())

done = [0]*n
WA_cnt = [0]*n
for _ in range(m):
  p, s = input().split()
  p = int(p)-1
  if done[p] == 1:
    continue
  else:
    if s=='AC':
      done[p] = 1
    elif s=='WA':
      WA_cnt[p] += 1

for i in range(n):
  if done[i]==0:
    WA_cnt[i] = 0
    
print(sum(done), sum(WA_cnt))

Solution (Python):
n, m = map(int,input().split())
li = [0] * n
wa = 0
ac = 0

for i in range(m):
    p, s = map(str, input().split())
    p = int(p)

    if s == "WA" and li[p-1] >= 0: 
        li[p-1] += 1 
    
    elif s == "AC" and li[p-1] >= 0: 
        wa += li[p-1] 
        li[p-1] = -1 
        ac += 1 

print(ac, wa)

Solution (Python):
N,M=map(int,input().split())


S = [[0 for j in range(3)] for i in range(N)]

for i in range(M):
    A,B=map(str,input().split())
    A=int(A)
    if B=="AC":
        S[A-1][1]="AC"
    elif B=="WA":
        if S[A-1][1]=="AC":
            S[A-1][2]+=0
        else:
            S[A-1][2]+=1

ACcount=0
WAcount=0
for i in range(N):
    if S[i][1]=="AC":
        ACcount+=1
        WAcount+=S[i][2]
        
print(ACcount,WAcount)

Solution (Python):
N, M = map(int, input().split())

A = [[0, 0] for _ in range(N)]

for _ in range(M):
    p, s = input().split()
    if s == "AC":
        if not A[int(p)-1][0]:
            A[int(p)-1][0] = 1
    else:
        if not A[int(p)-1][0]:
            A[int(p)-1][1] += 1

ans = [0, 0]
for ac, wa in A:
    if ac:
        ans[0] += 1
        ans[1] += wa

print(*ans)

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n, m = map(int, input().split())
    penalty = dict()
    penalty_cnt = 0
    ans = set()
    for _ in range(m):
        num, result = input().split()
        if result == 'AC':
            ans.add(num)
            if num not in penalty:
                penalty[num] = 0
        elif num not in ans:
            if num not in penalty:
                penalty[num] = 1
            else:
                penalty[num] += 1
    ans = list(ans)
    for i in range(len(ans)):
        penalty_cnt += penalty[ans[i]]
    print(len(ans), penalty_cnt)

if __name__ == '__main__':
    main()

Solution (Python):
N, M = map(int, input().split())
AC = set()
wa = [0] * (N+1)
 
for _ in range(M):
    p, s = input().split()
    p = int(p)
    if not p in AC:
        if s == 'AC':
            AC.add(p)
        if s == 'WA':
            wa[p] += 1
 
wa_ans = 0
for i in AC:
    wa_ans += wa[i]
 
print(len(AC), wa_ans)

Solution (Python):
N, M = map(int,input().split())
Pn = [0] * N
Wrong = 0
Accept = 0
for i in range(M):
    p, S = map(str, input().split())
    p = int(p)
    if S == "WA" and Pn[p-1] >= 0:
        Pn[p-1] += 1
    elif S=="AC" and Pn[p-1] >= 0:
        Wrong += Pn[p-1]
        Pn[p-1] = -1
        Accept += 1
print(Accept, Wrong)

Solution (Python):
n,m = map(int,input().split())
a = [-1 for _ in range(n)]
wa = [0 for _ in range(n)]
for i in range(m):
  ps,s = input().split()
  pi = int(ps)
  if(a[pi-1] == 1):
    continue
  elif(s == 'WA'):
    wa[pi-1] += 1
  elif(s == 'AC'):
    a[pi-1] = 1
for l in range(n):
  if(a[l] == -1):
    wa[l] = 0
print(a.count(1),sum(int(i) for i in wa) )

Solution (Python):
N,M = map(int,input().split())
ok = 0
ng = 0
Q = [0]*N
for _ in range(M):
    p,s = map(str,input().split())
    if Q[int(p)-1] != -1 and s == "AC":
        ok += 1
        ng += Q[int(p)-1]
        Q[int(p)-1]= -1
    elif Q[int(p)-1] != -1 and s == "WA":
        Q[int(p)-1] += 1
print(ok,ng)

Solution (Python):
n, m = map(int, input().split())

ac = [False] * n
wa = [0] * n
res_ac = 0
res_wa = 0
for _ in range(m):
    p, s = input().split()
    p = int(p)

    if s == "AC":
        if not ac[p-1]:
            ac[p-1] = True
            res_ac += 1
            res_wa += wa[p-1]
    else:
        wa[p-1] += 1

print(res_ac, res_wa)

Solution (Python):
N,M = map(int,input().split())

ac = 0
wa = 0
acs = [0]*(N+1)
was = [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)

Solution (Python):
N, M = map(int, input().split())
pnt = {}
ac = {}
for i in range(M):
	p,s = input().split()
	p = int(p)
	if not p in pnt:
		pnt[p] = 0
		ac[p] = 0
	if s == "WA" and ac[p] == 0:
		pnt[p] += 1
	elif s == "AC" and ac[p] == 0:
		ac[p] += 1

for i in pnt:
	if pnt[i] != 0 and ac[i] == 0:
		pnt[i] = 0

print(sum(ac.values()),sum(pnt.values()))