akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
string N;
int K;
int ans = 0;
int choice(int N, int r) {
    int ret = 1;
    rep(i, r) ret *= N - i;
    //cout << N << " " << r << " " << ret << endl;
    rep(i, r) ret /= i + 1;
    //cout << N << " " << r << " " << ret << endl;
    rep(i, r) ret *= 9;
    //cout << N << " " << r << " " << ret << endl;
    return max(0LL, ret);
}
int f(int digit, int select, bool smaller) {
    if ((int)N.length() - digit  < K - select) return 0;
    if (select == K) return 1;
    if (smaller) {
        //cout << choice(N.length() - digit, K - select) << endl;
        return choice(N.length() - digit, K - select);
    }
    int ret = 0;
    if (N[digit] == '0')
        ret += f(digit + 1, select, false); // 0を選択
    else if (N[digit] != '0')
        ret += f(digit + 1, select, true); // 0を選択
    if (N[digit] >= '2')
        ret += max(0LL, f(digit + 1, select + 1, true) * (N[digit] - '0' - 1)); // 1~N-1を選択
    if (N[digit] >= '1')
        ret += f(digit + 1, select + 1, false); // Nを選択
    //cout << digit << " " << ret << endl;
    return ret;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    cin >> K;
    int len = N.length();
    int ans = 0;
    cout << f(0, 0, false) << endl;


    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main{
    
	public static void main(String[] $){
		Scanner s = new Scanner(System.in);
		String A = s.next();
		char[] c = A.toCharArray();
		if(c[0] >= 'a' && c[0] <= 'z'){
			System.out.println("a");
		}else{
			System.out.println("A");
		}
		
		
			
	}
} 

Measured memory_bytes: 35644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
//#define MOD 1000000007
#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(ll i=0;i<(n);++i)
#define OREP(i,n) for(ll i=1;i<=(n);++i)
#define RREP(i,n) for(ll i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false


int main(void){
    ll N;
    cin >> N;
    
    vector<ll> C;
    while(N>0){
        C.push_back((N-1)%26);
        N=((N-1)/26);
    }
    
    RREP(i,C.size()){
        cout << (char)(C[i]+'a');
    }
    cout << endl;
    
    return 0;
}



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

using namespace std;
using ll = long long int;
#define long ll

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

    while(1) {
        ll r0, w0, c, r;
        cin >> r0 >> w0 >> c >> r;
        if(!r0) break;

        ll ok = 1e9, ng = -1;
        while(abs(ok - ng) > 1) {
            ll m = (ok + ng) / 2;
            (r0 + m*r >= c * w0 ? ok : ng) = m;
        }
        cout << ok << endl;
    }
}



Measured memory_bytes: 3132
// ALDS1_12_B, ALDS1_12_C: SSSP, nonnegative edges (Dijkstra's)

import java.util.*;

// Given: all nodes are reachable; source is node 0
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();

    Map<Integer, Integer> cost = new HashMap<Integer, Integer>();
    cost.put(0, 0);

    // representing vertices as int[] with values {id, tentative cost}
    PriorityQueue<int[]> pq =
        new PriorityQueue<int[]>(
            new Comparator<int[]>() {
              public int compare(int[] v1, int[] v2) {
                return Integer.compare(v1[1], v2[1]);
              }
            });

    // populate adjacency list
    // adj[i] = list of all edges from node i
    ArrayList<ArrayList<int[]>> adj = new ArrayList<ArrayList<int[]>>();
    for (int i = 0; i < n; ++i) {
      adj.add(new ArrayList<int[]>());
      sc.nextInt(); // skip id
      int n_nbrs = sc.nextInt();
      for (int j = 0; j < n_nbrs; ++j) {
        int destination = sc.nextInt();
        int edge_cost = sc.nextInt();
        adj.get(i).add(new int[] {i, destination, edge_cost});
      }
    }

    // populate priority queue with neighbors of the source node 0
    for (int[] e : adj.get(0)) {
      pq.add(new int[] {e[1], e[2]});
    }

    while (cost.size() < n) {
      int[] v = pq.remove(); // cheapest vertex
      if (!cost.containsKey(v[0])) {
        cost.put(v[0], v[1]);
        for (int[] e : adj.get(v[0])) {
          pq.add(new int[] {e[1], v[1] + e[2]});
        }
      }
    }

    for (int i = 0; i < n; ++i) {
      System.out.printf("%d %d\n", i, cost.get(i));
    }
  }
}


Measured memory_bytes: 329648
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,a[100010],dp[100010];
    cin>>n;
    rep(i,n){
        cin>>a[i];
    }
    rep(i,100010) dp[i]=LLINF;
    rep(i,n){
        *lower_bound(dp,dp+n,a[i])=a[i];
    }
    cout<<lower_bound(dp,dp+n,LLINF)-dp<<endl;
    return 0;
}


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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL<<60;
const ll mod = 1000000007;		




int main() {

	int n, q;
	string s;
	cin >> n >> q >> s;

	VI dp(n + 10, 0);

	REP(i, s.size()) {
		if (s.substr(i, 2) == "AC")dp[i + 1] = dp[i] + 1;
		else dp[i + 1] = dp[i];
	}


	REP(i, q) {
		int l, r;
		cin >> l >> r;

		cout << dp[r - 1] - dp[l - 1] << endl;

	}

	return 0;
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

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

    ll sum = 0;
    rep(i, N) {
        sum += L + i;
    }

    ll best = 1e8, ans = -1e8;

    rep(i, N) {
        rep(j, N) {
            ll tmp = sum - (L + j);
            if (best >= abs(tmp-sum)) {
                best = abs(tmp-sum);
                ans = tmp;
            }
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr int inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
int main() {
    int n;cin >> n;
    vi prime;
    for(int i = 2;i<=1000;i++) {
        bool ok = false;
        for(int j = 2;j<=sqrt(i);j++) {
            if(i%j==0) {
                ok = true;
                break;
            }
        }
        if(!ok) prime.pb(i);
    }
    /*for(auto p:prime) cout << p << ' ';
    cout << endl << prime.size() << endl;*/
    ll count = 1;
    rep(i, 168) {
        int cnt = 0;
        int N = n;
        while(N/prime[i]!=0) {
            cnt += N/prime[i];
            N/=prime[i];
        }
        count*=cnt+1;
        count%=mod;
    }
    cout << count << endl;
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> d(n);
    for(int i=0;i<n;i++){cin >> d[i];}
    sort(d.begin(),d.end());
    int ans = 1;
    for(int j=1;j<n;j++){
        if(d[j-1] != d[j]){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
names = []
mins = []
for i in range(n):
  na,m = input().split()
  names.append(na)
  mins.append(int(m))
t = input()
c = 0
for i in range(len(names)):
  if not(t == names[i]):
    c += mins[i]
  else:
    c += mins[i]

    break
print(sum(mins)-c)

Measured memory_bytes: 38384
a,b,m=map(int,input().split())
la =list(map(int,input().split()))
lb =list(map(int,input().split()))
ans = min(la)+min(lb)
for i in range(m):
  aa,bb,cc =map(int,input().split())
  ans =min(ans,la[aa-1]+lb[bb-1]-cc)
print(ans)
  

Measured memory_bytes: 18736
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include<iomanip>
#include<sstream>
#include <fstream>
#define ll long long
#define pb push_back
#define clr(a, b) memset((a), (b), sizeof(a))
#define debugs(x) cout << "Line" << __LINE__ << "	" << #x << "=" << x << endl
#define break break
#define continue continue
#define itn int
#define endl '\n'
#define Endl endl
#define vint vector<ll>
#define pii pair<int, int> 
using namespace std;

int n, k, m;
int a[200005];

void solve(int T)
{
	//int l, r, d;
	//cin >> l >> r >> d;
	//cout << r / d - (l-1) / d  << endl;
	cin >> n;
	itn ans = 0;
	for (int i = 1; i <= n; i++)
	{
		cin >> m;
		if (i & 1 && m & 1)ans++;
	}
	cout << ans << Endl;
}
int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	int numoftest = 1;

	//cin >> numoftest;


	for (int siven = 1; siven <= numoftest; ++siven)
		solve(siven);
	return 0;
}

/*


*/

Measured memory_bytes: 3112
while True :
    n, x = map(int, input().split())
    
    if n == 0 :
        break
    else :
        ans = 0
        
        for i in range(1, n - 1) :
            for j in range(i + 1, n) :
                for k in range(j + 1, n + 1) :
                    if i + j + k == x :
                        ans += 1
                        
        print(ans)


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

struct BIT{
  int n;
  vector<ll> bit;
  BIT(int size):n(size),bit(size+1,0){}

  ll sum(int i){
    ll s=0;
    while(i>0){
      (s+=bit[i])%=mod;
      i-=i&-i;
    }
    return s;
  }

  void add(int i,ll v){
    if(i==0)return ;
    while(i<=n){
      (bit[i]+=v)%=mod;
      i+=i&-i;
    }
  }

  ll lower_bound(ll w){
    if(w<=0)return 0;
    ll x=0,r=1;
    while(r<n)r<<=1;
    for(ll k=r;k>0;k>>=1){
      if(x+k<=n&&bit[x+k]<w){
        w-=bit[x+k];
        x+=k;
      }
    }
    return x+1;
  }
};

ll N,M;
ll A[200010],B[200010];
ll L[200010],R[200010];
vector<P> ps;
vector<ll> rs,ord;

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

  cin>>N>>M;
  rep(i,N)cin>>A[i];
  rep(j,M)cin>>B[j];

  rep(i,N){
    ll idx=lower_bound(B,B+M,A[i])-B;
    if(idx==0||idx==M)continue;
    L[i]=A[i]-B[idx-1]; R[i]=B[idx]-A[i];
    ps.push_back(P(L[i],R[i]));
  }
  sort(all(ps)); uni(ps);
  rep(i,ps.size()){
    rs.push_back(ps[i].se); ord.push_back(i);
  }
  rs.push_back(0);
  sort(all(rs)); uni(rs);
  sort(all(ord),[=](const ll& a,const ll& b){
    if(ps[a].fi == ps[b].fi) return ps[a].se < ps[b].se;
    else return ps[a].fi < ps[b].fi;
  });
  rep(i,ps.size()){
    ps[i].se=lower_bound(all(rs),ps[i].se)-rs.begin();
  }
  ll K=rs.size();

  BIT bit(K);
  bit.add(1,1);
  for(ll i=0;i<(ll)ps.size();){
    vector<P> add;
    ll j=i;
    for(;j<(ll)ps.size()&&ps[j].fi==ps[i].fi;j++){
      add.push_back(P(ps[j].se+1,bit.sum(ps[j].se)));
    }
    rep(k,add.size()){
      bit.add(add[k].fi,add[k].se);
    }
    i=j;
  }
  cout<<bit.sum(K)<<endl;

  return 0;
}


Measured memory_bytes: 10224
#include <bits/stdc++.h>
using namespace std;
 
#define maxn -20000000000 //negative value to break code and force you to put right constraint
#define mod 1073741824
#define md(x) (x) % mod;
#define sc scanf
#define pr printf
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ps push
#define prt(x) cout << (#x) << " is " << (x) << endl
#define EPS 1e-9
#define INF 100000000000
#define INFd 1e9
typedef int ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<double> vd;



int main()
{
	string s;
	cin>>s;
	//vector<ll> v(27,0);
	ll c=0;
	for(ll i=0,j=s.length()-1;i<j;i++,j--)
	{
		if(s[i]!=s[j])
			c++;

	}

	cout<<c;
}


Measured memory_bytes: 256
A, B = map(int, input().split())
cnt=0
for i in range(A,B+1):
    i=str(i)
    a=i[::-1]
    flag=0
    for j in range(len(i)):
        if i[j]!=a[j]:
            flag=1
    if flag==0:
        cnt+=1
print(cnt)



Measured memory_bytes: 9112
import math
mod = 10**9+7
N,M = map(int,input().split())
if abs(N-M) > 1:
    print(0)
elif N == M:
    print((math.factorial(N)*math.factorial(M)*2)%mod)
else:
    print((math.factorial(N)*math.factorial(M))%mod)

Measured memory_bytes: 55152
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int M;
int P[10];
int s[10][10];
int arr[10];
int main(){
  int i, j, k, mask, res=0;
  rd(N);
  rd(M);
  for(i=0;i<M;i++){
    int Lj4PdHRW;
    rd(k);
    for(Lj4PdHRW=0;Lj4PdHRW<k;Lj4PdHRW++){
      rd(j);
      s[j-1][i] = 1;
    }
  }
  {
    int KL2GvlyY;
    for(KL2GvlyY=0;KL2GvlyY<M;KL2GvlyY++){
      rd(P[KL2GvlyY]);
    }
  }
  for(mask=0;mask<1<<N;mask++){
    int Q5VJL1cS, e98WHCEY;
    for(j=0;j<M;j++){
      arr[j] = P[j];
    }
    for(i=0;i<N;i++){
      if(mask & 1<<i){
        for(j=0;j<M;j++){
          arr[j] ^= s[i][j];
        }
      }
    }
    if(M==0){
      e98WHCEY = 0;
    }
    else{
      e98WHCEY = arr[0];
      for(Q5VJL1cS=1;Q5VJL1cS<M;Q5VJL1cS++){
        e98WHCEY += arr[Q5VJL1cS];
      }
    }
    if(e98WHCEY==0){
      res++;
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190526-1

// --- original code ---
// int N, M;
// int P[10];
// 
// int s[10][10];
// int arr[10];
// {
//   int i, j, k, mask;
//   int res = 0;
// 
//   rd(N,M);
//   rep(i,M){
//     rd(k);
//     rep(k){
//       rd(j);
//       s[j-1][i] = 1;
//     }
//   }
//   rd(P(M));
// 
//   rep(mask, 1<<N){
//     rep(j,M) arr[j] = P[j];
//     rep(i,N) if(mask & 1<<i) rep(j,M) arr[j] ^= s[i][j];
//     if(sum(arr(M))==0) res++;
//   }
//   wt(res);
// }


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int a_1,a_2,a_3;
    scanf("%d",&a_1);
    scanf("%d",&a_2);
    scanf("%d",&a_3);
    if (a_1 <= a_2 && a_1 <= a_3)
        if (a_2 <= a_3) printf("%d",a_3-a_1);
        else printf("%d",a_2-a_1);
    else if(a_2 <= a_3 && a_2 <= a_1)
        if (a_1 <= a_3) printf("%d",a_3-a_2);
        else printf("%d",a_1-a_2);
    else if(a_1 <= a_2 && a_3 <= a_1 && a_3 <= a_2) printf("%d",a_2-a_3);
    else printf("%d",a_1-a_3);

   
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <vector>
#include <queue>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <queue>
using namespace std;
#define sd(n) scanf("%d", &n)
#define sdd(n, m) scanf("%d%d", &n, &m)
#define sddd(n, m, k) scanf("%d%d%d", &n, &m, &k)
#define pd(n) printf("%d\n", n)
#define pc(n) printf("%c", n)
#define pdd(n, m) printf("%d %d\n", n, m)
#define pddd(n, m, z) printf("%d %d %d\n", n, m, z)
#define pld(n) printf("%lld\n", n)
#define pldd(n, m) printf("%lld %lld\n", n, m)
#define plddd(n, m, z) printf("%lld %lld %lld\n", n, m, z)
#define sld(n) scanf("%lld", &n)
#define sldd(n, m) scanf("%lld%lld", &n, &m)
#define slddd(n, m, k) scanf("%lld%lld%lld", &n, &m, &k)
#define sf(n) scanf("%lf", &n)
#define sc(n) scanf("%c", &n)
#define sff(n, m) scanf("%lf%lf", &n, &m)
#define sfff(n, m, k) scanf("%lf%lf%lf", &n, &m, &k)
#define ss(str) scanf("%s", str)
#define rep(i, a, n) for (int i = a; i <= n; i++)
#define per(i, a, n) for (int i = a; i >= n; i--)
#define mem(a, n) memset(a, n, sizeof(a))
#define debug(x) cout << #x << ": " << x << endl
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define ce i == n ? '\n' : ' '
#define mod(x) ((x) % MOD)
#define gcd(a, b) __gcd(a, b)
#define lowbit(x) (x & -x)
typedef pair<int, int> PII;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int MOD = 1e9 + 7;
const double eps = 1e-9;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
const int inf = 0x3f3f3f3f;
inline int read()
{
	int ret = 0, sgn = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9')
	{
		if (ch == '-')
			sgn = -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9')
	{
		ret = ret * 10 + ch - '0';
		ch = getchar();
	}
	return ret * sgn;
}
inline void Out(int a) //ê?3?ía1ò
{
	if (a > 9)
		Out(a / 10);
	putchar(a % 10 + '0');
}

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

ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
///快速幂m^k%mod
ll qpow(ll x, ll n, ll mod)
{
	ll res = 1;
	while (n)
	{
		if (n & 1)
			res = (res * x) % mod;
		x = x * x % mod, n >>= 1;
	}
	return res;
}

const int N = 1e6 + 50;


int main()
{
	int n;
	sd(n);
	int x=n%10;
	if(x==2||x==4||x==5||x==7||x==9)
	puts("hon");
	else if(x==0||x==1||x==6||x==8)
	puts("pon");
	else
	puts("bon");
	return 0;
}

Measured memory_bytes: 3744
#include<bits/stdc++.h>                               
using namespace std;
 
#define PI acos(-1)
#define fi first 
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
#define all(c) (c).begin(), (c).end()
#define TIMESTAMP fprintf(stderr, "Execution time: %.3lf s.\n", 1.0*clock()/CLOCKS_PER_SEC)
 
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair <int, int> pii;
typedef vector <vi> vvi;
typedef vector <pii> vpii;
typedef vector<string> vs;
 
const int INF = 100500;
const int MAXN = 1e5 + 9;
const int MOD = 1e9 + 7;
 
ll n, k;

ll f(ll a, ll b) {
	if(a <= 0 || b <= 0) return 0 - a - b;
	if(a > b) swap(a, b);
	if(a == b)
		return a;
	return 2 * a * (b / a) + f(b % a, a);
}
 
void input() {                  
	cin >> n >> k;
}
 
void solve() {          
	cout << n + f(n - k, k);
}
 
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);     
#ifdef LOCAL
	freopen("xxx.in", "r", stdin);
	freopen("xxx.out", "w", stdout);
#else
	//freopen("xxx.in", "r", stdin);
	//freopen("xxx.out", "w", stdout);
#endif	
	input();
	solve();
	return 0;
}


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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define what_is(x) cerr << #x << " is " << x << endl;
#define debug(v) for (auto el : v) { cerr << el << ' '; } cerr << endl;

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	ll n, k;
	scanf("%lld%lld", &n, &k);
	vll a(n), cnt(64);
	for (int i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
		for (int j = 0; j < 60; j++)
			if (a[i] & (1LL << j)) cnt[j]++;
	}

	ll x = 0;
	for (int i = 59; i >= 0; --i) {
		if (n - cnt[i] > n/2) {
			ll tmp = x + (1LL << i);
			if (tmp <= k) x = tmp;
		}
	}

	ll answer = 0;
	for (int i = 0; i < n; i++) answer += a[i] ^ x;
	cout << answer << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int n, a, x[50];
ll dp[51][51][51 * 51];

ll f(int k, int m, int s)
{
    if (k == n) return (m > 0 && s / m == a && s % m == 0);
    if (dp[k][m][s] != -1) return dp[k][m][s];
    return dp[k][m][s] = f(k + 1, m, s) + f(k + 1, m + 1, s + x[k]);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> a;
    for (int i = 0; i < n; ++i)
        cin >> x[i];

    memset(dp, -1, sizeof dp);
    cout << f(0, 0, 0);
}


Measured memory_bytes: 53120
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        k: usize,
        s: usize
    }

    //test
    //
    /*
    let k: usize = 2;
    let s: usize = 2;
    */

    let mut ans: usize = 0;

    for x in 0..k + 1 {
        if x > s {
            break;
        }
        for y in 0..k + 1 {
            if (x + y) > s {
                break;
            }
            if (x + y + k) >= s {
                ans = ans + 1;
            }
        }
    }

    //assert_eq!(ans, 6);
    println!("{}", ans);
}

Measured memory_bytes: 4352
# coding:utf-8

INF = float('inf')


def inpl(): return list(map(int, input().split()))


N, L = inpl()
A = inpl()

tmp = 0
connect = False
knot = None
for i in range(N):
    if A[i] >= L:
        knots = i
        break

if knot is None:
    for i in range(N - 1):
        if sum(A[i:i + 2]) >= L:
            knot = i
            connect = True
            break

if knot is None:
    print('Impossible')
else:
    print('Possible')
    for i in range(N - 1):
        if i == knot:
            break
        else:
            print(i + 1)

    for i in range(N - 2, -1, -1):
        if i == knot:
            break
        else:
            print(i + 1)
    if connect:
        print(knot + 1)


Measured memory_bytes: 14400
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll q;
    cin >> q;
    rep(t,q){
        ll n,ans=0;
        cin >> n;
        vl k(n),l(n),r(n);
        vector<P> a,b;
        rep(i,n){
            cin >> k[i] >> l[i] >> r[i];
            ans+=min(l[i],r[i]);
            if(l[i]>r[i]){
                a.pb({k[i],l[i]-r[i]});//小さい順にみてく
            }
            if(l[i]<r[i]){
                b.pb({n-k[i],r[i]-l[i]});
            }
        }
        sort(a.begin(),a.end());
        sort(b.begin(),b.end());
        priority_queue<ll,vector<ll>,greater<ll>> ppq,mpq;
        rep(i,(ll)a.size()){
            ppq.push(a[i].second);
            while(a[i].first<ppq.size()){
                ppq.pop();
            }
        }
        while(ppq.size()){
            ans+=ppq.top();
            ppq.pop();
        }
        rep(i,(ll)b.size()){
            mpq.push(b[i].second);
            while(b[i].first<mpq.size()){
                mpq.pop();
            }
        }
        while(mpq.size()){
            ans+=mpq.top();
            mpq.pop();
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 13664
#include <stdio.h>

int main() {
    int a[3];
    scanf("%d%d%d", &a[0], &a[1], &a[2]);

    int max = 0;
    int index = 0;
    for (int i = 0; i < 3; i++) {
        if (max < a[i]) {
            max = a[i];
            index = i;
        }
    }

    int ans = 0;
    for (int i = 0; i < 3; i++) {
        if (i == index) {
            ans += a[i] * 10;
        } else {
            ans += a[i];
        }
    }

    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 128
import sys
def main():
    N,K=tuple(map(int,sys.stdin.readline().split()))
    C=[0 for _ in [0]*N]
    for _ in [0]*K:
        d=int(sys.stdin.readline())
        A=list(map(lambda x:int(x)-1,sys.stdin.readline().split()))
        for a in A:C[a]+=1
    print(C.count(0))
if __name__=='__main__':main()

Measured memory_bytes: 9116
def dist(a,b,size)
    ret = (0...size).map{|i|(a[i]-b[i])**2}.inject(:+)
    return Math.sqrt(ret)
end

n,d=gets.split.map &:to_i
x=[]
n.times{x<<gets.split.map(&:to_i)}
cnt=0
for i in 0...n
    for j in i+1...n
        dis=dist(x[i],x[j],d)
        if dis==dis.to_i
            cnt = cnt + 1
        end
    end
end
p cnt


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

int main(){
	vector<int> a(3);
	cin >> a[0] >> a[1] >> a[2];
	sort(a.begin(), a.end());
	cout << a[1]-a[0] + a[2] -a[1] <<endl;
	return 0;

}




Measured memory_bytes: 256
s = input()
t = input()
ls, lt = map(len, [s, t])
for i in range(lt-1, ls)[::-1]:
    if ls < lt:
        break
    flag = 0
    for j in range(lt):
        if s[i-j] == "?":
            continue
        elif s[i-j] != t[lt-1-j]:
            flag = 1
            break
    if flag == 0:
        s = s.replace("?", "a")
        print(s[:i-lt+1]+t+s[i+1:])
        exit()
print("UNRESTORABLE")



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ‘ ‘
const ll mei = (ll)1e9 + 7;

int main(){
  ll n;
  cin >> n;
  cout << n * (n - 1) / 2;
  memi;
}

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

int main()
{
	int n,k;
   cin >> n >> k;
   vector<int> a(n);
   for(auto &i:a)cin >> i;
   for(int i = 0 ;i<k;i++)
   {
      vector<int> b(n+1,0);
      for(int j = 0;j<n;j++)
      {
         int l = max(0,j-a[j]);
         int r = min(n-1,j+a[j]);
         r++;
         b[l]++;
         b[r]--;
      }
      bool flg = true;
      for(int j = 0;j<n;j++)
      {
         b[j+1]+=b[j];
         a[j]= b[j];
         //cout<<a[j]<<' ';
         if(a[j]!=n)flg=false;
      }
      if(flg)break;
      //cout<<endl;
   }
   for(auto &i:a)cout<<i<<' ';cout<<endl;
}

Measured memory_bytes: 4844
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		int n = in.nextInt();
        int nam[] = new int[n];
      
      for(int i = 0 ;i < n ;i++){
       nam[i] =  in.nextInt();
      }
      Arrays.sort(nam);
     
      if(nam[(n/2)-1]==nam[n/2]){System.out.print(0);}
      else{System.out.print(nam[n/2]-nam[(n/2)-1]);}
      
      
      
	}
}

Measured memory_bytes: 50940
import itertools as itt
def resolve():
    N,M,X = map(int,input().split())
    CA = [list(map(int,input().split())) for i in range(N)]
    mxc = float('inf')
    for r in range(N+1):
        for cmb in itt.combinations(CA,r):
            cost = 0
            tbl = [0]*M
            for x in cmb:
                cost+=x[0]
                for i in range(M):
                    tbl[i]+= x[i+1]

            for i in tbl:
                if i < X:
                    break
            else:
                mxc = min(cost,mxc)
                
    if mxc == float('inf'):
        print(-1)
    else:
        print(mxc)



if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9216
N = int(input())
D = [int(i) for i in input().split()]
count = [0]*N
max_n = 0

for elem in D:
    count[elem] += 1
    if elem > max_n:
        max_n=elem

ans=1
if count[0] == 1 and D[0] == 0:
    for i in range(1,max_n+1):
        ans = (ans*((count[i-1])**count[i]))%998244353
else:
    ans = 0

print(ans%998244353)

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;


// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, m, y, k;
string s, t;

// <------------- Implement Functions Here ----------> //


// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n;
	set<ll> val;
	ll cou =1;
	while(val.count(n) == 0) {
		val.insert(n);
		if(n&1) n = 3*n+1;
		else n/=2;
		cou++;
	}
	cout<<cou;
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 3652
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <stack>
#include <queue>
#include <numeric>
#include <cstring>

#define REP(i, a, b) for(i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)

using namespace std;

int main(){
    int i, j;
    int H, W;
    vector<string> f;
    vector< vector< int > > dp;
    
    cin >> H >> W;
    f.resize(H);
    dp.resize(H);
    rep(i, H){cin >> f[i]; dp[i].resize(W);}

    
    rep(i, H)rep(j, W){
        if(i == 0 && j == 0){
            dp[i][j] = f[i][j] - '0';
        }else if(i == 0){
            dp[i][j] = dp[i][j-1] + (f[i][j-1] - '0');
        }else if(j == 0){
            dp[i][j] = dp[i-1][j] + (f[i-1][j] - '0');
        }else{
            dp[i][j] = min(dp[i-1][j] + (f[i-1][j]-'0'), dp[i][j-1] + (f[i][j-1]-'0'));
        }
    }
    cout << dp[H-1][W-1] << endl;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int main(){
  long int N,M,k,l;
  cin>>N>>M;
  char s[N],t[M];
  long int LCM,gameover=0;
  for(int i=0;i<N;i++)
  {
    cin>>s[i];
  }
  for(int i=0;i<M;i++)
  {
    cin>>t[i];
  }
  if(M>=N){
  k=M;
  l=N;
}else {
  k=N;
  l=M;
  }
  while(k!=0&&l!=0){
    if(k>=l){
      k=k%l;
    }else{
      l=l%k;
    }
    }
    if(k==0){
      LCM=l;
    }else{
      LCM=k;
    }
if(M==LCM&&N==LCM){
  for(int i=0;i<M;i++){
    if(s[i]!=t[i]){
      gameover=1;
      break;
    }
  }
}else if(M==LCM){
  for(int i=0;i<M;i++){
    if(s[i*(N/M)]!=t[i]){
      gameover=1;
      break;
  }
}
}else if(N==LCM){
      for(int i=0;i<N;i++){
        if(s[i]!=t[i*(M/N)]){
          gameover=1;
          break;
      }
    }

  }else {
    int N2=N/LCM; int M2=M/LCM;
    for(int i=0;i*N2<N&&i*M2<M;++i){
      if(s[i*N2]!=t[i*M2]){
        gameover=1;
      }
    }
    //if(s[0]!=t[0]){
    //  gameover=1;
    //}
  }
  if(gameover==1){
    std::cout<<-1<<std::endl;
  }else{
    std::cout<<M*N/LCM<<std::endl;
  }
}


Measured memory_bytes: 384
# SPDX-License-Identifier: X11
# 2020-08-30
# Forbidden List (300pt)

function main()
  X, N = parse.(Int, split(readline(), " "))

  if N == 0
    println(X)
    return
  end

  P = parse.(Int, split(readline(), " "))
  for i ∈ 0:cld(N, 2)
    if X - i ∉ P
      println(X - i)
      return
    elseif X + i ∉ P
      println(X + i)
      return
    end
  end
end

main()


Measured memory_bytes: 174952
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	s := getString()
	if s[len(s)-1] == 's' {
		out(s + "es")
		return
	}
	out(s + "s")
}


Measured memory_bytes: 1776
#include<iostream>  
  
using namespace std;  
  
  
int coordinate[8][2] = {-1,0, -1,1, 0,1, 1,1, 1,0, 1,-1, 0,-1, -1,-1};  
  
int count(int x, int y, int a[100][100], int row, int column);  
  
int main()  
{  
    int number = 0;           
    int row = 1;           
    int column = 1;           
    int mineSweeper[100][100];  
    char symbol = '.';        
  
    while (cin >> row >> column)  
    {  
        if ((row == 0) || (column == 0))
        {  
            break;  
        }  
  
        //初始化数组  
        for (int i=0; i<100; i++)  
        {  
            for (int j=0; j<100; j++)  
            {  
                mineSweeper[i][j] = -1;  
            }  
        }  
  
      
        for (int i=0; i<row; i++)  
        {  
            for (int j=0; j<column; j++)  
            {  
                cin >> symbol; 
  
                if (symbol == '.')  
                {  
                    mineSweeper[i][j] = 0; 
                }  
            }  
        }  
  
        if (number > 0) 
        {  
            cout << endl;  
        }  
        number++;  
  
      
        for (int i=0; i<row; i++)  
        {  
            for (int j=0; j<column; j++)  
            {  
                if (mineSweeper[i][j] == -1) 
                {  
                    cout << '#';  
                }  
                else  
                {  
                    cout << count(i, j, mineSweeper, row, column);  
                }  
            }  
  
            cout << endl;  
        }  
    }  
  
    return 0;  
}  
  
int count(int x, int y, int a[100][100], int row, int column)  
{  
    int num = 0;  
    int xc = 0;   
    int yc = 0;   
  
   
    for (int i=0; i<8; i++)  
    {  
        xc = x + coordinate[i][0];  
        yc = y + coordinate[i][1];  
  
     
        if ((xc >= 0) && (xc < row) && (yc >= 0) && (yc < column))  
        {  
            if (a[xc][yc] == -1)  
            {  
                num ++;   
            }  
        }  
    }  
  
    return num;  
}  

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

int main(){
  long n;  cin >> n;
  vector<long> a(n);
  long maxi = 0;

  for(int i=0; i<n; i++){
    cin >> a[i];
    maxi = max(maxi, a[i]);
  }

  sort(a.begin(), a.end());
  int s = 0;
  while(a[s]*2 < maxi)  s++;
  
  cout << maxi << " ";
  if(min(a[s], maxi-a[s]) > min(a[s-1], maxi-a[s-1]))
    cout << a[s] << endl;
  else
    cout << a[s-1] << endl;
  
  return 0;
}


Measured memory_bytes: 4032
// AOJ 1169 The Most Powerful Spell
// 2018.4.17 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define QMAX 2500
typedef struct { char s; short t; char *lab; } QUE;
QUE que[QMAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int s, int t, char *lab)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].s = s, que[i].t = t, que[i].lab = lab;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

// バッファ入力から数値を得る
char buf[20], *p;
int in()
{
	int n = 0;
	while (*p >= '0') n = 10*n + (*p++ & 0xf);
	p++;
	return n;
}

char hi[42], to[42][42];
char w[42][42]; char lab[42][42][8];
char dist[42][510][510];
char *str, *ans; char tmp[510];

char *dijkstra(int n, int start, int goal)
{
	int  i, s, e, t, nt;

	for (s = 0; s < n; s++) for (i = 0; i < 350; i++) {
		dist[s][i][0] = 0x7e, dist[s][i][1] = 0;
	}
	qsize = 0;
	dist[start][0][0] = 0, enq(start, 0, dist[start][0]);
	while (qsize) {
		s = que[0].s, t = que[0].t, str = que[0].lab, deq();
		if (t > 350) continue;
		if (strcmp(dist[s][t], str) < 0) continue;
		for (i = 0; i < hi[s]; i++) {
			e = to[s][i], nt = t + w[s][i];
			memcpy(tmp, str, t), memcpy(tmp+t, lab[s][i], w[s][i]), tmp[nt] = 0;
			if (strcmp(dist[e][nt], tmp) > 0) {
				memcpy(dist[e][nt], tmp, nt+1);
				enq(e, nt, dist[e][nt]);
			}
		}
	}
	tmp[0] = 0x7e, tmp[1] = 0, ans = tmp;
	for (i = 0; i < 350; i++) {
		if (strcmp(ans, dist[goal][i]) > 0) {
			if (i > 250) return NULL;
			ans = dist[goal][i];
		}
	}
	if (*ans == 0x7e) return NULL;
	return ans;
}

int main()
{
	int n, a, s, g, k, x, y;
	char *q;

	while (fgets(p=buf, 20, stdin) && *p != '0') {
		n = in(), a = in(), s = in(), g = in();
		memset(hi, 0, sizeof(hi));
		while (a--) {
			fgets(p=buf, 20, stdin);
			x = in(), y = in();
			k = hi[x]++;
			to[x][k] = y;
			q = lab[x][k]; while (*p > ' ') *q++ = *p++; *q = 0;
			w[x][k] = q - lab[x][k];
		}

		if ((q = dijkstra(n, s, g)) == NULL) puts("NO");
		else puts(q);
	}
	return 0;
}


Measured memory_bytes: 8700
#include <bits/stdc++.h>
using namespace std;
//using lint = long long;

struct P
{
    int x;
    long long y;

    bool operator<(const P &a)const{
        if(x!=a.x)
              return x>a.x;
        return y>a.y;
    }

};

vector<int> v[111111],v1;

//bitset<4001000> b;
int i,n,d,m,k,a,b,c,h;

int o[111111];
int l[111115];
int j[111115];
int e[111111];


//int dx[10]={2,2,-2,-2,1,1,-1,-1},dy[10]={1,-1,1,-1,2,-2,2,-2};

int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={1,0,-1,0,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};
long long mod=1000000007,mod2=1000000009,mod3=2017;
long long x,z,y;
double pi=3.14159265;
P u[311111];
stack<int> s;
//set<int> s[222][22];
//priority_queue<int> q;
queue<int> q;
//2147483647
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
map<int,int> p;
/*
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
unordered_map<long long, int, custom_hash> safe_map;
*/
//list<int> l;

string r;
//char r[2];
//deque<int> de;
//srand((int)time(NULL));
/*bool as(P a,P b)
{
    if(a.x!=b.x)
    return a.x<b.x;
    return a.y<b.y;
}*/



bool as(P a,P b)
{
    if(a.x!=b.x)
        return a.x<b.x;
    return a.y<b.y;

}


int main()
{
    scanf("%d",&a);
    o[0]=1987654321;
    for(int t=1;t<=a;t++)
        scanf("%d",&o[t]);
    for(int t=2;t<=a;t++)
        l[t]=min(l[t-1]+max(o[t]-o[t-1],o[t-1]-o[t]),l[t-2]+max(o[t-2]-o[t],o[t]-o[t-2]));
    printf("%d",l[a]);
}





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

int main(){
    int N, W; cin>>N>>W;
    int w[N], v[N];
    rep(i, N) cin>>w[i]>>v[i];

    long dp[N+1][W+1];
    rep(i, W+1) dp[0][i] = 0;

    for(int i=0; i<N; i++){
        for(int j=0; j<=W; j++){
            if(w[i] <= j) dp[i+1][j] = max(dp[i][j-w[i]] + v[i], dp[i][j]);
            else dp[i+1][j] = dp[i][j];
        }
    }

    cout << dp[N][W] << endl;
}


Measured memory_bytes: 82440
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    long long A, B, C; cin >> A >> B >> C;
    rrep (i, 0, A) {
        if ((i*B+C)%A == 0) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/**
********************************************************************
******************* Author:Bisnu sarkar ****************************
********************************************************************
**/
#define ull            unsigned long long
#define ll             long long
#define vi             vector<int>
#define pb             push_back
#define mp             make_pair
#define pii            pair<int,int>
#define vit            vector<int> :: iterator
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';
#define what_is(x)     cerr << #x << " is " << x << endl;
///*....Debugger....*/
#define error(args...) {vector <string> _v = split(#args, ','); err(_v.begin(), args); cout << endl;}
vector <string> split(const string &s, char c) {
    vector <string> v;
    stringstream ss(s); string x;
    while (getline(ss, x, c)) v.emplace_back(x);
    return move(v);
}
void err(vector <string> :: iterator it) {}
template <typename T, typename... Args>
void err(vector <string> :: iterator it, T a, Args... args) {
    cout << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", ";
    err(++it, args...);
}
 
int ini(){int x; scanf("%d",&x);return x;}
long long inl(){ long long x;scanf("%lld",&x); return x;}
double ind(){double x; scanf("%lf",&x);return x;}
#define Iin ini();
#define Lin inl();
#define Din ind();

int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;

int a[N];

int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    int t=1,te=0;
  //  cin>>t;
    while(t--){
        string s;
        cin>>s;
        int sz=(int)s.size();
        int i=1,j=(sz-1)/2;

        for( ;i<j;++i,--j){
            if(s[i-1]!=s[j-1]){
                printf("No\n");
                return 0;
            }
        }

        i=((sz+3)/2),j=sz;

        for( ;i<j;++i,--j){
            if(s[i-1]!=s[j-1]){
                 printf("No\n");
                return 0;
            }
        }
        i=1,j=sz;
         for( ;i<j;++i,--j){
            if(s[i-1]!=s[j-1]){
                 printf("No\n");
                return 0;
            }
        }

        printf("Yes\n");

        //printf("Case %d: ",++te);
    }
    return 0;
}




Measured memory_bytes: 256