Problem:
問題 3
入力ファイルの１行目に正整数 n （n≧3）が書いてあり，
つづく n 行に異なる正整数 a
1
, ..., a
n
が
１つずつ書いてある．
a
1
, ..., a
n
から異なる２個を選んで作られる
順列を（数として見て）小さい順に並べたとき，
３番目に来るものを出力せよ．
ただし，
例えば，a
1
= 1，a
4
= 11 のような場合も，
a
1
a
4
と a
4
a
1
は異なる順列とみなす．
また，
1≦a
i
≦10000 (i=1, ..., n) かつ 3≦n≦10
4
である．
出力ファイルにおいては，
出力の最後にも改行コードを入れること．
入出力例
入力例１
3
2
7
5
出力例１
52
入力例２
4
17
888
1
71
出力例２
171
問題文と自動審判に使われるデータは、
情報オリンピック日本委員会
が作成し公開している問題文と採点用テストデータです。

Submitted solutions:

code_snippet: #include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(A) A.begin(),A.end()

int main() {

    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    ll N;
    cin>>N;
    vector<ll> A(N);
    vector<int> B(4,2e9);
    rep(i,N)cin>>A[i];
    rep(i,N)rep(j,N)if(i!=j){
        int t=stoi(to_string(A[i])+to_string(A[j]));
        B[3]=t;
        for(int k=2;k>=0;k--)if(B[k]>B[k+1])swap(B[k],B[k+1]);   
        
    }
    cout<<B[2]<<endl;
}
accuracy: 1
time_ms: 7980
memory_kb: 3568
final_rank: 18

code_snippet: #include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
  #include "settings/debug.cpp"
#else
  #define Debug(...) void(0)
#endif
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<int> ans;
  rep(i, n) rep(j, n) {
    if (i == j) continue;
    ans.push_back(stoi(to_string(a[i]) + to_string(a[j])));
    sort(ans.begin(), ans.end());
    while (ans.size() > 3) ans.pop_back();
  }
  cout << ans[2] << endl;
  return 0;
}
accuracy: 1
time_ms: 2010
memory_kb: 3456
final_rank: 11

code_snippet: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int main(){
    int n, x;
    const int t = 4;
    cin >> n;
    string b[t];
    vector<int> a, c;

    for (int i = 0; i < n; i++){
        cin >> x;
        a.push_back(x);
        sort(a.begin(), a.end());
    }
    for (int j = 0; j < t; j++){
        b[j] = to_string(a[j]);
    }
    for (int j = 0; j < t; j++){
        for (int k = 0; k < t; k++){
            if (j != k) c.push_back(stoi(b[j]+b[k]));
        }
        sort(c.begin(), c.end());
    }
    cout << c[2] << endl;
    
}
accuracy: 1
time_ms: 690
memory_kb: 3508
final_rank: 6

code_snippet: #include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int func(int, int);

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

    int a[n];
    for (int &i: a) cin >> i;

    int ab, ba;
    pair<int, int> aa[3];
    aa[0].first = 1 << 29;
    aa[1].first = 1 << 29;
    aa[2].first = 1 << 29;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            ab = func(a[i], a[j]);
            ba = func(a[j], a[i]);
            sort(aa, aa + 3, greater<>());
            for (auto &k: aa) {
                if (ab < k.first) {
                    k.first = ab;
                    k.second = 1;
                    break;
                } else if (ab == k.first) {
                    k.second++;
                    break;
                }
            }
            sort(aa, aa + 3, greater<>());
            for (auto &k: aa) {
                if (ba < k.first) {
                    k.first = ba;
                    k.second = 1;
                    break;
                } else if (ba == k.first) {
                    k.second++;
                    break;
                }
            }
        }
    }

    sort(aa, aa + 3);

    int ans, k = 0;
    while (1) {
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < aa[i].second; j++) {
                ans = aa[i].first;
                k++;
                if (k == 3) goto outer;
            }
        }
    }
    outer:

    cout << ans << endl;
}

int func(int a, int b) {
    int ab, d;
    d = log10(b) + 1;
    if (d == 5) {
        ab = a * 100000 + b;
    } else if (d == 4) {
        ab = a * 10000 + b;
    } else if (d == 3) {
        ab = a * 1000 + b;
    } else if (d == 2) {
        ab = a * 100 + b;
    } else {
        ab = a * 10 + b;
    }
    return ab;
}
accuracy: 1
time_ms: 1390
memory_kb: 3684
final_rank: 9

code_snippet: #include "bits/stdc++.h"

#define REP(i,num) for(ll i=0;i<(num);++i)
#define FOR(i,c,num) for(ll (i)=(c);(i)<(num);++(i))
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){ T x; cin >> x; return (x); }
template<typename T=ll,typename C=vector<T>>
C vecin(int N){ C x(N);REP(i,N){ x[i]=in<T>(); }return x; }
template<typename T=ll,size_t N>
array<T,N> arrin(){array<T,N> x;REP(i,N){ x[i]=in<T>(); }return x;}

void vout(){ cout << endl; }
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){ cout << ' ' << h;vout(forward<Tail>(t)...); }
void out(){ cout << endl; }
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){ cout << h;vout(forward<Tail>(t)...); }

template<typename T>
bool chmax(T& a,T b){ if(a<b){ a=b;return true; }return false; }
template<typename T>
bool chmin(T& a,T b){ if(a>b){ a=b;return true; }return false; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	auto N=in();
	vector<string> A=vecin<string>(N);
	auto comp=[](string& l,string& r){return (l.size()==r.size())?l<r:l.size()<r.size();};
	priority_queue<string,vector<string>,decltype(comp)> Q(comp);

	ll C=0;
	REP(i,N){
		REP(j,N){
			if(i==j) continue;
			if(C<3){
				Q.push(A[i]+A[j]);
				C++;
			}
			else{
				auto V=Q.top();
				Q.pop();
				auto T=A[i]+A[j];
				if(comp(V,T)) Q.push(V);
				else Q.push(T);
			}
		}
	}
	out(Q.top());
	return 0;
}
accuracy: 1
time_ms: 3800
memory_kb: 3400
final_rank: 16

code_snippet: #include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define drep(i,j,n) for(int i=0;i<(int)(n-1);i++)for(int j=i+1;j<(int)(n);j++)
#define trep(i,j,k,n) for(int i=0;i<(int)(n-2);i++)for(int j=i+1;j<(int)(n-1);j++)for(int k=j+1;k<(int)(n);k++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yes(ans) if(ans)printf("yes\n");else printf("no\n")
#define Yes(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YES(ans) if(ans)printf("YES\n");else printf("NO\n")
#define popcount(v) __builtin_popcountll(v)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define vector3d(type,name,h,w,...) vector<vector<vector<type>>>name(h,vector<vector<type>>(w,vector<type>(__VA_ARGS__)))
#define vector4d(type,name,h,w,d,...) vector<vector<vector<vector<type>>>>name(h,vector<vector<vector<type>>>(w,vector<vector<type>>(d,vector<type>(__VA_ARGS__))))
using namespace std;
using ll = long long;
template<class T> using rpriority_queue = priority_queue<T, vector<T>, greater<T>>;
const int MOD=1000000007;
const int MOD2=998244353;
const int INF=1<<30;
const ll INF2=1LL<<60;
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T,class L>void scan(pair<T, L>& p){scan(p.first);scan(p.second);}
template<class T,class U,class V>void scan(tuple<T,U,V>& p){scan(get<0>(p));scan(get<1>(p));scan(get<2>(p));}
template<class T, size_t size> void scan(array<T, size>& a){ for(auto&& i : a) scan(i);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T,class L>void print(const pair<T, L>& p){print(p.first);putchar(' ');print(p.second);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll modinv(ll a, ll m) {ll b = m, u = 1, v = 0;while (b) {ll t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}
ll updivide(ll a,ll b){return (a+b-1)/b;}
int msb(ll v){return 63-__builtin_clzll(v);}
template<class T> void chmax(T &a,const T b){if(b>a)a=b;}
template<class T> void chmin(T &a,const T b){if(b<a)a=b;}

int main(){
    INT(n);
    vector<int> a(n),b,d={1,10,100,1000,10000,100000};
    in(a);
    sort(all(a));
    multiset<int> S;
    for(int i=0;i<n;i++){
        int mul=*upper_bound(all(d),a[i]);
        for(int j=0;j<n;j++){
            if(i==j)continue;
            S.insert(a[j]*mul+a[i]);
            if(S.size()>=4){
                S.erase(S.find(*S.rbegin()));
            }
        }
    }
    out(*S.rbegin());
}
accuracy: 1
time_ms: 1270
memory_kb: 3460
final_rank: 7

code_snippet: #include <bits/stdc++.h>
using namespace std;
const long long MOD1 = 1000000007;
const long long MOD2 = 998244353;
typedef long long ll;
typedef pair<long long, long long> P;
const long long INF = 1e18;
const ll MOD = INF;
template <typename T>
void input_arr(vector<T>& A, ll N) {
	for (ll i = 0; i < N; i++) {
		cin >> A[i];
	}
}
template <typename T, typename Q>
void input_arr(vector<pair<T, Q>>& A, ll N) {
	for (ll i = 0; i < N; i++) {
		cin >> A[i].first >> A[i].second;
	}
}
template <typename T>
void input_arr(vector<vector<T>>& A, ll H, ll W) {
	for (ll i = 0; i < H; i++) {
		for (ll j = 0; j < W; j++) {
			cin >> A[i][j];
		}
	}
}
ll gcd(ll a, ll b) {return (b == 0 ? a : gcd(b, a % b));}
int main() {
	ll N; cin >> N;
	vector<string>S(N); input_arr(S, N);
  	sort(S.begin(),S.end());
	vector<string>A;
	for (ll i = 0; i < N; i++) {
		for (ll j = 0; j < min(N, 500LL); j++) {
			if (i == j) continue;
			string T = S[i];
			for (char ch : S[j]) T.push_back(ch);
			A.push_back(T);
		}
	}
	sort(A.begin(), A.end(),[](string& a, string& b){
		return stoi(a) < stoi(b);
	});
	cout << A[2] << endl;
}
accuracy: 0.6
time_ms: 740
memory_kb: 19952
final_rank: 20

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

using namespace std;

int N;
vector<int> DataInfo;

void solve() {
	int aF, aR, num;
	stringstream ss;
	multiset<int> result;
	multiset<int>::iterator pos;

	for (int i = 0; i < 2; ++i) {
		aF = DataInfo[i];
		for (int j = i + 1; j < N; ++j) {
			aR = DataInfo[j];
			ss.clear();
			ss << aF << aR;
			ss >> num;
			//cout << "1:" << num << endl;
			result.insert(num);
			ss.clear();
			ss << aR << aF;
			ss >> num;
			//cout << "2:" << num << endl;
			result.insert(num);
		}
	}

	pos = result.begin();
	advance(pos, 2);
	cout << *pos << endl;
}

int main() {
	int num;

	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> num;
		DataInfo.push_back(num);
	}
	sort(DataInfo.begin(), DataInfo.end());
	solve();
	
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 4768
final_rank: 5

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

//    #include <boost/multiprecision/cpp_int.hpp>
 #define int long long
 #define inf  1000000007
 #define pa pair<int,int>
 #define ll long long
 #define pal pair<double,double>
 #define ppap pair<pa,int>
//  #define PI 3.14159265358979323846
  #define paa pair<int,char>
  #define  mp make_pair
  #define  pb push_back
  #define EPS (1e-10)
                                          
    int dx[8]={0,-1,0,1,1,1,-1,-1};
    int dy[8]={1,0,-1,0,-1,1,1,-1};
                                            using namespace std;
                                   			class pa3{
                                            	public:
                                            	int x,y,z;
                                            	pa3(int x=0,int y=0,int z=0):x(x),y(y),z(z) {}
                                            	bool operator < (const pa3 &p) const{
                                            		if(x!=p.x) return x<p.x;
                                            		if(y!=p.y) return y<p.y;
                                            		 return z<p.z;
                                            		//return x != p.x ? x<p.x: y<p.y;
                                            	}
                                   				bool operator > (const pa3 &p) const{
                                            		if(x!=p.x) return x>p.x;
                                            		if(y!=p.y) return y>p.y;
                                            		 return z>p.z;
                                            		//return x != p.x ? x<p.x: y<p.y;
                                            	}
                                            	bool operator == (const pa3 &p) const{
                                            		return x==p.x && y==p.y && z==p.z;
                                            	}
                                            		bool operator != (const pa3 &p) const{
                                            			return !( x==p.x && y==p.y && z==p.z);
                                            	}
                                            
                                            };
                                            
                                            class pa4{
                                            	public:
                                            	double x;
                                            	int y,z,w;
                                            	pa4(double x=0,int y=0,int z=0,int w=0):x(x),y(y),z(z),w(w) {}
                                            	bool operator < (const pa4 &p) const{
                                            		if(x!=p.x) return x<p.x;
                                            		if(y!=p.y) return y<p.y;
                                            		if(z!=p.z)return z<p.z;
                                            		return w<p.w;
                                            		//return x != p.x ? x<p.x: y<p.y;
                                            	}
                                            	bool operator > (const pa4 &p) const{
                                            		if(x!=p.x) return x>p.x;
                                            		if(y!=p.y) return y>p.y;
                                            		if(z!=p.z)return z>p.z;
                                            		return w>p.w;
                                            		//return x != p.x ? x<p.x: y<p.y;
                                            	}
                                            	bool operator == (const pa4 &p) const{
                                            		return x==p.x && y==p.y && z==p.z &&w==p.w;
                                            	}
                                            		
                                            
                                            };
                                            class pa2{
                                            	public:
                                            	int x,y;
                                            	pa2(int x=0,int y=0):x(x),y(y) {}
                                            	pa2 operator + (pa2 p) {return pa2(x+p.x,y+p.y);}
                                            	pa2 operator - (pa2 p) {return pa2(x-p.x,y-p.y);}
                                            	bool operator < (const pa2 &p) const{
                                            		return y != p.y ? y<p.y: x<p.x;
                                            	}
                                            	bool operator > (const pa2 &p) const{
                                            		return x != p.x ? x<p.x: y<p.y;
                                            	}
                                            	bool operator == (const pa2 &p) const{
                                            		return abs(x-p.x)==0 && abs(y-p.y)==0;
                                            	}
                                            	bool operator != (const pa2 &p) const{
                                            		return !(abs(x-p.x)==0 && abs(y-p.y)==0);
                                            	}
                                            		
                                            
                                            };
                                            
/*
                                            class Point{
                                            	public:
                                            	double x,y;
                                            	Point(double x=0,double y=0):x(x),y(y) {}
                                            	Point operator + (Point p) {return Point(x+p.x,y+p.y);}
                                            	Point operator - (Point p) {return Point(x-p.x,y-p.y);}
                                            	Point operator * (double a) {return Point(x*a,y*a);}
                                            	Point operator / (double a) {return Point(x/a,y/a);}
                                            	double absv() {return sqrt(norm());}
                                            	double norm() {return x*x+y*y;}
                                            	bool operator < (const Point &p) const{
                                            		return x != p.x ? x<p.x: y<p.y;
                                            	}
                                            	bool operator == (const Point &p) const{
                                            		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
                                            	}
                                            };
                                            typedef Point Vector;
                                     #define pl pair<int,pas>
                                            struct Segment{
                                            Point p1,p2;
                                            };
                                             double dot(Vector a,Vector b){
                                            	return a.x*b.x+a.y*b.y;
                                            }
                                            double cross(Vector a,Vector b){
                                            	return a.x*b.y-a.y*b.x;
                                            }
                                        
                bool parareru(Point a,Point b,Point c,Point d){
                //	if(abs(cross(a-b,d-c))<EPS)cout<<"dd "<<cross(a-b,d-c)<<endl;
                	return abs(cross(a-b,d-c))<EPS;
                }
                double distance_ls_p(Point a, Point b, Point c) {
                  if ( dot(b-a, c-a) < EPS ) return (c-a).absv();
                  if ( dot(a-b, c-b) < EPS ) return (c-b).absv();
                  return abs(cross(b-a, c-a)) / (b-a).absv();
                }
                bool is_intersected_ls(Segment a,Segment b) {
                	if(a.p1==b.p1||a.p2==b.p1||a.p1==b.p2||a.p2==b.p2) return false;
                	if(parareru((a.p2),(a.p1),(a.p1),(b.p2))&&parareru((a.p2),(a.p1),(a.p1),(b.p1))){
                //		cout<<"sss"<<endl;
                		if(dot(a.p1-b.p1,a.p1-b.p2)<EPS) return true;
                		if(dot(a.p2-b.p1,a.p2-b.p2)<EPS) return true;
                		if(dot(a.p1-b.p1,a.p2-b.p1)<EPS) return true;
                		if(dot(a.p1-b.p2,a.p2-b.p2)<EPS) return true;
                		return false;
                	}
                  else return ( cross(a.p2-a.p1, b.p1-a.p1) * cross(a.p2-a.p1, b.p2-a.p1) < EPS ) && ( cross(b.p2-b.p1, a.p1-b.p1) * cross(b.p2-b.p1, a.p2-b.p1) < EPS );
                }
                 
                double segment_dis(Segment a,Segment b){
                	if(is_intersected_ls(a,b))return 0;
                	double r=distance_ls_p(a.p1, a.p2, b.p1);
                	r=min(r,distance_ls_p(a.p1, a.p2, b.p2));
                	r=min(r,distance_ls_p(b.p1, b.p2, a.p2));
                	r=min(r,distance_ls_p(b.p1, b.p2, a.p1));
                	return r;
                }
                Point intersection_ls(Segment a, Segment b) {
                  Point ba = b.p2-b.p1;
                  double d1 = abs(cross(ba, a.p1-b.p1));
                  double d2 = abs(cross(ba, a.p2-b.p1));
                  double t = d1 / (d1 + d2);
                 
                  return a.p1 + (a.p2-a.p1) * t;
                }
 */                
                                string itos( int i ) {
                                ostringstream s ;
                                s << i ;
                                return s.str() ;
                                }
                                 
                                int gcd(int v,int b){
                                	if(v>b) return gcd(b,v);
                                	if(v==b) return b;
                                	if(b%v==0) return v;
                                	return gcd(v,b%v);
                                }
                 
                                double distans(double x1,double y1,double x2,double y2){
                                	double rr=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
                                	return sqrt(rr);
                                	
                                }
                                int mod;
                                
                int pr[500010];
                int inv[500010];
                
                int beki(int wa,int rr,int warukazu){
                	if(rr==0) return 1%warukazu;
                	if(rr==1) return wa%warukazu;
                	if(rr%2==1) return (beki(wa,rr-1,warukazu)*wa)%warukazu;
                	int zx=beki(wa,rr/2,warukazu);
                	return (zx*zx)%warukazu;
                }
    double bekid(double w,int r){
    	if(r==0) return 1.0;
    	if(r==1) return w;
    	if(r%2) return bekid(w,r-1)*w;
    	double f=bekid(w,r/2);
    	return f*f;
    }
                
    			int comb(int nn,int rr){
    				int r=pr[nn]*inv[rr];
    				r%=mod;
    				r*=inv[nn-rr];
    				r%=mod;
    				return r;
    			}
                
                void gya(int ert){
                	pr[0]=1;
                	for(int i=1;i<ert;i++){
                		pr[i]=(pr[i-1]*i)%mod;
                	}
                	for(int i=0;i<ert;i++) inv[i]=beki(pr[i],mod-2,mod);
                	
                }
                
              //   cin.tie(0);
    		//	ios::sync_with_stdio(false);
    			//priority_queue<pa3,vector<pa3>,greater<pa3>> pq;            
                 //sort(ve.begin(),ve.end(),greater<int>());
                                         //----------------kokomade tenpure------------
                //vector<double> ans(100000000),ans2(100000000)
      


int h(int a,int b){
	return stoi(itos(a)+itos(b));
}

  signed main(){
    	       cin.tie(0);
    			ios::sync_with_stdio(false);

int n;
  	cin>>n;
  	vector<int> ve(n);
  	for(int i=0;i<n;i++)cin>>ve[i];

  	sort(ve.begin(),ve.end());
  	
  	set<pa3> ans;
  	for(int i=0;i<n;i++)for(int j=0;j<3;j++)if(i!=j){
  		ans.insert((pa3){h(ve[i],ve[j]),i,j});
  				ans.insert((pa3){h(ve[j],ve[i]),j,i});
  
  	}
  	auto it=ans.begin();
  	it++;
  	it++;
  	cout<<(*it).x<<endl;
  	return 0;
    }
accuracy: 1
time_ms: 40
memory_kb: 6172
final_rank: 8

code_snippet: #include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> a(n), b;
	for (int& i : a) cin >> i;
	sort(a.begin(), a.end());
	if (1000 < a.size()) a.erase(1000 + a.begin(), a.end());
	for (int i = 0; i < a.size() - 1; ++i) {
		for (int j = 1 + i; j < a.size(); ++j) {
			b.push_back(stoi(to_string(a[i]) + to_string(a[j])));
			b.push_back(stoi(to_string(a[j]) + to_string(a[i])));
		}
	}
	sort(b.begin(), b.end());
	cout << b[2] << endl;
}
accuracy: 1
time_ms: 270
memory_kb: 7036
final_rank: 10

code_snippet: #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://onlinejudge.u-aizu.ac.jp/challenges/sources/JOI/Prelim?year=2006>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int n; cin >> n;
    vector<ll> a(n); for(auto& in:a) cin >> in;
    sort(a.begin(),a.end());
    
    vector<ll> ts;
    for(int i = 0; i < min(100,n);i++){
        for(int j = 0; j < n;j++){
            if(i==j)continue;
            string t = to_string(a[i]) + to_string(a[j]);
            ts.push_back(atoll(t.c_str()));
        }
    }
    sort(ts.begin(),ts.end());
    res = ts[2];
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}
accuracy: 1
time_ms: 200
memory_kb: 11300
final_rank: 17

code_snippet: #define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

int dig[11000];
int a[11000];

int main(){
    int n;
    cin >> n;
    int t[6] = {1, 10, 100, 1000, 10000, 100000};
    for(int i = 0; i < n; i++){
        cin >> a[i];
        for(int j = 0; j < 5; j++){
            if(a[i] >= t[j]){
                dig[i] = j;
            }
        }
    }
    long long int n1 = INF, n2 = INF, n3 = INF;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(i == j){
                continue;
            }
            long long int num = a[i] * t[dig[j] + 1] + a[j];
            if(num < n1){
                n3 = n2;
                n2 = n1;
                n1 = num;
            }else if(num < n2){
                n3 = n2;
                n2 = num;
            }else if(num < n3){
                n3 = num;
            }
        }
    }
    cout << n3 << endl;
    return 0;
}
accuracy: 1
time_ms: 80
memory_kb: 3156
final_rank: 1

code_snippet: #include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

int main()
{	
	const int INF = 1000010001;
	int n;
	int c[3] = { INF, INF, INF };

	cin >> n;

	vector<int> a(n);

	for (int i = 0; i < n; i++)
		cin >> a[i];

	sort(a.begin(), a.end());

	int u = 0;
	while (u < n && a[u] < a[2] * 10)
		u++;

	for (int i = 0; i < u; i++) {
		for (int j = 0; j < u; j++) {
			if (i != j) {
				int b = a[j], k = 0;

				while (b /= 10)
					k++;

				int w = a[i] * (int)pow(10, k + 1) + a[j];
				if (c[2] > w) {
					c[2] = w;
					sort(c, c + 3);
				}
			}
		}
	}

	cout << c[2] << endl;
	
	return 0;
}
accuracy: 1
time_ms: 3320
memory_kb: 3320
final_rank: 12

code_snippet: #include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

int main()
{	
	const int INF = 1000010001;
	int n;
	int c[3] = { INF, INF, INF };

	cin >> n;

	vector<int> a(n);

	for (int i = 0; i < n; i++)
		cin >> a[i];

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i != j) {
				int b = a[j], k = 0;

				while (b /= 10)
					k++;

				int w = a[i] * (int)pow(10, k + 1) + a[j];
				if (c[2] > w) {
					c[2] = w;
					sort(c, c + 3);
				}
			}
		}
	}

	cout << c[2] << endl;
	
	return 0;
}
accuracy: 1
time_ms: 3340
memory_kb: 3340
final_rank: 13

code_snippet: #include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define vii vector<int>
#define vll vector<long long>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

bool cmp(string a, string b) {
    return stoi(a) < stoi(b);
}

int n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n;
    vector<string> a(n), ans;
    rep(i, 0, n) cin >> a[i];
    sort(all(a), cmp);
    rep(i, 1, n) {
        ans.pb(a[0] + a[i]);
        ans.pb(a[i] + a[0]);
    }
    sort(all(ans), cmp);
    cout << ans[2] << endl;
    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 4360
final_rank: 4

code_snippet: #define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define INF         1e9
#define EPS         1e-9
#define REP(i,n)    for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(lint i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(lint i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define R_UP(a,b)   (((a)+(b)-1)/(b))
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP        cout << fixed << setprecision(8)
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }
int digits(int arg)
{
	int result = 0;
	while (arg != 0)
	{
		arg /= 10;
		result++;
	}
	return result;
}
signed main()
{
	int n = in();
	vector<int>nums(n); REP(i, n)cin >> nums[i];
	int mines[3] = { 1000010001,1000010001,1000010001 };
	REP(i, n)
	{
		REP(j, n)
		{
			if (i == j)continue;
			int temp_i = nums[i];
			REP(i, digits(nums[j]))temp_i *= 10;
			int result = temp_i + nums[j];
			if (result < mines[0])
			{
				mines[2] = mines[1];
				mines[1] = mines[0];
				mines[0] = result;
			}
			else if (result < mines[1])
			{
				mines[2] = mines[1];
				mines[1] = result;
			}
			else if (result < mines[2])
			{
				mines[2] = result;
			}
		}
	}
	cout << mines[2] << endl;
}
accuracy: 1
time_ms: 330
memory_kb: 3148
final_rank: 3

code_snippet: #include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
string s[10000];
main()
{
    int a=1e9,b=1e9,c=1e9;
    cin>>n;
    for(int i=0;i<n;i++)cin>>s[i];
    for(int i=0;i<n;i++)for(int j=0;j<n;j++)
    {
        if(i==j)continue;
        int n=stoi(s[i]+s[j]);
        if(a>n)
        {
            c=b;b=a;a=n;
        }
        else if(b>n)
        {
            c=b;b=n;
        }
        else if(c>n)
        {
            c=n;
        }
    }
    cout<<c<<endl;
}
accuracy: 1
time_ms: 3680
memory_kb: 3624
final_rank: 15

code_snippet: #include <iostream>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	int n, m;
	cin >> n;
	vector<string> s(n);
	int nP2 = n * (n - 1);
	vector<int> a(3, 1000010001);
	for (int i = 0; i < n; i++)
	{
		cin >> s[i];
	}
	int k = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if (i == j) continue;
			m = atoi((s[i] + s[j]).c_str());
			if (a[2] > m)
			{
				a[2] = m;
				sort(a.begin(), a.end());
			}
		}
	}
	cout << a[2] << endl;
	return 0;
}
accuracy: 1
time_ms: 3490
memory_kb: 3456
final_rank: 14

code_snippet: #include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>

using namespace std;

int main(){
	int n,dum,temp;
	vector<int> a;
	vector<int> dig;
	//vector<int> ans;
	int ans[3]={100000000,100000000,100000000};
	
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&dum);
		a.push_back(dum);
		temp=0;
		while(dum!=0){
			dum=dum/10;
			temp++;
		}
		dig.push_back(temp);
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(i!=j){
				temp=1;
				for(int k=0;k<dig[j];k++){
					temp*=10;
				}
				dum=a[i]*temp+a[j];
				if(ans[0]>=dum){
					ans[2]=ans[1];
					ans[1]=ans[0];
					ans[0]=dum;
				}
				else if(ans[1]>=dum){
					ans[2]=ans[1];
					ans[1]=dum;
				}
				else if(ans[2]>=dum){
					ans[2]=dum;
				}
			}
		}
	}
	printf("%d\n",ans[2]);
}
accuracy: 1
time_ms: 170
memory_kb: 3348
final_rank: 2

code_snippet: #include <iostream>
#include <algorithm>
using namespace std;
const int inf=1000000000;

int main() {
  std::ios::sync_with_stdio(false);
  cout.tie(0); cin.tie(0);
  int n; cin>>n;
  string a[n]; for (int i=0; i<n; i++) cin>>a[i];
  int permutation_a[n*n];
  for (int i=0; i<n*n; i++) permutation_a[i]=inf;
  int index=0;
  for (int i=0; i<n; i++) {
    for (int j=0; j<n; j++) {
      if (i==j) continue;
      permutation_a[index]=atoi((a[i]+a[j]).c_str());
      index++;
    }
  }
  sort(permutation_a,permutation_a+index);
  cout<<permutation_a[2]<<endl;
  return 0;
}
accuracy: 0.8
time_ms: 100
memory_kb: 7104
final_rank: 19