Go: package main

import "fmt"

func isOrdered(a []int) bool {
	if len(a) <= 1 {
		return true
	}
	for i := 0; i+1 < len(a); i++ {
		if a[i] > a[i+1] {
			return false
		}
	}
	return true
}

func main() {
	// ボールの数がせいぜい10個しかないので、全てのボールの落とし方を全探索することが可能
	// Bit全探索を行う。右から見てj番目のビットが立っているときには左側の筒、立っていない時は右側の筒にいれる物とする。
	// 全てのボールを落とし終わった後に、それぞれの筒で昇順に並んでいるか調べることにする。
	var t int
	fmt.Scan(&t)
	ans := make([]bool, t)
	for i := 0; i < t; i++ {
		balls := make([]int, 10)
		for i := range balls {
			fmt.Scan(&balls[i])
		}
		ans[i] = false
		for bits := 0; bits < (1 << uint(10)); bits++ {
			pipeB := make([]int, 0)
			pipeC := make([]int, 0)
			for j := 0; j < 10; j++ {
				if (bits & (1 << uint(j))) != 0 {
					pipeB = append(pipeB, balls[j])
				} else {
					pipeC = append(pipeC, balls[j])
				}
			}
			if isOrdered(pipeB) && isOrdered(pipeC) {
				// fmt.Printf("test case %d - OK pattern - pipeB %v, pipec %v\n", i, pipeB, pipeC)
				ans[i] = true
				break
			}
		}
	}
	for i := range ans {
		if ans[i] {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

Python: # -*- coding: utf-8 -*-


def ball(nums):
    l = []
    r = []
    for i, num in enumerate(nums):
        if i == 0:
            l.append(num)
        elif l[-1] < num:
            l.append(num)
        elif len(r) == 0:
            r.append(num)
        elif r[-1] < num:
            r.append(num)
        else:
            return 'NO'
    return 'YES'

N = int(input())
# N = 1


for _ in range(N):
    nums = [int(e) for e in input().split()]
    # nums = [3, 1, 4, 2, 5, 6, 7, 8, 9, 10]
    # nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
    print(ball(nums))

Python: n = int(input())
for i in range(n):
    balls = list(map(int, input().split()))

    count = 0
    first = 0
    for i, n in enumerate(balls):
        min_ball = 11
        for m in balls[i:]:
            if m != first and n < m < min_ball:
                min_ball = m
        if min_ball != 11:
            first = min_ball
            count += 1
        if count == 2:
            break
    if count == 2:
        print('YES')
    else:
        print('NO')

Python: def dfs(i, b, c):
    if i == 11:
        print(b)
        print(c)
        return (b == sorted(b) and c == sorted(c))

    if dfs(i + 1, b + [balls[i - 1]], c):
        return True

    if dfs(i + 1, b, c + [balls[i - 1]]):
        return True

    return False


if __name__ == '__main__':
    N = int(input())
    for i in range(N):
        balls = list(map(int, input().split()))
        if dfs(1, [], []):
            print("YES")
        else:
            print("NO")

Python: class Depth_First_Search:
    def __init__(self, bolls):
        self.bolls = bolls
        self.possible = False

    def search(self, left, right, remaining):
        if len(remaining) == 0:
            self.possible = True
        else:
            boll = remaining[0]
            if boll > max(left):
                self.search(left+[boll], right, remaining[1:])
            if boll > max(right):
                self.search(left, right+[boll], remaining[1:])

    def run(self):
        self.search([-1], [-1], self.bolls)

if __name__ == '__main__':
    N = int(input())
    for i in range(N):
        bolls = list(map(int, input().split(' ')))
        DFS = Depth_First_Search(bolls)
        DFS.run()
        if DFS.possible:
            print('YES')
        else:
            print('NO')

Python: from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

for _ in xrange(int(stdin.readline())):
    result = 'YES'
    b = c = 0
    for a in (int(s) for s in stdin.readline().split()):
        if b < a:
            b = a
        elif c < a:
            c = a
            if b < c:
                b, c = c, b
        else:
            result = 'NO'
            break
    print(result)

Python: 
N = int(input())

for i in range(N):
    x = input()
    y = x.split(' ')
    a = []
    b = []
    text='YES'
    for j in range(10):
        number = int(y[j])
        aNum = 0
        bNum = 0
        if a != [] :
            aNum = a[-1]
        if b != [] :
            bNum = b[-1]

        if(aNum > bNum):
            if(aNum < number):
                a.append(number)
            else:
                if(bNum < number):
                    b.append(number)
                else:
                    text = 'NO'
                    break
        else:
            if(bNum < number):
                b.append(number)
            else:
                if(aNum < number):
                    a.append(number)
                else:
                    text = 'NO'
                    break
#    print(a)
#    print(b)
    print(text)

Python: for n in range(int(input())):
  A = [int(i) for i in input().split()]
  B = [0]
  C = [0]
  for a in A:
    if a > B[-1] and a > C[-1]:
      if a - B[-1] <= a - C[-1]:
        B.append(a)
      else:
        C.append(a)
    elif a > B[-1] and a < C[-1]:
      B.append(a)
    elif a > C[-1]:
      C.append(a)
    else:
      print("NO")
      break
  if len(B) + len(C) == 12:
    print("YES")

Python: def dfs(i, b, c):
    if i == 10:
        return (b == sorted(b) and c == sorted(c))

    if dfs(i + 1, b + [balls[i - 1]], c):
        return True

    if dfs(i + 1, b, c + [balls[i - 1]]):
        return True

    return False


if __name__ == '__main__':
    N = int(input())
    for i in range(N):
        balls = list(map(int, input().split()))
        if dfs(1, [], []):
            print("YES")
        else:
            print("NO")

Python: n=int(input())
for i in range(n):
    a=list(map(int,input().split()))
    b,c=0,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: n = int(input())
a = [[0 for i in range(10)] for j in range(n)]

for i in range(n):
    a[i] = list(map(int, input().split()))
    
for i in range(n):
    l = 0
    r = 0
    f = 1
    for j in range(10):
        if l>=r and l<a[i][j]:
            l = a[i][j]
        elif r<a[i][j]:
            r = a[i][j]
        else:
            f = 0
            break
    if f == 1:
        print("YES")
    else:
        print("NO")

Python: from itertools import product
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
    *B, = map(int, readline().split())
    N = 10
    for p in product([0, 1], repeat = N):
        p1 = p2 = 0
        ok = 1
        for b, e in zip(B, p):
            if e:
                if not p1 < b:
                    break
                p1 = b
            else:
                if not p2 < b:
                    break
                p2 = b
        else:
            write("YES\n")
            break
    else:
        write("NO\n")
T = int(readline())
for i in range(T):
    solve()

Python: for i in range(int(input())):
    b = list(map(int, input().split()))
    for j in range(8):
        if b[j] >= b[j + 2]:
            print("NO")
            break
    else:
        print("YES")

Python: # -*- coding:utf-8 -*-

def dfs(datas, b, c, count):
    if len(data) == count: return 1
    p = int(data[count])
    if p > b:
        q = dfs(data, p, c, count+1)
        if q==1:return 1
    if p > c:
        q = dfs(data, b, p, count+1)
        if q==1:return 1
    return 0

def solve():
    b=0
    c=0
    count = 0
    q = dfs(data, b, c, count)
    if q==1:
        print("YES")
    elif q==0:
        print("NO")

counter = 0
line = input()
if not " " in line:
    nums = line
while True:
    line = input()
    data = line.split(" ")
    q = solve()
    counter += 1
    if int(nums) == counter:
        break

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