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 = map(int, input().split())
P = [input().split() for i in range(m)]
P = list(itertools.chain.from_iterable(P))
ac_list = [0] * n
wa_list = [0] * n
counta = 0
countb = 0
for i in range(1, m * 2, 2):
    if P[i] == "AC" and ac_list[int(P[i - 1])-1] == 0:
        counta += 1
        ac_list[int(P[i - 1])-1] = 1
        countb += wa_list[int(P[i - 1]) - 1]
    elif P[i] == "WA":
        wa_list[int(P[i - 1]) - 1] += 1
    else:
        continue

print(counta, countb)

Solution (Python):
n, m = map(int, input().split(' '))
a = {}
b = 0
c = 0
for q in range(m):
    p, s = map(str, input().split(' '))
    if p not in a:
        if s == 'AC':
            a[p] = [0, 1]
            b += 1
        else:
            a[p] = [1, 0]
    else:
        if a[p][1] == 1:
            continue
        else:
            if s == 'AC':
                a[p][1] = 1
                b += 1
                c += a[p][0]
            else:
                a[p][0] += 1
print(b, c)

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

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

resWA = map(lambda x, y: x*y, AC, WA)    

print(sum(AC), sum(resWA))

Solution (Python):

n,m=list(map(int,input().split()))
wa=[0 for _ in range(n)]
ac=[False for _ in range(n)]
for _ in range(m):
    p,s=input().split()
    p=int(p)-1
    if ac[p]:
        continue
    if s=="AC":
        ac[p]=True
    else:
        wa[p]+=1
ans=0
for i in range(n):
    if ac[i]:
        ans+=wa[i]
print(sum(ac),ans)

Solution (Python):


class Problem:
    def __init__(self, status):
        self.status = status
        self.penalties = 0

n,m = map(int, input().split())
data = []
for _ in range(m):
    x, y = map(str, input().split())
    data.append((x, y))

problems = {str(i+1): Problem('-') for i in range(n)}


for number, isAC  in data:
    if problems[number].status == 'AC':
        continue
    else: 
        if isAC == 'AC':
            problems[number].status = 'AC'
        elif isAC == 'WA':
            problems[number].penalties += 1 

cntACproblems = 0
cntPenalties = 0

for problem in problems.values():
    if problem.status == 'AC': 
        cntACproblems += 1
        cntPenalties += problem.penalties

print(str(cntACproblems) + ' ' + str(cntPenalties))

Solution (Python):
N,M= [int(i) for i in input().split()]
tmp=[]
scr=[0]*2
rec=[0]*N
eec=[0]*N

ts=0
for i in range(M):
        tmp = ([x for x in input().split()])
        q=int(tmp[0])

        if rec[q-1] == 1:
                continue
        else:
                if tmp[1] == 'AC':
                        rec[q-1]=1
                        scr[0]+=1
                        scr[1]+=eec[q-1]
                elif tmp[1]=='WA':
                        eec[q-1]+=1
        
        
print(scr[0],scr[1])

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

flags = [False] * N
p_ary = [0] * N

penalty = 0
score = 0
for _ in range(M):
    p_num, result = input().split()
    p_num = int(p_num) - 1
    if result == 'AC':
        if flags[p_num] is False:
            score += 1
        flags[p_num] = True
    elif result == 'WA' and flags[p_num] is False:
        p_ary[p_num] += 1

for p, flag in zip(p_ary, flags):
    if flag is True:
        penalty += p

print(score, penalty)

Solution (Python):
def t(n, ps):
    ac = 0
    wa = 0
    a = [False]*(n + 1)
    b = [0]*(n+1)
    for p, s in ps:
        if a[int(p)]:
            continue
        if s == 'AC':
            ac += 1
            wa += b[int(p)]
            a[int(p)] = True
        else:
            b[int(p)] += 1
    return (ac, wa)


if __name__ == '__main__':
    n, m = map(int, input().split())
    ps = [input().split() for i in range(m)]
    print(' '.join(map(str, t(n, ps))))

Solution (Python):
ac={}
wa={}
ans1=0
ans2=0
N,M=input().split(" ")
for i in range(int(M)):
    num,sa=input().split(" ")
    if sa=='AC':
        if num in ac:
            continue
        else:
            ans1+=1
            ac[num]=1
            if num in wa:
                ans2+=wa[num]
    else:
        if num in wa:
            wa[num]+=1
        else:
            wa[num]=1
print(ans1,ans2)

Solution (Python):
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
    
    
N,M=map(int,input().split())
a=0
b=0
AC=[0]*(N+1)
pen=[0]*(N+1)
p=0
l=[]
for i in range(M):
	j,r=input().split()
	if AC[int(j)]==0:
		if r=="WA":
			pen[int(j)]+=1
		else:
			AC[int(j)]+=1
for k in range(N+1):
	if AC[k]==1:
		p+=pen[k]

print(sum(AC),p)

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

AC = [0]*N
WA = [0]*N
wa = 0

for i in range(M):
    j, res = input().split()
    j = int(j)-1

    if AC[j] == 0 and res == "AC":
            AC[j] = 1
            wa += WA[j]
    WA[j] += 1

print(sum(AC), wa)

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


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

SUBMISSIONS = {i:[] for i in range(1, n + 1)}
for _ in range(m):
    p, s = input().split()
    SUBMISSIONS[int(p)].append(s)

ac, penalty = 0, 0
for i in range(1, n + 1):
    wa = 0
    for result in SUBMISSIONS[i]:
        if result == "WA":
            wa += 1
        else:
            ac += 1
            penalty += wa
            break

print(ac, penalty)

Solution (Python):
n,m=map(int,input().split())
ac=set()
from collections import Counter
w=Counter()
wa=0
for i in range(m):
    p,s=input().split()
    if s=="AC":
        if p not in ac:
            wa+=w[p]
        ac.add(p)
    else:
        if p not in ac:
            w[p]+=1
print(len(ac),wa)

Solution (Python):


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


flag = [False for e in range(N)]
corr = 0

for i in range(M):
    
    if flag[p[i]]:
        continue
    else:
        
        if S[i] == "AC":
            corr += 1
            flag[p[i]] = True


flag = [False for e in range(N)]
error = 0

errors = [0 for e in range(N)]

for i in range(M):
    
    if flag[p[i]]:
        continue
    else:
        
        if S[i] == "WA":
            errors[p[i]] += 1
        
        else:
            error += errors[p[i]]
            flag[p[i]] = True

print(corr,error)

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

answer = [0] * N
penalty = [0] * N
P = 0

for i in range(M):
    p_tmp, s_tmp = input().split()   
    p_tmp = int(p_tmp) - 1

    if(answer[p_tmp] == 0):
        
        if s_tmp == 'AC':
            answer[p_tmp] = 1
            P += penalty[p_tmp]
        else:
            penalty[p_tmp] += 1

print(sum(answer), P)

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

lst_ac = [0 for i in range(n+1)]
for i in range(m):
    if s[i] == 'AC':
        lst_ac[p[i]] = 1
ans_ac = sum(lst_ac)

out = 0
for i in range(m):
    if s[i] == 'WA' and lst_ac[p[i]] == 1:
        out += 1
    if s[i] == 'AC' and lst_ac[p[i]] == 1:
        lst_ac[p[i]] = 2

print(ans_ac, out)

Solution (Python):
N, M = map(int, input().split())
if M == 0:
  print(0, 0)
else:
  pS = [list(input().split()) for i in range(M)]

  for i in range(M):
    pS[i][0] = int(pS[i][0])

  listWA = [0 for i in range(N)]
  listAC = [0 for i in range(N)]
  
  for j in range(M):
    if listAC[pS[j][0] - 1] < 1:
      if pS[j][1] == "AC":
        listAC[pS[j][0] - 1] = 1
      else:
        listWA[pS[j][0] - 1] += 1
  
  for i in range(N):
    if listAC[i] < 1:
      listWA[i] = 0
  
  
  print(sum(listAC), sum(listWA))

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

max_val = 10**5+1

ac_L = []
wa_L = []
for val in range(1,max_val):
    wa_L.append(0)
    ac_L.append(0)

ac_ans,wa_ans = 0,0


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



print(sum(ac_L),wa_ans)

Solution (Python):
from collections import defaultdict

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

d = defaultdict(int)
res_ans = 0
res_pena = 0

for _ in range(m):
    p, s = input().split()
    if s == "AC":
        if d[p] == -1:
            continue
        else:
            res_ans += 1
            res_pena += d[p]
            d[p] = -1
    else:
        if d[p] == - 1:
            continue
        else:
            d[p] += 1

print(res_ans, res_pena)

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

    d[p] = a

ac = 0
wa = 0
for x in d.values():
    if x[0] == 1:
        ac += x[0]
        wa += x[1]

print("{0} {1}".format(ac, wa))

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

Solution (Python):
from sys import stdin
N, M = [int(_) for _ in stdin.readline().rstrip().split()]
PM = [stdin.readline().rstrip().split() for _ in range(M)]
AC = set()
WA = {}
wa = 0
for pm in PM:
    if pm[0] in AC:
        continue
    if pm[1] == "AC":
        AC.add(pm[0])
        if pm[0] in WA:
            wa += WA[pm[0]]
    elif pm[1] == "WA":
        if pm[0] not in WA:
            WA[pm[0]] = 0
        WA[pm[0]] += 1  
print(len(AC), wa)

Solution (Python):

N, M = map(int, input().split())
 
submit = []
for _ in range(M):
  temp = [x for x in input().split()]
  submit.append(temp)
 
ac = [0]*(N + 1)
wa = [0]*(N + 1)
  
for i in range(M):
  result = submit[i][1]
  question = int(submit[i][0])
  
  if result == 'AC' and ac[question] == 0:
    ac[question] = 1
  elif result == 'WA' and ac[question] == 0:
    wa[question] += 1
 
for i in range(N + 1):
  if ac[i] != 1:
    wa[i] = 0
 
print(sum(ac), sum(wa))

Solution (Python):

n_prob, n_submission = (int(x) for x in input().split())
condition = [[0,0] for _ in range(n_prob)] 
n_penalty = 0
n_ac = 0

for i in range(n_submission):
    tmp = input().split()
    prob_num = int(tmp[0])
    ac_wa = tmp[1]
    if ac_wa == 'AC' and condition[prob_num-1][0] == 0:
        n_penalty += condition[prob_num-1][1]
        n_ac += 1
        condition[prob_num-1][0] = 1
    elif ac_wa == 'WA':
            condition[prob_num-1][1] += 1

print(n_ac , n_penalty)

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

list_ac = [0 for i in range(N)]
list_pen = [0 for i in range(N)]
list_count = [0 for i in range(N)]

for i in range(M):
  pS = input().split()
  p = int(pS[0])-1
  S = pS[1]
  if S == "AC":
    list_pen[p] += list_count[p] * (1 - list_ac[p])
    list_ac[p] = 1
  else:
    list_count[p] += 1

print(str(sum(list_ac)) + " " + str(sum(list_pen)))

Solution (Python):
n,m = list(map(int,input().split()))
ac = 0
wa = 0
y = {i:0 for i in range(1,n+1)}
z = {i:0 for i in range(1,n+1)}

for _ in range(m):
  p,s = input().split()
  p = int(p)
  if not y[p] and s == 'WA':
    z[p] += 1
  elif not y[p] and s == 'AC':
    ac += 1
    y[p] += 1

for i in range(1,n+1):
  if y[i]:
    wa += z[i]

print(ac,wa)

Solution (Python):
N, M = map(int, input().split())
 
cor = 0
penalty = 0
dic_penalty = {}
dic = {}
for i in range(M):
  p, S = input().split()
  p = int(p)
  if p not in dic:
    dic[p] = "_"
    dic_penalty[p] = 0
  if (S == "AC") & (dic[p] != "AC"):
    dic[p] = "AC"
    cor = cor+1
    penalty = penalty + dic_penalty[p]
    continue
  elif (S == "WA") & (dic[p] != "AC"):
    dic_penalty[p] = dic_penalty[p] + 1
    
print("{} {}".format(cor, penalty))

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



list_problem_results = [[] for i in range(N)]

for _ in range(M):
    problem_index, result = input().split()
    problem_index = int(problem_index)-1
    list_problem_results[problem_index].append(result)


count_completed_problems = sum(["AC" in problem for problem in list_problem_results])


overall_penalty_count = 0
for problem in list_problem_results:
    count_penalty = 0
    for result in problem:
        if result == "WA":
            count_penalty += 1
        elif result == "AC":
            overall_penalty_count += count_penalty
            break

print(count_completed_problems, overall_penalty_count)

Solution (Python):




def main():
  N, M = map(int, input().split())
  acs = [0] * N
  was = [0] * N

  for _ in range(M):
    p, s = input().split()
    p = int(p) - 1

    if s == 'AC':
      acs[p] = 1
    elif acs[p] == 0:
      was[p] += 1

  s = 0
  p = 0

  for a, w in zip(acs, was):
    if a == 0:
      continue

    s += 1
    p += w

  print(s, p)


if __name__ == '__main__':
  main()

Solution (Python):
from collections import defaultdict


def solve():
    n, m = map(int, input().split())
    wa_count = 0
    dict1 = defaultdict(int)
    dict2 = defaultdict(int)
    ac_p, wa_p = set(), set()
    for i in range(m):
        p, s = map(str, input().split())
        p = int(p)
        if s == 'AC':
            dict1[p] = 1
            ac_p.add(p)
        else:
            if dict1[p] != 1:
                dict2[p] += 1
                wa_p.add(p)
    for ac in ac_p:
        if ac in wa_p:
            wa_count += dict2[ac]
    print(sum(dict1.values()), wa_count)


if __name__ == '__main__':
    solve()

Solution (Python):
n,m = map(int,input().split())
l = [0 for i in range(n)]
pena = 0
for i in range(m):
    q,res = input().split()
    if res == "AC":
        if l[int(q)-1] != 1:
            pena += l[int(q)-1]//2
            l[int(q)-1] = 1
    elif l[int(q)-1]%2 == 0:
        l[int(q)-1] +=2

print(l.count(1),pena)

Solution (Python):
total = {}
penalty = 0
ac_answer = 0 
n,m = map(int, input().split())
for _ in range(m):
    num,answer = input().split()

    if num in total:
        total[num].append(answer)
    else:
        total[num] = [answer]
        
for answer_value in total.values():
    if "AC" in answer_value:
        penalty += answer_value.index("AC")
        ac_answer += 1
            
print(ac_answer,penalty)

Solution (Python):
n, m = list(map(int, input().split()))
ac = [0] * n
wa = [0] * n
for _ in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == "AC":
        ac[p] = 1
    elif not ac[p]:
        wa[p] += 1
ans = [sum(ac), sum([i * j for i, j in zip(ac, wa)])]
print("{} {}".format(ans[0], ans[1]))

Solution (Python):
import numpy as np
n, m = list(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 s == "AC":
        ac[p] = 1
    elif not ac[p]:
        wa[p] += 1
print("{} {}".format(np.sum(ac, dtype=np.int64), np.sum(ac * wa, dtype=np.int64)))

Solution (Python):
def solve(string):
    n, m, *ps = string.split()
    n = int(n)
    ac = [0] * n
    wa = [0] * n
    for p, s in zip(*[iter(ps)] * 2):
        p = int(p) - 1
        if s == "AC":
            ac[p] = 1
        elif not ac[p]:
            wa[p] += 1
    return "{} {}".format(sum(ac), sum([w * a for a, w in zip(ac, wa)]))
 
 
if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

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

for i in range(M):
  p, S = input().split()
  p = int(p)-1
  if S=="WA":
    if D[p] != -1:
      D[p] += 1
  else:
    if D[p] != -1:
      ansAC += 1
      ansWA += D[p]
      D[p]= -1

print (ansAC,ansWA)

Solution (Python):
N, M = list(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(AC[p-1] == 0):
    WA[p-1] += 1
for i in range(N):
  if(AC[i] == 0):
    WA[i] = 0
print(sum(AC), sum(WA))

Solution (Python):
def solve(n, m, p, s):
    accept = {i+1: False for i in range(n)}
    penalty = {i+1: 0 for i in range(n)}
    for i in range(m):
        if s[i] == "WA":
            if not accept[p[i]]:
                penalty[p[i]] += 1
        else:
            accept[p[i]] = True
    a = sum(accept.values())
    b = sum([v for k, v in penalty.items() if accept[k]])
    return "%d %d" % (a, b)

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])
print(solve(n, m, p, s))

Solution (Python):
n, m = map(int, input().split())
correct = {i: 0 for i in range(1,n+1)}
acs = 0
penal = {i: 0 for i in range(1,n+1)}

for _ in range(m):
    p, s = input().split()
    p = int(p)
    if s == 'AC':
        if not correct[p]:
            acs += 1
            correct[p] = 1
    else:
        if not correct[p]:
            penal[p] += 1

wa = 0
for key in penal.keys():
    if correct[key]:
        wa += penal[key]
print(acs, wa)

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

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()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,m = LI()
    ps = [LS() for _ in range(m)]
    c = collections.defaultdict(int)
    r = 0
    o = 0
    for p,s in ps:
        if c[p] == -1:
            continue
        if s == 'AC':
            r += 1
            o += c[p]
            c[p] = -1
        else:
            c[p] += 1

    return JA([r,o]," ")


print(main())

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

points    = [0] * n
penalty   = [0] * n
penalties = 0

for i in range(m):
  q, ans = input().split()
  q = int(q) - 1
  
  if(points[q] == 0):
    
    if(ans == 'AC'):
      points[q] = 1
      penalties += penalty[q]
    
    else:
      penalty[q] += 1

print('{} {}'.format(sum(points), penalties))

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

AC_and_penalty = {i:[False, 0] for i in range(1, N+1)}

for p, s in PS:
  _AC_and_penalty = AC_and_penalty[int(p)]
  if _AC_and_penalty[0]:
    continue
  else:
    if s == "AC":
      _AC_and_penalty[0] = True
    else:
      _AC_and_penalty[1] += 1
    
num_AC = 0
penalty = 0
for cond, p in AC_and_penalty.values():
  if cond:
    num_AC += 1
    penalty += p
    
print("{} {}".format(num_AC, penalty))

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

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

max_val = 10**5+1

ac_L = []
wa_L = []
for val in range(1,max_val):
    wa_L.append(0)
    ac_L.append(0)

ac_ans,wa_ans = 0,0


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



print(sum(ac_L),wa_ans)

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

AC,WA = 0,0

cnt_AC = [False]*(N+1)
cnt_WA = [0]*(N+1)

for i in range(M):
  p,S = input().split()
  p = int(p)
  if S == 'AC' and not cnt_AC[p]:
    AC += 1
    cnt_AC[p] = True
  elif S == 'WA' and not cnt_AC[p]:
    cnt_WA[p] += 1

for i in range(N+1):
  if cnt_AC[i]:
    WA += cnt_WA[i]
print(AC,WA)

Solution (Python):

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

list_AC = [0] * N
list_WAcount = [0] * N
sumAC = 0
sumWA = 0

for i in range(M):
    sp , S = input().split(' ')
    p = int(sp)
    
    if (list_AC[p-1] != 0):
        
        continue 
    else:
        
        if S == 'AC':
            sumAC += 1
            list_AC[p-1] = 1
            sumWA += list_WAcount[p-1]
        else:
            list_WAcount[p-1] += 1

print("{} {}".format(sumAC,sumWA))

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

seitou=0
pe=0
cont=0
q=[0]*(n+1)
pena=[0]*(n+1)
for i in range(m):
    
    p,s=input().split()
    p=int(p)
    if q[p]==0:
        if s=="WA":pena[p]+=1
        if s=="AC":
            seitou+=1
            q[p]=1    
for i in range(n+1):
    if q[i]==1:
        pe+=pena[i]
print(sum(q),pe)

Solution (Python):
import sys
N, M = [int(v) for v in sys.stdin.readline().split()]
AC = set()
WA = {}
for i in range(M):
    p, s = sys.stdin.readline().split()
    p = int(p)

    if s == 'AC':
        AC.add(p)
    else:
        if p not in AC:
            if p not in WA:
                WA[p] = 1
            else:
                WA[p] += 1
wa = 0
for a, c in WA.items():
    if a in AC:
        wa += c

print(len(AC), wa)

Solution (Python):
n, m = map(int, input().split())
cnt_ac = [False]*(n+1)
cnt_wa = [0]*(n+1)
ac, wa = 0, 0
for i in range(m):
  p, s = input().split()
  p = int(p)
  if s == 'AC' and not cnt_ac[p]:
    ac += 1
    cnt_ac[p] = True
  elif s =='WA' and not cnt_ac[p]:
    cnt_wa[p] += 1

for i in range(n+1):
  if cnt_ac[i]: wa += cnt_wa[i]
print(ac, wa)

Solution (Python):
import numpy as np

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

lst = [[] for i in range(N)]
for i in range(M):
  p, S = input().split()
  p = int(p) - 1
  lst[p].append(S == 'AC')

ac = 0
wa = 0
for Q in lst:
  tmp_wa = 0
  for q in Q:
    if q == True:
      ac += 1
      wa += tmp_wa
      break
    else:
      tmp_wa += 1

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

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

Solution (Python):
n,m=map(int,input().split())
cor, wro = 0,0
solved = [False]*(n+1)
pen = [0]*(n+1)
for i in range(m):
    p,s = input().split()
    p = int(p)
    if s == 'AC' and not solved[p]:
        cor+=1
        solved[p]=True
    elif s == 'WA' and not solved[p]:
        pen[p]+=1
for i in range(n+1):
  if solved[i]:
    wro+=pen[i]
print(cor,wro)

Solution (Python):
a,b=map(int,input().split())
list = [0]*a
t_cnt = 0
f_cnt = [0]*a
for i in range(b):
  c, d = map(str,input().split())
  x = int(c) - 1
  if list[x] == 0:
    if d == 'AC':
        list[x] = 1
        t_cnt += 1
    else:
        f_cnt[x] += 1
for i in range(a):
  if list[i] ==0:
    f_cnt[i] = 0
print("{} {}".format(t_cnt, sum(f_cnt)))

Solution (Python):
from collections import defaultdict
n, m = map(int, input().split())
a = defaultdict(list)
for _ in range(m):
    p, s = input().split()
    a[p].append(1 if s == "AC" else 0)

ac, wa = 0, 0
for l in a.values():
    pcnt = 0
    for is_ac in l:
        if is_ac:
            ac += 1
            wa += pcnt
            break
        else: pcnt += 1

print(ac, wa)

Solution (Python):
a,b=map(int, input().split())
c=[0]*a
d=[0]*a
e=0
for i in range(b):
    p, s=input().split()
    p=int(p)-1
    if c[p]==0 and s=='AC':
        c[p]=1
        e+=d[p]
    d[p]+=1
print(sum(c),e)

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

isAC=[False]*100005
cntWA=[0]*100005
ans=0

for i in range(m):
	num = int(pss[i][0])
	if isAC[num]:
		continue
	if pss[i][1] == "WA":
		cntWA[num]+=1
	else:
		ans+=cntWA[num]
		isAC[num]=True
print(sum(isAC),ans)

Solution (Python):
n, m = map(int, input().split())
Ps = [ input().split() for _ in range(m)]
Prb = [[-1, -1] for _ in range(n)]
wa, ac = 0, 0
for ps in Ps:
    p, s = int(ps[0])-1, ps[1]
    if Prb[p][0] == -1:
        Prb[p][0] = 0
    if Prb[p][1] == -1:
        if s == 'WA':
            Prb[p][0] += 1
        else:
            Prb[p][1] = 1
            wa += Prb[p][0]
            ac += 1
print(ac, wa)

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

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

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

for p in range(n):
  if ac[p] == 0:
    pen[p] = 0
print(str(sum(ac)) + ' ' + str(sum(pen)))

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


N = input_int_list[0]
M = input_int_list[1]

Q_ans_list = [0] * (N+1)

ans_correct = 0
ans_penalty = 0

for i in range(M):
	input_list_i = list( input().split())
	Q_num = int(input_list_i[0])
	if input_list_i[1] == "WA":
		if Q_ans_list[Q_num] != -1:
			Q_ans_list[Q_num] = Q_ans_list[Q_num] + 1
	elif input_list_i[1] == "AC":
		if Q_ans_list[Q_num] != -1:
			ans_correct = ans_correct + 1
			ans_penalty = ans_penalty + Q_ans_list[Q_num]
			Q_ans_list[Q_num] = -1





print(ans_correct,ans_penalty)

Solution (Python):
N,M = map(int,raw_input().split())
ans_done = [[0 for i in range(3)] for j in range(N)]

for i in range(M):
  p,S = raw_input().split()
  p = int(p)-1
  if ans_done[p][0] == 0:
    ans_done[p][0] = p+1
    if S == "AC":
      ans_done[p][1] = 1
    else:
      ans_done[p][1] = 2
    if ans_done[p][1] == 2:
      ans_done[p][2] = ans_done[p][2] + 1
  elif ans_done[p][1] == 2:
    if S == "AC":
      ans_done[p][1] = 1
    else:
      ans_done[p][1] = 2
    if ans_done[p][1] == 2:
      ans_done[p][2] = ans_done[p][2] + 1

pen = 0
ans = 0
for i in ans_done:
  if i[1] == 1:
    ans = ans + 1
    pen = pen + i[2]
print ans,pen

Solution (Python):
def solve(string):
    n, m, *ps = string.split()
    n = int(n)
    ac = [0] * n
    wa = [0] * n
    for p, s in zip(*[iter(ps)] * 2):
        p = int(p) - 1
        if s == "AC":
            ac[p] = 1
        elif not ac[p]:
            wa[p] += 1
    return "{} {}".format(sum(ac), sum([w * a for a, w in zip(ac, wa)]))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

Solution (Python):
def solve(string):
    n, m, *ps = string.split()
    n = int(n)
    ac = [0] * n
    wa = [0] * n
    for p, s in zip(*[iter(ps)] * 2):
        p = int(p) - 1
        if s == "AC":
            ac[p] = 1
        elif not ac[p]:
            wa[p] += 1
    return "{} {}".format(sum(ac), sum([w if a else 0 for a, w in zip(ac, wa)]))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

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

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

for m in range(M):
  p, S = input().split()
  p = int(p)
  
  if S == 'AC' and AC[p-1] == 0:
    AC[p-1] = 1
  elif S == 'WA' and AC[p-1] == 0:
    WA[p-1] += 1

penalty = 0
for i in range(N):
  if AC[i] == 1:
    penalty += WA[i]
    
print(sum(AC), penalty)

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

pe = 0
acset = set()
peset = {}

if m > 0:
    for i,name in enumerate(ps):
        p1,s1 = name
        if s1 == "AC" and p1 not in acset:
            acset.add(p1)
            if p1 in peset:
                pe += peset[p1]
        elif p1 not in acset:
            if p1 not in peset:
                peset[p1] = 0
            peset[p1] += 1

ac = len(acset)
print(" ".join(list(map(str, [ac, pe]))))

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

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

    if s == "AC":
        ac[p] = True
    
    if s == "WA" and ac[p] == False:
        wa[p] += 1

ac_ans = ac.count(True)
wa_ans = sum([wa[i] for i in range(n) if ac[i] == True])

print(ac_ans, wa_ans)

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

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

ac_lis =[0]*N
wa_lis =[0]*N

for i in log:
    p,s = int(i[0])-1,i[1]
    if s=="AC":
        ac_lis[p]=1
    elif s=="WA" and not ac_lis[p]:
        wa_lis[p] +=1
for i in range(N):
    if not ac_lis[i]:
        wa_lis[i] = 0
        
print(sum(ac_lis), sum(wa_lis))

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

ac = [0] * N
wa = [0] * N
buff = [0] * N
for _ in range(M):
    p, S = input().split()
    p = int(p) - 1
    if ac[p] == 0:
        if S == 'AC':
            ac[p] = 1
            wa[p] = buff[p]
        else:
            buff[p] += 1
print(sum(ac), sum(wa))

Solution (Python):
N,  M = map(int, input().split())
p = []; S = []
for _ in range(M):
    pi, Si = input().split()
    p.append(int(pi))
    S.append(Si)

wa_count = [0] * N
is_ac = [False] * N
ac = 0; wa = 0
for i in range(M):
    if is_ac[p[i]-1] == True:
        continue
    else:
        if S[i] == 'AC':
            ac += 1
            wa += wa_count[p[i]-1]
            is_ac[p[i]-1] = True
        else:
            wa_count[p[i]-1] += 1

print(ac, wa)

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

WA = 0

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

    if ac[p] == 0 and s == 'AC':
        ac[p] = 1
        WA += wa[p]

    wa[p] += 1

print(sum(ac), WA)

Solution (Python):
N, M = map(int, input().split())
isAC = [False] * N
numWA = [0] * N
for i in range(M):
  p_str, S = map(str, input().split(' '))
  p = int(p_str) - 1
  if S == 'AC':
    isAC[p] = True
  else:
    if isAC[p]:
      continue
    numWA[p] += 1
    
ac = 0
wa = 0
for i in range(N):
  if isAC[i]:
    ac += 1
    wa += numWA[i]
print(str(ac) + " " + str(wa))