For this Question: Sansa has discovered Theon is at Winterfell. Ramsay is forcing him to apologize to her for supposedly killing her younger brothers. But Sansa will accept the apology string S if it satisfies the following conditions for a given value of N:
<li> String S should have exactly <b>N distinct substrings</b>.
<li> Length of the string should be minimum possible.
<li> Among all shortest strings, S should be lexicographically smallest one.The first and the only line of input contains an integer N.

Constraints
1 <= N <= 300Output the apology string S.Sample Input
3

Sample Output
ab

Explanation: Distinct substrings of ab are: "a", "b", "ab"

Sample Input
7

Sample Output
aaab

Explanation: Distinct substrings of aaab are: "a", "b", "aa", "ab", "aaa", "aab", "aaab", I have written this Solution Code: #pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountll
#define m_p make_pair
#define infi 1e18+1
#define eps 0.000000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T>//usage rand<long long>()
T rand() {
    return uniform_int_distribution<T>()(rng);
}
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template<class T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
//////////////

typedef unsigned long long ull;
auto clk=clock();
#define all(x) x.begin(),x.end()
#define S second
#define F first
#define sz(x) ((long long)x.size())
#define int long long  
#define f80 __float128
#define pii pair<int,int>
/////////////
 
int n;
 
int get(string s) {
	set<string> all;
	for (int i=0; i<sz(s); i++)
		for (int l=1; l<=sz(s)-i; l++)
			all.insert(s.substr(i,l));
	return sz(all);
}
 
int getMin(int len, string cur) {
	while (sz(cur)!=len)
		cur+="a";
	return get(cur);
}
 
int getMax(int len, string cur) {
	char ch='z';
	while (sz(cur)!=len) {
		cur+=ch;
		ch--;
	}
	return get(cur);
}
 
string solve(int len, string cur) {
	if (sz(cur)==len) {
		if (get(cur)==n) return cur;
		return "";
	}
	if (getMin(len,cur)>n) return "";
	if (getMax(len,cur)<n) return "";
	for (char ch='a'; ch<='z'; ch++) {
		string tmp=cur+ch;
		string next=solve(len,tmp);
		if (next!="") return next;
	}
	return "";
}
signed main(){
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	cin>>n;
	for (int len=1; len<=26; len++) {
		string res=solve(len,"");
		if (res!="") {
			cout<<res;
			return 0;
		}
	}
}, In this Programming Language: C++, Now tell me if this Code is compilable or not?