Problem: 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.

Submission attempts (in order):
N,M=map(int,input().split())
ac=[0]*N
wa=[0]*N

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

penalty=[w(k) for k in [i for i,j in enumerate(ac) if j!=0]]    
print("%d %d" %())

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

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

penalty=[w(k) for k in [i for i,j in enumerate(ac) if j!=0]]    
print("%d %d" %(sum(ac),sum(penalty)))


def f(S,start_num,j):
  start=start_num[j-1]
  s=0
  for i in range(0,strat_num[j]-start_num[j-1]):
    if S[start+i]=="WA":
      s=s+1
      continue
    else:
      break
return s

N,M=map(int,input().split())
P_str=[0]*M
S=[0]*M
for i in range(M):
  P_str[i],S[i]=map(str,input().split())
P=[int(P_str[j]) for j in range(M)]

start_num=[0]*N
start_num[0]=1
for i in range(1,M):
    if not P[i-1]==P[i]:
      i=start_num[P[i]-1]

correct=0
for j in range(1,N+1):
  if f(S,start_num,j)<(start_num[j]-start_num[j-1]):
    correct+=1
penalty=0
for j in range(1,N+1):
  penalty+=f(S,start_num,j)

print(correct,"",penalty)

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

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

penalty=[wa[j] for j,k in enumerate(ac) if not K==0]
print("%d %d" %(sum(ac),sum()))

def f(S,start_num,j):
  start=start_num[j-1]
  s=0
  for i in range(0,strat_num[j]-start_num[j-1]):
    if S[start+i]=="WA":
      s=s+1
      continue
    else:
      break
return s

N,M=map(int,input().split())
P_str=[0]*M
S=[0]*M
for i in range(M):
  P_str[i],S[i]=map(str,input().split())
P=[int(P_str[j]) for j in range(M)]

start_num=[0]*N
start_num[0]=0
for i in range(1,M):
    if not P[i-1]==P[i]:
      i=start_num[P[i]-1]

correct=0
for j in range(1,N+1):
  if f(S,start_num,j)<(start_num[j]-start_num[j-1]):
    correct+=1

penalty=0
for j in range(1,N+1):
  penalty+=f(S,start_num,j)

print(correct,"",penalty)


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

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

penalty=[w(k) for k in [i for i,j in enumerate(ac) if j!=0]]    
print("%d %d" %())


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

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

penalty=[w[k] for k in [i for i,j in enumerate(ac) if j!=0]]    
print("%d %d" %(sum(ac),sum(penalty)))


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

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

penalty=[w[k] for k in [i for i,j in enumerate(ac) if j!=0]]    
print("%d %d" % (sum(ac),sum(penalty)))


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

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

penalty=[wa[k] for k in [i for i,j in enumerate(ac) if j!=0]]    
print("%d %d" % (sum(ac),sum(penalty)))


Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted