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: 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:
            print('NO')
            break
    if len(a)==0:
        print('YES')

Python: for _ in range(int(input())) :
    b, c = 0, 0
    for number, a in enumerate(input().split()) :
        a = int(a)
        if a < b and a < c :
            print('NO')
            break
        elif b < a and c <= b : b = a
        else : c = a
    if number == 9 : print('YES')

Python: #!/usr/bin/env python3
# -*- coding: utf-8 -*-

import collections


def judge(balls):
    left_balls = collections.deque([0])
    right_balls = collections.deque([0])
    while balls:
        ball = balls.popleft()
        if ball > left_balls[-1]:
            left_balls.append(ball)
        elif ball > right_balls[-1]:
            right_balls.append(ball)
        else:
            return "NO"
    return "YES"


def main():
    n = int(input())
    for x in range(n):
        balls = collections.deque(map(int, input().split()))
        print(judge(balls))


if __name__ == "__main__":
    main()

Python: n = int(input())
for i in range(n):
    str = input().split()
    arr = [int(str[j]) for j in range(len(str))]
    b,c = 0,0
    flag = True
    for i in range(len(arr)):
        if b < arr[i]:
            b = arr[i]
            continue
        if c < arr[i]:
            c = arr[i]
            continue
        print("NO")
        flag = False
        break
    if flag:
        print("YES")

Python: a=[]
n=int(input())
for i in range(10):
        a.append(-1)
while(n!=0):
    b=[]
    c=[]
    a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9]=map(int,input().split())
    for i in range(10):
        b.append(-1)
        c.append(-1)
    j=1
    k=0
    lenb=0
    lenc=0
    b[0]=a[0]
    for i in range(1,10):
        if(a[i]>b[j-1]):
            b[j]=a[i]
            j+=1
        else:
            if(k==0):
                c[0]=a[i]
                k+=1
            elif(a[i]>c[k-1]):
                c[k]=a[i]
                k+=1
    for i in range(10):
        if(b[i]!=-1):
            lenb+=1
        if(c[i]!=-1):
            lenc+=1
    if(len(a)==(lenb+lenc)):
        print("YES")
    else:
        print("NO")

Python: n = int(input())
for i in range(n):
    balls = list(map(int, input().split()))
    min_ball = balls[0]
    count = 0
    for ball in balls:
        if ball > min_ball:
            min_ball = ball
            count += 1
    if count > 1:
        print('YES')
    else:
        print('NO')

Python: for _ in range(int(input())):
    pipe = [0, 0]
    a = list(map(int, input().split()))
    for i in a:
        if i > max(pipe):
            pipe[pipe.index(max(pipe))] = i
        elif i > min(pipe):
            pipe[pipe.index(min(pipe))] = i
        else:
            print('NO')
            break
    else:
        print('YES')

Python: x=int(input())
for i in range(x):
	num=[int(i) for i in 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: for _ in range(int(input())):
    a = list(map(int, input().split()))
    t = 1
    for i in a:
        if i == t:
            t += 1
    for i in a:
        if i == t:
            t += 1
    if t == 11:
        print("YES")
    else:
        print("NO")

Python: import sys

def stackBall(ball):
	sB, sC = [0], [0]
	for b in ball:
		if max(sB[-1], sC[-1]) < b:
			if sB[-1] >= sC[-1]:
				sB.append(b)
			else:
				sC.append(b)
		elif min(sB[-1], sC[-1]) < b:
			if sB[-1] >= sC[-1]:
				sC.append(b)
			else:
				sB.append(b)
		else:
			return False
	return True


n = int(input())

for _ in range(n):
	ball = list(map(int, input().split()))
	if stackBall(ball):
		print("YES")
	else:
		print("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: n = int(input())

for i in range(n):
    l = list(map(int, input().split()))
    b, c, flag = 0, 0, 0
    for seq in l:
        if seq > b:
            b = seq
        elif seq > c:
            c = seq
        else:
            flag = 1
    if flag == 0:
        print("YES")
    else:
        print("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(int(0))
	for i in range(1,10):
		if b[0]<num[i]:
			b.append(num[i])
		elif c[0]<num[i]:
			c.append(num[i])
		else:
			flag=1
			break
	if flag==0:
		print("YES")
	else:
		print("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(int(0))
	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: def load_balls():
	LINE_NUM, TOTAL = 0, 0
	balls = []
	i = 0
	for line in sys.stdin:
		line = line.strip()
		LINE_NUM += 1
		if LINE_NUM == 1:
			TOTAL = int(line.strip())
			continue
		balls.append([int(i) for i in line.split(" ")])
		if LINE_NUM == TOTAL+1: break
	return balls

class VesselClass:

	def __init__(self):
		self.BALL_NUM = 10
		self.tmp = []
		self.left = [0]
		self.right = [0]

	def fill(self, balls:list):
		self.tmp = balls

	def DFS(self):
		if len(self.tmp) == 0: print("Yes")
		elif self.left[-1] < self.tmp[0]:
			self.left.append(self.tmp[0])
			self.tmp.pop(0)
			self.DFS()
		elif self.right[-1] < self.tmp[0]:
			self.right.append(self.tmp[0])
			self.tmp.pop(0)
			self.DFS()
		else: print("No")

balls_list = load_balls()
Vessel = VesselClass()
for balls in balls_list:
	Vessel.fill(balls)
	Vessel.DFS()

Python: 
if __name__ == '__main__':

	n = int(input())

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

		tmp1 = [0]
		tmp2 = [0]

		Flg = True
		for j in A:
			if tmp1[-1] < j:
				tmp1.append(j)
			else:
				if tmp2[-1] < j:
					tmp2.append(j)
				else:
					Flg = False
					break

		if Flg:
			print("YES")
		else:
			print("NO")

Python: for _ in[0]*int(input()):
 b=c=0
 for e in map(int,input().split()):
  if e>b:b=e
  elif e>c:c=e
  else:print('NO');break
 else:print('YES')

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