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

Solution (Python):
n,*s=open(0);print(max(0,*[s.count(i)-s[int(n):].count(i)*2for i in s]))

Solution (Python):
n = int(input())
ans = 0
cnt = dict()
for i in range(n):
    s = input()
    try:
        cnt[s] += 1
    except:
        cnt[s] = 1
m = int(input())
for i in range(m):
    s = input()
    try:
        cnt[s] -= 1
    except:
        cnt[s] = -1

for i in cnt.values():
    ans = max(ans, i)
print(ans)

Solution (Python):
d = {}

N = int(input())
for i in range(N):
    s = input()
    d[s] = d.get(s, 0) + 1

M = int(input())
for i in range(M):
    t = input()
    d[t] = d.get(t, 0) - 1

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

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

Solution (Python):
n = int(raw_input())
s = []
t = []
for i in range(n):
	s.append(str(raw_input()))
m = int(raw_input())
for i in range(m):
	t.append(str(raw_input()))
s_uni = list(set(s))
count = 0
for i in range(len(s_uni)):
	tmp = s.count(s_uni[i]) - t.count(s_uni[i])
	count = max(count, tmp)
print count

Solution (Python):
n = int(input())
a = [input() for i in range(n)]
m = int(input())
b = [input() for i in range(m)]

from collections import Counter

c = Counter(a)
d = Counter(b)

max = 0

for key, value in c.items():
    if value - d[key] > max:
        max = value - d[key]

print(max)

Solution (Python):


N = int(input())
input_Blue = [input() for i in range(N)]

M = int(input())
input_Red = [input() for j in range(M)]

dict_Blue = {}
for str_Blue in input_Blue:
  dict_Blue[str_Blue] = dict_Blue.get(str_Blue,0) + 1

dict_Red = {}
for str_Red in input_Red:
  dict_Red[str_Red] = dict_Red.get(str_Red,0) + 1

for Blue_Key in dict_Blue.keys():
    if Blue_Key in dict_Red.keys():
      dict_Blue[Blue_Key] = dict_Blue[Blue_Key] - dict_Red[Blue_Key]

if max(dict_Blue.values()) < 0 :
       print(0)
else:
       print(max(dict_Blue.values()))

Solution (Python):
import collections
N = int(input())
Red_list = []
Blue_list = []
max = 0
for i in range(N):
    s = str(input())
    Red_list.append(s)
M = int(input())
for j in range(M):
    t = str(input())
    Blue_list.append(t)
count_red = collections.Counter(Red_list)
count_blue = collections.Counter(Blue_list)
result = count_red - count_blue
lists = list(result.values())
for i in range(len(lists)):
    if max < lists[i]:
        max = lists[i]
print(max)

Solution (Python):
ans = {}
N = int(input())
for _ in range(N):
  S = input()
  if S in ans:
    ans[S] += 1
  else:
    ans[S] = 1
    
N = int(input())
for _ in range(N):
  S = input()
  if S in ans:
    ans[S] -= 1
  else:
    ans[S] = -1

maxans = 0
for key in ans.keys():
  maxans = max(maxans, ans[key])
print(maxans)

Solution (Python):
n=int(input())
s=[]
for i in range(n):
    s.append(str(input()))
m=int(input())
t=[]
for i in range(m):
    t.append(str(input()))

ln=s+t
ans=[]
for i in range(len(ln)):
    ctr=0
    test=ln[i]
    for k in range(n):
        if s[k]==test:
            ctr+=1
    for j in range(m):
        if t[j]==test:
            ctr-=1
    ans.append(ctr)

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

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


ans=[0]+[s.count(i)-t.count(i) for i in set(s)]
print(max(ans))

Solution (Python):
N = int(input())
S =[input() for _ in range(N)]
M= int(input())
T =[input() for _ in range(M)]

counts = []
for si in S:
    count = 0
    for s in S:
        if s == si:
            count+=1
    for t in T:
        if t == si:
            count -=1
    counts.append(count)

max_count = max(counts)
if max_count < 0:
    print(0)
else:
    print(max_count)

Solution (Python):
n = int(input())

words = {"":0}
for i in range(n):
  s = input()
  if s not in words:
    words[s] = 1
  else:
    words[s] += 1
  
m = int(input())
for i in range(m):
  s = input()
  if s not in words:
    words[s] = -1
  else:
    words[s] -= 1

print(max(words.values()))

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

st = list(set(s + t))
sl = list(map(lambda x : s.count(x), st))
tl = list(map(lambda x : t.count(x), st))

ans = []
for i in range(len(st)):
    ans.append(sl[i] - tl[i])
print(max(max(ans), 0))

Solution (Python):
a=[]
for i in range(int(input())):
  a+=[input()]
b=[]
for i in range(int(input())):
  b+=[input()]
ans=0
for i in range(len(a)):
  ans=max(ans,a.count(a[i])-b.count(a[i]))
print(ans)

Solution (Python):

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()

money = [0] * n

for i in range(n):
    money[i] += 1
    for j in range(i+1,n):
        if s[i] == s[j]:
            money[i] += 1
    for j in range(m):
        if s[i] == t[j]:
            money[i] -= 1

money.sort()

print(max(0,money[-1]))

Solution (Python):
N = int(input())
s = []
mozi = set()
for i in range(N):
  S =input()
  s.append(S)
  mozi.add(S)
M = int(input())
t = []
for i in range(M):
  t.append(input())
ans = 0
for elem in mozi:
    cur = 0
    for i in range(N):
        if elem == s[i]:
            cur += 1
    for j in range(M):
        if elem == t[j]:
            cur -=1
    ans = max(ans,cur)

print(ans)

Solution (Python):
import collections
n = int(input())
s = []
for _ in range(n):
    s.append(input())
m = int(input())
t = []
for _ in range(m):
    t.append(input())
s_ = collections.Counter(s)
t_ = collections.Counter(t)
a = []
for key in s_.keys():
    num = s_[key] - t_[key]
    a.append(num)
print(max(max(a),0))

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

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

SD = {}
for s in S:
    SD[s] = SD.get(s, 0) + 1

TD = {}
for t in T:
    TD[t] = TD.get(t, 0) + 1




ans = 0
for k, v in SD.items():
    
    ans = max(ans, v - TD.get(k, 0))

print(ans)

Solution (Python):
s, t = [], []

N = int(input())
for i in range(N):
  s.append(input())
M= int(input())
for i in range(M):
  t.append(input())
  
dic = list(set(s + t))
result = 0
for i in range(len(dic)):
  result = max(result, s.count(dic[i]) - t.count(dic[i]))
print(result)

Solution (Python):
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
S = set(s)
res = 0
ans = 0
for i in S:
    res = s.count(i)-t.count(i)
    ans = max(ans,res)
print(ans)

Solution (Python):
N = int(input())
cards = {}
for _ in range(N):
    fraise = input()
    if not fraise in cards:
        cards[fraise] = 1
    else:
        cards[fraise] += 1
M = int(input())
for _ in range(M):
    fraise = input()
    if not fraise in cards:
        cards[fraise] = -1
    else:
        cards[fraise] -= 1
max = 0
for card in cards:
    if cards[card] > max:
        max = cards[card]
print(max)

Solution (Python):
import collections
n = int(input())
s_list = [input() for _ in range(n)]
m = int(input())
t_list = [input() for _ in range(m)]

cs = dict(collections.Counter(s_list))
ct = dict(collections.Counter(t_list))

count_list = []
for k,v in cs.items():
    if k in ct:
        if ct[k] < v:
            count_list.append(v-ct[k])
    else:
        count_list.append(v)

print(max(count_list) if len(count_list)!= 0 else 0)

Solution (Python):
N = int(input())
plus = []
for _ in range(N):
    plus.append(input())
M = int(input())
minus = []
for _ in range(M):
    minus.append(input())
def counter(array):
    from collections import Counter
    return list(Counter(array).most_common())
plus = counter(plus)
minus = counter(minus)
ans = 0
for x in plus:
    for y in minus:
        if x[0] == y[0]:
            ans = max(ans,x[1] - y[1])
            break
    else:
        ans = max(ans,x[1])
print(ans)

Solution (Python):

n = int(input())
s = {}
for _ in range(n):
    c = input()
    if c not in s:
        s[c] = 0
    s[c] += 1

m = int(input())
t = {}
for _ in range(m):
    c = input()
    if c not in t:
        t[c] = 0
    t[c] += 1

res = 0
for k in s.keys():
    r = s[k]
    if k in t:
        r -= t[k]
    res = max(res, r)

for k in t.keys():
    r = 0
    if k in s:
        r += s[k]
    r -= t[k]
    res = max(res, r)

print(res)

Solution (Python):
N = int(input())
sn = [input() for _ in range(N)]
M = int(input())
tn = [input() for _ in range(M)]

str_count = {}
for s in sn:
    if s in str_count:
        str_count[s] += 1
    else:
        str_count[s] = 1
for t in tn:
    if t in str_count:
        str_count[t] -= 1
    else:
        str_count[t] = -1

m = max(str_count.values())
print(m if m > 0 else 0)

Solution (Python):
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for j in range(M)]
a = 0
for i in range(len(s)):
    a = max(a, s.count(s[i]) - t.count(s[i]))
print(a)

Solution (Python):
n=int(input())
br=[]
re=[]
for i in range(n):
    s=input()
    br.append(s)

m=int(input())
for i in range(m):
    t=input()
    re.append(t)
count=[0]
for i in range(n):
    brcou=0
    for j in range(n):
        if br[i]==br[j]:
            brcou+=1
    for k in range(m):
        if br[i]==re[k]:
            brcou-=1
    count.append(brcou)
print(max(count))

Solution (Python):
from sys import stdin
n = int(stdin.readline().rstrip())
sl = [stdin.readline().rstrip() for _ in range(n)]
m = int(stdin.readline().rstrip())
tl = [stdin.readline().rstrip() for _ in range(m)]
ans=[sl.count(s) - tl.count(s) for s in set(sl)]
if max(ans) < 0:
    print(0)
else:
    print(max(ans))

Solution (Python):
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]
 
result = 0
for ch in s:
    score = s.count(ch) - t.count(ch)
    if result < score:
        result = score
print(result)

Solution (Python):
n=int(input());a=[input()for i in range(n)];m=int(input());b=[input()for i in range(m)];ans=0
for i in a:ans=max(a.count(i)-b.count(i),ans)
print(ans)

Solution (Python):
n = int(input())
blue = []
red = []
score_list = []
for i in range(n):
    blue.append(input())
m = int(input())
for j in range(m):
    red.append(input())
for value in blue:
    score = 0
    for s in blue:
        if value == s:
            score += 1
    for t in red:
        if value == t:
            score -= 1
    if score not in score_list:
        score_list.append(score)
if max(score_list) < 0:
    print(0)
else:
    print(max(score_list))

Solution (Python):
from random import randint






class ListNode:
    def __init__(self, key, value, next_=None):
        self.key, self.value, self.next = key, value, next_


class HashMapLinkedList:
    def __init__(self):
        self.__head = ListNode(None, None)
        self.__tail = self.__head
        self.__num_items = 0

    def __repr__(self):
        return "->" +  " -> ".join(str(kv_pair) for kv_pair in self)

    def __len__(self):
        return self.__num_items

    def find(self, key):
        cur_node = self.__head.next
        while cur_node:
            if cur_node.key == key:
                return cur_node
            cur_node = cur_node.next
        raise ValueError(key if type(key) != str else "'" + key + "'")

    def insert(self, key, value):
        
        try:
            node = self.find(key)
            node.value = value
            return 0
        
        except ValueError:
            self.__tail.next = ListNode(key, value)
            self.__tail = self.__tail.next
            self.__num_items += 1
            return 1

    def delete(self, key):
        cur_node = self.__head
        while cur_node.next:
            if cur_node.next.key == key:
                cur_node.next = cur_node.next.next
                self.__num_items -= 1
                return
            cur_node = cur_node.next

    def __iter__(self):
        self._cur_node = self.__head.next
        return self

    def __next__(self):
        if not self._cur_node:
            raise StopIteration()
        key, value = self._cur_node.key, self._cur_node.value
        self._cur_node = self._cur_node.next
        return (key, value)


class HashMap:
    SCALE_FACTOR = 2
    SHRINKAGE_THRESHOLD = 4
    PRIME_NUMBER = (1 << 31) - 1
    def __init__(self, capacity=16):
        self.__arr = [HashMapLinkedList() for _ in range(capacity)]
        self.__capacity = capacity
        self.__num_items = 0
        self.__param1 = randint(0, self.PRIME_NUMBER - 1)
        self.__param2 = randint(0, self.PRIME_NUMBER - 1)

    def __repr__(self) -> str:
        kv_pairs = [kv_pair for linked_list in self.__arr for kv_pair in linked_list]
        return "{" + ", ".join((str(key) if type(key) != str else "'" + key + "'") \
            + ": " + str(value) for key, value in kv_pairs) + "}"

    def __len__(self) -> int:
        return self.__num_items

    def _range_hash(self, prehash):
        """
        Converts an arbitrary integer to an integer within [0, self.__capacity).
        """
        return (self.__param1 * prehash + self.__param2) % self.__capacity
    
    def _resize(self, enlarge=True):
        if enlarge:
            self.__capacity *= self.SCALE_FACTOR
        else:
            self.__capacity //= self.SCALE_FACTOR
        new_arr = [HashMapLinkedList() for _ in range(self.__capacity)]
        for linked_list in self.__arr:
            for key, value in linked_list:
                new_idx = self._range_hash(hash(key))
                new_arr[new_idx].insert(key, value)
        self.__arr = new_arr

    def insert(self, key, value):
        """
        Inserts an item whose key and value are key and value.
        """
        idx = self._range_hash(hash(key))
        self.__num_items += self.__arr[idx].insert(key, value)
        
        if self.__num_items == self.__capacity:
            self._resize(enlarge=True)

    def __setitem__(self, key, value):
        self.insert(key, value)

    def find(self, key):
        """
        Find the corresponding value given a key.
        """
        idx = self._range_hash(hash(key))
        node = self.__arr[idx].find(key)
        return node.value

    def __getitem__(self, key):
        return self.find(key)
    
    def __contains__(self, key):
        try:
            self.find(key)
            return True
        except ValueError:
            return False

    def delete(self, key):
        """
        Delete the item whose key is key.
        """
        idx = self._range_hash(hash(key))
        self.__arr[idx].delete(key)
        self.__num_items -= 1
        
        if self.__num_items * self.SHRINKAGE_THRESHOLD <= self.__capacity:
            self._resize(enlarge=False)

    def __delitem__(self, key):
        self.delete(key)
    
    def keys(self):
        for linked_list in self.__arr:
            for k, _ in linked_list:
                yield k
    
    def values(self):
        for linked_list in self.__arr:
            for _, v in linked_list:
                yield v
    
    def items(self):
        for linked_list in self.__arr:
            for k, v in linked_list:
                yield (k, v)


N = int(input())
counter = HashMap()

for _ in range(N):
    s = input()
    if s not in counter:
        counter[s] = 1
    else:
        counter[s] += 1

M = int(input())
for _ in range(M):
    s = input()
    if s in counter:
        counter[s] -= 1

max_profit = 0
for profit in counter.values():
    max_profit = max(max_profit, profit)
print(max_profit)

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

ans = 0
for i in s:
    yen = s.count(i) - t.count(i)
    if ans <= yen:
        ans = yen

print(ans)

Solution (Python):



import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

c = Counter()
N = int(input())
for _ in range(N):
    s = input()
    c[s] += 1
M = int(input())
for _ in range(M):
    s = input()
    c[s] -= 1
print(max(list(c.values()) + [0]))

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

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

result = 0
for s in S:
    score = S.count(s) - T.count(s)
    if result < score:
        result = score
print(result)

Solution (Python):
n=int(input())
dic={}
for i in range(n):
    s=input()
    if s in dic:
        dic[s]+=1
    else:
        dic[s]=1
m=int(input())
for j in range(m):
    s=input()
    if s in dic:
        dic[s]-=1
print(max(max(dic.values()),0))

Solution (Python):
from collections import Counter


def solve(string):
    n, *rest = string.split()
    n = int(n)
    count = Counter(rest[:n])
    m = rest[n]
    count -= Counter(rest[n + 1:])
    return str(max(max(count.values()), 0)) if len(count) > 0 else "0"


if __name__ == '__main__':
    n = int(input())
    ins = '{}\n'.format(n) + '\n'.join([input() for _ in range(n)])
    m = int(input())
    print(solve(ins + '\n{}\n'.format(m) + '\n'.join([input() for _ in range(m)])))

Solution (Python):
def solve(string):
    count = dict([])
    n, *rest = string.split()
    n = int(n)
    blues = rest[:n]
    m = rest[n]
    reds = rest[n + 1:]
    for key in blues:
        if key in count:
            count[key] += 1
        else:
            count[key] = 1
    for key in reds:
        if key in count:
            count[key] -= 1
        else:
            count[key] = -1
    num = 0
    for k, v in count.items():
        if num < v:
            num = v
    return str(num)


if __name__ == '__main__':
    n = int(input())
    ins = '{}\n'.format(n) + '\n'.join([input() for _ in range(n)])
    m = int(input())
    print(solve(ins + '\n{}\n'.format(m) + '\n'.join([input() for _ in range(m)])))

Solution (Python):
n=int(input())
s=[]
for i in range(n):
  k=input()
  s.append(k)
m=int(input())
t=[]
for i in range(m):
  k=input()
  t.append(k)
check=[]
ans=[0]
for i in s:
  if i in check:
    continue
  ans.append(s.count(i)-t.count(i))
  check.append(i)
print(max(ans))

Solution (Python):
import collections

n = int(input())
s =[]
for i in range(n):
    s.append(input())

m = int(input())
t = []
for l in range(m):
    t.append(input())

s_counter = collections.Counter(s)
t_counter = collections.Counter(t)

x_max = 0
for n in s_counter.keys():
    x_max = max(x_max, s_counter[n] - t_counter[n])

print(x_max)

Solution (Python):
N = int(input())
ss = [ input() for _ in range(N)]
M = int(input())
ts = [ input() for _ in range(M)]

result = {}
for s in ss:
    if not s in result:
        result[s] = 0
    result[s] += 1
for t in ts:
    if not t in result:
        result[t] = 0
    result[t] -= 1
ans = max(0, max(result.values()))

print(ans)

Solution (Python):
N=int(input())
blue={}
for _ in range(N):
    s=input()
    if s in blue.keys():
        blue[s]+=1
    else:
        blue[s]=1
M=int(input())
red={}
for _ in range(M):
    t=input()
    if t in red.keys():
        red[t]+=1
    else:
        red[t]=1
ans=0
for k in blue.keys():
    tmp=blue[k]
    if k in red.keys():
        tmp-=red[k]
    ans=max(ans,tmp)
print(ans)

Solution (Python):
from collections import defaultdict

N = int(input())
d1 = defaultdict(int)
d2 = defaultdict(int)
for i in range(N):
    d1[input()] += 1
M = int(input())
for i in range(M):
    d2[input()] += 1
ans = []
for x in d1:
    ans.append(d1[x]-d2[x])
print(max(max(ans), 0))

Solution (Python):

import sys



def solve(lines):
    N = int(lines.pop(0))
    NLIST = {}
    for i in range(N):
        s = lines.pop(0)
        if s in NLIST:
            NLIST[s] += 1
        else:
            NLIST[s] = 1

    M = int(lines.pop(0))
    for i in range(M):
        s = lines.pop(0)
        if s in NLIST:
            NLIST[s] -= 1
        else:
            NLIST[s] = -1
    print(max(max(NLIST.values()), 0))

lines = [x.strip() for x in sys.stdin.readlines()]




solve(lines)

Solution (Python):
N = int(input())
s = []
for i in range(N):
    s.append(input())
M = int(input())
t = []
for i in range(M):
    t.append(input())
ans = []
for i in range(N):
    if s.count(s[i]) - t.count(s[i]) > 0:
        Ans = s.count(s[i]) - t.count(s[i])
        ans.append(Ans)
    else:
        ans.append(0)
print(max(ans))

Solution (Python):
import numpy as np
from collections import Counter
ans=[]
N=int(input())
a=Counter([input() for _ in range(N)])
M=int(input())
b=Counter([input() for _ in range(M)])
for k, v in a.items():
  if k in b.keys():
    ans.append(v-b[k])
  else:
    ans.append(v)
print(max(0, *ans))

Solution (Python):



import sys

s = {}
t = {}
for _ in range(int(input())):
  st = str(input())
  if st not in s:
    s[st] = 1
  else:
    s[st] += 1
for _ in range(int(input())):
  st = str(input())
  if st not in t:
    t[st] = 1
  else:
    t[st] += 1


ans = 0
for st in s:
  if st not in t:
    ans = max(ans,s[st])
  else:
    ans = max(ans,s[st]-t[st])

print(ans)

Solution (Python):
from collections import defaultdict
cards = defaultdict(int)
N = int(input())
for i in range(N):
    s = input()
    cards[s] += 1
M = int(input())
for i in range(M):
    t = input()
    cards[t] -= 1

print(max(0, max(list(cards.values()))))

Solution (Python):
n=int(input())
dic={}
for i in range(n):
    s=input()
    if s in dic:
        dic[s]+=1
    else:
        dic[s]=1
m=int(input())
for i in range(m):
    s=input()
    if s in dic:
        dic[s]-=1
print(max(max(dic.values()),0))

Solution (Python):
N=int(input())
words={}
for i in range(N):
  c = input()
  if c not in words:
    words[c]=1
  else:
    words[c]+=1
M=int(input())
for i in range(M):
  c = input()
  if c not in words:
    words[c]=-1
  else:
    words[c]-=1
print(max(0,max(list(words.values()))))

Solution (Python):
from collections import defaultdict
N = int(input())
gain_set = defaultdict(int)
for i in range(N):
    s = input()
    gain_set[s] += 1

M = int(input())
lose_set = defaultdict(int)
for i in range(M):
    s = input()
    lose_set[s] += 1


max_count = 0
for (k, v) in gain_set.items():
    c = lose_set[k]
    d = v - c
    if max_count < d:
        max_count = d

print(max_count)

Solution (Python):
from collections import defaultdict
dd = defaultdict(int)
n = int(input())
for s in (input() for _ in range(n)):
  dd[s] += 1
m = int(input())
for s in (input() for _ in range(m)):
  dd[s] -= 1
print(max(0, max(dd.values())))

Solution (Python):
import numpy as np

N = np.int(input())
slist = [input() for _ in range(N)]
M = np.int(input())
tlist = [input() for _ in range(M)]
sslist = np.array(list(set(slist)))
number = np.zeros(len(sslist))
for i in range(len(sslist)):
    number[i] = np.sum(slist.count(sslist[i])) - np.sum(tlist.count(sslist[i]))
answer = np.int(np.max(number))  
print(np.max((answer, 0)))

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

ans = 0

card = set(s + t)

for i in card:
    tmp = 0
    tmp += s.count(i)
    tmp -= t.count(i)
    ans = max(tmp, ans)

print(ans)

Solution (Python):
import collections
l = collections.Counter()
n = int(input())
for i in range(n):
    k = input()
    l[k] += 1
n = int(input())
for i in range(n):
    k = input()
    l[k] -= 1
l = l.most_common()
print(l[0][1] if l[0][1] >= 0 else 0)

Solution (Python):
import collections

n = int(input())
blueCards = [input() for i in range(n)]
blueCards = collections.Counter(blueCards)
m = int(input())
redCards = [input() for i in range(m)]
redCards = collections.Counter(redCards)

diff = blueCards - redCards
print(diff.most_common()[0][1]) if diff else print(0)

Solution (Python):
N = int(input())
s = sum([input().split() for _ in range(N)],[])
M = int(input())
t = sum([input().split() for _ in range(M)],[])
getmax = 0

for i in range(N):
    tmp = s.count(s[i])-t.count(s[i])
    if tmp > getmax:
        getmax = tmp

print(max(getmax,0))

Solution (Python):

n = int(input())
s = list(map(str,[input() for i in range(n)]))
m = int(input())
t = list(map(str,[input() for i in range(m)]))
answer = 0

for i in range(n):
	aka = s.count(s[i])
	ao = t.count(s[i])
	answer = max(answer, (aka-ao))
print(answer)

Solution (Python):
n=int(input())
a=[]
b=[]
c=[0]
for i in range(n):
    a.append(input())
m=int(input())
for i in range(m):
    b.append(input())
for d in a:
    ans=a.count(d)-b.count(d)
    c.append(ans)
print(max(c))

Solution (Python):
n = int(input()) 
s = []
t = []

for i in range(n):
	s.append(input())
  
m = int(input())

for i in range(m):
	t.append(input())
    
max = 0

for i in range(n):
	k = s.count(s[i]) - t.count(s[i])
	if max < k:
		max = k
        
print(max)

Solution (Python):

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


D = {}
for i in range(N):
  if s[i] in D.keys():  
    D[s[i]] += 1
  else:                 
    D[s[i]] = 1
    
for i in range(M):
  if t[i] in D.keys():  
    D[t[i]] -= 1
  
ans = 0  
for v in D.values():  
  ans = max(ans, v)


print(ans)

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

max_score = 0
for s_ in s:
    score = s.count(s_) - t.count(s_)
    if score > max_score:
        max_score = score

print(max_score)

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

S = set(s)
T = set(t)
cands = []

for i in S:
    cands.append(s.count(i)-t.count(i))

print(max(max(cands), 0))

Solution (Python):
from collections import Counter

lst1 = [input() for _ in range(int(input()))]
lst2 = [input() for _ in range(int(input()))]

c = Counter(lst1)
c.subtract(Counter(lst2))
n = max(c.values())
print(max(0, n))

Solution (Python):
import collections
import itertools
import numpy as np
import sys
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()


N = I()
s = [S() for i in range(N)]
M = I()
t = [S() for i in range(M)]
dic = {}

for i in s:
    if i not in dic:
        dic[i] = 1
    else:
        dic[i] += 1

for i in t:
    if i in dic:
        dic[i] -= 1


cnt = list(dic.values())
cnt.sort()
if cnt == "" or cnt[-1] < 0:
    print(0)
else:
    print(cnt[-1])

Solution (Python):
n=int(input())
hoge=[]
for i in range(n):
  hoge.append(input())
m=int(input())
huga=[]
for i in range(m):
  huga.append(input())
ans=[]
ans.append(0)
for i in range(len(hoge)):
  ans.append(hoge.count(hoge[i])-huga.count(hoge[i]))

print(max(ans))

Solution (Python):
def two_color_card_games(N: int, S: list, M: int, T: list) -> int:
    
    d = {'': 0}
    for s in S:
        d.setdefault(s, 0)
        d[s] += 1

    for t in T:
        d.setdefault(t, 0)
        d[t] -= 1

    return max(d.values())


if __name__ == "__main__":
    N = int(input())
    S = [input() for _ in range(N)]
    M = int(input())
    T = [input() for _ in range(M)]
    ans = two_color_card_games(N, S, M, T)
    print(ans)

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

count = 0
for i in set(s):
  count = max(count, s.count(i)-t.count(i))
print(count)

Solution (Python):
n=int(input())
s=list([input() for i in range(n)])
m=int(input())
t=list([input() for i in range(m)])
a=[]
for i in range(len(s)):
    a.append(s.count(s[i])-t.count(s[i]))
a.sort()
print(max(0,a[-1]))

Solution (Python):
N = int(input())
card = {}
for i in range(N):
    temp = input()
    if temp in card:
        card[temp] += 1
    else:
        card[temp] = 1
M = int(input())
for i in range(M):
    temp = input()
    if temp in card:
        card[temp] -= 1

vals = card.values()
print(str(max(0, max(vals))))

Solution (Python):
import collections
N = int(input())
Ss= [input() for i in range(N)]
M = int(input())
Mm = [input() for i in range(M)]
Scounter = collections.Counter(Ss)
Mcounter = collections.Counter(Mm)
Ansdic = {}
for s,value in Scounter.items():
    if s not in Ansdic:
        Ansdic[s]=value
    else:
        Ansdic[s]+=value
for m,value in Mcounter.items():
    if m not in Ansdic:
        Ansdic[m]=-value
    else:
        Ansdic[m]-=value
print(max(0,max(Ansdic.values())))

Solution (Python):
from collections import Counter

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

s = Counter(S)
s[0] = 0
for t in T:
  if(t in s):
    s[t] -= 1
print(max(s.values()))

Solution (Python):
N = int(input())
all_str = []
dic_s = {}
dic_t = {}
for i in range(N):
  s = input()
  all_str.append(s)
  if(s in dic_s):
    dic_s[s] += 1
  else:
    dic_s[s] = 1
    dic_t[s] = 0

M = int(input())
for i in range(M):
  t = input()
  if(t in dic_t):
    dic_t[t] += 1
  else:
    dic_t[t] = 1
  if(t in dic_s):
    dummy = 0
  else:
    dic_s[t] = 0
    all_str.append(t)
 
point = []
for i in range(len(all_str)):
  point.append(dic_s[all_str[i]] - dic_t[all_str[i]])
if(max(point)<=0):
  print(0)
else:
  print(max(point))

Solution (Python):
N = int(input())
blue = [input() for i in range(N)]
M = int(input())
red = [input() for i in range(M)]
blue_dict = {}
red_dict = {}
for s in blue:
    if s not in blue_dict:
        blue_dict[s] = 1
    else:
        blue_dict[s] += 1

for t in red:
    if t not in red_dict:
        red_dict[t] = 1
    else:
        red_dict[t] += 1

ans = 0
for key in blue_dict:
    if key in red_dict:
        ans = max(ans, blue_dict[key] - red_dict[key])
    else:
        ans = max(ans, blue_dict[key])
print(ans)

Solution (Python):
N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]

v = 0
for s in set(S):
    v = max(v, S.count(s)-T.count(s))
print(v)

Solution (Python):
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
score = []
for a in s:
    score.append(s.count(a)-t.count(a))
print(max(max(score),0))