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: 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")

Python: def ball(nums):
    b, c = 0, 0
    for i in range(len(nums)):
        if b < nums[i]:
            b = nums[i]
            continue
        if c < nums[i]:
            c = nums[i]
            continue
        return "NO"
    return "YES"

N = int(input())

for _ in range(N):
    a = list(map(int, input().split()))
    print(ball(a))

Python: n = int(input())

for j in range(n):
    nums = list(map(int, input().split()))

    b = [0]
    c = []
    ans = "YES"

    for i in range(10):
        if nums[i] > b[-1]:
            b.append(nums[i])
        else:
            c.append(nums[i])

    if len(c) > 1:
        x = c[0]
        for i in range(1, len(c)):
            if x > c[i]:
                ans = "NO"
            else:
                x = c[i]
    print(ans)

Python: def check(a):
    b = [a[0]]
    c = [0]
    for i in range(1, len(a)):
        x = a[i]
        if x < b[-1] and x < c[-1]:
            return False
        elif b[-1] < x < c[-1]:
            b.append(x)
        elif c[-1] < x < b[-1]:
            c.append(x)
        elif b[-1] > c[-1]:
            b.append(x)
        else:
            c.append(x)
    return True

n = int(input())
for i in range(n):
    a = list(map(int, input().split()))
    print('YES' if check(a) else 'NO')

Python: n=int(input())
for i in range(n):
    ball=list(map(int,input().split()))
    b=0
    c=0
    flag=0
    for j in ball:
        if b>j and c>j:
            flag=1
            break
        elif b>j or j-c<j-b:
            c=j
        else:
            b=j
    print('YNEOS'[flag::2])

Python: import sys
sys.setrecursionlimit(10 ** 8)

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    n = Z()
    for _ in range(n):
        A = ZZ()
        done = [False] * 10

        def dfs(i, a):
            if done[i]:
                if i+1 < 10: dfs(i+1, a)
                else: return
            else:
                if a < A[i]:
                    done[i] = True
                    if i+1 < 10: dfs(i+1, A[i])
                else:
                    if i+1 < 10: dfs(i+1, a)

        cc = 0
        for i in range(10):
            if done[i]: continue
            cc += 1
            done[i] = True
            dfs(i, A[i])

        print('YES' if cc <= 2 else 'NO')


    return

if __name__ == '__main__':
    main()

Python: ans=0
def solve(n,left,right):
    if n==10:
        ans=1
    else:
        if a[n]>left:
            ans=solve(n+1,a[n],right)
        if a[n]>right:
            ans=solve(n+1,left,a[n])
    return ans

n=int(input())
for _ in range(n):
    a=[int(i) for i in input().split()]
    print("YES" if solve(0,0,0) else "NO")

Python: # AOJ 0033 Ball
# Python3 2018.6.16 bal4u

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: n = int(input())
for i in range(n):
    b = list()
    c = list()
    a =  list(map(int, input().split()))
    # print(a)
    b.append(a.pop(0))

    for _  in range(9):
        a0 = a.pop(0)
        if b[-1] < a0:
            b.append(a0)
        elif len(c)==0 or c[-1]<a0:
            c.append(a0)
        else:
            a.append(a0)
            print('NO')
            break
    if len(a)==0:
        print('YES')

Python: n=int(input())
for i in range(n):
    a=list(map(int,input().aplit()))
    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())
for i in range(n):
    data = [int(i) for i in input().split()]
    flag = False
    a = [0]
    b = [0]
    for ball in data:
        if ball > a[-1]:
            a.append(ball)
        elif ball > b[-1]:
            b.append(ball)
        else:
            flag = True
            break
    print("NO") if flag else print("YES")