Problem:


Score : 200 points

Problem Statement

Takahashi has N blue cards and M red cards.
A string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i.

Takahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen.

Here, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces atcoder, he will not earn money even if there are blue cards with atcoderr, atcode, btcoder, and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.)

At most how much can he earn on balance?

Note that the same string may be written on multiple cards.

Constraints

N and M are integers.

1 \leq N, M \leq 100

s_1, s_2, ..., s_N, t_1, t_2, ..., t_M are all strings of lengths between 1 and 10 (inclusive) consisting of lowercase English letters.

Input

Input is given from Standard Input in the following format:

N
s_1
s_2
:
s_N
M
t_1
t_2
:
t_M

Output

If Takahashi can earn at most X yen on balance, print X.

Sample Input 1

3
apple
orange
apple
1
grape

Sample Output 1

2

He can earn 2 yen by announcing apple.

Sample Input 2

3
apple
orange
apple
5
apple
apple
apple
apple
apple

Sample Output 2

1

If he announces apple, he will lose 3 yen. If he announces orange, he can earn 1 yen.

Sample Input 3

1
voldemort
10
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort

Sample Output 3

0

If he announces voldemort, he will lose 9 yen. If he announces orange, for example, he can avoid losing a yen.

Sample Input 4

6
red
red
blue
yellow
yellow
red
5
red
red
yellow
green
blue

Sample Output 4

1



Sample input:
3
apple
orange
apple
1
grape


Sample output:
2

Submission status: Runtime Error

Solution code:
x = int(input())
a = [input() for i in range(x)]
y = int(input())
b = [input() for i in range(y)]

count_max == 0
for i in a:
  if x.count(i) - y.count(i) > count_max:
    x.count(i) - y.count(i) = count_max
print(count_max)

Submission status: Runtime Error

Solution code:
x = int(input())
a = [input() for i in range(x)]
y = int(input())
b = [input() for i in range(y)]

count_max == 0
for i in range(x):
  if x.count(i) - y.count(i) > count_max:
    x.count(i) - y.count(i) = count_max
print(count_max)

Submission status: Runtime Error

Solution code:
import collections
n = int(input())
s = [str(input()) for _ in range(n)]
m = int(input())
t = [str(input()) for _ in range(m)]
s = collections.Counter(s)
t = collections.Counter(t)

for k, j in t.items():
    if k in s:
        s[k] -= j

values, counts = zip(*s.most_common())
print(max(0,counts[0))

Submission status: Runtime Error

Solution code:
def resolve():
    A, B, C, K = list(map(int, input().split()))
    if A + B >= K:
        print(A)
    else:
        print(A-(K - A - B))

    return


resolve()

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(str,input().split())
m = int(input())
b = list(str,input().split())
ans = 0
de = 0
def get():
  for i in range(n+1):
    
    if a[i]==a[i+1]:
    ans += 1
    return ans
def lose():
  for i in range(m+1):
    if b[i]==b[i+1]:
      de -= 1
      return de

if get()<=lose():

Submission status: Runtime Error

Solution code:
n = [int(input()) for i in range(int(input()))]
m = [int(input()) for i in range(int(input()))]
l = list(set(n))
print(max(0,(n.count(l[i])-m.count(l[i])) for i in range(len(l))))

Submission status: Runtime Error

Solution code:
n = [int(input()) for i in range(int(input()))]
m = [int(input()) for i in range(int(input()))]
print(max(len(set(n))-len(set(m)),0))

Submission status: Runtime Error

Solution code:
n = [int(input()) for i in range(int(input()))]
m = [int(input()) for i in range(int(input()))]
print(min(len(set(n))-len(set(m)),0))

Submission status: Runtime Error

Solution code:
blue = [input() for i in range(int(input()))]
red = [input() for i in range(int(input()))]
print(max(0, [blue.count(i) - red.count(i) for i in set(blue + red)]))

Submission status: Runtime Error

Solution code:
ans=0
n=int(input())
lst=[]
for i in range(n):
  lst.append(input())
m=int(input())
x=[]
for j in range(m):
  x.append(int(input()))
for k in set(lst):
  c=lst.count(k)-x.cont(k)
  ans=max(ans,c)
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

n = int(input())
s = np.full(n, "", dtype=object)
for i in range(n):
    s[i] = input()

m = int(input())
t = np.full(m, "", dtype=object)
for i in range(m):
    t[i] = input()
    
uni, counts = np.unique(
    np.hstack([s, t]),
    return_counts=True
)

neg_uni, neg_counts = np.unique(t, return_counts=True)

for i in range(len(uni)):
    try:
        neg_count = neg_counts[neg_uni.tolist().index(uni[i])]
    except ValueError:
        continue

    counts[i] -= 2 * neg_count

print(np.max(np.append(counts, 0)))

Submission status: Runtime Error

Solution code:
from collections import Counter

N = int(input())
S = [input() for _ in range(N)]

M = int(input())
T = [input() for _ in range(M)]

s_counter = Counter(S)
t_counter = Counter(T)

result = 0

for k, v in s_counter:
    result = max(result, v - (t_counter[k] if t_counter[k] else 0))

print(result)

Submission status: Runtime Error

Solution code:
s=[input()for _ in range(int(input()))]
t=[input()for _ in range(int(input()))]
a=set(s)
print(max(0,max(s.count(a[i])-t.count(a[i]) for i in range(len(a)))))

Submission status: Runtime Error

Solution code:
s=[int(input())for _ in range(int(input()))]
t=[int(input())for _ in range(int(input()))]
a=list(set(s))
print(max(0,max(s.count(a[i])-t.count(a[i]) for i in range(len(a)))))

Submission status: Runtime Error

Solution code:
s=[int(input())for _ in range(int(input()))]
t=[int(input())for _ in range(int(input()))]
a=set(s)
print(max(0,max(s.count(a[i])-t.count(a[i]) for i in range(len(a)))))

Submission status: Runtime Error

Solution code:
from collections import Counter
N = int(input())
dic = Counter()
for _ in range(N):
  dic[input()] += 1
M = int(input())
for _ in range(N):
  dic[input()] -= 1
 
if dic.most_common():
  freq = dic.most_common()[0][1]
  print(max(freq, 0))
else:
  print(0)

Submission status: Runtime Error

Solution code:
from collections import Counter
N = int(input())
dic = Counter()
for _ in range(N):
  dic[input()] += 1
M = int(input())
for _ in range(N):
  dic[input()] -= 1

if c.most_common():
  freq = c.most_common()[0][1]
  print(freq, 0)
else:
  print(0)

Submission status: Runtime Error

Solution code:
n=int(input())
b=[input() for i in range(n)]
m=int(input())
r=[input() for i in range(m)]
ans=[0]
for i in set(b)
    ans.append(b.count(i)-r.count(i))
print(max(ans))

Submission status: Runtime Error

Solution code:
n = int(input())
s = list()

for a in range(n):
    s.append(input())

t = list()
m = int(input())

for a in range(m):
    t.append(input())

kind = list(set(s))
kind_length = len(kind)

counter = dict()
for a in range(kind_length):
    counter[kind[a]] = 0

for a in range(n):
    counter[s[a]] += 1

for a in range(m):
    if t[a] not in counter:
        continue
    counter[t[a]] -= 1

print(max(counter.values(), 0))

Submission status: Runtime Error

Solution code:
s = [input() for _ in range(int(input()))]
t = [input() for _ in range(int(input()))]

print(max(0,max(s.count(s[i]) - t.count(s[i]) for i in range(len(S)))))

Submission status: Runtime Error

Solution code:
s = [input() for _ in range(int(input()))]
t = [input() for _ in range(int(Input()))]

print(max(0,max(s.count(s[i]) - t.count(s[i]) for i in range(len(S)))))

Submission status: Runtime Error

Solution code:
s = [input() for _ in range(int(input()))]
t = [input() for _ in range(int(Input()))]

print(max([s.count(s[i]) - t.count(s[i]) for i in range(len(S))]))

Submission status: Runtime Error

Solution code:
s = [int(input()) for _ in range(int(input()))]
t = [int(input()) for _ in range(int(Input()))]

print(max(
    [s.count(s[i]) - t.count(s[i]) for i in range(len(S))]))

Submission status: Runtime Error

Solution code:
from collections import Counter
N = int(input())
S = Counter([input() for _ in range(N)])
M = int(input())
T = Counter([input() for _ in range(M)])
G = S-T
print(max([a for a in G.values()]))

Submission status: Runtime Error

Solution code:
n = int(input())
from collections import Counter
c = Counter()
for i in range(n):
  c.update[{input():1}]
  
m = int(input())
for i in range(m):
  s = input()
  if c[s] >= 1:
    c.update[{s:-1}]
    
print(c.most_common()[0][1])

Submission status: Runtime Error

Solution code:
N = int(input())
S = [input() for i in range(N)]
M = int(input())
T = [input() for i in range(M)]
ans = 0

for i in list(set(X)):
  tmp = S.count(i) - T.count(i)
  if ans < tmp:
    ans = tmp
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
l = list(set(s))
print(max(0,max(s.count(l[i]) - t.count(l[i]) for i in l)))

Submission status: Runtime Error

Solution code:
N=int(input())
s=[input() for i in range(N)]
M=int(input())
t=[input() for j in range(M)]
score = []
set_s_t=set(s)&set(t)
lst_s_t=list(set_s_t)
for k in lst_s_t:
  b=s.count(k)
  r=t.count(k)
  score.append(b-r)
if max(score)>0:
  print(max(score))
else:
  print(0)

Submission status: Runtime Error

Solution code:
N=int(input())
s=[input() for i in range(N)]
M=int(input())
t=[input() for j in range(M)]
score = []
set_s_t=set(s)&set(t)
lst_s_t=list(set_s_t)
for k in lst_s_t:
  b=s.count(k)
  r=t.count(k)
  score.append(b-r)
print(max(score))

Submission status: Runtime Error

Solution code:
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]

judge = 0
for i in range(N):
  count = 0
  for j in range(i+1,N+1):
    for k in range(M):
      if s[i] == s[j]:
        count += 1
      if s[i] == t[k]:
        count -= 1
      if count > judge:
        judge = count
print(judge)

Submission status: Runtime Error

Solution code:
# ABC091B

n = int(input)
s = [0] * n
for i in range(n):
    s[i] = input()
m = int(input)
t = [0] * m
for i in range(m):
    t[i] = input()

blue = {}
for c in s:
    if c in blue.keys():
        blue[c] += 1
    else:
        blue.setdefault(c, 1)
red = {}
for c in t:
    if c in red.keys():
        red[c] += 1
    else:
        red.setdefault(c, 1)

Max = 0
for blue_key, blue_value in blue.items():
    get = blue_value
    if blue_key in red.keys():
        for red_key, red_value in red.items():
            if blue_key == red_key:
                get -= red_value
                break
    Max = max(Max, get)
print(Max)

Submission status: Runtime Error

Solution code:
N=int(input())
s=[int(input()) for _ in range(N)]
M=int(input())
t=[int(input()) for _ in range(M)]
l=set(s)
List=[s.count(l[i])-t.count(l[i]) for i in range(len(l))]
print(max(0,max(List)))

Submission status: Runtime Error

Solution code:
n=int(input())
s=list(input() for i in range(n))
m=int(input())
t=list(input() for j in range(m))
l=list(set(n))
ans=(max(0,s.count(l[k])-t.count(l[k])) for k in range(len(l)))

Submission status: Runtime Error

Solution code:
n=[input() for _ in range(int(input()))]
m=[input() for _ in range(int(input()))]
l=list(set(n))
print(max(0,max(n.count(l[i]-m.count(l[i]) for i in range(len(l))))))

Submission status: Runtime Error

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

def main():
  A,B,C = map(int, input().split())
  if A==B:
    print(C)
  elif B==C:
    print(A)
  else:
    print(B)

if __name__ == "__main__":
  main()

Submission status: Runtime Error

Solution code:
N = int(input())
S = []
for i in range(N):
  Si = str(input())
  S.append(Si) 
  
M = int(input())
T = []
for i in range(M):
  Ti = str(input())
  T.append(Ti)

total = 0
tokuten_list = []
tokuten = []
for i in range(N):
  if not S[i] in T:
    if not S[i] in tokuten_list:
      tokuten_list.append(S[i])
      tokuten.append(1)
    else:
      tokuten[tokuten_list.index(S[i])] = tokuten[tokuten_list.index(S[i])] + 1

print(max(tokuten))

Submission status: Runtime Error

Solution code:
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]

print(max(s.count(S) - t.count(S) for S in s) + [0])

Submission status: Runtime Error

Solution code:
b_list = [int(input() for i in range(int(input())))]
r_list = [int(input() for i in range(int(input())))]

ans = 0 
for i in list(set(b_list)):
  s = b_list.count(i) - r_list.count(i)
  if ans <= s:
    ans = s
    
print(ans)

Submission status: Runtime Error

Solution code:
b_list = [int(input() for i in range(int(input())))]
r_list = [int(input() for i in range(int(input())))]

ans = 0 
for i in list(set(b_list)):
  if ans <= b_list.count(i) - r_list.count(i):
    ans = b_list.count(i) - r_list.count(i)
    
print(ans)

Submission status: Runtime Error

Solution code:
import collections
n = int(input())
Lista = [str(input()) for i in range(n)]
m = int(input())
Listb = [str(input()) for j in range(m)]
lst = []
for k in range(m):
  if Listb[k] in Lista:
    Lista.remove(Listb[k])
lst = collections.Counter(Lista)
print(lst.most_common()[0][1])

Submission status: Runtime Error

Solution code:
N=input()
N=int(N)
S=[0]*N
for i in range(N):
    S[i]=input()

M=input()
M=int(M)
T=[0]*M
for i in range(M):
    T[i]=input()

A=[]
for i in S:
    A.append(S.count(i)-T.count(i))

print(max(*A,0))

Submission status: Runtime Error

Solution code:
N=int(input())
S=[0]*N
for i in range(N):
    S[i]=input()

M=int(input())
T=[0]*M
for i in range(M):
    T[i]=input()

A=[]
for i in S:
    A.append(S.count(i)-T.count(i))

print(max(*A,0))

Submission status: Runtime Error

Solution code:
N = int(input())
s = sorted([input() for i in range(N)])
M = int(input())
t = sorted([input() for i in range(M)])
a = 0
for i in s:
    for j in t:
        if a <= (s.count(s[i]) - t.count(t[j])):
            a = s.count(s[i]) - t.count(t[j])
print(a)

Submission status: Runtime Error

Solution code:
N = int(input())
s = sorted([input() for i in range(N)])
M = int(input())
t = sorted([input() for i in range(M)])
a = 0
for i in s:
    for j in t:
        if a < s.count(s[i])-t.count(j):
            a = s.count(s[i])-t.count(j)
print(a)

Submission status: Runtime Error

Solution code:
n = int(input())
red =[]
for i in range(n):
  l = str(input())
  red.append(l)

m = int(input())
blue =[]
for i in range(m):
  l = str(input())
  blue.append(l)
  
import collections

cr = collections.Counter(red)
red_name = cr.most_common()[0][0]
red_count = cr.most_common()[0][1]
cb = collections.Counter(blue)
blue_name = cb.most_common()[0][0]
blue_count = cb.most_common()[0][1]

if blue_name == red_name:
  if red_count - blue_count < 0:
    if len(red)==1:
      print(0)
    else:
      print(cr.most_common()[1][1])
  else:
    print(red_count - blue_count)
else:
  print(red_count)

Submission status: Runtime Error

Solution code:
n = int(input())
red =[]
for i in range(n):
  l = str(input())
  red.append(l)

m = int(input())
blue =[]
for i in range(m):
  l = str(input())
  blue.append(l)
  
import collections

cr = collections.Counter(red)
red_name = cr.most_common()[0][0]
red_count = cr.most_common()[0][1]
cb = collections.Counter(blue)
blue_name = cb.most_common()[0][0]
blue_count = cb.most_common()[0][1]

if blue_name == red_name:
  if red_count - blue_count < 0:
    if len(red)==1:
      print(0)
    else:
      if cr.most_common()[1][0]==cb.most_common()[1][0]:
        if cr.most_common()[1][1]-cb.most_common()[1][1] > 0:
          print(cr.most_common()[1][1]-cb.most_common()[1][1])
      else:
        print(cr.most_common()[1][1])
  else:
    print(red_count - blue_count)
else:
  print(red_count)

Submission status: Runtime Error

Solution code:
n = int(input())
red =[]
for i in range(n):
  l = str(input())
  red.append(l)

m = int(input())
blue =[]
for i in range(m):
  l = str(input())
  blue.append(l)
  
import collections

cr = collections.Counter(red)
red_name = cr.most_common()[0][0]
red_count = cr.most_common()[0][1]
cb = collections.Counter(blue)
blue_name = cb.most_common()[0][0]
blue_count = cb.most_common()[0][1]

if blue_name == red_name:
  if red_count - blue_count < 0:
    if len(red)==1:
      print(0)
    else:
      if cr.most_common()[1][0]==cb.most_common()[1][0]:
        print(cr.most_common()[1][1]-cb.most_common()[1][1])
      else:
        print(cr.most_common()[1][1])
  else:
    print(red_count - blue_count)
else:
  print(red_count)

Submission status: Runtime Error

Solution code:
n = int(input())
red =[]
for i in range(n):
  l = str(input())
  red.append(l)

m = int(input())
blue =[]
for i in range(m):
  l = str(input())
  blue.append(l)
  
import collections

cr = collections.Counter(red)
red_name = cr.most_common()[0][0]
red_count = cr.most_common()[0][1]
cb = collections.Counter(blue)
blue_name = cb.most_common()[0][0]
blue_count = cb.most_common()[0][1]

if blue_name == red_name:
  if red_count - blue_count < 0:
    if len(red)==1:
      print(0)
    else:
      if cr.most_common()[1][0]==cb.most_common()[1][0]:
        print(cr.most_common()[1][0]-cb.most_common()[1][0])
      else:
        print(cr.most_common()[1][1])
  else:
    print(red_count - blue_count)
else:
  print(red_count)

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  map<string, int> cnt;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    cnt[s]++;
  }
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    string t;
    cin >> t;
    cnt[t]--;
  }
  int res = 0;
  for (auto &sc : cnt) {
    res = max(res, sc.second);
  }
  cout << res << '\n';
  return 0;

}

Submission status: Runtime Error

Solution code:
n = [input() for i in range(int(input()))]
m = [input() for i in range(int(input()))]
n_set = list(set(n))

print(max(0, max(n.count(n_set[i]) - m.count(n_set(i)) for i in len(n_set))))

Submission status: Runtime Error

Solution code:
from collections import Counter
n=int(input())
s = list(input() for _ in range(n))
m=int(input())
t = list(input() for _ in range(m))

def list_difference(s,t):
    l = s.copy()
    for value in t:
        if value in l:
            l.remove(value)

    return l
l=list_difference(s,t)
l1=Counter(l)
print(l1.most_common()[0][1])

Submission status: Runtime Error

Solution code:
n=int(input())
s = list(input() for _ in range(n))
m=int(input())
t = list(input() for _ in range(m))

def list_difference(s,t):
    l = s.copy()
    for value in t:
        if value in l:
            l.remove(value)

    return l
l=list_difference(s,t)
l1=Counter(l)
print(l1.most_common()[0][1])

Submission status: Runtime Error

Solution code:
n=int(input())
s = list(input() for _ in range(n))
m=int(input())
t = list(input() for _ in range(m))

def list_difference(s,t):
    l = s.copy()
    for value in t:
        if value in l:
            l.remove(value)

    return l
l=list_difference(s,t)
print(l.most_common()[0][1])

Submission status: Runtime Error

Solution code:
n=int(input())
s = list(input() for _ in range(n))
m=int(input())
t = list(input() for _ in range(m))

def list_difference(s,t):
    l = s.copy()
    for value in t:
        if value in l:
            l.remove(value)

    return l
print(l.most_common()[0][1])

Submission status: Runtime Error

Solution code:
from collections import Counter
N=int(input())
s=[0]*N
t=[0]*M
for i in range(N):
    s[i]=input()
M=int(input())
for j in range(M):
    t[j]=input()

c=dict(Counter(s))
d=dict(Counter(t))
maxi=0
#print(c)
#print(d)

for item in c:
    if item in d:
        tmp = c[item]-d[item]
    else:
        tmp = c[item]
    maxi=max(maxi, tmp)
   
print(maxi)

Submission status: Runtime Error

Solution code:
from collections import Counter
n=int(input())
s=[input() for _ in range(n)]
m=int(input())
t =[input() for _ in range(m)]
sc=Counter(s)
tc=Counter(t)
u=list(set(s)&set(t))
ans=0
for i in u:
    ans=max(ans,max(0,sc[i]-st[i]))
v=list(set(s)-set(u))
for i in v:
    ans=max(ans,sc[i])
print(ans)

Submission status: Runtime Error

Solution code:
from collections import Counter
n=int(input())
s=[input() for _ in range(n)]
m=int(input())
t =[input() for _ in range(m)]
sc=Counter(s)
tc=Counter(t)
u=list(set(s)&set(t))
ans=n
for i in u:
    ans-=sc[i]
    ans+=max(0,sc[i]-st[i])
print(ans)

Submission status: Runtime Error

Solution code:
from collections import defaultdict
def main():
    N = int(input())
    ans = 0
    s = defaultdict(int)
    for _ in range(N):
        a = input()
        s[a] += 1
    M = int(input())
    for _ in range(M):
        b = input()
        s[b] -= 1
    for v in s.items():
        ans = max(ans,v[1])
    print(ans)
if __name__ == a__main__":
    main()

Submission status: Runtime Error

Solution code:

#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
int main(){
    cin.tie(0);
    cout.sync_with_stdio(false);
    int N; cin >> N;
    map<string, int> m;
    string s;
    REP(i, N) {
        cin >> s;
        m[s] += 1;
    }
    int M; cin >> M;
    REP(i, M){
        cin >> s;
        if(m.count(s)) m[s] -= 1;
    }
    int mx = 0;
    for(auto p: m){
        mx = max(mx, p.second);     
    }
    cout << mx << endl;
    return 0;
}

Submission status: Runtime Error

Solution code:

#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
int main(){
    cin.tie(0);
    cout.sync_with_stdio(false);
    int N; cin >> N;
    map<string, int> m;
    string s;
    REP(i, N) {
        cin >> s;
        m[s] += 1;
    }
    int M; cin >> M;
    REP(i, M){
        cin >> s;
        if(m.count(s)) m[s] -= 1;
    }
    int mx = 0;
    for(auto p: m){
        mx = max(mx, p.second);     
    }
    cout << mx << endl;
    return 0;
}

Submission status: Runtime Error

Solution code:
# import math
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque
from collections import Counter

# import numpy as np
# import scipy as scp

# 入力の受け取り
n = int(input())
arrN = []
for _ in range(n):
    arrN += [input()]  #table.append(input())とも書ける
m = int(input())
arrM = []
for _ in range(m):
    arrM += [input()]  #table.append(input())とも書ける

countaN = Counter(arrN)
countaM = Counter(arrM)
countaAns = countaN - countaM

s,ans = countaAns.most_common()[0]

print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
b=[int(input()) for _ in range(n)]
m=int(input())
r=[int(input()) for _ in range(m)]
l=list(set(b))
a=[]
for s in l:
    a.append(b.count(s) - r.count(b))
print(max(max(a),0))

Submission status: Runtime Error

Solution code:
n = int(input())
lsn=[int(input()) for i in range(n)]
m = int(input())
lsm=[int(input()) for i in range(m)]
ls = []
for i in range(n):
  ls.append(lsn.count(lsn[i])-lsm.count(lsn[i]))
if max(ls) <= 0:
  print(0)
else:
  print(max(ls))

Submission status: Runtime Error

Solution code:
n = int(input())
blu_list = [str(input()) for _ in range(n)]
m = int(input())
red_list = [str(input()) for _ in range(m)]

blu_set_list = list(set(blu_list))
red_set_list = list(set(red_list))
set_list = blu_set_list + red_set_list

blu_cnt = []
red_cnt = []
ans = []

for i in set_list:
    blu_cnt.append(blu_list.count(i))
    red_cnt.append(red_list.count(i))

for i in range(len(blu_list)):
    ans.append(blu_cnt[i] - red_cnt[i])

print(max(ans))

Submission status: Runtime Error

Solution code:
n = int(input())
blu_list = [str(input()) for _ in range(n)]
m = int(input())
red_list = [str(input()) for _ in range(m)]

blu_set_list = list(set(blu_list))
red_set_list = list(set(red_list))
set_list = blu_set_list + red_set_list

blu_cnt = []
red_cnt = []
ans = []

for i in set_list:
    blu_cnt.append(blu_list.count(i))
    red_cnt.append(red_list.count(i))

for i in range(len(blu_list)):
    ans.append(blu_cnt[i] - red_cnt[i])

print(max(ans) if max(ans) > 0 else 0)

Submission status: Runtime Error

Solution code:
def main(n, s: list, m, t: list):
    choices = set(s + t)

    ans = [0]

    for choice in choices:
        ans_t = 0
        for _s in s:
            if choice == _s:
                ans_t += 1
        for _t in t:
            if choice == _t:
                ans_t -= 1

        ans.append(ans_t)

    print(max(ans))


if __name__ == "__main__":
    n = int(input())
    s = [input() for _ in range(n)]
    m = int(input())
    t = [input() for _ in range(n)]

    main(n, s, m, t)

Submission status: Runtime Error

Solution code:
n=int(input())
blue=[input() for _ in range(n)]
bset = set(blue)

m=int(input())
red=[input() for _ in range(m)]

print(min(0, max([blue.count(b) - red.count(b)) for b in bset]))

Submission status: Runtime Error

Solution code:
n = int(input())
ss = []
for i in range(n):
    ss.append(input())

m = int(input())
ts = []
for i in range(m):
    ts.append(input())

counter = dict()

for s in ss:
    counter.setdefault(s, 0)
    c = counter.get(s)
    counter[s] = c + 1
    
for t in ts:
    counter.setdefault(t, 0)
    c = counter.get(t)
    counter[t] =  c - 1
    
ans = max(counter.values()
if ans < 0:
    ans = 0
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(n)]
ans = 0

for i in set(s):
  num = s.count(i) - t.count(i)
  if num > ans :
    ans = num
    
    
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(n)]
ans = 0

for i in set(s):
  num = s.count(i) - t.count(i)
  if num > ans :
    ans = num
    
    
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(n)]
ans = 0

for i in set(s):
  num = s.count(i) - t.count(s)
  if num > ans :
    ans = num
    
    
print(ans)

Submission status: Runtime Error

Solution code:
from collections import Counter

n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]

s_c = Counter(s)
t_c = Counter(t)

keys,values = zip(*(s_c-t_c).most_common())

print(values[0])

Submission status: Runtime Error

Solution code:
lst_blue = []
lst_red = []

N = int(input())
for i in range(0,N):
  lst_blue.append(input())
M = int(input())
for i in range(0,M):
  lst_red.append(input())

for i in list(set(lst_blue)):
  dic = {lst_bule[i]:int(lst_blue.count(i))}
for i in list(set(lst_red)):
  if i in dic:
    dic[i] -= 1

print(max(dic.values()))

Submission status: Runtime Error

Solution code:
N = int(input())
s = {}
for i in range(N):
  a = input()
  if a in s:
    s[a] += 1
  else:
    s[a] = 1
M = int(input())
t = {}
for i in range(M):
  b = input()
  if b in t:
    t[b] += 1
  else:
    t[b] = 1
ans = 0
for p in s:
  if p in t:
    m = s[p] - t[p]
  else:
    m = s[p]
  if m > n:
    ans = m
print(ans)

Submission status: Runtime Error

Solution code:
s=[input() for _ in range(int(input()))]
t=[input() for _ in range(int(input()))]
l=list(set(n))
print(max(0,max(s.count(l[i])-t.count(l[i]) for i in range(len(l)))))n=[input() for _ in range(int(input()))]
m=[input() for _ in range(int(input()))]
l=list(set(n))
print(max(0,max(n.count(l[i])-m.count(l[i]) for i in range(len(l)))))

Submission status: Runtime Error

Solution code:
s=[input() for _ in range(int(input()))]
t=[input() for _ in range(int(input()))]
l=list(set(n))

print(max(0,max(s.count(l[i])-t.count(l[i]) for i in range(len(l)))))

Submission status: Runtime Error

Solution code:
s=[input() for _ in range(int(input()))]
t=[input() for _ in range(int(input()))]
l=list(set(n))
#s内の重複消去　リストに変更
print(max(0,max(s.count(l[i])-t.count(l[i]) for i in range(len(l)))))

Submission status: Runtime Error

Solution code:

s=[input() for _ in range(int(input()))]
t=[input() for _ in range(int(input()))]
l=list(set(n))
#s内の重複消去　リストに変更
print(max(0,max(n.count(l[i])-m.count(l[i]) for i in range(len(l)))))

Submission status: Runtime Error

Solution code:
s=[input() for _ in range(input())]
t=[input() for _ in range(input())]
l=list(set(n))
#s内の重複消去　リストに変更
print(max(0,max(n.count(l[i])-m.count(l[i]) for i in range(len(l)))))

Submission status: Runtime Error

Solution code:
N=int(input())
s=[input() for _ in range(N)]
M=int(input())
t=[input() for _ in range(M)]
ans=""
ans_1=0
for S in s:
    if s.count(S)-t.count(S)>0:
        ans=S
        if s.count(S)-t.count(S)>ans:
            ans_1=s.count(S)-t.count(S)
if ans_1>=0:
    print(ans)
else:
    print("0")

Submission status: Runtime Error

Solution code:
N=int(input())
s=[input() for _ in range(N)]
M=int(input())
t=[input() for _ in range(M)]

ans=input()
print(s.count(ans)-t.count(ans))

Submission status: Runtime Error

Solution code:
N,M=int(input())
s=[input() for _ in range(N)]
t=[input() for _ in range(M)]
ans=input()
print(s.count(ans)-t.count(ans))

Submission status: Runtime Error

Solution code:
from collections import defaultdict
d = defaultdict(int)

n = int(input())
for _ in range(n):
    d[input()] += 1
m = int(input())
for _ in range(n):
    d[input()] -= 1
print(max(0, max(d.values())))

Submission status: Runtime Error

Solution code:
from collections import defaultdict
d = defaultdict(int)

n = int(input())
for _ in range(n):
    d[input()] += 1
m = int(input())
for _ in range(n):
    d[input()] -= 1
print(max(d.values()))