Problem:


Score : 400 points

Problem Statement

In this problem, we only consider strings consisting of lowercase English letters.

Strings s and t are said to be isomorphic when the following conditions are satisfied:

|s| = |t| holds.

For every pair i, j, one of the following holds:

s_i = s_j and t_i = t_j.

s_i \neq s_j and t_i \neq t_j.

For example, abcac and zyxzx are isomorphic, while abcac and ppppp are not.

A string s is said to be in normal form when the following condition is satisfied:

For every string t that is isomorphic to s, s \leq t holds. Here \leq denotes lexicographic comparison.

For example, abcac is in normal form, but zyxzx is not since it is isomorphic to abcac, which is lexicographically smaller than zyxzx.

You are given an integer N.
Print all strings of length N that are in normal form, in lexicographically ascending order.

Constraints

1 \leq N \leq 10

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N

Output

Assume that there are K strings of length N that are in normal form: w_1, \ldots, w_K in lexicographical order.
Output should be in the following format:

w_1
:
w_K

Sample Input 1

1

Sample Output 1

a

Sample Input 2

2

Sample Output 2

aa
ab



Sample input:
1


Sample output:
a

Submission status: Runtime Error

Solution code:
import itertools

n = input()
n = int(n)

num = [i for i in range(n)]
pairs = [i for i in itertools.combinations(num, 2)]

hoge = len(pairs) + 1
for i in range(1, hoge):
    comb = itertools.combinations(pairs, i)

    dup_check = set()
    for c in comb:
        c_list = list(c)
        dup_check.clear()
        for pair in c_list:
            dup_check.add(pair[0])
            dup_check.add(pair[1])

        if len(dup_check) != len(c_list)*2:
            continue

        ret:str = [''] * n
        chr_i = 97
        for i in range(n):
            if ret[i] is not '':
                continue

            used = False
            for pair in c_list:
                if pair[0] == i:
                    ret[i] = chr(chr_i)
                    ret[pair[1]] = chr(chr_i)
                    used = True
                    chr_i += 1
                    break
            if used:
                c_list.remove(pair)
            else:
                ret[i] = chr(chr_i)
                chr_i += 1

        retstr = ""
        for c in ret:
            retstr += c
        print(retstr)


retstr = ""
chr_i = 97
for i in range(n):
    retstr += chr(chr_i)
    chr_i += 1
print(retstr)

Submission status: Runtime Error

Solution code:
k=["a","b","c","d","e","f","g","h","i","j"]
n=int(input())
list=[]
yl=[]
for i in range(n):
    list.append(k[i])
    yl.append(k[i])
    for j in range(n):
        list[i]=yl[i]+k[j]
xlist=list
for l in range(len(list)-1):
    xl=[str(c) for c in xlist[l]]

    if xl.count("a")==0:
        list.remove(list[l])
    for o in range(n-l):
        if xl.count(k[l])==0 and xl.count(k[l+o-1])!=1:
            list.remove(list[l])
list.sort()
for i in list:
    print(i)

Submission status: Runtime Error

Solution code:
N=int(input())
alp="abcdefghij"
S=[""for i in range(N)]

def gen(cnt,rem):
    if rem==0:
        print("".join(S))
    else:
        for i in range(max(N,cnt+2)):
            S[N-rem]=alp[i]
            gen(i,rem-1)            

S[0]="a"
gen(0,N-1)

Submission status: Runtime Error

Solution code:
A = ["a","b","c","d","e","f","g","h","i","j"]
n = int(input())
l = ["a"]

def L(n):
  if n == 1:
    return l
  else:
    m = len(L(n-1))
    N = []
    for i in range(m):
      M = []
      k = len(set(L(n-1)[i]))
      for j in range(k+1):
        M = M.append(L(n-1)[i]+A[j]) 
      N += M
    return N

for _ in range(len(L(n))):
  print(L(n)[_])

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10000)

strings=["a","b","c","d","e","f","g","h","i","j"]

N=int(input())
def f(x):
    for i in x:
        print(strings[i],end="")
    if x[-1]==N-1:
        return ""
    print("")
    if x[-1]-1==x[-2]:
        x[-1]+=1
        return f(g(x,N-1))
    else:
        x[-1]+=1
        return f(x)


def g(x,level):
    if x[level]-1<=x[level-1]:
        return x
    x[level]=0
    x[level-1]+=1
    level-=1
    return g(x,level)

a=[]
for i in range(N):
    a.append(0)
f(a)

Submission status: Runtime Error

Solution code:
n = int(input())
w = [0]*n
t = [w]*n
for i in range(0, n):
  
  for j in range(0, n):
    if t[i][j] == 0:

Submission status: Runtime Error

Solution code:
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define zeros(arr) memset(arr,0,sizeof(arr))
#define precise(num)  cout<<fixed; cout << std::setprecision(num)
int32_t main(){
    
    ios_base::sync_with_stdio(cin.tie(NULL));
    cout.tie(NULL);
    
    int tc = 1;
    // cin>>tc;
    while(tc -- ){
        
        vector< string >v;
        
        string p = "a";
        v.pb(p);
        int n;
        cin>>n;
        
        int curr = 'a';
        
        // vector< char >pos;
        // pos.pb(curr);
        vector< string>final;
        for(int i = 1 ;i < n ; i++ ){
            
            int sz =v.size(); 
            curr++;
            // pos.pb(curr);
            for(int j = 0; j < sz; j++ )
            {
                    vector< char > pos;
                    map<char,int>cn;
                    char p = 'a';
                    for(int k = 0; k < v[j].size() ; k ++ )
                        {
                            cn[v[j][k]]++;
                            p = max(p , v[j][k]);
                            if(cn[v[j][k]]==1)
                            pos.pb(v[j][k]);
                        }
                        pos.pb(p+1);
                    
                    for(int k = 0 ; k <pos.size() ; k++)
                        {
                            string  res = v[j] + pos[k];
                            
                            
                            v.pb(res);
                        
                            // if(i == n-1)
                            //     final.pb(res);
                        }
                        
            }
            
        }
        unordered_map<string , int > cn;
        for(int i = 0; i < v.size() ; i++ )
        {
            cn[v[i]]++;
            if(v[i].size() == n && cn[v[i]] == 1)
                final.pb(v[i]);
        }
        
        
        sort(all(final));
        
        for(int i =0 ; i< final.size() ; i ++ ){
            cout<<final[i]<<endl;
        }
        // if( n == 1)cout<<'a'<<endl;
        
        
    }
    
}

Submission status: Runtime Error

Solution code:
n = int(input())
ans = [[] for _ in range(2**(n-1))]

ans[0].append([1])
ans[1].append([1,1])
ans[1].append([1,2])
#ans[2].append([1,1,1])
#ans[2].append([1,1,2])
#ans[2].append([1,2,2])
#ans[2].append([1,2,3])
import numpy as np

for i in range(2, n):
    for j in range(2):
        for ai in ans[i-1]:
            x = np.array(ai)
            y = list(x+j)
            ans[i].append([1] + y)

r = ['a','b','c','d','e','f','g','h','i','j','k']
for ai in ans[n-1]:
    print(''.join(map(lambda x: str(r[x-1]), ai)))

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
char alpha[11];
int n;
void output(int n){

}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> n;
    rep(i,0,n) alpha[i] = 'a' + i;
    int ans[n+1]={};
    ans[n] = -1;
    bool end=true;
    while(end){
        rel(i,n,0) cout << alpha[ans[i]];
        cout << endl;
        int mov=0;
        while(true){
            if(ans[mov+1]>=ans[mov]){ ans[mov]++; break;}
            else{
                rep(i,0,mov) ans[i] = 1;
                mov++;
                if(mov==n){ end = false; break;}
            }
        }
    }
}

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(2000)

strings=["a","b","c","d","e","f","g","h","i","j"]

N=int(input())
def f(x):
    for i in x:
        print(strings[i],end="")
    if x[-1]==N-1:
        return ""
    print("")
    if x[-1]-1==x[-2]:
        x[-1]+=1
        return f(g(x,N-1))
    else:
        x[-1]+=1
        return f(x)


def g(x,level):
    if x[level]-1<=x[level-1]:
        return x
    x[level]=0
    x[level-1]+=1
    level-=1
    return g(x,level)

a=[]
for i in range(N):
    a.append(0)
f(a)

Submission status: Runtime Error

Solution code:
mport sys
sys.setrecursionlimit(10 ** 7)
from functools import lru_cache

n = int(input())
ans = []

if n == 1:
    print('a')
    exit()

@lru_cache(None)
def rec(before, depth, MAX):
    for i in range(MAX-ord('a') +2):
        tmp = before + chr(ord('a') + i)
        if len(tmp) >= n:
            ans.append(tmp)
        else:
            MAX = max(MAX, ord(tmp[-1]) )
            rec(tmp, depth+1, MAX)


rec('a',1, ord('a'))

ans.sort()

print(*ans, sep ='\n')

Submission status: Runtime Error

Solution code:
N = int(input())

def func(n):
  if n <= 1:
    return ["a"]
  S = []
  for i in func[n - 1]:
    S.append("a" + i)
    
    for j in range(len(i)):
      if i[j] == "a":
        i[j] = "b"
      elif i[j] == "b":
        i[j] = "a"
    
    S.append("a" + i)
    
  return S
 
Ans = .sort(func(N))

for i in Ans:
  print(i)

Submission status: Runtime Error

Solution code:
import itertools

bells = [[], [[0]]] + [None for i in range(9)]
bell_n = [1, 1, 2, 5, 15, 52, 203, 877, 4140, 21147, 115975]

def search(n):
    ret = []
    ret.append( [ 0 for _ in range(n) ] )
    for k in range(1,n):
        for bi in bells[k]:
            for ids in itertools.combinations(range(1,n), k):
                st = [0 for _ in range(n)]
                for i, id in enumerate(ids):
                    st[id] = bi[i] + 1
                ret.append(st)
    return ret

for i in range(2, 10):
    bells[i] = search(i)
    assert bell_n[i] == len(bells[i])

N = int(input())
table = "abcdefghij"
outs = []
for bi in bells[N]:
    out = ""
    for b in bi:
        out += table[b]
    outs.append(out)

print("\n".join(sorted(outs)))

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
typedef long long int ll;
typedef long double ld;
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; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}
ll n;
void solve(char a,ll k,ll c,string s){
    if (k==n-1){
        cout << s << endl;
    }else{
        s+=a;
        if (c>a-'a'){
            for (ll i=0;i<=c;i++){
                s[k+1]='a'+i;
                solve('a'+i,k+1,c,s);
            }
        }else{
            for (ll i=0;i<=c+1;i++){
                s[k+1]='a'+i;
                solve('a'+i,k+1,c+1,s);
            }
        }
    }
}

int main(){
    cin >> n;
    string s;
    s='a';
    solve('a',0,1,s);
    return 0;
}

Submission status: Runtime Error

Solution code:
= int(input())
alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
def norm(n, prev_list):
	out_list = []
	for line in prev_list:
		for i in range(len(set(line))+1):
			new_line = line + az[i]
			out_list.append(new_line)
	return out_list
init_line = ['a']
for _ in range(N-1):
	init_line = norm(1, init_line)
for line in init_line:
	print(line)

Submission status: Runtime Error

Solution code:
N = int(input())
az = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
def norm(n, in_list):
	out_list = []
	for line in in_list:
		for i in range(len(set(line))+1):
			new_line = line + alphabet[i]
			out_list.append(new_line)
	return out_list
init_line = ['a']
for _ in range(N-1):
	init_line = norm(1, init_line)
for line in init_line:
	print(line)

Submission status: Runtime Error

Solution code:
N=int(input())
def hyoujyun(n):
	if n==1:
    	A=[1]
    	return A
    else:
    	A=[hyoujyun(n-1)+[i] for i in range(n)]
		return A
A=hyoujyun[N]
if N==1:
	print("a")
else:
	for i in range(len(A)):
		Ans=[]
		for j in range(len(A[i])):
			if A[i][j]==1:
				Ans.append(a)
			if A[i][j]==2:
				Ans.append(b)
			if A[i][j]==3:
				Ans.append(c)
			if A[i][j]==4:
				Ans.append(d)
			if A[i][j]==5:
				Ans.append(e)
			if A[i][j]==6:
				Ans.append(f)
			if A[i][j]==7:
				Ans.append(g)
			if A[i][j]==8:
				Ans.append(h)
			if A[i][j]==9:
				Ans.append(i)
			if A[i][j]==10:
				Ans.append(j)
		print Ans

Submission status: Runtime Error

Solution code:
strings=["a","b","c","d","e","f","g","h","i","j"]


N=int(input())
def f(x):
    for i in x:
        print(strings[i],end="")
    if x[-1]==N-1:
        return ""
    print("")
    if x[-1]-1==x[-2]:
        x[-1]+=1
        return f(g(x,N-1))
    else:
        x[-1]+=1
        return f(x)


def g(x,level):
    if x[level]-1<=x[level-1]:
        return x
    x[level]=0
    x[level-1]+=1
    level-=1
    return g(x,level)

a=[]
for i in range(N):
    a.append(0)
f(a)

Submission status: Runtime Error

Solution code:
import sys
import numpy as np
readline = sys.stdin.buffer.readline

a,b,c = map(int,readline().split())
array = np.array([a,b,c],dtype="float64")
if np.sqrt(a)+np.sqrt(b) < np.sqrt(c):
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
N = int(input())

dic = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]

old = ["a"]
new = []
for i in range(1, N):
    print(old)
    for word in old:
        for j in range(i+1):
            if word[-1] == dic[j] or word[-1] == dic[j-1]:
                new.append(word+dic[j])
    old = new.copy()
    new = []
for i in old:
    print(i)

Submission status: Runtime Error

Solution code:
N = int(input())
A = {
    1: ["a"],
    2: ["aa", "ab"],
    3: ["aaa", "aab", "aba", "abb", "abc"],
    4: [
        "aaaa",
        "aaab",
        "aabb",
        "aabc",
        "abaa",
        "abab",
        "abac",
        "abba",
        "abbb",
        "abbc",
        "abca",
        "abcb",
        "abcc",
        "abcd",
    ],
    5: [
        "aaaaa",
        "aaaab",
        "aaaba",
        "aaabb",
        "aaabc",
        "aabba",
        "aabbb",
        "aabbc",
        "aabca",
        "aabcb",
        "aabcc",
        "aabcd",
        "abaaa",
        "abaab",
        "abaac",
        "ababa",
        "ababb",
        "ababc",
        "abaca",
        "abacb",
        "abacc",
        "abacd",
        "abbaa",
        "abbab",
        "abbac",
        "abbba",
        "abbbb",
        "abbbc",
        "abbca",
        "abbcb",
        "abbcc",
        "abbcd",
        "abcaa",
        "abcab",
        "abcac",
        "abcad",
        "abcba",
        "abcbb",
        "abcbc",
        "abcbd",
        "abcca",
        "abccb",
        "abccc",
        "abccd",
        "abcda",
        "abcdb",
        "abcdc",
        "abcdd",
        "abcde",
    ],
}
Ans = A[N]
for i in range(len(Ans)):
    print(Ans[i])

Submission status: Runtime Error

Solution code:
N = int(input())
alp = ["b","c","d","e","f","g","h","i","j","a"]
a = "a"
A = "a"
for i in range(N):
    word = [a]
    a = a + "a"
for i in range(N):
    word = [A]
    A = A + alp.pop(0)
word.pop(N)
s = "\n".join(word)
print(s)

Submission status: Runtime Error

Solution code:
base = input().split()
a = int(base[0])
b = int(base[1])
c = int(base[2])
import math
key = math.sqrt(a*b)
ans = a**4+a**2*b**4+6*a**3*b+4*a**3*key+4*a**2*b*key+a**2*b**2+b**4+6*a*b**3+4*a*b**2*key+4*b**3*key+6*a**3*b+6*a*b**3+24*a**2*b*key+24*a*b**2*key+36*a**2*b**2+4*a**3*key+4*a*b**2*key+24*a**2*b*key+16*a**3*b+16*a*b**3+4*a**2*b*key+4*b**3*key+24*a*b**2*key+16*a**3*b+16*a*b**3
if ans<c**4:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
from typing import List


def diff_one(l: List[str]) -> bool:
    prev = l[0]

    for i in range(1, len(l)):
        if abs(ord(l[i]) - ord(prev)) >= 2:
            return False
        prev = l[i]

    return True


def comb(current: List[str], rest: List[str], target: int):
    if len(current) == target:
        yield current
    elif len(current) < target and len(rest) > 0:
        for i in range(len(current) + 1):
            yield from comb(current + [rest[i]], rest, target)


if __name__ == '__main__':
    n = int(input())
    alphabet = [str(chr(i)) for i in range(97, 97 + 26)]

    for perm in comb([], alphabet[:n], n):
        if diff_one(perm):
            print("".join(perm))

Submission status: Runtime Error

Solution code:
from typing import List


def diff_one(l: List[str]) -> bool:
    prev = l[0]

    for i in range(1, len(l)):
        if abs(ord(l[i]) - ord(prev)) >= 2:
            return False
        prev = l[i]

    return True


def comb(current: List[str], rest: List[str], target: int):
    if len(current) == target:
        yield current
    elif len(current) < target and len(rest) > 0:
        for i in range(len(current) + 1):
            yield from comb(current + [rest[i]], rest, target)


if __name__ == '__main__':
    n = int(input())
    alphabet = [str(chr(i)) for i in range(97, 97 + 26)]

    for perm in comb([], alphabet[:n], n):
        if diff_one(perm):
            print(perm)

Submission status: Runtime Error

Solution code:
from itertools import product, combinations_with_replacement
N=int(input())
s="abcdefghij"

def get_gen(a, N):
  for c in s[:s.index(max(a))+2]:
    t = a+c
    if len(t) == N:
      print(t)
    else:
      get_gen(t,N)
get_gen("a", N)

Submission status: Runtime Error

Solution code:
def main():
    import sys
    input = sys.stdin.readline

    a,b,c = map(int,input().split())
    if (a**(1/2)) + (b**(1/2)) < (c**(1/2)):
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
n = int(input())

az = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

def norm(n, in_list):
	out_list = []
	for l in in_list:
		for i in range(len(set(l))+1):
			new_l = l + az[i]
      		out_list.append(new_l)
	return out_list

line = ["a"]

for _ in range(n-1):
	line = norm(1,line)
  
for l in line:
	print(l)

Submission status: Runtime Error

Solution code:
N = int(input())

result_list = [
    ["a"],
    ["aa", "ab"],
    ["aaa", "aab", "aba", "abb", "abc"]
]

for s in result_list[N - 1]:
    print(s)

Submission status: Runtime Error

Solution code:
# coding: utf-8

import math

# 標準入力 <int><int>
a, b, c = map(float, input().split())

ans = "No"

if math.sqrt(a) + math.sqrt(b) - math.sqrt(c) < 0:
    ans = "Yes"

print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())

az = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

def norm(n, in_list):
	out_list = []
	for l in in_list:
		for i in range(len(set(l))+1):
			new_l = l + az[i]
      		out_list.append(new_l)
	return out_list

line = ["a"]

for _ in range(n-1):
  line = norm(1,line)
  
for l in line:
  print(l)

Submission status: Runtime Error

Solution code:
n = int(input())

az = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

def norm(n, in_list):
	out_list = []
	for l in in_list:
		for i in range(len(set(l))+1):
			new_l = l + az[i]
      		out_list.append(new_l)
	return out_list

line = ["a"]

for _ in range(N-1):
  line = norm(1,line)
  
for l in line:
  print(l)

Submission status: Runtime Error

Solution code:
import itertools
n = int(input())

lis = ["a","b","c","d","e",
		"f","g","h","i","j"]

l = lis[:n]
#print(l)
cand = list(itertools.product(l, repeat=n))

already = [[-1 for _ in range(n)]for _ in range(len(cand))]


count = 0
for i in range(len(cand)):#何セットあるか
	temp = []
	temp.append(cand[i][0])
	cand[i] = list(cand[i])
	cand[i][0] = l[len(temp)-1]

	for j in range(1,n):#要素の数n
		for k in range(len(temp)):
			if cand[i][j] == temp[k]:#tempに入ってたら
				cand[i][j] = l[k]
			else:#未知なら
				temp.append(cand[i][j])
				cand[i][j] = l[len(temp)-1]
def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]

				
ans = get_unique_list(cand)
for i in range(len(ans)):
	p = ""
	for j in range(n):
		p += ans[i][j]
	print(p)

Submission status: Runtime Error

Solution code:
n = int(input())
import sys

a = 'abcdefghij'
s = 'a'
count = 0

if n == 1:
  print('a')
  sys.exit()

for i in range(2):
  s.append(a[i])
  if i == 0:
    count += 1
  if count == n - 1:
    print(s)
    break
  for j in range(i + 1):
    s.append(a[i])
    if i == 0:
      count += 1
    if count == n - 1:
      print(s)
      break
    for k in range(j + 1):
      s.append(a[i])
      if i == 0:
        count += 1
      if count == n - 1:
        print(s)
        break
      for l in range(k + 1):
        s.append(a[i])
        if i == 0:
          count += 1
        if count == n - 1:
          print(s)
          break
        for m in range(l + 1):
          s.append(a[i])
          if i == 0:
            count += 1
          if count == n - 1:
            print(s)
            break
          for o in range(m + 1):
            s.append(a[i])
            if i == 0:
              count += 1
            if count == n - 1:
              print(s)
              break
            for p in range(o + 1):
              s.append(a[i])
              if i == 0:
                count += 1
              if count == n - 1:
                print(s)
                break
              for q in range(p + 1):
                s.append(a[i])
                if i == 0:
                  count += 1
                if count == n - 1:
                  print(s)
                  break

Submission status: Runtime Error

Solution code:
import copy

ab = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']

n = int(input())

# 最初はaで確定

value = ['a']
for i in range(10):
    if len(value[0]) == n:
        break
    tmp_value = copy.copy(value)
    value = []
    for v in tmp_value:
        for j in range(n):
            value.append(v + ab[j])
            if ab[j] not in v:
                break
    for v in value:
    print(v)

Submission status: Runtime Error

Solution code:
n = int(input())

az = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

def norm(n, in_list):
	out_list = []
	for l in in_list:
		for i in range(len(set(l))+1):
			new = l + az[i]
      		out_list.append(new)
	return out_list

line = ["a"]

for _ in range(N-1):
  line = norm(1,line)
  
for l in line:
  print(l)

Submission status: Runtime Error

Solution code:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int N;
    cin >> N;
    string alphabet = "bcdefghij";

    for (int i = 0; i < N; i++)
    {
        string ans = "";
        for (int j = 0; j < (N - i); j++)
        {
            ans += 'a';
        }

        ans += alphabet.substr(0, i);
        cout << ans << endl;
    }
}

Submission status: Runtime Error

Solution code:
n = int(input())
import sys

a = 'abcdefghij'
s = 'a'
count = 0

if n == 1:
  print('a')
  sys.exit()

for i in range(2):
  s.append(a[i])
  if i == 0:
    count += 1
  if count == n - 1:
    break
  for j in range(i + 1):
    s.append(a[i])
    if i == 0:
      count += 1
    if count == n - 1:
      break
    for k in range(j + 1):
      s.append(a[i])
      if i == 0:
        count += 1
      if count == n - 1:
        break
      for l in range(k + 1):
        s.append(a[i])
        if i == 0:
          count += 1
        if count == n - 1:
          break
        for m in range(l + 1):
          s.append(a[i])
          if i == 0:
            count += 1
          if count == n - 1:
            break
          for o in range(m + 1):
            s.append(a[i])
            if i == 0:
              count += 1
            if count == n - 1:
              break
            for p in range(o + 1):
              s.append(a[i])
              if i == 0:
                count += 1
              if count == n - 1:
                break
              for q in range(p + 1):
                s.append(a[i])
                if i == 0:
                  count += 1
                if count == n - 1:
                  break
print(s)

Submission status: Runtime Error

Solution code:
num = int(input())
word = "a" * num
for i in range(2):
  print(word)
  word[num - 1] = "b"

Submission status: Runtime Error

Solution code:
num = int(input())
word = "a" * num
for i in range(num):
  print(num)
  word[num - 1] = "b"

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;

set<string> S;
string ans;
int n;

void solve()
{
	if(ans.size() == n)
	{
		S.insert(ans);
		return;
	}
	ans.push_back(ans.back());
	solve();
	ans.pop_back();
	
	ans.push_back(ans.back() - 1);
	if(ans.back() >= 'a') solve();
	ans.pop_back();
	
	ans.push_back(ans.back() + 1);
	if(ans.back() <= 'z') solve();
	ans.pop_back();
}

int main ()
{
	cin >> n;
	ans = "a";
	solve();
	
	for(auto s : S)
		cout << s << '\n';	

	return 0;
}

Submission status: Runtime Error

Solution code:
N = int(input())
alp = ["a","b","c","d","e","f","g","h","i","j"]]
a = "a"
A = "a"
for i in range(N):
    word = [a]
    a = a + "a"
for i in range(N):
    word = [A]
    A = A + alp.pop(0)
newword = sorted(word)
s = "\n".join(newword)
print(s)

Submission status: Runtime Error

Solution code:
N = int(input())
alp = ["a","b","c","d","e","f","g","h","i","j"]]
a = "a"
A = ""
for i in range(N):
    word = [a]
    a = a + "a"
for i in range(N):
    A = A + alp.pop(0)
    word = [A]
newword = sorted(word)
s = "\n".join(newword)
print(s)

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;

#define endl "\n"
#define INF (int) 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define deb(x) cerr << #x << " => " << x << "\n"
#define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n";
#define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)

int fastpow(int a, int b, int m) {
    int res = 1; a %= m; while (b > 0) {
        if (b & 1) res = (res * a) % m;
        a = (a * a) % m; b >>= 1;
    } return res;
}

int now() {
    return chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now()
    .time_since_epoch()).count();
}

void populate(int index, string s, int n, vector<string> &res) {
    if (index == n + 1) {
        res.push_back(s);
        return;
    }
    for (int i = 0; i <= (s[index - 2] - 'a' + 1); i++) {
        s.push_back('a' + i);
        populate(index + 1, s, n, res);
        s.pop_back();
    }
}

int32_t main() { fastio;
    time_t start = now();

    int n;
    vector<string> res;

    cin >> n;
    populate(2, "a", n, res);
    sort(res.begin(), res.end());
    for (auto r : res) {
        cout << r << endl;
    }

    cerr << "TIME => " << now() - start << endl;
    return 0;
}

Submission status: Runtime Error

Solution code:
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N = int(input())
print(int(2 ** cmb(N, 2)))

Submission status: Runtime Error

Solution code:
import math

a,b,c=map(int,input().split())

if  math.sqrt(a).as_integer_ratio() + math.sqrt(b).as_integer_ratio() < math.sqrt(c).as_integer_ratio():
    print("Yes")
else :
    print("No")

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;

#define endl "\n"
#define INF (int) 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define deb(x) cerr << #x << " => " << x << "\n"
#define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n";
#define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)

int fastpow(int a, int b, int m) {
    int res = 1; a %= m; while (b > 0) {
        if (b & 1) res = (res * a) % m;
        a = (a * a) % m; b >>= 1;
    } return res;
}

int now() {
    return chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now()
    .time_since_epoch()).count();
}

int n;
vector<string> res;

void populate(int index, string s) {
    if (index == n + 1) {
        res.push_back(s);
        return;
    }
    for (int i = 0; i <= (s[index - 2] - 'a' + 1); i++) {
        s.push_back('a' + i);
        populate(index + 1, s);
        s.pop_back();
    }
}

int32_t main() { fastio;
    time_t start = now();

    cin >> n;
    populate(2, "a");
    sort(res.begin(), res.end());
    for (auto r : res) {
        cout << r << endl;
    }

    cerr << "TIME => " << now() - start << endl;
    return 0;
}

Submission status: Runtime Error

Solution code:
from collections import deque

N = int(input())

queue = deque()
queue.append((0,)
while queue:
    s = queue.popleft()
    if len(s) == N:
        print(''.join('abcdefghij'[i] for i in s))
        continue
    for i in range(max(s) + 2):
        queue.append(s + (i,))

Submission status: Runtime Error

Solution code:
from collections import deque
N = int(input())
alpha = ['a','b','c','d','e','f','g','h','i','j']
ans = []

stack = deque(['a'])

while stack:
    print(stack)
    if len(stack[-1]) == N:
        break
    s = stack.pop()
    s_list = list(s)
    index = alpha.index(s_list[-1])
    print(index)
    for i in range(index+2):
        stack.appendleft(s+alpha[i])
    

stack.reverse()
for j in range(len(stack)):
    print(stack[j])