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:
N, M = map(int, input().strip().split(" "))


p = []
s = []
ans = [0]*N
c_wa = 0

for i in range(M):
    temp1, temp2 = input().strip(" ").split(" ")
    p.append(int(temp1))
    s.append(str(temp2))
  

for j in range(M):
    
    if s[j] == "WA":
        print("WA", j, s[p[j]-1])
        if ans[p[j]-1] == 0:
            c_wa += 1
            
    elif s[j] == "AC":
        if ans[p[j]-1] == 1:
            continue
        elif ans[p[j]-1] == 0:
            ans[p[j]-1] += 1
            
print(sum(ans), c_wa)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
ACL=[0]*N
PL=[0]*N
AC=0
P=0
for i in range(M):
  p,S=input().split()
  p=int(p)
  if S =='AC':
    if ACL[p]==0:
      AC+=1
      P+=PL[p]
      ACL[p]=1
    else:
      PL[p]+=1
print(AC,P)

Submission status: Runtime Error

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

p_judge = {}
p_lsit = []
ac = 0
wa = 0
for i in range(m):
    p_name, result = input().split()

    if (len(p_lsit) == n):
        if p_judge[p_name] == True:
            continue

    if p_name in p_lsit:
        if p_judge[p_name] == False and result == "AC":
            p_judge[p_name] = True
            ac += 1

        else:
            wa += 1
    else:
        p_judge = {}
        if result == "WA":
            wa += 1
            p_judge[p_name] = False
        else:
            ac += 1
            p_judge[p_name] = True

        p_lsit.append(p_name)

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

Submission status: Runtime Error

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

p_judge = {}
p_lsit = []
already_flag = True
ac = 0
wa = 0
for i in range(m):
    p_name, result = input().split()

    if p_name in p_lsit:
        if p_judge[p_name] == False and result == "AC":
            p_judge[p_name] = True
            ac += 1
        else:
            wa += 1
    else:
        p_judge = {}
        if result == "WA":
            wa += 1
            p_judge[p_name] = False
        else:
            ac += 1
            p_judge[p_name] = True
        
        p_lsit.append(p_name)

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

Submission status: Runtime Error

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

ac = 0
wa = 0
prob = 0

for i in range(m):
    if p[i][0] != prob:
        if p[i][1] == "WA":
            wa += 1
        elif p[i][1] == "AC":
            ac += 1
            prob = p[i][0]
            
print(ac, wa

Submission status: Runtime Error

Solution code:

 
penaltyCount = dict()
penaltyCount = defaultdict(lambda: 0, penaltyCount)
 
correct = 0
penalty = 0
 
for i in range(m):
    submission = input.split()
    p = int(submission[0]) - 1
    status = submission[1]

Submission status: Runtime Error

Solution code:
from collections import defaultdict

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

penaltyCount = dict()
penaltyCount = defaultdict(lambda: 0, penaltyCount)

correct = 0
penalty = 0

for i in range(m):
    submission = input.split()
    p = int(submission[0]) - 1
    status = submission[1]

    if penaltyCount[p] == -1:
        continue
    if status == "WA":
        penaltyCount[p] += 1
    else:
        penalty += penaltyCount[p]
        penaltyCount[p] = -1
        correct += 1

print(str(correct) + " " + str(penalty))

Submission status: Runtime Error

Solution code:
params = input().split(' ')
m = eval(params[0])
n = eval(params[1])

penaltyCount = []

for i in range(m):
    penaltyCount.append(0)

penalties = 0
points = 0

for i in range(n):
    submission = input().split(' ')
    p = eval(submission[0])
    status = submission[1]
    
    if penaltyCount[p] == -1:
        continue

    if status == 'AC':
        penalties += penaltyCount[p]
        penaltyCount[p] = -1
        points += 1
    else:
        penaltyCount[p] += 1


print(points, penalties)

Submission status: Runtime Error

Solution code:
params = input().split(' ')
m = eval(params[0])
n = eval(params[1])

penaltyCount = []

for i in range(m):
    penaltyCount[i] = 0

penalties = 0
points = 0

for i in range(n):
    submission = input().split(' ')
    p = eval(submission[0])
    status = submission[1]
    
    if penaltyCount[p] == -1:
        continue

    if status == 'AC':
        penaltyCount += penaltyCount[p]
        penaltyCount[p] = -1
        points += 1
    else:
        penaltyCount[p] += 1


print(points, penalties)

Submission status: Runtime Error

Solution code:
params = input().split(' ')
n = eval(params[1])

penaltyCount = [0] * eval(params[0])

penalties = 0
points = 0

for i in range(n):
    submission = input().split(' ')
    p = eval(submission[0])
    status = submission[1]
    
    if penaltyCount[p] == -1:
        continue

    if status == 'AC':
        penaltyCount += penaltyCount[p]
        penaltyCount[p] = -1
        points += 1
    else:
        penaltyCount[p] += 1


print(points, penalties)

Submission status: Runtime Error

Solution code:
params = input().split(' ')
n = eval(params[1])

AC = set()
WA = {}

penalties = 0
points = 0

for i in range(n):
    submission = input().split(' ')
    p = eval(submission[0])
    status = submission[1]
    
    if p in AC:
        continue
    
    if status == 'AC':
        AC.add(p)
        points += 1
        penalties += getPenalties(p)
    
    elif p in WA:
        WA[p] += 1

    else:
        WA[p] = 1

print(points, penalties)


def getPenalties(x):
    if x in WA:
        return WA[x]
    return 0

Submission status: Runtime Error

Solution code:
params = input().split(' ')
n = eval(params[1])

AC = set()
WA = {}

penalties = 0
points = 0

for i in range(n):
    submission = input().split(' ')
    p = eval(submission[0])
    status = submission[1]
    
    if p in AC:
        continue
    
    if status == 'AC':
        AC.add(p)
        points += 1
        penalties += getPenalties(p)
    
    elif p in WA:
        WA[p] += 1

    else:
        WA[p] = 1
    


def getPenalties(x):
    if x in WA:
        return WA[x]
    return 0

Submission status: Runtime Error

Solution code:
params = input().split(' ')
n = params[1]

acfoundfor = []

penalties = 0
points = 0

for i in range(n):
    submission = input().split(' ')
    p = eval(submission[0])
    status = submission[1]
    
    if p in acfoundfor:
        continue

    if status == 'AC':
        points += 1
        acfoundfor.append(p)
    else:
        penalties += 1

Submission status: Runtime Error

Solution code:
N, M = map(int,input().split())
AC_Set = set()
WA_Dict = {}
WA_SUM = 0
for i in range(M):
    num,result = list(input().split())
    if num in AC_Set:
        continue
    else:
        if result == "AC":
            AC_Set.add(num)
            WA_SUM += WA_Dict.get(num)
        else:
            WA_Dict[num] = WA_Dict.get(num,0) + 1

print("{} {}".format(len(AC_Set),WA_SUM))

Submission status: Runtime Error

Solution code:
import itertools
# import math

MOD = 10 ** 9 + 7


def solve(N, K, A):
    A.sort()
    ans = 0

    for group in list(itertools.combinations(A, K - 1)):
        ans += max(group) - min(group)

    return ans % MOD


# N = int(input())
# S = input()
N, K = map(int, input().split())
A = list(map(int, input().split()))

print(solve(N, K, A))

Submission status: Runtime Error

Solution code:
n,m = list(map(int,input().split()))
counter = 0
data = []
checkd = []
tmp = {}

wa = 0
#入力処理
for i in range(m):
  a,b = input().split()
  if b == "WA":
    if int(a) not in tmp:
      tmp[int(a)] = 0
    tmp[int(a)] += 1  
  elif (( b == "AC") and (tmp[int(a)] != -1)):
    counter += 1
    #checkd.append(int(a))
    if int(a) not in tmp:
      tmp[int(a)] = 0  
    wa += tmp[int(a)]
    tmp[int(a)] = -1


"""
for i in range(m):
  if data[i][1] == "WA":
    if int(data[i][0]) not in tmp:
      tmp[int(data[i][0])] = 0
    tmp[int(data[i][0])] += 1  
  elif ((data[i][1]) == "AC") and (int(data[i][0]) not in checkd):
    counter += 1
    checkd.append(int(data[i][0]))
    if int(data[i][0] ) not in tmp:
      tmp[int(data[i][0])] = 0  
    wa += tmp[int(data[i][0])]
"""    
print(counter,wa)

Submission status: Runtime Error

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

ans1 = 0
ans2 = 0

aclis = [0] * n
walis = [0] * n
ac = 1s


for i in range(m):
    if s[i] == 'AC':
        aclis[p[i]] = True
        

    if aclis[p[i]] == 0:
        walis[p[i]] += 1
ans1 = aclis.count('True')

for i in range(n):
    if aclis[i] == True:
        ans2 += walis[i]

print(ans1, ans2)

Submission status: Runtime Error

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

ans1 = 0
ans2 = 0

aclis = [0] * n
walis = [0] * n



for i in range(m):
    if s[i] == 'AC':
        aclis[p[i]] = True
        ac += 1

    if aclis[p[i]] == 0:
        walis[p[i]] += 1
ans1 = aclis.count('True')

for i in range(n):
    if aclis[i] == True:
        ans2 += walis[i]

print(ans1, ans2)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
if m == 0:
    print(0, 0)
else:
    p = [0] * m
    s = [0] * m
    for i in range(m):
        p[i], s[i] = map(str, input().split())
    for i in range(m):
        p[i] = int(p[i])
    p.append(int(ie9))

    probcnt = p[0]
    ACval = False
    ACcnt = 0
    wa = 0
    pena = 0
    for i in range(m):
        if probcnt == p[i]:
            if ACval == False:
                if s[i] == 'WA':
                    wa += 1
                    if p[i] !=p[i+1]:
                        wa = 0
                else:
                    ACval = True
                    ACcnt += 1
                    pena += wa
                    wa = 0

        else:
            ACval = False
            probcnt = p[i]
            if ACval == False:
                if s[i] == 'WA':
                    wa += 1
                    if p[i] !=p[i+1]:
                        wa = 0
                else:
                    ACval = True
                    ACcnt += 1
                    pena += wa


    print(ACcnt, pena)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
if m == 0:
    print(0, 0)
else:
    p = [0] * m
    s = [0] * m
    for i in range(m):
        p[i], s[i] = map(str, input().split())
    for i in range(m):
        p[i] = int(p[i])

    probcnt = p[0]
    ACval = False
    ACcnt = 0
    wa = 0
    pena = 0
    for i in range(m):
        if probcnt == p[i]:
            if ACval == False:
                if s[i] == 'WA':
                    wa += 1
                else:
                    ACval = True
                    ACcnt += 1
                    pena += wa
        wa = 0
        else:
            ACval = False
            probcnt = p[i]
            if ACval == False:
                if s[i] == 'WA':
                    wa += 1
                else:
                    ACval = True
                    ACcnt += 1
                    pena += wa
        wa = 0

    print(ACcnt, pena)

Submission status: Runtime Error

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

probcnt = p[0]
ACval = False
ACcnt = 0
wa = 0
for i in range(m):
    if probcnt == p[i]:
        if ACval == False:
            if s[i] == 'WA':
                wa += 1
            else:
                ACval = True
                ACcnt += 1
    else:
        ACval = False
        probcnt = p[i]
        if ACval == False:
            if s[i] == 'WA':
                wa += 1
            else:
                ACval = True
                ACcnt += 1

print(ACcnt, wa)

Submission status: Runtime Error

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

probcnt = 1
ACval = False
ACcnt
wa = 0
for i in range(m):
    if probcnt == p[i]:
        if ACval == False:
            if s[i] == 'WA':
                wa += 1
            else:
                ACval = True
                ACcnt += 1
    else:
        ACval = False
        probcnt += 1
        if ACval == False:
            if s[i] == 'WA':
                wa += 1
            else:
                ACval = True
                ACcnt += 1

print(ACcnt, wa)

Submission status: Runtime Error

Solution code:
n,m = map(int, input().split())
p=[0]*(10**5+2)
s=[0]*m
for i in range(m):
	p[i],s[i]=map(str, input().split()) 
l=[0]*(m+1)
wal=[]
accnt=0
wacnt=0

for i in range(m):
	if l[int(p[i])]==0 and s[i]=='AC':
		l[int(p[i])]=1
		wal.append(wacnt)
		wacnt=0
	elif l[int(p[i])]==1 and s[i]=='AC':
		continue
	elif l[int(p[i])]==0 and s[i]=='WA':
		wacnt+=1
print(sum(l),sum(wal))

Submission status: Runtime Error

Solution code:
n,m = map(int, input().split())
p=[0]*m
s=[0]*m
for i in range(m):
	p[i],s[i]=map(str, input().split()) 
l=[0]*(m+1)
wal=[]
accnt=0
wacnt=0

for i in range(m):
	if l[int(p[i])]==0 and s[i]=='AC':
		l[int(p[i])]=1
		wal.append(wacnt)
		wacnt=0
	elif l[int(p[i])]==1 and s[i]=='AC':
		continue
	elif l[int(p[i])]==0 and s[i]=='WA':
		wacnt+=1
print(sum(l),sum(wal))

Submission status: Runtime Error

Solution code:
n,m = list(map(int,input().split()))
counter = 0
data = []
#入力処理
for i in range(n):
  data.append(input().split())
num = [int(s) for s in range(1,n+1)]
checkd = []
tmp = 0
wa = 0
for i in range(n):
  if data[i][1] == "WA":
    tmp += 1
  elif data[i][1] == "AC" and data[i][0] not in checkd:
    counter += 1
    checkd.append(data[i][0])
    wa += tmp
    tmp = 0
print(counter,wa)

Submission status: Runtime Error

Solution code:
from collections import defaultdict

lines = []
while True:
    line = input()
    if line:
        lines.append(line)
    else:
        break

correct = 0
penalty = 0
d = dict()
d = defaultdict(lambda: 0, d)

for line in lines[1:]:
    n = line.split()[0]
    m = line.split()[1]

    if d[n] == -1:
        continue
    if m == "WA":
        d[n] += 1
    else:
        penalty += d[n]
        d[n] = -1
        correct += 1

print(str(correct) + " " + str(penalty))

Submission status: Runtime Error

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

jdg_wa = [0] * n 
jdg_ac = [0] * n

for _ in lst:
    idx = _[0] - 1
    if _[1] == 'WA' and jdg_ac[idx] != 1:
        jdg_wa[idx] += 1
    elif _[1] == 'AC':
        jdg_ac[idx] = 1
        penalty += jdg_wa[idx]
        
print(sum(jdg_ac),penalty)

Submission status: Runtime Error

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

jdg_wa = [0] * n 
jdg_ac = [0] * n

for _ in lst:
    if _[1] == 'WA' and jdg_ac[_[0]] == 0:
        jdg_wa[_[0]] += 1
    if _[1] == 'AC' and jdg_ac[_[0]] == 0:
        jdg_ac[_[0]] = 1

print(sum(jdg_ac),sum(jdg_wa))

Submission status: Runtime Error

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

wa_count, ac_count = 0, 0
WA_List = {}  # {prob_id: wa_count}
AC_list = []  # [prob_id]

for i in range(M):
    id = A_list[i][0]
    if A_list[i][1] == 'AC':
        if not id in AC_list:
            if id in WA_List:
                wa_count += WA_List[id]
            ac_count += 1
            AC_list += f"{id}"
    else:
        if id in WA_List:
            WA_List[id] += 1
        else:
            WA_List[id] = 1

print(ac_count, wa_count)

Submission status: Runtime Error

Solution code:
n , m = map(int,input().split())
a,w = 0,0
As = []
for _ in range(n):
  t, k = input().split()
  t = int(t)
  if t in As:
    continue
  if k == "AC":
    As.appent(t)
    a += 1
  if k == "WA":
    w += 1
print(a,w)

Submission status: Runtime Error

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

wa_count, ac_count = 0, 0
WA_List = {}  # {prob_id: wa_count}
AC_list = []  # [prob_id]

for i in range(M):
    if A_list[i][1] == 'AC':
        if not A_list[i][0] in AC_list:
            if A_list[i][0] in WA_List:
                wa_count += WA_List[A_list[i][0]]
            ac_count += 1
            AC_list.append(A_list[i][0])
    else:
        # if A_list[i][0] in WA_List:
        WA_List[A_list[i][0]] += 1
    # else:
    #     WA_List[A_list[i][0]] = 1

print(ac_count, wa_count)

Submission status: Runtime Error

Solution code:
from sys import stdin

input_ = stdin.readline.rstrip().split()

N, M = map(int, input_)
A_list = [input_ for _ in range(M)]

wa_count, ac_count = 0, 0
WA_List = {}
AC_list = []

for i in range(M):
    if A_list[i][1] == 'AC':
        if not A_list[i][0] in AC_list:
            if A_list[i][0] in WA_List:
                wa_count += WA_List[A_list[i][0]]
            ac_count += 1
            AC_list.append(A_list[i][0])
    else:
        if A_list[i][0] in WA_List:
            WA_List[A_list[i][0]] += 1
        else:
            WA_List[A_list[i][0]] = 1

print(ac_count, wa_count)

Submission status: Runtime Error

Solution code:
number,submit=input().rstrip().split()
result=[input().rstrip().split() for i in range(int(submit))]
#print(result)
good=[]
bad=[]
stocK=[]
for i in range(int(submit)):
    if result[i][1]=='WA':       
        bad.append(result[i][0])
    elif result[i][1]=='AC' and result[i][0] not in good:
        good.append(result[i][0])
        stocK.append(bad.count(result[i][0]))
        bad.clear(result[i][0])


print(str(len(good))+' '+str(sum(stocK)))

Submission status: Runtime Error

Solution code:
number,submit=input().rstrip().split()
result=[input().rstrip().split() for i in range(int(submit))]
#print(result)
good=[]
bad=[]
stocK=[]
for i in range(int(submit)):
    if result[i][1]=='WA':       
        bad.append(result[i][0])
    elif result[i][1]=='AC' and result[i][0] not in good:
        good.append(result[i][0])
        stocK.append(len(bad)
        bad.clear


print(str(len(good))+' '+str(sum(stocK)))

Submission status: Runtime Error

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

temp_wa_count, wa_count, ac_count, prob_id = 0, 0, 0, 0
WA_List = {} # {prob_id: wa_count}
AC_list = [] # [prob_id]

for i in range(M):
    if A_list[i][1] == 'AC':
        if not 'AC' in AC_list:
            wa_count += WA_List[A_list[i][0]]
            ac_count += 1
            AC_list += A_list[i][0]
    else:
        if A_list[i][0] in WA_List:
            WA_List[A_list[i][0]] += 1
        else:
            WA_List = {A_list[i][0]: 1}

print(ac_count, wa_count)

Submission status: Runtime Error

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

Qa,Qw = [0 for _ in range(N)], [0 for _ in range(N)]
for _ in range(M):
    p, S = input().split()
    p = int(p)-1

    if S == 'AC':
        Qa[p] = 1
    elif S == 'WA':
        if Qa[p] <= 0:
            Qw[p] += 1

AC = sum([ac for ac in Qa])
WA = sum([Qw[i] for i in Qa if Qa[i] > 0])
print( AC, WA)

Submission status: Runtime Error

Solution code:
N, M=map(int,input().split())
if M==0:
	print("0 0")
else:
	ac=0
	pe=0
	ch=[0]*N
    Ch=[0]*N
	for i in range(M):
		a, b=input().split()
		a=int(a)-1
		if ch[a]==1:
			continue
		elif b=="WA":
			Ch[a]+=1
		else:
			ch[a]=1
			ac+=1
			pe+=Ch[a]
	print(ac,pe)

Submission status: Runtime Error

Solution code:
N, M=map(int,input().split())
if M==0:
	print("0 0")
else:
	ac=0
	pe=0
	ch=[]
	for i in range(M):
		a, b=input().split()
        a=int(a)
		if a in ch:
			continue
		elif b=="AC":
			ch.append(a)
			ac+=1
		else:
			pe+=1
	print(ac,pe)

Submission status: Runtime Error

Solution code:
n, m = [int(x) for x in input().split()]
lst = [None]*(n+1)
a = 0
b = 0
for i in range(m):
  p, s = input().split()
  if s == 'AC' and lst[p] is None:
    a += 1
    lst[p] = True
  elif s == 'WA' and lst[p] is None:
    b += 1
print(a,b)

Submission status: Runtime Error

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

solved = [0]* 10*5
penalty_sum = 0
penalty = 0

for _ in range(m):
    q, result = input().split()
    q = int(q)
    
    if result == 'AC':
        if solved[q] == 0:
            penalty_sum += penalty
            penalty = 0
    else:
        if solved[q] == 0:
            penalty += 1

print(str(len(ac)) + " " + str(penalty_sum))

Submission status: Runtime Error

Solution code:
def strr():
 a=raw_input()
 return a
def sstrr():
 a=raw_input().split()
 return a
def intt():
 a=int(raw_input())
 return a
def iintt():
 a=[int(s) for s in raw_input().split()]
 return a
def nestt(t):
 a=[raw_input().split() for s in range(t)] 
 return a

n,m=iintt()
ps=nestt(m)
a_={}
aa=0
ab=0
for p,s in ps:
 int(p)
 if p in a_:
  if a_[p]=="WA":
   ab+=1
   a_[p]=s
 else:
  a_[p]=s
if ps[-1][-1]=="WA":
 ab+=1
for o in a_.keys():
 if a_[o]=="AC":
  aa+=1
print(str(aa)+" "+str(ab))

Submission status: Runtime Error

Solution code:
n,m =map(int, input().split())
a =[list(input().split()) for i in range(m)]
ends = [0]*n
was = [0]*n
for num, kekka in a:
    num=int(num)-1
    if kekka=='AC':
        ends[num]=1
    else:
        if ends[num]!=1:
            was[num]+=1
for i in range(n):
    if end[i]==0:
        was[i]=0
print(sum(ends), sum(was))

Submission status: Runtime Error

Solution code:
n, m = list(map(int, input().split()))
ac = set()
wa = 0
for i in range(m):
  p, s = input.split()
  p = int(p)
  if p in ac:
    continue
  if s == 'WA':
    wa += 1
  else:
    ac.add(p)
print("%d %d" % (len(ac), wa))

Submission status: Runtime Error

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 = [0] * n
wa_list = [0] * n

counta = 0
countb = 0
for i in range(1, m * 2, 2):
    if P[i] == "AC" and ac_list[int(P[i - 1])] == 0:
        counta += 1
        ac_list[int(P[i - 1])] = 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: Runtime Error

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

flags = [False]*N
kari = [0]*N
good = 0
bad = 0

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

    if flags[int(p)]:
        continue
    if S == 'AC':
        good+=1
        flags[int(p)] = True
    elif S == 'WA':
        bad+=1

print(str(good) + ' ' + str(bad))

Submission status: Runtime Error

Solution code:
n = [int(e) for e in input().split(" ")]
h = [False for i in range(n[0])]
ac = 0
wa = 0
for _ in range(n[1]):
    raw = input().split(" ")
    line = [int(raw[0]) - 1, raw[1] == "AC"]
    if(not h[line[0]]):
        if(not line[1]):
            wa += 1
        else:
            h[line[0]] = True
            ac += 1

print(f"{ac} {wa}")

Submission status: Runtime Error

Solution code:
n,m =map(int,input().split())
Wa=0
Ac=0
i=0
while(i<m):
 while(s[i]="WA"):
  i++
  Wa++
 Ac++
 i++
print(Ac,Wa)

Submission status: Runtime Error

Solution code:
times = [int(idx) for idx in  input().split()]
datas = [input().split() for idx in range(times[1])]

pen = 0
ans = 0
num = 0
get_ = False
tmp = ""

for i in datas:
  if tmp != i[0]:
      get_ = False
  tmp = i[0]
  num = int(i[0])
  if i[1] == "WA":
        name = i[0]+ " AC"
   		if name not in datas:
          datas.remove(i)
        if get_ == False:
            pen += 1

  elif i[1] == "AC":
    if get_ == False:
        ans += 1
    get_=True
print(str(ans) + " " + str(pen))

Submission status: Runtime Error

Solution code:
times = [int(idx) for idx in  input().split()]
datas = [idx for idx in input()]
times = [int(idx) for idx in  input().split()]
datas = [input().split() for idx in range(times[1])]

pen = 0
ans = 0
num = 0
get_ = False
tmp = ""

for i in datas:
  if tmp != i[0]:
      get_ = False
  print(i[0])
  print(tmp)
  tmp = i[0]
  print("aaa" + tmp)
  num = int(i[0])
  if i[1] == "WA":
        if get_ == False:
            pen += 1
  elif i[1] == "AC":
    print(datas)
    if get_ == False:
        ans += 1
    get_=True
print(str(ans) + " " + str(pen))

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
cnt=0
acc=0
ac={}
for i in range(m):
	p,s= map(str,input().split())
	if ac[p]==0:
		if s=='AC':
			acc+=1
			ac[p]=1
		else:
			cnt+=1
print(acc,cnt)

Submission status: Runtime Error

Solution code:
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
    
    
N,M=map(int,input().split())
a=0
b=0
AC=[0]*(M+1)
pen=0
l=[]
for i in range(M):
	j,r=input().split()
	if AC[int(j)]==0:
		if r=="WA":
			pen+=1
		else:
			AC[int(j)]+=1
print(sum(AC),pen)

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split())
l=list(range(a))
ac=0
wa=0
for _ in range(b):
  i,x=input().split()
  j=int(i)
  if l[j] != "AC":
    if x == "WA":
      wa += 1
    elif x == "AC":
      l.insert(j,x)
      ac += 1
print(ac,wa)

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split())
l=[]
ac=0
wa=0
for _ in range(b):
  i,x=input().split()
  j=int(i)
  if l[j] != "AC":
    if x == "WA":
      wa += 1
    elif x == "AC":
      l.insert(j,x)
      ac += 1
print(ac,wa)

Submission status: Runtime Error

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

lst_ac = [0 for i in range(n+1)]
for i in range(n):
    if s[i] == 'AC':
        lst_ac[p[i]] = 1
ans_ac = sum(lst_ac)

out = 0
for i in range(n):
    if s[i] == 'WA' and lst_ac[p[i]] == 1:
        out += 1

print(ans_ac, out)

Submission status: Runtime Error

Solution code:
#Nが問題数Mが提出数
N, M = map(int, input().split())

submit = []
for _ in range(M):
  temp = [x for x in input().split()]
  submit.append(temp)

ac = [0]*(N + 1)
wa = [0]*(N + 1)
  
for i in range(M):
  result = submit[i][1]
  question = int(submit[i][0])
  
  if result == 'AC' and ac[question] == 0:
    ac[question] = 1
  elif result == 'WA' and ac[question] == 0:
    wa[question] += 1

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

print(sum(ac), sum(wa))

Submission status: Runtime Error

Solution code:
n,m = list(map(int,input().split()))
ac = 0
wa = 0
y = [0] * n
z = [0] * n

for _ in range(m):
  p,s = input().split()
  p = int(p)
  if not y[p] and s == 'WA':
    z[p] += 1
  elif not y[p] and s == 'AC':
    ac += 1
    y[p] += 1

for i in range(m):
  if y[i]:
    wa += z[i]

print(ac,wa)

Submission status: Runtime Error

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

cor = 0
penalty = 0
dic = {}
for i in range(M):
  p, S = input().split()
  p = int(p)
  if p not in dic:
    dic[p] = "_"
  if (S == "AC") & (dic[p] != "AC"):
    dic[p] = "AC"
    cor = cor+1
    continue
  elif (S == "WA") & (dic[p] != "AC"):
    penalty = penalty + 1
    
print("{} {}"penalty)

Submission status: Runtime Error

Solution code:
#include <stdio.h>

int main(void){
	int i,m,m,a,ok=0,pena=0,cnt[100010]={};
	char s[3];
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++){
		scanf("%d %s"&a,s);
		if(ac[a]<0){
          continue;
        }
		if(s[0]=='W'){
          cnt[a]++;
        }else{
			pena = pena + cnt[a];
			cnt[a] = -1;
			ok++;
		}
	}
	printf("%d %d",ok,pena);
	return 0;
	
}

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
h,w = map(int,input().split())
n = h*w

field = []
for i in range(h):
    field.append(input())

dist = [[INF] * n for _ in range(n)]

for i in range(h):
    for j in range(w):
        if field[i][j] == "#":continue
        if j + 1 < w and field[i][j+1] != "#":
            dist[i * w + j][i * w + j + 1] = 1
            dist[i * w + j + 1][i * w + j] = 1
        if i + 1 < h and field[i+1][j] != "#":
            dist[i * w + j][(i+1) * w + j] = 1
            dist[(i+1) * w + j][i * w + j] = 1

for i in range(n):
    for j in range(n):
        for k in range(n):
            dist[j][k] = min(dist[j][k],dist[j][i],dist[i][k])

ans = 0
for i in range(n):
    for j in range(n):
        if(i==j):continue
        if(dist[i][j]==INF):continue
        ans = max(ans,dist[i][j])

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:

N , M = [int(n) for n in input().split(' ')]

list_AC =[]
list_WAcount = [0] * N
sumWA = 0

for i in range(M):
    p , S = input().split(' ')
    
    if (p in list_AC):
        # 既にAC済みの場合は何もしない
        continue 
    else:
        # 最初に正解したときにそれまでのWA回数を加算
        if S == 'AC':
            list_AC.append(p)
            sumWA += list_WAcount[p-1]
        else:
            list_WAcount[p-1] += 1

print("{} {}".format(len(list_AC),sumWA))

Submission status: Runtime Error

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

list_AC = []
count_WA = {}

for i in range(M):
    p , S = input.split(' ')
    
    if (p in list_AC):
        # 既にAC済みの場合は何もしない
        continue 
    else:
        if S == 'AC':
            list_AC.append(p)
        else:
            if p in count_WA:
                count_WA[p] += 1
            else:
                count_WA[p] = 1
        
for i in list_AC:
    if i in count_WA:
        print(count_WA[i])
    else:
        print(0)