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: Runtime Error

Solution code:
import sys

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

try:
    p_ini, s_ini = map(str, input().split())
except ValueError:
    print(0, 0)
    sys.exit()

p_list = []
s_list = []

p_list.append(p_ini)
s_list.append(s_ini)

for i in range(M - 1):
    p, s = map(str, input().split())
    p_list.append(p)
    s_list.append(s)

index_list = [i for i in range(M)]

# 区切れ目の辞書配列
p_dict = dict([(p_list[j], index_list[j]) for j in range(M)])
p_dict_taple = sorted(p_dict.items(), key=lambda x: x[0])
p_dict_list = [list(p_dict_taple[i]) for i in range(len(p_dict_taple))]

p_unique = list(set(p_list))

AC_num = 0
WA_num = 0
index_start = 0
for i, j in enumerate(p_unique):
    index_end = p_dict_list[i][1]
    j_list = s_list[index_start:index_end + 1]
    j_len = len(j_list)

    # ACがある場合、ACの数, WAの数をカウント
    if 'AC' in j_list:
        AC_num += 1
        span = j_list.index('AC')
        j_len = len(j_list[:span])
        WA_num += j_len

    else:
        WA_num += j_len

    index_start = index_end + 1

print(AC_num, WA_num)

Submission status: Runtime Error

Solution code:
import pandas as pd
N, M = map(int, input().split())

if M == 0:
    print('0 0')
else:
    S = []
    for _ in range(M):
        S.append(input().split())
    
    df = pd.DataFrame(S,columns=['P','S'])
    ACdf = df[df['S'] == 'AC'].drop_duplicates()
    AC = len(ACdf)
    last = ACdf.tail(1).index.values[0]
    WAdf = df[(df[df['P'].isin(ACdf['P'])]['S'] == 'WA')][:(last-1)]
    WA = len(WAdf)
    print(AC, WA)

Submission status: Runtime Error

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

cor_count = 0
pen_count = 0
AC_list = []

p = [0]*M#問題の番号
s = [0]*M#結果 AC,WA

if M == 0 or N==0:
	print('0 0')
	sys.exit()


l = []
for i in range(M):
	p[i],s[i] = input().split()

for i in range(M-1):
	if p[i] != p[i+1]:
		l.append(i+1)

x = 0
for i in range(M):
	if not p[i] in AC_list:
		if s[i] == 'AC':
			AC_list.append(p[i])
		else:
			pen_count += 1
	else:
		if len(l)!= 0:
			i = l[x]
			x += 1

#print(AC_list)
cor_count = len(set(AC_list))

print(cor_count,pen_count)

Submission status: Runtime Error

Solution code:
N,M = map(int, input().split())
p = [0]*M
S = [0]*M
X = [0]*N
Y = [0]*N
A = 0
B = 0
for i in range(M):
    p[i],S[i] = input().split()
q = [int(s) for s in p]
for i in range(M):
    if S[i] == "AC":
        if Y[q[i]]==0:
            Y[q[i]]+=1
            A += 1
            B += X[q[i]]
        else:
            A = A
            B = B
    else:
        if Y[q[i]]==0:
            X[q[i]] += 1
        else:
            A = A
            B = B
print(str(A)+" "+str(B))

Submission status: Runtime Error

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

cor_count = 0
pen_count = 0
AC_list = []

p = [0]*M#問題の番号
s = [0]*M#結果 AC,WA

if M == 0 or N==0:
	print('0 0')
	sys.exit()


l = []
for i in range(M):
	p[i],s[i] = input().split()

for i in range(M-1):
	if p[i] != p[i+1]:
		l.append(i+1)
print(l)
x = 0
for i in range(M):
	if not p[i] in AC_list:
		if s[i] == 'AC':
			AC_list.append(p[i])
		else:
			pen_count += 1
	else:
		if len(l)!= 0:
			i = l[x]
			x += 1

#print(AC_list)
cor_count = len(set(AC_list))

print(cor_count,pen_count)

Submission status: Runtime Error

Solution code:
import pandas as pd
N, M = map(int, input().split())

if M == 0:
    print('0 0')
else:
    S = []
    for _ in range(M):
        S.append(input().split())
    
    df = pd.DataFrame(S,columns=['P','S'])
    ACdf = df[df['S'] == 'AC'].drop_duplicates()
    AC = len(ACdf)
    last = ACdf.tail(1).index.values[0]
    WAdf = df[(df[df['P'].isin(ACdf.P)].S == 'WA')][:(last-1)]
    WA = len(WAdf)
    print(AC, WA)

Submission status: Runtime Error

Solution code:
N, M = map(int,input().split())
A = [list(map(str,input().split())) for _ in range(M)]
A = sorted(A, key=lambda x: x[0])

all_failure = 0
all_AC = 0
scan = 0
for j in range(N):
    while scan <= M:
        if int(A[scan][0]) == j+1 and A[scan][1] == "WA":
            all_failure += 1
            scan+=1

        elif int(A[scan][0]) == j+1 and A[scan][1] ==  "AC":
            all_AC+=1
            scan+=1
            break
        else:
            break
        
print(all_AC, all_failure)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
p = [0]*M
s = [a]*M
for i in range(M):
    p[i],s[i] = map(str,input().split())
pans = 0
sans = 0

for j in range(N):
    for k,val in enumerate(p):
        if val == str(j+1) and s[k] == "WA":
            sans += 1
        elif val == str(j+1) and s[k] == "AC":
            pans += 1
            break
print(int(pans),int(sans))

Submission status: Runtime Error

Solution code:
N,M = map(int, input().split())
p = [0]*M
S = [0]*M
X = [0]*N
Y = [0]*N
A = 0
B = 0
for i in range(M):
    p[i],S[i] = input().split()
q = [int(s) for s in p]
for i in range(M):
    if Y[q[i]]==1:
        break
    if S[i] == "AC":
        if Y[q[i]]==0:
            Y[q[i]]+=1
            A += 1
            B += X[q[i]]
    else:
        if Y[q[i]]==0:
            X[q[i]] += 1
print(str(A)+" "+str(B))

Submission status: Runtime Error

Solution code:
import pandas as pd
N, M = map(int, input().split())

if M == 0:
    print('0 0')
else:
    S = []
    for _ in range(M):
        S.append(input().split())
    
    df = pd.DataFrame(S,columns=['P','S'])
    ACdf = df[df.S == 'AC'].drop_duplicates()
    AC = len(ACdf)
    last = ACdf.tail(1).index.values[0]
    WAdf = df[(df[df.P.isin(ACdf.P)].S == 'WA')][:(last-1)]
    WA = len(WAdf)
    print(AC, WA)

Submission status: Runtime Error

Solution code:
n , m = map(int,input().split())
r = 0
w = 0
a = []
b = []
tem = []
man = [0]
for i in range(m):
    ta,tb = map(str,input().split())
    a.append(ta)
    b.append(tb)
for i in range(m):
    if len(man) == 1:
        if b[i] == "AC":
                r += 1
                tem.append(i)
                man.append(a[i])
    else:
        for k in range(len(man) - 1):
            z = man[k + 1]
            if b[i] == "AC" and int(a[i]) != int(z):
                r += 1
                tem.append(i)
                man.append(a[i])
for j in range(len(tem)):
    for i in range(tem[j] + 1):
        #print(i)
        #print(j)
        if a[j] == a[i] and b[j] == "WA":
            w += 1
ans = (r + "" + w)
print(ans)

Submission status: Runtime Error

Solution code:
N,M = map(int, input().split())
p = [0]*M
S = [0]*M
X = [0]*N
Y = [0]*N
A = 0
B = 0
for i in range(M):
    p[i],S[i] = input().split()
q = [int(s) for s in p]
for i in range(M):
    if S[i] == "AC":
        if Y[q[i]]==0:
            Y[q[i]]+=1
            A += 1
            B += X[q[i]]
    else:
        if Y[q[i]]==0:
            X[q[i]] += 1
print(str(A)+" "+str(B))

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
A = [input().split() for i in range(M)]
problems = {}
reject_count = 0
for P, S in A:
    if not problems.get(P) and P <= N:
        if S != 'AC':
            reject_count += 1
        else:
            problems[P] = S
print(len(problems), reject_count)

Submission status: Runtime Error

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 int_data[1] = 'WA':
    if n in data:
      data[n] += 1
    else:
      data[n] = 1
  else:
    if  n in ch:
      None
    else:
      ch.append(n)
      pe += data[n]
      sum += 1
print(sum,' ',pe)

Submission status: Runtime Error

Solution code:
n , m = map(int,input().split())
r = 0
w = 0
a = []
b = []
tem = []
man = [0]
for i in range(m):
    ta,tb = map(str,input().split())
    a.append(ta)
    b.append(tb)
for i in range(m):
    if len(man) == 1:
        fif b[i] == "AC":
                r += 1
                tem.append(i)
                man.append(a[i])
    else:
        for k in range(len(man) - 1):
            z = man[k + 1]
            if b[i] == "AC" and int(a[i]) != int(z):
                r += 1
                tem.append(i)
                man.append(a[i])
for j in range(len(tem)):
    for i in range(tem[j] + 1):
        #print(i)
        #print(j)
        if a[j] == a[i] and b[j] == "WA":
            w += 1
ans = (r + "" + w)
print(ans)

Submission status: Runtime Error

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 int_data[1] = 'WA':
    if n in data:
      data[n] += 1
    else:
      data[n] = 0
  else:
    if  n in ch:
      None
    else:
      ch.append(n)
      pe += data[n]
      sum += 1
print(sum,' ',pe)

Submission status: Runtime Error

Solution code:
n, m = [int(i) for i in input().split(" ")]
score_dict = {}
 
for i in range(m):
    p, s = input().split(" ")
    if p not in score_dict:
        score_dict[p] = []
    
    score_dict[p].append(s)
 
ac_count = 0
wa_count = 0
 
for i in score_dict.values():

    if "AC" in i:
        ac_count += 1
        wa_count += i.index("AC")]
    else:
        wa_count += len(i)
 
print("{0} {1}".format(ac_count, wa_count))

Submission status: Runtime Error

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

cor_count = 0
pen_count = 0
AC_list = []

p = [0]*M#問題の番号
s = [0]*M#結果 AC,WA

if M == 0 or N==0:
	print('0 0')
	sys.exit()


l = []
for i in range(M):
	p[i],s[i] = input().split()

for i in range(M-1):
	if p[i] != p[i+1]:
		l.append(i+1)
print(l)
x = 0
for i in range(M):
	if not p[i] in AC_list:
		if s[i] == 'AC':
			AC_list.append(p[i])
		else:
			pen_count += 1
	else:
		i = l[x]
		x += 1

#print(AC_list)
cor_count = len(set(AC_list))

print(cor_count,pen_count)

Submission status: Runtime Error

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):
    print(newlist)
    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: Runtime Error

Solution code:
N,M = map(int, input().split())
p = [0]*M
S = [0]*M
X = [0]*N
Y = [0]*N
X = [int(s) for s in X]
Y = [int(s) for s in Y]
A = 0
B = 0
for i in range(M):
    p[i],S[i] = input().split()
q = [int(s) for s in p]
for i in range(M):
    if S[i] == "AC":
        if Y[q[i]]==0:
            Y[q[i]]+=1
            A += 1
            B += X[q[i]]
    else:
        if Y[q[i]]==0:
            X[q[i]] += 1
print(str(A)+" "+str(B))

Submission status: Runtime Error

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

for i in range(M):
    p.append(p_S[i][0])
    S.append(p_S[i][1]=='AC')

p = list(map(int, p))
S = list(map(int, S))

flag_p = p[0]
flag_ac = 0
AC_sum = 0
WA_sum = 0
WA = 0

for i in range(M):

    if flag_p == p[i]:
        if S[i] == 0 and flag_ac == 0:
            WA += 1
        elif S[i] == 1 and flag_ac == 0:
            AC_sum += 1
            WA_sum += WA
            flag_ac = 1
    else:
        flag_p = p[i]
        flag_ac = 0
        WA = 0
        if S[i] == 0 and flag_ac == 0:
            WA += 1
        elif S[i] == 1 and flag_ac == 0:
            AC_sum += 1
            WA_sum += WA
            flag_ac = 1

print(AC_sum, WA_sum)

Submission status: Runtime Error

Solution code:
N, M=map(int, input().split())
P=[]
S=[]
for i range(M):
  p, s = map(int, input().split())
  count('WA')
  count('AC')
  P.append(p)
  S.append(s)
  if i in range(M):
    index=P.index(i+1)
    if S[index]=='WA':
      WA+=1
    else:
      AC=1
      if AC!=0:
        WA=0
      return break
print(AC, WA)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
p = [0] * N
s = [0] * M
for i in range(M):
    p[i], s[i] = input().split()
#sort_p = sorted(p)
#set_p = list(set(sort_p))
sort_p = list(set(p))
set_p = sorted(sort_p)
b = [0] * len(set_p)
for i in range(len(set_p)):
    b[i] = False

seikai = 0
pena = 0
for i in range(M):
  if False not in b:
    break
  for n in range(len(set_p)):
    if p[i] == set_p[n]:
      if s[i] == "AC":
        if b[n] == False:
          seikai += 1
          b[n] = True
      else:
        if b[n] == False:
          pena += 1

print("{0} {1}".format(seikai, pena))

Submission status: Runtime Error

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: Runtime Error

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

flag_p = p[0]
flag_ac = 0
AC_sum = 0
WA_sum = 0
WA = 0

for i in range(M):

    if flag_p == p[i]:
        if S[i] == 0 and flag_ac == 0:
            WA += 1
        elif S[i] == 1 and flag_ac == 0:
            AC_sum += 1
            WA_sum += WA
            WA = 0
            flag_ac = 1
            
    else:
        flag_p = p[i]
        flag_ac = 0
        WA_sum += WA
        WA = 0
        if S[i] == 0 and flag_ac == 0:
            WA += 1
        elif S[i] == 1 and flag_ac == 0:
            AC_sum += 1
            WA_sum += WA
            flag_ac = 1

print(AC_sum, WA_sum)

Submission status: Runtime Error

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

RES = []

for i in range(M):
    RES.append(list(input().split()))

WA = [0]*(M+2)
ACed = [0]*(N+2)
tmp = 0
for i in range(M):
    num = int(RES[i][0])
    if RES[i][1] == "WA" and not ACed[num]:
        WA[num] += 1
    elif RES[i][1] == "WA" and ACed[num]:
        tmp += 1
    else:
        ACed[num] = 1

print(sum(ACed),end=" ")
print(sum(WA))

Submission status: Runtime Error

Solution code:
import numpy as np
hoge = input().split()
N = int(hoge[0])
M = int(hoge[1])

if M != 0:
  A = []
  ACnum = []
  ACkazu = []
  for i in range(M):
    hoge = input().split()
    if hoge[1] == "AC" and hoge[0] not in ACkazu:
      ACnum.append(i)
      ACkazu.append(hoge[0])
      A.append(hoge)
    elif hoge[0] not in ACkazu:
      A.append(hoge)
  pena = 0
  _remove = []
  for i in ACnum:
    i = int(i)
    AC_num = A[i][0]
    for j in range(0,i):
      if A[j][0] == A[i][0]:
        pena += 1
        _remove.append(j)
    _remove.append(i)
  # popでケツから消していく
  for i in reversed(_remove):
    A.pop(i)
  pena += len(A)
  print(len(ACnum), end="")
  print(" ", end="")
  print(pena, end="")
else:
  print(0, end="")
  print(" ", end="")
  print(0, end="")

Submission status: Runtime Error

Solution code:
flag_p = p[0]
flag_ac = 0
AC_sum = 0
WA_sum = 0
WA = 0

for i in range(M):

    if flag_p == p[i]:
        if S[i] == 0 and flag_ac == 0:
            WA += 1
            print("1!")
        elif S[i] == 1 and flag_ac == 0:
            AC_sum += 1
            WA_sum += WA
            WA = 0
            flag_ac = 1
            print("2!")
        print(flag_p)
            
    else:
        flag_p = p[i]
        flag_ac = 0
        WA_sum += WA
        WA = 0
        if S[i] == 0 and flag_ac == 0:
            WA += 1
            print("3!")
        elif S[i] == 1 and flag_ac == 0:
            AC_sum += 1
            WA_sum += WA
            flag_ac = 1
            print("4!")
        print(flag_p)

print(AC_sum, WA_sum)

Submission status: Runtime Error

Solution code:
import collections
S=input().split()
alldata=((input().split() for i in range(int(S[1])))
AC=(pair[0] for pair in alldata if pair[1]=="AC")
WA=(pair[0] for pair in data if (pair[1]=="WA") and (pair[0] in AC))
print(len(collectons.Counter(AC)+""+len(WA))

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
TF=[0]*n
p=[0]*n
for _ in range(m):
    i,s =map(str,input().split())
    i=int(i)-1
    if (s=="WA") and (TF[i]==1):
        pass
    elif (s=="WA") and (TF[i]==0):
        p[i]+=1
    elif (s=="AC") and (TF[i]==0):
        TF[i]=1
    elif (s=="AC") and (TF[i]==1):
        pass
for i in range(m):
    if TF[i]==0:
        p[i]=0
ac=sum(TF)
pe=sum(p)
print(ac,pe)

Submission status: Runtime Error

Solution code:
N,M = map(int, input().split())
p = [0]*M
S = [0]*M
X = [0]*N
Y = [0]*N
X = [int(s) for s in X]
Y = [int(s) for s in Y]
A = 0
B = 0
for i in range(M):
    p[i],S[i] = input().split()
p = [int(s) for s in p]
for i in range(M):
    if S[i] == "AC":
        if Y[p[i]]==0:
            Y[p[i]]+=1
            A += 1
            B += X[p[i]]
    else:
        if Y[p[i]]==0:
            X[p[i]] += 1
print(str(A)+" "+str(B))

Submission status: Runtime Error

Solution code:
N, M = list(map(int, input().split())) #問題数(リストサイズ）と提出数（ループ回数）を受ける
list_WA = [0] * N
list_Flag = [0] * N
for i in range(M):
  a, b = list(map(int, input().split()))
  if list_Flag[a-1] == 1:
	pass
  else:
    if b=='WA':
      list_WA[a-1]=list_WA[a-1]+1
    else:
      list_Flag[a-1]=list_Flag[a-1]+1
WA=sum(list_WA)
AC=sum(list_Flag)
ans=[AC,WA]
print(' '.join(map(str, ans)))

Submission status: Runtime Error

Solution code:
from operator import itemgetter
import collections
import numpy as np

N,  M = map(int, input().split())
S = [input().split() for i in range(M)]
S1 = sorted(S, key=itemgetter(0))
W = np.array(S1)
d = collections.Counter(W[:,0])
keylist = list(d.keys())
WA_cnt = 0
AC_cnt = 0
for num in range(len(keylist)):
    if len([i for i, x in enumerate(W[W[:,0] == keylist[num]][:,1]) if x == 'AC'] ) == 0:
        WA_cnt += len([i for i, x in enumerate(W[W[:,0] == keylist[num]][:,1]) if x == 'WA'] )
    else:
        MIN = min([i for i, x in enumerate(W[W[:,0] == keylist[num]][:,1]) if x == 'AC'] ) 
        WA_cnt += len([i for i, x in enumerate(W[W[:,0] == keylist[num]][:MIN+1,1]) if x == 'WA'] )
        AC_cnt += len([i for i, x in enumerate(W[W[:,0] == keylist[num]][:MIN+1,1]) if x == 'AC'] )
print(AC_cnt,WA_cnt)

Submission status: Runtime Error

Solution code:
N,M =  map(int,input().split())
WA = 0
AC = 0
for i in range(M):
    p,S = input().split()
    
    if S =="WA":
        WA = WA + 1
    if S == "AC":
        AC = AC +1
        for i in range(M):
            p1,S1 = input().split()
            if p != p1:
                break

print(AC,WA)

Submission status: Runtime Error

Solution code:
n, m = input().split(" ")
score_dict = {}
 
for i in range(m):
    p, s = input().split(" ")
    if p not in score_dict:
        score_dict[p] = []
    
    score_dict[p].append(s)
 
ac_count = 0
wa_count = 0
 
for i in score_dict.values():
    if "AC" in i:
        ac_count += 1
    
    wa_count += len(i[:i.index("AC")])
 
print("{0} {1}".format(ac_count, wa_count))

Submission status: Runtime Error

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

p = [0] * M
S = [''] * M


for i in range(M):
    p[i], S[i] = input().split()
    p[i] = int(p[i])

penalty = 0
right_ans = 0

dp = [[0] * 2 for i in range(N)]  # x問目の、score, penalty

for i in range(M):

    # 得点済
    if(dp[p[i]][0] > 0):
        continue

    if(S[i] == 'AC'):
        dp[p[i]][0] += 1
        continue

    elif(S[i] == 'WA'):
        dp[p[i]][1] += 1

print(right_ans, penalty)

Submission status: Runtime Error

Solution code:
import sys
def main():  
    s = sys.stdin.readlines()

    c = []
    a = 0
    b = 0
    N, M = map(int, s[0].split())
    for e in s[1:M + 1]:
    p, S = e.split()
    if p not in c:
        if S == 'AC':
            c.append(p)
            a += 1
        else:
            b += 1

    print('{} {}'.format(a, b)) 


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N, M = [int(num) for num in input().split()]
pro = {}
c_sum = 0
c = []
f_sum = 0
for i in xrange(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: Runtime Error

Solution code:
def main():
    import sys
    s = sys.stdin.readlines()

    c = []
    a = 0
    b = 0
    N, M = map(int, s[0].split())
    for e in s[1:M + 1]:
    p, S = e.split()
    if p not in c:
        if S == 'AC':
            c.append(p)
            a += 1
        else:
            b += 1

    print('{} {}'.format(a, b)) 


if __name__ == '__main__':
    main()

Submission status: Runtime Error

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 = []

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

for i, j in enumerate(S):
  if 'WA' in j:
    if P[i] not in P:
      penalty -= 1

print(correct, penalty)

Submission status: Runtime Error

Solution code:
n, m = [int(i) for i in input().split(" ")]
score_dict = {}
 
for i in range(m):
    p, s = input().split(" ")
    if p not in score_dict:
        score_dict[p] = []
    
    score_dict[p].append(s)
 
ac_count = 0
wa_count = 0
 
for i in score_dict.values():
    if "AC" in i:
        ac_count += 1
    
    wa_count += len(i[:i.index("AC")])
 
print("{0} {1}".format(ac_count, wa_count))

Submission status: Runtime Error

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

if m == 0:
  print(0,0)

else:  
  for j in range(m):
    if (taka[j][1] == 'AC') and (int(taka[j][0]) not in ac):
      ac.append(int(taka[j][0]))
    if (taka[j][1] == 'WA')
      wa[int(taka[j][0])-1] += 1
    
  for k in range(1,n+1):
    if k not in ac:
      wa[k-1] = 0
  
  print(len(ac),sum(wa))

Submission status: Runtime Error

Solution code:
import sys
import pandas as pd

st = sys.stdin.readlines()

n=int(st[0].split()[0])
m=int(st[0].split()[1])

if m != 0:
    ps = []
    ss = []
    for i in range(m):
        ps.append(int(st[i+1].split()[0]))
        if st[i+1].split()[1] == "WA":
            ss.append(0)
        else:
            ss.append(1)

    # print(ps)
    # print(ss)

    df = pd.DataFrame()
    df = df.append(ps)
    ss = pd.Series(ss)
    df = pd.concat([df, ss], axis=1)
    df.columns=[0,1]
    # print(df)

    wa = 0
    ac = 0
    for i in df[0].unique():
        watemp = 0
        # print(df[df[0]==i+1])
        for result in df[df[0]==i][1]:
            # print(result)
            if result == 0:
                watemp += 1
            else:
                ac += 1
                wa += watemp
                break

    print(str(ac) + " " + str(wa))

else:
    print("0 0")

Submission status: Runtime Error

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

answerd = [0] * 10010
WA_count = 0
AC_count = 0

for i in range(M):
    p, s = input().split()
    p = int(p)

    if s == 'WA' and answerd[p] == 0:
        WA_count += 1

    elif s == 'AC' and answerd[p] == 0:
        AC_count += 1
        answerd[p] = 1

print(AC_count, WA_count)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
a=0
b=0
if m==0:
    print(0,0)
    exit()
p = [[str(i) for i in input().split()] for _ in range(m)]

c = sorted(p,key=lambda x:x[0])

now = c[0][0]
d = 1
aa=0
bb=0
f = 0

for i in c:
    if i[0] == now:
        if i[1]=='AC':
            if d:
                a += 1
                f = 1
                d = 0
        else:
            if not f:
                bb+=1
    else:
        now = i[0]
        d = 1
        if f:
            b += bb
            f = 0
            bb = 0
        if i[1]=='AC':
            if d:
                a+=1
                f=1
                d = 0
        else:
            if not f:
                bb+=1
    else:
        now = i[0]
        d = 1
	if f:
            b += bb
            f = 0
            bb = 0
        if i[1]=='AC':
            if d:
                a+=1
                f=1
                d = 0
        else:
            if not f:
                bb+=1
b += bb
print(a,b)

Submission status: Runtime Error

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

for i in range(m):
    res = input()
    res_list = list(res.split())
    if res not in PS:
        PS[res] = 0
        PS[res] += 1
    elif res_list[1] == "WA" and PS[res_list[0]+ " AC"] >= 1:
        pass
    elif res_list[1] == "AC" and PS[res_list[0]+ " AC"] >= 1:
        pass
    else:
        PS[res] += 1


ans = 0
pn = 0
for k, v in PS.items():
    if k[-2:] == "AC":
        ans += 1
    elif k[-2:] == "WA":
        pn += 1

print(ans, pn)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
a=0
b=0
if m==0:
    print(0,0)
    exit()
p = [[str(i) for i in input().split()] for _ in range(m)]

c = sorted(p,key=lambda x:x[0])

now = c[0][0]
d = 1
aa=0
bb=0
f = 0
print(now)
for i in c:
    if i[0] == now:
        if i[1]=='AC':
            if d:
                a += 1
                f = 1
                d = 0
        else:
            if not f:
                bb+=1
    else:
        now = i[0]
        d = 1
        if f:
            b += bb
            f = 0
            bb = 0
        if i[1]=='AC':
            if d:
                a+=1
                f=1
                d = 0
        else:
            if not f:
                bb+=1
    else:
        now = i[0]
        d = 1
	if f:
            b += bb
            f = 0
            bb = 0
        if i[1]=='AC':
            if d:
                a+=1
                f=1
                d = 0
        else:
            if not f:
                bb+=1
b += bb
print(a,b)

Submission status: Runtime Error

Solution code:
import numpy as np

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

counter = {}

for i in range(m):
    res = list(input().split())
    p, s = (int(res[0]), res[1])
    if p in counter.keys():
        if s == 'AC':
            counter[p][0] = 1
        elif s == 'WA' and (not counter[p][0]):
            counter[p][1] += 1
    else:
        if s == 'AC':
            counter[p] = np.array([1, 0])
        else:
            counter[p] = np.array([0, 1])

if len(counter):
    print(*sum(filter(lambda v: v[0] >= 1, counter.values())))
else:
    print('0 0')

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
seikai = 0
matigai = 0
oklist = []
for i in range(m):
    if len(oklist) == n:
        break
    a,b=input().split()
    list.append((int(a), b))

    if b == "WA" and a not in oklist:
        matigai += 1
    elif b == "AC" and a not in oklist:
        seikai += 1
        oklist.append(a)
            
print(str(seikai)+" "+str(matigai))

Submission status: Runtime Error

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 ]
  tf = q.count("AC")
  if tf != 0:
    t = t + 1
  d = q.index("AC")
  f = f + d
print(t,f)

Submission status: Runtime Error

Solution code:
buf=input().split(" ")
 
N=int(buf[0])
M=int(buf[1])
clear=[0]*N
ac=0
wa=0
 
for i in range(M):
  buf=input().split(" ")
  if clear.count(int(buf[0])) == 0:
    if buf[1] == "AC":
      clear[i]=int(buf[0])
      ac=ac+1
    elif buf[1] == "WA":
      wa=wa+1
print(str(ac)+" "+str(wa))

Submission status: Runtime Error

Solution code:
from operator import mul
from functools import reduce
def cmb(n,r):
    r=min(n-r,r)
    if r==0: return 1
    over=reduce(mul, range(n,n-r,-1))
    under=reduce(mul, range(1,r+1))
    return over//under
n,k=map(int,input().split())
A=sorted(list(map(int,input().split())))
s=0
c=int(cmb(n-1,k-1))
for i in range(n-k+1):
  s+=(A[n-1-i]-A[i])*c
  s%=10**9+7
  c=c*(n-k-i)//(n-1-i)
print(s)

Submission status: Runtime Error

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 = []
relate = []

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

for i, j in enumerate(S):
  if 'WA' in j:
    if P[i] not in relate:
      peanlty -= 1

print(correct, penalty)

Submission status: Runtime Error

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 S == 'WA':
        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: Runtime Error

Solution code:
import sys
from functools import reduce

n, m = map(int, input().split())
ps = [r.split() for r in sys.stdin.read().split('\n') if r != '']
ps.sort(key=lambda t: int(t[0]))
ac = {}
wa = {}
for j in range(0, m):
    i = int(ps[j][0])
    if i in ac:
        continue
    if ps[j][1] == 'AC':
        ac[i] = 1
        continue
    if i not in wa:
        wa[i] = 1
    else:
        wa[i] += 1
wacount = reduce(lambda a, b: a + b, map(lambda t: t[1], filter(lambda t: t[0] in ac, wa.items()))) if len(wa) > 0 else 0
print(len(ac), wacount)