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: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

def main():
    m='abcdefghijklmnopqrstuvwxyz'
    m=list(m)
    n=int(input())
    ans=[[] for _ in range(n)]
    ans[0].append('0')
    for i in range(1,n):
        for j in ans[i-1]:
            for k in range(i+1):
                if k<=int(j[-1])+1:
                    ans[i].append(j+str(k))
    for i in ans[n-1]:
        s=''
        for j in range(len(i)):
            s+=m[int(i[j])]
        print(s)
        
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import string
import itertools

n = int(input())
num = [i for i in range(11)]
s = string.ascii_lowercase
lis = list(itertools.combinations_with_replacement(num[0:n-1], n-1))

if n != 1:
    for li in lis:
        for i in range(n-2):
            if li[i+1] - li[i] >= 2 or li[0] >= 2:
                break
        else:
            print('a', end='')
            for i in range(n-1):
                print(s[li[i]], end='')
            print('')

print(s[:n])

Submission status: Wrong Answer

Solution code:
def main(n):
    if n == 1:
        return ['a']
    else:
        ans = []
        for a in main(n-1):
            b = '`'
            while b <= a[-1]:
                b = chr(ord(b) + 1)
                ans.append(a + str(b))
        return ans
N = int(input())
L = main(N)
for i in L:
    print(i)

Submission status: Wrong Answer

Solution code:
alpha_small_ = [chr(i) for i in range(97, 97+26)] #アルファベッドの小文字

n = int(input())
ans = []
def solve(now,i):
    if len(now) == n:
        ans.append(now)
        return
    for j in range(i+1):
        solve(now+alpha_small_[j],i+1)

solve("a",1)


for x in sorted(ans):
    print(x)

Submission status: Wrong Answer

Solution code:
K = int(input())
S = 'a'*K
arr = [chr(i) for i in range(97, 97+26)]
print(arr)

Submission status: Wrong Answer

Solution code:
n = int(input())
for i in range(n):
    #print("i", i)
    res = [0] * n
    if i != 0:
        res[n-i] += 1
    else:
        resstr = list(map(lambda x: chr(ord("a") + x), res))
        print("".join(resstr))
        continue
    while res[n-i] == 1:
        resstr = list(map(lambda x: chr(ord("a") + x), res))
        print("".join(resstr))
        res[-1] += 1
        for j in range(1, i):
            #print("try", n-j)
            if res[n-j] > (res[n-j-1] + 1):
                res[n-j] = 0
                res[n-j-1] += 1
    continue
    res = list(map(lambda x: chr(ord("a") + x), res))
    print("".join(res))

Submission status: Wrong Answer

Solution code:
import sys
import time
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
N = int(input())

groups = []

def dfs(s, n):
    if n == N:
        bits = [-1] * N
        for i, ss in enumerate(s):
            if bits[i] != -1:
                continue
            for ii in range(i+1, N):
                if s[ii] == ss:
                    bits[ii] = i
        if bits not in groups:
            groups.append(bits)
            print(s)
            return True
        return False
    for ns in 'abcdefghijklmnopqrstuvwxyz':
        if dfs(s+ns, n+1):
            continue
        else:
            return True

dfs('', 0)

Submission status: Wrong Answer

Solution code:
n = int(input())

results = []
if n == 1:
    results = ["a"]
elif n == 2:
    results = ["aa", "ab"]
elif n == 3:
    results = ["aaa", "aab", "abb", "abc"]
elif n == 4:
    results = ["aaaa", "aaab", "aabb", "aabc", "abbb", "abbc", "abcc", "abcd"]

for result in results:
    print(result)

Submission status: Wrong Answer

Solution code:
N = int(input())

alphabets = list('Zabcdefghijklmn')
s = ['a']
ss = []
for i in range(2, N + 1):
    subset = alphabets[1:i + 1]
    for j in range(len(s)):
        for k in subset:
            ss.append(s[j] + k)
    # print('s, ss', s, ss)
    s = ss
    ss = []
for i in s:
    print(i)

Submission status: Wrong Answer

Solution code:
import string
import itertools

alphabets = string.ascii_lowercase

N = int(input())

res = []


def bfs(s, d):
    if d == N - 1:
        res.append(s)
        return

    for i in range(ord(s[-1]) - ord("a") + 2):
        bfs(s + alphabets[i], d + 1)


bfs("a", 0)

res = sorted(res)
print("\n".join(res))
# print(list(bfs("a", 0)))

Submission status: Wrong Answer

Solution code:
from itertools import product
n=int(input())
s='abcdefghijklmnopqrstuvwxyz'
use_s=tuple(s[:n])
#print(use_s,1)
for i in product(use_s, repeat=n):
    ans=i
    if tuple(use_s)<ans:continue
    print(''.join(ans))

Submission status: Wrong Answer

Solution code:
N = int(input())
l = set()

for i in range(N**2):
  pattern = [True] * N
  
  for j in range(N):
    if ((i>>j) & 1):
      pattern[j] = False
   
  o = ord('a')
  t = ''
  for n in range(N):
    if pattern[n]:
      t += 'a'
    else:
      t += chr(o)
      o += 1
      
  l.add(t)
  
l = list(l)  
l.sort()

for ans in l:
  print(ans)

Submission status: Wrong Answer

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

ans = []

for x in range(2, N + 1):
    C = itertools.combinations(range(N), x)
    cnt = ord("a")
    a = [None] * N
    for c in C:
        cnt = ord("a")
        a = [None] * N
        for cc in c:
            a[cc] = chr(cnt)
        cnt += 1
        for i in range(N):
            if a[i] is None:
                a[i] = chr(cnt)
                cnt += 1
        ans.append(a)

cnt = ord("a")
a = [None] * N
for i in range(N):
    a[i] = chr(cnt)
    cnt += 1
ans.append(a)


                
ans = sorted(ans)

for a in ans:
    for i in range(N):
        print(a[i], end="")
    print()

Submission status: Wrong Answer

Solution code:
import itertools
n = int(input())
original_ans = list(map(list, list(itertools.combinations_with_replacement([i for i in range(n)], n))))
ans = []
figures = ["a","b","c","d","e","f","g","h","i","j","k"]
for line in original_ans:
    dic = {}
    flag = 0
    ans_line = ""
    for i in range(n):
        if not line[i] in dic:
            dic[line[i]] = figures[flag]
            flag += 1
            ans_line += dic[line[i]]
        else:
            ans_line += dic[line[i]]
    ans.append(ans_line)

answers = list(set(ans))
for answer in answers:
    print(answer)

Submission status: Wrong Answer

Solution code:
import string
# print(string.ascii_lowercase[:10])
ans = []
N = int(input())

def rec(s):
    if len(s) == N:
        ans.append(s)
        return
    for c in string.ascii_lowercase[:N]:
        rec(s + c)

rec("a")
for x in ans:
    print(x)

Submission status: Wrong Answer

Solution code:
from itertools import combinations_with_replacement as cb

N = int(input())
al = [chr(i) for i in range(97, 97 + 26)]

ans = []
for C in cb(al[:N], N):
    if C[0] != 'a': continue
    cur = 'a'
    flag = True

    for i in range(1, N):
        if ord(cur) >= ord(C[i]): continue
        if ord(cur) + 1 == ord(C[i]):
            cur = C[i]
        else: flag = False
    if flag:
        ans.append(''.join(C))

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

Submission status: Wrong Answer

Solution code:
import itertools
n =int(input())
alp = [chr(i+96) for i in range(1,n+1)]
cmbs = list(itertools.permutations(alp,n))
for cmb in cmbs:
    flg = False
    for i, al in enumerate(alp):
        if al in cmb:
            for a in alp[0:i]:
                if a not in cmb:
                    flg = True
                    break
            if flg:
                break
    if not flg:
        print(''.join(cmb))

Submission status: Wrong Answer

Solution code:
K = int(input())
word_dic = {"a":1,"b":2,"c":3,"d":4,"e":5,"f":6,"g":7,"h":8,"i":9,"j":10}
l_word = ["a","b","c","d","e","f","g","h","i","j"]
L = ["a"]
if K == 1:
  print("a")
else:
  for i in range(K-1):
    M = []
    for x in L:
      k_x = word_dic[x[-1]]
      for j in range(k_x+1):
        M.append(x + l_word[j])
    L = M[:]
  else:
    for x in L:
      print(x)

Submission status: Wrong Answer

Solution code:
N = int(input())

for b in range(2 ** (N-1)):
    print(format(b, 'b').zfill(N).replace('0', 'a').replace('1', 'b'))

Submission status: Wrong Answer

Solution code:
N = int(input())

a = 0
ans = ['a'] * 2**(N - 1)

for n in range(1, N):
    for i in range(2**(N - 1)):
        if i % 2 == 0:
            c = chr(ord(ans[i][-1]) + 1)
            ans[i] += str(c)
        else:
            c = chr(ord(ans[i][-1]))
            ans[i] += str(c)

    ans = sorted(ans)

for a in ans:
    print(a)

Submission status: Wrong Answer

Solution code:
N = int(input())
a= "0" + str(N) + "b"

for i in range(2**(N-1)):
    x = format(i, a)
    print(x.replace('0', 'a').replace('1', 'b'))

Submission status: Wrong Answer

Solution code:
ans =["a"]
n =int(input())
for i in range(1,n):
  plus=[]
  for s in ans:
    num=ord(s[-1])-ord("a")+1
    for j in range(num+1):
      plus.append(s+chr(ord("a")+j))
  ans = plus
ans.sort()
for ss in ans:print(ss)

Submission status: Wrong Answer

Solution code:
N = int(input().rstrip())
zumi = []
for i in range(1, N+1):
    ret = 'a'*i + 'b'*(N-i)
    # print(f'origin: {ret}')
    for j in range(i, N+1):
        # print(f'1: {ret[:j-1]}, 2: {ret[j:]}')
        tmp = ret[:j-1] + 'a' + ret[j:]
        if tmp not in zumi:
            print(tmp)
            zumi.append(tmp)

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
from itertools import product
mod = 10**9 + 7

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))


n = ni()
ans = list()
def f(n, first = "a"):
    for switch in product([0, 1], repeat=n-1):
        a = ord("a")
        #print(switch)
        now = "a"
        s = first
        for i, m in enumerate(switch):
            if m == 0 and now != "a":
                f(n-i, first=s)
                s += now
            elif m==0:
                s += "a"
            else:
                now = chr(ord(now)+1)
                s += now
        ans.append(s)
f(n)
ans.sort()
for a in ans:
    print(a)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
s_lis = ["a"]
s_list = np.array(s_lis)
for i in range(N-1):
    ss = np.array([])
    for s in s_list:
        ss = np.append(ss,s + (s[-1]))
        ss = np.append(ss,s + chr(ord(s[-1])+1))
    s_list = np.copy(ss)
if N == 1 :
    print (s_lis[0])
else :
    for i in ss:
        print(i)

Submission status: Wrong Answer

Solution code:
n = int(input())
words = ['a', 'b', 'c', 'd', 'e', 'f','g','h', 'i', 'j']
ans = []
a0 = ""
for i in range(1,n + 1)[::-1]:
    ai = a0 + words[0] * i
    if len(ai) == n:
        ans.append(ai)
    for j in range(1, n + 1 - i)[::-1]:
        aj = ai + words[1] * j
        if len(aj) == n:
            ans.append(aj)
        for k in range(1, n + 1 - i - j)[::-1]:
            ak = aj + words[2] * k
            if len(ak) == n:
                ans.append(ak)

            for l in range(1, n + 1 - i - j - k)[::-1]:
                al = ak + words[3] * l
                if len(al) == n:
                    ans.append(al)

                for m in range(1, n + 1 - i - j - k - l)[::-1]:
                    am = al + words[4] * m
                    if len(am) == n:
                        ans.append(am)
                    for o in range(1, n + 1 - i - j - k - l - m)[::-1]:
                        ao = am + words[5] * o
                        if len(ao) == n:
                            ans.append(ao)
                        for p in range(1, n + 1 - i - j - k - l - m - o)[::-1]:
                            ap = ao + words[6] * p
                            if len(ap) == n:
                                ans.append(ap)
                            for q in range(1, n + 1 - i - j - k - l - m - o - p)[::-1]:
                                aq = ap + words[7] * q
                                if len(aq) == n:
                                    ans.append(aq)
                                for r in range(1, n + 1 - i - j - k - l - m - o - p - q)[::-1]:
                                    ar = aq + words[8] * r
                                    if len(ar) == n:
                                        ans.append(ar)
                                    for s in range(1, n + 1 - i - j - k - l - m - o - p - q - r)[::-1]:
                                        ass = ar + words[9] * s
                                        if len(ass) == n:
                                            ans.append(ass)


for a in ans:
    print(a)

Submission status: Wrong Answer

Solution code:
n = int(input())
print("a"*n)
c = "a"
if n > 1:
    for i in range(1,n):
        c += chr(ord("a") + (i))
    print(c)

Submission status: Wrong Answer

Solution code:
n = int(input())

def aa(nokori, str, nowID, firstID):
  if nokori == 1:
    print(str+chr(nowID))
    return
  for i in range(nowID - firstID + 2):
    aa(nokori-1, str+chr(nowID), firstID + i, firstID)
 
aa(n, "", 97, 97)

Submission status: Wrong Answer

Solution code:
n = int(input())
#lis = ['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]
ans = []
#for i in range(n):
t = ['a'] * n

ans.append(''.join(t))
for j in range(1,n):
    t = ['a'] * n
    t[j] = 'b'
    ans.append(''.join(t))
ans.sort()
for i in range(len(ans)):
    print(ans[i])

Submission status: Wrong Answer

Solution code:
n = int( input() )

for i in range(n):
  print("a"*(n -i),"b"*i,sep='')

Submission status: Wrong Answer

Solution code:
import math

N = int(input())
ZL = [[] for _ in range(N)]
ZL[0].append([0])
for i in range(1, N):
    for szl in ZL[i - 1]:
        n1 = szl[-1]
        for j in range(n1 + 2):
            ZL[i].append(szl + [j])


def func(i):
    if i == 0:
        return "a"
    if i == 1:
        return "b"
    if i == 2:
        return "c"
    if i == 3:
        return "d"
    if i == 4:
        return "e"
    if i == 5:
        return "f"
    if i == 6:
        return "g"
    if i == 7:
        return "h"
    if i == 8:
        return "i"
    if i == 9:
        return "j"


L = ZL[N - 1]
for sl in L:
    for i in range(N):
        sl[i] = func(sl[i])

for sl in L:
    print("".join(map(str, sl)))

Submission status: Wrong Answer

Solution code:
import copy
N = int(input())

moji = ["a","b","c","d","e","f","g","h","i","j"]
start = ["a"]
ll = [[] for i in range(11)] #0個目は使わない

def syurui(l):
    return len(set(l))

ll[1].append(["a"])

for i in range(2,N+1):
    for j in range(len(ll[i-1])):
        for k in range(syurui(ll[i-1][j])+1):
            tmp = copy.copy(ll[i-1][j])
            ll[i-1][j].append(moji[k])
            ll[i].append(ll[i-1][j])
            ll[i-1][j] = tmp

for i in range(len(ll[N])):
    print(*ll[N][i])

Submission status: Wrong Answer

Solution code:
n=int(input())
tmp=[['1',set({1})]]
for i in range(1,n):
  tmp2=[]
  for s,c in tmp:
    for j in range(len(c)+1):
      tmp2.append([s+str((j+1)%10),c|set({j+1})])
  tmp=tmp2
ans=[]
dic={'1':'a','2':'b','3':'c','4':'d','5':'e','6':'f','7':'g','8':'h','9':'i','0':'k'}
for s,c in tmp:
  ts=''
  for tc in s:
    ts+=dic[tc]
  ans.append(ts)
ans=sorted(ans)
for s in ans:
  print(s)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]
a = []
def h(i, s, t):
	if i == 0:
		a.append(s)
		print(s)
	else:
		for j in range(t+1):
			ns = s+l[j]
			h(i-1, ns, t+1)
h(n, "", 0)

Submission status: Wrong Answer

Solution code:
import sys
import math
import string
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
import bisect

MOD = 10 ** 9 + 7
INF = float('inf')
input = lambda: sys.stdin.readline().strip()
alphabets = string.ascii_lowercase

N = int(input())
ans = [["a", 0]]
for i in range(N - 1):
    ans2 = copy.deepcopy(ans)
    ans = []
    for l in ans2:
        for k in range(min(l[1] + 2, i + 2)):
            ans.append([l[0] + alphabets[k], k + 1])
for i in ans:
    print(i[0])

Submission status: Wrong Answer

Solution code:
n = int(input())
alpha = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]
def doukei(n):
  if n == 1:
    return ["a"]
  k = doukei(n-1)
  ans = []
  for i in range(len(k)):
    key = k[i][-1]
    ans.append(k[i]+"a")
    for j in range(1, 10):
      ans.append(k[i]+alpha[j])
      if key == alpha[j-1]:
        break
  return ans
answer = doukei(n)
for i in range(len(answer)):
  print(answer[i])

Submission status: Wrong Answer

Solution code:
n = int(input())


def dfs(s, d, n):
    if d == n:
        print(s)
        return

    dfs(s + "a", d + 1, n)
    dfs(s + "b", d + 1, n)

    return


dfs("a", 1, n)

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque

class alphabet(): #Trueなら大文字
    def __init__(self, capitalize):
        self.num = dict()
        self.index = dict()
        self.abc = ["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"]
        if capitalize: 
            for i in range(26): self.abc[i] = self.abc[i].upper()
        for i, a in enumerate(self.abc):
            self.num[a] = i
            self.index[str(i)] = a

def solve():
    N = int(input())
    AB = alphabet(False)
    Ans = []
    q = deque()
    q.append(("0", 1))
    while q:
        current, length = q.popleft()
        if length == N:
            ans = ""
            for i in range(N): ans += AB.index[current[i]]
            print(ans)
        else:
            border = int(current[length - 1])
            for j in range(border + 2):
                q.append((current + str(j), length + 1))
    #Ans.sort()
    #for a in Ans: print(a)
    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
N=int(input())
ans="a"*N
re_ans=""
S=""
L=["b","c","d","e","f","g","h","i","j","k"]
for i in range(N):
    re_ans+=ans
    S+=L[i]
    ans="\n"+"a"*(N-i-1)+S

    
print(re_ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
a = int(input())

l = 1
cur_ret = [[0]]
while l < a:
    new_ret = []
    na = new_ret.append
    for i in cur_ret:
        for j in range(i[-1]+2):
            na(i+[j])
    cur_ret = new_ret
    l+=1

def format(x):
    x = list(map(lambda x : chr(x+97),x))
    return "".join(x)

cur_ret = list(map(format,cur_ret))
cur_ret.sort()
for i in cur_ret:
    print(i)

Submission status: Wrong Answer

Solution code:
N = int(input())

if N == 1:
  print('a')
elif N == 2:
  print('aa')
  print('ab')
elif N == 3:
  print('aaa')
  print('aab')
  print('abb')
  print('abc')

Submission status: Wrong Answer

Solution code:
def search(s):
    global ans_li
    if len(s) > max_length:
        ans_li.append(s)
    else:
        temp = s+"a"
        search(temp)
        temp = s+"b"
        search(temp)

global ans_li
ans_li = []
n = int(input())
max_length = n-1

search("a")
ans_li.sort()
for i in ans_li:
    print(i)

Submission status: Wrong Answer

Solution code:
N=int(input())
S="a"*N
print(S)
Z=[]
for i in range(1,N):
	Z.append("a"*i+"b"+"a"*(N-1-i))
for i in sorted(Z):
	print(i)

Submission status: Wrong Answer

Solution code:
import itertools
n = int(input())
l = [i for i in range(1, n+1)]
alpha_dict = {}
for i,c in enumerate(range(ord('A'),ord('Z')+1)):
  alpha_dict[i+1] = chr(c)

ans = set()
for v in itertools.combinations_with_replacement(l, n):
  m = min(v)
  diff = m - 1 
  tmp = ""
  num = m-diff 
  dic = {i:0 for i in range(1, 11)}
  used = []
  dic[m] = 1
  used += [m]
  for n in v:
    if dic[n] != 1:
      dic[n] = 1
      used += [n]
      num = len(used)
    tmp += str(alpha_dict[num].lower()) 
  ans.add(tmp)

ans = sorted(list(ans))
for v in ans:
  print(v)

Submission status: Wrong Answer

Solution code:
import string
import itertools

alphabets = string.ascii_lowercase

N = int(input())


def bfs(s, d):
    if d == N - 1:
        print(s)
        return s

    res = []
    for i in range(ord(s[-1]) - ord("a") + 2):
        res.append(bfs(s + alphabets[i], d + 1))
    # return res


bfs("a", 0)
# print(list(bfs("a", 0)))

Submission status: Wrong Answer

Solution code:
import itertools
n =int(input())
alp = [chr(i+96) for i in range(1,n+1)]
cmbs = list(itertools.combinations_with_replacement(alp,n))
for cmb in cmbs:
    flg = False
    for i, al in enumerate(alp):
        if al in cmb:
            for a in alp[0:i]:
                if a not in cmb:
                    flg = True
                    break
            if flg:
                break
    if not flg:
        print(''.join(cmb))

Submission status: Wrong Answer

Solution code:
N = int(input())

pre = ["a"]
for n in range(N - 1):
    nex = []
    for v in pre:
        for i in range(ord("a"), ord(v[-1]) + 2):
            nex.append(v + chr(i))
    pre = nex[:]
        
print(*sorted(pre), sep="\n")

Submission status: Wrong Answer

Solution code:
s=['a']*10
n=int(input())
for i in range(2**(n-1)):
    print(''.join(s[-n:]))
    for j in range(n):
        if s[-j-1]=='a':
            s[-j-1]='b'
            break
        else:
            s[-j-1]='a'

Submission status: Wrong Answer

Solution code:
abc = 'abcdefghij'
n = int(input())
for bits in range(2 ** (n - 1)):
    cur_height = 1
    heights = []
    isfree = []
    for _ in range(n - 1):
        if bits % 2 == 1:
            cur_height += 1
            heights.append(cur_height)
            isfree.append(False)
        else:
            heights.append(cur_height)
            isfree.append(True)
        bits //= 2
    results = [[0]]
    for i in range(n - 1):
        new_results = []
        for result in results:
            if isfree[i]:
                for j in range(heights[i]):
                    new_results.append(result + [j])
            else:
                new_results.append(result + [heights[i] - 1])
        results = new_results
    for result in results:
        abcresult = (abc[i] for i in result)
        print(''.join(abcresult))

Submission status: Wrong Answer

Solution code:
N = int(input())
chrA = ["a", "b"]

def getBin(number):
    ans = list(map(int, bin(number)[2:].zfill(N)))
    strAns = ""
    for i in range(len(ans)):
        strAns += chrA[ans[i]]

    print(strAns)
    return 0

for _ in range(N):
    getBin(_)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
from string import ascii_lowercase

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()

ans = []
def rec(i, S):
    if i == N:
        ans.append(S)
        return
    for j, c in enumerate(ascii_lowercase):
        rec(i+1, S+c)
        if i == j or (i >= 1 and ord(S[-1]) + 1 == ord(c)):
            break
rec(0, '')
[print(s) for s in ans]

Submission status: Wrong Answer

Solution code:
std=[]
n=int(input())
cmb=[[] for i in range(n)]
cmb[0].append("a")
tmp=[[] for i in range(n)]
if n==1:
	print("a")
for i in range(1,n):
	for j in range(len(cmb)):
		for s in cmb[j]:
			for k in range(0,j+1):
				tmp[j].append(s+chr(ord("a")+k))
			tmp[j+1].append(s+chr(ord("a")+k+1))
	cmb=tmp
	tmp=[[] for i in range(n)]
lst=[]
for i in range(len(cmb)):
	for std in cmb[i]:
		lst.append(std)
lst.sort()
for i in range(len(lst)):
	print(lst[i])

Submission status: Wrong Answer

Solution code:
N = int(input())
alpha = 'abcdefghijklmnopqrstuvwxyz'

cnt = 0
for i in range(N):
    ans = ''
    for j in range(N - 1):
        ans += alpha[0]
    ans += alpha[cnt]
    cnt += 1
    print(ans)

Submission status: Wrong Answer

Solution code:
ans =["a"]
n =int(input())
for i in range(1,n):
  plus=[]
  for s in ans:
    if len(s)==i+1:
      num=ord(s[-1])-ord("a")+1
      for j in range(num):
        plus.append(s+char(ord("a")+j))
  ans += plus
ans.sort()
for ss in ans:print(ss)

Submission status: Wrong Answer

Solution code:
ans = []
N = int(input())

def rec(s):
    if len(s) == N:
        ans.append(s)
        return
    rec(s + "a")
    rec(s + "b")


rec("a")
for x in ans:
    print(x)

Submission status: Wrong Answer

Solution code:
from itertools import combinations
N = int(input())

ans = [[] for i in range(2**(N-1))]
for i in range(N): #桁
    one_set = 2**(N-1-i)
    counter = 0
    for _ in range(len(ans)//one_set):
        second = _%2
        for j in range(one_set):
            if not ans[counter]:
                ans[counter].append(0)
            else:
                ans[counter].append(ans[counter][-1]+int(second))
            counter += 1
def repqqq(array):
    alpha = "abcdefghijklmn"
    temp = []
    for a in array:
        temp.append(alpha[a])
    return "".join(temp)
ans = [repqqq(line) for line in sorted(ans)]
for a in ans:
    print(a)

Submission status: Wrong Answer

Solution code:
import string

normal_set = set()
def reccursion(n, _s):
    if len(_s) == n:
        global normal_set
        normal_set.add(_s)
        return

    for i in range(len(_s) + 1):
        next_s = _s + string.ascii_lowercase[i]
        reccursion(n, next_s)

def solve():
    n = int(input())
    reccursion(n, "")

    global normal_set
    normal_set = sorted(list(normal_set))
    
    for _s in normal_set:
        print(_s)

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
from time import time 

n=int(input())
from itertools import combinations as pe
al=[]
for i in range(n):
    for tu in pe(range(n-1),i):
        if tu:
            pre=tu[0]
            ans="a"*(pre+1)
            for d,v in enumerate(tu[1:]):
                ans+=chr(98+d)*(v-pre);pre=v
            ans+=chr(ord(ans[-1])+1)*(n-len(ans))
            al.append(ans)
        else:print("a"*n)
print(*sorted(al),sep="\n")

Submission status: Wrong Answer

Solution code:
n = int(input())

s = [chr(ord('a') + i ) for i in range(n)]
ans = set()
def dfs(i,now):
  if len(now) == n:
    ans.add(now)
    return
  for j in range(min(0,i-1),n):
    dfs(j+1,now + s[j])

dfs(0,s[0])

ans = sorted(list(ans))
for v in ans:
  print(v)

Submission status: Wrong Answer

Solution code:
import sys
import math
#sys.stdin=open("input.in","r")
#sys.stdout=open("output.out","w")
def toString(List): 
    return ''.join(List) 
def allLexicographicRecur (string, data, last, index,n): 
    length = len(string) 
    for i in range(length): 
        data[index] = string[i] 
        if index==last: 
            x=toString(data)
            if(len(x)==n and x[0]=="a"):
                print (x) 
        else: 
            allLexicographicRecur(string, data, last, index+1,n) 
def allLexicographic(string,n): 
    length = len(string) 
    data = [""] * (length+1)  
    string = sorted(string)  
    allLexicographicRecur(string, data, length-1, 0,n) 
st=""
al=["a","b","c","d","e","f","g","h","i","j"]
n=int(input())
for i in range(n):
    st+=al[i]
    allLexicographic(st,n)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)

from string import ascii_lowercase
d = dict(zip(ascii_lowercase, range(26)))
N = int(input())

def nexts(s, n):
    if n == N:
        print(s)
        return
    prenum = d[s[-1]] + 1
    for i in range(prenum+1):
        nexts(s + ascii_lowercase[i], n+1)

nexts('a', 1)

Submission status: Wrong Answer

Solution code:
import sys

input_methods=['clipboard','file','key']
using_method=1
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

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

def mm(sl, i):
	if len(sl)==i:
		print(''.join(sl))
		return
	for j in range(ord(sl[i-1])-ord('a')+2):
		sl[i]=ll[j]
		mm(sl, i+1)

def main():
	n = int(input())
	sl=['a']*n
	mm(sl, 1)
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Wrong Answer

Solution code:
n = int(input())

alp = [chr(v) for v in range(ord("a"), ord("z") + 1)]

results = []
def f(i=0, j=0, s="a"):
    if i == n - 1:
        return results.append(s)
    f(i + 1, j, s + alp[j])
    f(i + 1, j + 1, s + alp[j + 1])
f()
print(*results, sep="\n")

Submission status: Wrong Answer

Solution code:
def inp():
    return input()
def iinp():
    return int(input())
def inps():
    return input().split()
def miinps():
    return map(int,input().split())
def linps():
    return list(input().split())
def lmiinps():
    return list(map(int,input().split()))
def lmiinpsf(n):
    return [list(map(int,input().split()))for _ in range(n)]

n = iinp()
a = ["a","b"]

for i in range(2**(n-1)):
  d = []
  p = len(bin(i))
  q = bin(i)
  for j in range(p-2):
    q = bin(i>>j)
    if int(q[len(q)-1]) == 1:
      d.append(n-j-2)

  print("a",end="")
  for j in range(n-1):
    if j in d:
      print(a[1],end="")
    else:
      print(a[0],end="")
  print("")

Submission status: Wrong Answer

Solution code:
import string

def generate(n, cur = None, alphabet = None):
    if cur is None:
        cur = []
    if alphabet is None:
        alphabet = list(string.ascii_lowercase)[::-1]
    if n == 0:
        print(''.join(cur))
        return
    for i in range(len(cur)):
        cur.append(cur[i])
        generate(n - 1, cur, alphabet)
        cur.pop()
    cur.append(alphabet.pop())
    generate(n - 1, cur, alphabet)
    alphabet.append(cur.pop())

generate(int(input()))