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):
import collections,sys
def I(): return int(sys.stdin.readline().rstrip())
def S(): return sys.stdin.readline().rstrip()
s = [S() for _ in range(I())]
t = [S() for _ in range(I())]
ans = 0
count_s = collections.defaultdict(int)
count_t = collections.defaultdict(int)
for x in s:
    count_s[x] += 1
for y in t:
    count_t[y] += 1
for k,v in count_s.items():
    ans = max(ans,v-count_t[k])
print(ans)

Solution (Python):



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

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


max_point = 0

for s, blue_count in blue.items():
    red_count = red.get(s) or 0
    point = blue_count - red_count

    if point > max_point:
        max_point = point

print(max_point)

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=int(input())
    s=[input() for i in range(N)]
    M=int(input())
    t=[input() for i in range(M)]
    ans=0
    for a in set(s):
        ans=max(ans,s.count(a)-t.count(a))
    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)]

A = 0
for i in S:
    A = max(S.count(i)  - T.count(i), A)

print(A)

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

from collections import Counter

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

ans=0
for i,j in sc.items():
  tmp=j-tc[i]
  if tmp>0:
    ans=max(ans,tmp)
print(ans)

Solution (Python):
from collections import Counter

n = int(input())
s = []
for _ in range(n):
  s.append(input())
m = int(input())
t = []
for _ in range(m):
  t.append(input())
c_s = Counter(s)
c_t = Counter(t)

candidates = [0]

for k in c_s.keys():
  candidates.append(c_s[k]-c_t[k])
print(max(candidates))

Solution (Python):
import sys,bisect,string,math,time,functools,random,fractions
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
def Golf():*a,=map(int,open(0))
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def GI(V,E,ls=None,Directed=False,index=1):
    org_inp=[];g=[[] for i in range(V)]
    FromStdin=True if ls==None else False
    for i in range(E):
        if FromStdin:
            inp=LI()
            org_inp.append(inp)
        else:
            inp=ls[i]
        if len(inp)==2:
            a,b=inp;c=1
        else:
            a,b,c=inp
        if index==1:a-=1;b-=1
        aa=(a,c);bb=(b,c);g[a].append(bb)
        if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'

    mp=[boundary]*(w+2);found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[boundary]+[mp_def[j] for j in s]+[boundary]
    mp+=[boundary]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def bit_combination(n,base=2):
    rt=[]
    for tb in range(base**n):s=[tb//(base**bt)%base for bt in range(n)];rt+=[s]
    return rt
def gcd(x,y):
    if y==0:return x
    if x%y==0:return y
    while x%y!=0:x,y=y,x%y
    return y
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)
 
YN=['YES','NO'];Yn=['Yes','No']
mo=10**9+7
inf=float('inf')
FourNb=[(-1,0),(1,0),(0,1),(0,-1)];EightNb=[(-1,0),(1,0),(0,1),(0,-1),(1,1),(-1,-1),(1,-1),(-1,1)];compas=dict(zip('WENS',FourNb));cursol=dict(zip('LRUD',FourNb))
l_alp=string.ascii_lowercase

input=lambda: sys.stdin.readline().rstrip()

class Tree:
    def __init__(self,inp_size=None,ls=None,init=True,index=0):
        self.LCA_init_stat=False
        self.ETtable=[]
        if init:
            if ls==None:
                self.stdin(inp_size,index=index)
            else:
                self.size=len(ls)+1
                self.edges,_=GI(self.size,self.size-1,ls,index=index)
        return
 
    def stdin(self,inp_size=None,index=1):
        if inp_size==None:
            self.size=int(input())
        else:
            self.size=inp_size
        self.edges,_=GI(self.size,self.size-1,index=index)
        return
    
    def listin(self,ls,index=0):
        self.size=len(ls)+1
        self.edges,_=GI(self.size,self.size-1,ls,index=index)
        return
 
    def __str__(self):
        return  str(self.edges)
 
    def dfs(self,x,func=lambda prv,nx,dist:prv+dist,root_v=0):
        q=deque()
        q.append(x)
        v=[-1]*self.size
        v[x]=root_v
        while q:
            c=q.pop()
            for nb,d in self.edges[c]:
                if v[nb]==-1:
                    q.append(nb)
                    v[nb]=func(v[c],nb,d)
        return v
 
    def EulerTour(self,x):
        q=deque()
        q.append(x)
        self.depth=[None]*self.size
        self.depth[x]=0
        self.ETtable=[]
        self.ETdepth=[]
        self.ETin=[-1]*self.size
        self.ETout=[-1]*self.size
        cnt=0
        while q:
            c=q.pop()
            if c<0:
                ce=~c
            else:
                ce=c
                for nb,d in self.edges[ce]:
                    if self.depth[nb]==None:
                        q.append(~ce)
                        q.append(nb)
                        self.depth[nb]=self.depth[ce]+1
            self.ETtable.append(ce)
            self.ETdepth.append(self.depth[ce])
            if self.ETin[ce]==-1:
                self.ETin[ce]=cnt
            else:
                self.ETout[ce]=cnt
            cnt+=1
        return
    
    def LCA_init(self,root):
        self.EulerTour(root)
        self.st=SparseTable(self.ETdepth,init_func=min,init_idl=inf)
        self.LCA_init_stat=True
        return
    
    def LCA(self,root,x,y):
        if self.LCA_init_stat==False:
            self.LCA_init(root)
        xin,xout=self.ETin[x],self.ETout[x]
        yin,yout=self.ETin[y],self.ETout[y]
        a=min(xin,yin)
        b=max(xout,yout,xin,yin)
        id_of_min_dep_in_et=self.st.query_id(a,b+1)
        return self.ETtable[id_of_min_dep_in_et]
 
class SparseTable: 
    def __init__(self,ls,init_func=min,init_idl=float('inf')):
        self.func=init_func
        self.idl=init_idl
        self.size=len(ls)
        self.N0=self.size.bit_length()
        self.table=[ls[:]]
        self.index=[list(range(self.size))]
        self.lg=[0]*(self.size+1)
        
        for i in range(2,self.size+1):
            self.lg[i]=self.lg[i>>1]+1
 
        for i in range(self.N0):
            tmp=[self.func(self.table[i][j],self.table[i][min(j+(1<<i),self.size-1)]) for j in range(self.size)]
            tmp_id=[self.index[i][j] if self.table[i][j]==self.func(self.table[i][j],self.table[i][min(j+(1<<i),self.size-1)]) else self.index[i][min(j+(1<<i),self.size-1)] for j in range(self.size)]
            self.table+=[tmp]
            self.index+=[tmp_id]
    
    
    def query(self,l,r):
        if r>self.size:r=self.size
        
        N=self.lg[r-l]
        return self.func(self.table[N][l],self.table[N][max(0,r-(1<<N))])
    
    
    def query_id(self,l,r):
        if r>self.size:r=self.size
        
        N=self.lg[r-l]
        a,b=self.index[N][l],self.index[N][max(0,r-(1<<N))]
        if self.table[0][a]==self.func(self.table[N][l],self.table[N][max(0,r-(1<<N))]):
            b=a
        return b
    
    def __str__(self):
        return str(self.table[0])
 
    def print(self):
        for i in self.table:
            print(*i)
 
class Comb:
    def __init__(self,n,mo=10**9+7):
        self.fac=[0]*(n+1)
        self.inv=[1]*(n+1)
        self.fac[0]=1
        self.fact(n)
        for i in range(1,n+1):
            self.fac[i]=i*self.fac[i-1]%mo
            self.inv[n]*=i
            self.inv[n]%=mo
        self.inv[n]=pow(self.inv[n],mo-2,mo)
        for i in range(1,n):
            self.inv[n-i]=self.inv[n-i+1]*(n-i+1)%mo
        return
    
    def fact(self,n):
        return self.fac[n]
        
    def invf(self,n):
        return self.inv[n]
 
    def comb(self,x,y):
        if y<0 or y>x:
            return 0
        return self.fac[x]*self.inv[x-y]*self.inv[y]%mo

def dijkstra(edge,st):
    
    
    n=len(edge)
    d=[(0 if st==i else inf) for i in range(n)]
    prev=[0]*n
    q=[(j,i) for i,j in enumerate(d)]
    heapify(q)
    v=[False]*n
    
    while q:
        dist,cur=heappop(q)
        if v[cur]:
            continue
        v[cur]=True
        for dst,dist in edge[cur]:
            alt=d[cur]+dist
            if alt<d[dst]:
                d[dst]=alt
                prev[dst]=cur
                heappush(q,(alt,dst))
    return d,prev


show_flg=False
show_flg=True
ans=0

p=defaultdict(int)

n=I()
for i in range(n):
    p[input()]+=1

m=I()
for i in range(m):
    p[input()]-=1

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

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

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

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]


def Yes(): print("Yes"); return
def No(): print("No"); return


def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr


def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def Base_10_to_n(X, n):
  if (int(X/n)):
    return Base_10_to_n(int(X/n), n)+[X%n]
  return [X%n]






N = inputI()
P_dic = defaultdict(int)
for _ in range(N):
  k = inputS()
  P_dic[k] += 1
M = inputI()
M_dic = defaultdict(int)
for _ in range(M):
  k = inputS()
  M_dic[k] += 1

  
ans = 0
for k in P_dic:
  ans = max(ans,P_dic[k]-M_dic[k])
print(ans)

Solution (Python):
n = int(input())
sl = []
for i in range(n):
  s = str(input())
  sl.append(s)
m = int(input())
tl = []
for i in range(m):
  t = str(input())
  tl.append(t)
al = sl + tl
setal = set(al)
lsetal = list(setal)
cl = []
for i in range(len(lsetal)):
  cp = sl.count(lsetal[i])
  cm = tl.count(lsetal[i])
  cl.append(cp - cm)
mcl = max(cl)
if mcl > 0:
  print(mcl)
else:
  print('0')

Solution (Python):
import collections
n=[]
for i in range(int(input())):
    n.append(input())
    N = collections.Counter(n)
m=[]
for j in range(int(input())):
    m.append(input())
    M= collections.Counter(m)
intersection=list(N.keys()&M.keys())
for k in range(len(intersection)):
    N[intersection[k]]=N[intersection[k]]-M[intersection[k]]
print(max(max(list(N.values())),0))

Solution (Python):
N = int(input())
dn = {}
dm = {}

for _ in range(N):
    s = input()
    if s in dn:
        dn[s] += 1
    else:
        dn[s] = 1
        
M = int(input())
for _ in range(M):
    t = input()
    if t in dm:
        dm[t] += 1
    else:
        dm[t] = 1

ans = 0
for k, v in dn.items():
    res = v
    if k in dm:
        res -= dm[k]
    ans = max(ans, res)

print(ans)

Solution (Python):
dic = {}

n = int(input())
for _ in range(n):
    s = input()
    if dic.get(s):
        dic[s] += 1
    else: 
        dic[s] = 1
        
m = int(input())
for _ in range(m):
    s = input()
    if dic.get(s):
        dic[s] -= 1
    else: 
        dic[s] = -1

ans = 0
for k, v in dic.items():
    ans = max(ans, v)
    
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):
    score = 0
    score += sum([s == x for s in S])
    score -= sum([t == x for t in T])
    ans = max(ans, score)
print(ans)

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

orange = [0]
for i in s:
    a = s.count(i)
    b = t.count(i)
    orange.append(a - b)

print(max(orange))

Solution (Python):
N=int(input())
s=[input() for i in range(N)]
M=int(input())
t=[input() for i in range(M)]
S=list(set(s))
S2=[s.count(S[i]) for i in range(len(S))]

for i in range(len(S)):
    x=t.count(S[i])
    S2[i]-=x
if max(S2)>=0:
    print(max(S2))
else:
    print(0)

Solution (Python):
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ 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):
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)
a = 0
for sck in sc.keys():
    a = max(a,sc.get(sck,0)-tc.get(sck,0))
if a>=1:
    print(a)
else:
    print(0)

Solution (Python):
n1 = int(input())
cnt_dict = {}
for _ in range(n1):
  s = input()
  if s not in cnt_dict:
    cnt_dict[s] = 1
  else:
    cnt_dict[s] += 1
n2 = int(input())
for _ in range(n2):
  s = input()
  if s not in cnt_dict:
    cnt_dict[s] = -1
  else:
    cnt_dict[s] -= 1
print(max(max(cnt_dict.values()),0))

Solution (Python):
n=[input() for i in range(int(input()))]
m=[input() for i 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):
n=int(input())
b=[input() for i in range(n)]
m=int(input())
r=[input() for i in range(m)]

ans=[0]

for i in set(b):
    ans.append(b.count(i)-r.count(i))

print(max(ans))

Solution (Python):
import collections

n=int(input())
lb=[input() for i in range(n)]
m=int(input())
lr=[input() for i in range(m)]

for i in range(len(lr)):
    if lr[i] in lb:
        lb.remove(lr[i])
    else:
        pass
if lb==[]:
    ans=0
else:
    s=collections.Counter(lb)
    ans=s.most_common()[0][1]      

print(ans)

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

d = {}
for each in s:
  d[each] = d.get(each, 0) + 1
for each in t:
  d[each] = d.get(each, 0) - 1

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

Solution (Python):
N = int(input())
NList1 = []
NList2 = []
ans = 0
for i in range(N):
  tmp = input()
  NList1.append(tmp)
  NList2.append(tmp)
M = int(input())
MList = []
for k in range(M):
  tmp = input()
  MList.append(tmp)
NList2 = list(set(NList2))
for t in NList2:
  tmp2 = NList1.count(t) - MList.count(t)
  ans = max(ans,tmp2)
print(str(ans))

Solution (Python):
def main():
    n = int(input())
    S = {}

    for _ in range(n):
        s = input()

        if s in S:
            S[s] +=1
        else:
            S[s] = 1
    
    m = int(input())
    
    for _ in range(m):
        t = input()

        if t in S:
            S[t] -= 1
        else:
            S[t] = -1
    
    print(max(0, max(list(S.values()))))

if __name__ == '__main__':
    main()

Solution (Python):
from collections import defaultdict

memo = defaultdict(int)

N = int(input())

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

M = int(input())

for i in range(M):
    tmp = input()
    memo[tmp] -= 1

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

Solution (Python):
from collections import defaultdict
dd=defaultdict(int)
n = int(input())
for i in range(n):
    dd[input()] += 1
m = int(input())
for i in range(m):
    dd[input()] -= 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)])

S = {}
T = {}
p = 0

for i in s:
    if i not in S:
        S[i] = 1
    else:
        S[i] += 1
for i in t:
    if i not in T:
        T[i] = 1
    else:
        T[i] += 1

for i in S:
    if i not in T:
        p = max(p, S[i])
    else:
        if S[i] > T[i]:
            p = max(p, S[i] - T[i])
print(p)

Solution (Python):
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
L1 = list(set(s) - set(t))
L2 = list(set(s) & set(t))
ans = 0
for i in L1:
    ans = max(ans, s.count(i))
for j in L2:
    ans = max(ans, s.count(j) - t.count(j))
print(ans)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    ls=[input() for i in range(n)]
    m=int(input())
    lt=[input() for i in range(m)]
    lbutu=list(set(ls)|set(lt))
    kosu=len(lbutu)
    lnum=[0]*kosu
    for j in ls:
        for k in range(kosu):
            if j==lbutu[k]:
                lnum[k]+=1
    for j in lt:
        for k in range(kosu):
            if j==lbutu[k]:
                lnum[k]-=1
    if max(lnum)<0:
        print(0)
    else:
        print(max(lnum))

resolve()

Solution (Python):
N = [input() for _ in range(int(input()))]
M = [input() for _ in range(int(input()))]
L = list(set(N))

r = 0
for l in L:
    n = N.count(l) - M.count(l)
    if r < n:
        r = n
print(r)

Solution (Python):
from collections import Counter
n = int(input())
s = list()

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

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

count_s = dict(Counter(s))

for a in range(m):
    t = input()
    if t not in count_s.keys():
        continue
    count_s[t] -= 1

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

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

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

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

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

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

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

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

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

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

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

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

bb = set(b)
dd = set(d)
s = max(b.count(i) -d.count(i)  for i in bb)
print(s if s > 0 else 0)

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

price = []
tmp = 0 
for i in range(n):
    price.append(s.count(s[i]) - t.count(s[i]))

print(max(0, max(price)))

Solution (Python):
N = int(input())
S =[]
for n in range(N):
    S.append(input())
T = []
M = int(input())
for m in range(M):
    T.append(input())
from collections import Counter
C_S = Counter(S)
C_T = Counter(T)
m = 0
for k,v in C_S.items():
    if v - C_T[k]>m:
        m =v - C_T[k]
print(m)

Solution (Python):
from collections import Counter

n = int(input())
s_input=Counter([input() for i in range(n)])
m = int(input())
t_input=Counter([input() for i in range(m)])

ans=0
for k,v in s_input.items():
    if k in t_input:
        tmp=v-t_input[k]
    else:
        tmp=v
    ans=max(tmp,ans)

print(max(ans,0))

Solution (Python):
def resolve():
	n = int(input())
	d = dict()
	for _ in range(n):
		v = input()
		if d.get(v):
			d[v] += 1
		else:
			d[v] = 1
	m = int(input())
	for _ in range(m):
		v = input()
		if d.get(v):
			d[v] -= 1
		else:
			d[v] = -1
	ans = float('-inf')
	for k in d.keys():
		ans = max(ans, d[k])
	print(max(ans, 0))
resolve()

Solution (Python):

from collections import defaultdict
n = int(input())
s = defaultdict(int)
for _ in range(n):
    s[input()] += 1

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


ans = 0
for k, v in s.items():
    if k in t:
        v -= t[k]
    ans = max(ans, v)
print(ans)

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

d = {}
for each in s:
  d[each] = d.get(each, 0) + 1
for each in t:
  d[each] = d.get(each, 0) - 1

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

Solution (Python):
import collections
S=int(input())
D=[]
for i in range(S):
   D.append(input())
D=collections.Counter(D)
N=int(input())
for i in range(N):
   J=input()
   D[J]-=1
N = D.most_common()[0][1]
if 0 < N:
   print(N)
else:
   print(0)

Solution (Python):
n = int(input())
n_word = [input() for nesya in range(n)]
m = int(input())
m_word = [input() for motsu in range(m)]
ans = 0
for nn in n_word:
  point = n_word.count(nn) - m_word.count(nn)
  if point > ans:
    ans = point
print(ans)

Solution (Python):


import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))

from collections import defaultdict
def resolve():
    N,=pin()
    a=defaultdict(lambda :0)
    for i in range(N):
        t=input()
        a[t]+=1
    M,=pin()
    for j in range(M):
        s=input()
        a[s]-=1
    t=(max(a.values()))          
    print(max(0,t))  

resolve()

Solution (Python):


import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))

from fractions import gcd
def resolve():
    N,=pin()
    a=dict()
    for i in range(N):
        t=input()
        a.setdefault(t,0)
        a[t]+=1
    M,=pin()
    for j in range(M):
        s=input()
        a.setdefault(s,0)
        a[s]-=1
    t=(max(a.values()))          
    print(max(0,t))  

resolve()

Solution (Python):
lwrd = list()
lcnt = list()

N = int(input())
for i in range(N):
    w = input()
    if w in lwrd:
        lcnt[lwrd.index(w)] += 1
    else:
        lwrd.append(w)
        lcnt.append(1)

M = int(input())
for i in range(M):
    w = input()
    if w in lwrd:
        lcnt[lwrd.index(w)] -= 1
    else:
        lwrd.append(w)
        lcnt.append(-1)

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

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

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

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

Solution (Python):
N = int(input())
s = []
syuugou = set()
for _ in range(N):
    i = input()
    s.append(i)
    syuugou.add(i)
M = int(input())
t = []
for _ in range(M):
    i = input()
    t.append(i)
    syuugou.add(i)
    
def counter(array):
    from collections import Counter
    return Counter(array)
t = counter(t)
s = counter(s)
ans = [0]
for x in syuugou:
    ans.append(s[x] - t[x])
print(max(ans))

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

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

    sc = Counter(s)
    tc = Counter(t)
    r = 0
    for sce in sc:
        r = max(r, sc[sce] - tc[sce])

    print(r)


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

dict = {}

for s in S:
    if s not in dict:
        dict[s] = 1
    else:
        dict[s] += 1

for t in T:
    if t not in dict:
        dict[t] = -1
    else:
        dict[t] -= 1

if max(dict.values()) <= 0:
    print(int(0))
else:
    print(max(dict.values()))

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)])
G = S-T
G["@"]=0
print(max([a for a in G.values()]))

Solution (Python):
import collections

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

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

CTR_blue = collections.Counter(blue)
CTR_red = collections.Counter(red)

maxx = 0

for v in CTR_blue.keys():
    cnt = CTR_blue[v] - CTR_red[v]
    
    maxx = max(cnt, maxx)

print(maxx)

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

Sdict = {}
Tdict = {}
N = int(input().rstrip())
for i in range(N):
  item = input().rstrip()
  if item not in Sdict.keys():
    Sdict[item] = 1
  else:
    Sdict[item] += 1
M = int(input().rstrip())
for i in range(M):
  item = input().rstrip()
  if item not in Tdict.keys():
    Tdict[item] = 1
  else:
    Tdict[item] += 1

ans_dict = {'0': 0}
for i in Sdict.keys():
  S = Sdict[i]
  if i not in Tdict:
    T = 0
  else:
    T = Tdict[i]
  ans_dict[i] = S-T

print(max(ans_dict.values()))

Solution (Python):
N = int(input())
S = []
for i in range(N):
    S.append(input())
T = []
M = int(input())
for i in range(M):
    T.append(input())
res = 0
for i in range(N):
    temp = S.count(S[i])-T.count(S[i])
    if res < temp:
        res = temp
print(res)

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

Solution (Python):
from collections import defaultdict
def solve():
    N = int(input())
    d = defaultdict(lambda: 0)
    for i in range(N):
        S = input()
        d[S] += 1
    M = int(input())
    for i in range(M):
        T = input()
        d[T] -= 1
    ans = 0
    for v in d.values():
        ans = max(ans,v)
    return ans
print(solve())

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

print(ans)

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
key = ''
for i in s.keys():
    ans = max((s[i]-t[i]), ans)

print(ans)

Solution (Python):
n=int(input())
s = [0]*n
for i in range(0,n):
  s[i]=str(input())
m=int(input())
t = [0]*m
for i in range(0,m):
  t[i]=str(input())
result=0
for i in range(0,n):
  p=s.count(s[i])-t.count(s[i])
  if p>result:
    result=p
print(result)

Solution (Python):
def main():
    from collections import defaultdict

    d = defaultdict(int)

    N = int(input())
    for _ in range(N):
        s = input()
        d[s] += 1

    M = int(input())
    for _ in range(M):
        t = input()
        d[t] -= 1

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


if __name__ == '__main__':
    main()

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

ans={}

for i in s:
    if i not in ans.keys():
        ans[i]=1
    else:
        ans[i]+=1
for j in t:
    if j not in ans.keys():
        ans[j]=-1
    else:
        ans[j]-=1
print(max(max(ans.values()),0))