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<cstdio>
#include<cmath>
using namespace std;
int main(){
int l[10];
int v[2];
double m;
double pos;
int ans;
while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&l[0],&l[1],&l[2],&l[3],&l[4],&l[5],&l[6],&l[7],&l[8],&l[9],&v[0],&v[1])!=EOF){
m=0;
for(int i=0;i<10;i++){
m+=l[i];
}
pos=(m*v[0])/double(v[0]+v[1]);
for(int i=0;i<10;i++){
pos-=l[i];
if(!(pos>0)){
ans=i+1;
break;
}
}
cout<<ans<<endl;
}
return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<climits>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = j; i < k; i++)
#define P pair<int, int>
const int INF = INT_MAX / 2;
const int N = 10;

bool dfs(vector<int> a, vector<int> b, vector<int> vec, int now){
    if(now >= N) return true;
    else{
        bool ret = false;
        if(a.size() == 0 || vec[now] > a[a.size() - 1]){
            vector<int> tmp = a;
            tmp.push_back(vec[now]);
            ret = max(ret, dfs(tmp, b, vec, now + 1));
        }
        if(b.size() == 0 || vec[now] > b[b.size() - 1]){
            vector<int> tmp = b;
            tmp.push_back(vec[now]);
            ret = max(ret, dfs(a, tmp, vec, now + 1));
        }
        return ret;
    }
}


int main(){
    int n; cin >>n;
    REP(z, n){
        vector<int> vec(N); REP(i, N) cin >>vec[i];
        cout <<((dfs(vector<int>(), vector<int>(), vec, 0))? "YES" : "NO") <<endl;
    }
    return 0;
}

C++: #include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
int main(){
	int N;
	cin>>N;
	for(int i=0;i<N;i++){
		int a[9]={};
		int b[9]={};
		int dat[9],o=0,s=0,f;
		for(int k=0;k<10;k++){
			cin>>f;
			dat[k]=f;
		}
		for(int j=0;j<=10;j++){
			if(j==10){
				cout<<"YES"<<endl;
				break;
						}					if(s==0 || dat[j]>a[s-1]){
				a[s]=dat[j];
				s++;
			}
			else if(o==0 || dat[j]>b[o-1]){
				b[0]=dat[j];
				o++;}
			else{
				cout<<"NO"<<endl;
			break;
			}
					}
	}
	return 0;
}

C++: C++

#include <iostream> // C++?????\??????
#include <stdio.h> // C ?????\??????
#include <algorithm> // sort ???????????¢?????´?????????
#include <string.h> // C ??????????????¨
#include <ctype.h> // C ??????????¨???¨
#include <string> // C++????????????
#include <math.h>
#include <sstream>
using namespace std;
int ball[10];
bool dfs(int i,int b,int c);
int main(void){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        for(int s=0;s<10;s++){
            cin>>ball[s];
        }
        if(dfs(0,0,0))cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    return 0;
}
bool dfs(int i,int b,int c){
    if(i==10)return true;
    if(b<ball[i]){
        if(dfs(i+1,ball[i],c))return true;
    }
    if(c<ball[i]){
        if(dfs(i+1,b,ball[i]))return true;
    }
    return false;
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int n;
  while(cin>>n){
    bool ok=true;
    int a,b=0,c=0;
    rep(i,10){
      cin>>a;
      if(b>c){
	if(a>b)b=a;
	else if(a>c)c=a;
	else ok=false;
      }else{
	if(a>c)c=a;
	else if(a>b)b=a;
	else ok=false;
      }
    }
    if(ok)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <stack>
using namespace std;
int main(){
  stack<int>st[2];
  int n,f;
  cin >> n;
  while(n--){
    f = 1;
    st[0].push(0);st[1].push(0);
    int i;
    for(i = 0 ; i < 10 ; i++ ){
      int a;
      cin >> a;
      if(a-st[0].top() > 0 && st[0].top() > st[1].top()){
	st[0].push(a);
      } else if(a-st[1].top() > 0 ){
	st[1].push(a);
      } else {f=0;}
    }
    if(f)cout << "YES" << endl;
    else cout << "NO" << endl;
  }
}

C++: #include<iostream>
#include<algorithm>
int N;
int t[10000][10];
bool d[10000];
int a, b, c;
int main() {
	std::cin >> N;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 10; j++) {
			std::cin >> t[i][j];
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 10; j++) {
			if (t[i][j] > a) {
				a = t[i][j];
			}
			else if (t[i][j] > b) {
				b = t[i][j];
			}
			else {
				std::cout << "NO" << "\n";
				a = 0; b = 0;
				break;
			}
			if (j == 9) {
				std::cout << "YES" << "\n";
				a = 0; b = 0;
			}
		}
	}
	return 0;
}

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

using namespace std;

int main() {
	int N;
	cin >> N;
	
	for (int i = 0; i < N; i++) {
		int a[10];
		bool success = false;
		for (int j = 0; j < 10; j++) scanf("%d", &a[j]);
		int len = 1 << 10;
		for (int j = 0; j < len; j++) {
			vector<int> u;
			vector<int> v;
			for (int k = 0; k < 10; k++) {
				if (j >> k & 1) u.push_back(a[k]);
				else v.push_back(a[k]);
			}
			
			bool x = is_sorted(u.begin(), u.end());
			bool y = is_sorted(v.begin(), v.end());
			if (x && y) {
				printf("YES\n");
				success = true;
				break;
			}
		}
		
		if (!success) {
			printf("NO\n");
		}
	}
}

C++: 
#include<iostream>
using namespace std;
int table[10];

bool ok(int i,int left,int right){
	if(i>=9){
		return true;
	}
	if(left<table[i]){
		if(ok(i+1,table[i],right))return true;
		else return false;
	}
	
	if(right<table[i]){
		if(ok(i+1,left,table[i]))return true;
		else return false;
	}
	return false;
}
int main(){
	int n;
	cin>>n;
	for(int set=0;set<n;set++){
		for(int i=0;i<10;i++)cin>>table[i];
		if(ok(0,0,0))cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	
	}
	return 0;
}