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):
    tmp =  [int(x) for x in input().split()]
    B = 0
    C = 0
    flg = 0
    for i in tmp:
        if B >= C:
            if B < i :
                B = i
                continue
            else:
                if C < i :
                    C = i
                    continue
                else:
                    flg = 1
                    break

        else:
            if C < i :
                C = i
                continue
            else:
                if B < i :
                    C = i
                    continue
                else:
                    flg = 1
                    break
    if flg != 1:
        print("YES")
    else:
        print("NO")

Python: x=int(input())
for j in range(x):
	num=list(map(int,input().split()))
	b,c=0,0
	flag=0
	for i in num:
		if b<i:
			b=i
		elif c<i:
			c=i
		else:
			print("No")
			flag=1
			break
	if flag==0:
		print("YES")

Python: #数列に対しy/nの判定をする
def solve(balls):

  #B, Cの一番上の数(ただし常にB <= Cを保つ)
  last_b = last_c = 0

  while balls:
    new = balls.pop(0)
    
    #new <= last_b <= last_c  --> 不可能
    if new <= last_b:
      print("NO")
      break
    
    #last_b < new <= last_c   --> Bを更新
    elif new <= last_c:
      last_b = new
    
    #last_b < last_c < new    --> Cを更新
    else:
      last_c = new
  
  else:
    print("YES")

      


while True:
  try:
    n = int(input())

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

  except EOFError:
    break

Python: import sys

def stackBall(stackB, stackC, ball):
	if len(ball) == 0:
		return True
	if len(stackB) == 0 or stackB[-1] < ball[0]:
		stackB.append(ball.pop(0))
		if stackBall(stackB, stackC, ball):
			return True
	if len(stackC) == 0 or stackC[-1] < ball[0]:
		stackC.append(ball.pop(0))
		if stackBall(stackB, stackC, ball):
			return True
	return False

n = input()

for _ in range(n):
	ball = list(map(int, input().split()))
	if stackBall([], [], ball):
		print("YES")
	else:
		print("NO")

Python: import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
import copy
from test.support import _MemoryWatchdog

BIG_NUM = 2000000000
HUGE_NUM = 99999999999999999
MOD = 1000000007
EPS = 0.000000001
sys.setrecursionlimit(100000)


NUM = 10
POW = [1]*(NUM+1)
for i in range(1,NUM+1):
    POW[i] = POW[i-1]*2


N = int(input())

for _ in range(N):

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

    FLG = False

    for state in range(POW[NUM]):
        A = []
        B = []

        for i in range(NUM):
            if state & POW[i] != 0:
                A.append(table[i])
            else:
                B.append(table[i])

        tmpFLG = True
        for i in range(len(A)-1):
            if A[i] >= A[i+1]:
                tmpFLG = False
                break

        if tmpFLG == False:
            continue

        for i in range(len(B)-1):
            if B[i] >= B[i+1]:
                tmpFLG = False
                break

        if tmpFLG == True:
            FLG = True
            break


    if FLG == True:
        print("YES")
    else:
        print("NO")

Python: N = int(input())
for _ in range(N):
	balls = list(map(int, input().split()))
	left = right = 0
	ans = "YES"
	for i in range(10):
		if min(left, right) > balls[i]:
			ans = "NO"
			break
		if left < right:
			if right < balls[i]:
				right = balls[i]
			else:
				left = balls[i]
		else:
			if left < balls[i]:
				left = balls[i]
			else:
				right = balls[i]
	print(ans)

Python: for i in range(int(input())):
	a=b=c=0
	for n in map(int,input().split()):
		if n>b: n=b
		elif n>c: n=c
		else: a=1
	print(['YES','N'][a])

Python: def solve(A):
	B=[]
	C=[]
	#print(A)
	#??????
	B.append(A[0])
	C.append(0)#?????§??????
	for i in range(1,9):
		if B[-1]<A[i] and C[-1]>A[i]:
			B.append(A[i])
			#print("B",B)
			#print("C",C)
		elif B[-1]>A[i] and C[-1]<A[i]:
			C.append(A[i])
			#print("B",B)
			#print("C",C)
		elif B[-1]<A[i] and C[-1]<A[i]:
			for j in range(i+1,len(A)):
				if A[j]<A[i]:
					if B[-1]<C[-1]:
						C.append(A[i])
						#print("B",B)
						#print("C",C)
						break
					else:
						B.append(A[i])
						#print("B",B)
						#print("C",C)
						break
			else:
				B.append(A[i])
				#print("B",B)
				#print("C",C)
		else:
			break
	del C[0]
	#print("B is ",B)
	#print("C is ",C)
	if B[-1]<A[-1] or C[-1]<A[-1]:
		if len(B)+len(C)==len(A)-1:
			print("YES")
		else:
			print("NO")
	else:
		print("NO")










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

Python: n = int(input())
for i in range(n):
    left = right = []
    arr = map(int, input().split())
    for a in arr:
        if len(left) == 0 or left[-1] < a:
            left.append(a)
        elif len(right) == 0 or right[-1] < a:
            right.append(a)
        else:
            break
    if len(left) + len(right) == 10:
        print("YES")
    else:
        print("NO")

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

Python: n = int(input())
for i in range(n):
    l = list(map(int, input().split()))
    k , c= l[0], 0
    for j in l:
        if j < k:
            c += 1
        else:
            c = 0
    if 2 <= c:
        print("NO")
    else:
        print("YES")

Python: def f(x):
    a,b=0,0
    for e in x:
        if e>a: a=e
        elif e>b: b=e
        else: return 0
    return 1

n=input()
for i in range(n):
    D = map(int, raw_input().split())
    print ["NO","YES"][f(D)]

Python: n = int(input())
for i in range(n):
    balls = list(map(int, input().split()))
    b, c = 0, 0 
    flag = 0
    for ball in balls:
        if b == 0:
            b = ball
        elif b < ball:
            b = ball
        elif c > ball:
            flag = 1
            break
        else:
            c = ball
    if flag == 0:
        print('YES')
    else:
        print("NO")

Python: x=int(input())
for j in range(x):
	num=list(map(int,input().split()))
	b,c=0,0
	flag=0
	for i in num:
		if b<i:
			b=i
		elif c<i:
			c=i
		else:
			print("No")
			flag=1
			break
	if flag==0:
		print("YES")

Python: N = int(input())
for n in range(N):
	str = input().split()
	list = []
	for i in str:
		list.append(int(i))
	b = c = []
	ans = True

	for a in list:
		bLen = len(b)
		cLen = len(c)
		bLast = bLen - 1 if bLen > 0 else 0
		cLast = cLen - 1 if cLen > 0 else 0
		if bLast == 0:
			b.append(a)
			continue
		if b[bLast] > a:
			if cLast == 0 or c[cLast] < a:
				c.append(a)
				continue
			else:
				ans = False
				break
		
	print('YES' if ans is True else 'NO')