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):
n,m=map(int,input().split())
dicts = {key: [False,0] for key in range(1, n+1)}
for i in range(m):
    p, s = input().split()
    p = int(p)
    if s == "AC":
        dicts[p][0] = True
        continue
    else:
        if dicts[p][0]==True:
            continue
        else:
            dicts[p][1] += 1
ans_list = [v[1] for k, v in dicts.items() if v[0]==True]
ans_n = len(ans_list)
penal = sum(ans_list)
print(ans_n,penal)

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

AC, WA = [0] * n, [0] * n

ac, wa = 'AC', 'WA'

for i in range(m):
    if L[i][1] == ac and AC[int(L[i][0]) - 1] == 0:
        AC[int(L[i][0]) - 1] = 1
    elif L[i][1] == wa and AC[int(L[i][0]) - 1] == 0:
        WA[int(L[i][0]) - 1] += 1
sum_ac, sum_wa = 0, 0
for i in range(n):
    sum_ac += AC[i]
    if AC[i] > 0:
        sum_wa += WA[i]
print(sum_ac, end = ' ')
print(sum_wa)

Solution (Python):
n, m = map(int, input().split())
dicts = {key: [False,0] for key in range(1, n+1)}

for i in range(m):
    p, s = input().split()
    p = int(p)
    if s == "AC":
        dicts[p][0] = True
        continue
    else:
        if dicts[p][0]==True:
            continue
        else:
            dicts[p][1] += 1
        
ans_list = [v[1] for k, v in dicts.items() if v[0]==True]
ans_n = len(ans_list)
penal = sum(ans_list)
print(ans_n, penal)

Solution (Python):
import sys
from io import StringIO
import unittest


def resolve():
    N, M = [int(i) for i in input().split()]
    pp = []
    SS = []
    for _ in range(M):
        p, s = [i for i in input().split()]
        pp.append(int(p))
        SS.append(s)
    AC = 0
    WA = 0
    WAtmp = {}
    flgs = [False] * N
    for i in range(M):
        if not flgs[pp[i] - 1]:
            if SS[i] == "AC":
                AC += 1
                flgs[pp[i] - 1] = True
                if pp[i] - 1 in WAtmp.keys():
                    WA += WAtmp[pp[i] - 1]
            else:
                if pp[i] - 1 in WAtmp.keys():
                    WAtmp[pp[i] - 1] += 1
                else:
                    WAtmp[pp[i] - 1] = 1

    print(AC, WA)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2 5
1 WA
1 AC
2 WA
2 AC
2 WA"""
        output = """2 2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """100000 3
7777 AC
7777 AC
7777 AC"""
        output = """1 0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """6 0"""
        output = """0 0"""
        self.assertIO(input, output)

    def test_入力例_n(self):
        input = """3 5
1 WA
1 AC
2 WA
2 AC
3 WA"""
        output = """2 2"""
        self.assertIO(input, output)


if __name__ == "__main__":
    
    resolve()

Solution (Python):
n,m = map(int,input().split())
p_s = [input().split() for _ in range(m)]
problem = [0]*n
pena = [0]*n
penalty = 0
for i in range(m):
    if p_s[i][1] == 'WA':
        if problem[int(p_s[i][0])-1] == 0:
            pena[int(p_s[i][0])-1] += 1
    elif p_s[i][1] == 'AC':
        problem[int(p_s[i][0])-1] = 1
        penalty += pena[int(p_s[i][0])-1]
        pena[int(p_s[i][0])-1] = 0
print(sum(problem), penalty)

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

ac_list=[]
ac_flags=[False]*n
wa_count=[0]*n
penalty = 0

for i in range(m):
    pi,si=input().split()
    pi=int(pi)
    if si=='AC':
        if ac_flags[pi-1]==False:
            ac_list.append(pi-1)
            penalty += wa_count[pi-1]
            ac_flags[pi-1]=True
    else:
        wa_count[pi-1]+=1

print(len(ac_list),penalty)

Solution (Python):
import collections

N, M = map(int, input().split())
ac = 0
wa = 0
aced = set()
dic = collections.defaultdict(lambda:0)
for _ in range(M):
  p, s = input().split()
  if s == 'WA' and p not in aced:
    dic[p] += 1
  elif s == 'AC' and p not in aced:
    aced.add(p)
    ac += 1
    if p in dic:
      wa += dic[p]

print(ac, wa)

Solution (Python):
n,m= list(map(int, input().split()))
ans_box=[0]*n
wa=[0]*n
ac=0
wa_cnt=0
for j in range(m):
    k,l=input().split()
    h=int(k)-1
    if ans_box[h]==0:
        if l=="AC":
            ac+=1
            ans_box[h]+=1
            wa_cnt+=wa[h]
        else:
            wa[h]+=1
print(ac,wa_cnt)

Solution (Python):
n, m = map(int, input().split())
d = {}
cnt_ac = 0
cnt_wa = 0
for _ in range(m):
    p, s = input().split()
    if p not in d:
        d[p] = [s]
    else:
        d[p].append(s)
for i in d:
    if 'AC' in d[i]:
        cnt_ac += 1
        cnt_wa += d[i].index('AC')
print(cnt_ac, cnt_wa)

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

AC_count = 0
WA_count = 0
WA_count_dict = {}
is_not_AC = {}

for m in range(M):
    p, S = input().split()
    p = int(p)
    
    if p not in is_not_AC.keys():
        is_not_AC[p] = True
        WA_count_dict[p] = 0
        
    if is_not_AC[p]:
        if S=="WA":
            WA_count_dict[p] += 1
        else:
            AC_count += 1
            is_not_AC[p] = False
            
for k in is_not_AC.keys():
    if is_not_AC[k] == False:
        WA_count += WA_count_dict[k]

print(AC_count, WA_count)

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

ns = lambda:stdin.readline().rstrip()
ni = lambda:int(stdin.readline().rstrip())
nm = lambda:map(int,stdin.readline().split())
nl = lambda:list(map(int,stdin.readline().split()))

N,M=nm()
Al=[0]*N
Wl=[0]*N
ac=0
wa=0
for i in range(M):
    tmp1,tmp2=map(str,stdin.readline().split())
    p=int(tmp1)-1
    s=tmp2
    if(s=='AC'):
        Al[p]+=1
        if(Al[p]==1):
            ac+=1
            wa+=Wl[p]
    else:
        Wl[p]+=1

ans=[ac,wa]
print(*ans)

Solution (Python):
n, m = map(int, input().split())
hist = [0]*n
pena = 0
collect = 0
for i in range(m):
    p, s = input().split()
    p = int(p)
    p -= 1
    if hist[p] != -1 and s == "WA":
        hist[p] += 1
    if hist[p] != -1 and s == "AC":
        pena += hist[p]
        hist[p] = -1

print(hist.count(-1),pena)

Solution (Python):
n, m = map(int,input().split())
p = []
s = []
for _ in range(m):
    temp = input().split()
    p.append(int(temp[0]))
    s.append(temp[1])

ac = 0
pena = [0]*n
flag = [False]*n

for pe, se in zip(p, s):
    if se == "AC":
        flag[pe-1] = True
    else:
        if flag[pe-1] is False:
            pena[pe-1] += 1

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

print(ac, psum)

Solution (Python):


N,M = map(int, input().split())
List = [list(input().split()) for i in range(M)]

ACList=[0]*N
WAList=[0]*N

i=0
while i<M:
    if List[i][1]=="AC":
        ACList[int(List[i][0])-1]=1
    if List[i][1]=="WA" and ACList[int(List[i][0])-1]==0:
        WAList[int(List[i][0])-1]+=1
    i+=1

j=0
while j<len(WAList):
    if ACList[j]!=1 and WAList[j]!=0:
        WAList[j]=0
    j+=1

print(sum(ACList),sum(WAList))

Solution (Python):
import numpy as np
N, M = map(int, input().split())
AC = np.array([0]*N)
WA = np.array([0]*N)

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

print(sum(AC), sum(AC*WA))

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

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

ac_F = [False] * (n + 1)
acc = 0
pena = [0] * (n+1)

for i in range(m):
    if sl[i] == "AC":
        if not ac_F[pl[i]]:
            acc += 1
            ac_F[pl[i]] = True
    else:
        if not ac_F[pl[i]]:
            pena[pl[i]] += 1

penac = 0
for i in range(n+1):
    if ac_F[i]:
        penac += pena[i]

print(acc, penac)

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

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

for i in range(m):
    if ps[i][1]=='WA' and ac[int(ps[i][0])-1]==0:
        wa[int(ps[i][0])-1]+=1
    else:
        if ac[int(ps[i][0])-1]==0:
            ac[int(ps[i][0])-1]+=1
        else:
            pass

ac_num=0
wa_num=0

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

print(ac_num,wa_num)

Solution (Python):

n,m=map(int,input().split())
ps=[list(input().split()) for i in range(m)]
pen=[0]*n
rig=[0]*n

for i in range(m):
    if ps[i][1]=="AC":
        rig[int(ps[i][0])-1]=1
    else:
        if rig[int(ps[i][0])-1]==0:
            pen[int(ps[i][0])-1]+=1
cnt1,cnt2=0,0
for i in range(n):
    if rig[i]==1:
        cnt1+=rig[i]
        cnt2+=pen[i]

print(str(cnt1)+" "+str(cnt2))

Solution (Python):
n, m = list(map(int, input().split()))
S = [input().split() for _ in range(m)]
S = [[int(s[0]), s[1]] for s in S]
ac = [0] * n
wa = [0] * n
for s in S:
    if s[1] == 'AC':
        ac[s[0] - 1] = 1
        continue
    elif ac[s[0] - 1] == 0:
        wa[s[0] - 1] += 1
        continue
wa = [0 if ac[i] == 0 else wa[i] for i in range(n)]
ans = ' '.join(list(map(str, [sum(ac), sum(wa)])))
print(ans)

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

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

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

print(sum(AC), sum(WA))

Solution (Python):

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


AC_questions = {}
for i in range(M):
    P, S = map(str, input().split())

    if P not in AC_questions:
        AC_questions[P] = {
            "wa_cnt": 0,
            "ac": False
        }

    if AC_questions[P]["ac"] is True:
        continue
    elif S == "AC":
        AC_questions[P]["ac"] = True
    
    else:
        AC_questions[P]["wa_cnt"] += 1



target_keys = [key for key in AC_questions.keys() if AC_questions[key]['ac'] is True]
AC_cnt = sum([1 for key in target_keys])
WA_cnt = sum([AC_questions[key]["wa_cnt"] for key in target_keys])

print(AC_cnt, WA_cnt)

Solution (Python):

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


AC_questions = {}
for i in range(M):
    P, S = map(str, input().split())

    if P not in AC_questions:
        AC_questions[P] = {
            "wa_cnt": 0,
            "ac": False
        }

    if AC_questions[P]["ac"] is True:
        continue
    elif S == "AC":
        AC_questions[P]["ac"] = True
    
    else:
        AC_questions[P]["wa_cnt"] += 1

AC_cnt = sum([1 for key in AC_questions.keys() if AC_questions[key]['ac'] is True])
WA_cnt = sum([AC_questions[key]["wa_cnt"] for key in AC_questions.keys() if AC_questions[key]["ac"] is True])

print(AC_cnt, WA_cnt)

Solution (Python):
import numpy as np

def solve():
    dp = np.zeros((2, N+1))

    ac = 0
    wa = 0
    for i in range(M): 
        if (dp[0][S[i][0]] == 0):
            if(S[i][1] == "WA"):
                dp[1][S[i][0]] += 1
            elif(S[i][1] == "AC"):
                ac += 1
                dp[0][S[i][0]] = 1
                wa += dp[1][S[i][0]]
    print(ac, int(wa))

if __name__=="__main__":

    N, M = list(map(int, input().split()))
    S = []
    for i in range(M):
        a,b = input().split()
        S.append([int(a), b])

    
    solve()

Solution (Python):
N, M = map(int, input().split())
correct = [False] * N
penalty = [0] * N

sum_AC, sum_WA = 0, 0
for i in range(M):
    p, s = input().split()
    p = int(p) - 1
    if correct[p]:
        continue
    if s == "AC":
        correct[p] = True
        sum_AC += 1
        sum_WA += penalty[p]
    else:
        penalty[p] += 1

print(sum_AC, sum_WA)

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

for i in range(m):
    h[i][0] = int(h[i][0])
l=set()
penalty = 0
import numpy as np
p = np.zeros(n)
for i in range(m):
    if h[i][0] not in l:
        if h[i][1] == 'AC':
            l.add(h[i][0])
            penalty += p[h[i][0]-1]
        else:
            p[h[i][0]-1] += 1
ansnum = len(l)




print(ansnum,int(penalty))

Solution (Python):
n,m=map(int,input().split())
acset=set()
finacset=set()
penalty=0
pslist=[]

for i in range(m):
	p,s=input().split()
	p=int(p)
	pslist.append([p,s])
	
	if s == "AC":
		finacset.add(p)

for ps in pslist:
	p=ps[0]
	s=ps[1]
	
	if s == "AC":
		acset.add(p)
	else:
		if p in finacset and not p in acset:
			penalty += 1

output=[str(len(acset))," ",str(penalty)]
print("".join(output))

Solution (Python):
N, M = map(int, input().split())
ps = [input().split() for _ in range(M)]
passed = [0]*(N+1)
cnt = [0]*(N+1)
ac_num = 0
wa_num = 0

for p, s in ps:
  p = int(p)
  if s == "WA":
    cnt[p] += 1
  elif s == "AC" and passed[p] == 0:
    wa_num += cnt[p]
    ac_num += 1
    passed[p] = 1

print(ac_num, wa_num)

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

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

for p, s in ps:
    i = int(p)
    if s == "WA":
        if ac[i] != 1:
            wa[i] += 1
    else:
        if ac[i] != 1:
            ac[i] = 1

print(sum(ac), sum(wa[i] * ac[i] for i in range(n + 1)))

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

Solution (Python):
n,m = map(int,input().split())
pS_list = [list(input().split()) 
           for nesya in range(m)]
ac = 0
wa = 0
q_list = [0]*n
for ps in pS_list:
  p = int(ps[0])-1
  s = ps[1]
  if q_list[p] == 1:
    continue
  if s == 'WA':
    q_list[p] -= 1
  else:
    a = q_list[p]
    wa -= a
    ac += 1
    q_list[p] = 1
print(ac,wa)

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

    N, M = map(int, input().split())
    pS = [list(input().split()) for i in range(M)]

    was = [0]*N
    acs = [0]*N

    for p, s in pS:
        q_ind = int(p)-1
        if acs[q_ind] == 0:
            if s == 'AC':
                acs[q_ind] = 1
            else:
                was[q_ind] += 1
    ans_wa = 0
    for i in range(N):
        if acs[i] != 0:
            ans_wa += was[i]

    print(sum(acs), ans_wa)


if __name__ == "__main__":
    main()

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

AC = [0] * N
WA = [0] * N
wa = 0
ac = 0
for i in range(M):
    p,S = input().split()
    if S == 'AC':
        if AC[int(p)-1] == 0:
            ac += 1
            AC[int(p)-1] += 1
    elif AC[int(p)-1] == 0:
        WA[int(p)-1] += 1

for i in range(N):
    if AC[i] > 0:
        wa += WA[i]

print(str(ac) + ' ' + str(wa))

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




















from collections import defaultdict
d = defaultdict(list)
for _ in range(M):
    p, S = input().split()
    d[int(p)].append(S)


for p, results in d.items():
    is_ac = 'AC' in results
    if not is_ac:
        d[p] = (False, 0)
    else:
        d[p] = (True, results.index('AC'))

cnt = 0
penas = 0
for ac, pena in d.values():
    if ac == True:
        cnt += 1
    penas += pena
print(cnt, penas)

Solution (Python):
N,M=list(map(int,input().split()))
S=[list(map(str,input().split())) for i in range(M)]
D={}
D2={}
D3={}
for i in S:
    if D.get(i[0],0)!='AC':
        D[i[0]]=i[1] 
        D2[(i[0],i[1])]=D2.get((i[0],i[1]),0)+1
ans=[0,0]
for i in D.items():
    if i[1]=='AC':
        ans[1]+=D2.get((i[0],'WA'),0)
        ans[0]+=D2.get((i[0],'AC'),0)

print(*ans)

Solution (Python):
n,m=map(int,input().split())
l=[]
for _ in range(n):l.append(0)
wa=0
for i in range(m):
    p,s=map(str,input().split())
    if l[int(p)-1]==-1:continue
    elif s=="AC":
        wa+=l[int(p)-1]
        l[int(p)-1]=-1
    else: l[int(p)-1]+=1
print(l.count(-1),wa)

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

Solution (Python):
il1 = [int(k) for k in input().split()]
N = il1[0]
M = il1[1]
answered = ['WA']
answered = answered * (N+1)
result = [0, 0]
was = [0]
was = was * (N+1)

for i in range(M):
    il = input().split()
    p = int(il[0])
    s = il[1]
    if (answered[p] == 'AC'):
        pass
    else:
        if (s == 'AC'):
            result[0] = result[0]+1
            answered[p] = s
            result[1] = result[1]+was[p]
        else:
            was[p] = was[p] + 1

print(str(result[0])+" "+str(result[1]))

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

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

for s in sub:
    if s[1] == 'AC':
        ac[int(s[0])-1] += 1
    elif ac[int(s[0])-1] == 0:
            wa[int(s[0])-1] += 1

ac_sum = 0
wa_sum = 0
for i in range(n):
    if ac[i] != 0:
        wa_sum += wa[i]
        ac_sum += 1
print(ac_sum, wa_sum)

Solution (Python):
n,m = (int(i) for i in input().split())
ac=0
pe=0
p = [0]*(n+1)
a = [0]*(n+1)
for i in range(m):
	x,y = input().split()
	x = int(x)
	if y=="AC":
		a[x]=1
	elif not a[x]: p[x]+=1
ac = sum(a)
pe = sum(p[i] for i in range(n+1) if a[i])
print(ac, pe)

Solution (Python):
n,m = map(int,input().split())
cor = set()
pens = {}
for i in range(m):
  p,s = input().split()
  if s=="AC":
    cor.add(p)
  else:
    if not p in cor:
      if p in pens:
        pens[p] += 1
      else:
        pens[p] = 1
pen = 0
for x in cor:
  if x in pens:  
    pen += pens[x]
print(str(len(cor))+" "+str(pen))

Solution (Python):
n, m = map(int, input().split())
cnt = [0]*n
wrong_cnt = [0]*n
wrong = 0
for i in range(m):
    p, s = map(str, input().split())
    p = int(p)-1
    if cnt[p] != 0:
        continue
    if s == "WA":
        if wrong_cnt[p] == 0:
            wrong_cnt[p] = 1
            continue
        elif s == "WA" and wrong_cnt[p] == -1:
            continue
        else:
            wrong_cnt[p] += 1
            continue
    cnt[p] = 1
    wrong += wrong_cnt[p]
    wrong_cnt[p] = -1

correct = 0
for i in cnt:
    correct += i

print(correct, wrong)

Solution (Python):
from collections import defaultdict


def main():
    N, M = map(int, input().split())
    pS = defaultdict(list)
    for i in range(M):
        p, S = input().split()
        pS[p].append(S)

    ac = 0
    wa = 0
    for pp in pS:
        tmp = pS[pp]
        wa_tmp = 0
        for t in tmp:
            if t == 'WA':
                wa_tmp += 1
            else:
                ac += 1
                wa += wa_tmp
                break
    print(ac, wa)


if __name__ == "__main__":
    main()

Solution (Python):
n,m = map(int,input().split())
li = [[0,0] for _ in range(n)]
t1,t2 = 0,0
for i in range(m):
    a,b = input().split()
    if li[int(a)-1][0] != 1:
        if b == "WA":
            li[int(a)-1][1] += 1
        if b == "AC":
            li[int(a)-1][0] += 1
for i in range(n):
    t1 += li[i][0]
    t2 += li[i][1]*li[i][0]
print(t1,t2)

Solution (Python):
n,m=map(int,input().split())
w,l=0,[0]*n
for i in range(m):
    p,s=input().split()
    p=int(p)-1
    if s=='AC':
        w+=l[p]*(l[p]>=0)
        l[p]=-1
    else:
        l[p]+=(l[p]>=0)
print(l.count(-1),w)

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

for i in range(m):
    p,s = input().split()
    p = int(p)-1
    if s=='AC':
        penalty[p][0]=1
    else:
        if penalty[p][0]==0:
            penalty[p][1]+=1
a = 0
b = 0
for i in range(n):
    if penalty[i][0]==1:
        a += penalty[i][0]
        b += penalty[i][1]
print(a,b)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,m=map(int, input().split())
    if m==0:
        print(0,0)
    else:
        l=[list(input().split()) for i in range(m)]
        wacnt=[0]*n
        accheck=[False]*n
        pcnt=0
        for p,s in l:
            p=int(p)
            if accheck[p-1]:
                continue
            if s=='WA':
                wacnt[p-1]+=1
            elif s=='AC':
                accheck[p-1]=True
                pcnt+=wacnt[p-1]
        print(sum(accheck),pcnt)
resolve()

Solution (Python):
def main():
    S=lambda:input()
    I=lambda:int(input())
    L=lambda:list(map(int,input().split()))
    LS=lambda:list(map(str,input().split()))
    
    n,m=L()
    penanum=[0]*n
    acflag=[False]*n
    acsum=0
    penasum=0
    for i in range(m):
        tmp=LS()
        if tmp[1]=='WA':
            penanum[int(tmp[0])-1]+=1
        elif acflag[int(tmp[0])-1]==False:
            penasum+=penanum[int(tmp[0])-1]
            acsum+=1
            acflag[int(tmp[0])-1]=True
            
    print(acsum,penasum)
    
if __name__ == '__main__':
    main()

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

result = {}
fin = {}
success = 0
wa_sum = 0
for i in range(m):
    p, s = map(str, input().split())
    if not (p in result):
        result[p] = 0
        fin[p] = False
    if s == 'AC' and not fin[p]:
        fin[p] = True
        success += 1
        wa_sum += result[p]
    elif not fin[p]:
        result[p] += 1

print(success, wa_sum)

Solution (Python):
def main():
    N,M=map(int,input().split())
    pS=[[i for i in input().split()] for _ in range(M)]
    ac_wa=[[0,0] for _ in range(N)]
    ac_wa_count=[0,0]
    for p,S in pS:
        p=int(p)
        if S=='WA':
            ac_wa[p-1][1]+=1
        else:
            if ac_wa[p-1][0]==0:
                ac_wa[p-1][0]=1
                ac_wa_count[0]+=1
                ac_wa_count[1]+=ac_wa[p-1][1]
    print(*ac_wa_count)

main()

Solution (Python):
n, m = map(int, input().split())
ps = [list(input().split()) for i in range(m)]
ac = [0] * n
wa = [0] * n
for i in range(m):
    if ac[int(ps[i][0]) - 1] == 0:
        if ps[i][1] == "AC":
            ac[int(ps[i][0]) - 1] = 1
        else:
            wa[int(ps[i][0]) - 1] += 1
for i in range(n):
    if ac[i] == 0:
        wa[i] = 0
print(sum(ac), sum(wa))

Solution (Python):
from sys import stdin, setrecursionlimit


def main():
    n, m = map(int, stdin.readline().split())
    ac = [0] * n
    wa = [0] * n
    for _ in range(m):
        p, s = map(str, stdin.readline().split())
        p = int(p) - 1
        if ac[p] == 0 and s == 'WA':
            wa[p] += 1
        elif s == 'AC':
            ac[p] = 1
    n_ac = 0
    n_wa = 0
    for i in range(n):
        n_ac += ac[i]
        if ac[i] == 1:
            n_wa += wa[i]

    print(n_ac, n_wa)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Solution (Python):

"""
Created on Sat May  9 02:11:20 2020

@author: shinba
"""
n,m = map(int,input().split())

W = [[False,0] for i in range(n)]

ac = 0

for i in range(m):
    A = input().split()
    a = int(A[0])
    b = str(A[1])
    if not W[a-1][0]:
        if b == "AC":
            ac += 1
            W[a-1][0] = True
        else:
            W[a-1][1] += 1

wa = 0

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

print(ac,wa)

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

co = 0
pe = 0

ans_check = [0]*n
wa_check = [0]*n
temp = 0

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


print(co,pe)

Solution (Python):
N, M = map(int, input().split())
accepted = [0] * N
penalties = [0] * N
for _ in range(M):
    p, ac = input().split()
    p, ac = int(p) - 1, ac == "AC"
    accepted[p] |= ac
    penalties[p] += not accepted[p]
print(sum(accepted), sum(p for ac, p in zip(accepted, penalties) if ac))

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

WA = [0] * (N+1)
AC = [0] * (N+1)
for i in range(M):
    p, s = input().split()
    p = int(p)
    
    if s == "AC":
        AC[p] = 1
    elif AC[p] == 0:
        WA[p] += 1
            
print(sum(AC), sum(w if a > 0 else 0 for a, w in zip(AC, WA)))

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

Solution (Python):
N,M=map(int,input().split())
P=[];S=[]
judge=[0]*N
wa_c=[0]*N

for m in range(M):
  p,s = input().split()
  P.append(int(p))
  S.append(s)
  
for m in range(M):
  if judge[P[m]-1]==0 and S[m]=="WA":
    wa_c[P[m]-1] +=1
   
  elif judge[P[m]-1]==0 and S[m]=="AC":
    judge[P[m]-1]=1
    

for n in range(N):
  if judge[n]==0:
    wa_c[n]=0
  
  
print(sum(judge),sum(wa_c))

Solution (Python):
N,M = map(int,input().split())
pena = [0]*(N+1)
ac = [0]*(N+1)
for i in range(0,M,1):
    p,s = input().split()
    if s =="AC":
        ac[int(p)]=1
    elif s=="WA":
        if ac[int(p)] == 0:
            pena[int(p)]+=1
pen =0
for i in range(0,N+1,1):
    if ac[i]==1:
        pen += pena[i]

print(sum(ac),pen)

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

scores = [[0, False] for _ in range(n+1)]

for _ in range(m):
    p, S = input().split()
    p = int(p)

    if scores[p][1]:
        continue

    if S == "AC":
        scores[p][1] = True
        continue

    if S == "WA":
        scores[p][0] += 1

score = pena = 0
for count, ac in scores:
    if ac:
        score += 1
        pena += count

print(score, pena)

Solution (Python):
if __name__ == "__main__":
    n, m = map(int, input().split())
    result = {}
    for _ in range(m):
        p, s = input().split()
        p = int(p)

        if not p in result:
            result[p] = [s]
        else:
            result[p].append(s)
    
    seikai = 0
    pena = 0

    for key in result:
        ptr = 0
        while ptr < len(result[key]) and result[key][ptr] == 'WA':
            ptr += 1
        
        if ptr == len(result[key]):
            continue

        seikai += 1
        pena += ptr
    print(seikai, pena)

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
n,m = [int(i) for i in readline().split()]
ps = []
for _ in range(m):
    p,s = [i for i in readline().split()]
    ps.append([int(p),s])

acs = 0
was = 0
solved = {}
fail_cnt = {}
for p,s in ps:
    if p in solved and solved[p] == 1:
        pass
    elif p in solved and solved[p] == 0 and s == 'AC':
        acs += 1
        solved[p] = 1
        was += fail_cnt[p]
    elif p in solved and solved[p] == 0 and s == 'WA':
        fail_cnt[p] += 1
    elif s == 'AC':
        acs += 1
        solved[p] = 1
    else:
        solved[p] = 0
        fail_cnt[p] = 1
print(acs, was)

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

AC=[0]*N
WA=[0]*N
WA_P=[0]*N
for i in range(M):
    p,s=map(str,input().split())
    if s=="WA" and AC[int(p)-1]==0:
        WA_P[int(p)-1]+=1
    elif AC[int(p)-1]==0 and s=="AC":
        AC[int(p)-1]=1
        WA[int(p)-1]=WA_P[int(p)-1]
print(sum(AC),sum(WA))

Solution (Python):
N,M = map(int, input().split())
pro_pen = [0]*N
pro_ac  = [0]*N
for i in range(M):
    p_i,s_i = map(str, input().split())
    if pro_ac[int(p_i)-1] == 0 and s_i == "WA":
        pro_pen[int(p_i)-1] += 1
    if pro_ac[int(p_i)-1] == 0 and s_i == "AC":
        pro_ac[int(p_i)-1] = 1
wa = 0
for i in range(N):
    if pro_ac[i] == 1:
        wa += pro_pen[i]
print(sum(pro_ac),wa)

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

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

wa = 0
marked = [0 for _ in range(n)]
cnt = [0 for _ in range(n)]

for i in range(m):
    x, s = map(str, input().split())
    x = int(x) - 1
    if s == "AC":
        if marked[x] == False:
            wa += cnt[x]
            marked[x] = True
    else:
        cnt[x] += 1

print(sum(marked), wa)

Solution (Python):
n,m=map(int,input().split())
acl=["WA"]*n
wal=[0]*n
ans=0
for i in range(m):
    p,s=input().split()
    p=int(p)-1
    if(acl[p]=="WA"):
        if s=="WA":
            wal[p]+=1
        else:
            ans+=wal[p]
            acl[p]="AC"
print(acl.count("AC"),ans)

Solution (Python):
n,m=map(int,input().split())
acs=[0]*n
was=[0]*n
WA=0
for i in range(m):
    p,s=input().split()
    p=int(p)
    if acs[p-1]==0:
        if s=="AC":
            acs[p-1]=1
            WA+=was[p-1]
        else:
            was[p-1]+=1
print(sum(acs),WA)

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

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

ok = [False] * n
wa_cnt = [0] * n
ac_cnt = 0
for i in range(m):
    p, m = input().split()
    if ok[int(p) - 1]:
        continue
    if m == 'WA':
        wa_cnt[int(p) - 1] += 1
    else:
        ac_cnt += 1
        ok[int(p) - 1] = True

ans_wa = 0
for i in range(n):
    if ok[i]:
        ans_wa += wa_cnt[i]

print(ac_cnt, ans_wa)

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




teisyutu_list = {} 

for i in range(1, M+1) :
    q_num, ac_wa = map(str, input().split())

    
    if q_num in teisyutu_list.keys() :
        
        teisyutu_list[q_num].append(ac_wa)
    else : 
        teisyutu_list[q_num] = [ac_wa]

ac_cnt = 0
wa_cnt = 0

for j in teisyutu_list.keys() :
    
    if 'AC' not in teisyutu_list[j] :
        continue
    else :
        ac_cnt += 1

        for k in teisyutu_list[j] :
            if 'WA' == k :
                wa_cnt += 1
            else :
                break

print('%d %d' % (ac_cnt, wa_cnt))

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

a = [0 for i in range (n)]

ans = 0
pnl = 0
ha = {}

for i in range (m) :
    p , s = input().split()
    p = int(p) - 1
    if s == 'WA' :
        a[p] += 1
    elif str(p) not in ha.keys() :
        ans += 1
        pnl += a[p]
        ha[str(p)] = '1'

print( str(ans) + ' ' + str(pnl))