akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define all(c) ((c).begin()), ((c).end())
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
#define fst first
#define snd second
#define pb push_back
#define debug( fmt, ... ) \
        fprintf( stderr, \
                  fmt "\n", \
                  ##__VA_ARGS__ \
        )

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1 << 30;
const double EPS = 1e-10;

double zero(double d) {
    return d < EPS ? 0.0 : d;
}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &a) {
    os << '[';
    rep(i, a.size()) os << (i ? " " : "") << a[i];
    return os << ']';
}

string toString(int i) {
    stringstream ss;
    ss << i;
    return ss.str();
}

const int MOD = 1000000007;
// a^k
ll fpow(ll a, ll k, int M) {
    ll res = 1ll;
    ll x = a;
    while (k != 0) {
        if ((k & 1) == 1)
            res = (res * x) % M;
        x = (x * x) % M;
        k >>= 1;
    }
    return res;
}

struct prepare {
	prepare() {
	    cout.setf(ios::fixed, ios::floatfield);
	    cout.precision(8);
	    ios_base::sync_with_stdio(false);
	}
} _prepare;

ll dig(ll b, ll n) {
    ll ans = 0;
    while(n > 0) {
        if(n < b) {
            ans += n;
            break;
        }
        ans += (n % b);
        n /= b;
    }
    return ans;
}

int main() {
	ll n, s;
    cin >> n >> s;

    if(n == s) {
        cout << n+1 << endl;
        return 0;
    }

    for(ll i = 2; i*i <= n; i++) {
        if(dig(i, n) == s) {
            cout << i << endl;
            return 0;
        }
    }

    ll ans = 1ll<<60;
    for(ll i = 1; i*i < n; i++) {
        if( n - s >= 0 && (n-s) % i == 0) {
            ll b = ((n-s) / i) + 1;
            if(dig(b, n) == s)
                chmin(ans, b);
        }
    }

    if(ans != 1ll<<60) {
        cout << ans << endl;
    }
    else if(s == 1) {
        cout << n << endl;
    } else
        cout << -1 << endl;

    return 0;
}


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

using namespace std;

typedef long long          ll;
typedef unsigned long long ull;
typedef vector<int>	       vi;
typedef vector<bool>       vb;
typedef map<int, int>      mii;
typedef pair<int, int>     ii;

#define INF                0x3f3f3f3f
#define INFLL              0x3f3f3f3f3f3f3f3f
#define each(x, s)         for(auto& x : s)
#define loop(x)	           for(int i = 0;i < x;i++)
#define vloop(v, x)        for(int v = 0;v < x;v++)
#define avg(l, r)          l + (r - l) / 2
#define iter(a)            a.begin(), a.end()
#define riter(a)           a.rbegin(), a.rend()
#define endl               "\n"

const ll mod = 1000000007;

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

	int n;
	cin >> n;
	vi a(n);
	loop(n) cin >> a[i];
	int x = 0;
	each(y, a) x ^= y;
	each(y, a) cout << (y xor x) << " ";
	cout << endl;
	return 0;
}



Measured memory_bytes: 3968
n=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
dp=[[0 for j in range(2)]for i in range(n)]
dp[0][0]=a[0]
dp[0][1]=b[0]+a[0]
for i in range(1,n):
    dp[i][0]=dp[i-1][0]+a[i]
for i in range(1,n):
    dp[i][1]=max(dp[i-1][1],dp[i][0])+b[i]
maxi=0 
maxi=max(maxi,dp[n-1][0],dp[n-1][1])
print(maxi)


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

int main() {
  int w, h, n;
  cin >> w >> h >> n;
  int w1, w2, h1, h2;
  w1=0; w2=w; h1=0; h2=h;
  for (int i=0; i<n; i++){
    int x, y, a;
    cin >> x >> y >> a; 
    if (a==1)
      w1 = max(x,w1);
    if (a==2)
      w2 = min(x,w2);
    if (a==3)
      h1 = max(y,h1);
    if (a==4)
      h2 = min(y,h2);
  }
  int width = max(w2-w1,0);
  int height = max(h2-h1,0);
  cout << width * height << endl;
}

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

	int P;
	P = 700;

	for (int i = 0; i < 3; i++) {
		if (topping.at(i) == 'o') {
			P += 100;
		}
	}
	cout << P << endl;
}

Measured memory_bytes: 3572
import bisect

n=int(input())
a=[int(i) for i in input().split()]
a.sort()

nnn=a[n-1]
k=bisect.bisect_left(a[:n-1], nnn/2)
  
if k==n-1:
  rrr=a[n-2]
else:
  if abs(a[k-1]-nnn/2) < abs(a[k]-nnn/2):
    rrr=a[k-1]
  else:
    rrr=a[k]

print(nnn, rrr)


Measured memory_bytes: 14052
h,w = map(int,input().split())
a = [list(input()) for _ in range(h)]

for i in range(h-1,-1,-1):
    if set(a[i]) == {'.'}:
        del a[i]

for j in range(w-1,-1,-1):
    cnt = 0
    for k in range(len(a)):
        if a[k][j] == '.':
            cnt += 1
    if cnt == len(a):
        for l in range(len(a)):
            del a[l][j]
for i in a:
    print("".join(i))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef signed long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
//vvi(n, vector<int>(m, -1))
 
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a) (a).begin(), (a).end()

int main(){
	int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;

  if(e - a > k) cout << ":(";
  else cout << "Yay!";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M;cin>>N>>M;
  vector<int>A(N);
  int ans=1000000000;
  for(int i=0;i<N;i++)cin>>A[i];
  for(int i=M-1;i<N;i++){
    if(A[i-M+1]>=0)ans=min(ans,A[i]);
    else if(A[i]<=0)ans=min(ans,abs(A[i-M+1]));
    else ans=min(min(ans,A[i]*2+abs(A[i-M+1])),abs(A[i-M+1])*2+A[i]);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3752
using System;
class Program
{
	static void Main(string[] args)
	{
		// スペース区切りの整数の入力
		string[] input = Console.ReadLine().Split(' ');
		int A = int.Parse(input[0]);
		int B = int.Parse(input[1]);
		int X = 0;
        
        if(A > B)
    	{
    		X = A * 2 -1;
 		}
    	else if(A < B)
    	{
      		X = B * 2 -1;
    	}
        else
        {
        	X = A * 2;
        }
        //出力
		Console.WriteLine(X);
	}
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
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;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
  
  int h,w;

   while(1){
     cin>>h>>w;

     if(h==0 && w==0)break;

     rep(i,h){
       rep(j,w){
         if(i%2==0){
           if(j%2==0){
             cout<<'#';
           }
           else
           {
             cout<<".";
           }
           
         }
         else
         {
           if(j%2==0){
             cout<<'.';
           }
           else
           {
             cout<<'#';
           }

           
         }
         
       }
        cout<<endl;
     }
     cout<<endl;
   }
}


Measured memory_bytes: 3148
function Main(input) {
	let [nm, ...others] = input.split('\n');
	nm = nm.split(' ');
	let n = Number(nm[0]);
	let m = Number(nm[1]);

	let arryA = [];
	for (let i = 0; i < n + m; i++){
		arryA.push([]);
	}
	
	for (let i = 0; i < n + m; i++){
		arryA[i] = others[i].split(' ').map(Number);		
	}
	
	for (let i = 0; i < n; i++){
		let result = 0;
		for (let j = 0; j < m; j++){
			result += arryA[i][j] * arryA[n + j][0];			
		}
		console.log(result);
	}
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 17496
#include <iostream>
using namespace std;
int main(void){
    string s, t;
    int count = 0;
    cin >> s >> t;
    
    for (int i=0;i<3;i++){
        if(s[i]==t[i]){
            count+=1;
        }
    }
    
    cout << count << endl;
    
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main() {
  long N, k, c;
  scanf("%ld", &N);
  k = log10(N);
  c = N / pow(10, k);
  if (N - pow(10, k) * c == pow(10, k) - 1) {
    printf("%ld\n", c + 9 * k);
  } else {
    printf("%ld\n", c + 9 * k - 1);
  }
  return 0;
}


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

int main(){
  long long A,V,B,W,T;
  cin >> A >> V >> B >> W >> T;
  if (W >= V){
    cout << "NO" << endl;
    return 0;
  }
  V -= W;
  if (A > B)
    swap(A, B);
  B -= A;
  if (V*T >= B){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 3636
def read_input():
    a, b = map(int, input().split())
    return a, b

def submit():
    a, b = read_input()

    if a >= 13:
        print(b)
        return

    if a >= 6:
        print(b // 2)
        return

    print(0)
    return


if __name__ == '__main__':
    submit()


Measured memory_bytes: 38384
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()

	xm := make(map[int]map[int]bool, n)
	ym := make(map[int]map[int]bool, n)
	for i := 1; i <= n; i++ {
		a := scanInt()
		if x := i - a; x > 0 {
			if _, ok := xm[x]; !ok {
				xm[x] = make(map[int]bool)
			}
			xm[x][i] = true
		}
		y := i + a
		if _, ok := ym[y]; !ok {
			ym[y] = make(map[int]bool)
		}
		ym[y][i] = true
	}

	ans := 0
	for x, m := range xm {
		if _, ok := ym[x]; ok {
			ans += len(m) * len(ym[x])
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 50452
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n;
  cin>>n;
  ll cp=n;
  ll tmp;
  ll count=1;
  bool fg=false;
  if(n%10!=9){
    fg=true;
  }
  n/=10;
  while(n!=0){
    if(n/10==0){
      tmp=n;
    }
    else if(n%10!=9){
      fg=true;
    }
    n/=10;
    count++;
  }
  if(count==1){
    cout<<cp<<'\n';
  }
  else{
    if(fg){
      cout<<tmp-1+(count-1)*9<<'\n';
    }
    else{
      cout<<tmp+(count-1)*9<<'\n';
    }
  }
  return(0);
}


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

int main(){
  int N;
  cin >> N;
  vector<long long> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  long long w=1000,c=0;
  for(int i=0; i<N-1; i++){
    if(A[i+1] > A[i]){ c += w/A[i]; w -= A[i]*(w/A[i]); }
    else { w += c*A[i]; c = 0;}
  }
  w += c*A[N-1];
  cout << w;
  return 0;
}

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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solver() {
    int d = input();
    cout << "Christmas";
    range(i, d, 25) cout << " Eve";
    cout << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define M_PI 3.14159265358979
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include<iomanip>
#include<vector>
#include<cmath>
#include <algorithm>

using namespace std;

double hankei(double z1,double z2,double dx,double dy){
	 
	double r = sqrt((dx - z1)*(dx - z1) + (dy - z2)*(dy - z2));
	return r;
}


int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		
		double x1, y1, x2, y2, x3, y3,px,py;
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

		px = ((y1 - y3)*(y1*y1 - y2*y2 + x1*x1 - x2*x2) - (y1 - y2)*(y1 *y1 - y3*y3 + x1 *x1 - x3 *x3)) / (2 *(y1 - y3)*(x1 - x2) - 2 * (y1 - y2)*(x1 - x3));
		py = ((x1 - x3)*(x1*x1 - x2*x2 + y1*y1 - y2*y2) - (x1 - x2)*(x1 *x1 - x3*x3 + y1 *y1 - y3 *y3)) / (2 *(x1 - x3)*(y1 - y2) - 2 * (x1 - x2)*(y1 - y3));

		printf("%.3f %.3f %.3f\n",floor(px * 1000 + 0.5) / 1000,floor(py * 1000 + 0.5) / 1000 ,floor(hankei(x1, y1, px, py) * 1000 + 0.5) / 1000);
	}
	
	return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

int main(){
    int N, Q;
    cin >> N >> Q;
    int S[N], T[N], X[N];
    pii p[N];
    rep(i, N){
        cin >> S[i] >> T[i] >> X[i];
        p[i] = pii(S[i]-X[i], i);
    }
    sort(p, p+N);
    //(x[i], i)
    priority_queue<pii, vector<pii>, greater<pii> > que;
    int now = 0;
    rep(i, Q){
        int D;
        cin >> D;
        while(now < N && p[now].first <= D){
            int j = p[now].second;
            que.push(pii(X[j], j));
            now++;
        }
        while(!que.empty()){
            int j = que.top().second;
            if(T[j]-X[j] <= D) que.pop();
            else break;
        }
        if(que.empty()) cout << -1 << endl;
        else cout << que.top().first << endl;
    }
}

Measured memory_bytes: 6896
import java.util.*;

class Main {
	public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
     
      int a = sc.nextInt();
      int b = sc.nextInt();
      
      if( (a * b) % 2 == 0 ){
      	System.out.println("Even");
      }else{
      	System.out.println("Odd");
      }
      
    }
}

Measured memory_bytes: 23252
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<set>
#define fi first
#define se second
using namespace std;
const int maxn =100003;
vector<pair<int,long long> > G[maxn];
set<pair<int,int> > S;
int son[maxn], sz[maxn];
int tree[maxn*4];
int n, tot;
long long ANS=0,Min=1e18;
void dfs0(int x,int fa){
    sz[x]=1;
	for(auto e:G[x]){
        if(e.fi==fa)continue;
        dfs0(e.fi,x);
        sz[x]+=sz[e.fi];
        son[x]=max(son[x],sz[e.fi]);
    }
    son[x]=max(son[x],n-sz[x]);
}
void dfs(int x,int fa,long long v){
    sz[x]=1;
    for(auto e:G[x]){
        if(e.fi==fa)continue;
        dfs(e.fi,x,e.se+v);
        sz[x]+=sz[e.fi];
    }
    ANS+=v;
}
int main(){
    cin>>n;
    for(int i=1;i<n;i++){
        int x,y,w;
        cin>>x>>y>>w;
        G[x].push_back({y,w});
        G[y].push_back({x,w});
    }
    int X;
    dfs0(1,1);
    for(int i=1;i<=n;i++){
    	if(son[i]<=n/2){
    		X=i;
		}
	}
    dfs(X,X,0);
    for(auto e:G[X]){
        if(sz[e.fi]==(n+1)/2){
			Min=e.se;
			break;
		}
        Min=min(e.se,Min);
    }
    cout<<ANS*2-Min<<endl;
	return 0;
}
/*

in:
8
2 8 8
1 5 1
4 8 2
2 5 4
3 8 6
6 8 9
2 7 12

out:
132

*/

Measured memory_bytes: 13952
n, c, k = gets.split.map(&:to_i)
t = n.times.map{gets.to_i}.sort
r = 0
until t.empty?
  a = t.first
  i = t.bsearch_index{|b| b > a + k}
  i = t.size if i == nil
  j = [c, i].min
  r += 1
  t = t.drop(j)
end
p r

Measured memory_bytes: 4656
// EbTech's Rust template. Thanks EbTech!
#![allow(unused_imports)]
use std::cmp::{max, min, Reverse};
use std::collections::{HashMap, HashSet};
use std::io::{self, prelude::*};
use std::str;

/*
5 2
5 -4 4 3 -5
4 3
3 -1

5 -4 4 3 -5 -> 8
5 -4 4 3 3  -> 11
5 -4 4 -1 3 -> 7
*/

struct Scanner<R> {
    reader: R,
    buf_str: Vec<u8>,
    buf_iter: str::SplitWhitespace<'static>,
}
impl<R: BufRead> Scanner<R> {
    fn new(reader: R) -> Self {
        Self {
            reader,
            buf_str: vec![],
            buf_iter: "".split_whitespace(),
        }
    }
    fn next<T: str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buf_iter.next() {
                return token.parse().ok().expect("Failed parse");
            }
            self.buf_str.clear();
            self.reader
                .read_until(b'\n', &mut self.buf_str)
                .expect("Failed read");
            self.buf_iter = unsafe {
                let slice = str::from_utf8_unchecked(&self.buf_str);
                std::mem::transmute(slice.split_whitespace())
            }
        }
    }
}

fn solve<R: BufRead, W: Write>(scan: &mut Scanner<R>, w: &mut W) {
    let n: usize = scan.next();
    let mut v = vec![0; n];
    let mut one_pres = 0;
    for i in 0..n {
        v[i] = scan.next::<usize>();
        if v[i] == 1 {
            one_pres += 1
        }
    }
    let v = v;
    const N: usize = 1e6 as usize + 100;
    let mut is_prime = vec![true; N];
    is_prime[0] = false;
    is_prime[1] = false;
    let mut fac = vec![1; N];
    for i in 2..N {
        if is_prime[i] {
            fac[i] = i;
            for j in (2 * i..N).step_by(i) {
                is_prime[j] = false;
                fac[j] = i;
            }
        }
    }

    let mut seen = HashSet::new();
    let mut proceed = false;
    'main: for i in 0..n {
        let mut e = v[i];
        let mut vec = Vec::with_capacity(50);
        while fac[e] != 1 {
            if seen.get(&fac[e]).is_some() {
                proceed = true;
                break 'main;
            }
            vec.push(fac[e]);
            e /= fac[e];
        }
        for e in vec {
            seen.insert(e);
        }
    }
    if proceed {
        fn gcd(a: usize, b: usize) -> usize {
            if a == 0 {
                b
            } else if b == 0 {
                a
            } else {
                gcd(b, a % b)
            }
        }
        let mut se = gcd(v[0], v[1]);
        for i in 2..n {
            se = gcd(se, v[i]);
        }
        if se == 1 {
            println!("setwise coprime");
        } else {
            println!("not coprime");
        }
    } else {
        println!("pairwise coprime");
    }
}

fn main() {
    let (stdin, stdout) = (io::stdin(), io::stdout());
    let mut scan = Scanner::new(stdin.lock());
    let mut out = io::BufWriter::new(stdout.lock());
    // let t: u64 = scan.next();
    let t = 1;
    for _ in 0..t {
        solve(&mut scan, &mut out);
    }
}


Measured memory_bytes: 26548
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
typedef long long ll;
typedef pair<int, int> P;

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

    int m = 0;
    rep(i, n) {
        m = max(m, h[i]);
    }

    int ans = 0;
    rep(i, m) {
        int cnt = 0;
        rep(j, n) {
            if (h[j] <= 0) {
                ans += cnt;
                cnt = 0;
            } else {
                h[j]--;
                cnt = 1;
            }
            if (j == n-1) ans += cnt;
        }
    }
    
    cout << ans << endl;

}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<ll, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

struct edge {
    int to;
    int64_t cost;
    edge(int x=0, int64_t y=0):to(x), cost(y) {}
};

vector<vector<edge> > G; // resizeの必要あり


struct UnionFind {
    vector<int> par; // 親を指すvector,-par[親]は木のサイズ
    UnionFind(int n):par(n, -1) {} // uniteで親を埋め込んでいく必要あり
    int root(int x) { // 親をたどる&データの整理
        if(par[x] < 0) return x;
        return par[x] = root(par[x]);
    }
    bool unite(int x, int y) { // データの結合
        x = root(x);
        y = root(y);
        if(x == y) return false;
        if(par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    bool same(int x, int y) {return root(x) == root(y);} // 所属判定
    int size(int x) {return -par[root(x)];} // 木のサイズ
}uft(100000);

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    G.resize(n);
    rep(i, m) {
        int l, r, d;
        cin >> l >> r >> d;
        --l; --r;
        G[l].push_back(edge(r, d));
        G[r].push_back(edge(l, -d));
        uft.unite(l, r);
    }

    auto say = [](bool x) {cout << (x?"Yes":"No") << endl;};

    set<int> x;
    ll c = 0;
    vector<ll> dist(n, LINF);
    rep(i, n) {
        int ro = uft.root(i);
        if(x.find(ro) == x.end()) {
            x.insert(ro);

            queue<int> que;
            que.push(i);
            ll mi = 0, ma = 0;
            dist[i] = 0;
            while(!que.empty()) {
                int now = que.front();
                que.pop();

                for(auto e:G[now]) {
                    if(dist[e.to] != LINF) {
                        if(dist[e.to] != dist[now] + e.cost) {
                            say(false);
                            return 0;
                        }
                    } else {
                        dist[e.to] = dist[now] + e.cost;
                        ma = max(ma, dist[e.to]);
                        mi = min(mi, dist[e.to]);
                        que.push(e.to);
                    }
                }
            }
            if(ma-mi > 1e9) {
                say(false);
                return 0;
            }
        }
    }
    say(true);
}

Measured memory_bytes: 14336
#include<vector>
#include<iostream>
#include<numeric>
#include<list>
#include<limits>
#include<algorithm>
#include<cmath>
#include<unordered_map>
#include<unordered_set>

#define pi 3.141592653589793
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define pb push_back
#define FP(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)
#define FS(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)
#define IT(it, a) for(__typeof(a.begin()) it = a.begin();it != a.end(); ++it)

using namespace std;
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector< pair<int, int> > VPII;
typedef vector< pair<int, PII > > VPPI;

const long long MOD = 1e9 + 7;
const long long INF = 1e9 ;

template <typename T>
std::ostream& operator<<(ostream& os, 
                        const vector<T> &v)
{
    for (T const& i: v) {
        os << i << " ";
    }
    os<<endl;
    return os;
}


template<class T> inline T gcd(T x, T y) { if (!y) return x; return gcd(y, x%y);}
vector<int> sieve(int n){
    vector<bool> s(n, true);
    for(int i =2 ; i*i <= n; i++ )
        if(s[i])
            for(int j=2*i; j< n; j +=i )
                s[j] = false;

    vector<int> primes;
    for(int i =0; i<n; i++)
        if( s[i] )
            primes.push_back(s[i]);

    return primes;
}


int main(){
    int n;
    cin>>n;
    vector<int> ar(n);
    vector<int> table(n, 999999999);
    for(auto &i: ar) cin>>i;
    table[0] = 0;
    table[1] =  abs( ar[0]- ar[1]);
    for(int i = 2; i< n; i++)
        table[i] =  min( table[i-1] + abs( ar[i-1] - ar[i] ), table[i-2] + abs( ar[i-2] - ar[i] ) );
    

    cout<<table.back();
    
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>

int main(void){

	int DICE[6]={1,2,3,4,5,6};
/* DICE={UP,FRONT,RIGHT,LEFT,BACK,UNDER};*/
	char com[10];
	int n,i,temp,s;
	while(1){
	s=0;
	DICE[0]=1;
	DICE[1]=2;
	DICE[2]=3;
	DICE[3]=4;
	DICE[4]=5;
	DICE[5]=6;
	scanf("%d",&n);
	if(n==0){break;}
	s=s+DICE[0];
	for(i=0;i<n;i++){
		scanf("%s",com);
	switch(com[0]){
	case 'N':
	case 'n':
		temp=DICE[0];
		DICE[0]=DICE[1];
		DICE[1]=DICE[5];
		DICE[5]=DICE[4];
		DICE[4]=temp;
		break;
	case 'S':
	case 's':
		temp=DICE[0];
		DICE[0]=DICE[4];
		DICE[4]=DICE[5];
		DICE[5]=DICE[1];
		DICE[1]=temp;
		break;
	case 'E':
	case 'e':
		temp=DICE[0];
		DICE[0]=DICE[3];
		DICE[3]=DICE[5];
		DICE[5]=DICE[2];
		DICE[2]=temp;
		break;
	case 'W':
	case 'w':
		temp=DICE[0];
		DICE[0]=DICE[2];
		DICE[2]=DICE[5];
		DICE[5]=DICE[3];
		DICE[3]=temp;
		break;
	case 'R':
	case 'r':
		temp=DICE[1];
		DICE[1]=DICE[2];
		DICE[2]=DICE[4];
		DICE[4]=DICE[3];
		DICE[3]=temp;
		break;
	case 'L':
	case 'l':
		temp=DICE[1];
		DICE[1]=DICE[3];
		DICE[3]=DICE[4];
		DICE[4]=DICE[2];
		DICE[2]=temp;
		break;

		}
	s=s+DICE[0];
	}
    printf("%d\n",s);
	}
	return 0;
}

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

int N, a, b, c;
vector<int> DP[2];

int main()
{
    scanf("%d", &N);
    for(int i = 0; i < N; i++) {
        scanf("%d %d %d", &a, &b, &c);
        if(i == 0) {
            DP[0] = vector<int>{a,b,c};
        } else {
            DP[1].assign(3,0);

            DP[1][0] = max(DP[0][1], DP[0][2]) + a;
            DP[1][1] = max(DP[0][0], DP[0][2]) + b;
            DP[1][2] = max(DP[0][1], DP[0][0]) + c;

            DP[0] = DP[1];
        }
    }

    printf("%d\n", max(DP[min(1,N-1)][0], max(DP[min(1,N-1)][1], DP[min(1,N-1)][2])));

    return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(1000000)

D = [(1,0), (0,1), (-1,0), (0,-1), (-1,-1),(1,-1),(-1,1),(1,1) ] # 下、右、上、左、斜め

def dfs(x,y):
  # Validation
  if not(0<=x<H and 0<=y<W) : return

  # 探索済みか、探索可能かを確認する
  if f[x][y]!=0 or G[x][y] == 0: return

  # Validation完了、探索範囲内、探索可能、ゴール以外＝＞visitフラグを立てる
  f[x][y]=1
 
  # 次の場所に向かう
  for dx,dy in D:
     nx=x+dx
     ny=y+dy
     dfs(nx,ny)
  return

def main():

    cnt=0
    for i in range(H):
        for j in range(W):
            if f[i][j]==0 and G[i][j]: 
                dfs(i, j)
                cnt+=1
    print(cnt)

while True:
    W,H=map(int,input().split())
    if W==0 and H==0: break
    G=[list(map(int,input().split())) for _ in range(H)]
    f=[[0]*W for _ in range(H)]

    main()


Measured memory_bytes: 7988
from operator import itemgetter
n, m = map(int, input().split())
A = [(1, i) for i in map(int, input().split())]
BC = [ tuple(map(int, input().split())) for _ in range(m) ]
XY = sorted(A + BC, reverse=True, key=itemgetter(1))
c = n
now = 0
ans = 0
while c > 0 and now < n+m:
  x, y = XY[now]
  t = min(c, x)
  ans += y*t
  c -= t
  now += 1
print(ans)

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max<R>(x,0.0));}

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

// Problem Specific Parameter:

// Description: 文字列の接尾辞配列
// TimeComplexity: $\mathcal{O}(|S|\log^2|S|)$ 
// Verifyed: ARC050 D

auto suffix_array(string s){
	const int n=s.size();
	vector<int> sa(n+1),rnk(n+1,0),tmp(n+1,0);
	rep(i,n+1) sa[i]=i,rnk[i]=(i<n?s[i]:-1);
	for(int k=1;k<=n;k<<=1){
		auto cmp=[&](int i,int j){
			if(rnk[i]!=rnk[j]) return rnk[i]<rnk[j];
			int ci=(i+k<=n)?rnk[i+k]:-1;
			int cj=(j+k<=n)?rnk[j+k]:-1;
			return ci<cj;
		};
		sort(begin(sa),end(sa),cmp);
		tmp[sa[0]]=0;
		rep(i,n) tmp[sa[i+1]]=tmp[sa[i]]+cmp(sa[i],sa[i+1]);
		rep(i,n+1) rnk[i]=tmp[i];
	}
	return make_tuple(rnk,sa);
}

// Description: 文字列の最長共通接頭辞
// TimeComplexity: $\mathcal{O}(|S|)$ 
// Verifyed: ARC050 D

auto longest_common_prefix(string s,const auto &rnk,const auto &sa){
	int n=s.size(),h=0;
	vector<int> lcp(n+1,0);
	rep(i,n){
		int j=sa[rnk[i]-1];
		for(h=max(h-1,0);j+h<n&&i+h<n;h++) if(s[j+h]!=s[i+h]) break;
		lcp[rnk[i]-1]=h;
	}
	return lcp;
}

int csum[100010];

int main(void){
	string s;
	cin >> s;

	vector<int> rnk,sa,lcp;
	tie(rnk,sa)=suffix_array(s);
	lcp=longest_common_prefix(s,rnk,sa);

	const int n=int(s.size());
	rep(i,1,n) csum[lcp[i]]++;
	rrep(i,n) csum[i]+=csum[i+1];

	int ans=0;
	rep(k,1,n+1) chmax(ans,n-k+1-csum[k]);
	cout << ans << endl;
	 
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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


int main() {

    int N;
    cin >> N;
    vector<int> B(N-1);
    REP(i, N-1) cin >> B[i];

    int sum = B[0] + B[N - 2];
    REP(i, N - 2){
        sum += min(B[i], B[i + 1]);
    }
    cout << sum << endl;
    return 0;
}

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

int main(){
    ll n,max=0,max2;cin>>n;
    vector<ll> a(n);
    for(i=0;i<n;i++){
        cin>>a[i];
        if(max<a[i]){
            max=a[i];
        }
    }

    vector<ll> ans(n,max);
    
    ll key=-1;
    max2=-1;
    ll cnt=0;
    for(i=0;i<n;i++){
        if(max2<a[i] && a[i]!=max){
            max2=a[i];
        }
        if(a[i]==max){key=i;cnt++;}
    }
    
    if(max2!=-1 && cnt<=1){ans[key]=max2;}
    for(i=0;i<n;i++){
        cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 4736
import sys
n, y = map(int, input().split())
for i in range(n + 1):
    for j in range(n + 1):
        u = y - 1000 * i - 5000 * j
        if n - i - j >= 0 and u == (n - i - j) * 10000:
            print(n - i - j, j, i)
            sys.exit()
print(-1, -1, -1)

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

const ll INF = 1001001001;

int main(){
  int k,x;
  cin>>k>>x;
  if(500*k>=x) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}



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


int main() {
  int a,b,c,d,sum,ans;
  string s;
  cin>>a;
  ans=0;
  b=0;c=0;
  vector<int> vec(a);
  
  for(int i=0;i<a;i++){
  	cin>>b;
    if(c<=b){
    	ans++;
      	c=b;
    }
  }
  
 
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 using namespace std;
 #define rep(i, c) for(int i = 0; i < (int)c; i++)
 const int inf = 1000000000; // 10^9

 int main() {
 int N;
 cin >> N;
 vector<int> X(N);
 rep(i, N) cin >> X[i];
 int L = X[0], R = X[0];
 rep(i, N) {
 L = min(L, X[i]);
 R = max(R, X[i]);
 }
 int ans = inf;
 for(int i = L; i <= R; i++) {

 int cost = 0;
 rep(j, N) cost += (X[j] - i) * (X[j] - i);//einu per koordinates visas ir sudejineju is pasirinkto tasko (i) stamina, ir kai i pasikeicia, vel sudejineju stamina ir lyginu su praeita.
 ans = min(ans, cost);// sitas dalykas nera rep j N cikle, nes man reikia visos cost sumos, o tam cikle gausiu tasko maziausia stamina, kas bus lygu 0
 }
 cout << ans << endl;
 return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;
char s[5050];
int k;
int t[30300],tot;
char u[10];
void gao(char u[],int l) {
    int x=0;
    for (int i=0;i<l;i++) {
        x=x*27+u[i]-'a'+1;
    }
    for (int i=l;i<k;i++) x=x*27;
    t[tot++]=x;
}
char* inv(int x) {
    for (int i=k-1;i>=0;i--) {
        u[i]=x%27,x/=27;
        if (u[i]) u[i]=u[i]+'a'-1;
    }
    u[k]=0;
    return u;
}
int main(void) {
    scanf("%s%d",s,&k);
    for (int i=0;s[i];i++) {
        for (int j=i;j<i+k&&s[j];j++) {
            u[j-i]=s[j];
            gao(u,j-i+1);
        }
    }
    sort(t,t+tot);
    tot=unique(t,t+tot)-t;
    printf("%s\n",inv(t[k-1]));
    return 0;
}


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



namespace ConsoleApplication2
{

    class Program
    {
        static void Main(string[] args)
        {

            string[] eatmass = Console.ReadLine().Split(' ');
            string[] mass =eatmass;



            for(int i=0;i<eatmass.Count();i++)
            {
                mass[i] = eatmass[eatmass.Count() - 1-i];
            }
            


            

            //string[] greed = Console.ReadLine().Split(' ');
            //string[] bonus = Console.ReadLine().Split(' ');

            //int[] pointlist = new int[mass.Length];
            float Eatmass = float.Parse(eatmass[0]);
            float height;
            height = Eatmass * 2.0f*(float)Math.PI;



            //for (int i = 0; i < Eatmass; i++)
            //{
            //    pointlist[i] = int.Parse(mass[i]);
            //}

            //int[] greedlist = new int[greed.Length];
            //for (int i = 0; i < Eatmass; i++)
            //{
            //    greedlist[i] = int.Parse(greed[i]);
            //}

            //int[] bonuslist = new int[bonus.Length];
            //for (int i = 0; i < bonus.Length; i++)
            //{
            //    bonuslist[i] = int.Parse(bonus[i]);
            //}

            //float result = 0,eaten=0;

            //result = height * height * height;
            //for(int i=0;i< Eatmass; i++)
            //{

            //    result += greedlist[pointlist[i]-1];
               
            //    if(eaten!=0)
            //    {
            //        if(pointlist[i]  == eaten+1)
            //        {
            //            result += bonuslist[eaten-1];
            //        }
            //    }
            //    eaten = pointlist[i];

            //}
            //int[] listinput = new int[mass.Length];

            //for (int i = 0; i < mass.Length; i++)
            //{
            //    listinput[i] = int.Parse(mass[i]);
            //}


            Console.Write(height);



            //postition = int.Parse(mass[1]);

            //int nowposition = postition - (range - 1);

            //for(int i= 0; i<=(range-1)*2;i++)
            //{

            //    Console.Write(nowposition);
            //    Console.Write(" ");
            //    nowposition++;
            //}

            //result = 0;

        }
    }
}


Measured memory_bytes: 19440
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner num = new Scanner(System.in);
        while(true) {
            int a = num.nextInt();
            char s = num.next().charAt(0);
            int b = num.nextInt();
            int result = 0;

            if(s == '+') {
                result = a + b;
            } else if(s == '-') {
                result = a - b;
            } else if(s == '*') {
                result = a * b;
            } else if(s == '/') {
                result = a / b;
            } else {
                break;
            }
            System.out.println(result);
        }
    }
}


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

typedef long long LL;

#define __m int mid=(l+r)>>1;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1

#define rep(i,a,b) for(register int i = (a); i< (b); i++)
#define per(i,a,b) for(register int i = (a); i> (b); i--)
#define mem(a) memset(a,0,sizeof(a));
#define pb push_back

#ifdef LOCAL
    #define bug(x) cout<<#x<<" : "<<x<<endl;
#else
    #define bug(x) ;
#endif

template<class T>
inline bool read(T &num)  
{
       char in;bool IsN=false;
       while(in=getchar(),in!='-'&&(in<'0'||in>'9'))if(in==EOF)return false;
       in=='-'?(IsN=true,num=0):num=in-'0';
       while(in=getchar(),in>='0'&&in<='9')num=num*10+in-'0';
       return IsN?num=-num:num,true;
}

const int maxn = 2e2+7;
const int inf  = 2e9+7;
const int mod  = 1e9+7;

set<string>sub;
int main(){
#ifdef LOCAL
    //freopen("sample.in","r",stdin);
#endif
    ios::sync_with_stdio(false);
    string in;
    int k;
    cin>>in>>k;
    rep(i,0,in.size()){
        string temp;
        rep(j,i,i+k){
            if(j>=in.size())
                break;
            temp+=in[j];
            sub.insert(temp);
        }
    }
    string ans;
    int c=1;
    for(set<string>::iterator p=sub.begin();p!=sub.end();p++){
        if(c==k) {
            cout<<*p<<endl;
            break;
        }
        c++;
    }
    return 0;
}


Measured memory_bytes: 1664
//************************
//** author  :  Alex Hu **
//************************

//  _______        __________         ________        __
//  \      \   ____\______   \ ____  /  _____/  _____/  |_
//  /   |   \ /  _ \|       _// __ \/   \  ____/ __ \   __\
// /    |    (  <_> )    |   \  ___/\    \_\  \  ___/|  |
// \____|__  /\____/|____|_  /\___  >\______  /\___  >__|
//         \/              \/     \/        \/     \/

#include<bits/stdc++.h>

using namespace std;

#define CLEAN(a,b) memset(a,b,sizeof(a))
#define mkp make_pair
#define pb push_back
#define rept(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define fi first
#define se second
#define sqr(a) ((a)*(a))

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int r,d,x;

int main()
{
	cin>>r>>d>>x;
	rept(i,0,10)
	{
		cout<<r*x-d<<endl;
		x=r*x-d;
	}
	return 0;
}

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

ll a[1100], b[1100], c[1100];
int main() {
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    for (int i = 0; i < x; i++) cin >> a[i];
    for (int i = 0; i < y; i++) cin >> b[i];
    for (int i = 0; i < z; i++) cin >> c[i];
    vector<ll> v, ans;
    sort(a, a + x);
    sort(b, b + y);
    sort(c, c + z);
    reverse(a, a + x);
    reverse(b, b + y);
    reverse(c, c + z);
    for (int i = 0; i < x; i++) {
        for (int j = 0; j < y; j++) {
            v.push_back(a[i] + b[j]);
        }
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    int d = min(k, x * y);
    for (int i = 0; i < d; i++) {
        for (int j = 0; j < z; j++) {
            ans.push_back(v[i] + c[j]);
        }
    }
    sort(ans.begin(), ans.end());
    reverse(ans.begin(), ans.end());
    for (int i = 0; i < k; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 43236
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
namespace io{
    #define ll long long
    #define inf 0x3f3f3f3f
    #define il inline 
    #define in1(a) read(a)
    #define in2(a,b) in1(a),in1(b)
    #define in3(a,b,c) in2(a,b),in1(c)
    #define in4(a,b,c,d) in2(a,b),in2(c,d)
    il void readl(ll &x){
        x=0;ll f=1;char c=getchar();
        while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
        while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
        x*=f;
    }
    il void read(int &x){
        x=0;int f=1;char c=getchar();
        while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
        while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
        x*=f;
    }
}using namespace io;
#define N 100005
ll n,K;
ll a[N],cnt[2];
int main(){
	ll ans=0,sum=0;
	readl(n);
	readl(K);
	for(int i=1;i<=n;i++) readl(a[i]);
	for(int k=40;k>=0;k--){
		cnt[0]=cnt[1]=0;
		for(int i=1;i<=n;i++){
			cnt[(a[i]>>k)&1ll]++;
		}
		if(cnt[0]>cnt[1]&&ans+(1ll<<k)<=K) ans+=(1ll<<k);
	}
	for(int i=1;i<=n;i++) sum+=a[i] xor ans;
	printf("%lld",sum);
}

Measured memory_bytes: 896
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
#include<fstream>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)

#define mp make_pair
#define P pair<int,int>
#define ll __int64
int t[1000],a;
int main(){
	rep(i,28){
		cin>>a;
		t[a]=1;
	}
	for(int i=1;i<=30;i++)if(t[i]==0)cout<<i<<endl;
	return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, K;
	cin >> N >> K;
	if (N <= K) {
		cout << min(abs(K - N), N) << endl;
		return 0;
	}
	int ans = N;
	chmin(ans, N%K);
	chmin(ans, abs(K - N % K));
	cout << ans << endl;
	
	return 0;
}



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

#define INF (int)1e9+7
#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 vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define N 100005
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795

ll no_of_div(ll a)
{
  ll cnt=0,i;
  if (a==2)return 1;
  for(i=2;i*i<a;i++)
  {
if(a%i==0)cnt+=2;
  }
  if(i*i==a)cnt++;
  return cnt;
}

//vl a(1001);

ll powM(ll a,ll b)
{ 
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }

return ans;
}







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

ll a,b;
cin>>a>>b;

ll dup=b,p=1;
while(dup)
{
  p*=10;
  dup/=10;
}

ll x=a*p+b;
double root=sqrt(x);

if(floor(root)==root)cout<<"Yes"<<"\n";
else cout<<"No"<<"\n";

  return 0;

}

Measured memory_bytes: 256