Harryxun/stf_run huggingface dataset:
N,K = map(int,input().split())

H = list(map(int,input().split()))

HSorted = sorted(H)

HIndexToHeight = []
HHeightToIndex = {}

for i in range(N):
    if i != 0 and HSorted[i] == HSorted[i-1]:
        continue
    HIndexToHeight.append(HSorted[i])
    HHeightToIndex[HSorted[i]] = len(HIndexToHeight) - 1

INF = 10 ** 12

heightCount = len(HIndexToHeight)

DP = []
for i in range(N):
    DP.append([])
    for j in range(K + 1):
        DP[i].append([])
        for k in range(heightCount):
            DP[i][j].append(INF)

for k in range(heightCount):
    if k == HHeightToIndex[H[0]]:
        DP[0][0][k] = H[0]
    else:
        DP[0][1][k] = HIndexToHeight[k]

for i in range(1,N):
    currentHeight = HHeightToIndex[H[i]]
    for j in range(K + 1):
        for k in range(heightCount):
            if currentHeight > k:
                if j > 0:
                    DP[i][j][k] = min(DP[i-1][j-1][k], DP[i][j][k])
                DP[i][j][currentHeight] = min(DP[i-1][j][k] + HIndexToHeight[currentHeight] - HIndexToHeight[k], DP[i][j][currentHeight])
            elif currentHeight == k:
                DP[i][j][currentHeight] = min(DP[i-1][j][k], DP[i][j][currentHeight])
            else:
                if j > 0:
                    DP[i][j][k] = min(DP[i-1][j-1][k], DP[i][j][k])
                DP[i][j][currentHeight] = min(DP[i-1][j][k], DP[i][j][currentHeight])
ans = INF

for j in range(K + 1):
    for k in range(heightCount):
        if ans > DP[N-1][j][k]:
            ans = DP[N-1][j][k]

print(ans)




### FIXED CODE ###

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

H = list(map(int,input().split()))

HSorted = sorted(H)

HIndexToHeight = []
HHeightToIndex = {}

for i in range(N):
    if i != 0 and HSorted[i] == HSorted[i-1]:
        continue
    HIndexToHeight.append(HSorted[i])
    HHeightToIndex[HSorted[i]] = len(HIndexToHeight) - 1

INF = 10 ** 12

heightCount = len(HIndexToHeight)

DP = []
for i in range(N):
    DP.append([])
    for j in range(K + 1):
        DP[i].append([])
        for k in range(heightCount):
            DP[i][j].append(INF)

for k in range(heightCount):
    if k == HHeightToIndex[H[0]]:
        DP[0][0][k] = H[0]
    elif K != 0:
        DP[0][1][k] = HIndexToHeight[k]

for i in range(1,N):
    currentHeight = HHeightToIndex[H[i]]
    for j in range(K + 1):
        for k in range(heightCount):
            if currentHeight > k:
                if j > 0:
                    DP[i][j][k] = min(DP[i-1][j-1][k], DP[i][j][k])
                DP[i][j][currentHeight] = min(DP[i-1][j][k] + HIndexToHeight[currentHeight] - HIndexToHeight[k], DP[i][j][currentHeight])
            elif currentHeight == k:
                DP[i][j][currentHeight] = min(DP[i-1][j][k], DP[i][j][currentHeight])
            else:
                if j > 0:
                    DP[i][j][k] = min(DP[i-1][j-1][k], DP[i][j][k])
                DP[i][j][currentHeight] = min(DP[i-1][j][k], DP[i][j][currentHeight])
ans = INF

for j in range(K + 1):
    for k in range(heightCount):
        if ans > DP[N-1][j][k]:
            ans = DP[N-1][j][k]
if K == N:
    print(0)
else:
    print(ans)
from collections import deque
from operator import itemgetter
import heapq
import sys
n,p=map(int,input().split())

e=[]
for _ in range(n):
    s,t,x = map(int,input().split())
    e.append((s-x,1,x))
    e.append((t-x,-1,x))
e = sorted(e, key=itemgetter(0))
q = deque()
for _ in range(p):
    q.append(int(input()))
s=set()

for t,f,x in e:
    while t > q[0]:
        q.popleft()
        if s:
            print(min(s))
        else:
            print(-1)
        if not q:
            sys.exit()
    if f == 1:
        s.add(x)
    else:
        s.remove(x)
        
while q:
    q.pop()
    print(-1)

### FIXED CODE ###

import sys
input = sys.stdin.readline
 
n,q = map(int,input().split())
imos = []
for i in range(n):
    s,t,x = map(int,input().split())
    imos.append((s-x,x))
    imos.append((t-x,-x))
ans = set()
j = 0
for i in range(q):
    d = int(input())
    imos.append((d,1e100))
imos.sort()
m = 1e100
flag = False
for t,stop in imos:
    if stop == 1e100:
        if ans:
            if not flag:
                m = min(ans)
                flag = True
            print(m)
        else:
            print(-1)
    elif stop > 0:
        ans.add(stop)
        if stop < m:
            m = stop
            flag = True
    else:
        ans.remove(-stop)
        if m == -stop:flag = False
n,m=map(int,input().split())
N=2*m+1
if m%2==0:
    for i in range(m//2):
        print(i+1,m+1-i)
        print(m+2+i,N-i)
else:
    for i in range(m//2):
        print(i+1,m-i)
        print(m+1+i,N-i)
    print(m+1+i+1,N-i-1)

### FIXED CODE ###

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

for i in range(M):
    j = i // 2
    if i % 2 == 1:
        print(j+1, M-j)
    else:
        print(M+j+1, 2*M+1-j)
a = input()
ls = {}
for i in range(ord('a'), ord('z')):
    ls[chr(i)] = 0

for i in a:
    ls[i]+=1;

f = 1;
for i in a:
    if ls[i] > 1:
        f = 0
        break
if f:
    print("yes")
else:
    print("no")


### FIXED CODE ###

a = input()
ls = {}
for i in range(ord('a'), ord('z') + 1):
    ls[chr(i)] = 0

for i in a:
    ls[i]+=1;

f = 1;
for i in a:
    if ls[i] > 1:
        f = 0
        break
if f:
    print("yes")
else:
    print("no")
S = include()
a = "Sunny"
b = 'Cloudy'
c = 'Rainy'
if S == a:
    print('Cloudy')
    elif S == b:
        print('Rainy')
    elif S == b:
        print('Sunny')
else
exit()

### FIXED CODE ###

import sys
S = input()
a = "Sunny"
b = 'Cloudy'
c = 'Rainy'
if S == a:
    print(b)
elif S == b:
        print(c)
elif S == c:
        print(a)
else:
    sys.exit()
sys.exit()
q = input().strip().split()
N, X, T = int(q[0]), int(q[1]), int(q[2])
ans = ((N + x) // x - 1) * T
print(ans)

### FIXED CODE ###

q = input().strip().split()
N, X, T = int(q[0]), int(q[1]), int(q[2])
ans = (N + X - 1) // X * T
print(ans)
import bisect

N,A=map(int,input().split())
x=[i-A for i in map(int,input().split())]


dp=[[0]*(2*N*A+1) for _ in [0]*(N+1)]
dp[0][N*A]=1
# dp[n][k]:n番目までの整数でkが作れる場合の数
    
for n in range(1,N+1):
    for k in range(-N*A,N*A+1):
        dp[n][k]+=dp[n-1][k-x[n-1]]+dp[n-1][k]

print(dp[N][N*A]-1)

### FIXED CODE ###

import bisect

N,A=map(int,input().split())
x=[i-A for i in map(int,input().split())]

B=max(max(x),abs(min(x)))

dp=[[0]*(2*N*B+1) for _ in [0]*(N+1)]
dp[0][N*B]=1
# dp[n][k]:n番目までの整数でkが作れる場合の数
    
for n in range(1,N+1):
    for k in range(-N*B,N*B+1):
        dp[n][k]+=dp[n-1][k-x[n-1]]+dp[n-1][k]

print(dp[N][N*B]-1)
import math
n, p = [int(i) for i in input().split()]
max_x = int(p**(1/n))
ans = 1
for i in range(max_x+1, 1, -1):
    if p % math.pow(i,n) == 0:
        ans = i
        break
print(ans)

### FIXED CODE ###

n, p = [int(i) for i in input().split()]
tmp = p**(1/n)
if tmp - int(tmp) > 0.999:
    max_x = int(tmp) + 1
else:
    max_x = int(tmp)
ans = 1
for i in range(max_x, 1, -1):
    if p % pow(i,n) == 0:
        ans = i
        break
print(ans)
a,b,c,d=map(int,input().split())
print("Yes" b-a<=d and c-b<=d else "No" )

### FIXED CODE ###

a,b,c,d=map(int,input().split())
print("Yes" if (abs(b-a)<=d and abs(c-b)<=d) or abs(c-a)<=d else "No" )
n = int(input())
a = list(input().split())

A = []
A1 = []
A2 = []
for i in a:
    A.append(list(i))
    A1.append(list(i))
    A2.append(list(i))

# check stable or not
def is_stable(A3):
    for i in range( 1, n ):
        if int(A3[i-1][1]) == int(A3[i][1]):
            sm = i-1
            bg = i
            for j in range( n ):
                if ( A[j][0] == A3[sm][0]) & ( A[j][1] == A3[sm][1]):
                    t1 = j
                if ( A[j][0] == A3[bg][0]) & ( A[j][1] == A3[bg][1]):
                    t2 = j
            print(t1)
            print(t2)
            if t1 > t2:
                return "Not stable"
    return "Stable"

# bubble
for i in range( n ):
    for j in range( n-1, i, -1 ):
        if int(A1[j][1]) < int(A1[j-1][1]):
            t = A1[j-1]
            A1[j-1] = A1[j]
            A1[j] = t

s = is_stable(A1)
print(" ".join(A1))
print(s)


# selection
for i in range( n ):
    minj = i
    for j in range( i+1, n ):
        if int(A2[j][1]) < int(A2[minj][1]):
            minj = j
    if minj != i:
        t = A2[i]
        A2[i] = A2[minj]
        A2[minj] = t

s = is_stable(A2)
print(" ".join(A2))
print(s)

### FIXED CODE ###

import copy

N = int(input())
A = list(input().split())

def is_stable(sorted_list):
    for i in range(len(sorted_list)-1):
        if sorted_list[i][1] == sorted_list[i+1][1]:
            for j in range(len(A)):
                if A[j] == sorted_list[i]:
                    smaller_idx = j
                if A[j] == sorted_list[i+1]:
                    larger_idx = j
            if smaller_idx > larger_idx:
                return False
    return True

def print_stable_or_not(is_stable):
    if is_stable:
        print("Stable")
    else:
        print("Not stable")

def bubble_sort(A1):
    flg = True
    while flg:
        for i in range(N):
            flg = False
            for j in range(N-1, i, -1):
                if int(A1[j-1][1]) > int(A1[j][1]):
                    A1[j-1], A1[j] = A1[j], A1[j-1]
                    flg = True
    print(" ".join(A1))
    print_stable_or_not(is_stable(A1))

def insertion_sort(A2):
    for i in range(N-1):
        min_idx = i
        for j in range(i+1, N):
            if int(A2[min_idx][1]) > int(A2[j][1]):
                min_idx = j
        if min_idx != i:
            A2[i], A2[min_idx] = A2[min_idx], A2[i]
    print(" ".join(A2))
    print_stable_or_not(is_stable(A2))

if __name__ == '__main__':
    A1 = copy.deepcopy(A)
    A2 = copy.deepcopy(A)
    bubble_sort(A1)
    insertion_sort(A2)
## B - Iron Bar Cutting
N = int(input())
A = list(map(int, input().split()))
val = sum(A)//2
tmp = 0
for n in range(N):
    tmp += A[n]
    if tmp >= val:
        print( min( abs(sum(A[n+1:] - tmp ), abs(sum(A[n:] - tmp - A[n] ) )
        break

### FIXED CODE ###

## B - Iron Bar Cutting
N = int(input())
A = list(map(int, input().split()))
L = 0
R = sum(A)
ans = sum(A)
for n in range(N):
    L += A[n]
    R -= A[n]
    if ans > abs(L-R):
        ans = abs(L-R)
print(ans)
# 未完成
import numpy as np
N = int(input())
x = np.zeros(N)
y = np.zeros(N)
kouholist = []

for i in range(N):
    x[i], y[i] = map(int, input().split())
ans = []
for m in range(N):
    for p in range(N):
        if m == p:
            continue
        diff_x = x[m] - x[p]
        diff_y = y[m] - y[p]
        ans_kari = 0
        if (diff_x, diff_y) not in kouholist:
            kouholist.append((diff_x, diff_y))

for list_i in kouholist:
    ans_kari=0
    for r in range(N):
        for q in range(N):
            if r == q:
                continue
            if x[q] - x[r] == list_i[0] and y[q] - y[r] == list_i[1]:
                ans_kari += 1
    ans.append(ans_kari)

print("{}".format(N-max(ans)))


### FIXED CODE ###

# 未完成

import sys
N = int(input())
x = [0]*N
y = [0]*N
kouholist = []
ans = N
if N == 1:
    print(1)
    sys.exit()

for i in range(N):
    x[i], y[i] = map(int, input().split())
for m in range(N):
    for p in range(N):
        if m == p:
            continue
        diff_x = x[m] - x[p]
        diff_y = y[m] - y[p]
        ans_kari = N
        for r in range(N):
            for q in range(N):
                if x[q] - x[r] == diff_x and y[q] - y[r] == diff_y:
                    ans_kari -= 1
        if ans_kari < ans:
            ans = ans_kari

print("{}".format(ans))
import math
a, b, C = map(float, input().split()
C_rad = math.radians(C)
c = math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(C_rad))
S = a * b * math.sin(C_rad) / 2
L = a + b + c
h = b * math.sin(C_rad)
print("{0:.6} {1:.6} {2:.6}".format(S, L, h))

### FIXED CODE ###

import math
a, b, C = map(float, input().split())
C_rad = math.radians(C)
c = math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(C_rad))
S = a * b * math.sin(C_rad) / 2
L = a + b + c
h = b * math.sin(C_rad)
print("{0} {1} {2}".format(S, L, h))
N,M=map(int,input().split())
A=list(map(int,input().split()))
A=A.sort(reverse=True)
s=sum(A)

P=0 #選べる個数
for a in A:
    if a>=s/(4*M):
        P+=1
    else:
        break
        
if P==M:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
s=sum(A)

if A[M-1]>=s/(4*M):
    print("Yes")
else:
    print("No")
def main():
  N = int(input())
  A = [int(x) for x in input().split()]
  
  B = []
  for i in range(N):
    B.append(0)
    
  for i in range(N):
    e = int(A[N-i-1])
    B[e] += 1
  
  for i in range(N):
    print(B[i])
    
if __name__ == '__main__':
  main()

### FIXED CODE ###

def main():
  N = int(input())
  A = [int(x) for x in input().split()]
  
  B = [0] * N    
  for i in range(N-1):
      B[A[N-i-2]-1] += 1
  
  for i in range(N):
    print(B[i])
    
if __name__ == '__main__':
  main()
b = inout()
if  b == "A":
    print("T")
elif b == "C":
    print("G")
elif b == "T":
    print("A")
else:
    print("C")

### FIXED CODE ###

b = input()
if  b == "A":
    print("T")
elif b == "C":
    print("G")
elif b == "T":
    print("A")
else:
    print("C")
import sys
import math
sys.setrecursionlimit(200000)
MOD = 10 ** 9 + 7


def main():
    X, Y = map(int, input().split())
    while X != Y:
        if X > Y:
            X -= 2
            Y -= 1
        else:
            X -= 1
            Y -= 2
    if X % 2 == 1 and Y % 2 == 1:
        ab = math.factorial((X + Y) // 3)
        a = math.factorial(X // 3)
        b = math.factorial(Y // 3)
        print(ab // (a * b) % MOD)
    else:
        print(0)



if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
import math
sys.setrecursionlimit(200000)
MOD = 10 ** 9 + 7


def extgcd(a, b):
    r = [1, 0, a]
    w = [0, 1, b]
    while w[2] != 1:
        q = r[2] // w[2]
        r2 = w
        w2 = [r[0] - q * w[0], r[1] - q * w[1], r[2] - q * w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0], w[1]]
# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)


def mod_inv(a,m):
    x = extgcd(a, m)[0]
    return (m + x % m) % m


def main():
    X, Y = map(int, input().split())
    if (X + Y) % 3 != 0:
        print(0)
        exit()
    else:
        m = (2 * X - Y) // 3
        n = (2 * Y - X) // 3
        if m < 0 or n < 0:
            print(0)
            exit()
        else:
            res = 1
            for i in range(1, n + m + 1):
                res = res * i % MOD
            for i in range(1, n + 1):
                res = res * mod_inv(i, MOD) % MOD
            for i in range(1,m + 1):
                res = res * mod_inv(i, MOD) % MOD
            print(res)

if __name__ == "__main__":
    main()
def main():
    N = int(input())
    L = list(map(int, input().split()))

    s1, s2 = 0,sum(L)
    ans = sum(L)

    for i in range(N):
        s1 += L[i]
        s2 -= L[i]
        ans = min(ans, abs(s1-s2))

    print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    p = list(map(int,input().split()))
    ans = []

    p.sort()

    ans = p[0] + p[1]
    print(ans)

if __name__ == '__main__':
    main()
import sys, io, os, re
import bisect
from pprint import pprint
from math import sin, cos, pi, radians, sqrt
from copy import copy, deepcopy
from collections import deque
from fractions import gcd

def array1(n): return [0] * n
def array2(n, m): return [[0] * m for x in range(n)]
def array3(n, m, l): return [[[0] * l for y in xrange(m)] for x in xrange(n)]

a = int(sys.stdin.readline().strip())
arr = map(int, sys.stdin.readline().strip().split())

x = reduce(lambda x, y: x*y, arr)

print(x if x < 10**18 else -1)


### FIXED CODE ###

import sys, io, os, re
import bisect
from pprint import pprint
from math import sin, cos, pi, radians, sqrt
from copy import copy, deepcopy
from collections import deque
from fractions import gcd
from functools import reduce

def array1(n): return [0] * n
def array2(n, m): return [[0] * m for x in range(n)]
def array3(n, m, l): return [[[0] * l for y in xrange(m)] for x in xrange(n)]

a = sys.stdin.readline().strip()
arr = list(map(int, sys.stdin.readline().strip().split()))
mod = 10**18

ans = arr[0]
for i in range(1, len(arr)):
    ans *= arr[i]
    if ans > mod:
        ans = -1
        break

if 0 in arr:
    ans = 0

print(ans)
DEVISOR = 2019

L, R = (int(word) for word in input().split())

if R // DEVISOR > L // DEVISOR:
    print(0)

L %= DEVISOR
R %= DEVISOR

print(min(i * j for i in range(L, R) for j in range(i+1, R+1)))


### FIXED CODE ###

DEVISOR = 2019

L, R = (int(word) for word in input().split())

if (R // DEVISOR) > (L // DEVISOR):
    print(0)
    exit()

L %= DEVISOR
R %= DEVISOR

print(min(i * j % DEVISOR for i in range(L, R) for j in range(i+1, R+1)))
#!/mnt/c/Users/moiki/bash/env/bin/python
H,W      = list(map(int, input().split()))
S        =  [ list(input()) for _ in range(H)]


united_count = [ ]
# [ (黒1個、白2個) ,... k 個] 

directions = [(1,0), (0,1), (-1,0), (0,-1)] # y,x の順番


def dfs(pos, c, now_k):
    # pos : (1,2)
    # 引数は現在の連結成分の番号
    # 座標と、現在の1,0 が渡される
    # 渡されたnow_kで塗りつぶす
    y,x = pos
    for d in directions:
        try:
            if y+d[0] < 0 or x+d[1] < 0:
                continue
            content = S[y+d[0]][x+d[1]] 

            if c != content and (content == "#" or content == ".") :
                S[y+d[0]][x+d[1]] = now_k
                inplace_tuple     = united_count[now_k]
                united_count[now_k]     = ( inplace_tuple[0] + 1, inplace_tuple[1]) if content == "#" else \
                                    ( inplace_tuple[0]    , inplace_tuple[1]+1) # タプルなので新しく作る

                dfs( (y+d[0], x+d[1]),  content,  now_k)  # DFSかける

            else:
                continue
        except:
            continue



now_k = 0
for y in range(H):
    for x in range(W):
        c = S[y][x]  
        if c == "#" or c == "." :
            united_count.append( (1,0) if  c == "#" else (0,1) ) # now_k番目
            S[y][x] = now_k  # cの値は黒だったら、1 を入れてdfsに投げる

            pos = (y,x)
            dfs(pos, c, now_k)
            now_k         += 1

        else:
            continue # もう数字が入っている場合は、パス

# for y in range(H):
#     for x in range(W):
#         print(S[y][x], end="")
#     print("")


answer = 0
mod    = int(1e9)+7
for uni in united_count:
    answer = ((uni[0]*uni[1])%mod + answer) % mod

print(answer)




### FIXED CODE ###

#!/mnt/c/Users/moiki/bash/env/bin/python
H,W      = list(map(int, input().split()))
S        =  [ list(input()) for _ in range(H)]

import sys
sys.setrecursionlimit(2600000)

united_count = [ ]
# [ (黒1個、白2個) ,... k 個] 

directions = [(1,0), (0,1), (-1,0), (0,-1)] # y,x の順番


def dfs(pos, c, now_k):
    # pos : (1,2)
    # 引数は現在の連結成分の番号
    # 座標と、現在の1,0 が渡される
    # 渡されたnow_kで塗りつぶす
    y,x = pos
    for d in directions:
        try:
            if y+d[0] < 0 or x+d[1] < 0:
                continue
            content = S[y+d[0]][x+d[1]] 

            if c != content and (content == "#" or content == ".") :
                S[y+d[0]][x+d[1]] = now_k
                inplace_tuple     = united_count[now_k]
                united_count[now_k]     = ( inplace_tuple[0] + 1, inplace_tuple[1]) if content == "#" else \
                                    ( inplace_tuple[0]    , inplace_tuple[1]+1) # タプルなので新しく作る

                dfs( (y+d[0], x+d[1]),  content,  now_k)  # DFSかける

            else:
                continue
        except:
            continue



now_k = 0
for y in range(H):
    for x in range(W):
        c = S[y][x]  
        if c == "#" or c == "." :
            united_count.append( (1,0) if  c == "#" else (0,1) ) # now_k番目
            S[y][x] = now_k  # cの値は黒だったら、1 を入れてdfsに投げる

            pos = (y,x)
            dfs(pos, c, now_k)
            now_k         += 1

        else:
            continue # もう数字が入っている場合は、パス


answer = 0
for uni in united_count:
    answer = ((uni[0]*uni[1]) + answer) 

print(answer)
lis = map(int,list(input().split()))
lis.sort()
if lis == [5,5,7]:
  print('YES')
else:
  print('NO')


### FIXED CODE ###

lis = list(map(int,input().split()))
lis.sort()
if lis == [5,5,7]:
  print('YES')
else:
  print('NO')
N = int(input())


def sum_ms(ps):
    n = len(ps)
    result = 0
    for j in range(n):
        i = j + 1
        result += i % ps[j]
    return result


ps = list(range(2, N + 1))
ps.append(1)
print(sum_ms(ps))

### FIXED CODE ###

import decimal

N = decimal.Decimal(input())
print(N * (N - 1) / 2)
import sys

table = "abcdefghijklmnopqrstuvwxyz"

sentence = sys.stdin.read()
sentence1 = sentence.lower()
for i in table:
    print(i + ' : ' + str(sentence1.count(i))



### FIXED CODE ###

import sys

table = "abcdefghijklmnopqrstuvwxyz"

sentence = sys.stdin.read()
sentence1 = sentence.lower()
for i in table:
    print(i + ' : ' + str(sentence1.count(i)))
def typing(s, ans):
    for i in range(len(s)):
        if s[i] == '0':
            ans.append('0')
        elif s[i] == '1':
            ans.append('1')
        elif s[i] == 'B' and ans != '':
            ans.pop()
        else:
            continue
            
    print(ans)

S = str(input())
ANS = []
typing(S, ANS)

### FIXED CODE ###

def typing(s, ans):
    for i in range(len(s)):
        if s[i] == '0':
            ans += '0'
        if s[i] == '1':
            ans += '1'
        if s[i] == 'B' and ans != '':
            ans = ans[:len(ans)-1]

    print(ans)

S = str(input())
ANS = ''
typing(S, ANS)
x1, v1 = map(int, input().split(' '))
x2, v2 = map(int, input().split(' '))
t = int(input())

if v1 == v2:
	print("NO")
else:
	s = abs(x2 - x1) / (v1 - v2)
	if s <= T:
		print("YES")
	else:
		print("NO")

### FIXED CODE ###

x1, v1 = map(int, input().split(' '))
x2, v2 = map(int, input().split(' '))
t = int(input())

p = abs(x2 - x1)
q = (v1 - v2) * t
if p <= q:
	print("YES")
else:
	print("NO")
import sys
import math
 
a,b=map(int, input().split())
 
probablity = 0.0
 
for i in range(a + 1):
  ceil = math.ceil(math.log2(b / (i + 1)))
  if(ceil < 0):
    ceil = 0
  elif(ceil < 1):
    ceil = 1
    
  probablity = probablity + 1 / (a * 2 ** ceil)
  
print(probablity)
import sys
import math
 
a,b=map(int, input().split())
 
probablity = 0.0
 
for i in range(a + 1):
  ceil = math.ceil(math.log2(b / (i + 1)))
  if(ceil < 0):
    ceil = 0
    
  probablity = probablity + 1 / (a * 2 ** ceil)
  
print(probablity)


### FIXED CODE ###

import sys

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

abcs = input()
 
def change_upper_to_lower(str, num):
  
  before = str[:int(num) - 1]
  after = str[int(num):]

  if(str[int(num) - 1] == "A"):
    newstr = before + "a" + after
  elif(str[int(num) - 1] == "B"):
    newstr = before + "b" + after
  else:
    newstr = before + "c" + after
    
  return newstr
 
 
changed_abcs = change_upper_to_lower(abcs, b)
 
print(changed_abcs)
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

a = i()
b = i()

if len(a) > len(b):
	print("GREATER")
elif a == b:
	print("EQUAL")
else:
	print("LESS")

### FIXED CODE ###

def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

a = i()
b = i()

if a > b:
	print("GREATER")
elif a == b:
	print("EQUAL")
else:
	print("LESS")
N,K = map(input.split())

if K==1:
  print(0)
else : 
  print(N % K)

### FIXED CODE ###

N, K = map(int,input().split())
if K==1: print(0)
else: print(N-K)
num =input()

YN = []

for i in range(num):
    x = map(float, raw_input().split(' '))

    if (x[0]-x[2])/(x[1]-x[3]) == (x[4]-x[6])/(x[5]-x[7]):
        YN.append('YES')
    else:
        YN.append('NO')

for i in YN:
    print i

### FIXED CODE ###

num =input()


for i in range(num):
    x = map(float, raw_input().split(' '))

    if x[1]-x[3] == 0 or x[5]-x[7] == 0:
        if x[1]-x[3] == 0 and x[5]-x[7] == 0:
            print 'YES'
        else:
            print 'NO'
        
    elif (x[0]-x[2])/(x[1]-x[3]) == (x[4]-x[6])/(x[5]-x[7]):
        print 'YES'
    else:
        print 'NO'