Problem:


Score : 200 points

Problem Statement

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

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

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

At most how much can he earn on balance?

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

Constraints

N and M are integers.

1 \leq N, M \leq 100

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

Input

Input is given from Standard Input in the following format:

N
s_1
s_2
:
s_N
M
t_1
t_2
:
t_M

Output

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

Sample Input 1

3
apple
orange
apple
1
grape

Sample Output 1

2

He can earn 2 yen by announcing apple.

Sample Input 2

3
apple
orange
apple
5
apple
apple
apple
apple
apple

Sample Output 2

1

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

Sample Input 3

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

Sample Output 3

0

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

Sample Input 4

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

Sample Output 4

1



Sample input:
3
apple
orange
apple
1
grape


Sample output:
2

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import statistics
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]
for i in range(M):
    if t[i] in s:
        s.remove(t[i])
if s ==list():
    print(0)
else:
    print(s.count(statistics.mode(s)))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# B - Two Colors Card Game
from collections import Counter
n = int(input())
n_dict = {}
for _ in range(n):
    ns = str(input())
    if ns not in n_dict.keys():
        n_dict[ns] = 1
    else:
        n_dict[ns] += 1

m = int(input()
m_dict = {}
for _ in range(n):
    ms = str(input())
    if ms not in m_dict.keys():
        n_dict[ms] = 1
    else:
        n_dict[ms] += 1

delta = dict(Counter(n_dict) - Counter(m_dict))
ans = max(delta.values())
print(ans)

Submission status: Runtime Error

Solution code:
s = [input() for _ in range(int(input()))]
t = [input() for _ in range(int(input()))]
ls = list(set(s))
temp=0
for l in ls:
    ans=0
    ans += 1 for ss in s if ss == l
    ans -= 1 for tt in t if tt == l
    temp = max(temp, ans)
print(temp)

Submission status: Runtime Error

Solution code:
s = [input() for _ in range(int(input()))]
t = [input() for _ in range(int(input()))]
ls = list(set(s))
temp=0
for l in ls:
    ans=0
    ans += 1 for ss in s if ss == l
    ans -= 1 for tt in t if tt == l
    temp = ans if ans>temp
print(temp)

Submission status: Runtime Error

Solution code:
s = [input() for _ in range(int(input()))]
t = [input() for _ in range(int(input()))]
ls = list(set(s))
temp=0
for l in ls:
    ans=0
    ans += 1 for ss in s if l == ss
    ans-=1 for tt in t if tt == l
    temp = ans if ans>temp
print(temp)

Submission status: Runtime Error

Solution code:
s = [input() for _ in range(int(input()))]
t = [input() for _ in range(int(input()))]
ls = set(s)
temp=0
for l in ls:
    ans=0
    ans += 1 for ss in s if l == ss
    ans-=1 for tt in t if tt == l
    temp = ans if ans>temp
print(temp)

Submission status: Runtime Error

Solution code:
s = [input() for _ in range(input())]
t = [input() for _ in range(input())]
ls = set(s)
ans=0
temp=0
for l in ls:
    for ss in s:
      ans += 1if l == ss
    ans-=1for tt in t if tt == l
    temp = ans if ans>temp
print(temp)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from collections import Counter

n = int(input())
b = [input() for _ in range(n)]
m = int(input())
r = [input() for _ in range(m)]

db, dr = [Counter(x) for x in (b, r)]

print(max(*(v-dr[k] for k, v in db.items()), 0))

Submission status: Runtime Error

Solution code:
from collections import Counter
n = int(input())
b = [input() for _ in range(n)]
m = int(input())
r = [input() for _ in range(m)]

db = Counter(b)
dr = Counter(r)

print(max(*(v-dr[k] for k, v in db.items()), 0))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
sL = [input() for i in range(n)]
m = int(input())
tL = [input() for i in range(m)]
L = list(set(sL))
maxnum = 0
for i in range(len(L)):
    num = max(0, max(sL.count(L[i])-tL.count(L[i])))
    if num > maxnum:
        maxnum = num
print(maxnum)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
blue = {}
for _ in range(n):
  s = input()
  blue[s] += 1
m = int(input())
red = {}
for _ in range(m):
  t = input()
  red[t] += 1
res = -100
for key, value in blue.items():
  tmp = 0
  if(key in red):
    tmp = blue[key] - red[key]
  else:
    tmp = blue[key]
  if(tmp > res):
    res = tmp
print(res)

Submission status: Runtime Error

Solution code:
n = int(input())
blue = {}
for _ in range(n):
  s = input()
  blue[s] += 1
m = int(input())
red = {}
for _ in range(m):
  t = input()
  red[t] += 1
res = -100
for key, value in blue:
  tmp = 0
  if(key in red):
    tmp = blue[key] - red[key]
  else:
    tmp = blue[key]
  if(tmp > res):
    res = tmp
print(res)

Submission status: Runtime Error

Solution code:
BlueN = int(input())
BlueList = []
for i in range(1,BlueN):
  BlueList.append(input())

RedN = int(input())
RedList = []
for i in range(1,RedN):
  RedList.append(input())

stocker = 0

for i in set(BlueList):
  if BlueList.count(i) * 1 + RedList.count(i) * -1 >= stocker:
    stocker = BlueList.count(i)

print(stocker)

Submission status: Runtime Error

Solution code:
a = int(input())
b = [input() for i in range(a)]
c = int(input())
d = [input() for j in range(c)]
g = [0]*a
for k in b:
    e = b.count(k)
    f = d.count(k)
    g[k] = e - f
print(max(g))

Submission status: Runtime Error

Solution code:
nN = int(input())
 
sListA = []
nListA = [ 0 for i in range(nN)]
 
for i in range(nN):
  sTmp = input()
  if sTmp in sListA:
    nTmp = sListA.index(sTmp)
    nListA[nTmp] += 1
  else:
    sListA.append(sTmp)
    nTmp = sListA.index(sTmp)
    nListA[nTmp] += 1
 
    
nN = int(input())
sListB = []
nListB = [ 0 for i in range(nN)]
 
for i in range(nN):
  sTmp = input()
  if sTmp in sListA:
    nTmp = sListA.index(sTmp)
    nListA[nTmp] -= 1
  else:
    sListA.append(sTmp)
    nTmp = sListA.index(sTmp)
    nListA[nTmp] -= 1
 
nMax = max(nListA)
# print(sListA)
print(nMax)

Submission status: Runtime Error

Solution code:

n = int(input())
ss = [input() for _ in range(n)]
m = int(input())
tt = [input() for _ in range(n)]

res = 0
for u in ss:
    tmp = ss.count(u) - tt.count(u)
    res = max(res, tmp)
print(res)

Submission status: Runtime Error

Solution code:
nm = int(input())
n = [input() for _ in range(nm)]
mm = int(input())
m = [input() for _ in range(mm)]
s = list(set(n))

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

Submission status: Runtime Error

Solution code:
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]
s_set = list(set(s))
t_set = list(set(t))
check_list = []
for i in s_set:
    check_list.append(s.count(i) - t.count(i))
print(max(max(check_list), 0)

Submission status: Runtime Error

Solution code:
n = int(input())
d= {}
for _ in range(n):
    i = input()
    if i in d:
        d[i] += 1
    else: d[i] = 1

for _ in range(int(input())):
    i = input()
    if i in d:
        d[i] -= 1

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

Submission status: Runtime Error

Solution code:
N = int(input())
s = [int(input()) for i in range(N)]
M = int(input())
t = [int(input()) for i in range(M)]
cs = collections.Counter(s)
ct = collections.Counter(t)
print(max(0, cs.most_common()[0][1] - ct.most_common()[0][1]))

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Your code here!

from collections import defaultdict

n = int(input())
x = [input() for _ in range(n)]
m = int(input())
y = [input() for _ in range(n)]

dx = defaultdict(int)
dy = defaultdict(int)

for temp_x in x:
    dx[temp_x] += 1
for temp_y in y:
    dy[temp_y] += 1
    
max_count = 0
for k in dx.keys():
    max_count = max(max_count, dx[k] - dy[k])
    
print(max_count)

Submission status: Runtime Error

Solution code:
import sys

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(blues, reds):
    blue_counts = {}
    red_counts = {}

    for b in blues:
        if b not in blue_counts:
            blue_counts[b] = 1
        else:
            blue_counts[b] += 1

    for r in reds:
        if r not in red_counts:
            red_counts[r] = 1
        else:
            red_counts[r] += 1

    max_count = 0
    for name, c in blue_counts.items():
        if name in red_counts:
            max_count = max(max_count, c - red_counts[name])
        else:
            max_count = max(max_count, c)
    return max_count


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    [N] = string_to_int(inputs())
    blues = inputs(N)
    [M] = string_to_int(inputs())
    reds = inputs(M)
    ret = solve(blues, reds)
    print(ret)

Submission status: Runtime Error

Solution code:
N = int(input())
S = [int(input()) for i in range(N)]
M = int(input())
T = [int(input()) for i in range(M)]
 
Scores = []
for s in S:
  score = len([s2 for s2 in S if s == s2])
  score -= len([s2 for s2 in T if s == s2])
  Scores.append(score)
print(max(Scores))

Submission status: Runtime Error

Solution code:
N=int(input())
result={}
s=[]
t=[]
for i in range(N):
  s.append(input())
  if s[i] in result.keys():
    result[s[i]]+=1
  else:
    result[s[i]]=1
M=int(input())
for j in range(M):
  t.append(input())
  if t[j] in result.keys():
    result[t[j]]-=1
print(max(k for k in result.values() if k > 0))

Submission status: Runtime Error

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

name_union = set(s) | set(t)
money = {}0
for i, n in enumerate(name_union):
  money.setdefault(n, 0)
  money[n] += sum(map(lambda x: 1 if x == n else 0, s))
  money[n] -= sum(map(lambda x: 1 if x == n else 0, t))
print(0 if max(money.values()) < 0 else max(money.values()))

Submission status: Runtime Error

Solution code:
n = int(input())
lsn = [input() for _ in range(n)]
m = int(input())
lsm = [input() for _ in range(m)]

from collections import defaultdict

d = defaultdict(str)

for i in lsn:
    d[i] += 1
for j in lsm:
    d[j] -= 1

cnt = 0
for k in d.values():
    if k > 0:
        cnt +=k

print(cnt)

Submission status: Runtime Error

Solution code:
d = dict()

def getv():
  M = int(input())
  for x in range(M):
    n = input()
    if d.get(n) is None:
      d[n] = 0
    d[n] += 1

getv(1)
getv(-1)

print(sorted(d, key=lambda x:x[1], reverse=True)[0])

Submission status: Runtime Error

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

s.sort()
t.sort()

ans = 0
sset = set(s)

for si in sset:
    ans = max(ans, s.count(si)-t.coutn(si))
print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
r=[]
for i in range(n):
    a,b=map(int,input().split())
    r.append((a,b))
l=[]
for i in range(n):
    c,d=map(int,input().split())
    l.append((c,d))


r.sort()
l.sort(key=lambda x:x[1],reverse=1)
ans=0
for s,t in r.copy():
    for p,q in l.copy():
        if s<p and t<q:
            ans+=1
            r.remove((s,t))
            l.remove((p,q))
            break
print(ans)

Submission status: Runtime Error

Solution code:
ans = 0
n = int(input())
blue = [input() for i in range(n)]
m = int(input())
red = [input() for i in range(m)]
for i in range(m):
    if red[m] in blue:
        blue.remove(red[m])
for j in list(set(blue)):
    if blue.count(j) > ans:
        ans = blue.count(j)
print(ans)

Submission status: Runtime Error

Solution code:
ans = 0
n = int(input())
blue = [input() for i in range(n)]
m = int(input())
red = [input() for i in range(m)]
print(blue)
for i in range(m):
    if red[m] in blue:
        blue.remove(red[m])
for j in list(set(blue)):
    if blue.count(j) > ans:
        ans = blue.count(j)
print(ans)

Submission status: Runtime Error

Solution code:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n,m;
  cin>>n;
  vector<string> blue(n);
  rep(i,n){
    cin>>blue[i];
  }
  cin>>m;
  vector<string> red(m);
  rep(i,m){
    cin>>red[i];
  }
  int ans=0;
  rep(i,n){
    int count=0;
    rep(j,n){
      if(blue[i]==blue[j]){count++;}
    }
    rep(l,m){
      if(blue[i]==red[l]){count--;}
    }
    ans=max(ans,count);
  }
  cout<<ans;
}

Submission status: Runtime Error

Solution code:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n,m;
  cin>>n;
  vector<string> blue(n);
  rep(i,n){
    cin>>blue[i];
  }
  cin>>m;
  vector<string> red(m);
  rep(i,m){
    cin>>red[i];
  }
  int ans=0;
  rep(i,n){
    int count=0;
    rep(j,n){
      if(blue[i]==blue[j]){count++;}
    }
    rep(j,m){
      if(blue[i]==red[j]){count--;}
    }
    ans=max(ans,count-1);
  }
  cout<<ans;
}

Submission status: Runtime Error

Solution code:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n,m;
  cin>>n;
  vector<string> blue(n);
  rep(i,n){
    cin>>blue[i];
  }
  cin>>m;
  vector<string> red(m);
  rep(i,m){
    cin>>red[i];
  }
  int ans=0;
  rep(i,n){
    int count=0;
    rep(j,n){
      if(blue[i]==blue[j]){count++;}
    }
    rep(j,m){
      if(blue[i]==red[j]){count--;}
    }
    ans=max(ans,count);
  }
  cout<<ans;
}

Submission status: Runtime Error

Solution code:
N = int(input())
s = []
for _ in range(N):
    s.append(input())
M = int(input())
t = []
for _ in range(M):
    t.append(input())
ans = []
for ss in set(s):
    ans.append(s.count(ss) - t.count(ss))
p = ans if ans > 0 else 0
print(p)

Submission status: Runtime Error

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

ans = 0
for i in range(N):
  x = S[i]
  cnt1 = S.count(x)
  cnt2 = T.count(x)
  ans = max(cnt1-cnt2,ans)
print(ans)

Submission status: Runtime Error

Solution code:
import collections

blue = int(input())
blue_string = [input() for i in range(blue)]
blue_type = set(blue_string)
red = int(input())
red_string = [input() for i in range(red)]
red_type = set(red_string)
blue_number = len(blue_type)
result = [0]

for i in range(blue_number):
    blue_sort = blue_type[i]
    bulue_sort_count = blue_string.count(blue_sort)
    red_sort_count = red_string.count(blue_sort)
    result.append(bulue_sort_count - red_sort_count )
print(max(result))

Submission status: Runtime Error

Solution code:
3
apple
orange
apple
1
grape

Submission status: Runtime Error

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


mine = 0
    
flags = [1] * N

for i in range(N):
    plus = 1
    minus = 0
    
    if flags[i] == 0:
        continue
        
    if flags[i] == 1:
        flags[i] = 0
    
    for j in range(i+1, N):
        if s[i] == s[j]:
            plus += 1
            flags[j] = 0
            
    for k in range(M):
        if s[i] == t[k]:
            minus += 1
            
    mine = max[mine, plus - minus]       

    
print(mine)

Submission status: Runtime Error

Solution code:
# 2019/05/16
# AtCoder Beginner Contest 091 - B

# Input
n = int(input())
bc = list()
for i in range(n):
    bc.append(input())

m = int(input())
rc = list()
for j in range(m):
    rc.append(input())

bc.sort()
rc.sort()

# Count up
strdict = dict()
wk_str = bc[0]
wk_cnt = 1
for i in range(1, n):
    if wk_str != bc[i]:
        strdict[wk_str] = wk_cnt
        wk_cnt = 1
        wk_str = bc[i]
    else:
        wk_cnt += 1

strdict[wk_str] = wk_cnt

wk_str = rc[0]
wk_cnt = 1

for j in range(1, m):
    if wk_str != rc[i]:
        strdict[wk_str] += wk_cnt * -1
        wk_cnt = 1
        wk_str = rc[i]
    else:
        wk_cnt += 1

strdict[wk_str] += wk_cnt * -1

# Search max
maxval = -101
for k in strdict.keys():
    if maxval < strdict[k]:
        maxval = strdict[k]

ans = max(maxval, 0)

# Output
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from collections import Counter
def main(s, t):
    s_c = sorted(Counter(s).items(), key=lambda x: -x[1])
    t_c = Counter(t)
    for i, (k, v) in enumerate(s_c):
        benefit = v - t_c[k]
        if s_c[i + 1][1] <= benefit:
            print(benefit)
            break
    else:
        print(benefit)

if __name__ == '__main__':
    N = int(input().strip())
    s = [input().strip() for _ in range(N)]
    M = int(input().strip())
    t = [input().strip() for _ in range(M)]
    main(s, t)

Submission status: Runtime Error

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

for i in range(n):
  for j in range(m):
    if s[i] == s[j]:
      ans-=1
if ans < 0:
  print("0")
else:
  print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())

b = {}
for i in range(N):
  s = str(input())
  if b.get(s) is None:
    b[s] = 1
  else:
    b[s] += 1
    
r = {}
for i in range(N):
  s = str(input())
  if r.get(s) is None:
    r[s] = 1
  else:
    r[s] += 1

ans = -999999
for st in b:
  if r.get(st) is None:
    ans = max(ans, b[st])
  else:
    ans = max(ans, b[st] - r[st])
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
num = int(input())
dic = { "JPY": 0, "BTC": 0 }
for i in range(0, num):
    val, coin = input().split(' ')
    dic[coin] += float(val)
print(dic["JPY"] + (dic["BTC"] * 380000.0))

def two_colors_card_game():
dic_words = {}
for i in range(0, int(input())):
    word = input()
    if word in dic_words.keys():
        dic_words[word] += 1
    else:
        dic_words[word] = 1

for i in range(0, int(input())):
    word = input()
    if word in dic_words.keys():
        dic_words[word] -= 1
    else:
        dic_words[word] = -1

if (max(dic_words.values()) >= 0):
    print(max(dic_words.values()))
else:
    print(0)

Submission status: Runtime Error

Solution code:
from collections import Counter as cnt

N = int(input())
blue = []
for i in range(N):
  blue.append(int(input()))
blue = cnt(blue)
N = int(input())
red = []
for i in range(N):
  red.append(int(input()))
red = cnt(red)

p = blue - red
print(p.most_common()[0][1])

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
#ABC 091 B - Two Colors Card Game
import collections
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
c = collections.Counter(s) - collections.Counter(t)
print(c.most_common()[0][1])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import collections
n = int(input())
blue = []
red = []
for i in range(n):
    blue.append(input())
m = int(input())
for j in range(m):
    red.append(input())

blue_dict = collections.Counter(blue)
red_dict = collections.Counter(red)
count_list = []
for b_key, b_value in blue_dict.items():
    for r_key, r_value in red_dict.items():
        if b_key == r_key:
            count_list.append(b_value - r_value)
print('出力 : {}'.format(max(count_list)))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import collections

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

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

Submission status: Runtime Error

Solution code:
# coding: utf-8
N = int(input())
S = {}
for _ in range(N):
    s = input()
    if s not in S:
        S[s] = 0
    S[s] += 1
M = int(input())
for _ in range(M):
    s = input()
    if s not in S:
        S[s] = 0
    S[s] -= 1
print(max(*S.values(), 0))

Submission status: Runtime Error

Solution code:
# coding: utf-8
from collections import defaultdict
N = int(input())
S = defaultdict(int)
for _ in range(N):
    S[input()] += 1
M = int(input())
for _ in range(M):
    S[input()] -= 1
print(max(*S.values(), 0))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:

N=int(input())
L=[input() for i in range(N)]
M=int(input())
S=[input() for i in range(M)]
A=[0]
for i in range(N):
  A.append(L.count(L[i])-S.count(S[i]))

print(max(A))

Submission status: Runtime Error

Solution code:
from collections import Counter
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)

B = int(input())
Lb = [input() for _ in range(B)]
R = int(input())
Lr = [input() for _ in range(R)]

Cb = Counter(Lb)
Cr = Counter(Lr)

cand = []
for i, v in Cb.items():
    cand.append(v-Cr[i])
ans = max(list(filter(lambda x: x > 0, cand)))
print(ans)

Submission status: Runtime Error

Solution code:
from collections import Counter
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)

B = int(input())
Lb = [input() for _ in range(B)]
R = int(input())
Lr = [input() for _ in range(R)]

Cb = Counter(Lb)
Cr = Counter(Lr)

cand = []
for i, v in Cb.items():
    cand.append([v-Cr[i]])
ans = sum(list(filter(lambda x: x > 0, cand)))
print(ans)

Submission status: Runtime Error

Solution code:
import collections
n=int(input())
s=[str(input()) for i in range(n)]
m=int(input())
t=[str(input()) for i in range(m)]
s_s=set(s)
t_s=set(t)
#import pdb;pdb.set_trace()
s_c=collections.Counter(s)
t_c=collections.Counter(t)
a_l=[]
for i in s_c.keys():
    a_l.append(s_c[i]-t_c[i])
if max(a_l)>0:
    ans=max(a_l)
else:
    ans=0
print(ans)
import pdb;pdb.set_trace()

Submission status: Runtime Error

Solution code:
n=int(input())
s=[]
for x in range(n):
    s.append(input())
m=int(input())
t=[]
for y in range(m):
    t.append(input())
m=0
for i in range(n):
    v=s[i]
    c=0
    for k in range(i,n):
        if v==s[k]:
            c+=1
    for j in range(m):
        if v==t[j]:
            c-=1
    if c>m:
        m=c
print(m)

Submission status: Runtime Error

Solution code:
    from collections import defaultdict
    a = int(input())
    d = defaultdict(int)
    for i in range(a):
        k = input()
        d[k] += 1
    b = int(input())
    for i in range(b):
        k = input()
        d[k] -= 1
     
    c = d[0]
    for i in range(len(d)):
        c = max(c, d[k])
    print(c)

Submission status: Runtime Error

Solution code:
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 s in S:
  score = 0
  for s2 in S:
    if s == s2:
      score += 1
  for t in T:
    if s == t:
      score -= 1
  ans = max(ans, score)

print(ans)

Submission status: Runtime Error

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

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

ans = 0
for s in S:
  score = 0
  for s2 in S:
    if s == s2:
      score += 1
  for t in T:
    if s == t:
      score -= 1
  ans = max(ans, score)

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
I=lambda:[input()for _ in[0]*int(input())].count;s=I();t=I();print(max([0]+[s(i)-t(i)for i in set(s)]))

Submission status: Runtime Error

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

tmp_S = {}
for s in S:
  if(s in tmp_S):
    tmp_S[s] += 1
  else:
    tmp_S[s] = 1
for t in T:
  if(t in tmp_S):
    tmp_S[t] -= 1
print(max(0, tmp_S.values()))

Submission status: Runtime Error

Solution code:
n = int(input())
dc = {}
for i in range(n):
  s = input()
  if s in dc:
    dc[s] += 1
  else :
    dc[s] = 1
m = int(input())
for i in range(n):
  t = input()
  if t in dc:
    dc[t] -= 1
  else :
    dc[t] = -1
ans = 0
for i in dc:
  ans = max(ans, dc[i])
print(ans)

Submission status: Runtime Error

Solution code:
a=int(input())
A=[]
for i in range(n):
  A.append(input())
m=int(input())
B=[]
for j in range(m):
  B.append(input())
ans=[]
for i in A:
  ans.append(A.count(i)-B.count(i))
print(max(ans))

Submission status: Runtime Error

Solution code:
n = int(input())
s = {}
for i in range(n):
    d = input()
    if d in s:
        s[d] += 1
    else:
        s.update({d:1}) 

m = int(input())
for j in range(m):
    t = input()
    if t in s:
        s[t] -= 1
    else:
        s.update({t:-1})

print("0" if max(d.values()) < 0 else max(d.values()))

Submission status: Runtime Error

Solution code:
n = int(input())
s = {}
for i in range(n):
    d = input()
    if d in s:
        s[d] += 1
    else:
        s.update({d:1}) 

m = int(input())
for j in range(m):
    t = input()
    if t in s:
        s[t] -= 1
    else:
        s.update({t:-1})

print(0 if max(d.values()) < 0 else max(d.values()))

Submission status: Runtime Error

Solution code:
b=int(input())
a=[for i in range(b)]
r=int(input())
c=[for i in range(r)]
cnt=0
for i in range(b):
  cnt=max(cnt,a.count(a[i])-c.count(a[i]))
print(cnt)

Submission status: Runtime Error

Solution code:
N = int(input())

N_list = []
M_list = []
answer = -100

for i in range(N):
	s = input()
	N_list.append(s)

N = int(input())

for i in range(M):
	t = input()
	M_list.append(s)

for i in range(N):
	S = N_list[i]
	plus  = N_list.count(S)
	minus = M_list.count(S)
	if answer < (plus - minus):
		answer = (plus - minus)

print(answer)

Submission status: Runtime Error

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

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

sum = 0
for i in range(N):
    temp = 0
    sample = s[i]
    for j in range(N):
        if sample == s[j]:
            temp += 1
    for k in range(M):
        if sample == t[k]:
            temp -= 1
    if temp > sum:
        sum = temp
print(sum)

Submission status: Runtime Error

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

judge = 0
for l in range(N):
  money = s.count(s[l]) - t.count(s[l])
  
  if( judge < money):
    judge = money
  
  else:
    continue
    
print(judge)

Submission status: Runtime Error

Solution code:
import collections
n_co = collections.Counter()
m_co = collections.Counter()

n = int(input())

for i in range(n):
	ni = input()
	n_co[ni] += 1

m = int(input())

for j in range(m):
	mi = input()
	m_co[mi] += 1

ans = (n_co - m_co).most_common(1)

print(ans[0][1])