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



def main():
    N = int(input())
    s = [input() for _ in range(N)]
    M = int(input())
    t = [input() for _ in range(M)]
    y = 0
    for ss in set(s):
        yy = s.count(ss) - t.count(ss)
        if y < yy:
            y = yy
    print(y)


main()

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

M = int(input())
T = []
for i in range(M):
    t = input()
    T.append(t)

ans = -1
x = 0
for i in S:
    x = S.count(i) - T.count(i)
    ans = max(ans, x)

if ans < 0:
    ans = 0

print(ans)

Solution (Python):
blue = []
red = []
ans = 0
n = int(input())
for i in range(n):
  blue.append(input())
m = int(input())
for j in range(m):
  red.append(input())
word = set(blue)
for k in word:
  c = blue.count(k) - red.count(k)
  ans = max(ans,c)
print(ans)

Solution (Python):
import sys
input = sys.stdin.readline

N=int(input())
pts = dict()
for _ in range(N):
    s = input().strip()
    if not pts.get(s):
        pts[s] = 0
    pts[s] += 1

M=int(input())
for _ in range(M):
    t = input().strip()
    if not pts.get(t):
        pts[t] = 0
    pts[t] -= 1

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

Solution (Python):
N = int(input())
L = list(input() for i in range(N))
M = int(input())
T = list(input() for i in range(M))

Li = []
for i in set(L):
    if i not in T:
        K = 0
    else:
        K = T.count(i)
    Li.append(L.count(i) - K)

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

Solution (Python):
N = int(input())
Ns = []
for i in range(N):
  Ns.append(input())
  
M = int(input())
Ms = []
for i in range(M):
  Ms.append(input())
  
Ws = list(set(Ns + Ms))

As = []
for i in Ws:
  ans = 0
  for j in Ns:
    if i == j:
      ans += 1
  for j in Ms:
    if i == j:
      ans -= 1
  As.append(ans)
  
print(max(max(As), 0))

Solution (Python):
from collections import Counter

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

c = Counter(s).most_common()
d = Counter(t)

p = -1000

for k, v in c:
    p = max(p, v - d[k])

print(max(p, 0))

Solution (Python):
def resolve():
    n = int(input())
    blue_cards = list()
    for i in range(n):
        card = input()
        blue_cards.append(card)
    blue_cards = sorted(blue_cards)
    m = int(input())
    red_cards = list()
    for i in range(m):
        card = input()
        red_cards.append(card)
    red_cards = sorted(red_cards)
    former = ""
    cards_points = []
    for card in blue_cards:
        point = 0
        if former == card:
            continue
        else:
            p = blue_cards.count(card)
            m = red_cards.count(card)
            point = p - m
            cards_points.append(point)
            former = card
    cards_points = sorted(cards_points)
    if cards_points[-1] < 0:
        print(0)
    else:
        print(cards_points[-1])
resolve()

Solution (Python):
from collections import defaultdict


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


dic=defaultdict(int)
for i in range(n):
    dic[s[i]]+=1

for i in range(m):
    dic[t[i]]-=1

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

Solution (Python):
s_dict = dict()
n = int(input())
for _ in range(n):
    s = input()
    if not s in s_dict:
        s_dict[s] = 1
    else:
        s_dict[s] += 1
n = int(input())
for _ in range(n):
    s = input()
    if s in s_dict:
        s_dict[s] -= 1
print(max(max(s_dict.values()), 0))

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

Solution (Python):
n=int(input())
import sys
mod=10**9+7 ; inf=float("inf")
from math import sqrt, ceil
from collections import deque, Counter, defaultdict 
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from decimal import ROUND_HALF_UP,Decimal  
  
from functools import lru_cache
from bisect import bisect_left as bileft, bisect_right as biright






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

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    s = [SS() for _ in range(N)]
    M = I()
    t = [SS() for _ in range(M)]

    cnt_s = collections.Counter(s)
    cnt_t = collections.Counter(t)
    ans = max([max(cnt_s[i] - cnt_t[i], 0) for i in (cnt_s.keys() | cnt_t.keys())])
    print(ans)

if __name__ == '__main__':
    resolve()

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

s_l = list(set(s))
cnt = []

for i in s_l:
    cnt.append(s.count(i)-t.count(i))
    
if max(cnt) <= 0:
    print(0)
else:
    print(max(cnt))

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:
    ans = max(ans,s.count(i)-t.count(i))

print(ans)

Solution (Python):
n = int(input())
a = {}
for i in range(n):
    s = str(input())
    if s in a.keys():
        a[s] = a[s] + 1
    else:
        a[s] = 1
        
m = int(input())
for i in range(m):
    t = str(input())
    if t in a.keys():
        a[t] = a[t] - 1
    else:
        a[t] = -1
if max(a.values()) >= 0:
    print(max(a.values()))
elif max(a.values()) < 0:
    print(0)

Solution (Python):
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy


import heapq
sys.setrecursionlimit(10**6)

INF = 10**18
import bisect
import statistics
mod = 10**9+7



N = int(input())
s = defaultdict(int)

for i in range(N):
    s[input()] += 1

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

m = 0
for p in list(s.keys()):
    m = max(m, s[p] - t[p])
print(m)

Solution (Python):
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)))))

Solution (Python):
Blue=[]
Red=[]

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

ans=0
for a in Blue:
    plus = Blue.count(a)
    minus = Red.count(a)
    point = plus - minus
    ans = max(ans, point)
print(ans)

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

Solution (Python):

N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]
s_set = list(set(s))

maxim = 0
for i in s_set:
    count = 0
    for j in s:
        if i == j:
            count += 1
    for k in t:
        if i == k:
            count -= 1
    if maxim<count:
        maxim = count
print(maxim)

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


dic = {}

for i in range(n):
  if s[i] not in dic:
    dic[s[i]] = 0
  dic[s[i]] += 1


for i in range(m):
  if t[i] in dic:
    dic[t[i]] -= 1


max_dic = max(max(dic.values()), 0)

print(max_dic)

Solution (Python):
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
l = []
ans = -1000
for i in range(n):
    if s[i] not in l:
        l.append(s[i])
        pnt = s.count(s[i]) - t.count(s[i])
        ans = max(ans, pnt)
if ans < 0:
    print(0)
else:
    print(ans)

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

maxCount = 0
for i in s:
    if s.count(i) - t.count(i) > maxCount:
        maxCount = s.count(i) - t.count(i)
print(maxCount)

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

count_max = 0
for j in a:
  if (a.count(j) - b.count(j)) > count_max:
    count_max = a.count(j) - b.count(j)
print(count_max)

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

count_max = 0
for j in a:
  if (a.count(j) - b.count(j)) > count_max:
    count_max = a.count(j) - b.count(j)
print(count_max)

Solution (Python):
N = int(input())
s = {}
for i in range(N):
    str = input()
    if str in s:
        s[str]+=1
    else:
        s[str] = 1
M = int(input())
for j in range(M):
    str = input()
    if str in s:
        s[str]-= 1
    else:
        s[str] = -1
if max(s.values()) < 0:
    print(0)
else:
    print(max(s.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())
wordlist=list(set(s))+list(set(t))
wordcount=[]
for i in range(len(wordlist)):
    wordcount.append(s.count(wordlist[i])-t.count(wordlist[i]))
if max(wordcount)>=1:
    print(max(wordcount))
else:
    print(0)

Solution (Python):
from collections import Counter as C

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

points = dict(blue)
for rk, rv in red.items():
    points[rk] = points.get(rk, 0) - rv
else:
    print(max(0, max(points.values())))

Solution (Python):
import collections

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

s_counter = collections.Counter(s)
t_counter = collections.Counter(t)
t_keys = list(t_counter.keys())
ans = []

for key in s_counter.keys():
    if key in t_keys:
        ans.append(int(s_counter[key]) - int(t_counter[key]))
    else:
        ans.append(s_counter[key])
max_ans = max(ans)
if max_ans < 0:
    print(0)
else:
    print(max_ans)

Solution (Python):
N = int(input())
s = [(input()) for _ in range(N)] + ['0']
M = int(input())
t = [(input()) for _ in range(M)]
s.sort(reverse=True)
sc = 0
ans = 0
for i in range(N) :
    sc += 1
    if s[i] == s[i+1] :
        continue
    tc = t.count(s[i])
    ans = max(ans,sc-tc)
    sc = 0

print(ans)

Solution (Python):
n = int(input())
blue = [input() for _ in range(n)]

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

price_max = 0
for a in blue:
    if (blue.count(a) - red.count(a)) > price_max:
        price_max = blue.count(a) - red.count(a)
print(price_max)

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

s_set = list(set(s))
t_set = list(set(t))

ans = 0
for i in range(len(s_set)):
    y = 0
    for j in range(N):
        if s_set[i] == s[j]:
            y += 1
    for k in range(M):
        if s_set[i] == t[k]:
            y -= 1
    if y > ans:
      ans = y

print(ans)

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

rev_list = []
for i in range(len(s_list)):
    a = s_list.count(s_list[i])
    b = t_list.count(s_list[i])
    if a >= b:
        ans_num = a-b
    else:
        ans_num = 0
    rev_list.append(ans_num)
    
print(max(rev_list))

Solution (Python):
from collections import Counter

blue_cards = [input() for _ in range(int(input()))]
red_cards = Counter([input() for _ in range(int(input()))])

sources = set(blue_cards)
blue_cards = Counter(blue_cards)

result = 0
for x in sources:
  tmp = blue_cards[x]
  
  if x in red_cards:
    tmp -= red_cards[x]
  
  result = max(result, tmp)
  
print(result)

Solution (Python):
from collections import Counter

n = int(input())
S = [input() for _ in range(n)]
m = int(input())
T = [input() for _ in range(m)]

cnt_S = Counter(S)
cnt_T = Counter(T)
values, counts = zip(*cnt_S.most_common())

ans = 0
for i in range(len(values)):
    ans = max(ans, counts[i] - cnt_T[values[i]])
print(ans)

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

ans = 0
P = set(S)
for i in P:
    ans = max(ans,S.count(i)-T.count(i))

print(ans)

Solution (Python):
from collections import defaultdict

S = defaultdict(int)
T = defaultdict(int)

for _ in range(int(input())):
    S[input()] += 1

for _ in range(int(input())):
    T[input()] += 1

print(max(0, max([S[k] - T[k] for k, v in S.items()])))

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

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

sc = collections.Counter(s)
tc = collections.Counter(t)

ans = 0
for string, times in sc.items():
    if string in tc.keys():
        ans = max(ans, times - tc[string])
    else:
        ans = max(ans, times)
        
        
print(ans)

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

ans=0
for i in range(N):
    x=s.count(s[i])
    y=t.count(s[i])
    if ans<x-y:
        ans=x-y
print(ans)

Solution (Python):
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
blue = []
red = []
for i in range(n):
    s = input()
    blue.append(s)
m = int(input())
for i in range(m):
    t = input()
    red.append(t)
for i in range(n):
    c = blue[i]
    chk = blue.count(c) - red.count(c)
    if chk > ans:
        ans = chk
print(ans)

Solution (Python):
N = int(input()) 
S = [input() for _ in range(N)]
new_S = set(S)
M = int(input()) 
T = [input() for _ in range(M)]
use = 0
for i in new_S:
    use1 = S.count(i) - T.count(i) 
    use = max(use,use1)

print(use)

Solution (Python):

import collections

N=input()

N=int(N)

aaa=[]

for i in range(N):
    a1=input()
    aaa.append(a1)


M=input()

M=int(M)


bbb=[]

for i in range(M):
    a1=input()
    bbb.append(a1)
    





c = collections.Counter(aaa)

d = collections.Counter(bbb)







dic2 = sorted((c-d).items(), key=lambda x:x[1], reverse=True)




if len(dic2)==0:
    print(0)
else:
    print(dic2[0][1])

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

ans = 0
for s in S:
  ans = max(ans, S.count(s)-T.count(s))

print(ans)

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

ans = 0

for s in S:
    point_S = S.count(s)
    point_T = T.count(s)
    ans = max(ans, point_S - point_T)

print(ans)

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

print(max(0, *[s.count(sn) - t.count(sn) for sn in set(s)]))

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

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

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

Solution (Python):
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 range(N):
    ans = max(ans, s.count(s[i])-t.count(s[i]))
print(max(ans,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
for i in range(N):
    ans = max(ans, s.count(s[i])-t.count(s[i]))
print(ans)

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

count = 0

for i in s:
    v = s.count(i) - t.count(i)
    if v >= count:
        count = v

print(count)

Solution (Python):



import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3
apple
orange
apple
1
grape"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """3
apple
orange
apple
5
apple
apple
apple
apple
apple"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1
voldemort
10
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """6
red
red
blue
yellow
yellow
red
5
red
red
yellow
green
blue"""
        output = """1"""
        self.assertIO(input, output)


def resolve():
    N = int(input())
    s = []
    for _ in range(N):
        s.append(input())
    M = int(input())
    t = []
    for _ in range(M):
        t.append(input())
    ans = 0
    for i in range(N):
        ans = max(s.count(s[i]) - t.count(s[i]), ans)
    print(ans)


if __name__ == "__main__":
    
    resolve()

Solution (Python):



import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3
apple
orange
apple
1
grape"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """3
apple
orange
apple
5
apple
apple
apple
apple
apple"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1
voldemort
10
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """6
red
red
blue
yellow
yellow
red
5
red
red
yellow
green
blue"""
        output = """1"""
        self.assertIO(input, output)


def resolve():
    N = int(input())
    l = {}
    for _ in range(N):
        w = input()
        if w in l:
            l[w] += 1
        else:
            l[w] = 1
    M = int(input())
    for _ in range(M):
        w = input()
        if w in l:
            l[w] -= 1
        else:
            l[w] = -1
    print(max(max(l.values()), 0))


if __name__ == "__main__":
    
    resolve()

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

Solution (Python):
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 s:
    if s.count(i) - t.count(i) > ans:
        ans = s.count(i) - t.count(i)
print(ans)

Solution (Python):
from collections import defaultdict

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

d=defaultdict(int)
for x in s:
  d[x]+=1
for y in t:
  d[y]-=1

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

Solution (Python):
def calc(blue, red):
	lst = []
	
	for ch in blue:
		if ch in red:
			lst.append(blue[ch] - red[ch])
		else:
			lst.append(blue[ch])

	return max(lst)


def main():
	N = int(input())
	blue = {}

	for _ in range(N):
		ch = input()
		if ch in blue:
			blue[ch] += 1
		else:
			blue[ch] = 1

	M = int(input())
	red = {}

	for _ in range(M):
		ch = input()
		if ch in red:
			red[ch] += 1
		else:
			red[ch] = 1

	value = calc(blue, red)

	if value >= 0:
		print(value)
	else:
		print(0)	

  
if __name__ == "__main__":
  	main()

Solution (Python):
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 range(n):
  a=s.count(s[i])-t.count(s[i])
  ans=max(ans,a)
print(ans)

Solution (Python):
N = int(input())
s = {}
for i in range(N):
    text = input()
    if not (text in s.keys()):
        s[text] = 1
    else:
        s[text] += 1

M = int(input())
t = dict()
for i in range(M):
    text = input()
    if not (text in t.keys()):
        t[text] = 1
    else:
        t[text] += 1

for key in s.keys():
    if key not in t.keys():
        t[key] = 0


maxVal = 0
for key in s.keys():
    maxVal = max(maxVal, s[key] - t[key])

print(maxVal)

Solution (Python):
d={}
a=[]
N=int(input())
for i in range(N):
  s=input()
  if s not in a:
    a.append(s)
    d[s]=1
  else:
    d[s]+=1
  a=list(set(a))
M=int(input())
for j in range(M):
  t=input()
  if t not in a:
    a.append(t)
    d[t]=-1
  else:
    d[t]-=1
  a=list(set(a))
ans=0
for k in a:
  ans=max(ans,d[k])
print(ans)

Solution (Python):
r1,r2=[input() for _ in range(int(input()))],[input() for _ in range(int(input()))]
print(max(0,max([r1.count(i)-r2.count(i) for i in set(r1)])))

Solution (Python):
r1,r2=[input() for _ in range(int(input()))],[input() for _ in range(int(input()))];ans=0
ans=[r1.count(i)-r2.count(i) for i in set(r1)];print(max(0,max(ans)))

Solution (Python):
r1=[input() for _ in range(int(input()))];r2=[input() for _ in range(int(input()))];ans=0
for i in set(r1): ans=max(ans,r1.count(i)-r2.count(i))
print(ans)

Solution (Python):
d={}
r=[input() for _ in range(int(input()))]
for _ in range(int(input())):
  a=input()
  if a in r:
    r.pop(r.index(a))
for i in r:
  if i not in d:
    d[i] = 1
  else:
    d[i] += 1
d=sorted(d.items(),key=lambda x:-x[1])
print([0,d[0][1]][d[0][1]>0] if d else 0)

Solution (Python):
N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]
print(max(max([s.count(e)-t.count(e) for e in s+t]),0))

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

from collections import Counter
s = Counter(s).most_common()
t = Counter(t).most_common()
l = []
for x in range(len(s)):
    z = 'Y'
    for y in range(len(t)):
        if s[x][0] == t[y][0]:
            l.append((s[x][1]-t[y][1],s[x][0]))
            z = 'N'
            break
    if z == 'Y':
        l.append((s[x][1],s[x][0]))
l.sort()
if l[-1][0] < 0:
    print(0)
else:
    print(l[-1][0])

Solution (Python):
n = int(input())
slist = [input() for _ in range(n)]
sset = set(slist)
m = int(input())
tlist = [input() for _ in range(m)]

ans = 0
for s in sset:
	if slist.count(s)>tlist.count(s):
		ans =max(ans,slist.count(s)-tlist.count(s))
print(ans)

Solution (Python):
N=int(input())
S=list()
for i in range(N):
  S.append(input())
M=int(input())
T=list()
for i in range(M):
  T.append(input())
ans=0
for i in S:
  v=S.count(i)-T.count(i)
  if v>ans:
    ans=v
print(ans)

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

Solution (Python):









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

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

ss = list(set(s))
ans = [0] * len(ss)

for i in range(len(ss)):
    for j in range(n):
        if ss[i] == s[j]:
            ans[i] += 1
    for j in range(m):
        if ss[i] == t[j]:
            ans[i] -= 1

print(max(max(ans), 0))

Solution (Python):
import collections
N = int(input())
lsN = []
for i in range(N):
    lsN.append(input())
M = int(input())
lsM = []
for i in range(M):
    lsM.append(input())

counterN = collections.Counter(lsN)
counterM = collections.Counter(lsM)
ans = 0
for key in counterN.keys():
    money = counterN[key]
    if key in counterM.keys():
        money -= counterM[key]
    ans = max(ans,money)
print(ans)

Solution (Python):
N = int(input())
S = [input() for T in range(0,N)]
M = int(input())
T = [input() for T in range(0,M)]
MAX = 0
for IS in set(S):
    Point = S.count(IS)-T.count(IS)
    if MAX<Point:
        MAX = Point
print(MAX)

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

import collections

cS = collections.Counter(S)
cT = collections.Counter(T)
ans = 0

for x in list(cS.keys()):
  ans = max(cS[x] - cT[x],ans)
print(ans)

Solution (Python):
N = int(input())
blue = []
for i in range(N):
  blue.append(input())
M = int(input())
red = []
for i in range(M):
  red.append(input())
ans = 0
for i in range(N):
  count = 0
  for j in range(N):
    if blue[j] == blue[i]:
      count += 1
  for j in range(M):
    if red[j] == blue[i]:
      count -= 1
  if count > ans:
    ans = count
print(ans)

Solution (Python):
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 set(s):
    ans = max(ans, s.count(i)-t.count(i))
print(ans)

Solution (Python):
N = input()
s = []
for i in range(int(N)):
  s.append(input())
M = input()
t = []
for i in range(int(M)):
  t.append(input())
  
strdict = dict()
strset = set()
strset.add('')
strdict['']=0

for str in s:
  if str in strset:
    strdict[str]+=1
  else:
    strset.add(str)
    strdict[str]=1
for str in t:
  if str in strset:
    strdict[str]-=1
  else:
    strset.add(str)
    strdict[str]=-1

maxval=0
for str in strset:
  if maxval < strdict[str]:
    maxval=strdict[str]
print(maxval)

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

Solution (Python):
import statistics
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 s:
    tmp = s.count(i) - t.count(i)
    if ans <= tmp:
        ans = tmp
print(ans)

Solution (Python):
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 s:
    tmp = s.count(i) - t.count(i)
    if ans <= tmp:
        ans = tmp
print(ans)

Solution (Python):
blue=int(input())
b=[]
r=[]
count=[]
for i in range(blue):
  b.append(input())
red=int(input())
for i in range(red):
  r.append(input())
for i in b:
  count.append(b.count(i)-r.count(i))
if max(count)<0:
  print(0)
else:
  print(max(count))

Solution (Python):
blue=int(input())
b=[]
r=[]
for i in range(blue):
  b.append(input())
red=int(input())
for i in range(red):
  r.append(input())
count=[]
for i in range(len(b)):
  counter=0
  for j in range(len(b)):
    if b[i]==b[j]:
      counter+=1
  for j in range(len(r)):
    if b[i]==r[j]:
      counter-=1
  count.append(counter)
if max(count)<0:
  print(0)
else:
  print(max(count))

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

Pt = max([S.count(s)-T.count(s) for s in S])

print(max(0, Pt))

Solution (Python):
from collections import Counter
N = int(input())
s = Counter([input().strip() for i in range(N)])
M = int(input())
t = Counter([input().strip() for i in range(M)])
r = 0
for k, v in s.items():
    r = max(r, v-t.get(k, 0))
print(r)

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())
from collections import Counter
s=Counter(s)
t=Counter(t)
ans=0
for i in s:
  ans=max(ans,s[i]-t.get(i,0))
for i in t:
  ans=max(ans,-t[i]+s.get(i,0))

print(ans)

Solution (Python):
import sys
from collections import Counter

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    S = [0] * N
    for i in range(N):
        S[i] = readline().strip()
    M = int(readline())
    T = [0] * M
    for i in range(M):
        T[i] = readline().strip()

    c1 = Counter(S)
    c2 = Counter(T)

    ans = 0
    for k, v in c1.items():
        if ans < v - c2[k]:
            ans = v - c2[k]

    print(ans)
    return


if __name__ == '__main__':
    main()

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


dic_blue = {}
for i in range(n):
    a = str(input())
    if a in dic_blue:
        dic_blue[a] += 1
    else:
        dic_blue[a] = 1

m = int(input())
dic_red = {}
for i in range(m):
    b = str(input())
    if b in dic_red:
        dic_red[b] += 1
    else:
        dic_red[b] = 1

total_list = []
total_list.append(0)
for j in dic_blue.keys():
    total = 0
    if j in dic_red:
        total = dic_blue[j] - dic_red[j]
        total_list.append(total)
    else:
        total = dic_blue[j]
        total_list.append(total)

print(max(total_list))

Solution (Python):
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]
a=[0]*101
for i in range(N):
    a[i]=s.count(s[i])
    for j in range(M):
        if s[i]==t[j]:
            a[i]-=1

print(max(a))