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):
dict = {}
N, M = input().split(" ")

ACList = []
WAdict = {}
statusDict = {}
i = 1
while i <= int(M):
    key, ans = input().split(" ")
    if (ans == "AC"):
        ACList.append(key)
        statusDict[str(key)] = "OK"
    elif (ans == "WA" and key not in WAdict and key not in statusDict):
        WAdict[key] = 1
    elif (ans == "WA" and key in WAdict and key not in statusDict):
        WAdict[key] += 1

    i += 1

ACList = set(ACList)

penaList = []
for ACListItem in ACList:
    if (ACListItem in WAdict):
        penaList.append(WAdict[ACListItem])
print(len(set(ACList)), sum(penaList))

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

ac = 0
wa = [0 for _ in range(n)]
notAC = [True for _ in range(n)]

for i in range(m):
    if s[i] == "AC" and notAC[p[i]-1]:
        notAC[p[i]-1] = False
        ac += 1
    elif s[i] == "WA" and notAC[p[i]-1]:
        wa[p[i]-1] += 1

ans_wa = 0
for i in range(n):
    if not notAC[i]:
        ans_wa += wa[i]
print(ac, ans_wa)

Solution (Python):


n,m = list(map(int,input().split()))
a = []
dic = {}

ac = 0
wa = 0

for i in range(m):
    a.append(list(map(str,input().split())))

for i in a:
    if i[1] == "AC" and not(i[0]+i[1] in dic.keys()):
        if i[0] + "WA" in dic.keys():
            wa += int(dic[i[0] + "WA"])
        dic[i[0] + i[1]] = "OK"
        ac += 1
    elif i[1] == "WA" and not(i[0]+"AC" in dic.keys()):
        if i[0] + "WA" in dic.keys():
            dic[i[0] + "WA"] = int(dic[i[0] + "WA"]) + 1
        else:
            dic[i[0] + "WA"] = 1

print(str(ac) + " " + str(wa))

Solution (Python):
N,M=map(int,input().split())
PS=[list(input().split()) for _ in range(M)]
wa=[0]*(N+1)
ac=[0]*(N+1)
ac_cnt=set()
for ps in PS:
    if ps[1]=='AC':
        ac_cnt.add(ps[0])
        ac[int(ps[0])]=1
    if ps[1]=='WA' and ac[int(ps[0])]==0:
        wa[int(ps[0])]+=1
for i in range(1,N+1):
    if str(i) not in ac_cnt:
        wa[i]=0
print(sum(ac),sum(wa))

Solution (Python):
n, m = map(int, input().split(' '))
l = {}
ac = 0
er = 0

for _ in range(m):
  num_prob, state = input().split(' ')
  if (num_prob in l) and (l[num_prob] != -1):
    if state == 'WA':
      l[num_prob] += 1
    else:
      er += l[num_prob]
      l[num_prob] = -1
      ac += 1
  elif num_prob not in l:
    l[num_prob] = 0
    if state == 'WA':
      l[num_prob] += 1
    else:
      er += l[num_prob]
      l[num_prob] = -1
      ac += 1
      
print(ac, er)

Solution (Python):

n, m = map(int, input().split())
l = [[] for _ in range(n)]

for i in range(m):
    a, b = input().split()
    a = int(a) - 1
    l[a].append(b)


ac = 0
wa = 0

for i in range(n):
    if l[i].count('AC') >= 1:
        ac += 1
        for j in range(len(l[i])):
            if l[i][j] == 'AC':
                break
            else:
                wa += 1
    else:
        pass

print(ac, wa)

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



wa_ct = 0
ac_ct = 0
wa_l = [0] * (n+1)
ac_l = [False] * (n+1)

for item in l:
    if ac_l[int(item[0])] == True:
        continue
    else:
        if item[1] == 'WA':
            
            wa_l[int(item[0])] += 1
        else:
            ac_ct += 1
            wa_ct += wa_l[int(item[0])]
            ac_l[int(item[0])] = True


print(ac_ct, wa_ct)

Solution (Python):
from collections import defaultdict
import sys
input = sys.stdin.readline

m = defaultdict(int)
ac = {}

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

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


print("{} {}".format(len(ac.keys()), pena))

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

n, m = [int(i) for i in input().split()]

submits = [0] * m
for i in range(m):
    p, s = input().split()
    submits[i] = (int(p), s.strip())

answer = [0] * (n+1)
for i in range(n):
    answer[i+1] = {'AC':0, 'WA':0}

for submit in submits:
    p, s = submit[0], submit[1]
    if s == 'WA' and answer[p]['AC'] == 0:
        answer[p]['WA'] += 1
        continue
    if s == 'AC':
        answer[p]['AC'] = 1
        continue

ac_num = 0
wa_num = 0
for a in answer[1:]:
    ac_num += a['AC']
    if a['AC'] == 1:
        wa_num += a['WA']
print(ac_num, wa_num)

Solution (Python):
N,M = map(int,input().split())
PS = [list(input().split()) for i in range(M)]
PS = [[int(PS[i][0])-1,PS[i][1]] for i in range(M)]
AC = [0]*N
WA = [0]*N

for i in range(M):
    
    if AC[PS[i][0]] == 0:
        if PS[i][1] == "AC":
            AC[PS[i][0]] = 1
        else:
            WA[PS[i][0]] += 1
        
w = 0
for i in range(N):
    if AC[i] == 1:
        w += WA[i]
print(sum(AC),w)

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

ac = 0
wa = 0

li_2 = []
for i in range(n):
  li_2.append(0)
wa_li = []
for i in range(n):
  wa_li.append(0)
  
for i in range(m):
  s = list(input().split())
  s[0] = int(s[0])
  if li_2[s[0]-1] == 0:
    if s[1] == "AC":
      ac+=1
      wa+= wa_li[s[0]-1]
      li_2[s[0]-1] =1
    else:
      wa_li[s[0]-1]+=1
print(ac,wa)

Solution (Python):
N, M = map(int, input().split())
pS = []
pS_dict = {i:[] for i in range(10**5)}
shutugen = set()
for i in range(M):
    tmp = input().split()
    if tmp[1] == "AC":
        pS_dict[int(tmp[0])].append(1)
    else:
        pS_dict[int(tmp[0])].append(0)
    shutugen.add(int(tmp[0]))
    
seitou = 0
penaru = 0
for i in shutugen:
    seitou_i = 0
    penaru_i = 0
    set_i = pS_dict[i]
    for s in set_i:
        if s == 0:
            penaru_i += 1
        else:
            seitou_i += 1
            break
    if seitou_i == 0:
        continue
    else:
        seitou += seitou_i
        penaru += penaru_i
print(seitou, penaru)

Solution (Python):
n, m = map(int, input().split())
count_wa = 0
count_ac = 0
if m == 0:
    print('0 0')
    exit()
al = [False] * n
wa_list = [0] * n
while True:
    try:
        p, s = map(str, input().split())
        if s == 'AC' and not al[int(p) - 1]:
            count_ac += 1
            al[int(p) - 1] = True
        elif s == 'WA' and not al[int(p) - 1]:
            wa_list[int(p) - 1] = wa_list[int(p) - 1] + 1
    except:
        break
for al_i in range(len(al)):
    if al[al_i]:
        count_wa = count_wa + wa_list[al_i]
print(str(count_ac) + ' ' + str(count_wa))

Solution (Python):
N,M=map(int, input().split())
ansY = [0]*N
ansWA = [0]*N
for i in range(M):
  id,ans = input().split()
  idr = int(id)-1
  if ans=='AC':
    ansY[idr]=1
  elif ans=='WA' and ansY[idr]==0:
    ansWA[idr]+=1
WA = sum([x * y for (x, y) in zip(ansY, ansWA)])
print(sum(ansY),WA)

Solution (Python):
n,m = map(int,input().split())
lis = {}
cs = set()
for i in range(m):
    ps,s = input().split()
    p = int(ps)
    if lis.get(p) == None:
        lis[p] = [0,0]
    if s == "WA":
        if lis[p][0] == 0:
            lis[p][1] += 1
    if s == "AC":
        if lis[p][0] == 0:
            lis[p][0] += 1
            cs.add(p)
pcnt = 0
for i in cs:
    pcnt += lis[i][1]
print(len(cs),pcnt)

Solution (Python):
n, m = map(int, input().split())
p = []
s = []

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


done = []
for i in range(0,n):
    done.append(False)
wa_num = []
for i in range(0,n):
    wa_num.append(0)

ac = 0
for i in range(0, m):
    num = p[i] - 1
    if not done[num]:
        if s[i] == 'WA':
            wa_num[num] += 1
        else: 
            ac += 1
            done[num] = True

wa = 0
for i in range(0,n):
    if done[i]:
        wa += wa_num[i]

print(ac, wa)

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

rs = []
for i in range(m):
    a,s = map(str,input().split())
    r = [int(a),s]
    rs.append(r)


c = 0
d = 0
acs = [0] * n 
was = [0] * n
for i in range(m):
    if rs[i][1] == 'AC':
        acs[rs[i][0] - 1]  += 1
    elif (rs[i][1] == 'WA') & (acs[rs[i][0] - 1] == 0):
        was[rs[i][0] - 1] += 1

for i in range(n):
    if acs[i] != 0:
        c += 1
        d += was[i]

print(("{} {}").format(c,d))

Solution (Python):
N, M = map(int,input().split())
ps = [list(input().split()) for i in range(M)]
wa = 0
ACdict = {}
for i in range(M):
    if ps[i][0] not in ACdict.keys():
        if ps[i][1] == "WA":
            ACdict[ps[i][0]] = 1
        else: ACdict[ps[i][0]] = "AC"
    else:
        if ACdict[ps[i][0]] == "AC":
            continue
        else:
            if ps[i][1] == "WA":
                ACdict[ps[i][0]] += 1
            else: 
                wa += ACdict[ps[i][0]]
                ACdict[ps[i][0]] = "AC"
acs = [k for k, v in ACdict.items() if v == "AC"]
print(len(acs), wa)

Solution (Python):


n ,m = list(map(int, input().split()))
flg = [False] * n
wa = [0] * n
ac = 0
for _ in range(m):
    p, s = input().split()
    p = int(p) -1
    if not flg[p]:
        if s == 'WA':
            wa[p] = wa[p] + 1
        else:
            ac = ac + 1
            flg[p] = True

was = [0] * n
for i in range(n):
    if flg[i]:
        was[i] = wa[i]


print("%d %d" % (ac, sum(was)))

Solution (Python):


import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        
        
        lines.append(input())
        (n, m) = [int(e) for e in lines[0].split(" ")]
        for _ in range(m):
            lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]
        (n, m) = [int(e) for e in lines[0].split(" ")]


    ps = [] 
    for i in range(1, m + 1):
        e = lines[i].split(" ")
        p = int(e[0])
        s = e[1]
        ps.append((p, s))

    return (n, m, ps)


def solve(n, m, ps):

    
    submits = dict()
    
    

    for (p, s) in ps:

        ans_list = submits.get(p, [])
        ans_list.append(s)
        submits[p] = ans_list
    
    total_ac = 0
    total_wa = 0
    for (p, ans_list) in submits.items():

        ac = 0
        wa = 0
        for ans in ans_list:
            if ans == 'WA':
                wa = wa + 1
            elif ans == 'AC':
                ac = ac + 1
                break
        
        if ac == 0:
            wa = 0

        total_ac = total_ac + ac
        total_wa = total_wa + wa
        
        if debug:
            log("p=%d, ac=%d, wa=%d" % (p, ac, wa))
            log("total_ac=%d, total_wa=%d" % (total_ac, total_wa))

    result = [total_ac, total_wa] 

    return result


def main():
    
    result = solve(*parse_input())
    if isinstance(result, list):
        print("%d %d" % (result[0], result[1]))
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()

Solution (Python):
n, m = map(int, input().split())
ps = [input().split() for _ in range(m)]
all_ac = set(int(p) for p,s in ps if s=='AC')
ac = set()
pena_cnt = 0
ac_cnt = 0
for p,s in ps:
  p = int(p)
  if p in all_ac:
    if p not in ac:
      if s == 'WA':
        pena_cnt += 1
      else:
        ac_cnt += 1
        ac.add(p)
print(ac_cnt, pena_cnt)

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

for i in range(M):
	S = list(input().split())
	
	num = int(S[0])
	res = S[1]
	if res == "AC":
		seitou[num - 1] = 1
	else:
		if seitou[num - 1] == 0:
			penalty[num - 1] += 1
			


print(sum(seitou), end=" ")

ans = 0

for i in range(N):
	if seitou[i] == 1:
		ans += penalty[i]
print(ans)

Solution (Python):
from collections import defaultdict

n, m = list(map(int, input().split()))

submissions = []
for _ in range(m):
    num, result = input().split()
    submissions.append((int(num), result))

score = defaultdict(lambda: {"passed": False, "wa": 0})

for p, s in submissions:
    if score[p]["passed"]:
        pass
    elif s == "AC":
        score[p]["passed"] = True
    elif s == "WA":
        score[p]["wa"] += 1

ans = 0
pena = 0



for v in score.values():
    if v["passed"]:
        ans += 1
        pena += v["wa"]

print(ans, pena)

Solution (Python):
N, M = [int(x) for x in input().split()]
p = []; S = []
for _ in range(M):
    p_tmp, S_tmp = input().split()
    p.append(int(p_tmp))
    S.append(str(S_tmp))

AC = [0] * N
WA = [0] * N
for i in range(M):
    if AC[p[i] - 1] == 1:
        continue
    if S[i] == 'AC':
        AC[p[i] - 1] = 1
    else:
        WA[p[i] - 1] += 1
for i in range(N):
    if AC[i] == 0:
        WA[i] = 0
AC_count = sum(AC)
WA_count = sum(WA)
print(AC_count, WA_count)

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

ac_list = [False] * (N + 1)
ac_count = 0
penalty = [0] * (N + 1)

for i in range(M):
    problem, status = input().split()
    problem = int(problem)

    if status == "AC":
        if not ac_list[problem]:
            ac_count += 1
        ac_list[problem] = True
        continue

    if status == "WA" and not ac_list[problem]:
        penalty[problem] += 1

point = 0
for i, p in enumerate(penalty):
    if ac_list[i]:
        point += p

print(ac_count, point)

Solution (Python):
n, m = map(int, input().split())
a = {}
for i in range(m):
    p, s = input().split()
    if p not in a:
        a[p] = {'flag':False, 'wa':0}
    if s == 'AC':
        a[p]['flag'] = True
    elif not a[p]['flag']:
        a[p]['wa'] += 1

ac, wa = 0,0
for k, i in a.items():
    if i['flag']:
        ac += 1
        wa += i['wa']
print(ac, wa)

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

AC = [0] * (N + 1)
WA = [0] * (N + 1)

for _ in range(M):
    pS = input().split()
    n = int(pS[0])
    
    if pS[1] == 'AC':
        AC[n] = 1
    elif (pS[1] == 'WA') & (AC[n] == 0):
        WA[n] += 1
        

correct = len([i for i in AC if i > 0])


penalty = sum([x * y for (x, y) in zip(AC, WA)])

print(correct, penalty)

Solution (Python):
n, m = map(int, input().split())
sub = [list(input().split()) for j in range(m)]
li = [[0 for i in range(n)]for j in range(2)]
for i in range(m):
    x = int(sub[i][0])-1
    if sub[i][1] == 'AC':
        if li[0][x] == 0:
            li[0][x] += 1
    elif li[0][x] == 0:
        li[1][x] += 1
    else:
        next

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

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

Solution (Python):
N, M = map(int, input().split())
res=[]
sto, WAsto=[],[]
for i in range(M):
    res.append([x for x in input().split()])
for i in range(N):
    sto.append(0)
    WAsto.append(0)




for i in range(M):
    if res[i][1]=="AC" and sto[int(res[i][0])-1]!=-1:
        WAsto[int(res[i][0])-1]=sto[int(res[i][0])-1]
        sto[int(res[i][0])-1]=-1 
    elif sto[int(res[i][0])-1]!=-1:
        sto[int(res[i][0])-1]+=1        




WA=sum(WAsto)

AC=sto.count(-1)

print(AC,WA)

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

dp = [0 for _ in range(n+1)]

def ans(dp, n, m) -> list:
    if m == 0:
        return [0, 0]

    ac = 0
    wa = 0
    i = 0
    while i < m:
        q, r = input().split()
        q = int(q)

        if dp[q] == None:
            pass
        elif r == 'WA':
            dp[q] += 1
        elif r == 'AC':
            ac += 1
            wa += dp[q]
            dp[q] = None

        i += 1

    return [ac, wa]

a = ans(dp, n, m)

print(*a)

Solution (Python):

N, M = map(int, input().split())
ANS = [0 for i in range(N)]
PNL = [0 for i in range(N)]
p = [0 for i in range(M)]
S = ['' for i in range(M)]
for i in range(M):
    l = input().split()
    p[i] = int(l[0])
    S[i] = str(l[1])
for i in range(M):
    if ANS[p[i]-1] == 0:
        if S[i] == 'AC':
            ANS[p[i]-1] = 1
        else:
            PNL[p[i]-1] = PNL[p[i]-1] + 1
ans = 0
pnl = 0
for i in range(N):
    if ANS[i] == 1:
        ans = ans + 1
        pnl = pnl + PNL[i]
print(ans, pnl)

Solution (Python):
n,m = map(int, input().split())
ac=0
wa=0
pp=set()
d={}
for i in range(0,m):
    p,s = input().split()
    if p in pp:
        continue
    if s == 'AC':
        pp.add(p)
        ac=ac+1
        wa = wa+d.get(p, 0)
    if p in d.keys():
        d[p] = d[p] + 1
    else:
        d[p]=1
print(ac, wa)

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

N=int(N)
M=int(M)

Ps=[]
Ss=[]

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


cleared=[0]*(N+1)

AC_n=0
WA_n=0

for i in range(M):

    if Ss[i]=="WA":
        if not cleared[Ps[i]]==1:
            cleared[Ps[i]]-=1

    if Ss[i]=="AC":
        if cleared[Ps[i]]<=0:
            AC_n+=1
            WA_n-=cleared[Ps[i]]
            cleared[Ps[i]]=1

print(AC_n,WA_n)

Solution (Python):
n,m=map(int,input().split())
D={}
for i in range(m):
    p,s=input().split()
    if p not in D:
        if s=="AC":
            D[p]=[["AC",1],["WA",0]]
        else:
            D[p]=[["AC",0],["WA",1]]
    else:
        if D[p][0][1]==1:
            continue
        else:
            if s=="AC":
                D[p][0][1]+=1
            else:
                D[p][1][1]+=1
AC,WA=0,0
for i in D:
    if D[i][0][1]==1:
        AC+=1
        WA+=D[i][1][1]

print(AC,WA)

Solution (Python):
import sys
n, m = map(int, sys.stdin.readline().split())
a=[sys.stdin.readline().split() for i in range(m)]
wa = [0 for i in range(n)]
ac = [0 for i in range(n)]

for i in range(m):
    p = int(a[i][0])-1
    s = a[i][1]
    if s=="WA" and ac[p]==0:
        wa[p] +=1
        
    elif s=="AC":
        ac[p] = 1
        

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

Solution (Python):
n, m = map(int, input().split())
ac = 0
wa = [0 for i in range(n + 1)]
al = [0 for i in range(n + 1)]
if m == 0:
  k = [0, 0]
  print(*k)
  exit()
for i in range(m):
  k = list(input().split())
  a = int(k[0])
  if al[a] == 1:
    continue
  elif al[a] == 0 and k[1] == "WA":
    wa[a] += 1
  elif al[a] == 0 and k[1] == "AC":
    ac += 1
    al[a] = 1
wan = 0
for i in range(n+1):
  if al[i] == 1:
    wan += wa[i]
lis = [ac, wan]
print(*lis)

Solution (Python):
import sys

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

L = []

d = {}

for _ in range(M):
    P,S = input().split()
    P = int(P)
    L.append([P,S])

for i in range(M):
    p,s = L[i]
    if p in d:
        if s=="AC" and d[p]["AC"]==0:
            d[p]["AC"] = 1
        elif s=="WA" and d[p]["AC"]==0:
            d[p]["WA"] = d[p]["WA"] + 1
    else:
        d[p] = {}
        d[p]["AC"] = 0
        d[p]["WA"] = 0
        if s=="AC":
            d[p]["AC"] = 1
        else:
            d[p]["WA"] = 1

ac_count = 0
wa_count = 0

for i in range(1,N+1,1):
    if not (i in d):
        continue    
    ac_count = ac_count + d[i]["AC"]
    if d[i]["AC"]!=0:
        wa_count = wa_count + d[i]["WA"]

print(ac_count, wa_count)

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

N=int(N)
M=int(M)

Ps=[]
Ss=[]

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


cleared=[0]*(N+1)

AC_n=0
WA_n=0

for i in range(M):

    if Ss[i]=="WA":
        if not cleared[Ps[i]]==1:
            cleared[Ps[i]]-=1

    if Ss[i]=="AC":
        if cleared[Ps[i]]<=0:
            AC_n+=1
            WA_n-=cleared[Ps[i]]
            cleared[Ps[i]]=1

print(AC_n,WA_n)

Solution (Python):


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


answer_dict = {}


class AnswerState:
    
    def __init__(self):
        self.wrong_num = 0         
        self.is_corrected = False 
    
    def submit(self, is_correct):
        
        if not is_correct and not self.is_corrected:
            self.wrong_num += 1
        
        if is_correct:
            self.is_corrected = True

for _ in range(M):
    tmp = input().split()
    p_index = int(tmp[0])
    p_result = tmp[1]
    
    if not p_index in answer_dict:
        answer_dict[p_index] = AnswerState()
    
    answer_dict[p_index].submit(p_result == 'AC')


correct_num = 0
penalty_num = 0

for state in answer_dict.values():
    if state.is_corrected:
        correct_num += 1
        penalty_num += state.wrong_num

print('%d %d' % (correct_num, penalty_num))

Solution (Python):
n,m=map(int,input().split())
counter = {}
for i in range(n):
  counter[i] = [0,0]

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

crt = 0
pen = 0
for i in range(n):
  if counter[i][1] == 1:
    crt+=1
    pen+=counter[i][0]

print(crt,pen)

Solution (Python):
N, M = map(int, input().split())
p = [0] * M
S = [0] * M
count_AC = [0] * N
count_WA = [0] * N
for i in range(M):
    p[i],S[i] =  input().split()
    p[i] = int(p[i]) - 1

    if S[i] == 'AC':
        if count_AC[p[i]] == 0:
            count_AC[p[i]] = 1
            
    if S[i] == 'WA':
        if count_AC[p[i]] == 0:
            count_WA[p[i]] = count_WA[p[i]] + 1
            
print(sum(count_AC) , sum([x * y for (x, y) in zip(count_AC, count_WA)]))

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

li = ['WA'] * n
countwa = [0] * n
ac = 0
wa = 0

for p,s in ps:
    if s == 'AC':
        if li[int(p)-1] == 'WA':
            li[int(p)-1] = 'AC'
            ac += 1
    else:
        if li[int(p)-1] == 'WA':
            countwa[int(p)-1] += 1

ac = li.count('AC')
for i in range(n):
    if li[i] == 'AC':
        wa += countwa[i]

print(ac, wa)

Solution (Python):
from sys import stdin
N, M = [int(i) for i in stdin.readline().rstrip().split()]
ans_list = []
for m in range(M):
    ans_list.append([i for i in stdin.readline().rstrip().split()])
ac = 0
wa = 0
result_dict = {}
wa_count = {}
for n in range(1, N + 1):
    result_dict[n] = False
    wa_count[n] = 0
for q, r in ans_list:
    q_now = int(q)
    if result_dict[q_now] == False:
        if r == "WA":
            wa += 1
            wa_count[q_now] += 1
        if r == "AC":
            ac += 1
            result_dict[q_now] = True
for n in range(1, N + 1):
    if result_dict[n] == False:
        wa -= wa_count[n]
print(ac, wa)

Solution (Python):
N, M = map(int, input().split())
l = []
ansewered_question = set()
submit_for = {}

for i in range(M):
  a = input().split()
  l.append([int(a[0]), a[1]])
  ansewered_question.add(int(a[0]))
for submition in l:
    if submition[0] in submit_for:
        submit_for[submition[0]].append(submition[1])
    else:
        submit_for[submition[0]] = [submition[1]]
AC = 0
WA = 0
for i in ansewered_question:
    wa = 0
    for submit in submit_for[i]:
      if submit == "WA":
        wa += 1
      else:
          AC += 1
          WA += wa
          break
print(AC, WA)

Solution (Python):
n, m = map(int, input().split())
p_s = list(input().split() for _ in range(m))

is_ac = [0] * n
ac_cnt = 0
wa_cnt_lst = [0] * n
for i in range(m):
    p_s[i][0] = int(p_s[i][0])
    if p_s[i][1] == 'AC' and is_ac[p_s[i][0] - 1] == 0:
        ac_cnt += 1
        is_ac[p_s[i][0] - 1] += 1
    if p_s[i][1] == 'WA' and is_ac[p_s[i][0] - 1] == 0:
        wa_cnt_lst[p_s[i][0] - 1] += 1

wa_cnt = 0
for i in range(n):
    if is_ac[i] > 0:
        wa_cnt += wa_cnt_lst[i]

print(ac_cnt, end = " ")
print(wa_cnt)

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

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

for i in range(m):
  a,b=input().split()
  a=int(a)
  if ac[a] ==0:
    if b=="WA":
      wa[a]+=1
    else:
      ac[a]+=1
wcon=0
accon=0
for i in range(n+1):
  if ac[i]>0:
    accon+=1
    wcon+=wa[i]
print(accon,wcon)

Solution (Python):
N, M = [int(x) for x in input().split()]


correct = 0
penalty = {i: 0 for i in range(1, N+1)}
final = 0

ans = set([])

for _ in range(M):
    p, S = input().split()
    p = int(p)
    if p in ans:
        continue
    elif S == 'WA':
        penalty[p] += 1
    else:
        correct += 1
        ans.add(p)
for i in range(1, N+1):
    if i in ans:
        final += penalty[i]

print(correct, final)

Solution (Python):

n, m = [int(x) for x in input().split(" ")]
ans = 0
pens = 0
prbstate = {}
fins = {}
A = []
for i in range(m):
    A.append(input().split(" "))
for a in A:
    if a[1] == "AC":
        fins.setdefault(a[0], 1)
for x in fins.values():
    ans += x
for i in range(m):
    p, s = A[i]
    prbstate.setdefault(p, 0)
    fins.setdefault(p, 0)
    if s == "AC":
        prbstate[p] += 1
    if s == "WA" and prbstate[p] < 1 and fins[p] == 1:
        pens += 1
print(ans, pens)

Solution (Python):
n,m = map(int,input().split())
d = {}
for i in range(m):
  p,s = input().split()
  if p not in d:
    d[p] = [s]
  else:
    d[p].append(s)

wa_c = 0
ac_c = 0
for k in d.keys():
  target = d[k]
  if target.count("AC") != 0:
    ind = d[k].index("AC")
    ac_c += 1
    wa_c += target[:ind].count("WA")
print(ac_c,wa_c)

Solution (Python):
NM = list(map(int, input().split()))

sumi = set()

correct = 0
penalty = 0

dic = dict()

for i in range(NM[1]):
    s = input().split()
    if (s[0] in sumi):
        continue
    else:
        if (s[1] == "WA"):
            if (s[0] in dic.keys()):
                dic[s[0]] = dic[s[0]] + 1
            else:
                dic[s[0]] = 1
        else:
            correct += 1
            sumi.add(s[0])

for i in sumi:
    if (i in dic.keys()):
        penalty += dic[i]

print(correct,penalty)

Solution (Python):
N,M = map(int,input().split())
check = [0]*(N+3)
fail = [0]*(N+3)

wa=0
cnt=0
for i in range(M):
    pi,si=input().split()
    pi = int(pi)
    if si=='AC':
        if check[pi]==0:
            check[pi]=1
    else:
        if check[pi]==0:
            fail[pi]+=1
fa=0
for ans, fail in zip(check, fail):
    if ans>0:
        fa += fail
print(sum(check), fa)

Solution (Python):
input1 = input().split()
N = int(input1[0])
M = int(input1[1])
SUBMIT = []


for i in range(M):
    input2 = list(input().split())
    SUBMIT.append(input2)


CHECK = []

for i in range(N):
    CHECK.append([i+1,0,"yet"])


for i in range(M):
    if SUBMIT[i][1] == "WA":
        if CHECK[int(SUBMIT[i][0]) - 1][2] == "yet":
            CHECK[int(SUBMIT[i][0]) - 1][1] += 1
    else:
        CHECK[int(SUBMIT[i][0]) - 1][2] = "done"
    
result_1 = 0
result_2 = 0

for i in range(N):
    if CHECK[i][2] == "done":
        result_2 += 1
        result_1 += CHECK[i][1]
        
print(result_2,result_1)

Solution (Python):
N, M = map(int, input().split())
p = []
S = []
for i in range(M):
	p_, S_ = input().split()
	p.append(int(p_))
	S.append(S_)

uni_p = list(set(p))
AC_numbers = {key:0 for key in uni_p}
WA_numbers = {key:0 for key in uni_p}

for num, res in zip(p, S):
	if res == "WA":
		if AC_numbers[num] != 1:
			WA_numbers[num] += 1

	else:
		AC_numbers[num] = 1

ac = 0
wa = 0
for i in uni_p:
	ac += AC_numbers[i]
	if AC_numbers[i] == 1:
		wa += WA_numbers[i]
	
print(ac, wa)

Solution (Python):
N, M = map(int, input().split())
AC_list = set()
WA_list = {}
WA = 0
AC = 0
for i in range(M):
    p, S = map(str, input().split())
    p = int(p)

    if S == "AC":
        if p in AC_list:
            continue
        else:
            AC += 1
            AC_list.add(p)
    elif S == "WA":
        if p not in AC_list:
            if p not in WA_list:
                WA_list[p] = 1
            else:
                WA_list[p] += 1
        else:
            continue

for key, val in WA_list.items():
    if key in AC_list:
        WA += val
    else:
        continue

print(AC, WA)

Solution (Python):
import math
import itertools
import fractions
import heapq
import collections
import bisect
import sys

sys.setrecursionlimit(10**9)
mod = 998244353
inf = 10**20

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

n,m = LI()

l = [False]*n
c = [0]*n
ans=0
for i in range(m):
    p,s = LS()
    if s=="AC":
        l[int(p)-1]=True

    else:
        if l[int(p)-1]==False:
            c[int(p)-1]+=1

for i in range(n):
    if l[i]:
        ans+=c[i]

print(l.count(True),ans)

Solution (Python):
n,m=map(int, input().split())
al=[]
for i in range(m):
    a=list(map(str, input().split()))
    al.append(a)
l_all=[[] for i in range(n)]
for i in range(m):
    l_all[int(al[i][0])-1].append(al[i][1])
ac=0
pn=0
for j in range(n):
    if l_all[j].count('AC')!=0:
        pn+=l_all[j].index('AC')
        ac+=1
print('{} {}'.format(ac,pn))

Solution (Python):
N, M = map(int, input().split())
p = [0] * M
s = [0] * M
for i in range(M):
    p[i], s[i] = map(str, input().split())
    p[i] = int(p[i])

'''
a = [0] * M
for i in range(M):
    a[i] = [p[i],s[i]]
'''
maru = [0] * (N+1)
batu = [0] * (N+1)

for i in range(M):
    if s[i] == "AC" and maru[p[i]] == 0:
        maru[p[i]] += 1 
    elif s[i] == "AC" and maru[p[i]] != 0:
        continue
    elif s[i] == "WA" and maru[p[i]] != 0:
        continue
    elif s[i] == "WA" and maru[p[i]] == 0:
        batu[p[i]] += 1

batu_ans = 0
for i in range(1, N+1):
    if maru[i] != 0:
        batu_ans += batu[i]

print(sum(maru), batu_ans)

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

ps = sorted(ps, key=lambda x: x[0])

flag = 0
wa = {}
AC_count = 0
WA_count = 0
for i in range(m):
    if ps[i][0] != flag:
        if ps[i][1] == 'AC':
            AC_count += 1
            if ps[i][0] in wa.keys():
                WA_count += wa[ps[i][0]]
            flag = ps[i][0]
        else:
            if ps[i][0] in wa.keys():
                wa[ps[i][0]] += 1
            else:
                wa[ps[i][0]] = 1
print(AC_count, WA_count)