Harryxun/stf_run huggingface dataset:
from itertools import product

INF = 10**18

N, M = map(int, input().split())
XYZ = [list(map(int, input().split())) for _ in range(N)]

# i番目までのケーキの内、j個食べた時のpointの最大値
# (ただしpointの計算時には、8通りのmaskを乗算する)

def mul_mask(l, mask):
    return [a*b for a, b in zip(l, mask)]

dp_std = [[-INF for _ in range(M+1)] for _ in range(N+1)]
for i in range(N+1):
    dp_std[i][0] = 0
# print(dp_std)

max_p = -INF
for mask in product([-1, 1], repeat=3):
    dp = dp_std.copy()
    for i in range(1, N+1):
        score = sum(mul_mask(XYZ[i-1], mask))
        for j in range(1, M+1):
            # print(i, j, XYZ[i-1], mask)
            dp[i][j] = max(
                dp[i-1][j],
                dp[i-1][j-1] + score
            )
            # for dp_i in dp:
            #     print(dp_i)
    p = dp[N][M]
    max_p = max(max_p, p)
    # print(p)

print(max_p)

### FIXED CODE ###

# from itertools import product

INF = 10**18

N, M = map(int, input().split())
XYZ = [list(map(int, input().split())) for _ in range(N)]

# i番目までのケーキの内、j個食べた時のpointの最大値
# (ただしpointの計算時には、8通りのmaskを乗算する)

def mul_mask(l, mask):
    p = []
    for i, m in enumerate(l):
        p.append(m*mask[i])
        # print(p)
    return p
    # return [a*b for a, b in zip(l, mask)]

dp_std = [[-INF for _ in range(M+1)] for _ in range(N+1)]
for i in range(N+1):
    dp_std[i][0] = 0
# print(dp_std)

max_p = -INF
# masks = product([-1, 1], repeat=3)
masks = []
for i in [1, -1]:
    for j in [1, -1]:
        for k in [1, -1]:
            masks.append([i, j, k])
# print(masks)
for mask in masks:
    dp = dp_std[:]
    for i in range(1, N+1):
        score = sum(mul_mask(XYZ[i-1], mask))
        for j in range(1, M+1):
            # print(i, j, XYZ[i-1], mask)
            dp[i][j] = max(
                dp[i-1][j],
                dp[i-1][j-1] + score
            )
            # for dp_i in dp:
            #     print(dp_i)
    p = dp[N][M]
    max_p = max(max_p, p)
    # print(p)

print(max_p)
# -*- coding: utf-8 -*-
# 整数の入力
a = int(input())
print(a)

### FIXED CODE ###

input = str(input())
check = input.isupper()

if check:
    print('A')
else:
    print('a')
dishes = []
serve = []
for i in range(5):
    dish = int(input())
    dishes.append(dish)
    if dish % 10 != 0:
        time = 10 - dish%10
        serve.append(time)
sort_serve = sorted(serve)
sort_serve.remove(sort_serve[len(sort_serve)-1])
if sort_serve == []:
    print(sum(dishes))
else:
    ans = sum(dishes) + sum(sort_serve)
    print(ans)

### FIXED CODE ###

dishes = []
serve = []
for i in range(5):
    dish = int(input())
    dishes.append(dish)
    if dish % 10 != 0:
        time = 10 - dish%10
        serve.append(time)
if serve == []:
    print(sum(dishes))
else:
    sort_serve = sorted(serve)
    sort_serve.remove(sort_serve[len(sort_serve)-1])
    ans = sum(dishes) + sum(sort_serve)
    print(ans)
n, a, b = map(int, input().split())
ans = 0
 
for i in range(n+1):
  	if a <= sum(list(map(int, list(str(i))))) <= b:
      	ans += i
print(ans)

### FIXED CODE ###

n, a, b = map(int, input().split())
ans = 0
for i in range(n+1):
    if a <= sum(list(map(int, list(str(i))))) <= b:
        ans += i
print(ans)
A, B, K = map(int, input().split())
l = list(range(A, B + 1))
print('\n'.join(map(str, sorted(l[:K] + l[-K:]))))


### FIXED CODE ###

A, B, K = map(int, input().split())

for i in range(A, min(A+K, B+1)):
    print(i)
for i in range(max(A+K, B-K+1), B+1):
    print(i)
limit = 100000
def resolve()
	N = int(input())
  	for k in range(N, limit+1):
        if k % 2 == 0 and k != 2:
            continue
        for divisor in range(2, math.floor(math.sqrt(k))+1):
            if k % divisor == 0:
              	print(k)
                break
resolve()

### FIXED CODE ###

limit = 100003
import math
def resolve():
    N = int(input())
    for k in range(N, limit+1):
        factor = 0
        if k % 2 == 0 and k != 2:
            continue
        for divisor in range(2, math.floor(math.sqrt(k))+1):
            if k % divisor == 0:
                factor += 1
        if factor == 0:
                return k
print(resolve())
from collections import Counter
N, P = map(int, input().split())
S = input()
L = len(str(P))
M = []
for i in range(10 ** L):
    M.append(i % P)

q = Counter([int(S[i:L-1]) for i in range(L-1)])
q[0] += 1
ans = 0
for i in range(L-1, N):
    nq = Counter()
    n = int(S[i])
    for a, c in q.items():
        s = (a * 10 + n) % P
        if s == 0:
            ans += c
        nq[s] += c
    nq[0] += 1
    q = nq
print(ans)

### FIXED CODE ###

from collections import Counter
N, P = map(int, input().split())
S = input()

ans = 0
if P in [2, 5]:
    for i, c in enumerate(S):
        if int(c) % P == 0:
            ans += i + 1
else:
    ct = Counter()
    ct[0] = 1
    prevmod = 0
    mods = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
    for i in range(N-1, -1, -1):
        n = int(S[i])
        mod = (mods[n] + prevmod) % P
        ans += ct[mod]
        ct[mod] += 1
        prevmod = mod
        mods = [10 * a % P for a in mods]
print(ans)
A=input()
B=input()
if A%B==0:
    print(A+B)
else:
    print(B-A)


### FIXED CODE ###

DATA=input()
DATA=DATA.split(" ")
A=int(DATA[0])
B=int(DATA[1])

if B%A==0:
    print(A+B)
else:
    print(B-A)
items=list(input.split())
    T_health=int(items[0])
    T_strength=int(items[1])
    A_health=int(items[2])
    A_strength=int(items[3])
    while(T_health>0 and A_health>0):
        A_health-=T_strength
        if(A_health>0):
            T_health-=A_strength
    if(T_health<=0):
        print("No")
    if(A_health<=0):
        print("Yes")

### FIXED CODE ###

def solve():
    items=list(input().split())
    T_health=int(items[0])
    T_strength=int(items[1])
    A_health=int(items[2])
    A_strength=int(items[3])
    while(T_health>0 and A_health>0):
        A_health-=T_strength
        if(A_health>0):
            T_health-=A_strength
    if(T_health<=0):
        print("No")
    if(A_health<=0):
        print("Yes")
    return
solve()
B = [False]*10005
C = [0]*10005
for i in range(2,10001):
    if not B[i]:
      	for j in range(i+i,10001,i):
          	B[j]=True
for i in range(3,10001,2):
    if not B[i] and not B[(i+1)//2]:
        C[i]+=1
for i in range(3,10001):
    C[i]=C[i]+C[i-1]
    
N = int(input())
for _ in range(N):
    a, b = map(int,input().split())
    print(C[b]-C[a-1])

### FIXED CODE ###

B = [False]*100005
C = [0]*100005
for i in range(2,100001):
    if not B[i]:
      	for j in range(i+i,100001,i):
          	B[j]=True
for i in range(3,100001,2):
    if not B[i] and not B[(i+1)//2]:
        C[i]+=1
for i in range(3,100001):
    C[i]=C[i]+C[i-1]
    
N = int(input())
for _ in range(N):
    a, b = map(int,input().split())
    print(C[b]-C[a-1])
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LLI(): return [int(x) for x in sys.stdin.readlines()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from bisect import bisect_left

def main():
    N, Q = LI()
    XST = []
    for _ in range(N):
        s, t, x = LI()
        XST.append([x, s, t])
    XST.sort()
    D = LLI()
    ans = [-1] * Q
    skip = [0] * Q
    for x, s, t in XST:
        i = bisect_left(D, s - x)
        end = bisect_left(D, t - x)
        while i < end:
            while skip[i] != 0:
                i += skip[i]
                if i >= end:
                    break
            ans[i] = x
            skip[i] = end - i
            i += 1
    for y in ans:
        print(y)
    return

main()


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from bisect import bisect_left

def main():
    N, Q = LI()
    XST = []
    for _ in range(N):
        s, t, x = LI()
        s -= x
        t -= x
        XST.append([x, s, t])
    D = []
    for _ in range(Q):
        D.append(II())
    ans = [-1] * Q
    nexts = [-1] * Q
    XST.sort()
    for x, s, t in XST:
        i = bisect_left(D, s)
        end = bisect_left(D, t)
        while i < end:
            if nexts[i] == -1:
                ans[i] = x
                nexts[i] = end
                i += 1
            else:
                i = nexts[i]
    for y in ans:
        print(y)
    return

main()
import numpy as np

def main():
    args1, args2 = input().rstrip().split(' '), input().rstrip().split(' ')
    N, M = int(args1[0]), int(args1[1])
    items = np.array([int(val) for val in args2])
    items = np.sort(items)[::-1]
    items_sum = np.sum(items)
    bottom = items_sum / 4. / M
    
    if(items[M-1] >= bottom):
        print('Yes')
    else:
        print('No')
    
if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    args = input().rstrip().split(' ')
    a, b, c = int(args[0]), int(args[1]), int(args[2])
    print('{} {} {}'.format(c, a, b))
    
if __name__ == "__main__":
    main()
N=input()
P=[int(i) for i in input().split()]
mes=[]

for i in range(len(P)):

	if i!=1 and i!=N-1:
		if (P[i+1]<P[i] and P[i+1]<=P[i-1]) or (P[i+1]<P[i] and P[i+1]<=P[i-1]):
			mes+=mes+P[i]

for n in mes:
	print(mes)
		
      

### FIXED CODE ###

N=int(input())
P=[int(i) for i in input().split()]
mes=0
for i in range(len(P)):

	if i!=0 and i!=N-1:
		if (P[i+1]<P[i] and P[i+1]<=P[i-1] and P[i]<=P[i-1])or(P[i-1]<P[i] and P[i-1]<=P[i+1] and P[i]<=P[i+1]):
			mes+=1
print(mes)
from itertools import repeat

n = int(input())
lis = list(map(int, input.split()))
d = [[0] for i in repeat(None, n)]

for i in lis:
  d[i - 1][0] += 1
  
for i in d:
  print(i[0])

### FIXED CODE ###

from itertools import repeat
 
n = int(input())
lis = list(map(int, input().split()))
d = [[0] for i in repeat(None, n)]
 
for i in lis:
  d[i - 1][0] += 1
  
for i in d:
  print(i[0])
n=int(input())
d=[int(input()) for i in range(n)]

sum=0
for i in range(n-1):
    for l in range(i+1,n):
        sum+=d[i]*d[l]
print(sum)


    

### FIXED CODE ###

n=int(input())
d=list(map(int,input().split()))
 
sum=0
for i in range(n-1):
    for l in range(i+1,n):
        sum+=d[i]*d[l]
print(sum)
A, P = map(int, input().split())

print((A * 3 + p) // 2)

### FIXED CODE ###

A, P = map(int, input().split())
 
print((A * 3 + P) // 2)
print 2**len(bin(input()))//4-1

### FIXED CODE ###

a=int(input())
k=2
while a>=k:k*=2
print(k-1)
n,m = map(int,input().split())
nm = ['#'] * n
nm.insert(0,0)
nm.insert(n+1,0)
nm = [nm]*m
nm.insert(0,[0]*(m+2))
nm.insert(m+1,[0]*(m+2))
ans = 0

for i in range(1,m+1):
    for j in range(1,n+1):
        cnt = 0
        if nm[i+1][j+1] == '#':
            cnt += 1
        if nm[i+1][j] == '#':
            cnt += 1
        if nm[i+1][j-1] == '#':
            cnt += 1
        if nm[i][j+1] == '#':
            cnt += 1
        if nm[i][j] == '#':
            cnt += 1
        if nm[i][j-1] == '#':
            cnt += 1
        if nm[i-1][j+1] == '#':
            cnt += 1
        if nm[i-1][j] == '#':
            cnt += 1
        if nm[i-1][j-1] == '#':
            cnt += 1
        if cnt % 2 != 0:
            ans+=1

print(ans)

### FIXED CODE ###

n,m = map(int,input().split())
print(abs((n-2)*(m-2)))
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
dishes = [a,b,c,d,e]
n = []
ans = 0
for i in range(5):
  if dishes[i]%10==0:
    ans += dishes[i]//10
  else:
    ans += dishes[i]//10+1
    n.append(dishes[i]%10) 
ans = ans*10-10+min(n)
print(ans)

### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
dishes = [a,b,c,d,e]
n = []
ans = 0
for i in range(5):
  if dishes[i]%10==0:
    ans += dishes[i]//10
  else:
    ans += dishes[i]//10+1
    n.append(dishes[i]%10)
if len(n)==0:
  print(ans*10)
else:
  ans = ans*10-10+min(n)
  print(ans)
S = input()
n = []
k=0
for c in S:
    if c in 'ACGT':
        k+=1
    elif k>0:
        n.append(k)
        k=0
if k>0: n.append(k)

print(max(n))

### FIXED CODE ###

S = input()
n = [0]
k=0
for c in S:
    if c in 'ACGT':
        k+=1
    elif k>0:
        n.append(k)
        k=0
if k>0: n.append(k)

print(max(n))
N = int(input())
A = list(map(int, input().split()))
l = [0] * 100000
for i in A:
    l[i] += 1
c = 0
nums = [0] * N
for i in range(N):
    nums[i] = l[i] * (l[i] - 1) / 2
s = sum(nums)
for i in range(N):
    a = A[i]
    print(int(s - nums[a - 1] + (l[a] - 1) * (l[a] - 2) / 2))


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
l = [0] * 10000001
for i in A:
    l[i] += 1
s = 0
for i in range(N + 1):
    i = l[i]
    s += i * (i - 1) // 2
for a in A:
    a = l[a]
    print(s - (a * (a - 1) // 2) + ((a - 1) * (a - 2) // 2))
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
AB.sort(key=lambda x: x[1], reverse=True)
memo = [0] * min(N, M)
ans = 0
for a, b in AB:
    Ma = max(M - a + 1, 0)
    for i in range(Ma, 0, -1):
        if memo[i - 1] == 0:
            memo[i - 1] = 1
            ans += b
            break
print(ans)

### FIXED CODE ###

import bisect


N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
AB.sort(key=lambda x: x[1], reverse=True)
memo = [x for x in range(N)]
ans = 0
for a, b in AB:
    if M < a:
        continue
    Ma = M - a
    i = bisect.bisect_right(memo, Ma)
    if i > 0:
        del memo[i - 1]
        ans += b
print(ans)
INF = 1e9
n,k = map(int, input().split())
x = list(map(int, input().split()))
ans = INF
for i in range(n-k):
    if x[i]*x[i+k-1]<0:
        a = abs(x[i])+x[i+k-1] + min(abs(x[i], x[i+k-1]))
    else:
        a = abs(x[i+k-1])
    
    ans = min(ans, a)

if k==1:
    ans = abs(x[0])
print(ans)

### FIXED CODE ###

INF = 1e9
n,k = map(int, input().split())
x = list(map(int, input().split()))
ans = INF
for i in range(n-k+1):
    if x[i]*x[i+k-1]>=0:
        ans = min(ans, max(abs(x[i]), abs(x[i+k-1])))
    else:
        a = min(abs(x[i]), abs(x[i+k-1]))
        b = max(abs(x[i]), abs(x[i+k-1]))
        ans = min(ans, a*2+b)
print(ans)
inport math
line = input().split(' ')
M = int(line[0])
N = int(line[1])
print(math.ceil(M/N))


### FIXED CODE ###

import math
line = input().split(' ')
M = int(line[0])
N = int(line[1])
print(math.ceil(M/N))
s=[]
for _ in range(int(input())):
 e=input()
 if e[0]=='i':s=[e.split()[1]]+s
 else:
  n=len(s)
  if n==6:s.remove(e.split()[1])
  elif n%2:s=s[1:]
  else:s.pop()
print(*s)


### FIXED CODE ###

import collections,sys
def s():
 d=collections.deque()
 input()
 for e in sys.stdin:
  if'i'==e[0]:d.appendleft(e[7:-1])
  else:
   if' '==e[6]:
    m=e[7:-1]
    if m in d:d.remove(m)
   elif'i'==e[7]:d.popleft()
   else:d.pop()
 print(*d)
if'__main__'==__name__:s()
X=int(input())
A=0
G=0
N=0
M=0
Z=0
N=X/500
M=int(X%500)
Z=M/5
N=N+Z
for i in range(0,N):
    if X-500:
        X=X-500
        G=G+1000
    elif X-5:
        X=X-5
        G=G+5
    else:
        break
        
print(G)

### FIXED CODE ###

X=int(input())
A=0
G=0
N=0
M=0
Z=0
N=int(X/500)
M=int(X%500)
Z=int(M/5)
N=N+Z
for i in range(0,N):
    if X>=500:
        X=X-500
        G=G+1000
    elif X>=5:
        X=X-5
        G=G+5
    else:
        break
        
print(G)
sentence = raw_input()
ans = []

for i in range(26):
  ans.append(0)

for string in sentence:
  string = string.strip()
  for s in string:
    string = string.lower()
    key = ord(string) - ord('a')
    if 0 <= key <= 25:
      ans[key] += 1

for i in range(len(ans)):
  print('{} : {}".format(chr(ord('a') + i), ans) 

### FIXED CODE ###

import sys
 
text = sys.stdin.readlines()
ans = []
for i in range(26):
    ans.append(0)
for i in text:
    i = i.strip()
    for j in i:
        j = j.lower()
        key = ord(j) - ord("a")
        if 0 <= key <= 25:
            ans[key] += 1
for i in range(len(ans)):
    print "{} : {}".format(chr(ord("a") + i), ans[i])
S = input()
Fa = int(S[:2])
Se = int(S[2:])
if 1 <= Fa,Se <= 12:
	print("AMBIGIOUS")
elif 1 <= Fa <= 12:
	print("MMYY")
elif 1 <= Se <= 12:
	print("YYMM")
else:
	print("NA")

### FIXED CODE ###

S = input()
Fa = int(S[:2])
Se = int(S[2:])
if 1 <= Fa <= 12 and 1 <= Se <= 12:
	print("AMBIGUOUS")
elif 1 <= Fa <= 12:
	print("MMYY")
elif 1 <= Se <= 12:
	print("YYMM")
else:
	print("NA")
x=int(input())
cac=0
cwa=0
tle=0
cre=0

for i in range(0,x):
    moji=input()
    if(moji='AC'):
        cac+=1
    if(moji='WA'):
        cwa+=1
    if(moji='TLE'):
        ctle+=1
    if(moji='RE'):
        cre+=1
print('AC x',cac)
print('WA x',cwa)
print('TLE x',ctle)
print('RE x',cre)

### FIXED CODE ###

x=int(input())
cac=0
cwa=0
ctle=0
cre=0

for i in range(0,x):
    moji=input()
    if(moji=='AC'):
        cac+=1
    if(moji=='WA'):
        cwa+=1
    if(moji=='TLE'):
        ctle+=1
    if(moji=='RE'):
        cre+=1
print('AC x ',cac)
print('WA x' ,cwa)
print('TLE x ',ctle)
print('RE x' ,cre)
str = input().split(" ")
S = str[0]
T = str[1]
num = input().split(" ")
NS = int(num[0])
NT = int(num[1])
U = input()

if S == U:
  print(str(NS - 1) + " " + str(NT))
else:
  print(str(NS) + " " + str(NT - 1))

### FIXED CODE ###

str = input().split(" ")
S = str[0]
T = str[1]
num = input().split(" ")
NS = int(num[0])
NT = int(num[1])
U = input()

if S == U:
  print(NS - 1, end=" ")
  print(NT)
else:
  print(NS, end=" ")
  print(NT - 1)
n , k , q = map(int, input().split())
a = [int(input()) for i in range(q)]
points = [k - q for i in range(n)]
for i in range(n):
    points[i-1] += a.count(i+1)
    if points[i] >= 1:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

S = input()

if S == 'Sunny':
    S_tomorrow = 'Cloudy'
elif S == 'Cloudy':
    S_tomorrow = 'Rainy'
else:
    S_tomorrow = 'Sunny'

print(S_tomorrow)
n = 1
N = int(input())

while True:
  if  26*(26**n-1)/25 >= N:
    break
  else:
    n +=1

alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
num = [0 for _ in range(n)]

for i in range(n):
  ii = n-i
  for j in range(1,27):
    if 26**(ii-1) * j >= N:
      if i != n-1:
        num[i] = alpha[j-2]
      else:
        num[i] = alpha[j-1]
      N -= 26**(ii-1) * (j-1)
      break

print(''.join(num))

### FIXED CODE ###

n = 1
N = int(input())

while True:
  if  26*(26**n-1)/25 >= N:
    break
  else:
    n +=1

alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
num = []

num = [0 for _ in range(n)]

for i in reversed(range(n)):
  for j in range(1,27):
    pre = 26*(26**i-1)/25
    if 26**i * j + pre >= N:
      num[i] = alpha[j-1]

      N -= 26**i * j
      break


print(''.join(num[::-1]))
import sys
import fractions


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, readline().split()))
    a = list(map(int, readline().split()))
    gcd = a[0]
    lcm = a[0]
    for i in range(1, n):
        gcd = fractions.gcd(lcm, a[i])
        lcm = lcm * a[i] // gcd
    if int(lcm / 2) - lcm / 2 == 0:
        print(max((m - (lcm // 2)) // lcm + 1, 0))
    else:
        print(0)


if __name__ == '__main__':
    solve()


### FIXED CODE ###

import sys
import fractions


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, readline().split()))
    a = [v >> 1 for v in list(map(int, readline().split()))]
    lcm = a[0]
    for v in a[1:]:
        gcd = fractions.gcd(lcm, v)
        if lcm // gcd % 2 == 0 or v // gcd % 2 == 0:
            print(0)
            exit()
        else:
            lcm = lcm * v // gcd
        if lcm > m:
            print(0)
            exit()
    print(m // lcm - m // (lcm * 2))


if __name__ == '__main__':
    solve()
n = int(input())
s = [input() for i in range(n)]

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

ans = 0

for str in s:#strは単語を表している。ループの回数としてはn回（sの配列数）
    count = s.oount(str)-t.count(str) #sの中にstr（たとえばapple)が何個あるか、tの中に同じく　str（spple)が何個あるか調べて引いてる。
    ans = max(ans,count)　

print(ans)
    


### FIXED CODE ###

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

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

ans = 0
for str in s: #strは単語を表している。ループの回数としてはn回（sの配列数）
    cou = s.count(str) - t.count(str) #sの中にstr（たとえばapple)が何個あるか、tの中に同じく　str（spple)が何個あるか調べて引いてる。
    ans = max(cou, ans)

print(ans)
x = int(input())
y = int(input())

if y==0:
 print(x+y)
else:
  print(int(x+(y/2)))


### FIXED CODE ###

X,Y = map(int,input().split())
 
print( X + (Y // 2))
t=input()
n=len(t)
a=[0]*n
for i in range(n):
    a[i]=t[i]

for i in range(n):
    if a[i]=="?":
        if a[i-1]="D" and a[i+1]=="?":
            a[i]=="p"
        elif a[i-1]=="P" and a[i+1]=="?":
            s[i]=="D"
        elif a[i-1]=="P":
            a[i]=="D"
        else:
            a[i]=="D"
    #print(a)

s=''.join(a)
print(s)


### FIXED CODE ###

t=input()
n=len(t)
a=[0]*n
for i in range(n):
    a[i]=t[i]

for i in range(n):
    if a[i]=="?":
        if i!=n-1:
            if a[i-1]=="D" and a[i+1]=="?":
                a[i]="P"
            elif a[i-1]=="P" and a[i+1]=="?":
                a[i]="D"
            elif a[i-1]=="D" and a[i+1]=="D":
                a[i]="P"
            else:
                a[i]="D"
        else:
            a[i]="D"
    #print(a)

s=''.join(a)
print(s)
mod = 10**9 + 7
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
 
for i in range(2, 10 ** 6 + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)
 
 
def comb(n, r, mod):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n-r] % mod

N, K = map(int, input().split())
R = N - K

ans = [0]*K
if R == 0:
  ans[0] = 1
elif R == 1:
  ans[0] = 2
  if K >= 2:
    ans[1] = (K-1) % mod
elif R == 2:
  ans[0] = 3
  if K >= 2:
    ans[1] = (3*K - 3) % mod
    if K >= 3:
      ans[2] = (K-1)*(K-2)//2 % mod
else:
  ans[0] = R + 1
  if K >= 2:
    if R > K:
      for i in range(2, K+1):
        ans[i-1] = comb(K-1, i-1)*(comb(R-1, i-2)+2*comb(R-1, i-1)+comb(R-1, i)) % mod
    else:
      for i in range(2, R):
        ans[i-1] = comb(K-1, i-1)*(comb(R-1, i-2)+2*comb(R-1, i-1)+comb(R-1, i)) % mod
      for i in range(R, K+1):
        ans[i-1] = comb(K-1, i-1)*(comb(R-1, i-2)+2*comb(R-1, i-1)) % mod

for a in ans:
  print(a)

### FIXED CODE ###

mod = 10**9 + 7
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range(2, 10 ** 6 + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)


def comb(n, r, mod):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n-r] % mod

N, K = map(int, input().split())
R = N - K
for i in range(1, K+1):
  print(comb(K-1, i-1, mod)*comb(R+1, i, mod) % mod)
n=int(input())
l=list(map(int,input().split()))
ans=[[]for i in range(max(l)+1)]
for i in range(n):
    ans[l[i]].append(i+1)

    
c=1
tem=[]
ch=0
while 1:
    if len(ans[c])==0:
        break
    else:
        flag=0
        for i in ans[c]:
            if i>ch:
                tem.append(i)
                ch=i
                flag=1
                break
        if not flag:
            break
        else:
            c+=1
                
                
if len(tem)==0:
    print(-1)
else:
    print(n-len(tem))
                
            

### FIXED CODE ###

n=int(input())
l=list(map(int,input().split()))
ans=[[]for i in range(n+1)]
for i in range(n):
    ans[l[i]].append(i+1)

    
c=1
tem=[]
ch=0
while 1:
    if c>n:
        break
    else:
        
        if len(ans[c])==0:
            break
        else:
            flag=0
            for i in ans[c]:
                if i>ch:
                    tem.append(i)
                    ch=i
                    flag=1
                    break
            if not flag:
                break
            else:
                c+=1
                    
                
if len(tem)==0:
    print(-1)
else:
    print(n-len(tem))