Harryxun/stf_run huggingface dataset:
from sys import stdin

N, K = [int(x) for x in stdin.readline().rstrip().split()]
A = [int(x) for x in stdin.readline().rstrip().split()]

A.sort()
c = 1
ans = 0
inf = 10 ** 9 + 7
fact_list = [0] * (N + 1)
fact_list[0] = 1
f = 1

for i in range(1, N + 1):
    f *= i
    fact_list[i] = f

for i in range(N - K + 1):
    tmp_min = A[i]
    tmp_max = A[N - i - 1]
    d = (tmp_max - tmp_min) % inf
    n = (fact_list[N - i - 1] / fact_list[K - 1] / fact_list[N - i -K]) % inf
    ans += (tmp_max - tmp_min) * n
    ans %= inf

print(int(ans))

### FIXED CODE ###

from sys import stdin

N, K = [int(x) for x in stdin.readline().rstrip().split()]
A = [int(x) for x in stdin.readline().rstrip().split()]

A.sort()
c = 1
ans = 0
inf = 10 ** 9 + 7
fact_list = [1] * (N + 1)
fact_inv = [1] * (N + 1)
f = 1

for i in range(1, N + 1):
    f *= i
    f %= inf
    fact_list[i] = f

for i in range(1, N + 1):
    fact_inv[i] = pow(fact_list[i], inf - 2, inf)

for i in range(N - K + 1):
    tmp_min = A[i]
    tmp_max = A[N - i - 1]
    d = (tmp_max - tmp_min) % inf
    n = fact_list[N - i - 1] * fact_inv[K - 1] * fact_inv[N - i -K] % inf
    ans += d * n
    ans %= inf

print(int(ans))
import math
from functools import reduce

n = int(input())
a = list(map(int, input().split()))
ans = reduce(math.gcd, a)

for i in range(n):
    b = a[:i]+a[i+1:]
    ans = max(reduce(math.gcd, b), ans)

print(ans)

### FIXED CODE ###

import fractions

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

l_gcd = [0]
for i in range(n):
    l_gcd.append(fractions.gcd(l_gcd[-1], a[i]))
# print(l_gcd)

r_gcd = [0]
for i in range(n):
    r_gcd.append(fractions.gcd(r_gcd[-1], a[-(i+1)]))
r_gcd.reverse()
# print(r_gcd)

for i in range(n):
    ans = max(ans, fractions.gcd(l_gcd[i], r_gcd[i+1]))
print(ans)
n = int(input())
a = map(int, input().split())
for i in range(0, n):
 print(a[n - i], end = ' ')
print()

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
for i in range(0, n - 1):
 print(a[n - 1 - i], end = ' ')
print(a[0])
if __name__ == '__main__':
    X, t = map(int, raw_input().split())
    rt = X-t
    if re>0:
        print(re)
    else:
        print(0)

### FIXED CODE ###

if __name__ == '__main__':
    X, t = map(int, input().split())
    re = X-t
    if re>0:
        print(re)
    else:
        print(0)
today = input()

weather = ["Sunny", "Cloudy", "Rainy"]

days = weather.index(today)
tomorrow = days + 1
print(weather[tomorrow])

### FIXED CODE ###

today = input()

weather = ["Sunny", "Cloudy", "Rainy"]

days = weather.index(today)
tomorrow = days + 1
if tomorrow == 3:
    tomorrow = 0
    
print(weather[tomorrow])
import math
 
def main():
  N = int(input())
  
  print(search(N))
 
def search(x):
  
  ints = list(range(2,x))
  
  # 順に確認する
  for i in ints:
    if x%i==0:
      seartch(x+1)
  	elif x < i**2:
      break
    
  return x

### FIXED CODE ###

def main():
  N = int(input())
  
  print(search(N))
 
def search(x):
  
  ints = list(range(2,x))
  
  # 順に確認する
  for i in ints:
    if x%i==0:
      return search(x+1)
    elif x < i**2:
      break
    
  return x

main()
import sys
import resource

sys.setrecursionlimit(10 ** 9)
resource.setrlimit(resource.RLIMIT_STACK, ((2 ** 9) * 1000 * 1000, (2 ** 9) * 1000 * 1000))

k = int(input())

ary = [1, 2, 3, 4, 5, 6, 7, 8, 9]

def ans(j, nums):
    nums[j] += 1
    pre = nums[j]
    for i in range(j + 1, len(nums)):
        if pre > 0:
            nums[i] = pre - 1
            pre = nums[i]
        else:
            nums[i] = pre
    return int(''.join(map(str, nums)))

def lunlun(n):
    if n <= 9:
        return ary[n - 1]
    l = lunlun(n - 1)
    nums = list(map(int, list(str(l))))
    first = len(nums) - 1
    last = 0
    for i in range(len(nums)):
        j = len(nums) - i - 1
        c = nums[j] + 1
        # 桁数が変わらないとき
        if j == first:
            # 1桁目
            if nums[j] < 9 and abs(nums[j - 1] - c) <= 1:
                nums[j] += 1
                return int(''.join(map(str, nums)))
        elif j == last:
            # 最終桁
            if nums[j] < 9 and abs(nums[j + 1] - c) <= 1:
                return ans(j, nums)
        elif j != first and j != last:
            # 間の桁
            if nums[j] < 9 and abs(nums[j - 1] - c) <= 1 and abs(nums[j + 1] - c) <= 1:
                return ans(j, nums)

    # 桁が繰り上がるとき
    return int('1' + ''.join(['0'] * len(nums)))

print(lunlun(k))


### FIXED CODE ###

import sys
# import resource

sys.setrecursionlimit(10 ** 9)
# resource.setrlimit(resource.RLIMIT_STACK, ((2 ** 7) * 1000 * 1000, -1))

k = int(input())

ary = [1, 2, 3, 4, 5, 6, 7, 8, 9]

def ans(j, nums):
    nums[j] += 1
    pre = nums[j]
    for i in range(j + 1, len(nums)):
        if pre > 0:
            nums[i] = pre - 1
            pre = nums[i]
        else:
            nums[i] = pre
    return int(''.join(map(str, nums)))

def lunlun(n):
    if n <= 9:
        return ary[n - 1]
    l = lunlun(n - 1)
    nums = list(map(int, list(str(l))))
    first = len(nums) - 1
    last = 0
    for i in range(len(nums)):
        j = len(nums) - i - 1
        c = nums[j] + 1
        # 桁数が変わらないとき
        if j == first:
            # 1桁目
            if nums[j] < 9 and abs(nums[j - 1] - c) <= 1:
                nums[j] += 1
                return int(''.join(map(str, nums)))
        elif j == last:
            # 最終桁
            if nums[j] < 9 and abs(nums[j + 1] - c) <= 1:
                return ans(j, nums)
        elif j != first and j != last:
            # 間の桁
            if nums[j] < 9 and abs(nums[j - 1] - c) <= 1 and abs(nums[j + 1] - c) <= 1:
                return ans(j, nums)

    # 桁が繰り上がるとき
    return int('1' + ''.join(['0'] * len(nums)))

print(lunlun(k))
N = int(input()) 
A = list(map(int,input().split())) 
B = list(map(int,input().split())) 

ans = 0 
for i in range(N): 
    d = min(A[i], B[i]) 
    ans += d 
    A[i] -= d 
    B[i] -= d 
    d = min(A[i + 1], B[i]) 
    ans += d A[i + 1] -= d 
    B[i] -= d print(ans)
print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
ans = 0
 
for i in range(N):
    k = B[i] - A[i]
    if k > 0:
        ans += A[i]
        A[i] = 0 
        if A[i+1] < k:
            ans += A[i+1]
            A[i+1] = 0
        else:
            ans += k
            A[i+1] -= k
    else:
        ans += B[i]
        A[i] =- k

print(ans)
N = int(input())
d = map(int, input().split())
d.sort()
a = d[N//2-1]
b = d[N//2]
if a==b:
  print(0)
else:
  print(b-a)

### FIXED CODE ###

N = int(input())
d = list(map(int, input().split()))
d.sort()
a = d[N//2-1]
b = d[N//2]
if a==b:
  print(0)
else:
  print(b-a)
a, b = map(int, input().split())

l = [1]
for i in range(2, 999):
    l.append(l[i-2] + i)
    
diff = b - a

print(l[diff-1] - b)


### FIXED CODE ###

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

l = [1]
for i in range(2, 1000):
    l.append(l[i-2] + i)
    
diff = b - a

print(l[diff-1] - b)
import time

def fib(n):
    memo = [0] * n
    memo[0:2] = [2, 1]
    for i in range(2, n):
        memo[i] = memo[i - 1] + memo[i - 2]
    return memo[i]

def main():
    N = input()
    print(fib(int(N)+1))

if __name__ == '__main__':
    main()


### FIXED CODE ###

import time
import sys

def fib(n):
    memo = [0] * n
    memo[0:2] = [2, 1]
    for i in range(2, n):
        memo[i] = memo[i - 1] + memo[i - 2]
    return memo[i]

def main():
    N = input()
    if(int(N) == 0):
        print(2)
        sys.exit()
    elif(int(N) == 1):
        print(1)
        sys.exit()
    else:
        print(fib(int(N)+1))

if __name__ == '__main__':
    main()
n = int(input())
l - list(map(int,input().split()))
if max(l)>= sum(l)-2*max(l):
  print("No")
else:
  print("Yes")

### FIXED CODE ###

n = int(input())
l = list(map(int,input().split()))
if 2*max(l)>= sum(l):
  print("No")
else:
  print("Yes")
a,b,c=input().split()
print('YES' if a[-1]==b[1] and b[-1]==c[1] else 'NO')

### FIXED CODE ###

a,b,c=input().split()
print('YES' if a[-1]==b[0] and b[-1]==c[0] else 'NO')
S = input()

if len(set(S)) == 26:
  print("None")
else:
  for dam in ["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"]:
    if not dam in list(set(S)):
           break
print(dam)

### FIXED CODE ###

S = input()

if len(set(S)) == 26:
  print("None")
else:
  for dam in ["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"]:
    if not dam in list(set(S)):
           break
  print(dam)
import bisect
N = int(input())
A = [int(input()) for n in range(N)]

tree = [[A[0]]]
leaf = [A[0]]
for n in range(1,N):
    a = A[n]
    pos = min(n-1,bisect.bisect_left(leaf,a)-1)
    if pos==-1:
        tree = a + tree
        leaf = a + leaf
    else:
        tree[pos].append(a)
        leaf[pos] = a
print(len(tree))

### FIXED CODE ###

import bisect
from collections import deque
N = int(input())
A = [int(input()) for n in range(N)]

tree = deque([[A[0]]])
leaf = deque([A[0]])
for n in range(1,N):
    a = A[n]
    pos = min(n-1,bisect.bisect_left(leaf,a)-1)
    if pos==-1:
        tree.appendleft([a])
        leaf.appendleft(a)
    else:
        tree[pos].append(a)
        leaf[pos] = a
print(len(tree))
n = int(input())
s = str(input())
r = [i for i in range(n) if s[i] == "("]
l = [i for i in range(n) if s[i] == ")"]
if r == []: print(n*"(" + s)
elif l == []: print(s + n*")")
elif min(r) > max(l):
    print(len(l)*"(" + s + len(r)*")")
else:
    cnt = 0
    for i in reversed(range(len(r))):
        if r[i] < max(l):
            cnt += 1
            l.pop(-1)
    print((len(l)) * "(" + s + (len(r) - cnt) * ")")

### FIXED CODE ###

n = int(input())
s = str(input())
r = [i for i in range(n) if s[i] == "("]
l = [i for i in range(n) if s[i] == ")"]
if r == []: print(n*"(" + s)
elif l == []: print(s + n*")")
elif min(r) > max(l):
    print(len(l)*"(" + s + len(r)*")")
else:
    cnt = 0
    for i in reversed(range(len(r))):
        if r[i] < max(l):
            cnt += 1
            l.pop(-1)
        if l == []: break
    print((len(l)) * "(" + s + (len(r) - cnt) * ")")
n = input()
list = []

for i in range(n):
    s, p = input().split()
    #s, p = sp[0], int(sp[1])
    list.append([i+1, s, p])

list.sort(key=lambda x:(x[0],x[1]))
for l in list:
    print(l[0])


### FIXED CODE ###


n = int(input())
list = []

for i in range(n):
    sp = input().split()
    s = str(sp[0])
    p = int(sp[1])
    list.append([i+1, s, p])

list.sort(key=lambda x:(x[1],-x[2]))
for l in list:
    print(l[0])
a,b = input()
if b%a ==0:
  print(a+b)
else:
  print(b-a)


### FIXED CODE ###

x,y=map(int,input().split())
if y%x ==0:
  print(x+y)
else:
  print(y-x)
N,K = map(int,input().split())
p = list(map(int,input().split)
p.sort(reverse = True)
print(sum(p[:K]))

### FIXED CODE ###

N,K = map(int,input().split())
p = list(map(int,input().split()))
p.sort()
print(sum(p[:K]))
import sys
import numpy as np

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N,T = MI()
	max_T = -1
	dish = []
	for i in range(N):
		A,B = MI()
		dish.append([A,B])
		max_T = max(max_T, A)

	dp=np.array([-1 for _ in range(T+max_T)])
	dp[0] = 0
	upper = 1
	for i in range(N):
		ch2 = (dp>=0)
		ch2[T:] = False
		ch = np.roll(ch2, dish[i][0])
		ch[:i+1]=False
		dp[ch] = np.maximum(dp[ch] , dp[ch2] + dish[i][1])
	print(max(dp[:-1]))
main()

### FIXED CODE ###

import sys
import numpy as np

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N,T = MI()
	max_T = -1
	dish = []
	for i in range(N):
		A,B = MI()
		dish.append([A,B])
		dish.sort(key=lambda x : x[0])
		max_T = max(max_T, A)

	dp=np.array([-1 for _ in range(T+max_T)])
	dp[0] = 0
	upper = 1
	for i in range(N):
		ch = (dp>=0)
		ch[T:] = False
		ch2 = np.roll(ch, dish[i][0])
		ch2[:dish[i][0]]=False
		dp[ch2] = np.maximum(dp[ch2] , dp[ch] + dish[i][1])
	print(max(dp))
main()
while 1:
    try:
        weight = float(input())

        if(weight <= 48.00):
            print("light fly")
        elif(weight <= 51.00):
            print("fly")
        elif(weight <= 54.00):
            print("bantam")
        elif(weight <= 57.00):
            print("feather")
        elif(weight <= 60.00):
            print("light")
        elif(weight <= 64.00):
            print("light welter")
        elif(weight <= 69.00):
            print("welter")
        elif(weight <= 75.00):
            print("light middle")
        elif(weight <= 81.00):
            print("middle")
        elif(weight <= 91.00):
            print("light heavy")
        else:
            print("heavy")
    except ValueError:
        break;



### FIXED CODE ###

# AOJ 0048
# Class
# 5/1/2019

min = 40.00
max = 150.00

measure = [min, 48.00, 51.00, 54.00, 57.00, 60.00, 64.00, 69.00, 75.00, 81.00, 91.00, max]
className = ['light fly',
         'fly',
         'bantam',
         'feather',
         'light',
         'light welter',
         'welter',
         'light middle',
         'middle',
         'light heavy',
         'heavy']

while True:
    try:
        weight = float(input())
    except:
        break;
    for i in range(11):
        if(measure[i] < weight and weight <= measure[i + 1]):
            print(className[i])
#include <stdio.h>

int main() {
    S = input()
    if S[0] == S[1] and S[1] == S[2]:
    print('No')
    else:
    print('Yes')
    
    
    
    
	return 0;
}

### FIXED CODE ###

S = input()
if S[0] == S[1] and S[1] == S[2]:
	print('No')
else:
	print('Yes')
if S = ABC:
 print('ARC')
else:
 print('ABC')

### FIXED CODE ###

s=input()
print("ABC" if s=="ARC" else "ARC")
s = int(input())
MOD = 10 ** 9 + 7
ans = 0
fact = [0] * 10000
fact[0], fact[1] = 1, 1
for i in range(2, 10000):
    fact[i] = (fact[i-1] * i) % MOD

def f(n, r):
    return fact[n] * pow(fact[n-r], -1, MOD) * pow(fact[r], -1, MOD)

for i in range(1, s//3+1):
    if i == 1:
        ans += 1
    else:
        m = s - i * 3
        ans += f(m+i-1, m)
        ans %= MOD
print(ans%MOD)

### FIXED CODE ###

s = int(input())
MOD = 10 ** 9 + 7
ans = 0
fact = [0] * 10000
fact[0], fact[1] = 1, 1
for i in range(2, 10000):
    fact[i] = (fact[i-1] * i) % MOD

def f(n, r):
    return fact[n] * pow(fact[n-r], -1, MOD) * pow(fact[r], -1, MOD)

for i in range(1, s//3+1):
    if i == 1:
        ans += 1
    else:
        m = s - i * 3
        ans += f(m+i-1, m)
        ans %= MOD
print(ans%MOD)
a,b = map(int,input().split())
if(a*b<=0)print(Zero)
elif(a<0 and (b-a)%2==0)
	print(Positive)
else
	print(Negative)

### FIXED CODE ###

a,b = map(int,input().split())
if a*b<=0:
    print("Zero")
elif a<0 and (b-a)%2==0:
    print("Negative")
else:
    print("Positive")
n = int(input())
d = list(map(int,input().split()))
if d[int(n/2)] == d[int(n/2)+1]:
    print(0)
else:
    print(d[int(n/2)+1] - d[int(n/2)])

### FIXED CODE ###

n = int(input())
d = list(map(int,input().split()))
d.sort()
print(d[(int(n/2))] - d[int(n/2)-1])
N,A,B = map(int, input().split())
  
N -= 1
A -= 1
B -= 1

ans = 0
distAB = B - A

if distAB % 2 == 0:
    ans = distAB / 0
else:
    if (N-B) < A:
        ans = (N-B+1) + ((distAB-1)/2)
    else:
        ans = A+1 + ((distAB-1)/2)

print(int(ans))

### FIXED CODE ###

from decimal import *
N,A,B = map(int, input().split())

N -= 1
A -= 1
B -= 1

ans = 0
distAB = B - A

if distAB % 2 == 0:
    ans = Decimal(distAB) / Decimal(2)
else:
    if (N-B) < A:
        ans = (N-B+1) + (Decimal(distAB-1)/Decimal(2))
    else:
        ans = A+1 + (Decimal(distAB-1)/Decimal(2))

print(int(ans))
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
t = input()
n = len(s)
m = len(t)

if m > n:
    print('UNRESTORABLE')
    quit()
i = n-1
while i-m >= 0:
    if (s[i] == t[-1]) or (s[i] == '?'):
        cnt = 0
        flg = False
        while cnt < m:
            if (s[i-cnt] == t[-cnt-1]) or (s[i-cnt] == '?'):
                cnt += 1
                if cnt == m:
                    flg = True
            else:
                break
        if flg:
            break
    i -= 1
if not flg:
    print('UNRESTORABLE')
    quit()
ans = ''
print(cnt)
cnt2 = 0
for k in range(n):
    if (k <= i-cnt) or (k > i):
        if s[k] == '?':
            ans += 'a'
        else:
            ans += s[k]
    else:
        ans += t[cnt2]
        cnt2 += 1
print(ans)


### FIXED CODE ###

#!/usr/bin/env python3
#ABC76 C

from copy import deepcopy
s = list(input())
t = list(input())

ns = len(s)
nt = len(t)
f1 = 0
for i in range(ns):
    if s[i] in t:
        ind = t.index(s[i])
        for j in range(i-ind,i-ind+nt):
            if j < ns:
                if s[j] == t[j-i+ind] or s[j] == '?':
                    continue
                else:
                    break
            else:
                break
        else:
            f1 = 1
            x = deepcopy(s)
            x[i-ind:i-ind+nt] = t
            break
f2 = 0
for i in range(ns)[::-1]:
    if s[i] == '?':
        for j in range(i,i+nt):
            if j < ns:
                if s[j] == t[j-i] or s[j] == '?':
                    continue
                else:
                    break
            else:
                break
        else:
            f2 = 1
            y = deepcopy(s)
            y[i:i+nt] = t
            break
if f1 & f2:
    for i in range(ns):
        if x[i] == '?':
            x[i] = 'a'
        if y[i] == '?':
            y[i] = 'a'
    x = ''.join(x)
    y = ''.join(y)
    ans = [x,y]
    ans.sort()
    print(ans[0])

elif f1 and not f2:
    for i in range(ns):
        if x[i] == '?':
            x[i] = 'a'
    x = ''.join(x)
    print(x)
elif not f1 and f2:
    for i in range(ns):
        if y[i] == '?':
            y[i] = 'a'
    y = ''.join(y)
    print(y)
else:
    print('UNRESTORABLE')
inn = str(input())

result = 999

for i in range(len(inn)-2):
  if i == len(inn) - 3:
    num = inn[i:]

  else:
    num = inn[i:i+3]

  sa = abs(753 - innt(num))

  if sa < result:
    result = sa

prinnt(result)


### FIXED CODE ###


inn = str(input())

result = 999

for i in range(len(inn)-2):
  if i == len(inn) - 3:
    num = inn[i:]

  else:
    num = inn[i:i+3]

  sa = abs(753 - int(num))

  if sa < result:
    result = sa

print(result)
X = int(input())
Y = int(input())

x = X + Y/2
print(int(x))

### FIXED CODE ###

X,Y = map(int,input().split())
print(X+Y//2)
n, k = list(map(int, input().split()))

s = [str, i for in input()]

print(s.lower(k))


### FIXED CODE ###

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

print(s[:k-1]+s[k-1].lower()+s[k:])
from decimal import *
import math
a,b,c = map(int,input().split())
a2 = Decimal(str(math.sqrt(Decimal(str(a))))
b2 = Decimal(str(math.sqrt(Decimal(str(b))))
c2 = Decimal(str(math.sqrt(Decimal(str(c))))

if a2 + b2 < c2:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

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

if c-a-b>0:
    if 4*a*b<(c-a-b)**2:
        print('Yes')
    else:
        print('No')
else:
    print('No')
a = int(input())
b = int(input())
print('GREATER'if a > b 'EQUAL' elif a == b else 'LESS')


### FIXED CODE ###

A = input()
B = input()

if len(A) > len(B):
  print('GREATER')
elif len(A) < len(B):
  print('LESS')
else:
  for i in range(len(A)):
    if int(A[i]) > int(B[i]):
      print('GREATER')
      exit()
    elif int(A[i]) < int(B[i]):
      print('LESS')
      exit()
  print('EQUAL')
N, L = map(int, input().split())
S = [input().split() for i in range(L)]

s = sorted(S)
print(*s)

### FIXED CODE ###

N, L = map(int, input().split())
S = [input() for i in range(N)]
s = sorted(S)
print(*s, sep='')
import copy
import bisect
#input=sys.stdin.readline
#sys.setrecursionlimit(10 ** 9)
import math
import heapq
 
#N, K = list(map(int, input().split()))
 
N = int(input())
 
x = []
for i in range(5):
	x.append(int(input()))
 
bottle = min(x)
times = math.ceil(N/bottle)
print(times + 4)
import sys
from collections import deque, defaultdict
import copy
import bisect
#input=sys.stdin.readline
#sys.setrecursionlimit(10 ** 9)
import math
import heapq

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

N = int(input())

x = []
for i in range(5):
	x.append(int(input()))

bottle = min(x)
times = math.ceil(N/bottle)
print(times + 4)

### FIXED CODE ###

import math
import heapq


N = int(input())

x = []
for i in range(5):
	x.append(int(input()))

bottle = min(x)
times = math.ceil(N/bottle)
print(times + 4)
x,y,z = list(map(int, input().split()))
def myFun(a,b):
  c = a
  a = b
  b = c
  return(a,b)
x,y = myFunc(x,y)
x,z = myFunc(x,z)
print(x,y,z)

### FIXED CODE ###

a,b,c = list(map(int,input().split()))
 
def myFun(x,y):
    val = x
    x = y
    y = val
    return (x,y)
 
a,b = myFun(a,b)
a,c = myFun(a,c)
print(a,b,c)
N , A , B = (map(int , input().split()))
a = ''
l = -(-N//(A + B))
for i in range(l):
    a += 'b'*A
    a += 'r'*B
    if len(a) >= N:
        break
print(list(a[:N]).count('b'))

### FIXED CODE ###

N , A , B = (map(int , input().split()))
def divmod_(a ,b):
    q, mod = divmod(a ,b)
    return q, mod
c , d = divmod_(N ,A+B)
if (d - A) > 0:
    d = A
print((c * A) + d)
k = int(input())
  a, b = map(int,input().split())
  for i in range(a, b):
    if i%k ==0:
      print('OK')
      return
    print('NG')
  return
 

### FIXED CODE ###

def main():
  k = int(input())
  a, b = map(int,input().split())
  for i in range(a, b+1):
    if i%k ==0:
      print('OK')
      return
  print('NG')
  return
 
main()
w, h, n = map(int, input().split())
xya = [list(map(int, input().split())) for _ in range(n)]

ans=[0,0,w,h]
for i in range(n):
    if xya[i][2] == 1:
        if xya[i][0] >= ans[0]:
            ans[0] = xya[i][0]
    elif xya[i][2] == 2:
        if xya[i][0] <= ans[2]:
            ans[2] = xya[i][0]
    elif xya[i][2] == 3:
        if xya[i][1] >= ans[1]:
            ans[1] = xya[i][1]
    elif xya[i][2] == 4:
        if xya[i][1] <= ans[3]:
            ans[3] = xya[i][1]

print(0 if ans[2]-ans[0] <= 0 || ans[3]-ans[1] <= 0 else (ans[2]-ans[0])*(ans[3]-ans[1]))


### FIXED CODE ###

w, h, n = map(int, input().split())
xya = [list(map(int, input().split())) for _ in range(n)]

ans=[0,0,w,h]
for i in range(n):
    if xya[i][2] == 1:
        if xya[i][0] >= ans[0]:
            ans[0] = xya[i][0]
    elif xya[i][2] == 2:
        if xya[i][0] <= ans[2]:
            ans[2] = xya[i][0]
    elif xya[i][2] == 3:
        if xya[i][1] >= ans[1]:
            ans[1] = xya[i][1]
    elif xya[i][2] == 4:
        if xya[i][1] <= ans[3]:
            ans[3] = xya[i][1]

print(0 if ans[2]-ans[0] <= 0 or ans[3]-ans[1] <= 0 else (ans[2]-ans[0])*(ans[3]-ans[1]))