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 itertools
n , m = list(map(int, input().split()))
p = []
s = []

cheak = [0]*n

for i in range(m):
    x,y = [j for j in input().split()]
    p.append(int(x))
    s.append(y)

ok = 0
out = 0

for i in range(m):
    if s[i]=="AC" and cheak[p[i]-1]==0:
        cheak[p[i]-1]=1
        ok += 1



for i in range(m):
    if cheak[p[i]-1]==1 and s[i]=="WA":
        out += 1
    elif cheak[p[i]-1]==1 and s[i]=="AC":
        cheak[p[i]-1]= -1



print(str(ok)+" "+str(out))

Solution (Python):
import sys


def main():
    n, m = map(int, sys.stdin.readline().split(" "))
    mem = dict()
    ac_count = 0
    wrong_count = 0
    for _ in range(m):
        t, result = sys.stdin.readline().strip().split(" ")
        test_no = int(t)
        if test_no > n:
            continue
        if test_no in mem:
            if mem[test_no] > 0:
                if mem[test_no] == -1:
                    continue
                if result == "WA":
                    mem[test_no] += 1
                else:
                    ac_count += 1
                    wrong_count += mem[test_no]
                    mem[test_no] = -1
        else:
            mem[test_no] = result == "AC"
            if result == "WA":
                mem[test_no] = 1
            else:
                ac_count += 1
                mem[test_no] = 0
    print("%d %d" % (ac_count, wrong_count))


if __name__ == '__main__':
    main()

Solution (Python):
n,m = map(int,input().split())
d={}
for i in range(m):
  p,s=input().split()
  if p in d.keys():
    d[p].append(s)
  else:
    d[p]=[s,]
ac=0
wa=0
for k,v in d.items():
  if "AC" in v:
    for i in v:
      if i=="WA":
        wa=wa+1
      else:
        ac=ac+1
        break

print(ac,wa)

Solution (Python):
import sys
bbn=1000000007
	


		
def main():
	n,m = map(int, input().split())
	ac_list=[False]*n
	wa_list=[0]*n
	for i in range(m):
		a,b=input().split()
		a=int(a)-1
		if not ac_list[a] and b=='WA':
			wa_list[a]+=1
		elif b =='AC':
			ac_list[a]=True
	ra=sum(ac_list)
	rb=sum([c if t else 0 for c,t in zip(wa_list,ac_list)])
	print(ra,rb)
	
	

isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

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

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

N,M = map(int,input().split())
a=[tuple(map(str,input().split())) for _ in range(M)]
ac = [0]*N
wa = [0]*N
for i in range(M):
    q = int(a[i][0])-1
    res = a[i][1]
    if res == 'AC':
        ac[q] = 1
    else:
        if ac[q] == 0:
            wa[q] += 1
wa2=0
for i in range(N):
    if ac[i]==1:
        wa2 += wa[i]
print("{} {}".format(sum(ac),wa2))

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

pena = [0 for x in range(n + 1)]

clear = [False for i in range(n + 1)]

for i in range(m):
    p, c = input().split()
    p = int(p)
    if clear[p] is False:
        if c == "AC":
            clear[p] = True
        else:
            pena[p] += 1

ans_ac = 0
ans_pena = 0

for pe, cl in zip(pena, clear):
    if cl:
        ans_ac += 1
        ans_pena += pe

print(ans_ac, ans_pena)

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

ac_flag = [0 for _ in range(N)]
wa = ac_flag.copy()

for i in range(M):

    question, result = input().split(" ")
    question = int(question)

    if not ac_flag[question-1] and result == 'WA':
        wa[question - 1] += 1
    
    if result == 'AC':
        ac_flag[question-1] = 1

wa = [x*y for x, y in zip(ac_flag, wa)]
print(sum(ac_flag), sum(x*y for x, y in zip(wa, ac_flag)))

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

ac_list = [0] * (N+1)
wa_list = [0] * (N+1)
wa_cnt = 0
ac_cnt = 0

for _ in range(M):
  p, S = map(str, input().split())
  if S == 'AC':
    if ac_list[int(p)] == 0:
      ac_cnt += 1
      ac_list[int(p)] = 1
      wa_cnt += wa_list[int(p)]
    else:
      pass
  else:
    if ac_list[int(p)] == 0:
      wa_list[int(p)] += 1
    else:
      pass
    

print(ac_cnt, wa_cnt)

Solution (Python):
import numpy as np
N, M = list(map(lambda x: int(x), input().split()))
cleared = np.array([False for i in range(N+1)])
wa_count = np.array([0 for i in range(N+1)])
for _ in range(M):
  p, s = input().split()
  p = int(p)
  
  if cleared[p]:
    continue
  if s == "AC":
    cleared[p] = True
  elif s == "WA":
    wa_count[p] = wa_count[p] + 1

print("{} {}".format(sum(np.array(cleared) *1), sum(wa_count[cleared])))

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

Solution (Python):
N, M = map(int, input().split())
status = {str(i): 0 for i in range(1, N+1)}
error = 0
for _ in range(M):
  q, r = input().split()
  if r == "AC": 
    if status[q] <= 0: 
    	error += -(status[q])
    status[q] = 1
  elif r =="WA":
    if status[q] <= 0: 
      status[q] -= 1

print(sum([i for i in status.values() if i > 0]), error)

Solution (Python):
from sys import stdin
n,m = [int(x) for x in stdin.readline().rstrip().split()]

li = [list(stdin.readline().rstrip().split()) for _ in range(m)]
lin = [0]*(n+1)
wor = [0]*(n+1)

for i in li:
    if lin[int(i[0])] == 0:
        if i[1] == "WA":
            wor[int(i[0])] += 1
        elif i[1] == "AC":
            lin[int(i[0])] = 1
wa = 0
for i in range(n+1):
    if lin[i] == 1:
        wa += wor[i]

print(sum(lin),wa)

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

arr = [False]*n
warr = [0]*n

for i in range(m):
    p,s = input().split()
    p = int(p)-1
    if arr[p]:
        pass
    else:
        if s == "AC":
            arr[p] = True
        else:
            warr[p] += 1

warr = [warr[i] if arr[i] else 0 for i in range(n)]
answer = str(sum(arr)) + " " + str(sum(warr))
print(answer)

Solution (Python):



n, m = map(int, input().split())
check_list = [0] * n
ac_count = 0
wa_count = 0
wa_list = [0] * n
for i in range(0, m):
    p, s = input().split()
    if check_list[int(p) - 1] == 0:
        if s == "WA":
            wa_list[int(p) - 1] += 1
        else:
            ac_count += 1
            check_list[int(p) - 1] = 1
            wa_count += wa_list[int(p) - 1]
print(ac_count, wa_count)

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())
PS = [line.split() for line in readlines()]

AC = [False] * (N+1)
WA_cnt = [0] * (N+1)

penal = 0
for p,s in PS:
    p = int(p)
    if AC[p]:
        continue
    if s == b'WA':
        WA_cnt[p] += 1
    else:
        AC[p] = True
        penal += WA_cnt[p]

ac = sum(AC)
print(ac, penal)

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

AB=[]
for i in range(M):
    a,b=map(str,input().split())
    AB.append([a,b])

AC,WA=0,0
cu=AB[0][0]
L=[[0,0] for i in range(N+1)]

for i in range(M):
    t,s=int(AB[i][0]),AB[i][1]
    if L[t][0]==1:
        continue
    elif s=='AC':
        L[t][0]+=1
    else:
        L[t][1]+=1

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

print(AC,WA)

Solution (Python):
from collections import Counter

N, M = input().split()
N, M = int(N), int(M)
p = [0] * M
S = [0] * M

cnt_wa = Counter()
cnt_ac = Counter()
cnt_wa_all = 0
cnt_ac_all = 0
for i in range(M):
    pt, S = input().split()
    p = int(pt)

    if cnt_ac[p] == 0:
        if S == 'WA':
            cnt_wa.update([p])
        if S == 'AC':
            cnt_ac.update([p])
            cnt_ac_all += 1
            cnt_wa_all += cnt_wa[p]

print(cnt_ac_all, cnt_wa_all)

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

ac_cnt = 0
wa_cnt = 0
for _ in range(m):
    _p, _s = map(str, input().split())
    _p = int(_p)-1
    
    if cnt[_p] != -1:
        
        if _s == 'WA':
            cnt[_p] += 1
        else:
            ac_cnt += 1
            wa_cnt += cnt[_p]
            cnt[_p] = -1

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

Solution (Python):

N, M = map(int, input().split())
ac, wa = 0, 0
l = {}
T = {}
idx, sta = -1, -1
for i in range(M):
    tmp = input().split()
    p = int(tmp[0])
    s = tmp[1]
    if p not in l.keys():
        l[p] = 0
        T[p] = False
    if s == "AC" and not T[p]:
        ac += 1
        T[p] = True
    if s == "WA" and not T[p]:
        wa += 1
        l[p] += 1
cnt = 0
for k in l.keys():
    if not T[k]:
        cnt += l[k]
print(ac, wa-cnt)

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

Solution (Python):
N, M = [int(n) for n in input().split(' ')]
WA = {}
AC = {}
for i in range(M):
    p, S = [n for n in input().split(' ')]
    if p not in WA:
        WA[p] = 0
    if S == "WA":
        WA[p] += 1
    else:
        if p not in AC: 
            AC[p] = WA.pop(p)
print(len(AC), sum(AC.values()))

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

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

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

  if s == 'AC':
    answer[p][0] = True
  else:
    answer[p][1] += 1

cor = sum(map(lambda x: x[0], answer))
pen = sum(map(lambda x: x[1] if x[0] == True else 0, answer))
print(cor, pen)

Solution (Python):
N ,M = map(int,input().split())
P_list = [0 for i in range(N+1)]
AC_count = 0
WA_count = 0

for i in range(M):
    box = input().split()
    if P_list[int(box[0])] != "AC":
        if box[1] == "AC":
            AC_count += 1
            WA_count += P_list[int(box[0])]
            P_list[int(box[0])] = "AC"
        elif box[1] == "WA":
            P_list[int(box[0])] += 1


print(AC_count,WA_count)

Solution (Python):
all_question, submission_count = map(int, input().split())
results = {}
for _ in range(submission_count):
    question_num, res = input().split()
    if question_num not in results:
        results[question_num] = []
    results[question_num].append(res)


def get_index(l, x):
    if x in l:
        return l.index(x)
    else:
        return -1

clear_count = penalty_count = 0

for questuin_num, res_list in results.items():
    index = get_index(res_list, "AC")
    if index == -1:
        continue
    penalty_count += index
    clear_count += 1

print(clear_count, penalty_count)

Solution (Python):
N, M = map(int, input().split(' '))
penalty = [0] * N
actually = [False] * N
for i in range(M):
    ptmp, stmp = input().split(' ')
    pi = int(ptmp)-1
    if actually[pi] == False:
        if stmp == 'WA':
            penalty[pi] += 1
        else:
            actually[pi] = True

sum_penalty = 0
sum_correct = 0
for i in range(N):
    if actually[i] == True:
        sum_correct += 1
        sum_penalty += penalty[i]
print(sum_correct, sum_penalty)

Solution (Python):
from collections import defaultdict
N,M = map(int,input().split())
d1 = defaultdict(lambda:False)
d2 = defaultdict(lambda:0)
for i in range(M):
    p,s = input().split()
    if s == 'WA':
        if not d1[p]:
            d2[p] += 1
    else:
        if not d1[p]:           
            d1[p] = True
ans = [0,0]
for p in d1:
    if d1[p]:
        ans[0] += 1
        ans[1] += d2[p]
print(*ans)

Solution (Python):
n, m = [int(x) for x in input().split()]
ac = [0] * (n + 1)
wa = [0] * (n + 1)

for i 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

print(sum(ac), sum([p for a, p  in zip(ac, wa) if a == 1]))

Solution (Python):
N,M=map(int, input().split())
p=[0]*M
S=['']*M
for i in range(M):
    p[i],S[i]=input().split()
A=[0]*N
count=[0]*N
cnt=0
for i in range(M):
    tmp=int(p[i])-1
    if S[i]=='AC':
        A[tmp]=1
    if S[i]=='WA':
        if A[tmp]==0:
            count[tmp]+=1
countA=0
for i in range(N):
    if A[i]==1:
        countA+=1
        cnt+=count[i]
print(countA, cnt)

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)
    if s == 'WA':
        if ac[int(p) - 1] == 0:
            wa[p - 1] += 1
    else:
        ac[p - 1] = 1

acs, was = 0, 0

for i in range(n):
    acs += ac[i]
    was += ac[i] * wa[i]

print(acs, was)

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

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

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

Solution (Python):
n,m = map(int,input().split())
PS = sorted([input().split() for i in range(m)], key=lambda x:x[0])
PS += [["",""]]
ac = 0
wa = 0

pre = ""
wa_tmp=0
ac_tmp=0




pre = ""
for p,s in PS:
    if pre!=p:
        wa_tmp=0
        ac_tmp=0
    if s == "AC":
        if not ac_tmp:
            ac+=1 
            wa+=wa_tmp
            wa_tmp=0
            ac_tmp+=1
    elif s == "WA":
        wa_tmp+=1
    pre = p

print(ac,wa)

Solution (Python):
N, M = map(int, input().split())
ans = {i:0 for i in range(N+1)}
pn = {i:0 for i in range(N+1)}
ans_num = 0
pn_num = 0

for i in range(M):
    p_tmp, S_tmp = input().split()
    p_tmp = int(p_tmp)
    
    if ans[p_tmp] == 0 and S_tmp == "AC":
        ans[p_tmp] = 1
        ans_num += 1
        pn_num += pn[p_tmp]
        
    elif ans[p_tmp] != 1 and S_tmp == "WA":
        pn[p_tmp] = pn[p_tmp] + 1
        
print(ans_num, pn_num)

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

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

for i in range(m):
    if ps[i][1] == "AC" and AC[int(ps[i][0]) - 1] == 0:
        
        AC[int(ps[i][0]) - 1] = 1
    
    if ps[i][1] == "WA" and AC[int(ps[i][0]) - 1] == 0:
        
        WA[int(ps[i][0]) - 1] += 1

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

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

Solution (Python):
n,m=map(int,input().split())
li=[input().split() for i in range(m)]
 
ac=set()
wa=0
 
q=[[0,-1] for i in range(n+1)]
 
for x,y in li:
  if y=="AC" and q[int(x)][1]==-1: 
    wa+=q[int(x)][0]
    q[int(x)][1]=0
    ac.add(x)
  elif y=="WA" and q[int(x)][1]==-1:
    q[int(x)][0]+=1
 
print(len(ac),wa)

Solution (Python):
n,m=map(int,input().split())
fin=[False]*(10**5+10)
pena=0
corr=0
tmp=[0]*(10**5+10)
for _ in range(m):
  p,s=input().split()
  p=int(p)
    
  if fin[p]==True:
    continue
    
  if s=="WA":
    tmp[p]=tmp[p]+1
  if s=="AC":
    corr+=1
    pena+=tmp[p]
    fin[p]=True
        
print(corr,pena)

Solution (Python):




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

problem_ac = set()
problem_penalty = dict()

for _ in range(M):
    problem, verdict = input().split()

    if problem in problem_ac:
        continue
    elif verdict == "WA":
        problem_penalty[problem] = problem_penalty.get(problem, 0) + 1
    elif verdict == "AC":
        problem_ac.add(problem)

num_ac = len(problem_ac)
num_penalties = sum(penalty for problem, penalty in problem_penalty.items() if problem in problem_ac)
print(num_ac, num_penalties)

Solution (Python):
def main():
    N, M = map(int, input().split())
    pre = set()
    wa = [0] * N
    ans, ans2 = 0, 0
    for _ in range(M):
        p, s = input().split()

        if int(p) in pre:
            continue

        if s == 'AC':
            pre.add(int(p))
            ans += 1
        else:
            wa[int(p)-1] += 1

    for i in range(N):
        if (i+1) in pre:
            ans2 += wa[i]
    print(ans, ans2)

if __name__ == '__main__':
    main()

Solution (Python):
N, M = map(int, input().split())
pS = [tuple(input().split()) for i in range(M)]
pS.sort(key=lambda x: x[0])
problems = [0]*N
AC = 0
penalty = 0

for p, S in pS:
    p = int(p)
    if problems[p-1] < 0:
        continue
    else:
        if S == "AC":
            penalty += problems[p-1]
            problems[p-1] = -1
            AC += 1

        else:
            problems[p-1] += 1

print(AC, penalty)

Solution (Python):
import sys
sys.setrecursionlimit(10000000)

from bisect import *
from collections import *




INF = 500000
mod = 10**9+7

N, M = map(int, input().split())
flg = [0] * N
cnt = [0] * N
ans = 0
for i in range(M):
    p, S = input().split()
    p = int(p)-1
    if S == 'WA':
        if flg[p] == 0:
            cnt[p] += 1
    else:
        if flg[p] == 0:
            flg[p] = 1
            ans += cnt[p]
print(sum(flg), ans)

Solution (Python):
n,m = list(map(int,input().split()))
a = [0]*n
s=0
pe=0
for i in range(m):
    p,v = input().split()
    p = int(p)
    if(v=="WA"):
        if(a[p-1] != 1):
            a[p-1] = a[p-1]-1
    elif(v == "AC"):
        if(a[p-1]==1):
            continue
        else:
            pe-=a[p-1]
            a[p-1] = 1
            s+=1
print(s,pe)

Solution (Python):
[N, M] = [int(i) for i in input().split()]
submits = [0]*M

for i in range(M):
    submits[i] = input().split()

ac = 0

acs = set([])
was = {}

for i in range(1, N+1):
    was[str(i)] = 0

for item in submits:
    if item[0] in acs:
        continue
    elif item[1] == "WA":
        was[item[0]] += 1
    else:
        ac += 1
        acs.add(item[0])
        
pen = 0

for key in was.keys():
    if key in acs:
        pen += was[key]
        
print(' '.join([str(ac), str(pen)]))

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

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

r = [False]*n
q = [0]*n

res = 0

for _ in [0]*m:
    p,s = map(str,input().split())
    p = int(p)-1
    if s == 'AC':
        if not r[p]:
            r[p] = True
            res += q[p]
    else:
        q[p] += 1

print(sum(r),res)

Solution (Python):

import numpy as np

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

ac = np.zeros(n)
wa = np.zeros(n)

for _ in range(m):
    p, s = input().split()
    p = int(p) - 1
    if ac[p] == 1:
        continue
    if s == "WA":
        wa[p] += 1
    else:
        ac[p] = 1

acc = 0
wac = 0
for a, w in zip(ac, wa):
    if a == 1:
        acc += 1
        wac += w

print(acc, int(wac))

Solution (Python):
N,M = map(int,input().split())
ans = 0
ans2 = 0
ps = [list(map(str,input().split())) for i in range(M)]
ppp = [tuple(i) for i in ps]
pss = set(sorted(ppp))
check = [[0] for i in range(N+1)]
for i in pss:
    if "AC" in i:
        ans += 1
for i in ps:
    i[0] = int(i[0])
for i in range(len(ps)):
    if ps[i][1] == "WA" and check[ps[i][0]] != [-1]:
        check[ps[i][0]][0] += 1
    if ps[i][1] == "AC" and check[ps[i][0]] != [-1]:
        ans2 += check[ps[i][0]][0]
        check[ps[i][0]][0] = -1
print(ans, ans2)

Solution (Python):
N,M = map(int,input().split())
dic = dict(zip(list(range(1,N+1)),[0]*N))
bl = [True]*N
ac,wa = 0,0
for i in range(M):
    p,s = input().split()
    if s == "WA":
        dic[int(p)] += 1
    elif s == "AC":
        if bl[int(p)-1]:
            ac += 1
            wa += dic[int(p)]
            bl[int(p)-1] = False
print(ac,wa)

Solution (Python):
import sys

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

if m == 0:
  print('{} {}'.format(0, 0))
  sys.exit()

result = {}
ac_result = 0
wa_result = 0
for i in range(m):
  x = input().split()
  p = int(x[0])
  s = x[1]
  if s == 'AC':
    try:
      if result[p] == 'AC':
        pass
      else:
        wa_result += result[p]
        ac_result += 1
        result[p] = 'AC'
    except:
      ac_result += 1
      result[p] = 'AC'
      pass
  else:
    try:
      if result[p] == 'AC':
        pass
      else:
        result[p] += 1
    except:
      result[p] = 1

print('{} {}'.format(ac_result, wa_result))

Solution (Python):
N, M  = map(int, input().split())
pS = [input().split() for a in range(M)]

total = [0 for a in range(N)]
correct = [0 for a in range(N)]
for ptext, S in pS:
  p = int(ptext)-1
  if S == 'WA' and correct[p] == 0:
    total[p] += 1
  elif S == 'AC':
    correct[p] = 1

for i in range(N):
  if correct[i] == 0:
    total[i] = 0
print(sum(correct), sum(total))

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


def main():
    sc = Scan()
    N, M = sc.intarr()
    array = []
    for i in range(M):
        p, s = sc.strarr()
        array.append([p, s])

    data = {}
    AC_cnt = 0
    WA_cnt = 0
    for ss in array:
        if ss[0] not in data:
            if ss[1] == 'WA':
                data[ss[0]] = [0, 1]
            elif ss[1] == 'AC':
                data[ss[0]] = [1, 0]
        elif data[ss[0]][0] == 0:
            if ss[1] == 'WA':
                data[ss[0]][1] += 1
            elif ss[1] == 'AC':
                data[ss[0]][0] += 1

    for key in data:
        if data[key][0] != 0:
            AC_cnt += 1
            WA_cnt += data[key][1]

    print(AC_cnt, WA_cnt)


def perm(p):
    if len(p) == 1:
        return [p]
    else:
        s = []
        for i in range(len(p)):
            q = p[i]
            r = perm(p[:i]+p[i+1:])
            for t in r:
                s.append([q] + t)
        return s


class Scan():

    def intarr(self):
        num_array = list(map(int, input().split()))
        return num_array

    def intarr_ver(self, n):
        return [int(input()) for _ in range(n)]

    def strarr(self):
        line = input()
        array = line.split(' ')
        array[-1] = array[-1].strip('\n')
        return array


def display(array):
    for a in range(len(array)):
        if len(array) - a != 1:
            print(array[a], end=' ')
        else:
            print(array[a])


def gcd(a, b):  
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):  
    return a * b // gcd(a, b)


main()

Solution (Python):


def main():
    syutudai,teisyutsu_count = map(int, input().split())
    result_list = [input().split() for i in range(teisyutsu_count)]
    penalty_count = [0] * syutudai

    penalty_sum = 0
    ac_count = 0
    for result in result_list:
        problem = int(result[0])
        result = result[1]
        if penalty_count[problem-1] == -1:
            continue
        if result == 'AC':
            penalty_sum += penalty_count[problem-1]
            penalty_count[problem-1] = -1
            ac_count += 1
        else:
            penalty_count[problem-1] = penalty_count[problem-1] + 1

    print('{} {}'.format(ac_count,penalty_sum))




if __name__ == "__main__":
    main()

Solution (Python):
n,m = (int(i) for i in input().split())
p = []
ac = 0
wa = 0
for i in range(m):
  a,b = (input().split())
  a = int(a)
  p.append([a,b])
x = [0]*n
w = [0]*n
for i in range(m):
  tmp = p[i][0] - 1
  if p[i][1] == "AC":
    x[tmp] = 1
  elif p[i][1] == "WA":
    if x[tmp] == 0:
      w[tmp] += 1
for i in range(n):
  if x[i] == 1:
    ac += 1
    wa += w[i]
print(ac,wa)

Solution (Python):
n,m = map(int, input().split())
a = [list(input().split()) for i in range(m)]
b=[[0,0] for i in range(n)]
AC=0
WA=0

for i in range(m):
    if b[int(a[i][0])-1][0]==0 and a[i][1]=='AC':
        b[int(a[i][0]) - 1][0]+=1
    elif b[int(a[i][0])-1][0]==1 and a[i][1]=='AC':
        continue
    elif b[int(a[i][0])-1][0]==0 and a[i][1]=='WA':
        b[int(a[i][0]) - 1][1] +=1
    elif b[int(a[i][0])-1][0]==1 and a[i][1]=='WA':
        continue

for i in range(n):
    if b[i][0]>=1:
        AC+=1
    if b[i][0]>=1 and b[i][1]>=1:
        WA+=b[i][1]
print(AC,WA)

Solution (Python):

def main():
    n, m = map(int, input().split())
    dic = {}
    ac, wa = "AC", "WA"
    for _ in range(m):
        p, s = input().split()
        if p not in dic:
            dic[p] = [0, False]  
        if dic[p][1]:
            continue
        if s == wa:
            dic[p][0] += 1
        else:
            dic[p][1] = True

    ac_num, wa_num = 0, 0
    for _, (wa_count, accepted) in dic.items():
        ac_num += accepted
        if accepted:
            wa_num += wa_count

    print(ac_num, wa_num)


if __name__ == "__main__":
    main()

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

if __name__ == '__main__':
    main()

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

d = {}
ans = [0, 0]

for i in range(M):
  p, s = input().split()
  r = d.get(p, 0)
  if r == 'AC':
    pass
  else:
    if s == 'AC':
      ans[0] += 1
      d[p] = 'AC'
    else:
      ans[1] += 1
      d[p] = r + 1

for key, value in d.items():
  if value != 'AC':
    ans[1] -= value

print(*ans)

Solution (Python):
n,m = list(map(int, input().split()))
aclist=[0 for i in range(n)]
ac=0
wa=[0 for i in range(n)]
for i in range(m):
    j = list(input().split())
    j[0]=int(j[0])
    if aclist[j[0]-1]==0:
        if j[1]=='AC':
            ac+=1
            aclist[j[0]-1]=1
        elif j[1]=='WA':
            wa[j[0]-1]+=1
ans=0
for i,j in enumerate(aclist):
    if j==1:
        ans+=wa[i]
print(ac,ans)

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 == 'AC':
        AC[p-1] = 1
    elif S == 'WA' and AC[p-1] == 0:
        WA[p-1] += 1

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

print(AC_cnt, WA_cnt)

Solution (Python):
n, m = map(int, input().split())
P, S = [], [] 
PS = set()
for _ in range(m):
    p, s = map(str, input().split())
    P.append(int(p))
    S.append(s)
    PS.add((int(p),s))

gotou = 0

sudeni_seitou = set()
for i in range(m):
    if S[i] == 'AC':
        sudeni_seitou.add(P[i])

mou_sudeni_seitou = set()
for i in range(m):
    if S[i] == 'AC':
        mou_sudeni_seitou.add(P[i])
    elif (S[i] == 'WA') and (P[i] in sudeni_seitou) and (P[i] not in mou_sudeni_seitou):
        gotou += 1

seitou = len(sudeni_seitou)

print(str(seitou) + ' ' + str(gotou))

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


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

for i in range(M):
    if AC_f[P[i]] == 0:
        if S[i] == "AC":
            AC += 1
            AC_f[P[i]] = 1
        else:
            WA += 1
            WA_f[P[i]] += 1
for i in range(1,N+1):
    if AC_f[i] == 0 and WA_f[i] != 0:
        WA -= WA_f[i]
print(AC,WA)

Solution (Python):
n,m = map(int, input().split())
wrong = [0] * n
wrongAns = [0] * n
goodAns = [0] * n
badAnsF = 0
greatAnsF = 0

for i in range(m):
  p,s = input().split()
  if(s == "WA"):
    wrong[int(p)-1] += 1
  elif(s == "AC"):
    if(goodAns[int(p)-1] == 0):
      wrongAns[int(p)-1] = wrong[int(p)-1]
      goodAns[int(p)-1] = 1
    
for i in wrongAns:
  badAnsF += i
for i in goodAns:
  greatAnsF += i

print(greatAnsF,badAnsF)

Solution (Python):
a = input().split(" ")
n = int(a[0])
m = int(a[1])
ac = dict()
wa = dict()
for i in range(m):
    v = input().split(" ")
    q = int(v[0])
    res = v[1]
    if q in ac:
        continue
    if res == "AC":
        ac[q] = wa.get(q, 0) + 1
    elif res == "WA":
        wa[q] = wa.get(q, 0) + 1

acs = len(ac)
was = 0
for k in ac.keys():
    was = was + wa.get(k, 0)
print(str(acs) + " " + str(was))

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

n,m=map(int,input().split())
dic={}
w=ac=0
for _ in range(m):
  a,b=input().split()
  if a in dic:
    if dic[a][1]:
      if b == 'WA':
        dic[a][0]+=1
      else:
        ac+=1
        w+=dic[a][0]
        dic[a][1]=False
  else:
    dic[a]=[0,True]
    if b == 'WA':
      dic[a][0]+=1
    else:
      ac+=1
      dic[a]=[0,False]

print(ac,w)

Solution (Python):
N, M = [int(a) for a in input().split()]
p = [0] * M
S = [None] * M

num_WA = [0] * N
num_AC = [0] * N

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

    if S[i] == "AC":
        num_AC[p[i]-1] = 1
    else:
        if num_AC[p[i]-1] == 0:
            num_WA[p[i]-1] += 1

nAC = sum(num_AC)
nWA = 0
for i in range(N):
    if num_AC[i] == 1:
        nWA += num_WA[i]

print(nAC, nWA)

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