akhauriyash/Code-Regression huggingface dataset:
#define LOCAL
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos((ld)-1.0))
#define MAXN (300006)
#define ll long long int 
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < (ll)ee; ++ii)
#define space " "
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph push
#define btinpct(x) __builtin_popcountll((x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
string to_string(char c) {string s(1,c);return s;}string to_string(bool b){return (b ? "true" : "false");}template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A>string to_string(A v) {bool first = true;string res = "{";for (const auto &x : v) {if (!first) {res += ", ";}first = false;res += to_string(x);}res += "}";return res;}void degug_out() { cerr << endl; }template <typename Head, typename... Tail>void degug_out(Head H, Tail... T) {cerr << " " << to_string(H);degug_out(T...);}inline ll gcd(ll a,ll b){if(a>b)swap(a,b);if(a==0)return b;return gcd(b%a,a);}
#ifdef LOCAL
#define degug(...) cerr << "[" << #__VA_ARGS__ << "]:", degug_out(__VA_ARGS__)
#else
#define degug(...) 42
#define cerr if(0)cout
#endif
ll n; string A; ll dp[MAXN]; set<ll> co[27];
void init(ll pos) {
	FOR(i,0,26){
		while(co[i].size()&&*co[i].begin()<pos) co[i].erase(co[i].begin());
	}return;
}
string ans="";
int main()
{
	FAST
	cin>>A;n=A.size();FOR(i,0,26)co[i].ins(n+1);
	dp[n]=1;for(ll i=n-1;i>=0;--i){
		co[A[i]-'a'].ins(i);dp[i]=INF;
		FOR(j,0,26)dp[i]=min(dp[i],dp[*co[j].begin()+1]+1);
		//~ if(i==0)FOR(j,0,26)cerr<<dp[*co[j].begin()+1]<<' ';
	} FOR(j,0,26)if(*co[j].begin()==n+1){cout<<(char)('a'+j)<<'\n';return 0;}
	ll mi_len=INF;
	ll pos=-1;
	FOR(j,0,26) mi_len=min(mi_len,1+dp[*co[j].begin()+1]); 
	FOR(j,0,26) if(1+dp[*co[j].begin()+1]==mi_len) { pos=(*co[j].begin())+1; ans+=(char)('a'+j); break; }
	assert(~pos); ll tmp=mi_len-1;
	init(pos);
	while(pos<n){
		ll hmm=-1;
		FOR(j,0,26)if(tmp==dp[*co[j].begin()+1]+1){hmm=j;ans+=(char)('a'+j);break;}
		assert(~hmm); --tmp;
		pos=*co[hmm].begin()+1;
		init(pos);
	}
	cout<<ans<<'\n';assert(ans.size()==mi_len);
}


Measured memory_bytes: 11412
n = int(input())
link = [[] for _ in range(n)]
for i in range(n-1):
    a,b = list(map(int,input().split()))
    link[a-1].append(b-1)
    link[b-1].append(a-1)
c=list(map(int, input().split()))
c.sort(reverse=True)
print(sum(c)-c[0])

from collections import deque
Q = deque()
Q.append(0)
visited=[-1]*n
visited[0]=0

ind=1
while Q:
    now = Q.popleft()
    for nxt in link[now]:
        if visited[nxt]!=-1:
            continue
        visited[nxt]=ind
        ind+=1
        Q.append(nxt)
for i in visited:
    print(c[i],end=" ")

Measured memory_bytes: 51672
#include <iostream>
#include <algorithm>
#include <string>

int main() {

    int n; std::cin >> n;
    int sum = 0;
    for (int i = 0; i < n; i++) {
        int num; std::cin >> num;
        sum += num - 1;
    }
    std::cout << sum << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main (){

  int n,d[1000];
  
  double a[6],b,c;
  
  cin >>n;

  for(int j=0 ; j < n ; j++){
    
    for(int i=0 ; i < 6 ; i++){
      cin >> a[i];
    }
    
    c=(a[0]-a[3])*(a[0]-a[3])+(a[1]-a[4])*(a[1]-a[4]);
    b=sqrt(c);
    
    
    if( a[2]-b > a[5]){
      d[j]=2;
    }else if( a[5]-b > a[2] ){
      d[j]=-2;
    }else if( b > a[2]+a[5]){
      d[j]=0;
    }else{
      d[j]=1;
    }
    
  }

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

Measured memory_bytes: 1232
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

string s, t;

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	cin >> s;
	for (int i = 0; i < s.length(); t.pb(s[i ++]))
		if ((s[i] == 'K' || s[i] == 'B' || s[i] == 'R') && (!i || s[i - 1] != 'A'))
			t.pb('A');
	if (t.back() != 'A')
		t.pb('A');
	return puts(t == "AKIHABARA" ? "YES" : "NO"), 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int r,b,g;
multiset<string> st;
int main() 
{
//	freopen("beargguy.in","r",stdin);
//	freopen("beargguy.out","w",stdout);
	scanf("%d%d%d",&r,&b,&g);   
    for(int i=1;i<=r;i++) st.insert("a");
    for(int i=1;i<=b;i++) st.insert("b");
    for(int i=1;i<=g;i++) st.insert("c");
    while(st.size()>1) 
	{
        string s=*st.begin(),t=*st.rbegin();
        st.erase(st.lower_bound(s));
        st.erase(st.lower_bound(t));
        st.insert(s+t);
    }
    puts((*st.begin()).c_str());
    return 0;
} 

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    internal class QuestionB
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            long n = long.Parse(Console.ReadLine());

            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => Decimal.Parse(i)).ToArray();

            if (inputLongArray.Where(v => v == 0).Count() > 0) {
                Console.WriteLine("0");
                Console.Out.Flush();

                return;
            }

            try {
                var resultLong = inputLongArray.Aggregate((a, b) => a * b);

                if ((resultLong - 1).ToString().Length >= 19) {
                    printMinusOne();

                    return;
                }

                string result = resultLong.ToString();
                Console.WriteLine(result);
                Console.Out.Flush();
            } catch {
                printMinusOne();
                return;
            }
        }

        private static void printMinusOne()
        {
            string result = "-1";

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 43560
#include <bits/stdc++.h>
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  
  if (a * b % 2 == 1) {
    cout << " Odd" << endl;
  }
  else if (a * b % 2 == 0) {
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <queue>
#include <set>
#include <cassert>
using namespace std;
using ll = long long;
using plong = pair<ll,ll>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    ll N,K;
    cin>>N>>K;
    for(ll i=0;;i++){
        if(pow(K,i)>N){
            cout<<i<<endl;
            break;
        }
    }

}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int n,i;
	
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		if(i%3==0)printf(" %d",i);
		else
		{
			int s=i;
			while(s)
			{
				if(s%10==3)
				{
					printf(" %d",i);
					break;
				}
				s/=10;
			}
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 596
#include <stdio.h>

int main(void)
{
  int N, i, con = 0;
  scanf("%d", &N);
  //100000
  for(i = 1; i <= N; i ++){
    if(i < 100000){
      if(i < 10000){
        if(i < 1000){
          if(i < 100){
            if(i < 10){
              con ++;
            }
            else{}
          }
          else{con ++;}
        }
        else{}
      }
      else{con ++;}
    }
    else{}
  }

  printf("%d\n", con);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;

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

  string kind = "Three";
  for(int i = 0; i<N; i++){
    
      string color;
      cin >> color;
    
      if( color == "Y" ){
          kind = "Four";
          break;
      }

  }

  cout << kind << endl;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int main(){
  int n,k,a[200010]={},v=0,c=0,m=0,d[200010]={};
  cin>>n>>k;
  fr(i,n) cin>>a[i];
  sort(a,a+n);
  v=a[0],c=1;
  Fr(i,n-1){
    if(v!=a[i]){
      v=a[i];d[m++]=c;c=1;
    }
    else{
      c++;
    }
  }
  d[m++]=c;
  sort(d,d+m);
  int ans=0;
  fr(i,m-k) ans+=d[i];
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <math.h>
#include <bits/stdc++.h>
#include <iomanip>
#include <algorithm>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define N 100005
#define inf 1e18
#define mem(a,b) memset(a,b,sizeof(a))

using namespace std;

ll binomialCoeff(ll n,ll k)
{
    ll res = 1;
    if(k >n - k)
        k = n - k;
    for(int i = 0; i < k; ++i)
    {
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}

ll power(ll x,ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = power(x, y/2);
    if (y%2 == 0)
        return temp*temp;
    else
        return x*temp*temp;
}


ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}

void Sieve(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          cout << p << " ";
}

//*************************************************    CHECK CONSTRAINS    **********************************************************************//

ld dp[305][305][305];

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
    int n;
    cin >> n;
    int c1=0,c2=0,c3=0;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin >> x;
        if(x==1)
            c1++;
        else if(x==2)
            c2++;
        else
            c3++;
    }
    for(int i=0;i<305;i++)
    {
        for(int j=0;i+j<305;j++)
        {
            for(int k=0;i+j+k<305;k++)
            {
                if(i+j+k==0)
                    continue;
                ld p = 1.0/(i+j+k);
                dp[k][j][i] += n*p;
                if(i)
                    dp[k][j][i] += i*p*dp[k][j+1][i-1];
                if(j)
                    dp[k][j][i] += j*p*dp[k+1][j-1][i];
                if(k)
                    dp[k][j][i] += k*p*dp[k-1][j][i];
            }
        }
    }
    cout << fixed << setprecision(20) << dp[c1][c2][c3] ;
}


Measured memory_bytes: 442624
#include<bits/stdc++.h>
using namespace std;
const int N=105;
int n,a[N];
vector<int> ans;
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)scanf("%d",&a[i]);
	for (int i=1;i<=n;i++){
		int flag=0;
		for (int j=n-i+1;j;j--)
			if (a[j]==j){
				for (int k=j;k<n-i+1;k++)a[k]=a[k+1];
				ans.push_back(j);
				flag=1;
				break;
			}
		if (!flag){
			puts("-1");
			return 0;
		}	
	}
	for (int i=n-1;i>=0;i--)printf("%d\n",ans[i]);
}

Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
using namespace std;

#define LL long long int

LL H;

LL ans = 0;
 
void solve(){
	LL counter = 1;
	while(1){
		if(H==1){
			ans+=counter;
			break;
		}else{
			ans+=counter;
			H/=2;
			counter*=2;
		}
	}
}
 
int main(){
	cin>>H;

	solve();

	cout << ans;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int,input().split()))

step = 0
ma = max(A)
idx = A.index(ma)
for i in range(idx-1):
    dif = A[i+1]-A[i]
    if dif < 0:
        step += abs(dif)
        A[i+1] += abs(dif)
for i in range(idx,n):
    step += ma-A[i]
print(step)

Measured memory_bytes: 32180
n = int(input())
z100 = [[0 for _ in range(10)] for _ in range(10)]
for i in range(1,n+1):
  h = int(str(i)[0])
  t = int(str(i)[-1])
  z100[h][t] += 1
  #print(h,t)
ans = 0
for h in range(10):
  for t in range(10):
    ans += z100[h][t] * z100[t][h]
#print(z100)
print(ans)

Measured memory_bytes: 3064
n = int(input())
a = [0]
a += list(map(int, input().split()))
a.append(0)
ans = 0
for i in range(1, n + 1):
    ans += abs(a[i] - a[i + 1])
for i in range(n):
    ans -= abs(a[i+1]-a[i+2])
    print(ans+abs(a[i] - a[i + 2]))
    ans += abs(a[i] - a[i + 1])


Measured memory_bytes: 14044
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b;
     if(a==b) cout<<"Draw\n";
     else if(a==1)cout<<"Alice\n";
     else if(b==1)cout<<"Bob\n";
     else if(a>b)cout<<"Alice\n";
     else if(b>a)cout<<"Bob\n";
     else cout<<"Draw\n";
    return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main()
{	
	int a[3];
	for(int i=0;i<3;i++)cin>>a[i];
	sort(a,a+3);
	cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;
	return 0;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 300;

int n, l, r, ind, i, j;
char t[10], res[N], ansL;

int main() {
scanf("%d", &n);
printf("? ");
for (i=1;i<=n;i++) printf(" %d", i);
printf("\n");
fflush(stdout);
scanf("%s", t);
ansL = t[0];
l = n;
r = 2 * n;
while (l + 1 < r) {
	ind = (l + r) / 2;
	printf("? ");
	for (i=ind - n + 1;i<=ind;i++) printf(" %d", i);
	printf("\n");
	fflush(stdout);
	scanf("%s", t);
	if (t[0] == ansL) l = ind; else r = ind;
}
res[r] = (ansL == 'B') ? 'R' : 'B';
res[r - n] = ansL;
for (i=1;i<=2*n;i++) if (i != r && i != r - n) {
	printf("? %d", i);
	for (j=1;j<=2*n;j++) {
		if (i > r - n && i < r && (j < r - n || j > r)) printf(" %d", j);
		if ((i < r - n || i > r) && j > r - n && j < r) printf(" %d", j);
	}
	printf("\n");
	fflush(stdout);
	scanf("%s", t);
	res[i] = t[0];
}
printf("! ");
for (i=1;i<=2*n;i++) printf("%c", res[i]);
printf("\n");
fflush(stdout);
return 0;
}

Measured memory_bytes: 724
N = int(input())
if N % 2 == 1:
    print(0)
    exit()
ans = 0
"""tmp = 10
while tmp <= N:
    ans += N // tmp
    tmp *= 10"""
tmp = 50
while tmp <= N:
    ans += N // tmp
    tmp *= 5
ans += N // 10
print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>

using namespace std;

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

    int A[N];

    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    double t = 0;
    for (int i = 0; i < N; i++)
    {
        t += 1.0/A[i];
    }
    
    cout << std::setprecision(8) << 1.0/t << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

int main()
{
  i64 r, g, b, n;
  cin >> r >> g >> b >> n;
  i64 ans = 0;
  for (i64 i = 0; i <= 3000; i++)
    for (i64 j = 0; j <= 3000; j++)
      if (0 <= n - r * i - g * j && (n - r * i - g * j) % b == 0)
        ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>

typedef long long LL;
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	LL A, B; std::cin >> A >> B;
	if (A == B) return std::cout << "1\n", 0;
	LL L = 1ll << std::__lg(A ^ B);
	A &= L - 1; B &= L - 1;
	LL ans = L - A;
	LL x = B ? 1ll << std::__lg(B) + 1 : 1;
	if (x > A) ans += L; else ans += L - A + x;
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;


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

    vector<int> v;
    for (auto i = 0; i < n; ++i) {
        int x;
        cin >> x;
        v.push_back(x);
    }

    for (auto j = 0; j < v.size(); ++j) {
        // cerr << j << ", " << v[j] << endl;
        auto k = j + 1;
        cout << "node " << k << ": ";
        cout << "key = " << v[j] << ", ";

        if (j > 0) {
            cout << "parent key = " << v[(j-1)/2] << ", ";
        }
        if (j*2+1 < v.size()) {
            cout << "left key = " << v[j*2+1] << ", ";
        }
        if (j*2+2 < v.size()) {
            cout << "right key = " << v[j*2+2] << ", ";
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3148
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;

int isPrime(int x){
    if(x==2) return 1;
    if(x<2||x%2==0) return 0;
    for(int i=3;i<=sqrt(x);i++){
        if(x%i==0) return 0;
        i++;
    }
    return 1;
}

int main(){
    int n,a,c=0;
    cin>>n;
    for(int j=0;j<n;j++){
        cin>>a;
        if(isPrime(a)) c++;
    }
    cout<<c<<endl;
    return 0;
}



Measured memory_bytes: 3100
#include <iostream>
using namespace std;

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(abs(a-c)<=d)cout << "Yes";
  else if(abs(a-b)>d)cout << "No";
  else if(abs(b-c)>d)cout << "No";
  else cout << "Yes";
}


Measured memory_bytes: 3632
#include<stdio.h>
int main(void){
    int n, min, max, i, x;
    scanf("%d", &n);
    scanf("%d", &min);
    scanf("%d", &x);
    max = x - min;
    if(min > x){
        min = x;
    }
    for(i=2;i<n;i++){
        scanf("%d", &x);
        if(max < x - min){
            max = x - min;
        }
        if(min > x){
            min = x;
        }
    }
    printf("%d\n", max);
    return 0;
}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x); i<=(y); i++)
#define per(i,x,y) for (int i=(x); i>=(y); i--)
#define ll long long
#define ull unsigned long long
#define ld long double
#define inf 1000000000
#define INF 1000000000000000000ll
#define pii pair<int,int>
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define sqr(x) ((x)*(x))
#define y1 y1_
#define cmin(x,y) (x)=(y)<(x)?(y):(x)
#define cmax(x,y) (x)=(y)>(x)?(y):(x)
#define mset(x,y) memset((x),(y),sizeof(x))
#define mcpy(x,y) memcpy((x),(y),sizeof(y))
using namespace std;
const ld pi=acos(-1);
const ld eps=1e-8;
//////////////////////// header files ////////////////////////
ll read(){
	char ch=getchar(); ll x=0; int op=1;
	for (; !isdigit(ch); ch=getchar()) if (ch=='-') op=-1;
	for (; isdigit(ch); ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
	return x*op;
}
void write(ll a){
	if (a<0) putchar('-'),a=-a;
	if (a>=10) write(a/10); putchar(a%10+'0');
}
////////////////////////// fast i/o //////////////////////////
#ifdef mod
ll ksm(ll x,ll p){
	ll ret=1;
	for (; p; p>>=1,x=x*x%mod) if (p&1) ret=ret*x%mod;
	return ret;
}
ll get_inv(ll x){
	return ksm(x,mod-2);
}
#else
ll ksm(ll x,ll p){
	ll ret=1;
	for (; p; p>>=1,x=x*x) if (p&1) ret=ret*x;
	return ret;
}
#endif
//////////////////////////// qpow ////////////////////////////
#define N 100005
int n,a[N];
//#define local
int main(){
#ifdef local
	freopen("test.in","r",stdin); freopen("test.out","w",stdout);
#endif
	n=read();
	rep (i,1,n) a[i]=read();
	sort(a+1,a+1+n);
	int mx=-1,pos;
	rep (i,1,n-1){
		int x=min(a[i],a[n]-a[i]);
		if (x>mx) mx=x,pos=i;
	}
	cout<<a[n]<<' '<<a[pos]<<endl;
	return 0;
}
// sample data:
/*

*/

// rest:
/*

*/

Measured memory_bytes: 640
#include <iostream>
using namespace std;

int main(void)
{
  char s;
  cin >> s;
  if (s == 'a' || s == 'i' || s == 'u' || s == 'e' || s == 'o')
  {
    cout << "vowel" << endl;
  }
  else
  {
    cout << "consonant" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

a,b,c,d = m()

print(max(a*c,a*d,b*c,b*d))

Measured memory_bytes: 65172
S = input()
T = input()

keys_list = []
for i in range(len(S) - len(T) + 1):
    flag = True
    key = ""
    for j, char in enumerate(T):
        if S[i+j] != "?" and S[i+j] != T[j]:
            flag = False
            break
    if flag:
        keys_list.append(S[:i] + T + S[i+len(T):])

if len(keys_list) == 0:
    print("UNRESTORABLE")
else:
    ans_list = []
    for key in keys_list:
        ans = key.replace("?", "a")
        ans_list.append(ans)
    print(sorted(ans_list)[0])


Measured memory_bytes: 38256
function Main(input){
	input = input.split("\n");
  var len = input[0].length;
  for(var i = 0; i <len; i++){
  	if(input[0] === input[1])return "Yes";
    input[0] = input[0].split("");
    input[0].push(input[0].shift());
    input[0] = input[0].join("");
  }
  
  return "No"
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
abc
arc
`);

Measured memory_bytes: 11468
#include <stdio.h>
#include <math.h>
#define N_MAX 999999

int main(void){
	/* eratosthenes */
	char a[N_MAX+1]; int i, j;
	
	a[0]=0, a[1]=0;
	for(i=2; i<=N_MAX; i++) a[i]=1;
	
	for(i=2; i<=(int)sqrt(N_MAX); i++)
		if(a[i])
			for(j=2*i; j<=N_MAX; j+=i) a[j]=0;
	
	while(~scanf("%d",&i)){
		int sum=0;
		
		for(;i>=0;i--) sum+=a[i];
		printf("%d\n",sum);
	}
	
	return 0;
}

Measured memory_bytes: 0
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nm = readln.split.to!(long[]);
    auto N = nm[0];
    auto M = nm[1];
    auto as = readln.split.to!(long[]);
    sort(as);

    auto cs = new long[](10^^5+1);
    foreach (a; as) {
        cs[a] += 1;
    }
    foreach_reverse (i; 0..10^^5) {
        cs[i] += cs[i+1];
    }
    long x, y = 10^^5*2+1;
    while (x+1 < y) {
        auto m = (x+y)/2;
        long c;
        foreach (i; 0..N) {
            auto n = m - as[i];
            if (n < 0) n = 0;
            if (n > 10^^5) continue;
            c += cs[n];
        }
        if (c >= M) {
            x = m;
        } else {
            y = m;
        }
    }
    auto ds = new long[](N);
    foreach_reverse (i; 0..N) {
        if (i+1 < N) ds[i] = ds[i+1];
        ds[i] += as[i];
    }
    long r, c;
    foreach (i; 0..N) {
        if (as[i] + as[0] >= x) {
            r += as[i] * N + ds[0];
            c += N;
        } else if (as[i] + as[N-1] >= x) {
            long a, b = N-1;
            while (a+1 < b) {
                auto m = (a+b)/2;
                if (as[i] + as[m] >= x) {
                    b = m;
                } else {
                    a = m;
                }
            }
            r += as[i] * (N-b) + ds[b];
            c += N-b;
        }
    }
    writeln(r - x*(c-M));
}

Measured memory_bytes: 4540
#include <stdio.h>
#include <stdlib.h>
int compare_int(const void *a, const void *b){
	return *(int*)a - *(int*)b;
}
int main(void){
	int N;
	scanf("%d",&N);
	int A[N];
	int B[N];
	int i;
	for(i=0;i<N;i++){
		scanf("%d",&A[i]);
		B[i] = (A[i]-i-1);
	}
	
	qsort(B,N,sizeof(int),compare_int);
	long sum = 0;int b,c,d;
	if(N%2 == 1){b = B[N/2];}
	else	{b = B[N/2-1];c = B[N/2];d=1;}
	
	long sum2=0;
	for(i=0;i<N;i++){
		sum += abs(A[i]-(b+i+1));
		if(d==1)sum2 += abs(A[i]-(c+i+1));
	}
	if(d==1 && sum2 < sum) sum=sum2;
	

	printf("%ld",sum);
	
	return 0;
}

Measured memory_bytes: 2556
#include<bits/stdc++.h>
using namespace std;

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};

int H,W,sy,sx,gy,gx;
int N;

int C[100][100];
bool vis[100][100];

signed main(){
    while(cin>>W>>H,W||H){
        cin>>sx>>sy>>gx>>gy;
        cin>>N;
        sy--;sx--;gy--;gx--;
        memset(C,0,sizeof(C));
        rep(i,N){
            int c,d,x,y;
            cin>>c>>d>>x>>y;
            x--;y--;
            for(int dy=0;dy<2;dy++){
                for(int dx=0;dx<4;dx++){
                    int ny,nx;
                    if(!d)ny=y+dy,nx=x+dx;
                    else ny=y+dx,nx=x+dy;
                    C[ny][nx]=c;
                }
            }
        }
        if(!C[sy][sx]){
            cout<<"NG"<<endl;
            continue;
        }

        memset(vis,0,sizeof(vis));
        queue<pint>que;
        que.push(pint(sy,sx));
        vis[sy][sx]=true;
        while(que.size()){
            int y,x;
            tie(y,x)=que.front();
            que.pop();
            rep(i,4){
                int ny=y+dy[i],nx=x+dx[i];
                if(ny<0||ny>=H||nx<0||nx>=W||C[y][x]!=C[ny][nx]||vis[ny][nx])continue;
                vis[ny][nx]=true;
                que.push(pint(ny,nx));
            }
        }
        if(vis[gy][gx])cout<<"OK"<<endl;
        else cout<<"NG"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3180
# 解説を参考に作成


def solve(N, X, Y):
    ans = [0] * (N)

    for i in range(1, N):
        for j in range(i + 1, N + 1):
            k = min(abs(j - i), abs(X - i) + 1 + abs(Y - j))
            ans[k] += 1

    for i in ans[1:]:
        print(i)


if __name__ == '__main__':
    N, X, Y = map(int, input().split())
    solve(N, X, Y)


Measured memory_bytes: 3444
s=list(input())
k=int(input())
for e,i in enumerate(s):
    c=(123-ord(i))%26
    if k>=c:
        s[e]="a"
        k-=c
    else:s[e]=i
l = chr((ord(s[-1])-97+k)%26+97)
print("".join(s[:-1])+l)


Measured memory_bytes: 4788
#include <bits/stdc++.h>
using namespace std;

int kensaku(int s,int g,vector<pair<int,int>> H){
  for(int i=0;i<H.size();i++){
    if(s==H.at(i).first&&g==H.at(i).second)
      return 1;
    if(g==H.at(i).first&&s==H.at(i).second)
      return 1;
  }
  return 0;
}

int main(){
  int N,M,a,b,ans=0,ac=0;
  cin>>N>>M;
  vector<pair<int,int>> H;
  vector<int> v(N);
  for(int i=0;i<M;i++){
    cin>>a>>b;
    H.push_back(make_pair(a,b));
  }
  for(int i=1;i<=N;i++)
    v.at(i-1)=i;

  sort(v.begin(), v.end());
  do {
    ac=0;
    // 1行で今の並び方を出力
    for (int i=0;i<N-1;i++) {
      if(kensaku(v.at(i),v.at(i+1),H)==0){
        ac=1;
        break;
      }
    }
    if(ac==0)
      ans++;
  } while (next_permutation(v.begin()+1, v.end()));

  cout <<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
bool bfs(int a, int b) {
	if (a <= 1 && b <= 1)return false;
	bool res = false;
	for (int i = 2; i <= a; i += 2) {
		if (!bfs(a - i, b + i / 2))res = true;
	}
	for (int i = 2; i <= b; i += 2) {
		if (!bfs(a + i / 2, b - i))res = true;
	}
	return res;
}
int main() {
	ll x, y; cin >> x >> y;
	if (abs(x - y) <= (ll)1)cout << "Brown" << endl;
	else cout << "Alice" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define INF 1000000007
#define ggr getchar(); getchar();return 0;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}

int n, h, a[100010], b[100010], ans;
vector<pair<int, int>> ta;

signed main() {
	cin >> n >> h;
	rep(i, n) {
		cin >> a[i] >> b[i];
		ta.push_back(make_pair(a[i], 1));
		ta.push_back(make_pair(b[i], 0));
	}
	sort(ta.begin(), ta.end());
	reverse(ta.begin(), ta.end());
	rep(i, ta.size()) {
		if (ta[i].second == 0) {
			h -= ta[i].first;
			ans++;
		}
		else {
			if (h%ta[i].first == 0) {
				cout << ans + h / ta[i].first << endl;
				ggr
			}
			else {
				cout << ans + h / ta[i].first + 1 << endl;
				ggr
			}
		}
		if (h <= 0) {
			cout << ans << endl;
			ggr
		}
	}
	ggr
}

Measured memory_bytes: 6640
#include <bits/stdc++.h>
using namespace std;

int main() {
	long long int n, W1, w[100001]={0}, j, temp, temp2, max1;
	cin>>n>>W1;
	for(int i=0;i<n;i++){
		cin>>temp>>temp2;
		j=W1;
		while(j-temp>=0){
			if(w[j-temp]){
					w[j]=max(w[j],w[j-temp]+temp2);
			}
			j--;
		}
		if(w[temp]<temp2){
			w[temp]=temp2;
		}
	}
	max1=w[0];
		for(int i=1;i<=W1;i++){
			if(max1<w[i]){
				max1=w[i];
			}
		}
		cout<<max1;
	return 0;
}

Measured memory_bytes: 1024
N = int(input())
torump = [[0 for i in range(1,14)] for i in range(4)]
for _ in range(N):
  pattern,num = map(str,input().split())
  num = int(num)
  if pattern == "S":
    pattern = 0
    torump[pattern][num-1] = 1
  elif pattern == "H":
    pattern = 1
    torump[pattern][num-1] = 1    
  elif pattern == "C":
    pattern = 2
    torump[pattern][num-1] = 1
  elif pattern == "D":
    pattern = 3
    torump[pattern][num-1] = 1

for i in range(4):
  for j in range(13):
    if torump[i][j] == 0:
      if i == 0:
        print(f'S {j+1}')
      elif i == 1:
        print(f'H {j+1}')
      elif i == 2:
         print(f'C {j+1}')
      elif i == 3:
        print(f'D {j+1}') 


Measured memory_bytes: 5620
#include <iostream>
#include <vector>
using namespace std;

bool calc(int a,int b,int c,int d){
    if(c==0&&d==0){
        return true;
    }
    if(a==0&&b==0){
        return false;
    }
    if(a!=0){
    if(c!=0){
    if(a+c>=5){
        if(!calc(0,d,a,b)){
            return true;
        }
    }else{
        if(!calc(a+c,d,a,b)){
            return true;
        }
    }
    }
    if(d!=0){
    if(a+d>=5){
        if(!calc(c,0,a,b)){
            return true;
        }
    }else{
        if(!calc(c,a+d,a,b)){
            return true;
        }
    }
    }
    }
    if(b!=0){
    if(c!=0){
    if(b+c>=5){
        if(!calc(0,d,a,b)){
            return true;
        }
    }else{
        if(!calc(b+c,d,a,b)){
            return true;
        }
    }
    }
    if(d!=0){
    if(b+d>=5){
        if(!calc(c,0,a,b)){
            return true;
        }
    }else{
        if(!calc(c,b+d,a,b)){
            return true;
        }
    }
    }
    }
    return false;
}


int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(calc(a,b,c,d)){
        cout << "ISONO" << endl;
    }else{
        cout << "NAKAJIMA" << endl;
    }
    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
#define REP(i, n) for (int i = 0; i < n; i++)

ll n, dp[4005][4005];  // dp[i][j]:i回操作して自由に使える青がj個になる通り

int main() {
    string s;
    cin >> s;
    n = s.size();
    dp[0][0] = 1;
    REP(i,n*2){
        REP(j,n*2){
            ll b=0, r=0;
            b = j + (i<n ? s[i]-'0' : 0);  // blue
            r = min((i+1LL)*2, n*2)-b-i;  // red
            if(r>0){
                dp[i+1][b] += dp[i][j];
                dp[i+1][b] %= MOD;
            }
            if(b>0){
                dp[i+1][b-1] += dp[i][j];
                dp[i+1][b-1] %= MOD;
            }
        }
    }
    cout << dp[n*2][0] << endl;
    return 0;
}

Measured memory_bytes: 125440
#include<bits/stdc++.h>
#define FASTIO                     ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define REP(i,n)                   for(int i=1 ; i<=n ; i++)
#define mod                        1000000007
#define pi                         pair<int,int>
#define vi                         vector<int>
#define vii                        vector<pair<int,int>>
#define lli                        long long int
#define pb                         push_back
#define Mp                         make_pair
#define ff                         first
#define ss                         second
#define endl                       '\n'

using namespace std;

int main()
{
    FASTIO;
    string str;
    cin>>str;

    transform(str.begin(), str.end(), str.begin(), ::tolower);

    int len = str.length();

    if(str[len-1] == 's')
        str.append("es");
    else
        str.append("s");

    cout<<str<<endl;


    return 0;
}



Measured memory_bytes: 3664
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<string>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007

using namespace std;

typedef long long int ll;

const ll INF=(ll)1e18;

int N,W;

int main(){
    cin >> N >> W;

    ll dp[N+1][W+1];
    REP(i,N+1)REP(j,W+1)dp[i][j] = -1;

    dp[0][0] = 0;

    FOR(i,1,N+1){
      ll w,v;
      cin >> w >> v;
      REP(j,W+1){
        if(dp[i-1][j] == -1)continue;

        // i個目を選ばない
        if(dp[i][j] < dp[i-1][j])dp[i][j] = dp[i-1][j];

        // i個目を選ぶ
        if(j+w <= W){
          if(dp[i][j+w] < dp[i-1][j] + v){
            dp[i][j+w] = dp[i-1][j] + v;
          }
        }
      }

    }
    ll ans = 0;
    REP(i,W+1){
      if(ans < dp[N][i]) ans = dp[N][i];
    }    
    cout << ans << endl;
}


Measured memory_bytes: 79104
import math

x = int(input())

pow_list = [1, 1000]
i = 2
while i**2 < 1000:
    j = 2
    while i**j < 1000:
        pow_list.append(i**j)
        j += 1
    i += 1

pow_list = set(pow_list)

for i in range(x, 0, -1):
    if i in pow_list:
        res = i
        break

print(res)

Measured memory_bytes: 3064
N,M,K = map(int,input().split())

# Union Find

# xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]


# xとyの属する集合の併合
def unite(x, y):
    x = find(x)
    y = find(y)

    if x == y:
        return False
    else:
        # sizeの大きいほうがx
        if par[x] > par[y]:
            x, y = y, x
        par[x] += par[y]
        par[y] = x
        return True


# xとyが同じ集合に属するかの判定
def same(x, y):
    return find(x) == find(y)


# xが属する集合の個数
def size(x):
    return -par[find(x)]

# 初期化
# 根なら-size,子なら親の頂点
par = [-1]*(N+1)


friend_list = [[] for _ in range(N+1)]
for _ in range(M):
    A,B = map(int,input().split())
    unite(A,B)
    friend_list[A].append((B))
    friend_list[B].append((A))

block_list = [[] for _ in range(N+1)]
for _ in range(K):
    C, D = map(int, input().split())
    block_list[C].append(D)
    block_list[D].append(C)

anslist = [0]*(N)
for i in range(1,N+1):

    block_and_connect = 0
    for hito in block_list[i]:
        if same(hito,i):
            block_and_connect += 1
    ans = size(i) - 1 - len(friend_list[i]) - block_and_connect
    anslist[i-1] = ans
print(*anslist)



Measured memory_bytes: 46840
#include "bits/stdc++.h"
using namespace std;

#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<vll>		vvll;
typedef vector<vi>		vvi;
typedef vector<vb>		vvb;
typedef vector<vs>		vvs;
typedef vector<vc>		vvc;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

template <typename T>
using mat2d = vector<vector<T>>;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

template<typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " " << p.second << "}";
	return os;
}

ostream& operator << (ostream& os, const edge e) {
	os << "{to: " << e.to << ", cost: " << e.cost << "}";
	return os;
}

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/



int main()
{
	int N, M;
	cin >> N >> M;
	vi A(M);
	cin >> A;
	vi num = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };

	vs dp(N + 1, "0");
	dp[0] = "";
	for (int i = 0; i < N; i++) {
		if (dp[i] == "0") continue;
		for (int j = 0; j < M; j++) {
			if (i + num[A[j]] <= N) {
				string n1, n2;
				n1 = dp[i] + to_string(A[j]);
				n2 = to_string(A[j]) + dp[i];
				if (dp[i + num[A[j]]].length() < n1.length())
					dp[i + num[A[j]]] = max(n1, n2);
				else if (dp[i + num[A[j]]].length() == n1.length())
					dp[i + num[A[j]]] = max({ n1, n2, dp[i + num[A[j]]] });
			}
		}
	}
	
	//for (auto i : dp)
	//cout << i << endl;

	cout << dp[N] << endl;

	return 0;
}

Measured memory_bytes: 33792
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define all(n) (n).begin(),(n).end()
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

int main(){
	int n;
	cin >> n;
	ll h[100010];
	FOR(i,n){
		cin >> h[i];
	}
	int f=0,cnt=0,ans=0;
	while(f!=n-1){
		if(h[f]>=h[f+1])cnt++;
		else{chmax(ans,cnt);cnt=0;}
		f++;
	}
	chmax(ans,cnt);

	cout << ans << endl;


}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n);
  rep(i, n) cin >> a[i] >> b[i] >> c[i];

  vector<vector<int>> dp(n, vector<int>(3));

  dp[0][0] = a[0];
  dp[0][1] = b[0];
  dp[0][2] = c[0];

  for (int i = 1; i < n; i++) {
    dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
    dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
    dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
  }

  int ans = max(max(dp[n - 1][0], dp[n - 1][1]), dp[n - 1][2]);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
#define rep(i, N)  for (int i = 0; i < N; i++)

int main(){

    double A, B, H, M;
    cin >> A >> B >> H >> M;

    double alpha = 2 * M_PI * (H + M / 60) /12;
    double beta = 2 * M_PI * M / 60;

    double r = sqrt(pow(A*cos(alpha) - B*cos(beta), 2)
               + pow(A*sin(alpha) - B*sin(beta), 2)
                );
    
    cout << fixed << setprecision(15) << r << endl;

    return 0;
}

Measured memory_bytes: 4100
n,k=map(int,input().split())
h=[]
for _ in range(k):
    d=int(input())
    as_=list(map(int,input().split()))
    for a in as_:
        h.append(a)
ans=0
for m in range(1, n+1):
    if not m in h:
        ans+=1
print(ans)


Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int n; cin>>n;
  int an[n]; rep(i,n) cin >> an[i];
  ll coin = 1000;
  ll stock = 0;
  int i=0;	//day
  while (i<n-1) {
    if (stock==0) {
      if (an[i] < an[i+1]) {
        stock = coin / an[i];
        coin -= stock * an[i];
        //cout<<i<<" "<<stock<<endl;
      }
    } else {
      if (an[i] > an[i+1]) {
        coin += stock * an[i];
        //cout<<i<<" "<<stock<<endl;
        stock = 0;
      }
    }
    i++;
  }
  coin += stock * an[n-1];
  cout<<coin;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>B(N);
  for(int i=0;i<N-1;i++) cin>>B[i];
  B[N-1]=1000000;
  vector<int>A(N);
  A[0]=B[0];
  for(int i=1;i<N;i++){
    A[i]=min(B[i],B[i-1]);
  }
  int S=0;
  for(int i=0;i<N;i++) S+=A[i];
  cout<<S<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//One implementation to rule them all?
#define db              double
#define ll              long long int
#define ld                long long double
//#define int           long long int
#define ull             unsigned long long
#define fi              first
#define se              second
#define rep(i,a,n)      for(int i=a;i<n;i++)
#define repr(i,n,b)     for(int i=n;i>=b;i--)
#define endl            '\n'
#define mem(a,b)        memset(a, b, sizeof a)
#define mkp             make_pair
#define pb              push_back
#define max3(a,b,c)     max(a,max(b,c))
#define min3(a,b,c)     min(a,min(b,c))
#define w(t)            int t; cin>>t; while(t--)
#define all(a)          a.begin(), a.end()
#define sz(a)           int((a).size())
#define debug(x)        cerr << #x << " = " << x << endl;
//Bitwise 
#define isOn(S, j)      (S & (1<<j))
#define setBit(S, j)    (S |= (1<<j))
#define clearBit(S, j)  (S &= ~(1<<j))
#define toggleBit(S, j) (S ^= (1<<j))
#define lowBit(S)       (S & (-S))
#define setAll(S, n)    (S = (1<<n)-1)
#define turnOffLastBit(S) ((S) & (S-1))
#define turnOnLastZero(S) ((S) | (S+1))
//Can use tuples in C++17
using namespace std;
typedef vector < int > vii;
typedef vector < ll > vll;
typedef vector < vii > vvi;
typedef pair < int,int > pii;
template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
const db PI = 2*acos(0.0);
const int INF = 0x3f3f3f3f;
const ll LINF = (ll)2e18;
db eps       =          0.000001;
ll mod       =          998244353;   //(1e9+7)
void print(vector <int> &arr){
    for(int i=0;i<arr.size();i++)
        cout<<arr[i]<<" ";
    
    cout<<endl;
}
void printll(vector <ll> &arr){
    for(int i=0;i<arr.size();i++)
        cout<<arr[i]<<" ";
    
    cout<<endl;
}

ll ncr(ll n, ll r)
{
    r=min(r,n-r);
    ll A[r],i,j,B[r];
    iota(A,A+r,n-r+1);  
    iota(B,B+r,1);     

    ll g;
    for(i=0;i<r;i++)
    for(j=0;j<r;j++)
    {
        if(B[i]==1)
            break;
        g=__gcd(B[i], A[j] );
        A[j]/=g;
        B[i]/=g;
    }
    ll ans=1;
    for(i=0;i<r;i++)
        ans=(ans*A[i]%mod);
    return ans;
}
const int SIZE=1e5+5;
bool judgePermutation(int a[], int n){
    static int used[SIZE+1];
    for(int i = 1; i <= n; i++) used[i] = 0;
    for(int i = 0; i < n; i++) used[a[i]] = 1;
    for(int i = 1; i <= n; i++) {
        if(!used[i]) return 0;
    }
    return 1;
}

int main(){ 
//CONDITION && cout << "YES" || cout << "NO"; cout << '\n';
//////////////////////////////////////////////////////////////////////
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cerr.tie(NULL);
//For fast IO
///////////////////////////////////////////////////////////////////// 
//  std::cout.unsetf ( std::ios::floatfield );  // floatfield not set
//  std::cout.precision(10);
//  freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
	int a,b;
	cin>>a>>b;
	if(a*2==b || a*4==b) cout<<"Yes"<<endl;
	else if((4*a-b)&1 || (4*a<b) || (2*a>b)) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <math.h>

using namespace std;

int main(){
	bool first;
	int min;
	int x, y, z, e,buf_z,buf_y;
	cin >> e;
	while (e != 0){
		first = true;
		for (z = 0; (buf_z = pow(z, 3)) <= e; z++)
		{
			for (y = 0; buf_z + (buf_y = pow(y, 2)) <= e; y++)
			{
				x = e - buf_z - buf_y;
				if (first == true)
				{
					min = x + y + z;				
					first = false;
				}
				else if (min > x + y + z)
				{
					min = x + y + z;
				}
			}
		}
		cout << min << "\n";
		cin >> e;
	}
	return 0;
}

Measured memory_bytes: 1224