Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	scanner.Split(bufio.ScanWords)
	n := nextInt()
	for i := 0; i < n; i++ {
		a := -1
		b := -1
		ans := true
		// それぞれの筒の一番上にあるたまの数字に着目すればよい
		for j := 0; j < 10; j++ {
			x := nextInt()
			if x > a {
				a = x
			} else if x > b {
				b = x
			} else {
				ans = false
			}
		}
		if ans {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

Python: N = int(input())
for i in range(N):
    Ball = list(map(int, input().split()))
    cannot = 0
    right = 0
    left = 0
    for j in range(10):
        if abs(Ball[j] - right) <= abs(Ball[j] - left) and Ball[j] > right:
            right = Ball[j]
        elif abs(Ball[j] - right) > abs(Ball[j] - left) and Ball[j] > left:
            left = Ball[j]
        else:
            cannot = 1
            break
    if cannot == 1: print('NO')
    elif cannot == 0: print('YES')

Python: # import sys
from itertools import compress
# from random import shuffle, seed, random
from time import perf_counter


def is_right_order(B, C):
    """ B, C????????§??????????????????????????????(??????)????????§???????????? """
    max_val = 0
    for b in B:
        if b < max_val:
            return False
        max_val = b

    max_val = 0
    for c in C:
        if c < max_val:
            return False
        max_val = c
    return True


def solve_bf(d):
    """ ??????????????§?§£???(??????) """
    for i in range(1024):  # ????????§??????????????????????????????????????????????????????B?????????C????????????????????????
        bin_i = '{0:010b}'.format(i)
        bin_i = [int(x) for x in bin_i]
        comp = compress(d, bin_i)
        B = list(comp)
        C = d[:]
        for b in B:
            C.remove(b)
        if is_right_order(B, C):  # ???????????????????????????????????§?????¶???????????????????????????????¨???????
            return True
    return False


def solve_greed(d):
    """ ????¬????????????????
    ????????¨?????????????????????????????\????????????C?????\?????????????????\?????????B?????\?????????
    ??? ???????????????????????????????????°????????¨???????????????????????¨????????????????????????????????´?????????
    """
    used = [False] * 11  # ???????????????????????????????????????????????°?????????????????????index??????????????????used[1]?????????????????????????????§????????????+1????????????

    B = []  # ?????\????????????????????\?????????
    C = []  # ????????\???????????????????????????????????\?????????
    for b in d:
        cb = 0
        for i in range(1, 11):
            if used[i] == False:
                cb = i  # ?????????????????????????????????????????\????????????cb??¨?????¶
                break
        if b == cb:
            C.append(b)
        else:
            B.append(b)
        used[b] = True  # ????????????????????????????????????B?????????C???????????????????????????????????§????????¨?????????
    return is_right_order(B, C)


if __name__ == '__main__':
    # ??????????????\???
    num = int(input())
    data = []
    for _ in range(num):
        data.append(list(map(int, input().split(' '))))

    # ???????????¨??????????????????????????????
#    for i in range(100):
#        t = list(range(1, 11))
#        shuffle(t)
#        data.append(t)

    # start_time = perf_counter()
    # ????????????
    for d in data:
        # print('trying: {0}'.format(d))
        #result = solve_bf(d)
        result = solve_greed(d)

        if result:
            print('YES')
        else:
            print('NO')

    # end_time = perf_counter()
    # print('elapsed: {0}'.format(end_time - start_time))

Python: x=int(input())
for _ in range(x):
	num=list(map(int,input().split()))
	b,c=0,0
	flag=True
	for d in num:
		if b < d:
			b=i
		elif c<i:
			c=i
		else:
			print("NO")
			flag=False
			break
	if flag:
		print("YES")

Python: n = int(input())
for i in range(n):
    a = list(map(int, input().split()))
    b = c = 0
    yes = True
    for j in range(10):
        if a[j] > b: b = a[j]
        elif a[j] > c: c = a[j]
        else: yes = False
    print('YES' if yes else 'NO')

Python: import sys
f = sys.stdin
def cylinder(balls):
    cy = []
    for ball in balls:
        if len(cy) < 2:
            pass
        elif min(ball, *cy) == ball:
            return False
        elif max(ball, *cy) == ball:
            cy.remove(max(cy))
        else:
            cy.remove(min(cy))
        cy.append(ball)
    return True

n = int(f.readline())
for _ in range(n):
    balls = list(map(int, f.readline().split()))
    print('YES' if cylinder(balls) else 'NO')

Python: n = int(input())
for _ in range(n):
    data = list(map(int, input().split()))
    B, C = 0, 0
    flag = True
    for d in data:
        if B < d:
            B = d
        elif C < d:
            C = d
        else:
            print("NO")
            flag = False
            break
    if flag:
        print("YES")

Python: n = int(input())
for _ in range(n):
    balls = list(map(int, input().split()))
    b = 0
    c = 0
    flag = True
    for itm in balls:
        if b>c: b,c = c,b
        if c<itm: c=itm; continue
        elif b<itm: b=itm; continue
        else: flag = False; break
    if flag: print("YES")
    else: print("NO")

Python: import bisect


def LIS(seq):
    r = [seq[0]]
    for n in seq[1:]:
        if n > r[-1]:
            r.append(n)
        else:
            idx = bisect.bisect_left(r, n)
            r[idx] = n
    return r
N = int(input())
for _ in range(N):
    seq = list(map(int, input().split()))
    left = set(LIS(seq))
    remain = [n for n in seq if n not in left]
    right = LIS(remain)
    print("YES" if len(left) + len(right) == len(seq) else "NO")

Python: x=int(input())
for i in range(x):
	num=[int(i) for i in input().split()]
	b=[]
	c=[]
	flag=0
	b.append(num[0])
	c.append(min(num)-1)
	for i in range(1,10):
		if b[len(b)-1]<num[i]:
			b.append(num[i])
		elif c[len(c)-1]<num[i]:
			c.append(num[i])
		else:
			flag=1
			break
	if flag==0:
		print("YES")
	else:
		print("No")

Python: import sys
def solve(balls):
    if distribute(balls, [], []): print('YES')
    else: print("NO")
        
def distribute(balls, R, L):    
    if len(balls) != 0:
        next = balls[0]
        if isMutch(next, R):
            neoR = R
            neoR.append(next)
            if distribute(balls[1:], neoR, L): return True
        
        if isMutch(next, L):
            neoL = L
            neoL.append(next)
            if distribute(balls[1:], R, neoL): return True
    else:
        return isOrdered(R) and isOrdered(L)

def isMutch(next, lis):
    if len(lis) != 0:
        return next >= lis[len(lis)-1]
    return True
    
def isOrdered(lis):
    #check both R and L are ordered
    checker = sorted(lis)
    return checker == lis

sys.setrecursionlimit(2**11)
size = int(input());
for i in range(size):
    balls = []
    for a in input().split(' '):
        balls.append(int(a))   
    solve(balls)

Python: n = int(input())
for i in range(n):
    a = list(map(int, input().split()))
    b = 0
    c = 0
    for j in range(10):
        if a[j] > b:
            if a[j] > c:
                if a[j] - b < a[j] - c:
                    b = a[j]
                else:
                    c = a[j]
            else:
                b = a[j]
        elif a[j] > c:
            c = a[j]
        else:
            print("NO")
            break

        if j == 9:
            print("YES")