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: Time Limit Exceeded

Solution code:
import itertools
n, m = map(int, input().split())
P = [input().split() for i in range(m)]
P = list(itertools.chain.from_iterable(P))
ac_list = []
wa_list = [0] * n

counta = 0
countb = 0
for i in range(1, m * 2, 2):
    if P[i] == "AC" and int(P[i - 1]) not in ac_list:
        counta += 1
        ac_list.append(int(P[i - 1]))
        countb += wa_list[int(P[i - 1]) - 1]
    elif P[i] == "WA":
        wa_list[int(P[i - 1]) - 1] += 1
    else:
        continue

print(counta, countb)

Submission status: Time Limit Exceeded

Solution code:
N,M= map(int,input().split())
#L = [list(map(str,input().split())) for i in range(M)]

AC =0
WC =0
dic = {}
for m in range(M):
    id, res = map(str,input().split())
    if id not in dic.keys():
        dic[id] = [res]
    elif 'AC' not in dic[id]:
        dic[id].append(res)

for d in dic.values():
    if 'AC' in d:
        AC += 1
        if 'WA' in d:
            WC += d.count('WA')
print(AC)
print(WC)

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int,input().split())
AC = 0
WA = 0
lis_ac = []
dic_wa ={}
if M == 0:
  print(0,0)
else:
  A = [list(input().split()) for i in range(M)]
  A.sort(key = lambda x: int(x[0]))
  for i in range(M):
    if A[i][0] not in lis_ac:
      if A[i][1] == 'AC':
        lis_ac.append(A[i][0])
        if A[i][0] in dic_wa.keys():
          WA += dic_wa[A[i][0]]
      elif A[i][0] in dic_wa.keys():
        dic_wa[A[i][0]] += 1
      else:
        dic_wa[A[i][0]] = 1
  print(len(lis_ac), WA)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
pro = {}
c = []
s =[input().split() for i in range(M)]
f_sum = 0
for i in s:
    if i[1] == 'AC':
        if i[0] not in c:
            if i[0] in pro:
                f_sum += pro[i[0]]
            c.append(i[0])
    else:
        if i[0] in c:
            continue
        elif i[0] not in pro:
            pro[i[0]] = 1
        else:
            pro[i[0]] += 1
print("{} {}".format(len(c), f_sum))

Submission status: Time Limit Exceeded

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

p = []
S = []

for i in range(M):
    p1, s1 = input().split()

    p.append(int(p1))
    S.append(s1)
AC = 0
WA = 0
list = []

for i in range(M):
    if S[i] == "AC" and p[i] not in list:
        AC += 1
        list.append(p[i])
        for j in range(i):
            if p[j] == p[i]:
                WA += 1
print(AC, WA)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!
inf = [ int(a) for a in input().rstrip().split(' ')]
# results = [[a for a in input().rstrip().split(' ')] for i in range(inf[1])]

solved = []
pennalty = {}

for i in range(inf[1]):
    sub = [a for a in input().split(' ')]
    if not(sub[0] in solved):
        if sub[1] == 'AC':
            solved.append(sub[0])
        else:
            if (sub[0] in pennalty):
                pennalty[sub[0]] += 1
            else:
                pennalty[sub[0]] = 1

pena = 0
for key in solved:
    if key in pennalty:
        pena += pennalty[key]
            
print('{} {}'.format(len(solved), pena))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
 
def main():
    NM = [int(i) for i in input().split(" ")]
    if NM[1] == 0:
        ans = "0 0"
    else:
        pss = np.array([np.array(input().split(" ")) for j in range(NM[1])])
 
        probs = pss[:,0]
        answs = pss[:,1]

        ans_ac = 0
        ans_wa = 0
 
        probs_uniq = list(set(probs))
        for p in probs_uniq:
            res = answs[probs == p]
            ind_ac = np.where(res == "AC")[0]
            if ind_ac.shape[0] == 0:
                pass
            else:
                ans_ac += 1
                ans_wa += ind_ac[0]

        ans = str(ans_ac) + " " + str(ans_wa)
    print(ans)
 
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
pro = {}
c = []
s =[input().split() for i in range(M)]
f_sum = 0
for i in s:
    p = i[0]
    if i[1] == 'AC':
        if p not in c:
            if p in pro:
                f_sum += pro[p]
            c.append(p)
    else:
        if p in c:
            continue
        elif p not in pro:
            pro[p] = 1
        else:
            pro[p] += 1
print("{} {}".format(len(c), f_sum))

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int,input().split())
count_ac = 0
count_wa = 0
l = [('','')]*m
memo_n = []
import collections
idx = 0
for i in range(m):
    t = tuple(input().split())
    l[i] = t
    if t[1] == 'AC' and t[0] not in memo_n:
        memo_n.append(t[0])
        count_ac += 1
        c = collections.Counter(l[idx:i])
        # count_wa += l.count((t[0],'WA'))
        count_wa += c[(t[0],'WA')]

print(str(count_ac) + " " + str(count_wa))

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
N, M=map(int, input().split())


ACs=[]
WAs={}

AC=0
pena=0
readline = stdin.readline
for i in range(M):
  num, jud=readline().split()
  if num in ACs:
    continue
  elif jud=="WA":
    if num not in WAs.keys():
      WAs[num]=1
    else:
      WAs[num]+=1
  else:
    ACs.append(num)
    AC+=1
    if num in WAs.keys():
      pena+=WAs[num]

print(AC, pena)

Submission status: Time Limit Exceeded

Solution code:
A = list(map(int,input().split()))
B = []
for i in range(A[1]):
    a,b=input().split()
    B.append((int(a), b))

C = [0] * A[0]
X = [0] * A[0]

D = []
for j in range(A[1]):
    for l in range(A[0]):
        if B[j][0]==l+1:
            if B[j][1] == 'WA':
                C[l] = C[l] +1
            elif B[j][1] == 'AC' and X[l] == 0:
                X[l] = 1
                D.append(C[l])
print(len(D),sum(D))

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
plist=[]
slist=[]

for i in range(M):
    p, s = input().split()
    plist.append(p)
    slist.append(s)

newlist=[]
seikai=0
hazure=0
for i in range(M):
    if  plist[i]+" "+slist[i] not in newlist and slist[i]=="AC":
        seikai=seikai+1
        newlist.append(plist[i]+" "+slist[i])
        pass
    elif plist[i]+" "+slist[i] in newlist and slist[i]=="AC":
        pass
        newlist.append(plist[i]+" "+slist[i])
    elif plist[i]+" "+"AC" not in newlist and slist[i]=="WA":
        hazure=hazure+1
        newlist.append(plist[i]+" "+slist[i])
    elif plist[i]+" "+slist[i] in newlist and slist[i]=="WA":
        newlist.append(plist[i]+" "+slist[i])

print(str(seikai)+" "+str(hazure))

Submission status: Time Limit Exceeded

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

p_list=[]
latest=""
cnt=[0]*(n+1)
ans=0
plt=0
for i in range(m):
    p,s=map(str,input().split())
    if s == "WA":
        cnt[int(p)] += 1;
    if s == "AC":
        if p != latest:
            if p not in p_list:
                ans+=1
                plt+=cnt[int(p)]
                p_list.insert(0,p)
                latest=p
        
print(str(ans) + " " + str(plt))

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int,input().split())
count_ac = 0
count_wa = 0
l = [('','')]*m
memo_n = []
import collections
for i in range(m):
    t = tuple(input().split())
    l[i] = t
    if t[1] == 'AC' and t[0] not in memo_n:
        memo_n.append(t[0])
        count_ac += 1
        c = collections.Counter(l)
        # count_wa += l.count((t[0],'WA'))
        count_wa += c[(t[0],'WA')]

print(str(count_ac) + " " + str(count_wa))

Submission status: Time Limit Exceeded

Solution code:
import sys
n, m = map(int, input().split())
wa, ac = 0, []
memo = []
hi = n
if n < m:
    hi = m
b = [0] * hi
table = [sys.stdin.readline().split() for x in range(m)]
for x in range(m):
    if not table[x][0] in memo:
        if table[x][1] == 'AC':
            memo.append(table[x][0])
            wa += b[int(table[x][0])]
        elif table[x][1] == 'WA':
            b[int(table[x][0])] += 1

print(len(set(memo)), wa)

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
al = []
for i in range(M):
  al.append(tuple(input().split()))
al_a = [i[0] for i in al if i[1] == 'AC']
al_a = list(set(al_a))
r1 = len(al_a)
r2 = 0
for j in al:
  if j[0] in al_a:
    if j[1] == 'AC':
      al_a.remove(j[0])
    else:
      r2 += 1
    
print(r1 ,r2)

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
a=[input().split() for i in range(m)]
for i in range(m):
    a[i][0]=int(a[i][0])
#print(a)
miss=[0]*n
ans=[]
total=0
for i in range(m):
    if a[i][1]=="AC":
        ans.append(a[i][0]-1)
        miss[a[i][0]-1]+=(10**9+7)
    if a[i][1]=="WA" and miss[a[i][0]-1]<10**9:
        miss[a[i][0]-1]+=1
#print(ans)
cnt=len(set(ans))
#print(cnt)
for i in range(n):
  if i not in ans:
    miss[i]=0
#print(miss)
for i in range(len(miss)):
  miss[i]=miss[i]%(10**9+7)
print(cnt,sum(miss))

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
P = [input().split() for i in range(m)]
P = sum(P,[])
ac_list = list(range(n + 1))
wa_list = [0] * n

counta = 0
countb = 0
for i in range(1, m * 2, 2):
    if P[i] == "AC" and int(P[i - 1]) in ac_list:
        counta += 1
        ac_list.remove(int(P[i - 1]))
        countb += wa_list[int(P[i - 1]) - 1]
    elif P[i] == "WA":
        wa_list[int(P[i - 1]) - 1] += 1
    else:
        continue

print(counta, countb)

Submission status: Time Limit Exceeded

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

WA_dict = {}
AC_list = []

for i in range(M):
    S_str = input().split()
    S = [str(s) for s in S_str]
    if(S[1] == "AC"):
        AC_list.append(S[0])
    elif(not(S[0] in AC_list)):
        WA_dict.setdefault(S[0], 0)
        WA_dict[S[0]] += 1

AC_set = list(set(AC_list))

WA_count = 0

for item in AC_set:
    if(item in WA_dict):
        WA_count += WA_dict[item]

print(str(len(AC_set)) + " " + str(WA_count))

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int, input().split())
li_1=list(range(m))
li_2=list(range(m))
pr=list(range(n))
wa=0
ac=0
for i in range(n):
    pr[i]=0
for i in range(m):
    li_1[i],li_2[i]=map(str, input().split())
    li_1[i]=int(li_1[i])

for i in range(m):
    if li_2[i]=='AC':
        a=li_1[i]-1
        if pr[a]==0:
            for j in range(i):
                if li_1[j]==li_1[i]:
                    wa=wa+1
            pr[a]=1
            ac=ac+1
print(ac,wa)

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int,input().split())
AC = 0
WA = 0
lis_ac = []
dic_wa ={}
if M == 0:
  print(0,0)
else:
  A = [list(input().split()) for i in range(M)]
  for i in range(M):
    if A[i][0] not in lis_ac:
      if A[i][1] == 'AC':
        lis_ac.append(A[i][0])
        if A[i][0] in dic_wa.keys():
          WA += dic_wa[A[i][0]]
      elif A[i][0] in dic_wa.keys():
        dic_wa[A[i][0]] += 1
      else:
        dic_wa[A[i][0]] = 1
  print(len(lis_ac), WA)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
def main(pS):
    ans = {}
    ac = 0
    wa = 0
    for i in pS:
        if i[0] not in ans.keys():
            ans[i[0]] = [0, 0] 
        if i[1] == "AC":
            if ans[i[0]][0] == 0:
                    ans[i[0]][0] += 1
                    ac += 1
                    wa += ans[i[0]][1]
        elif i[1] == "WA":
            if ans[i[0]][0] == 0:
                ans[i[0]][1] += 1
    return [ac, wa]

"""
for i in ans.values():
    ac += i[0]
    if i[0] >= 1:
        wa += i[1]
"""
if __name__ == "__main__":
    N, M = input().split()
    pS = [stdin.readline().rstrip().split() for _ in range(int(M))]
    ac, wa = main(pS)
    print(ac, wa)

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int,input().split())
A = [list(input().split())for i in range(M)]
ans = 0
pen = 0
r = []
for i in range(len(A)):
  if A[i][1] == 'AC':
    r.append(A[i][0])
R = list(set(r))
ans = len(R)
for _ in range(ans):
  for j in range(len(A)):
    if A[j][0] == R[0] and A[j][1] == 'AC':
      del R[0]
      break
    if A[j][0] == R[0] and A[j][1] == 'WA':
      pen+=1
print(ans,pen)

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
a=[input().split() for i in range(m)]
for i in range(m):
    a[i][0]=int(a[i][0])
#print(a)
miss=[0]*n
ans=[]
total=0
for i in range(m):
    if a[i][1]=="AC":
        ans.append(a[i][0]-1)
        miss[a[i][0]-1]+=(10**9+7)
    if a[i][1]=="WA" and miss[a[i][0]-1]<10**9:
        miss[a[i][0]-1]+=1
#print(ans)
cnt=len(set(ans))
#print(cnt)
for i in range(n):
  if i not in ans:
    miss[i]=0
#print(miss)
for i in range(len(miss)):
  miss[i]=miss[i]%(10**9+7)
print(cnt,sum(miss))

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
answer = 0
ans = []
pen = []
penal = 0
p = [0]*m
x = [0]*m
for i in range(m):
    p[i], x[i] = map(str, input().split())
    if x[i] == "AC":
        if p[i] not in ans:
            ans.append(p[i])
            answer += 1
    elif x[i] == "WA":
        for j in range(len(ans)):
            if p[i] == ans[j]:
                penal -= 1
                break
        penal += 1
        pen.append((p[i], x[i]))
    if answer == n:
        break

for i in range(len(pen)):
    if pen[i][0] not in ans:
        penal -= 1


print("{}".format(answer) + " {}".format(penal))

Submission status: Time Limit Exceeded

Solution code:
N,M = list(map(int,input().split()))
moto = list()
for i in range (M):
  moto.append(input())

monme = list()
seigo = list()
i = 0
while i < M:
  a = list(moto[i].split())
  monme.append(int(a[0]))
  seigo.append(a[1])
  i += 1
  
monme2 = list()
seigo2 = list()
j = 1

while j <= N:
  k = 0
  while k < M:
    if monme[k] == j:
      monme2.append(monme[k])
      seigo2.append(seigo[k])
    k += 1
  j += 1

seitou = 0
pena = 0
c = 1
while c <= N:
  d = 0
  karinopena = 0
  while d < M:
    if monme2[d] == c:
      if seigo2[d] == 'WA':
        karinopena += 1
      else:
        seitou += 1
        pena += karinopena
        d = M
    d += 1
  c += 1
print(seitou,pena)

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int, input().split())
l=[]
for _ in range (0,m):
    l.append(input())
wa_total=0
ac_total=0
ac_list=[]

for value in l:
    if str(value.split()[1]) == "AC":
        if not str(value.split()[0]) in ac_list:
            ac_list.append(str(value.split()[0]))
            for i in range(0,l.index(value)):
                if l[i].split()[0] == value.split()[0]:
                    if l[i].split()[1] == "WA":
                        wa_total+=1
            l.remove(value)

print (len(ac_list), wa_total)

Submission status: Time Limit Exceeded

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

p_list=[]
cnt=[0]*(n+1)
ans=0
plt=0
for i in range(m):
    p,s=map(str,input().split())
    if s == "WA":
        cnt[int(p)] += 1;
    if s == "AC":
        if p not in p_list:
            ans+=1
            plt+=cnt[int(p)]
            p_list.insert(0,p)
        
print(str(ans) + " " + str(plt))

Submission status: Time Limit Exceeded

Solution code:
import itertools

n, m = map(int, input().split())
P = [input().split() for i in range(m)]
P = list(itertools.chain.from_iterable(P))
ac_list = list(range(n + 1))
wa_list = [0] * n

counta = 0
countb = 0
for i in range(1, m * 2, 2):
    if P[i] == "AC" and int(P[i - 1]) in ac_list:
        counta += 1
        ac_list.remove(int(P[i - 1]))
        countb += wa_list[int(P[i - 1]) - 1]
    elif P[i] == "WA":
        wa_list[int(P[i - 1]) - 1] += 1
    else:
        continue

print(counta, countb)

Submission status: Time Limit Exceeded

Solution code:
N, M = [int(num) for num in input().split()]
pro = {}
c = []
f_sum = 0
for i in range(M):
    p, S = input().split()
    if S == 'AC':
        if p not in c:
            if p in pro:
                f_sum += pro[p]
            c.append(p)
    else:
        if p in c:
            continue
        elif p not in pro:
            pro[p] = 1
        else:
            pro[p] += 1
print("{} {}".format(len(c), f_sum))

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int,input().split())
ls = []
count_ac = 0
count_wa = 0
ls2 = []
for i in range(M):
    P, S = input().split()
    ls.append((P, S))

for i in ls:
    if i[1] == "AC":
        ls2.append([i[0], i[1]])
    else:
        if [i[0], "AC"] in ls2:
            pass
        else:
            ls2.append([i[0], i[1]])

a = 0
for i in ls2:
    if i[1] == "AC":
        if i[0] == a:
            continue
        else:
            count_ac += 1
            a = i[0]
    else:
        count_wa += 1

print(count_ac, count_wa)

Submission status: Time Limit Exceeded

Solution code:
from operator import itemgetter

n,m = map(int,input().split())	
q=[]
ac=[]
for i in range(m):
  a, b = input().split()
  q.append(int(a))
  ac.append(b)

good=0
bad=0

#問題ごとに処理
qlist=list(set(q))
for j in qlist:
  #問題ｊごとにリストから抽出
  index=[i for i, x in enumerate(q) if x == j]
  index=[]
  qset=[]
  for i,x in enumerate(q):
    if x == j:
      index.append(i)
      qset.append(ac[i])
  #print(index,qset)

  if "AC" in qset:
    firstac=qset.index("AC")
    good+=1
    bad+=firstac

print(good,bad)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline

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

ac = []
ans2 = 0
listm = list(range(m))
for i in listm:
    if a[i][1] == "AC":
        ac.append(a[i][0])
    if (a[i][1] == "WA") and (not (a[i][0] in ac)):
        ans2 += 1
for i in listm:
    if (not(a[i][0] in ac)) and a[i][1] == "WA":
        ans2 -= 1
ans1 = len(set(ac))

print(ans1,end = " ")
print(ans2)

Submission status: Time Limit Exceeded

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

WA_dict = {}
AC_list = []

for i in range(M):
    S_str = input().split()
    S = [str(s) for s in S_str]
    if(S[1] == "AC"):
        AC_list.append(S[0])
    elif(S[0] not in AC_list):
        WA_dict.setdefault(S[0], 0)
        WA_dict[S[0]] += 1

AC_set = list(set(AC_list))

WA_count = 0

for item in AC_set:
    if(item in WA_dict):
        WA_count += WA_dict[item]

print(str(len(AC_set)) + " " + str(WA_count))

Submission status: Time Limit Exceeded

Solution code:
N, M = [int(num) for num in input().split()]
pro = {}
c = []
f_sum = 0
for i in range(M):
    p, S = input().split()
    if S == 'AC':
        if p not in c:
            if p in pro:
                f_sum += pro[p]
            c.append(p)
    else:
        if p in c:
            continue
        if p not in pro:
            pro[p] = 1
        else:
            pro[p] += 1
print("{} {}".format(len(c), f_sum))

Submission status: Time Limit Exceeded

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

p_list=[]
cnt=[0]*(n+1)
ans=0
plt=0
for i in range(m):
    p,s=map(str,input().split())
    if p not in p_list:
        if s == "WA":
            cnt[int(p)] += 1;
        if s == "AC":
            ans+=1
            plt+=cnt[int(p)]
            p_list.append(p)
        
print(str(ans) + " " + str(plt))

Submission status: Time Limit Exceeded

Solution code:
def main():
  AC = 0
  WA = 0
  
  solving = {}
  solved = []
  
  N,M = map(int, input().split())
  
  P = [0] * M
  S = [0] * M
  
  for i in range(M):
    p, s = input().split()
    if p in solved:
      continue
    elif s == 'WA':
      if p in solving:
        _wa = solving[p]
        solving[p] = _wa + 1
      else:
        solving[p] = 1
    else:
      AC += 1
      if p in solving:
      	WA += solving[p]
      solved.append(p)
  
  print(AC, WA)
  return 0
 
if __name__ == "__main__":
  main()

Submission status: Time Limit Exceeded

Solution code:
N, M = [int(num) for num in input().split()]
pro = {}
c_sum = 0
c = []
f_sum = 0
for i in range(M):
    p, S = input().split()
    if S == 'AC':
        if p not in c:
            if p in pro:
                f_sum += pro[p]
            c.append(p)
            c_sum += 1
    else:
        if p in c:
            continue
        if p not in pro:
            pro[p] = 1
        else:
            pro[p] += 1
print("{} {}".format(c_sum, f_sum))

Submission status: Time Limit Exceeded

Solution code:
A = list(map(int, input().split()))
B = [tuple(input().split()) for i in range(A[1])]
ac = 0
wa = 0
for k in range(1,A[0] +1):
  l = [B[i][1] for i in range(len(B)) if B[i][0] == str(k)]
  wa_count = 0
  for m in range(len(l)):
    if l[m] == 'WA':
      wa_count += 1
    else:
      wa = wa + wa_count
      ac += 1
      break;

print(ac, wa)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

x = list(map(int, input().split()))

N, M = x[0], x[1]

AC, WA = 0, 0

if M == 0:
    AC, WA = 0, 0
else:
    input_line = np.array([input() for i in range(M)])
    save_data = np.array([[0, "x"] for j in range(M)])

    for i in range(M):
        save_data[i] = input_line[i].split()

    data = np.array([["x" for i in range(M)] for j in range(M)])
    num, alph = 0, 0
    for i in range(M):
        data[num][alph] = save_data[i][1]
        alph += 1
        if i + 1 < M:
            if save_data[i][0] != save_data[i + 1][0]:
                num += 1
                alph = 0

    for i in range(M):
        for j in range(M):
            if data[i][j] == "W":
                WA += 1
            elif data[i][j] == "A":
                AC += 1
                break

print(AC, WA)

Submission status: Time Limit Exceeded

Solution code:
from operator import itemgetter

n,m = map(int,input().split())	
q=[]
ac=[]
for i in range(m):
  a, b = input().split()
  q.append(int(a))
  ac.append(b)

good=0
bad=0

#問題ごとに処理
qlist=list(set(q))
for j in qlist:
  #問題ｊごとにリストから抽出
  index=[i for i, x in enumerate(q) if x == j]
  index=[]
  qset=[]
  for i,x in enumerate(q):
    if x == j:
      index.append(i)
      qset.append(ac[i])
  #print(index,qset)

  try:
    firstac=qset.index("AC")
  except ValueError:
    continue
  #print(firstac)
  good+=1
  bad+=firstac
print(good,bad)

Submission status: Time Limit Exceeded

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

p_list=[]
cnt=[0]*(n+1)
ans=0
plt=0
for i in range(m):
    p,s=map(str,input().split())
    
    if s == "WA":
        cnt[int(p)] += 1;
    if s == "AC":
        if p not in p_list:
            ans+=1
            plt+=cnt[int(p)]
            p_list.append(p)
        
print(str(ans) + " " + str(plt))

Submission status: Time Limit Exceeded

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

ac = []
wn = []
acn,wan = 0,0
for i in range(m):
  ans = input().split()
  if ans[0] not in ac:
    if ans[1] == 'AC' :
      wan += wn.count(ans[0])
      ac += [ans[0]]
      acn += 1
    else :
      wn += [ans[0]]
print(acn,wan)

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split(' '))
ans = []
c = 0
p = {} 
p_ = 0
for i in range(m):
  arr = list( input().split(' '))
  if ans.count(arr[0]) == 0:
    if not arr[0] in p:
      p[arr[0]] = 0
    if arr[1] == 'WA':
      p[arr[0]] += 1
    if arr[1] == 'AC':
      c += 1
      ans.append(arr[0])
      p_ += p[arr[0]]
      p.pop(arr[0])
      
      
print(c,p_)

Submission status: Time Limit Exceeded

Solution code:
a,s=input().split()
a=int(a) 
s=int(s)
A=[]
B=[]
ac=0
wa=0
for i in range(s):
  d,f=input().split()
  if f=="AC" and d not in B:
    ac+=1
    B.append(d)
  elif f=="WA" and d not in B:
    A.append(d)
wa+=len(A)
for i in A:
  if i not in B:
    wa-=1
print(ac,wa)

Submission status: Time Limit Exceeded

Solution code:
n, m = list(map(int,input().split()))
a = []
for i in range(m):
  s,t = input().split()
  a.append((int(s), t))
wa = 0
ac = 0
i = 0
j = 0
list = []
aclist = []
while i < m:
  if a[i][1] == 'AC':
    aclist.append(int(a[i][0]))
  i = i + 1

ac = len(set(aclist))
while j < m:
  if (a[j][0] not in list) and (a[j][0] in aclist):
    if a[j][1] == 'WA':
      wa = wa + 1
    else:
      list.append(int(a[j][0]))
  j = j + 1

print(str(ac) + ' ' + str(wa))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
qus = list(map(int, input().split()))
data  = {}
ch = []
sum = 0
pe = 0
for i in range(0, qus[1]):
  int_data = list(map(str, input().split()))
  n = int_data[0]
  if n in ch:
      None
  else:
      if n in data:
        if int_data[1] == 'WA':
          data[n] += 1
        else:
          sum += 1
          pe += data[n]
          ch.append(n)
      else:
        if int_data[1] == 'AC':
          sum += 1
          ch.append(n)
        else:
          data[n] = 1
print(sum,' ',pe)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
p_s = []
for i in range(m):
  p_s.append(input().split())
#p_s = [input().split() for i in range(m)]
dic = {}
penalty = 0
acc = 0
num_list=[]
for i in range(m):
  num = p_s[i][0]
  if num in num_list:
    continue
  if p_s[i][1] == "WA":
    if num in dic:
      dic[num]+=1
    else:
      dic[num]=1
  else:
    if num not in num_list:
      num_list.append(num)
      acc += 1
    if num in dic:
      penalty += dic[num]
      del dic[num]

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

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
A = [input().split() for i in range(M)]
#import numpy as np
wa = 0
ans = 0
A_ = sum(A, [])
#print(A)
A_len = len(A_)
for j in range(1,N+1):
  tmp = [A_[i+1] for i in range(A_len) if A_[i] == str(j)]
  #print(tmp)
  for i in range(len(tmp)):
    if tmp[i] == 'WA':
      wa +=1
    if tmp[i] == 'AC':
      ans += 1
      break
print(ans,wa)

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
count = 0
ans = []
pen = []
penal = 0
p = [0]*m
x = [0]*m
for i in range(m):
    p[i], x[i] = map(str, input().split())
    if x[i] == "AC":
        ans.append(p[i])
    elif x[i] == "WA":
        for j in range(len(ans)):
            if p[i] == ans[j]:
                penal -= 1
                break
        penal += 1
        pen.append((p[i], x[i]))

ans = list(set(ans))

for i in range(len(pen)):
    if pen[i][0] not in ans:
        penal -= 1


print("{}".format(len(ans)) + " {}".format(penal))

Submission status: Time Limit Exceeded

Solution code:
import sys
n, m = map(int, input().split())
wa, ac = 0, []
memo = []
hi = n
if n < m:
    hi = m
b = [0] * hi
table = [sys.stdin.readline().split() for x in range(m)]
for x in range(m):
    if table[x][1] == 'AC' and not table[x][0] in memo:
        memo.append(table[x][0])
        wa += b[int(table[x][0])]
    elif table[x][1] == 'WA':
        b[int(table[x][0])] += 1
print(len(set(memo)), wa)

Submission status: Time Limit Exceeded

Solution code:
N, M = [int(item) for item in input().split()]
ans_list = [input().split() for _ in range(M)]
# print(ans_list)

res_ac = 0
ans_stack = []
wa_stack = []

for q, ans in ans_list:
    # print(q, ans)
    if ans == 'AC':
        if q not in ans_stack:
            res_ac += 1
        ans_stack.append(q)
    else:
        if q not in ans_stack:
            wa_stack.append(q)

res_list = []
for i in wa_stack:
    if i in ans_stack:
        res_list.append(i)


print(res_ac, len(res_list))

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
y = []
z = []
x = []
for i in range(1, m+1):
    p, s = input().split()
    if p not in x:
        if s == 'AC':
            x.append(p)
        else:
            y.append(p)
for i in y:
    if i in x:
        z.append(i)
print(len(x), len(z))

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int,input().split())
A = [list(input().split())for i in range(M)]
ans = 0
pen = 0
r = []
for i in range(len(A)):
  if A[i][1] == 'AC':
    r.append(A[i][0])
R = list(set(r))
ans = len(R)
for _ in range(ans):
  for j in range(len(A)):
    if A[j][0] == R[0] and A[j][1] == 'AC':
      del R[0]
      break
    if A[j][0] == R[0] and A[j][1] == 'WA':
      pen+=1
print(ans,pen)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
p_s = []
for i in range(m):
  p_s.append(input().split())
#p_s = [input().split() for i in range(m)]
dic = {}
penalty = 0
acc = 0
num_list=[]
for i in range(m):
  num = p_s[i][0]
  if num in num_list:
    continue
  if p_s[i][1] == "WA":
    if num in dic:
      dic[num]+=1
    else:
      dic[num]=1
  else:
    if num not in num_list:
      num_list.append(num)
      acc += 1
    if num in dic:
      penalty += dic[num]

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