akhauriyash/Code-Regression huggingface dataset:
n, m, *XY = map(int, open(0).read().split())
A = [1] * n
B = [0] * n
B[0] = 1
for x, y in zip(XY[::2], XY[1::2]):
  x, y = x-1, y-1
  A[x] -= 1
  A[y] += 1
  if B[x]:
    B[y] = 1
  if A[x] == 0:
    B[x] = 0
print(sum(B))

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

int main(){
    int a,b,c,sum,ans = 0,X;
    cin >> a >> b>>c; 
    cin >> X;

    for(int i1 = 0 ; i1 <=a;i1++){
        for(int i2 = 0 ; i2 <=b;i2++){
            for(int i3 = 0; i3 <=c;i3++){
                sum = i1* 500 + i2*100 + i3*50;
                if(sum == X) ans++;
            }
        }
    }

    cout << ans;
}

Measured memory_bytes: 256
n=int(input())
c=[[0]*10 for _ in range(10)]
for i in range(1,n+1):
    s=str(i)
    c[int(s[0])][int(s[-1])]+=1
ans=0

for i in range(10):
    for j in range(10):
        ans+=c[i][j]*c[j][i]
print(ans)


Measured memory_bytes: 40428
s = input()
ok = True

ok &= s[0] == 'A'
ok &= s[1].islower()
ok &= s[2:-1].count('C') == 1
ok &= all(c.islower() for c in s[2:-1] if c != 'C')
ok &= s[-1].islower()

print('AC' if ok else 'WA')


Measured memory_bytes: 3060
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
using namespace std;
const int N=5e5+10;
int cnt[N],ans[N],a[N];
int n,q,bl;
int res;
struct node
{
    int l,r,p;

}e[N];
bool cmp(const node &a,const node &b)
{
    return (a.l/bl)==(b.l/bl) ? a.r<b.r :a.l>b.l;
}
void remove(int x)
{
    if((--cnt[a[x]])==0) res--;
}
void add(int x)
{
    if((++cnt[a[x]])==1) res++;
}
int main()
{
    scanf("%d %d",&n,&q);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
     bl=sqrt(n);
    for(int i=1,l,r;i<=q;i++)
    {
        scanf("%d %d",&l,&r);
        e[i]={l,r,i};
    }
  //  cout<<"--------------"<<endl;

    sort(e+1,e+1+q,cmp);
   // cout<<"*****"<<endl;
    res=0;
    int curL=1,curR=0;
    for(int i=1;i<=q;i++)
    {
        //cout<<i<<endl;
        int L=e[i].l,R=e[i].r;
        while(curL<L) remove(curL++);
        while(curL>L) add(--curL);
        while(curR<R) add(++curR);
        while(curR>R) remove(curR--);
        ans[e[i].p]=res;
    }
    for(int i=1;i<=q;i++) printf("%d\n",ans[i]);

}


Measured memory_bytes: 15416
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	ll n;
	cin >> n;
	if(n == 0) {
		cout << 0 << endl;
		return 0;
	}

	string ans = "";
	ll base = 1;
	ll i = 0;
	while(n != 0) {
		if(n % (2 * base) == 0) {
			ans = '0' + ans;
		} else {
			ans = '1' + ans;
			n -= base;
		}
		i += 1;
		base *= -2;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <map>
#include <cstdlib>
#include <cctype>
#include <ctype.h>
#define ll long long
char toupper(char c);
char toupper(char c)
{
    return (c - 0x20);
}
using namespace std;
int main()
{
    char a, d;
    cin >> a >> d;
    if (a == d)
    {
        cout << "H" << endl;
    }
    else
    {
        cout << "D" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		int[][] card = new int[4][13];
		String[] card_symbol = { "S" , "H" , "C" , "D" };
		String in_symbol="";
		int in_num=0;

    	//初期化
    	for( int i = 0 ; i < card.length ; i++ ) {
    		for ( int j = 0 ; j < card[i].length ; j++ ) {
    			card[i][j] = 0;
    		}

    	}

    	Scanner sc= new Scanner( System.in );
    	int card_num = 0;
    	card_num = sc.nextInt();


    	for ( int i = 0 ; i < card_num ; i++ ) {
    		in_symbol = sc.next();
    		in_num = sc.nextInt();

        	switch( in_symbol ) {
        		case "S":
        			card[0][in_num-1] = 1;
        			break;
        		case "H":
        			card[1][in_num-1] = 1;
        			break;
        		case "C":
        			card[2][in_num-1] = 1;
        			break;
        		case "D":
        			card[3][in_num-1] = 1;
        			break;
        	}
    	}

    	for( int i = 0 ; i < card.length ; i++ ) {
    		for ( int j = 0 ; j < card[i].length ; j++ ) {
    			if( card[i][j] == 0 ) {
    				System.out.println( card_symbol[i] + " " + ( j + 1 ) );
    			}
    		}
    	}
    	sc.close();
	}
}


Measured memory_bytes: 26468
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt();
		sc.close();
		int ans = 0;
		String err = "IMPOSSIBLE";
		boolean error = false;
		if(a != b) {
			if(a % 2 != b % 2) {
				error = true;
				System.out.println(err);
			}
			ans = (a + b) / 2;
		}
		if(!error)
		System.out.println(ans);
	}
}


Measured memory_bytes: 22612
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#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 complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	int l; cin >> l;
    int now = 1, n = 1;
    while(now * 2 <= l) {
        now *= 2;
        ++ n;
    }
    int m = 2 * (n - 1) + __builtin_popcount(l) - 1;
    cout << n << " " << m << endl;
    int s = 0;
    rep(i, (n - 1)) {
        cout << i + 1 << " " << i + 2 << " " << 0 << endl;
        cout << i + 1 << " " << i + 2 << " " << (1<<i) << endl;
        s += (1<<i);
    }
    per(i, (n - 1)) {
        if(l & (1<<i)) {
            cout << i + 1 << " " << n << " " << s + 1 << endl;
            s += (1<<i);
        }
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6+10;
#define eps 1e-9

int main(){
	int a, b;
	cin >> a >> b;
	if(a > 0 && b > 0)printf("Positive\n");
	else if(a < 0 && b < 0){
		a = abs(a);
		b = abs(b);
		int cnt = (a-b) + 1;
		if(cnt&1)printf("Negative\n");
		else printf("Positive\n");
	}else printf("Zero\n");
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  const string dir = "RLUD";
  const int dx[] = {1, -1, 0, 0};
  const int dy[] = {0, 0, 1, -1};
  int n;
  cin >> n;
  vector<vector<long long>> x(4), y(4);
  for (int i = 0; i < n; i++) {
    long long xin, yin;
    cin >> xin >> yin;
    char c;
    cin >> c;
    int d = dir.find(c);
    x[d].push_back(xin * 2);
    y[d].push_back(yin * 2);
  }
  vector<long long> xs, ys;
  for (int d = 0; d < 4; d++) {
    if (x[d].size()) {
      xs.push_back(*max_element(x[d].begin(), x[d].end()));
      xs.push_back(*min_element(x[d].begin(), x[d].end()));
    }
    if (y[d].size()) {
      ys.push_back(*max_element(y[d].begin(), y[d].end()));
      ys.push_back(*min_element(y[d].begin(), y[d].end()));
    }
  }
  vector<long long> time_candi;
  for (vector<long long> v : {xs, ys}) {
    for (long long i : v) {
      for (long long j : v) {
        long long dif = abs(i - j);
        time_candi.push_back(dif / 2);
        time_candi.push_back(dif);
      }
    }
  }
  const long long inf = 1 << 30;
  long long ans = 1LL << 60;
  for (long long t : time_candi) {
    long long x_min = inf, x_max = -inf;
    long long y_min = inf, y_max = -inf;
    for (int d = 0; d < 4; d++) {
      for (long long xx : x[d]) {
        x_min = min(x_min, xx + t * dx[d]);
        x_max = max(x_max, xx + t * dx[d]);
      }
      for (long long yy : y[d]) {
        y_min = min(y_min, yy + t * dy[d]);
        y_max = max(y_max, yy + t * dy[d]);
      }
    }
    ans = min(ans, (x_max - x_min) * (y_max - y_min));
  }
  cout << setprecision(20) << fixed << 1. * ans / 4 << endl;
  return 0;
}

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

int main() {
  string str; cin >> str;
  for (int i = 0; i < str.length(); i++) {
    if (str[i] == '1') cout << '9';
    else cout << '1';
  }
  cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 200000;
int is_prime[maxn+5];

int main(){
	for(int i=2; i<=maxn; i++) is_prime[i] = i;
	for(int i=2; i*i<=maxn; i++){
		if(is_prime[i] == i){
			for(int j=i; j<=maxn; j+=i) is_prime[j] = i;
		}
	}
	int x;
	cin>>x;
	while(is_prime[x]!=x) x++;
	cout<<x;
}

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




int main(){
	int N;
	cin>>N;
	int sum = 0;
	
	int V[N],C[N];
	for(int i=0;i<N;i++){
		cin>>V[i];
	}
	for(int i=0;i<N;i++){
		cin>>C[i];
	}
	
	for(int i=0;i<N;i++){
		if(V[i]>C[i])sum+=V[i]-C[i];
	}
	
	cout<<sum<<endl;
	
	
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var d = new Dictionary<string,int>();
            for(var i = 0; i < n; i++){
                var s = Console.ReadLine().Trim();
                if(d.ContainsKey(s)){
                    d[s] += 1;
                }else{
                    d.Add(s,1);
                }
            }

            var m = int.Parse(Console.ReadLine());
            for(var i = 0; i < m; i++){
                var s = Console.ReadLine().Trim();
                if(d.ContainsKey(s)){
                    d[s] -= 1;
                }else{
                    d.Add(s,-1);
                }
            }

            var minV = d.Max(x => x.Value);
            Console.WriteLine(minV >= 0 ? minV : 0);
        }
    }
}


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

ll n,rez,br;
string s;

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

    cin>>s;
    n=s.size();

    for(ll i=0;i<n;i++)
    {
        if(s[i]=='g')
        {
            if(br>0)
            {
                rez++;
                br--;
            }
            else
                br++;
        }
        else
        {
            if(br>0)
                br--;
            else
            {
                rez--;
                br++;
            }
        }
    }

    cout<<rez<<endl;

    return 0;
}


Measured memory_bytes: 3700
#include <stdio.h>
#include <inttypes.h>
#include <stdlib.h>

static int
compare_int64_t(const void *a, const void *b)
{
        if (*(int64_t *)b > *(int64_t *)a)
                return 1;
        else if (*(int64_t *)a > *(int64_t *)b)
                return -1;
        else
                return 0;
}

static int
array_count(int64_t *A, int64_t *B, int64_t *C, int X, int Y, int Z, int64_t p, int K)
{
        int ret = 0;

        for (int i = 0; i < X; i++) {
                for (int j = 0; j < Y; j++) {
                        for (int k = 0; k < Z; k++) {
                                if ((A[i] + B[j] + C[k]) >= p) {
                                        ret++;
                                        if (ret > K)
                                                return ret;
                                } else {
                                        break;
                                }
                        }
                }
        }

        return ret;
}

int
main(void)
{
        int X, Y, Z, K;

        scanf("%d %d %d %d\n", &X, &Y, &Z, &K);

        int64_t *A = malloc(X * sizeof(int64_t));
        int64_t *B = malloc(Y * sizeof(int64_t));
        int64_t *C = malloc(Z * sizeof(int64_t));

        for (int i = 0; i < X; i++) {
                scanf("%ld\n", &A[i]);
                qsort(A, i + 1, sizeof(int64_t), compare_int64_t);
        }
        for (int i = 0; i < Y; i++) {
                scanf("%ld\n", &B[i]);
                qsort(B, i + 1, sizeof(int64_t), compare_int64_t);
        }
        for (int i = 0; i < Z; i++) {
                scanf("%ld\n", &C[i]);
                qsort(C, i + 1, sizeof(int64_t), compare_int64_t);
        }

        int64_t min = A[X-1] + B[Y-1] + C[Z-1];
        int64_t max = A[0] + B[0] + C[0];
        int64_t mid;
        mid = (min + max) / 2;
        while (min <= max) {
                int count = array_count(A, B, C, X, Y, Z, mid, K);
                if (count == K)
                        break;
                if (count > K)
                        min = mid + 1;
                else
                        max = mid - 1;
                mid = (min + max) / 2;
        }

        int64_t *buf = malloc(K * sizeof(int64_t));
        int index = 0;
        for (int i = 0; i < X; i++) {
                for (int j = 0; j < Y; j++) {
                        for (int k = 0; k < Z; k++) {
                                if (mid < (A[i] + B[j] + C[k])) {
                                        buf[index] = A[i] + B[j] + C[k];
                                        qsort(buf, index + 1, sizeof(int64_t), compare_int64_t);
                                        index++;
                                        if (index >= K)
                                                goto out;
                                } else {
                                        break;
                                }
                        }
                }
        }
out:
        for (int i = 0; i < K; i++) {
                if (i < index)
                        printf("%ld\n", buf[i]);
                else
                        printf("%ld\n", mid);
        }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <list>
#include <math.h>
using namespace std;

typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007


signed main(){

	stack<char> s;
	string str;
	cin >> str;
	for (int i = 0; i < str.length(); i++){
		if (s.size()>0 && s.top() == 'S' && str[i] == 'T') s.pop();
		else
			s.push(str[i]);
	}

	cout << s.size() << endl;

	return 0;
}

Measured memory_bytes: 644
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
#include<stdio.h>
#include<cctype>
using namespace std;

int main(){
    char str[1300];
    int word = 0;
    while (1){
        char s;
        scanf("%c",&s);
        char output;
        output = s;
        if (isalpha(s)){
            if('a' <= s && s <= 'z'){
                output = toupper(s);
            }else{
                output = tolower(s);
            }
        }
        str[word] = output;
        word +=1;
        if (s == '\n'){
            break;
        }
    }
    int count = 0;
    // cout << "convert"<< endl;
    while(1){

        if (str[count] == '\n'){
            cout << '\n';
            break;
        }else{
            cout << str[count];
            count += 1;
        }
    }

    return 0;

}


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

using namespace std;
typedef long long ll;
const int MAXN = 1e5 + 5;
ll n, l, t, cnt;
ll x[MAXN], w[MAXN], nx[MAXN];
vector< ll > vec; 
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> n >> l >> t;
	for(int i = 0; i < n; i ++)
		cin >> x[i] >> w[i], w[i] --;
	for(int i = 0; i < n; i ++){
		if( w[i] )
			vec.push_back( ((x[i] - t) % l + l) % l);
		else vec.push_back( (x[i] + t) % l);
	}
	sort(vec.begin(), vec.end());
	for(int i = 0; i < n;i ++){
		if( w[i] ) cnt -= (t + l - x[i] - 1)/l;
		else cnt += (t + l - (l - x[i] + 1))/l;
	}
	while(cnt < 0) cnt += n;
	cnt %= n;
	for(int i = cnt; i < n; i ++) cout << vec[i] << endl;
	for(int i = 0; i < cnt; i ++) cout << vec[i] << endl;
	return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  for (int i = 1; i <= 1000; ++i) {
    if (floor(i*0.08) == a && floor(i*0.1) == b) {
      cout << i << endl;
      return 0;
    }
  }
  cout << "-1\n";
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	long long a,b,c;
	cin>>a>>b>>c;
	if(b-a==c-b)
	cout<<"YES"<<endl;
	else
	cout<<"NO"<<endl;
	return 0;//第二次提交同样代码，加一个注释
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

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

	vector<int64_t> v(N), d(N);
	for (int i = 0; i < N; i++) {
		int n;
		cin >> n;
		d.at(i) = n - i;
		v.at(i) = n;
	}

	sort(d.begin(), d.end());
	int64_t a = d.at(N / 2);

	int64_t ans = 0;
	for (int i = 0; i < N; i++) {
		int64_t n = i + a;
		ans += abs(v.at(i) - n);
	}

	cout << ans << endl;
}

Measured memory_bytes: 6432
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int x, y;
    cin >> x >> y;
    x--; y--;
    vector<int> grp = {0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0};
    string ans = "No";
    if (grp[x]==grp[y]) ans = "Yes";
    
    cout << ans << endl;
    return 0;
}


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

#define int long long

vector<int>v[200009];
int dp[300003];
int ans[300003];
int n , mod  , m ;

void dfs( int now , int pre ) {
  dp[now] = 1;
  r(i,v[now].size()){
    int nex = v[now][i];
    if( pre == nex )continue;
    dfs( nex , now );
    dp[now] = ( dp[now] * (dp[nex]+1) ) % mod;
  }
}

void dfs2( int now , int pre , int x ) {
  ans[now] = (dp[now]*x) %mod;

  vector<int> l , r;
  l.push_back( 1 );
  r(i,v[now].size()){
    int nex = v[now][i];
    int w = nex==pre ? 1 : dp[nex]+1 ;
    l.push_back( w );
    r.push_back( w );
  }
  r.push_back( 1 );

  for( int i = 1 ; i < l.size() ; i++ ){
    l[i] = ( l[i] * l[i-1] ) % mod;
  }

  for( int i = r.size()-2 ; i >= 0 ; i-- ){
    r[i] = ( r[i] * r[i+1] ) % mod;
  }

  for( int i = 0 ; i < v[now].size() ; i++ ){
    if( v[now][i] == pre )continue;
    dfs2( v[now][i] , now , ( (x*(l[i]*r[i+1]%mod))%mod+1) %mod );
  }

}

signed main(){
  cin>>n>>mod;

  r(i,n-1){
    int a,b;
    cin>>a>>b;a--;b--;
    v[a].push_back(b);
    v[b].push_back(a);
  }

  dfs(0,0);
  dfs2(0,0,1);

  r(i,n) cout<<ans[i]<<endl;
}

Measured memory_bytes: 29568
/**
 *    author:  Daredevil666
 *    institution: IIT Patna
**/
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define nl cout<<"\n";
#define ll long long int
#define IOS  ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
ll mod=1e9+7;
int main()
{
IOS
int x,n;
cin>>x>>n;
vector<int> p(1000);
for(int i=0;i<n;i++)
{
    int t;
    cin>>t;
    p[t]=1;
}
int i=x,j=x;
while(1)
{
    if(p[i]==0)
    {
        cout<<i;
        return 0;;
    }
    if(p[j]==0)
    {
        cout<<j;
        return 0;;
    }
    i--;
    j++;
}
return 0;
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
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++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    string s; int K; cin >> s >> K;
    
    set<string> st;
    int N = s.size();
    rep(i, N){
        rep(j, N-i+1){
            if(j > 5) break;
            st.insert(s.substr(i, j));
        }
    }
    
    auto it = st.begin();
    rep(i, K) it++;
    cout << *it << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 5760
//=template==================================================================//
// include
#include <vector>
#include <list>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>

// namespace
using namespace std;

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

// typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef long long LL;

// conversion
inline int toInt(string s) {int v; istringstream sin(s); sin>>v; return v;}
template<class T> inline string toString(T x) {ostringstream sout; sout<<x; return sout.str();}
//===========================================================================//

//=function prototype========================================================//

//===========================================================================//

//=variables=================================================================//

//===========================================================================//
int main(void)
{
  // Scan begin.
  int n;
  int a[10001];
  int i;

  cin >> n;

  FOR (i, 1, n+1) {
    cin >> a[i];
  }
  // Scan done.

  // Code begin.
  int cnt = 0;

  FOR (i, 1, n+1) {
    while (a[i]%2 == 0) {
      a[i] /= 2;
      cnt++;
    }
  }

  cout << cnt << endl;
  // Code done.

  return 0;
}

//=functions=================================================================//

//===========================================================================//

Measured memory_bytes: 256
N, D  = map(int, input().split())
X  = [list(map(int, input().split())) for i in range(N)]

ans = 0

for i in range(N):
  for j in range(i+1,N):
    Dis = 0
    for k in range(D):
      Dis += (X[i][k] - X[j][k])**2 
    Dis = (Dis)**0.5
    if int(Dis) == Dis:
      ans += 1

print(ans)

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


int main() {
    int x,n,a;
    cin>>x>>n;
    if(n==0){
        cout<<x;
        return 0;
    }
    vector<int> p(n);
    rep(i,n)cin>>p[i];
    vector<int> pm={-1,1};
    for(int i=0;i<102;i++){
        for(int s:pm){
            a=x+s*i;
            if(count(p.begin(),p.end(),a)==0){
                cout<<a<<endl;
                return 0;
            }
        }
    }
    return 0;
}

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

long long a[100100];
long long sum,dif[100100];
long long mx,sum2;
long long k,cou;

main()
{
	long long n;
	scanf("%lld",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
		sum+=a[i];
	}//*
	if(sum%((n*(n+1))/2)!=0)
	{
		printf("NO\n");
		return 0;
	}
	k=sum/((n*(n+1))/2);
	//*/
	a[n]=a[0];
	n++;
	for(int i=0;i<n-1;i++)
	{
		dif[i]=a[i+1]-a[i];
		//printf("%lld ",dif[i]);
		mx=max(mx,dif[i]);
		sum2+=dif[i];
	}
	if(sum2!=0)
	{
		printf("NO\n");
		return 0;
	}
	//printf("\n");
	n--;
	for(int i=0;i<n;i++)
	{
		//printf("%lld %lld\n",dif[i],k-dif[i]);
		if(k-dif[i]<0)
		{
			printf("NO\n");
			return 0;
		}
		if((k-dif[i])%n!=0)
		{
			printf("NO\n");
			return 0;
		}//*
		else
		{
			cou+=((k-dif[i])/n);
			//printf("%lld\n",(mx-dif[i])/n);
		}//
	}
	//*
	//printf("%lld %lld\n",cou,mx);
	if(cou!=k)
	{
		printf("NO\n");
		return 0;
	}//*/
	printf("YES\n");
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
 // #include <ext/pb_ds/tree_policy.hpp>
 // #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
  using namespace std;
   using namespace std::chrono;      
  // using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
 #define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        1e18
 #define sm         -2e18
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;
#define MEM(x,val) memset(x,val,sizeof(x))

 // typedef tree<pii, null_type, less<pii>, rb_tree_tag,  
 //            tree_order_statistics_node_update>  odst; 


void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("gin.txt", "r", stdin);
   // freopen("output.txt", "w", stdout);
   
    #endif
}
vector<vii> gp;
int com ;
vii vis;

void dfs(int i)
{
  com++;
  vis[i]=1;
  for(auto x:gp[i])
    if(!vis[x])
    {
      dfs(x);
    }
}
void solve()
{
  
  int n,m;
  cin >> n >> m ;
  

  gp.assign(n+1,vii());
  vis.assign(n+1,0);

  forf(i,0,m)
  {
    int u,v;
    cin >> u >> v;
    gp[u].push_back(v);
    gp[v].push_back(u);
  }

  int an = 0;
  
  forf(i,1,n+1)
  if(!vis[i])
  {
      com=0;
      dfs(i);
      an = max(an,com);
  }

  cout<<an;

}

int32_t main()
{
  pr_init();
  fastio;
  auto start = high_resolution_clock::now(); 
  solve(); 
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
  
    // cout << "Time taken by function: "
    //      << duration.count() << " microseconds" << endl; 

  return 0;
}

Measured memory_bytes: 21980
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <set>
#include <string>
#include <map>

using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main() {
    int a,b,c; cin >> a >>b >> c;
    if(a+b+c>=22) {
        cout << "bust" << endl;
    } else {
        cout << "win" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INFLL (0x3f3f3f3f3f3f3f3fll)
using namespace std;
typedef long long ll;

const int MAXN = 500055;

ll A[MAXN], B[MAXN], C[MAXN];

ll L;
int N, Q;

int main() {
	ios::sync_with_stdio(false);

	cin >> N >> L;
	for(int i = 1; i <= N; i++) cin >> A[i];

	for(int i = N; i; i--) {
		if(A[i] <= B[i+1]*2+1) B[i] = B[i+1] + A[i];
		else B[i] = B[i+1];
	}

	C[0] = L;
	for(int i = 1; i <= N; i++)
		C[i] = min(C[i-1], abs(C[i-1]-A[i]));

	cin >> Q;
	for(int i; Q--;) {
		cin >> i;
		puts(C[i-1] <= B[i+1] ? "NO" : "YES");
	}
	return 0;
}

Measured memory_bytes: 13696
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;

int main() {
    int x,y,z; cin >> x >> y >> z;
    int sum = 0;
    int hito = 0;

    while (sum < x - z){
        sum += y + z;
        hito++;
    }
    if(sum <= x - z)print(hito);
    else print( hito - 1);
}

Measured memory_bytes: 256
import copy

class Card():
    def __init__(self, str):
        self.id = str
        self.sort = str[0]
        self.value = int(str[1])


def selectionSort(A, N):
    for i in range(N-1):
        minj = i
        for j in range(i, N):
            if A[j].value < A[minj].value:
                minj = j
        if i != minj:
            temp = A[i]
            A[i] = A[minj]
            A[minj] = temp

def bubbleSort(l, n):
    flag = 1
    while flag:
        flag = 0
        for i in range(n-1, 0, -1):
            if l[i].value < l[i-1].value:
                temp = l[i]
                l[i] = l[i-1]
                l[i-1] = temp
                flag = 1

def isStable(input, output, N):
    for i in range(N-1):
        for j in range(i+1, N):
            for a in range(N-1):
                for b in range(a+1, N):
                    if input[i].value == input[j].value and input[i] == output[b] and input[j] == output[a]:
                        return False
    return True

N = int(input())
A = list(map(Card, input().split()))
A_b = copy.copy(A)
A_s = copy.copy(A)

bubbleSort(A_b, N)
print(" ".join(map(lambda x: x.id, A_b)))
if isStable(A, A_b, N):
    print("Stable")
else:
    print("Not stable")

selectionSort(A_s, N)
print(" ".join(map(lambda x: x.id, A_s)))
if isStable(A, A_s, N):
    print("Stable")
else:
    print("Not stable")



Measured memory_bytes: 6344
//package ABC167;
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		
		int n=sc.nextInt();
		long k=sc.nextLong();
		
		int[] a=new int[n];
		long[] check=new long[n];
		
		for(int i=0;i<n;i++){
			a[i]=sc.nextInt();
		}
		
		ArrayList<Integer> list=new ArrayList<>();
		int cur=1;
		long rec=1;
		list.add(1);
		check[0]=1;
		while(true){
			if(rec==k){
				System.out.println(a[cur-1]);
				System.exit(0);
			}
			if(check[cur-1]>1){
				long prev=check[cur-1];
				int hoge=(int)((k-prev+1)%(rec-prev));
				int ans=list.get((int)(prev+hoge-1));
				System.out.println(ans);
				System.exit(0);
			}
			else {
				check[cur-1]=rec;
				cur=a[cur-1];
				rec++;
				list.add(cur);
				//System.out.println(cur);
			}
		}
		
		
		
	}

}


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

#define lint long long
#define all(it) it.begin(), it.end()
#define FOR(i, n) for(int i = 0; i < n; i++)
#define FORU(i, a, b, s) for(int i = a; i < b; i += s)
#define FORD(i, a, b, s) for(int i = a; i > b; i -= s)
#define endl "\n"
lint INF = 2e18;
lint MOD = 1e9 + 7;

int i, j, k, t;

pair<int, int> div(lint n) {
    pair<int, int> ret = {0, 0};
    while(true) {
        if(n % 2 == 0) {
            ret.first += 1;
            n /= 2;
        } else if(n % 5 == 0) {
            ret.second += 1;
            n /= 5;
        } else {
            break;
        }
    }
    return ret;
}

int main() {

    int N;
    cin >> N;

    map<pair<int, int>, int> count25;

    FOR(i, N) {
        string s;
        cin >> s;

        string g;
        if(count(s.begin(), s.end(), '.') != 0) {
            while(s.back() != '.') {
                g.push_back(s.back());
                s.pop_back();
            }
            s.pop_back();
            reverse(g.begin(), g.end());
        }
        while((int)g.length() < 9)
            g.push_back('0');

        lint x = stoi(s) * 1000000000LL + stoi(g);
        count25[div(x)] += 1;
    }

    vector<pair<int, int>> keys;
    for(const auto &it : count25) {
        keys.emplace_back(it.first);
    }

    lint ans = 0;
    for(auto &k1 : keys) {
        for(auto &k2 : keys) {
            if(k1.first + k2.first >= 18 && k1.second + k2.second >= 18) {
                if(k1.first == k2.first && k1.second == k2.second) {
                    ans += (lint)count25[k1] * (count25[k1] - 1);
                } else {
                    ans += (lint)count25[k1] * count25[k2];
                }
            }
        }
    }
    ans /= 2;
    cout << ans << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ARB ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define bp  __builtin_popcount
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int maxn=1e5+5;
const  double EPS = 1e-14;

int main()
{
    ARB
    int N;
    ll Y;
    cin>>N>>Y;
    int x=-1,y=-1,z=-1;
    for(int i = 0; i <=N; i++)
    {
        for(int j = 0; i+j <=N; j++)
        {
            if(1000*(N-i-j) == Y - 5000*j - 10000*i)
            {
                x = i;
                y = j;
                z = N -i-j;
            }
        }
    }
    cout << x << " " << y << " " << z << endl;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long int h,n;
     cin>>h>>n;

      long long int arr[n];

           long long int sum=0;
           
        for(int i=0;i<n;i++)
          {
               cin>>arr[i];
               sum+=arr[i];
          }

        if(sum >= h)
        cout<<"Yes";

          else
          cout<<"No";
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cassert>
using namespace std;
inline int read(){
	int re=0,flag=1;char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-') flag=-1;
		ch=getchar();
	}
	while(isdigit(ch)) re=(re<<1)+(re<<3)+ch-'0',ch=getchar();
	return re*flag;
}
int n,h,in[1010],f[1010],v[1010],vis[1010];
int find(int x){return ((f[x]==x)?x:(f[x]=find(f[x])));}
int main(){
	n=read();h=read();int i,a,b,c,d,l,r;
	for(i=1;i<=1000;i++) f[i]=i;
	for(i=1;i<=n;i++){
		a=read();b=read();c=read();d=read();
		if(c) l=-c;
		else l=a;
		if(d) r=d;
		else r=-b;
		l+=500;r+=500;
		f[find(l)]=find(r);
		in[l]++;in[r]--;vis[l]=vis[r]=1;
//		cout<<"addedge "<<l<<' '<<r<<' '<<in[l]<<' '<<in[r]<<' '<<find(l)<<' '<<find(r)<<'\n';
	}
	for(i=1;i<500;i++) if(in[i]>0){puts("NO");return 0;}
	for(i=501;i<=1000;i++) if(in[i]<0){puts("NO");return 0;}
	for(i=1;i<=1000;i++) v[i]=(in[i]!=0);
	for(i=1;i<=1000;i++) v[find(i)]|=v[i];
	for(i=1;i<=1000;i++) if(i==find(i)&&vis[i]&&(!v[i])){puts("NO");return 0;}
	puts("YES");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
   
using namespace std;
#define pb push_back
#define int long long


int32_t main()
{
	ios::sync_with_stdio(false);
    cin.tie(NULL);

    unordered_map<int,int> m1;
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
        m1[arr[i]]++;
    }
    int sum=0;
    for(auto x:m1){
        int f1=x.second;
        int a1=(f1*(f1-1))/2;
        sum+=a1;
    }
    
    for(int i=0;i<n;i++){
        int a1=sum-(m1[arr[i]]-1);
        cout<<a1<<" ";
    }
    
   
    
    
   
}

Measured memory_bytes: 9160
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n,max=0,xx=0;
    char s;
    cin>>n;
    for(int i=1; i<=n; ++i) {
        cin>>s;
        if(s=='I') {
            ++xx;
            if(xx>max) {
                ++max;
            }
        } else {
            --xx;
        }
    }
    cout<<max<<'\n';
	return 0;
}

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

int main()
{
    /*A
    string s;
    cin>>s;
    if(s=="AAA" || s=="BBB")
    {
        cout<<"No"<<endl;
    }
    else
    {
        cout<<"Yes"<<endl;
    }
    */
   /*B
    ll n,a,b;
    cin>>n>>a>>b;
    ll count=0;
    if(a==0)
    {
       cout<<0<<endl;
       return 0;
    }
    else if(n%(a+b)==0)
    {
        count = (n/(a+b))*a;
        cout<<count<<endl;
        return 0;
    }
    else
    {
        if(n%(a+b)<=a)
        {
            count=(n/(a+b))*a+n%(a+b);
            cout<<count<<endl;
            return 0;
        }
        else
        {
            count =  (n/(a+b))*a+a;
            cout<<count<<endl;
            return 0;
        }
    }

    cout<<count<<endl;
    */
    /*C
    int a,b;
    cin>>a>>b;

    for(int i=1;i<=1009;i++)
    {
        if(int(i*0.08)==a && int(i*0.1)==b)
        {
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    */
    string s;
    cin>>s;
    int q;
    cin>>q;
    string t;
    for(int i=0;i<q;i++)
    {
        int u,f;
        cin>>u;
        if(u%2==1)
        {
            swap(s,t);
        }
        else
        {
          cin>>f;  
          char c;
          cin>>c;  
          if(f==1)
          {
              t.push_back(c);
          }
          else
          {
              s.push_back(c);
          }
        }
    }
    reverse(t.begin(),t.end());
    t+=s;
    cout<<t<<endl;

    return 0;
}

Measured memory_bytes: 1128
import java.util.Scanner;

public class Main {

    private static int[] values;

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        int N = in.nextInt();
        values = new int[N];
        for (int i = 0; i < N; i++) {
            values[i] = in.nextInt();
        }

        int ans = values[0];

        for (int i = 0; i < N; i++) {
            ans = gcd(ans, values[i]);
        }
        System.out.println(ans);
    }

    private static int gcd(int x, int y) {
        while (true) {
            int tmp = x % y;
            if (tmp == 0) {
                return y;
            }
            x = y;
            y = tmp;
        }
    }
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  int n;
  cin >> n;
  vector<ll> v(n);
  ll res = 0;
  rep(i,n)cin >> v[i];
  vector<pair<ll,ll>> u;
  rep(i,n){
    if(v[i])u.push_back(make_pair(v[i],1));
    else {
      if(!u.empty() && u.back().first == 0)u.back().second++;
      else u.push_back(make_pair(0,1));
    }
  }
  rep(i,u.size()){
    ll k = u[i].first;
    res += u[i].second*(u[i].second+1)/2;
    for(int j = i+1;j < u.size();j++){
      if((u[j].first & k) != 0)break;
      k += u[j].first;
      res += u[j].second*u[i].second;
      }
  }
  cout << res << endl;


  


  
  


  return 0;
}

Measured memory_bytes: 8048
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    vector<ll> a(n);
    REP(i,n) cin >> a[i];
    sort(a.begin(), a.end());

    ll ans1 = a.back();
    ll mid = ans1/2;
    ll ans2 = LINF;
    REP(i,n-1) {
        if (abs(mid-a[i]) <= abs(mid-ans2)) {
            ans2 = a[i];
        } 
    }

    cout << ans1 << " " << ans2 << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep2(i,n) for (int i = 1; i <= (n); i++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
using ll = long long;
using vi = vector<int>;
template <class T>
using Grid = vector<vector<T>>;

int main(){
    int N;
    cin >> N;
    ll ans = (ll)(N - 1) * N / 2ll;
    cout << ans << endl;
}

Measured memory_bytes: 3640
#include <iostream>

using namespace std;

int main() {
  int k, a, b;
  cin >> k >> a >> b;
  bool flag = false;
  for (int i = a / k; i <= b / k + 1; ++i)
    if (a <= i * k && i * k <= b)
      flag = true;
  cout << (flag ? "OK" : "NG") << endl;
}


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

static const int MAX = 100;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

int prim() {
    
    int u, minv;
    int d[MAX], p[MAX], color[MAX];
    
    for (int i = 0; i < n; i ++) {
        
        d[i] = INFTY;
        p[i] = -1;
        color[i] = WHITE;
        
    }
    
    d[0] = 0;
    
    while(1) {
        
        minv = INFTY;
        u = -1;
        
        for (int i = 0; i < n; i ++) {
            
            if (minv > d[i] && color[i] != BLACK) {
                
                u = i;
                minv = d[i];
                
            }
            
        }
        
        if (u == -1) {
            
            break;
            
        }
        
        color[u] = BLACK;
        
        for(int v = 0; v < n; v ++) {
            
            if (color[v] != BLACK && M[u][v] != INFTY) {
                
                if (d[v] > M[u][v]) {
                    
                    d[v] = M[u][v];
                    p[v] = u;
                    color[v] = GRAY;
                    
                }
                
            }
            
        }
        
    }
        
    int sum = 0;
    
    for (int i = 0; i < n; i ++) {
        
        if (p[i] != -1) {
            
            sum += M[i][p[i]];
            
        }
        
    }
    
    return sum;
    
}

int main() {
    
    cin >> n;
    
    for (int i = 0; i < n; i ++) {
        
        for (int j = 0; j < n; j ++) {
            
            int e;
            
            cin >> e;
            
            M[i][j] = (e == -1) ? INFTY : e;
            
        }
        
    }
    
    cout << prim() << endl;
    
    return 0;
    
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const double EPS = 1e-10;

int main() {
    lint D, T, S;
    cin >> D >> T >> S;
    if (S * T >= D) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll ar[1000005];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    while(cin>>n)
    {
    ll cnt=0,mx=0;
    for(ll i=0;i<n;i++)
    {
       cin>>ar[i];
    }
    for(ll i=1;i<n;i++)
    {
        if(ar[i]<=ar[i-1])
            cnt++;
        else
        {
            if(cnt>mx)
                mx=cnt;
            cnt=0;

        }
    }
    if(cnt!=0)
    {
        if(cnt>mx)
            mx=cnt;
    }
    cout<<mx<<endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

struct edge{int to; ll cost;};
typedef pair<ll,int> P;

int V;
vector<edge> G[100005];
ll d[100005];

void dijkstra(int s){
    priority_queue<P, vector<P>, greater<P>> que;
    fill(d,d+V,INF);
    d[s] =0;
    que.push(P(0,s));
    while(!que.empty()){
        P p=que.top(); que.pop();
        int v=p.second;
        if(d[v]<p.first) continue;
        FOR(i,0,G[v].size()){
            edge e = G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(P(d[e.to],e.to));
            }
        }
    }
    return ;
}

int main(){
    int E; cin >> V >> E;
    int st; cin >> st;
    int x,y; ll co;
    edge ed;
    FOR(i,0,E){
        cin >> x >> y >> co;
        ed.to=y;
        ed.cost=co;
        G[x].push_back(ed);
    }
    dijkstra(st);
    FOR(i,0,V){
        if(d[i]==INF) cout << "INF" << endl;
        else cout << d[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 19356
function Main(input) {
	let inputs = input.split("\n");
	let nmc = inputs[0].split(' ').map((num:string) => (parseInt(num, 10)));
	let n = nmc[0];
	let m = nmc[1];
	let c = nmc[2];

	let bs = inputs[1].split(' ').map((num) => (parseInt(num, 10)));

	let ans = 0;

	for(let i = 0; i < n; i++) {
		let as = inputs[i + 2].split(' ').map((num) => (parseInt(num, 10)));
		let result = 0;
		for(let j = 0; j < m; j++) {
			result += (bs[j] * as[j]);
		}
		if(result + c > 0) ans++;
	}

	console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7500