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

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

using namespace std;

bool Solution()
{
    
    
    int left = 0;
    int right = 0;
    
    int a[10];
    
    for (int i = 0; i < 10; i++)
    {
        cin>>a[i];
    }
        
        for (int i = 0; i < 10; i++)
        {
            if (a[i] > left) // at the beginning, compare with first ball and the ball before first ball (empty)
            {
                left = a[i];
            }
            else if (a[i] > right)
            {
                right = a[i];
            }
            else                 //when can not enter to the both bottles to the end, then return false
            {
                return false;
            }
        }
    
    return true;
}

int main()
{
    int n;
    
    cin>>n;
    
    while(n--)
    {
        if (Solution())
        {
            cout<<"YES"<<endl;
        }
        else
        {
            cout<<"NO"<<endl;
        }
    }
    
    return 0;
}

C++: #include<cstdio>
using namespace std;
int main(){
	int t;
	scanf("%d", &t);
	while(t--){        
		int a, b = -1, c = -1;
		bool flag = true;
		for(int i = 1; i <= 10; i++){
			scanf("%d", &a);
			if(flag){
				if(a > b)   //????¬?????????????b??¶?????¢??? 
					b = a;
				else if(a > c)
					c = a;
				else
					flag = false;
			}
		}
		printf("%s\n", flag? "YES" :"NO");
	}
	return 0;
}

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


int main() {
  int n;
  int data[10];
  cin >> n;
  while ( n > 0 ) {
    n--;
    int flag = 1;
    for ( int i = 0; i < 10; i++ ) cin >> data[i];
    int b = 0,c = 0;
    for ( int i = 0; i < 10; i++ ) {
      if ( b < data[i] ) b = data[i];
      else if ( c < data[i] ) c = data[i];
      else flag = 0;
    }
    if ( flag ) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<stack>
using namespace std;

int main(){
	int n;
	cin >> n;
	while(n--){
		stack<int> B, C;
		B.push(0);
		C.push(0);
		int data[10];
		int tmp;
		int i;
		for(int i = 0; i < 10; i++){
			cin >> data[i];
		}
		for(i = 0; i < 10; i++){
			tmp = data[i];
			if(tmp > B.top() && tmp > C.top()){
				if(B.top() >= C.top()){
					B.push(tmp);
				}else{
					C.push(tmp);
				}
			}else if(tmp > B.top()){
				B.push(tmp);
			}else if(tmp > C.top()){
				C.push(tmp);
			}else{
				break;
			}
		}

		if(i == 10){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
}

C++: #include <cstdio>
#include <algorithm>
#define HEIGHT 10

using namespace std;

int a[HEIGHT];

void solve(){
	bool f=true;
	int right,left;
	right = left = 0;
	for(int i=0;i<HEIGHT;i++){
		if(right<a[i] && left<a[i]){
			if(right<left){
				left = a[i];
			} else {
				right = a[i];
			}
		} else if(right<a[i]){
			right = a[i];
		} else if(left<a[i]){
			left = a[i];
		} else {
			f = false;
			i = HEIGHT;
		}
	}
	if(f){
		printf("YES\n");
	} else {
		printf("NO\n");
	}
}
			
int main(){
	
	int lp;
	scanf("%d",&lp);
	
	for(int i=0;i<lp;i++){
		for(int j=0;j<HEIGHT;j++){
			scanf(" %d",&a[j]);
		}
		solve();	
	}
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

int a[10];

bool dfs(int i, int l, int r)
{
    if (i == 10) return true;

    if (l < a[i] && dfs(i + 1, a[i], r)) return true;
    if (r < a[i] && dfs(i + 1, r, a[i])) return true;

    return false;
}

int main()
{
    int n; cin >> n;

    while (n--) {
        l = r = 0;
        for (int i = 0; i < 10; ++i) cin >> a[i];
        cout << (dfs(0, 0, 0) ? "YES" : "NO") << endl;
    }
}

C++: #include <iostream>
#include <stack>
using namespace std;

int main(){
	int n, ball;cin >> n;
	stack<int> r, l;
	while(n--){
		r.push(0);l.push(0);
		bool f = false;
		for(int i = 0;i < 10;i++){
			cin >> ball;
			if(f == true)continue;
			if(r.top() < ball){
				r.push(ball);
			}else if(l.top() < ball){
				l.push(ball);
			}else{
				f = true;
			}
		}
		while(!r.empty())r.pop();
		while(!l.empty())l.pop();
		if(f == false)cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main(void) {
    int N, a, b, c;
    cin >> N;
    for (; N--; ) {
        b = c = 0;
        bool ok = true;
        for (int i = 0; i < 10; i++) {
            cin >> a;
            if (a < b && a < c) {
                ok = false;
                break;
            } else if (a < b) {
                c = a;
            } else if (a < c) {
                b = a;
            } else if (c < b) {
                c = a;
            } else {
                b = a;
            }
        }
        cout << (ok ? "YES" : "NO") << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <bitset>
#include <algorithm>
using namespace std;
 
///////////////////////////SubMain//////////////////////////////////
int main(int argc, char *argv[])
{
 
	int n;
	cin >> n;
	while (n--)
	{
		int ball[10];
		
		for (int i = 0; i < 10; ++i)
		{
			cin >> ball[i];
		}
 
		bitset<10> direction;
		int all = 1024;
		while (all-- > 0)
		{
			direction = static_cast<bitset<10> >(all);
			bool perfect = true;
			int left = 0;
			int right = 0;
			for (int i = 0; i < 10; ++i)
			{
				if (direction[i])
				{
					if (ball[i] > left)
					{
						left = ball[i];
					}
					else
					{
						perfect = false;
						break;
					}
				}
				else
				{
					if (ball[i] > right)
					{
						right = ball[i];
					}
					else
					{
						perfect = false;
						break;
					}
				}
			}
			if (perfect)
			{
				break;
			}
		}
	
		if (all >= 0)
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}
 
	return 0;
}

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

int main()
{
    int n;
    std::cin >> n;

    for (int i = 0; i < n; ++i) {
        int a[10];
        for (int j = 0; j < 10; ++j) std::cin >> a[j];

        std::stack<int> s1, s2;
        for (int j = 0; j < 10; ++j) {
            if (s1.empty()) s1.push(a[j]);
            else if (s1.top() < a[j]) s1.push(a[j]);
            else if (s2.empty()) s2.push(a[j]);
            else if (s2.top() < a[j]) s2.push(a[j]);
        }

        if (s1.size() + s2.size() == 10) std::cout << "YES" << std::endl;
        else std::cout << "NO" << std::endl;
    }
}

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

using namespace std;

int main(){
    int n;
    bool flag = true;
    vector<int> b, c;
    b.push_back(0);
    c.push_back(0);
    vector<int> ::iterator b_it=b.begin(), c_it=c.begin();

    cin>> n;
    while(n--, n!=-1){
        for(int i=0; i<10; i++){
            //if(flag){
                int num;
                cin>> num;
                if(num>*b_it){
                    b.push_back(num);
                    b_it = b.end()-1;
                }else if(num>*c_it){
                    c.push_back(num);
                    c_it = c.end()-1;
                }else{
                    flag = false;
                }
            //}
        }
        if(flag){
            cout<< "YES"<< endl;
        }else{
            cout<< "NO"<< endl;
        }
    }
    return 0;
}