Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import sys
def input(): return sys.stdin.readline().rstrip()
sys.setrecursionlimit(10 ** 7)

reverse = 0
S = input()
Q = int(input())
for i in range(Q):
    q = input()
    if q[0] == '1':
        reverse = 1 - reverse
    else:
        T, F, C = q.split()
        if (F == '1') ^ (reverse == 1):
            S = C + S
        else:
            S += C
if reverse:
    S = S[::-1]
print(S)


### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().rstrip()
sys.setrecursionlimit(10 ** 7)

reverse = 0
pre = []
after = []
S = input()
Q = int(input())
for i in range(Q):
    q = input()
    if q[0] == '1':
        reverse = 1 - reverse
    else:
        T, F, C = q.split()
        if (F == '1') ^ (reverse == 1):
            pre.append(C)
        else:
            after.append(C)
if reverse:
    after.reverse()
    ans = ''.join(after) + S[::-1] + ''.join(pre)
else:
    pre.reverse()
    ans = ''.join(pre) + S + ''.join(after)
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

n, c, k = [int(w) for w in input().split()]
la = [int(input()) for _ in range(n)]
la.sort()
lak = [a + k for a in la]

ind = 0
ans = 0
while ind < n:
    ride = 0
    for i in range(min(c, n - ind)):
        if la[ind + i] <= lak[ind]:
            ride += 1
    ind += ride
    ans += 1

print(ans)


### FIXED CODE ###

import sys
import bisect
input = sys.stdin.readline

n, c, k = [int(w) for w in input().split()]
la = [int(input()) for _ in range(n)]
la.sort()
lak = [a + k for a in la]

ind = 0
ans = 0
while ind < n:
    ride = bisect.bisect_right(la, lak[ind]) - ind
    ind += min(ride, c)
    ans += 1

print(ans)
### BUGGY CODE ###

# import math
# from collections import Counter

# N = int(input()) # 1行, 単数
# arg = list(map(int, input().split())) # 1行, 配列
# D = Counter(arg) # 出現数カウント

# print('Yes')
# print('No')
# print()


NM = list(map(int, input().split())) # 1行, 配列

N = NM[0]
M = NM[1]
H = list(map(int, input().split())) # 1行, 配列

AB=[]
while True:
  try:
    AB.append(list(map(int,input().split())))

  except:
    break;

good = 0


# for load in AB:

A = []
B = []


for i, item in enumerate(H):
  targetLoad = []
  # targetLoad = [H[list(set(load) - set([i+1]))[0]-1] for load in AB if list(set(load) - set([i+1])) == 1]
  for load in AB:
    if load[0] == i+1:
      targetLoad.append(H[load[1]-1])
    if load[1] == i+1:
      targetLoad.append(H[load[0]-1])
    # t = list(set(load) - set([i+1]))
    # if len(t) == 1:
    #   targetLoad.append(H[t[0]-1])
  if len(targetLoad) == 0:
      good = good + 1
  else:
    if max(targetLoad) < item:
      good = good + 1

print(good)

### FIXED CODE ###

# import math
# from collections import Counter

# N = int(input()) # 1行, 単数
# arg = list(map(int, input().split())) # 1行, 配列
# D = Counter(arg) # 出現数カウント

# print('Yes')
# print('No')
# print()


N,M = map(int, input().split()) # 1行, 配列
H = list(map(int, input().split())) # 1行, 配列

AB={}

while True:
  try:
    A,B = map(int, input().split())
    AB.setdefault(A, []).append(H[B-1])
    AB.setdefault(B, []).append(H[A-1])
  except:
    break;

good = 0

for i, item in enumerate(H):

  try:
    targetLoad = AB[i+1]
    if max(targetLoad) < item:
      good = good + 1
  except:
    good = good + 1

print(good)
### BUGGY CODE ###

s=input()
t=input()
u=input()
a=b=c=0
now = 0
while 1:
  if now == 0:
    if s[a] == 'a':
      now = 0
    elif s[a] == 'b':
      now = 1
    else:
      now = 2
    if a==len(s):
      print('A')
      break
  elif now == 1:
    if s[b] == 'a':
      now = 0
    elif s[b] == 'b':
      now = 1
    else:
      now = 2
    if b==len(t):
      print('B')
      break
  else:
    if s[c] == 'a':
      now = 0
    elif s[c] == 'b':
      now = 1
    else:
      now = 2
    if c==len(u):
      print('C')
      break

### FIXED CODE ###

s=input()
t=input()
u=input()
a=b=c=0
now = 0
while 1:
  if now == 0:
    if a==len(s):
      print('A')
      break
    if s[a] == 'a':
      now = 0
    elif s[a] == 'b':
      now = 1
    else:
      now = 2
    a+=1
  elif now == 1:
    if b==len(t):
      print('B')
      break
    if t[b]=='a':
      now = 0
    elif t[b]== 'b':
      now = 1
    else:
      now = 2
    b+=1
  else:
    if c==len(u):
      print('C')
      break
    if u[c]== 'a':
      now = 0
    elif u[c]== 'b':
      now = 1
    else:
      now = 2
    c+=1
### BUGGY CODE ###

import math
import bisect


def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    needed_prime = []
    data = [i + 1 for i in range(1, n)]
    i = 0
    for i in range(9592):
        p = data[0]
        prime.append(p)
        if int((p + 1) / 2) in prime and p != 2:
            needed_prime.append(p)
            #print(needed_prime)
        data = [e for e in data if (e % p != 0)]
    return needed_prime


arr = get_sieve_of_eratosthenes(100000)

Q = int(input())
for q in range(Q):
    l, r = map(int, input().split())
    left_ind = bisect.bisect_left(arr, l)
    right_ind = bisect.bisect_right(arr, r)
    print(right_ind - left_ind)

### FIXED CODE ###

import bisect
import math

def prime(n):
    for j in range(2, int(math.sqrt(n) + 1)):
        if n % j == 0:
            return False
    return True

lis = []
for i in range(3, 100000, 2):
    if prime(i) and prime((i + 1) / 2):
        lis.append(i)

Q = int(input())
for q in range(Q):
    l, r = map(int, input().split())
    left_ind = bisect.bisect_left(lis, l)
    right_ind = bisect.bisect_right(lis, r)
    print(right_ind - left_ind)
### BUGGY CODE ###

n=int(input())
a=input().split()
a=list(map(int,a))
i=0
ans=1
for calc in a:
    if(0 in a):
        print(0)
        exit()
    ans=ans*calc
    if(ans>1000000000000000000):
        print(-1)
        exit()
    i+=1
    if(i==n):
        break
if(ans>1000000000000000000):
    print(-1)
else:
    print(ans)


### FIXED CODE ###

n=int(input())
a=input().split()
a=list(map(int,a))
ans=1
if(0 in a):
    print(0)
    exit()

for calc in a:
    ans*=calc
    if(ans>10**18):
        print(-1)
        exit()
if(ans>10**18):
    print(-1)
else:
    print(ans)
### BUGGY CODE ###

import sys

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

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

def cmp(x, y, l):
	if len(x) < len(y):
		x, y = y, x
	lx = int(l/len(x))
	ly = int(l/len(y))
	for i in range(l):
		if i%lx == 0 and i%ly == 0 and x[int(i/lx)] != y[int(i/ly)]:
			return False
	return True

if __name__ == '__main__':
	N, M = list(map(int, input().split()))
	S = input()
	T = input()
	L = lcm(N,M)
	if not cmp(S,T,L):
		print(-1)
	else:
		print(L)


### FIXED CODE ###

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

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

def cmp(x, y, l):
	if len(x) < len(y):
		x, y = y, x
	lx = int(l/len(x))
	ly = int(l/len(y))
	lc = lcm(lx,ly)
	lt = [i*lc for i in range(int(l/lc))]
	for i in lt:
		if i%lc == 0 and x[int(i/lx)] != y[int(i/ly)]:
			return False
	return True

def cmp2(x, y, l):
	if len(x) < len(y):
		x, y = y, x
	lx = int(l/len(x))
	ly = int(l/len(y))
	for i in range(l):
		if i%lx == 0 and i%ly == 0 and x[int(i/lx)] != y[int(i/ly)]:
			return False
	return True


if __name__ == '__main__':
	N, M = list(map(int, input().split()))
	S = input()
	T = input()
	L = lcm(N,M)
	if not cmp(S,T,L):
		print(-1)
	else:
		print(L)
### BUGGY CODE ###

from math import factorial

N, M, K = map(int, input().split())

DIV = 10**9+7

#def comb(l, r):
#    if l == 0:
#        return 1
#    val = 1
#    for i in range(r, r-l, -1):
#        val *= i
#    for i in range(l, 0, -1):
#        val //= i
#    return val

#p = comb(K-2, N*M-2)
p = factorial(N*M-2) // factorial(K-2) // factorial((N*M-2) - (K-2))
#print(K-2, N*M-2, p)
ans = 0
for i in range(N):
    for j in range(M):
        if i == 0 and j == 0:
            continue
        d = i+j
        #print(i, j, calc_rec_num(N, M, 0, 0, i, j))
        cnt = (N-i) * (M-j)
        if i != 0 and j != 0:
            cnt *= 2
        ans += d * cnt
        #if ans > DIV:
        #    ans %= DIV
        #print(ans)

print((ans*p)%DIV)


### FIXED CODE ###

from math import factorial
N, M, K = map(int, input().split())

MOD = 10**9+7

fact = [1] * (N*M+1)
for i in range(2, N*M+1):
    fact[i] = fact[i-1] * i % MOD

def comb(n, r):
    r = n-r if n-r < r else r
    return fact[n] * pow(fact[r], MOD-2, MOD) * pow(fact[n-r], MOD-2, MOD) % MOD

p = comb(N*M-2, K-2)
ans = 0
for i in range(N):
    for j in range(M):
        if i == 0 and j == 0:
            continue
        d = i+j
        cnt = (N-i) * (M-j)
        if i != 0 and j != 0:
            cnt *= 2
        ans += d * cnt % MOD
ans = ans * p % MOD

print(ans)
### BUGGY CODE ###

n,s=map(int,input().split())
a = list(map(int,input().split()))
mod = 998244353
dp = [[[0 for i in range(2)] for i in range(s+1)]for i in range(n+1)]
dp[0][0][0]=0

for i in range(1,n+1):
    for j in range(s+1):
        if j==0:
            b=1
        else:
            b=0
        dp[i][j][0] += (dp[i-1][j][0]+b)
        dp[i][j][0] %= mod
        dp[i][j][1] += (dp[i-1][j][1]+dp[i-1][j][0]+b)
        dp[i][j][1] %= mod
        if j+a[i-1]<=s:
            dp[i][j+a[i-1]][0] += (dp[i-1][j][0]+b)
            dp[i][j][0] %= mod
            dp[i][j+a[i-1]][1] += (b+dp[i-1][j][0])
            dp[i][j][1] %= mod


print(dp[n][s][1])


### FIXED CODE ###

import sys
import math
def input():
    return sys.stdin.readline()[:-1]
n,s=map(int,input().split())
a = list(map(int,input().split()))
mod = 998244353
dp0 = [[0 for i in range(s+1)]for i in range(n+1)]
dp1 = [[0 for i in range(s+1)]for i in range(n+1)]
for i in range(1,n+1):
    for j in range(s+1):
        if j==0:
            b=1
        else:
            b=0
        dp0[i][j] += (dp0[i-1][j]+b)
        dp0[i][j] %= mod
        dp1[i][j] += (dp1[i-1][j]+dp0[i-1][j]+b)
        dp1[i][j] %= mod
        if j+a[i-1]<=s:
            dp0[i][j+a[i-1]] += (dp0[i-1][j]+b)
            dp0[i][j+a[i-1]] %= mod
            dp1[i][j+a[i-1]] += (b+dp0[i-1][j])
            dp1[i][j+a[i-1]] %= mod

        dp0[i][j]%=mod
        dp1[i][j]%=mod

print(dp1[n][s])
### BUGGY CODE ###

import bisect

k,s=map(int, input().split())

p=[]
for i in range(k+1):
    p.append(i)

ans=0
for x in range(k+1):
    for y in range(k+1):
           if p[bisect.bisect_right(p,s-x-y)-1]==s-x-y:
                ans+=1
print(ans)

### FIXED CODE ###

k,s=map(int, input().split())
ans=0
for x in range(k+1):
    for y in range(k+1):
        if 0<=(s-x-y)<=k:
            ans+=1
print(ans)
### BUGGY CODE ###

from random import randint
import sys
input = sys.stdin.readline
INF = 9223372036854775808


def calc_score(D, C, S, T):
    """
    開催日程Tを受け取ってそこまでのスコアを返す
    コンテストi 0-indexed
    d 0-indexed
    """
    score = 0
    last = [0]*26  # コンテストiを前回開催した日
    for d, t in enumerate(T):
        last[t] = d + 1
        for i in range(26):
            score -= (d + 1 - last[i]) * C[i]
        score += S[d][t]
    return score


def update_score(D, C, S, T, score, ct, ci):
    """
    ct日目のコンテストをコンテストciに変更する
    スコアを差分更新する

    ct: change t 変更日 0-indexed
    ci: change i 変更コンテスト 0-indexed
    """
    last = [0]*26  # コンテストiを前回開催した日
    for d in range(ct):
        last[T[d]] = d + 1
    prei = T[ct]  # 変更前に開催する予定だったコンテストi
    score -= S[ct][prei]
    score += S[ct][ci]
    for d in range(ct, D):
        if d != ct and T[d] == prei:
            break
        score += C[prei]*(d + 1 - ct - 1)
        score -= C[prei]*(d + 1 - last[prei])
    for d in range(ct, D):
        if d != ct and T[d] == ci:
            break
        score += C[ci]*(d + 1 - last[ci])
        score -= C[ci]*(d + 1 - ct - 1)
    T[ct] = ci
    return score, T


def local_search(D, C, S, T, today_score, d):
    pass


def evaluate(D, C, S, T, k):
    """
    d日目終了時点での満足度を計算し，
    d + k日目終了時点での満足度の減少も考慮する
    """
    score = 0
    last = [0]*26
    for d, t in enumerate(T):
        last[t] = d + 1
        for i in range(26):
            score -= (d + 1 - last[i]) * C[i]
        score += S[d][t]

    for d in range(len(T), min(len(T) + k, D)):
        for i in range(26):
            score -= (d + 1 - last[i]) * C[i]
    return score


def greedy(D, C, S):
    Ts = []
    for k in range(5, 20):
        T = []  # 0-indexed
        for d in range(D):
            # d+k日目終了時点で満足度が一番高くなるようなコンテストiを開催する
            max_score = -INF
            best_i = 0
            for i in range(26):
                T.append(i)
                score = evaluate(D, C, S, T, k)
                if max_score < score:
                    max_score = score
                    best_i = i
                T.pop()
            T.append(best_i)
        Ts.append((max_score, T))
    return max(Ts, key=lambda pair: pair[0])[1]


if __name__ == '__main__':
    D = int(input())
    C = [int(i) for i in input().split()]
    S = [[int(i) for i in input().split()] for j in range(D)]
    T = greedy(D, C, S)
    for t in T:
        print(t+1)


### FIXED CODE ###

from random import randint
import sys
input = sys.stdin.readline


def main(D, C, S):
    for _ in range(D):
        print(randint(1, 26))


if __name__ == '__main__':
    D = int(input())
    C = [int(i) for i in input().split()]
    S = [[int(i) for i in input().split()] for j in range(D)]
    main(D, C, S)
### BUGGY CODE ###

N, M = map(int, input().split())
S = list(map(int, input().split()))
T = list(map(int, input().split()))
dp = [1] * (M+1)
dpleft = [0] * (M)
MOD = 10 ** 9 + 7
ndp = [1] * (M+1)
for n in range(N):
    for m in range(M):
        if S[n] == T[m]:
            ndp[m+1] = ndp[m] + dp[m+1]
            dpleft[m] = dp[m+1]
        else:
            ndp[m+1] = ndp[m] + dpleft[m]
    dp = ndp[:]
print(dp[-1] % MOD)

### FIXED CODE ###

N, M = map(int, input().split())
S = list(map(int, input().split()))
T = list(map(int, input().split()))
dp = [1] * (M+1)
dpleft = [0] * (M)
MOD = 10 ** 9 + 7
ndp = [1] * (M+1)
for n in range(N):
    for m in range(M):
        if S[n] == T[m]:
            ndp[m+1] = ndp[m] + dp[m+1]
            dpleft[m] = dp[m+1]
        else:
            ndp[m+1] = ndp[m] + dpleft[m]
    dp = ndp[:]
print(dp[-1] % MOD)
### BUGGY CODE ###

N , M = map(int , input().split())
#内包表記で入力
jobs = [list(map(int , input().split())) for _ in range(N)]
sum = 0
#print(jobs)
for limit in range(1 , M + 1):
    index = ''
    max_reward = 0
    for job in jobs:
        if (job[0] <= limit and job[1] > max_reward):
            max_reward = job[1]
            index = jobs.index(job)
    if index != '':
        del jobs[index]
    #print("limit : ",limit)
    #print("max_reward : " , max_reward)
    sum += max_reward
#print(jobs)
print(sum)


### FIXED CODE ###

import heapq
N , M = map(int , input().split())
jobs = [list(map(int , input().split())) for _ in range(N)]
jobs.sort()

q = []
index = 0
ans = 0
for limit in range(1 , M + 1):
    while index < N:
        time =jobs[index][0]
        reward = jobs[index][1]
        if limit >= time:
            heapq.heappush(q , -reward)
            index += 1
        else:
            break
    #print(q)
    if len(q) != 0:
        tmp = heapq.heappop(q)
        ans -= tmp

print(ans)
### BUGGY CODE ###

from sys import stdin
import sys
import math
from functools import reduce
import itertools

n = int(stdin.readline().rstrip())

c = []
a = []

for i in range(n):
    s = stdin.readline().rstrip()

    if s not in a:
        a.append(s)
        c.append(1)
    else:
        idx = a.index(s)
        c[idx] = c[idx] + 1

b = [i for i, v in enumerate(c) if v == max(c)]
d = [a[i] for i in b]
d.sort()

for dd in d:
    print(dd)


### FIXED CODE ###

from sys import stdin
import sys
import math
from functools import reduce
import itertools

n = int(stdin.readline().rstrip())

d = {}
for i in range(n):
    s = stdin.readline().rstrip()

    if s in d:
        d[s] += 1
    else:
        d[s] = 1

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

m = d[0][1]
a = []
i = 0
for i in range(len(d)):
    if d[i][1] == m:
        a.append(d[i][0])
    else:
        break

a.sort()

for aa in a:
    print(aa)
### BUGGY CODE ###

import sys


H, W, M = map(int, input().split())
X = [set() for _ in range(H)]
Y = [set() for _ in range(W)]
cntX = [0] * H
cntY = [0] * W
for s in sys.stdin.readlines():
    h, w = map(lambda x: int(x) - 1, s.split())
    X[h].add(w)
    Y[w].add(h)
    cntX[h] += 1
    cntY[w] += 1

maxX = max(cntX)
maxY = max(cntY)
ans = 0
if maxX > maxY:
    for i, cnt in enumerate(cntX):
        if cnt < maxX:
            continue
        for w in range(W):
            tmp = cnt + len(Y[w]) - (w in X[i])
            if ans < tmp:
                ans = tmp
else:
    for i, cnt in enumerate(cntY):
        if cnt < maxY:
            continue
        for h in range(H):
            tmp = cnt + len(X[h]) - (h in Y[i])
            if ans < tmp:
                ans = tmp
print(ans)


### FIXED CODE ###

import sys


H, W, M = map(int, input().split())
bomb = [tuple(map(lambda x: int(x) - 1, s.split())) for s in sys.stdin.readlines()]
X = [0] * H
Y = [0] * W
for h, w in bomb:
    X[h] += 1
    Y[w] += 1
maxX = max(X)
maxY = max(Y)

R = []
C = []
for h, x in enumerate(X):
    if x == maxX:
        R.append(h)
for w, y in enumerate(Y):
    if y == maxY:
        C.append(w)

if len(R) * len(C) > M:
    ans = maxX + maxY
else:
    done = set()
    for r in R:
        for c in C:
            done.add((r, c))
    for b in bomb:
        if b in done:
            done.remove(b)
    if len(done) > 0:
        ans = maxX + maxY
    else:
        ans = maxX + maxY - 1
print(ans)
### BUGGY CODE ###

a,b,x=map(int,input().split())
ans=0
for i in range(a,b+1):
    if i%x==0:
        ans+=1

print(ans)

### FIXED CODE ###

a,b,x=map(int,input().split())
aa=(a-1)//x
bb=b//x
print(bb-aa)
### BUGGY CODE ###

n = int(input())
dams = list(map(int, input().split()))

mountSum = sum(dams)
result = []
for i in range(n):
    otSum = 0
    if i % 2 == 0:
        for j in range(i // 2):
            otSum += dams[j * 2] * 2
        for j in range(i // 2, n // 2):
            otSum += dams[j * 2 + 1] * 2
    else:
        for j in range(i // 2):
            otSum += dams[j*2 + 1] *2
        for j in range((i // 2) +1, (n //2) +1 ):
            otSum += dams[j * 2] * 2
    result.append(mountSum - otSum)

print(*result)



### FIXED CODE ###

n = int(input())
dams = list(map(int, input().split()))

mountSum = sum(dams)
result = []
otSum = 0
for j in range(0, n // 2):
    otSum += dams[j * 2 + 1] * 2
result.append(mountSum - otSum)
for i in range(1, n-1):
    result.append(dams[i-1] * 2 - result[i-1])
result.append(dams[n-1]*2 - result[0])

print(*result)
### BUGGY CODE ###

import math

s=list(map(int,input().split()))
t=list(map(int,input().split()))
a=0
t.sort(reverse=True)
for i in range(s[1]):
  t[0]=math.floor(t[0]/2)
  t.sort(reverse=True)
for j in range(s[0]):
  a=a+t[j]
print(a)

### FIXED CODE ###

import math
 
s=list(map(int,input().split()))
t=list(map(int,input().split()))
a=0
b=0
c=0
d=s[1]
t.sort(reverse=True)
if s[0]==1:
  for i in range(s[1]):
    t[0]=math.floor(t[0]/2)
else:
  c=t[0]/2
  for j in range(s[1]):
    for l in range(s[0]):
      if d>0:
        if c<t[l]:
          t[l]=math.floor(t[l]/2)
          d=d-1
        else:
            t.sort(reverse=True)
            c=t[0]/2
            break
      else:
        break
e=sum(t)
print(e)
### BUGGY CODE ###

s = input()
slist = list(s)
l = len(s)
n = 0
j = 1

while j != 0:
  j = 0
  start = 0
  end = l-1
  for i in range(start, end):
    if slist[i:i+2] == ['B','W']:
      slist[i:i+2] = ['W','B']
      n += 1
      j = 1
      end = i
    start += 1

print(n)

### FIXED CODE ###

S = input()
cnt = 0
ans = 0
left = 0
for i in range(len(S)):
    if S[i] == 'W':
        cnt += S[left:i].count('B')
        ans += cnt
        left = i
print(ans)
### BUGGY CODE ###

n = int(input())
x = list(map(int, input().split()))
num = (n // 2) - 1

for i in range(n):
    l = x[:]
    l.pop(i)
    l.sort()
    print(l[num])

### FIXED CODE ###

n = int(input())
x = list(map(int, input().split()))
y = sorted(x[:])

for i in range(n):
    if x[i] < y[n//2]:
        print(y[n//2])
    else:
        print(y[n//2 - 1])
### BUGGY CODE ###

from collections import defaultdict
H, W, M = map(int, input().split())
tate = defaultdict(int)
yoko = defaultdict(int)
T = {}
for i in range(M):
    h, w = map(int, input().split())
    tate[h-1] += 1
    yoko[w-1]+= 1
    T[(h-1, w-1)] = 1

tate = sorted(tate.items(), key=lambda x:x[1], reverse=True)
yoko = sorted(yoko.items(), key=lambda x:x[1], reverse=True)
tate_m = tate[0][1]
yoko_m = yoko[0][1]
ans = 0
for i in range(len(tate)):
    if tate[i][1] == tate_m:
        for j in range(len(yoko)):
            if yoko[j][1] == yoko_m:
                if (tate[i][0], yoko[j][0]) in T:
                    ans = max(ans, tate_m + yoko_m - 1)
                else:
                    ans = max(ans, tate_m + yoko_m)
            else:
                break
    else:
        break
print(ans)

### FIXED CODE ###

from collections import defaultdict
H, W, M = map(int, input().split())
tate = defaultdict(int)
yoko = defaultdict(int)
T = {}
for i in range(M):
    h, w = map(int, input().split())
    tate[h-1] += 1
    yoko[w-1]+= 1
    T[(h-1, w-1)] = 1

tate = sorted(tate.items(), key=lambda x:x[1], reverse=True)
yoko = sorted(yoko.items(), key=lambda x:x[1], reverse=True)
tate_m = tate[0][1]
yoko_m = yoko[0][1]
ans = 0
for i in range(len(tate)):
    if ans == tate_m + yoko_m:
        break
    if tate[i][1] == tate_m:
        for j in range(len(yoko)):
            if yoko[j][1] == yoko_m:
                if (tate[i][0], yoko[j][0]) in T:
                    ans = max(ans, tate_m + yoko_m - 1)
                else:
                    ans = max(ans, tate_m + yoko_m)
            else:
                break
    else:
        break
print(ans)
### BUGGY CODE ###

import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    H, N = map(int, input().split())
    AB = [tuple(map(int, input().split())) for _ in range(N)]

    MAX_V = 10**8+1
    dp = [MAX_V] * (H+1)
    dp[0] = 0
    for a, b in AB:
        for i in range(1, H+1):
            if i - a >= 0:
                v = dp[i-a] + b
            else:
                v = b
            if dp[i] > v:
                dp[i] = v

    print(dp[H])

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    H, N = map(int, input().split())
    AB = [tuple(map(int, input().split())) for _ in range(N)]

    dp = [10**9+1] * (H+1)
    dp[0] = 0
    for a, b in AB:
        for i in range(1, H+1):
            if i - a >= 0:
                v = dp[i-a] + b
            else:
                v = b
            if dp[i] > v:
                dp[i] = v

    print(dp[H])

if __name__ == '__main__':
    main()
### BUGGY CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))
s = 1
for j in range(K-1):
  s *= A[j]
for i in range(K, N):
  if A[i] > A[i-K]:
    print("Yes")
  else:
    print("No")
  s *= A[i]
  s //= A[i-K]

### FIXED CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))
for i in range(K, N):
  if A[i] > A[i-K]:
    print("Yes")
  else:
    print("No")