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 = int(input())

Firstlist = []
for i in range (0, N):
	Firstlist.append(input())

M = int(input())

Secondlist = []
for i in range (0, M):
	Secondlist.append(input())

Firstlist_set = list(set(Firstlist))

Point = []
for i in range (0, len(Firstlist_set)):
	Point.append(Firstlist.count(Firstlist_set[i]))

for i in range (0, len(Firstlist_set)):
	Point[i] = Point[i] - Secondlist.count(Firstlist_set[i])

print(max(max(Point),0))

Solution (Python):
from collections import defaultdict
total = defaultdict(int)

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

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

words = set(red) | set(blue)

for key in red:
    total[key] += 1

for key in blue:
    total[key] -= 1

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

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

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

from collections import Counter

sc = Counter(s)
M = int(input())
for i in range(M):
    sc[input()] -= 1
print(max(0,max(sc.values())))

Solution (Python):
dict = {}

N = int(input())

for i in range(N):
    s = str(input())
    if  (s in dict.keys())== False:
        dict.setdefault(s,1)
    else:
        dict[s] += 1

M = int(input())

for j in range(M):
    t = str(input())
    if (t in dict.keys())== False:
        dict.setdefault(s,-1)
    else:
        dict[t] -= 1

        
m = 0
for k in dict:
    m = max(dict[k],m)

print(m)

Solution (Python):
import collections
import sys

input = sys.stdin.readline

def myindex(l, x, default=-1):
    if x in l:
        return l.index(x)
    else:
        return default

def main():
    N = int(input())
    S = []
    for _ in range(N):
        S.append(input()[:-1])
    
    M = int(input())
    T = []
    for _ in range(M):
        T.append(input()[:-1])

    countS = list(zip(*collections.Counter(S).items()))
    countT = list(zip(*collections.Counter(T).items()))

    ans = 0
    for i, tmp in enumerate(countS[0]):
        cntS = countS[1][i]
        myidxT = myindex(countT[0], tmp)
        cntT = countT[1][myidxT]*(myidxT != -1)
        ans = max(ans, cntS-cntT)
    
    print(ans)

if __name__ == "__main__":
    main()

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

dic = dict()

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


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

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

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

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

    print(ans if ans > 0 else 0)

resolve()

Solution (Python):
def main():
    from collections import Counter
    n = int(input())
    s = [input() for _ in range(n)]
    ss = set(s)
    m = int(input())
    t = [input() for _ in range(m)]
    res = 0
    for i in ss:
        tmp = s.count(i) - t.count(i)
        res = max(tmp,res)
    print(res)

if __name__ == '__main__':
    main()

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

Solution (Python):
n = int(input())
from collections import Counter
c = Counter()
for i in range(n):
  a = input()
  c.update({a: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])

Solution (Python):
n=int(input())
s=[ input() for i in range(n)]
m=int(input())
t=[ input() for i in range(m)]
ans=dict()
for i in s:
  if not(i in ans):
    ans[i]=1
  else:
    ans[i]+=1
for i in t:
  if not(i in ans):
    ans[i]=-1
  else:
    ans[i]-=1
hantei=0
for i in ans:
  if ans[i]>hantei:
    hantei=ans[i]
print(hantei)

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

R={}
M=int(input())
for i in range(M):
    s=input()
    if s in R:
        R[s]+=1
    else:
        R[s]=1
    T.append(s)

T=set(T)
ans=0
for t in T:
    if t in B:
        b=B[t]
    else:
        b=0
    if t in R:
        r=R[t]
    else:
        r=0
    now=b-r
    ans=max(ans, now)
print(ans)

Solution (Python):
import sys
from collections import Counter
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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

    D_S = Counter(S)
    D_T = Counter(T)
    res = 0
    for k, v in D_S.items():
        cnt = v - D_T.get(k, 0)
        res = max(res, cnt)

    print(res)


if __name__ == '__main__':
    resolve()

Solution (Python):
def main():
    n = int(input())
    s_dic = {}
    for _ in range(n):
        s = input()
        if s in s_dic:
            s_dic[s] += 1
        else:
            s_dic[s] = 1
    m = int(input())
    t_dic = {}
    for _ in range(m):
        t = input()
        if t in t_dic:
            t_dic[t] += 1
        else:
            t_dic[t] = 1
    ans = 0
    for s in s_dic.keys():
        tmp = s_dic[s]
        if s in t_dic:
            tmp -= t_dic[s]
        ans = max(ans, tmp)
    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lisa=[input().rstrip() for i in range(n)]
m=I()
lisb=[input().rstrip() for i in range(m)]
u=Counter(lisa)
v=Counter(lisb)
mx=0
for j in u.keys():
    ans=u[j]-v[j]
    if ans>mx:
        mx=ans
print(mx)

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

ans = 0
for x,y in s.items():
  a = y
  if x in t:
    a -= t[x]
  if ans < a: ans = a
print(ans)

Solution (Python):
def main():
    N = int(input())
    S = [input() for i in range(N)]
    M = int(input())
    T = [input() for i in range(M)]
    ans = 0
    from collections import Counter
    c = Counter(S)
    cT = Counter(T)
    for k, v in c.items():
        ans = max(ans, v - cT[k])
    print(ans)


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)]
from collections import Counter
cnt_s = Counter(s)
cnt_t = Counter(t)
money = 0
for i in set(s):
    temp = cnt_s[i] - cnt_t[i]
    if money < temp:money = temp
print(money)

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

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

ans = 0
for x in d:
    ans = max(ans, d[x])
print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

from collections import defaultdict


dic = defaultdict(int)

N = int(input())
for _ in range(N):
    dic[str(input())] += 1

M = int(input())
for _ in range(M):
    dic[str(input())] -= 1

ans = 0
for tmp in dic:
    ans = max(ans, dic[tmp])

print (ans)

Solution (Python):
def main():
    n = int(input())
    card = {}
    for _ in range(n):
        s = input()
        if s in card:
            card[s] += 1
        else:
            card[s] = 1
    m = int(input())
    for _ in range(m):
        t = input()
        if t in card:
            card[t] -= 1
        else:
            card[t] = -1
    card = sorted(card.items(), key=lambda x: x[1], reverse=True)
    print(max(card[0][1], 0))


if __name__ == '__main__':
    main()

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

C = []  
for i in range(N):
  count = 0
  for j in range(N):
    if S[i] == S[j]:
      count = count + 1
  for k in range(M):
    if S[i] == T[k]:
      count = count -1
  C.append(count)

print(max(0,(max(C))))

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 list(set(S)):
  tmp = S.count(i) - T.count(i)
  if ans < tmp:
    ans = tmp
print(ans)

Solution (Python):
import sys
import math
n = int(input())
lis=[]
for i in range(n):
    tmp = input()
    lis.append(tmp)
m = int(input())
lit=[]
for i in range(m):
    tmp = input()
    lit.append(tmp)
lis.sort()
lit.sort()
ans=0
for i in range(len(lis)):
    tmp=0
    for j in lis:
            if j==lis[i]:
                tmp += 1
    if(lis[i] not in lit):
        ans = max(ans, tmp)
    else:
        for j in lit:
            if lis[i] == j:
                tmp -= 1
    ans = max(ans, tmp)
print(ans)

Solution (Python):
n=int(input())
blue_cards={}
red_cards={}

for i in range(n):
    s=input()
    if s in blue_cards:
        blue_cards[s]+=1
    else:
        blue_cards[s]=1

m=int(input())

for j in range(m):
    s=input()
    if s in red_cards:
        red_cards[s]+=1
    else:
        red_cards[s]=1

ans=0
for word in blue_cards:
    if word not in red_cards:
        ans=max(ans, blue_cards[word])
    else:
        ans=max(ans, blue_cards[word]-red_cards[word])

print(ans)

Solution (Python):
from collections import Counter

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

sc = Counter(s)
tc = Counter(t)
ns = len(sc)
ans = 0

for i in range(ns):
  key = sc.most_common()[i][0]
  if key in tc:
    ans = max(sc[key] - tc[key],ans)
  else:
    ans = max(sc[key],ans)
print(ans)

Solution (Python):
import collections

n = int(input())
blue = collections.defaultdict(lambda:0)
for _ in range(n):
  blue[input()] += 1

m = int(input())
red = collections.defaultdict(lambda:0)
for _ in range(m):
  red[input()] += 1

ans = 0
for i,v in blue.items():
  if i not in red:
    ans = max(ans, v)
  else:
    if v > red[i]:
      ans = max(ans, v - red[i])
      
print(ans)

Solution (Python):
score_dic = {}

for i in range(int(input())):
    s = input()
    if s not in score_dic:
        score_dic[s] = 1
    else:
        score_dic[s] += 1

for i in range(int(input())):
    t = input()
    if t not in score_dic:
        score_dic[t] = -1
    else:
        score_dic[t] -= 1

max_value = max(score_dic.values())
if max_value < 0:
    print(0)
else:
    print(max_value)

Solution (Python):
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(i) - t.count(i) for i in l)))

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):
    a = sum(k == i for k in s) - sum(k == i for k in t)
    ans = max(a,ans)
print(ans)

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

s = [None] * N
for i in range(N):
    s[i] = input()

sx = {x: s.count(x) for x in set(s)}

M = int(input())
t = [None] * M
for i in range(M):
    t[i] = input()

tx = {x: t.count(x) for x in set(t)}

mx = 0
for sk in sx.keys():
    td = tx[sk] if sk in tx else 0
    mx = max(mx, (sx[sk] - td))

print(mx)

Solution (Python):

import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
PI = math.pi

N = ri()
s = Counter([rs() for _ in range(N)])
M = ri()
t = Counter([rs() for _ in range(M)])
ans = 0
for si in s.items():
    ans = max(ans, max(si[1] - t[si[0]], 0))
print(ans)

Solution (Python):
import collections
n = int(input())
blue = [input() for i in range(n)]
blue_count = collections.Counter(blue)
m = int(input())
red = [input() for i in range(m)]
red_count = collections.Counter(red)
yen = []
for k, v in blue_count.items():
    if k in red_count:
        x = red_count[k]
        count = v - x
        yen.append(count)
    else:
        yen.append(v)
y = max(yen)
print(max(0, y))

Solution (Python):
n=int(input())
s=[input() for i in range(n)]
m=int(input())
t=[input() for j 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):
n=int(input())
s=[input() for i in range(n)]
m=int(input())
t=[input() for j in range(m)]
l=list(set(s))
print(max(0,max(s.count(l[i])-t.count(l[i]) for i in range(len(l)))))

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):
from collections import Counter

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

cs = Counter(s)
ct = Counter(t)

ans = 0
for key in cs.keys():
    ans = max(ans, cs[key] - ct[key])

print(ans)

Solution (Python):
import copy
n = int(input())
s = list(range(n))
for i in range(n):
    s[i] = input()
m = int(input())
t = list(range(m))
for i in range(m):
    t[i] = input()
tmp = list(range(m+n))
s2 = sorted(list(set(s)))
s3 = copy.copy(s2)
t2 = sorted(list(set(t)))
s3.extend(t2)
s3 = set(s3)
ans = []

for i in s3:
     ans.append(s.count(i)-t.count(i))






if max(ans) < 0:
    print(0)
else:
    print(max(ans))

Solution (Python):
n = int(input())
b_list = []
uni = []
for i in range(n):
  b = input()
  b_list.append(b)
  if not b in uni:
    uni.append(b)

m = int(input())
r_list = []
r_uni = []
for i in range(m):
  r = input()
  r_list.append(r)
  if not r in uni:
    uni.append(r)

uni.append("aaaaaaaaaaa")
uni_l = len(uni)
c = []
for i in range(uni_l):
  c.append(b_list.count(uni[i]) - r_list.count(uni[i]))
print(max(c))

Solution (Python):
from collections import Counter

n = int(input())
s_inputs = [input() for i in range(n)]
m = int(input())
t_inputs = [input() for i in range(m)]

s_count = Counter(s_inputs)
t_count = Counter(t_inputs)

ans=0
for s in set(s_inputs+t_inputs):
    tmp = s_count[s]-t_count[s]
    if tmp>ans:
        ans=tmp
print(ans)

Solution (Python):

import re
import math
from collections import defaultdict
import itertools
from copy import deepcopy
import random
from heapq import heappop,heappush
import time
import os
import queue
import sys
import datetime
from functools import lru_cache

readline=sys.stdin.readline
sys.setrecursionlimit(2000000)

alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def is_power(a,b):
    now=b
    while now<a:
        now*=b
    if now==a:return True
    else:return False
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def get_facs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(a,b,c):
    if a:return b
    else:return  c
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
def factorize(n,type_="dict"):
    b = 2
    list_ = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            list_.append(b)
        b+=1
    if n > 1:list_.append(n)
    if type_=="dict":
        dic={}
        for a in list_:
            if a in dic:
                dic[a]+=1
            else:
                dic[a]=1
        return dic
    elif type_=="list":
        return list_
    else:
        return None
def floor_(n,x=1):
    return x*(n//x)
def ceil_(n,x=1):
    return x*((n+x-1)//x)
def hani(x,min_,max_):
    ret=x
    if x<min_:ret=min_
    if x>max_:ret=max_
    return ret
def seifu(x):
    return x//abs(x)


def main():
    n=int(input())
    dic=defaultdict(int)
    for a in range(n):
        dic[input()]+=1
    m=int(input())
    for a in range(m):
        dic[input()]-=1
    mmax=0
    for a in dic.values():
        mmax=max(mmax,a)
    print(mmax)
main()

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 range(n):
    ans = max(s.count(s[i]) - t.count(s[i]), ans)
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 x in set(s) | set(t):
    d = s.count(x) - t.count(x)
    ans = max(ans, d)
print(ans)

Solution (Python):

import sys
input = sys.stdin.readline









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

from collections import defaultdict
dic = defaultdict(int)

for s in S:
    dic[s] += 1
for t in T:
    dic[t] -= 1

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

print(ans)

Solution (Python):
N=int(input())
A=[]
B=[]
for i in range(N):
  A.append(input())
M=int(input())
for i in range(M):
  B.append(input())
ans=0  
for i in set(A):
  s=0
  s+=A.count(i)-B.count(i)
  ans=max(ans,s)
print(ans)

Solution (Python):
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  
    s_arr = []
    for i in range(N):
        _ =     _in[i+1]   
        s_arr.append(_)
    M = int(_in[N+1])  
    t_arr = []
    for i in range(M):
        _ =     _in[i+N+2]   
        t_arr.append(_)    
    
    cnt = 0
    w_arr = list(set(s_arr))
    for w in w_arr:
        _ = s_arr.count(w)-t_arr.count(w)
        cnt = max(cnt,_)
    
    print(cnt)

Solution (Python):
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  
    s_arr = []
    for i in range(N):
        _ =     _in[i+1]   
        s_arr.append(_)
    M = int(_in[N+1])  
    t_arr = []
    for i in range(M):
        _ =     _in[i+N+2]   
        t_arr.append(_)    
    
    w_arr = s_arr+t_arr
    w_arr = list(set(w_arr))
    cnt = 0
    for w in w_arr:
        _ = s_arr.count(w)-t_arr.count(w)
        cnt = max(cnt,_)
    
    print(cnt)

Solution (Python):
n = int(input())
blue_cards = {}
for i in range(n):
    s = input()
    if s in blue_cards:
        blue_cards[s] += 1
    else:
        blue_cards[s] = 1

m = int(input())
red_cards = {}
for i in range(m):
    s = input()
    if s in red_cards:
        red_cards[s] += 1
    else:
        red_cards[s] = 1
        
ans = 0
for k in blue_cards:
    if k in red_cards:
        score = blue_cards[k] - red_cards[k]
    else:
        score = blue_cards[k]
    ans = max(ans, score)
print(ans)

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

Solution (Python):
from collections import Counter as cnt
b = cnt([input() for _ in range(int(input()))])
r = cnt([input() for _ in range(int(input()))])
a = 0
for l in b.keys(): a = max(a,b[l]-r[l])
print(a)

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())
A=set(S)
ans=0
for i in A:
    s=0
    s=S.count(i)-T.count(i)
    if s>ans:
        ans=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())
count = 0
maxcount = 0
for i in range(N):
  count = 0
  for j in range(N):
    if S[i] == S[j]:
      count += 1
  for j in range(M):
    if S[i] == T[j]:
      count -= 1
  if count > maxcount:
    maxcount = count
print(maxcount)

Solution (Python):
import sys
from collections import deque, Counter, defaultdict
from itertools import accumulate  
from bisect import bisect_left, bisect
from heapq import heappop, heappush  
from fractions import gcd
from math import ceil, floor, sqrt
from copy import deepcopy

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

for _ in range(int(input())):
    scores[input()] -= 1

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

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

    paymax = 0
    for w in s:
        pay = s.count(w) - t.count(w)
        if paymax < pay:
            paymax = pay

    print(paymax)
resolve()

Solution (Python):
N=int(input())
S=dict()
for i in range(N):
	tmp=input()
	if tmp in S:
		S[tmp]+=1
	else:
		S[tmp]=1
M=int(input())
T=dict()
for i in range(M):
	tmp = input()
	if tmp in T:
		T[tmp]+=1
	else:
		T[tmp]=1
ans=0
for SS in S:
	tmp = 0
	if SS in T:
		tmp=S[SS]-T[SS]
	else:
		tmp=S[SS]
	if tmp > ans:
		ans = tmp
print(ans)

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

sd = {}
for i in s:
    if i not in sd:
        sd[i] = 0
    sd[i] += 1
td = {}
for i in t:
    if i not in td:
        td[i] = 0
    td[i] += 1
d = {}
for i in sd.keys():
    try:
        d[i] = (sd[i] - td[i])
    except:
        d[i] = sd[i]

if max([d[i] for i in d.keys()]) <= 0:
    print(0)
else:
    print(max([d[i] for i in d.keys()]))

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

Solution (Python):
from collections import defaultdict
def resolve():
    n = int(input())
    dict = defaultdict(lambda: [0, 0])
    for _ in range(n):
        dict[input()][0] += 1

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

    ans = 0
    for blue, red in dict.values():
        ans = max(ans, blue - red)

    print(ans)

resolve()

Solution (Python):
n=int(input())
s=[input() for i in range(n)]
m=int(input())
t=[input() for i in range(m)]
ans=0
word={}
for i in range(n):
  if s[i] not in word.keys():
    word[s[i]]=0
  word[s[i]]+=1
for i in range(m):
  if t[i] not in word.keys():
    word[t[i]]=0
  word[t[i]]-=1
for i in word.keys():
  if ans < word[i]:
    ans=word[i]
print(ans)

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

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

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):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7


n=I()
ss=[input().rstrip() for i in range(n)]
m=I()
ts=[input().rstrip() for i in range(m)]
u=Counter(ss)
v=Counter(ts)


ans=[]
for j in u.keys():
    ans.append(u[j]-v[j])
print(max(max(ans),0))

Solution (Python):
import sys

input = sys.stdin.readline
MOD = 1000000007

N = int(input())

num = [0]*(200)

S = {}

cnt = 0
for i in range(N):
    x = input()[:-1]
    if x not in S:
        S[x] = cnt
        num[cnt] = 1
        cnt+=1
    else:
        num[S[x]]+=1

M = int(input())
for i in range(M):
    x = input()[:-1]
    if x not in S:
        pass
    else:
        num[S[x]] -=1


res = 0
for i in num:
    if i > 0:
        res+= i

print(max(num))

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

MAX = 0
for i in range(N):
    MAX = max(Blue.count(Blue[i])- Red.count(Blue[i]), MAX)

print(MAX)

Solution (Python):
from collections import Counter
N = int(input())
blue = []
for _ in range(N):
    blue.append(input())
blue = Counter(blue)

M = int(input())
red = []
for _ in range(M):
    red.append(input())
red = Counter(red)

diff = blue - red
if len(diff)==0:
    print(0)
else:
    print(max(diff.values()))

Solution (Python):
n=int(input())
blue=[input() for i in range(n)]
m = int(input())
red = [input() for i in range(m)]
money = [0 for i in range(n)]

for i in range(n):
  for j in range(n):
    if blue[i] == blue[j]:
      money[i] += 1
  for k in range(m):
    if blue[i] == red[k]:
      money[i] -= 1

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

Solution (Python):
n=int(input())
res=0
blue=[]
for i in range(n):
  blue.append(input())
m=int(input())
red=[]
for j in range(m):
  red.append(input())

res=0
for i in range(0,n):
  bl=blue.count(blue[i])
  re=red.count(blue[i])
  if bl-re>res:
    res=bl-re
print(res)

Solution (Python):
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-1):
  count = 1
  for j in range(i+1,N):
    if s[i] == s[j]:
      count += 1
  for k in range(M):
    if s[i] == t[k]:
      count -= 1
  if count > judge:
    judge = count
print(judge)

Solution (Python):
n = int(input())
sl = list(input() for _ in range(n))
m = int(input())
tl = list(input() for _ in range(m))

ans = 0

for s in sl:
    cnt = sl.count(s) - tl.count(s)
    ans = max(ans, cnt)

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_g = 0
for i in s:
    c_s = s.count(i)
    c_t = t.count(i)

    max_g = max(max_g,c_s-c_t)

print(max_g)