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())

AC = [0 for i in range(N)]
WA = [0 for i in range(N)]

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

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

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

Solution (Python):
N,M=map(int,input().split())
ac,wa=0,0
task=[0]*N
for m in range(M):
    p,S=input().split()
    p=int(p)-1
    if task[p]!=-1 and S=="WA":
        task[p]+=1
    elif task[p]!=-1 and S=="AC":
        ac+=1
        wa+=task[p]
        task[p]=-1
print(ac,wa)

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

for i in range(m):
    p, s = input().split()
    p = int(p)
    if s == 'AC' and pena_list[p-1][0] == 0:
        ac += 1
        wa += pena_list[p-1][1]
        pena_list[p-1][0] = 1
    elif s == 'WA':
        pena_list[p-1][1] += 1

print(ac, wa)

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

rslts = [[] for _ in range(n)]
for i in range(m):
    x, y = input().split()
    rslts[int(x) - 1].append(y)


ac, p = 0, 0
for j in range(n):
    seq = rslts[j]
    if 'AC' in seq:
        ac += 1
        for k in seq:
            if k == 'WA':
                p += 1
            else:
                break

print(ac, p)

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

ac_num=0
wr_num=0
for i in range(n):
  if "AC" in check[i]:
    ac_num=ac_num+1
    wr_num=wr_num+check[i].index("AC")

print(str(ac_num)+" "+str(wr_num))

Solution (Python):
n,m = map(int,input().split())
di = [[] for _ in range(n)]
ac = 0
wa = 0
for i in range(m):
    a,b = map(str,input().split())
    di[int(a)-1].append(b)
for j in range(n):
    if "AC" in di[j]:
        wa += di[j].index("AC")
        ac += 1
print(ac,wa)

Solution (Python):
N,M = map(int,input().split())
a = 0
w = 0
lis = [[] for _ in range(N)]
for i in range(M):
  p,s = map(str,input().split())
  p = int(p)
  lis[p - 1].append(s)
for j in range(N):
  if lis[j].count("AC") > 0:
    a += 1
    w += lis[j].index("AC")

    
print(a,w)

Solution (Python):
n,m = map(int,input().split())
di = [[] for _ in range(n)]
ac = 0
wa = 0
for i in range(m):
    a,b = map(str,input().split())
    di[int(a)-1].append(b)
for j in range(n):
    if "AC" in di[j]:
        wa += di[j].index("AC")
        ac += 1
print(ac,wa)

Solution (Python):

N,M=map(int,input().split())
re=[0 for i in range(N+1)]
P=[0 for i in range(N+1)]
x=0
y=0
for i in range(M):
    p,S=input().split()
    p=int(p)
    if re[p]=="AC":
        continue
    elif S=="WA":
        P[p]+=1
    elif S=="AC":
        re[p]="AC"
        y+=1
for i in range(1,N+1):
    if re[i]=="AC":
        x+=P[i]
print(y,x)

Solution (Python):
N,M = input().split()
l = [0]*int(N) 
m = [0]*int(N) 
c =0

for i in range(int(M)):
    p,s = input().split()
    if s =="AC":
        if l[int(p)-1]==1:
            pass
        else:
            l[int(p)-1] = 1
            c += m[int(p)-1]
    elif s == "WA":
        m[int(p)-1] += 1



print(l.count(1),c)

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

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

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

Solution (Python):
N, M = map(int, input().split())
penalty = 0
AC = [0]*N
WA = [0]*N
for i in range(M):
    p, S = input().split()
    if S == 'AC':
        AC[int(p)-1]=1
    else:
        if AC[int(p)-1]==0:
            WA[int(p)-1] += 1
penalty = [a*b for a, b in zip(AC, WA)]
print(sum(AC), sum(penalty))

Solution (Python):
N, M = list(map(int,input().split()))
A = []
for i in range(M):
    in1, in2 = input().split()
    A.append([int(in1) - 1, in2])
    
ac = [0 for _ in range(N)]
wa = [0 for _ in range(N)]

for i in range(M):
    if A[i][1] == "AC":
        ac[A[i][0]] = 1
    else:
        if ac[A[i][0]] == 0:
            wa[A[i][0]] += 1
            
ac_sum = sum(ac)

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

print(ac_sum, wa_sum)

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

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

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

ACflg = [0] * N
WAflg = [0] * N

WAcnt = 0
for _ in range(M):
    p, S = list(input().split())
    p = int(p)
    if(S == "AC"):
        if(ACflg[p-1] == 0):
            ACflg[p - 1] = 1
            WAcnt += WAflg[p-1]
    
    else:
        if(ACflg[p - 1] == 0):
            WAflg[p - 1] += 1




print(sum(ACflg), WAcnt)

Solution (Python):

n, m = map(int, input().split())
submits = []
for i in range(m):
  ta, tb = map(str, input().split())
  submits.append([int(ta), tb])

ac = [0 for i in range(n+1)]
ac_cnt = 0
wa = [0 for i in range(n+1)]
wa_cnt = 0


for s in submits:
  if s[1] == "WA" and ac[s[0]] == 0:
    wa[s[0]] += 1
  if s[1] == "AC" and ac[s[0]] == 0:
    ac[s[0]] += 1


for i in range(n+1):
  if ac[i] == 1:
    ac_cnt += ac[i]
    wa_cnt += wa[i]

print(ac_cnt, wa_cnt)

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

submit = [input().split() for i in range(M)]
ans = [[0, 0] for i in range(N)]

for i in range(M):
    tmp = int(submit[i][0]) - 1
    if submit[i][1] == 'AC' and ans[tmp][0] == 0:
        ans[tmp][0] += 1
    elif submit[i][1] == 'WA' and ans[tmp][0] == 0:
        ans[tmp][1] += 1

print(sum(ans[i][0] for i in range(N)), sum(ans[i][1] for i in range(N) if ans[i][0] == 1))

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

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

right = [False]*n
penalty = [0]*n

for i in range(m):
    p,s = input().split()
    p = int(p)-1
    if right[p]:
        pass
    else:
        if s == "AC":
            right[p] = True
        else:
            penalty[p] += 1
r = 0
pen = 0

for j in range(n):
    if right[j]:
        r += 1
        pen += penalty[j]

print(r,pen)

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

print(sum(A),sum(W))

Solution (Python):


def main():
    N, M = map(int, input().split())
    
    cnt = [[0, 0] for _ in range(N)]
    for _ in range(M):
        num, status = input().split()
        num = int(num) -1
        if status == "AC":
            if cnt[num][0] == 0:
                cnt[num][0] += 1
        if status == "WA":
            if cnt[num][0] == 0:
                cnt[num][1] += 1

    ac_cnt, wa_cnt = 0, 0
    for i in range(N):
        if cnt[i][0] == 1:
            ac_cnt += cnt[i][0]
            wa_cnt += cnt[i][1]

    print(ac_cnt, wa_cnt, sep=" ")

if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np

num_of_problems, num_of_submittions = map(int, input().split())
submittions = []
for _ in range(num_of_submittions):
    submittions.append(list(input().split()))

WAs = [0] * num_of_problems
ACs = [0] * num_of_problems

for submittion in submittions:
    problem_index = int(submittion[0]) - 1
    result = submittion[1]

    if result == 'WA' and ACs[problem_index] == 0:
        WAs[problem_index] = WAs[problem_index] + 1

    if result == 'AC' and ACs[problem_index] == 0:
        ACs[problem_index] = 1


WAs = np.array(WAs) * np.array(ACs)

print(str(ACs.count(1)) + ' ' + str(sum(WAs)))

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())

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

for i in range(m):
    p, s = readline().decode().rstrip().split()
    if ac[int(p) - 1] == 0:
        if s == 'AC':
            ac[int(p) - 1] += 1
            pena[int(p) - 1] += wa[int(p) - 1]
        else:
            wa[int(p) - 1] += 1

print(sum(ac), sum(pena))

Solution (Python):

import sys
input = lambda: sys.stdin.readline().strip()

def solve(N: int, M: int, p: "List[int]", S: "List[str]"):
    solved = [False for i in range(N + 1)]
    penalties = [0 for i in range(N + 1)]
    for prob, verd in zip(p, S):
        if not solved[prob]:
            penalties[prob] += verd == 'WA'
            solved[prob] = verd == 'AC'
    print(sum(solved), sum(penalty for i, penalty in enumerate(penalties) if solved[i]))
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    M = int(next(tokens))  
    p = [int()] * (M)  
    S = [str()] * (M)  
    for i in range(M):
        p[i] = int(next(tokens))
        S[i] = next(tokens)
    solve(N, M, p, S)

if __name__ == '__main__':
    main()

Solution (Python):

N ,M = map(int, input().split())
AC = [0] + [0] * N
WA = [0] + [0] * N
for m in range(M):
    p, S = map(str, input().split())
    if S == 'WA' and AC[int(p)] != 1:
        WA[int(p)] += 1
    else:
        AC[int(p)] = 1
print(' '.join([str(x) for x in [sum(AC), sum([WA[i] for i in range(N+1) if AC[i] == 1 ])] ]) )

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

def main():
    N,M = map(int, readline().split())

    is_solved = [False] * (N + 1)
    wa_cnt = [0] * (N + 1)
    pena = 0

    for _ in range(M):
        p, s = readline().split()
        p = int(p)
        if s == "WA":
            if is_solved[p]:
                continue
            else:
                wa_cnt[p] += 1
        else:
            if is_solved[p]:
                continue
            else:
                pena += wa_cnt[p]
                is_solved[p] = True

    print(sum(is_solved), pena)


if __name__ == "__main__":
    main()

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

def main():
    N,M = map(int, readline().split())

    is_solved = [False] * (N + 1)
    wa_cnt = [0] * (N + 1)

    for _ in range(M):
        p, s = readline().split()
        p = int(p)
        if s == "WA":
            if is_solved[p]:
                continue
            else:
                wa_cnt[p] += 1
        else:
            is_solved[p] = True

    ac = 0
    pena = 0
    for i in range(1, N+1):
        if is_solved[i]:
            ac += 1
            pena += wa_cnt[i]

    print(ac, pena)


if __name__ == "__main__":
    main()

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

memo = {key:0 for key in range(1, N+1)}
AC = 0
WA = 0



for _ in range(M):
    pi, Si = input().split()
    pi = int(pi)
    if memo[pi] != "AC":
        if Si == "WA":
            memo[pi] += 1
        elif Si == "AC":
            AC += 1
            WA += memo[pi]
            memo[pi] = "AC"

print(AC, WA)

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

    if s == "AC":
        res[int(p)-1]=1
    if s == "WA" and not res[int(p)-1]:
        wa[int(p)-1]+=1
for i in range(n):
    if res[i]:
        pena += wa[i]
print(sum(res), pena)

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

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

print(sum(AC), w)

Solution (Python):
n,m=[int(_) for _ in input().split()]
p=[0 for i in range(m)]
s=[0 for i in range(m)]
for i in range(m):
    _p,_s=input().split()
    p[i]=int(_p)-1
    s[i]=_s

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

for  i in range(m):
    if s[i]=="WA" and not(ac[p[i]]):
        wa[p[i]]+=1
    else:
        ac[p[i]]=True

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

print(sum(ac),sum(wa))

Solution (Python):

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

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

ac = 0
wa = 0
res1 = [0]*n
res2 = [0]*n
for i in range(m):
  p, s = list(map(str, input().split()))
  if s == 'AC' and res1[int(p)-1] == 0:
    ac += 1
    res1[int(p)-1] = 1
    wa += res2[int(p)-1]
  elif s == 'WA' and res1[int(p)-1] == 0:
    res2[int(p)-1] += 1
print(ac, wa)

Solution (Python):
n,m=[int(x) for x in input().rstrip().split()]
dic={}
wa=[0 for i in range(n)]
ac=[0 for i in range(n)]
ans=0
pena=0
for i in range(m):
  p,s=[x for x in input().rstrip().split()]
  p=int(p)
  if p in dic:
    if dic[p]=="WA" and s=="WA":
      wa[p-1]+=1
    elif dic[p]=="WA" and s=="AC":
      ac[p-1]=1
      dic[p]="AC"
      pena+=wa[p-1]

  else:
    if s=="AC":
      ac[p-1]=1
      dic[p]="AC"
    else:
      dic[p]=s
      wa[p-1]=1

print(sum(ac),pena)

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

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

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

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

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

ac_sum = 0
wa_sum = 0

for j in range(N):
    ac_sum += arr[j][1]
    if arr[j][1] == 1:
        wa_sum += arr[j][0]

print(str(ac_sum) + ' ' + str(wa_sum))

Solution (Python):


NM=list(map(int,input().split()))
ac_count=0
wa_count=0

dic={}
ac_flag={}
for i in range(NM[0]+1):
    s=str(i)
    dic[s]=0
    ac_flag[s]=False

for i in range(NM[1]):
    ps=list(input().split())
    p=ps[0]
    S=ps[1]
    if S=="WA" and ac_flag[p]==False:
        dic[p]+=1
    elif S=="AC" and ac_flag[p]==False:
        ac_count+=1
        wa_count+=dic[p]
        ac_flag[p]=True
    else:pass
    
print(str(ac_count)+" "+str(wa_count))

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

print(ac,wa)

Solution (Python):
N,M = map(int,input().split())
AC = [0] * N
WA = [0] * N
a = 0
b = 0
for i in range(M):
    s = list(input().split())
    c = int(s[0])
    if s[1] == "AC":
        AC[c - 1] = 1
    elif AC[c - 1] == 0:
        WA[c - 1] += 1
for i in range (N):
    if AC[i] == 1:
        a += 1
        b += WA[i]
print(a,b)

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

for i in range(m):
    p,s = input().split()
    p = int(p)-1
    if s == 'AC' and j[p] == 0:
        ac += 1
        j[p] = 1
        wa += w[p]
    elif s == 'WA' and j[p] == 0:
        w[p] += 1

print(ac,wa)

Solution (Python):
n,m = map(int,input().split())
submit = []
for i 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,m = map(int,input().split())
ac,wa = 0,0
number=[0]*n

for i in range(m):
  p,s = input().split()
  p = int(p) - 1
  if number[p]!=-1:
    if s == "WA":
      number[p]+=1
    elif s == "AC":
      ac+=1
      wa+=number[p]
      number[p]=-1
print(ac,wa)

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

ac = set()
wa = {}
c = 0
for p,s in ps:
  if p in ac:
    continue

  if s == 'WA':
    if p in wa:
      wa[p] += 1
    else:
      wa[p] = 1

  if s == 'AC':
    ac.add(p)
    if p in wa:
      c += wa[p]
    continue

print(len(ac) , c)

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

for i in range(m):
    p,s = input().split()
    p = int(p)-1
    if s == 'AC' and j[p] == 0:
        ac += 1
        j[p] = 1
        wa += w[p]
    elif s == 'WA' and j[p] == 0:
        w[p] += 1

print(ac,wa)

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

acline = [0]*n
wanum = [0]*n

for i in range(m):
    num, acwa = map(str, input().split())
    
    num = int(num) -1
    
    if acwa == "AC":
        acline[num] = 1
    else:
        if acline[num] == 1:
            continue
        else:
            wanum[num] += 1
            
for j in range(n):
    if acline[j] == 0:
        wanum[j] = 0
            
print(sum(acline), sum(wanum))

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

check_ac = [0]*n 
cnt_wa = [0]*n 

for i in range(m):
    p, s = map(str, input().split())
    p = int(p)-1
    if s == "AC": 
        if check_ac[p]==0:
            check_ac[p] = 1
    else:
        if not check_ac[p]:
            cnt_wa[p] += 1

for i in range(n):
    if not check_ac[i]:
        cnt_wa[i]=0

print(sum(check_ac), sum(cnt_wa))

Solution (Python):
def main():
    N,M = map(int, input().split())
    ac = [0]*N
    wa = [0]*N
    pen = 0
    for i in range(M):
        p,s = input().split()
        p = int(p)-1
        if ac[p]==0:
            if s=='AC':
                ac[p] = 1
                pen += wa[p]
            else:
                wa[p] += 1
    ans = [sum(ac), pen]
    print(*ans)

main()

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

ps = []
for i in range(m):
  ps.append(input())

ans = [0] * (n+1)
pen = [0] * (n+1)
sum1 = 0
for i in range(m):
  p,s = ps[i].split()
  if ans[int(p)] == 0:
    if s == "AC" :
      ans[int(p)] += 1
      sum1 += pen[int(p)]
    else:
      pen[int(p)] += 1

print("{} {}".format(sum(ans),sum1))

Solution (Python):
def main():
    from sys import stdin
    input = stdin.readline
    N, M = map(int, input().split())
    SP = [list(input().split()) for i in range(M)]
    was = [0] * N
    acs = [0] * N
    penaltyCount = 0
    for sp in SP:
        if acs[int(sp[0])-1] == 1:
            continue
        if acs[int(sp[0])-1] == 0 and sp[1] == "WA":
            was[int(sp[0])-1] += 1
        elif acs[int(sp[0])-1] == 0 and sp[1] == "AC":
            acs[int(sp[0])-1] = 1
            penaltyCount += was[int(sp[0])-1]

    print(sum(acs), penaltyCount)


if __name__ == "__main__":
    main()

Solution (Python):
import numpy as np

n,m = map(int,input().split())
base = np.zeros(n)
pena = np.zeros(n)

for i in range(m):
  s = list(input().split())
  if (s[1] == "WA") and (base[int(s[0])-1] == 0):
    pena[int(s[0])-1] += 1
  elif (s[1] == "AC"):
    base[int(s[0])-1] = 1
    
ans_1 = np.multiply(base,pena)
print(int(np.sum(base)),int(np.sum(ans_1)))

Solution (Python):
N,M = map(int, input().split())
WL = [0]*(N+1)
AL = [0]*(N+1)
WLsum = 0
for _ in range(M):
    xx = input().split()
    p = int(xx[0])
    if xx[1]=='AC':
        if AL[p] == 0:
            AL[p] = 1
            WLsum += WL[p]
    else:
        WL[p] += 1

print(str(AL.count(1)) + ' ' + str(WLsum))

Solution (Python):

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    N, M = map(int, readline().split())
    submit = [line.split() for line in readlines()]
    submit = [[int(p), S.decode()] for p, S in submit]
    WA_count = [0] * (N + 1)
    correct_list = [False] * (N + 1)
    correct = 0
    penalty = 0
    for p, S in submit:
        if not correct_list[p]:
            if S == 'WA':
                WA_count[p] += 1
            else:
                correct += 1
                penalty += WA_count[p]
                correct_list[p] = True
    print(correct, penalty)


if __name__ == '__main__':
    main()

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

Solution (Python):
N, M = map(int, input().split())
results = {}
penalty = 0
acs = 0

for i in range(M):
    ans = input().split()
    try:
        results[ans[0]].append(ans[1])
    except KeyError:
        results[ans[0]] = [ans[1]]

for data in results.values():
    if "AC" in data:
        acs += 1
        penalty += data[:data.index("AC")].count("WA")

print(acs, penalty)

Solution (Python):
N,M=map(int,input().split())
number=[0]*N
ac,wa,=0,0
for m in range(M):
    p,s=input().split()
    p=int(p)-1
    if number[p]!=-1:
        if s == "WA":
            number[p]+=1
        elif s == "AC":
            ac+=1
            wa+=number[p]
            number[p] = -1
print(ac,wa)

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

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

for _ in range(m):
    a, b = input().split()
    a = int(a)
    if b == 'AC':
        ac[a] = 1
    else: 
        if ac[a] == 0:
            wa[a] = wa[a] + 1

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

print(sum(ac), sum(wa))

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

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

ac = 0
penalty = 0
check = [0 for i in range(N)]
for i in range(M):
    p, S = ps[i]
    if check[int(p)-1] != -1:
        if S == "AC":
            ac += 1
            penalty += check[int(p)-1]
            check[int(p)-1] = -1
        if S == "WA":
            check[int(p)-1] += 1

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

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

Solution (Python):
n,m = map(int,input().split())
A=[input().split(' ') for i in range(m)]
 
ac={i:0 for i in range(1,n+1)}
wa={i:0 for i in range(1,n+1)}
wa2={i:0 for i in range(1,n+1)}
 
for i in range(m):
    if A[i][1]=='AC':
        tmp=int(A[i][0])
        ac[tmp]=1
    else:
        tmp=int(A[i][0])
        if ac[tmp]==1:
            pass
        else:
            wa[tmp]+=1
for i in range(1,n+1):
    if ac[i]==1:
        wa2[i]=wa[i]
    else:
        pass

print(str(sum(ac.values()))+' '+str(sum(wa2.values())))

Solution (Python):
N,M = map(int,input().split())
W = dict()
A = dict()
ac = 0
pt = 0
Q = []
for i in range(M):
    p, S = input().split()
    p = int(p)
    if not p in W.keys():
        W[p] = 0
        A[p] = 0
    if S == 'WA':
        W[p] += 1
    if S == 'AC':
        if A[p] != 'AC':
            A[p] = 'AC'
            pt += W[p]
            ac += 1
print(ac,pt)

Solution (Python):
from collections import defaultdict

def main():
	N,M = map(int,input().split())
	submit = defaultdict(lambda : [0,0])
	for _ in range(M):
		p,s = input().split()
		p = int(p)
		if(s == "AC"):
			submit[p][0] = 1
		else:
			if(submit[p][0] == 0):
				submit[p][1] +=1
	num_AC = 0
	num_WA = 0
	for _,value in submit.items():
		if(value[0] == 1):
			num_AC += 1
			num_WA += value[1]
	print(num_AC,num_WA)

if __name__ == "__main__":
	main()

Solution (Python):
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,m = mi()

wa = [0] * n
ac  = [0] * n
for i in range(m):
    a = input().split()
    p,s = int(a[0]), a[1] 
    if s == 'AC':
       ac[p-1] = 1
    else: 
        if 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):


n,m=map(int,input().split())
res_ac=[-1 for i in range(n)]
tmp_wa=[0 for i in range(n)]
ac=0
wa=0


for i in range(m):
    sbmt=input().split()
    problem_num=int(sbmt[0])-1
    problem_ans=sbmt[1]
    if (problem_ans=="WA")&(res_ac[problem_num]==-1):
        tmp_wa[problem_num]+=1
    if (problem_ans=="AC")&(res_ac[problem_num]==-1):
        res_ac[problem_num]=1
        ac+=1
        wa+=tmp_wa[problem_num]

print(ac,wa)

Solution (Python):
def main():
    n, m = map(int, input().split())
    ac = [0] * n
    pena = [0] * n
    for i in range(m):
        p = input().split()
        if ac[int(p[0])-1] > 0:
                continue
        elif p[1] == "AC":
            ac[int(p[0])-1] += 1
        else:
            pena[int(p[0])-1] += 1
    for i in range(n):
        if ac[i] == 0:
            pena[i] = 0
    print(sum(ac), sum(pena))

if __name__ == '__main__':
    main()

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

ans=[0]*N
pen=[0]*N
AC=[0]*N

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

print(AC.count(1),sum(ans))

Solution (Python):
N, M = map(int, input().split())
AC = [0]*N
WA = [0]*N
L = []
for m in range(M):
    p, S = map(str, input().split())
    p = int(p)
    L.append([p, S])
for m in range(M):
    if not AC[L[m][0]-1] == 0:
        continue    
    if L[m][1] == 'AC':
        AC[L[m][0]-1] = 1
    elif L[m][1] == 'WA':
        WA[L[m][0]-1] += 1
A = sum(AC)
W = 0
for n in range(N):
    if AC[n] == 1:
        W += WA[n]
print(A, W)

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

Solution (Python):

N, M = map(int, input().split())
P = []
s = []
for i in range(M):
    p, S = input().split()
    p = int(p) - 1
    P.append(p)
    s.append(S)
A = [[0, 0] for _ in range(N)]
for i in range(M):
    if s[i] == 'AC':
        A[P[i]][0] = 1
    if s[i] == 'WA' and A[P[i]][0] != 1:
        A[P[i]][0] = 2
        A[P[i]][1] += 1

print(len([a for a in A if a[0] == 1]), sum([a[1] for a in A if a[0] == 1]))

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


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

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

for i in range(m):
    p, s = input().split()
    p = int(p)
    p -= 1
    
    if (s == "AC"):
        if (isac[p] != 1):
            ac += 1
            pena += wa[p]
            isac[p] = 1
    else:
        if (isac[p] == 0):
            wa[p] += 1
    

print(ac, pena)

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

inputs = [ input().split() for _ in range(m) ]

collectNum = 0
penaltyNum = 0



waCounts = [0] * (n+1)

for inp in inputs:
    questNum = int(inp[0])
    result = inp[1]

    if waCounts[questNum] != -1:
        if result == 'AC':
            collectNum += 1
            penaltyNum += waCounts[questNum]
            waCounts[questNum] = -1
        elif result == 'WA':
            waCounts[questNum] += 1

print("{} {}".format(collectNum, penaltyNum))

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

AC_count = 0
WA_count = 0

problem_list = [0]*N
result_list = [0]*N
wa_list = [0]*N

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

    if problem_list[p] == 1:
        if result_list[p] == 'AC':
            continue
        elif result_list[p] == 'WA' and s =='AC':
            result_list[p] = 'AC'
            AC_count += 1
        else:
            wa_list[p] += 1
            
    else:
        problem_list[p] = 1
        result_list[p] = s

        if s == 'AC':
            AC_count += 1
        else:
            wa_list[p] += 1

for i in range(N):
    if result_list[i] == 'AC':
        WA_count += wa_list[i]

print(AC_count, WA_count)

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