Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var num int
	fmt.Scan(&num)

	for i := 0; i < num; i++ {
		sc.Scan()
		line := sc.Text()

		insertCheck(line)
	}
}

func insertCheck(line string) {
	var B, C []int

	for _, v := range strings.Split(line, " ") {
		ball, _ := strconv.Atoi(v)
		switch {
		case len(B) == 0:
			B = append(B, ball)
		case B[len(B)-1] < ball:
			B = append(B, ball)
		case B[len(B)-1] >= ball:
			switch {
			case len(C) == 0:
				C = append(C, ball)
			case C[len(C)-1] < ball:
				C = append(C, ball)
			case C[len(C)-1] >= ball:
				fmt.Println("NO")
				return
			}
		}
	}
	fmt.Println("YES")
}

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;
}

C++: #include<iostream>
#include<cstring>
using namespace std;
int dfs(int b[10],int c[10],int m,int k,int t);//a中，b中，c中游标
int a[10];
int flag;
int main()
{
	int N;
	cin >> N;
	while (N--)
	{
		for (int i = 0; i < 10; i++)
			cin >> a[i];
		int b[10];
		int c[10];
		b[0] = 0;
		c[0] = 0;
		if (dfs(b, c, 0, 0, 0)== 1)
			cout << "YES" << endl;
		if (dfs(b, c, 0, 0, 0) == 0)
			cout << "NO" << endl;
	}
	return 0;
}
int dfs(int b[10], int c[10], int m, int k, int t)
{
	int ma = m;
	int kb = k;
	int tc = t;
	int i;
	int x[10], y[10];             //用x,y去中间值，好进行回溯
	if (ma == 10)
		return 1;
	for (i = 0; i <=kb; i++)
	{
		x[i] = b[i];	
	}
	for (i = 0; i <= tc; i++)
	{
        y[i] = c[i];
	}
	if (x[kb] > a[ma] && y[tc] > a[ma])
		return 0;
	if (x[kb] > a[ma] && y[tc] < a[ma])
	{
		y[tc] = a[ma];
		ma++; tc++;
		if (ma <=10)
			dfs(x, y, ma, kb, tc);
	}
	if (x[kb] < a[ma] && y[tc] > a[ma])
	{
		x[kb] = a[ma];
		ma++; kb++;
		if (ma <=10)
			dfs(x, y, ma, kb, tc);
	}
	if (x[kb] < a[ma] && y[tc] < a[ma])
	{
		x[kb] = a[ma];
		ma++; kb++;
		if (ma <=10)
			dfs(b, c, ma, kb, tc);
		 kb--;
		y[tc] = a[ma];
		 tc++;
		if (ma <=10)
			dfs(x, y, ma, kb, tc);
	}
}

C++: #include <iostream>

using namespace std;

int main(void){
    int a[11],fir,sec=0,i,n;
    cin>>n;
    while (1) {
    
    for (i=0; i<10; i++) {
        cin>>a[i];
    }
    fir=a[0];
    for (i=1; i<10; i++) {
        if(fir<a[i])fir=a[i];
        else if(sec<a[i])sec=a[i];
        else break;
    }
    if(i==10)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
        n--;
        if(n==0)break;
        
    }
    return 0;
}

C++: #include 	   <stdio.h>
#include <vector>  

using namespace std;			

void solve(vector<int> left, vector<int> right, vector<int> all, int n) {
	bool flag = true;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 10; j++) {
			if (left.size() > 0) {
				if (all[10 * i + j] > left[left.size() - 1]) {
					left.push_back(all[10 * i + j]);
				}
				else {
					if (right.size() > 0) {
						if (all[10 * i + j] > right[right.size() - 1])
							right.push_back(all[10 * i + j]);
						else
							flag = false;
					}
					else {
						right.push_back(all[10 * i + j]);
					}
				}
			}
			else {
				left.push_back(all[10 * i + j]);
			}
		}	 	
		if (flag)
			printf("YES\n");
		else
			printf("NO\n");
		flag = true;
	}
}

int main() {		
	vector<int> left;
	vector<int> right;
	vector<int> all;


	int n;
	scanf("%d", &n);
	if (n <= 0) return -1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 10; j++) {
			int temp;
			scanf("%d", &temp);
			all.push_back(temp);
		}
	}	  

	solve(left, right, all, n);

	return 0;
}

C++: #include<iostream>
#include<stack>

using namespace std;

int main(){
	stack<int> st1,st2;
	int ball[10];
	int n;
	cin >> n;
	for(int loop=0;loop<n;loop++){
		for(int i=0;i<10;i++){
			cin >> ball[i];
		}
		st1.push(ball[0]);
		for(int i=1;i<10;i++){
			if(st1.top() < ball[i]){
				st1.push(ball[i]);
			}else if(st2.empty()){
				st2.push(ball[i]);
			}else if(st2.top() < ball[i]){
				st2.push(ball[i]);
			}
		}

		if(st1.size()+st2.size() == 10){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
}

C++: #include <bits/stdc++.h>
using namespace std;

vector<vector<int> > arr;

void display(int n){
  for(int i = 0; i < n; i++){
    for(int j = 0; j < 10; j++){
      cout << arr[i][j] << " ";
    }
    cout << endl;
  }
  cout << endl;
}

bool dfs(int n, int i, int left, int right){
  if(i == 10) return true;

  bool ans = false;
  if(left < arr[n][i]) ans = dfs(n, i + 1, arr[n][i], right);
  if(right < arr[n][i]) ans = dfs(n, i + 1, left, arr[n][i]);

  return ans;
  
}

int main(){
  int n;
  cin >> n;
  arr.resize(n);
  for(int i = 0; i < n; i++){
    for(int j = 0; j < 10; j++){
      int tmp;
      cin >> tmp;
      arr[i].push_back(tmp);
    }
  }

  //display(n);

  for(int i = 0; i < n; i++){
	bool ans = dfs(i, 0, 0, 0);
	if(ans) cout << "YES" << endl;
	else cout << "NO" << endl;
  }
  
  
  return 0;
}

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


bool vis[15];
int a[15];

bool ok = false;


void dfs(int cnt, int last){
	if(ok){
		return;
	}
	if(cnt == 9){
		vector<int> ver;
		for (int i = 0; i < 10; i++){
			if(!vis[i]){
				ver.push_back(a[i]);
			}
		}
		bool flag = true;
		for (int i = 1; i < ver.size(); i++){
			if(ver[i] < ver[i - 1]){
				flag = false;
			}
		}
		if(flag){
			ok = true;
		}
		return;
	}
	for (int i = cnt; i < 10; i++){
		if(a[i] > last){
			vis[i] = true;
			dfs(i + 1, a[i]);
			vis[i] = false;
		}
	}
	return;
}
 





int main(){
	int n;
	cin >> n;
	while(n--){
		ok = false;
		memset(a, 0, sizeof(a));
		memset(vis, false, sizeof(vis));
		for (int i = 0; i < 10; i++){
			cin >> a[i];
		}
		
		dfs(0, 0);
		if(ok){
			cout << "YES" << endl;
		}else cout << "NO" << endl; 
		
		
		
	}
	return 0;
}