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 WAs 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



Sample input:
2 5
1 WA
1 AC
2 WA
2 AC
2 WA


Sample output:
2 2

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
n,m=map(int,input().split())
num=[0]*(n+1)
numcnt=[0]*(n+1)
ans=0
cnt=0
for i in range(m):
    p,s=map(str,input().split())
    p=int(p)
    if s=="WA":
        num[p]+=1
    if s=="AC" and numcnt[p]!=1:
        ans+=num[p]
        cnt+=1
        numcnt[p]=1
print(cnt,ans)

Submission status: Accepted

Solution code:
import sys
import math
import bisect

def main():
    n, m = map(int, input().split())
    wa = [0] * n
    ac = [0] * n
    penalty = 0
    for _ in range(m):
        p, s = input().split()
        p = int(p) - 1
        if s == 'WA':
            wa[p] += 1
        else:
            if ac[p] == 0:
                ac[p] = 1
                penalty += wa[p]
            ac[p] = 1
    print('%d %d' % (sum(ac), penalty))

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
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
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

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

N, M = MAP()
p = [0]*M
S = [""]*M
for i in range(M):
	p[i], S[i] = input().split()
	p[i] = int(p[i])

ac = 0
wa = 0
dic = defaultdict(int)
for i in range(M):
	if S[i] == "AC":
		if dic[p[i]] == -1:
			continue
		ac += 1
		wa += dic[p[i]]
		dic[p[i]] = -1
	else:
		if dic[p[i]] == -1:
			continue
		dic[p[i]] += 1
print(ac, wa)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
sgn=[0 for i in range(n)]
penal=[0 for i in range(n)]
pp=0
for i in range(m):
    p,s=map(str,input().split())
    p=int(p)-1
    if s=='AC':
        if sgn[p]==0: pp+=penal[p]
        sgn[p]=1
    else:
        penal[p]+=1



print(sum(sgn),pp)

Submission status: Accepted

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

wa = [0] * n
ac = [False] * n
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == "WA":
        if not ac[p]:
            wa[p] += 1
    else:
        ac[p] = True

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

print(sum(ac), wa_count)

Submission status: Accepted

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

from collections import defaultdict
dic = defaultdict(int)
wa = defaultdict(int)
ans1 = 0
ans2 = 0
for _ in range(m):
    p,s = map(str,input().split())
    p = int(p)
    if s == "AC":
        if dic[p] == 0:
            ans2 += wa[p]
            ans1 += 1
            dic[p] = 1

    else:
        if dic[p] == 0:
            wa[p] += 1
   
print(ans1)
print(ans2)

Submission status: Accepted

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

acs = [0 for i in range(n)]
was = [0 for i in range(n)]
ps = []
ss = []


for i in range(m):
    pa,sa = input().split()
    pa = int(pa)
    if sa == "AC":
        acs[pa-1] = 1
    if sa == "WA" and acs[pa-1] == 0:
        was[pa-1] += 1

wa_cnt = 0
for i in range(n):
    if acs[i] == 1:
        wa_cnt += was[i]


print(sum(acs), wa_cnt)

Submission status: Accepted

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,M = inpl()
cnts = [0]*N
pena = 0
for _ in range(M):
    p,s = input().split()
    p = int(p)-1
    if s == "WA" and cnts[p]!=-1:
        cnts[p] += 1
    elif s == "AC" and cnts[p]!=-1:
        pena += cnts[p]
        cnts[p] = -1


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

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ac = 0
wa = 0

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

print(ac, wa)

Submission status: Accepted

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

ac = [False]*N
wa = [0]*N

for i in range(M):
    p,res=input().split()
    p = int(p)-1
    if res=="AC":
        ac[p]=True
    else:
        if not ac[p]:
            wa[p]+=1
account = 0
wacount = 0
for i in range(N):
    if ac[i]:
        account+=1
        wacount+=wa[i]

print(account,wacount)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
flag = [False for i in range(N)]
WA = [0 for i in range(N)]
ans = 0
WA_count = 0
for _ in range(M):
    p, s = input().split()
    p = int(p)-1
    if flag[p]:
        pass
    else:
        if s == 'WA':
            WA[p] += 1
        else:
            flag[p] = True
            WA_count += WA[p]
            ans += 1
print(ans, WA_count)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
wls = [0]*N
ls = [0]*N
for i in range(M):
  p, s = input().split()
  p = int(p)-1
  if ls[p]==0:
    if s=='WA':
      wls[p] += 1
    else:
      ls[p] = 1
  else:
    continue
pena = 0
ac = 0
for i in range(N):
  if ls[i] == 1:
    ac += 1
    pena += wls[i]
print(ac, pena)

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
 
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return [list(map(int, input().split())) for _ in range(n)]

def main():
    n,m = inpm()
    dic = defaultdict(int)
    x = 0
    y = 0
    for _ in range(m):
        ps = inpls()
        ps[0] = int(ps[0])
        if ps[1] == 'WA':
            dic[ps[0]] += 1
        elif ps[1] == 'AC' and dic[ps[0]]<10**6:
            x += 1
            y += dic[ps[0]]
            dic[ps[0]]= 10**6
    print(x,y)



if __name__ == "__main__":
    main()

Submission status: Accepted

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

p = []
a = []
flag = []
for i in range(n):
    p.append(0)
    a.append(0)
    flag.append(True)

for i in range(m):
    if ps[i][1] == 'WA' and flag[ps[i][0] - 1]:
        p[ps[i][0] - 1] += 1
    else:
        a[ps[i][0] - 1] = 1
        flag[ps[i][0] - 1] = False

#print(p, a)

pen = 0
ac = 0
for i in range(n):
    if a[i] > 0:
        pen += p[i]
        ac += 1
print(ac, pen)

Submission status: Accepted

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

    N, M = map(int, input().split())
    cnt = 0
    wa = 0
    flg = {i: 0 for i in range(1, N+1)}
    for _ in range(M):
        p, ver = input().split()
        p = int(p)
        if ver == 'AC':
            if flg[p] >= 0:
                cnt += 1
                wa += flg[p]
                flg[p] = -1
        else:
            if flg[p] >= 0:
                flg[p] += 1
    print(cnt, wa)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
A = [list(input().split()) for i in range(m)]

for i in range(m):
    A[i][0] = int(A[i][0])-1

P = [0] * n
AC = [0] * n

for i in range(m):
    if A[i][1] == "WA":
        if AC[A[i][0]] == 0:
            P[A[i][0]] += 1
    else:
        AC[A[i][0]] = 1
    
p=0
ac=sum(AC)
for i in range(len(P)):
    if AC[i] == 1:
        p += P[i]
print(ac,p)

Submission status: Accepted

Solution code:
def main():
    N, M = [int(n) for n in input().split()]
    was = [0]*N
    isAc = [False]*N
    acs = 0
    pes = 0
    for _ in range(M):
        p, s = input().split()
        p = int(p) -1
        if s == "AC":
            if isAc[p] == True:
                continue
            isAc[p] = True
            pes += was[p]
            acs+=1
        else:
            was[p] += 1
    print(" ".join([str(acs),str(pes)]))
main()

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ac = [False] * n
wa = [0] * n
u, v = 0, 0
for i in range(m):
    p, s = input().split()
    p = int(p)
    if ac[p - 1]:
        continue
    if s == 'AC':
        ac[p - 1] = True
        u += 1
        v += wa[p - 1]
    elif s == 'WA':
        wa[p - 1] += 1
print(u, v)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,m = LI()
f = defaultdict(int)
f1 = defaultdict(int)
ans1 = 0
ans2 = 0
for _ in range(m):
    p,s = input().split()
    if f1[p] == 1:
        continue
    if s == 'WA':
        f[p] += 1
    else:
        f1[p] = 1
        ans1 += f[p]
        ans2 += 1
print(ans2,ans1)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
t = [0] * (N + 1)
vis = set()
for _ in range(M):
  p, s = input().split()
  p = int(p)
  if p in vis: continue
  if s == "AC":
    vis.add(p)
  else:
    t[p] += 1
res = 0
for i in range(N + 1):
  if i in vis:
    res += t[i]
print(len(vis), res)

Submission status: Accepted

Solution code:
def main():
    n, m = map(int, input().split())
    ab = [input().split() for _ in [0]*m]
    cnt = 0
    ac_list = [False]*n
    cnt_list = [0]*n
    for a, b in ab:
        if b == "WA":
            cnt_list[int(a)-1] += 1
        else:
            if ac_list[int(a)-1] == False:
                cnt += cnt_list[int(a)-1]
                ac_list[int(a)-1] = True
    print(sum(ac_list), cnt)


main()

Submission status: Accepted

Solution code:
def examA():
    C = SI()
    ans = chr(ord(C)+1)
    print(ans)
    return

def examB():
    N,K,M = LI()
    A = LI()
    ans = N*M-sum(A)
    if ans>K:
        ans = -1
    elif ans<0:
        ans = 0
    print(ans)
    return

def examC():
    N, M = LI()
    ansT = 0; ansP = 0
    d = defaultdict(bool)
    WA = [0]*(N+1)
    for i in range(M):
        S, P = LSI()
        S = int(S)
        if P=="WA":
            WA[S] +=1
        elif P=="AC":
            if d[S]:
                continue
            else:
                d[S] = True
                ansT +=1
                ansP +=WA[S]
    print(ansT,ansP)
    return

def examE():
    return

def examF():
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examC()

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
l = [0] * n
f = [True] * n
for _ in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == 'WA':
        if f[p]:
            l[p] += 1
    else:
        f[p] = False
ans = 0
for i in range(n):
    if not f[i]:
        ans += l[i]
print(f.count(False), ans)

Submission status: Accepted

Solution code:
from collections import defaultdict

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

aced = set()
d = defaultdict(int)
pen = 0
for i in xrange(m):
    p, s = raw_input().split()
    p = int(p)
    s = s.strip()

    if p in aced:
        continue

    if s == 'WA':
        d[p] += 1
    elif s == 'AC':
        aced.add(p)
        pen += d[p]
    else:
        assert False

print len(aced), pen

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N,M=map(int,input().split())
    b=[False]*N
    c=[0]*N
    ans=0
    ans2=0
    for i in range(M):
        p,S=input().split()
        p=int(p)-1
        if S=='WA' and b[p]==False:
            c[p]+=1
        elif S=='AC' and b[p]==False:
            b[p]=True
            ans+=c[p]
            ans2+=1
    print(ans2,ans)
        
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.readline

N, M = map(int, readline().split())
ACed = [False]*N
count = [0]*N

for _ in range(M):
    p, S = readline().strip().split()
    p = int(p)-1
    if S == 'AC':
        ACed[p] = True
    elif not ACed[p]:
        count[p] += 1

print(sum(ACed), sum(count[i] for i in range(N) if ACed[i]))

Submission status: Accepted

Solution code:
from collections import defaultdict

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

ac, wa = 0, 0
solved = defaultdict(int)
warning = defaultdict(int)

for p, S in pS :
  if solved[p] == 1 :
    continue
    
  if S == 'WA' :
    warning[p] += 1
    
  else :
    ac += 1
    solved[p] = 1
    wa += warning[p]
    
print(ac, wa)

Submission status: Accepted

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,M=MI()
    AC=set()
    WA=defaultdict(int)
    ans = 0
    for _ in range(M):
        p,s = ST().split()
        if s=="AC":
            if p in AC:
                continue
            ans += WA[p]
            AC.add(p)
        else:
            WA[p]+=1
    print(len(AC),ans)
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

#ライブラリインポート
from collections import defaultdict

#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, M = getlist()
	D = defaultdict(int)
	AC = 0
	WA = 0
	for i in range(M):
		p, S = list(input().split())
		if S == "AC":
			if D[p] != -1:
				AC += 1
				WA += D[p]
				D[p] = -1
		else:
			if D[p] != -1:
				D[p] += 1

	print(AC, WA)


if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
AC,WA = 0,0
was = [0]*(N+1)
acs = [0]*(N+1)
for i in range(M):
    p,S = input().split()
    p = int(p)
    if S=="AC":
        if acs[p]==0:
            AC+=1
            WA+=was[p]
            acs[p]=1
    else:
        was[p] += 1
print(AC,WA)

Submission status: Accepted

Solution code:
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[] for _ in range(num)]
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

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

ac = [False]*N
pn = [0]*N
acn = 0
pnn = 0

for i in range(M):
    if S[i]=='WA':
        pn[p[i]-1] += 1
    else:
        if ac[p[i]-1]==False:
            acn += 1
            ac[p[i]-1] = True
            pnn += pn[p[i]-1]

print(acn,pnn)

Submission status: Accepted

Solution code:
n, m = [int(i) for i in input().split()]
pe = [0] * n
isok = [False] * n
for _ in range(m):
    p, s = [i for i in input().split()]
    p = int(p) - 1
    if s == "AC":
        isok[p] = True
    else:
        if not isok[p]:
            pe[p] += 1
pen = 0
ans = 0
for i in range(n):
    if isok[i]:
        ans += 1
        pen += pe[i]
print(ans,pen)

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict

n, m = map(int, input().split())
ac = 0
wa = defaultdict(lambda: 0)
already = set()
for line in sys.stdin:
    p, s = line.strip().split()
    p = int(p)
    if p in already:
        continue
    if s == 'AC':
        ac += 1
        already.add(p)
    else:
        wa[p] += 1

print(ac, sum(wa[i] for i in already))

Submission status: Runtime Error

Solution code:
def resolve():
    n,m = map(int,input().split())
    ac_list = [1]*n
    ac = 0
    wa = 0
    for _ in range(m):
        p,s = input().split()
        if s == 'WA' and ac_list[int(p)-1]==1:
            wa += 1
        elif s == 'AC' and ac_list[int(p)-1]==1:
            ac += 1
            ac_list[int(p)-1] = 0
    print(f'{ac} {wa}')
resolve():

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
ac_cnt = set()
wa_cnt = 0
penalty = [0]*n
for i in range(m):
    p,s = input().split()
    num = p - 1
    if num not in ac_cnt:
        if s == "AC":
            ac_cnt.add(num)
            wa_cnt += penalty[num]
        else:
            penalty[num] += 1
print(len(set(ac_cnt)),wa_cnt)

Submission status: Runtime Error

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

ans_ac = set()
wa_cnt = 0
wa_sled = [i for i in range(1,n+1)]


for i in range(m):
  p,s = input().split()
  if s == "AC":
    ans_ac.add(p)
    wa_sled.remove(int(p))
    if len(wa_sled) == 0:
      break
      
  if s == 'WA' and p not in wa_sled:
    wa_cnt += 1
    
print(len(ans_ac),wa_cnt)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
p = []
s = []
for i in range(m):
    p_i, s_i = input().split()
    p.append(int(p_i))
    s.append(b)


res = [0]*n
correct = 0
penalty = 0
for i in range(m):
    no = p[i] - 1
    if res[no] == 1:
        continue
    elif s[i] == 'WA':
        penalty += 1
    elif s[i] == 'AC':
        correct += 1
        res[no] = 1

print(correct, penalty)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
ps = [input().split() for _ in range(m)]
p, s = [list(i) for i in zip(*ps)]
p = list(map(int, p))

res = [0]*n
correct = 0
penalty = 0
for i in range(m):
    no = p[i] - 1
    if res[no] == 1:
        continue
    elif s[i] == 'WA':
        penalty += 1
    elif s[i] == 'AC':
        correct += 1
        res[no] = 1

print(correct, penalty)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
ps = [input().split() for _ in range(m)]
p, s = [list(i) for i in zip(*ps)]
p = list(map(int, p))

res = [0]*n
correct = 0
penalty = 0
for i in range(m):
    no = p[i] - 1
    if res[no] == 1:
        continue
    elif s[no] == 'WA':
        penalty += 1
    elif s[no] == 'AC':
        correct += 1
        res[no] = 1

print(correct, penalty)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int,input().split()))

ans = 1
cnt = 0

if ans not in a:
  print(-1)
  exit()
for i in range(n):
  if ans in a[i:n]:
    ans += 1
    continue
  cnt += 1
  
print(cnt)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
l1 = [0]*n
l2 = [0]*n
for i in range(m):
        p,s=map(str,input().split())
        p= int(p)
        if s == 'AC':
                if l2[p-1] == 0:
                        l2[p-1] +=1
                else:
                        pass 
        else:
                if l2[p-1] == 0:
                        l1[p-1] +=1
                else:
                        pass
for i in range(n):
        if l2[i] == 0:
                l1[i] == 0:
                
print(sum(l2),sum(l1))

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
A = [input().split for i in range(M)]
cac = 0
cwa = 0

for i in range(1, N + 1):
    for a in A:
        while a[0] == str(i):
            if a[1] == 'WA':
                cwa += 1
            else:
                cac += 1
                break
        while a[0] == str(i):
            A.remove(a)
print(cac, cwa)

Submission status: Runtime Error

Solution code:
N, M = map(int,input().split())
results = [0 for _ in range(N+1)]
wa_cnt = 0
ac_cnt = 0
for _ in range(M):
  problem, result = input().split()
  if results[problem] == 0 and result == 'AC':
    ac_cnt += 1
    results[problem] = 1
  elif results[problem] == 0 and result == 'WA':
    wa_cnt += 1
print(ac_cnt, wa_cnt)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
l=[0]*(n+1)
miss=[0]*(n+1)
for _ in range(m):
    p,s=input().split()
    p=int(p)
    if l[p]==0:
        if s=='AC':
            l[p]+=1
        else:
            miss[p]+=1
for i in range(m):
    if l[i]==0 and miss[i]!=0:
        miss[i]=0
a=l.count(1)
b=sum(miss)
print(a,b)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from collections import defaultdict
N,M = map(int,input().split())
AC_List = defaultdict(int)
WA_List = defaultdict(int)

for i in range(M):
    Num,Sta = map(str,input().split())
    if Num in AC_List:
        continue
    else:
        if Sta == "WA":
            WA_List[Num] += 1
        else:
            AC_List[Num] += 1

ansct = 0
for k,v in WA_List:
    if k in AC_List:
        ansct += v
            
print(str(len(AC_List))+" " +str(ansct))

Submission status: Runtime Error

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

dp = [[0 for _ in range(2)] for _ in range(n)] # AC_flg, WA数

for i in range(m):
    if dp[i][0]==1:
        continue
    else:
        if lis[i][1]=='WA':
            dp[int(lis[i][0])][1] += 1
        if lis[i][1]=='AC':
            dp[int(lis[i][0])][0] = 1

ac = 0
wa = 0

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

print(ac,wa)

Submission status: Runtime Error

Solution code:
import sys


def resolve(in_):
    N, M = map(int, next(in_).split())
    PS = tuple(line.strip().split() for line in in_)
    
    ac = set()
    wa = {}

    for p, s in PS:
        if s == 'AC':
            ac.add(p)
        if s == 'WA' and p not in ac:
            wa[p] = wa.setdefault(p, 0) + 1

    penalties = 0
    for k, v in wa.items:
        if k in ac:
            penalties += v
    
    return '{} {}'.format(len(ac), penalties)


def main():
    answer = resolve(sys.stdin)
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

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

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

ac, wa=0,0

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

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

int main() {
    int N,M;
    cin >> N >> M;
    vector<int> p(M);
    vector<string> S(M);
    for(int i=0;i<M;i++) {
        cin >> p.at(i) >> S.at(i);
    }
    vector<vector<int>> submits(N,vector<int>(2,0));
    for(int i=0;i<M;i++) {
        if(submits.at(p.at(i)-1).at(0) != 0) {
            continue;
        }
        if(S.at(i) == "WA") {
            submits.at(p.at(i)-1).at(1)++;
        }else{
            submits.at(p.at(i)-1).at(0)++;
        }
    }
    int ac = 0;
    int pena = 0;

    for(int i=0;i<N;i++) {
        ac += submits.at(i).at(0);
        pena += submits.at(i).at(1);
    }
    cout << ac <<" " << pena << endl;
}

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
l = [list(input().split()) for i in range(m)]
cnt = 0
ans = [0]*n
num = 0
for i in range(0, m):
  num = int(l[i][0])
  if l[i][1] == 'AC':
    ans[num] = 1
  elif ans[num] != 1:    
    cnt += 1
print(sum(ans), cnt)

Submission status: Runtime Error

Solution code:
N, M = [int(x) for x in input().split()]

P = [0] * (N + 1)
correct = 0
ok = [False] * (N + 1)
for i in range(M):
    query = input().split()
    p = int(query[0])
    S = query[1]
    if ok[p] == False:
        if S == 'AC':
            ok[p] = True
            correct += 1
        else: # S = 'WA'
            P[p] += 1

penalty = 0
for i in range(N):
    if ok[p] == True:
        penalty += P[p]

print(correct, end=' ')
print(penalty)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
pp=[0]*n
qq=[True]*n
for i in range(m):
    i,j=input().split()
    i=int(i)
    i-=1
    if qq[i] and j=="AC":
        qq[i]=False
    if qq[i]:
        pp[i]+=1
ans=0
for i in qq:
    if qq[i]==False:
        ans+=1
print(qq.count(False),ans)

Submission status: Runtime Error

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

questions = [False] * N
ac_count = penalty_count = 0
P = []
S = []

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

    P.append(p)
    S.append(s)

    if s == 'AC':
        questions[p] = True

for i in range(M):
    if S[P[i]] == 'WA' and questions[P[i]]:
        penalty_count += 1

print(sum(questions), penalty_count)

Submission status: Runtime Error

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

questions = [False] * N
ac_count = penalty_count = 0
P = []
S = []

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

    P.append(p)
    S.append(s)

    if s == 'AC':
        questions[p] = True

for i in range(M):
    if S[P[i]] == 'WA' and questions[P[i]]:
            penalty_count += 1

print(sum(questions), penalty_count)

Submission status: Runtime Error

Solution code:
N, M, *PS = open(0).read().split()
N, M = [int(_) for _ in [N, M]]
cor = [0] * (N + 1)
pen = [0] * (N + 1)
for p, s in PS:
    p = int(p)
    if cor[p] == 1:
        continue
    if s == 'AC':
        cor[p] = 1
    else:
        pen[p] += 1
ans = [0, 0]
for i in range(1, N + 1):
    if cor[p] == 0:
        continue
    ans[0] += 1
    ans[1] += pen[ @ ]
print(*ans)

Submission status: Runtime Error

Solution code:
N, M = map(int,input().split())
hashmap = {}
ac = 0
wa = 0
for i in range(M):
  p, s = input().split()
  if s == 'WA':
    if p not in hashmap:
      hashmap[p] = False
      wa+=1
    elif not hashmap[p]:
      wa+=1
  else:
    if p not in hashmap:
      hashmap[p] = True
      ac+=1
    elif not hashmap[p]:
      hashmap[p] = True
      ac+=1
  print(hashmap)
print(ac, wa)

Submission status: Runtime Error

Solution code:
N, M = map(int,input().split())
hashmap = {}
ac = 0
wa = 0
for i in range(M):
  p, s = map(int,input().split())
  if s == 'WA':
    if p not in hashmap:
      hashmap[p] = False
      wa+=1
    elif not hashmap[p]:
      wa+=1
  else:
    if p not in hashmap:
      hashmap[p] = True
    elif not hashmap[p]:
      ac+=1
print(ac, wa)

Submission status: Runtime Error

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

ac=[False]*N
wa=[0]*N

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

    if s=="AC":
        ac[p]=True
    else:
        if not ac[p]:
            wa[p]+=1

a=0
b=0

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

print(a,b,sep=" ")

Submission status: Runtime Error

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

ac=[False]*N
wa=[0]*N

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

    if s=="AC":
        ac[p]=True
    else:
        wa[p]+=1

a=0
b=0

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

print(a,b,sep=" ")