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:
tmp = input().split()
N = int(tmp[0])
M = int(tmp[1])

quiz_dict = {}
wa_dict = {}
 
for i in range(M):
  tmp = input().split()
  
  quiz = tmp[0]
  res = tmp[1]
  
  if quiz not in quiz_dict:
    quiz_dict[quiz] = 0
  
  if quiz not in wa_dict: 
    wa_dict[quiz] = 0
  
  if res == "AC":
    quiz_dict[quiz] = 1
  if res == "WA":
    if quiz_dict[quiz] == 0:
      wa_dict[quiz] += 1



tmp_list = [k for k, v in quiz_dict.items() if v > 0] 


def filter_dict(f, d):
  return {k:v for k,v in d.items() if f(k,v)}

a = len(filter_dict(lambda k,v: v==1, quiz_dict))
tmp = filter_dict(lambda k,v: k in tmp_list, wa_dict)
wa_n = sum(tmp.values())

print(a, wa_n)

Submission status: Time Limit Exceeded

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

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

sl = []
ans = 0
pen = 0
WA = [0 for _ in range(N)]
for i in range(M):
    p, S = input().split()
    if p in sl:
        continue

    if S == 'AC':
        ans += 1
        sl.append(p)
        pen += WA[int(p) - 1]
    else:
        WA[int(p) - 1] += 1

print(ans, pen)

Submission status: Time Limit Exceeded

Solution code:
import collections
n, m =map(int,input().split())
p = []
for i in range(m):
    p.append(input().split())

del_l = []
for j in range(m):
    if p[j][1] == 'AC':
        del_l.append(p[j][0])
        p[j][0] = 'pass'
        p[j][1] = 'pass'
    if p[j][1] =='WA' and p[j][0] in del_l:
        p[j][0] = 'pass'
        p[j][1] = 'pass'
pen = 0
for s in range(m):
    if p[s][1] == 'WA' and p[s][0] in del_l:
        pen += 1
print(len(collections.Counter(del_l)),pen)

Submission status: Time Limit Exceeded

Solution code:
import sys
from collections import defaultdict

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

wa=defaultdict(lambda: 0)
ac=set()
cnt = 0
for line in sys.stdin:
  p, s = line.split()
  p = int(p)
  if p in set(ac):
    continue

  if s == "AC":
    cnt+=1
    ac.add(p)
  else:
    wa[p] += 1

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

Submission status: Time Limit Exceeded

Solution code:
import sys
from collections import defaultdict

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

wa=defaultdict(lambda: 0)
ac=set()

for line in sys.stdin:
  p, s = line.split()
  p = int(p)
  if p in set(ac):
    continue

  if s == "AC":
    ac.add(p)
  else:
    wa[p] += 1

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

Submission status: Time Limit Exceeded

Solution code:
import sys
from collections import defaultdict

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

pen_dic=defaultdict(lambda: 0)
ac=set()

for line in sys.stdin:
  p, s = line.split()
  p = int(p)
  if p in set(ac):
    continue

  if s == "AC":
    ac.add(p)
  else:
    pen_dic[p] += 1
print(len(ac), sum(pen_dic[i] for i in ac))

Submission status: Time Limit Exceeded

Solution code:
P=[]
S=[]

N,M = map(int, input().split(' '))
for i in range(M):
    p,s=map(str,input().split(' '))
    P+=p
    S+=[s]    
P=[int(p) for p in P]

Q=[]
for i in range(N):
    Q+=[[]]

for i in range(M):
    for j in  range(N):
        if P[i] == j+1 :
            Q[j]+=[S[i]]
            

A=0
B=0
b=0

def length(Q):
    if Q == []:
        return 0
    else:
        return len(Q)



for  i in range(len(Q)):
    b = 0
    if Q[i]==[]:
        pass
    else:
        for j in range(len(Q[i])):
            if Q[i]==[]:
                break
            elif Q[i][j]=='WA':
                b +=1
            elif Q[i][j]=='AC':
                A +=1
                B+=b
                break

print(A,B)

Submission status: Time Limit Exceeded

Solution code:
import sys
from collections import defaultdict

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

pen_dic=defaultdict(lambda: 0)
ac=set()

for line in sys.stdin:
  p, s = line.split()
  if p in set(ac):
    continue

  if s == "AC":
    ac.add(p)
  else:
    pen_dic[p] += 1
print(len(set(ac)), sum(pen_dic[str(i)] for i in list(ac)))

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict

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

pen_dic=defaultdict(lambda: 0)
ac=set()

for _ in range(m):
  p, s = input().split()
  if p in set(ac):
    continue

  if s == "AC":
    ac.add(p)
  else:
    pen_dic[p] += 1
print(len(set(ac)), sum(pen_dic[str(i)] for i in list(ac)))

Submission status: Time Limit Exceeded

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

del_l = []
for j in range(m):
    if p[j][1] == 'AC' and p[j][0] not in del_l:
        del_l.append(p[j][0])
    if p[j][1] =='WA' and p[j][0] in del_l:
        p[j][0] = 'pass'
        p[j][1] = 'pass'
pen = 0
for s in range(m):
    if p[s][1] == 'WA' and p[s][0] in del_l:
        pen += 1
print(len(del_l),pen)

Submission status: Time Limit Exceeded

Solution code:
P=[]
S=[]

N,M = map(int, input().split(' '))
for i in range(M):
    p,s=map(str,input().split(' '))
    P+=p
    S+=[s]    
P=[int(p) for p in P]

Q=[]
for i in range(N):
    Q+=[[]]

for i in range(M):
    for j in  range(N):
        if P[i] == j+1 :
            Q[j]+=[S[i]]
            

A=0
B=0
b=0

def length(Q):
    if Q == []:
        return 0
    else:
        return len(Q)



for  i in range(length(Q)):
    b = 0
    for j in range(length(Q[i])):
        if Q[i]==[]:
            break
        elif Q[i][j]=='WA':
            b +=1
        elif Q[i][j]=='AC':
            A +=1
            B+=b
            break
            
print(A,B)

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict

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

cor = pen = temp_pen = 0
temp_p = "0"
pen_dic=defaultdict(lambda: 0)
ac=set()

for _ in range(m):
  p, s = input().split()
  if p in set(ac):
    continue

  t = pen_dic[p]
  if s == "AC":
    ac.add(p)
  else:
    pen_dic.update({p:t + 1})
print(len(set(ac)), sum(pen_dic[str(i)] for i in list(ac)))

Submission status: Time Limit Exceeded

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




count_WA=0

AC=[]
x=[]
for i in range(M):
    a=input().split()
    x.append(a)
    if a[1]=="AC" and not(a[0] in AC):
        AC.append(a[0])

count_AC=len(AC)

for i in x:
    if i[0] in AC:
        if i[1]=="AC":

            AC.remove(i[0])
        else:
            count_WA+=1




print(count_AC,count_WA,sep=" ")

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int,input().split())
p = []
S = []
for i in range(M):
    p1,S1=[i for i in input().split()]
    p.append(p1)
    S.append(S1)
a = 0
b = 0
c = 0

for j in range(N):
    for k in range(M):
        if int(p[k]) == j+1:
            if S[k] == 'WA':
                b += 1
            elif S[k] == 'AC':
                a += 1
                c = b
                break
print(a,c)

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:

def solve(N, M, A):
    A = [[int(x[0]), x[1]] for x in A]

    Unsolve = [0]*(N+1)
    Solved = []
    ac = 0
    wa = 0
    for i in range(M):
        if A[i][0] not in Solved:
            if A[i][1] == 'WA':
                Unsolve[A[i][0]] += 1
            elif A[i][1] == 'AC':
                Solved.append(A[i][0])
                wa += Unsolve[A[i][0]]
                ac += 1

    return ac, wa

def main():
    N, M = map(int, input().split())
    A = [list(x for x in input().split()) for _ in range(M)]
    ans = solve(N, M, A)
    print(*ans)

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
l=[]
ac_l=[]
cnt1=0
cnt2=0
for i in range(m):
	p=list(input().split())
	l.append(p)
	if l[i][1]=="AC" and l[i][0] not in ac_l:
			ac_l.append(l[i][0])
			cnt1+=l[:i].count([l[i][0],"WA"])
			cnt2+=1
print("{} {}".format(cnt2,cnt1))

Submission status: Time Limit Exceeded

Solution code:
import sys

n, m = input().split()
i = [input() for i in range(int(m))]

n_l = [0] * int(n)
w_l = [0] * int(n)
p_l = []

a = 0
w = 0
for i_s in i:
    p, c = i_s.split()
    p = int(p) - 1
    if n_l[p] == 1:
        continue

    if p not in p_l:
        p_l.append(p)

    if c == "AC":
        n_l[p] = 1
    else:
        w_l[p] += 1

for p in p_l:
    if n_l[p] == 1:
        a += 1
        w += w_l[p]

print("{} {}".format(a, w))

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
l=[]
ac_l=[]
cnt1=0
cnt2=0
for i in range(m):
	p=list(input().split())
	l.append(p)
for i in range(m):
	if l[i][1]=="AC" and l[i][0] not in ac_l:
			ac_l.append(l[i][0])
			cnt1+=l[:i].count([l[i][0],"WA"])
			cnt2+=1
print("{} {}".format(cnt2,cnt1))

Submission status: Time Limit Exceeded

Solution code:
import sys

n, m = input().split()
i = [input() for i in range(int(m))]

n_l = [0] * int(n)
w_l = [0] * int(n)
p_l = []

a = 0
w = 0
for i_s in i:
    p, c = i_s.split()
    p = int(p) - 1
    if p not in p_l:
        p_l.append(p)

    if n_l[p] == 1:
        continue

    if c == "AC":
        n_l[p] = 1
    else:
        w_l[p] += 1

for p in p_l:
    if n_l[p] == 1:
        a += 1
        w += w_l[p]

print("{} {}".format(a, w))

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int,input().split())
l = [input().split() for _ in range(m)]
 
o = [l[i][0] for i in range(m)]
p = list(set(o))

t,f = 0,0
for i in p:
  q = [l[j][1] for j in range(m) if l[j][0] == i ]
  if q.count("AC") == 0:
    pass
  else:
    t = t + 1
    f = f + q.index("AC")
print(t,f)

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int,input().split())
l = [input().split() for _ in range(m)]
 
o = [l[i][0] for i in range(m)]
p = list(set(o))

t = 0
f = 0
 
for i in p:
  q = [l[j][1] for j in range(m) if l[j][0] == i ]
  if q.count("AC") == 0:
    pass
  else:
    t = t + 1
    f = f + q.index("AC")
print(t,f)

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
l=[]
ac_l=[]
cnt1=0
cnt2=0
for i in range(m):
	p=list(input().split())
	l.append(p)
for i in range(m):
	if l[i][1]=="AC":
		if l[i][0] not in ac_l:
			ac_l.append(l[i][0])
			a=l[i][0]
			cnt1+=l[:i].count([a,"WA"])
			cnt2+=1
print("{} {}".format(cnt2,cnt1))

Submission status: Time Limit Exceeded

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

l_1 = []
l_2 = []
for x in p:
    l_1.append(x[0])
for y in p:
    l_2.append(y[1])
del_l = []
for j in range(m):
    if l_2[j] == 'AC' and l_1[j] not in del_l:
        del_l.append(l_1[j])
    if l_2[j] =='WA' and l_1[j] in del_l:
        l_1[j] = 'pass'
        l_2[j] = 'pass'
pen = 0
for s in range(m):
    if l_2[s] == 'WA' and l_1[s] in del_l:
        pen += 1
print(len(del_l),pen)

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_list = [0 for _ in range(N)]
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])
        AC_list = list(set(AC_list))
    elif(not(S[0] in AC_list)):
        WA_list[int(S[0])-1] += 1
        
WA_count = 0

for item in AC_list:
    WA_count += WA_list[int(item)-1]

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

Submission status: Time Limit Exceeded

Solution code:
N,M=map(int,input().split())
List=[list(input().split()) for i in range(M)]
AC = set([])
WA = []
accnt = 0
wacnt = 0

for i in range(M):
  num = List[i][0]
  res = List[i][1]
  
  if num in AC:
    aa = 9
  else:
    if res == "AC":
      accnt = accnt + 1
      AC.add(num)
      wacnt = wacnt + WA.count(num)
    if res == "WA":
      WA.append(num)
  
ans = [int(accnt),int(wacnt)]
print(*ans)

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_list = [0 for _ in range(N)]
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_list[int(S[0])-1] += 1

AC_set = list(set(AC_list))

WA_count = 0

for item in AC_set:
    WA_count += WA_list[int(item)-1]

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

Submission status: Time Limit Exceeded

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

ac = []
ac2 = []
wa = 0

for i in range(M):
    [p, S] = A[i]
    if (not p in ac) and S == 'AC':
            ac.append(p)

for i in range(M):
    [p, S] = A[i]
    if p in ac:
        if S == 'AC':
            ac2.append(p)
        elif (not p in ac2):
            wa += 1

print(len(ac), wa)

Submission status: Time Limit Exceeded

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




count_WA=0

AC=[]
x=[]
for i in range(M):
    a=input().split()
    x.append(a)
    if a[1]=="AC" and not(a[0] in AC):
        AC.append(a[0])

count_AC=len(AC)

for i in x:
    if i[0] in AC:
        if i[1]=="AC":
            AC.remove(i[0])
        else:
            count_WA+=1




print(count_AC,count_WA,sep=" ")

Submission status: Time Limit Exceeded

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

p = []
tmp_p = [0]*N
S = []

wa = 0
ac = 0

for i in range(M):
    P, s = list(map(str, input().split()))

    if s == 'AC' and P not in p:
        ac += 1
        p.append(P)
        wa += tmp_p[int(P)-1]
    if s == 'WA' and P not in p:
        tmp_p[int(P)-1] += 1


print(ac, wa)

Submission status: Time Limit Exceeded

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

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

print(ac, sum(wa))

Submission status: Time Limit Exceeded

Solution code:
N,M = (int(x) for x in input().split())
cor = 0
mis = 0
numList = []
misList = {}

for _ in range(M):

    num,ans = input().split()

    if num not in numList:
        if num not in misList.keys():
            misList[num] = 0
            
        if ans == 'AC':
            cor += 1
            numList.append(num)
            mis += misList[num]
            misList.pop(num)
        else:
            misList[num] += 1

print(cor,mis)

Submission status: Time Limit Exceeded

Solution code:
N,M=map(int, input().split())
wa={}
ac=[]
key=[]

    
for i in range(M):
    p,s=input().split()
    if p not in ac:
        if p not in key:
            key.append(p)
            wa[p]=0

        if s=="WA":
            wa[p]+=1
        else:
            ac.append(p)
ans=0
for i in key:
    if i in ac:
        ans+=wa[i]
print(len(ac),ans)

Submission status: Time Limit Exceeded

Solution code:
N,M = (int(x) for x in input().split())
cor = 0
mis = 0
numList = []
misList = {}

for _ in range(M):

    num,ans = input().split()

    if num not in numList:
        if num not in misList.keys():
            misList[num] = 0
            
        if ans == 'AC':
            cor += 1
            numList.append(num)
            mis += misList[num]
        else:
            misList[num] += 1

print(cor,mis)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!
n,m = map(int,input().split())
p =[]
s = []
for i in range(m):
    pp,ss = input().split()
    pp =int (pp)
    p.append(pp)
    s.append(ss)
correct_num =[]
for i in range(n):
    correct_num.append(0)
correct = 0
penalty =[]
for i in range(n):
    penalty.append(0)
for i in range(m):
    if s[i] == "AC" :
        correct_num[p[i]-1] = 1
for i in range(n):
    if correct_num[i] == 1:
        correct+=1
i = 0
while i <n :
    if correct_num[i] ==1:
        for j in range(m):
            if p[j]==i+1 and s[j] == "WA" :
                penalty[i] +=1
            if p[j]==i+1 and s[j] == "AC" :
                break
    i+=1
penaltysum=0
for i in range(n):
    penaltysum+=penalty[i]
print(correct,penaltysum)

Submission status: Time Limit Exceeded

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


ACs=[]
WAs={}

AC=0
pena=0
for i in range(M):
  num, jud=input().split()
  if num in ACs:
    continue
  elif jud=="WA":
    try:
      WAs[num]+=1
    except:
      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:
qus = list(map(int, input().split()))
data  = []
ch = []
sum = 0
pe = 0
for i in range(0,qus[0]):
  data.append(0)
for i in range(0, qus[1]):
  int_data = list(map(str, input().split()))
  n = int(int_data[0])-1
  if int_data[1] == 'WA':
    data[n] += 1
  else:
    if n in ch:
      None
    else:
      ch.append(n)
      sum += 1
      pe += data[n]
print(sum,' ',pe)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
lp, ls = [0] * m, [0] * m
for i in range(m):
    lp[i], ls[i] = input().split()

lpu = list(set(lp))
lac = [0] * len(lpu)
lwa = [0] * len(lpu)

for e, i in enumerate(lpu):
    if lac[e] == 0:
        for j in range(m):
            if lp[j] == i and ls[j] == 'WA':
                lwa[e] += 1
            if lp[j] == i and ls[j] == 'AC':
                lac[e] = 1
                break
        else:
            lwa[e] = 0
    else:
        break

print(sum(lac), sum(lwa))

Submission status: Time Limit Exceeded

Solution code:
A = list(map(int, input().split()))
B = [tuple(input().split()) for i in range(A[1])]
C = [int(B[i][0]) for i in range(A[1])]
ac = 0
wa = 0
import collections
x = collections.Counter(C)
for k in list(x.keys()):
  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:
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=[]
  qset=[]
  for i,x in enumerate(q):
    if x == j:
      index.append(i)
      qset.append(ac[i])
      if ac[i] =="AC":
        continue
  #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:
n,m = map(int,input().split(" "))
question_list = []
res_list = []
ac_list = []
for i in range(m):
    a,b = input().split(" ")
    a = int(a)
    question_list.append(a)
    res_list.append(b)
correct = 0
mistake = 0




for i,j in enumerate(res_list):
    if i == 0:
        if j == "WA":
            mistake += 1
        else:
            correct += 1
            ac_list.append(question_list[i])
            
    else:
        #今やっている問題がまだ正解していない
        if question_list[i] not in ac_list:
            if j == "WA":
                mistake += 1
            else:
                correct += 1
                ac_list.append(question_list[i])
                
            
    if len(ac_list) == n:
        break
            
for i,j in enumerate(res_list):
    if question_list[i] not in ac_list:
        mistake -= 1
        
      
print(correct,mistake)

Submission status: Time Limit Exceeded

Solution code:
N, M = list(map(int, input().split()))
P = []
S = []


def f(s):
  lst = s.split()
  return int(lst[0]),lst[1]

for i in range(M):
  p, s = f(input())
  P.append(p)
  S.append(s)

correct = 0
penalty = 0
q = []
p = []

for i, j in enumerate(S):
  if 'AC' in j:
    if P[i] not in q:
      q.append(P[i])
      correct += 1
    else:
      continue
  if 'WA' in j:
    p.append(P[i])
    if P[i] not in q:
        penalty += 1
    else:
      continue
for i in range(len(p)):
  if p[i] not in q:
    penalty -= 1

print(correct, penalty)

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int,input().split())
li = []
sets = set()
for m in range(M):
  x,y = input().split()
  li.append([int(x), y])
  if y == 'AC':
    sets.add(int(x))

ac = len(sets)
wa = 0

for s in sets:
  for i in li:
    if i[0] == s and i[1] == 'WA':
      wa += 1
    if i[0] == s and i[1] == 'AC':
      break

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

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])
    elif plist[i]+" "+slist[i] in newlist and slist[i]=="AC":
        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])
    else:
        pass

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

Submission status: Time Limit Exceeded

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

solved = []
pennalty = {}
pena = 0

for i in range(inf[1]):
    sub = [a for a in input().split(' ')]
    key = sub[0]
    if not(key in solved):
        if sub[1] == 'AC':
            solved.append(key)
            if key in pennalty:
                pena += pennalty[key]
        else:
            if (key in pennalty):
                pennalty[key] += 1
            else:
                pennalty[key] = 1
            
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" and li[j][0] not in a:
    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(a), b)

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int,input().split())
sekai = 0
wrong = [0]*(10**5)
ans = 0
problem = []

for i in range(M):
  p,S = map(str,input().split())
  if (S == 'AC') and (p not in problem):
    problem.append(p)
    sekai += 1
  elif(S=='WA') and (p not in problem):
    wrong[int(p)] += 1

for j in problem:
  ans += wrong[int(j)]
print(sekai, ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
n,m = map(int,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())
P=[]
S=[]
for i in range(M):
    p,s=input().split()
    P.append(int(p))
    if s=="WA":
      S.append(0)
    else:
      S.append(1)


import numpy as np
P=np.array(P)
S=np.array(S)

if M>0:
    ans=np.unique(P[S==1])

    wa=0
    for j in ans:
        for i in S[P==j]:
            if i==0:
                wa+=1
            else:
                break

    print(len(ans),wa)
else:
    print(0,0)

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":
        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 = tuple(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:
N, M = list(map(int, input().split()))
P = []
S = []


def f(s):
  lst = s.split()
  return int(lst[0]),lst[1]

for i in range(M):
  p, s = f(input())
  P.append(p)
  S.append(s)

correct = 0
penalty = 0
q = []
p = []

for i, j in enumerate(S):
  if 'AC' in j:
    if P[i] not in q:
      q.append(P[i])
      correct += 1
    else:
      q.append(P[i])
      continue
  if 'WA' in j:
    p.append(P[i])
    if P[i] not in q:
        penalty += 1
    else:
      continue
for i in range(len(p)):
  if p[i] not in q:
    penalty -= 1

print(correct, penalty)

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
WA =0
dic = {}
for m in range(M):
    id, res = map(str,input().split())
    if id not in dic.keys():
        dic[id] = [res]
        if res == 'AC':
            AC += 1
    elif 'AC' not in dic[id]:
        dic[id].append(res)
        if res == 'AC':
            AC += 1
            if 'WA' in dic[id]:
                WA += dic[id].count('WA')


print(str(AC)+ ' '+str(WA))

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 = []
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())
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:
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
p_s = []
for i in range(m):
  p_s.append(input().split())
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())
ac=0
wa=0
problem=[]
ac_problem=[]
for i in range(m):
    ps=list(map(str,input().split()))
    ps[0]=int(ps[0])
    problem.append(ps)
    if ps[1]=='AC' and ac_problem.count(ps[0])==0:
        ac_problem.append(ps[0])
for i in range(m):
    if ac_problem.count(problem[i][0])>0:
        if problem[i][1]=='AC':
            ac+=1
            t=problem[i][0]
            ac_problem[ac_problem.index(t)]=0
        elif problem[i][1]=='WA':
            wa+=1
            
print(ac,wa)

Submission status: Time Limit Exceeded

Solution code:
N,M=map(int, input().split())
P=[]
S=[]
for i in range(M):
    p,s=input().split()
    P.append(int(p))
    S.append(s)


import numpy as np
P=np.array(P)
S=np.array(S)

if M>0:
    ans=np.unique(P[S=="AC"])

    wa=0
    for j in ans:
        for i in S[P==j]:
            if i=="WA":
                wa+=1
            else:
                break

    print(len(ans),wa)
else:
    print(0,0)

Submission status: Time Limit Exceeded

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

args = input().split()
n = int(args[0])
m = int(args[1])
ok_list = [0] * 100000
ok_cnt = 0
ng_cnt = 0
args_results = [input().split() for i in range(m)]
for args_result in args_results:
    target = int(args_result[0])
    score = args_result[1]
    if target in ok_list:
        continue
    else:
        if score == 'AC':
            ok_list[ok_cnt] = target
            ok_cnt += 1
        else:
            ng_cnt += 1
print ok_cnt, ng_cnt

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=[]
  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:
n,m = map(int,input().split())
ans = []
for i in range(m):
  ans += [input().split()]
ac = []
wn = []
acn,wan = 0,0
for i in ans:
  if i[0] not in ac:
    if i[1] == 'AC' :
      wan += wn.count(i[0])
      ac += [i[0]]
      acn += 1
    else :
      wn += [i[0]]
print(acn,wan)