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 <string>
#include <vector>

using namespace std;

int main(int argc, char *argv[]) {
  int n, ball[10];
  vector<string> result;

  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++)
      cin >> ball[j];
    int j, a = 0, b = 0;
    for (j = 0; j < 10; j++) {
      if (ball[j] > a)
        a = ball[j];
      else if (ball[j] > b)
        b = ball[j];
      else
        break;
    }
    if (j == 10)
      result.push_back("YES");
    else
      result.push_back("NO");
  }

  for (int i = 0; i < n; i++)
    cout << result[i] << endl;
  return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main(){

  int n,i;
  cin >> n;
  for(i=0;i<n;i++){
    int j;
    int tmp;
    int han=0;
    vector<int>in1;
    vector<int>in2;
    int c1=0,c2=0;
    in1.push_back(0);
    in2.push_back(0);
    for(j=0;j<10;j++){
      cin >> tmp;
      if(in1[c1]<tmp){
	in1.push_back(tmp);
	c1++;
      }else{
	in2.push_back(tmp);
	c2++;

      }
    }
    
    
    
    for(j=1;j<c2;j++){
      if(in2[j-1]>in2[j])
	han=1;
    }

    if(han==0)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }


}

C++: #include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#define rep(i,a,b) for(int i = (a); i < (b); i++)
#define range(i,b) rep(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
	int a,b;
	int n;
	int input;
	bool check;

	while(cin >> n){
		range(i,n){
			a = b = 0;
			check = true;
			range(i,10){
				cin >> input;
				if(input > a && input > b){
					if(a > b)
						a = input;
					else
						b = input;
				}else if(input > a){
					a = input;
				}else if(input > b){
					b = input;
				}else{
					check = false;
				}
			}
			if(check) cout << "YES" << endl;
			else cout << "NO" << endl;
		}
	}
}

C++: #include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

bool search(int l, int r, int n)
{
  if (n == 10) {
    return true;
  }

  if (l < ball[n]) {
    if (search(ball[n], r, n + 1)) {return true;}
  } 
  if (r < ball[n]) {
    if (search(l, ball[n], n + 1)) {return true;}
  }
  return false;
}

vector<int> ball;
int main()
{
  int N;
  scanf("%d ", &N);
  
  for (int i = 0; i < N; i++) {
    ball.clear();
    ball.resize(10);
    for (int i = 0; i < 10; i++) {
      scanf("%d ", &ball[i]);
    }
    if (search(ball[0], 0, 1)) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}

C++: #include<iostream>
#include<string>
#include<cstring>
#include<cmath>
#include<vector>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<climits>
#include<algorithm>
#include<functional>
#include<iomanip>
#define LL long long
using namespace std;

int T,a[15];

int main(void){
    scanf("%d",&T);
    while(T--){
        int i;
        for(i=1;i<=10;i++) scanf("%d",&a[i]);
        bool can=true;
        int l=0,r=0;
        for(i=1;i<=10;i++){
            if(a[i]<l && a[i]<r){
                can=false;
                break;
            }
            if(l<r){
                if(a[i]>r) r=a[i];
                else l=a[i];
            }
            else{
                if(a[i]>l) l=a[i];
                else r=a[i];
            }
        }
        if(can) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}

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

int main(){
	int N;
	int A[11];
	int cnt1=0;
	cin>>N;
	while(1){
		
		if(cnt1==N){
			break;
		}
		cnt1++;
		for(int i=1;i<=10;i++){
			cin>>A[i];
		}
		int B=A[1];
		int Z[11];
		for(int i=1;i<=10;i++){
			Z[i]=0;
		}
		int C=0;
		int cnt2=0;
		int su=0;
		for(int i=2;i<=10;i++){
			if((B+1==A[i])/*||((su==1)&&(B<A[i]))*/){
				B=A[i];
				cnt2++;
				cout<<"1"<<A[i]<<endl;
			}
			else if((C+1==A[i])/*||((su==1)&&(B<A[i]))*/){
				C=A[i];
				cnt2++;
				Z[i]=C;
				su=0;
//cout<<"2"<<A[i]<<endl;
			}
			else if(B<A[i]){
				B=A[i];
				//Z[i]=C;
				//su=0;
				cnt2++;
//cout<<"3"<<A[i]<<endl;
			}
			else if(C<A[i]){
				C=A[i];
				Z[i]=C;
				su=0;
				cnt2++;
//cout<<"4"<<A[i]<<endl;
			}
			//CにB＋1がはいっていたらsu=1にすること
			for(int q=1;q<=10;q++){
				if(B+1==Z[q]){
					su=1;
				}
			}
			
		}
		if(cnt2==9){
			cout<<"YES"<<endl;
		}
		else{
			cout<<"NO"<<endl;
		}
	}
	return 0;	
}

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

using namespace std;

void solve() {
  int a = 0, b = 0, c;
  bool f = true;
  for (int i = 0; i < 10; ++i) {
    cin >> c;
    if (c < a) f = false;
    else if (c < b) a = c;
    else b = c;
  }
  cout << (f ? "YES" : "NO") << endl;
}

int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; ++i) solve();
}

C++: #include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <string>
#include <algorithm>
#include <climits>
#include <utility>

#define PRINT(STR) cout << STR << endl;
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define REG(i, a, b) for (int (i) = ((int)(a)); (i) < ((int)(b)); i++)
#define ALL(V) (V).begin(), (V).end()
#define SPACE " "

typedef long long ll;

using namespace std;

int nextInt() { int n = -1; cin >> n; return n; }
double nextDouble() { double d = -1; cin >> d; return d; }
ll nextll() { ll n = -1; cin >> n; return n; }
string nextString() { string str; cin >> str; return str; }

int INF = 1LL << 25;
double EPS = 1e-9;
int numofbits(int bits)
{
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

// BEGIN //////////////////////////////////////////////////////////////
int main() {
  int N = nextInt();
  REP(i, N) {
    stack<int> bs, cs;
    bool flag = true;
    bs.push(0);
    cs.push(0);
    REP(j, 10) {
      int a = nextInt();
      if (bs.top() < a) {
        bs.push(a);
      } else if (cs.top() < a) {
          cs.push(a);
      } else {
        flag = false;
        break;
      }
    }
    if (flag) {
      PRINT("YES");
    } else {
      PRINT("NO");
    }
  }
	return 0;
}
// END   //////////////////////////////////////////////////////////////

C++: #include<cstdio>
#include<algorithm>
#define MAXL 10
using namespace std;
int n;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int t,last1=0,last2=0;	//假?last1>last2
		bool flag=0;
		for(int j=1;j<=10;j++){
			scanf("%d",&t);
			if(last1<t)	last1=t;
			else
				if(last2<t)	last2=t;
				else flag=1;
			if(last1<last2)	swap(last1,last2);
		}
		if(flag==0)printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}