Language: C++

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

using namespace std;

char a[5005];
char b[5005];
set<string>s;
string p;
int main()
{
    int k;
    scanf("%s",a);
    scanf("%d",&k);
    int len=strlen(a),j;
    for(int i=0;i<len;i++)
    {
        j=0;
        b[j++]=a[i];
        b[j]='\0';
        p=b;
        s.insert(p);
    }
    for(int i=0;i<len-1;i++)
    {
        j=0;
        b[j++]=a[i],b[j++]=a[i+1];
        b[j]='\0';
        p=b;
        s.insert(p);
    }
    for(int i=0;i<len-2;i++)
    {
        j=0;
        b[j++]=a[i],b[j++]=a[i+1],b[j++]=a[i+2];
        b[j]='\0';
        p=b;
        s.insert(p);
    }
    for(int i=0;i<len-3;i++)
    {
        j=0;
        b[j++]=a[i],b[j++]=a[i+1],b[j++]=a[i+2],b[j++]=a[i+3];
        b[j]='\0';
        p=b;
        s.insert(p);
    }
    for(int i=0;i<len-4;i++)
    {
        j=0;
        b[j++]=a[i],b[j++]=a[i+1],b[j++]=a[i+2],b[j++]=a[i+3],b[j++]=a[i+4];
        b[j]='\0';
        p=b;
        s.insert(p);
    }
    int m=0;
    for(set<string>::iterator it=s.begin();it!=s.end();it++)
    {
        m++;
        if(m==k)
        {
            cout<<*it<<endl;
        }
    }
    return 0;
}

Compiler output:
a.cc:11:1: error: 'set' does not name a type
   11 | set<string>s;
      | ^~~
a.cc:12:1: error: 'string' does not name a type; did you mean 'stdin'?
   12 | string p;
      | ^~~~~~
      | stdin
a.cc: In function 'int main()':
a.cc:24:9: error: 'p' was not declared in this scope
   24 |         p=b;
      |         ^
a.cc:25:9: error: 's' was not declared in this scope
   25 |         s.insert(p);
      |         ^
a.cc:32:9: error: 'p' was not declared in this scope
   32 |         p=b;
      |         ^
a.cc:33:9: error: 's' was not declared in this scope
   33 |         s.insert(p);
      |         ^
a.cc:40:9: error: 'p' was not declared in this scope
   40 |         p=b;
      |         ^
a.cc:41:9: error: 's' was not declared in this scope
   41 |         s.insert(p);
      |         ^
a.cc:48:9: error: 'p' was not declared in this scope
   48 |         p=b;
      |         ^
a.cc:49:9: error: 's' was not declared in this scope
   49 |         s.insert(p);
      |         ^
a.cc:56:9: error: 'p' was not declared in this scope
   56 |         p=b;
      |         ^
a.cc:57:9: error: 's' was not declared in this scope
   57 |         s.insert(p);
      |         ^
a.cc:60:9: error: 'set' was not declared in this scope
   60 |     for(set<string>::iterator it=s.begin();it!=s.end();it++)
      |         ^~~
a.cc:6:1: note: 'std::set' is defined in header '<set>'; this is probably fixable by adding '#include <set>'
    5 | #include <algorithm>
  +++ |+#include <set>
    6 | 
a.cc:60:13: error: 'string' was not declared in this scope
   60 |     for(set<string>::iterator it=s.begin();it!=s.end();it++)
      |             ^~~~~~
a.cc:6:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
    5 | #include <algorithm>
  +++ |+#include <string>
    6 | 
a.cc:60:31: error: missing template arguments before 'it'
   60 |     for(set<string>::iterator it=s.begin();it!=s.end();it++)
      |                               ^~
a.cc:60:44: error: 'it' was not declared in this scope; did you mean 'int'?
   60 |     for(set<string>::iterator it=s.begin();it!=s.end();it++)
      |                                            ^~
      |                                            int
a.cc:60:48: error: 's' was not declared in this scope
   60 |     for(set<string>::iterator it=s.begin();it!=s.end();it++)
      |                                                ^
a.cc:65:13: error: 'cout' was not declared in this scope
   65 |             cout<<*it<<endl;
      |             ^~~~
a.cc:6:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    5 | #include <algorithm>
  +++ |+#include <iostream>
    6 | 
a.cc:65:24: error: 'endl' was not declared in this scope
   65 |             cout<<*it<<endl;
      |                        ^~~~
a.cc:6:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    5 | #include <algorithm>
  +++ |+#include <ostream>
    6 |