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

from collections import defaultdict
R, C, K = map(int, input().split())

I = defaultdict(int)
for _ in range(K):
    r, c, v = map(int, input().split())
    I[(r-1, c-1)] = v   # 0-indexed

dp = [[[0 for k in range(4)]
       for j in range(C)] for i in range(R)]
for i in range(R):
    for j in range(C):
        for k in range(4):
            if i < R-1:
                if k <= 2:
                    dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][k]+I[(i, j)])
                else:
                    dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][k])
            if j < C-1:
                if k <= 2:
                    dp[i][j+1][k] = max(dp[i][j+1][k], dp[i][j][k])
                    dp[i][j+1][k+1] = max(dp[i][j+1][k+1],
                                          dp[i][j][k]+I[(i, j)])
                else:
                    dp[i][j+1][k] = max(dp[i][j+1][k], dp[i][j][k])


# print(*dp, sep='\n')

ans = 0
for k in range(4):
    if k <= 2:
        ans = max(ans, dp[R-1][C-1][k]+I[(R-1, C-1)])
    ans = max(ans, dp[R-1][C-1][k])
print(ans)


### FIXED CODE ###

import sys
input = sys.stdin.readline

R, C, K = map(int, input().split())

I = [[0]*C for i in range(R)]
for _ in range(K):
    r, c, v = map(int, input().split())
    I[r-1][c-1] = v   # 0-indexed

dp0 = [[0 for j in range(C+1)] for i in range(R+1)]
dp1 = [[0 for j in range(C+1)] for i in range(R+1)]
dp2 = [[0 for j in range(C+1)] for i in range(R+1)]
dp3 = [[0 for j in range(C+1)] for i in range(R+1)]
for i in range(R):
    for j in range(C):
        dp3[i][j] = max(dp3[i][j], dp2[i][j]+I[i][j])
        dp2[i][j] = max(dp2[i][j], dp1[i][j]+I[i][j])
        dp1[i][j] = max(dp1[i][j], dp0[i][j]+I[i][j])
        dp0[i+1][j] = max(dp0[i+1][j], dp0[i][j], dp1[i]
                          [j], dp2[i][j], dp3[i][j])
        dp0[i][j+1] = max(dp0[i][j+1], dp0[i][j])
        dp1[i][j+1] = max(dp1[i][j+1], dp1[i][j])
        dp2[i][j+1] = max(dp2[i][j+1], dp2[i][j])
        dp3[i][j+1] = max(dp3[i][j+1], dp3[i][j])


# print(*dp, sep=' \n')

ans = max(dp0[R-1][C-1], dp1[R-1][C-1], dp2[R-1][C-1], dp3[R-1][C-1])
print(ans)
### BUGGY CODE ###

list6 = [6, 36, 216, 1296, 7776, 46656, 279936]
list9 = [9, 81, 729, 6561, 59049, 531441]

def f(N,ans):
    if N < 6:
        return ans + N
    if N < 9:
        return ans + (N-6)+1
 
    max6 = max(y for y in list6 if N >= y)
    max9 = max(y for y in list9 if N >= y)
    return min(f(N-max6,ans+1),f(N-max9,ans+1))

print(f(int(input()),0))

### FIXED CODE ###

N = int(input())

def f9(a,i):
    if a < 9**i:
        return i-1
    return f9(a,i+1)

def f6(a,i):
    if a < 6**i:
        return i-1
    return f6(a,i+1)

def func(a,ans):
    if a < 6:
        return ans+a
    elif a < 9:
        return ans+1+(a-6)
    return min(func(a-6**f6(a,0),ans+1),func(a-9**f9(a,0),ans+1))

print(func(N,0))
### BUGGY CODE ###

import bisect

n, h = map(int, input().split())
A, B = [], []
for _ in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

B = sorted(B, reverse=True)
bigger = [x for x in B if x >= max(A)]
throw_b = len(bigger)

throw = 0
check = 0

while check == 0:
    if throw >= throw_b:
        break
    h = h - B[throw]
    throw += 1
    if h <= 0:
        break

if h <= 0:
    ans = throw
else:
    ans = throw + -(-h//max(A))

print(ans)

### FIXED CODE ###

n, h = map(int, input().split())
A, B = [], []
for _ in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

B = sorted(B, reverse=True)
a_max = max(A)

bigger = [x for x in B if x >= a_max]
throw_b = len(bigger)

throw = 0
check = 0

while check == 0:
    if throw >= throw_b:
        break
    h = h - B[throw]
    throw += 1
    if h <= 0:
        break

if h <= 0:
    ans = throw
else:
    ans = throw + -(-h//max(A))

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

import math

n = int(input())

for i in range(1, n + 1):
    cnt = 0
    f = int(math.sqrt(n)) + 1
    for x in range(1, f):
        for y in range(1, f):
            for z in range(1, f):
#                 print(i, x, y, z)
                if (x ** 2) + (y ** 2) + (z ** 2) + (x * y) + (y * z) + (z * x) == i:
                    cnt += 1

    print(cnt)

### FIXED CODE ###

import math

n = int(input())
ans = [0] * (n+1)

f = int(math.sqrt(n)) + 1
for x in range(1, f):
    for y in range(1, f):
        for z in range(1, f):
            v = (x ** 2) + (y ** 2) + (z ** 2) + (x * y) + (y * z) + (z * x)
            if v < n + 1:
                ans[v] += 1
            
for i in range(n):
    print(ans[i+1])
### BUGGY CODE ###

if __name__ == '__main__':
    s = input()
    q = int(input())
    ans = s
    for i in range(q):
        a = [i for i in input().split()]
        if len(a) == 1:
            ans = ans[::-1]
        else:
            if int(a[1]) == 1:
                ans =  a[2] + ans
            else:
                ans = ans + a[2]

    print(ans)


### FIXED CODE ###

from collections import deque

if __name__ == '__main__':
    s = input()
    q = int(input())
    ans = s
    rev_count = 0
    leftList = deque()
    rightList =[]
    alist =[]

    for i in range(q):
        a = [i for i in input().split()]
        alist.append(a)
        if len(a) == 1:
            rev_count = rev_count +1

    if rev_count % 2 ==1:
        ans = ans[::-1]

    for i in alist:
        if len(i) == 1:
            rev_count = rev_count -1
        else:
            if int(i[1]) == 1:
                if rev_count % 2 == 1:
                    rightList.append(i[2])
                else:
                    leftList.appendleft(i[2])

            else:
                if rev_count % 2 == 1:
                    leftList.appendleft(i[2])
                else:
                    rightList.append(i[2])

    ans = ''.join(leftList)+ ans+''.join(rightList)

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

# input
N = int(input())
A = list(map(int, input().split()))

# define combination
fact = [1, 1]
combs = [0, 0]
for i in range(2, N+1):
    fact.append(fact[-1]*i)
    combs.append(fact[i] // (fact[i - 2] * 2))

# process
nums = [0]*(N+1)
for a in A:
    nums[a] += 1

sumall = 0
for n in nums:
    sumall += combs[n]

ans = [sumall]*N
for i, a in enumerate(A):
    ans[i] += combs[nums[a]-1] - combs[nums[a]]

# output
for a in ans:
    print(a)


### FIXED CODE ###

# input
N = int(input())
A = list(map(int, input().split()))

# define combination
combs = [0, 0]
for i in range(2, N+1):
    combs.append(i*(i-1)//2)

# process
nums = [0]*(N+1)
for a in A:
    nums[a] += 1

sumall = 0
for n in nums:
    sumall += combs[n]

ans = [sumall]*N
for i, a in enumerate(A):
    n = nums[a]
    ans[i] += combs[n-1] - combs[n]

# output
for a in ans:
    print(a)
### BUGGY CODE ###

S = input()
l = len(S)

count = 0
for i in range(l):
  for j in range(l):
    if i < (j-2):
      new_s = int(S[i:j+1])
      if new_s % 2019 == 0:
        count += 1
      else:
        continue
    else:
      continue
print(count)

### FIXED CODE ###

from collections import Counter
S=input()[::-1]
mod=2019

X = [0]
for i, s in enumerate(S):
  X.append((X[-1] + int(s)*pow(10, i, mod)) % mod)

C = Counter(X)
ans = 0
for v in C.values():
    ans += v * (v - 1) // 2
print(ans)
### BUGGY CODE ###

import sys

use_clipboard=True
bbn=1000000007
	
#+++++

		
def main():
	h, n = map(int, input().split())
	ii=[]
	for i in range(n):
		a,b=map(int, input().split())
		ii.append([a/b, a, b])
	#ii.sort()
	
	_,ma,mb = ii[0]
	tn = (h + ma-1)//ma
	tc = tn * mb
	
	vv=[bbn]*(h+1)
	vv[0]=0
	for i in range(h+1):
		for c,a,b in ii:
			nn = min(i + a, h)
			vv[nn]= min(vv[i] + b, vv[nn])
	
	print(vv[-1])
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
class input_clipboard:
	def __init__(self,s):
		self.input_l=s.splitlines()
		self.ii=0
		
	def input(self):
		ret = self.input_l[self.ii]
		self.ii+=1
		return ret

if __name__ == "__main__":
	if sys.platform =='ios':
		if use_clipboard:
			import clipboard
			input_text=clipboard.get()
			ic=input_clipboard(input_text)
			input = lambda : ic.input()
		else:
			sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

### FIXED CODE ###

import sys

use_clipboard=True
bbn=1000000007
	
#+++++

		
def main():
	h, n = map(int, input().split())
	ii=[]
	for i in range(n):
		a,b=map(int, input().split())
		ii.append([a/b, a, b])
	#ii.sort()
	
	_,ma,mb = ii[0]
	tn = (h + ma-1)//ma
	tc = tn * mb
	
	vv=[bbn]*(h+1)
	vv[0]=0
	for i in range(h+1):
		for c,a,b in ii:
			nn = min(i + a, h)
			vv[nn]= min(vv[i] + b, vv[nn])
	
	print(vv[-1])
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
class input_clipboard:
	def __init__(self,s):
		self.input_l=s.splitlines()
		self.ii=0
		
	def input(self):
		ret = self.input_l[self.ii]
		self.ii+=1
		return ret

if __name__ == "__main__":
	if sys.platform =='ios':
		if use_clipboard:
			import clipboard
			input_text=clipboard.get()
			ic=input_clipboard(input_text)
			input = lambda : ic.input()
		else:
			sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)
### BUGGY CODE ###

k=int(input())
if k%2==0:
    print(-1)
    exit()
count=1
while True:
    if int('7'*count)%k==0:
        print(count)
        break
    count+=1


### FIXED CODE ###

k=int(input())
if k%2==0 or k%5==0:
    print(-1)
    exit()
a=0
for i in range(k):
    a=(a*10+7)%k
    if a==0:
        print(i+1)
        exit()
### BUGGY CODE ###

N = int(input())
A_list = list(map(int, input().split()))
B_list = list(map(int, input().split()))


count = 0
tmp = 0
for i, a in enumerate(A_list[::-1]):
  
  if i < len(B_list):  
    if a <= B_list[::-1][i] + tmp:
      count += a
      # tmp = B_list[::-1][i] + tmp - a      
      if tmp > a:
        tmp = B_list[::-1][i]
      else:
        tmp = B_list[::-1][i] + tmp - a
      
    else:
      count += B_list[::-1][i] + tmp
      tmp = 0
      
    # print(count, tmp)
      
  elif i == len(B_list):
    if a <= tmp:
      count += a
    else:
      count += tmp
    
print(count)

### FIXED CODE ###

N = int(input())
A_list = list(map(int, input().split()))
B_list = list(map(int, input().split()))


A_list = A_list[::-1]
B_list = B_list[::-1]

count = 0
tmp = 0
for i, a in enumerate(A_list):
  
  if i < len(B_list):  
    if a <= B_list[i] + tmp:
      count += a
      if tmp > a:
        tmp = B_list[i]
      else:
        tmp = B_list[i] + tmp - a      
    else:
      count += B_list[i] + tmp
      tmp = 0            
  else:
    if a <= tmp:
      count += a
    else:
      count += tmp
    
print(count)
### BUGGY CODE ###

x , y ,z , k = map(int, input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

e = [i + j for i in a for j in b]
e.sort(reverse=True)
e = e[:k]
ans = [i + j for i in e for j in c]
ans.sort(reverse=True)

for i in range(k):
    print(ans[i])


### FIXED CODE ###

x , y ,z , k = map(int, input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

e = [i + j for i in a[:k] for j in b[:k]]
e.sort(reverse=True)
e = e[:k]
ans = [i + j for i in e for j in c[:k]]
ans.sort(reverse=True)

for i in range(k):
    print(ans[i])
### BUGGY CODE ###

n = int(input())
s = []
count = 0
for i in range(n):
    s1 = list(input())
    s1.sort()
    s1 = "".join(s1)
    s.append(s1)
s2 = list(set(s))
if len(s) == len(s2):
    print("0")
else:
    for i in range(len(s2)):
        k =  s.count(s2[i])
        if k != 1:
            count = count + int(k*(k-1)/2)
    print(count)

### FIXED CODE ###

n = int(input())
s = []
count = 0
for i in range(n):
    s1 = list(input())
    s1.sort()
    s1 = "".join(s1)
    s.append(s1)
s.sort()
s2 = list(set(s))
s2.sort()
if len(s) == len(s2):
    print("0")
else:
    j1 = 0
    j2 = 0
    count1 = 0
    while j1 < n and j2 < len(s2):
        if s[j1] == s2[j2]:
            count1 = count1 + 1
            j1 = j1 + 1
        else:
            count = count + int(count1*(count1-1)/2)
            j2 = j2 + 1
            count1 = 0
    count = count + int(count1*(count1-1)/2)
    print(count)
### BUGGY CODE ###

if __name__ == '__main__':
    S = str(input())
    N = len(S)

    answer = 0
    for i in range(0, N):
        index_00 = S.find('01')
        if index_00 != -1:
            answer += 2
            S = S[:index_00] + S[index_00+2:]
            continue
        index_11 = S.find('10')
        if index_11 != -1:
            answer += 2
            S = S[:index_11] + S[index_11+2:]
            continue
        if S.find('01') == -1 and S.find('10') == -1:
            break

    print(answer)

### FIXED CODE ###

if __name__ == '__main__':
    S = str(input())
    N = len(S)

    count_0 = S.count('0')
    count_1 = S.count('1')

    answer = 2 * min(count_0, count_1)

    print(answer)
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
ans=1
L=10**18
for i in range(N):
  ans*=A[i]

if ans > L:
  print(-1)
else:
  print(ans)



### FIXED CODE ###

N=int(input())
A=sorted(list(map(int,input().split())))
ans=1
L=10**18

if A[0]==0:
  print(0)
  exit()

for i in range(N):
  ans*=A[i]
  if ans > L:
    print(-1)
    exit()

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

import bisect
n = int(input())
As = sorted(list(map(int, input().split())))
Bs = sorted(list(map(int, input().split())))
Cs = sorted(list(map(int, input().split())))

cnt = 0
for a in As:
    cntB = bisect.bisect_right(Bs, a)
    for b in Bs[cntB:]:
        cnt += len(Cs) - bisect.bisect_right(Cs, b)
print(cnt)


### FIXED CODE ###

import bisect
n = int(input())
As = list(map(int, input().split()))
Bs = sorted(list(map(int, input().split())))
Cs = sorted(list(map(int, input().split())))

cnt = [0]*(n+1)
v = 0
for idx, b in enumerate(Bs[::-1]):
    v += len(Cs) - bisect.bisect_right(Cs, b)
    cnt[n-1-idx] = v

print(sum([cnt[bisect.bisect_right(Bs, a)] for a in As]))
### BUGGY CODE ###

N, C = map(int, input().split())
STC = [[*map(int, input().split())] for _ in range(N)]
mx_t = 200002
R = [0]*mx_t
for cc in range(1, C+1):
    TZ = [0]*mx_t
    for s,t,c in STC:
        if c == cc:
            TZ[2*s - 1] += 1
            TZ[2*t] -= 1
    for i in range(mx_t - 1):
        TZ[i+1] += TZ[i]
        if TZ[i+1] > 0: R[i+1] += 1
print(max(R))



### FIXED CODE ###

N, C = map(int, input().split())
STC = [[*map(int, input().split())] for _ in range(N)]
mx_t = 200002
R = [0]*mx_t
for cc in range(1, C+1):
    TZ = [0]*mx_t
    for s,t,c in STC:
        if c == cc:
            TZ[2*s - 1] += 1
            TZ[2*t] -= 1
    for i in range(mx_t - 1):
        TZ[i+1] += TZ[i]
        if TZ[i+1] > 0: R[i+1] += 1
print(max(R))
### BUGGY CODE ###

n,M=list(map(int,input().split()))
lr=[list(map(int,input().split())) for i in range(M)]
cnt=0
for i in range(1,n+1):
  sub=0
  for m in range(M):
    if i>=lr[m-1][0] and i<=lr[m-1][1]:sub+=1
    if sub==M:cnt+=1
#    print('i:',i,'l:',lr[m-1][0],'r:',lr[m-1][1],'sub:',sub)
print(cnt)


### FIXED CODE ###

n,m=list(map(int,input().split()))
L,R=0,n
for _ in range(m):
  l,r=map(int,input().split())
  L,R=max(L,l),min(R,r)
print(max(R-L+1,0))
### BUGGY CODE ###

h,w=map(int,input().split())
a=[list(map(lambda x:int(x=='#'),list(input()))) for _ in range(h)]
todo=[]
next_todo=[]
from collections import deque
for i in range(h):
  for j in range(w):
    if a[i][j]==1:
      next_todo.append([i,j])
seen=[[0]*w for _ in range(h)]
ans=0
while next_todo:
  todo=next_todo.copy()
  next_todo=[]
  while todo:
    i,j=todo.pop()
    if i>0 and a[i-1][j]==0:
      a[i-1][j]=1
      next_todo.append([i-1,j])
    if i<h-1 and a[i+1][j]==0:
      a[i+1][j]=1
      next_todo.append([i+1,j])
    if j>0 and a[i][j-1]==0:
      a[i][j-1]=1
      next_todo.append([i,j-1])
    if j<w-1 and a[i][j+1]==0:
      a[i][j+1]=1
      next_todo.append([i,j+1])
  if next_todo:
    ans+=1
print(ans)


### FIXED CODE ###

h,w=map(int,input().split())
a=[input() for _ in range(h)]
seen=[[-1]*w for _ in range(h)]
from collections import deque
todo=deque([])
for hi in range(h):
  for wi in range(w):
    if a[hi][wi]=='#':
      seen[hi][wi]=0
      todo.append((hi,wi,0))
while len(todo)>0:
  hi,wi,i=todo.popleft()
  if hi>0 and seen[hi-1][wi]==-1:
    todo.append((hi-1,wi,i+1))
    seen[hi-1][wi]=i+1
  if hi<h-1 and seen[hi+1][wi]==-1:
    todo.append((hi+1,wi,i+1))
    seen[hi+1][wi]=i+1
  if wi>0 and seen[hi][wi-1]==-1:
    todo.append((hi,wi-1,i+1))
    seen[hi][wi-1]=i+1
  if wi<w-1 and seen[hi][wi+1]==-1:
    todo.append((hi,wi+1,i+1))
    seen[hi][wi+1]=i+1
print(max([max(seeni) for seeni in seen]))
### BUGGY CODE ###

tmp = list(map(int, input().split()))
N, M = tmp[0], tmp[1]
A = []
B = []
for i in [0]*M:
    tmp = list(map(int, input().split()))
    A.append(tmp[0])
    B.append(tmp[1])

arranged = [[1]]
nextroom = []
ans = [0]*(N-1)
for j in [0]*M:
    flattenarr = sum(arranged, [])
    for i in range(M):
        for rooms in arranged:
            if A[i] in rooms and B[i] not in flattenarr:
                nextroom.append(B[i])
                if ans[B[i]-2] == 0:
                    ans[B[i]-2]=A[i]
                break

            if B[i] in rooms and A[i] not in flattenarr:
                nextroom.append(A[i])
                if ans[A[i]-2] == 0:
                    ans[A[i]-2]=B[i]
                break
    arranged.append(nextroom)
    nextroom = []

if 0 in ans:
    print('No')
else:
    print('Yes')
    for x in ans:
        print(x)

### FIXED CODE ###

import queue

N, M = map(int, input().split())
adj = [[] for i in [0]*N] # 隣接リスト
for i in [0]*M:
    a, b = map(int, input().split())
    adj[a-1].append(b)
    adj[b-1].append(a)

que = queue.Queue()
que.put(1)
guide = [-1]*(N)
 
while not que.empty():
    x = que.get()
    for y in adj[x-1]:
        if guide[y-1] == -1:
            que.put(y)
            guide[y-1] = x


print('Yes')
for i in guide[1:]:
        print(i)
### BUGGY CODE ###

#inputは文字列として取得
input1=input()
input2=input()
#splitする必要がある
input2=input2.split(" ")

N=int(input1)
D=[int(s) for s in input2]

ans=None

if D.count(0)==1 and D[0]==0:

    mul=1
    n=1

    for i in range(1,max(D)+1):
        m=D.count(i)
        n=n%998244353
        mul*=n**m
        n=m
    
    ans=mul%998244353

else:
    ans=0

print(int(ans))

### FIXED CODE ###

#inputは文字列として取得
input1=input()
input2=input()
#splitする必要がある
input2=input2.split(" ")

N=int(input1)
D=[int(s) for s in input2]

ans=None


if D.count(0)==1 and D[0]==0:

    L=[0]*(max(D)+1)

    for i in range(len(D)):
        L[D[i]]+=1

    mul=1

    for i in range(len(L)-1):
        mul*=L[i]**L[i+1]%998244353
    
    ans=mul%998244353

else:
    ans=0

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

import collections

Row = int(input())
List = []
for i in range (Row):
  List.append(input())
c = collections.Counter(List)
tryList = []
k=""
for i in range(len(c)):
  if c.most_common()[i][1] == c.most_common()[0][1]:
    tryList.append(c.most_common()[i][0])
  else:
    break
tryList.sort()
for element in tryList:
  print(element)

### FIXED CODE ###

Row = int(input())
dictA= {}
a = ""
mid = 0
for i in range (Row):
  a = input()
  dictA.setdefault(a,0) 
  dictA[a] += 1
  mid = max(mid, dictA[a])
sDict = sorted(dictA.items())
for i in range(len(dictA)):
  if sDict[i][1]== mid:
    print(sDict[i][0])
### BUGGY CODE ###

import numpy as np

N = int(input())

values = np.array([list(map(int, input().split(' '))) for _ in range(N)])
dp = np.zeros(shape=(N, 3), dtype=int)

dp[0] = values[0]

for i in range(1, N):
    dp[i][0] = np.max(values[i][0] + dp[i - 1][1:3])
    dp[i][1] = np.max(values[i][1] + dp[i - 1][0::2])
    dp[i][2] = np.max(values[i][2] + dp[i - 1][:2])

print(np.max(dp[N - 1]))


### FIXED CODE ###

def main(n, choices):
    results = [[0, 0, 0] for _ in range(n)]
    results[0] = choices[0]
    for i in range(1, n):
        results[i][0] = choices[i][0] + max(results[i - 1][1], results[i - 1][2])
        results[i][1] = choices[i][1] + max(results[i - 1][0], results[i - 1][2])
        results[i][2] = choices[i][2] + max(results[i - 1][0], results[i - 1][1])
    return max(results[-1])


if __name__ == '__main__':
    N = int(input())
    C = []
    for _ in range(N):
        C.append(list(map(int, input().split())))
    print(main(N, C))
### BUGGY CODE ###

a, b, c, d = map(int, input().split())

maxi = float("-inf")
for i in range(a, b + 1):
  for j in range(c, d + 1):
    maxi = max(maxi, i * j)
print(maxi)

### FIXED CODE ###

a, b, c, d = map(int, input().split())

print(max(a*c, a*d, b*c, b*d))
### BUGGY CODE ###

A, B, M = [int(n) for n in input().split()]
a  = [int(n) for n in input().split()]
b = [int(n) for n in input().split()]
XY = {}
for m in range(M):
    x, y, c = [int(n) for n in input().split()]
    v = XY.setdefault((x-1, y-1), 0)
    XY[(x-1, y-1)] = max(v, c)
ans = 10**5+1
for i, ai in enumerate(a):
    for j, bj in enumerate(b):
        if (i, j) in XY:
            vc = ai + bj - XY[(i, j)]
            if ans > vc:
                ans = vc
        else:
            vc = ai + bj
            if ans > vc:
                ans = vc
print(ans)

### FIXED CODE ###

A, B, M = [int(n) for n in input().split()]
a  = [int(n) for n in input().split()]
b = [int(n) for n in input().split()]
ma = sorted(a)[0]
mb = sorted(b)[0]
XY = {}
ans = ma + mb
for m in range(M):
    x, y, c = [int(n) for n in input().split()]
    dv = a[x-1] + b[y-1] - c
    mv = min((ma+mb), dv)
    if ans > mv:
        ans = mv
print(ans)
### BUGGY CODE ###

import fractions

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

ans = 0

for i in range(n): # 無効にする
  cd = -1
  for j in range(n):
    if i==j:
      continue
    if cd < 0:
      cd = a[j]
    else :
      cd = fractions.gcd(cd,a[j])      
  if ans < cd:
    ans = cd
print(ans)

### FIXED CODE ###

import fractions

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

ans = 0

ls = [0]*n
rs = [0]*n

for i in range(1,n):
  ls[i] = fractions.gcd(ls[i-1],a[i-1])
  rs[i] = fractions.gcd(rs[i-1],a[-i])

ans = 0
for i in range(n):        
    ans = max(ans,fractions.gcd(ls[i],rs[-i-1]))

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

#!/usr/bin/env python3
from itertools import accumulate

n, m, q = list(map(int, input().split()))
lr = [list(map(int, input().split())) for _ in range(m)]
pq = [list(map(int, input().split())) for _ in range(q)]

data = [[0]*500 for i in range(500)]
# data = [[0]*10 for i in range(10)]

for l, r in lr:
    data[l-1][r-1] += 1


for i in range(0, 500):
    data[i] = list(accumulate(data[i]))

# print(data)
for p, q in pq:
    ans = 0
    for i in range(p-1, q-1+1):
        if p == 1:
            ans += data[i][q-1]
        else:
            ans += data[i][q-1]-data[i][p-1-1]
    print(ans)


### FIXED CODE ###

#!/usr/bin/env python3
from itertools import accumulate
import numpy as np

n, m, q = list(map(int, input().split()))
lr = [list(map(int, input().split())) for _ in range(m)]
pq = [list(map(int, input().split())) for _ in range(q)]

data = [[0]*500 for i in range(500)]
# data = [[0]*10 for i in range(10)]

for l, r in lr:
    data[l-1][r-1] += 1


# for i in range(0, 500):
#     data[i] = list(accumulate(data[i]))

# print(data)
# for p, q in pq:
#     ans = 0
#     if p == 1:
#         for i in range(p-1, q-1+1):
#             ans += data[i][q-1]
#     else:
#         for i in range(p-1, q-1+1):
#             ans += data[i][q-1]-data[i][p-1-1]
#     print(ans)

data = np.array(data)

data = np.cumsum(data, axis=1)
data = np.cumsum(data, axis=0)

# print(data[:10, :10])
for p, q in pq:
    ans = 0
    if p == 1:
        ans = data[q-1][q-1]
    else:
        ans = data[q-1][q-1]-data[p-1-1][q-1]
    print(ans)
# for p, q in pq:
#     ans = 0
#     if p == 1:
#         for i in range(p-1, q-1+1):
#             ans += data[i][q-1]
#     else:
#         for i in range(p-1, q-1+1):
#             ans += data[i][q-1]-data[i][p-1-1]
#     print(ans)