akhauriyash/Code-Regression huggingface dataset:
/*
*          Name : chaitanya
*
*     Institute : ANITS,Visakhapatnam
*
*/
#include<cstdio>
#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
#define all(x) begin(x),end(x)
#define ll long long int
#define ff first
#define ss second
#define pb push_back
const ll mod = 1000000007;
#pragma GCC optimization ("O3")
const int N = 1000010;
using namespace std;
int main()
{
 
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
     //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    string s;
    cin >> s;
    if( !(s[0]== '7' || s[1] == '7' || s[2] == '7') )
        cout << "No";
    else
        cout << "Yes"; 
    return 0;
} 


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

using namespace std;
const int N = 100010;
int _w;

int n, a[N];

int main() {
	_w = scanf( "%d", &n );
	for( int i = 1; i <= n; ++i )
		_w = scanf( "%d", a+i );
	sort(a+1, a+n+1, greater<int>());
	int p;
	for( int i = 1; i <= n; ++i )
		if( a[i] >= i ) p = i;
	int q;
	for( int i = 1; i <= n; ++i )
		if( a[i] >= p ) q = i;
	int c1 = (a[p] - p) & 1;
	int c2 = (q - p) & 1;
	puts( c1 || c2 ? "First" : "Second" );
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

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

vector<int> par;
vector<int> rnk;

void init(int n){
    par = vector<int>(n);
    rnk = vector<int>(n);
    for (int i = 0; i < n; i++){
        par[i] = i;
        rnk[i] = 0;
    }
}

int find(int x){
    if (par[x] == x) return x;
    return par[x] = find(par[x]);
}

void unite(int x, int y){
    x = find(x);
    y = find(y);
    if (x == y) return;

    if (rnk[x] < rnk[y]) par[x] = y;
    else{
        par[y] = x;
        if (rnk[x] == rnk[y]) rnk[x]++;
    }
}

bool same(int x, int y){
    return find(x) == find(y);
}

int main(){
    int n, m;
    cin >> n >> m;
    init(2 * n);
    for (int i = 0; i < n; i++){
        int p;
        cin >> p;
        unite(i, p - 1 + n);
    }

    for (int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        unite(x - 1, y - 1);
    }

    int ans = 0;
    for (int i = 0; i < n; i++){
        if (same(i, i + n)) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
#define pb push_back
#define F  first
#define S  second
#define int ll
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define edl "\n"
#define ceils(s,n) (s+n-1)/n
#define str string
#define add insert
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, N = 1e5 + 10;
const ll LINF = LLONG_MAX;
ll a,b,c,sum;
str s,s1,s2;
int32_t main() {
    fast();
    cin >>a >>b >> c;
    if(a+b+c>=22){
    	cout<<"bust";
    } 
    else{
    	cout<<"win";
    }

    cerr << "\nTime taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}
 

Measured memory_bytes: 256
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    ans = 0
    pre = False
    for i, a in enumerate(A):
        if pre:
            pre = False
        elif i+1 == a:
            ans += 1
            pre = True
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 52908
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>

using namespace std;
using pii=pair<int,int>;
using ll=long long;

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

    int n;
    cin>>n;
    vector<pii> v(n);
    for(int i=0; i<n; i++) cin>>v[i].second>>v[i].first;
    sort(v.begin(),v.end());

    int now=0;
    bool answer=true;
    for(int i=0; i<n; i++){
        now+=v[i].second;
        if(now>v[i].first){
            answer=false;
            break;
        }
    }

    if(answer) cout<<"Yes";
    else cout<<"No";

    return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <math.h>
#include <cstdio>
#include <string.h>
#include <vector>
#include <functional>
#include <stack>
#include <queue>
#include <string>
#include <list>
using namespace std;
typedef long long ll;
/* prototype */
int EDSum(ll);//各桁の和
vector<int> SOE(int,int);//素数 (Min,Max)
int MinCM(int,int);//最小公倍数(num1,num2)
int MaxCD(int,int);//最大公約数(num1,num2)
vector<int> igets(int);//cin * N
ll nPr(ll,ll); //(n,r)
ll nE(ll); //(n)
ll nCr(ll,ll); //(n,r)

void solve(){
    //START
  	char A,B[] = {'a','e','i','o','u'};
  	cin >> A;
  	for(int i=0;i<=4;++i)
      if(B[i]==A){
    	  cout << "vowel" << endl;
			exit(0);
      }
    cout << "consonant" << endl;
}

int main(void){cin.tie(0);ios::sync_with_stdio(false);solve();}
/*FUNC*/
//各桁の和
int EDSum(ll number){
    int ans=0;
    while(1){
        ans += number % 10;
        number /= 10;
        if(number == 0) break;
    }
    return ans;
}

//エラトステネスのふるい(素数発見アルゴリズム)
vector<int> SOE(int min, int max)
{
    //0,1は含まれない
    if (min < 2) min = 2;
    //探索リスト作成
    vector<int> int_array;
    for (int i = min; i <= max; i++) int_array.push_back(i);
    //素数リスト
    vector<int> sosu;
    //√max
    double stop = sqrt(max);
    //計算
    while (true)
    {
        //素数リストに追加
        sosu.push_back(int_array.front());
        int_array.erase(int_array.begin());
        //停止
        if (stop < (double)(sosu.back())) break;
        //ふるい
        for (int i = 0; i < (int)int_array.size(); i++)
        {
            if (int_array[i] % sosu.back() == 0)
                int_array.erase(int_array.begin() + i);
        }
    }
    sosu.insert(sosu.end(), int_array.begin(), int_array.end());
    return sosu;
}

//最小公倍数
int MinCM(int a, int b)
{
    int c = a * b;
//入れ替え
    if (a < b)
        swap(a, b);
    int r = a % b;
    while (r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }
    return c / b;
}

//最大公約数
int MaxCD(int a, int b)
{
//入れ替え
    if (a < b)
        swap(a, b);
    int r = a % b;
    while (r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
//iget cin int 2 vector
vector<int> igets(int N){
    vector<int> A;
    int temp;
    for (int i = 0; i < N; ++i) {
        cin >> temp;
        A.push_back(temp);
    }
    return A;
}

ll nPr(ll n,ll r) {
    ll ans=1;
    r=n-r;
    while(n!=r) {
        ans*=n;
        --n;
    }
    return ans;
}

ll nE(ll n) {
    return nPr(n,n);
}

ll nCr(ll n,ll r) {
    if(r==0)return -1;
    else{
        if(0!=n-r&&n-r<r)r=n-r;
        return nPr(n,r)/nE(r);
    }
}

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

dp = [float('inf')] * 2**n

dp[0]=0

for i in range(m):
    a,b = map(int, input().split())
    c = list(map(int, input().split()))
    key = 0
    for j in c:
        key+=2**(j-1)
    for j in range(len(dp)):
        dp[j|key] = min(dp[j|key], dp[j]+a)

print(dp[-1] if dp[-1]!=float('inf') else -1)






Measured memory_bytes: 50652
n = int(input())
def solve(n):
  l = [0]*(n**3)
  for x in range(1,n+1):
    for y in range(1,n+1):
      for z in range(1,n+1):
        l[x**2+y**2+z**2+x*y+y*z+z*x] += 1
  return l
l = solve(100)
print(*l[1:n+1])

Measured memory_bytes: 76024
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<string>
#include<cmath>
#include<numeric>
using namespace std;


int main(void) {

  string s;
  while(cin >> s){
    if( s == "-" ) break;

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

    string tmp = "";
    for(int i=0; i<n; i++){
      tmp = "";
      for(int j=h[i]; j<s.size(); j++) tmp += s[j];
      for(int j=0; j<h[i]; j++) tmp += s[j];
      s = tmp;
      // cerr << s << endl;
    }
    cout << s << endl;
  }



  return 0;
}

Measured memory_bytes: 3144
#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;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << 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 input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    string s; cin>>s;
    rep(i,3) {
        if (s[i]=='7') {
            cout << "Yes" << '\n';
            return 0;
        }
    }
    cout << "No" << '\n';
    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod=1e9+7;
ll dp[1001][1001];
int main()
{
	ll n,m,i,j;
	cin >> n >> m;
	string s[n];
	for(i=0;i<n;i++)
		cin >> s[i];
	
	dp[0][0]=1;	
	for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
		{
			ll r1=i+1;
			ll c1=j;
			ll r2=i;
			ll c2=j+1;
			if(r1<n && c1<m && s[r1][c1]=='.')
			{
				dp[r1][c1]+=dp[i][j];
				dp[r1][c1]%=mod;
			}
			if(r2<n && c2<m && s[r2][c2]=='.')
			{
				dp[r2][c2]+=dp[i][j];
				dp[r2][c2]%=mod;
			}
		}
	}
	cout<<dp[n-1][m-1]<<"\n";
}


Measured memory_bytes: 9088
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#define REP(i, n) for(int i=0; i<n; i++)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define INF 10000000000;
using namespace std;
typedef unsigned long ul;
typedef long long ll;
typedef pair<ll, ll> p;

int main(void) {
    ll n, a, b;
    cin >> n >> a >> b;
    if(a>b) {
        cout << 0 << endl;
        return 0;
    }
    ll ans=b*(n-1)+a-a*(n-1)-b+1;
    if(ans<0) {
        cout << 0 << endl;
        return 0;
    }
    cout << ans << endl;
    
    
}


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

constexpr int64_t mod = 1'000'000'007; //'

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> edges[100000];
    for(int i=0;i<n-1;++i){
        int a, b;
        cin >> a >> b;
        --a; --b;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    static int v[100000];
    queue<pair<int,int>> q;
    int64_t ans = k;
    v[0] = 1;
    for(int to: edges[0]) q.emplace(to, 0);
    while(!q.empty()){
        int nv, np;
        tie(nv, np) = q.front();
        q.pop();
        if(v[np] >= k){
            cout << 0 << endl;
            return 0;
        }
        ans = ans * (k-v[np]) % mod;
        v[nv] = 2;
        ++v[np];
        for(int to: edges[nv]){
            if(v[to] == 0) q.emplace(to, nv);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 7288
# 入力
N=int(input())
l=list(map(int,input().split()))

# カウンタ
c=0

# ループ脱出フラグ
f=False

while True:
  # 各整数を割る
  for i in range(len(l)):
    if l[i]%2==0:
      l[i]//=2
    else:
      # 割り切れない数があった場合はフラグを立てる
      f=True
      break
  # カウンタを加算
  c+=1

  # フラグが立ったらループ終了
  # カウンタを一回多く加算しているので減らす
  if f:
    c-=1
    break

# 出力
print(c)

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

#define DEBUG(x) cout << "DEBUG>" << #x << ":" << x << endl;
#define REP(i,n) for(long long i=0;i<(n);i++)
#define FOR(i,a,b) for(long long i=(a);i<=(b);i++)

int main() {
  string S;
  cin >> S;
  if(S[5] == '0' && S[6] <= '4') {
    cout << "Heisei" << endl;
  } else {
    cout << "TBD" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
H,W = gets.split.map(&:to_i)
x = ("."*(W+2)).split('')
s = [x]

H.times do
  s << ('.'+gets.chomp+'.').split('')
end
s << x
  

1.upto(H) do |j|
  1.upto(W) do |i|
    next if s[j][i] == '#' 
    c=[]
    -1.upto(1) do |y|
      -1.upto(1) do |x|
        c << s[j+y][i+x]
      end
    end
    s[j][i] = c.count('#')
  end
  puts s[j][1..W].join
end

Measured memory_bytes: 2556
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define int long long
#define ll long long 
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define rep(i, a, b) for(int i = a; i < b; i++)
#define repr(i, a, b) for(int i = a - 1; i >= b; i--)
#define iter(m) for(auto it = m.begin(); it != m.end(); it++)
#define iterr(m) for(auto it = m.rbegin(); it != m.rend(); it++)
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll mx = 0;
ll n, m, t;
vector<vector<ll>> dataa;
vector<ll> v;
void solve() {
    ll sum = 0;
    for(int i = 0; i < t; i++) {
        if(v[dataa[i][1] - 1] - v[dataa[i][0] - 1] == dataa[i][2]) {
            sum += dataa[i][3];
        }
    }
    mx = max(mx, sum);
}
void rec(int ind) {
    if(ind == n) {
        solve();
        return;
    } else {
        for(int i = 0; i <= m; i++) {
            if(ind == 0) {
                v[ind] = i;
                if(v[ind] >= m) return;
                rec(ind+1);
            } else {
                v[ind] = v[ind - 1] + i;
                if(v[ind] >= m) return;
                rec(ind+1);
            }
        }
    }
}
signed main(){
   speed;
   cin >> n >> m;
   v = vector<int> (n); 
   cin >> t;
   dataa = vector<vector<int>> (t, vector<int> (4));
   rep(i, 0, t) {
       int a, b, c, d;
       cin >> a >> b >> c >> d;
       dataa[i][0] = a;
       dataa[i][1] = b;
       dataa[i][2] = c;
       dataa[i][3] = d;
   }
    rec(0);
    cout << mx;
}


Measured memory_bytes: 3672
#include <iostream>
#include <string>

using namespace std;

int main() 
{
    int shift;
    string str;
    
    cin >> shift >> str;
    shift %= 26;
    
    for(int i=0 ; i<str.size() ; i++)
    {
        if(str[i]+shift > 'Z')
        {
            int temp = 'Z' - str[i];
            str[i] = 'A' + (shift-temp-1);
        }
        else
            str[i] += shift;
    }
    cout << str;
    
    return 0;
}

Measured memory_bytes: 256
n = int(input())
dat = []
s = input()
t = input()
i = 0
while i < n:
    if s[i] == t[i]:
        dat.append(0)
        i+=1
    else:
        dat.append(1)
        i+=2
#print(dat)
res = 0
prev = None
if dat[0] == 0:
    res = 3
    prev = 0
else:
    res = 6
    prev = 1
for i in range(1, len(dat)):
    if prev == 0 and dat[i] == 0:
        res *= 2
    elif prev == 0 and dat[i] == 1:
        res *= 2
    elif prev == 1 and dat[i] == 0:
        res *= 1
    elif prev == 1 and dat[i] == 1:
        res *= 3
    prev = dat[i]
print(res % 1000000007)



Measured memory_bytes: 61812
#include<iostream>
#include<cstdio>
#include<set>
using namespace std;

int main(){

    int N,count = 0;
    cin >> N;
    long long int A;
    set<long long int> number;
    set<long long int>::iterator ite;

    for(int i = 0;i < N;i++){

        cin >> A;
        ite = number.find(A);
        if(ite == number.end()){
            number.insert(A);
            count++;
        }else{
            count--;
            number.erase(A);
        }
    }
    
    cout << count << endl;

    return 0;
}

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

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

    bool ret = false;
    int num = 0;
    while(num < b){
        num += k;
        if (num >= a && num <= b){
            ret = true;
            break;
        }
    }

    cout << (ret ? "OK" : "NG") << endl;

}


Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int value;
		int i = 0;

		while(true){
			value = scan.nextInt();
			if (value == 0)
				break;
			System.out.printf("Case %d: %d\n", ++i, value);
		}
	}
}

Measured memory_bytes: 62016
#include<bits/stdc++.h>
using namespace std;
int main(){
    int k,s;
    cin >> k >> s;
    int ans=0;
    for(int x=0;x<=k;x++){
        for(int y=0;y<=k;y++){
            if(s-x-y>=0&&s-x-y<=k)ans++;
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
import unittest


class TestA(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think(4), 48)

    def test_2(self):
        self.assertEqual(think(15), 675)

    def test_3(self):
        self.assertEqual(think(80), 19200)


def solve():
    r = read()
    result = think(r)
    write(result)


def read():
    return read_int(1)[0]


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_float(n):
    return list(map(lambda x: float(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(r):
    return 3 * r ** 2


def write(result):
    print(result)


if __name__ == '__main__':
    # unittest.main()
    solve()

Measured memory_bytes: 5644
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>

int people[100005][4];
int sum[100005];

int main(){
  int N;
  scanf("%d", &N);
  std::vector<int > A(N);
  for (int i=0; i<N; i++){
    scanf("%d", &A[i]);
  }
  int prev=0;
  long long ans=0;
  if (A[0]!=0){
    std::cout << "-1" << std::endl;
    return 0;
  }
  for (int i=1; i<N; i++){
    if (A[i]>prev+1) {
      std::cout << "-1" << std::endl;
      return 0;
    } else if (A[i]==prev+1){
      ans++;
    } else {
      ans+=A[i];
    }
    prev = A[i];
  }
  std::cout << ans <<std::endl;
  return 0;
}

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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()

signed main(){
    int a, b;
    cin >> a >> b;
    if(a + b >= 10){
        cout << "error" << endl;
    } else {
        cout << a + b << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<bits/stdc++.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstdio>
#include<map>
#include<set>
#define  queues      priority_queue
#define mod  1000000007
#define mem(a)  memset(a,0,sizeof(a));
#define def(a) ((a)&(-a))
#define fi  first
#define se  second
#define mp  make_pair
#define  pb push_back
typedef long long unsigned ull;
typedef long long ll;
const ll maxn=10003;
//priority_queue<ll,vector<ll >,greater<ll > >q;
const int INF=0x3f3f3f3f;
//const double E=exp(1);
const double PI=acos(-1);
using namespace std;
//__builtin_popcount
//priority_queue
ll kc(ll a,ll b)
{
    ll c=1;
    while(b)
    {
        if(b&1)c=(c*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return c;
}
int kc(int a,ll b,int mod1)
{
    int c=1;
    while(b)
    {
        if(b&1)c=(ll)c*a%mod1;
        a=(ll)a*a%mod1;
        b>>=1;
    }
    return c;
}
inline char nc()
{
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline ll read()
{
    char ch=nc();
    ll sum=0;
    while(!(ch>='0'&&ch<='9'))ch=nc();
    while(ch>='0'&&ch<='9')sum=sum*10+ch-48,ch=nc();
    return sum;
}
int gcd(int a,int b)
{
    return b==0?a:gcd(b,a%b);
}
bool cmp(ll a,ll b)
{
    return a>b;
}
struct A{
 int x,y;
 bool operator <(A z)
 {
     return y<z.y;
 }
}s[maxn];
int dp[2][1000003];
ll f[1000003];
int sum[103];
int main()
{ /*f[1]=1;
ll sum=0;
  for(int i=2;i<=30;i++)
  {
      sum+=f[i-1]*(i-1);
      f[i]=sum%i;

  }

 int t;
  scanf("%d",&t);
  while(t--)
  {
      ll n; scanf("%lld",&n);
     // for(int n=1;n<=nn;n++){
      if(n%6==0)cout<<n/2<<endl;
      else {ll z=n/6;
        if(n%6==1)cout<<(ll)1+(z)*4<<endl;
         if(n%6==2)cout<<n/2<<endl;
         if(n%6==3)cout<<(ll)1+(z)*4-n/2<<endl;
         if(n%6==4)cout<<n-1<<endl;
         if(n%6==5)cout<<n%5<<endl;

      }
  }*/
  string s;cin>>s;
  int a=s.size();
  int sum=1;
  int x=0;
  for(int i=1;i<a;i++)
     if(s[i]==s[i-1]&&!x&&(i+1)<a)
  {
      sum++;i++;x=1;
  }
  else if(s[i]!=s[i-1]||x)
    {
    sum++;x=0;
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-
H, W = map(int, input().split())
HW_list = []

for i in range(H):
    HW_list.append(str(input()))

dp = [[H * W] * W] * H

dp[0][0] = 0
for i in range(H):
    for j in range(W):
        if i == 0 and j == 0:
            continue
        if i == 0:
            min_num_h = H * W
        else:
            min_num_h = dp[i - 1][j] + (0 if HW_list[i][j] == HW_list[i - 1][j] else 1)
        if j == 0:
            min_num_w = H * W
        else:
            min_num_w = dp[i][j - 1] + (0 if HW_list[i][j] == HW_list[i][j - 1] else 1)
        dp[i][j] = min(min_num_h, min_num_w)

print(dp[H - 1][W - 1] // 2 + (1 if HW_list[0][0] == "#" or HW_list[H - 1][W - 1] == "#" else 0))

Measured memory_bytes: 3064
n = int(input())
s = input()

# 左側の黒の個数, 右側の白の個数
b, w = 0, s.count('.')
ans = min(s.count('#'), w)
for i in range(n):
    if s[i] == '#':
        b += 1
    elif s[i] == '.':
        w -= 1
    ans = min(ans, b+w)
print(ans)

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

int N, K;
const int MAX_N = 1.0e5;
char x[MAX_N];

vector<int> modify(char nums[]) {
    vector<int> ret;

    if (nums[0] == '0') ret.push_back(0);

    for (int i = 0; i < N;) {
        int cnt = 0;
        for (int j = i; j < N; j++) {
            if (nums[i] == nums[j]) {
                cnt++;
                
                if (j == N-1) {
                    if (nums[i] == '1') ret.push_back(cnt);
                    else ret.push_back(-cnt);

                    i = N;
                    break;
                }
            }
            else {
                if (nums[i] == '1') ret.push_back(cnt);
                else ret.push_back(-cnt);
                
                i = j;
                break;
            }
        }
    }

    if (nums[N-1] == '0') ret.push_back(0);

    return ret;
}

int main() {
    cin >> N >> K;
    for (int i = 0; i < N; i++) cin >> x[i];

    vector<int> x_vec = modify(x);

    int ans = 0;
    int length = x_vec.size();


    if (2*K > length) {
        for (int i = 0; i < length; i++) {
            ans += abs(x_vec[i]);
        }
    }
    else {
        for (int i = 0; i < length - 2*K; i += 2) {
            int sakadachi = 0;
            for (int j = i; j < i + 2*K + 1; j++) {
                sakadachi += abs(x_vec[j]);
            }
            ans = max(ans, sakadachi);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1020
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int length = sc.nextInt();
		String[] str = new String[num];
		for (int i = 0; i < num; i++) {
			str[i] = sc.next();
		}

		Arrays.sort(str);
		StringBuffer res = new StringBuffer();
		for (String s : str) {
			res.append(s);
		}
		System.out.println(res);

	}
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int n,i,h=0,count=0;
    scanf("%d",&n);
    int a[n];
    for(i=0; i<n; i++)
        scanf("%d",&a[i]);
    for(i=0,h=0; h<n-1;)
    {
        h++;
        if(a[i]>=a[h])
        {
            count++;
            i=h;
        }
    }
    printf("%d",count+1);
    return 0;
}


Measured memory_bytes: 896
#include<stdio.h>
int main(void)
{
	int t,g=0,h,i;
	for(i=0; i<5; i++)
	{
		scanf("%d", &t);
		if(t<40)
		t=40;
		g+=t;
	}
	h=g/5;
	printf("%d\n", h);
	
	return 0;
}


Measured memory_bytes: 2052
#include <stdio.h>
#include <math.h>
 
int main(void){
  int a,b;
  int i,tmp;
   
  while(scanf("%d %d",&a,&b)!=EOF){
    printf("%d\n",(int)log10((float)a+b) + 1);
  }
   
  return 0;
}
 

Measured memory_bytes: 640
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();
        int x = sc.nextInt();
        
        double ans = 0;

        if(x==a*a*b/2.0){
            double h = b;
            double i = Math.sqrt(a * a + b * b);
            ans = Math.toDegrees(Math.asin(h / i));
        }
        else if(x<a*a*b/2.0){
            double h = 2.0 * x / b / a;
            double i = Math.sqrt(h * h + b * b);
            ans = 90 - Math.toDegrees(Math.asin(h / i));
        }
        else{
            double h = 2 * b - 2.0 * x / a / a;
            double i = Math.sqrt(h * h + a * a);
            ans = Math.toDegrees(Math.asin(h / i));
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21972
r, c = map(int, input().split())
queue = []
for _ in range(r):
    row = list(map(int, input().split()))
    row.append(sum(row))
    queue.append(row)

queue.append([])

for i in range(c):
    tmp = 0
    for j in range(r):
        tmp += queue[j][i]
    queue[r].append(tmp)

queue[r].append(sum(queue[r]))

[print(queue[i][j]) if j == c else print(queue[i][j], end=' ') for i in range(r + 1) for j in range(c + 1)]



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

int main(){
    int W,H,x,y,r;
    
    cin>>W>>H>>x>>y>>r;
    if((x>=r && y>=r)&&(x<=(W-r)&&y<=(H-r)))
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 3092
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N, K = list(map(int, sys.stdin.readline().split()))
A = list(map(int, sys.stdin.readline().split()))


def bisect_left_callable(fn, x, lo, hi):
    """
    (memo) いっぱい呼ぶなら np.searchsorted のほうがベクトル化されててはやそう
    lo から hi-1 のうち、fn の結果が x 以上となる、最も左の値
    bisect.bisect_left と同じ
    https://docs.python.org/ja/3/library/bisect.html
    :param callable fn:
    :param x:
    :param int lo: 最小値
    :param int hi: 最大値 + 1
    :return: lo <= ret <= hi
    """
    while lo < hi:
        mid = (lo + hi) // 2
        if fn(mid) < x:
            lo = mid + 1
        else:
            hi = mid
    return lo


def is_necessary(ai):
    # A[ai] が必要かどうか
    # A[ai] を使わずに K-A[ai] 以上 K 未満を作れるか

    # dp[j]: j を作れる
    dp = np.zeros(K, dtype=bool)
    dp[0] = 1
    for i, a in enumerate(A):
        if i == ai:
            continue
        dp[a:] = dp[a:] | dp[:-a]
    return any(dp[K - A[ai]:])


A.sort()
unnecessary = bisect_left_callable(is_necessary, 1, lo=0, hi=N)
print(unnecessary)


Measured memory_bytes: 13640
startX, countK, distanceD = map(int, input().split())
n = int(abs(startX) / distanceD)
ans = abs(startX) % distanceD
if n > countK:
    ans += distanceD * (n - countK)
else:
    if (countK - n) % 2 == 1:
        ans= abs(ans - distanceD)
print(ans)


Measured memory_bytes: 9132
import java.util.Scanner;

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

		int W = scan.nextInt();
		int H = scan.nextInt();
		int x = scan.nextInt();
		int y = scan.nextInt();
		int r = scan.nextInt();
		
		if(x-r>=0 && x+r<=W && y+r<=H && y-r>=0){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

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

int main()
{
    long long int n;
    int AC=0, WA=0, TLE=0, RE=0;

    cin>>n;

    string S[n];
    for(int i=0; i<n; i++){
        cin>>S[i];
    }

    for(int j=0; j<n; j++){
        if(S[j] == "AC"){AC++;}
        else if(S[j] == "WA"){WA++;}
        else if(S[j] == "TLE"){TLE++;}
        else if(S[j] == "RE"){RE++;}
    }
    cout<<"AC x "<<AC<<endl;
    cout<<"WA x "<<WA<<endl;
    cout<<"TLE x "<<TLE<<endl;
    cout<<"RE x "<<RE<<endl;

    return 0;
}


Measured memory_bytes: 6692
#include<iostream>
#include<cstring>
#include<queue>
using namespace std;
bool visit[102][102];
char map[102][102];
int step[102][102];
int dir[4][2]={0,1,1,0,-1,0,0,-1};
int h,w;
struct node{
	int xx,yy;
	node(){}
	node(int x,int y){
		this->xx=x;
		this->yy=y;
	}
}point;
int  bfs()
{
	queue<node> q;
	step[0][0]=1; 
	q.push(node(0,0));
	while(!q.empty())
	{
		point=q.front();
		q.pop();
		visit[0][0]=1;
		for(int i=0;i<4;i++)
		{
			int tx=point.xx+dir[i][0];
			int ty=point.yy+dir[i][1];
			if(tx==h-1&&ty==w-1)return step[point.xx][point.yy]+1;
			if(tx>=0&&ty>=0&&tx<h&&ty<w&&visit[tx][ty]==0&&map[tx][ty]=='.')
			{
				visit[tx][ty]=1;
				step[tx][ty]=step[point.xx][point.yy]+1;
				q.push(node(tx,ty));
			}
		}
	}
	return -1;
}
int main()
{
	cin>>h>>w;
	int hei=0; 
	memset(visit,0,sizeof(visit));
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			cin>>map[i][j];
			if(map[i][j]=='#')hei++; 
		}
	}
	int res=bfs();
	if(res==-1)cout<<"-1"<<endl;
	else cout<<h*w-res-hei<<endl;
	return 0;
} 

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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};


int main(){
  int N, M;
  cin >> N >> M;
  
  UnionFind tree(N);
  
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  for (int j = 0; j < M; j++) {
    int x, y;
    cin >> x >> y;
    tree.unite(x - 1, y - 1);
  }
  
  
  int ans = 0;
  for(int k=0 ; k < N; k++){
    if (tree.same(k, vec[k] - 1)){
      ans++;
    }
  }
  
  cout << ans << endl;
  return 0;
  
}  

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

int N, C, K;
int T[1000010];

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

    for (int i = 0; i < N; i++)
    {
        scanf("%d", &T[i]);
    }

    sort(T, T + N);

    int cnt = 0;
    for (int i = 0; i < N;)
    {
        int start = i;

        while (i < N && T[i] - T[start] <= K && i - start < C)
        {
            i++;
        }
        cnt++;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define up(l,r,i) for(int i=l;i<=r;i++)
#define dn(l,r,i) for(int i=l;i>=r;i--)
using namespace std;

typedef long long LL;
const int INF =2147483647;
int qread(){
	int w=1,c,ret;
	while((c=getchar())> '9'||c< '0')
	w=(c=='-'?-1:1); ret=c-'0';
	while((c=getchar())>='0'&&c<='9')
	ret=ret*10+c-'0';
	return ret*w;
}
bool tmp;
LL ans,t;
int main(){
	dn(qread(),1,T){
		t=qread();
		if(tmp&&t) ans++,t--;
		ans+=(t>>1),tmp=t&1;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n,a;cin>>n>>a;
  int sm = 0;
  int mn = 100000;
  for(int i = 0; n > i; i++){
    sm += a+i;
   	if(abs(a+i) < abs(mn)){
      mn = a+i;
    }
  }
  cout << sm-mn << endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::Integer;
#[allow(unused_imports)]
use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp;

fn index(s: &str) -> (usize, usize) {
  match s {
    "AB" => (0, 1),
    "AC" => (0, 2),
    _ => (1, 2),
  }
}

fn solve(abc: &mut Vec<i64>, s: &Vec<String>) -> Option<Vec<char>> {
  if abc.iter().sum::<i64>() == 0 {
    return None;
  }
  let mut ans = vec![];
  for i in 0..s.len() {
    let (l, r) = index(&s[i]);
    let (al, ar) = (abc[l], abc[r]);
    let mut pass = |src: usize, dst: usize| {
      ans.push(['A', 'B', 'C'][dst]);
      abc[src] -= 1;
      abc[dst] += 1;
    };
    match (al, ar) {
      (0, 0) => return None,
      (1, 1) => {
        if i == s.len() - 1 || s[i] == s[i + 1] {
          pass(l, r);
        } else {
          let (nl, nr) = index(&s[i + 1]);
          if l == nl || l == nr {
            pass(r, l);
          } else {
            pass(l, r);
          }
        }
      }
      (al, ar) if al > ar => {
        pass(l, r);
      }
      _ => {
        pass(r, l);
      }
    }
  }

  Some(ans)
}

#[fastout]
fn main() {
  input! {
    n: usize,
    mut abc: [i64; 3],
    s: [String; n],
  }
  match solve(&mut abc, &s) {
    None => {
      println!("No");
    }
    Some(v) => {
      println!("Yes");
      for c in &v {
        println!("{}", c);
      }
    }
  }
}


Measured memory_bytes: 8328
#include <iostream>
using namespace std;
int main() {
    int n;
    cin>>n;
    string s;
    cin>>s;
    int cnt=0;
    for(int i=0;i<n-2;i++)
    {
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
        {
            cnt++;    
            i+=2;
        }
    }
    cout<<cnt<<endl;
}


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

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr = ds.begin(); itr != ds.end(); ++itr)
#define mp make_pair
#define INF 1000000000
#define MOD 1000000007
#define PI 3.1415926536
typedef long long ll;
typedef pair<int, int> P;

int main() {
	string s;
	cin >> s;
	int l, r;
	rep(i, s.length()) {
		if (s[i] == 'A') {
			l = i;
			break;
		}
	}
	reprev(i, s.length()) {
		if (s[i] == 'Z') {
			r = i;
			break;
		}
	}
	cout << r - l + 1 << endl;

	return 0;
}

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

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

    int a = n[n.size() - 1] - '0';

    if (a <= 1 || a == 6 || a == 8)
        cout << "pon" << endl;
    else if (a == 3)
        cout << "bon" << endl;
    else
        cout << "hon" << endl;
    return 0;
}


Measured memory_bytes: 3624
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

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

func main() {
	n, _ := strconv.Atoi(input())
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i], _ = strconv.Atoi(input())
	}

	ans := 1
	state := "eq"
	for i := 1; i < n; i++ {
		if a[i] == a[i-1] {
			continue
		}
		if state == "eq" {
			if a[i] > a[i-1] {
				state = "up"
			} else {
				state = "down"
			}
		}
		if state == "up" && a[i] < a[i-1] {
			state = "eq"
			ans++
		}
		if state == "down" && a[i] > a[i-1] {
			state = "eq"
			ans++
		}
	}
	fmt.Println(ans)
}


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

using namespace std;

int main()
{
    int D,N;
    cin>>D>>N;
    if(D==0 && N%100==0) cout<<N+1<<endl;
    else if(D==0) cout<<N<<endl;
    else
    {
        for(int i=0;i<D;i++)
        {
            if(N==100) N=N*101;
            else N=N*100;
        }
        cout<<N<<endl;
    }
    return 0;
}


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

using ll = long long;
using pll = pair<ll, ll>;
using pii = pair<int, int>;
using ull = unsigned long long;

#define NL '\n'
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define sii(x, y) scanf("%d%d",&x, &y)
#define sll(x, y) scanf("%lld%lld",&x, &y)

#define xx first
#define yy second
#define ins insert
#define mp make_pair
#define pb push_back
#define mdx ((l+r)>>1)
#define ldx ((idx<<1))
#define rdx ((idx<<1)|1)
#define sz(x) x.size()
#define pi 2.0*acos(0.0)
#define sqr(x)  ((x) * 1ll * (x))
#define all(x) (x).begin(),(x).end()
#define mem(a, b) memset(a, b, sizeof(a))
#define file_in(); freopen("input.txt", "r", stdin);
#define file_out(); freopen("output.txt", "w", stdout);
#define file_err(); freopen("serr.txt", "w", stderr);
#define rep(ii,aa,bb) for(ll (ii)=ll(aa);(ii)<(ll)(bb);++(ii))
#define _fastIO() ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define _runtime() cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"

template<class T> T setbit(T n, T pos){n=n|(1<<pos); return n;}
template<class T> T checkbit(T n, T pos){n=n&(1<<pos); return n;}
template<class T> T gcd(T a, T b ) {return b<=0?a:gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return ((a / gcd(a,b) ) * b);}


const ll inf = 1e17;


const int mxx = 1e5+9;
int n, w, a[101], b[101];
ll dp[101][mxx], ans;


ll f(int pos, int val){
	if(pos == n){
	 if(val > 0) return inf; 
	 return 0;
	}
	ll &ret = dp[pos][val];
	if(ret != -1) return ret;
	ret = min(inf, f(pos + 1, val));
	if(val - b[pos] >= 0) ret = min(ret, a[pos] + f(pos + 1, val - b[pos]));
	return ret;
}

int main(){
	_fastIO();
	cin >> n >> w;
	rep(i, 0, n) cin >> a[i] >> b[i];
	mem(dp, -1);
	for(int i = 0; i <= 1e5; i++){
		ll z = f(0, i);
		if(z <= w) ans = i; 
	}
	cout << ans << NL;
}


Measured memory_bytes: 79232
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

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

  vector<int> m;
  m.emplace_back(1);
  for(int i=1;pow(6,i)<=n;i++) m.emplace_back(pow(6,i));
  for(int i=1;pow(9,i)<=n;i++) m.emplace_back(pow(9,i));
  sort(ALL(m));

  vector<int> dp(n+1,100000);
  REP(i,n+1){
    if(i==0) dp[0]=0;
    else{
      REP(j,m.size()){
        if(m[j]>i) continue;
        dp[i]=min(dp[i],dp[i-m[j]]+1);
      }
    }
  }
  cout<<dp[n]<<endl;

  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <random>
using namespace std;
typedef long long ll;


int main()
{
	string s, t;
	cin >> s >> t;
	int minN = 987654321;
	for (int i = 0; i <= s.size()-t.size(); i++)
	{
		int cnt = 0;
		for (int j = 0; j < t.size(); j++)if (s[i + j] != t[j])cnt++;
		minN = min(cnt, minN);
	}
	cout << minN;
}

Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define N	    100001
#define rep(i,a,b)  for(int i=a;i<b;i++)
typedef long long ll;
void solve(){
	string s;
	cin>>s;
	int k;
	cin>>k;
	set<string> st;
	for(int i = 0; i < s.size(); i++) {
		for(int j = 0; j <= 7; j++) {
			st.insert(s.substr(i, j));
		}
	}
	auto it = st.begin();
	advance(it, k);
	cout<<*it<<endl;
}
int main() {
	int t;
//	cin>>t;
	t = 1;
	while(t--){
		solve();
	}
}


Measured memory_bytes: 2560
import java.util.Scanner



object Main {

  def read(): (Int, IndexedSeq[String]) = {
    val sc: Scanner = new Scanner(System.in)
    val n = sc.nextInt()
    val arr = (1 to n).map { _ =>
      sc.next()
    }
    sc.close()
    (n, arr)
  }


  def solve(n: Int, arr: IndexedSeq[String]): Long = {
    val defaultMap: Map[String, Int] = Map.empty
    val combinationMap = arr.foldLeft(defaultMap) { (stock, str) =>
      val sortedStr = str.sorted
      stock.get(sortedStr) match {
        case None => stock + (sortedStr -> 1)
        case Some(x) => stock + (sortedStr -> (x + 1))
      }
    }
    val combinationCount: Long = combinationMap.values.toSeq.map{ num =>
      num * (num-1L) / 2L
    }.sum

    if(combinationMap.isEmpty) 0
    else combinationCount
  }


  def main(args: Array[String]): Unit = {
    val (n, arr) = read()
    println(solve(n, arr))
  }

}


Measured memory_bytes: 108064
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <cstdio>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
    ll a,b,c,k;
    cin >> a >> b >>c >> k;
    ll t = max(a,max(b,c));
    ll s = t;
    for(ll i=0;i<k;i++){
        t *= 2;
    }
    cout << a+b+c+t-s << endl;
    return 0;
}

Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;

int main(){
    fastio
    int n , L ; 
    cin >> n >> L ; 
    vector<int> v(n) ; 
    int target = 0 ; 
    for(int i=0;i<n;i++){
    	v[i] = L + i; 
    	target += v[i] ; 
    }
    debug() << imie(target) ; 
    debug() << imie(v) ; 
    int ans = 1e5 ; 
    int res = 0 ; 
    for(int i=0;i<n;i++){
    	if ( abs(target - (target - v[i])) < ans ){
    		ans = abs(target - (target - v[i])) ; 
    		res = target - v[i] ; 
    	}
    }
    cout << res << endl;
    return 0 ;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

template<class T> inline void chmax(T& a, T b) { if(b > a) a = b; }

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

	for(int n, m; cin >> n >> m, n;) {
		vector<int> p;
		p.reserve(n);
		for(int i = 0; i < n; ++i) {
			int in;
			cin >> in;
			if(in <= m)
				p.push_back(in);
		}

		n = p.size();

		vector<int> score;
		score.reserve(n * n + n);
		for(int i = 0; i < n; ++i) {
			score.push_back(p[i]);
			for(int j = 0; j < n; ++j) {
				if(p[i] + p[j] <= m)
					score.push_back(p[i] + p[j]);
			}
		}

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

		int ans = 0;
		for(int i = 0, j = score.size() - 1; i <= j; ++i) {
			while(i <= j && score[i] + score[j] > m)
				--j;

			if(i <= j)
				chmax(ans, score[i] + score[j]);
		}

		cout << ans << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 5408
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
  }
}init;


int main(){

  int N;
  while(cin >> N){
    vector<vector<int>> g(N, vector<int>(N));

    REP(i,N){
      REP(j,N){
        if(i == j) continue;

        REP(k,10){
          if((i&bit(k)) != (j&bit(k))){
            g[i][j] = k+1;
            break;
          }
        }
      }
    }
    

  
  

    REP(i,N-1){
      FOR(j,i+1,N){
        cout << g[i][j] << " ";
      }
      cout << endl;
    }
  


  }
  return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
 
using namespace std;
using namespace __gnu_pbds;
 
//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!
 
// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(1e9 + 7)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long
 
//////////////////////
const int N = 200005;
 
int32_t main() {
 
    ios::sync_with_stdio(false);
    cin.tie(0); 
    cout.tie(0);

    priority_queue<int> pq1;
    int n,m;
    cin >> n >> m;

    rep(i,n) {
        int a;cin >> a;
        pq1.push(a);
    }

    while(!pq1.empty() and m--) {
        int elem = pq1.top();
        pq1.pop();
        elem /= 2;
        if(elem > 0) pq1.push(elem);
    }

    int sum = 0;
    while(!pq1.empty()) {
        sum += pq1.top();
        pq1.pop();
    }

    cout << sum << '\n';
}

Measured memory_bytes: 1400