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 solve():
    N = int(input())
    for _ in range(N):
        balls = list(map(int, input().split()))
        lefts, rights = [0], [0]
        for ball in balls:
            if lefts[-1] < ball:
                lefts.append(ball)
            elif rights[-1] < ball:
                rights.append(ball)
            else:
                print('NO')
                break
        else:
            print('YES')

if __name__ == "__main__":
    solve()

Python: N = int(input())

for testCase in range(N):
    A = list(map(int,input().split()))
    ok = False
    for i in range(2 ** 10):
        x = []
        y = []
        for j in range(10):
            if i & (1 << j):
                x.append(A [j])
            else:
                y.append(A [j])
        if x == sorted(x) and y == sorted(y):
            ok = True
    if ok:
        print('YES')
    else:
        print('NO')

Python: 
def solve(Balls,Left,Right,i):
	if i==len(Balls):#???????????¶
		return True

	#????????\????????´???
	if len(Left)==0 or Left[-1]<Balls[i]:
		Left.append(Balls[i])
		return solve(Balls,Left,Right,i+1)

	#????????\????????´???
	if len(Right)==0 or Right[-1]<Balls[i]:
		Right.append(Balls[i])
		return solve(Balls,Left,Right,i+1)
	
	return False#??\???????????????



if __name__ == "__main__":
	n=int(input())
	for i in range(n):
		Balls = [int(i) for i in input().split()]
		Left=[]
		Right=[]
		i=0
		if solve(Balls,Left,Right,0):
			print("YES")
		else:
			print("NO")

Python: num = int(input())
for _ in range(num):
    n = [int(i) for i in input().split()]
    b = 0
    able = 1
    for j in range(10):
        if j == 0:
            a = n[0]
        else:
            if n[j] < a:
                if n[j] < b:
                    print("NO")
                    able = 0
                    break
                else:
                    b = n[j]
            else:
                a = n[j]
    if able == 1:
        print("YES")

Python: n = input()
data = []
for i in range(n):
	tmp = map(int,raw_input().split())
	data.append(tmp)

Python: import sys
sys.setrecursionlimit(100000)

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