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 java.lang.reflect.Array;
import java.util.*;
import java.util.Map.*;
import java.io.*;
import java.util.StringTokenizer;
import java.util.stream.Collectors;
import java.util.AbstractMap.SimpleEntry;
import java.util.Comparator;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);

        int N = sc.nextInt();
        int M = sc.nextInt();
        Boolean[] ACs = new Boolean[N];
        Arrays.fill(ACs, Boolean.FALSE);

        Map<Integer, Integer> WAs = new HashMap<>();
        for(int i = 0; i < N; i++)
            WAs.put(i, 0);

        for(int i = 0; i < M; i++){
            Integer p = sc.nextInt() - 1;
            String s_tmp = sc.next();
            if(s_tmp.equals("AC") && !ACs[p]){
                ACs[p] = true;
            }
            else if(!ACs[p]){
                if(WAs.containsKey(p))
                    WAs.put(p, WAs.get(p) + 1);
            }
        }

        Integer AcN = 0;
        Integer WaN = 0;

        for(int i = 0; i < N; i++){
            if(ACs[i]){
                AcN++;
                WaN += WAs.get(i);
            }
        }

        System.out.println(AcN.toString() + " " + WaN.toString());
    }

    public static boolean isPrime(long num){
        for(int i = 2; i < num;i++){
            if(num % i == 0)
                return false;
        }
        return true;
    }


    public static long factorial(Long n){
        if(n == 1)
            return 1;
        return n * factorial(n - 1);
    }

    public static <T> HashMap<T,Integer> count_item(T[] target){
        HashMap<T,Integer> hs = new HashMap<>();
        for(T t: target){
            if(hs.containsKey(t))
                hs.put(t,hs.get(t) + 1);
            else
                hs.put(t,1);
        }
        return hs;
    }

    public static class Iterations{

        // nCr を求める
        // 第1引数: 列挙対象の配列 n
        // 第2引数: r
        // 第3引数: 答えの組み合わせ配列を保持するための set
        public static <T> HashSet<ArrayList<T>> combination(ArrayList<T> n, Integer r) {
            HashSet<ArrayList<T>> ans = new HashSet<>();
            Iterations.comb(n,r,ans);
            return ans;
        }


        public static <T> void comb(ArrayList<T> n, Integer r, HashSet<ArrayList<T>> ans) {
            if (n.size() == r) {
                ans.add(n);
                return;
            }

            for (int i = 0; i < n.size(); i++) {
                ArrayList<T> N = new ArrayList<>(n);
                N.remove(i);
                comb(N, r, ans);
            }
        }


        // nPr を求める
        // 第1引数: 列挙対象の配列 n
        // 第2引数: r
        // 第3引数: 答えの組み合わせ配列を保持するための set
        public static <T> List<List<T>> permutation(T[] n,int r) {
            List<T> n_list = Arrays.asList(n);
            HashSet<ArrayList<T>> hs = combination(new ArrayList<>(n_list),r);

            List<List<T>> result = new ArrayList<>();
            for(ArrayList<T> tmp: hs){
                helper(0, tmp, result);
            }
            return result;
        }

        private static <T> void helper(int start, List<T> nums, List<List<T>> result) {
            if (start == nums.size() - 1) {
                ArrayList<T> list = new ArrayList<>();
                for (T num : nums) {
                    list.add(num);
                }
                result.add(list);
                return;
            }

            for (int i = start; i < nums.size(); i++) {
                swap(nums, i, start);
                helper(start + 1, nums, result);
                swap(nums, i, start);
            }
        }

        private static <T> void swap(List<T> nums, int i, int j) {
            T temp = nums.get(i);
            nums.set(i,nums.get(j));
            nums.set(j,temp);
        }
    }


    public static List<Entry<Integer,Integer>> SortMapByValue(HashMap<Integer,Integer> maps,boolean is_reverse){
        List<Entry<Integer,Integer>> entries = new ArrayList<>(maps.entrySet());

        Collections.sort(entries, new Comparator<Entry<Integer, Integer>>() {
            @Override
            public int compare(Entry<Integer, Integer> o1, Entry<Integer, Integer> o2) {
                return (is_reverse ? -1 : 1) * o1.getValue().compareTo(o2.getValue());
            }
        });

        return entries;
    }

    public static long max(int[] ar,int size){
        long max = 0;
        for(int i = 0; i< size;i++)
            if(max < ar[i])
                max = ar[i];
        return max;
    }

    public static <T extends Comparable<T>> T max(T left, T right){
        return left.compareTo(right) < 0 ? right : left;
    }

    public static <T extends Comparable<T>> T min(T left, T right){
        return left.compareTo(right) > 0 ? right : left;
    }

    public static long max(List<Long> ar){
        long max = 0;
        for(int i = 0; i< ar.size();i++)
            if(max < ar.get(i))
                max = ar.get(i);
        return max;
    }

    public static Integer min(List<Integer> ar){
        int min = 10000;
        int index = 0;
        for(int i = 0; i< ar.size();i++){
            if(min > ar.get(i)){
                min = ar.get(i);
                index = i;
            }
        }
        return min;
    }

    // 最大公約数を求める
    public static <T extends Number> Long gcd(T left, T right) {
        Long m = left.longValue();
        Long n = right.longValue();
        if(m == 0)
            return n;
        if(n == 0)
            return m;
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }

    // 最小公倍数を求める
    public static <T extends Number> Long lcm(T left, T right){
        return left.longValue() * right.longValue() / gcd(left,right);
    }

    // A 以上、B 以下のCの倍数の個数を考える (A <= B)
    public static <T extends Number> Long get_multiple_count(T A, T B,T C){
        Long b_multi = B.longValue() / C.longValue();
        Long a_multi = (A.longValue() - 1) / C.longValue();
        return b_multi - a_multi;
    }



    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public String[] nextArray(int n) {
            String[] a = new String[n];
            for (int i = 0; i < n; i++)
                a[i] = next();
            return a;
        }


        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }

    public static class SizeComparator implements Comparator<HashSet>{
        @Override
        public int compare(HashSet l1, HashSet l2){
            return l1.size() > l2.size() ? -1 : 1;
        }
    }

}

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
Counted = [0 for _ in range(N)]
num1 = 0
num2 = 0
subnum2 = [0 for l in range(N)]
for j in range(M):
  p, S = input().split()
  p_ = int(p)
  if S == "AC" and Counted[p_] == 0:
    num1 += 1
    num2 += subnum2[p_ - 1]
    Counted[p_] = 1
  elif S == "WA" and Counted[p_] == 0:
    subnum2[p_ - 1] += 1
print("{} {}".format(num1, num2))

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
Counted = [0 for _ in range(M)]
num1 = 0
num2 = 0
subnum2 = [0 for l in range(N)]
for j in range(M):
  p, S = input().split()
  p_ = int(p)
  if S == "AC" and Counted[p_] == 0:
    num1 += 1
    num2 += subnum2[p_ - 1]
    Counted[p_] = 1
  elif S == "WA" and Counted[p_] == 0:
    subnum2[p_ - 1] += 1
print("{} {}".format(num1, num2))

Submission status: Runtime Error

Solution code:
nm = input().split()
n = int(nm[0])
m = int(nm[1])

p = []
r = []

for i in range(m):
	pr = input().split()
	p.append(int(pr[0]))
	r.append(pr[1])

ac = 0
wa = 0
flg = [False for i in range(n)]

if m != 0:
	for l in range(m):
		if r[l] == 'AC' and flg[p[l]-1] == False :
			ac += 1
			flg[p[l]] = True
		elif  flg[p[l]-1] == False :
			wa += 1

print(ac)
print(wa)

Submission status: Runtime Error

Solution code:
nm = input().split()
n = int(nm[0])
m = int(nm[1])

p = []
r = []

for i in range(m):
	pr = input().split()
	p.append(int(pr[0]))
	r.append(pr[1])

ac = 0
wa = 0
flg = [False for i in range(n)]

if m != 0:
	for l in range(m):
		if r[l] == 'AC' and flg[p[l]] == False :
			ac += 1
			flg[p[l]] = True
		elif  flg[p[l]] == False :
			wa += 1

print(ac)
print(wa)

Submission status: Runtime Error

Solution code:
nm = input().split()
n = int(nm[0])
m = int(nm[1])

p = []
r = []

for i in range(m):
	pr = input().split()
	p.append(int(pr[0]))
	r.append(pr[1])

ac = 0
wa = 0
flg = [False for i in range(m)]

if m != 0:
	for l in range(m):
		if r[l] == 'AC' and flg[p[l]] == False :
			ac += 1
			flg[p[l]] = True
		elif  flg[p[l]] == False :
			wa += 1

print(ac)
print(wa)

Submission status: Runtime Error

Solution code:
nm = input().split()
n = int(nm[0])
m = int(nm[1])

p = []
r = []

for i in range(m):
	pr = input().split()
	p.append(int(pr[0]))
	r.append(pr[1])

ac = 0
wa = 0

for i in range(1,p[-1]+1):
    for l in range(m):
#         print(p[l])
#         print(r[l])
        if i != p[l]: continue
        if r[l] == 'AC':
            ac += 1
            break
        else: wa += 1

            
print(ac)
print(wa)

Submission status: Runtime Error

Solution code:
n, m=map(int, input().split())
a=set()
d={}
pena=0
for i in range(m):
    p, s=input().split()
    if s=="AC":
        a.add(int(p))
        pena+=d.pop(p)
    else:
        if p in d:
            d[p]+=1
        else:
            d[p]=1
print(len(a), pena)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
ls = []
for i in range(m):
    ls.append(list(map(int,input().split())))
li = sorted(ls, key = lambda x: x[1])
a = sorted(li, key = lambda x: x[0])

ans = []
for i in range(n):
    ans.append([0,0])
    t = 0
    while a[t,0] == i +1:
        if a[t,1] == "AC":
            ans[i,0] += 1
        else:
            ans[i,1] += 1
        t += 1

ac = 0
acs = 0
for i in range(len(ans)):
    if ans[i,0] != 0:
        ac += 1
        acs += ans[i,0]
print(ac)

print(m-acs)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
p=[0]*N
S=[0]*N
sei=[0]*N
pena=[0]*N
total=[0]*N

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

  if S[i]=="AC":
    if sei[p[i]]>=1:
      pass
    else:
      sei[p[i]] +=1
      
  else: # WAのとき
    if sei[p[i]]>=1:
      pass
    else: #0のとき
      pena[p[i]] +=1

for j in range(N):
  total[j]=sei[j]*pena[j]
  
print(sum(sei),sum(total))

Submission status: Runtime Error

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

l=list(input().split() for _ in range(m))

w=[0]*n
a=[0]*n
seitou=0
pena=0

for i in l:
    k=int(i[0])-1
    if a[k]==0:
        if i[1]=="AC":
            a[k]+=1
        else:
            w[k]+=1

seitou=sum(a)
for j in range(n):
    if a[i]==1:
        pena+=w[i]
        
print(seitou,pena)

Submission status: Runtime Error

Solution code:
from collections import deque

def bfs(maze, visited, sy, sx, gy, gx):
  queue = deque([[sy, sx]])
  visited[sy][sx] = 0
  while queue:
    y,x = queue.popleft()
    if [y, x] == [gy, gx]:
      return visited[y][x]
    for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
      new_y, new_x = y+j, x+k
      if maze[new_y][new_x] == "." and visited[new_y][new_x] == -1:
        visited[new_y][new_x] = visited[y][x] + 1
        queue.append([new_y, new_x])

h,w = map(int,input().split())
wall = ''
for i in range(w+2):
  wall += '#'
maze = [wall]
for i in range(h) :
  m1 = input()
  maze.append('#'+m1+'#')
maze .append(wall)

s = [[1,1],[1,h],[w,1],[w,h]]
g = [[w,h],[w,1],[1,h],[1,1]]

ans = []
for i in range(4) :
  sy = s[i][1] ; sx = s[i][0]
  for j in range(1,h+1) :
    for k in range(1,w+1) :
      gy = j ; gx = k
      if maze[gy][gx] == '#' :
        break
      visited = [[-1]*(w+2) for _ in range(h+2)]
      ans.append(bfs(maze, visited, sy, sx, gy, gx))

print(max(ans))

Submission status: Runtime Error

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

q = [0]*n
t = [0]*n

for [p,s] in ps:
    p = int(p) - 1
    if s == "AC" and q[p] == 0:
        q[p] += 1
    elif s == "WA" and q[p]== 0:
        t[p] += 1

for [p,s] in ps:
    if q[p] == 0 and t[p] != 0:
        t[p] == 0


print(sum(q),sum(t))

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
AC = 0
penalty = 0
AC_list = [0]*N
WA_list = [0]*N

for i in range(M):
  p,s = map(str,input().split())
  p = int(p-1)
  if s == "AC" and AC_list[p] == 0:
    AC += 1
    AC_list[p] = 1
    penalty += WA_list[p]
  elif s == "WA":
    WA_list[p] += 1
  if AC == N:
    break
print(AC,penalty)

Submission status: Runtime Error

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

memoAC = [0]*N
memoWA = [0]*N
for list in L:
  if list[1]=="AC":
    memoAC[int(list[0])]=1
  else:
    if memoAC[int(list[0])]!=1:
      memoWA[int(list)[0]]+=1
      
AC = sum(memoAC)
WA = sum(memoWA)
print(AC,WA)

Submission status: Runtime Error

Solution code:
def get_ints():
    return map(int, input().split())

n, m = get_ints()
penalty = 0
oks = 0
ac = []
for i in range(n):
    ac.append(False)
for i in range(m):
    p, s = input().split()
    p = int(p)
    p -= 1
    if ac[p]:
        continue
    if s == 'AC':
        ac[p] = True
        oks += 1
    else:
        penalty += 1

print(f'{oks} {penalty}')

Submission status: Runtime Error

Solution code:
import sys

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

WA = [0] * N
isAC = [False] * N

for _ in range(M):
	p, S = input().split()
	if S == "AC":
		isAC[int(p) - 1] = True
	elif not isAC[int(p) - 1]:
		WA += 1

ACsum, WAsum = 0, 0
for i in range(N):
	if isAC[i]:
		ACsum += 1
		WAsum += WA[i]

print(ACsum, WAsum)

Submission status: Runtime Error

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

i_ac = 0
i_wa = 0
listA= []

for i in range(M):
	num,ans = map(str,input().split())
        If num == 0:
                         break         
	if ans == "AC":
                if num not in listA:
			listA.append(num)
			i_ac = i_ac + 1
	else:
		if num not in listA:
			i_wa = i_wa + 1
                else:
                        i_wa = i_wa 
print("{} {}".format(i_ac, i_wa))

Submission status: Runtime Error

Solution code:
input_line = input()
Line = input_line.split()
Line = [int(s) for s in Line]
#mondaisuu
N = Line[0]
#teisyutu
M = Line[1]

AC_Lists = [""]*N
# print(AC_Lists)

for i in range(M):
    input_line = input()
    Line = input_line.split()
    print(Line)
    AC_Lists[int(Line[0])-1] += Line[1][0]
    print(AC_Lists)

AC_count = 0
WA_count = 0

for s in AC_Lists:
    # print(s)
    if 'A' in s:
        AC_count += 1
        my_str = s.split("A")
        print(my_str)
        # print(len(my_str[0]))
        WA_count += len(my_str[0])
    else:
        # print(len(s))
        WA_count += len(s)
# print(AC_Lists)

print(AC_count,WA_count)

Submission status: Runtime Error

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,M = map(int,input().split())
PS = (input().split() for _ in range(N))

ac = [False] * N
wa_cnt = [0] * N
penal = 0
for P,S in PS:
    p = int(P)-1
    if ac[p]:
        pass
    elif S == b'WA':
        wa_cnt[p] += 1
    else:
        ac[p] = True
        penal += wa_cnt[p]

ac = sum(ac)
print(ac, penal)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
AC = []
c = 0
p = 0
for _ in range(M):
    st = list(input())
    if st[-2:] = ["A","C"]:
        if st[:-3] not in AC:
            c += 1
            AC.append(st[:-3])
    else:
        if st[:-3] not in AC:
            p += 1
print(c, p)

Submission status: Runtime Error

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

wa = [0] * N
pnt = [0] * N
ac = [False] * N

for _ in range(M):
    tmp = 0
    p, s = list(map(str, input().split()))
    if s == 'WA':
      wa[int(p)] += 1
    elif s == 'AC' and not (ac[int(p)]):
      ac[int(p)] = not (ac[int(p)])
      pnt[int(p)] += wa[int(p)]

print(ac.count(True), sum(pnt))

Submission status: Runtime Error

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

ac = 0
wr = 0
list = []

for _ in range(M):
    tmp = 0
    p, s = list(map(str, input().split()))
    if not(tmp == int(p)) and s == 'AC' and not int(p) in list:
      tmp = int(p)
      list.append(int(p))
      ac += 1
    elif s == 'WA' and not int(p) in list and tmp == 1:
      wr += 1

print(ac, wr)

Submission status: Runtime Error

Solution code:
def resolve():
	import sys
    input = sys.stdin.readline
    n, m = map(int, input().split())
    a = list(input().split() for _ in range(m))
    flag = [0]*2*n
    if m == 0:
        print("{} {}".format(0, 0))
        exit()
    miss = 0
    correct = 0
    for i in range(m):
        if flag[int(a[i][0])] == 0:
            if a[i][1] == "WA":
                miss += 1
            elif a[i][1] == "AC":
                correct += 1
                flag[int(a[i][0])] = 1
    print("{} {}".format(correct, miss))
resolve()

Submission status: Runtime Error

Solution code:
def resolve()
	import sys
    input = sys.stdin.readline
    n, m = map(int, input().split())
    a = list(input().split() for _ in range(m))
    flag = [0]*2*n
    if m == 0:
        print("{} {}".format(0, 0))
        exit()
    miss = 0
    correct = 0
    for i in range(m):
        if flag[int(a[i][0])] == 0:
            if a[i][1] == "WA":
                miss += 1
            elif a[i][1] == "AC":
                correct += 1
                flag[int(a[i][0])] = 1
    print("{} {}".format(correct, miss))
resolve()

Submission status: Runtime Error

Solution code:
    import sys
    input = sys.stdin.readline
    n, m = map(int, input().split())
    a = list(input().split() for _ in range(m))
    flag = [0]*2*n
    if m == 0:
        print("{} {}".format(0, 0))
        exit()
    miss = 0
    correct = 0
    for i in range(m):
        if flag[int(a[i][0])] == 0:
            if a[i][1] == "WA":
                miss += 1
            elif a[i][1] == "AC":
                correct += 1
                flag[int(a[i][0])] = 1
    print("{} {}".format(correct, miss))
resolve()

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
ac_list = []
wa_dic = {}
for i in range(M):
    p, s = input().split()
    p = int(p)
    if p in ac_list: continue

    if s == 'WA':
        try:
            wa_dic[p] += 1
        except:
            wa_dic[p] = 1
        
    else:
        ac_list.append(p)
        

#print(ac_list, wa_dic)
print(len(ac_list), sum([wa_dic[x] for x in ac_list]))

Submission status: Runtime Error

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

ans =[]
for i in range(m):
  if not(ps[i][0] in ans) :
    ans += ps[i][0]
    

print(ps[0][0])
wa = 0
ac = 0
for i in ans:
  for j in range(m):
    #問題番号の確認
    w = 0
    if ps[j][0] == str(i):
      if ps[j][1] =="WA":
        w += 1
      elif ps[j][1] == "AC":
        ac += 1
        wa +=w
        break

    else:
      continue
      
      
print(ac,wa)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
ac=0
wa=0
mydict={}
already=[]
for i in range(M):
    P,S=input().split()
    if S=="WA":
        if already.count(P)==0:
            mydict[P]=1
        else:
            mydict[P]=mydict[P]+1
    else:
        if already.count(P)==0:
            ac=ac+1
            wa=wa+mydict[P]
        else:
            pass
print(wa,ac)

Submission status: Runtime Error

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

ac = []
wa = [0 for i in range(N)]

for _ in range(M):
    p_i, s_i = input().split()
    if s_i == "AC" and p_i not in ac:
        ac.append(p_i)
    if s_i == "WA" and p_i not in ac:
        wa[p_i - 1] += 1
        
ac = set(ac)
wa_num = 0
for i in range(N):
    if i + 1 not in ac:
        continue
    else:
        wa_num += wa[i]

print(len(ac), wa_num)

Submission status: Runtime Error

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

ac = []
wa = [0 for i in range(N)]

for _ in range(M):
    p_i, s_i = input().split()
    if s_i == "AC" and p_i not in ac:
        ac.append(p_i)
    if s_i == "WA" and p_i not in ac:
        wa[p_i - 1] += 1
        
ac = set(ac)                
wa = [count for i, count in enumerate(wa) if i + 1 in ac]

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

Submission status: Runtime Error

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

wa = 0
for _ in range(M):
  p, s = input().split()
  index = int(p)-1
  if s == 'AC':
    wa += P[index]
    P[index] = -1
  elif :
    if P[index] != -1
      P[index] += 1
  
print(P.count(-1), wa)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
AC={}
WA={}
for i in range(M):
    a,b=input().split()
    if not(a in AC.keys()):
        if b=="AC":
            AC[a]=1
        else:
            if a in WA.keys():
                WA[a]+=1
            else:
                WA[a]=1
y=0
for i in AC.keys():
    y+=WA[i]
print(sum(AC.values()),y)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
cnt=[0]*(n+1)
l=[0]*(n+1)
ac=0
wa=0
for i in range(m):
  p,s=input().split()
  p=int(p)
  if l[p]!=0:
    continue
  if l[p]==0 and s=='WA':
    cnt[i]+=1
  if l[p]==0 and s=='AC':
    ac+=1
    l[p]=1
for i in range(1,n+1):
  if l[i]!=0:
    wa+=cnt[i]
print(ac,wa)

Submission status: Runtime Error

Solution code:
list_1 = [input().split() for _ in range(M)]

tmp = 0
pen = 0
for i in list_1:
    if i[1] == 'WA':
        tmp += 1
    elif i[1] == 'AC':
        pen = tmp
new_list = [j for j in list_1 if j[1] == 'AC']
ans_list = list(map(list, set(map(tuple, new_list))))
print(len(ans_list),pen)

Submission status: Runtime Error

Solution code:
atcoder-tools: The pre-rendered templates are not found.import numpy as np

N, M = map(int, input().split())
AC_or_not = np.array([0] * N)
n_penalty = np.array([0] * N)

for _ in range(M):
    prob, wa_ac = input().split()
    prob = int(prob) - 1
    if wa_ac == 'AC':
        AC_or_not[prob] = 1
    else:
        if not AC_or_not[prob]:
            n_penalty[prob] += 1

print(sum(AC_or_not), sum(n_penalty * AC_or_not))

Submission status: Runtime Error

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

eva = {}

ac = 0
wa = 0

for i in range(m):
    q, s = input().split()
    if eva[q] == "AC":
        pass
    else:
        if s == "AC":
            ac += 1
            eva[q] = "AC"
        else:
            wa += 1

print(ac, wa)

Submission status: Runtime Error

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

eva = [[0] for _ in range(n)]

ac = 0
wa = 0

for i in range(m):
    a = input().split()
    q = int(a[0])
    s = a[1]
    if "AC" in eva[q]:
        pass
    else:
        if s == "AC":
            ac += 1
            eva[q].append("AC")
        else:
            wa += 1
            eva[q] += 1

print(ac, wa)

Submission status: Runtime Error

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

ac_list = []
wa_dict = {}
num_wa = 0

for ps in ps_list:
    p = int(ps[0])
    s = ps[1]
    
    if s == 'AC':
        ac_list.append(p)
        num_wa += wa_dict[p]
    elif p not in ac_list:
        if p not in wa_dict.keys():
            wa_dict[p] = 1
        else:
            wa_dict[p] += 1
            
num_ac = len(ac_list)
        
print(num_ac, num_wa)

Submission status: Runtime Error

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

ac_list = []
wa_dict = {}
num_wa = 0

for ps in ps_list:
    p = int(ps[0])
    s = ps[1]
    
    if s == 'AC':
        ac_list.append(p)
        num_wa += wa_dict[p]
    elif p not in ac_list:
        if p not in wa_dict.keys():
            wa_dict[p] = 1
        else:
            wa_dict[p] += 1
         
print(num_ac, num_wa)

Submission status: Runtime Error

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


answer =["inf"]*m
count = 0

for i in range(len(ps)):
  if ps[i][0] not in answer:
    if ps[i][1] == "AC":
      answer[i] = ps[i][0]
    else:
      count += 1
answer.remove("inf")
print(len(answer),count)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
A=[[0,0] for i in range(m)] #ACしたか、WA数
AC=0
pen=0
for i in range(m):
    a,b=map(str,input().split())
    a=int(a)
    if b=="AC":
        A[a-1][0]=1
    elif b=="WA" and A[a-1]==0:
        A[a-1][1]+=1
for i in range(n):
    if A[i][0]==1:
        AC+=1
        pen+=A[i][1]
print(AC,pen)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
pen=0
A=[0 for i in range(n)]
for i in range(m):
  a,b=map(str,input().split())
  a=int(a)
  if b=="AC":
    A[a-1]=1
for i in range(m):
  a,b=map(int,input().split())
  a=int(a)
  if b=="WA" and A[a-1]==1:
    pen+=1
print(sum(A),pen)

Submission status: Runtime Error

Solution code:
n,m = map(int, input().split())
dic = {}
cnt = 0
for _ in range(m):
    p,s = input.split()
    if p not in dic.keys():
        if s == 'AC':
            dic[p] = 1
        else:
            cnt += 1
cor = sum(dic.values())
print('{} {}'.format(cor, cnt))

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
ll=[input().split() for _ in range(m)]
la={p for p,s in ll if s=='AC'})
f,c=0,0
for p,s in ll:
  if s=='AC': 
  if

Submission status: Runtime Error

Solution code:
from collections import defaultdict

n, m = map(int, input().split())
ps = []
for _ in range(n):
  ps.append(map(int, input().split()))

sub_st = defaultdict(list)
for p, s in ps:
  sub_st[p].append(s)

solved = 0
error = 0
for k, v in sub_st.items():
  temp_error = 0
  for history in v:
    temp_error += 1
    if 'AC' in v:
      error += temp_error
      solved += 1
      break

priny(solved, error)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
wa=0
ac=0
already=[]
for i in range(M+1):
    P,S=map(input().split())
    if S=="WA" and already.count(P)==0:
        wa=wa+1
    if S=="AC" and already.count(P)==0:
        ac=ac+1
        already.append(P)
    else:
        pass
print(wa,ac)

Submission status: Runtime Error

Solution code:
#151c
n,w=map(int,input().split())
ac=0
wa=[0]*n
wa_cnt=[0]*n
ac_flg=[0]*n
for i in range(w):
	p,s=input().split()
	p=int(p)-1
	if ac_flg[p]==1:
		continue
	else:
		if s=='AC':
			ac_flg[p]=1
			ac+=1
			wa[p] =wa_cnt
			#wa_cnt=0
		else:
			wa_cnt[p]+=1

wa_ans=0
for i in range(n):
	wa_ans+=wa[i]

print(ac,wa_ans)

Submission status: Runtime Error

Solution code:
#151c
n,w=map(int,input().split())
ac=0
wa=[0]*n
wa_cnt=[0]*n
ac_flg=[0]*n
for i in range(w):
	p,s=input().split()
	p=int(p)-1
	if ac_flg[p]==1:
		continue
	else:
		if s=='AC':
			ac_flg[p]=1
			ac+=1
			wa[p] +=wa_cnt
			#wa_cnt=0
		else:
			wa_cnt[p]+=1

wa_ans=0
for i in range(n):
	wa_ans+=wa[i]

print(ac,wa_ans)

Submission status: Runtime Error

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

ac = 0
aced = set()
pindex = set()
s = []
if nm[1] != 0 :
    ps = input().split()
    pindex.add(ps[0])
    s.append(0)
    if ps[1] == 'WA':
        s[pindex.index(ps[0])] += 1
    else:
        ac += 1
        aced.add(ps[0])
    for i in range(nm[1] - 1):
        ps = input().split()
        if ps[0] not in aced:
            if ps[0] not in pindex:
                pindex.add(ps[0])
                s.append(0)
            if ps[1] == 'WA':
                s[pindex.index(ps[0])] += 1
            else:
                ac += 1
                aced.add(ps[0])

    print(str(ac) + ' ' + str(sum(s)))
else:
    print('0 0')

Submission status: Runtime Error

Solution code:
#151c
n,w=map(int,input().split())
ac=0
wa=[0]*w
wa_cnt=0
ac_flg=[0]*n
for i in range(w):
	p,s=input().split()
	p=int(p)-1
	if ac_flg[p]==1:
		continue
	else:
		if s=='AC':
			ac_flg[p]=1
			ac+=1
			wa[p] +=wa_cnt
			wa_cnt=0
		else:
			wa_cnt+=1

wa_ans=0
for i in range(n):
	wa_ans+=wa[i]

print(ac,wa_ans)

Submission status: Runtime Error

Solution code:
#151c
n,w=map(int,input().split())
ac=0
wa=[0]*w
wa_cnt=0
ac_flg=[0]*n
for i in range(w):
	p,s=input().split()
	p=int(p)-1
	if ac_flg[p]==1:
		continue
	else:
		if s=='AC':
			ac_flg[p]=1
			ac+=1
			wa[p] +=wa_cnt
			wa_cnt=0
		else:
			wa_cnt+=1

wa_ans=0
for i in (n):
	wa_ans+=wa[i]

print(ac,wa_ans)

Submission status: Runtime Error

Solution code:
#151c
n,w=map(int,input().split())
ac=0
wa=[0]*w
wa_cnt=0
ac_flg=[0]*n
for i in range(w):
	p,s=input().split()
	p=int(p)-1
	if ac_flg[p]==1:
		continue
	else:
		if s=='AC':
			ac_flg[p]=1
			ac+=1
			wa[p] =wa_cnt
			wa_cnt=0
		else:
			wa_cnt+=1

wa_ans=0
for i in (n):
	wa_ans+=wa[i]
print(ac,wa_ans)