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: BALL_NUM = 10


def main():
    n = int(input())
    while n > 0:
        balls = list(map(int, input().split()))
        if dfs(balls, 0, 0):
            print("YES")
        else:
            print("NO")

        n -= 1


def dfs(balls, b, c):
    if len(balls) == 1:
        if balls[0] > b or balls[0] > c:
            return True
        else:
            return False

    # ????????????b?????\????????´???
    if balls[0] > b and dfs(balls[1:], balls[0], c):
        return True
    # ????????????c?????\????????´???
    if balls[0] > c and dfs(balls[1:], b, balls[0]):
        return True

    return False


if __name__ == '__main__':
    main()

Python: def main():
    n = int(input())
    for i in range(n):
        Ball = map(int,input().split())
        l = r = 0
        for value in Ball:
            if value > r:
                r = value
            elif value > l:
                l = value
            else:
                print("NO")
                r = -777
                break
            if r < l:
                r,l = l,r
            
        if r == -777:
            continue
        else:
            print("Yes")

if __name__ == '__main__':
    main()

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):
            print(j)
            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: N = input()
for x in range(int(N)):
    B = map(int, input().split())
    a = b = 0
    for y in B:
        if y > a:
            a = y
        elif y > b:
            b = y
        else:
            print('NO')
            a = -1
            break
        if a < b:
            a, b = b, a
    if a == -1:
        continue
    else:
        print('YES')

Python: N = int(input())
for _ in range(N):
    balls = list(map(int, input().split()))
    B, C = [0], [0]
    ans = 1
    for i in range(10):
        b = balls[i]
        if b > B[-1]:
            B.append(b)
        else:
            if b > C[-1]:
                C.append(b)
            else:
                ans = 0
                break
    print("YES" if ans else "NO")

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

    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, [0], [0]):
            print("YES")
        else:
            print("NO")

Python: n = int(input())
for i in range(n):
    B = 0
    C = 0
    A = [int(i) for i in input().split()]
    ans = 'YES'
    for v in A:
        if B > v and C > v:
            ans = 'NO'
            break
        elif B < v and C < v:
            if B > C:
                B = v
            else:
                C = v
        elif B < v:
            B = v
        else:
            C = v
    print(ans)

Python: n = int(input())
for _ in range(n):
    data = list(map(int, input().split()))
    B, C = 0, 0
    flag = True
    for d in data:
        if B < d:
            B = d
        elif C < d:
            C = d
        else:
            print("NO")
            flag = False
            break
    if flag:
        print("YES")

Python: def bl(l):
    b=[]
    c=[]
    for (i,j) in enumerate(l):
        if(i==0):b.extend([j])
        elif(j>b[-1]):b.extend([j])
        elif(c and j>c[-1] and j<b[-1]):c.extend([j])
        elif(not c):c.extend([j])
        else:return 0
    return 1

l=[list(map(int,input().split())) for i in range(int(input()))]
[print("YES") if bl(i) else print("NO") for i in l]

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

import sys
sys.setrecursionlimit(10**6)

def dfs(balls,B=-1,C=-1,cp=0):
	if cp==len(balls): 	return True
	ball = balls[cp]
	if B<ball:
		is_find = dfs(balls,ball,C,cp+1)
		if is_find: return True
	if C<ball:
		is_find = dfs(balls,B,ball,cp+1)
		if is_find: return True
	return False

def main():
	N = int(input().strip())
	for _ in range(N):
		balls = list(map(int,input().split(' ')))
		is_find = dfs(balls)
		if is_find:		print('YES')
		else:			print('NO')

if __name__=='__main__':
	main()

"""
2
3 1 4 2 5 6 7 8 9 10
10 9 8 7 6 5 4 3 2 1
"""

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

Python: def judge(data):
    num = list(map(int,data.split()))
    a,b = 0,0
    for i in range(10):
        if a <= num[i]:
            a = num[i]
        elif b <= num[i]:
            b = num[i]
        else:
            print('NO')
            return 0
    print('YES')
    return 0
            
n = int(input())
array = [0]*n
for i in range(n):
    array[i] = input()

for i in range(n):
    judge(array[i])

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
            k = j
    if 2 <= c:
        print("NO")
    else:
        print("YES")

C++: #include<iostream>
#include<cstdio>
#include<string>
#include<vector>
using namespace std;


int res=0;

int saiki(int ball[],int ttB,int ttC,int res){
	if(res==10)return res;
	if(ball[res]>ttB){
		return saiki(ball,ball[res],ttC,res+1);
	}
	if(ball[res]>ttC){
		return saiki(ball,ttB,ball[res],res+1);
	}
	return res;
}

int main(void){
	int a,b;
	int ball[11];
	int ttB=0,ttC=0;
	int n;
	scanf("%d",&n);
	for(a=0;a<n;a++){
		for(b=0;b<10;b++){
			ball[b]=0;
		}
		ttB=0;
		ttC=0;
		res=0;
		for(b=0;b<10;b++){
			scanf("%d",&ball[b]);
		}
		res=max(res,saiki(ball,ttB,ttC,res));
		if(res==10)printf("Yes\n");else printf("No\n");
	}
	return 0;
}