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())
a=[]
ac_list = [0]*N
wa_list= [0]*N
count_wa = 0
for i in range(M):
    p,s=input().split()
    p = int(p) - 1
    if ac_list[p] == 0:
        if s == 'WA':
            wa_list[p] += 1
        else:
            ac_list[p] = 1
for i in range(N):
    if ac_list[i] == 1:
        count_wa += wa_list[i]

print(sum(ac_list),count_wa)

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

pn_num=0
WA_list=[0]*N
AC_list=[0]*N

for _ in range(M):
    pi,Si=input().split()
    pi=int(pi)
        
    if Si=='AC':
        if AC_list[pi-1]==0:
            pn_num+=WA_list[pi-1]
            AC_list[pi-1]=1
    
    else:
        WA_list[pi-1]+=1
    
print(sum(AC_list),pn_num)

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

lac = [0] * n
lwa = [0] * n

for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if lac[p] == 0:
        if s == 'WA':
            lwa[p] += 1
        if s == 'AC':
            lac[p] = 1

lwa = [x * y for x, y in zip(lac, lwa)]
print(sum(lac), sum(lwa))

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

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

WAs = [0] * n
correct = 0
penalty = 0
for i in range(m):
    p, s = input().strip().split(' ')
    p = int(p) - 1
    if WAs[p] == -1:
        continue
    if s == 'AC':
        penalty += WAs[p]
        correct += 1
        WAs[p] = -1
    else:
        WAs[p] += 1

print(correct, penalty)

Solution (Python):
N,M= map(int,input().split())
P = [0 for _ in range(N+1)]
S = [0 for _ in range(N+1)]
for i in range(M):
    p, s = input().split()
    if s == "WA" and S[int(p)] != 1:P[int(p)] += 1
    if s == "AC":S[int(p)] = 1
for i in range(N+1):
    if S[i] == 0:P[i] = 0
print(sum(S),sum(P))

Solution (Python):

N,M=map(int,input().split())
 
ac = 0
wa = 0
aclist = {}
walist = {}

for i in range(N):
    aclist[i + 1] = 0
    walist[i + 1] = 0

for i in range(M):
    a,b=input().split()
    a=int(a)
    if aclist[a] == 1:
        continue
    elif b == 'WA':
        walist[a] += 1
    elif b == 'AC':
        aclist[a] += 1
        ac += 1
        wa += walist[a]

print(ac,wa,sep=" ")

Solution (Python):
a,b=map(int,input().split())
wa={i:0 for i in range(1,a+1)}
ac={i:0 for i in range(1,a+1)}
g=0
pe=0
if b==0:
    print("0 0")
    g=1
for i in range(b):
    c,d=input().split()
    
    if d=="WA" and ac[int(c)]==0:
        wa[int(c)]+=1
        
    if d=="AC" and ac[int(c)]==0:
        pe+=wa[int(c)]
        ac[int(c)]=1
    
        
f=0
h=0
if g==0:
    
    print(str(sum(ac.values()))+" "+str(pe))

Solution (Python):
s=[]
lis=[]
N,M=map(int, input().split())
wacount=0
account=0
count=0
zero=0
flag=1
cur=0
changeflag=1



 
for i in range(M):
     lis=input().split()
     
     lis[0]=int(lis[0])
     lis.append(i)
     
     s.append(lis)
 
s2=sorted(s,key=lambda x:x[0])
sorted(s2,key=lambda x:x[2])
j=1
for i in range(len(s2)):
    if s2[i][0]>j:
        j=s2[i][0]
        flag=1
        count=0
    if (s2[i][0]==j)and(flag==1):
        if s2[i][1]=="WA":
            count=count+1
        elif s2[i][1]=="AC":
            account=account+1
            wacount=wacount+count
            flag=0
            count=0
                
print(account,wacount)

Solution (Python):
from collections import defaultdict

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

ac = set()
wa = defaultdict(int)
ttl_wa = 0

for _ in range(M):
    pi, st = input().split()
    pi = int(pi)

    if st == 'AC':
        if pi not in ac:
            ac.add(pi)
            ttl_wa += wa[pi]
    else: 
        wa[pi] += 1

print(len(ac), ttl_wa)

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

for _ in range(M):
  p_str, s = map(str, input().split())
  p = int(p_str)
  if ac[p-1] == 1:
    continue
  if s == 'AC':
    ac[p-1] = 1
  if s == 'WA':
    wa[p-1] += 1

result = [x * y for (x, y) in zip(ac, wa)]
AC = sum(ac)
WA = sum(result)

print(AC, WA)

Solution (Python):
from itertools import groupby
N, M  =map(int, input().split())
ps = [[] for i in range(M)]
for i in range(M):
    ps[i] = list(input().split())
if M == 0:
    print(0,0)
    exit()
newps = sorted(ps,key=lambda i:i[0]) 
newpslist = list([list(g) for k, g in groupby(newps, key = lambda i:i[0])])
countAC = 0
counterror = 0
for group in newpslist:
    subcounterror = 0
    for subgroup in group:
        if subgroup[1] == 'WA':
            subcounterror += 1
        else:
            countAC += 1
            counterror += subcounterror
            break    
print(countAC, counterror)

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

a = [0] * (n+1)
b = [0] * (n+1)

c = 0

for i in [0]*(m):

    s = input().split()

    if a[int(s[0])] == 0:
        if s[1] == "AC":
            a[int(s[0])] = 1
            c += b[int(s[0])]
        else:
            b[int(s[0])] += 1

print(sum(a), c)

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

ac = 0
wa = 0
check = [0 for i in range(n)]
fail  = [0 for i in range(n)]
for i in range(m):
  p, s = map(str, input().split())
  if check[int(p)-1] == 1:
    continue
  if s == 'AC':
    check[int(p)-1] = True
    ac+=1
    wa+= fail[int(p)-1]
  else:
    fail[int(p)-1]+=1
      
print(str(ac) + " " + str(wa))

Solution (Python):
F_str = input().split()
F = [int(f) for f in F_str]
N = F[0]
M = F[1]

WA_list = [0 for _ in range(N)]
AC_list = [0 for _ in range(N)]

for i in range(M):
    S_str = input().split()
    S = [str(s) for s in S_str]
    if(S[1] == "AC"):
        AC_list[int(S[0])-1] = 1
    elif(AC_list[int(S[0])-1] != 1):
        WA_list[int(S[0])-1] += 1

WA_count = 0
AC_count = 0

for i in range(N):
    if(AC_list[i] == 1):
        AC_count += 1
        WA_count += WA_list[i]

print(AC_count, WA_count)

Solution (Python):
n, m = map(int, input().split())
li = []
for i in range(m):
  li.append(list(input().split()))
li_a = [0 for i in range(n)]
li_b = [0 for i in range(n)]
a = 0
b = 0
for j in range(m):
  if li[j][1] == "WA":
    li_b[int(li[j][0])-1] += 1
  elif li[j][1] == "AC" and li_a[int(li[j][0])-1] == 0:
    a += 1
    b += li_b[int(li[j][0])-1]
    li_a[int(li[j][0])-1] += 1
print(a, b)

Solution (Python):
from collections import OrderedDict
n, m = map(int,input().split())

aclist = [0]*n
walist = [0]*n
ac = 0
wa = 0
for i in range(m):
  pp, s = input().split()
  p = int(pp) - 1
  if s == 'AC' and not aclist[p]:
    aclist[p] = 1
    ac += 1
    wa += walist[p]
  else:
    walist[p] += 1
  

print(ac, wa)

Solution (Python):
N, M = list(map(int, input().split()))
lst = [input().split() for lst in range(M)]
pn = 0
lst_pn = []
lst_cr = []
for _ in range(N):
  lst_pn.append(0)
  lst_cr.append(0)
cr = 0
for i in lst:
  a = int(i[0])
  if lst_cr[a-1] == 1:
    continue
  elif i[1] == "WA":
    lst_pn[a-1] += 1
  elif i[1] == "AC":
    cr += 1
    lst_cr[a-1] += 1
    pn += lst_pn[a-1]
print(cr, pn)

Solution (Python):
def main():
    n, m = [int(i) for i in input().split()]
    wa = [0]*n
    ac = [0]*n
    
    for _ in range(m):
        p, s = input().split()
        if s == "WA":
            if ac[int(p)-1] == 0:
                wa[int(p)-1] += 1
        else:
            ac[int(p)-1] += 1
    
    print(n-ac.count(0), sum([wa[i] for i in range(n) if ac[i] >= 1]))


if __name__ == "__main__":
    main()

Solution (Python):
init = input().split(" ")
n = int(init[0])
m = int(init[1])

class problem():
  right_or_wrong = 0
  mistake = 0
  
  def set_right(self):
    self.right_or_wrong = 1
  
  def set_wrong(self):
    self.mistake += 1
  
  def check(self, result):
    if result == "AC":
      self.set_right()
    elif result == "WA" and self.right_or_wrong == 0:
      self.set_wrong()

if m == 0:
  print("0 0")
  exit()

result = {}
for i in range(m):
  score = input().split(" ")
  p = int(score[0])
  s = score[1]
  if p not in result:
    result[p] = problem()
  result[p].check(s)

ans = [0, 0]
for v in result.values():
  if v.right_or_wrong == 1:
    ans[0] += 1
    ans[1] += v.mistake

print(" ".join([str(i) for i in ans]))

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

ok, ng = (0, 0)
oks = set()
ngdict = dict()
for _ in range(M):
    pp, S = input().split()
    p = int(pp)
    if p in oks:
        continue
    if S == 'AC':
        ok += 1
        ng += ngdict.get(pp, 0)
        oks.add(p)
    else:
        ngdict[pp] = ngdict.get(pp, 0) + 1

print('{} {}'.format(ok, ng))

Solution (Python):
n,m=input().split()
n=int(n)
m=int(m)
x=[False for i in range(n)]
count=[0 for i in range(n)]
for i in range(m):
  p,s=input().split()
  p=int(p)
  if(not x[p-1]):
    if(s=="AC"):
      x[p-1]=True
    else:
      count[p-1]=count[p-1]+1
ans=0
ans2=0
for i in range(n):
  if(x[i]):
    ans+=1
    ans2+=count[i]
print(ans,ans2)

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

an1=0
an2=0
li=[0]*n

if m==0:
    print(an1,an2)
    exit()

for i in range(m):
    p,s=map(str,input().split())
    p=int(p)
    
    if s=="WA":
        if li[p-1]!=-1:
            li[p-1]+=1
    else:
        if li[p-1]!=-1:
            an1+=1
            an2+=li[p-1]
            li[p-1]=-1

print(an1,an2)

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

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

penal = 0
for _ in range(M):
    p,s = map(str,input().split())
    p = int(p)
    if AC[p]:
        continue
    if s == "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())
AC = 0
WA = 0
lis = [0] * N
for i in range(M):
  a,b = input().split()
  if lis[int(a)-1] < 0:
    pass
  elif b == 'AC':
    WA += lis[int(a)-1]
    AC += 1
    lis[int(a)-1] = -1
  else:
    lis[int(a)-1] += 1
print(AC, WA)

Solution (Python):
n, m = map(int, input().split())
ps = []
for i in range(m):
    p, s = input().split()
    ps.append([int(p), s])
flag = [False for _ in range(n)]
ac = [0 for _ in range(n)]
wa = [0 for _ in range(n)]
i = 0
sumac = 0
sumwa = 0

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

print(str(sumac) + " " + str(sumwa))

Solution (Python):
N, M = map(int, input().split())
A = [input().split() for i in range(M)]
problems = {}
rejected = [0]*(N+1)
reject_count = 0
for P, S in A:
    P = int(P)
    if not problems.get(P):
        if S != 'AC':
            rejected[P] += 1
        else:
            problems[P] = S
for i in range(N+1):
    if problems.get(i):
        reject_count += rejected[i]
print(len(problems), reject_count)

Solution (Python):
n,m=map(int,input().split())
cnt1=[0]*(n+1)
cnt2=[0]*(n+1)
for _ in range(m):
  p,s=map(str,input().split())
  p=int(p)
  if cnt1[p]==1:
    continue
  else:
    if s=='AC':
      cnt1[p]=1
    else:
      cnt2[p]+=1
ans1=0
ans2=0
for i in range(1,n+1):
  if cnt1[i]==1:
    ans1+=1
    ans2+=cnt2[i]
print(ans1,ans2)

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

PS = {}
for _ in range(m):
    p, s = input().split()
    try:
        PS[int(p)].append(s)
    except KeyError:
        PS[int(p)] = [s]

a, b = 0, 0
for S in PS.values():
    if "AC" in S:
        for s in S:        
            if s == "AC":
                a += 1
                break
            if s == "WA":
                b += 1

print(a, b)

Solution (Python):
import numpy as np

N,M = map(int,input().split())
OK = np.zeros(N, dtype = int)
NG = np.zeros(N, dtype = int)
for i in range(M):
    p,s = map(str,input().split())
    p = int(p)
    if s == 'AC':
        s = 1
        OK[p-1]=1
    else:
        if OK[p-1]==0:
            NG[p-1]+=1
    
cOK = sum(OK)
cNG = sum(NG[OK==1])

print(cOK, cNG)

Solution (Python):
n,m=map(int,input().split())
p=[];s=[]
if m==0:
    print(0,0)
    exit()
for i in range(m):
    x,y=input().split()
    p.append(int(x))
    s.append(y)
ac=0
wa=0
t=[0]*(n+1)
wf=[0]*(n+1)
for i in range(m):
    if t[p[i]]>=1:
        continue
    elif s[i]=="WA":
        wf[p[i]]+=1
    elif s[i]=="AC":
        t[p[i]]+=1
        ac+=1
        wa+=wf[p[i]]
print(ac,wa)

Solution (Python):






from sys import stdin,setrecursionlimit










setrecursionlimit(10**6)
input=stdin.readline

n,m=map(int,input().split())
c=[False]*n
cnt=[0]*n
ac,pena=0,0
for i in range(m):
    p,s=input().split()
    p=int(p)-1
    if not c[p] and s=="AC":
        pena+=cnt[p]
        c[p]=True
    elif s=="WA":
        cnt[p]+=1

print(c.count(True),pena)

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

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

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

print(n-ac.count(0), sum([wa[i] for i in range(n) if ac[i] >= 1]))

Solution (Python):
N,M = map(int,input().split())
lis_ac = [None] * N
lis_wa = [0] * N
ac = 0
wa = 0
for i in range(M):
    a,b = map(str,input().split())
    a = int(a)
    if b == 'AC' and lis_ac[a-1] == None:
        lis_ac[a-1] = 'AC'
        ac += 1
        wa += lis_wa[a-1]
    elif b == 'AC' and lis_ac[a-1] == 'AC':
        continue
    elif b == 'WA' and lis_ac[a-1] == 'AC':
        continue
    else:
        lis_wa[a-1] += 1
print(ac,wa)

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

Solution (Python):
from collections import defaultdict
d = defaultdict(int)

N,M = map(int,input().split())
li = []
for m in range(M):
  x,y = input().split()
  li.append([int(x), y])

sets = set()

ac = 0
wa = 0

for i in li:
  if i[1] == 'AC':
    if i[0] not in sets:
      sets.add(i[0])
      ac += 1
      wa += d[i[0]]

  else:
    if i[0] not in sets:
      d[i[0]] += 1

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

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


ac = 0
wa = 0
aclist = {}
walist = {}

count_WA=0
for i in range(N):
    aclist[i + 1] = 0
    walist[i + 1] = 0

for i in range(M):
    a,b=input().split()
    a=int(a)
    if aclist[a] == 1:
        continue
    elif b == 'WA':
        walist[a] += 1
    elif b == 'AC':
        aclist[a] += 1
        ac += 1
        wa += walist[a]




print(ac,wa,sep=" ")

Solution (Python):
s=list(map(int,input().split()))
ans=[list(map(str,input().split())) for i in range(s[1])]
ac=[0]*s[0]
wa=[0]*s[0]
a=0
b=0
c=0
for i in range(s[1]):
  c=int(ans[i][0])-1
  if ac[c]==0:
    if ans[i][1]=='WA':
      wa[c]+=1
    else:
      a+=1
      b+=wa[c]
      ac[c]=1
print(a,b)

Solution (Python):


import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N, M = read_ints()
from collections import defaultdict
flgs = [False] * N  
n_wa_ls = [0] * N


for _ in range(M):
    p, s = input().split()
    p = int(p) - 1
    if flgs[p]:
        continue
    if s == 'AC':
        flgs[p] = True
    elif s == 'WA':
        n_wa_ls[p] += 1

n_wa = 0
for i in range(N):
    if flgs[i]:
        n_wa += n_wa_ls[i]

print(sum(flgs), n_wa)

Solution (Python):
def main():
    N, M = map(int, input().split(" "))
    ac = 0
    wa = 0
    answer = ["C"] * N  
    for _ in range(M):
        ps = input().split(" ")
        p = int(ps[0]) - 1
        if not answer[p][-1] == "A":
            answer[p] = answer[p] + ps[1][0]
    if M > 0:
        for a in answer:
            if a[-1] == "A":
                ac += 1
                wa += (len(a) - 2)
    print(ac, wa)


if __name__ == '__main__':
    main()

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

acd = dict()
pcd = dict()
ac = 0
pc = 0
for i in range(M):
    p, S = input().split(' ')
    if p not in acd:
        if S == 'AC':
            acd[p] = 1
            ac += 1
            if p in pcd:
                pc += pcd[p]
        else:
            if p not in pcd:
                pcd[p] = 1
            else:
                pcd[p] += 1

print("{} {}".format(ac, pc))

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    n, m = MAP()
    ac = defaultdict(int)
    wa = defaultdict(int)
    for i in range(m):
        p, s = input().split()
        p = int(p)
        if s == "AC":
            ac[p] = 1
        else:
            if ac[p] == 0:
                wa[p] += 1
    for i in range(1,n+1):
        if ac[i] == 0:
            wa[i] = 0

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


if __name__=='__main__':
    main()

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

a = []
for i in range(M):
    a.append(int(p[i]))

AC = 0
P = 0

Q = []
R = []
for i in range(N):
    Q.append(0)
    R.append(0)

for i in range(M):
    index = a[i] - 1
    if Q[index] == 0 and S[i] == 'AC':
        AC = AC + 1
        Q[index] = 1
    elif Q[index] == 0 and S[i] == 'WA':
        R[a[i] - 1] = R[a[i] - 1] + 1

for i in range(N):
    if Q[i] == 0:
        P = P
    else: P = P + R[i]

print(AC, P)

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


data = []
for i in range(1, M+1):
    p,S = map(str, input().split())
    s = 0
    if S == 'AC':
        s = 1
    data.append([int(i),int(p),int(s)])


sorted_data = sorted(data, key=lambda x:(x[1], x[0]))

before = 0
is_ac = False
ac_num = 0
wa_num = 0
tmp = 0
for val in sorted_data:
    if before == val[1]:
        if is_ac:
            continue
        else:
            if val[2] == 1:
                ac_num += 1
                wa_num += tmp
                is_ac = True
            else:
                tmp += 1
    else:
        is_ac = False
        before = val[1]
        tmp = 0
        if val[2] == 1:
            ac_num += 1
            is_ac = True
        else:
            tmp += 1

print(str(ac_num)+' '+str(wa_num))

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

ac = 0
wa = [0 for i in range(N)]
ansed = set()
for psn in ps:
    if psn[1] == 'AC':
        if psn[0] not in ansed:
            ac += 1
            ansed.add(psn[0])
    else:
        if psn[0] not in ansed:
            wa[int(psn[0])-1] += 1
for i in range(N):
    if str(i+1) not in ansed:
        wa[i] = 0

print(ac, sum(wa))

Solution (Python):
n,m = map(int,input().split())
ac = 0
wa = 0
aclist = {}
walist = {}
for i in range(n):
    aclist[i + 1] = 0
    walist[i + 1] = 0

for i in range(m):
    a,b = input().split()
    a = int(a)
    if aclist[a] == 1:
        continue
    elif b == 'WA':
        walist[a] += 1
    elif b == 'AC':
        aclist[a] += 1
        ac += 1
        wa += walist[a]
        
print(ac, wa)

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

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

for i in range(M):
    if S[i] == "WA":
        if AC[P[i]] == 0:
            wa[P[i]] += 1
    else:
        AC[P[i]] = 1

for i in range(N+1):
    WA += wa[i]*AC[i] 

print(sum(AC[1:]), WA)

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

problem = [0] * n
count = [0] * n

penal = 0

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

for i in range(n):
    if problem[i] == 0:
        count[i] = 0

print("{}".format(sum(problem)) + " {}".format(sum(count)))

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

N, M = list(map(int, input().split()))
ac = np.zeros(N, dtype=np.int)
wa = np.zeros(N, dtype=np.int)
for n in range(M):
    p, S = input().split()
    p = int(p)
    if ac[p - 1] == 1:
        continue
    if S == 'AC':
        ac[p - 1] = 1
    else:
        wa[p - 1] += 1
wa = str(sum(wa * ac))
ac = str(sum(ac))
ans = ac + ' ' + wa
print(ans)

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

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

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

for i in range(M):
    p, s = input().split()
    j = int(p) - 1
    if s == 'AC':
        acs[j] = 1
    elif s == 'WA':
        if acs[j] == 0:
            was[j] += 1

ac, wa = 0, 0
for i in range(N):
    ac += acs[i]
    if acs[i]:
        wa += was[i]

print(ac, wa)

Solution (Python):
def main():
    N, M= map(int, input().split())
    
    acList = [False] * N
    waList = [0] * N
    waCount = 0

    for _ in range(M):
        p, s = map(str, input().split())
        p = int(p) - 1
        if acList[p]:
            continue
        if s == "WA":
            waList[p] += 1
            continue
        waCount += waList[p]
        acList[p] = True

    print(sum(acList), waCount)

if __name__ == "__main__":
    main()

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

Solution (Python):
import sys

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

p_S = []
for _ in range(M):
    p_S.append(input().split())
    
p = []
S = []


for i in range(M):
    p_S[i][0] = int(p_S[i][0])
    p_S[i][1] = int(p_S[i][1] =='AC')
    
p_S.sort(key=lambda x: x[0])

for i in range(M):
    p.append(p_S[i][0])
    S.append(p_S[i][1])

p = list(map(int, p))
S = list(map(int, S))

flag_p = p[0]
flag_ac = 0
AC_sum = 0
WA_sum = 0
WA = 0

for i in range(M):

    if flag_p == p[i]:
        if S[i] == 0 and flag_ac == 0:
            WA += 1
        elif S[i] == 1 and flag_ac == 0:
            AC_sum += 1
            WA_sum += WA
            flag_ac = 1
    else:
        flag_p = p[i]
        flag_ac = 0
        WA = 0
        if S[i] == 0 and flag_ac == 0:
            WA += 1
        elif S[i] == 1 and flag_ac == 0:
            AC_sum += 1
            WA_sum += WA
            flag_ac = 1

print(AC_sum, WA_sum)

Solution (Python):
import sys

N, M = [int(x) for x in sys.stdin.readline().rstrip().split(" ")]

count = [0 for x in range(N + 1)]

ac = 0
pena = 0


for i in range(M):
	p, S = sys.stdin.readline().rstrip().split(" ")
	p = int(p)
	if count[p] >= 0:
		if S == "AC":
			ac += 1
			pena += count[p]
			count[p] = -1
		else:
			count[p] += 1

print("%d %d" % (ac, pena))

Solution (Python):
nm = list(map(int, (input().split())))
if nm[1] == 0:
    print(0, 0)

else:    
    ans_dict = {}
    ans_list = [input().split() for i in range(nm[1])]
    for i in range(len(ans_list)):
        key_val = ans_list[i][0]

        try:
            ans_dict[key_val].append(ans_list[i][1])
        except:
            ans_dict[key_val] = [ans_list[i][1]]
    ans_cnt = 0
    wa_cnt = 0
    for key_val in ans_dict.keys():
        check_list = ans_dict[key_val]

        if "AC" in check_list:
            ans_cnt += 1
        else:
            pass
        try:
            wa_cnt += len(check_list[:check_list.index("AC")])
        except:
            pass
    print(ans_cnt, wa_cnt)

Solution (Python):
import numpy as np
n, m = map(int, input().split())
record = np.zeros(n)
penalty = np.zeros(n)
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if record[p]:
        continue
    else:
        if s == "AC":
            record[p] = 1
        elif s == "WA":
            penalty[p] += 1

ans1 = int(sum(record))
ans2 = int(np.dot(record, penalty))
print(ans1, ans2)

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

p = [0]*(n+1)
q = [False]*(n+1)

for _ in range(m) :
  v,s = input().split()
  v = int(v)
  if q[v] : continue
  if s[0] == 'A' : q[v] = True
  else : p[v] += 1

print(sum(q), sum(p[i] for i in range(n+1) if q[i]))

Solution (Python):
import sys
from functools import reduce

n, m = map(int, input().split())
ps = [r.split() for r in sys.stdin.read().split('\n') if r != '']
log = []
for i in range(0, n):
    log.append([])
for j in range(0, m):
    i = int(ps[j][0])
    log[i-1].append(ps[j][1])
wacount = sum(map(lambda l: l.index('AC'), filter(lambda e: e.count('AC') > 0, log)))
print(len(list(filter(lambda e: e.count('AC') > 0, log))),
        wacount)

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

ans = [0 for i in range(N)]
done = [False for i in range(N)]

suc = 0

for j in range(M):
	
	p, S = [num for num in input().split(' ')]
	p = int(p)
    
	if done[p-1] == False:
		if S == 'AC':
			done[p-1]=True
			suc+=1
		else:
			ans[p-1]+=1
	else: 
		if S == 'AC':
			pass
		else:
			pass

pen = 0
for i, ans_i in enumerate(ans):
	if done[i]==True: pen+=ans_i

print('{} {}'.format(suc, pen))

Solution (Python):
import numpy as np
N,M=map(int,input().split())
A=[]
for i in range(M):
  A.append(tuple(map(str,input().split())))
check=np.zeros((N,2))
for i in range(M):
  if check[int(A[i][0])-1,0]==0:
    if A[i][1]=='WA':
      check[int(A[i][0])-1,1]+=1
    elif A[i][1]=='AC':
      check[int(A[i][0])-1,0]+=1
for i in range(N):
  if check[i,0]==0:
    check[i,1]=0
sum=check.sum(axis=0)
print(int(sum[0]),int(sum[1]))

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

        if s=='WA':
            WA[p]+=1

        else:
            AC[p]=1
            A+=1

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

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

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

for i in range(M):
    s = int(ps[i][0])-1
    if ps[i][1] == "WA" and ac[s] == 0:
        wa[s] += 1

    if ps[i][1] == "AC" and ac[s] == 0:
        ac[s] = 1

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

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

Solution (Python):
def main():
    N, M = map(int, input().split())
    ans = [False for _ in range(N)]
    wa_list = [0 for _ in range(N)]
    ac = 0
    wa = 0
    for _ in range(M):
        i, result = input().split()
        i = int(i)
        if result == "AC":
            if ans[i-1] == False:
                ac += 1
                ans[i - 1] = True
                wa += wa_list[i-1]
        else:
            if ans[i - 1] == False:
                wa_list[i - 1] += 1
    if sum(ans) == 0:
        wa = 0
    print(ac, wa)
    return 0
if __name__ == '__main__':
    main()

Solution (Python):
n, m = map(int, input().split(' '))
problem = [0] * n
ok=0
pen=0
i=0

while i < m:
    p, result = input().split(' ')
    p = int(p) - 1
    if problem[p] < 0:
        pass
    else:
        if result == 'WA':
            problem[p] += 1
        else:
            ok += 1
            pen += problem[p]
            problem[p] = -1
    i+=1
print('{} {}'.format(ok, pen))

Solution (Python):
N, M = list(map(int, input().split(' ')))
AC_total = 0
WA_total = 0
ac_list = [False] * N
wa_list = [0] * N
for i in range(M):
    p, s = input().split(' ')
    p = int(p) - 1
    if not ac_list[p]:
        if s == 'WA':
            wa_list[p] += 1
        else:
            AC_total += 1
            WA_total += wa_list[p]
            ac_list[p] = True
print('{} {}'.format(AC_total, WA_total))

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

Solution (Python):
import sys
from functools import reduce

n, m = map(int, input().split())
ps = [r.split() for r in sys.stdin.read().split('\n') if r != '']
ps.sort(key=lambda t: int(t[0]))
log = []
for i in range(0, n):
    log.append([])
for j in range(0, m):
    i = int(ps[j][0])
    log[i-1].append(ps[j][1])
wacount = sum(map(lambda l: l.index('AC'), filter(lambda e: e.count('AC') > 0, log)))
print(len(list(filter(lambda e: e.count('AC') > 0, log))),
        wacount)

Solution (Python):
N,M = map(int, input().split())
p = [0]*M
S = [0]*M
for i in range(M):
    p[i],S[i] = input().split()
q = [int(s)-1 for s in p]
X = [0]*N
Y = [0]*N
A = 0
B = 0
for i in range(M):
    if S[i] == "AC":
        if Y[q[i]]==0:
            Y[q[i]]+=1
            A += 1
            B += X[q[i]]
    else:
        if Y[q[i]]==0:
            X[q[i]] += 1
print(str(A)+" "+str(B))